Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp433897lqg; Thu, 11 Apr 2024 07:23:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV/xOPm1K5+Ersocf9DXzdPpGoMvN10mjpK5pMYxn6AczDIqu07ofUzqQHX6BjJS9lBWfdSYXffvKKZHWD7Qz46vuQYTHLMKvCaBPKyFg== X-Google-Smtp-Source: AGHT+IEIJh2+JgojPXX5VaNNUMFysHjNbCFOFd4wkungjvkuLAMZOCOuFxSIoxQNCSf5ehRLmyx/ X-Received: by 2002:ac2:46da:0:b0:516:d14a:9697 with SMTP id p26-20020ac246da000000b00516d14a9697mr3416774lfo.53.1712845382281; Thu, 11 Apr 2024 07:23:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712845382; cv=pass; d=google.com; s=arc-20160816; b=exn1qJnz0gqKqFFnqhdXM4Fhdo/r7KYc4+ne+mSlOE8eDLXHvthgmC6PWDivONZ/IK x3ypruHfqn51QqGOpbksNzgCq6ipa12AqUEXriptNdT5l9gusTwT2FzSPAXttRqrWVfy edRtj71ITHwsEp2O6XHIwEEQiIpE1WZN/Jg56VZXJpELhHWwR6CEVw/iMkoi0FO5pLdr 1Bu4XyjPEm7vQRoj7S+qPauoxr4x6CtCxqNpQDeZ4AjS9GMAJa/p3tE8sazGIZ4Sla7R J0OJDwm5gDP4oHSfet3bHPz/U399T9R7fm0lOuFVrLKxPXRLnSGZZ6SY2jIlcD5Q/4xN wFRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=9GtzFk1KROuOyCTzMxxWmq/Qzlg7l7c+rvMLuBjBAYQ=; fh=A8cE+bI8fEib+ZZHE9VAXfeKJihX6VBx1p5YetyDWCE=; b=V63tfV+NLrBa/UuRE9In9LCYy6Ol7tKbmyIczYRzV5NJ3JlQI3kQye8fP0ii2hZ9Ms vCAzy5IFxGG3ggugyIEEP+2NN63o4OzNg4iF7tG3PZqfCnilTj1eVEK5R4gmL9ulKZCf OxEPRfY8VZNP4FyvJrucqzSCi9mqeUMTBt+64coshm4SdbEqyXpxYfTTZUpS6P97fGTe U1p13ipfwX3NqI3my0Yw3Xx/eell0GL5tB+VF6IdvRTcAQU09LbVbvb4H/nnXrX0rSpk NXZanaudHL/UGRdAHcam9xAU4q5qxTpBGGknAv5xKbYdHmBfjRuhNgB+YH4jn3ZGy71o l5Uw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RaKXz5PV; 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-140635-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id z10-20020a1709063aca00b00a51dfda479asi842579ejd.43.2024.04.11.07.23.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:23:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140635-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RaKXz5PV; 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-140635-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140635-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1ED401F21993 for ; Thu, 11 Apr 2024 14:23:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C86A114EC4A; Thu, 11 Apr 2024 14:22:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RaKXz5PV" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 990E414D443 for ; Thu, 11 Apr 2024 14:22:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712845367; cv=none; b=e05R6uLwJOrWBfktc3ZA7r0EbECZNGA8Cqo8I3vi82bO//LovTotuCX8nONzX8F3VrL7Ubnt6oUpNiW7SxOZ+gSiH2ZRf9q3aHe3e4PocLQmcPUk1LNDw1PCmb3IzaDP2/89hCIvR2bB5HsJAD6wY2sx977OwkSW0FMJ0UbdLBI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712845367; c=relaxed/simple; bh=5ws/A/06xIoL6+cVU7hMy6Emh6zWldKl+mIyryAkvSE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=RsdwbpNkCbgscrgFLF0TZYfWvVFibKUS7ZIm5DSXUykE415X7zXCeHdzLeRD0X6WSLvPQRTYQRs84wwTQ/PK+Pnl1C5xfTV3rUE2AGZG/6qCVHdYVYSn8uXmQXlaTph1MnJ0rX+Ei2OfqifoHWjBRTAArTtyOaDCVNGwcq1/p7U= 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=RaKXz5PV; arc=none smtp.client-ip=209.85.128.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-yw1-f202.google.com with SMTP id 00721157ae682-60a4ee41269so133402877b3.0 for ; Thu, 11 Apr 2024 07:22:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712845365; x=1713450165; 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=9GtzFk1KROuOyCTzMxxWmq/Qzlg7l7c+rvMLuBjBAYQ=; b=RaKXz5PV9xVBhOIDiZiDdzGTjHHF/gFPElEcFmWzbcOHEcDBio9yl5EP4qHW6U2aqu +/g++rF3ifKPkDRLmOFm4QhnINlvndl9+lY5cvxCJ81CZgk6sv63SNNharfm1VwUglWB NJ3Xw4mzm5IXPOGLgpx4aoZTyo1sTA3MTD4tpJO1+lI0be5V8SlEBtIzWWf6elBRXnQl aTpqWoe2sF6B8pFz5bHCeWtNMrUMF8OidsZU51rkAEGkKmDGvSGFTEMXOYPmDLC+G1DY mbeoG2LqIxpTp3RMKy9BDykquC/cqXABUjMs1Wtyw4Wkb3t/evufXIhrABLCxhgZ0F/Z Z3fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712845365; x=1713450165; 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=9GtzFk1KROuOyCTzMxxWmq/Qzlg7l7c+rvMLuBjBAYQ=; b=aUfT0rt6ILZWPiCjUPeUL/wffRbMIYIPrtFSG23ZbVE1y7C7g1T8mJLaInBWmroGcu rdcd/y9wzM+f7v31Sow1WhivA2TM+SZtO9PmUzeszti3livF/4PrjndSyVYyGHshpJLj 41T64ElK0okZ1lbUAmcvhoSEstwdInL6UwBUrPpV5m/jKuzlYhTYr3jEWXzOq/iGvVAB D+jwqUiJkh6mKIJUARl5NrayJOJZBVjQVdiatcXIbtIzrNj8i+xyfJJyvRqg34V6WyHB rHeLv66t3WarY4gYXr+VADo/WoC497I6eVeh5ZkjVBwC06BUfyY/gsfsAPn6MLnNOodC HxPQ== X-Forwarded-Encrypted: i=1; AJvYcCU+aOiu7L3P+6ZU4ldng8ruz3T8KDcJp9UufokWJVi+cj/6GY6MDgvgMvZhWoq7Ah5oCWQkBjHBCantQeg177RtXpMRwizMMGcve4PU X-Gm-Message-State: AOJu0YzbYrQo39mt3Sz7KTGfSKi/dUx3eu8ndoec5WQoMjFq5lkPfIA1 sIngTuKZi4SjXfDEP4EZ5ahTJGFWzsgVBxErEKe66zMfnyVuzT5FgRkfNYh96Mlm1XyfbG0gFnC /ow== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a0d:d8d3:0:b0:615:134c:7ef3 with SMTP id a202-20020a0dd8d3000000b00615134c7ef3mr1511695ywe.9.1712845365687; Thu, 11 Apr 2024 07:22:45 -0700 (PDT) Date: Thu, 11 Apr 2024 07:22:44 -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: <5faaeaa7bc66dbc4ea86a64ef8e8f9b22fd22ef4.camel@intel.com> <957b26d18ba7db611ed6582366066667267d10b8.camel@intel.com> <8b40f8b1d1fa915116ef1c95a13db0e55d3d91f2.camel@intel.com> <4ae4769a6f343a2f4d3648e4348810df069f24b7.camel@intel.com> Message-ID: Subject: Re: [ANNOUNCE] PUCK Notes - 2024.04.03 - TDX Upstreaming Strategy From: Sean Christopherson To: Rick P Edgecombe Cc: "davidskidmore@google.com" , Xiaoyao Li , "linux-kernel@vger.kernel.org" , "srutherford@google.com" , "pankaj.gupta@amd.com" , "kvm@vger.kernel.org" , Isaku Yamahata , Wei W Wang Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 11, 2024, Rick P Edgecombe wrote: > On Tue, 2024-04-09 at 09:26 -0700, Sean Christopherson wrote: > > > Haha, if this is the confusion, I see why you reacted that way to "JS= ON". > > > That would be quite the curious choice for a TDX module API. > > >=20 > > > So it is easy to convert it to a C struct and embed it in KVM. It's j= ust not > > > that useful because it will not necessarily be valid for future TDX m= odules. > >=20 > > No, I don't want to embed anything in KVM, that's the exact same as har= dcoding > > crud into KVM, which is what I want to avoid.=C2=A0 I want to be able t= o roll out a > > new TDX module with any kernel changes, and I want userspace to be able= to > > assert > > that, for a given TDX module, the effective guest CPUID configuration a= ligns > > with > > userspace's desired the vCPU model, i.e. that the value of fixed bits m= atch up > > with the guest CPUID that userspace wants to define. > >=20 > > Maybe that just means converting the JSON file into some binary format = that > > the > > kernel can already parse.=C2=A0 But I want Intel to commit to providing= that > > metadata > > along with every TDX module. >=20 > Oof. It turns out in one of the JSON files there is a description of a di= fferent > interface (TDX module runtime interface) that provides a way to read CPUI= D data > that is configured in a TD, including fixed bits. It works like: > 1. VMM queries which CPUID bits are directly configurable. > 2. VMM provides directly configurable CPUID bits, along with XFAM and > ATTRIBUTES, via TDH.MNG.INIT. (KVM_TDX_INIT_VM) > 3. Then VMM can use this other interface via TDH.MNG.RD, to query the res= ulting > values of specific CPUID leafs. >=20 > This does not provide a way to query the fixed bits specifically, it tell= s you > what ended up getting configuring in a specific TD, which includes the fi= xed > bits and anything else. So we need to do KVM_TDX_INIT_VM before KVM_SET_C= PUID in > order to have something to check against. But there was discussion of > KVM_SET_CPUID on CPU0 having the CPUID state to pass to KVM_TDX_INIT_VM. = So that > would need to be sorted. >=20 > If we pass the directly configurable values with KVM_TDX_INIT_VM, like we= do > today, then the data provided by this interface should allow us to check > consistency between KVM_SET_CPUID and the actual configured TD CPUID beha= vior. I think it would be a good (optional?) sanity check, e.g. KVM_BUG_ON() if t= he post-KVM_TDX_INIT_VM CPUID set doesn't match KVM's internal data. But that= alone provides a terrible experience for userspace. - The VMM would still need to hardcode knowledge of fixed bits, without a = way to do a sanity check of its own. - Lack of a sanity check means the VMM can't fail VM creation early. - KVM_SET_CPUID2 doesn't have a way to inform userspace _which_ CPUID bits= are "bad". - Neither userspace nor KVM can programming detect when bits are fixed vs. flexible. E.g. it's not impossible that userspace would want to do X if= a feature is fixed, but Y if it's flexible.