MdePkg: Fix AsmReadMsr64() and AsmWriteMsr64() with GCC toolchain

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3325

1. AsmReadMsr64() in X64/GccInlinePriv.c
AsmReadMsr64 can return uninitialized value if FilterBeforeMsrRead
returns False. This causes build error with the CLANG toolchain.

2. AsmWriteMsr64() in X64/GccInlinePriv.c
In the case that FilterBeforeMsrWrite changes Value and returns True,
The original Value, not the changed Value, is written to the MSR.
This behavior is different from the one of AsmWriteMsr64() in
X64/WriteMsr64.c for the MSFT toolchain.

Signed-off-by: Takuto Naito <naitaku@gmail.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Takuto Naito 2021-04-12 23:07:18 +08:00 committed by mergify[bot]
parent 83876950ab
commit 037090cb7c
1 changed files with 3 additions and 4 deletions

View File

@ -80,7 +80,7 @@ AsmReadMsr64 (
}
FilterAfterMsrRead (Index, &Value);
return (((UINT64)HighData) << 32) | LowData;
return Value;
}
/**
@ -111,11 +111,10 @@ AsmWriteMsr64 (
UINT32 HighData;
BOOLEAN Flag;
LowData = (UINT32)(Value);
HighData = (UINT32)(Value >> 32);
Flag = FilterBeforeMsrWrite (Index, &Value);
if (Flag) {
LowData = (UINT32)(Value);
HighData = (UINT32)(Value >> 32);
__asm__ __volatile__ (
"wrmsr"
: