From: Sean Christopherson <seanjc@google.com>
To: Gokul K <gokul02k@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Shuah Khan <shuah@kernel.org>,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: selftests: Compare the entire XSAVE buffer in the SEV smoke test
Date: Mon, 10 Aug 2026 07:07:38 -0700 [thread overview]
Message-ID: <annbKnNqQvzyn8tp@google.com> (raw)
In-Reply-To: <20260807071026.195503-1-gokul02k@gmail.com>
On Fri, Aug 07, 2026, Gokul K wrote:
> compare_xsave() stops at index 4094, so the last byte of the XSAVE state
> is never compared. Both buffers handed to it are 4096 bytes: the host
> copy is a struct kvm_xsave, whose region[] member is 1024 u32s, and the
> guest copy is the PAGE_SIZE shared page that guest_code_xsave() runs
> XSAVE into. A VMSA synchronization bug that corrupted only that final
> byte would go unreported and the test would still pass.
>
> Bound the loop with sizeof(struct kvm_xsave) rather than an open-coded
> length, and make the index unsigned so it does not mix signedness with
> sizeof.
>
> Fixes: 8c53183dbaa2 ("selftests: kvm: add test for transferring FPU state into VMSA")
> Signed-off-by: Gokul K <gokul02k@gmail.com>
> ---
> tools/testing/selftests/kvm/x86/sev_smoke_test.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/x86/sev_smoke_test.c b/tools/testing/selftests/kvm/x86/sev_smoke_test.c
> index 6b2cbe2a90b7..c7af27954356 100644
> --- a/tools/testing/selftests/kvm/x86/sev_smoke_test.c
> +++ b/tools/testing/selftests/kvm/x86/sev_smoke_test.c
> @@ -90,9 +90,10 @@ asm("guest_code_xsave:\n"
>
> static void compare_xsave(u8 *from_host, u8 *from_guest)
> {
> - int i;
> + unsigned int i;
> bool bad = false;
> - for (i = 0; i < 4095; i++) {
The fix looks right, but this is so bizarrely wrong that I can't help but wonder
if it was somehow intentional.
Paolo?
> +
> + for (i = 0; i < sizeof(struct kvm_xsave); i++) {
> if (from_host[i] != from_guest[i]) {
> printf("mismatch at %u | %02hhx %02hhx\n",
> i, from_host[i], from_guest[i]);
> --
> 2.54.0
>
>
prev parent reply other threads:[~2026-08-10 14:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 7:10 [PATCH] KVM: selftests: Compare the entire XSAVE buffer in the SEV smoke test Gokul K
2026-08-10 14:07 ` Sean Christopherson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=annbKnNqQvzyn8tp@google.com \
--to=seanjc@google.com \
--cc=gokul02k@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox