Re: [PATCH v7 26/26] KVM: selftest: Add a selftest for VMRUN/#VMEXIT with unmappable vmcb12

From: Yosry Ahmed

Date: Thu Mar 05 2026 - 17:53:02 EST


On Thu, Mar 5, 2026 at 2:30 PM Jim Mattson <jmattson@xxxxxxxxxx> wrote:
>
> On Mon, Mar 2, 2026 at 4:43 PM Yosry Ahmed <yosry@xxxxxxxxxx> wrote:
> >
> > Add a test that verifies that KVM correctly injects a #GP for nested
> > VMRUN and a shutdown for nested #VMEXIT, if the GPA of vmcb12 cannot be
> > mapped.
> >
> > Signed-off-by: Yosry Ahmed <yosry@xxxxxxxxxx>
> > ...
> > + /*
> > + * Find the max legal GPA that is not backed by a memslot (i.e. cannot
> > + * be mapped by KVM).
> > + */
> > + maxphyaddr = kvm_cpuid_property(vcpu->cpuid, X86_PROPERTY_MAX_PHY_ADDR);
> > + max_legal_gpa = BIT_ULL(maxphyaddr) - PAGE_SIZE;
> > + vcpu_alloc_svm(vm, &nested_gva);
> > + vcpu_args_set(vcpu, 2, nested_gva, max_legal_gpa);
> > +
> > + /* VMRUN with max_legal_gpa, KVM injects a #GP */
> > + vcpu_run(vcpu);
> > + TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_IO);
> > + TEST_ASSERT_EQ(get_ucall(vcpu, &uc), UCALL_SYNC);
> > + TEST_ASSERT_EQ(uc.args[1], SYNC_GP);
>
> Why would this raise #GP? That isn't architected behavior.

I don't see architected behavior in the APM for what happens if VMRUN
fails to load the VMCB from memory. I guess it should be the same as
what would happen if a PTE is pointing to a physical address that
doesn't exist? Maybe #MC?