From patchwork Sat Feb 3 00:09:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13543619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E61A5C48295 for ; Sat, 3 Feb 2024 00:09:40 +0000 (UTC) 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 :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=k5imWXN5dB3jHsbWVT0amRcsO6Raegsq0aH6Lm8Tdxw=; b=HOTVRwaquwHKiM SzXh83Ku+iAfiy2W8PacEKzEsDShZu4CwhFYvAKQ9dYGFv0l6hcKT7mo6HzC4DMa7WAScWIyDKf7v 6UCYQ+KaM01pLF58AqYaD26rItql5HoiUhIl/WJl6uy3lUTCbcTQ2XI9jkWUxgRmCyQGhUOadaFi0 1dfca6bC3nz9U/G3zkYSWbjbPCgOAgzJrk3JKr3OQlqCbGC+AmA7XZf7vetsYLDr5bEkg742ndCf4 IzMZFkkbT2CsKJdbmyXJlTuzDa+OZUBm2e3m9fYjIy2lM49OSMIoA12dcZ8PUw2Kvp5JllkatPpWN dVRCcMIX2C+6KqEvtEUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rW3b4-0000000DsWz-1IfK; Sat, 03 Feb 2024 00:09:26 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rW3b2-0000000DsVF-0CV8 for linux-arm-kernel@lists.infradead.org; Sat, 03 Feb 2024 00:09:25 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-60407831b3cso45321627b3.1 for ; Fri, 02 Feb 2024 16:09:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706918962; x=1707523762; darn=lists.infradead.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=OEEHd6q2TChurvVJ9QWQDtWt/fR7D+phxscUNFsCU/w=; b=2693572nlouLpI/pq1ue1Jz/zQxAPZCEDnpEQ4i2Itg0gv/LSQVYzQp43kY3cHKdY+ kD+HcHbAIdB+egwZjLaQ1kYRBlRpSWQ3H7Y6aswWYe4r+037eS9h8dkh0BdtQw0npUb8 TPpmsPRz5T5FpMHTFm3awwZA1t7n+qggwwrG8uGciBkU3t9Geyjx9UqmryAHhcBWPcDO l/JpNA1+pBXe34QbqY6YRdsWf/MnrzVfbokbOtX5RBQ+6aGxCeL+zR66qsy+Bsu5NZho neH4N9bbs51VfPDmBZxw0gdJEEMfS9pRJnFHwE6ifrK5Yc2wrYmBQ1uGDk/1BKvnHAXb xj3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706918962; x=1707523762; 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=OEEHd6q2TChurvVJ9QWQDtWt/fR7D+phxscUNFsCU/w=; b=Ta5p6uCOMorhj6lSRdYCf+H9zzq0FR+EgpQONBLNgcNOrwgDXwLUJT6/7nH/vOHMjn 0M5W6Nrp2VX82jg+kNoLGStZDZUyBvoMbaAXqu2AockYDEVUfQbCW0/XulMz4XgVcKAB UKLNkSqB+pWNWk9g3uTUVvVlOiJwMR0x9+c5KxNBqfgHDIyorlWmG5JrulAV+ldRRORX D+HINKP8lQA2J8UpHHObr5FOQx58qClkbEAHw3hjDCZi78NI4ldWQ70Kmu8QojnoSin0 zxShbNMTxNVZ0espMQX3H6OmWC73sCOCukcqip+RFAvscH6ywA4eisRlZuzl/PvPpkOG i6oQ== X-Gm-Message-State: AOJu0YxOdx7hHyD7PNv3ftskzLKKQ7iAMcM3ZpZkufP7O5VNBnK62vDa 8Y40W4MPcqTrQbKVM4ZFu3yT/67wWMR33+19jyGCpp/NGryZQxcKVellXFvwDEQifUK1gD6OBVd 3IA== X-Google-Smtp-Source: AGHT+IEcnlTVvkgM/agP2AI7SK0XtZwpf1RNWRzpnYbOzQzjKWA86nEjOukuZ0+7uKPyvsge0rWvGPAYF88= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:2402:b0:dc6:e7e8:caae with SMTP id dr2-20020a056902240200b00dc6e7e8caaemr1059362ybb.0.1706918962763; Fri, 02 Feb 2024 16:09:22 -0800 (PST) Date: Fri, 2 Feb 2024 16:09:07 -0800 In-Reply-To: <20240203000917.376631-1-seanjc@google.com> Mime-Version: 1.0 References: <20240203000917.376631-1-seanjc@google.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Message-ID: <20240203000917.376631-2-seanjc@google.com> Subject: [PATCH v8 01/10] KVM: selftests: Extend VM creation's @shape to allow control of VM subtype From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Sean Christopherson Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Vishal Annapurve , Ackerley Tng , Andrew Jones , Tom Lendacky , Michael Roth , Peter Gonda X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240202_160924_112401_6229C537 X-CRM114-Status: GOOD ( 12.62 ) X-BeenThere: linux-arm-kernel@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: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Carve out space in the @shape passed to the various VM creation helpers to allow using the shape to control the subtype of VM, e.g. to identify x86's SEV VMs (which are "regular" VMs as far as KVM is concerned). Cc: Paolo Bonzini Cc: Sean Christopherson Cc: Vishal Annapurve Cc: Ackerley Tng Cc: Andrew Jones Cc: Tom Lendacky Cc: Michael Roth Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/include/kvm_util_base.h | 9 +++++++-- tools/testing/selftests/kvm/lib/kvm_util.c | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h index 070f250036fc..d9dc31af2f96 100644 --- a/tools/testing/selftests/kvm/include/kvm_util_base.h +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h @@ -90,6 +90,7 @@ enum kvm_mem_region_type { struct kvm_vm { int mode; unsigned long type; + uint8_t subtype; int kvm_fd; int fd; unsigned int pgtable_levels; @@ -191,10 +192,14 @@ enum vm_guest_mode { }; struct vm_shape { - enum vm_guest_mode mode; - unsigned int type; + uint32_t type; + uint8_t mode; + uint8_t subtype; + uint16_t padding; }; +kvm_static_assert(sizeof(struct vm_shape) == sizeof(uint64_t)); + #define VM_TYPE_DEFAULT 0 #define VM_SHAPE(__mode) \ diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 4994afbdab40..a53caf81eb87 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -276,6 +276,7 @@ struct kvm_vm *____vm_create(struct vm_shape shape) vm->mode = shape.mode; vm->type = shape.type; + vm->subtype = shape.subtype; vm->pa_bits = vm_guest_mode_params[vm->mode].pa_bits; vm->va_bits = vm_guest_mode_params[vm->mode].va_bits;