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

From: Jim Mattson

Date: Thu Mar 05 2026 - 17:32:43 EST


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.