From patchwork Thu Oct 6 00:34:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 1686547 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=mdsIbapz; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=F2g4wdl3; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MjXWl1xHxz20Pd for ; Thu, 6 Oct 2022 11:34:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :Mime-Version:Date:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=YwPAyLWcMSuyq1CdImEOuhZLka7VFiZfpuhNub/WzQY=; b=mdsIbapz0PBPQY h0+k1rbbCG46oxZNwkTL+uB8i/7DsVLtut+alzAblWNsCOykfeYyAfFhU3zp7NNAj0e4CkvCCMUjt M7K25+ynS4k+Nq4fEhZqHCYsXuiNoV/4FBJ5xntWH70A9GtHtCDqfMB2HY4qN9bFRGPpaLoVxi0FJ gCWQGFAJW3tYDQp+YwaI3/EjXry43TlMGy433cVpCtUnJkLxroi5XTp5AWFKPpI7T+EXZJmHQX/K1 lwN9rREYSm+oRcXv8wvb38X1bQgKaxuS567W3arzTZeylV4jd0loLOs8T4t4O30Za9iNpD1gac2Vd WwZvF5t6IutXxLQUCFpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogEqU-00GdEl-SE; Thu, 06 Oct 2022 00:34:38 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogEqC-00Gczw-6n for kvm-riscv@lists.infradead.org; Thu, 06 Oct 2022 00:34:22 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-3538689fc60so4231087b3.3 for ; Wed, 05 Oct 2022 17:34:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=aS/Wdb92KUsn+dSQWf+yYhnYTdFnVqHuKhKCKXyH9JU=; b=F2g4wdl3c+W55IiNBL1XgO+YOlTtL/Cjx1CGVdwkn3nnZikiuEYRXFu5+yxq8XvD8Q UnKjxO/Ihl2o7nKCs3Fyoj+597+kBPoBQydqP9spHLrAFp/AZkuV37eBUc24VeghkL8e haVbAgTXMwnfUeqSyaf7Qwgnc7VBxGWvMqqr4+HraCL4gw0nLFgfcM8h2qRhivdOmTbl xQjAAvTL/Xx+nRVqFB2hx/oPVgCumgax0xpgJ8zPH4AnDa+A0Era8LoseKjRTriNUs2+ 2sp1R3eQ6bZssw7ySWObtNTOd4+HTkPE6I6ZntqOMrN6qr4SUaYKMJUhxZG0gWES5RFm M2Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aS/Wdb92KUsn+dSQWf+yYhnYTdFnVqHuKhKCKXyH9JU=; b=Ci3HBsAJ7U/kkeaRuDhPJqkOBunxmEiSfj+9q5XJnMvLWqIur2NQR9osZ384DLME2H TjuqalgVchda9rhPqNdk98oJbZ3jihEGwxwv+nHC2GPsVn1IcbH6UR5zEJvCLHsDDLzd XrMqbjeZyutcu16q1hev0dQDW+QmK+KtYjFhsp5rPMxsiD20nwD5iOzcWUI6G7QddG3J E9XfuDjmyaOW7bl3s7mdOVAXgpFPAkcqfW+8VccTbLqSvA3LuM0GO3rNk2xkLPZzl+z7 3aMI64gS0Z8hafCNP0cyFppXrv4veYkQnl+hoNxAj6AZSrPul+YmSF9C5u3lMvTi8YgL 2xRg== X-Gm-Message-State: ACrzQf1niWwKk40c2ixk+Sb3g9XsvYOIPhFG1GQqrEkWsCvSwLW3yRCS QMZ+8Ab0J+MqH82g9ZgPUVfNgoyWa5Q= X-Google-Smtp-Source: AMsMyM5GoF0VwOlSnE1/Af4DhxMzGTCQS3omOdlhLBZkXBmerEM6VVh7882ZBLcBagfLbnLAIrgnQoTB6v4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:ad13:0:b0:6bd:9745:a428 with SMTP id y19-20020a25ad13000000b006bd9745a428mr2331326ybi.563.1665016454054; Wed, 05 Oct 2022 17:34:14 -0700 (PDT) Date: Thu, 6 Oct 2022 00:34:02 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog Message-ID: <20221006003409.649993-1-seanjc@google.com> Subject: [PATCH v6 0/7] KVM: selftests: Implement ucall "pool" (for SEV) From: Sean Christopherson To: Paolo Bonzini , Shuah Khan , Marc Zyngier , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Nathan Chancellor , Nick Desaulniers Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Atish Patra , David Hildenbrand , Tom Rix , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, llvm@lists.linux.dev, Colton Lewis , Andrew Jones , Peter Gonda , Sean Christopherson X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221005_173420_270781_BD40C21E X-CRM114-Status: UNSURE ( 9.02 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -7.7 (-------) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Rework the ucall infrastructure to use a pool of ucall structs to pass memory instead of using the guest's stack. For confidential VMs with encrypted memory, e.g. SEV, the guest's stack "needs" to be [...] Content analysis details: (-7.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1149 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_MED DKIMwl.org - Medium trust sender X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Rework the ucall infrastructure to use a pool of ucall structs to pass memory instead of using the guest's stack. For confidential VMs with encrypted memory, e.g. SEV, the guest's stack "needs" to be private memory and so can't be used to communicate with the host. Convert all implementations to the pool as all of the complexity is hidden in common code, and supporting multiple interfaces adds its own kind of complexity. v6: - Collect tags. [Andrew, Peter] - Drop an unnecessary NULL check on in_use. [Andrew] v5: - Use less convoluted method of writing per-VM "globals". [Oliver] - Add patch to drop ucall_uninit(). v4: https://lore.kernel.org/all/20220824032115.3563686-1-seanjc@google.com Peter Gonda (2): tools: Add atomic_test_and_set_bit() KVM: selftests: Add ucall pool based implementation Sean Christopherson (5): KVM: selftests: Consolidate common code for populating ucall struct KVM: selftests: Consolidate boilerplate code in get_ucall() KVM: selftests: Automatically do init_ucall() for non-barebones VMs KVM: selftests: Make arm64's MMIO ucall multi-VM friendly KVM: selftest: Drop now-unnecessary ucall_uninit() tools/arch/x86/include/asm/atomic.h | 7 ++ tools/include/asm-generic/atomic-gcc.h | 12 ++ tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/aarch64/arch_timer.c | 1 - .../selftests/kvm/aarch64/debug-exceptions.c | 1 - .../selftests/kvm/aarch64/hypercalls.c | 1 - .../testing/selftests/kvm/aarch64/psci_test.c | 1 - .../testing/selftests/kvm/aarch64/vgic_init.c | 2 - .../testing/selftests/kvm/aarch64/vgic_irq.c | 1 - tools/testing/selftests/kvm/dirty_log_test.c | 3 - .../selftests/kvm/include/kvm_util_base.h | 15 +++ .../selftests/kvm/include/ucall_common.h | 10 +- .../selftests/kvm/kvm_page_table_test.c | 2 - .../testing/selftests/kvm/lib/aarch64/ucall.c | 102 +++-------------- tools/testing/selftests/kvm/lib/kvm_util.c | 11 ++ .../selftests/kvm/lib/perf_test_util.c | 3 - tools/testing/selftests/kvm/lib/riscv/ucall.c | 42 +------ tools/testing/selftests/kvm/lib/s390x/ucall.c | 39 +------ .../testing/selftests/kvm/lib/ucall_common.c | 103 ++++++++++++++++++ .../testing/selftests/kvm/lib/x86_64/ucall.c | 39 +------ .../testing/selftests/kvm/memslot_perf_test.c | 1 - tools/testing/selftests/kvm/rseq_test.c | 1 - tools/testing/selftests/kvm/steal_time.c | 1 - .../kvm/system_counter_offset_test.c | 1 - 24 files changed, 190 insertions(+), 210 deletions(-) create mode 100644 tools/testing/selftests/kvm/lib/ucall_common.c base-commit: e18d6152ff0f41b7f01f9817372022df04e0d354