[RFC PATCH 07/31] KVM: selftests: Fix ghcb_entry returned in ghcb_alloc()

From: Neeraj Upadhyay
Date: Fri Feb 28 2025 - 04:42:11 EST


Currently, ghcb_alloc() always returns first entry. Fix
it to return an unused entry.

Signed-off-by: Neeraj Upadhyay <Neeraj.Upadhyay@xxxxxxx>
---
tools/testing/selftests/kvm/lib/x86/sev.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kvm/lib/x86/sev.c b/tools/testing/selftests/kvm/lib/x86/sev.c
index 425ec8a3a3c7..228c446072a8 100644
--- a/tools/testing/selftests/kvm/lib/x86/sev.c
+++ b/tools/testing/selftests/kvm/lib/x86/sev.c
@@ -68,7 +68,6 @@ static void sev_es_terminate(void)

static struct ghcb_entry *ghcb_alloc(void)
{
- return &ghcb_pool->ghcbs[0];
struct ghcb_entry *entry;
struct ghcb *ghcb;
int i;
@@ -81,7 +80,7 @@ static struct ghcb_entry *ghcb_alloc(void)
entry = &ghcb_pool->ghcbs[i];
ghcb = &entry->ghcb;

- memset(&ghcb, 0, sizeof(*ghcb));
+ memset(ghcb, 0, sizeof(*ghcb));
ghcb->ghcb_usage = 0;
ghcb->protocol_version = 1;

--
2.34.1