[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZeqQT1DAxnji75KZ@google.com>
Date: Thu, 7 Mar 2024 20:13:03 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Vitaly Kuznetsov <vkuznets@...hat.com>
Cc: kvm@...r.kernel.org, Paolo Bonzini <pbonzini@...hat.com>,
Li RongQing <lirongqing@...du.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] KVM: selftests: Check that KVM_FEATURE_PV_UNHALT is
cleared with KVM_X86_DISABLE_EXITS_HLT
Shortlog is a wee bit long, I went with:
KVM: selftests: Check that PV_UNHALT is cleared when HLT exiting is disabled
On Wed, Feb 28, 2024, Vitaly Kuznetsov wrote:
> KVM_FEATURE_PV_UNHALT is expected to get cleared from KVM PV feature CPUID
> data when KVM_X86_DISABLE_EXITS_HLT is enabled. Add the corresponding test
> to kvm_pv_test.
>
> Note, the newly added code doesn't actually test KVM_FEATURE_PV_UNHALT and
> KVM_X86_DISABLE_EXITS_HLT features.
>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@...hat.com>
> ---
..
> + TEST_ASSERT(ent->eax & (1 << KVM_FEATURE_PV_UNHALT),
> + "Enabling X86_FEATURE_KVM_PV_UNHALT had no effect");
> +
> + /* Make sure KVM clears vcpu->arch.kvm_cpuid */
> + ent = vcpu_get_cpuid_entry(vcpu, KVM_CPUID_SIGNATURE);
> + kvm_sig_old = ent->ebx;
> + ent->ebx = 0xdeadbeef;
> + vcpu_set_cpuid(vcpu);
> +
> + vm_enable_cap(vm, KVM_CAP_X86_DISABLE_EXITS, KVM_X86_DISABLE_EXITS_HLT);
> + ent = vcpu_get_cpuid_entry(vcpu, KVM_CPUID_SIGNATURE);
> + ent->ebx = kvm_sig_old;
> + vcpu_set_cpuid(vcpu);
> + ent = vcpu_get_cpuid_entry(vcpu, KVM_CPUID_FEATURES);
> +
> + TEST_ASSERT(!(ent->eax & (1 << KVM_FEATURE_PV_UNHALT)),
X86_FEATURE_KVM_PV_UNHALT already exists, all we're missing is a helper to get
a CPUID feature from host userspace given a vCPU. I added this
static inline bool vcpu_cpuid_has(struct kvm_vcpu *vcpu,
struct kvm_x86_cpu_feature feature)
{
struct kvm_cpuid_entry2 *entry;
entry = __vcpu_get_cpuid_entry(vcpu, feature.function, feature.index);
return *((&entry->eax) + feature.reg) & BIT(feature.bit);
}
and used it in this test instead of open coding the reg+bit.
Powered by blists - more mailing lists