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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 12 Mar 2009 12:08:49 +0000
From:	"Jan Beulich" <jbeulich@...ell.com>
To:	<mingo@...e.hu>, <tglx@...utronix.de>, <hpa@...or.com>
Cc:	<linux-kernel@...r.kernel.org>
Subject: [PATCH] x86: move various CPU initialization objects into
	 .cpuinit.rodata

Impact: debuggability and micro-optimization

Putting whatever is possible into the (final) .rodata section increases
the likelihood of catching memory corruption bugs early, and reduces
false cache line sharing.

Signed-off-by: Jan Beulich <jbeulich@...ell.com>

---
 arch/x86/kernel/cpu/addon_cpuid_features.c |    2 +-
 arch/x86/kernel/cpu/amd.c                  |    2 +-
 arch/x86/kernel/cpu/centaur.c              |    2 +-
 arch/x86/kernel/cpu/centaur_64.c           |    2 +-
 arch/x86/kernel/cpu/common.c               |   23 ++++++++++++-----------
 arch/x86/kernel/cpu/cpu.h                  |   11 ++++++-----
 arch/x86/kernel/cpu/cyrix.c                |   16 ++++++++--------
 arch/x86/kernel/cpu/intel.c                |    2 +-
 arch/x86/kernel/cpu/intel_cacheinfo.c      |    8 ++++----
 arch/x86/kernel/cpu/transmeta.c            |    2 +-
 arch/x86/kernel/cpu/umc.c                  |    2 +-
 arch/x86/kernel/mmconf-fam10h_64.c         |    2 +-
 12 files changed, 38 insertions(+), 36 deletions(-)

--- linux-2.6.29-rc7/arch/x86/kernel/cpu/addon_cpuid_features.c	2009-03-04 09:10:19.000000000 +0100
+++ 2.6.29-rc7-cpuinitconst-x86/arch/x86/kernel/cpu/addon_cpuid_features.c	2009-02-18 15:34:25.000000000 +0100
@@ -29,7 +29,7 @@ void __cpuinit init_scattered_cpuid_feat
 	u32 regs[4];
 	const struct cpuid_bit *cb;
 
-	static const struct cpuid_bit cpuid_bits[] = {
+	static const struct cpuid_bit __cpuinitconst cpuid_bits[] = {
 		{ X86_FEATURE_IDA, CR_EAX, 1, 0x00000006 },
 		{ 0, 0, 0, 0 }
 	};
--- linux-2.6.29-rc7/arch/x86/kernel/cpu/amd.c	2009-03-04 09:10:19.000000000 +0100
+++ 2.6.29-rc7-cpuinitconst-x86/arch/x86/kernel/cpu/amd.c	2009-02-18 15:34:25.000000000 +0100
@@ -452,7 +452,7 @@ static unsigned int __cpuinit amd_size_c
 }
 #endif
 
-static struct cpu_dev amd_cpu_dev __cpuinitdata = {
+static const struct cpu_dev __cpuinitconst amd_cpu_dev = {
 	.c_vendor	= "AMD",
 	.c_ident	= { "AuthenticAMD" },
 #ifdef CONFIG_X86_32
--- linux-2.6.29-rc7/arch/x86/kernel/cpu/centaur.c	2008-12-25 00:26:37.000000000 +0100
+++ 2.6.29-rc7-cpuinitconst-x86/arch/x86/kernel/cpu/centaur.c	2009-02-18 15:34:25.000000000 +0100
@@ -468,7 +468,7 @@ centaur_size_cache(struct cpuinfo_x86 *c
 	return size;
 }
 
-static struct cpu_dev centaur_cpu_dev __cpuinitdata = {
+static const struct cpu_dev __cpuinitconst centaur_cpu_dev = {
 	.c_vendor	= "Centaur",
 	.c_ident	= { "CentaurHauls" },
 	.c_early_init	= early_init_centaur,
--- linux-2.6.29-rc7/arch/x86/kernel/cpu/centaur_64.c	2008-12-25 00:26:37.000000000 +0100
+++ 2.6.29-rc7-cpuinitconst-x86/arch/x86/kernel/cpu/centaur_64.c	2009-02-18 15:34:25.000000000 +0100
@@ -25,7 +25,7 @@ static void __cpuinit init_centaur(struc
 	set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
 }
 
-static struct cpu_dev centaur_cpu_dev __cpuinitdata = {
+static const struct cpu_dev centaur_cpu_dev __cpuinitconst = {
 	.c_vendor	= "Centaur",
 	.c_ident	= { "CentaurHauls" },
 	.c_early_init	= early_init_centaur,
--- linux-2.6.29-rc7/arch/x86/kernel/cpu/common.c	2009-03-04 09:10:19.000000000 +0100
+++ 2.6.29-rc7-cpuinitconst-x86/arch/x86/kernel/cpu/common.c	2009-02-18 15:35:09.000000000 +0100
@@ -60,7 +60,7 @@ cpumask_t cpu_sibling_setup_map;
 #endif /* CONFIG_X86_32 */
 
 
-static struct cpu_dev *this_cpu __cpuinitdata;
+static const struct cpu_dev *this_cpu __cpuinitdata;
 
 #ifdef CONFIG_X86_64
 /* We need valid kernel segments for data and code in long mode too
@@ -220,9 +220,9 @@ static inline void squash_the_stupid_ser
  */
 
 /* Look up CPU names by table lookup. */
-static char __cpuinit *table_lookup_model(struct cpuinfo_x86 *c)
+static const char *__cpuinit table_lookup_model(struct cpuinfo_x86 *c)
 {
-	struct cpu_model_info *info;
+	const struct cpu_model_info *info;
 
 	if (c->x86_model >= 16)
 		return NULL;	/* Range check */
@@ -256,7 +256,7 @@ void switch_to_new_gdt(void)
 #endif
 }
 
-static struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {};
+static const struct cpu_dev *__cpuinitdata cpu_devs[X86_VENDOR_NUM] = {};
 
 static void __cpuinit default_init(struct cpuinfo_x86 *c)
 {
@@ -275,7 +275,7 @@ static void __cpuinit default_init(struc
 #endif
 }
 
-static struct cpu_dev __cpuinitdata default_cpu = {
+static const struct cpu_dev __cpuinitconst default_cpu = {
 	.c_init	= default_init,
 	.c_vendor = "Unknown",
 	.c_x86_vendor = X86_VENDOR_UNKNOWN,
@@ -579,12 +579,12 @@ static void __init early_identify_cpu(st
 
 void __init early_cpu_init(void)
 {
-	struct cpu_dev **cdev;
+	const struct cpu_dev *const *cdev;
 	int count = 0;
 
 	printk("KERNEL supported cpus:\n");
 	for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) {
-		struct cpu_dev *cpudev = *cdev;
+		const struct cpu_dev *cpudev = *cdev;
 		unsigned int j;
 
 		if (count >= X86_VENDOR_NUM)
@@ -710,7 +710,7 @@ static void __cpuinit identify_cpu(struc
 
 	/* If the model name is still unset, do table lookup. */
 	if (!c->x86_model_id[0]) {
-		char *p;
+		const char *p;
 		p = table_lookup_model(c);
 		if (p)
 			strcpy(c->x86_model_id, p);
@@ -789,7 +789,7 @@ struct msr_range {
 	unsigned max;
 };
 
-static struct msr_range msr_range_array[] __cpuinitdata = {
+static const struct msr_range msr_range_array[] __cpuinitconst = {
 	{ 0x00000000, 0x00000418},
 	{ 0xc0000000, 0xc000040b},
 	{ 0xc0010000, 0xc0010142},
@@ -836,7 +836,7 @@ __setup("noclflush", setup_noclflush);
 
 void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
 {
-	char *vendor = NULL;
+	const char *vendor = NULL;
 
 	if (c->x86_vendor < X86_VENDOR_NUM)
 		vendor = this_cpu->c_vendor;
--- linux-2.6.29-rc7/arch/x86/kernel/cpu/cpu.h	2008-12-25 00:26:37.000000000 +0100
+++ 2.6.29-rc7-cpuinitconst-x86/arch/x86/kernel/cpu/cpu.h	2009-02-18 15:34:25.000000000 +0100
@@ -5,15 +5,15 @@
 struct cpu_model_info {
 	int vendor;
 	int family;
-	char *model_names[16];
+	const char *model_names[16];
 };
 
 /* attempt to consolidate cpu attributes */
 struct cpu_dev {
-	char	* c_vendor;
+	const char	* c_vendor;
 
 	/* some have two possibilities for cpuid string */
-	char	* c_ident[2];	
+	const char	* c_ident[2];
 
 	struct		cpu_model_info c_models[4];
 
@@ -25,11 +25,12 @@ struct cpu_dev {
 };
 
 #define cpu_dev_register(cpu_devX) \
-	static struct cpu_dev *__cpu_dev_##cpu_devX __used \
+	static const struct cpu_dev *const __cpu_dev_##cpu_devX __used \
 	__attribute__((__section__(".x86_cpu_dev.init"))) = \
 	&cpu_devX;
 
-extern struct cpu_dev *__x86_cpu_dev_start[], *__x86_cpu_dev_end[];
+extern const struct cpu_dev *const __x86_cpu_dev_start[],
+			    *const __x86_cpu_dev_end[];
 
 extern void display_cacheinfo(struct cpuinfo_x86 *c);
 
--- linux-2.6.29-rc7/arch/x86/kernel/cpu/cyrix.c	2008-12-25 00:26:37.000000000 +0100
+++ 2.6.29-rc7-cpuinitconst-x86/arch/x86/kernel/cpu/cyrix.c	2009-02-18 15:34:25.000000000 +0100
@@ -61,23 +61,23 @@ static void __cpuinit do_cyrix_devid(uns
  */
 static unsigned char Cx86_dir0_msb __cpuinitdata = 0;
 
-static char Cx86_model[][9] __cpuinitdata = {
+static const char __cpuinitconst Cx86_model[][9] = {
 	"Cx486", "Cx486", "5x86 ", "6x86", "MediaGX ", "6x86MX ",
 	"M II ", "Unknown"
 };
-static char Cx486_name[][5] __cpuinitdata = {
+static const char __cpuinitconst Cx486_name[][5] = {
 	"SLC", "DLC", "SLC2", "DLC2", "SRx", "DRx",
 	"SRx2", "DRx2"
 };
-static char Cx486S_name[][4] __cpuinitdata = {
+static const char __cpuinitconst Cx486S_name[][4] = {
 	"S", "S2", "Se", "S2e"
 };
-static char Cx486D_name[][4] __cpuinitdata = {
+static const char __cpuinitconst Cx486D_name[][4] = {
 	"DX", "DX2", "?", "?", "?", "DX4"
 };
 static char Cx86_cb[] __cpuinitdata = "?.5x Core/Bus Clock";
-static char cyrix_model_mult1[] __cpuinitdata = "12??43";
-static char cyrix_model_mult2[] __cpuinitdata = "12233445";
+static const char __cpuinitconst cyrix_model_mult1[] = "12??43";
+static const char __cpuinitconst cyrix_model_mult2[] = "12233445";
 
 /*
  * Reset the slow-loop (SLOP) bit on the 686(L) which is set by some old
@@ -435,7 +435,7 @@ static void __cpuinit cyrix_identify(str
 	}
 }
 
-static struct cpu_dev cyrix_cpu_dev __cpuinitdata = {
+static const struct cpu_dev __cpuinitconst cyrix_cpu_dev = {
 	.c_vendor	= "Cyrix",
 	.c_ident	= { "CyrixInstead" },
 	.c_early_init	= early_init_cyrix,
@@ -446,7 +446,7 @@ static struct cpu_dev cyrix_cpu_dev __cp
 
 cpu_dev_register(cyrix_cpu_dev);
 
-static struct cpu_dev nsc_cpu_dev __cpuinitdata = {
+static const struct cpu_dev __cpuinitconst nsc_cpu_dev = {
 	.c_vendor	= "NSC",
 	.c_ident	= { "Geode by NSC" },
 	.c_init		= init_nsc,
--- linux-2.6.29-rc7/arch/x86/kernel/cpu/intel.c	2009-03-04 09:10:19.000000000 +0100
+++ 2.6.29-rc7-cpuinitconst-x86/arch/x86/kernel/cpu/intel.c	2009-02-18 15:34:25.000000000 +0100
@@ -374,7 +374,7 @@ static unsigned int __cpuinit intel_size
 }
 #endif
 
-static struct cpu_dev intel_cpu_dev __cpuinitdata = {
+static const struct cpu_dev __cpuinitconst intel_cpu_dev = {
 	.c_vendor	= "Intel",
 	.c_ident	= { "GenuineIntel" },
 #ifdef CONFIG_X86_32
--- linux-2.6.29-rc7/arch/x86/kernel/cpu/intel_cacheinfo.c	2009-03-04 09:10:19.000000000 +0100
+++ 2.6.29-rc7-cpuinitconst-x86/arch/x86/kernel/cpu/intel_cacheinfo.c	2009-02-18 15:34:25.000000000 +0100
@@ -32,7 +32,7 @@ struct _cache_table
 };
 
 /* all the cache descriptor types we care about (no TLB or trace cache entries) */
-static struct _cache_table cache_table[] __cpuinitdata =
+static const struct _cache_table __cpuinitconst cache_table[] =
 {
 	{ 0x06, LVL_1_INST, 8 },	/* 4-way set assoc, 32 byte line size */
 	{ 0x08, LVL_1_INST, 16 },	/* 4-way set assoc, 32 byte line size */
@@ -197,15 +197,15 @@ union l3_cache {
 	unsigned val;
 };
 
-static unsigned short assocs[] __cpuinitdata = {
+static const unsigned short __cpuinitconst assocs[] = {
 	[1] = 1, [2] = 2, [4] = 4, [6] = 8,
 	[8] = 16, [0xa] = 32, [0xb] = 48,
 	[0xc] = 64,
 	[0xf] = 0xffff // ??
 };
 
-static unsigned char levels[] __cpuinitdata = { 1, 1, 2, 3 };
-static unsigned char types[] __cpuinitdata = { 1, 2, 3, 3 };
+static const unsigned char __cpuinitconst levels[] = { 1, 1, 2, 3 };
+static const unsigned char __cpuinitconst types[] = { 1, 2, 3, 3 };
 
 static void __cpuinit
 amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,
--- linux-2.6.29-rc7/arch/x86/kernel/cpu/transmeta.c	2008-12-25 00:26:37.000000000 +0100
+++ 2.6.29-rc7-cpuinitconst-x86/arch/x86/kernel/cpu/transmeta.c	2009-02-18 15:34:25.000000000 +0100
@@ -98,7 +98,7 @@ static void __cpuinit init_transmeta(str
 #endif
 }
 
-static struct cpu_dev transmeta_cpu_dev __cpuinitdata = {
+static const struct cpu_dev __cpuinitconst transmeta_cpu_dev = {
 	.c_vendor	= "Transmeta",
 	.c_ident	= { "GenuineTMx86", "TransmetaCPU" },
 	.c_early_init	= early_init_transmeta,
--- linux-2.6.29-rc7/arch/x86/kernel/cpu/umc.c	2008-12-25 00:26:37.000000000 +0100
+++ 2.6.29-rc7-cpuinitconst-x86/arch/x86/kernel/cpu/umc.c	2009-02-18 15:34:25.000000000 +0100
@@ -8,7 +8,7 @@
  * so no special init takes place.
  */
 
-static struct cpu_dev umc_cpu_dev __cpuinitdata = {
+static const struct cpu_dev __cpuinitconst umc_cpu_dev = {
 	.c_vendor	= "UMC",
 	.c_ident	= { "UMC UMC UMC" },
 	.c_models = {
--- linux-2.6.29-rc7/arch/x86/kernel/mmconf-fam10h_64.c	2009-03-04 09:10:19.000000000 +0100
+++ 2.6.29-rc7-cpuinitconst-x86/arch/x86/kernel/mmconf-fam10h_64.c	2009-02-18 15:34:25.000000000 +0100
@@ -226,7 +226,7 @@ static int __devinit set_check_enable_am
         return 0;
 }
 
-static struct dmi_system_id __devinitdata mmconf_dmi_table[] = {
+static const struct dmi_system_id __cpuinitconst mmconf_dmi_table[] = {
         {
                 .callback = set_check_enable_amd_mmconf,
                 .ident = "Sun Microsystems Machine",


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ