From: Sean Christopherson <seanjc@google.com>
To: Ewan Hai-oc <ewanhai-oc@zhaoxin.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Shuah Khan <shuah@kernel.org>, Frank Zhu <frankzhu@zhaoxin.com>,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, ewanhai@zhaoxin.com,
cobechen@zhaoxin.com
Subject: Re: [PATCH v2 9/9] KVM: selftests: vmx_apic_access_test: Check APIC virtualization support
Date: Fri, 11 Sep 2026 09:32:20 -0700 [thread overview]
Message-ID: <aqQtFOzx35CVqfDK@google.com> (raw)
In-Reply-To: <20260910115414.3015260-10-ewanhai-oc@zhaoxin.com>
On Thu, Sep 10, 2026, Ewan Hai-oc wrote:
> diff --git a/tools/testing/selftests/kvm/lib/x86/vmx.c b/tools/testing/selftests/kvm/lib/x86/vmx.c
> index 089e1a8af..e512191f1 100644
> --- a/tools/testing/selftests/kvm/lib/x86/vmx.c
> +++ b/tools/testing/selftests/kvm/lib/x86/vmx.c
> @@ -390,6 +390,21 @@ bool kvm_cpu_has_ept(void)
> return ctrl & SECONDARY_EXEC_ENABLE_EPT;
> }
>
> +bool kvm_cpu_has_vmx_apic_access_virt(void)
This should be kvm_cpu_has_vmx_virtualize_apic_accesses() to match the macro, and
to match what KVM itself uses.
> +{
> + u64 ctrl;
> +
> + if (!kvm_cpu_has(X86_FEATURE_VMX))
> + return false;
> +
> + ctrl = kvm_get_feature_msr(MSR_IA32_VMX_TRUE_PROCBASED_CTLS) >> 32;
> + if (!(ctrl & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS))
> + return false;
> +
> + ctrl = kvm_get_feature_msr(MSR_IA32_VMX_PROCBASED_CTLS2) >> 32;
> + return ctrl & SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;
Carve out the guts of kvm_cpu_has_ept() into a helper isntead of copy+pasting.
> +}
> +
> void prepare_virtualize_apic_accesses(struct vmx_pages *vmx, struct kvm_vm *vm)
> {
> vmx->apic_access = (void *)vm_alloc_page(vm);
> diff --git a/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c b/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c
> index 463f73aa9..a1b6da4c0 100644
> --- a/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c
> +++ b/tools/testing/selftests/kvm/x86/vmx_apic_access_test.c
> @@ -78,6 +78,7 @@ int main(int argc, char *argv[])
> struct kvm_vm *vm;
>
> TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
> + TEST_REQUIRE(kvm_cpu_has_vmx_apic_access_virt());
This can replace the X86_FEATURE_VMX check, since KVM shouldn't report support
for virtualizing APIC accesses without VMX.
No need for a new version, I'll fixup everything when applying.
prev parent reply other threads:[~2026-09-11 16:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 11:54 [PATCH v2 0/9] KVM: selftests: Add Zhaoxin CPU support Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 1/9] KVM: selftests: Add Zhaoxin CPU detection support Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 2/9] KVM: selftests: Use host_cpu_is_intel_compatible for mediated PMU Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 3/9] KVM: selftests: nx_huge_pages_test: Add TDP detection for Zhaoxin CPUs Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 4/9] KVM: selftests: vmx_exception_with_invalid_guest_state: Support " Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 5/9] KVM: selftests: fix_hypercall_test: Add Zhaoxin CPU support Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 6/9] KVM: selftests: Skip PERF_CAPABILITIES vCPU checks without PDCM Ewan Hai-oc
2026-09-11 16:19 ` Sean Christopherson
2026-09-10 11:54 ` [PATCH v2 7/9] KVM: selftests: feature_msrs_test: Extend MSR_IA32_UCODE_REV quirk to Zhaoxin Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 8/9] KVM: selftests: nested_exceptions_test: Add Zhaoxin CPU support Ewan Hai-oc
2026-09-10 11:54 ` [PATCH v2 9/9] KVM: selftests: vmx_apic_access_test: Check APIC virtualization support Ewan Hai-oc
2026-09-11 16:32 ` Sean Christopherson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aqQtFOzx35CVqfDK@google.com \
--to=seanjc@google.com \
--cc=cobechen@zhaoxin.com \
--cc=ewanhai-oc@zhaoxin.com \
--cc=ewanhai@zhaoxin.com \
--cc=frankzhu@zhaoxin.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox