Re: [PATCH v3 09/12] KVM: selftests: Port VMware backdoor coverage

From: Zack Rusin

Date: Tue Nov 17 2026 - 16:50:27 EST


On Thu, Nov 12, 2026 at 1:37 PM 'Jim Mattson' via
BCM-KERNEL-FEEDBACK-LIST,PDL
<bcm-kernel-feedback-list.pdl@xxxxxxxxxxxx> wrote:
>
> On Tue, Nov 10, 2026 at 10:08 PM Zack Rusin <zack.rusin@xxxxxxxxxxxx> wrote:
> >
> > Add vmware_backdoor_test, adapted from KVM-unit-tests' vmware_backdoors
> > test. From CPL3, with CR4.PCE clear and no I/O permission bitmap in
> > the TSS, read the VMware pseudo-PMCs with RDPMC and issue backdoor
> > commands on the backdoor port with IN. Verify that the pseudo-PMC
> > reads succeed and the port accesses exit to userspace only when the
> > backdoor is enabled and raise #GP otherwise, and that other PMC indices
> > and ports always raise #GP. Repeat the pseudo-PMC checks at CPL3 with
> > CR4.PCE set and at CPL0, where RDPMC doesn't fault before KVM handles
> > it. Skip the pseudo-PMC checks if KVM doesn't virtualize a PMU, as KVM
> > then injects #GP for every RDPMC.
> >
> > Run the checks for a VM that relies on the enable_vmware_backdoor
> > default and for a VM that enables KVM_VMWARE_ENABLE_BACKDOOR, and
> > verify that KVM_CAP_X86_VMWARE rejects every flag it doesn't report.
> > KVM-unit-tests can only cover the module parameter, which applies to
> > every VM, while the selftest also covers the per-VM capability.
> >
> > Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> > Link: https://lore.kernel.org/r/aIEoNpe-LFoH6LBm@xxxxxxxxxx
> > Signed-off-by: Zack Rusin <zack.rusin@xxxxxxxxxxxx>
> > ---
>
> [ ... ]
>
> > +static struct insn_result guest_inl(u16 port, u32 command)
> > +{
> > + struct insn_result result;
> > + unsigned long rax = VMPORT_DEFAULT_RETVAL;
>
> Shouldn't %rax be VMWARE_MAGIC?

Yes, good catch! Thanks. The KUT test loads the magic value there and
I must have lost in the port. KVMs L1 backdoor only looks at the port,
which is why the test was passing, but I'll fix in the next version.
Again, thanks for looking at this.

z

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature