Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp747259lqp; Thu, 21 Mar 2024 14:28:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4dcIDPa+eGwpMZbfqCFkE2cDtEpTnwHcbK/Tq2iIEGbhFFjB8XBESpa4iLCCjlDBmQao+boecEiTT4PWdS38Z6V3F3M8HqPSHJ1r6yQ== X-Google-Smtp-Source: AGHT+IGooO7ECKTCwfEPVOXUPSOeFQb8sl2C/nS3D/xNixTczXdlTKniIe6zY1NVIXZ410ii6ixC X-Received: by 2002:a05:6a20:43a8:b0:1a3:80b8:4c43 with SMTP id i40-20020a056a2043a800b001a380b84c43mr828775pzl.49.1711056515686; Thu, 21 Mar 2024 14:28:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711056515; cv=pass; d=google.com; s=arc-20160816; b=biZV3n7Tw4B7owGqD3N74mKczrqIgTCYeI4/xopchD+LAEkVXPggQ1e5cQXo7rTvAH tRVXML8Z0LeKLLeLkkZwxI7RUzCRMC6C/fB9nNduVUU18u/8BLl+/0KSuXdFBiFOm9cT Q5zQd2uPkUC8UqUR0yPiVKhNU4adIpkVAhcY7smPmZbKBUILdM441h7Lu44pbwWK/Xeq pYLpu9Dp9ppqu1wiH04QwT4h4r/HOz2NxfxdDQD2skdouQrt0Yf3kkV+pENZFxS6emNi 8eAeMAhIMHPHXat+3+NakUROsdPCyLHcj3IwxiF2oMHTwyZhpYn/Yotjfm/vDAbxIqcZ XNgA== 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=TH2tri2gLUkZkRb5RNSWqxv4+/CyawaK021ipxkE3f4=; fh=Vj5trRVmnU8XdLFcSV47Z6Q81f2aWcrI0gBACy/KTKk=; b=uIyijKgwTPnaRJPz5LPOm81bthzqo1oD8r4FSm3KhUZPL8ScgG3zVJyv3lf7Rd6+wZ izHCGvCwxJ8ttVv69kUjUPA4AzLpSjaAGLmb0kVw81t+t5w0cO6F8TLK+aspd+c6PFy7 u0d/M03c7OW0uWM4ipUAvE0gJrDe6lsYB7pw9J3nDDTKhPct6S+pgvV7Aob0Rh6968fe F/pgrVTRxMrOWaJCctQe3DsM732IfVGhHXxwZloOFfkOfUa8TiW0Rgx/BQYE77jG+20/ sgTXmrszBOt5UnUCn6Moht5oLAHX663q9DcYk1L6WGFD9tlos/AaybW0y4WaJ8NmO5KE D0XQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CiJNTqx7; 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-110693-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110693-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 137-20020a63018f000000b005d8b8f81dd2si500103pgb.700.2024.03.21.14.28.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 14:28:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110693-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=CiJNTqx7; 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-110693-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110693-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 97FAAB2359C for ; Thu, 21 Mar 2024 21:24:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5CFC213664E; Thu, 21 Mar 2024 21:24:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CiJNTqx7" 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 630EC135A55; Thu, 21 Mar 2024 21:24:14 +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=1711056256; cv=none; b=KqIIc93a3U+7hzPZE6yWIc9hT8Jn5qT8/AnYGfr5ZpW2TePBUzMBbkEXcWwcQHqTLV12C4D8bi8t/c5psL4gW/T7ErLqE6gMHxRKc8151Eauc2S20GKGGb2gIDd3Osf7XD+PN9D85vvftgElZ6p2TcaRvyK0AZEeKHgfagAbJEs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711056256; c=relaxed/simple; bh=0YXDk0lo2amfuxfoAWLgdqVOuj49kR3I7zPhp3zFKBQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gJsFsuD2KSh+ODOCAfaV44Lc9fnShoS2WocTBJgMxYLOB0HzdepnkLtNjLx9/iJZrzrEqjmqmcErpvQtFvHmtFAcsRJliJNjiZxWVBnWLlL/Tts2LDcg8rkO/bQiUf94JQqfhmbKp9UdBZOz+sK++Jj8EKi24nPU1kuVWAaDo7E= 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=CiJNTqx7; arc=none smtp.client-ip=192.198.163.12 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=1711056254; x=1742592254; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=0YXDk0lo2amfuxfoAWLgdqVOuj49kR3I7zPhp3zFKBQ=; b=CiJNTqx7EL8rdHXuut3DhS9wrX3J1d4vo8CVbcJ9AqA9tVfTVX1Jk6xW fxy7Gr2LPRUw7TP3vtLLcCsqFGXS2tx0SJW6y3Hn9fMQSemEknjrNpE9O Uw9frRpCIt9vYyIOHZxpqt7Vz6LEGQWITMfb8Y5cHUPR9oNbnQhFc0nXj /b4dqvzbf9eFdY64eyIiNDlukLSwBahKjJLwPDEXqn/Ra995RqFXWbCni j2Vah4QPO2fpNdjrXuGo6t5NaR9+Z1zlxu+EnCCd023cIihekbS2Ts1er 3gBtDOoyEjEfNvt6pz5Riknzs/ZklCqYG6zb9oCIPGenb4pCjJD+Erg7K A==; X-IronPort-AV: E=McAfee;i="6600,9927,11020"; a="9847269" X-IronPort-AV: E=Sophos;i="6.07,144,1708416000"; d="scan'208";a="9847269" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2024 14:24:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,144,1708416000"; d="scan'208";a="14627431" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2024 14:24:12 -0700 Date: Thu, 21 Mar 2024 14:24:12 -0700 From: Isaku Yamahata To: "Edgecombe, Rick P" Cc: "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Yamahata, Isaku" , "Zhang, Tina" , "seanjc@google.com" , "Yuan, Hang" , "Huang, Kai" , "Chen, Bo2" , "sagis@google.com" , "isaku.yamahata@gmail.com" , "Aktas, Erdem" , "pbonzini@redhat.com" , isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 056/130] KVM: x86/tdp_mmu: Init role member of struct kvm_mmu_page at allocation Message-ID: <20240321212412.GR1994522@ls.amr.corp.intel.com> References: <5d2307efb227b927cc9fa3e18787fde8e1cb13e2.1708933498.git.isaku.yamahata@intel.com> <9c58ad553facc17296019a8dad6a262bbf1118bd.camel@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: <9c58ad553facc17296019a8dad6a262bbf1118bd.camel@intel.com> On Thu, Mar 21, 2024 at 12:11:11AM +0000, "Edgecombe, Rick P" wrote: > On Mon, 2024-02-26 at 00:25 -0800, isaku.yamahata@intel.com wrote: > > 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 > > and more info about sp can be passed down. > > > > 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 > > kvm_mmu_page. > > tdp_mmu_alloc_sp() is only called in two places. One for the root, and > one for the mid-level tables. > > In later patches when the kvm_mmu_alloc_private_spt() part is added, > the root case doesn't need anything done. So the code has to take > special care in tdp_mmu_alloc_sp() to avoid doing anything for the > root. > > It only needs to do the special private spt allocation in non-root > case. If we open code that case, I think maybe we could drop this > patch, like the below. > > The benefits are to drop this patch (which looks to already be part of > Paolo's series), and simplify "KVM: x86/mmu: Add a private pointer to > struct kvm_mmu_page". I'm not sure though, what do you think? Only > build tested. Makes sense. Until v18, it had config to disable private mmu part at compile time. Those functions have #ifdef in mmu_internal.h. v19 dropped the config for the feedback. https://lore.kernel.org/kvm/Zcrarct88veirZx7@google.com/ After looking at mmu_internal.h, I think the following three function could be open coded. kvm_mmu_private_spt(), kvm_mmu_init_private_spt(), kvm_mmu_alloc_private_spt(), and kvm_mmu_free_private_spt(). -- Isaku Yamahata