From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752735AbdA1WWy (ORCPT ); Sat, 28 Jan 2017 17:22:54 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36235 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752572AbdA1WUU (ORCPT ); Sat, 28 Jan 2017 17:20:20 -0500 From: Ingo Molnar To: linux-kernel@vger.kernel.org Cc: Andrew Morton , Andy Lutomirski , Borislav Petkov , "H . Peter Anvin" , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Yinghai Lu Subject: [PATCH 37/50] x86/boot/e820: Use 'enum e820_type' in 'struct e820_entry' Date: Sat, 28 Jan 2017 23:11:58 +0100 Message-Id: <1485641531-22124-38-git-send-email-mingo@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485641531-22124-1-git-send-email-mingo@kernel.org> References: <1485641531-22124-1-git-send-email-mingo@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use a stricter type for struct e820_entry. Add a build-time check to make sure the compiler won't ever pack the enum into a field smaller than 'int'. No change in functionality. Cc: Alex Thorlton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dan Williams Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Huang, Ying Cc: Josh Poimboeuf Cc: Juergen Gross Cc: Linus Torvalds Cc: Paul Jackson Cc: Peter Zijlstra Cc: Rafael J. Wysocki Cc: Tejun Heo Cc: Thomas Gleixner Cc: Wei Yang Cc: Yinghai Lu Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/asm/e820/types.h | 31 ------------------------------- arch/x86/include/uapi/asm/e820/types.h | 37 ++++++++++++++++++++++++++++++++++--- arch/x86/kernel/e820.c | 3 +++ 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/arch/x86/include/asm/e820/types.h b/arch/x86/include/asm/e820/types.h index 1c3426825535..eb313b62d548 100644 --- a/arch/x86/include/asm/e820/types.h +++ b/arch/x86/include/asm/e820/types.h @@ -1,37 +1,6 @@ #ifndef _ASM_E820_TYPES_H #define _ASM_E820_TYPES_H -enum e820_type { - E820_RAM = 1, - E820_RESERVED = 2, - E820_ACPI = 3, - E820_NVS = 4, - E820_UNUSABLE = 5, - E820_PMEM = 7, - - /* - * This is a non-standardized way to represent ADR or - * NVDIMM regions that persist over a reboot. - * - * The kernel will ignore their special capabilities - * unless the CONFIG_X86_PMEM_LEGACY=y option is set. - * - * ( Note that older platforms also used 6 for the same - * type of memory, but newer versions switched to 12 as - * 6 was assigned differently. Some time they will learn... ) - */ - E820_PRAM = 12, - - /* - * Reserved RAM used by the kernel itself if - * CONFIG_INTEL_TXT=y is enabled, memory of this type - * will be included in the S3 integrity calculation - * and so should not include any memory that the BIOS - * might alter over the S3 transition: - */ - E820_RESERVED_KERN = 128, -}; - #include /* diff --git a/arch/x86/include/uapi/asm/e820/types.h b/arch/x86/include/uapi/asm/e820/types.h index 54b812e80bac..65c7a1beab22 100644 --- a/arch/x86/include/uapi/asm/e820/types.h +++ b/arch/x86/include/uapi/asm/e820/types.h @@ -6,14 +6,45 @@ #ifndef __ASSEMBLY__ +enum e820_type { + E820_RAM = 1, + E820_RESERVED = 2, + E820_ACPI = 3, + E820_NVS = 4, + E820_UNUSABLE = 5, + E820_PMEM = 7, + + /* + * This is a non-standardized way to represent ADR or + * NVDIMM regions that persist over a reboot. + * + * The kernel will ignore their special capabilities + * unless the CONFIG_X86_PMEM_LEGACY=y option is set. + * + * ( Note that older platforms also used 6 for the same + * type of memory, but newer versions switched to 12 as + * 6 was assigned differently. Some time they will learn... ) + */ + E820_PRAM = 12, + + /* + * Reserved RAM used by the kernel itself if + * CONFIG_INTEL_TXT=y is enabled, memory of this type + * will be included in the S3 integrity calculation + * and so should not include any memory that the BIOS + * might alter over the S3 transition: + */ + E820_RESERVED_KERN = 128, +}; + /* * A single E820 map entry, describing a memory range of [addr...addr+size-1], * of 'type' memory type: */ struct e820_entry { - __u64 addr; - __u64 size; - __u32 type; + __u64 addr; + __u64 size; + enum e820_type type; } __attribute__((packed)); #endif /* __ASSEMBLY__ */ diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 511402d88795..010a289ddd9f 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -1164,6 +1164,9 @@ void __init e820__memory_setup(void) { char *who; + /* This is a firmware interface ABI - make sure we don't break it: */ + BUILD_BUG_ON(sizeof(struct e820_entry) != 20); + who = x86_init.resources.memory_setup(); memcpy(e820_table_firmware, e820_table, sizeof(struct e820_table)); -- 2.7.4