Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp227921lqb; Thu, 14 Mar 2024 09:38:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV8pBDLBBemn5Iw1NkAUDY76TKg2/ifclbjLK4AM3MZiblil+7YF7WHI6bwXWDJZHZ68Z0kyUIYy7UQgj2toCL6g9rcGas3sMp0qToAMg== X-Google-Smtp-Source: AGHT+IHt5mzBTavr0413EzB3NUL8C+nt8ITMu6z8CIsJ5ZyFyW1dWist7+DwJwWnLu8+qul57AhT X-Received: by 2002:a05:6402:5485:b0:568:a727:cf07 with SMTP id fg5-20020a056402548500b00568a727cf07mr560832edb.12.1710434287302; Thu, 14 Mar 2024 09:38:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710434287; cv=pass; d=google.com; s=arc-20160816; b=e0j23kY0iCKIhYhQHaSP2n/TU+3Q/q35cMlhNOfRkFbnVpv+fWq4O3eCuA9BpxKggP E8kfbHGKy7SeWy6igeUjIxOQzfLNKYmHajaSfXaNr1ZuS6CelMcVkpwDXbfKn8XkfNnM WtEEwCmvqjx+BhVMVhWvR8dRLBUOv7J+NbPTsdSsZ5g624z/mhRn4WtewTb+TmnIo9NZ Miu6+aF9E7wO8VjiO96zb/GfmapgYhRUD1XVX0z8lWhkZa+Idl1Q1hVcfsiIegjI7ICv aedI4LaB5E7W425DOdugg14h2leNYt1m/n2eIKDrsOcM7B+d9sAfn+5Oz6XXOkmxH+y5 icrw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vuGzJOsNr9ZXMtULREJfb2xAKQQR+mYddBCDgNtrmyg=; fh=P/quV/w7uXmndbL78FtEpLTNkJRPx4LJS51PzREvtL8=; b=FROuFhDDzWO8Izwwq/FdswA5iHvB7Ah0CuUaV5pRWyBWOofH6PmlqZ9xUaErnk+lXU lZ7YZklWyJ5WcQ9ictJ/jxffHpOikPpEE1M64f9YgbzQoSEWPu3u0X0MNXemDaXuWsyF nLrCD/sjc5f9wJIHkRhxRCW3e11CmtuGtmcsalPPMec/2hrDHImnW0UnSVMSUaGrB3Ah pE7sXecVKSTLTTQshsVS4T44JEMZjNk+gtNvOeWeT+LMs6kTQVy/c4IIAs5YR4X7C/an hkgVuJ1y24tLxpnOrc9NpH79QV3L5sO4DoqEvUNNa1c7NdN0Gr6k1MdwOqsNXVn0DmLz wdgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Iws/2AUw"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-103583-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103583-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id j18-20020a05640211d200b005687b20f45csi868226edw.286.2024.03.14.09.38.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 09:38:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103583-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=@intel.com header.s=Intel header.b="Iws/2AUw"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-103583-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103583-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 0F9D71F21DBE for ; Thu, 14 Mar 2024 16:38:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9909E74400; Thu, 14 Mar 2024 16:37:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Iws/2AUw" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEC111E529; Thu, 14 Mar 2024 16:37:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710434277; cv=none; b=o6oN4cXR1bgib0FUO8sebojMZjHnoPVeLI3OJBpkwzxzl3XyxGSq2jYSnYnu8pK5DNox7R8LB5K62VsDlTT+7opYQ2Q584UImLaBJwKSJJmKpA/uaM0wv8x+STTJQr4aLQjD02P48YAnp1Lypxd0DASdDVBcWYj+AAEsvPJ7si0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710434277; c=relaxed/simple; bh=89SB6/Lm3nQq91hRbocRMx7TBx2IIowK8lQdEgFpcVM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cdX1sIivNEGVzoU4xYjSuaeV62j+HkdFYjCqr+pSRoQZqOz4lSZ7Y+S/ZVX5Tn6bUt61IU2DQG5vZTp8k6CLXD1OeWkxMLuht+zkwwxdXxR9r2SUW8QGKKRzEOdUmqm3n6O17oaMDAMIKKfGY1rlxbFzndMQhb9RMi5JfUF7z38= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Iws/2AUw; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710434276; x=1741970276; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=89SB6/Lm3nQq91hRbocRMx7TBx2IIowK8lQdEgFpcVM=; b=Iws/2AUwBi09CfgV6XqwYxyDEKyvjLahJRzNrEHQWho6dxkXN6iUgnma Rw2BoWxiC9AKYlnKPtwLUiFXCUMmxbFTXRU7nli76FihOf2DVlBXxIvUl jVgHSS3gZm2qqMo/5pYLNhVRLqzCpX1GQTg7e1XGcU+s8zWiZrQ5bzsSq 4Dmoix+tPLHlqI0yTepWpcoYcXX6Vogzbydq4f8JoDk0J26jGqoqfhaR5 bzaDB2W2OvNA0iiJPcmiEZvxn5S3CbLQD2PIY85XKsQWwB1YPg0rZS1JR tnldyN/WdvhO4g6inlk7FfHSKu0STgXa4brxxo5SgCz0OAnNNAfYuxl5x Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="5135704" X-IronPort-AV: E=Sophos;i="6.07,125,1708416000"; d="scan'208";a="5135704" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 09:37:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,125,1708416000"; d="scan'208";a="12749010" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 09:37:55 -0700 Date: Thu, 14 Mar 2024 09:37:53 -0700 From: Isaku Yamahata To: Binbin Wu Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 024/130] KVM: TDX: Add placeholders for TDX VM/vcpu structure Message-ID: <20240314163753.GP935089@ls.amr.corp.intel.com> References: <1ae483bc-b279-44ca-b396-04aa480e3781@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1ae483bc-b279-44ca-b396-04aa480e3781@linux.intel.com> On Thu, Mar 14, 2024 at 02:21:04PM +0800, Binbin Wu wrote: > > diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c > > index 18aef6e23aab..e11edbd19e7c 100644 > > --- a/arch/x86/kvm/vmx/main.c > > +++ b/arch/x86/kvm/vmx/main.c > > @@ -5,6 +5,7 @@ > > #include "vmx.h" > > #include "nested.h" > > #include "pmu.h" > > +#include "tdx.h" > > static bool enable_tdx __ro_after_init; > > module_param_named(tdx, enable_tdx, bool, 0444); > > @@ -18,6 +19,9 @@ static __init int vt_hardware_setup(void) > > return ret; > > enable_tdx = enable_tdx && !tdx_hardware_setup(&vt_x86_ops); > > + if (enable_tdx) > > + vt_x86_ops.vm_size = max_t(unsigned int, vt_x86_ops.vm_size, > > + sizeof(struct kvm_tdx)); > > return 0; > > } > > @@ -215,8 +219,18 @@ static int __init vt_init(void) > > * Common KVM initialization _must_ come last, after this, /dev/kvm is > > * exposed to userspace! > > */ > > + /* > > + * kvm_x86_ops is updated with vt_x86_ops. vt_x86_ops.vm_size must > > + * be set before kvm_x86_vendor_init(). > > The comment is not right? > In this patch, vt_x86_ops.vm_size is set inĀ  vt_hardware_setup(), > which is called in kvm_x86_vendor_init(). > > Since kvm_x86_ops is updated by kvm_ops_update() with the fields of > vt_x86_ops. I guess you wanted to say vt_x86_ops.vm_size must be set > before kvm_ops_update()? Correct. Here's an updated version. /* * vt_hardware_setup() updates vt_x86_ops. Because kvm_ops_update() * copies vt_x86_ops to kvm_x86_op, vt_x86_ops must be updated before * kvm_ops_update() called by kvm_x86_vendor_init(). */ -- Isaku Yamahata