[PATCH v2] x86/sev: Add missing RIP_REL_REF() invocations during sme_enable()

From: Kevin Loughlin
Date: Fri Nov 22 2024 - 15:23:52 EST


commit 1c811d403afd ("x86/sev: Fix position dependent variable
references in startup code") introduced RIP_REL_REF() to force RIP-
relative accesses to global variables, as needed to prevent crashes
during early SEV/SME startup code. For completeness, RIP_REL_REF()
should be used with additional variables during sme_enable() [0].
Access these vars with RIP_REL_REF() to prevent problem reoccurence.

[0] https://lore.kernel.org/all/CAMj1kXHnA0fJu6zh634=fbJswp59kSRAbhW+ubDGj1+NYwZJ-Q@xxxxxxxxxxxxxx/

Fixes: 1c811d403afd ("x86/sev: Fix position dependent variable references in startup code")
Signed-off-by: Kevin Loughlin <kevinloughlin@xxxxxxxxxx>
Reviewed-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
Reviewed-by: Tom Lendacky <thomas.lendacky@xxxxxxx>
---

v1 -> v2: Fix typo in commit message, add Ard's and Tom's "Reviewed-by"

arch/x86/mm/mem_encrypt_identity.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c
index e6c7686f443a..9fce5b87b8c5 100644
--- a/arch/x86/mm/mem_encrypt_identity.c
+++ b/arch/x86/mm/mem_encrypt_identity.c
@@ -565,7 +565,7 @@ void __head sme_enable(struct boot_params *bp)
}

RIP_REL_REF(sme_me_mask) = me_mask;
- physical_mask &= ~me_mask;
- cc_vendor = CC_VENDOR_AMD;
+ RIP_REL_REF(physical_mask) &= ~me_mask;
+ RIP_REL_REF(cc_vendor) = CC_VENDOR_AMD;
cc_set_mask(me_mask);
}
--
2.47.0.371.ga323438b13-goog