Re: [PATCH v3 09/10] KVM: selftests: Expect #PF(RSVD) when TDP is disabled

Sean Christopherson
2022-10-31T18:08:13Z

On Mon, Oct 31, 2022, David Matlack wrote:
> -static void guest_code(void)
> +static void guest_code(bool tdp_enabled)
> {
> - flds(MEM_REGION_GVA);
> + uint64_t error_code;
> + uint64_t vector;
> +
> + vector = kvm_asm_safe_ec(FLDS_MEM_EAX, error_code, "a"(MEM_REGION_GVA));
> +
> + /*
> + * When TDP is disabled, no instruction emulation is required so flds
> + * should generate #PF(RSVD).
> + */
> + if (!tdp_enabled) {
> + GUEST_ASSERT_EQ(vector, PF_VECTOR);
> + GUEST_ASSERT(error_code & PFERR_RSVD_MASK);
> + }

Probably worth adding

} else {
GUEST_ASSERT(!vector);
}

to verify no fault occurs in the emulation case? Or to avoid the inverted check,

if (tdp_enabled) {
GUEST_ASSERT(!vector);
} else {
GUEST_ASSERT_EQ(vector, PF_VECTOR);
GUEST_ASSERT(error_code & PFERR_RSVD_MASK);
}

It's mostly redundant with assert_exit_for_flds_emulation_failure(), but at worst
it'll help docuemnts the expected behavior in the TDP case.