[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kvm
Subject:    Re: [PATCH v3 09/10] KVM: selftests: Expect #PF(RSVD) when TDP is disabled
From:       Sean Christopherson <seanjc () google ! com>
Date:       2022-10-31 18:07:42
Message-ID: Y2AO7v5puszylEvv () google ! com
[Download RAW message or body]

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.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic