lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 28 Jan 2017 23:12:01 +0100
From:   Ingo Molnar <mingo@...nel.org>
To:     linux-kernel@...r.kernel.org
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Andy Lutomirski <luto@...capital.net>,
        Borislav Petkov <bp@...en8.de>,
        "H . Peter Anvin" <hpa@...or.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Yinghai Lu <yinghai@...nel.org>
Subject: [PATCH 40/50] x86/boot/e820: Clean up the E820 table size define names

We've got a number of defines related to the E820 table and its size:

	E820MAP
	E820NR
	E820_X_MAX
	E820MAX

The first two denote byte offsets into the zeropage (struct boot_params),
and can are not used in the kernel and can be removed.

The E820_*_MAX values have an inconsistent structure and it's unclear in any
case what they mean. 'X' presuably goes for extended - but it's not very
expressive altogether.

Change these over to:

	E820_MAX_ENTRIES_ZEROPAGE
	E820_MAX_ENTRIES

... which are self-explanatory names.

No change in functionality.

Cc: Alex Thorlton <athorlton@....com>
Cc: Andy Lutomirski <luto@...nel.org>
Cc: Borislav Petkov <bp@...en8.de>
Cc: Brian Gerst <brgerst@...il.com>
Cc: Dan Williams <dan.j.williams@...el.com>
Cc: Denys Vlasenko <dvlasenk@...hat.com>
Cc: H. Peter Anvin <hpa@...or.com>
Cc: Huang, Ying <ying.huang@...el.com>
Cc: Josh Poimboeuf <jpoimboe@...hat.com>
Cc: Juergen Gross <jgross@...e.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Paul Jackson <pj@....com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Rafael J. Wysocki <rjw@...k.pl>
Cc: Tejun Heo <tj@...nel.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Wei Yang <richard.weiyang@...il.com>
Cc: Yinghai Lu <yinghai@...nel.org>
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
 arch/x86/include/asm/e820/types.h      | 18 ++++++------------
 arch/x86/include/uapi/asm/bootparam.h  |  2 +-
 arch/x86/include/uapi/asm/e820/types.h |  7 +++++--
 arch/x86/kernel/crash.c                |  2 +-
 arch/x86/kernel/e820.c                 |  8 ++++----
 arch/x86/kernel/kexec-bzimage64.c      |  6 +++---
 arch/x86/mm/init.c                     |  6 +++---
 arch/x86/mm/kasan_init_64.c            |  4 ++--
 arch/x86/xen/setup.c                   |  2 +-
 include/xen/page.h                     |  2 +-
 10 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/arch/x86/include/asm/e820/types.h b/arch/x86/include/asm/e820/types.h
index eb313b62d548..cf6074f8d563 100644
--- a/arch/x86/include/asm/e820/types.h
+++ b/arch/x86/include/asm/e820/types.h
@@ -4,12 +4,12 @@
 #include <uapi/asm/e820/types.h>
 
 /*
- * The legacy E820 BIOS limits us to 128 (E820MAX) nodes due to the
- * constrained space in the zeropage.
+ * The legacy E820 BIOS limits us to 128 (E820_MAX_ENTRIES_ZEROPAGE) nodes
+ * due to the constrained space in the zeropage.
  *
  * On large systems we can easily have thousands of nodes with RAM,
  * which cannot be fit into so few entries - so we have a mechanism
- * to extend the e820 table size at build-time, via the E820_X_MAX
+ * to extend the e820 table size at build-time, via the E820_MAX_ENTRIES
  * define below.
  *
  * ( Those extra entries are enumerated via the EFI memory map, not
@@ -17,7 +17,7 @@
  *
  * Size our internal memory map tables to have room for these additional
  * entries, based on a heuristic calculation: up to three entries per
- * NUMA node, plus E820MAX for some extra space.
+ * NUMA node, plus E820_MAX_ENTRIES_ZEROPAGE for some extra space.
  *
  * This allows for bootstrap/firmware quirks such as possible duplicate
  * E820 entries that might need room in the same arrays, prior to the
@@ -31,20 +31,14 @@
 
 #include <linux/numa.h>
 
-#define E820_X_MAX		(E820MAX + 3*MAX_NUMNODES)
-
-/* Our map: */
-#define E820MAP			0x2d0
-
-/* Number of entries in E820MAP: */
-#define E820NR			0x1e8
+#define E820_MAX_ENTRIES	(E820_MAX_ENTRIES_ZEROPAGE + 3*MAX_NUMNODES)
 
 /*
  * The whole array of E820 entries:
  */
 struct e820_table {
 	__u32 nr_entries;
-	struct e820_entry entries[E820_X_MAX];
+	struct e820_entry entries[E820_MAX_ENTRIES];
 };
 
 /*
diff --git a/arch/x86/include/uapi/asm/bootparam.h b/arch/x86/include/uapi/asm/bootparam.h
index 5f41518f7159..7f04c45aa429 100644
--- a/arch/x86/include/uapi/asm/bootparam.h
+++ b/arch/x86/include/uapi/asm/bootparam.h
@@ -152,7 +152,7 @@ struct boot_params {
 	struct setup_header hdr;    /* setup header */	/* 0x1f1 */
 	__u8  _pad7[0x290-0x1f1-sizeof(struct setup_header)];
 	__u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX];	/* 0x290 */
-	struct e820_entry e820_table[E820MAX];		/* 0x2d0 */
+	struct e820_entry e820_table[E820_MAX_ENTRIES_ZEROPAGE]; /* 0x2d0 */
 	__u8  _pad8[48];				/* 0xcd0 */
 	struct edd_info eddbuf[EDDMAXNR];		/* 0xd00 */
 	__u8  _pad9[276];				/* 0xeec */
diff --git a/arch/x86/include/uapi/asm/e820/types.h b/arch/x86/include/uapi/asm/e820/types.h
index 29391386b63f..3ac962f724f5 100644
--- a/arch/x86/include/uapi/asm/e820/types.h
+++ b/arch/x86/include/uapi/asm/e820/types.h
@@ -1,8 +1,11 @@
 #ifndef _UAPI_ASM_E820_TYPES_H
 #define _UAPI_ASM_E820_TYPES_H
 
-/* The maximum number of entries in E820MAP: */
-#define E820MAX			128
+/*
+ * This is the maximum number of entries in struct boot_params::e820_table (the zeropage),
+ * which is part of the x86 boot protocol ABI:
+ */
+#define E820_MAX_ENTRIES_ZEROPAGE 128
 
 #ifndef __ASSEMBLY__
 
diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index 5feba9a21130..22217ece26c8 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -509,7 +509,7 @@ static int add_e820_entry(struct boot_params *params, struct e820_entry *entry)
 	unsigned int nr_e820_entries;
 
 	nr_e820_entries = params->e820_entries;
-	if (nr_e820_entries >= E820MAX)
+	if (nr_e820_entries >= E820_MAX_ENTRIES_ZEROPAGE)
 		return 1;
 
 	memcpy(&params->e820_table[nr_e820_entries], entry,
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 90dcd240a389..055ac2484729 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -261,10 +261,10 @@ static int __init cpcompare(const void *a, const void *b)
 
 int __init e820__update_table(struct e820_entry *biosmap, int max_nr_map, u32 *pnr_map)
 {
-	static struct change_member change_point_list[2*E820_X_MAX] __initdata;
-	static struct change_member *change_point[2*E820_X_MAX] __initdata;
-	static struct e820_entry *overlap_list[E820_X_MAX] __initdata;
-	static struct e820_entry new_bios[E820_X_MAX] __initdata;
+	static struct change_member change_point_list[2*E820_MAX_ENTRIES] __initdata;
+	static struct change_member *change_point[2*E820_MAX_ENTRIES] __initdata;
+	static struct e820_entry *overlap_list[E820_MAX_ENTRIES] __initdata;
+	static struct e820_entry new_bios[E820_MAX_ENTRIES] __initdata;
 	enum e820_type current_type, last_type;
 	unsigned long long last_addr;
 	int chgidx;
diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c
index 3e43a7d3b191..9d7fd5e6689a 100644
--- a/arch/x86/kernel/kexec-bzimage64.c
+++ b/arch/x86/kernel/kexec-bzimage64.c
@@ -102,9 +102,9 @@ static int setup_e820_entries(struct boot_params *params)
 
 	nr_e820_entries = e820_table_firmware->nr_entries;
 
-	/* TODO: Pass entries more than E820MAX in bootparams setup data */
-	if (nr_e820_entries > E820MAX)
-		nr_e820_entries = E820MAX;
+	/* TODO: Pass entries more than E820_MAX_ENTRIES_ZEROPAGE in bootparams setup data */
+	if (nr_e820_entries > E820_MAX_ENTRIES_ZEROPAGE)
+		nr_e820_entries = E820_MAX_ENTRIES_ZEROPAGE;
 
 	params->e820_entries = nr_e820_entries;
 	memcpy(&params->e820_table, &e820_table_firmware->entries, nr_e820_entries*sizeof(struct e820_entry));
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 158dfecdab72..6b6b4c59cfc1 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -373,14 +373,14 @@ static int __meminit split_mem_range(struct map_range *mr, int nr_range,
 	return nr_range;
 }
 
-struct range pfn_mapped[E820_X_MAX];
+struct range pfn_mapped[E820_MAX_ENTRIES];
 int nr_pfn_mapped;
 
 static void add_pfn_range_mapped(unsigned long start_pfn, unsigned long end_pfn)
 {
-	nr_pfn_mapped = add_range_with_merge(pfn_mapped, E820_X_MAX,
+	nr_pfn_mapped = add_range_with_merge(pfn_mapped, E820_MAX_ENTRIES,
 					     nr_pfn_mapped, start_pfn, end_pfn);
-	nr_pfn_mapped = clean_sort_range(pfn_mapped, E820_X_MAX);
+	nr_pfn_mapped = clean_sort_range(pfn_mapped, E820_MAX_ENTRIES);
 
 	max_pfn_mapped = max(max_pfn_mapped, end_pfn);
 
diff --git a/arch/x86/mm/kasan_init_64.c b/arch/x86/mm/kasan_init_64.c
index bf9a511c98f3..7d02845ec456 100644
--- a/arch/x86/mm/kasan_init_64.c
+++ b/arch/x86/mm/kasan_init_64.c
@@ -11,7 +11,7 @@
 #include <asm/sections.h>
 
 extern pgd_t early_level4_pgt[PTRS_PER_PGD];
-extern struct range pfn_mapped[E820_X_MAX];
+extern struct range pfn_mapped[E820_MAX_ENTRIES];
 
 static int __init map_range(struct range *range)
 {
@@ -103,7 +103,7 @@ void __init kasan_init(void)
 	kasan_populate_zero_shadow((void *)KASAN_SHADOW_START,
 			kasan_mem_to_shadow((void *)PAGE_OFFSET));
 
-	for (i = 0; i < E820_X_MAX; i++) {
+	for (i = 0; i < E820_MAX_ENTRIES; i++) {
 		if (pfn_mapped[i].end == 0)
 			break;
 
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 625ceafeb7a0..381a0d3577a7 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -41,7 +41,7 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
 unsigned long xen_released_pages;
 
 /* E820 map used during setting up memory. */
-static struct e820_entry xen_e820_table[E820_X_MAX] __initdata;
+static struct e820_entry xen_e820_table[E820_MAX_ENTRIES] __initdata;
 static u32 xen_e820_table_entries __initdata;
 
 /*
diff --git a/include/xen/page.h b/include/xen/page.h
index 9dc46cb8a0fd..064194f6453e 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -38,7 +38,7 @@ struct xen_memory_region {
 	unsigned long n_pfns;
 };
 
-#define XEN_EXTRA_MEM_MAX_REGIONS 128 /* == E820MAX */
+#define XEN_EXTRA_MEM_MAX_REGIONS 128 /* == E820_MAX_ENTRIES_ZEROPAGE */
 
 extern __initdata
 struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS];
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ