x86/sev: Fix operator precedence in GHCB_MSR_VMPL_REQ_LEVEL macro
PATCH v2 1/1 x86/sev: Fix operator precedence in GHCB_MSR_VMPL_REQ_LEVEL macro
From: leonardo-leecaprio <[email protected]>
The GHCB_MSR_VMPL_REQ_LEVEL macro lacked parentheses around the bitmask expression, causing the shift operation to bind too early. As a result, when switching to VMPL2 from VMPL1 (e.g., GHCB_MSR_VMPL_REQ_LEVEL(1)), incorrect values such as 0x000000016 were generated instead of the intended 0x100000016.
Fixes the precedence issue by grouping the masked value before applying the shift.
--- arch/x86/include/asm/sev-common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/sev-common.h +1 -1
@@ -116,7 +116,7 @@ enum psc_op {#define GHCB_MSR_VMPL_REQ 0x016 #define GHCB_MSR_VMPL_REQ_LEVEL(v) \ /* GHCBData[39:32] */ \ - (((u64)(v) & GENMASK_ULL(7, 0) << 32) | \ + ((((u64)(v) & GENMASK_ULL(7, 0)) << 32) | \ /* GHCBDdata[11:0] */ \GHCB_MSR_VMPL_REQ )
Signature · 1 line
2.39.5 (Apple Git-154)
Borislav Petkov
maintainerQuoted 1 line · Seongmanlee
From: leonardo-leecaprio <[email protected]>
^^^^^^^^^^^^^
Right, when you fix the name, you need to fix the authorship too:
$ git commit --amend --author="Seongman Lee <[email protected]>"
as this name will appear in the git history.
But no worries, I'll fix it up when applying - just something to think about in the future.
You can also set your name in .git/config or .gitconfig and then it'll be correct automagically.
Quoted 22 lines
The
GHCB_MSR_VMPL_REQ_LEVELmacro lacked parentheses around the bitmask expression, causing the shift operation to bind too early. As a result, when switching to VMPL2 from VMPL1 (e.g.,GHCB_MSR_VMPL_REQ_LEVEL(1)), incorrect values such as0x000000016were generated instead of the intended0x100000016.Fixes the precedence issue by grouping the masked value before applying the shift.
Fixes 34ff65901735 ("x86/sev: Use kernel provided SVSM Calling Areas")Signed-off-by Seongman Lee <[email protected]>--- arch/x86/include/asm/sev-common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/include/asm/sev-common.h +0
-0
arch/x86/include/asm/sev-common.h enum psc_op { · line 122
Quoted 8 lines
arch/x86/include/asm/sev-common.h +1
-1@@ -116,7 +116,7 @@ enum psc_op {#define GHCB_MSR_VMPL_REQ 0x016 #define GHCB_MSR_VMPL_REQ_LEVEL(v) \ /* GHCBData[39:32] */ \ - (((u64)(v) & GENMASK_ULL(7, 0) << 32) | \ + ((((u64)(v) & GENMASK_ULL(7, 0)) << 32) | \ /* GHCBDdata[11:0] */ \GHCB_MSR_VMPL_REQ )
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteThe following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: f7387eff4bad33d12719c66c43541c095556ae4e Gitweb: https://git.kernel.org/tip/f7387eff4bad33d12719c66c43541c095556ae4e Author: Seongman Lee <[email protected]> AuthorDate: Sun, 11 May 2025 18:23:28 +09:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Sun, 11 May 2025 11:38:03 +02:00
x86/sev: Fix operator precedence in GHCB_MSR_VMPL_REQ_LEVEL macro
The GHCB_MSR_VMPL_REQ_LEVEL macro lacked parentheses around the bitmask expression, causing the shift operation to bind too early. As a result, when requesting VMPL1 (e.g., GHCB_MSR_VMPL_REQ_LEVEL(1)), incorrect values such as 0x000000016 were generated instead of the intended 0x100000016 (the requested VMPL level is specified in GHCBData[39:32]).
Fix the precedence issue by grouping the masked value before applying the shift.
[ bp: Massage commit message. ]
--- arch/x86/include/asm/sev-common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/sev-common.h +1 -1
@@ -116,7 +116,7 @@ enum psc_op {#define GHCB_MSR_VMPL_REQ 0x016 #define GHCB_MSR_VMPL_REQ_LEVEL(v) \ /* GHCBData[39:32] */ \ - (((u64)(v) & GENMASK_ULL(7, 0) << 32) | \ + ((((u64)(v) & GENMASK_ULL(7, 0)) << 32) | \ /* GHCBDdata[11:0] */ \GHCB_MSR_VMPL_REQ )