Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1224172lqg; Sat, 2 Mar 2024 23:59:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWSdtbJ64Ciq0fPiX9/7ATJprnaoHjHFYE3/2VJ4F7k5sllHRagFmnxESQnrz0svLeq+w913cJ17FuGFWe1n7cOTlbP6oXNwh9ROyTvtg== X-Google-Smtp-Source: AGHT+IG03FWbnC8Qx0ug+m5L1sYvWKU+dSDP6W90i3oQ1Y665HbqlKOpP7bkqIDzGlocrtApE0Rr X-Received: by 2002:a05:6a20:958c:b0:19e:a36c:36ef with SMTP id iu12-20020a056a20958c00b0019ea36c36efmr8420381pzb.48.1709452777253; Sat, 02 Mar 2024 23:59:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709452777; cv=pass; d=google.com; s=arc-20160816; b=hYpKlxj70TEZDI2JX6TPvdacZyVEfsiFBULwZroWj6ggzkutrW7RpXfAMFxrTb5VrZ OlQuQ08SNwYHF5+Jk8tTnOKfmM8VH5CmXudCNtwHWuTMhveFHqa2xfciYpr8TM9sO7PU 9S1yqHu+ZlGpO8FnzLj57Vim1DagDjAOQfWbHrnj/wd0a5C1w/DFOyRNtj31oLvutYVP rAnhmh5cdgY69LzRVWirSAfWO42Y8HPKer6FUKWChrzS/znMDpSIVmmhQMx85R352BOh eFelaONylYKUsZfro56GV4mAi9wvCGnHqGak4rv2MtzFlNKK85KEnf0pg/1uJuL98z7o lRTQ== 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=RqwODg/5+QRH2j9tJBIUiO1kssEY3u+9VKVqk1+Xx0w=; fh=tgUWUbuI+B0KV3Xw+e/6lpHO2uTJDIACNIPu4ivbyA8=; b=Rqrk+J8FPsQF9KNl+1oygzFIbkuS61XV1p3qI76Oz7XtRGfpgb5lEOl2zpKieuO/iK BA/ezIsqOgzj56s74rvGEZup+RFw4zBUS9XbholATPzsgSPbmTS8V/gt0x0KliGkTgNq YFxSlzRPDsnHlNcASFAn1Dju1YP8YeEIcCHochQtxnp4yE/RFI/O78FOU4HxfN21z5EC ogSb3Epm+rO4De7miQhUm/oHcRPbv4P5hPOHNs+fqTAhKg2Z9c7+a2zbPJp0s6ddD+lD biAG7xyEmqwjW2N84Cl5i7HhPxDvZsNTXHte1Wg+iuLeNMI0Tdzv4EIFt1BnNUj9AFa5 k33A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BH6uByEa; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-89656-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89656-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. [147.75.48.161]) by mx.google.com with ESMTPS id y9-20020a17090a600900b00298d20b37a3si8664044pji.7.2024.03.02.23.59.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 23:59:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89656-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=@intel.com header.s=Intel header.b=BH6uByEa; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-89656-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89656-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 BE07AB22517 for ; Sun, 3 Mar 2024 04:51:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5632379DC; Sun, 3 Mar 2024 04:51:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BH6uByEa" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 B331753BE; Sun, 3 Mar 2024 04:51:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709441493; cv=none; b=Uk9Dng+4FeWaQFtndKlIZfm/HigD55C7JVOVofST0tJGDLX7IFecaqXuUlY7Hll87xMU+zbOWIix4f72exNJyPgN/yaTLYtqRwT3mPHYoeBBMUYx8hWdl9QcjoHPrYdiQWXloEBKwUFNbfpr8f2l+dQa5MZRmpnODYgmFlWUpKI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709441493; c=relaxed/simple; bh=DiznAYK71m8KjN3kngmKzjZ08qDdBKWha23BeRkoj2U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GzZG/0e9IDcbemzcUc/ctcAgKMLDawIHLxdU0/eFJkNCnx5shxD2OrmBdRk/NvEXHtpTS37hSFphBs1wfisV83OyWUFGBBgLgeE2tdR8bBt61TvDA16tnClS2oWkzv7XIM19OaYw1e4ibBN11cRdu9OoCBA3e0cHJ1untL4D/4c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=BH6uByEa; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709441492; x=1740977492; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=DiznAYK71m8KjN3kngmKzjZ08qDdBKWha23BeRkoj2U=; b=BH6uByEalP3xReEcXzs7RGVVqK58iHJnXN5Hkf0I1weTCBB2Q7QqWInB c8SnAaSWQSjZmqNOFZfaxjgo3PhxIf6iUTHCUnk1q2Qh1v0jauxlXOGzX XTVktWsNSLgBiFHyZ55K7L3U6mbnDY947lbfwtdJDNZFaWoGe2GylDrld GmuWLAcA9U29gAtgSGG4EPo9p9dZt8mbpfl6sRiAcsO7a4wYuLXRxcbA6 SDHsxV4mm6A0CJcvhar+qP1qH0cCpmGQLSGvEabEG+Noui+XlSoZhQtpl sZlLsEOF4Yujq0MsBqkZdkucwf5OmUM+C5yKc+I/2mMlELabk6Ltij2k4 w==; X-IronPort-AV: E=McAfee;i="6600,9927,11001"; a="7723694" X-IronPort-AV: E=Sophos;i="6.06,200,1705392000"; d="scan'208";a="7723694" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2024 20:51:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,200,1705392000"; d="scan'208";a="39621421" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmviesa001.fm.intel.com with ESMTP; 02 Mar 2024 20:51:29 -0800 Date: Sun, 3 Mar 2024 12:47:19 +0800 From: Xu Yilun To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, seanjc@google.com, michael.roth@amd.com, isaku.yamahata@intel.com, thomas.lendacky@amd.com Subject: Re: [PATCH 11/21] KVM: x86/tdp_mmu: Init role member of struct kvm_mmu_page at allocation Message-ID: References: <20240227232100.478238-1-pbonzini@redhat.com> <20240227232100.478238-12-pbonzini@redhat.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=us-ascii Content-Disposition: inline In-Reply-To: <20240227232100.478238-12-pbonzini@redhat.com> On Tue, Feb 27, 2024 at 06:20:50PM -0500, Paolo Bonzini wrote: > From: Isaku Yamahata > > Refactor tdp_mmu_alloc_sp() and tdp_mmu_init_sp and eliminate ^ tdp_mmu_init_sp() > tdp_mmu_init_child_sp(). Currently tdp_mmu_init_sp() (or > tdp_mmu_init_child_sp()) sets kvm_mmu_page.role after tdp_mmu_alloc_sp() > allocating struct kvm_mmu_page and its page table page. This patch makes > tdp_mmu_alloc_sp() initialize kvm_mmu_page.role instead of > tdp_mmu_init_sp(). > > To handle private page tables, argument of is_private needs to be passed > down. Given that already page level is passed down, it would be cumbersome > to add one more parameter about sp. Instead replace the level argument with > union kvm_mmu_page_role. Thus the number of argument won't be increased This section is hard to understand. I'm lost at which functions are mentioned here that took the level argument and should be replaced by role. > and more info about sp can be passed down. My understanding of the change is: Extra handling is need for Allocation of private page tables, so earlier caculate the kvm_mmu_page_role for the sp and pass it to tdp_mmu_alloc_sp(). Since the sp.role could be decided on sp allocation, in turn remove the role argument for tdp_mmu_init_sp(), also eliminate the helper tdp_mmu_init_child_sp(). > > For private sp, secure page table will be also allocated in addition to > struct kvm_mmu_page and page table (spt member). The allocation functions > (tdp_mmu_alloc_sp() and __tdp_mmu_alloc_sp_for_split()) need to know if the > allocation is for the conventional page table or private page table. Pass > union kvm_mmu_role to those functions and initialize role member of struct ^ Should be kvm_mmu_page_role Thanks, Yilun