From patchwork Mon Dec 12 18:37:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vipin Sharma X-Patchwork-Id: 32499 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2402872wrr; Mon, 12 Dec 2022 10:39:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf6VFMzffrcNIyejlwnQQkEM48BlsWxiM2yMC5S8bYN3koRKnte1MGKPNfU3taAS9yIg0cl2 X-Received: by 2002:aa7:db91:0:b0:461:9075:4161 with SMTP id u17-20020aa7db91000000b0046190754161mr13861144edt.15.1670870383334; Mon, 12 Dec 2022 10:39:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670870383; cv=none; d=google.com; s=arc-20160816; b=RnPJvIiL1Q0+BvkDQOpNL9xwAomItJenLqapq6paZj7rvKNRSahhTntcslgD9ZKqce kehYeuk+GZad6fRUz+gqPs1zxck+cCJSkSnIEvrXs5oJFmn+pUyTvakiaH3yY7UVkmAv g4Zn1IScjBVEbok/j3Rm46F3W4LwJ9FJVjYYL1X+MwZNC4kQ4iob5JuOwQg/6nWVj3mM VzrCReo60I4NSSHDgboah3mOqw+aWxt8rnyZCic8Tb1uLapK7KZFQ1xwTJbWSWIgMEcB HZQLpBf8DvsocDsrjt5VUzw1hHxPL16FgLXSrzMc2qUUltW1LBkqPOJtggZ2f2HfczhV pVKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=AQIHU7oFJzfN/dD6MjFy5Gqv9IoHRNmGXG4ddL/MsoE=; b=PU6G32T8kgAkVC5pxHWT2L27pyZVj9Mnn4fDEi0fWi9bMgfEm1e3GW4ypJVkJBG1Gz 9OX/xOHragxgqtqtAcIp8f+Zw0gfKXXGOtaZ9XP9Lv8fqhDDB2ygRmPbEgQklX29EC2/ iPjBgbrP9NI91tmwXM4spoqow0xLegFVsxKcH5co2kvD66XIENppsbUUpzvhDxWDD0Pc vsLp2weWv0txdqPSz3JV2T9B/+Q/20EJ7TZD/87ZqXjcz6RoCwAXfBwqr5eQaDMa7QCn K/NBNstmAyIp10DWVfKImyNv881ZMajQOt0hW/PB/d4sBo3k54hHfgPkWOgPsQEgyj+L oTsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=WZDTp5uH; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s14-20020a50d48e000000b0046ccbb640a3si7586568edi.278.2022.12.12.10.39.20; Mon, 12 Dec 2022 10:39:43 -0800 (PST) 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=@google.com header.s=20210112 header.b=WZDTp5uH; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234065AbiLLSij (ORCPT + 99 others); Mon, 12 Dec 2022 13:38:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233619AbiLLShm (ORCPT ); Mon, 12 Dec 2022 13:37:42 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 955BE29F for ; Mon, 12 Dec 2022 10:37:40 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id u15-20020a170902e5cf00b001899d29276eso11124618plf.10 for ; Mon, 12 Dec 2022 10:37:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=AQIHU7oFJzfN/dD6MjFy5Gqv9IoHRNmGXG4ddL/MsoE=; b=WZDTp5uHSLJqlVqV7BsnAygUubdknMcQxot4GSHCGt3kDvVaGTS5iwHIZaa+KHHOD+ E0fScrJ9kFGJ5yGajKLeL7D6jiQSjkKICmzpbB2fxH+8MZpRY0Ho4p5Bn5WuRqgekZZC G1eeE7pEdWgfx2P7ylueHxelrEwP5Gog/R8nKds+Zi7kKsHWpPMxUYEXgC9zSRSSru8q Q92QHA+M3D0svZUKyV6pK6QnTRdKWicJuMh6rqM0/7nWtkw0QA+rk7a8HtRtoN9ucGKv wEtbnGLTRRBnOrWXjAJfnlerqZHWtJeEGj80PqCqsmPT8Lsz49gv6vS17ePpQoa6VAJn Dv3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AQIHU7oFJzfN/dD6MjFy5Gqv9IoHRNmGXG4ddL/MsoE=; b=YouNuG4N585EDcVouTWXLo574VnnX3y3WFGwXsVyqdC8zSvQsX2yiYuds+dFBhXMCD 2RNX3ojvTzfcxLr6Jhxzr3HBydqdjbv2ueGhfyd5PpwIOOi95+eq/Z0oX2A9G0HePhvR fhQGI367h9oqwWsDfUotLqHrLGeDo5XTg8hoOmswTwlrj4hLn5NFd2fSiAQ92R1Qdwpw vqhl5YueQ/odTCRDqGJ7Yq67oOeaydoKc2oTlpVGg+uhBwDnWkv3GxEF0oqNR0e7+DZT 7CMnIlVCZGoDm/tdPwga07hty/7PAuv1LZLr74YaOAsUCv4/Z+L02N1khG0PBFUTAckr jiGw== X-Gm-Message-State: ANoB5pnPvahPxrhOe/vusbw/4H6a0TZcbSaX3bY0p7TE6arwui7lJNIt ScQMAjjvgjzs2FAqDJBekvGCl04k9PpA X-Received: from vipin.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:479f]) (user=vipinsh job=sendgmr) by 2002:a17:90a:fa46:b0:200:1df3:a7a9 with SMTP id dt6-20020a17090afa4600b002001df3a7a9mr108504791pjb.202.1670870260194; Mon, 12 Dec 2022 10:37:40 -0800 (PST) Date: Mon, 12 Dec 2022 10:37:17 -0800 In-Reply-To: <20221212183720.4062037-1-vipinsh@google.com> Mime-Version: 1.0 References: <20221212183720.4062037-1-vipinsh@google.com> X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-goog Message-ID: <20221212183720.4062037-11-vipinsh@google.com> Subject: [Patch v4 10/13] KVM: selftests: Test Hyper-V extended hypercall enablement From: Vipin Sharma To: seanjc@google.com, pbonzini@redhat.com, vkuznets@redhat.com, dmatlack@google.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Vipin Sharma X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752034583108768787?= X-GMAIL-MSGID: =?utf-8?q?1752034583108768787?= Test Hyper-V extended hypercall, HV_EXT_CALL_QUERY_CAPABILITIES (0x8001), access denied and invalid parameter cases. Access is denied if CPUID.0x40000003.EBX BIT(20) is not set. Invalid parameter if call has fast bit set. Signed-off-by: Vipin Sharma --- tools/testing/selftests/kvm/include/x86_64/hyperv.h | 5 +++++ tools/testing/selftests/kvm/x86_64/hyperv_features.c | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/tools/testing/selftests/kvm/include/x86_64/hyperv.h b/tools/testing/selftests/kvm/include/x86_64/hyperv.h index 28eb99046475..fa65b908b13e 100644 --- a/tools/testing/selftests/kvm/include/x86_64/hyperv.h +++ b/tools/testing/selftests/kvm/include/x86_64/hyperv.h @@ -137,6 +137,8 @@ KVM_X86_CPU_FEATURE(HYPERV_CPUID_FEATURES, 0, EBX, 11) #define HV_CPU_MANAGEMENT \ KVM_X86_CPU_FEATURE(HYPERV_CPUID_FEATURES, 0, EBX, 12) +#define HV_ENABLE_EXTENDED_HYPERCALLS \ + KVM_X86_CPU_FEATURE(HYPERV_CPUID_FEATURES, 0, EBX, 20) #define HV_ISOLATION \ KVM_X86_CPU_FEATURE(HYPERV_CPUID_FEATURES, 0, EBX, 22) @@ -213,6 +215,9 @@ #define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af #define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_LIST 0x00b0 +/* Extended hypercalls */ +#define HV_EXT_CALL_QUERY_CAPABILITIES 0x8001 + #define HV_FLUSH_ALL_PROCESSORS BIT(0) #define HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES BIT(1) #define HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY BIT(2) diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_features.c b/tools/testing/selftests/kvm/x86_64/hyperv_features.c index 258267df8e2a..c5e3b39edd07 100644 --- a/tools/testing/selftests/kvm/x86_64/hyperv_features.c +++ b/tools/testing/selftests/kvm/x86_64/hyperv_features.c @@ -649,6 +649,15 @@ static void guest_test_hcalls_access(void) hcall->expect = HV_STATUS_SUCCESS; break; case 19: + hcall->control = HV_EXT_CALL_QUERY_CAPABILITIES; + hcall->expect = HV_STATUS_ACCESS_DENIED; + break; + case 20: + vcpu_set_cpuid_feature(vcpu, HV_ENABLE_EXTENDED_HYPERCALLS); + hcall->control = HV_EXT_CALL_QUERY_CAPABILITIES | HV_HYPERCALL_FAST_BIT; + hcall->expect = HV_STATUS_INVALID_PARAMETER; + break; + case 21: kvm_vm_free(vm); return; }