From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.12396.1675337276999803720 for ; Thu, 02 Feb 2023 03:27:57 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JAG+qQg0; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 82F1F61AED; Thu, 2 Feb 2023 11:27:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5F2FC4339B; Thu, 2 Feb 2023 11:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675337276; bh=IXjkfw8q+WxpW1Mn8lAA2nIlrODMaxAfmIz3HDsbdsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JAG+qQg0a9iBNah4mg1keHVrpWrvA5QwUSUZ+x5+5QoLm1K4BGJ0vPbdwpuF0+QRl 6GNW5PNjlNcz4xbCw/7fN2Lkn+89tGmbY1kPFXp9i+ucGBAx3ocP+CBd/OK/ECtdq1 Emcdmlsp16hORrwUbHI5kl6PE1GOYC3UVCXPDTsPG4a1E0Ofh0kceStmEkU7vhur4e 7WNSN9wqTwbqHyO77jZSDXwItJivMTH/DwxV3tc8dwkIyX3OXKuA6TFBMTJcjeexG3 mmr8949FNWa3EFtSNW1rEJ4kP1wTzczpSOzODEIOLRMHcwAp+xCXxMJDJRkSyz4udv syYQlGAEdGYJg== From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Michael Kinney , Liming Gao , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Leif Lindholm , Sami Mujawar , Taylor Beebe Subject: [PATCH v2 1/3] MdePkg: Add Memory Attribute Protocol definition Date: Thu, 2 Feb 2023 12:27:20 +0100 Message-Id: <20230202112722.2200755-2-ardb@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230202112722.2200755-1-ardb@kernel.org> References: <20230202112722.2200755-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Add the Memory Attribute Protocol definition, which was adopted and included in version 2.10 of the UEFI specification. Link: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3519 Signed-off-by: Ard Biesheuvel --- MdePkg/Include/Protocol/MemoryAttribute.h | 142 ++++++++++++++++++++ MdePkg/MdePkg.dec | 3 + 2 files changed, 145 insertions(+) diff --git a/MdePkg/Include/Protocol/MemoryAttribute.h b/MdePkg/Include/Pro= tocol/MemoryAttribute.h new file mode 100644 index 000000000000..ff930fb21aa6 --- /dev/null +++ b/MdePkg/Include/Protocol/MemoryAttribute.h @@ -0,0 +1,142 @@ +/** @file=0D +=0D + EFI Memory Attribute Protocol provides retrieval and update service=0D + for memory attributes in EFI environment.=0D +=0D + Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2023, Google LLC. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef __EFI_MEMORY_ATTRIBUTE_H__=0D +#define __EFI_MEMORY_ATTRIBUTE_H__=0D +=0D +#define EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID \=0D + { \=0D + 0xf4560cf6, 0x40ec, 0x4b4a, { 0xa1, 0x92, 0xbf, 0x1d, 0x57, 0xd0, 0xb1= , 0x89 } \=0D + }=0D +=0D +typedef struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL EFI_MEMORY_ATTRIBUTE_PROTOCO= L;=0D +=0D +/**=0D + This function set given attributes of the memory region specified by=0D + BaseAddress and Length.=0D +=0D + The valid Attributes is EFI_MEMORY_RP, EFI_MEMORY_XP, and EFI_MEMORY_RO.= =0D +=0D + @param This The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.=0D + @param BaseAddress The physical address that is the start address= of=0D + a memory region.=0D + @param Length The size in bytes of the memory region.=0D + @param Attributes The bit mask of attributes to set for the memo= ry=0D + region.=0D +=0D + @retval EFI_SUCCESS The attributes were set for the memory reg= ion.=0D + @retval EFI_INVALID_PARAMETER Length is zero.=0D + Attributes specified an illegal combinatio= n of=0D + attributes that cannot be set together.=0D + @retval EFI_UNSUPPORTED The processor does not support one or more= =0D + bytes of the memory resource range specifi= ed=0D + by BaseAddress and Length.=0D + The bit mask of attributes is not supporte= d for=0D + the memory resource range specified by=0D + BaseAddress and Length.=0D + @retval EFI_OUT_OF_RESOURCES Requested attributes cannot be applied due= to=0D + lack of system resources.=0D + @retval EFI_ACCESS_DENIED Attributes for the requested memory region= are=0D + controlled by system firmware and cannot b= e=0D + updated via the protocol.=0D +=0D +**/=0D +typedef=0D +EFI_STATUS=0D +(EFIAPI *EFI_SET_MEMORY_ATTRIBUTES)(=0D + IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length,=0D + IN UINT64 Attributes=0D + );=0D +=0D +/**=0D + This function clears given attributes of the memory region specified by= =0D + BaseAddress and Length.=0D +=0D + The valid Attributes is EFI_MEMORY_RP, EFI_MEMORY_XP, and EFI_MEMORY_RO.= =0D +=0D + @param This The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.=0D + @param BaseAddress The physical address that is the start address= of=0D + a memory region.=0D + @param Length The size in bytes of the memory region.=0D + @param Attributes The bit mask of attributes to clear for the me= mory=0D + region.=0D +=0D + @retval EFI_SUCCESS The attributes were cleared for the memory= region.=0D + @retval EFI_INVALID_PARAMETER Length is zero.=0D + Attributes specified an illegal combinatio= n of=0D + attributes that cannot be cleared together= .=0D + @retval EFI_UNSUPPORTED The processor does not support one or more= =0D + bytes of the memory resource range specifi= ed=0D + by BaseAddress and Length.=0D + The bit mask of attributes is not supporte= d for=0D + the memory resource range specified by=0D + BaseAddress and Length.=0D + @retval EFI_OUT_OF_RESOURCES Requested attributes cannot be applied due= to=0D + lack of system resources.=0D + @retval EFI_ACCESS_DENIED Attributes for the requested memory region= are=0D + controlled by system firmware and cannot b= e=0D + updated via the protocol.=0D +=0D +**/=0D +typedef=0D +EFI_STATUS=0D +(EFIAPI *EFI_CLEAR_MEMORY_ATTRIBUTES)(=0D + IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length,=0D + IN UINT64 Attributes=0D + );=0D +=0D +/**=0D + This function retrieves the attributes of the memory region specified by= =0D + BaseAddress and Length. If different attributes are got from different p= art=0D + of the memory region, EFI_NO_MAPPING will be returned.=0D +=0D + @param This The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.=0D + @param BaseAddress The physical address that is the start address= of=0D + a memory region.=0D + @param Length The size in bytes of the memory region.=0D + @param Attributes Pointer to attributes returned.=0D +=0D + @retval EFI_SUCCESS The attributes got for the memory region.= =0D + @retval EFI_INVALID_PARAMETER Length is zero.=0D + Attributes is NULL.=0D + @retval EFI_NO_MAPPING Attributes are not consistent cross the me= mory=0D + region.=0D + @retval EFI_UNSUPPORTED The processor does not support one or more= =0D + bytes of the memory resource range specifi= ed=0D + by BaseAddress and Length.=0D +=0D +**/=0D +typedef=0D +EFI_STATUS=0D +(EFIAPI *EFI_GET_MEMORY_ATTRIBUTES)(=0D + IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length,=0D + OUT UINT64 *Attributes=0D + );=0D +=0D +///=0D +/// EFI Memory Attribute Protocol provides services to retrieve or update= =0D +/// attribute of memory in the EFI environment.=0D +///=0D +struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL {=0D + EFI_GET_MEMORY_ATTRIBUTES GetMemoryAttributes;=0D + EFI_SET_MEMORY_ATTRIBUTES SetMemoryAttributes;=0D + EFI_CLEAR_MEMORY_ATTRIBUTES ClearMemoryAttributes;=0D +};=0D +=0D +extern EFI_GUID gEfiMemoryAttributeProtocolGuid;=0D +=0D +#endif=0D diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 3d08f20d15b0..a8658403c8fd 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -1915,6 +1915,9 @@ [Protocols] ## Include/Protocol/RedfishDiscover.h=0D gEfiRedfishDiscoverProtocolGuid =3D { 0x5db12509, 0x4550, 0x4347, {= 0x96, 0xb3, 0x73, 0xc0, 0xff, 0x6e, 0x86, 0x9f }}=0D =0D + ## Include/Protocol/MemoryAttribute.h=0D + gEfiMemoryAttributeProtocolGuid =3D { 0xf4560cf6, 0x40ec, 0x4b4a, { 0xa1= , 0x92, 0xbf, 0x1d, 0x57, 0xd0, 0xb1, 0x89 }}=0D +=0D #=0D # Protocols defined in Shell2.0=0D #=0D --=20 2.39.0