Received: by 2002:a05:7208:2202:b0:86:316c:7444 with SMTP id s2csp97915rbb; Thu, 30 May 2024 16:21:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCULziPF7g53Laj7fmSXjztOL0JgrLCoQbkFWG/1NYswxI8gFkqxyD56rteVqVoV+d2sVFjIvq5tTi4uXTehzNcM8/a45q3jaFkFf4X6lw== X-Google-Smtp-Source: AGHT+IHl5Mf/Iu5eiPfTX30LiuhhHxuaLS+Kzi+1Yt/rKhAcuOE14IaVb4a+6vjfLceSRxQj6cvf X-Received: by 2002:a05:6e02:1546:b0:371:bacd:797 with SMTP id e9e14a558f8ab-3748b98e627mr4268895ab.15.1717111314419; Thu, 30 May 2024 16:21:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717111314; cv=pass; d=google.com; s=arc-20160816; b=XrC6XQTIbEC7bK76voDaXSVGMzZyZapiK1gl/8LUMFEBVNt1Yifc8jAe66rwSja2TG W4SKaCkeLq8x7azURe8iMIO3rUOa+5MA3XvUjDE6xwANJ/NCmLEtxUzS09vwegQN7PDi vzM+J1yxc6heQIrWH5J+1qCGfopkD0Z0B7Rjphdpbe+cQ+hIy6yV8DxMYoAlLenomeAh Jh/KbypH9H13K8LLl1lPrw8I2LAd2wdBWGjjjGfY/SzGfOnCaXNa4XB/RylYYS1oNOY4 8p0gCKWftwqRoRSZ5nQ9+xq03xAOjSKsltkAoanfrqKCU/rUnBWSmB8wxAgLoKk0Ze8j /u5A== 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=4ujQILWXT37aY3kE457ngW3RW7Zg+FC2HbFYHJC4pvU=; fh=eU/M5SEaouJRx3UPYsZ7I7Pti8qzNjRK5CxGXYBiCO0=; b=Hjpmqfmz4OxFOESzX8ZxOPWLApxMntqS1CiZ1DY59dW2d5mSxNrRjPvJvBpc+LpWY9 E5r5SEb4zv529UEqe74qeREd++y2CrenESAbHgK/ijsZ54Z877h5VqaAgrQdG+ZNPLco kC7nxPZ/8hreLL3qQI8iF1Vvnwz2kkekzgK7GRJsNPmSgip0f8dDthSc0BpBITTDsET+ s1qaCLK8wjXnmO4kQbvyOhnZkIo+peXJhd6nIC9Rc9ngEYXRiRNMlMLaUxl2l/PhOxLK 1MvX5QaPn2Fl6znrXKmlRGKxSGu32OHHOTaRK4uBJmIvJ+q9VqjleRpY4u4ujxE29DhG gIFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Mb9IFab9; 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-196014-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196014-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35b40c31esi428273a12.585.2024.05.30.16.21.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 16:21:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196014-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Mb9IFab9; 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-196014-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196014-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5CBDBB238F8 for ; Thu, 30 May 2024 23:12:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BBE1B186280; Thu, 30 May 2024 23:12:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Mb9IFab9" 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 77F9018399B for ; Thu, 30 May 2024 23:12:47 +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=1717110768; cv=none; b=SbJcHrbbFiAnelbVdm/jYEPCjhKTSv33gFMJH4C1n8JAFTGoem7YzrdpfDc15/fZg+U9Tlek2OxNpIVzeRbiM23rMVh5ln4ImQ/n1ggTp+2srwFUU2DuWOkE6u2iY9BY6CHuJhc45cY7g2khQMe+PFAID9G1t/AE6fPeNRWIcVg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717110768; c=relaxed/simple; bh=eTliIFmIq5hD6o87LUn9o7uoz31PWHrz5z33kKfUKVw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=t14Zjhonuk/2EFgmbQm3il9kPUXilfZ0017l7lzt+rv3ya57ILBOFZnhRPS9pumMqBm5H/yT41NgQEXCV9uhvPndkzLjwQadizIZJEMi7JHqLIjIaTk/nAWt4cCm0U9k5AHY5bnxg5GoggibVG5/ix49z0NfWpPiKSRhpuR7WNg= 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=Mb9IFab9; 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-df77196089eso2186949276.1 for ; Thu, 30 May 2024 16:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717110766; x=1717715566; 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=4ujQILWXT37aY3kE457ngW3RW7Zg+FC2HbFYHJC4pvU=; b=Mb9IFab9AbS7uPGRhsGuyWeIM2h975b5GA4RLtTqQyW62Fe2XkrI1v9tfxcfjm5PN1 UNs4CQqax3Ipr9l47lxRCibKuSZtzbH1j8CZasFYgCr8NwImBmkRiB3SSMTo3W+tUHDH lQGp7thJIWMItWVWuMrP4VH7pIjW4vFFkXE7EY0iJYHhAYdZH1IRGsIVttV2S0uvPGbH VgazKCrggw+PXMvFy5LSEWS6x1VMvUr9HhFDmJvjCoTWZ8Hs0Jprj0EKvM6P4U1nsmUK eKDbjZvjPTJpZM6PMkwcWeXenw8oYxJ5LTEzdbxlEUNK1pNxWM9E0HseEV/OITDDh0Ly FQeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717110766; x=1717715566; 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=4ujQILWXT37aY3kE457ngW3RW7Zg+FC2HbFYHJC4pvU=; b=kHGsR3AurK+6ZZ7fDGVQ9zbV371Rccs7bkoG58OkSNdZmKKY9gy9FXd5BNaydteOPm pVjO3DkapdE4RMdWi4+2gndIzvNDu2mP08Ohwb3ob3xB4tRhLIEbI1OHP292rV8lXDc/ nZjqvKmz8I+CJDewxHrOAtXFwKJ+M3rrPxhBdWOk54YV25QhGAxrsna1IpGNM3iB9CGr l1cbpe4wO30RFjGQR8bh3T+3QmO/xijN5aF+u2WhyOT6wEAws+5FsCjT5/CbWMR9J+hX k9VsumCfpLTJH4PZJ0xLDEAn4xbZOk2QoR8CGrYGM3V4AUt6LaLyCMU0v7EtuiCsiJqM qU/A== X-Forwarded-Encrypted: i=1; AJvYcCVxloY6zPS/vpFpdiUxkDsgPN/9/sSy/PKh1ZgBY11IQref03DQ8hJq0A9yYxdGaVVqANG/Ac2uO6D6wE6/Y4ySDwC/Lv/ghJxmLFyc X-Gm-Message-State: AOJu0YywuTcitILm/M/uZSlzUv0hUwnCulMopYDseYyUthCq39H/WTly 14kHIdhgldk64dDaqM03II4yseaRoGL+1+ZTO+qcey0f7xvDgYcXSQ0E+NIwpV8MJI8ZNpTeBwz jiQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:1003:b0:df7:62ec:c517 with SMTP id 3f1490d57ef6-dfa73dba365mr10840276.11.1717110766469; Thu, 30 May 2024 16:12:46 -0700 (PDT) Date: Thu, 30 May 2024 16:12: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: <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: Tina Zhang , "isaku.yamahata@linux.intel.com" , Hang Yuan , Bo Chen , "sagis@google.com" , "isaku.yamahata@gmail.com" , Erdem Aktas , "kvm@vger.kernel.org" , "pbonzini@redhat.com" , Isaku Yamahata , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="us-ascii" On Thu, May 30, 2024, Kai Huang wrote: > On Wed, 2024-05-29 at 16:15 -0700, Sean Christopherson wrote: > > 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. > > I am afraid we already have a legitimate case: TD partitioning. Isaku > told me the 'max_vcpus_per_td' is lowed to 512 for the modules with TD > partitioning supported. And again this is static, i.e., doesn't require > TD partitioning to be opt-in to low to 512. So what's Intel's plan for use cases that creates TDs with >512 vCPUs? > So AFAICT this isn't a theoretical thing now. > > Also, I want to say I was wrong about "MAX_VCPUS" in the TD_PARAMS is part > of attestation. It is not. TDREPORT dosen't include the "MAX_VCPUS", and > it is not involved in the calculation of the measurement of the guest. > > Given "MAX_VCPUS" is not part of attestation, I think there's no need to > allow user to change kvm->max_vcpus by enabling KVM_ENABLE_CAP ioctl() for > KVM_CAP_MAX_VCPUS. Sure, but KVM would still need to advertise the reduced value for KVM_CAP_MAX_VCPUS when queried via KVM_CHECK_EXTENSION. And userspace needs to be conditioned to do a VM-scoped check, not a system-scoped check. > So we could just once for all adjust kvm->max_vcpus for TDX in the > tdx_vm_init() for TDX guest: > > kvm->max_vcpus = min(kvm->max_vcpus, tdx_info->max_vcpus_per_td); > > AFAICT no other change is needed. > > And in KVM_TDX_VM_INIT (where TDH.MNG.INIT is done) we can just use kvm- > >max_vcpus to fill the "MAX_VCPUS" in TD_PARAMS.