mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] x86/sev: Fix operator precedence in GHCB_MSR_VMPL_REQ_LEVEL macro
@ 2025-05-11  9:23 Seongmanlee
  2025-05-11  9:30 ` Borislav Petkov
  2025-05-11  9:47 ` [tip: x86/urgent] " tip-bot2 for Seongman Lee
  0 siblings, 2 replies; 3+ messages in thread
From: Seongmanlee @ 2025-05-11  9:23 UTC (permalink / raw)
  To: x86
  Cc: leonardo-leecaprio, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, H. Peter Anvin,
	open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)

From: leonardo-leecaprio <augustus92@kaist.ac.kr>

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.

Fixes: 34ff65901735 ("x86/sev: Use kernel provided SVSM Calling Areas")

Signed-off-by: Seongman Lee <augustus92@kaist.ac.kr>
---
 arch/x86/include/asm/sev-common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/sev-common.h b/arch/x86/include/asm/sev-common.h
index acb85b934..0020d77a0 100644
--- a/arch/x86/include/asm/sev-common.h
+++ b/arch/x86/include/asm/sev-common.h
@@ -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)
 
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-11  9:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-11  9:23 [PATCH v2] x86/sev: Fix operator precedence in GHCB_MSR_VMPL_REQ_LEVEL macro Seongmanlee
2025-05-11  9:30 ` Borislav Petkov
2025-05-11  9:47 ` [tip: x86/urgent] " tip-bot2 for Seongman Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®