Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1516938rbb; Mon, 26 Feb 2024 11:47:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWaqRwJrPHAe8LNsktwV+UlYqolrt0/+G2CeTxeKrRM4XRp4cPtL+t+O1rw1b+mf9wFfFV8sOGEgf1yY6U00R8Zl+Wh84JDGODEWgZY9A== X-Google-Smtp-Source: AGHT+IHdcFClPTHqDsYd54qBELb6SDzRGNVXtOBAJI6QW72bASZvcKtb0zE6OASJayUEllXG1v1t X-Received: by 2002:a17:90a:1f08:b0:299:38ec:1baa with SMTP id u8-20020a17090a1f0800b0029938ec1baamr6035052pja.28.1708976837684; Mon, 26 Feb 2024 11:47:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708976837; cv=pass; d=google.com; s=arc-20160816; b=0sODbeI8+yMoLsJDNL5VvmskzFIJPDY/Q8kF78P6ZmE+o7icnuDdEkHs0HK4RUBEDg NCg/tJ39TmrjB1a1YSPvd5MxgW9MuGHHuNjPHT2YuTXYk06Kr0ijRBCUEqNY65E+DcIZ FscWVz5HE8ZazhopHf5RiEbsIEKfGSk2Vp8F6mNBPUKv39yi4cJUlG12fElG4XVwlMLj Z4mQYTKdy04OmPI1AXfoainX/vtuOsLrrH/7YJxl6flDF1Mxta+aM38RY9rYT4vENJ2y faqpFCQXJsWayaryPhQi7wdOuIScxkI5pdv3dxMhF7xZn9iZNh5FyER8677SReAuBRpb wT5g== 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=Y/TWygqayynms9exCQ03G+PTvF1U4uqqZoLl6gZmxdI=; fh=YYXmQolDZ545DIbHBGg3a8Ad9BfifqTm1mpLJOVQCbk=; b=s3sRTFxmt5QF2Igee/1B6LgMdtYc/D58jDyDrDArz5uTdWSVJGbs5HV7p+EHEvceSy iWHdz0zFRkX7g0fqfhEKVWepaKkKAI4sboMJfGpH2fJEXKz27AzrdEfgVIp5TOz63VTm EBIDHoKJhc9CiR0N9i1Og9r2SfFwIk8R51xJixjcu9t+4cbig47E+ose8y26AY7SMUBM eOf/zHCa7NeHEMSFZx9QquEooBtI0wtT3PVUeEI9ceQ7xgWV8bqBthAK+qHs93oF+20j bzhFEsQBLrACPFy7WdWbvZ+WnnO9aTqvs6Hv8sQ03zuM5kdfhEsxbJPYexo6oh2ndR2m z15w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BRCLsaeV; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-82220-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82220-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 pj12-20020a17090b4f4c00b0029a8b12c840si4303315pjb.35.2024.02.26.11.47.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 11:47:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82220-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=BRCLsaeV; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-82220-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82220-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 E15D7B2AC49 for ; Mon, 26 Feb 2024 19:16:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A1A3130ADA; Mon, 26 Feb 2024 19:15:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BRCLsaeV" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.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 7909B6A006; Mon, 26 Feb 2024 19:15:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708974906; cv=none; b=Fl9snUwU8EjQV3CVoqzLyLGsk70dx7wGPL//pSLWraVJns+5732Ij3bkUAGstRyTLRFdWwRddmsJJwu5JURVbKB9NyHOJ4PWPhDlnh/cGyGhRxd1slN3+o0cjSnrlnmpcHdSRLdD06L9+G6EtbwcaoTyBp44td+iQCFzhtDQ1iw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708974906; c=relaxed/simple; bh=LJiXX+ulWwWSULerhyjRE2sXzGGRm+4Qph36BbfVcE8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MaKj5Aw4/tj6j7mrDzWcMOfqU4ovKko9hoqycOqT4l4wk3Ot/owQoYvnozZc4sBYIVQxupmFKlqNhCfpV7zHq4gfXfEiKQHek9+a2Py6cO7QwpumIm+aQzm1R1OyjEHX45bKcOwPE2hqpk3hr2zlJVf4vpb2nqtwYXUHfnj1LuI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=BRCLsaeV; arc=none smtp.client-ip=198.175.65.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=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=1708974905; x=1740510905; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=LJiXX+ulWwWSULerhyjRE2sXzGGRm+4Qph36BbfVcE8=; b=BRCLsaeVlWmJmFikCx+S8jt1Z+7a2V27dCKSG6IeDqZTG8yWq+3K7egn HMYbvBadP6Hn2zBxn2HwIxr221BaTmtmjMkGgJJxqGUsnNS+nGn7jDWpf KMpz/9RKGmFDquBuR9jC8zrvVThSvce3+pI9v7flA/n3/+/whPF+0IkAz dzLFplxFDjPwleVdktuUJisys0ud3dD1cWsTzwab6ULL7ur9mpRMwv3e4 yYjhBXtlZdxS+4acxckM7nLUQZf6XcxrlthYfd5waC1vIM26yinDHm1nK iyNqLO++pBc8SiXZhL164MZ4jAEdQ/8RV0igIF452whBEzLilmY5IhMEy w==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="14721893" X-IronPort-AV: E=Sophos;i="6.06,186,1705392000"; d="scan'208";a="14721893" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 11:15:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,186,1705392000"; d="scan'208";a="6912300" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 11:15:03 -0800 Date: Mon, 26 Feb 2024 11:15:02 -0800 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, Sean Christopherson , isaku.yamahata@linux.intel.com Subject: Re: [PATCH v18 057/121] KVM: TDX: Add load_mmu_pgd method for TDX Message-ID: <20240226191502.GO177224@ls.amr.corp.intel.com> References: <9d024bfc-4b1d-4da5-81ba-36e60cf5e284@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 In-Reply-To: <9d024bfc-4b1d-4da5-81ba-36e60cf5e284@linux.intel.com> On Mon, Feb 05, 2024 at 10:23:34AM +0800, Binbin Wu wrote: > > diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c > > index 59d170709f82..25510b6740a3 100644 > > --- a/arch/x86/kvm/vmx/tdx.c > > +++ b/arch/x86/kvm/vmx/tdx.c > > @@ -501,6 +501,11 @@ void tdx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) > > */ > > } > > +void tdx_load_mmu_pgd(struct kvm_vcpu *vcpu, hpa_t root_hpa, int pgd_level) > > +{ > > + td_vmcs_write64(to_tdx(vcpu), SHARED_EPT_POINTER, root_hpa & PAGE_MASK); > > If we have concern about the alignment of root_hpa, shouldn't we do some > check instead of masking the address quietly? Makes sense. I'll add WARN_ON_ONCE(root_hpa & ~PAGE_MASK) -- Isaku Yamahata