Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1140265rwe; Thu, 25 Aug 2022 16:43:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR4otD5l0Oq51kjrUupqxPLPPxuCbm2E+Moux4Fqgboy5yu9qWJlZm3j/TLY4uOnuj4M4WKs X-Received: by 2002:a17:907:7632:b0:73d:c346:de57 with SMTP id jy18-20020a170907763200b0073dc346de57mr3924205ejc.647.1661471014972; Thu, 25 Aug 2022 16:43:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661471014; cv=none; d=google.com; s=arc-20160816; b=kQBGdXl+Hbo8vJJf3pNC3bm8cRmOAdJrqaEf9l+juv4/LqEzNXKJeHLsOrEylqGkjW gIITcx5aBQR8VsFevkKSreYxxrfkpRj0m/haKTzy2VyZDAyDfGguvwPEsHs7HphkEYBG +0EZYL8gHB/rVVwmDUvH05mKNP2XmbUS+B714Rm0yXyVGyzthWhGAdEaFHTpfkKNYOVv tQgKOGGzk+qXeCrH6wq+m3w4ASCy9ROiX+HD/qT2HL0oS9ZZ11HpOG+bUndibCWI39Nt QI/tMAZ/M+hAfoXw1heQu0z3y6NyQDn2yyDvt/bXISKwuAIFnjSP6/GtpOmr0gUV4V0k itCQ== 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:mime-version:date :reply-to:dkim-signature; bh=y2TyZVHOzKZlb9wECS9yMCNcXCNpwqCPWpTxl29+IMY=; b=kW4Q52KkQDqKpPEoU7H6c6JH0o6ieqM3edWEGfJkv3R7LZRtP8sygXB/+Kj0Z/Lebt B+BAEfZBklqaB+td/R8mjH2xR9LpYBctjrGGmjgPQ/x5rbWhmpX5og7rGltfDzdczmXv UrVPvZ83OduN/UcS8A78qotJjsuS51NEsrzG32sf8fe4VizkVX2p/uXNoufkmxKRTa9+ oLslLtCI19zLCAiJPxNWCtxzzYTSJvvgQ7ghSrwKMI3NJyIoWws7jYIRAmqQTX7zQKyi 3iPqKC/W+zterEQtzJ0K4CQQyu9xJBuBx7L9VysLGqQfbRHkWGS2HHWrysWwre19ry8X 9jGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=dkM+A09p; 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 ga41-20020a1709070c2900b007316cc1113asi299705ejc.910.2022.08.25.16.43.09; Thu, 25 Aug 2022 16:43:34 -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=20210112 header.b=dkM+A09p; 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 S244312AbiHYXZd (ORCPT + 99 others); Thu, 25 Aug 2022 19:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244332AbiHYXZ1 (ORCPT ); Thu, 25 Aug 2022 19:25:27 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56A0852468 for ; Thu, 25 Aug 2022 16:25:25 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-336c3b72da5so359646607b3.6 for ; Thu, 25 Aug 2022 16:25:25 -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; bh=y2TyZVHOzKZlb9wECS9yMCNcXCNpwqCPWpTxl29+IMY=; b=dkM+A09pjx32V3tjxCAZAaj4iTr2QWwZFTx14MwcUXXnZscAY3fsOcj6h5WXQXxdoD pE2ASAcwod4FD0N0sCT4FjUT0tg9Opertqs8xb3KgjTkUGEmN0krLyCYuuqUGRjMcltU i55uCtWc8Su1TGA6H/a9JTuhvCJcNgBM50Y1A4ihMCdqTUfplBKQUaiEUX2n1Vh4N710 3yOt5OJYxOGq7VwXawE8F72ZOkRT8JCFAjGnVJAcUhtb87iwBUwK1cOzoECBWrP6U0Ke ZtEkGqxLhvl3GVE9ZNy1Tt1CBoQxoOnHS9H5jY9/byfHRVWvrd+Zhz17D7ZlFyP3ffIM c1wA== 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; bh=y2TyZVHOzKZlb9wECS9yMCNcXCNpwqCPWpTxl29+IMY=; b=qgaq2RNL4s/VPY6jb3PH22yivl7wFHT1krjZ1otLQYFwI/wawBkh2n537sh9Wg9ezU T6HaRRAkZ5qfqF58cTajiZoolYVcP0bqDqA7AwYj7J0xoKNk3NM4LjOeZeJLySBy1lef ruCIg4FxbZjjGU7IueM+3XDBkxaG5u8B8DLTwb+L5zrGNtwSO9yk3fMZpoRm05Z9wlzP DdNDXhU384kq8NYcuwrG2L3TmRls0gavdYfUys5Fypw8c5U+/vqiO0VXNaL6TNUGDxT/ 5ZkgJ0VZGQW1akxfJx0cLgu4jEQshkBqrsqsqHNLeaBUtWSlCZn4p1BEaDAOS0aAGrHm IwVQ== X-Gm-Message-State: ACgBeo0dqA+XzYZFSLRosLVX3gG8xljMrlm7vh9I6fQgwbBy8kok2dQA JdzXIkx0IvfoKDcztjk+c+iTl03QMPM= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:6143:0:b0:335:3076:168e with SMTP id v64-20020a816143000000b003353076168emr5851445ywb.460.1661469924695; Thu, 25 Aug 2022 16:25:24 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 25 Aug 2022 23:25:15 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog Message-ID: <20220825232522.3997340-1-seanjc@google.com> Subject: [PATCH v5 0/7] KVM: selftests: Implement ucall "pool" (for SEV) From: Sean Christopherson To: Paolo Bonzini , 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 , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Colton Lewis , Peter Gonda , Andrew Jones , Sean Christopherson 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=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 Non-KVM folks, y'all got pulled in because of the atomic_test_and_set_bit() patch. 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. Tested on x86 and ARM, compile tested on s390 and RISC-V. 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 | 102 ++++++++++++++++++ .../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, 189 insertions(+), 210 deletions(-) create mode 100644 tools/testing/selftests/kvm/lib/ucall_common.c base-commit: 372d07084593dc7a399bf9bee815711b1fb1bcf2 -- 2.37.2.672.g94769d06f0-goog