Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp951148lqb; Wed, 29 May 2024 16:15:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV8pVLRRGN792XxIrN8vnynR8p8tk9xO/hpdPxoSd0smICX8iCggGKVmFAz7vGsukSt/CStEgthsbmSlN0rzy8H6yZG8X7BQc+8y+pqBQ== X-Google-Smtp-Source: AGHT+IFAdkcJt8ax2hI2cDZTzpNMCJYrPpGZFeYi9o/wagkehPusjuyRE9lIIaaS2ioYnTjwO6AZ X-Received: by 2002:a17:902:cec8:b0:1f4:923a:4ed1 with SMTP id d9443c01a7336-1f61983ab32mr5448625ad.49.1717024514781; Wed, 29 May 2024 16:15:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717024514; cv=pass; d=google.com; s=arc-20160816; b=EZ9apo8wTMItTHnwLt86vQfUV3CVSWFe3tRy0nAlGCro7a0F47HGMpb6r54b6QcEfj 95etDfDK4wi23KspR81Jgr1FLleOsznCg0iChRpx1WvSiG23RB+Sc0vLHXOj2yQ7oDUv /se/5LwYYGthTK/9eLUrM/2mH8UKOSzH/W3BOB3TQ/ltc3+Yu05CpJ4Xj+rr8zp8FBMp mZZA4fTdGRBN77B1Vo3NPuiAhckSRu/FqWYrVTL5ZJyaDD+JM6zs4NaKuA5QQEaKFcVT jRa7qbqsgi0E8OOL26yYYf5E+Pualufp2gFOEmRATQC5ULXcK1ZA9yI3hQUQh0c9JbJa qlUQ== 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 :dkim-signature; bh=dnabaEVJa/tSEflSlXJy3215kO3e1psGL7hL7HuyYb4=; fh=sj/Hi8EwnuQwnkV0UMnXo8rBVRGfECWoXitdpHq9UDk=; b=VYWhKNQeTTozsOvsamjKYc3WtiaTVPHAXFuh+ttoylAlVOEgehdFk0oIcMCX0BpF0g NR7x1kmrgABPdNQCIGhyHRntn8gQLqAVlwGD5vvgggjbWxg+bGI+23qvH//Jl+fW8ycR BY+hC0c/VGhjtOs5LkTsUOhh4n6RRsuH7Qdop6nIi6NzXokPALwDu9hjaOXOvmP0ZQXb gxdTCj0IqXSr3Lel4BabuFMvuiA2SBQDezgA0zKOX1qGCXmpfwwXK4NHvAzAHd95uiK7 s6EGNIQ3CKdQ90ODk85HcBx121o2yCXg3lxYJktJU8GSCnHGTIVj+fSsOI1SotiQ9ISd 1NDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=JSLG9eGc; 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-194779-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194779-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c78bea6si107503355ad.52.2024.05.29.16.15.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 16:15:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194779-linux.lists.archive=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=JSLG9eGc; 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-194779-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194779-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E97F1287201 for ; Wed, 29 May 2024 23:15:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E85C3161307; Wed, 29 May 2024 23:15:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JSLG9eGc" Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.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 B3B7514B957 for ; Wed, 29 May 2024 23:15:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717024505; cv=none; b=KnEdjJG7raDCicvtGWcOgSlq0WfBTUy8G0R2B4fMG7EvjrXPMFAO/Umn+WnofJ5tlEuU13e4ll8IvqgcgiO8Mze+uFM7lvS3g+u/vN/xF3xoaa0MIGXeXHMSti6O+Nr3CPMpNLAD5ZnTexy7BLWl0+mWNITotfNlKDPR2yDN0sk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717024505; c=relaxed/simple; bh=MjQOp5UWOk5r9+sxgG/QsPE0boIDxSM9o3fH5lVCqNA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=IrR+A5D3nZGUVqlLoI+5pZv3F+hUdVxA0YBZ03xawR9Oxvu/pCfOIvMKDwrcigL3YEteZbmbRqDg2hgD5TpIBCq/SyrjTV6M/vc7E4OpG1soIGMIYnMdfw9rLT3LoyWPiegF5+xs+X3hfCZdEAaTvlJr4zpveP9qn+I0b1KBkJo= 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=JSLG9eGc; arc=none smtp.client-ip=209.85.210.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-pf1-f201.google.com with SMTP id d2e1a72fcca58-6f8e859eb1eso298733b3a.0 for ; Wed, 29 May 2024 16:15:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717024503; x=1717629303; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=dnabaEVJa/tSEflSlXJy3215kO3e1psGL7hL7HuyYb4=; b=JSLG9eGcjrUqQJCpBBxatZbmztvgdGeS/xS3j+QwwubNOga29Yr+6h2nJutLb5G6Qx VZD3zwYaRLNVE+g4L94VbP9EuISjgQCy3q4PFMaBXZ+08q5RoBHtqYpOzFNC12esxAQf uvL+qZsouha4LR0Ad9jU0duTiH4+iqcMWdAzITunqf7Z8HoKD6Gf98qEbvDAIZdMo+tG c/WYSTWedltkToJsIY9JE73vHizg6VQEinEoSnIzzBlhqNczav60K61P3XVW2ic1a7jl JwNP4Y8/Uc1GdukK2R/9768GAi+Du6AmHyN8VjDQbJnu5mquSH1BB1QAPeZajMCYIAcI 7qUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717024503; x=1717629303; h=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=dnabaEVJa/tSEflSlXJy3215kO3e1psGL7hL7HuyYb4=; b=a0nfl1+suxubV7k7HQmgCqsqGzQUG6MWneizgIE37QVVuKr5Nf13eVsX2ksR4vZbCh YGsUwUkEyYqJcZhzfKitJf39VIZu1tlVUbcS/0mSPXLTncpgoRxzoO/Xy9Nmv7+14MrZ XbSMUnd4EHk67DO4wqODQeVZd+TIjSKFmzMBt4wzn8VTkxRES7/E93B8mHTg6gTV/yLA oNxpWL+xP0+D1eEvYCTvFoxrXHyBu3ezpT4sZAxiS0Fbjy28U6xeTK79UAqpz9jw3xDa dSBLYY1y1mCOgi7ShCMRCCC2l7AV+KG7IXPFpnS/6+q1t26MEHjrolxZxiuxlKIMpC23 VqmQ== X-Forwarded-Encrypted: i=1; AJvYcCXAorX1mUs3QmSwXb8rUlD5MwgLVHI4aPChlLGDMOmpnPuMxYwCbf7/7N8HkNCwP37NrnQ/P/GZ3X7fSMJodigaDo9lv8ZlexYNHJRY X-Gm-Message-State: AOJu0YyU5rcXu7BsJ76EX3tahzzv4A5MvIWORfiVNaOP6V1++8R2PcXm Cqm6pFr3OzmZwP2ZuCS9PoekB0Jq+/kiJA/YWxYoBOfhX12oL1U8GUCjokAjxvI+N3w2ydl/Km/ rEQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:2d8b:b0:6ed:d215:9c30 with SMTP id d2e1a72fcca58-702313ff946mr19851b3a.6.1717024502862; Wed, 29 May 2024 16:15:02 -0700 (PDT) Date: Wed, 29 May 2024 16:15:01 -0700 In-Reply-To: <50e09676-4dfc-473f-8b34-7f7a98ab5228@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <9bd868a287599eb2a854f6983f13b4500f47d2ae.1708933498.git.isaku.yamahata@intel.com> <5ba2b661-0db5-4b49-9489-4d3e72adf7d2@intel.com> <49b7402c-8895-4d53-ad00-07ce7863894d@intel.com> <20240509235522.GA480079@ls.amr.corp.intel.com> <50e09676-4dfc-473f-8b34-7f7a98ab5228@intel.com> Message-ID: Subject: Re: [PATCH v19 037/130] KVM: TDX: Make KVM_CAP_MAX_VCPUS backend specific From: Sean Christopherson To: Kai Huang Cc: Isaku Yamahata , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "isaku.yamahata@gmail.com" , Paolo Bonzini , Erdem Aktas , Sagi Shahar , Bo2 Chen , Hang Yuan , Tina Zhang , isaku.yamahata@linux.intel.com Content-Type: text/plain; charset="us-ascii" On Tue, May 14, 2024, Kai Huang wrote: > > > On 11/05/2024 2:04 am, Sean Christopherson wrote: > > On Thu, May 09, 2024, Isaku Yamahata wrote: > > > On Fri, May 10, 2024 at 11:19:44AM +1200, Kai Huang wrote: > > > > On 10/05/2024 10:52 am, Sean Christopherson wrote: > > > > > On Fri, May 10, 2024, Kai Huang wrote: > > > > > > On 10/05/2024 4:35 am, Sean Christopherson wrote: > > > > > > > KVM x86 limits KVM_MAX_VCPUS to 4096: > > > > > > > > > > > > > > config KVM_MAX_NR_VCPUS > > > > > > > int "Maximum number of vCPUs per KVM guest" > > > > > > > depends on KVM > > > > > > > range 1024 4096 > > > > > > > default 4096 if MAXSMP > > > > > > > default 1024 > > > > > > > help > > > > > > > > > > > > > > whereas the limitation from TDX is apprarently simply due to TD_PARAMS taking > > > > > > > a 16-bit unsigned value: > > > > > > > > > > > > > > #define TDX_MAX_VCPUS (~(u16)0) > > > > > > > > > > > > > > i.e. it will likely be _years_ before TDX's limitation matters, if it ever does. > > > > > > > And _if_ it becomes a problem, we don't necessarily need to have a different > > > > > > > _runtime_ limit for TDX, e.g. TDX support could be conditioned on KVM_MAX_NR_VCPUS > > > > > > > being <= 64k. > > > > > > > > > > > > Actually later versions of TDX module (starting from 1.5 AFAICT), the module > > > > > > has a metadata field to report the maximum vCPUs that the module can support > > > > > > for all TDX guests. > > > > > > > > > > My quick glance at the 1.5 source shows that the limit is still effectively > > > > > 0xffff, so again, who cares? Assert on 0xffff compile time, and on the reported > > > > > max at runtime and simply refuse to use a TDX module that has dropped the minimum > > > > > below 0xffff. > > > > > > > > I need to double check why this metadata field was added. My concern is in > > > > future module versions they may just low down the value. > > > > > > TD partitioning would reduce it much. > > > > That's still not a reason to plumb in what is effectively dead code. Either > > partitioning is opt-in, at which I suspect KVM will need yet more uAPI to express > > the limitations to userspace, or the TDX-module is potentially breaking existing > > use cases. > > The 'max_vcpus_per_td' global metadata fields is static for the TDX module. > If the module supports the TD partitioning, it just reports some smaller > value regardless whether we opt-in TDX partitioning or not. > > I think the point is this 'max_vcpus_per_td' is TDX architectural thing and > kernel should not make any assumption of the value of it. It's not an assumption, it's a requirement. And KVM already places requirements on "hardware", e.g. kvm-intel.ko will refuse to load if the CPU doesn't support a bare mimimum VMX feature set. Refusing to enable TDX because max_vcpus_per_td is unexpectedly low isn't fundamentally different than refusing to enable VMX because IRQ window exiting is unsupported. In the unlikely event there is a legitimate reason for max_vcpus_per_td being less than KVM's minimum, then we can update KVM's minimum as needed. But AFAICT, that's purely theoretical at this point, i.e. this is all much ado about nothing.