diff mbox series

[3/3] x86/dmi: Constify quirks data

Message ID 20190724174256.5295-4-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show
Series x86/dmi: Cleanup | expand

Commit Message

Andrew Cooper July 24, 2019, 5:42 p.m. UTC
All DMI quirks tables are mutable, but are only ever read.

Update dmi_check_system() and dmi_system_id.callback to pass a const pointer,
and move all quirks tables into __initconst.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/dmi_scan.c             | 16 ++++++++--------
 xen/arch/x86/genapic/bigsmp.c       |  4 ++--
 xen/arch/x86/hvm/quirks.c           |  4 ++--
 xen/arch/x86/ioport_emulate.c       |  2 +-
 xen/arch/x86/shutdown.c             |  4 ++--
 xen/arch/x86/x86_64/mmconf-fam10h.c |  2 +-
 xen/include/xen/dmi.h               |  4 ++--
 7 files changed, 18 insertions(+), 18 deletions(-)

Comments

Jan Beulich July 25, 2019, 10:37 a.m. UTC | #1
On 24.07.2019 19:42, Andrew Cooper wrote:
> All DMI quirks tables are mutable, but are only ever read.
> 
> Update dmi_check_system() and dmi_system_id.callback to pass a const pointer,
> and move all quirks tables into __initconst.

I think you need to use __initconstrel throughout.

> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

With that adjustment
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan
Andrew Cooper July 25, 2019, 10:46 a.m. UTC | #2
On 25/07/2019 11:37, Jan Beulich wrote:
> On 24.07.2019 19:42, Andrew Cooper wrote:
>> All DMI quirks tables are mutable, but are only ever read.
>>
>> Update dmi_check_system() and dmi_system_id.callback to pass a const pointer,
>> and move all quirks tables into __initconst.
> I think you need to use __initconstrel throughout.

Hmm - what's the practical difference?  __initconst certainly compiles
fine for me.

(I've got no vested interest, but I'd like to understand why)

~Andrew
Jan Beulich July 25, 2019, 11:59 a.m. UTC | #3
On 25.07.2019 12:46, Andrew Cooper wrote:
> On 25/07/2019 11:37, Jan Beulich wrote:
>> On 24.07.2019 19:42, Andrew Cooper wrote:
>>> All DMI quirks tables are mutable, but are only ever read.
>>>
>>> Update dmi_check_system() and dmi_system_id.callback to pass a const pointer,
>>> and move all quirks tables into __initconst.
>> I think you need to use __initconstrel throughout.
> 
> Hmm - what's the practical difference?  __initconst certainly compiles
> fine for me.
> 
> (I've got no vested interest, but I'd like to understand why)

Some compiler versions dislike mixing of .section with the
same name, but different "writable" attributes. When static
initializers involve relocations, the respective section
gets marked writable by the compiler, whereas when they
don't the section would remain readonly. Hence things
generally build fine either way _until_ both an initconst
item with and one without relocations appear in the same CU.

Jan
diff mbox series

Patch

diff --git a/xen/arch/x86/dmi_scan.c b/xen/arch/x86/dmi_scan.c
index 7063c2c799..808fa7f10e 100644
--- a/xen/arch/x86/dmi_scan.c
+++ b/xen/arch/x86/dmi_scan.c
@@ -459,13 +459,13 @@  static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string)
  * Toshiba keyboard likes to repeat keys when they are not repeated.
  */
 
-static __init int broken_toshiba_keyboard(struct dmi_blacklist *d)
+static __init int broken_toshiba_keyboard(const struct dmi_blacklist *d)
 {
 	printk(KERN_WARNING "Toshiba with broken keyboard detected. If your keyboard sometimes generates 3 keypresses instead of one, see http://davyd.ucc.asn.au/projects/toshiba/README\n");
 	return 0;
 }
 
-static int __init ich10_bios_quirk(struct dmi_system_id *d)
+static int __init ich10_bios_quirk(const struct dmi_system_id *d)
 {
     u32 port, smictl;
 
@@ -488,14 +488,14 @@  static int __init ich10_bios_quirk(struct dmi_system_id *d)
     return 0;
 }
 
-static __init int reset_videomode_after_s3(struct dmi_blacklist *d)
+static __init int reset_videomode_after_s3(const struct dmi_blacklist *d)
 {
 	/* See wakeup.S */
 	acpi_video_flags |= 2;
 	return 0;
 }
 
-static __init int dmi_disable_acpi(struct dmi_blacklist *d) 
+static __init int dmi_disable_acpi(const struct dmi_blacklist *d)
 { 
 	if (!acpi_force) { 
 		printk(KERN_NOTICE "%s detected: acpi off\n",d->ident);
@@ -510,7 +510,7 @@  static __init int dmi_disable_acpi(struct dmi_blacklist *d)
 /*
  * Limit ACPI to CPU enumeration for HT
  */
-static __init int force_acpi_ht(struct dmi_blacklist *d) 
+static __init int force_acpi_ht(const struct dmi_blacklist *d)
 { 
 	if (!acpi_force) { 
 		printk(KERN_NOTICE "%s detected: force use of acpi=ht\n", d->ident);
@@ -533,7 +533,7 @@  static __init int force_acpi_ht(struct dmi_blacklist *d)
  *	interrupt mask settings according to the laptop
  */
  
-static __initdata struct dmi_blacklist dmi_blacklist[]={
+static const struct dmi_blacklist __initconst dmi_blacklist[]={
 
 	{ broken_toshiba_keyboard, "Toshiba Satellite 4030cdt", { /* Keyboard generates spurious repeats */
 			MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),
@@ -708,10 +708,10 @@  void __init dmi_scan_machine(void)
  *	returns non zero or we hit the end. Callback function is called for
  *	each successfull match. Returns the number of matches.
  */
-int __init dmi_check_system(struct dmi_system_id *list)
+int __init dmi_check_system(const struct dmi_system_id *list)
 {
 	int i, count = 0;
-	struct dmi_system_id *d = list;
+	const struct dmi_system_id *d = list;
 
 	while (d->ident) {
 		for (i = 0; i < ARRAY_SIZE(d->matches); i++) {
diff --git a/xen/arch/x86/genapic/bigsmp.c b/xen/arch/x86/genapic/bigsmp.c
index 91a973ac16..2ed1cb8f49 100644
--- a/xen/arch/x86/genapic/bigsmp.c
+++ b/xen/arch/x86/genapic/bigsmp.c
@@ -11,7 +11,7 @@ 
 #include <asm/mach-default/mach_mpparse.h>
 #include <asm/io_apic.h>
 
-static __init int force_bigsmp(struct dmi_system_id *d)
+static __init int force_bigsmp(const struct dmi_system_id *d)
 {
 	printk(KERN_NOTICE "%s detected: force use of apic=bigsmp\n", d->ident);
 	def_to_bigsmp = true;
@@ -19,7 +19,7 @@  static __init int force_bigsmp(struct dmi_system_id *d)
 }
 
 
-static struct dmi_system_id __initdata bigsmp_dmi_table[] = {
+static const struct dmi_system_id __initconst bigsmp_dmi_table[] = {
 	{ force_bigsmp, "UNISYS ES7000-ONE", {
 		DMI_MATCH(DMI_PRODUCT_NAME, "ES7000-ONE")
 	 }},
diff --git a/xen/arch/x86/hvm/quirks.c b/xen/arch/x86/hvm/quirks.c
index a298ccdbb9..906bf80cc3 100644
--- a/xen/arch/x86/hvm/quirks.c
+++ b/xen/arch/x86/hvm/quirks.c
@@ -24,7 +24,7 @@ 
 s8 __read_mostly hvm_port80_allowed = -1;
 boolean_param("hvm_port80", hvm_port80_allowed);
 
-static int __init dmi_hvm_deny_port80(/*const*/ struct dmi_system_id *id)
+static int __init dmi_hvm_deny_port80(const struct dmi_system_id *id)
 {
     printk(XENLOG_WARNING "%s: port 0x80 access %s allowed for HVM guests\n",
            id->ident, hvm_port80_allowed > 0 ? "forcibly" : "not");
@@ -41,7 +41,7 @@  static int __init check_port80(void)
      * Quirk table for systems that misbehave (lock up, etc.) if port
      * 0x80 is used:
      */
-    static struct dmi_system_id __initdata hvm_no_port80_dmi_table[] =
+    static const struct dmi_system_id __initconst hvm_no_port80_dmi_table[] =
     {
         {
             .callback = dmi_hvm_deny_port80,
diff --git a/xen/arch/x86/ioport_emulate.c b/xen/arch/x86/ioport_emulate.c
index 504bc513e2..626533b66c 100644
--- a/xen/arch/x86/ioport_emulate.c
+++ b/xen/arch/x86/ioport_emulate.c
@@ -34,7 +34,7 @@  static bool ioemul_handle_proliant_quirk(
 }
 
 /* This table is the set of system-specific I/O emulation hooks. */
-static struct dmi_system_id __initdata ioport_quirks_tbl[] = {
+static const struct dmi_system_id __initconst ioport_quirks_tbl[] = {
     /*
      * I/O emulation hook for certain HP ProLiant servers with
      * 'special' SMM goodness.
diff --git a/xen/arch/x86/shutdown.c b/xen/arch/x86/shutdown.c
index 69b82542b3..3af7b5b023 100644
--- a/xen/arch/x86/shutdown.c
+++ b/xen/arch/x86/shutdown.c
@@ -157,7 +157,7 @@  static void default_reboot_type(void)
         reboot_type = BOOT_ACPI;
 }
 
-static int __init override_reboot(struct dmi_system_id *d)
+static int __init override_reboot(const struct dmi_system_id *d)
 {
     enum reboot_type type = (long)d->driver_data;
 
@@ -181,7 +181,7 @@  static int __init override_reboot(struct dmi_system_id *d)
     return 0;
 }
 
-static struct dmi_system_id __initdata reboot_dmi_table[] = {
+static const struct dmi_system_id __initconst reboot_dmi_table[] = {
     {    /* Handle problems with rebooting on Dell E520's */
         .callback = override_reboot,
         .driver_data = (void *)(long)BOOT_KBD,
diff --git a/xen/arch/x86/x86_64/mmconf-fam10h.c b/xen/arch/x86/x86_64/mmconf-fam10h.c
index fa2f5b4881..5af6f22c9f 100644
--- a/xen/arch/x86/x86_64/mmconf-fam10h.c
+++ b/xen/arch/x86/x86_64/mmconf-fam10h.c
@@ -185,7 +185,7 @@  void fam10h_check_enable_mmcfg(void)
 	wrmsrl(MSR_FAM10H_MMIO_CONF_BASE, val);
 }
 
-static struct dmi_system_id __initdata mmconf_dmi_table[] = {
+static const struct dmi_system_id __initconst mmconf_dmi_table[] = {
 	{
 		.ident = "Sun Microsystems Machine",
 		.matches = {
diff --git a/xen/include/xen/dmi.h b/xen/include/xen/dmi.h
index eba2c27b2f..fa25f6cd38 100644
--- a/xen/include/xen/dmi.h
+++ b/xen/include/xen/dmi.h
@@ -24,7 +24,7 @@  struct dmi_strmatch {
 };
 
 struct dmi_system_id {
-	int (*callback)(struct dmi_system_id *);
+	int (*callback)(const struct dmi_system_id *);
 	char *ident;
 	struct dmi_strmatch matches[4];
 	void *driver_data;
@@ -32,7 +32,7 @@  struct dmi_system_id {
 
 #define DMI_MATCH(a,b)	{ a, b }
 
-extern int dmi_check_system(struct dmi_system_id *list);
+extern int dmi_check_system(const struct dmi_system_id *list);
 extern void dmi_scan_machine(void);
 extern const char *dmi_get_table(paddr_t *base, u32 *len);
 extern void dmi_efi_get_table(const void *smbios, const void *smbios3);