[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250923050942.206116-9-Neeraj.Upadhyay@amd.com>
Date: Tue, 23 Sep 2025 10:39:15 +0530
From: Neeraj Upadhyay <Neeraj.Upadhyay@....com>
To: <kvm@...r.kernel.org>, <seanjc@...gle.com>, <pbonzini@...hat.com>
CC: <linux-kernel@...r.kernel.org>, <Thomas.Lendacky@....com>,
<nikunj@....com>, <Santosh.Shukla@....com>, <Vasant.Hegde@....com>,
<Suravee.Suthikulpanit@....com>, <bp@...en8.de>, <David.Kaplan@....com>,
<huibo.wang@....com>, <naveen.rao@....com>, <pgonda@...gle.com>,
<linux-kselftest@...r.kernel.org>, <shuah@...nel.org>, <tiala@...rosoft.com>
Subject: [RFC PATCH v2 08/35] KVM: selftests: Align GHCB entry struct to page size
The SEV GHCB specification defines two methods for a guest to register
its GHCB page with the hypervisor: an MSR-based protocol and a GPA-based
protocol. The hypervisor (KVM) distinguishes between them by inspecting
the value written to the MSR_AMD64_SEV_ES_GHCB MSR. If the value has its
lower 12 bits as zero, it is treated as a page-aligned Guest Physical
Address (GPA). Otherwise, it is interpreted as a command for the
MSR-based protocol.
The selftest's ghcb_entry struct is not explicitly page-aligned. When
the test guest attemptd to register the GHCB by writing its unaligned
GPA to the MSR, KVM would incorrectly interpret the request as a
malformed MSR-based command instead of a GPA registration. This caused
GHCB initialization to fail.
Fix this by aligning the ghcb_entry struct definition to PAGE_SIZE.
This forces the structure to be page-aligned, ensuring its GPA has
zero in the lower 12 bits and allowing KVM to correctly recognize
it as a GPA registration request.
Signed-off-by: Neeraj Upadhyay <Neeraj.Upadhyay@....com>
---
tools/testing/selftests/kvm/lib/x86/sev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/lib/x86/sev.c b/tools/testing/selftests/kvm/lib/x86/sev.c
index 3090a6518066..edefba7f49ce 100644
--- a/tools/testing/selftests/kvm/lib/x86/sev.c
+++ b/tools/testing/selftests/kvm/lib/x86/sev.c
@@ -22,7 +22,7 @@ struct ghcb_entry {
/* Host virtual address of this struct. */
struct ghcb_entry *hva;
-};
+} __aligned(PAGE_SIZE);
struct ghcb_header {
struct ghcb_entry ghcbs[KVM_MAX_VCPUS];
--
2.34.1
Powered by blists - more mailing lists