Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1505025lqp; Fri, 22 Mar 2024 18:37:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4HfF/SnHOLHY1gj9NlH2m/1dygBOvp/wefW7XR/0b7WHRec8k7FYLDbGyerCITv1OyQ44XjTJ5HVSd68SfepPlb408BQKYF5N40EFTA== X-Google-Smtp-Source: AGHT+IH2EFZbcKDg2gJooMAr5Cyn1DkxKeivrQF8QiI3OgELUWCJgsGRmOSmz8uzYj9nNvRT1otd X-Received: by 2002:a05:6358:3a03:b0:17f:5b3d:1611 with SMTP id g3-20020a0563583a0300b0017f5b3d1611mr1290021rwe.11.1711157820922; Fri, 22 Mar 2024 18:37:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711157820; cv=pass; d=google.com; s=arc-20160816; b=k7ezn/9uzRvXm0wByGkLMbQAFC7K2y/9X91o1Cbnx3yqP3HAOZdRQOkLaFL46/7tGg kOzTgEXfhoHVMWMjDfqFj+9HD3h0oKydYWL/LMTZ+mROkdwJ+AiDVTD2d6MvCYrY4mJk XBaRY67RnROwOlq5GEkiO5f0MTaHuXEiMd86SAkgRHH++XZSTi9+y4XweKIGVJ5lvDdo R2K4P4u+YPdJjzdHFfpqjlmzyhHHNuXcBT4O0U3vC7Dwa8TnOeMzCCG1X1CNYJM3c07D PolnHi1ZRUGWbc+9R18TWBiShd2HpjKcA6VznbmsikY4dMJjo0sPUvN9oDDNENhQRrXS /blA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=74wCmusYZ4VxDlLRpuGLWKNzKXk55GIPWKQk4iTvHX8=; fh=go+TtFjibR1uT8GqWJETZBnc+De4cwEtCPu7WIb71qc=; b=xGvcRkz1+mMUPaMOgSYrECyPY4Tz/l0sKGsAOSaSZ2UiFBuXhOwqL2mWlys+/saBQ3 wCeUHnYMRcxTrsuCzMytx/yh5xhWxgRGnIL6gMtTnBwptdr/U8YGVpNSVn6Z6pvRye3j Qr9MrymseGgSY3C/aFUsby4nPj2AfXxmcCCv1s7COHoxFi3LEkrnXL1rswKNSznmS32m OPwF5FKqbiKCe8pD6iieaIhxSP7vlauKMsNI4pdwKLe5KLuYMNIFaFGhLp06ysyBSxGw 6KAX3WC4aPVlsOO09w1/UNNiTd9Uangjz/B1a54GYbxQDmklOiEDTpUnfucQ9Mdmw7HD orGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Nuc9giT2; 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-112161-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112161-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i7-20020a63e447000000b005e2b17c97efsi3082575pgk.28.2024.03.22.18.37.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 18:37:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112161-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Nuc9giT2; 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-112161-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112161-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E7377B22A39 for ; Sat, 23 Mar 2024 01:36:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 647B315A4; Sat, 23 Mar 2024 01:36:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Nuc9giT2" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 BBC3EA41; Sat, 23 Mar 2024 01:36:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711157805; cv=none; b=tkEQl19ab/g93yUknkiYZ6888+RyiEYxCXFws7KVR2poYhogz8u3x63QgPL+fuky7glvKUTDYIi7tIcDu8DVWFStR4u9NNcABy8bJeecO0wwBJG8xLMfkU0mQgdAvvAml1/rOji6e1pQ6BZn4iMxaBS5YQOUpU4oy4rZHc9MYyE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711157805; c=relaxed/simple; bh=65ixw4lK/doWtlz4tMa11O5NDcLxBpEhPUhTqIqJZnQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=O2VPuz+stAOf7fiBOGW1SvVc+zk2N0mEdS5HDy6LZ2iQeq0Tzihi58cYB853SHWXPL+7qw482VMkuID1nYBURtofYRx6BumVKSdrBI/HWh3nv6pHWagYITZlqe0+37E6Ol3iJrc9ZdZfOjqsORQzph9qZP6560r2AygLqsvGWYM= 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=Nuc9giT2; arc=none smtp.client-ip=192.198.163.14 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=1711157804; x=1742693804; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=65ixw4lK/doWtlz4tMa11O5NDcLxBpEhPUhTqIqJZnQ=; b=Nuc9giT2/b3TU6hrnMlSBdtU12p5Ca34ACV0W9UxoRY8V68sTGw0Rx0g 2G2zc32LMMkSAdURy8TAQ6btMzZATvBimaMyc7HN6KwmssvkZvr3b99Md nG6rcJwiiW3NNAT/NGyYtZmjKKGOmnTmeeD9A+fpfKG/eVQK/nwWzu2li 6PP4UMN6ptteg6LPxh8Mmn9VvmxkmhFUJ4SO4OQdKMIZz3a133NBKOwNx kdrIPWoQ1Tn+V8yFhu/UrYpt0PXpTFX7FE/lOtVCJIVqNd3dGkw+NW6jW WLnF5XVkoKKeVr4cucbzOSPrneAkvcsIbJstYow1X7LhaKYSVSywvjWDj g==; X-IronPort-AV: E=McAfee;i="6600,9927,11021"; a="6434356" X-IronPort-AV: E=Sophos;i="6.07,147,1708416000"; d="scan'208";a="6434356" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2024 18:36:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,147,1708416000"; d="scan'208";a="14992270" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2024 18:36:43 -0700 Date: Fri, 22 Mar 2024 18:36:42 -0700 From: Isaku Yamahata To: "Huang, Kai" Cc: "Yamahata, Isaku" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "isaku.yamahata@gmail.com" , Paolo Bonzini , "Aktas, Erdem" , Sean Christopherson , Sagi Shahar , "Chen, Bo2" , "Yuan, Hang" , "Zhang, Tina" , Sean Christopherson , isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 038/130] KVM: TDX: create/destroy VM structure Message-ID: <20240323013642.GE2357401@ls.amr.corp.intel.com> References: <7a508f88e8c8b5199da85b7a9959882ddf390796.1708933498.git.isaku.yamahata@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 In-Reply-To: On Fri, Mar 22, 2024 at 02:06:19PM +1300, "Huang, Kai" wrote: > Roughly checking the code, you have implemented many things including > MNG.KEY.CONFIG staff. It's worth to add some text here to give reviewer a > rough idea what's going on here. > > > > > Before tearing down private page tables, TDX requires some resources of the > > guest TD to be destroyed (i.e. HKID must have been reclaimed, etc). Add > > mmu notifier release callback before tearing down private page tables for > > it. > > > Add vm_free() of kvm_x86_ops hook at the end of kvm_arch_destroy_vm() > > because some per-VM TDX resources, e.g. TDR, need to be freed after other > > TDX resources, e.g. HKID, were freed. > > I think we should split the "adding callbacks' part out, given you have ... > > 9 files changed, 520 insertions(+), 8 deletions(-) > > ... in this patch. > > IMHO, >500 LOC change normally means there are too many things in this > patch, thus hard to review, and we should split. > > I think perhaps we can split this big patch to smaller pieces based on the > steps, like we did for the init_tdx_module() function in the TDX host > patchset?? > > (But I would like to hear from others too.) Ok, how about those steps - tdr allocation/free - allocate+configure/release HKID - phyemme cache wb - tdcs allocation/free - clearing page 520/5 = 104. Want more steps? > > + if (WARN_ON_ONCE(err)) > > + pr_tdx_error(TDH_PHYMEM_CACHE_WB, err, NULL); > > +} > > [snip] > > I am stopping here, because I need to take a break. > > Again I think we should split this patch, there are just too many things to > review here. Thank you so much for the review. Let me try to break this patch. -- Isaku Yamahata