lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YyuFkmJRP/4ynKqD@google.com>
Date:   Wed, 21 Sep 2022 14:43:46 -0700
From:   David Matlack <dmatlack@...gle.com>
To:     Vishal Annapurve <vannapurve@...gle.com>
Cc:     x86@...nel.org, kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-kselftest@...r.kernel.org, pbonzini@...hat.com,
        shuah@...nel.org, bgardon@...gle.com, seanjc@...gle.com,
        oupton@...gle.com, peterx@...hat.com, vkuznets@...hat.com
Subject: Re: [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@...gle.com>
> Signed-off-by: Vishal Annapurve <vannapurve@...gle.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
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ