All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sean Christopherson" <seanjc@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v2 6/6] KVM: selftests: Expect failure when trying to set EFER that violates vCPU model
Date: Tue, 27 Oct 2026 22:52:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-187178@kernel.org> (raw)
In-Reply-To: <20261027224914.1574319-7-seanjc@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] KVM: selftests: uninitialized sregs in test_sregs_lmsle()
--

commit 6277431d999ca1b09f23758ba28993921a931827
Author: Sean Christopherson <seanjc@google.com>

KVM: selftests: Expect failure when trying to set EFER that violates vCPU model

This commit updates test_host_initiated_lmsle() in svm_nested_efer_test.c to
expect KVM_SET_MSRS to reject EFER.LMSLE=1 when EFER_LMSLE_MBZ is enabled in
guest CPUID, and cleans up related comments in the test.

> diff --git a/tools/testing/selftests/kvm/x86/svm_nested_efer_test.c b/tools/testing/selftests/kvm/x86/svm_nested_efer_test.c
> index fa9cfe8b12427..bdec7cdb37146 100644
> --- a/tools/testing/selftests/kvm/x86/svm_nested_efer_test.c
> +++ b/tools/testing/selftests/kvm/x86/svm_nested_efer_test.c

[ ... ]

> @@ -222,11 +219,6 @@ static void test_sregs_lmsle(void)
>  	vm = vm_create_with_one_vcpu(&vcpu, NULL);
>  	vcpu_set_cpuid_feature(vcpu, X86_FEATURE_EFER_LMSLE_MBZ);
>  
> -	/*
> -	 * Unlike KVM_SET_MSRS, KVM_SET_SREGS runs the full set of guest CPUID
> -	 * checks, i.e. rejects EFER.LMSLE even though it's host-initiated.
> -	 */
> -	vcpu_sregs_get(vcpu, &sregs);
>  	TEST_ASSERT(!(sregs.efer & EFER_LMSLE), "EFER.LMSLE unexpectedly set");

[Severity: Medium]
Was removing vcpu_sregs_get(vcpu, &sregs) in test_sregs_lmsle() unintentional?

Without that call, the stack variable sregs is left uninitialized when
TEST_ASSERT() reads sregs.efer and when sregs.efer |= EFER_LMSLE is passed to
_vcpu_sregs_set(vcpu, &sregs):

tools/testing/selftests/kvm/x86/svm_nested_efer_test.c:test_sregs_lmsle() {
	struct kvm_vcpu *vcpu;
	struct kvm_sregs sregs;
	struct kvm_vm *vm;
	int rc;

	vm = vm_create_with_one_vcpu(&vcpu, NULL);
	vcpu_set_cpuid_feature(vcpu, X86_FEATURE_EFER_LMSLE_MBZ);

	TEST_ASSERT(!(sregs.efer & EFER_LMSLE), "EFER.LMSLE unexpectedly set");

	sregs.efer |= EFER_LMSLE;
	rc = _vcpu_sregs_set(vcpu, &sregs);
	...
}

In addition to reading uninitialized stack memory on the assertion, passing
an uninitialized struct kvm_sregs to KVM_SET_SREGS means KVM may reject the
ioctl due to garbage in other fields rather than specifically testing
rejection of EFER.LMSLE=1.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261027224914.1574319-1-seanjc@google.com?part=6

  reply	other threads:[~2026-10-27 22:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 22:49 [PATCH v2 0/6] KVM: x86: More EFER.LMA vs. CR4.PAE fixes Sean Christopherson
2026-10-27 22:49 ` [PATCH v2 1/6] Revert "KVM: x86: Skip EFER vs. guest CPUID checks for host-initiated writes" Sean Christopherson
2026-10-27 22:49 ` [PATCH v2 2/6] KVM: x86: Reject clearing EFER.SVME via KVM_SYNC_X86_SREGS if L2 is active Sean Christopherson
2026-10-28  0:08   ` Yosry Ahmed
2026-10-28 13:36     ` Sean Christopherson
2026-10-28 14:47       ` Yosry Ahmed
2026-10-27 22:49 ` [PATCH v2 3/6] KVM: nSVM: Synthesize #GP instead of SHUTDOWN if L2 attempts to clear EFER.SVME Sean Christopherson
2026-10-27 22:49 ` [PATCH v2 4/6] KVM: x86: Recompute EFER.LMA instead of inheriting the current value on EFER writes Sean Christopherson
2026-10-27 23:17   ` sashiko-bot
2026-10-28 13:39     ` Sean Christopherson
2026-10-27 22:49 ` [PATCH v2 5/6] KVM: selftests: Update nSVM EFER test to expect #GP when clearing SVME in L2 Sean Christopherson
2026-10-27 22:49 ` [PATCH v2 6/6] KVM: selftests: Expect failure when trying to set EFER that violates vCPU model Sean Christopherson
2026-10-27 22:52   ` sashiko-bot [this message]
2026-10-28 13:41     ` Sean Christopherson

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=sashiko-outbox-187178@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=seanjc@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.