Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp875776lqc; Fri, 8 Mar 2024 14:39:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUwva2eMe67ueEe3bDYkTbCy3K81n6G/qfhdpwPLa2d3RRQ44i95Q4fqcM7ZwiweeZdFaGTnY1nUIniyzdkh5xRt3Xt3CZ2wWVxIeLmjg== X-Google-Smtp-Source: AGHT+IHRw6q6YHNNDBS86n3YNg1TWeQfmcYcwf7MZUYFyDLlbaT3fxSbb1oIuvo41lmus+3l9jE6 X-Received: by 2002:ad4:4e4e:0:b0:690:4695:326b with SMTP id eb14-20020ad44e4e000000b006904695326bmr371424qvb.64.1709937556260; Fri, 08 Mar 2024 14:39:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709937556; cv=pass; d=google.com; s=arc-20160816; b=R5tKgxXlpjKiTywSQZ8gYhgo58Gkdx8UvVI4jAp3Aqcxo6dHBr6zu71lOKb5wEJoh6 nC58uSVuwHvUfcLDSWl11sF72FSsbQ5/W2ZnyBr8XDGkJWf1gMm5zdflYrkOSiD4inAf RQRhmvevEuIJenLgZ2WitAwIO9Z3s0TSrdrFv4qzB0UPQnkxDbR4t2DtV4gtbROGCtB0 LZzVlOHcgVy1uk8Z4AW1ZTtXPdxlBRrxB37Ch4UZg0v1Wn1mUOqgUG9xxsUKOdjdzcM5 IR3qlsvxfUSGq4AIFIa0wQY/IMrB9jQK6ZZYJFlf4569IryM+CSb29y7HQ0bmYP0Ofgf +a3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=LOPgQup6F0h+Ij6sYWAHH/M666uh+NTVfASk5SQVjok=; fh=6X8AATF4cqshPKzFNKOjBrUFjzbZbR7HlPsa09XhG4I=; b=edPmBmO5AxmCB8oERODiYgXHZq82278bazmqFp6egJ8F3YH0ApdRTXfd1MZScDcmKH 4QE0PwnWI+ggq+ymOnQPRQuKQSj6pGfMi/4ONZPmYywGG4SJAgAid6WWRlY6JKSVkMVz 4Ht1GvMrSeQYkW1tZGvXInTJgZpSI5mpQvSGKERGHowfvRan9e1hi1oaTLWpajmQgICg LRCwuoD8DDpZ47MWBHwmKUB8QobzHOr8isDaOOQMvtJEn6rQ41MeJUXGgdmr04M2cdVa gK3yKSNE8TTil9beHQbu1Le843ReBlnUMvzeBochAyoOQJUMLjzsN4COkHMh5Hx/fQ4L rNmw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3fBf2xKm; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-97663-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97663-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gm1-20020a056214268100b00690ba65db08si463685qvb.272.2024.03.08.14.39.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 14:39:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97663-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3fBf2xKm; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-97663-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97663-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E9C0D1C21528 for ; Fri, 8 Mar 2024 22:39:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C3815E08E; Fri, 8 Mar 2024 22:37:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="3fBf2xKm" Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7350C481A8 for ; Fri, 8 Mar 2024 22:37:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709937441; cv=none; b=sF5VHFVjNrdm6o8hjaAzVKZgNQit4apLrLbaSe5b3Ogf5nTfR+6wKpU7O9WS2DCC7NKs//wY2KOChQJMI8t/raI5eVZ2VlREx/JuxDp7XwqZywW90JyguPwCt4khi/974UBES/tIwapzLJ+5UTOZzhkLmMlEqC5Upg96k8ywUzg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709937441; c=relaxed/simple; bh=IHkAWM8Bsx+VfJRZIYMmESxXShX5sefkocQEmr3ATY0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=loLfXBHbhFV/x7i2/jD9sHAU+xPZtXfoyQWjt+ChZ8P7kGoi/nqU9iqGX1cpfT/z/lJhTsLLak+fHrY+AgtBcMvdGPbURv01oY1oTRjD/8b5SngjbPqhmUotJnQQSKA9WoO8yKe+yWG7gahv5ZB5qp52Q7paurgzgqMzOf/HI2I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=3fBf2xKm; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-6e678cd2f25so145073b3a.3 for ; Fri, 08 Mar 2024 14:37:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709937439; x=1710542239; darn=vger.kernel.org; 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=LOPgQup6F0h+Ij6sYWAHH/M666uh+NTVfASk5SQVjok=; b=3fBf2xKm09OkSwtX6Ni0r0TXTpFjHeZ49MzgEd74Mj4TZE1eeWYG96lbX8YXJMutm0 LKZbjCbiMrNUIQXVc4QS/mhQcWGD3STeyG/izbNEPveiZgtBqCZBjyfXIwzkweb0qRnG 9DsNRG3fOMJ+mgxsHudmJxQlrg4OS8/LO6wYhP2NGRHI/TKjnxZq0lhlR1+BpV+2H37i rmEjrxfVOeF2tGexuiEGfx3/edQdpJ3t3SYyCdxrs8OZ4AN1rBhS5uvKU2QUApoxTev/ is9Z6y3j+zuB8FAW5HiZc/SFahYwzTEV6pvaL/21cTttuRPGUoYQIdSxpZP+fSzmTJrG E/6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709937439; x=1710542239; 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=LOPgQup6F0h+Ij6sYWAHH/M666uh+NTVfASk5SQVjok=; b=iLUlRxtA7sXBijMDLBxf1bdLqPGFvGwDpceNBza44SFwsCBds0n2boLMvUxmeEHX1W I3bUyTovhsjkD1bM8izY5X//atKvN1xVPOcPlIimr4K+BdxYGD4BOsMdjcrcomWoHqu7 lEms8P6TwTZcKBSC5Kaa2564Wmbj+AvG8agibo/6BBF7cwb+VjJCHtyZaGt9UtytE1OV jglz40A0d3OtC73NQWRwxGarFF7ooqq51r6Yts9qTqM4AiheylR3bdKfUmaLWCSlY1Ne i6sa/in6hlDFm4AjjLnDxAnTmY08A0htmSE18qnmv3zIZnNYhvfdGkTTLcGfM1lbHmUj P7Cw== X-Forwarded-Encrypted: i=1; AJvYcCU13cCCAgiOHriKEGr3AfX84GWarR4yIgwc1isuM/vBuYu3wAhaEwsbvGA5fswKVDLxYKfR3Vxh8CSgGfUpHW0Ai05OmAJCM3+6bKLh X-Gm-Message-State: AOJu0YzuWFxfQ1zmkVVaEaYpeERoTvbZvVtSFTvJbyxH8/o3ecK0yoqN zxKmIAmvldPzPSNWRtAnbxpZuPFZcyjXvQc9pTzSv7wN2AmMHbFBQxjywZ3U1phjas14r9xweIt RWQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:2291:b0:6e5:94b0:68be with SMTP id f17-20020a056a00229100b006e594b068bemr21598pfe.2.1709937438717; Fri, 08 Mar 2024 14:37:18 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 8 Mar 2024 14:36:59 -0800 In-Reply-To: <20240308223702.1350851-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240308223702.1350851-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240308223702.1350851-7-seanjc@google.com> Subject: [GIT PULL] KVM: x86: Selftests changes for 6.9 From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson Content-Type: text/plain; charset="UTF-8" Add SEV(-ES) smoke tests, and start building out infrastructure to utilize the "core" selftests harness and TAP. In addition to provide TAP output, using the infrastructure reduces boilerplate code and allows running all testscases in a test, even if a previous testcase fails (compared with today, where a testcase failure is terminal for the entire test). As noted in the PMU pull request, the "Use TAP interface" changes have a few conflicts. 3 of 4 are relatively straightforward, but the one in userspace_msr_exit_test.c's test_msr_filter_allow() is a pain. At least, I thought so as I botched it at least twice. (LOL, make that three times, as I just botched my test merge resolution). The code should end up looking like this: --- KVM_ONE_VCPU_TEST_SUITE(user_msr); KVM_ONE_VCPU_TEST(user_msr, msr_filter_allow, guest_code_filter_allow) { struct kvm_vm *vm = vcpu->vm; uint64_t cmd; int rc; sync_global_to_guest(vm, fep_available); rc = kvm_check_cap(KVM_CAP_X86_USER_SPACE_MSR); --- The resolutions I've been using can be found in kvm-x86/next. The following changes since commit db7d6fbc10447090bab8691a907a7c383ec66f58: KVM: remove unnecessary #ifdef (2024-02-08 08:41:06 -0500) are available in the Git repository at: https://github.com/kvm-x86/linux.git tags/kvm-x86-selftests-6.9 for you to fetch changes up to e9da6f08edb0bd4c621165496778d77a222e1174: KVM: selftests: Explicitly close guest_memfd files in some gmem tests (2024-03-05 13:31:20 -0800) ---------------------------------------------------------------- KVM selftests changes for 6.9: - Add macros to reduce the amount of boilerplate code needed to write "simple" selftests, and to utilize selftest TAP infrastructure, which is especially beneficial for KVM selftests with multiple testcases. - Add basic smoke tests for SEV and SEV-ES, along with a pile of library support for handling private/encrypted/protected memory. - Fix benign bugs where tests neglect to close() guest_memfd files. ---------------------------------------------------------------- Ackerley Tng (1): KVM: selftests: Add a macro to iterate over a sparsebit range Dongli Zhang (1): KVM: selftests: Explicitly close guest_memfd files in some gmem tests Michael Roth (2): KVM: selftests: Make sparsebit structs const where appropriate KVM: selftests: Add support for protected vm_vaddr_* allocations Peter Gonda (5): KVM: selftests: Add support for allocating/managing protected guest memory KVM: selftests: Explicitly ucall pool from shared memory KVM: selftests: Allow tagging protected memory in guest page tables KVM: selftests: Add library for creating and interacting with SEV guests KVM: selftests: Add a basic SEV smoke test Sean Christopherson (4): KVM: selftests: Move setting a vCPU's entry point to a dedicated API KVM: selftests: Extend VM creation's @shape to allow control of VM subtype KVM: selftests: Use the SEV library APIs in the intra-host migration test KVM: selftests: Add a basic SEV-ES smoke test Thomas Huth (7): KVM: selftests: x86: sync_regs_test: Use vcpu_run() where appropriate KVM: selftests: x86: sync_regs_test: Get regs structure before modifying it KVM: selftests: Add a macro to define a test with one vcpu KVM: selftests: x86: Use TAP interface in the sync_regs test KVM: selftests: x86: Use TAP interface in the fix_hypercall test KVM: selftests: x86: Use TAP interface in the vmx_pmu_caps test KVM: selftests: x86: Use TAP interface in the userspace_msr_exit test tools/testing/selftests/kvm/Makefile | 2 + tools/testing/selftests/kvm/guest_memfd_test.c | 3 + .../selftests/kvm/include/aarch64/kvm_util_arch.h | 7 ++ .../selftests/kvm/include/kvm_test_harness.h | 36 ++++++ .../testing/selftests/kvm/include/kvm_util_base.h | 61 +++++++++-- .../selftests/kvm/include/riscv/kvm_util_arch.h | 7 ++ .../selftests/kvm/include/s390x/kvm_util_arch.h | 7 ++ tools/testing/selftests/kvm/include/sparsebit.h | 56 +++++++--- .../selftests/kvm/include/x86_64/kvm_util_arch.h | 23 ++++ .../selftests/kvm/include/x86_64/processor.h | 8 ++ tools/testing/selftests/kvm/include/x86_64/sev.h | 107 ++++++++++++++++++ .../testing/selftests/kvm/lib/aarch64/processor.c | 24 +++- tools/testing/selftests/kvm/lib/kvm_util.c | 67 ++++++++++-- tools/testing/selftests/kvm/lib/riscv/processor.c | 9 +- tools/testing/selftests/kvm/lib/s390x/processor.c | 13 ++- tools/testing/selftests/kvm/lib/sparsebit.c | 48 ++++---- tools/testing/selftests/kvm/lib/ucall_common.c | 3 +- tools/testing/selftests/kvm/lib/x86_64/processor.c | 45 +++++++- tools/testing/selftests/kvm/lib/x86_64/sev.c | 114 +++++++++++++++++++ .../selftests/kvm/x86_64/fix_hypercall_test.c | 27 +++-- .../kvm/x86_64/private_mem_conversions_test.c | 2 + .../selftests/kvm/x86_64/sev_migrate_tests.c | 60 +++------- .../testing/selftests/kvm/x86_64/sev_smoke_test.c | 88 +++++++++++++++ .../testing/selftests/kvm/x86_64/sync_regs_test.c | 121 +++++++++++++++------ .../selftests/kvm/x86_64/userspace_msr_exit_test.c | 52 +++------ .../selftests/kvm/x86_64/vmx_pmu_caps_test.c | 52 ++------- 26 files changed, 802 insertions(+), 240 deletions(-) create mode 100644 tools/testing/selftests/kvm/include/aarch64/kvm_util_arch.h create mode 100644 tools/testing/selftests/kvm/include/kvm_test_harness.h create mode 100644 tools/testing/selftests/kvm/include/riscv/kvm_util_arch.h create mode 100644 tools/testing/selftests/kvm/include/s390x/kvm_util_arch.h create mode 100644 tools/testing/selftests/kvm/include/x86_64/kvm_util_arch.h create mode 100644 tools/testing/selftests/kvm/include/x86_64/sev.h create mode 100644 tools/testing/selftests/kvm/lib/x86_64/sev.c create mode 100644 tools/testing/selftests/kvm/x86_64/sev_smoke_test.c