Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7516551rwp; Tue, 18 Jul 2023 17:10:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlEBOlEqUqLH0a/I0gpkRevP+y5y8TS0r6Fkbx5aI5j5ZGRGKO4Oe74JVbNndcnX/SgB3lSl X-Received: by 2002:a17:90a:dd93:b0:263:4962:94c6 with SMTP id l19-20020a17090add9300b00263496294c6mr15152264pjv.20.1689725444239; Tue, 18 Jul 2023 17:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689725444; cv=none; d=google.com; s=arc-20160816; b=ORlvTsZ2Dr8rjn2ht6KgyHVi5tm+GBsL7c7u3BVno5cIWmpMxlIdbJXS8fsRZbEtMd s1JYpCH0tDtHKuPLvKZlHDFd183ReY7urdcHfY4IB/4T9f6C8Ont6GrU/35LLirMPUVJ /KUM9yZJxO+thdEqz+4R4RprWFoC3cfebyQwPqYIp3OmH3qgTDK00tKwS1O7yXeGDDFO VoIQpx5rTFwwBMQIvLDVpoiE+3JqUDDnW8gfIQp69Bh03Af1etUImfiAbshhDGWc5LCW T6M2BzUoI3vGXj+DlsfYamML/n3mYpCfbaFkrQKw38RgBOouf6U0iBsoWBhOu9bCBbyP wbcw== 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:reply-to:dkim-signature; bh=JHyOFUOJNrHCsG8hxo3NWWS2w8rJ24DtuKIoDCRGyag=; fh=D6d5aNryYQiYyjenfSFWOT3594jRd4xJmyqVXmIxeQo=; b=v0r2AYLeca8oe4HTB5/zpmo0QlAb+z5s2xmbrNO8XQOTeqM2ZMKJc8KB91tydjrhVT 2pZFpk86P3HFfxaqzNwSDtlw3mZrQg8TKseV59hFDiszv6wZmurqsLzO//2DV9aN9K03 sXFAtfJ0UsjBSo6Z3wN+t77Z72MGQDjUzke4fiR6IzXKsTKx2bz9xzqRq+8IXESscMXb 2Bc8q9Ts5KsEOBE5gui0bgfvCttIZsmGODqwSrd10RCAmXqVJzm+5NELh9syB3ZF5/zP izOzuTh39WqkTmANOrwAKSSMaTYE2Si21fwkPscCaRRcEslq6adqqexdwOhRK5nBkkjQ 9egw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=xEjga5Lw; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c5-20020a17090ad90500b0025ea1c0edb1si258261pjv.146.2023.07.18.17.10.32; Tue, 18 Jul 2023 17:10:44 -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=@google.com header.s=20221208 header.b=xEjga5Lw; 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 S230242AbjGRXxA (ORCPT + 99 others); Tue, 18 Jul 2023 19:53:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231455AbjGRXve (ORCPT ); Tue, 18 Jul 2023 19:51:34 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 849F51FC7 for ; Tue, 18 Jul 2023 16:49:56 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-c6dd0e46a52so5463133276.2 for ; Tue, 18 Jul 2023 16:49:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689724154; x=1692316154; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=JHyOFUOJNrHCsG8hxo3NWWS2w8rJ24DtuKIoDCRGyag=; b=xEjga5LwPPSSdY8SIx3jyoncD3GGf3WPGooyrkM0KnahhnaL4mCb4YwQt0GO0HS22c NEcfXNGBndDk4nsku/Y91YS1hHA5MX/cUUC80CuRLM1bK9lLy4VQpDRd1Xi2xWiJI6o1 9/UCIe7gQuFQ2+gvKJ9C6ii8/xbm2jFSze0SQ3v0PRjd1NOqJPDidQ7wUtuL19wRUrTE yGaIkqqRPEKiBe0hyG7ZRrXgE8SEXgjc2KYKv831pMLCu06jrX+LffHvzIu5EPSPB+OK JqyI7fhSc4r9xeqc00aXehzDSyLGCvqUsUwXUuUYEMMNJQvdcAepZR51lMeVVKDz3MhJ Gd2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689724154; x=1692316154; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JHyOFUOJNrHCsG8hxo3NWWS2w8rJ24DtuKIoDCRGyag=; b=TzO+RvoNL3p+KbJGCBCk8RlHG8ZFhmEBb08SsePjHFFVz6T0AhIuV2In3RMlrFAoQ3 OvaqCrPhdiK3RnYG51nhsF8IiZ/oIorUdcBR9Ktx3Cor2cZI0ezJPDHQMxaFN33p8U0E jVNS1Xh8IK24F1zV29lVj0BVHxY0XgRst09OWxmxX8qy3i+RUIUxeOGnVcEccGQKFSqs Zn3UyEjcZMV0ij7FWOrTizoafaJqJ2RT6biMSXEAroeZ0aK3sYC8biAJbvwvlvDAP6Dt oCP3aY1r6Uyly8GAt2Z/uxY2TaM9hNin8SJa4JfwelHoyRmitRtAhs0G8I5c9J+ttu92 SsDA== X-Gm-Message-State: ABy/qLai/P5PxVu908zV5sDvzIjMaL0r94e7BatrxJ3vPMq77tYoDrX8 91FGgvWPmnrr0C4APlRlBGNZnkDAGa4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:a021:0:b0:cf2:9e82:a5b5 with SMTP id x30-20020a25a021000000b00cf29e82a5b5mr7746ybh.8.1689724154115; Tue, 18 Jul 2023 16:49:14 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 18 Jul 2023 16:45:05 -0700 In-Reply-To: <20230718234512.1690985-1-seanjc@google.com> Mime-Version: 1.0 References: <20230718234512.1690985-1-seanjc@google.com> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog Message-ID: <20230718234512.1690985-23-seanjc@google.com> Subject: [RFC PATCH v11 22/29] KVM: selftests: Add helpers to do KVM_HC_MAP_GPA_RANGE hypercalls (x86) From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Sean Christopherson , "Matthew Wilcox (Oracle)" , Andrew Morton , Paul Moore , James Morris , "Serge E. Hallyn" Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Chao Peng , Fuad Tabba , Jarkko Sakkinen , Yu Zhang , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , Vlastimil Babka , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" Content-Type: text/plain; charset="UTF-8" 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,T_SCC_BODY_TEXT_LINE,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 From: Vishal Annapurve Signed-off-by: Vishal Annapurve [sean: drop shared/private helpers (let tests specify flags)] Signed-off-by: Sean Christopherson --- .../selftests/kvm/include/x86_64/processor.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h index aa434c8f19c5..8857143d400a 100644 --- a/tools/testing/selftests/kvm/include/x86_64/processor.h +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h @@ -15,6 +15,7 @@ #include #include +#include #include #include "../kvm_util.h" @@ -1166,6 +1167,20 @@ uint64_t kvm_hypercall(uint64_t nr, uint64_t a0, uint64_t a1, uint64_t a2, uint64_t __xen_hypercall(uint64_t nr, uint64_t a0, void *a1); void xen_hypercall(uint64_t nr, uint64_t a0, void *a1); +static inline uint64_t __kvm_hypercall_map_gpa_range(uint64_t gpa, + uint64_t size, uint64_t flags) +{ + return kvm_hypercall(KVM_HC_MAP_GPA_RANGE, gpa, size >> PAGE_SHIFT, flags, 0); +} + +static inline void kvm_hypercall_map_gpa_range(uint64_t gpa, uint64_t size, + uint64_t flags) +{ + uint64_t ret = __kvm_hypercall_map_gpa_range(gpa, size, flags); + + GUEST_ASSERT_1(!ret, ret); +} + void __vm_xsave_require_permission(uint64_t xfeature, const char *name); #define vm_xsave_require_permission(xfeature) \ -- 2.41.0.255.g8b1d071c50-goog