From: "Takuto Naito" <naitaku@gmail.com>
To: devel@edk2.groups.io
Cc: Takuto Naito <naitaku@gmail.com>,
Michael D Kinney <michael.d.kinney@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>,
Zhiguang Liu <zhiguang.liu@intel.com>
Subject: [PATCH v1 1/1] Fix AsmReadMsr64() and AsmWriteMsr64() with GCC toolchain
Date: Tue, 13 Apr 2021 00:07:18 +0900 [thread overview]
Message-ID: <20210412150718.71002-2-naitaku@gmail.com> (raw)
In-Reply-To: <20210412150718.71002-1-naitaku@gmail.com>
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>
---
MdePkg/Library/BaseLib/X64/GccInlinePriv.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/MdePkg/Library/BaseLib/X64/GccInlinePriv.c b/MdePkg/Library/BaseLib/X64/GccInlinePriv.c
index e4920f2116..244bd62ee6 100644
--- a/MdePkg/Library/BaseLib/X64/GccInlinePriv.c
+++ b/MdePkg/Library/BaseLib/X64/GccInlinePriv.c
@@ -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"
:
--
2.31.1
next prev parent reply other threads:[~2021-04-12 15:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-12 15:07 [PATCH v1 0/1] Fix AsmReadMsr64() and AsmWriteMsr64() with GCC toolchain Takuto Naito
2021-04-12 15:07 ` Takuto Naito [this message]
2021-04-13 1:16 ` 回复: [edk2-devel] [PATCH v1 1/1] " gaoliming
[not found] ` <167545FDCFB469C8.2444@groups.io>
2021-04-14 1:28 ` gaoliming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210412150718.71002-2-naitaku@gmail.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox