From 05e57cc9ced67d2cd633c2bdcf70b5e1352bf635 Mon Sep 17 00:00:00 2001 From: Min M Xu Date: Sun, 12 Jun 2022 19:24:34 +0800 Subject: [PATCH] SecurityPkg/HashLibTdx: Return EFI_UNSUPPORTED if it is not Tdx guest HashLibTdx is designed for the Tdx guest. So if is not a Tdx guest, return EFI_UNSUPPORTED in RegisterHashInterfaceLib. Cc: Gerd Hoffmann Cc: Jiewen Yao Cc: Jian J Wang Signed-off-by: Min Xu Reviewed-by: Jiewen Yao --- SecurityPkg/Library/HashLibTdx/HashLibTdx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/SecurityPkg/Library/HashLibTdx/HashLibTdx.c b/SecurityPkg/Library/HashLibTdx/HashLibTdx.c index 75d96ee64b..3cebbc70d3 100644 --- a/SecurityPkg/Library/HashLibTdx/HashLibTdx.c +++ b/SecurityPkg/Library/HashLibTdx/HashLibTdx.c @@ -186,7 +186,13 @@ RegisterHashInterfaceLib ( IN HASH_INTERFACE *HashInterface ) { - ASSERT (TdIsEnabled ()); + // + // HashLibTdx is designed for Tdx guest. So if it is not Tdx guest, + // return EFI_UNSUPPORTED. + // + if (!TdIsEnabled ()) { + return EFI_UNSUPPORTED; + } // // Only SHA384 is allowed.