From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web09.4791.1648080751988371354 for ; Wed, 23 Mar 2022 17:12:37 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=RNlD+7xj; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648080757; x=1679616757; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I7LBQreBpEn5qWPAwxuDAlOZMCyIZTDQMaJmDkfSpI8=; b=RNlD+7xj2lAWmIXRO4R5+UwaQQSCAv5oHBDjcmR69GWFTEqbmbTQHqtj kG0DLTZsu6OTuFe5U/vmAlqVmnRwoNL8tl4O/lCnDq5+12PALNW7lYNrU ZSNQCl3R9hltN6y5lr3CoHUUzf/9Uvt09+WRQ+x6aTPlHNmwkf0+gjjVF qPpCwPwHByCTSZvs7qA1nWzFEUSEG9WlgCflLcFrQROtwM1yO8L0Niqfq fHdrKkPIXwu9wWXwY2KJCGAEDm524HQftnpu1RGW/bmPHVN59a16IfxWL XPHzL9DLdRWU5MoREYbm2VKIviO20abO6GV7pbdHdZWuP7FnUEoCrTfTK g==; X-IronPort-AV: E=McAfee;i="6200,9189,10295"; a="258207790" X-IronPort-AV: E=Sophos;i="5.90,205,1643702400"; d="scan'208";a="258207790" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2022 17:12:37 -0700 X-IronPort-AV: E=Sophos;i="5.90,205,1643702400"; d="scan'208";a="649651563" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.31.90]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2022 17:12:34 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [PATCH V10 37/47] UefiCpuPkg: Update AddressEncMask in CpuPageTable Date: Thu, 24 Mar 2022 08:10:23 +0800 Message-Id: <20220324001033.1169-38-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: <20220324001033.1169-1-min.m.xu@intel.com> References: <20220324001033.1169-1-min.m.xu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 MMIO region in Tdx guest is set with PcdTdxSharedBitMask in TdxDxe's entry point. In SEV guest the page table entries is set with PcdPteMemoryEncryptionAddressOrMask when creating 1:1 identity table. So the AddressEncMask in GetPageTableEntry (@CpuPageTable.c) is either PcdPteMemoryEncryptionAddressOrMask (in SEV guest), or PcdTdxSharedBitMask (in TDX guest), or all-0 (in Legacy guest). Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Acked-by: Gerd Hoffmann Reviewed-by: Ray Ni Signed-off-by: Min Xu --- UefiCpuPkg/CpuDxe/CpuDxe.inf | 1 + UefiCpuPkg/CpuDxe/CpuPageTable.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.inf b/UefiCpuPkg/CpuDxe/CpuDxe.inf index d87fe503d152..235241899222 100644 --- a/UefiCpuPkg/CpuDxe/CpuDxe.inf +++ b/UefiCpuPkg/CpuDxe/CpuDxe.inf @@ -80,6 +80,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask ## CONSUMES [Depex] TRUE diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTable.c index d9e65ab4b22a..f7a4d92e921a 100644 --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c @@ -307,6 +307,9 @@ GetPageTableEntry ( // Make sure AddressEncMask is contained to smallest supported address field. // AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64; + if (AddressEncMask == 0) { + AddressEncMask = PcdGet64 (PcdTdxSharedBitMask) & PAGING_1G_ADDRESS_MASK_64; + } if (PagingContext->MachineType == IMAGE_FILE_MACHINE_X64) { if ((PagingContext->ContextData.X64.Attributes & PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_5_LEVEL) != 0) { -- 2.29.2.windows.2