Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2434296lqt; Mon, 22 Apr 2024 10:30:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXQm9XUHZSQSOlWBr2rPYrxJFZPPQQZlKzWhe6/nOTKlgCp1+j+1/jvXdgnAl1Ny/wQyVnYV1nfSAF2GKaV422WgJM4qtHppuuVZXlqpw== X-Google-Smtp-Source: AGHT+IEcxVS5uYYEdEHXnW6kedvZN4ktR0Qo//2NatxBqAoZmZgCs+ND391xXNbfX9ZgI7/tsYpy X-Received: by 2002:a17:906:2318:b0:a58:7171:3914 with SMTP id l24-20020a170906231800b00a5871713914mr339281eja.16.1713807029343; Mon, 22 Apr 2024 10:30:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713807029; cv=pass; d=google.com; s=arc-20160816; b=INpNiPPS+nO0pKNNM9LpcC9iNCWJlO0Oe0VbUHPiYNTUoDfEpmr8cp64xyhu4eDgZ5 uaS20V3v0CJGOQvpBQobNmIrwpZJhInYssoHo4jbBm3vtF7kZXdBVrsKgoPhTwz/jlOD WqWip0EoxQF8Ym41vSMIphMnZ0wb96KquFT16WgNu0Xd1B1tAdF6LAVBCLJ11vas8PHg 4RrHq4Ai4p1YRDxN/1XJjoNyIEveh7yKvmozU/l8JyMu1WZeOohRfxfCP8YqJoqqglH5 tmKNddcVJQDZrljHlGpfeq7x8rlCj2V9nCXBoMxpdmwGjmFnvH6/m+oEKU4D1WbUrF1q NgJA== 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=QxQU87GU4E5zmBCmEazkEK3N7jNM1jYR2fczpgoNk6Q=; fh=1uJlVILT13PxTu5NU9rcLIdvaY3pePDg2x1zZAh8NYU=; b=kBFhBtrl3WMZKz3X5QJr5vIzLrbKQdkUzcnmU+uqiYKvXH+a/+uqM3mtQtf2ggAPbm CQhYajBwlOmdaPqCOU0Zmt/4vo52xwOXP7IUTtAbmHryNHbnOO+wdTiy1To7QhE7+vJV GYLD5wtb2r4a4XZARbN/Kz2vfflXke/XAnmMYVc9ZFXTWxZIkL3iSzc5ShJDkdwGPsSi qhkCBp2kAirozb09gnmXIUEEaE7dLHuUpG+rNUXtQIfSlVAe1MWnub+pMD4+dwBVGN97 TDchWnyhOK3CN3sj3ODko+e8ctplWi6PP6Mt+vVppIsBJWehpij330a/SJxQBB5Qqifp yquw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DqYLxSrH; 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-153798-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153798-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id fy10-20020a170906b7ca00b00a52331ab12dsi5840076ejb.267.2024.04.22.10.30.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 10:30:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153798-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DqYLxSrH; 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-153798-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153798-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 16ED31F21513 for ; Mon, 22 Apr 2024 17:30:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40575153BEF; Mon, 22 Apr 2024 17:30:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DqYLxSrH" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 91B8D15218D; Mon, 22 Apr 2024 17:30:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713807017; cv=none; b=aoZRgTztKuuGVLxerZ4LysHM32XEXx8i4uKmxRvQHsW9lpJ4qUAuxydqG0XDf5XMy6/CNf8yQn2pf5d8Aj65mjqjrkB8Y/LfagFmGYHoa1SKysKQbBZSAxU35jl2CcX7h1VEPLHOT4DK5odm+s0zykG9gYOFxOM/DEAKERNj3gw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713807017; c=relaxed/simple; bh=5ZRZVW31i+SBd3dvJdxmL6VxYW9DL9+AI1e6G7ZmfhQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jY/iGW/gRpDdL03vsE8Engj2+ORT46nAoRq3rH9TuSOlW+saF0r51liwRDHii5/Xzh4PudZCPoxyWs+vxTtTlQ+2VkreAUjBuBLF2ZdF10JwLX8d8tYzJdnebOGEsqw0YW+IPSbwULUUn+jOmHyjmT/y/KPCdRSsjpTKMOjQsPE= 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=DqYLxSrH; arc=none smtp.client-ip=198.175.65.15 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=1713807016; x=1745343016; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=5ZRZVW31i+SBd3dvJdxmL6VxYW9DL9+AI1e6G7ZmfhQ=; b=DqYLxSrHpl5hv4msVDsU+nzMNrqju5S+YE2fm+4Xd8IpQQ6hqYyArcHX QyMxdjXXCDRDLEHVetky4CEbnqZKN+pKw+kkbE7otP/JlGl62tOIcX780 FAGSTQEQt0OFuWckp5B0d7g/mo6M2vue709yXmdhUrZ78ebStQJWSksRt 0qyN1pdKuwy7awWpVtoRIRY1V6Rd7mmcKx5RwqV9CZt8JnbB9UGnw1Wui GUGLnd6mUoLlTJ2KQQNsrg9bdMLHzIYb9pNRbV8vz38At+fOLapMcapav TxGooTOjtziuum7HFlpl31nqhqX1xV1E04HYk2mHReSv/HDFo9b+G5Kak Q==; X-CSE-ConnectionGUID: jUkdocaVQ/u9TKMmsKscsA== X-CSE-MsgGUID: Jkb0NHm9RDWxucef/1slqA== X-IronPort-AV: E=McAfee;i="6600,9927,11052"; a="13146704" X-IronPort-AV: E=Sophos;i="6.07,221,1708416000"; d="scan'208";a="13146704" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2024 10:30:15 -0700 X-CSE-ConnectionGUID: WwRlqWucQv6CFJy3gFyxyg== X-CSE-MsgGUID: GMWGYYMdSCWwyx/dRFUh7w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,221,1708416000"; d="scan'208";a="28545389" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2024 10:30:14 -0700 Date: Mon, 22 Apr 2024 10:30:13 -0700 From: Isaku Yamahata To: Yan Zhao 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, Binbin Wu , isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 058/130] KVM: x86/mmu: Add a private pointer to struct kvm_mmu_page Message-ID: <20240422173013.GJ3596705@ls.amr.corp.intel.com> References: <9d86b5a2787d20ffb5a58f86e43601a660521f16.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 Mon, Apr 22, 2024 at 11:34:18AM +0800, Yan Zhao wrote: > On Mon, Feb 26, 2024 at 12:26:00AM -0800, isaku.yamahata@intel.com wrote: > > From: Isaku Yamahata > > +static inline void *kvm_mmu_private_spt(struct kvm_mmu_page *sp) > > +{ > > + return sp->private_spt; > > +} > > + > > +static inline void kvm_mmu_init_private_spt(struct kvm_mmu_page *sp, void *private_spt) > > +{ > > + sp->private_spt = private_spt; > > +} > This function is actually not used for initialization. > Instead, it's only called after failure of free_private_spt() in order to > intentionally leak the page to prevent kernel from accessing the encrypted page. > > So to avoid confusion, how about renaming it to kvm_mmu_leak_private_spt() and > always resetting the pointer to NULL? > > static inline void kvm_mmu_leak_private_spt(struct kvm_mmu_page *sp) > { > sp->private_spt = NULL; > } The older version had a config to disable TDX TDP MMU at a compile time. Now we dropped the config so that we don't necessarily need wrapper function with #ifdef. Now we have only single caller, I'll eliminate this wrapper function (and related wrapper functions) by open code. -- Isaku Yamahata