Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5493550rwb; Wed, 21 Sep 2022 08:31:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5U/8lXNc0gRn2YZLlfRT350Nqt3P3PXG7RRfZ6asSj51NuODYHNu+aGKqluvB0hKvqrsku X-Received: by 2002:a50:ef03:0:b0:44e:82bf:28e6 with SMTP id m3-20020a50ef03000000b0044e82bf28e6mr24424166eds.270.1663774298485; Wed, 21 Sep 2022 08:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663774298; cv=none; d=google.com; s=arc-20160816; b=jfuclod12Ut6RFE9il5C+I30XkwdmZ1PkraxGz87ZgY3yQeDKYXgn0H6Q1Lc6BqUV4 67OQHFpKz0pVFVPsz+HO9Y0C24lyxw26vTW7ehatdkpO+lYaLVV6Nhn50+XSOWjakGz/ AGkgwF+QPpCkcIDWGX8EpHgapRZ2PZSJG5nsZdxJ4aqCpXmUDbGIOIy5FK6wd4zlQAqm tehZptEZpoQH+w8SXER/HxIN7o84Rj0MQ1k2eKWZ3BX2BD4uJdW6slImBvEZdoMGjhOj bAg0yWA+6LRbsN5+pVVubZugRipyXz18aBTF4wRV/o0r4ZGBtwmZXG7GwVQ9MCrfmItP rJ1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aInygM06QUa4QmRLzx52jwNXMriEb4fJkMNpTnzs6dQ=; b=fiXmufmHf/rqnrRdnvnbOUDAgj9M5soTY0F4srKFDs1dB41T6WQKckXhm3N+MI3bLK wX0EBieGjFUfX3+QZWDigzxXKPr21TK01VN1PJhYyeKtS3zDLT3o3FGtjVYdUT49GBrv g3IBh0enm7vxw8+uIodIwRS8EPCRjZRBU32WQ9rPtCyghBr/XVozSQOIVqB4ER64hv4w S/u5EgiggUgHz3v8dEiOLP1ttn3LifjrIzsMebmRS4asQGaYFPDmCE2qriWvI+z/W4eZ b/GQHp4pLUoBnAH09P4SHd7vhXjpFQD92mO2jzBt6SJ67EdarmGM4mIyXeWH/dGjHhY4 9TeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="B/Zdisoy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e11-20020a056402190b00b00451d1712f5dsi3019339edz.40.2022.09.21.08.31.09; Wed, 21 Sep 2022 08:31:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="B/Zdisoy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231408AbiIUP2s (ORCPT + 99 others); Wed, 21 Sep 2022 11:28:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231358AbiIUP12 (ORCPT ); Wed, 21 Sep 2022 11:27:28 -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 ESMTPS id 590D37E82D for ; Wed, 21 Sep 2022 08:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663773951; 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=aInygM06QUa4QmRLzx52jwNXMriEb4fJkMNpTnzs6dQ=; b=B/Zdisoy/AYCoHo1uyUpYvQhm+ru41Zm57hhoe5VMtgj3B9ayzsKlXS3CfUKh1lUvWGmAh +KZ3+0UhnsMksHzL6p1lGjrherTRF6QFA45UOrTljVO6PgXg8Qo26sOFy7JX7OKoBeKPy7 QWQcJz5Vf1q1csq1SSIZ1aMPlW41svc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-457-SwObng1xMxqkJVJrkb9_Pw-1; Wed, 21 Sep 2022 11:25:46 -0400 X-MC-Unique: SwObng1xMxqkJVJrkb9_Pw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 81B5B85A5A6; Wed, 21 Sep 2022 15:25:45 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.194.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC6142166B26; Wed, 21 Sep 2022 15:25:43 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , Yuan Yao , Maxim Levitsky , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v10 25/39] KVM: selftests: Move the function doing Hyper-V hypercall to a common header Date: Wed, 21 Sep 2022 17:24:22 +0200 Message-Id: <20220921152436.3673454-26-vkuznets@redhat.com> In-Reply-To: <20220921152436.3673454-1-vkuznets@redhat.com> References: <20220921152436.3673454-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All Hyper-V specific tests issuing hypercalls need this. Reviewed-by: Maxim Levitsky Signed-off-by: Vitaly Kuznetsov --- .../selftests/kvm/include/x86_64/hyperv.h | 16 ++++++++++++++++ .../selftests/kvm/x86_64/hyperv_features.c | 18 +----------------- 2 files changed, 17 insertions(+), 17 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..285e9ff73573 100644 --- a/tools/testing/selftests/kvm/include/x86_64/hyperv.h +++ b/tools/testing/selftests/kvm/include/x86_64/hyperv.h @@ -185,6 +185,22 @@ /* hypercall options */ #define HV_HYPERCALL_FAST_BIT BIT(16) +static inline uint8_t hyperv_hypercall(u64 control, vm_vaddr_t input_address, + vm_vaddr_t output_address, + uint64_t *hv_status) +{ + uint8_t vector; + /* Note both the hypercall and the "asm safe" clobber r9-r11. */ + asm volatile("mov %[output_address], %%r8\n\t" + KVM_ASM_SAFE("vmcall") + : "=a" (*hv_status), + "+c" (control), "+d" (input_address), + KVM_ASM_SAFE_OUTPUTS(vector) + : [output_address] "r"(output_address) + : "cc", "memory", "r8", KVM_ASM_SAFE_CLOBBERS); + return vector; +} + /* 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 1144bd1ea626..c464d324cde0 100644 --- a/tools/testing/selftests/kvm/x86_64/hyperv_features.c +++ b/tools/testing/selftests/kvm/x86_64/hyperv_features.c @@ -13,22 +13,6 @@ #include "processor.h" #include "hyperv.h" -static inline uint8_t hypercall(u64 control, vm_vaddr_t input_address, - vm_vaddr_t output_address, uint64_t *hv_status) -{ - uint8_t vector; - - /* Note both the hypercall and the "asm safe" clobber r9-r11. */ - asm volatile("mov %[output_address], %%r8\n\t" - KVM_ASM_SAFE("vmcall") - : "=a" (*hv_status), - "+c" (control), "+d" (input_address), - KVM_ASM_SAFE_OUTPUTS(vector) - : [output_address] "r"(output_address) - : "cc", "memory", "r8", KVM_ASM_SAFE_CLOBBERS); - return vector; -} - struct msr_data { uint32_t idx; bool available; @@ -78,7 +62,7 @@ static void guest_hcall(vm_vaddr_t pgs_gpa, struct hcall_data *hcall) input = output = 0; } - vector = hypercall(hcall->control, input, output, &res); + vector = hyperv_hypercall(hcall->control, input, output, &res); if (hcall->ud_expected) GUEST_ASSERT_2(vector == UD_VECTOR, hcall->control, vector); else -- 2.37.3