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 E1609D801B3 for ; Fri, 4 Aug 2023 19:47:13 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=BrTgnt6/fX8+YOrNiJZrwGtmka/rkQnCwGn5HiziqY0=; 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=1691178432; v=1; b=Oh+zyvRRPBR+eh4hm27n4JRCRhlXnhTiepvk6Ia5lTs7Axdzd0ykNjsDyfRl/ErvQyOMa1tc kpgct958+6F6KRkZ0inqAfKKRVRURlKIgerDg/dYnfv1uDTDVb/VBMo9Pq+k/uESwUHukppdMRa iOkf7GtlZd0/oD2vpqZctJqc= X-Received: by 127.0.0.2 with SMTP id WjtrYY7687511xBEZzZ87HAW; Fri, 04 Aug 2023 12:47:12 -0700 X-Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by mx.groups.io with SMTP id smtpd.web10.6305.1691178429201326724 for ; Fri, 04 Aug 2023 12:47:09 -0700 X-Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1bbc87ded50so17406715ad.1 for ; Fri, 04 Aug 2023 12:47:09 -0700 (PDT) X-Gm-Message-State: wipp7bnrx110JTZcWyhDrjISx7686176AA= X-Google-Smtp-Source: AGHT+IG3aT8Qm8NVooiKUlOZrFx8aR/W9i3hxEZDllFsZU8mcIXr6Q2LVV81ITCQXoiEemxwU+uWzA== X-Received: by 2002:a17:903:2350:b0:1bc:3504:de35 with SMTP id c16-20020a170903235000b001bc3504de35mr3123978plh.62.1691178428598; Fri, 04 Aug 2023 12:47:08 -0700 (PDT) X-Received: from localhost.localdomain ([50.46.230.135]) by smtp.gmail.com with ESMTPSA id h15-20020a170902f7cf00b001b890b3bbb1sm2114133plw.211.2023.08.04.12.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 12:47:08 -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, 4 Aug 2023 12:46:45 -0700 Message-ID: <20230804194649.2001-12-t@taylorbeebe.com> In-Reply-To: <20230804194649.2001-1-t@taylorbeebe.com> References: <20230804194649.2001-1-t@taylorbeebe.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,t@taylorbeebe.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: 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=Oh+zyvRR; 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 From: Taylor Beebe 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.3 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107597): https://edk2.groups.io/g/devel/message/107597 Mute This Topic: https://groups.io/mt/100553443/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-