From: Sean Christopherson <seanjc@google.com>
To: kernel test robot <yi1.lai@intel.com>
Cc: oe-lkp@lists.linux.dev, lkp@intel.com,
Yosry Ahmed <yosry@kernel.org>,
kvm@vger.kernel.org
Subject: Re: [sean-jc:x86/evmcs_vmptrldst] [KVM] 7fecb27e8d: bunch of kselftests.kvm failures
Date: Thu, 3 Sep 2026 11:43:13 -0700 [thread overview]
Message-ID: <apm_wb4yJ0jM9_gg@google.com> (raw)
In-Reply-To: <apm0BpPvMZZWYthw@google.com>
On Thu, Sep 03, 2026, Sean Christopherson wrote:
> On Thu, Sep 03, 2026, kernel test robot wrote:
> > kernel test robot noticed "kselftests.kvm.hyperv_evmcs.fail" on:
> >
> > commit: 7fecb27e8d353adda91989eb01b3ae200b846a42 ("KVM: selftests: Always assert that vmwrite() succeeds") https://github.com/sean-jc/linux x86/evmcs_vmptrldst
> >
> > in testcase: kselftests
> > version: kselftests-x86_64-f5098b6bae76-1_20260727
> > with following parameters:
> >
> > group: kvm
> >
> > config: x86_64-rhel-9.4-kselftests
> > compiler: gcc-14
> > test machine: 16 threads Intel(R) Core(TM) i7-13620H (Raptor Lake) with 32G memory
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <yi1.lai@intel.com>
> > | Closes: https://lore.kernel.org/oe-lkp/202609030248.b516759d-lkp@intel.com
> >
> > The kernel config and materials to reproduce are available at:
> > https://download.01.org/0day-ci/archive/20260903/202609030248.b516759d-lkp@intel.com
> >
> > Detailed log:
> > # selftests: kvm: evmcs_smm_controls_test
> > # Random seed: 0x7ad5b4f9
> > #
> > # ==== Test Assertion Failure ====
> > # include/x86/vmx.h:434: __vmwrite(encoding, value)
> > # pid=5240 tid=5240 errno=4 - Interrupted system call
> > # 1 0x0000000000412f61: assert_on_unhandled_exception at processor.c:781
> > # 2 0x0000000000406f86: _vcpu_run at kvm_util.c:1687
> > # 3 (inlined by) vcpu_run at kvm_util.c:1698
> > # 4 0x0000000000402cc6: main at evmcs_smm_controls_test.c:93
> > # 5 0x00007f0a85d39ca7: ?? ??:0
> > # 6 0x00007f0a85d39d64: ?? ??:0
> > # 7 0x00000000004030c0: _start at ??:?
> > # vmwrite[0x0] = 0x0 hit VM-Fail
>
> /facepalm
>
> I managed to *repeatedly* not update the repository I was using to build selftests.
> Thank you friendly kernel test robot for saving me from major embarassment!
Ok, this is too funny not to tell someone, even if that someone ends up being a
bot.
I thought for sure I messed up the encoding, i.e. that the "vmwrite[0x0]" in the
report was either wrong, or or the encoding was getting clobbered along the way.
Nope, it just so happens that VIRTUAL_PROCESSOR_ID is encoding '0', and the very
first thing done by prepare_vmcs() => init_vmcs_control_fields() is:
vmwrite(VIRTUAL_PROCESSOR_ID, 0);
The actual bug is stupid simple (and also hilarious/typical):
diff --git a/tools/testing/selftests/kvm/include/x86/vmx.h b/tools/testing/selftests/kvm/include/x86/vmx.h
index 81028c24dc9e..a4807e41fe69 100644
--- a/tools/testing/selftests/kvm/include/x86/vmx.h
+++ b/tools/testing/selftests/kvm/include/x86/vmx.h
@@ -430,7 +430,7 @@ static __always_inline int __vmwrite(u64 encoding, u64 value)
static inline void vmwrite(u64 encoding, u64 value)
{
- __GUEST_ASSERT(__vmwrite(encoding, value),
+ __GUEST_ASSERT(!__vmwrite(encoding, value),
"vmwrite[0x%lx] = 0x%lx hit VM-Fail", encoding, value);
}
Just to double check that I didn't botch the formatting, I verified that this:
diff --git a/tools/testing/selftests/kvm/lib/x86/vmx.c b/tools/testing/selftests/kvm/lib/x86/vmx.c
index f32f8319301d..6066d200bcc2 100644
--- a/tools/testing/selftests/kvm/lib/x86/vmx.c
+++ b/tools/testing/selftests/kvm/lib/x86/vmx.c
@@ -251,11 +251,11 @@ static inline void init_vmcs_control_fields(struct vmx_pages *vmx)
{
u32 sec_exec_ctl = 0;
+ vmwrite(PIN_BASED_VM_EXEC_CONTROL, rdmsr(MSR_IA32_VMX_TRUE_PINBASED_CTLS));
+
vmwrite(VIRTUAL_PROCESSOR_ID, 0);
vmwrite(POSTED_INTR_NV, 0);
- vmwrite(PIN_BASED_VM_EXEC_CONTROL, rdmsr(MSR_IA32_VMX_TRUE_PINBASED_CTLS));
-
if (vmx->eptp_gpa) {
u64 eptp = vmx->eptp_gpa | EPTP_WB | EPTP_PWL_4;
Yields:
vmwrite[0x4000] = 0x3f00000016 hit VM-Fail
prev parent reply other threads:[~2026-09-03 18:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 0:29 [sean-jc:x86/evmcs_vmptrldst] [KVM] 7fecb27e8d: bunch of kselftests.kvm failures kernel test robot
2026-09-03 17:53 ` Sean Christopherson
2026-09-03 18:43 ` 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=apm_wb4yJ0jM9_gg@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=lkp@intel.com \
--cc=oe-lkp@lists.linux.dev \
--cc=yi1.lai@intel.com \
--cc=yosry@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