Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp2061475lqe; Tue, 9 Apr 2024 08:30:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX2C+OeuBurGTo/8JLHf60sH9Ku8pJYK364TT9/6Qd/032O/9A7bVw7uN001jFlJj5WNXK4plwWawOACuD90gjaMRDnS4jegUMoAVZHjw== X-Google-Smtp-Source: AGHT+IFP+3XGatndy6ReSh2a1+wiXtq0Hx3zXPA+QBnlMICPH7zNAuG7KVI5SQgLUYP6xBWIaRr7 X-Received: by 2002:a05:6102:10de:b0:479:eb8e:1bf with SMTP id t30-20020a05610210de00b00479eb8e01bfmr7220283vsr.24.1712676617446; Tue, 09 Apr 2024 08:30:17 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id if4-20020a0561022c8400b00479cd4b4dc5si1482060vsb.351.2024.04.09.08.30.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 08:30:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137221-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=neutral (body hash did not verify) header.i=@google.com header.s=20230601 header.b=CueSECOF; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-137221-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137221-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=REJECT sp=REJECT dis=QUARANTINE) 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 2D1441C212D5 for ; Tue, 9 Apr 2024 15:30:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 51B1F13D608; Tue, 9 Apr 2024 15:26:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="CueSECOF" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 1781E12F367 for ; Tue, 9 Apr 2024 15:26:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712676392; cv=none; b=BYQcPyTYDam4UQXx1umzost62Uit+wyk2ER+hCU3BsalR7bwyQr+14X0K+wVzlAPhzo3Esyd6jWdWV3qTjx5h0ZrKIHOF23tavCmbvUZj72y5pgPaLoi2/xVcIp6Gm34yjG1/pgHfDEwle9ojNYpYptxL/ZDVRp61j+i6GTSLxE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712676392; c=relaxed/simple; bh=7AkwAkiGFeXn/tzNgwfDv+w516qHyDpPTUwTkeRV5D0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=A0n2lILQd78BgMfNO4wevfbS7/KLiPUr2RJiKH5xbfluLPjeregFYJQIdSsXnb+8+9vPMBkohS/4Yf64BgwoMr97mPSGgA3sOnXkH3YMQzt1sWUHTM3CJT7KP1eQk4Jp+Rtvf8YbB25ch3Yxi8y68iyNPrOmSJdGEmgZ6tfJsO4= 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=CueSECOF; arc=none smtp.client-ip=209.85.128.201 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-yw1-f201.google.com with SMTP id 00721157ae682-6167463c60cso64779337b3.1 for ; Tue, 09 Apr 2024 08:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712676390; x=1713281190; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=L6zxjwXhkVdMVC69wPNMLfHGLf1mnpEnNlg9mNA1BZg=; b=CueSECOFYYF7LRtpdB09YssCkGviporTFhY3RfbGoSFLLQ6re0HbeQ1mbdGKIN1/Dm ei1354ZFavr1myENW5RJYIaXhMF9rpTM84Ekban/rfQoTycGFbavjIMBRklOMvFL6cNT aPGGP3vYkfelbF+QgGN7HCqeBniQ+WMPKXSbBotHhUkaU/CWx0AZy4Q63wD1yQWd5x// VedxBWd+n1zj/tzYS9spzk1FMRrxat4nu3Ls+5Eh1wH9fFZrhgkSpakC3mzp0fLm4rZW rhdFzUrPQrhplLFY27nuJBjOnWJ09Y0agflKsSZD87e/LqFeiTSTvuJ43Dg2jvXMgKUT bzgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712676390; x=1713281190; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=L6zxjwXhkVdMVC69wPNMLfHGLf1mnpEnNlg9mNA1BZg=; b=sevHYs6k0DZULFE5NnFdXqBcji4O4Hiy9lPxPUVbVHxpaZkWG+Qnr/1dJdi12DZ32R M9lAhcQVSLTqPwDi8DABJIXpQyOE73EXSs2KKgXZkDswyHUNN5X64yPUk64kV55+fNNO eh9TYten8Ux8pr/XSOMI9iRWFuVyOyWEQmgOIbwMMgXU60SSP45VDp5/llF4J+t7QcIW ZUpJFDVrz8U1eOUY8Eh4ru2MPMvZo/li3hP9hmsub5T8Rl0I3KBN/2R+NM9VkX9CkYo3 KzndqvzPr0hB6rA/UlPBajC3xL/6hDkAKXSt+bzZRl0ZR9yn5y7IACWdy+8g0Qvy0MyR jTYg== X-Forwarded-Encrypted: i=1; AJvYcCURY02SRy/w2m8jN4+xOJfhlwsMvOZuD+posiN9xWCTOo0JNqLcHoNIXau4h8EJtaozGflpMlJt54/y4z1RgfqEOyypWLPum8um2MxY X-Gm-Message-State: AOJu0Yy6IGHIJsPusxDkLg9qj4MANc30mwwnZpwF4Yy+P+bum2lzv/vC 4As3ISANlkKIrU1JlYVDrJ2mYUlNRPC0DwTaTd+00XRDmv7bHUjnvq/QVSiRzbvCLhRrcNxw0cW ZEA== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:c74d:0:b0:615:1c63:417e with SMTP id i13-20020a81c74d000000b006151c63417emr716361ywl.1.1712676390070; Tue, 09 Apr 2024 08:26:30 -0700 (PDT) Date: Tue, 9 Apr 2024 08:26:28 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240404121327.3107131-1-pbonzini@redhat.com> <20240404121327.3107131-8-pbonzini@redhat.com> <43d1ade0461868016165e964e2bc97f280aee9d4.camel@intel.com> Message-ID: Subject: Re: [PATCH v5 07/17] KVM: x86: add fields to struct kvm_arch for CoCo features From: Sean Christopherson To: Paolo Bonzini Cc: Rick P Edgecombe , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "michael.roth@amd.com" , Isaku Yamahata Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 09, 2024, Paolo Bonzini wrote: > On Tue, Apr 9, 2024 at 3:21=E2=80=AFAM Sean Christopherson wrote: > > > I'm a little late to this conversation, so hopefully not just complic= ating > > > things. But why not deduce has_private_mem and has_protected_state fr= om the > > > vm_type during runtime? Like if kvm.arch.vm_type was instead a bit ma= sk with > > > the bit position of the KVM_X86_*_VM set, kvm_arch_has_private_mem() = could > > > bitwise-and with a compile time mask of vm_types that have primate me= mory. > > > This also prevents it from ever transitioning through non-nonsensical= states > > > like vm_type =3D=3D KVM_X86_TDX_VM, but !has_private_memory, so would= be a little > > > more robust. > > > > LOL, time is a circle, or something like that. Paolo actually did this= in v2[*], > > and I objected, vociferously. >=20 > To be fair, Rick is asking for something much less hideous - just set >=20 > kvm->arch.vm_type =3D (1 << vm_type); >=20 > and then define kvm_has_*(kvm) as !!(kvm->arch.vm_type & SOME_BIT_MASK). >=20 > And indeed it makes sense as an alternative. Ah, yeah, I'd be fine with that.=20 > It also feels a little bit more restrictive and the benefit is small, so = I > think I'm going to go with this version. +1