From nobody Thu May 2 05:23:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+43920+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+43920+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1563433124; cv=none; d=zoho.com; s=zohoarc; b=HaMfRNxBwOUOX/MV4Nu8/s1W3gYjM2GGlirGYDEZVeu2C7srxLAJD4y4H7ubnDL6BzpQHcFGCMoyQswn0qtfHXDLe/6CqtkzKiSs8If+J+Z2HO4VBWkQvir9sg1LRhqwIsfaHcNraIHgFRwj6nnmAdlq5MxTTLU2jPnt7A+GJGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563433124; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=c3FirMZtXheJmIYOlyd+7pokseqznVWjphMzCL3CyS4=; b=DqlHN6ffuSq2ACSd1VqQr2cHHysaIIWNnfvAR8h5CSgkuRFnpvFwUgZFyWA2lJTBDsNDoIHk26b34XTSmqCCJ4i3Q/MOjwV+0Xtcbm8tZPFyebo8vibL7YYZjU832eCA+rL7iBIb1tew9Geo9dUhE2hW03gCOEo9KbYkpFWAOOE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+43920+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1563433124069134.61708667288985; Wed, 17 Jul 2019 23:58:44 -0700 (PDT) Return-Path: X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by groups.io with SMTP; Wed, 17 Jul 2019 23:58:42 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jul 2019 23:58:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,276,1559545200"; d="scan'208";a="161987835" X-Received: from ray-dev.ccr.corp.intel.com ([10.239.9.16]) by orsmga008.jf.intel.com with ESMTP; 17 Jul 2019 23:58:40 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Eric Dong , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH] UefiCpuPkg/PiSmmCpu: Allow SMM access-out when static paging is OFF Date: Thu, 18 Jul 2019 14:58:07 +0800 Message-Id: <20190718065807.434928-1-ray.ni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ray.ni@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1563433123; bh=uPAEb/1mID3YeLv1g+XId9S3geP4XpoTSRulNwLgTkc=; h=Cc:Date:From:Reply-To:Subject:To; b=abG++0u7vuS2m5F0i9PTXp18qhzv6yUIRFLXflpDYWOGGYwaJhwUX7E2+eUTenLNmo0 aMTf7+kjqomHgK/LqCydZFuMMQPPRWGet9jiW5Vg6rKUraS5IY9awrk9Cu9V4B6jT+ScL kZ1SaDSyByQqQbR9N3QMqjmhiqvvisbhEQc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Commit c60d36b4d1ee1f69b7cca897d3621dfa951895c2 * UefiCpuPkg/SmmCpu: Block access-out only when static paging is used updated page fault handler to treat SMM access-out as allowed address when static paging is not used. But that commit is not complete because the page table is still updated in SetUefiMemMapAttributes() for non-SMRAM memory. When SMM code accesses non-SMRAM memory, page fault is still generated. This patch skips to update page table for non-SMRAM memory and page table itself. Signed-off-by: Ray Ni Cc: Eric Dong Cc: Jiewen Yao Cc: Jian J Wang Acked-by: Laszlo Ersek Reviewed-by: Eric Dong --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmC= puDxeSmm/PiSmmCpuDxeSmm.c index 2f7d777ee7..f75e75f55c 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -1103,6 +1103,9 @@ FindSmramInfo ( *SmrrBase =3D (UINT32)CurrentSmramRange->CpuStart; *SmrrSize =3D (UINT32)CurrentSmramRange->PhysicalSize; =20 + // + // Extend *SmrrBase/*SmrrSize to include adjacent SMRAM ranges + // do { Found =3D FALSE; for (Index =3D 0; Index < mSmmCpuSmramRangeCount; Index++) { @@ -1414,14 +1417,20 @@ PerformRemainingTasks ( SetMemMapAttributes (); =20 // - // For outside SMRAM, we only map SMM communication buffer or MMIO. + // Do not protect memory outside SMRAM when SMM static page table is n= ot enabled. // - SetUefiMemMapAttributes (); + if (mCpuSmmStaticPageTable) { =20 - // - // Set page table itself to be read-only - // - SetPageTableAttributes (); + // + // For outside SMRAM, we only map SMM communication buffer or MMIO. + // + SetUefiMemMapAttributes (); + + // + // Set page table itself to be read-only + // + SetPageTableAttributes (); + } =20 // // Configure SMM Code Access Check feature if available. --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#43920): https://edk2.groups.io/g/devel/message/43920 Mute This Topic: https://groups.io/mt/32512605/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-