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: 196100 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp769271dyc; Fri, 2 Feb 2024 16:10:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFO4tIorNrEtHj0VuPm9YeCriGEXSuP8XcE3gAQHbnMHI3pwXqZm60CFeA7R8yX+pklcRjo X-Received: by 2002:a17:90a:fd0f:b0:28c:fb86:23ce with SMTP id cv15-20020a17090afd0f00b0028cfb8623cemr3556022pjb.44.1706919019065; Fri, 02 Feb 2024 16:10:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706919019; cv=pass; d=google.com; s=arc-20160816; b=s6m8DrLeinZnKMroDGCR7I3/rroqLZNXpKfJdXwEiAHZA8kWdDCBS812ckqsDORddB afjv/XCbLvwY2BP11PoVJFLZTTV7PcPCvVxC6g4rDkLSGOq0NbhbFVHx5Y0Ae5+bPcP0 0JGkz9gOXQjyAF2ITn3IershX09ENpeVjun0J4dYyPI720a9GImc1AxLLGK4xbByhbqu OhXQN8Uu+Kwj8Uwom4ot88H4kaUUskakzRRAxBQ/9ZKPw11KPNT7ClU4JEVwwcJ18Bj2 fkMCMTI8LSgRBEgeTRhPeZXT763QnajQPelLXscAPG7LqfbaqmOaO/EPWJXIb7kiCey7 swhQ== 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=OEEHd6q2TChurvVJ9QWQDtWt/fR7D+phxscUNFsCU/w=; fh=D6g3OrUcxGdqOMRlgpvpnlf3nT314G5MaFzXZUCeksc=; b=n2CP+2FYcXcAa2XMkA3zjRQaAcwoRxGs7CD0O9NUpvwr13iLz3S5JlqdKMKHAVDYjD 1w6XbhAvTISxefAjeilcv7t02RUseY+H2BF9NA8/itme8niToO9OyiGKBBPZfFm6Fmh4 7rG3yn2h7622XA/NJOcnZC1z0mp5olh6QZSufQIjJ8sI1WxeGQFrs0SfV3xMmh1awIPK myAoS+4CN8NcpZYtRV/Zfg7u0ve21TWQnJ/e+T98+rQRFFjXvgS0t3tWfWskQrlLkrZ9 rQrlz9DvQPZUQjITVFG/KU03BLdhgtC5y/2LYHn6soGlMKeaOJ2dgbLT4Kz3mI1Liwve RKug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=NCaTiZpY; 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-50747-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50747-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCVSoehB1JP7DmaBzfgPsG+/O7oDqd3V3VdoiY363/E9iyBW6WcNW5rUsol16j0gAfabK5YVy54mNnoH7n3rmHLtzsgQiQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id my5-20020a17090b4c8500b00295d9ec8e60si670853pjb.123.2024.02.02.16.10.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 16:10:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50747-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=NCaTiZpY; 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-50747-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50747-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D3B71281FDD for ; Sat, 3 Feb 2024 00:10:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C7EF6FCA; Sat, 3 Feb 2024 00:09:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NCaTiZpY" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.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 BC3BBA3D for ; Sat, 3 Feb 2024 00:09:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706918965; cv=none; b=VnZTwGcilGVzJAdHQi6K8QtHUNf7aL4HMKLemZAJ7v+4zzVZXuEB5V9xDa9M6sTtJfSjZA4jt2ZS9xWiqEGN4np7nVfDWYTrjvJ8b7bHfHGat0WxIKJ1EoGvlmZVsMPic7NiQpQ61U6j7HXEt5ae6ZJW3VKssBF2ACDbrGYAJHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706918965; c=relaxed/simple; bh=DQsGPwFy3v7uPs21OAJ9r/tyAnYHLR0BBzOxzUXWZ6A=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=EmLEgVOj9Ug56sjY/bxKEHiEi92edaYEbZkspBMkvl6GhMMkxq20KFIH5ur6oS3m658eTWlSNTxZWqZH2IjLoQqZmc+OumK+O1UiSvMVc1eZIscXl9gGqLnF+5cpaKoHa4FyyWSKMlSdVyWnAUt9QUh5JRMxBVN690lfX/HWvhg= 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=NCaTiZpY; arc=none smtp.client-ip=209.85.219.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-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6dbdcfd39so4559097276.2 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=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=OEEHd6q2TChurvVJ9QWQDtWt/fR7D+phxscUNFsCU/w=; b=NCaTiZpYfUYV6aEyCd55jbXAuVRLGHmocKLd11khnbFf2d5SITGcQY1/VCKor88P6T 3b1ofVmwetI1rzqzVVhX9zsr0ixBt1+8QA5DkNfal0P9y24cGACiyD0+QNg2rf3iIX2K y0QwynEX1sSrkt5ZVdphd0vqyUU2M40rf5B3GIQMmAfilEss7MmkQYdSMR1XOoTxBu9+ vCO6+der2su51qtCCadahvKTHcYjoA18XH4IGAyg/k6PKdjw16h6G2a/Bhfu7JXKKO+4 jHyCBvzhLs7M2NDnF+eMpyWLdL5BovQm6CW8l3FcjnKmI1mdcLiYjYDm0ipJvfSdJHz/ XCCQ== 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=hBaRGzePA22hVUb+qcsH6hfLZPbzglz8CaDzikIzXrnKzUTAVh9f5NbI8HmPQzx5UC XSBkDG7l3OMe8yWEqvek5MM1PBVBM+OOpynBY7ubAPJ9FLvXlR0WdSzREI1JiOl4OTch PUbe1qATAiW+dYPC8VCMK+93I1uBRU+xFJWe7ngjQvM2tfsUrrWeYgDYNibCK4S9izYK FNajYjygnhnE4e7RWdQK6GQgwLYEY/e8oVWUCXfjy8ztkM8xr9X6ZmmkhuCrCaoKHCgN ff2I4rU8l8//p0MgFkcUM7PJAMmFxJ2nOuXF21APseMJkprcRWOWXvCZgALkXot7ZVL6 hfbg== X-Gm-Message-State: AOJu0YzYgBnFtVBhYVL5UKf965jwm/Pr/gz2jMHP3P1u2bGVHw5+D1qr /4EPmgDzKquFx+NMVi/pwkq0xlGJBzRfD1S8ahSBy2FvLS8ltE3VeNtQ+ttRN+NdkfAYH0WOQAV 9gw== 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) Reply-To: Sean Christopherson Date: Fri, 2 Feb 2024 16:09:07 -0800 In-Reply-To: <20240203000917.376631-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: <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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789834317552869585 X-GMAIL-MSGID: 1789834317552869585 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;