From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 959BED80A13 for ; Tue, 18 Jul 2023 18:40:29 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=TPkVTNidKwTsZPYDSMncXBrS+gGbjRBb0FpHDQZhufc=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-Received:X-Gm-Message-State:X-Google-Smtp-Source:X-Received:X-Received:From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Unsubscribe:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:Content-Transfer-Encoding; s=20140610; t=1689705628; v=1; b=BCtHIOPiXcxREYlwFflfODvrGQhdK5A4xf9LhjV+6wixR4IGpa7exrqU6LuFUJVaepfW6sD2 Rr0d5oOUGSk1H6gMDuvJFxiNjJaEUwsyqAQgXKBkdJMzUURNwmadK/NCnPgS/o5NR8Q4MQI0kru LejhvRkFS5LoCENlmE3k0QMI= X-Received: by 127.0.0.2 with SMTP id Qm1ZYY7687511xwAfLQCcdG2; Tue, 18 Jul 2023 11:40:28 -0700 X-Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by mx.groups.io with SMTP id smtpd.web11.3676.1689705624593689841 for ; Tue, 18 Jul 2023 11:40:24 -0700 X-Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-666e5f0d60bso3885419b3a.3 for ; Tue, 18 Jul 2023 11:40:24 -0700 (PDT) X-Gm-Message-State: r3xBcMehd1YZ4s814tVQk6eAx7686176AA= X-Google-Smtp-Source: APBJJlGt11d64G4De9weYy0FwWXD7yfkA0tiF6PMl99Ljycrynj73gkRpwv0BpYvlZA86VamUw4KiQ== X-Received: by 2002:a05:6a00:1686:b0:67c:c8e4:8689 with SMTP id k6-20020a056a00168600b0067cc8e48689mr16527968pfc.12.1689705624000; Tue, 18 Jul 2023 11:40:24 -0700 (PDT) X-Received: from localhost.localdomain ([50.46.230.135]) by smtp.gmail.com with ESMTPSA id d18-20020aa78692000000b006827d86ca0csm1863153pfo.55.2023.07.18.11.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 11:40:23 -0700 (PDT) From: "Taylor Beebe" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [edk2-devel] [PATCH v1 8/9] UefiCpuPkg: Use Attribute From SMM MemoryAttributesTable if Nonzero Date: Tue, 18 Jul 2023 11:40:04 -0700 Message-ID: <20230718184006.534-9-t@taylorbeebe.com> In-Reply-To: <20230718184006.534-1-t@taylorbeebe.com> References: <20230718184006.534-1-t@taylorbeebe.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,t@taylorbeebe.com Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=BCtHIOPi; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none 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. Signed-off-by: Taylor Beebe Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann --- UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c index 6f498666157e..d302a9b0cbcf 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c @@ -1062,14 +1062,17 @@ SetMemMapAttributes ( MemoryMap = MemoryMapStart; for (Index = 0; Index < MemoryMapEntryCount; Index++) { DEBUG ((DEBUG_VERBOSE, "SetAttribute: Memory Entry - 0x%lx, 0x%x\n", MemoryMap->PhysicalStart, MemoryMap->NumberOfPages)); - if (MemoryMap->Type == EfiRuntimeServicesCode) { - MemoryAttribute = EFI_MEMORY_RO; - } else { - ASSERT ((MemoryMap->Type == EfiRuntimeServicesData) || (MemoryMap->Type == EfiConventionalMemory)); - // - // Set other type memory as NX. - // - MemoryAttribute = EFI_MEMORY_XP; + MemoryAttribute = MemoryMap->Attribute & EFI_MEMORY_ACCESS_MASK; + if (MemoryAttribute == 0) { + if (MemoryMap->Type == EfiRuntimeServicesCode) { + MemoryAttribute = EFI_MEMORY_RO; + } else { + ASSERT ((MemoryMap->Type == EfiRuntimeServicesData) || (MemoryMap->Type == EfiConventionalMemory)); + // + // Set other type memory as NX. + // + MemoryAttribute = EFI_MEMORY_XP; + } } // -- 2.41.0.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107029): https://edk2.groups.io/g/devel/message/107029 Mute This Topic: https://groups.io/mt/100221564/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-