linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] efi: add definition of EFI_MEMORY_CPU_CRYPTO and ability to report it
@ 2020-09-24 11:56 Ard Biesheuvel
  2020-09-24 12:51 ` Laszlo Ersek
  0 siblings, 1 reply; 2+ messages in thread
From: Ard Biesheuvel @ 2020-09-24 11:56 UTC (permalink / raw)
  To: linux-efi; +Cc: Ard Biesheuvel, Laszlo Ersek

Incorporate the definition of EFI_MEMORY_CPU_CRYPTO from the UEFI
specification v2.8, and wire it into our memory map dumping routine
as well.

To make a bit of space in the output buffer, which is provided by
the various callers, shorten the descriptive names of the memory
types.

Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
This could be split into two or even three patches, but this might need
to go into -stable as well, so presented as a single patch.

 drivers/firmware/efi/efi.c | 47 ++++++++++----------
 include/linux/efi.h        |  1 +
 2 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 3aa07c3b5136..ebb59e52294f 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -714,7 +714,7 @@ void __init efi_systab_report_header(const efi_table_hdr_t *systab_hdr,
 		vendor);
 }
 
-static __initdata char memory_type_name[][20] = {
+static __initdata char memory_type_name[][13] = {
 	"Reserved",
 	"Loader Code",
 	"Loader Data",
@@ -722,14 +722,14 @@ static __initdata char memory_type_name[][20] = {
 	"Boot Data",
 	"Runtime Code",
 	"Runtime Data",
-	"Conventional Memory",
-	"Unusable Memory",
-	"ACPI Reclaim Memory",
-	"ACPI Memory NVS",
-	"Memory Mapped I/O",
-	"MMIO Port Space",
+	"Conventional",
+	"Unusable",
+	"ACPI Reclaim",
+	"ACPI Mem NVS",
+	"MMIO",
+	"MMIO Port",
 	"PAL Code",
-	"Persistent Memory",
+	"Persistent",
 };
 
 char * __init efi_md_typeattr_format(char *buf, size_t size,
@@ -756,26 +756,27 @@ char * __init efi_md_typeattr_format(char *buf, size_t size,
 	if (attr & ~(EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY_WT |
 		     EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_RO |
 		     EFI_MEMORY_WP | EFI_MEMORY_RP | EFI_MEMORY_XP |
-		     EFI_MEMORY_NV | EFI_MEMORY_SP |
+		     EFI_MEMORY_NV | EFI_MEMORY_SP | EFI_MEMORY_CPU_CRYPTO |
 		     EFI_MEMORY_RUNTIME | EFI_MEMORY_MORE_RELIABLE))
 		snprintf(pos, size, "|attr=0x%016llx]",
 			 (unsigned long long)attr);
 	else
 		snprintf(pos, size,
-			 "|%3s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]",
-			 attr & EFI_MEMORY_RUNTIME ? "RUN" : "",
-			 attr & EFI_MEMORY_MORE_RELIABLE ? "MR" : "",
-			 attr & EFI_MEMORY_SP      ? "SP"  : "",
-			 attr & EFI_MEMORY_NV      ? "NV"  : "",
-			 attr & EFI_MEMORY_XP      ? "XP"  : "",
-			 attr & EFI_MEMORY_RP      ? "RP"  : "",
-			 attr & EFI_MEMORY_WP      ? "WP"  : "",
-			 attr & EFI_MEMORY_RO      ? "RO"  : "",
-			 attr & EFI_MEMORY_UCE     ? "UCE" : "",
-			 attr & EFI_MEMORY_WB      ? "WB"  : "",
-			 attr & EFI_MEMORY_WT      ? "WT"  : "",
-			 attr & EFI_MEMORY_WC      ? "WC"  : "",
-			 attr & EFI_MEMORY_UC      ? "UC"  : "");
+			 "|%3s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]",
+			 attr & EFI_MEMORY_RUNTIME		? "RUN" : "",
+			 attr & EFI_MEMORY_MORE_RELIABLE	? "MR"  : "",
+			 attr & EFI_MEMORY_CPU_CRYPTO   	? "CC"  : "",
+			 attr & EFI_MEMORY_SP			? "SP"  : "",
+			 attr & EFI_MEMORY_NV			? "NV"  : "",
+			 attr & EFI_MEMORY_XP			? "XP"  : "",
+			 attr & EFI_MEMORY_RP			? "RP"  : "",
+			 attr & EFI_MEMORY_WP			? "WP"  : "",
+			 attr & EFI_MEMORY_RO			? "RO"  : "",
+			 attr & EFI_MEMORY_UCE			? "UCE" : "",
+			 attr & EFI_MEMORY_WB			? "WB"  : "",
+			 attr & EFI_MEMORY_WT			? "WT"  : "",
+			 attr & EFI_MEMORY_WC			? "WC"  : "",
+			 attr & EFI_MEMORY_UC			? "UC"  : "");
 	return buf;
 }
 
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 6f9dc44d6d8e..9cc8b11d26de 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -122,6 +122,7 @@ typedef	struct {
 				((u64)0x0000000000010000ULL)	/* higher reliability */
 #define EFI_MEMORY_RO		((u64)0x0000000000020000ULL)	/* read-only */
 #define EFI_MEMORY_SP		((u64)0x0000000000040000ULL)	/* soft reserved */
+#define EFI_MEMORY_CPU_CRYPTO	((u64)0x0000000000080000ULL)	/* supports encryption */
 #define EFI_MEMORY_RUNTIME	((u64)0x8000000000000000ULL)	/* range requires runtime mapping */
 #define EFI_MEMORY_DESCRIPTOR_VERSION	1
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] efi: add definition of EFI_MEMORY_CPU_CRYPTO and ability to report it
  2020-09-24 11:56 [PATCH] efi: add definition of EFI_MEMORY_CPU_CRYPTO and ability to report it Ard Biesheuvel
@ 2020-09-24 12:51 ` Laszlo Ersek
  0 siblings, 0 replies; 2+ messages in thread
From: Laszlo Ersek @ 2020-09-24 12:51 UTC (permalink / raw)
  To: Ard Biesheuvel, linux-efi

On 09/24/20 13:56, Ard Biesheuvel wrote:
> Incorporate the definition of EFI_MEMORY_CPU_CRYPTO from the UEFI
> specification v2.8, and wire it into our memory map dumping routine
> as well.
> 
> To make a bit of space in the output buffer, which is provided by
> the various callers, shorten the descriptive names of the memory
> types.
> 
> Cc: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> This could be split into two or even three patches, but this might need
> to go into -stable as well, so presented as a single patch.
> 
>  drivers/firmware/efi/efi.c | 47 ++++++++++----------
>  include/linux/efi.h        |  1 +
>  2 files changed, 25 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index 3aa07c3b5136..ebb59e52294f 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -714,7 +714,7 @@ void __init efi_systab_report_header(const efi_table_hdr_t *systab_hdr,
>  		vendor);
>  }
>  
> -static __initdata char memory_type_name[][20] = {
> +static __initdata char memory_type_name[][13] = {
>  	"Reserved",
>  	"Loader Code",
>  	"Loader Data",
> @@ -722,14 +722,14 @@ static __initdata char memory_type_name[][20] = {
>  	"Boot Data",
>  	"Runtime Code",
>  	"Runtime Data",
> -	"Conventional Memory",
> -	"Unusable Memory",
> -	"ACPI Reclaim Memory",
> -	"ACPI Memory NVS",
> -	"Memory Mapped I/O",
> -	"MMIO Port Space",
> +	"Conventional",
> +	"Unusable",
> +	"ACPI Reclaim",
> +	"ACPI Mem NVS",
> +	"MMIO",
> +	"MMIO Port",
>  	"PAL Code",
> -	"Persistent Memory",
> +	"Persistent",
>  };
>  
>  char * __init efi_md_typeattr_format(char *buf, size_t size,
> @@ -756,26 +756,27 @@ char * __init efi_md_typeattr_format(char *buf, size_t size,
>  	if (attr & ~(EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY_WT |
>  		     EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_RO |
>  		     EFI_MEMORY_WP | EFI_MEMORY_RP | EFI_MEMORY_XP |
> -		     EFI_MEMORY_NV | EFI_MEMORY_SP |
> +		     EFI_MEMORY_NV | EFI_MEMORY_SP | EFI_MEMORY_CPU_CRYPTO |
>  		     EFI_MEMORY_RUNTIME | EFI_MEMORY_MORE_RELIABLE))
>  		snprintf(pos, size, "|attr=0x%016llx]",
>  			 (unsigned long long)attr);
>  	else
>  		snprintf(pos, size,
> -			 "|%3s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]",
> -			 attr & EFI_MEMORY_RUNTIME ? "RUN" : "",
> -			 attr & EFI_MEMORY_MORE_RELIABLE ? "MR" : "",
> -			 attr & EFI_MEMORY_SP      ? "SP"  : "",
> -			 attr & EFI_MEMORY_NV      ? "NV"  : "",
> -			 attr & EFI_MEMORY_XP      ? "XP"  : "",
> -			 attr & EFI_MEMORY_RP      ? "RP"  : "",
> -			 attr & EFI_MEMORY_WP      ? "WP"  : "",
> -			 attr & EFI_MEMORY_RO      ? "RO"  : "",
> -			 attr & EFI_MEMORY_UCE     ? "UCE" : "",
> -			 attr & EFI_MEMORY_WB      ? "WB"  : "",
> -			 attr & EFI_MEMORY_WT      ? "WT"  : "",
> -			 attr & EFI_MEMORY_WC      ? "WC"  : "",
> -			 attr & EFI_MEMORY_UC      ? "UC"  : "");
> +			 "|%3s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]",
> +			 attr & EFI_MEMORY_RUNTIME		? "RUN" : "",
> +			 attr & EFI_MEMORY_MORE_RELIABLE	? "MR"  : "",
> +			 attr & EFI_MEMORY_CPU_CRYPTO   	? "CC"  : "",
> +			 attr & EFI_MEMORY_SP			? "SP"  : "",
> +			 attr & EFI_MEMORY_NV			? "NV"  : "",
> +			 attr & EFI_MEMORY_XP			? "XP"  : "",
> +			 attr & EFI_MEMORY_RP			? "RP"  : "",
> +			 attr & EFI_MEMORY_WP			? "WP"  : "",
> +			 attr & EFI_MEMORY_RO			? "RO"  : "",
> +			 attr & EFI_MEMORY_UCE			? "UCE" : "",
> +			 attr & EFI_MEMORY_WB			? "WB"  : "",
> +			 attr & EFI_MEMORY_WT			? "WT"  : "",
> +			 attr & EFI_MEMORY_WC			? "WC"  : "",
> +			 attr & EFI_MEMORY_UC			? "UC"  : "");
>  	return buf;
>  }
>  
> diff --git a/include/linux/efi.h b/include/linux/efi.h
> index 6f9dc44d6d8e..9cc8b11d26de 100644
> --- a/include/linux/efi.h
> +++ b/include/linux/efi.h
> @@ -122,6 +122,7 @@ typedef	struct {
>  				((u64)0x0000000000010000ULL)	/* higher reliability */
>  #define EFI_MEMORY_RO		((u64)0x0000000000020000ULL)	/* read-only */
>  #define EFI_MEMORY_SP		((u64)0x0000000000040000ULL)	/* soft reserved */
> +#define EFI_MEMORY_CPU_CRYPTO	((u64)0x0000000000080000ULL)	/* supports encryption */
>  #define EFI_MEMORY_RUNTIME	((u64)0x8000000000000000ULL)	/* range requires runtime mapping */
>  #define EFI_MEMORY_DESCRIPTOR_VERSION	1
>  
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Thanks
Laszlo


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-24 12:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24 11:56 [PATCH] efi: add definition of EFI_MEMORY_CPU_CRYPTO and ability to report it Ard Biesheuvel
2020-09-24 12:51 ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).