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
| ||
|
Message-Id: <1403477209-14612-4-git-send-email-minipli@googlemail.com> Date: Mon, 23 Jun 2014 00:46:49 +0200 From: Mathias Krause <minipli@...glemail.com> To: linux-kernel@...r.kernel.org Cc: Andrew Morton <akpm@...ux-foundation.org>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Steven Rostedt <rostedt@...dmis.org>, Joe Perches <joe@...ches.com>, "Rafael J. Wysocki" <rjw@...ysocki.net>, Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, "H. Peter Anvin" <hpa@...or.com>, Jason Baron <jbaron@...hat.com>, Mathias Krause <minipli@...glemail.com> Subject: [RFC PATCH 3/3] x86, acpi: Mark __init strings as such Make use of the pi_<level>() helpers to mark the strings printed during initialization for automatic release. Do so for the strings used in command line parsing as well, by using the __init_str() macro. Also convert the remaining printk() calls to their pr_<level> / pi_<level> counterparts. This moves ~1.7 kB from the .rodata section to .init.rodata. Signed-off-by: Mathias Krause <minipli@...glemail.com> --- Should the checkpatch warnings be handled, too, e.g. removing the line breaks for strings?: WARNING: quoted string split across lines #421: FILE: arch/x86/kernel/acpi/boot.c:1263: + pi_notice("Warning: DMI blacklist says broken, but acpi " + "forced\n"); I'd rather not remove the braces as it's IMHO more readable and more consistent with the coding style with them, as this is just the start of a huge if-else-if-.. block: WARNING: braces {} are not necessary for single statement blocks #453: FILE: arch/x86/kernel/acpi/boot.c:1520: + if (strcmp(arg, _("off")) == 0) { disable_acpi(); } arch/x86/kernel/acpi/boot.c | 162 ++++++++++++++++++++----------------------- 1 file changed, 74 insertions(+), 88 deletions(-) diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index 86281ffb96..dc7d8b1f54 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -23,6 +23,8 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#define pr_fmt(fmt) "ACPI: " fmt + #include <linux/init.h> #include <linux/acpi.h> #include <linux/acpi_pmtmr.h> @@ -53,7 +55,7 @@ EXPORT_SYMBOL(acpi_disabled); # include <asm/proto.h> #endif /* X86 */ -#define PREFIX "ACPI: " +#define _(x) __init_str(x) int acpi_noirq; /* skip ACPI IRQ initialization */ int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */ @@ -167,15 +169,14 @@ static int __init acpi_parse_madt(struct acpi_table_header *table) madt = (struct acpi_table_madt *)table; if (!madt) { - printk(KERN_WARNING PREFIX "Unable to map MADT\n"); + pi_warn("Unable to map MADT\n"); return -ENODEV; } if (madt->address) { acpi_lapic_addr = (u64) madt->address; - printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n", - madt->address); + pi_debug("Local APIC address 0x%08x\n", madt->address); } default_acpi_madt_oem_check(madt->header.oem_id, @@ -196,7 +197,7 @@ static int acpi_register_lapic(int id, u8 enabled) unsigned int ver = 0; if (id >= MAX_LOCAL_APIC) { - printk(KERN_INFO PREFIX "skipped apicid that is too big\n"); + pr_info("skipped apicid that is too big\n"); return -EINVAL; } @@ -236,11 +237,11 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end) * when we use CPU hotplug. */ if (!apic->apic_id_valid(apic_id) && enabled) - printk(KERN_WARNING PREFIX "x2apic entry ignored\n"); + pi_warn("x2apic entry ignored\n"); else acpi_register_lapic(apic_id, enabled); #else - printk(KERN_WARNING PREFIX "x2apic entry ignored\n"); + pi_warn("x2apic entry ignored\n"); #endif return 0; @@ -319,7 +320,7 @@ acpi_parse_x2apic_nmi(struct acpi_subtable_header *header, acpi_table_print_madt_entry(header); if (x2apic_nmi->lint != 1) - printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n"); + pi_warn("NMI not connected to LINT 1!\n"); return 0; } @@ -337,7 +338,7 @@ acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long e acpi_table_print_madt_entry(header); if (lapic_nmi->lint != 1) - printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n"); + pi_warn("NMI not connected to LINT 1!\n"); return 0; } @@ -420,14 +421,14 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header, if (intsrc->source_irq == 0) { if (acpi_skip_timer_override) { - printk(PREFIX "BIOS IRQ0 override ignored.\n"); + pi_info("BIOS IRQ0 override ignored.\n"); return 0; } if ((intsrc->global_irq == 2) && acpi_fix_pin2_polarity && (intsrc->inti_flags & ACPI_MADT_POLARITY_MASK)) { intsrc->inti_flags &= ~ACPI_MADT_POLARITY_MASK; - printk(PREFIX "BIOS IRQ0 pin2 override: forcing polarity to high active.\n"); + pi_info("BIOS IRQ0 pin2 override: forcing polarity to high active.\n"); } } @@ -503,7 +504,7 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger) if (old == new) return; - printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old); + pi_info("setting ELCR to %04x (from %04x)\n", new, old); outb(new, 0x4d0); outb(new >> 8, 0x4d1); } @@ -622,7 +623,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu) cpu = acpi_register_lapic(physid, ACPI_MADT_ENABLED); if (cpu < 0) { - pr_info(PREFIX "Unable to map lapic to logical cpu number\n"); + pr_info("Unable to map lapic to logical cpu number\n"); return cpu; } @@ -678,7 +679,7 @@ static int __init acpi_parse_sbf(struct acpi_table_header *table) sb = (struct acpi_table_boot *)table; if (!sb) { - printk(KERN_WARNING PREFIX "Unable to map SBF\n"); + pi_warn("Unable to map SBF\n"); return -ENODEV; } @@ -698,13 +699,12 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table) hpet_tbl = (struct acpi_table_hpet *)table; if (!hpet_tbl) { - printk(KERN_WARNING PREFIX "Unable to map HPET\n"); + pi_warn("Unable to map HPET\n"); return -ENODEV; } if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) { - printk(KERN_WARNING PREFIX "HPET timers must be located in " - "memory.\n"); + pi_warn("HPET timers must be located in memory.\n"); return -1; } @@ -716,9 +716,8 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table) * want to allocate a resource there. */ if (!hpet_address) { - printk(KERN_WARNING PREFIX - "HPET id: %#x base: %#lx is invalid\n", - hpet_tbl->id, hpet_address); + pi_warn("HPET id: %#x base: %#lx is invalid\n", hpet_tbl->id, + hpet_address); return 0; } #ifdef CONFIG_X86_64 @@ -729,21 +728,19 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table) */ if (hpet_address == 0xfed0000000000000UL) { if (!hpet_force_user) { - printk(KERN_WARNING PREFIX "HPET id: %#x " - "base: 0xfed0000000000000 is bogus\n " - "try hpet=force on the kernel command line to " - "fix it up to 0xfed00000.\n", hpet_tbl->id); + pi_warn("HPET id: %#x base: %#lx is bogus\n", + hpet_tbl->id, 0xfed0000000000000UL); + pi_cont("try hpet=force on the kernel command line " + "to fix it up to 0xfed00000.\n"), hpet_address = 0; return 0; } - printk(KERN_WARNING PREFIX - "HPET id: %#x base: 0xfed0000000000000 fixed up " - "to 0xfed00000.\n", hpet_tbl->id); + pi_warn("HPET id: %#x base: %#lx fixed up to 0xfed00000.\n", + hpet_tbl->id, 0xfed0000000000000UL); hpet_address >>= 32; } #endif - printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", - hpet_tbl->id, hpet_address); + pi_info("HPET id: %#x base: %#lx\n", hpet_tbl->id, hpet_address); /* * Allocate and initialize the HPET firmware resource for adding into @@ -754,7 +751,7 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table) hpet_res->name = (void *)&hpet_res[1]; hpet_res->flags = IORESOURCE_MEM; - snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u", + snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, _("HPET %u"), hpet_tbl->sequence); hpet_res->start = hpet_address; @@ -805,8 +802,7 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table) pmtmr_ioport = acpi_gbl_FADT.pm_timer_block; } if (pmtmr_ioport) - printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", - pmtmr_ioport); + pi_info("PM-Timer IO Port: %#x\n", pmtmr_ioport); #endif return 0; } @@ -833,8 +829,7 @@ static int __init early_acpi_parse_madt_lapic_addr_ovr(void) acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE, acpi_parse_lapic_addr_ovr, 0); if (count < 0) { - printk(KERN_ERR PREFIX - "Error parsing LAPIC address override entry\n"); + pi_err("Error parsing LAPIC address override entry\n"); return count; } @@ -860,8 +855,7 @@ static int __init acpi_parse_madt_lapic_entries(void) acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE, acpi_parse_lapic_addr_ovr, 0); if (count < 0) { - printk(KERN_ERR PREFIX - "Error parsing LAPIC address override entry\n"); + pi_err("Error parsing LAPIC address override entry\n"); return count; } @@ -877,11 +871,11 @@ static int __init acpi_parse_madt_lapic_entries(void) acpi_parse_lapic, MAX_LOCAL_APIC); } if (!count && !x2count) { - printk(KERN_ERR PREFIX "No LAPIC entries present\n"); + pi_err("No LAPIC entries present\n"); /* TBD: Cleanup to allow fallback to MPS */ return -ENODEV; } else if (count < 0 || x2count < 0) { - printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n"); + pi_err("Error parsing LAPIC entry\n"); /* TBD: Cleanup to allow fallback to MPS */ return count; } @@ -892,7 +886,7 @@ static int __init acpi_parse_madt_lapic_entries(void) count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0); if (count < 0 || x2count < 0) { - printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n"); + pi_err("Error parsing LAPIC NMI entry\n"); /* TBD: Cleanup to allow fallback to MPS */ return count; } @@ -950,7 +944,7 @@ void __init mp_config_acpi_legacy_irqs(void) mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA; #endif set_bit(MP_ISA_BUS, mp_bus_not_pci); - pr_debug("Bus #%d is ISA\n", MP_ISA_BUS); + pi_debug("Bus #%d is ISA\n", MP_ISA_BUS); /* * Use the default configuration for the IRQs 0-15. Unless @@ -988,7 +982,7 @@ void __init mp_config_acpi_legacy_irqs(void) } if (idx != mp_irq_entries) { - printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i); + pi_debug("IRQ%d used by override.\n", i); continue; /* IRQ already used */ } @@ -1056,16 +1050,15 @@ int mp_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity) ioapic = mp_find_ioapic(gsi); if (ioapic < 0) { - printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi); + pr_warn("No IOAPIC for GSI %u\n", gsi); return gsi; } ioapic_pin = mp_find_ioapic_pin(ioapic, gsi); if (ioapic_pin > MP_MAX_IOAPIC_PIN) { - printk(KERN_ERR "Invalid reference to IOAPIC pin " - "%d-%d\n", mpc_ioapic_id(ioapic), - ioapic_pin); + pr_err("Invalid reference to IOAPIC pin %d-%d\n", + mpc_ioapic_id(ioapic), ioapic_pin); return gsi; } @@ -1106,8 +1099,7 @@ static int __init acpi_parse_madt_ioapic_entries(void) * if "noapic" boot option, don't look for IO-APICs */ if (skip_ioapic_setup) { - printk(KERN_INFO PREFIX "Skipping IOAPIC probe " - "due to 'noapic' option.\n"); + pi_info("Skipping IOAPIC probe due to 'noapic' option.\n"); return -ENODEV; } @@ -1115,10 +1107,10 @@ static int __init acpi_parse_madt_ioapic_entries(void) acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic, MAX_IO_APICS); if (!count) { - printk(KERN_ERR PREFIX "No IOAPIC entries present\n"); + pi_err("No IOAPIC entries present\n"); return -ENODEV; } else if (count < 0) { - printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n"); + pi_err("Error parsing IOAPIC entry\n"); return count; } @@ -1126,8 +1118,7 @@ static int __init acpi_parse_madt_ioapic_entries(void) acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr, nr_irqs); if (count < 0) { - printk(KERN_ERR PREFIX - "Error parsing interrupt source overrides entry\n"); + pi_err("Error parsing interrupt source overrides entry\n"); /* TBD: Cleanup to allow fallback to MPS */ return count; } @@ -1147,7 +1138,7 @@ static int __init acpi_parse_madt_ioapic_entries(void) acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src, nr_irqs); if (count < 0) { - printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n"); + pi_err("Error parsing NMI SRC entry\n"); /* TBD: Cleanup to allow fallback to MPS */ return count; } @@ -1180,8 +1171,7 @@ static void __init early_acpi_process_madt(void) /* * Dell Precision Workstation 410, 610 come here. */ - printk(KERN_ERR PREFIX - "Invalid BIOS MADT, disabling ACPI\n"); + pi_err("Invalid BIOS MADT, disabling ACPI\n"); disable_acpi(); } } @@ -1216,8 +1206,7 @@ static void __init acpi_process_madt(void) /* * Dell Precision Workstation 410, 610 come here. */ - printk(KERN_ERR PREFIX - "Invalid BIOS MADT, disabling ACPI\n"); + pi_err("Invalid BIOS MADT, disabling ACPI\n"); disable_acpi(); } } else { @@ -1227,8 +1216,7 @@ static void __init acpi_process_madt(void) * Boot with "acpi=off" to use MPS on such a system. */ if (smp_found_config) { - printk(KERN_WARNING PREFIX - "No APIC-table, disabling MPS\n"); + pi_warn("No APIC-table, disabling MPS\n"); smp_found_config = 0; } } @@ -1238,11 +1226,11 @@ static void __init acpi_process_madt(void) * processors, where MPS only supports physical. */ if (acpi_lapic && acpi_ioapic) - printk(KERN_INFO "Using ACPI (MADT) for SMP configuration " - "information\n"); + pi_info("Using ACPI (MADT) for SMP configuration " + "information\n"); else if (acpi_lapic) - printk(KERN_INFO "Using ACPI for processor (LAPIC) " - "configuration information\n"); + pi_info("Using ACPI for processor (LAPIC) configuration " + "information\n"); #endif return; } @@ -1250,8 +1238,7 @@ static void __init acpi_process_madt(void) static int __init disable_acpi_irq(const struct dmi_system_id *d) { if (!acpi_force) { - printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n", - d->ident); + pi_info("%s detected: force use of acpi=noirq\n", d->ident); acpi_noirq_set(); } return 0; @@ -1260,8 +1247,7 @@ static int __init disable_acpi_irq(const struct dmi_system_id *d) static int __init disable_acpi_pci(const struct dmi_system_id *d) { if (!acpi_force) { - printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n", - d->ident); + pi_notice("%s detected: force use of pci=noacpi\n", d->ident); acpi_disable_pci(); } return 0; @@ -1270,11 +1256,11 @@ static int __init disable_acpi_pci(const struct dmi_system_id *d) static int __init dmi_disable_acpi(const struct dmi_system_id *d) { if (!acpi_force) { - printk(KERN_NOTICE "%s detected: acpi off\n", d->ident); + pi_notice("%s detected: acpi off\n", d->ident); disable_acpi(); } else { - printk(KERN_NOTICE - "Warning: DMI blacklist says broken, but acpi forced\n"); + pi_notice("Warning: DMI blacklist says broken, but acpi " + "forced\n"); } return 0; } @@ -1285,8 +1271,8 @@ static int __init dmi_disable_acpi(const struct dmi_system_id *d) static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d) { if (!acpi_skip_timer_override) { - pr_notice("%s detected: Ignoring BIOS IRQ0 override\n", - d->ident); + pi_notice("%s detected: Ignoring BIOS IRQ0 override\n", + d->ident); acpi_skip_timer_override = 1; } return 0; @@ -1469,9 +1455,9 @@ void __init acpi_boot_table_init(void) */ if (acpi_blacklisted()) { if (acpi_force) { - printk(KERN_WARNING PREFIX "acpi=force override\n"); + pi_warn("acpi=force override\n"); } else { - printk(KERN_WARNING PREFIX "Disabling ACPI support\n"); + pi_warn("Disabling ACPI support\n"); disable_acpi(); return; } @@ -1531,32 +1517,32 @@ static int __init parse_acpi(char *arg) return -EINVAL; /* "acpi=off" disables both ACPI table parsing and interpreter */ - if (strcmp(arg, "off") == 0) { + if (strcmp(arg, _("off")) == 0) { disable_acpi(); } /* acpi=force to over-ride black-list */ - else if (strcmp(arg, "force") == 0) { + else if (strcmp(arg, _("force")) == 0) { acpi_force = 1; acpi_disabled = 0; } /* acpi=strict disables out-of-spec workarounds */ - else if (strcmp(arg, "strict") == 0) { + else if (strcmp(arg, _("strict")) == 0) { acpi_strict = 1; } /* acpi=rsdt use RSDT instead of XSDT */ - else if (strcmp(arg, "rsdt") == 0) { + else if (strcmp(arg, _("rsdt")) == 0) { acpi_gbl_do_not_use_xsdt = TRUE; } /* "acpi=noirq" disables ACPI interrupt routing */ - else if (strcmp(arg, "noirq") == 0) { + else if (strcmp(arg, _("noirq")) == 0) { acpi_noirq_set(); } /* "acpi=copy_dsdt" copys DSDT */ - else if (strcmp(arg, "copy_dsdt") == 0) { + else if (strcmp(arg, _("copy_dsdt")) == 0) { acpi_gbl_copy_dsdt_locally = 1; } /* "acpi=nocmcff" disables FF mode for corrected errors */ - else if (strcmp(arg, "nocmcff") == 0) { + else if (strcmp(arg, _("nocmcff")) == 0) { acpi_disable_cmcff = 1; } else { /* Core will printk when we return error. */ @@ -1569,7 +1555,7 @@ early_param("acpi", parse_acpi); /* FIXME: Using pci= for an ACPI parameter is a travesty. */ static int __init parse_pci(char *arg) { - if (arg && strcmp(arg, "noacpi") == 0) + if (arg && strcmp(arg, _("noacpi")) == 0) acpi_disable_pci(); return 0; } @@ -1580,9 +1566,9 @@ int __init acpi_mps_check(void) #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE) /* mptable code is not built-in*/ if (acpi_disabled || acpi_noirq) { - printk(KERN_WARNING "MPS support code is not built-in.\n" - "Using acpi=off or acpi=noirq or pci=noacpi " - "may have problem\n"); + pi_warn("MPS support code is not built-in.\n"); + pi_cont("Using acpi=off or acpi=noirq or pci=noacpi " + "may have problems.\n"); return 1; } #endif @@ -1609,16 +1595,16 @@ static int __init setup_acpi_sci(char *s) { if (!s) return -EINVAL; - if (!strcmp(s, "edge")) + if (!strcmp(s, _("edge"))) acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE | (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK); - else if (!strcmp(s, "level")) + else if (!strcmp(s, _("level"))) acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL | (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK); - else if (!strcmp(s, "high")) + else if (!strcmp(s, _("high"))) acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH | (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK); - else if (!strcmp(s, "low")) + else if (!strcmp(s, _("low"))) acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW | (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK); else -- 1.7.10.4 -- 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