From 6b18142fdbbb3c9aded1f65435c25b02b8644c74 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Sun, 2 Nov 2025 13:03:23 -0600 Subject: [PATCH] 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 --- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 6b433f18e9..0cf10bf479 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -1866,6 +1866,7 @@ UfsEnableHostController ( } if ((mUfsHcPlatform == NULL) || + (mUfsHcPlatform->Version < 3) || ((mUfsHcPlatform->Version >= 3) && !mUfsHcPlatform->SkipHceReenable)) { //