MdeModulePkg/UfsPassThruDxe: Fix v2 protocol backward compatibility

Commit b58ce4c226 broke backward compatibility with v2 platform
protocols by incorrectly skipping HCE re-enable for v2 implementations.

When used with a UfsPlatform.efi binary that was compiled against
an older stable tag, (where EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION
is defined as 2), the code attempted to read the v3-only
SkipHceReenable/SkipLinkStartup fields beyond the v2 struct boundary,
reading garbage memory and potentially skipping initialization.

Add explicit version check to ensure v2 protocols follow normal
initialization path, preventing out-of-bounds struct access.

TEST=build/boot google/yaviks with UFS storage

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
This commit is contained in:
Matt DeVillier 2025-11-02 13:03:23 -06:00 committed by MrChromebox
parent ef437b30ad
commit 6b18142fdb

View file

@ -1866,6 +1866,7 @@ UfsEnableHostController (
}
if ((mUfsHcPlatform == NULL) ||
(mUfsHcPlatform->Version < 3) ||
((mUfsHcPlatform->Version >= 3) && !mUfsHcPlatform->SkipHceReenable))
{
//