From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 476CFC43334 for ; Tue, 7 Jun 2022 10:04:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240609AbiFGKED (ORCPT ); Tue, 7 Jun 2022 06:04:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240623AbiFGKDz (ORCPT ); Tue, 7 Jun 2022 06:03:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 09948D02A3 for ; Tue, 7 Jun 2022 03:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654596232; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ap/ea5Xnr5bNkYBc/gjvXLi7f8rQXdBfxSXXArkzhjs=; b=Cj4lH2wLIL1d/CAIbZEZZEQD7/IKOMAK9RfVYykWZvzeMBtFs7sIiYKAT9vJSc0iL1k/xO 2X4I7+flB8H+TzkEN3v1gAsHrSAXVzeizmrXrjNexdnw3N08bZ5PkMEt8moZ91GvSx+VUN FcxykPYtElkpMXFGx9c+APNutPKcFn8= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-349-7RpuEZibMSehyPzWQnZJnQ-1; Tue, 07 Jun 2022 06:03:51 -0400 X-MC-Unique: 7RpuEZibMSehyPzWQnZJnQ-1 Received: by mail-qk1-f198.google.com with SMTP id bs39-20020a05620a472700b006a6772a6cb3so11730188qkb.14 for ; Tue, 07 Jun 2022 03:03:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=Ap/ea5Xnr5bNkYBc/gjvXLi7f8rQXdBfxSXXArkzhjs=; b=p9kCUVfnKMYZ5zg90ftWUrMde7IONKOICXOvShUvc5bAZRTsJEsLHfs0ai1bUt6zVH d58CEVEZLTnqYC6qAy9JEoztgmg01FhlJunTrTgXLxxGCdAsUH4DkIkTB+PY5SKY9Eja YM+tp/tlBhl42Cuqb0sOfdYFunT3VTfhvesdTdolZt3gtFETq+MqWBP2XjsUaGJp7lb8 hNQ4DVl4fT6IfPwbOtBbFMKoPoC0o9J4Lu5TQeEjYfYeTw4+hiHBkhLfwbgmC2BfjDGT 4AQ3L/lh4q7fvmiUQwR94PpeQVs3vHz93eVPy6dYtHqIF+qEq8V3BRr0+U5XdVaEXiJ3 B94A== X-Gm-Message-State: AOAM530eagzFqkaQjSMLBDYpMoaPc6tvZbLnFZ/ZGICetmmpgAhYQWEV I7nbzTHe1Bmkf9D4nEhvujScZw/tPdcn1PCOIOZW/wn1f924mRA6fhP4PR3trUpZMSKMks0MGQT TO+42aGnSPc4GEV+KOK/Zom7y X-Received: by 2002:a05:620a:1672:b0:6a6:b0de:88ae with SMTP id d18-20020a05620a167200b006a6b0de88aemr9502579qko.191.1654596230527; Tue, 07 Jun 2022 03:03:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL+Lux3U2smt/hKL3cajilOIB0if6MIVkVQu0anbpTi9HYKO5N42NE8prEF5fx5vOtIZXOyg== X-Received: by 2002:a05:620a:1672:b0:6a6:b0de:88ae with SMTP id d18-20020a05620a167200b006a6b0de88aemr9502564qko.191.1654596230302; Tue, 07 Jun 2022 03:03:50 -0700 (PDT) Received: from [10.35.4.238] (bzq-82-81-161-50.red.bezeqint.net. [82.81.161.50]) by smtp.gmail.com with ESMTPSA id h10-20020a05620a284a00b006a6e13e2b4bsm794500qkp.24.2022.06.07.03.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 03:03:49 -0700 (PDT) Message-ID: <42de55976d158eb34fe97595d4509c4de28771b7.camel@redhat.com> Subject: Re: [PATCH v6 26/38] KVM: selftests: Move the function doing Hyper-V hypercall to a common header From: Maxim Levitsky To: Vitaly Kuznetsov , kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , Yuan Yao , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 07 Jun 2022 13:03:46 +0300 In-Reply-To: <20220606083655.2014609-27-vkuznets@redhat.com> References: <20220606083655.2014609-1-vkuznets@redhat.com> <20220606083655.2014609-27-vkuznets@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-2.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- >  .../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 Best regards, Maxim Levitsky