lkml.org 
[lkml]   [2022]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [V2 PATCH 7/8] Kvm: selftests: x86: Execute cpu specific vmcall instruction
On Thu, Sep 15, 2022 at 12:04:47AM +0000, Vishal Annapurve wrote:
> Update the vmcall instruction invocation to happen according to the cpu
> type.
>
> Suggested-by: Sean Christopherson <seanjc@google.com>
> Signed-off-by: Vishal Annapurve <vannapurve@google.com>
> ---
> tools/testing/selftests/kvm/include/x86_64/processor.h | 8 ++++++++
> tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c | 2 +-
> .../selftests/kvm/x86_64/vmx_nested_tsc_scaling_test.c | 2 +-
> tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c | 2 +-

What's the reason to use kvm_hypercall() for these tests? All of these
are Intel-specific. i.e. is_amd_cpu() will always return false.

> 4 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h
> index 18a8a6a2b786..74893a7a80f8 100644
> --- a/tools/testing/selftests/kvm/include/x86_64/processor.h
> +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h
> @@ -833,6 +833,14 @@ void vm_set_page_table_entry(struct kvm_vm *vm, struct kvm_vcpu *vcpu,
> uint64_t kvm_hypercall(uint64_t nr, uint64_t a0, uint64_t a1, uint64_t a2,
> uint64_t a3);
>
> +/*
> + * Execute vmcall instruction.
> + */
> +static inline void vmcall(void)
> +{
> + kvm_hypercall(0, 0, 0, 0, 0);
> +}
> +
> void nested_guest_vmcall(void);
>
> void __vm_xsave_require_permission(int bit, const char *name);
> diff --git a/tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c b/tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c
> index 5abecf06329e..8180711c8684 100644
> --- a/tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c
> @@ -31,7 +31,7 @@
> static void l2_guest_code(void)
> {
> /* Exit to L1 */
> - __asm__ __volatile__("vmcall");
> + vmcall();
> }
>
> static void l1_guest_code(struct vmx_pages *vmx_pages, unsigned long high_gpa)
> diff --git a/tools/testing/selftests/kvm/x86_64/vmx_nested_tsc_scaling_test.c b/tools/testing/selftests/kvm/x86_64/vmx_nested_tsc_scaling_test.c
> index 465a9434d61c..37da9d01d5d6 100644
> --- a/tools/testing/selftests/kvm/x86_64/vmx_nested_tsc_scaling_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/vmx_nested_tsc_scaling_test.c
> @@ -76,7 +76,7 @@ static void l2_guest_code(void)
> check_tsc_freq(UCHECK_L2);
>
> /* exit to L1 */
> - __asm__ __volatile__("vmcall");
> + vmcall();
> }
>
> static void l1_guest_code(struct vmx_pages *vmx_pages)
> diff --git a/tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c b/tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c
> index 5943187e8594..00192f564d9b 100644
> --- a/tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c
> @@ -74,7 +74,7 @@ static void l2_guest_code(void)
> check_ia32_tsc_adjust(-2 * TSC_ADJUST_VALUE);
>
> /* Exit to L1 */
> - __asm__ __volatile__("vmcall");
> + vmcall();
> }
>
> static void l1_guest_code(struct vmx_pages *vmx_pages)
> --
> 2.37.2.789.g6183377224-goog
>

\
 
 \ /
  Last update: 2022-09-21 23:44    [W:0.030 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site