From nobody Thu Nov 14 07:09:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+110659+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110659+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1699031847; cv=none; d=zohomail.com; s=zohoarc; b=O+W/aNCG5UYwvY6xPc2UWVmH6o/5xvX4NEMmd5jRmFoGi14HTy+M7/294ExgkJXaAfA8TvKS4l2bLXgClC9Wi36pnVNwAaokBTZB92toFdH/MacAKgPKh5T8tK36yJIxy7FpDH1BTdZx2DLQdVga+JLsNtbmZTyUXlNUBv0o3Fc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699031847; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=o4QfmAEkzypQt0ZT/W+JUJjvaqsMOIMQ/zolZhu2I+8=; b=cxwUAYCaDJ+vvjPMeqDKFtpqRodOd1EYCC3nHS999NN1Vqc33JEJwDtvBqlI2q1cEMvd95iCsNgXDZvtcLRyXzxkGLA4y05YjjLxkntcvJSOkq+Ob3WPHdMqPzM+nAy7a0Gt/GdnhWvf0S05xwbTXXMmCMDJsZ3nOaYwu8WhpC8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110659+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1699031847345678.3453865442185; Fri, 3 Nov 2023 10:17:27 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=8/tOeaMqyx31QmZxKJPTfeGmyT4KtIwVhKl0M6YOQP4=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1699031846; v=1; b=WLQTCbaRD6lLji2mLeADBTkEqlxooFLlm+6A85/jZUlzLy56EAsqeQMtGcqyJD7+ia6mBmiY JmO3YQO1T/+E1s6eS75ecoXeS+mBAO/64sqO1CwFRw8vf3Mw6GHifgd1J6qsbfyEZht1GMv2Hmy oaw05ih6guGt9zp+JalaW4Rc= X-Received: by 127.0.0.2 with SMTP id AnVLYY1788612xAc4sRnvCo6; Fri, 03 Nov 2023 10:17:26 -0700 X-Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mx.groups.io with SMTP id smtpd.web10.59756.1699031844803351782 for ; Fri, 03 Nov 2023 10:17:24 -0700 X-Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1cc5b705769so20787975ad.0 for ; Fri, 03 Nov 2023 10:17:24 -0700 (PDT) X-Gm-Message-State: ClFgx7hVVjNfX8i6IcSVG85Hx1787277AA= X-Google-Smtp-Source: AGHT+IEw4dwD1KKTl6D2q9tbfpMJASPrZRYXdeDzElTA+cObGeL4TboLsWAvvOLKbLprMU85aavAEg== X-Received: by 2002:a17:902:f549:b0:1cc:49e7:ee16 with SMTP id h9-20020a170902f54900b001cc49e7ee16mr18325352plf.12.1699031844122; Fri, 03 Nov 2023 10:17:24 -0700 (PDT) X-Received: from localhost.localdomain ([50.46.253.1]) by smtp.gmail.com with ESMTPSA id b8-20020a170903228800b001bf5e24b2a8sm1625152plh.174.2023.11.03.10.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 10:17:23 -0700 (PDT) From: "Taylor Beebe" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [edk2-devel] [PATCH v4 11/14] UefiCpuPkg: Use Attribute From SMM MemoryAttributesTable if Nonzero Date: Fri, 3 Nov 2023 10:17:03 -0700 Message-ID: <20231103171706.148-12-taylor.d.beebe@gmail.com> In-Reply-To: <20231103171706.148-1-taylor.d.beebe@gmail.com> References: <20231103171706.148-1-taylor.d.beebe@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: 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,taylor.d.beebe@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1699031848908100038 Content-Type: text/plain; charset="utf-8" The function EnforceMemoryMapAttribute() in the SMM MAT logic will ensure that the CODE and DATA memory types have the desired attributes. The consumer of the SMM MAT should only override the Attributes field in the MAT if it is nonzero. This also allows the UEFI and SMM MAT logic to use ImagePropertiesRecordLib instead of carrying two copies of the image properties record manipulation logic. Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Signed-off-by: Taylor Beebe --- UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPk= g/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c index 6f498666157e..d302a9b0cbcf 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c @@ -1062,14 +1062,17 @@ SetMemMapAttributes ( MemoryMap =3D MemoryMapStart; for (Index =3D 0; Index < MemoryMapEntryCount; Index++) { DEBUG ((DEBUG_VERBOSE, "SetAttribute: Memory Entry - 0x%lx, 0x%x\n", M= emoryMap->PhysicalStart, MemoryMap->NumberOfPages)); - if (MemoryMap->Type =3D=3D EfiRuntimeServicesCode) { - MemoryAttribute =3D EFI_MEMORY_RO; - } else { - ASSERT ((MemoryMap->Type =3D=3D EfiRuntimeServicesData) || (MemoryMa= p->Type =3D=3D EfiConventionalMemory)); - // - // Set other type memory as NX. - // - MemoryAttribute =3D EFI_MEMORY_XP; + MemoryAttribute =3D MemoryMap->Attribute & EFI_MEMORY_ACCESS_MASK; + if (MemoryAttribute =3D=3D 0) { + if (MemoryMap->Type =3D=3D EfiRuntimeServicesCode) { + MemoryAttribute =3D EFI_MEMORY_RO; + } else { + ASSERT ((MemoryMap->Type =3D=3D EfiRuntimeServicesData) || (Memory= Map->Type =3D=3D EfiConventionalMemory)); + // + // Set other type memory as NX. + // + MemoryAttribute =3D EFI_MEMORY_XP; + } } =20 // --=20 2.42.0.windows.2 -=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 (#110659): https://edk2.groups.io/g/devel/message/110659 Mute This Topic: https://groups.io/mt/102368851/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-