Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1662188rdf; Sun, 5 Nov 2023 08:36:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYeYxcYKQTpMVAE6WbZZddXCp+y0rcfHbJoaBPuY+lo52/E8pmaCstSof4jI3/jSMb3gXB X-Received: by 2002:a05:6a00:158f:b0:690:fe13:1d28 with SMTP id u15-20020a056a00158f00b00690fe131d28mr33480640pfk.33.1699202170590; Sun, 05 Nov 2023 08:36:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699202170; cv=none; d=google.com; s=arc-20160816; b=Wnks107bGibhZHJWrIE9BpRLa1HT/b+pnzZq9xlB9e68OBz7WuX/akl3EiUZzVD6+U cHyZgty13xJJBYQWzSCPbzrEc2wC0AhrTcBUAY3pV5e+o/QS6+a7kVJMidnJwZ6p1KPH dogBSqb5mGccDmrNu47B5XTmSlnLucS7/h3EOedwSW7G5v5xRvDeV9Vh+s9wAYQ1VQPs kJ9qHq4/3RvEuAOLusWOAtDU0V70JFSl6a+DKL8XPcanRSdASZykywPfeQwxBtHVzjqr c1yCyRa84UOH5MVXuVdx46Kzuu65q6r3aj51w/W/u4jXmkHdldUvqPLAEDQ19mStMoO0 UtKw== 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=bLOqqs5CF8yk4LC9a+1vwMzoSy4qflmSUsjtCkwDz0I=; fh=HrMuB0qA2qw4RqBwyiyN+RBlGw+Ob1hcALwHW/PphXs=; b=f4wkinrruiY2PWzPs/OK0wkUrv5lXo3/wexireyPO4jBtEE8UpEH8/kJV+fiZkVE1Z FRBCuJ4P0KSIr8cBuSgKCrF5nNyYU+VtVmaFRYpfXqsvcsmQc8ii0hKlurQ/OcD1YUBC kuf4GV1edZKZA0hLlueZASsINM4ifwn49P+d6oK1KpasbF2DLEQ8KMrfqLhOwjp6aNQV juEWKZwT6TdzUQE65PukAWDyk59d7YmSqdGzRnkO2NiERZVx+srQU6CGjcY6NX0+VqFq MohbUxndsAIUcA5F82NV0fxhbLOTbwKYQherR7NK0tpYJ/36N3bRk6qAFxveB70os/+y D/EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C2TjZUkk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id p19-20020a056a000a1300b006b8b194005fsi6359770pfh.256.2023.11.05.08.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 08:36:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C2TjZUkk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9EC5B8045961; Sun, 5 Nov 2023 08:36:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230483AbjKEQgG (ORCPT + 99 others); Sun, 5 Nov 2023 11:36:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229954AbjKEQfl (ORCPT ); Sun, 5 Nov 2023 11:35:41 -0500 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 335DB19A7 for ; Sun, 5 Nov 2023 08:34:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699202057; 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=bLOqqs5CF8yk4LC9a+1vwMzoSy4qflmSUsjtCkwDz0I=; b=C2TjZUkkagdZTuzQJYta05l7kMuZsAh1pXg8CIAGpo21orMO0inQrF8pl8xfUJEpl4NbeO JySPHdoMECmwCFCotlM94aF5Bu4rp3uvcI3+rONGHt5i1Pnh2OzDlpI25DgecnlqLbxXS5 Vz5ep5I9E/W2AXZIDl7JgOAK8Y6Yj7Q= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-609-RNp8mDoTP1q6dpHOGd7mDg-1; Sun, 05 Nov 2023 11:34:13 -0500 X-MC-Unique: RNp8mDoTP1q6dpHOGd7mDg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A0FE33C0FC8E; Sun, 5 Nov 2023 16:34:11 +0000 (UTC) Received: from avogadro.redhat.com (unknown [10.39.192.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id E29DF2166B26; Sun, 5 Nov 2023 16:34:04 +0000 (UTC) From: Paolo Bonzini To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Sean Christopherson , Alexander Viro , Christian Brauner , "Matthew Wilcox (Oracle)" , Andrew Morton 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-kernel@vger.kernel.org, Xiaoyao Li , Xu Yilun , Chao Peng , Fuad Tabba , Jarkko Sakkinen , Anish Moorthy , David Matlack , Yu Zhang , Isaku Yamahata , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A. Shutemov" Subject: [PATCH 26/34] KVM: selftests: Add helpers to do KVM_HC_MAP_GPA_RANGE hypercalls (x86) Date: Sun, 5 Nov 2023 17:30:29 +0100 Message-ID: <20231105163040.14904-27-pbonzini@redhat.com> In-Reply-To: <20231105163040.14904-1-pbonzini@redhat.com> References: <20231105163040.14904-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 05 Nov 2023 08:36:09 -0800 (PST) From: Vishal Annapurve Add helpers for x86 guests to invoke the KVM_HC_MAP_GPA_RANGE hypercall, which KVM will forward to userspace and thus can be used by tests to coordinate private<=>shared conversions between host userspace code and guest code. Signed-off-by: Vishal Annapurve [sean: drop shared/private helpers (let tests specify flags)] Signed-off-by: Sean Christopherson Message-Id: <20231027182217.3615211-29-seanjc@google.com> Signed-off-by: Paolo Bonzini --- .../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 25bc61dac5fb..a84863503fcb 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" @@ -1194,6 +1195,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(!ret); +} + void __vm_xsave_require_permission(uint64_t xfeature, const char *name); #define vm_xsave_require_permission(xfeature) \ -- 2.39.1