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]
Date:   Tue, 07 Jun 2022 13:03:46 +0300
From:   Maxim Levitsky <mlevitsk@...hat.com>
To:     Vitaly Kuznetsov <vkuznets@...hat.com>, kvm@...r.kernel.org,
        Paolo Bonzini <pbonzini@...hat.com>
Cc:     Sean Christopherson <seanjc@...gle.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Michael Kelley <mikelley@...rosoft.com>,
        Siddharth Chandrasekaran <sidcha@...zon.de>,
        Yuan Yao <yuan.yao@...ux.intel.com>,
        linux-hyperv@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v6 26/38] KVM: selftests: Move the function doing
 Hyper-V hypercall to a common header

On Mon, 2022-06-06 at 10:36 +0200, Vitaly Kuznetsov wrote:
> All Hyper-V specific tests issuing hypercalls need this.
> 
> Signed-off-by: Vitaly Kuznetsov <vkuznets@...hat.com>
> ---
>  .../selftests/kvm/include/x86_64/hyperv.h       | 15 +++++++++++++++
>  .../selftests/kvm/x86_64/hyperv_features.c      | 17 +----------------
>  2 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/include/x86_64/hyperv.h b/tools/testing/selftests/kvm/include/x86_64/hyperv.h
> index f0a8a93694b2..e0a1b4c2fbbc 100644
> --- a/tools/testing/selftests/kvm/include/x86_64/hyperv.h
> +++ b/tools/testing/selftests/kvm/include/x86_64/hyperv.h
> @@ -185,6 +185,21 @@
>  /* hypercall options */
>  #define HV_HYPERCALL_FAST_BIT          BIT(16)
>  
> +static inline u64 hyperv_hypercall(u64 control, vm_vaddr_t input_address,
> +                          vm_vaddr_t output_address)
> +{
> +       u64 hv_status;
> +
> +       asm volatile("mov %3, %%r8\n"
> +                    "vmcall"
> +                    : "=a" (hv_status),
> +                      "+c" (control), "+d" (input_address)
> +                    :  "r" (output_address)
> +                    : "cc", "memory", "r8", "r9", "r10", "r11");
> +
> +       return hv_status;
> +}
> +
>  /* Proper HV_X64_MSR_GUEST_OS_ID value */
>  #define HYPERV_LINUX_OS_ID ((u64)0x8100 << 48)
>  
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_features.c b/tools/testing/selftests/kvm/x86_64/hyperv_features.c
> index 98c020356925..788d570e991e 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_features.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_features.c
> @@ -48,21 +48,6 @@ static void do_wrmsr(u32 idx, u64 val)
>  static int nr_gp;
>  static int nr_ud;
>  
> -static inline u64 hypercall(u64 control, vm_vaddr_t input_address,
> -                           vm_vaddr_t output_address)
> -{
> -       u64 hv_status;
> -
> -       asm volatile("mov %3, %%r8\n"
> -                    "vmcall"
> -                    : "=a" (hv_status),
> -                      "+c" (control), "+d" (input_address)
> -                    :  "r" (output_address)
> -                    : "cc", "memory", "r8", "r9", "r10", "r11");
> -
> -       return hv_status;
> -}
> -
>  static void guest_gp_handler(struct ex_regs *regs)
>  {
>         unsigned char *rip = (unsigned char *)regs->rip;
> @@ -138,7 +123,7 @@ static void guest_hcall(vm_vaddr_t pgs_gpa, struct hcall_data *hcall)
>                         input = output = 0;
>                 }
>  
> -               res = hypercall(hcall->control, input, output);
> +               res = hyperv_hypercall(hcall->control, input, output);
>                 if (hcall->ud_expected)
>                         GUEST_ASSERT(nr_ud == 1);
>                 else

Reviewed-by: Maxim Levitsky <mlevitsk@...hat.com>

Best regards,
	Maxim Levitsky

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ