x86_64: Update defconfig
Subsystems (12)
PATCH 90/145 x86_64: Replace i386 open-coded cmdline parsing with
In reply to a message not in the archiver
From: Rusty Russell <[email protected]>
This patch replaces the open-coded early commandline parsing throughout the i386 boot code with the generic mechanism (already used by ppc, powerpc, ia64 and s390). The code was inconsistent with whether it deletes the option from the cmdline or not, meaning some of these will get passed through the environment into init.
This transformation is mainly mechanical, but there are some notable parts:
1) Grammar: s/linux never set's it up/linux never sets it up/
2) Remove hacked-in earlyprintk= option scanning. When someone actually implements CONFIG_EARLY_PRINTK, then they can use early_param().
[AK: actually it is implemented, but I'm adding the early_param it in the next x86-64 patch]
3) Move declaration of generic_apic_probe() from setup.c into asm/apic.h
4) Various parameters now moved into their appropriate files (thanks Andi).
5) All parse functions which examine arg need to check for NULL, except one where it has subtle humor value.
AK: readded acpi_sci handling which was completely dropped
AK: moved some more variables into acpi/boot.c
--- arch/i386/kernel/acpi/boot.c | 76 ++++++++ arch/i386/kernel/apic.c | 15 + arch/i386/kernel/io_apic.c | 24 ++ arch/i386/kernel/machine_kexec.c | 23 ++ arch/i386/kernel/setup.c | 350 +++++++++++++-------------------------- arch/i386/kernel/smpboot.c | 13 + arch/i386/mach-generic/probe.c | 58 +++--- arch/i386/mm/init.c | 18 +- include/asm-i386/acpi.h | 14 - include/asm-i386/apic.h | 4 include/asm-i386/io_apic.h | 11 + include/asm-i386/pgtable.h | 2 12 files changed, 319 insertions(+), 289 deletions(-)
arch/i386/kernel/acpi/boot.c +74 -2
@@ -36,6 +36,8 @@#include <asm/io.h> #include <asm/mpspec.h> +int __initdata acpi_force =0 ; +#ifdef CONFIG_X86_64 extern void __init clustered_apic_check (void );
@@ -860,8 +862,6 @@ static void __init acpi_process_madt(voireturn ; } -extern int acpi_force; -#ifdef __i386__static int __init disable_acpi_irq (struct dmi_system_id *d)
@@ -1163,3 +1163,75 @@ int __init acpi_boot_init(void)return 0 ; } + +static int __init parse_acpi (char *arg) +{ +if (!arg) +return -EINVAL ; + +/* "acpi=off" disables both ACPI table parsing and interpreter */ +if (strcmp (arg,"off" ) ==0 ) { +disable_acpi (); + } +/* acpi=force to over-ride black-list */ +else if (strcmp (arg,"force" ) ==0 ) { + acpi_force =1 ; + acpi_ht =1 ; + acpi_disabled =0 ; + } +/* acpi=strict disables out-of-spec workarounds */ +else if (strcmp (arg,"strict" ) ==0 ) { + acpi_strict =1 ; + } +/* Limit ACPI just to boot-time to enable HT */ +else if (strcmp (arg,"ht" ) ==0 ) { +if (!acpi_force) +disable_acpi (); + acpi_ht =1 ; + } +/* "acpi=noirq" disables ACPI interrupt routing */ +else if (strcmp (arg,"noirq" ) ==0 ) { +acpi_noirq_set (); + }else { +/* Core will printk when we return error. */ +return -EINVAL ; + } +return 0 ; +} +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 ) +acpi_disable_pci (); +return 0 ; +} +early_param ("pci" , parse_pci); + +#ifdef CONFIG_X86_IO_APIC +static int __init parse_acpi_skip_timer_override (char *arg) +{ + acpi_skip_timer_override =1 ; +return 0 ; +} +early_param ("acpi_skip_timer_override" , parse_acpi_skip_timer_override); +#endif /* CONFIG_X86_IO_APIC */ + +static int __init setup_acpi_sci (char *s) +{ +if (!s) +return -EINVAL ; +if (!strcmp (s,"edge" )) + acpi_sci_flags.trigger =1 ; +else if (!strcmp (s,"level" )) + acpi_sci_flags.trigger =3 ; +else if (!strcmp (s,"high" )) + acpi_sci_flags.polarity =1 ; +else if (!strcmp (s,"low" )) + acpi_sci_flags.polarity =3 ; +else +return -EINVAL ; +return 0 ; +} +early_param ("acpi_sci" , setup_acpi_sci);
arch/i386/kernel/apic.c +15 -0
@@ -1372,3 +1372,18 @@ int __init APIC_init_uniprocessor (void)return 0 ; } + +static int __init parse_lapic (char *arg) +{ +lapic_enable (); +return 0 ; +} +early_param ("lapic" , parse_lapic); + +static int __init parse_nolapic (char *arg) +{ +lapic_disable (); +return 0 ; +} +early_param ("nolapic" , parse_nolapic); +
arch/i386/kernel/io_apic.c +23 -1
@@ -66,7 +66,7 @@ int sis_apic_bug = -1;*/ int nr_ioapic_registers[MAX_IO_APICS ]; -int disable_timer_pin_1__initdata ; +static int disable_timer_pin_1__initdata ;/* * Rough estimation of how many shared IRQs there are, can
@@ -2691,3 +2691,25 @@ int io_apic_set_pci_routing (int ioapic, }#endif /* CONFIG_ACPI */ + +static int __init parse_disable_timer_pin_1 (char *arg) +{ + disable_timer_pin_1 =1 ; +return 0 ; +} +early_param ("disable_timer_pin_1" , parse_disable_timer_pin_1); + +static int __init parse_enable_timer_pin_1 (char *arg) +{ + disable_timer_pin_1 =-1 ; +return 0 ; +} +early_param ("enable_timer_pin_1" , parse_enable_timer_pin_1); + +static int __init parse_noapic (char *arg) +{ +/* disable IO-APIC */ +disable_ioapic_setup (); +return 0 ; +} +early_param ("noapic" , parse_noapic);
arch/i386/kernel/machine_kexec.c +23 -0
@@ -9,6 +9,7 @@#include <linux/mm.h> #include <linux/kexec.h> #include <linux/delay.h> +#include <linux/init.h> #include <asm/pgtable.h> #include <asm/pgalloc.h> #include <asm/tlbflush.h>
@@ -209,3 +210,25 @@ NORET_TYPE void machine_kexec(struct kim rnk = (relocate_new_kernel_t ) reboot_code_buffer; (*rnk)(page_list, reboot_code_buffer, image->start, cpu_has_pae); } + +/* crashkernel=size@addr specifies the location to reserve for +* a crash kernel. By reserving this memory we guarantee +* that linux never sets it up as a DMA target. +* Useful for holding code to do something appropriate +* after a kernel panic. +*/ +static int __init parse_crashkernel (char *arg) +{ +unsigned long size, base; + size =memparse (arg, &arg); +if (*arg =='@' ) { + base =memparse (arg+1 , &arg); +/* FIXME: Do I want a sanity check +* to validate the memory range? +*/ + crashk_res.start = base; + crashk_res.end = base + size -1 ; + } +return 0 ; +} +early_param ("crashkernel" , parse_crashkernel);
arch/i386/kernel/setup.c +118 -232
398 lines not on this page · raw message
arch/i386/kernel/smpboot.c +13 -0
@@ -1487,3 +1487,16 @@ void __init smp_intr_init(void)/* IPI for generic function call */ set_intr_gate (CALL_FUNCTION_VECTOR , call_function_interrupt); } + +/* +* If the BIOS enumerates physical processors before logical, +* maxcpus=N at enumeration-time can be used to disable HT. +*/ +static int __init parse_maxcpus (char *arg) +{ +extern unsigned int maxcpus; + + maxcpus =simple_strtoul (arg,NULL ,0 ); +return 0 ; +} +early_param ("maxcpus" , parse_maxcpus);
arch/i386/mach-generic/probe.c +28 -30
81 lines not on this page · raw message
arch/i386/mm/init.c +12 -6
@@ -435,16 +435,22 @@ u64 __supported_pte_mask __read_mostly =* on Enable * off Disable */ -void __init noexec_setup (const char *str) +static int __init noexec_setup (char *str) { -if (!strncmp (str,"on" ,2 ) && cpu_has_nx) { - __supported_pte_mask |= _PAGE_NX; - disable_nx =0 ; - }else if (!strncmp (str,"off" ,3 )) { +if (!str || !strcmp (str,"on" )) { +if (cpu_has_nx) { + __supported_pte_mask |= _PAGE_NX; + disable_nx =0 ; + } + }else if (!strcmp (str,"off" )) { disable_nx =1 ; __supported_pte_mask &= ~_PAGE_NX; - } + }else +return -EINVAL ; + +return 0 ; } +early_param ("noexec" , noexec_setup);int nx_enabled =0 ;#ifdef CONFIG_X86_PAE
include/asm-i386/acpi.h +0 -14
@@ -131,21 +131,7 @@ static inline void disable_acpi(void)extern int acpi_gsi_to_irq (u32 gsi,unsigned int *irq);#ifdef CONFIG_X86_IO_APIC -extern int skip_ioapic_setup;extern int acpi_skip_timer_override; - -static inline void disable_ioapic_setup (void ) -{ - skip_ioapic_setup =1 ; -} - -static inline int ioapic_setup_disabled (void ) -{ -return skip_ioapic_setup; -} - -#else -static inline void disable_ioapic_setup (void ) { }#endif static inline void acpi_noirq_set (void ) { acpi_noirq =1 ; }
include/asm-i386/apic.h +2 -2
@@ -42,6 +42,8 @@ static inline void lapic_enable(void) }while (0 ) +extern void generic_apic_probe(void); +#ifdef CONFIG_X86_LOCAL_APIC /*
@@ -117,8 +119,6 @@ extern void enable_APIC_timer(void);extern void enable_NMI_through_LVT0 (void * dummy); -extern int disable_timer_pin_1; -void smp_send_timer_broadcast_ipi (struct pt_regs *regs);void switch_APIC_timer_to_ipi (void *cpumask);void switch_ipi_to_APIC_timer (void *cpumask);
include/asm-i386/io_apic.h +11 -0
@@ -188,6 +188,16 @@ static inline void io_apic_modify(unsign/* 1 if "noapic" boot option passed */ extern int skip_ioapic_setup; +static inline void disable_ioapic_setup (void ) +{ + skip_ioapic_setup =1 ; +} + +static inline int ioapic_setup_disabled (void ) +{ +return skip_ioapic_setup; +} +/* * If we use the IO-APIC for IRQ routing, disable automatic * assignment of PCI IRQ's.
@@ -206,6 +216,7 @@ extern int (*ioapic_renumber_irq)(int io#else /* !CONFIG_X86_IO_APIC */ #define io_apic_assign_pci_irqs 0 +static inline void disable_ioapic_setup (void ) { }#endif extern int assign_irq_vector (int irq);
include/asm-i386/pgtable.h +0 -2
@@ -391,8 +391,6 @@ extern pte_t *lookup_address(unsigned lostatic inline int set_kernel_exec (unsigned long vaddr,int enable) {return 0 ;}#endif -extern void noexec_setup (const char *str); -#if defined(CONFIG_HIGHPTE )#define pte_offset_map (dir, address) \ ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address))
PATCH 91/145 x86_64: Convert x86-64 to early param
In reply to a message not in the archiver
Instead of hackish manual parsing
Requires earlier i386 patchkit, but also fixes i386 early_printk again.
I removed some obsolete really early parameters which didn't do anything useful. Also made a few parameters that needed it early (mostly oops printing setup)
Also removed one panic check that wasn't visible without early console anyways (the early console is now initialized after that panic)
This cleans up a lot of code.
--- arch/x86_64/kernel/apic.c | 34 +++--- arch/x86_64/kernel/e820.c | 53 ++++++++- arch/x86_64/kernel/early_printk.c | 20 +-- arch/x86_64/kernel/head64.c | 15 -- arch/x86_64/kernel/io_apic.c | 15 +- arch/x86_64/kernel/machine_kexec.c | 28 +++++ arch/x86_64/kernel/pci-dma.c | 7 - arch/x86_64/kernel/setup.c | 197 +++---------------------------------- arch/x86_64/kernel/setup64.c | 8 - arch/x86_64/kernel/smpboot.c | 6 - arch/x86_64/kernel/traps.c | 28 +++-- arch/x86_64/mm/numa.c | 9 + include/asm-x86_64/apic.h | 4 include/asm-x86_64/e820.h | 3 include/asm-x86_64/pgtable.h | 1 include/asm-x86_64/proto.h | 10 - 16 files changed, 162 insertions(+), 276 deletions(-)
arch/x86_64/kernel/early_printk.c +8 -12
@@ -215,20 +215,16 @@ void early_printk(const char *fmt, ...)static int __initdata keep_early; -int __init setup_early_printk (char *opt) +static int __init setup_early_printk (char *buf) { -char *space; -char buf[256 ]; +if (!buf) +return 0 ;if (early_console_initialized) -return 1 ; - -strlcpy (buf,opt,sizeof (buf)); - space =strchr (buf,' ' ); -if (space) - *space =0 ; +return 0 ; + early_console_initialized =1 ; -if (strstr (buf,"keep" )) +if (!strcmp (buf,"keep" )) keep_early =1 ;if (!strncmp (buf,"serial" ,6 )) {
@@ -248,11 +244,12 @@ int __init setup_early_printk(char *opt) early_console = &simnow_console; keep_early =1 ; } - early_console_initialized =1 ;register_console (early_console);return 0 ; } +early_param ("earlyprintk" , setup_early_printk); +void __init disable_early_printk (void ) {if (!early_console_initialized || !early_console)
@@ -266,4 +263,3 @@ void __init disable_early_printk(void) } } -__setup ("earlyprintk=" , setup_early_printk);
arch/x86_64/kernel/head64.c +0 -15
@@ -58,7 +58,6 @@ static void __init copy_bootdata(char *rvoid __init x86_64_start_kernel (char * real_mode_data) { -char *s;int i;for (i =0 ; i <256 ; i++)
@@ -85,19 +84,5 @@ void __init x86_64_start_kernel(char * r#ifdef CONFIG_SMP cpu_set (0 , cpu_online_map);#endif - s =strstr (saved_command_line,"earlyprintk=" ); -if (s !=NULL ) -setup_early_printk (strchr (s,'=' ) +1 ); -#ifdef CONFIG_NUMA - s =strstr (saved_command_line,"numa=" ); -if (s !=NULL ) -numa_setup (s+5 ); -#endif -if (strstr (saved_command_line,"disableapic" )) - disable_apic =1 ; -/* You need early console to see that */ -if (__pa_symbol (&_end) >=KERNEL_TEXT_SIZE ) -panic ("Kernel too big for kernel mapping\n" ); -start_kernel (); }
arch/x86_64/kernel/setup.c +18 -179
219 lines not on this page · raw message
arch/x86_64/mm/numa.c +6 -3
@@ -348,9 +348,10 @@ void __init paging_init(void) } } -/* [numa=off] */ -__init int numa_setup (char *opt) +static __init int numa_setup (char *opt) { +if (!opt) +return -EINVAL ;if (!strncmp (opt,"off" ,3 )) numa_off =1 ;#ifdef CONFIG_NUMA_EMU
@@ -366,9 +367,11 @@ __init int numa_setup(char *opt)if (!strncmp (opt,"hotadd=" ,7 )) hotadd_percent =simple_strtoul (opt+7 ,NULL ,10 );#endif -return 1 ; +return 0 ; } +early_param ("numa" , numa_setup); +/* * Setup early cpu_to_node. *
include/asm-x86_64/proto.h +0 -10
@@ -53,9 +53,6 @@ extern int nohpet;extern unsigned long vxtime_hz;extern void time_init_gtod (void ); -extern int numa_setup (char *opt); - -extern int setup_early_printk (char *);extern void early_printk (const char *fmt, ...) __attribute__((format (printf,1 ,2 )));extern void early_identify_cpu (struct cpuinfo_x86 *c);
@@ -104,13 +101,7 @@ extern void select_idle_routine(const stextern unsigned long table_start, table_end;extern int exception_trace; -extern int using_apic_timer; -extern int disable_apic;extern unsigned cpu_khz; -extern int ioapic_force; -extern int skip_ioapic_setup; -extern int acpi_ht; -extern int acpi_disabled;extern void no_iommu_init (void );extern int force_iommu, no_iommu;
@@ -132,7 +123,6 @@ extern int fix_aperture;extern int reboot_force;extern int notsc_setup (char *); -extern int setup_additional_cpus (char *);extern void smp_local_timer_interrupt (struct pt_regs * regs);
arch/x86_64/kernel/apic.c +19 -15
@@ -36,6 +36,7 @@#include <asm/idle.h> #include <asm/proto.h> #include <asm/timex.h> +#include <asm/apic.h> int apic_verbosity;int apic_runs_main_timer;
@@ -546,18 +547,24 @@ static void apic_pm_activate(void) { }static int __init apic_set_verbosity (char *str) { +if (str ==NULL ) { + skip_ioapic_setup =0 ; + ioapic_force =1 ; +return 0 ; + }if (strcmp ("debug" , str) ==0 ) apic_verbosity =APIC_DEBUG ;else if (strcmp ("verbose" , str) ==0 ) apic_verbosity =APIC_VERBOSE ; -else +else {printk (KERN_WARNING "APIC Verbosity level %s not recognised" -" use apic=verbose or apic=debug" , str); +" use apic=verbose or apic=debug\n" , str); +return -EINVAL ; + } -return 1 ; +return 0 ; } - -__setup ("apic=" , apic_set_verbosity); +early_param ("apic" , apic_set_verbosity);/* * Detect and enable local APICs on non-SMP boards.
@@ -1078,14 +1085,17 @@ int __init APIC_init_uniprocessor (void)static __init int setup_disableapic (char *str) { disable_apic =1 ; -return 1 ; -} +clear_bit (X86_FEATURE_APIC , boot_cpu_data.x86_capability); +return 0 ; +} +early_param ("disableapic" , setup_disableapic); +/* same as disableapic, for compatibility */ static __init int setup_nolapic (char *str) { - disable_apic =1 ; -return 1 ; +return setup_disableapic (str); } +early_param ("nolapic" , setup_nolapic);static __init int setup_noapictimer (char *str) {
@@ -1118,11 +1128,5 @@ static __init int setup_apicpmtimer(char }__setup ("apicpmtimer" , setup_apicpmtimer); -/* dummy parsing: see setup.c */ - -__setup ("disableapic" , setup_disableapic); -__setup ("nolapic" , setup_nolapic);/* same as disableapic, for compatibility */ -__setup ("noapictimer" , setup_noapictimer); -/* no "lapic" flag - we only use the lapic when the BIOS tells us so. */
arch/x86_64/kernel/e820.c +43 -10
74 lines not on this page · raw message
arch/x86_64/kernel/io_apic.c +7 -8
@@ -48,7 +48,7 @@ int sis_apic_bug; /* not actually supporstatic int no_timer_check; -int disable_timer_pin_1__initdata ; +static int disable_timer_pin_1__initdata ;int timer_over_8254__initdata =0 ;
@@ -253,18 +253,17 @@ int ioapic_force;static int __init disable_ioapic_setup (char *str) { skip_ioapic_setup =1 ; -return 1 ; +return 0 ; } +early_param ("noapic" , disable_ioapic_setup); -static int __init enable_ioapic_setup (char *str) +/* Actually the next is obsolete, but keep it for paranoid reasons -AK */ +static int __init disable_timer_pin_setup (char *arg) { - ioapic_force =1 ; - skip_ioapic_setup =0 ; + disable_timer_pin_1 =1 ;return 1 ; } - -__setup ("noapic" , disable_ioapic_setup); -__setup ("apic" , enable_ioapic_setup); +__setup ("disable_timer_pin_1" , disable_timer_pin_setup);static int __init setup_disable_8254_timer (char *s) {
arch/x86_64/kernel/pci-dma.c +5 -2
@@ -274,6 +274,9 @@ __init int iommu_setup(char *p) { iommu_merge =1 ; +if (!p) +return -EINVAL ; +while (*p) {if (!strncmp (p,"off" ,3 )) no_iommu =1 ;
@@ -320,9 +323,9 @@ __init int iommu_setup(char *p)if (*p ==',' ) ++p; } -return 1 ; +return 0 ; } -__setup ("iommu=" , iommu_setup); +early_param ("iommu" , iommu_setup);void __init pci_iommu_alloc (void ) {
arch/x86_64/kernel/setup64.c +5 -3
@@ -46,8 +46,10 @@ Control non executable mappings for 64bion Enable(default) off Disable */ -int __init nonx_setup (char *str) +static int __init nonx_setup (char *str) { +if (!str) +return -EINVAL ;if (!strncmp (str,"on" ,2 )) { __supported_pte_mask |= _PAGE_NX; do_not_nx =0 ;
@@ -55,9 +57,9 @@ int __init nonx_setup(char *str) do_not_nx =1 ; __supported_pte_mask &= ~_PAGE_NX; } -return 1 ; +return 0 ; } -__setup ("noexec=" , nonx_setup);/* parsed early actually */ +early_param ("noexec" , nonx_setup);int force_personality32 =0 ;
arch/x86_64/kernel/smpboot.c +3 -3
@@ -1270,11 +1270,11 @@ void __cpu_die(unsigned int cpu) printk(KERN_ERR "CPU %u didn't die...\n", cpu); } -__init int setup_additional_cpus (char *s) +static __init int setup_additional_cpus (char *s) { -return get_option (&s, &additional_cpus); +return s &&get_option (&s, &additional_cpus) ?0 : -EINVAL ; } -__setup ("additional_cpus=" , setup_additional_cpus); +early_param ("additional_cpus" , setup_additional_cpus);#else /* ... !CONFIG_HOTPLUG_CPU */
arch/x86_64/kernel/traps.c +18 -10
@@ -1114,24 +1114,29 @@ void __init trap_init(void)cpu_init (); } - -/* Actual parsing is done early in setup.c. */ -static int __init oops_dummy (char *s) +static int __init oops_setup (char *s) { - panic_on_oops =1 ; -return 1 ; +if (!s) +return -EINVAL ; +if (!strcmp (s,"panic" )) + panic_on_oops =1 ; +return 0 ; } -__setup ("oops=" , oops_dummy); +early_param ("oops" , oops_setup);static int __init kstack_setup (char *s) { +if (!s) +return -EINVAL ; kstack_depth_to_print =simple_strtoul (s,NULL ,0 ); -return 1 ; +return 0 ; } -__setup ("kstack=" , kstack_setup); +early_param ("kstack" , kstack_setup);static int __init call_trace_setup (char *s) { +if (!s) +return -EINVAL ;if (strcmp (s,"old" ) ==0 ) call_trace =-1 ;else if (strcmp (s,"both" ) ==0 )
@@ -1140,6 +1145,9 @@ static int __init call_trace_setup(char call_trace =1 ; else if (strcmp(s, "new") == 0) call_trace =2 ; -return 1 ; +return 0 ; } -__setup ("call_trace=" , call_trace_setup); +early_param ("call_trace" , call_trace_setup); + + +
include/asm-x86_64/e820.h +1 -2
@@ -55,8 +55,7 @@ extern void e820_setup_gap(void);extern unsigned long e820_hole_size (unsigned long start_pfn,unsigned long end_pfn); -extern void __init parse_memopt (char *p,char **end); -extern void __init parse_memmapopt (char *p,char **end); +extern void finish_e820_parsing (void );extern struct e820map e820;
include/asm-x86_64/pgtable.h +0 -1
@@ -21,7 +21,6 @@ extern unsigned long __supported_pte_mas#define swapper_pg_dir init_level4_pgt -extern int nonx_setup (char *str);extern void paging_init (void );extern void clear_kernel_mapping (unsigned long addr,unsigned long size);
include/asm-x86_64/apic.h +1 -3
@@ -17,6 +17,7 @@extern int apic_verbosity;extern int apic_runs_main_timer; +extern int ioapic_force;/* * Define the default level of output to be very little
@@ -93,9 +94,6 @@ extern void setup_APIC_extened_lvt(unsig#define K8_APIC_EXT_INT_MSG_EXT 0x7#define K8_APIC_EXT_LVT_ENTRY_THRESHOLD 0 -extern int disable_timer_pin_1; - -void smp_send_timer_broadcast_ipi (void );void switch_APIC_timer_to_ipi (void *cpumask);void switch_ipi_to_APIC_timer (void *cpumask);
arch/x86_64/kernel/machine_kexec.c +28 -0
@@ -226,3 +226,31 @@ NORET_TYPE void machine_kexec(struct kim rnk = (relocate_new_kernel_t ) control_code_buffer; (*rnk)(page_list, control_code_buffer, image->start, start_pgtable); } + +/* crashkernel=size@addr specifies the location to reserve for +* a crash kernel. By reserving this memory we guarantee +* that linux never set's it up as a DMA target. +* Useful for holding code to do something appropriate +* after a kernel panic. +*/ +static int __init setup_crashkernel (char *arg) +{ +unsigned long size, base; +char *p; +if (!arg) +return -EINVAL ; + size =memparse (arg, &p); +if (arg == p) +return -EINVAL ; +if (*p =='@' ) { + base =memparse (p+1 , &p); +/* FIXME: Do I want a sanity check to validate the +* memory range? Yes you do, but it's too early for +* e820 -AK */ + crashk_res.start = base; + crashk_res.end = base + size -1 ; + } +return 0 ; +} +early_param ("crashkernel" , setup_crashkernel); +
PATCH 92/145 x86_64: Remove need for early lockdep init
In reply to a message not in the archiver
I think it was only needed for the printks and we can do them later.
I put in a single early_printk so that we know the kernel is alive (early_printk doesn't need any locks)
This makes some things easier for initialization of unwind for lockdep, which is needed by later patches.
--- arch/x86_64/kernel/head64.c | 8 +------- arch/x86_64/kernel/setup.c | 2 ++ 2 files changed, 3 insertions(+), 7 deletions(-)
arch/x86_64/kernel/head64.c +1 -7
@@ -45,15 +45,12 @@ static void __init copy_bootdata(char *r new_data = *(int *) (x86_boot_params +NEW_CL_POINTER );if (!new_data) {if (OLD_CL_MAGIC != * (u16 *)OLD_CL_MAGIC_ADDR ) { -printk ("so old bootloader that it does not support commandline?!\n" );return ; } new_data =OLD_CL_BASE_ADDR + * (u16 *)OLD_CL_OFFSET ; -printk ("old bootloader convention, maybe loadlin?\n" ); } command_line = (char *) ((u64)(new_data));memcpy (saved_command_line, command_line,COMMAND_LINE_SIZE ); -printk ("Bootdata ok (command line is %s)\n" , saved_command_line); }void __init x86_64_start_kernel (char * real_mode_data)
@@ -65,10 +62,7 @@ void __init x86_64_start_kernel(char * r asmvolatile ("lidt %0" ::"m" (idt_descr));clear_bss (); -/* -* This must be called really, really early: -*/ -lockdep_init (); +early_printk ("Kernel alive\n" );/* * switch to init_level4_pgt from boot_level4_pgt
arch/x86_64/kernel/setup.c +2 -0
@@ -355,6 +355,8 @@ void __init setup_arch(char **cmdline_p) {unsigned long kernel_end; +printk (KERN_INFO "Command line: %s\n" , saved_command_line); +ROOT_DEV =old_decode_dev (ORIG_ROOT_DEV ); screen_info =SCREEN_INFO ; edid_info =EDID_INFO ;
PATCH 93/145 i386/x86-64: Move acpi_disabled variables into acpi/boot.c
In reply to a message not in the archiver
Removes code duplication between i386/x86-64.
Not needed anymore in setup.c since early_param cleanup
--- arch/i386/kernel/acpi/boot.c | 7 +++++++ arch/i386/kernel/setup.c | 7 ------- arch/x86_64/kernel/setup.c | 3 --- 3 files changed, 7 insertions(+), 10 deletions(-)
arch/i386/kernel/acpi/boot.c +7 -0
@@ -38,6 +38,13 @@int __initdata acpi_force =0 ; +#ifdef CONFIG_ACPI +int acpi_disabled =0 ; +#else +int acpi_disabled =1 ; +#endif +EXPORT_SYMBOL (acpi_disabled); +#ifdef CONFIG_X86_64 extern void __init clustered_apic_check (void );
arch/i386/kernel/setup.c +0 -7
@@ -89,13 +89,6 @@ EXPORT_SYMBOL(boot_cpu_data);unsigned long mmu_cr4_features; -#ifdef CONFIG_ACPI -int acpi_disabled =0 ; -#else -int acpi_disabled =1 ; -#endif -EXPORT_SYMBOL (acpi_disabled); -/* for MCA, but anyone else can use it if they want */ unsigned int machine_id;#ifdef CONFIG_MCA
arch/x86_64/kernel/setup.c +0 -3
@@ -74,9 +74,6 @@ EXPORT_SYMBOL(boot_cpu_data);unsigned long mmu_cr4_features; -int acpi_disabled; -EXPORT_SYMBOL (acpi_disabled); -int acpi_numa__initdata ;/* Boot loader ID as an integer, for the benefit of proc_dointvec */
PATCH 94/145 x86_64: Clean up acpi_numa variable
In reply to a message not in the archiver
Move it into srat.c No need to clutter up setup.c for it
And remove use in setup.c completely - it only guarded a printk which can be done unconditionally.
--- arch/x86_64/kernel/setup.c | 5 +---- arch/x86_64/mm/srat.c | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-)
arch/x86_64/kernel/setup.c +1 -4
@@ -74,8 +74,6 @@ EXPORT_SYMBOL(boot_cpu_data);unsigned long mmu_cr4_features; -int acpi_numa__initdata ; -/* Boot loader ID as an integer, for the benefit of proc_dointvec */ int bootloader_type;
@@ -814,8 +812,7 @@ static void srat_detect_node(void) node =first_node (node_online_map);numa_set_node (cpu, node); -if (acpi_numa >0 ) -printk (KERN_INFO "CPU %d/%x -> Node %d\n" , cpu, apicid, node); +printk (KERN_INFO "CPU %d/%x -> Node %d\n" , cpu, apicid, node);#endif }
arch/x86_64/mm/srat.c +2 -0
@@ -21,6 +21,8 @@#include <asm/numa.h> #include <asm/e820.h> +int acpi_numa__initdata ; +#if (defined(CONFIG_ACPI_HOTPLUG_MEMORY ) || \ defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE )) \ && !defined(CONFIG_MEMORY_HOTPLUG )
PATCH 95/145 x86_64: Move e820 map into e820.c
In reply to a message not in the archiver
Minor cleanup. Keep setup.c free from unrelated clutter.
--- arch/x86_64/kernel/e820.c | 2 ++ arch/x86_64/kernel/setup.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-)
arch/x86_64/kernel/e820.c +2 -0
@@ -24,6 +24,8 @@#include <asm/bootsetup.h> #include <asm/sections.h> +struct e820map e820__initdata ; +/* * PFN of last memory page. */
arch/x86_64/kernel/setup.c +0 -1
@@ -97,7 +97,6 @@ struct sys_desc_table_struct {struct edid_info edid_info;EXPORT_SYMBOL_GPL (edid_info); -struct e820map e820;extern int root_mountflags;
PATCH 96/145 x86_64: Add sparse annotation to vsyscall.c
In reply to a message not in the archiver
Fixes
linux/arch/x86_64/kernel/vsyscall.c:276:7: warning: constant 0x0f40000000000 is so big it is long linux/arch/x86_64/kernel/vsyscall.c:80:14: warning: incorrect type in argument 1 (different address spaces)linux/arch/x86_64/kernel/vsyscall.c:80:14: expected void const volatile [noderef] *addr<asn:2>linux/arch/x86_64/kernel/vsyscall.c:80:14: got void *<noident>linux/arch/x86_64/kernel/vsyscall.c:200:7: warning: incorrect type in assignment (different address spaces)linux/arch/x86_64/kernel/vsyscall.c:200:7: expected unsigned short [usertype] *map1linux/arch/x86_64/kernel/vsyscall.c:200:7: got void [noderef] *<asn:2>linux/arch/x86_64/kernel/vsyscall.c:203:7: warning: incorrect type in assignment (different address spaces)linux/arch/x86_64/kernel/vsyscall.c:203:7: expected unsigned short [usertype] *map2linux/arch/x86_64/kernel/vsyscall.c:203:7: got void [noderef] *<asn:2>linux/arch/x86_64/kernel/vsyscall.c:215:10: warning: incorrect type in argument 1 (different address spaces)linux/arch/x86_64/kernel/vsyscall.c:215:10: expected void volatile [noderef] *addr<asn:2>linux/arch/x86_64/kernel/vsyscall.c:215:10: got unsigned short [usertype] *map2linux/arch/x86_64/kernel/vsyscall.c:217:10: warning: incorrect type in argument 1 (different address spaces)linux/arch/x86_64/kernel/vsyscall.c:217:10: expected void volatile [noderef] *addr<asn:2>linux/arch/x86_64/kernel/vsyscall.c:217:10: got unsigned short [usertype] *map1
--- arch/x86_64/kernel/vsyscall.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-)
arch/x86_64/kernel/vsyscall.c +8 -6
@@ -77,7 +77,8 @@ static __always_inline void do_vgettimeo __vxtime.tsc_quot) >> 32;/* See comment in x86_64 do_gettimeofday. */ }else { - usec += ((readl ((void *)fix_to_virt (VSYSCALL_HPET ) +0xf0 ) - + usec += ((readl ((void __iomem *) +fix_to_virt (VSYSCALL_HPET ) +0xf0 ) - __vxtime.last) * __vxtime.quot) >>32 ; } }while (read_seqretry (&__xtime_lock, sequence));
@@ -191,7 +192,8 @@ static int vsyscall_sysctl_change(ctl_ta void __user *buffer, size_t *lenp, loff_t *ppos) { extern u16 vsysc1, vsysc2; -u16 *map1, *map2; +u16 __iomem *map1; +u16 __iomem *map2;int ret =proc_dointvec (ctl, write, filp, buffer, lenp, ppos);if (!write)return ret;
@@ -206,11 +208,11 @@ static int vsyscall_sysctl_change(ctl_ta goto out; }if (!sysctl_vsyscall) { - *map1 =SYSCALL ; - *map2 =SYSCALL ; +writew (SYSCALL , map1); +writew (SYSCALL , map2); }else { - *map1 =NOP2 ; - *map2 =NOP2 ; +writew (NOP2 , map1); +writew (NOP2 , map2); }iounmap (map2); out:
PATCH 97/145 x86_64: Add sparse annotations to quiet sparse in arch/x86_64/mm/fault.c
In reply to a message not in the archiver
Fixes
linux/arch/x86_64/mm/fault.c:125:7: warning: incorrect type in argument 1 (different address spaces)linux/arch/x86_64/mm/fault.c:125:7: expected void [noderef] *<noident><asn:1>linux/arch/x86_64/mm/fault.c:125:7: got unsigned char *[assigned] instrlinux/arch/x86_64/mm/fault.c:163:8: warning: incorrect type in argument 1 (different address spaces)linux/arch/x86_64/mm/fault.c:163:8: expected void [noderef] *<noident><asn:1>linux/arch/x86_64/mm/fault.c:163:8: got unsigned char *[assigned] instrlinux/arch/x86_64/mm/fault.c:179:9: warning: incorrect type in argument 1 (different address spaces)linux/arch/x86_64/mm/fault.c:179:9: expected void [noderef] *<noident><asn:1>linux/arch/x86_64/mm/fault.c:179:9: got unsigned long *<noident>
--- arch/x86_64/mm/fault.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
arch/x86_64/mm/fault.c +5 -5
@@ -102,7 +102,7 @@ void bust_spinlocks(int yes) static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,unsigned long error_code) { -unsigned char *instr; +unsigned char __user *instr;int scan_more =1 ;int prefetch =0 ;unsigned char *max_instr;
@@ -111,7 +111,7 @@ static noinline int is_prefetch(struct pif (error_code &PF_INSTR )return 0 ; - instr = (unsigned char *)convert_rip_to_linear (current, regs); + instr = (unsigned char __user *)convert_rip_to_linear (current, regs); max_instr = instr +15 ;if (user_mode (regs) && instr >= (unsigned char *)TASK_SIZE )
@@ -122,7 +122,7 @@ static noinline int is_prefetch(struct punsigned char instr_hi;unsigned char instr_lo; -if (__get_user (opcode, instr)) +if (__get_user (opcode, (char __user *)instr))break ; instr_hi = opcode &0xf0 ;
@@ -160,7 +160,7 @@ static noinline int is_prefetch(struct pcase 0x00 :/* Prefetch instruction is 0x0F0D or 0x0F18 */ scan_more =0 ; -if (__get_user (opcode, instr)) +if (__get_user (opcode, (char __user *)instr))break ; prefetch = (instr_lo ==0xF ) && (opcode ==0x0D || opcode ==0x18 );
@@ -176,7 +176,7 @@ static noinline int is_prefetch(struct pstatic int bad_address (void *p) {unsigned long dummy; -return __get_user (dummy, (unsigned long *)p); +return __get_user (dummy, (unsigned long __user *)p); }void dump_pagetable (unsigned long address)
PATCH 98/145 x86_64: Fix most sparse warnings in sys_ia32.c
In reply to a message not in the archiver
Mostly by adding casts.
I didn't touch the "invalid access past ..." which are caused by the sigset conversion.
--- arch/x86_64/ia32/sys_ia32.c | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 deletions(-)
arch/x86_64/ia32/sys_ia32.c +13 -11
@@ -60,6 +60,7 @@#include <linux/highuid.h> #include <linux/vmalloc.h> #include <linux/fsnotify.h> +#include <linux/sysctl.h> #include <asm/mman.h> #include <asm/types.h> #include <asm/uaccess.h>
@@ -389,7 +390,9 @@ sys32_rt_sigprocmask(int how, compat_sig } }set_fs (KERNEL_DS ); - ret =sys_rt_sigprocmask (how, set ? &s :NULL , oset ? &s :NULL , + ret =sys_rt_sigprocmask (how, + set ? (sigset_t __user *)&s :NULL , + oset ? (sigset_t __user *)&s :NULL , sigsetsize);set_fs (old_fs);if (ret)return ret;
@@ -541,7 +544,7 @@ sys32_sysinfo(struct sysinfo32 __user *iint bitcount =0 ;set_fs (KERNEL_DS ); - ret =sys_sysinfo (&s); + ret =sys_sysinfo ((struct sysinfo __user *)&s);set_fs (old_fs);/* Check to see if any memory value is too large for 32-bit and scale
@@ -589,7 +592,7 @@ sys32_sched_rr_get_interval(compat_pid_tmm_segment_t old_fs =get_fs ();set_fs (KERNEL_DS ); - ret =sys_sched_rr_get_interval (pid, &t); + ret =sys_sched_rr_get_interval (pid, (struct timespec __user *)&t);set_fs (old_fs);if (put_compat_timespec (&t, interval))return -EFAULT ;
@@ -605,7 +608,7 @@ sys32_rt_sigpending(compat_sigset_t __usmm_segment_t old_fs =get_fs ();set_fs (KERNEL_DS ); - ret =sys_rt_sigpending (&s, sigsetsize); + ret =sys_rt_sigpending ((sigset_t __user *)&s, sigsetsize);set_fs (old_fs);if (!ret) {switch (_NSIG_WORDS) {
@@ -630,7 +633,7 @@ sys32_rt_sigqueueinfo(int pid, int sig,if (copy_siginfo_from_user32 (&info, uinfo))return -EFAULT ;set_fs (KERNEL_DS ); - ret =sys_rt_sigqueueinfo (pid, sig, &info); + ret =sys_rt_sigqueueinfo (pid, sig, (siginfo_t __user *)&info);set_fs (old_fs);return ret; }
@@ -666,9 +669,6 @@ sys32_sysctl(struct sysctl_ia32 __user *size_t oldlen;int __user *namep;long ret; -extern int do_sysctl (int *name,int nlen,void *oldval,size_t *oldlenp, -void *newval,size_t newlen); -if (copy_from_user (&a32, args32,sizeof (a32)))return -EFAULT ;
@@ -692,7 +692,8 @@ sys32_sysctl(struct sysctl_ia32 __user *set_fs (KERNEL_DS );lock_kernel (); - ret =do_sysctl (namep, a32.nlen, oldvalp, &oldlen, newvalp, (size_t ) a32.newlen); + ret =do_sysctl (namep, a32.nlen, oldvalp, (size_t __user *)&oldlen, + newvalp, (size_t ) a32.newlen);unlock_kernel ();set_fs (old_fs);
@@ -743,7 +744,8 @@ sys32_sendfile(int out_fd, int in_fd, coreturn -EFAULT ;set_fs (KERNEL_DS ); - ret =sys_sendfile (out_fd, in_fd, offset ? &of :NULL , count); + ret =sys_sendfile (out_fd, in_fd, offset ? (off_t __user *)&of :NULL , + count);set_fs (old_fs);if (offset &&put_user (of, offset))
@@ -831,7 +833,7 @@ long sys32_ustat(unsigned dev, struct us seg =get_fs ();set_fs (KERNEL_DS ); - ret =sys_ustat (dev,&u); + ret =sys_ustat (dev, (struct ustat __user *)&u);set_fs (seg);if (ret >=0 ) { if (!access_ok(VERIFY_WRITE,u32p,sizeof(struct ustat32)) ||
PATCH 99/145 x86_64: Fix sparse warnings in compat aout code
In reply to a message not in the archiver
--- arch/x86_64/ia32/ia32_aout.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
arch/x86_64/ia32/ia32_aout.c +5 -3
@@ -333,7 +333,8 @@ static int load_aout_binary(struct linuxreturn error; } - error = bprm->file->f_op->read (bprm->file, (char *)text_addr, + error = bprm->file->f_op->read (bprm->file, + (char __user *)text_addr, ex.a_text+ex.a_data, &pos);if ((signed long )error <0 ) {send_sig (SIGKILL , current,0 );
@@ -366,7 +367,8 @@ static int load_aout_binary(struct linuxdown_write (¤t->mm->mmap_sem);do_brk (N_TXTADDR (ex), ex.a_text+ex.a_data);up_write (¤t->mm->mmap_sem); - bprm->file->f_op->read (bprm->file,(char *)N_TXTADDR (ex), + bprm->file->f_op->read (bprm->file, + (char __user *)N_TXTADDR (ex), ex.a_text+ex.a_data, &pos); flush_icache_range((unsigned long) N_TXTADDR(ex), (unsigned long) N_TXTADDR(ex) +
@@ -477,7 +479,7 @@ static int load_aout_library(struct filedo_brk (start_addr, ex.a_text + ex.a_data + ex.a_bss);up_write (¤t->mm->mmap_sem); - file->f_op->read (file, (char *)start_addr, + file->f_op->read (file, (char __user *)start_addr, ex.a_text + ex.a_data, &pos);flush_icache_range ((unsigned long ) start_addr, (unsigned long ) start_addr + ex.a_text + ex.a_data);
PATCH 100/145 x86_64: Fix broken indentation in iommu_setup
In reply to a message not in the archiver
No functional changes; only white space.
--- arch/x86_64/kernel/pci-dma.c | 86 ++++++++++++++++++++----------------------- 1 files changed, 40 insertions(+), 46 deletions(-)
arch/x86_64/kernel/pci-dma.c +40 -46
@@ -272,58 +272,52 @@ EXPORT_SYMBOL(dma_set_mask);*/ __init int iommu_setup (char *p) { - iommu_merge =1 ; - + iommu_merge =1 ;if (!p)return -EINVAL ; - -while (*p) { -if (!strncmp (p,"off" ,3 )) - no_iommu =1 ; -/* gart_parse_options has more force support */ -if (!strncmp (p,"force" ,5 )) - force_iommu =1 ; -if (!strncmp (p,"noforce" ,7 )) { - iommu_merge =0 ; - force_iommu =0 ; - } - -if (!strncmp (p,"biomerge" ,8 )) { - iommu_bio_merge =4096 ; - iommu_merge =1 ; - force_iommu =1 ; - } -if (!strncmp (p,"panic" ,5 )) - panic_on_overflow =1 ; -if (!strncmp (p,"nopanic" ,7 )) - panic_on_overflow =0 ; -if (!strncmp (p,"merge" ,5 )) { - iommu_merge =1 ; - force_iommu =1 ; - } -if (!strncmp (p,"nomerge" ,7 )) - iommu_merge =0 ; -if (!strncmp (p,"forcesac" ,8 )) - iommu_sac_force =1 ; -if (!strncmp (p,"allowdac" ,8 )) - allow_dac =1 ; -if (!strncmp (p,"nodac" ,5 )) - allow_dac =-1 ; - +while (*p) { +if (!strncmp (p,"off" ,3 )) + no_iommu =1 ; +/* gart_parse_options has more force support */ +if (!strncmp (p,"force" ,5 )) + force_iommu =1 ; +if (!strncmp (p,"noforce" ,7 )) { + iommu_merge =0 ; + force_iommu =0 ; + } +if (!strncmp (p,"biomerge" ,8 )) { + iommu_bio_merge =4096 ; + iommu_merge =1 ; + force_iommu =1 ; + } +if (!strncmp (p,"panic" ,5 )) + panic_on_overflow =1 ; +if (!strncmp (p,"nopanic" ,7 )) + panic_on_overflow =0 ; +if (!strncmp (p,"merge" ,5 )) { + iommu_merge =1 ; + force_iommu =1 ; + } +if (!strncmp (p,"nomerge" ,7 )) + iommu_merge =0 ; +if (!strncmp (p,"forcesac" ,8 )) + iommu_sac_force =1 ; +if (!strncmp (p,"allowdac" ,8 )) + allow_dac =1 ; +if (!strncmp (p,"nodac" ,5 )) + allow_dac =-1 ;#ifdef CONFIG_SWIOTLB -if (!strncmp (p,"soft" ,4 )) - swiotlb =1 ; +if (!strncmp (p,"soft" ,4 )) + swiotlb =1 ;#endif -#ifdef CONFIG_IOMMU -gart_parse_options (p); +gart_parse_options (p);#endif - - p +=strcspn (p,"," ); -if (*p ==',' ) - ++p; - } -return 0 ; + p +=strcspn (p,"," ); +if (*p ==',' ) + ++p; + } +return 0 ; }early_param ("iommu" , iommu_setup);
PATCH 101/145 x86_64: Replace local_save_flags+local_irq_disable with
In reply to a message not in the archiver
From: Fernando Luis =?ISO-8859-1?Q?V=E1zquez?= Cao <[email protected]>
The combination of "local_save_flags" and "local_irq_disable" seems to be equivalent to "local_irq_save" (see code snips below). Consequently, replace occurrences of local_save_flags+local_irq_disable with local_irq_save.
* local_irq_save
#define raw_local_irq_save(flags) \
do { (flags) = __raw_local_irq_save(); } while (0)static inline unsigned long __raw_local_irq_save(void)
{
unsigned long flags = __raw_local_save_flags();
raw_local_irq_disable();
return flags;
}* local_save_flags
#define raw_local_save_flags(flags) \
do { (flags) = __raw_local_save_flags(); } while (0)---
--- arch/x86_64/kernel/apic.c | 3 +-- arch/x86_64/kernel/genapic_flat.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
arch/x86_64/kernel/apic.c +1 -2
@@ -468,8 +468,7 @@ static int lapic_suspend(struct sys_devi apic_pm_state.apic_tmict =apic_read (APIC_TMICT ); apic_pm_state.apic_tdcr =apic_read (APIC_TDCR ); apic_pm_state.apic_thmr =apic_read (APIC_LVTTHMR ); -local_save_flags (flags); -local_irq_disable (); +local_irq_save (flags);disable_local_APIC ();local_irq_restore (flags);return 0 ;
arch/x86_64/kernel/genapic_flat.c +1 -2
@@ -49,8 +49,7 @@ static void flat_send_IPI_mask(cpumask_tunsigned long cfg;unsigned long flags; -local_save_flags (flags); -local_irq_disable (); +local_irq_save (flags);/* * Wait for idle.
PATCH 102/145 x86_64: Remove unneeded externs in acpi/boot.c
In reply to a message not in the archiver
And move one into proto.h
--- arch/i386/kernel/acpi/boot.c | 3 --- include/asm-x86_64/proto.h | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-)
arch/i386/kernel/acpi/boot.c +0 -3
@@ -47,9 +47,6 @@ EXPORT_SYMBOL(acpi_disabled);#ifdef CONFIG_X86_64 -extern void __init clustered_apic_check (void ); - -extern int gsi_irq_sharing (int gsi);#include <asm/proto.h> static inline int acpi_madt_oem_check (char *oem_id,char *oem_table_id) {return 0 ; }
include/asm-x86_64/proto.h +2 -0
@@ -124,6 +124,8 @@ extern int fix_aperture;extern int reboot_force;extern int notsc_setup (char *); +extern int gsi_irq_sharing (int gsi); +extern void smp_local_timer_interrupt (struct pt_regs * regs);long do_arch_prctl (struct task_struct *task,int code,unsigned long addr);
Re: [PATCH for review] [102/145] x86_64: Remove unneeded externs in acpi/boot.c
Quoted 3 lines · Andi Kleen
And move one into
proto.h
Quoted 34 lines
Signed-off-by Andi Kleen <[email protected]>--- arch/i386/kernel/acpi/boot.c | 3 --- include/asm-x86_64/proto.h | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-)Index:
linux/arch/i386/kernel/acpi/boot.c
===================================================================arch/i386/kernel/acpi/boot.c +0
-3@@ -47,9 +47,6 @@ EXPORT_SYMBOL(acpi_disabled);#ifdef CONFIG_X86_64 -extern void __init clustered_apic_check (void ); - -extern int gsi_irq_sharing (int gsi);#include <asm/proto.h> static inline int acpi_madt_oem_check (char *oem_id,char *oem_table_id) {return 0 ; }Index:
linux/include/asm-x86_64/proto.h
===================================================================include/asm-x86_64/proto.h +2
-0@@ -124,6 +124,8 @@ extern int fix_aperture;extern int reboot_force;extern int notsc_setup (char *); +extern int gsi_irq_sharing (int gsi); +extern void smp_local_timer_interrupt (struct pt_regs * regs);long do_arch_prctl (struct task_struct *task,int code,unsigned long addr);
PATCH 103/145 i386/x86-64: rename is_at_popf(), add iret to tests and fix
In reply to a message not in the archiver
From: Chuck Ebbert <[email protected]>
is_at_popf() needs to test for the iret instruction as well as popf. So add that test and rename it to is_setting_trap_flag().
Also change max insn length from 16 to 15 to match reality.
LAHF / SAHF can't affect TF, so the comment in x86_64 is removed.
---
Tested on x86_64.
--- arch/i386/kernel/ptrace.c | 10 +++++----- arch/x86_64/kernel/ptrace.c | 12 +++++------- 2 files changed, 10 insertions(+), 12 deletions(-)
arch/i386/kernel/ptrace.c +5 -5
@@ -185,17 +185,17 @@ static unsigned long convert_eip_to_linereturn addr; } -static inline int is_at_popf (struct task_struct *child,struct pt_regs *regs) +static inline int is_setting_trap_flag (struct task_struct *child,struct pt_regs *regs) {int i, copied; -unsigned char opcode[16 ]; +unsigned char opcode[15 ];unsigned long addr =convert_eip_to_linear (child, regs); copied =access_process_vm (child, addr, opcode,sizeof (opcode),0 );for (i =0 ; i < copied; i++) {switch (opcode[i]) { -/* popf */ -case 0x9d : +/* popf and iret */ +case 0x9d :case 0xcf :return 1 ;/* opcode and address size prefixes */ case 0x66 :case 0x67 :
@@ -247,7 +247,7 @@ static void set_singlestep(struct task_s* don't mark it as being "us" that set it, so that we * won't clear it by hand later. */ -if (is_at_popf (child, regs)) +if (is_setting_trap_flag (child, regs))return ; child->ptrace |=PT_DTRACE ;
arch/x86_64/kernel/ptrace.c +5 -7
@@ -116,17 +116,17 @@ unsigned long convert_rip_to_linear(strureturn addr; } -static int is_at_popf (struct task_struct *child,struct pt_regs *regs) +static int is_setting_trap_flag (struct task_struct *child,struct pt_regs *regs) {int i, copied; -unsigned char opcode[16 ]; +unsigned char opcode[15 ];unsigned long addr =convert_rip_to_linear (child, regs); copied =access_process_vm (child, addr, opcode,sizeof (opcode),0 );for (i =0 ; i < copied; i++) {switch (opcode[i]) { -/* popf */ -case 0x9d : +/* popf and iret */ +case 0x9d :case 0xcf :return 1 ;/* CHECKME: 64 65 */
@@ -189,10 +189,8 @@ static void set_singlestep(struct task_s* ..but if TF is changed by the instruction we will trace, * don't mark it as being "us" that set it, so that we * won't clear it by hand later. -* -* AK: this is not enough, LAHF and IRET can change TF in user space too. */ -if (is_at_popf (child, regs)) +if (is_setting_trap_flag (child, regs))return ; child->ptrace |=PT_DTRACE ;
PATCH 104/145 x86_64: print whether CONFIG_IOMMU_DEBUG is enabled
In reply to a message not in the archiver
From: Muli Ben-Yehuda <[email protected]>
--- arch/x86_64/kernel/pci-calgary.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
arch/x86_64/kernel/pci-calgary.c +10 -4
@@ -127,15 +127,19 @@ static void tce_cache_blast(struct iommu/* enable this to stress test the chip's TCE cache */ #ifdef CONFIG_IOMMU_DEBUG +int debugging__read_mostly =1 ; +static inline void tce_cache_blast_stress (struct iommu_table *tbl) {tce_cache_blast (tbl); } -#else +#else /* debugging is disabled */ +int debugging__read_mostly =0 ; +static inline void tce_cache_blast_stress (struct iommu_table *tbl) { } -#endif /* BLAST_TCE_CACHE_ON_UNMAP */ +#endif /* CONFIG_IOMMU_DEBUG */ static inline unsigned int num_dma_pages (unsigned long dma,unsigned int dmalen) {
@@ -944,8 +948,10 @@ void __init detect_calgary(void)if (calgary_found) { iommu_detected =1 ; calgary_detected =1 ; -printk (KERN_INFO "PCI-DMA: Calgary IOMMU detected. " -"TCE table spec is %d.\n" , specified_table_size); +printk (KERN_INFO "PCI-DMA: Calgary IOMMU detected.\n" ); +printk (KERN_INFO "PCI-DMA: Calgary TCE table spec is %d, " +"CONFIG_IOMMU_DEBUG is %s.\n" , specified_table_size, + debugging ?"enabled" :"disabled" ); }return ;
PATCH 105/145 x86_64: only verify the allocation bitmap if CONFIG_IOMMU_DEBUG is on
In reply to a message not in the archiver
From: Muli Ben-Yehuda <[email protected]>
Introduce new function verify_bit_range(). Define two versions, one for CONFIG_IOMMU_DEBUG enabled and one for disabled. Previously we were checking that the bitmap was consistent every time we allocated or freed an entry in the TCE table, which is good for debugging but incurs an unnecessary penalty on non debug builds.
--- arch/x86_64/kernel/pci-calgary.c | 44 +++++++++++++++++++++++++++++++-------- 1 files changed, 35 insertions(+), 9 deletions(-)
arch/x86_64/kernel/pci-calgary.c +35 -9
@@ -133,12 +133,35 @@ static inline void tce_cache_blast_stres {tce_cache_blast (tbl); } + +static inline unsigned long verify_bit_range (unsigned long * bitmap, +int expected,unsigned long start,unsigned long end) +{ +unsigned long idx = start; + +BUG_ON (start >= end); + +while (idx < end) { +if (!!test_bit (idx, bitmap) != expected) +return idx; + ++idx; + } + +/* all bits have the expected value */ +return ~0UL ; +}#else /* debugging is disabled */ int debugging__read_mostly =0 ;static inline void tce_cache_blast_stress (struct iommu_table *tbl) { } + +static inline unsigned long verify_bit_range (unsigned long * bitmap, +int expected,unsigned long start,unsigned long end) +{ +return ~0UL ; +}#endif /* CONFIG_IOMMU_DEBUG */ static inline unsigned int num_dma_pages (unsigned long dma,unsigned int dmalen)
@@ -162,6 +185,7 @@ static void iommu_range_reserve(struct i {unsigned long index;unsigned long end; +unsigned long badbit; index = start_addr >>PAGE_SHIFT ;
@@ -173,14 +197,15 @@ static void iommu_range_reserve(struct iif (end > tbl->it_size)/* don't go off the table */ end = tbl->it_size; -while (index < end) { -if (test_bit (index, tbl->it_map)) + badbit =verify_bit_range (tbl->it_map,0 , index, end); +if (badbit != ~0UL ) { +if (printk_ratelimit ())printk (KERN_ERR "Calgary: entry already allocated at " "0x%lx tbl %p dma 0x%lx npages %u\n" , - index, tbl, start_addr, npages); - ++index; + badbit, tbl, start_addr, npages); } -set_bit_string (tbl->it_map, start_addr >>PAGE_SHIFT , npages); + +set_bit_string (tbl->it_map, index, npages); } static unsigned long iommu_range_alloc(struct iommu_table *tbl,
@@ -247,7 +272,7 @@ static void __iommu_free(struct iommu_ta unsigned int npages) {unsigned long entry; -unsigned long i; +unsigned long badbit; entry = dma_addr >>PAGE_SHIFT ;
@@ -255,11 +280,12 @@ static void __iommu_free(struct iommu_tatce_free (tbl, entry, npages); -for (i =0 ; i < npages; ++i) { -if (!test_bit (entry + i, tbl->it_map)) + badbit =verify_bit_range (tbl->it_map,1 , entry, entry + npages); +if (badbit != ~0UL ) { +if (printk_ratelimit ())printk (KERN_ERR "Calgary: bit is off at 0x%lx " "tbl %p dma 0x%Lx entry 0x%lx npages %u\n" , - entry + i, tbl, dma_addr, entry, npages); + badbit, tbl, dma_addr, entry, npages); }__clear_bit_string (tbl->it_map, entry, npages);
PATCH 106/145 x86_64: remove tce_cache_blast_stress()
In reply to a message not in the archiver
From: Muli Ben-Yehuda <[email protected]>
tce_cache_blast_stress was useful during bringup to stress the IOMMU's cache flushing. Now that we quiesce DMAs on every cache flush, using _stress() brings the machine down to its knees once you put it under load. Remove this debug / bringup code that isn't useful anymore completely.
--- arch/x86_64/kernel/pci-calgary.c | 11 ----------- 1 files changed, 11 deletions(-)
arch/x86_64/kernel/pci-calgary.c +0 -11
@@ -129,11 +129,6 @@ static void tce_cache_blast(struct iommu#ifdef CONFIG_IOMMU_DEBUG int debugging__read_mostly =1 ; -static inline void tce_cache_blast_stress (struct iommu_table *tbl) -{ -tce_cache_blast (tbl); -} -static inline unsigned long verify_bit_range (unsigned long * bitmap,int expected,unsigned long start,unsigned long end) {
@@ -153,10 +148,6 @@ static inline unsigned long verify_bit_r#else /* debugging is disabled */ int debugging__read_mostly =0 ; -static inline void tce_cache_blast_stress (struct iommu_table *tbl) -{ -} -static inline unsigned long verify_bit_range (unsigned long * bitmap,int expected,unsigned long start,unsigned long end) {
@@ -289,8 +280,6 @@ static void __iommu_free(struct iommu_ta }__clear_bit_string (tbl->it_map, entry, npages); - -tce_cache_blast_stress (tbl); } static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
PATCH 107/145 x86_64: Calgary IOMMU: eradicate sole remaining 80 chars per line offender
In reply to a message not in the archiver
From: Muli Ben-Yehuda <[email protected]>
--- arch/x86_64/kernel/pci-calgary.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-)
arch/x86_64/kernel/pci-calgary.c +2 -1
@@ -86,7 +86,8 @@#define MAX_NUM_OF_PHBS 8/* how many PHBs in total? */ #define MAX_NUM_CHASSIS 8/* max number of chassis */ -#define MAX_PHB_BUS_NUM (MAX_NUM_OF_PHBS * MAX_NUM_CHASSIS * 2)/* max dev->bus->number */ +/* MAX_PHB_BUS_NUM is the maximal possible dev->bus->number */ +#define MAX_PHB_BUS_NUM (MAX_NUM_OF_PHBS * MAX_NUM_CHASSIS * 2)#define PHBS_PER_CALGARY 4/* register offsets in Calgary's internal register space */
PATCH 108/145 x86_64: Some preparationary cleanup for stack trace
In reply to a message not in the archiver
- Remove unused all_contexts parameter
No caller used it
- Move skip argument into the structure (needed for followon patches)
--- arch/i386/kernel/stacktrace.c | 11 +++-------- arch/x86_64/kernel/stacktrace.c | 14 +++++--------- include/linux/stacktrace.h | 7 ++++--- kernel/lockdep.c | 5 ++++- 4 files changed, 16 insertions(+), 21 deletions(-)
arch/i386/kernel/stacktrace.c +3 -8
@@ -61,12 +61,8 @@ save_context_stack(struct stack_trace *t/* * Save stack-backtrace addresses into a stack_trace buffer. -* If all_contexts is set, all contexts (hardirq, softirq and process) -* are saved. If not set then only the current context is saved. */ -void save_stack_trace (struct stack_trace *trace, -struct task_struct *task,int all_contexts, -unsigned int skip) +void save_stack_trace (struct stack_trace *trace,struct task_struct *task) {unsigned long ebp;unsigned long *stack = &ebp;
@@ -85,10 +81,9 @@ void save_stack_trace(struct stack_tracestruct thread_info *context = (struct thread_info *) ((unsigned long )stack & (~(THREAD_SIZE -1 ))); - ebp =save_context_stack (trace, skip, context, stack, ebp); + ebp =save_context_stack (trace, trace->skip, context, stack, ebp); stack = (unsigned long *)context->previous_esp; -if (!all_contexts || !stack || - trace->nr_entries >= trace->max_entries) +if (!stack || trace->nr_entries >= trace->max_entries)break ; trace->entries[trace->nr_entries++] =ULONG_MAX ;if (trace->nr_entries >= trace->max_entries)
arch/x86_64/kernel/stacktrace.c +5 -9
@@ -109,9 +109,10 @@ out_restore:* Save stack-backtrace addresses into a stack_trace buffer: */ static inline unsigned long -save_context_stack (struct stack_trace *trace,unsigned int skip, +save_context_stack (struct stack_trace *trace,unsigned long stack,unsigned long stack_end) { +int skip = trace->skip;unsigned long addr;#ifdef CONFIG_FRAME_POINTER
@@ -159,12 +160,8 @@ save_context_stack(struct stack_trace *t/* * Save stack-backtrace addresses into a stack_trace buffer. -* If all_contexts is set, all contexts (hardirq, softirq and process) -* are saved. If not set then only the current context is saved. */ -void save_stack_trace (struct stack_trace *trace, -struct task_struct *task,int all_contexts, -unsigned int skip) +void save_stack_trace (struct stack_trace *trace,struct task_struct *task) {unsigned long stack = (unsigned long )&stack;int i, nr_stacks =0 , stacks_done[MAX_STACKS ];
@@ -207,9 +204,8 @@ void save_stack_trace(struct stack_tracereturn ; stacks_done[nr_stacks] = stack_end; - stack =save_context_stack (trace, skip, stack, stack_end); -if (!all_contexts || !stack || - trace->nr_entries >= trace->max_entries) + stack =save_context_stack (trace, stack, stack_end); +if (!stack || trace->nr_entries >= trace->max_entries)return ; trace->entries[trace->nr_entries++] =ULONG_MAX ;if (trace->nr_entries >= trace->max_entries)
include/linux/stacktrace.h +4 -3
@@ -5,15 +5,16 @@struct stack_trace {unsigned int nr_entries, max_entries;unsigned long *entries; +int skip;/* input argument: How many entries to skip */ +int all_contexts;/* input argument: if true do than one stack */ };extern void save_stack_trace (struct stack_trace *trace, -struct task_struct *task,int all_contexts, -unsigned int skip); +struct task_struct *task);extern void print_stack_trace (struct stack_trace *trace,int spaces);#else -# define save_stack_trace (trace, task, all, skip) do { } while (0) +# define save_stack_trace (trace, task) do { } while (0)# define print_stack_trace (trace) do { } while (0)#endif
kernel/lockdep.c +4 -1
@@ -224,7 +224,10 @@ static int save_trace(struct stack_trace trace->max_entries =MAX_STACK_TRACE_ENTRIES - nr_stack_trace_entries; trace->entries = stack_trace + nr_stack_trace_entries; -save_stack_trace (trace,NULL ,0 ,3 ); + trace->skip =3 ; + trace->all_contexts =0 ; + +save_stack_trace (trace,NULL ); trace->max_entries = trace->nr_entries;
Re: [PATCH for review] [108/145] x86_64: Some preparationary cleanup for stack trace
Quoted 2 lines · On Thu, 10 Aug 2006 21:37:06 +0200 (CEST) Andi Kleen <[email protected]> wrote:
- Remove unused
all_contextsparameter
No caller used it
s390 does and now it's busted.
Re: [PATCH for review] [108/145] x86_64: Some preparationary cleanup for stack trace
Quoted 7 lines · Andrew Morton
Quoted 2 lines · On Thu, 10 Aug 2006 21:37:06 +0200 (CEST) Andi Kleen <[email protected]> wrote:
- Remove unused
all_contextsparameter
No caller used its390 does and now it's busted.
I had actually undone this later because all_contexts == 0 fixed the previously commented out i386-stacktrace-unwinder (= use dwarf2 unwinder for i386 lockdep). So should be ok now on firstfloor.
-Andi
PATCH 109/145 x86_64: Convert modlist_lock to be a raw spinlock
In reply to a message not in the archiver
This is a preparationary patch for converting stacktrace over to the new dwarf2 unwinder. lockdep uses stacktrace and the new unwinder takes the modlist_lock so using a normal spinlock would cause a deadlock. Use a raw lock instead.
--- kernel/module.c | 42 ++++++++++++++++++++++++++---------------- 1 files changed, 26 insertions(+), 16 deletions(-)
kernel/module.c +26 -16
@@ -59,7 +59,7 @@#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1))/* Protects module list */ -static DEFINE_SPINLOCK (modlist_lock); +static raw_spinlock_t modlist_lock = __RAW_SPIN_LOCK_UNLOCKED;/* List of modules, protected by module_mutex AND modlist_lock */ static DEFINE_MUTEX (module_mutex);
@@ -751,11 +751,13 @@ void __symbol_put(const char *symbol)unsigned long flags;const unsigned long *crc; -spin_lock_irqsave (&modlist_lock, flags); +raw_local_save_flags (flags); +__raw_spin_lock (&modlist_lock);if (!__find_symbol (symbol, &owner, &crc,1 ))BUG ();module_put (owner); -spin_unlock_irqrestore (&modlist_lock, flags); +__raw_spin_unlock (&modlist_lock); +raw_local_irq_restore (flags); }EXPORT_SYMBOL (__symbol_put);
@@ -1134,11 +1136,13 @@ void *__symbol_get(const char *symbol)unsigned long value, flags;const unsigned long *crc; -spin_lock_irqsave (&modlist_lock, flags); +raw_local_save_flags (flags); +__raw_spin_lock (&modlist_lock); value =__find_symbol (symbol, &owner, &crc,1 );if (value && !strong_try_module_get (owner)) value =0 ; -spin_unlock_irqrestore (&modlist_lock, flags); +__raw_spin_unlock (&modlist_lock); +raw_local_irq_restore (flags);return (void *)value; }
@@ -2141,7 +2145,8 @@ const struct exception_table_entry *searconst struct exception_table_entry *e =NULL ;struct module *mod; -spin_lock_irqsave (&modlist_lock, flags); +raw_local_save_flags (flags); +__raw_spin_lock (&modlist_lock);list_for_each_entry (mod, &modules, list) {if (mod->num_exentries ==0 )continue ;
@@ -2152,7 +2157,8 @@ const struct exception_table_entry *searif (e)break ; } -spin_unlock_irqrestore (&modlist_lock, flags); +__raw_spin_unlock (&modlist_lock); +raw_local_irq_restore (flags);/* Now, if we found one, we are running inside it now, hence we cannot unload the module, hence no refcnt needed. */
@@ -2166,19 +2172,20 @@ int is_module_address(unsigned long addr {unsigned long flags;struct module *mod; +int ret =0 ; -spin_lock_irqsave (&modlist_lock, flags); - +raw_local_save_flags (flags); +__raw_spin_lock (&modlist_lock);list_for_each_entry (mod, &modules, list) {if (within (addr, mod->module_core, mod->core_size)) { -spin_unlock_irqrestore (&modlist_lock, flags); -return 1 ; + ret =1 ; +break ; } } +__raw_spin_unlock (&modlist_lock); +raw_local_irq_restore (flags); -spin_unlock_irqrestore (&modlist_lock, flags); - -return 0 ; +return ret; }
@@ -2199,9 +2206,12 @@ struct module *module_text_address(unsigstruct module *mod;unsigned long flags; -spin_lock_irqsave (&modlist_lock, flags); +/* This is called from lockdep */ +raw_local_save_flags (flags); +__raw_spin_lock (&modlist_lock); mod =__module_text_address (addr); -spin_unlock_irqrestore (&modlist_lock, flags); +__raw_spin_unlock (&modlist_lock); +raw_local_irq_restore (flags);return mod; }
Re: [PATCH for review] [109/145] x86_64: Convert modlist_lock to be a raw spinlock
Quoted 5 lines · On Thu, 10 Aug 2006 21:37:07 +0200 (CEST) Andi Kleen <[email protected]> wrote:
This is a preparationary patch for converting stacktrace over to the new dwarf2 unwinder. lockdep uses stacktrace and the new unwinder takes the
modlist_lockso using a normal spinlock would cause a deadlock. Use a raw lock instead.
It breaks the build on most architectures.
Quoted 20 lines
--- kernel/module.c | 42 ++++++++++++++++++++++++++---------------- 1 files changed, 26 insertions(+), 16 deletions(-)Index:
linux/kernel/module.c
===================================================================kernel/module.c +1
-1@@ -59,7 +59,7 @@#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1))/* Protects module list */ -static DEFINE_SPINLOCK (modlist_lock); +static raw_spinlock_t modlist_lock = __RAW_SPIN_LOCK_UNLOCKED;/* List of modules, protected by module_mutex AND modlist_lock */ static DEFINE_MUTEX (module_mutex);@@ -751,11 +751,13 @@ void __symbol_put(const char *symbol)unsigned long flags;const unsigned long *crc;
kernel/module.c void __symbol_put(const char *symbol) · line 760
Quoted 10 lines
kernel/module.c +4
-2-spin_lock_irqsave (&modlist_lock, flags); +raw_local_save_flags (flags); +__raw_spin_lock (&modlist_lock);if (!__find_symbol (symbol, &owner, &crc,1 ))BUG ();module_put (owner); -spin_unlock_irqrestore (&modlist_lock, flags); +__raw_spin_unlock (&modlist_lock); +raw_local_irq_restore (flags);
That looks fairly hacky. Wouldn't it be better to implement raw_spin_lock_irqsave()?
Re: [PATCH for review] [109/145] x86_64: Convert modlist_lock to be a raw spinlock
Quoted 10 lines · Andrew Morton
Quoted 5 lines · On Thu, 10 Aug 2006 21:37:07 +0200 (CEST) Andi Kleen <[email protected]> wrote:
This is a preparationary patch for converting stacktrace over to the new dwarf2 unwinder. lockdep uses stacktrace and the new unwinder takes the
modlist_lockso using a normal spinlock would cause a deadlock. Use a raw lock instead.It breaks the build on most architectures.
Hmm, I grepped and most architectures seem to have both __raw_spin_lock and local_save_flags. I didn't actually compile them because crosstool doesn't love me anymore since I use gcc 4.0.
What is the official portable interface to do a raw spinlock if this one doesn't work?
Quoted 4 lines
Quoted 4 lines
kernel/module.c +2
-1-spin_lock_irqsave (&modlist_lock, flags); +raw_local_save_flags (flags); +__raw_spin_lock (&modlist_lock);if (!__find_symbol (symbol, &owner, &crc,1 ))
Quoted 8 lines
kernel/module.c void __symbol_put(const char *symbol) · line 760
Quoted 5 lines
kernel/module.c +2
-1BUG ();module_put (owner); -spin_unlock_irqrestore (&modlist_lock, flags); +__raw_spin_unlock (&modlist_lock); +raw_local_irq_restore (flags);That looks fairly hacky. Wouldn't it be better to implement
raw_spin_lock_irqsave()?
Possible.
-Andi
Re: [PATCH for review] [109/145] x86_64: Convert modlist_lock to be a raw spinlock
Quoted 10 lines · On Sun, 13 Aug 2006 08:52:46 +0200 Andi Kleen <[email protected]> wrote:
Quoted 9 lines · Andrew Morton
Quoted 5 lines · On Thu, 10 Aug 2006 21:37:07 +0200 (CEST) Andi Kleen <[email protected]> wrote:
This is a preparationary patch for converting stacktrace over to the new dwarf2 unwinder. lockdep uses stacktrace and the new unwinder takes the
modlist_lockso using a normal spinlock would cause a deadlock. Use a raw lock instead.
Quoted 4 lines
Quoted 1 line
It breaks the build on most architectures.
Hmm, I grepped and most architectures seem to have both
__raw_spin_lockandlocal_save_flags.
box:/usr/src/25> grep -l raw_local_save_flags include/asm-*/*.h include/asm-avr32/irqflags.h include/asm-i386/irqflags.h include/asm-mips/irqflags.h include/asm-powerpc/irqflags.h include/asm-s390/irqflags.h include/asm-x86_64/irqflags.h
Quoted 2 lines
I didn't actually compile them because crosstool
doesn't love me anymore since I use gcc 4.0.
crosstool is a bit of a bitch.
Quoted 2 lines
What is the official portable interface to do a raw spinlock if this one doesn't work?
I don't see a way, really. Apart from going in and implementing it on the various architectures.
Perhaps x86_64-mm-module-locks-raw-spinlock-hack-hack-hack.patch could be hoisted up to include/linux/spinlock.h and then at least only lockdep-enabled architectures need to implement these things.
Re: [PATCH for review] [109/145] x86_64: Convert modlist_lock to be a raw spinlock
Quoted 7 lines
Quoted 4 lines
What is the official portable interface to do a raw spinlock if this one doesn't work?
I don't see a way, really. Apart from going in and implementing it on the various architectures.
Hmpf. Maybe lockdep just needs a recursion check.
-Andi
PATCH 110/145 x86_64: Don't access the APIC in safe_smp_processor_id when it is not mapped yet
In reply to a message not in the archiver
Lockdep can call the dwarf2 unwinder early, and the dwarf2 code uses safe_smp_processor_id which tries to access the local APIC page. But that doesn't work before the APIC code has set up its fixmap.
Check for this case and always return boot cpu then.
--- arch/x86_64/kernel/apic.c | 2 ++ arch/x86_64/kernel/smp.c | 2 +- include/asm-x86_64/apic.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-)
arch/x86_64/kernel/apic.c +2 -0
@@ -38,6 +38,7 @@#include <asm/timex.h> #include <asm/apic.h> +int apic_mapped;int apic_verbosity;int apic_runs_main_timer;int apic_calibrate_pmtmr__initdata ;
@@ -600,6 +601,7 @@ void __init init_apic_mappings(void) apic_phys = mp_lapic_addr;set_fixmap_nocache (FIX_APIC_BASE , apic_phys); + apic_mapped =1 ;apic_printk (APIC_VERBOSE ,"mapped APIC to %16lx (%16lx)\n" ,APIC_BASE , apic_phys);/*
arch/x86_64/kernel/smp.c +1 -1
@@ -526,7 +526,7 @@ int safe_smp_processor_id(void) {unsigned apicid, i; -if (disable_apic) +if (disable_apic || !apic_mapped)return 0 ; apicid =hard_smp_processor_id ();
include/asm-x86_64/apic.h +1 -0
@@ -18,6 +18,7 @@extern int apic_verbosity;extern int apic_runs_main_timer;extern int ioapic_force; +extern int apic_mapped;/* * Define the default level of output to be very little
PATCH 111/145 x86_64: Move unwind_init earlier
In reply to a message not in the archiver
Needed for use of the unwinder in lockdep, because lockdep runs really early too.
--- init/main.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
init/main.c +1 -1
@@ -468,6 +468,7 @@ asmlinkage void __init start_kernel(void* Need to run as early as possible, to initialize the * lockdep hash: */ +unwind_init ();lockdep_init ();local_irq_disable ();
@@ -506,7 +507,6 @@ asmlinkage void __init start_kernel(void __stop___param - __start___param, &unknown_bootoption);sort_main_extable (); -unwind_init ();trap_init ();rcu_init ();init_IRQ ();
PATCH 112/145 x86_64: Merge stacktrace and show_trace
In reply to a message not in the archiver
This unifies the standard backtracer and the new stacktrace in memory backtracer. The standard one is converted to use callbacks and then reimplement stacktrace using new callbacks.
The main advantage is that stacktrace can now use the new dwarf2 unwinder and avoid false positives in many cases.
I kept it simple to make sure the standard backtracer stays reliable.
--- arch/x86_64/kernel/stacktrace.c | 214 ++++------------------------------------ arch/x86_64/kernel/traps.c | 103 ++++++++++++++----- include/asm-x86_64/stacktrace.h | 18 +++ 3 files changed, 124 insertions(+), 211 deletions(-)
arch/x86_64/kernel/traps.c +80 -23
@@ -45,6 +45,7 @@#include <asm/pda.h> #include <asm/proto.h> #include <asm/nmi.h> +#include <asm/stacktrace.h> asmlinkage void divide_error(void); asmlinkage void debug(void);
@@ -138,7 +139,7 @@ void printk_address(unsigned long addres#endif static unsigned long *in_exception_stack (unsigned cpu,unsigned long stack, -unsigned *usedp,const char **idp) +unsigned *usedp,char **idp) {static char ids[][8 ] = { [DEBUG_STACK -1 ] ="#DB" ,
@@ -230,13 +231,19 @@ static unsigned long *in_exception_stackreturn NULL ; } -static int show_trace_unwind (struct unwind_frame_info *info,void *context) +struct ops_and_data { +struct stacktrace_ops *ops; +void *data; +}; + +static int dump_trace_unwind (struct unwind_frame_info *info,void *context) { +struct ops_and_data *oad = (struct ops_and_data *)context;int n =0 ;while (unwind (info) ==0 &&UNW_PC (info)) { n++; -printk_address (UNW_PC (info)); + oad->ops->address (oad->data,UNW_PC (info));if (arch_unw_user_mode (info))break ; }
@@ -248,49 +255,59 @@ static int show_trace_unwind(struct unwi* process stack * interrupt stack * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack +* See Documentation/x86_64/kernelstacks for more details. */ - -void show_trace (struct task_struct *tsk,struct pt_regs *regs,unsigned long * stack) +void dump_trace (struct task_struct *tsk,struct pt_regs *regs, +unsigned long *stack, +struct stacktrace_ops *ops,void *data) {const unsigned cpu =safe_smp_processor_id ();unsigned long *irqstack_end = (unsigned long *)cpu_pda (cpu)->irqstackptr;unsigned used =0 ; -printk ("\nCall Trace:\n" ); -if (!tsk) tsk = current;if (call_trace >=0 ) {int unw_ret =0 ;struct unwind_frame_info info; +struct ops_and_data oad = { .ops = ops, .data = data };if (regs) {if (unwind_init_frame_info (&info, tsk, regs) ==0 ) - unw_ret =show_trace_unwind (&info,NULL ); + unw_ret =dump_trace_unwind (&info, &oad); }else if (tsk == current) - unw_ret =unwind_init_running (&info, show_trace_unwind,NULL ); + unw_ret =unwind_init_running (&info, dump_trace_unwind, &oad);else {if (unwind_init_blocked (&info, tsk) ==0 ) - unw_ret =show_trace_unwind (&info,NULL ); + unw_ret =dump_trace_unwind (&info, &oad); }if (unw_ret >0 && !arch_unw_user_mode (&info)) {#ifdef CONFIG_STACK_UNWIND unsigned long rip = info.regs.rip; -print_symbol ("DWARF2 unwinder stuck at %s\n" , rip); + ops->warning_symbol (data, +"DWARF2 unwinder stuck at %s" , rip);if (call_trace ==1 ) { -printk ("Leftover inexact backtrace:\n" ); + ops->warning (data,"Leftover inexact backtrace:" ); stack = (unsigned long *)info.regs.rsp; }else if (call_trace >1 )return ;else -printk ("Full inexact backtrace again:\n" ); + ops->warning (data, +"Full inexact backtrace again:" );#else -printk ("Inexact backtrace:\n" ); + ops->warning (data,"Inexact backtrace:" );#endif } } +if (!stack) { +unsigned long dummy; + stack = &dummy; +if (tsk && tsk != current) + stack = (unsigned long *)tsk->thread.rsp; + } +/* * Print function call entries within a stack. 'cond' is the * "end of stackframe" condition, that the 'stack++'
@@ -308,7 +325,7 @@ void show_trace(struct task_struct *tsk,* down the cause of the crash will be able to figure \ * out the call path that was taken. \ */ \ -printk_address (addr); \ + ops->address (data, addr); \ } \ }while (0 )
@@ -317,16 +334,17 @@ void show_trace(struct task_struct *tsk,* current stack address. If the stacks consist of nested * exceptions */ -for ( ; ; ) { -const char *id; +for (;;) { +char *id;unsigned long *estack_end; estack_end =in_exception_stack (cpu, (unsigned long )stack, &used, &id);if (estack_end) { -printk (" <%s>" , id); +if (ops->stack (data, id) <0 ) +break ;HANDLE_STACK (stack < estack_end); -printk (" <EOE>" ); + ops->stack (data,"<EOE>" );/* * We link to the next stack via the * second-to-last pointer (index -2 to end) in the
@@ -341,7 +359,8 @@ void show_trace(struct task_struct *tsk, (IRQSTACKSIZE -64 ) /sizeof (*irqstack);if (stack >= irqstack && stack < irqstack_end) { -printk (" <IRQ>" ); +if (ops->stack (data,"IRQ" ) <0 ) +break ;HANDLE_STACK (stack < irqstack_end);/* * We link to the next stack (which would be
@@ -350,7 +369,7 @@ void show_trace(struct task_struct *tsk,*/ stack = (unsigned long *) (irqstack_end[-1 ]); irqstack_end =NULL ; -printk (" <EOI>" ); + ops->stack (data,"EOI" );continue ; } }
@@ -358,15 +377,53 @@ void show_trace(struct task_struct *tsk, }/* -* This prints the process stack: +* This handles the process stack: */ HANDLE_STACK (((long ) stack & (THREAD_SIZE -1 )) !=0 );#undef HANDLE_STACK +} +EXPORT_SYMBOL (dump_trace); + +static void +print_trace_warning_symbol (void *data,char *msg,unsigned long symbol) +{ +print_symbol (msg, symbol); +printk ("\n" ); +} +static void print_trace_warning (void *data,char *msg) +{ +printk ("%s\n" , msg); +} + +static int print_trace_stack (void *data,char *name) +{ +printk (" <%s> " , name); +return 0 ; +} + +static void print_trace_address (void *data,unsigned long addr) +{ +printk_address (addr); +} + +static struct stacktrace_ops print_trace_ops = { + .warning = print_trace_warning, + .warning_symbol = print_trace_warning_symbol, + .stack = print_trace_stack, + .address = print_trace_address, +}; + +void +show_trace (struct task_struct *tsk,struct pt_regs *regs,unsigned long *stack) +{ +printk ("\nCall Trace:\n" ); +dump_trace (tsk, regs, stack, &print_trace_ops,NULL );printk ("\n" ); } -static void _show_stack (struct task_struct *tsk,struct pt_regs *regs,unsigned long * rsp) +static void +_show_stack (struct task_struct *tsk,struct pt_regs *regs,unsigned long *rsp) {unsigned long *stack;int i;
include/asm-x86_64/stacktrace.h new file +18 -0
@@ -0,0 +1,18 @@ +#ifndef _ASM_STACKTRACE_H +#define _ASM_STACKTRACE_H 1 + +/* Generic stack tracer with callbacks */ + +struct stacktrace_ops { +void (*warning)(void *data,char *msg); +/* msg must contain %s for the symbol */ +void (*warning_symbol)(void *data,char *msg,unsigned long symbol); +void (*address)(void *data,unsigned long address); +/* On negative return stop dumping */ +int (*stack)(void *data,char *name); +}; + +void dump_trace (struct task_struct *tsk,struct pt_regs *regs,unsigned long *stack, +struct stacktrace_ops *ops,void *data); + +#endif
arch/x86_64/kernel/stacktrace.c +26 -188
237 lines not on this page · raw message
PATCH 113/145 i386: Do stacktracer conversion too
In reply to a message not in the archiver
Following x86-64 patches. Reuses code from them in fact.
Convert the standard backtracer to do all output using
callbacks. Use the x86-64 stack tracer implementation
that uses these callbacks to implement the stacktrace interface.
This allows to use the new dwarf2 unwinder for stacktrace and get better backtraces.
--- arch/i386/kernel/Makefile | 1 arch/i386/kernel/stacktrace.c | 93 ------------------------------------ arch/i386/kernel/traps.c | 108 +++++++++++++++++++++++++++++++----------- include/asm-i386/stacktrace.h | 1 4 files changed, 83 insertions(+), 120 deletions(-)
arch/i386/kernel/Makefile +1 -0
@@ -82,4 +82,5 @@ $(obj)/vsyscall-syms.o: $(src)/vsyscall. $(call if_changed,syscall) k8-y += ../../x86_64/kernel/k8.o +stacktrace-y += ../../x86_64/kernel/stacktrace.o
arch/i386/kernel/stacktrace.c deleted +0 -93
93 lines not on this page · raw message
arch/i386/kernel/traps.c +81 -27
190 lines not on this page · raw message
include/asm-i386/stacktrace.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-x86_64/stacktrace.h>
PATCH 114/145 x86_64: Don't force frame pointers for lockdep
In reply to a message not in the archiver
Now that stacktrace supports dwarf2 don't force frame pointers for lockdep anymore
--- lib/Kconfig.debug | 1 - 1 files changed, 1 deletion(-)
lib/Kconfig.debug +0 -1
@@ -218,7 +218,6 @@ config LOCKDEP bool depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT select STACKTRACE - select FRAME_POINTER select KALLSYMS select KALLSYMS_ALL
PATCH 115/145 x86_64: fix dubious segment register clear in cpu_init()
In reply to a message not in the archiver
From: Jeremy Fitzhardinge <[email protected]>
Fix a very dubious piece of code in arch/i386/kernel/cpu/common.c:cpu_init(). This clears out %fs and %gs, but clobbers %eax in the process without telling gcc. It turns out that gcc happens to be not using %eax at that point anyway so it doesn't matter much, but it looks like a bomb waiting to go off.
This does end up saving an instruction, because gcc wants %eax==0 for the set_debugreg()s below.
--- arch/i386/kernel/cpu/common.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
arch/i386/kernel/cpu/common.c +1 -1
@@ -675,7 +675,7 @@ old_gdt:#endif /* Clear %fs and %gs. */ - asmvolatile ("xorl %eax, %eax; movl %eax, %fs; movl %eax, %gs" ); + asmvolatile ("movl %0, %%fs; movl %0, %%gs" : :"r" (0 ));/* Clear all 6 debug registers: */ set_debugreg (0 ,0 );
PATCH 116/145 i386: don't taint UP K7's running SMP kernels.
In reply to a message not in the archiver
From: Dave Jones <[email protected]>
We have a test that looks for invalid pairings of certain athlon/durons that weren't designed for SMP, and taint accordingly (with 'S') if we find such a configuration. However, this test shouldn't fire if there's only a single CPU present. It's perfectly valid for an SMP kernel to boot on UP hardware for example.
AK: changed to num_possible_cpus()
--- arch/i386/kernel/smpboot.c | 3 +++ 1 files changed, 3 insertions(+)
arch/i386/kernel/smpboot.c +3 -0
@@ -177,6 +177,9 @@ static void __devinit smp_store_cpu_info*/ if ((c->x86_vendor ==X86_VENDOR_AMD ) && (c->x86 ==6 )) { +if (num_possible_cpus () ==1 ) + goto valid_k7; +/* Athlon 660/661 is valid. */ if ((c->x86_model==6 ) && ((c->x86_mask==0 ) || (c->x86_mask==1 ))) goto valid_k7;
PATCH 117/145 i386: error_code is not safe for kprobes
In reply to a message not in the archiver
From: Chuck Ebbert <[email protected]>
Because code marked unsafe for kprobes jumps directly to entry.S::error_code, that must be marked unsafe as well. The easiest way to do that is to move the page fault entry point to just before error_code and let it inherit the same section.
Also moved all the ".previous" asm directives for kprobes sections to column 1 and removed ".text" from them.
--- arch/i386/kernel/entry.S | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-)
arch/i386/kernel/entry.S +13 -12
@@ -587,11 +587,9 @@ ENTRY(name) \ /* The include is where all of the SMP etc. interrupts come from */ #include "entry_arch.h" -ENTRY(divide_error) - RING0_INT_FRAME - pushl $0 # no error code - CFI_ADJUST_CFA_OFFSET 4 - pushl $do_divide_error +KPROBE_ENTRY(page_fault) + RING0_EC_FRAME + pushl $do_page_fault CFI_ADJUST_CFA_OFFSET 4 ALIGN error_code:
@@ -641,6 +639,7 @@ error_code: call *%edi jmp ret_from_exception CFI_ENDPROC +.previous ENTRY(coprocessor_error) RING0_INT_FRAME
@@ -716,7 +715,8 @@ debug_stack_correct: call do_debug jmp ret_from_exception CFI_ENDPROC - .previous .text +.previous + /* * NMI is doubly nasty. It can happen _while_ we're handling * a debug fault, and the debug fault hasn't yet been able to
@@ -812,7 +812,7 @@ KPROBE_ENTRY(int3) call do_int3 jmp ret_from_exception CFI_ENDPROC - .previous .text +.previous ENTRY(overflow) RING0_INT_FRAME
@@ -877,7 +877,7 @@ KPROBE_ENTRY(general_protection) CFI_ADJUST_CFA_OFFSET 4 jmp error_code CFI_ENDPROC - .previous .text +.previous ENTRY(alignment_check) RING0_EC_FRAME
@@ -886,13 +886,14 @@ ENTRY(alignment_check) jmp error_code CFI_ENDPROC -KPROBE_ENTRY(page_fault) - RING0_EC_FRAME - pushl $do_page_fault +ENTRY(divide_error) + RING0_INT_FRAME + pushl $0 # no error code + CFI_ADJUST_CFA_OFFSET 4 + pushl $do_divide_error CFI_ADJUST_CFA_OFFSET 4 jmp error_code CFI_ENDPROC - .previous .text #ifdef CONFIG_X86_MCE ENTRY(machine_check)
PATCH 118/145 x86_64: Mark error_entry as forbidden to kprobes
In reply to a message not in the archiver
From: Prasanna S.P. <[email protected]>
This patch moves the entry.S:error_entry to .kprobes.text section, since code marked unsafe for kprobes jumps directly to entry.S::error_entry, that must be marked unsafe as well.
This patch also moves all the ".previous.text" asm directives to ".previous" for kprobes section.
AK: Following a similar i386 patch from Chuck Ebbert
arch/x86_64/kernel/entry.S | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
arch/x86_64/kernel/entry.S +7 -6
@@ -819,7 +819,7 @@ paranoid_schedule\trace: * Exception entry point. This expects an error code/orig_rax on the stack * and the exception handler in %rax. */ -ENTRY(error_entry) +KPROBE_ENTRY(error_entry) _frame RDI /* rdi slot contains rax, oldrax contains error code */ cld
@@ -904,6 +904,7 @@ error_kernelspace: je error_swapgs jmp error_sti END(error_entry) + .previous /* Reload gs selector with exception handling */ /* edi: new selector */
@@ -1023,7 +1024,7 @@ ENDPROC(execve) KPROBE_ENTRY(page_fault) errorentry do_page_fault END(page_fault) - .previous .text + .previous ENTRY(coprocessor_error) zeroentry do_coprocessor_error
@@ -1045,7 +1046,7 @@ KPROBE_ENTRY(debug) paranoidentry do_debug, DEBUG_STACK paranoidexit END(debug) - .previous .text + .previous /* runs on exception stack */ KPROBE_ENTRY(nmi)
@@ -1060,7 +1061,7 @@ KPROBE_ENTRY(nmi) CFI_ENDPROC #endif END(nmi) - .previous .text + .previous KPROBE_ENTRY(int3) INTR_FRAME
@@ -1070,7 +1071,7 @@ KPROBE_ENTRY(int3) jmp paranoid_exit1 CFI_ENDPROC END(int3) - .previous .text + .previous ENTRY(overflow) zeroentry do_overflow
@@ -1119,7 +1120,7 @@ END(stack_segment) KPROBE_ENTRY(general_protection) errorentry do_general_protection END(general_protection) - .previous .text + .previous ENTRY(alignment_check) errorentry do_alignment_check
PATCH 119/145 x86_64: X86_64 monotonic_clock goes backwards
In reply to a message not in the archiver
From: Dimitri Sivanich <[email protected]>
I've noticed some erratic behavior while testing the X86_64 version of monotonic_clock().
While spinning in a loop reading monotonic clock values (pinned to a single cpu) I noticed that the difference between subsequent values occasionally went negative (time going backwards).
I found that in the following code:
this_offset = get_cycles_sync();
/* FIXME: 1000 or 1000000? */
--> offset = (this_offset - last_offset)*1000 / cpu_khz;
}
return base + offset;the offset sometimes turns out to be 0, even though this_offset > last_offset.
--- arch/x86_64/kernel/time.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
arch/x86_64/kernel/time.c +3 -4
@@ -276,6 +276,7 @@ static void set_rtc_mmss(unsigned long n* Note: This function is required to return accurate * time even in the absence of multiple timer ticks. */ +static inline unsigned long long cycles_2_ns (unsigned long long cyc);unsigned long long monotonic_clock (void ) {unsigned long seq;
@@ -300,8 +301,7 @@ unsigned long long monotonic_clock(void) base = monotonic_base; }while (read_seqretry (&xtime_lock, seq)); this_offset =get_cycles_sync (); -/* FIXME: 1000 or 1000000? */ - offset = (this_offset - last_offset)*1000 / cpu_khz; + offset =cycles_2_ns (this_offset - last_offset); }return base + offset; }
@@ -405,8 +405,7 @@ void main_timer_handler(struct pt_regs * offset %=USEC_PER_TICK ; } -/* FIXME: 1000 or 1000000? */ - monotonic_base += (tsc - vxtime.last_tsc) *1000000 / cpu_khz; + monotonic_base +=cycles_2_ns (tsc - vxtime.last_tsc); vxtime.last_tsc = tsc - vxtime.quot * delay / vxtime.tsc_quot;
PATCH 120/145 i386/x86-64: Improve Kconfig description of CRASH_DUMP
In reply to a message not in the archiver
Improve Kconfig description of CONFIG_CRASH_DUMP. Previously it was too brief to be useful.
--- arch/i386/Kconfig | 7 +++++++ arch/x86_64/Kconfig | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-)
arch/i386/Kconfig +7 -0
@@ -759,6 +759,13 @@ config CRASH_DUMP depends on HIGHMEM help Generate crash dump after being started by kexec. + This should be normally only set in special crash dump kernels + which are loaded in the main kernel with kexec-tools into + a specially reserved region and then later executed after + a crash by kdump/kexec. The crash dump kernel must be compiled + to a memory address not used by the main kernel or BIOS using + PHYSICAL_START. + For more details see Documentation/kdump/kdump.txt config PHYSICAL_START hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP)
arch/x86_64/Kconfig +8 -1
@@ -484,7 +484,14 @@ config CRASH_DUMP bool "kernel crash dumps (EXPERIMENTAL)" depends on EXPERIMENTAL help - Generate crash dump after being started by kexec. + Generate crash dump after being started by kexec. + This should be normally only set in special crash dump kernels + which are loaded in the main kernel with kexec-tools into + a specially reserved region and then later executed after + a crash by kdump/kexec. The crash dump kernel must be compiled + to a memory address not used by the main kernel or BIOS using + PHYSICAL_START. + For more details see Documentation/kdump/kdump.txt config PHYSICAL_START hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP)
Re: [PATCH for review] [120/145] i386/x86-64: Improve Kconfig description of CRASH_DUMP
Quoted 44 lines · On Thu, 10 Aug 2006 21:37:19 +0200 (CEST) Andi Kleen wrote:
r
Improve
Kconfigdescription ofCONFIG_CRASH_DUMP. Previously it was too brief to be useful.Signed-off-by Andi Kleen <[email protected]>--- arch/i386/Kconfig | 7 +++++++ arch/x86_64/Kconfig | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-)Index: linux/arch/i386/Kconfig
===================================================================arch/i386/Kconfig +7
-0@@ -759,6 +759,13 @@ config CRASH_DUMP depends on HIGHMEM help Generate crash dump after being started by kexec. + This should be normally only set in special crash dump kernels + which are loaded in the main kernel with kexec-tools into + a specially reserved region and then later executed after + a crash by kdump/kexec. The crash dump kernel must be compiled + to a memory address not used by the main kernel or BIOS using + PHYSICAL_START. + For more details see Documentation/kdump/kdump.txt config PHYSICAL_START hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP)Index: linux/arch/x86_64/Kconfig
===================================================================arch/x86_64/Kconfig +2
-1@@ -484,7 +484,14 @@ config CRASH_DUMP bool "kernel crash dumps (EXPERIMENTAL)" depends on EXPERIMENTAL help - Generate crash dump after being started by kexec. + Generate crash dump after being started by kexec. + This should be normally only set in special crash dump kernels
arch/x86_64/Kconfig config CRASH_DUMP
Quoted 10 lines
arch/x86_64/Kconfig +6
-1+ which are loaded in the main kernel with kexec-tools into + a specially reserved region and then later executed after + a crash by kdump/kexec. The crash dump kernel must be compiled + to a memory address not used by the main kernel or BIOS using + PHYSICAL_START. + For more details see Documentation/kdump/kdump.txt config PHYSICAL_START hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP) -
Please fix indentation (use tabs consistently).
---
~Randy
PATCH 121/145 x86_64: Make boot_param_data pure BSS
In reply to a message not in the archiver
Since it's all zero.
Actually I think gcc 4+ will do that automatically, but earlier compilers won't
--- arch/x86_64/kernel/setup64.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
arch/x86_64/kernel/setup64.c +1 -1
@@ -24,7 +24,7 @@#include <asm/proto.h> #include <asm/sections.h> -char x86_boot_params[BOOT_PARAM_SIZE ]__initdata = {0 ,}; +char x86_boot_params[BOOT_PARAM_SIZE ]__initdata ;cpumask_t cpu_initialized__cpuinitdata =CPU_MASK_NONE ;
PATCH 122/145 i386: Fix warning in mpparse.c
In reply to a message not in the archiver
Fix
linux/arch/i386/kernel/mpparse.c: In function #MP_bus_info#:linux/arch/i386/kernel/mpparse.c:232: warning: comparison is always false due to limited range of data type
--- arch/i386/kernel/mpparse.c | 2 ++ 1 files changed, 2 insertions(+)
arch/i386/kernel/mpparse.c +2 -0
@@ -229,12 +229,14 @@ static void __init MP_bus_info (struct mmpc_oem_bus_info (m, str, translation_table[mpc_record]); +#if MAX_MP_BUSSES <256 if (m->mpc_busid >=MAX_MP_BUSSES ) {printk (KERN_WARNING "MP table busid value (%d) for bustype %s " " is too large, max. supported is %d\n" , m->mpc_busid, str,MAX_MP_BUSSES -1 );return ; } +#endif if (strncmp (str,BUSTYPE_ISA ,sizeof (BUSTYPE_ISA )-1 ) ==0 ) { mp_bus_id_to_type[m->mpc_busid] =MP_BUS_ISA ;
PATCH 123/145 i386: make fault notifier unconditional and export it
In reply to a message not in the archiver
It's needed for external debuggers and overhead is very small.
Also make the actual notifier chain they use static
--- arch/x86_64/mm/fault.c | 12 +++--------- 1 files changed, 3 insertions(+), 9 deletions(-)
arch/x86_64/mm/fault.c +3 -9
@@ -40,8 +40,7 @@#define PF_RSVD (1<<3)#define PF_INSTR (1<<4) -#ifdef CONFIG_KPROBES -ATOMIC_NOTIFIER_HEAD (notify_page_fault_chain); +static ATOMIC_NOTIFIER_HEAD (notify_page_fault_chain);/* Hook to register for page fault notifications */ int register_page_fault_notifier (struct notifier_block *nb)
@@ -49,11 +48,13 @@ int register_page_fault_notifier(structvmalloc_sync_all ();return atomic_notifier_chain_register (¬ify_page_fault_chain, nb); } +EXPORT_SYMBOL_GPL (register_page_fault_notifier);int unregister_page_fault_notifier (struct notifier_block *nb) {return atomic_notifier_chain_unregister (¬ify_page_fault_chain, nb); } +EXPORT_SYMBOL_GPL (unregister_page_fault_notifier);static inline int notify_page_fault (enum die_val val,const char *str,struct pt_regs *regs,long err,int trap,int sig)
@@ -67,13 +68,6 @@ static inline int notify_page_fault(enum };return atomic_notifier_call_chain (¬ify_page_fault_chain, val, &args); } -#else -static inline int notify_page_fault (enum die_val val,const char *str, -struct pt_regs *regs,long err,int trap,int sig) -{ -return NOTIFY_DONE ; -} -#endif void bust_spinlocks (int yes) {
Re: [PATCH for review] [123/145] i386: make fault notifier unconditional and export it
Quoted 2 lines
It's needed for external debuggers and overhead is very small.
...
We are currently trying to remove exports not used by any in-kernel code.
The patch description also lacks the name of what you call "external debuggers" (I assume the exports are not for a theoretical usage but for an already existing debugger?). There is no reason for keeping a patch description small.
Especially nowadays where people demand deprecation periods for removing exports without any in-kernel users there must be a _very_ good justification when adding such exports.
This is true for both the i386 and the x86_64 patches.
cu
Adrian
BTW1: The subject of this email is wrong (it's the x86_64 patch).
BTW2: Please use a valid To: header.
Signature · 6 lines
Gentoo kernels are 42 times more popular than SUSE kernels among
KLive users (a service by SUSE contractor Andrea Arcangeli that
gathers data about kernels from many users worldwide).
There are three kinds of lies: Lies, Damn Lies, and Statistics.
Benjamin DisraeliRe: [PATCH for review] [123/145] i386: make fault notifier unconditional and export it
Ar Sul, 2006-08-13 am 17:28 +0200, ysgrifennodd Adrian Bunk:
Quoted 5 lines
Quoted 2 lines
It's needed for external debuggers and overhead is very small.
...We are currently trying to remove exports not used by any in-kernel code.
Wrong pronoun. I think you meant to type "You".
Re: [PATCH for review] [123/145] i386: make fault notifier unconditional and export it
Quoted 8 lines · Alan Cox
Ar Sul, 2006-08-13 am 17:28 +0200, ysgrifennodd Adrian Bunk:
Quoted 5 lines
Quoted 2 lines
It's needed for external debuggers and overhead is very small.
...We are currently trying to remove exports not used by any in-kernel code.
Wrong pronoun. I think you meant to type "You".
"You are currently trying to remove exports..."?
Wouldn't this sound as if Andi was doing this?
I thought the "We" was correct since it's at least Arjan and me.
If this was wrong all I can say is that I'm not a native English speaker.
cu
Adrian
Signature · 6 lines
Gentoo kernels are 42 times more popular than SUSE kernels among
KLive users (a service by SUSE contractor Andrea Arcangeli that
gathers data about kernels from many users worldwide).
There are three kinds of lies: Lies, Damn Lies, and Statistics.
Benjamin DisraeliRe: [PATCH for review] [123/145] i386: make fault notifier unconditional and export it
Ar Sul, 2006-08-13 am 19:08 +0200, ysgrifennodd Adrian Bunk:
Quoted 9 lines
Quoted 1 line
Wrong pronoun. I think you meant to type "You".
"You are currently trying to remove exports..."?
Wouldn't this sound as if Andi was doing this?I thought the "We" was correct since it's at least Arjan and me.
If this was wrong all I can say is that I'm not a native English speaker.
"We" tends to imply 'I speak for all of us'. I was pointing out that you don't speak for everyone. The humour in making that point didn't translate and apparently I ended up confusing you as well which wasn't the intent.
The joys of language.
To put it more clearly "Not everyone agrees with the remove exports" approach, at least not the "all unused" part.
Alan
Re: [PATCH for review] [123/145] i386: make fault notifier unconditional and export it
In reply to Adrian BunkQuoted 5 lines · Adrian Bunk
Quoted 2 lines
It's needed for external debuggers and overhead is very small.
...We are currently trying to remove exports not used by any in-kernel code.
That ``we'' doesn't include me at least.
Quoted 4 lines
The patch description also lacks the name of what you call "external debuggers" (I assume the exports are not for a theoretical usage but for an already existing debugger?).
The fault chain is needed for pretty much any debugger, including kgdb, kdb, nlkd. The one in this case was NLKD.
Quoted 3 lines
Especially nowadays where people demand deprecation periods for removing exports without any in-kernel users there must be a _very_ good justification when adding such exports.
I've always exported symbols when people can make a reasonable case that they need it for extern free non broken by design code.
On the other hand I have no problems with removing unused exports that don't have such a case or are clearly not a useful external interface.
Quoted 1 line
BTW1: The subject of this email is wrong (it's the
x86_64patch).
Fixed, thanks
-Andi
Re: [PATCH for review] [123/145] i386: make fault notifier unconditional and export it
Quoted 10 lines · Andi Kleen (on Sun, 13 Aug 2006 22:17:48 +0200) wrote:
Quoted 5 lines · Adrian Bunk
Quoted 2 lines
It's needed for external debuggers and overhead is very small.
...We are currently trying to remove exports not used by any in-kernel code.
That ``we'' doesn't include me at least.
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
The patch description also lacks the name of what you call "external debuggers" (I assume the exports are not for a theoretical usage but for an already existing debugger?).
The fault chain is needed for pretty much any debugger, including kgdb, kdb, nlkd. The one in this case was NLKD.
No. The page fault event was only used by kprobes, but it slowed down all code. That is why it was changed to only be present if kprobes was in the system. kdb and AFAIK kgdb do not need the page fault chain. nlkd might need it, but that does not seem to have been explicitly stated.
PATCH 124/145 i386: make fault notifier unconditional and export it
In reply to a message not in the archiver
It's needed for external debuggers and overhead is very small.
Also make the actual notifier chain they use static
--- arch/i386/mm/fault.c | 14 ++++---------- 1 files changed, 4 insertions(+), 10 deletions(-)
arch/i386/mm/fault.c +4 -10
@@ -30,18 +30,20 @@extern void die (const char *,struct pt_regs *,long ); -#ifdef CONFIG_KPROBES -ATOMIC_NOTIFIER_HEAD (notify_page_fault_chain); +static ATOMIC_NOTIFIER_HEAD (notify_page_fault_chain); +int register_page_fault_notifier (struct notifier_block *nb) {vmalloc_sync_all ();return atomic_notifier_chain_register (¬ify_page_fault_chain, nb); } +EXPORT_SYMBOL_GPL (register_page_fault_notifier);int unregister_page_fault_notifier (struct notifier_block *nb) {return atomic_notifier_chain_unregister (¬ify_page_fault_chain, nb); } +EXPORT_SYMBOL_GPL (unregister_page_fault_notifier);static inline int notify_page_fault (enum die_val val,const char *str,struct pt_regs *regs,long err,int trap,int sig)
@@ -55,14 +57,6 @@ static inline int notify_page_fault(enum };return atomic_notifier_call_chain (¬ify_page_fault_chain, val, &args); } -#else -static inline int notify_page_fault (enum die_val val,const char *str, -struct pt_regs *regs,long err,int trap,int sig) -{ -return NOTIFY_DONE ; -} -#endif -/* * Unlock any spinlocks which will prevent us from getting the
PATCH 125/145 i376: Make acpi_force static
In reply to a message not in the archiver
From: Adrian Bunk <[email protected]>
acpi_force can become static.
--- arch/i386/kernel/acpi/boot.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
arch/i386/kernel/acpi/boot.c +1 -1
@@ -36,7 +36,7 @@#include <asm/io.h> #include <asm/mpspec.h> -int __initdata acpi_force =0 ; +static int __initdata acpi_force =0 ;#ifdef CONFIG_ACPI int acpi_disabled =0 ;
Re: [PATCH for review] [125/145] i376: Make acpi_force static
On Thursday 10 August 2006 15:37, Andi Kleen wrote:
Ack -- assuming there was a previous patch I didn't see to move the definition of acpi_force to boot.c from setup.c on i386...
-Len
Quoted 33 lines
From: Adrian Bunk <[email protected]>
acpi_forcecan become static.Signed-off-by Adrian Bunk <[email protected]>Signed-off-by Andi Kleen <[email protected]>--- arch/i386/kernel/acpi/boot.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)Index:
linux/arch/i386/kernel/acpi/boot.c
===================================================================arch/i386/kernel/acpi/boot.c +1
-2@@ -36,7 +36,7 @@#include <asm/io.h> #include <asm/mpspec.h> -int __initdata acpi_force =0 ; +static int __initdata acpi_force =0 ;#ifdef CONFIG_ACPI int acpi_disabled =0 ; -To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH for review] [125/145] i376: Make acpi_force static
Quoted 4 lines · On Wed, 16 Aug 2006 11:47:15 -0400 Len Brown <[email protected]> wrote:
On Thursday 10 August 2006 15:37, Andi Kleen wrote:
Ack -- assuming there was a previous patch I didn't see to move the definition of
acpi_forcetoboot.cfromsetup.con i386...
Yes there was. The complete early parameter parsing got changed to early_param() and the acpi parsing is now in boot.c only.
-andi
PATCH 126/145 i386: Make enable_local_apic static
In reply to a message not in the archiver
From: Adrian Bunk <[email protected]>enable_local_apic can now become static.
---
arch/i386/kernel/apic.c | 13 ++++++++++++- include/asm-i386/apic.h | 12 ------------ 2 files changed, 12 insertions(+), 13 deletions(-)
include/asm-i386/apic.h +0 -12
@@ -16,20 +16,8 @@#define APIC_VERBOSE 1#define APIC_DEBUG 2 -extern int enable_local_apic;extern int apic_verbosity; -static inline void lapic_disable (void ) -{ - enable_local_apic =-1 ; -clear_bit (X86_FEATURE_APIC , boot_cpu_data.x86_capability); -} - -static inline void lapic_enable (void ) -{ - enable_local_apic =1 ; -} -/* * Define the default level of output to be very little * This can be turned up by using apic=verbose for more
arch/i386/kernel/apic.c +12 -1
@@ -52,7 +52,18 @@ static cpumask_t timer_bcast_ipi;/* * Knob to control our willingness to enable the local APIC. */ -int enable_local_apic__initdata =0 ;/* -1=force-disable, +1=force-enable */ +static int enable_local_apic__initdata =0 ;/* -1=force-disable, +1=force-enable */ + +static inline void lapic_disable (void ) +{ + enable_local_apic =-1 ; +clear_bit (X86_FEATURE_APIC , boot_cpu_data.x86_capability); +} + +static inline void lapic_enable (void ) +{ + enable_local_apic =1 ; +}/* * Debug level
PATCH 127/145 i386: move kernel_thread_helper into entry.S
In reply to a message not in the archiver
And add proper CFI annotation to it which was previously impossible. This prevents "stuck" messages by the dwarf2 unwinder when reaching the top of a kernel stack.
--- arch/i386/kernel/entry.S | 15 +++++++++++++++ arch/i386/kernel/process.c | 9 --------- 2 files changed, 15 insertions(+), 9 deletions(-)
arch/i386/kernel/entry.S +15 -0
@@ -946,6 +946,21 @@ ENTRY(arch_unwind_init_running) ENDPROC(arch_unwind_init_running) #endif +ENTRY(kernel_thread_helper) + CFI_STARTPROC + movl %edx,%eax + CFI_REGISTER edx,eax + push %edx + CFI_ADJUST_CFA_OFFSET 4 + CFI_REL_OFFSET edx,0 + call *%ebx + push %eax + CFI_ADJUST_CFA_OFFSET 4 + CFI_REL_OFFSET eax,0 + call do_exit + CFI_ENDPROC +ENDPROC(kernel_thread_helper) + .section .rodata,"a" #include "syscall_table.S"
arch/i386/kernel/process.c +0 -9
@@ -321,15 +321,6 @@ void show_regs(struct pt_regs * regs)* the "args". */ extern void kernel_thread_helper (void ); -__asm__(".section .text\n" -".align 4\n" -"kernel_thread_helper:\n\t" -"movl %edx,%eax\n\t" -"pushl %edx\n\t" -"call *%ebx\n\t" -"pushl %eax\n\t" -"call do_exit\n" -".previous" );/* * Create a kernel thread
Re: [PATCH for review] [127/145] i386: move kernel_thread_helper into entry.S
arch/i386/kernel/entry.S ENTRY(arch_unwind_init_running) · line 952
Quoted 8 lines
And add proper CFI annotation to it which was previously impossible. This prevents "stuck" messages by the dwarf2 unwinder when reaching the top of a kernel stack.
arch/i386/kernel/entry.S +4
-0+ENTRY(kernel_thread_helper) + CFI_STARTPROC + movl %edx,%eax + CFI_REGISTER edx,eax
This is pointless, as %eax will be clobbered by the callee of the subsequent call.
arch/i386/kernel/entry.S ENTRY(arch_unwind_init_running) · line 955
Quoted 3 lines
arch/i386/kernel/entry.S +3
-0+ push %edx + CFI_ADJUST_CFA_OFFSET 4 + CFI_REL_OFFSET edx,0
This likewise is pointless, as the argument is owned by the callee.
arch/i386/kernel/entry.S ENTRY(arch_unwind_init_running) · line 959
Quoted 4 lines
arch/i386/kernel/entry.S +4
-0+ call *%ebx + push %eax + CFI_ADJUST_CFA_OFFSET 4 + CFI_REL_OFFSET eax,0
And this too - the value now in %eax has no relation with the value known by the caller of this routine (which doesn't expect any return from here anyway).
arch/i386/kernel/entry.S ENTRY(arch_unwind_init_running) · line 962
Quoted 3 lines
arch/i386/kernel/entry.S +3
-0+ call do_exit + CFI_ENDPROC +ENDPROC(kernel_thread_helper)
Jan
Re: [PATCH for review] [127/145] i386: move kernel_thread_helper into entry.S
Quoted 4 lines
And this too - the value now in %eax has no relation with the value known by the caller of this routine (which doesn't expect any return from here anyway).
Ok, but somehow it needs to be annotiated so that the unwinder stops and doesn't fall back. Can you please send a replacement patch that does this correctly?
Thanks,
-Andi
Re: [PATCH for review] [127/145] i386: move kernel_thread_helper into entry.S
Quoted 7 lines
Quoted 3 lines
And this too - the value now in %eax has no relation with the value known by the caller of this routine (which doesn't expect any return from here anyway).
Ok, but somehow it needs to be annotiated so that the unwinder stops and doesn't fall back. Can you please send a replacement patch that does this correctly?
I would do it this way (untested):
ENTRY(kernel_thread_helper)
CFI_STARTPROC
movl %edx,%eax
pushl %edx
CFI_ADJUST_CFA_OFFSET 4
call *%ebx
pushl %eax
CFI_ADJUST_CFA_OFFSET 4
call do_exit
CFI_ENDPROCENDPROC(kernel_thread_helper)
(i.e. tracking the stack pointer movement, but not the register values other than the return address)
Jan
Re: [PATCH for review] [127/145] i386: move kernel_thread_helper into entry.S
Quoted 13 lines
ENTRY(kernel_thread_helper)
CFI_STARTPROC
movl %edx,%eax
pushl %edx
CFI_ADJUST_CFA_OFFSET4
call *%ebx
pushl %eax
CFI_ADJUST_CFA_OFFSET4
calldo_exit
CFI_ENDPROCENDPROC(kernel_thread_helper)
Quoted 2 lines
(i.e. tracking the stack pointer movement, but not the register values other than the return address)
Done thanks.
-Andi
PATCH 128/145 i386: Descriptor and trap table cleanups.
In reply to a message not in the archiver
From: Rusty Russell <[email protected]>
The implementation comes from Zach's [RFC, PATCH 10/24] i386 Vmi descriptor changes:
Descriptor and trap table cleanups. Add cleanly written accessors for IDT and GDT gates so the subarch may override them. Note that this allows the hypervisor to transparently tweak the DPL of the descriptors as well as the RPL of segments in those descriptors, with no unnecessary kernel code modification. It also allows the hypervisor implementation of the VMI to tweak the gates, allowing for custom exception frames or extra layers of indirection above the guest fault / IRQ handlers.
--- arch/i386/kernel/traps.c | 24 +-------- include/asm-i386/desc.h | 119 +++++++++++++++++++++++++++++------------------ 2 files changed, 80 insertions(+), 63 deletions(-)
arch/i386/kernel/traps.c +5 -19
@@ -1156,20 +1156,6 @@ void __init trap_init_f00f_bug(void) }#endif -#define _set_gate (gate_addr,type,dpl,addr,seg) \ -do { \ - int __d0, __d1; \ - __asm__ __volatile__ ("movw %%dx,%%ax\n\t" \ - "movw %4,%%dx\n\t" \ - "movl %%eax,%0\n\t" \ - "movl %%edx,%1" \ - :"=m" (*((long *) (gate_addr))), \ - "=m" (*(1+(long *) (gate_addr))), "=&a" (__d0), "=&d" (__d1) \ - :"i" ((short) (0x8000+(dpl<<13)+(type<<8))), \ - "3" ((char *) (addr)),"2" ((seg) << 16)); \ -} while (0) - -/* * This needs to use 'idt_table' rather than 'idt', and * thus use the _nonmapped_ version of the IDT, as the
@@ -1178,7 +1164,7 @@ do { \*/ void set_intr_gate (unsigned int n,void *addr) { -_set_gate (idt_table+n,14 ,0 ,addr,__KERNEL_CS); +_set_gate (n,DESCTYPE_INT , addr, __KERNEL_CS); }/*
@@ -1186,22 +1172,22 @@ void set_intr_gate(unsigned int n, void*/ static inline void set_system_intr_gate (unsigned int n,void *addr) { -_set_gate (idt_table+n,14 ,3 , addr, __KERNEL_CS); +_set_gate (n,DESCTYPE_INT |DESCTYPE_DPL3 , addr, __KERNEL_CS); }static void __init set_trap_gate (unsigned int n,void *addr) { -_set_gate (idt_table+n,15 ,0 ,addr,__KERNEL_CS); +_set_gate (n,DESCTYPE_TRAP , addr, __KERNEL_CS); }static void __init set_system_gate (unsigned int n,void *addr) { -_set_gate (idt_table+n,15 ,3 ,addr,__KERNEL_CS); +_set_gate (n,DESCTYPE_TRAP |DESCTYPE_DPL3 , addr, __KERNEL_CS); }static void __init set_task_gate (unsigned int n,unsigned int gdt_entry) { -_set_gate (idt_table+n,5 ,0 ,0 ,(gdt_entry<<3 )); +_set_gate (n,DESCTYPE_TASK , (void *)0 , (gdt_entry<<3 )); }
include/asm-i386/desc.h +75 -44
149 lines not on this page · raw message
PATCH 129/145 x86_64: Auto size the per cpu area.
In reply to a message not in the archiver
From: [email protected] (Eric W. Biederman)
Now for a completely different but trivial approach. I just boot tested it with 255 CPUS and everything worked.
Currently everything (except module data) we place in the per cpu area we know about at compile time. So instead of allocating a fixed size for the per_cpu area allocate the number of bytes we need plus a fixed constant for to be used for modules.
It isn't perfect but it is much less of a pain to work with than what we are doing now.
AK: fixed warning
--- arch/x86_64/kernel/setup64.c | 7 ++----- include/asm-x86_64/percpu.h | 10 ++++++++++ 2 files changed, 12 insertions(+), 5 deletions(-)
arch/x86_64/kernel/setup64.c +2 -5
@@ -95,12 +95,9 @@ void __init setup_per_cpu_areas(void)#endif /* Copy section for each CPU (we discard the original) */ - size =ALIGN (__per_cpu_end - __per_cpu_start,SMP_CACHE_BYTES ); -#ifdef CONFIG_MODULES -if (size <PERCPU_ENOUGH_ROOM ) - size =PERCPU_ENOUGH_ROOM ; -#endif + size =PERCPU_ENOUGH_ROOM ; +printk (KERN_INFO "PERCPU: Allocating %lu bytes of per cpu data\n" , size); for_each_cpu_mask (i, cpu_possible_map) {char *ptr;
include/asm-x86_64/percpu.h +10 -0
@@ -11,6 +11,16 @@#include <asm/pda.h> +#ifdef CONFIG_MODULES +# define PERCPU_MODULE_RESERVE 8192 +#else +# define PERCPU_MODULE_RESERVE 0 +#endif + +#define PERCPU_ENOUGH_ROOM \ + (ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES) + \ + PERCPU_MODULE_RESERVE) +#define __per_cpu_offset (cpu) (cpu_pda(cpu)->data_offset)#define __my_cpu_offset () read_pda(data_offset)
PATCH 130/145 i386: clean up topology.c
In reply to a message not in the archiver
From: Magnus Damm <[email protected]>
There is no need to duplicate the topology_init() function.
---
arch/i386/kernel/topology.c | 21 +++------------------ 1 files changed, 3 insertions(+), 18 deletions(-)
arch/i386/kernel/topology.c +3 -18
@@ -28,6 +28,7 @@#include <linux/init.h> #include <linux/smp.h> #include <linux/nodemask.h> +#include <linux/mmzone.h> #include <asm/cpu.h> static struct i386_cpu cpu_devices[NR_CPUS ];
@@ -55,34 +56,18 @@ EXPORT_SYMBOL(arch_register_cpu);EXPORT_SYMBOL (arch_unregister_cpu);#endif /*CONFIG_HOTPLUG_CPU*/ - - -#ifdef CONFIG_NUMA -#include <linux/mmzone.h> -static int __init topology_init (void ) {int i; +#ifdef CONFIG_NUMA for_each_online_node (i)register_one_node (i); +#endif /* CONFIG_NUMA */ for_each_present_cpu (i)arch_register_cpu (i);return 0 ; } -#else /* !CONFIG_NUMA */ - -static int __init topology_init (void ) -{ -int i; - -for_each_present_cpu (i) -arch_register_cpu (i); -return 0 ; -} - -#endif /* CONFIG_NUMA */ -subsys_initcall (topology_init);
Re: [PATCH for review] [130/145] i386: clean up topology.c
arch/i386/kernel/topology.c EXPORT_SYMBOL(arch_register_cpu); · line 71
Quoted 13 lines · Andi Kleen
static int
__inittopology_init(void){ int i;arch/i386/kernel/topology.c +2
-0+#ifdef CONFIG_NUMA for_each_online_node (i)register_one_node (i); +#endif /* CONFIG_NUMA */ for_each_present_cpu (i)arch_register_cpu (i);return 0 ; }
Wouldn't it be more proper here to make register_one_node() have a non-NUMA definition, instead of putting an #ifdef in a .c file like this?
-- Dave
Re: [PATCH for review] [130/145] i386: clean up topology.c
Quoted 10 lines · Dave Hansen
Quoted 9 lines · Andi Kleen
static int
__inittopology_init(void){ int i;arch/i386/kernel/topology.c +2
-0+#ifdef CONFIG_NUMA for_each_online_node (i)register_one_node (i); +#endif /* CONFIG_NUMA */
Quoted 8 lines
Quoted 4 lines
for_each_present_cpu(i) arch_register_cpu(i); return 0;}
Wouldn't it be more proper here to make
register_one_node()have a non-NUMA definition, instead of putting an #ifdef in a .c file like this?
I don't see a particular advantage of that for something simple like this. But if you feel strongly about it please submit a tested replacement patch.
-Andi
Re: [PATCH for review] [130/145] i386: clean up topology.c
In reply to Dave HansenQuoted 10 lines · Dave Hansen
Quoted 9 lines · Andi Kleen
static int
__inittopology_init(void){ int i;arch/i386/kernel/topology.c +2
-0+#ifdef CONFIG_NUMA for_each_online_node (i)register_one_node (i); +#endif /* CONFIG_NUMA */
Quoted 8 lines
Quoted 4 lines
for_each_present_cpu(i) arch_register_cpu(i); return 0;}
Wouldn't it be more proper here to make
register_one_node()have a non-NUMA definition, instead of putting an #ifdef in a .c file like this?
I thought about that too, and my reason for not doing it is that this simple fix would be less straight-forward and probably more subject to whining and arguing. So my plan was to do this as a first step and then encourage anyone else that wanted to fix up register_one_node() properly. =)
Cheers,
/ magnus
PATCH 131/145 i386: mark two more functions as __init
In reply to a message not in the archiver
From: Magnus Damm <[email protected]>
cyrix_identify() should be __init because transmeta_identify() is. tsc_init() is only called from setup_arch() which is marked as __init.
These two section mismatches have been detected using running modpost on a vmlinux image compiled with CONFIG_RELOCATABLE=y.
---
arch/i386/kernel/cpu/cyrix.c | 2 +- arch/i386/kernel/tsc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/i386/kernel/cpu/cyrix.c +1 -1
@@ -394,7 +394,7 @@ static inline int test_cyrix_52div(void)return (unsigned char ) (test >>8 ) ==0x02 ; } -static void cyrix_identify (struct cpuinfo_x86 * c) +static void __init cyrix_identify (struct cpuinfo_x86 * c) {/* Detect Cyrix with disabled CPUID */ if ( c->x86 ==4 &&test_cyrix_52div () ) {
arch/i386/kernel/tsc.c +1 -1
@@ -192,7 +192,7 @@ int recalibrate_cpu_khz(void)EXPORT_SYMBOL (recalibrate_cpu_khz); -void tsc_init (void ) +void __init tsc_init (void ) {if (!cpu_has_tsc || tsc_disable)return ;
PATCH 132/145 x86_64: fix bus numbering format in mmconfig warning
In reply to a message not in the archiver
From: Brice Goglin <[email protected]>
Make an mmconfig warning print the bus id with a regular format.
---
arch/x86_64/pci/mmconfig.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
arch/x86_64/pci/mmconfig.c +2 -3
@@ -156,9 +156,8 @@ static __init void unreachable_devices(v addr =pci_dev_base (0 , k,PCI_DEVFN (i,0 ));if (addr ==NULL ||readl (addr) != val1) {set_bit (i +32 *k, fallback_slots); -printk (KERN_NOTICE -"PCI: No mmconfig possible on device %x:%x\n" , - k, i); +printk (KERN_NOTICE "PCI: No mmconfig possible" +" on device %02x:%02x\n" , k, i); } } }
PATCH 133/145 x86_64: Support physical cpu hotplug for x86_64
In reply to a message not in the archiver
From: Ashok Raj <[email protected]>
This patch enables ACPI based physical CPU hotplug support for x86_64. Implements acpi_map_lsapic() and acpi_unmap_lsapic() to support physical cpu hotplug.
---
arch/i386/kernel/acpi/boot.c | 69 ++++++++++++++++++++++++++++++++++++++++--- arch/i386/kernel/mpparse.c | 2 - include/asm-i386/smp.h | 1 3 files changed, 67 insertions(+), 5 deletions(-)
arch/i386/kernel/acpi/boot.c +65 -4
@@ -26,6 +26,7 @@#include <linux/init.h> #include <linux/acpi.h> #include <linux/efi.h> +#include <linux/cpumask.h> #include <linux/module.h> #include <linux/dmi.h> #include <linux/irq.h>
@@ -512,16 +513,76 @@ EXPORT_SYMBOL(acpi_register_gsi);#ifdef CONFIG_ACPI_HOTPLUG_CPU int acpi_map_lsapic (acpi_handle handle,int *pcpu) { -/* TBD */ -return -EINVAL ; +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *obj; +struct acpi_table_lapic *lapic; +cpumask_t tmp_map, new_map; +u8 physid; +int cpu; + +if (ACPI_FAILURE (acpi_evaluate_object (handle,"_MAT" ,NULL , &buffer))) +return -EINVAL ; + +if (!buffer.length || !buffer.pointer) +return -EINVAL ; + + obj = buffer.pointer; +if (obj->type !=ACPI_TYPE_BUFFER || + obj->buffer.length <sizeof (*lapic)) { +kfree (buffer.pointer); +return -EINVAL ; + } + + lapic = (struct acpi_table_lapic *)obj->buffer.pointer; + +if ((lapic->header.type !=ACPI_MADT_LAPIC ) || + (!lapic->flags.enabled)) { +kfree (buffer.pointer); +return -EINVAL ; + } + + physid = lapic->id; + +kfree (buffer.pointer); + buffer.length =ACPI_ALLOCATE_BUFFER ; + buffer.pointer =NULL ; + + tmp_map = cpu_present_map; +mp_register_lapic (physid, lapic->flags.enabled); + +/* +* If mp_register_lapic successfully generates a new logical cpu +* number, then the following will get us exactly what was mapped +*/ +cpus_andnot (new_map, cpu_present_map, tmp_map); +if (cpus_empty (new_map)) { +printk ("Unable to map lapic to logical cpu number\n" ); +return -EINVAL ; + } + + cpu =first_cpu (new_map); + + *pcpu = cpu; +return 0 ; }EXPORT_SYMBOL (acpi_map_lsapic);int acpi_unmap_lsapic (int cpu) { -/* TBD */ -return -EINVAL ; +int i; + +for_each_possible_cpu (i) { +if (x86_acpiid_to_apicid[i] == x86_cpu_to_apicid[cpu]) { + x86_acpiid_to_apicid[i] =-1 ; +break ; + } + } + x86_cpu_to_apicid[cpu] =-1 ; +cpu_clear (cpu, cpu_present_map); + num_processors--; + +return (0 ); }EXPORT_SYMBOL (acpi_unmap_lsapic);
arch/i386/kernel/mpparse.c +1 -1
@@ -69,7 +69,7 @@ unsigned int def_to_bigsmp = 0;/* Processor that is doing the boot up */ unsigned int boot_cpu_physical_apicid =-1U ;/* Internal processor count */ -static unsigned int __devinitdata num_processors; +unsigned int __cpuinitdata num_processors;/* Bitmask of physically existing CPUs */ physid_mask_t phys_cpu_present_map;
include/asm-i386/smp.h +1 -0
@@ -84,6 +84,7 @@ static inline int hard_smp_processor_id(extern int __cpu_disable (void );extern void __cpu_die (unsigned int cpu); +extern unsigned int num_processors;#endif /* !__ASSEMBLY__ */
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH for review] [133/145] x86_64: Support physical cpu hotplug for x86_64
Quoted 2 lines
Looks like subject or patch is misleading.
X86_64vsarch/i386
No, actually the patch implements it for x86-64 -- the x86-64 code lives in arch/i386 in this case
-Andi
Re: [PATCH for review] [133/145] x86_64: Support physical cpu hotplug for x86_64
In reply to Andi KleenQuoted 33 lines · Andi Kleen
r
From: Ashok Raj <[email protected]>
This patch enables ACPI based physical CPU hotplug support for
x86_64. Implementsacpi_map_lsapic()andacpi_unmap_lsapic()to support physical cpu hotplug.Signed-off-by Ashok Raj <[email protected]>Signed-off-by Andi Kleen <[email protected]>Cc Andi Kleen <[email protected]>Cc "Brown, Len" <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
arch/i386/kernel/acpi/boot.c | 69 ++++++++++++++++++++++++++++++++++++++++--- arch/i386/kernel/mpparse.c | 2 - include/asm-i386/smp.h | 1 3 files changed, 67 insertions(+), 5 deletions(-)Index:
linux/arch/i386/kernel/acpi/boot.c
===================================================================arch/i386/kernel/acpi/boot.c +1
-0@@ -26,6 +26,7 @@#include <linux/init.h> #include <linux/acpi.h> #include <linux/efi.h> +#include <linux/cpumask.h> #include <linux/module.h> #include <linux/dmi.h> #include <linux/irq.h>
arch/i386/kernel/acpi/boot.c EXPORT_SYMBOL(acpi_register_gsi); · line 518
Quoted 8 lines
arch/i386/kernel/acpi/boot.c +3
-2@@ -512,16 +513,76 @@ EXPORT_SYMBOL(acpi_register_gsi);#ifdef CONFIG_ACPI_HOTPLUG_CPU int acpi_map_lsapic (acpi_handle handle,int *pcpu) { -/* TBD */ -return -EINVAL ; +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *obj; +struct acpi_table_lapic *lapic;
Lets _not_ have a routine called acpi_map_lsapic() that on ia64 maps an lsapic and on i386 and x86_64 maps a lapic.
If you can't share the same routine between 3 architectures, then at least give it a generic name that applies to both lsapic and lapic.
thanks,
-Len
Quoted 103 lines
arch/i386/kernel/acpi/boot.c +61
-2+cpumask_t tmp_map, new_map; +u8 physid; +int cpu; + +if (ACPI_FAILURE (acpi_evaluate_object (handle,"_MAT" ,NULL , &buffer))) +return -EINVAL ; + +if (!buffer.length || !buffer.pointer) +return -EINVAL ; + + obj = buffer.pointer; +if (obj->type !=ACPI_TYPE_BUFFER || + obj->buffer.length <sizeof (*lapic)) { +kfree (buffer.pointer); +return -EINVAL ; + } + + lapic = (struct acpi_table_lapic *)obj->buffer.pointer; + +if ((lapic->header.type !=ACPI_MADT_LAPIC ) || + (!lapic->flags.enabled)) { +kfree (buffer.pointer); +return -EINVAL ; + } + + physid = lapic->id; + +kfree (buffer.pointer); + buffer.length =ACPI_ALLOCATE_BUFFER ; + buffer.pointer =NULL ; + + tmp_map = cpu_present_map; +mp_register_lapic (physid, lapic->flags.enabled); + +/* +* If mp_register_lapic successfully generates a new logical cpu +* number, then the following will get us exactly what was mapped +*/ +cpus_andnot (new_map, cpu_present_map, tmp_map); +if (cpus_empty (new_map)) { +printk ("Unable to map lapic to logical cpu number\n" ); +return -EINVAL ; + } + + cpu =first_cpu (new_map); + + *pcpu = cpu; +return 0 ; }EXPORT_SYMBOL (acpi_map_lsapic);int acpi_unmap_lsapic (int cpu) { -/* TBD */ -return -EINVAL ; +int i; + +for_each_possible_cpu (i) { +if (x86_acpiid_to_apicid[i] == x86_cpu_to_apicid[cpu]) { + x86_acpiid_to_apicid[i] =-1 ; +break ; + } + } + x86_cpu_to_apicid[cpu] =-1 ; +cpu_clear (cpu, cpu_present_map); + num_processors--; + +return (0 ); }EXPORT_SYMBOL (acpi_unmap_lsapic);Index:
linux/arch/i386/kernel/mpparse.c
===================================================================arch/i386/kernel/mpparse.c +1
-1@@ -69,7 +69,7 @@ unsigned int def_to_bigsmp = 0;/* Processor that is doing the boot up */ unsigned int boot_cpu_physical_apicid =-1U ;/* Internal processor count */ -static unsigned int __devinitdata num_processors; +unsigned int __cpuinitdata num_processors;/* Bitmask of physically existing CPUs */ physid_mask_t phys_cpu_present_map;Index:
linux/include/asm-i386/smp.h
===================================================================include/asm-i386/smp.h +1
-1@@ -84,6 +84,7 @@ static inline int hard_smp_processor_id(extern int __cpu_disable (void );extern void __cpu_die (unsigned int cpu); +extern unsigned int num_processors;#endif /* !__ASSEMBLY__ */ -To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
PATCH 134/145 x86_64: non lazy "sleazy" fpu implementation
In reply to a message not in the archiver
From: Arjan van de Ven <[email protected]>
Right now the kernel on x86-64 has a 100% lazy fpu behavior: after *every* context switch a trap is taken for the first FPU use to restore the FPU context lazily. This is of course great for applications that have very sporadic or no FPU use (since then you avoid doing the expensive save/restore all the time). However for very frequent FPU users... you take an extra trap every context switch.
The patch below adds a simple heuristic to this code: After 5 consecutive context switches of FPU use, the lazy behavior is disabled and the context gets restored every context switch. If the app indeed uses the FPU, the trap is avoided. (the chance of the 6th time slice using FPU after the previous 5 having done so are quite high obviously).
After 256 switches, this is reset and lazy behavior is returned (until there are 5 consecutive ones again). The reason for this is to give apps that do longer bursts of FPU use still the lazy behavior back after some time.
---
arch/x86_64/kernel/process.c | 10 ++++++++++ arch/x86_64/kernel/traps.c | 1 + include/asm-x86_64/i387.h | 5 ++++- include/linux/sched.h | 9 +++++++++ 4 files changed, 24 insertions(+), 1 deletion(-)
arch/x86_64/kernel/process.c +10 -0
@@ -552,6 +552,10 @@ __switch_to(struct task_struct *prev_p,int cpu =smp_processor_id ();struct tss_struct *tss = &per_cpu (init_tss, cpu); +/* we're going to use this soon, after a few expensive things */ +if (next_p->fpu_counter>5 ) +prefetch (&next->i387.fxsave); +/* * Reload esp0, LDT and the page table pointer: */
@@ -629,6 +633,12 @@ __switch_to(struct task_struct *prev_p, || test_tsk_thread_flag(prev_p, TIF_IO_BITMAP))__switch_to_xtra (prev_p, next_p, tss); +/* If the task has used fpu the last 5 timeslices, just do a full +* restore of the math state immediately to avoid the trap; the +* chances of needing FPU soon are obviously high now +*/ +if (next_p->fpu_counter>5 ) +math_state_restore ();return prev_p; }
arch/x86_64/kernel/traps.c +1 -0
@@ -1134,6 +1134,7 @@ asmlinkage void math_state_restore(void)init_fpu (me);restore_fpu_checking (&me->thread.i387.fxsave);task_thread_info (me)->status |=TS_USEDFPU ; + me->fpu_counter++; }void __init trap_init (void )
include/asm-x86_64/i387.h +4 -1
@@ -24,6 +24,7 @@ extern unsigned int mxcsr_feature_mask;extern void mxcsr_feature_mask_init (void );extern void init_fpu (struct task_struct *child);extern int save_i387 (struct _fpstate __user *buf); +extern asmlinkage void math_state_restore(void);/* * FPU lazy state save handling...
@@ -31,7 +32,9 @@ extern int save_i387(struct _fpstate __u#define unlazy_fpu (tsk) do { \ if (task_thread_info(tsk)->status & TS_USEDFPU) \ - save_init_fpu(tsk); \ + save_init_fpu(tsk); \ + else \ + tsk->fpu_counter = 0; \ } while (0)/* Ignore delayed exceptions from user space */
include/linux/sched.h +9 -0
@@ -865,6 +865,15 @@ struct task_struct {struct key *thread_keyring;/* keyring private to this thread */ unsigned char jit_keyring;/* default keyring to attach requested keys to */ #endif +/* +* fpu_counter contains the number of consecutive context switches +* that the FPU is used. If this is over a threshold, the lazy fpu +* saving becomes unlazy to save the trap. This is an unsigned char +* so that after 256 times the counter wraps and the behavior turns +* lazy again; this to deal with bursty apps that only use FPU for +* a short time +*/ +unsigned char fpu_counter;int oomkilladj;/* OOM kill score adjustment (bit shift). */ char comm[TASK_COMM_LEN ];/* executable name excluding path - access with [gs]et_task_comm (which lock
PATCH 135/145 x86_64: wire up oops_enter()/oops_exit()
In reply to a message not in the archiver
From: Andrew Morton <[email protected]>
Implement pause_on_oops() on x86_64.
AK: I redid the patch to do the oops_enter/exit in the existing oops_begin()/end(). This makes it much shorter.
---
arch/x86_64/kernel/traps.c | 4 ++++ 1 files changed, 4 insertions(+)
arch/x86_64/kernel/traps.c +4 -0
@@ -559,6 +559,8 @@ unsigned __kprobes long oops_begin(void)int cpu =safe_smp_processor_id ();unsigned long flags; +oops_enter (); +/* racy, but better than risking deadlock. */ local_irq_save (flags);if (!spin_trylock (&die_lock)) {
@@ -587,6 +589,8 @@ void __kprobes oops_end(unsigned long flspin_unlock_irqrestore (&die_lock, flags);if (panic_on_oops)panic ("Fatal exception: panic_on_oops" ); + +oops_exit (); }void __kprobes __die (const char * str,struct pt_regs * regs,long err)
PATCH 136/145 x86_64: x86_64 kernel mapping fix
In reply to a message not in the archiver
From: Keith Mannthey <[email protected]>
Fix for the x86_64 kernel mapping code. Without this patch the update path only inits one pmd_page worth of memory and tramples any entries on it. now the calling convention to phys_pmd_init and phys_init is to always pass a [pmd/pud] page not an offset within a page.
--- arch/x86_64/mm/init.c | 51 +++++++++++++++++++++++++------------------------- 1 files changed, 26 insertions(+), 25 deletions(-)
arch/x86_64/mm/init.c +26 -25
@@ -250,12 +250,13 @@ __init void early_iounmap(void *addr, un }static void __meminit -phys_pmd_init (pmd_t *pmd,unsigned long address,unsigned long end) +phys_pmd_init (pmd_t *pmd_page,unsigned long address,unsigned long end) { -int i; +int i =pmd_index (address); -for (i =0 ; i <PTRS_PER_PMD ; pmd++, i++, address +=PMD_SIZE ) { +for (; i <PTRS_PER_PMD ; i++, address +=PMD_SIZE ) {unsigned long entry; +pmd_t *pmd = pmd_page +pmd_index (address);if (address >= end) {if (!after_bootmem)
@@ -263,6 +264,10 @@ phys_pmd_init(pmd_t *pmd, unsigned longset_pmd (pmd,__pmd (0 ));break ; } + +if (pmd_val (*pmd)) +continue ; + entry = _PAGE_NX|_PAGE_PSE|_KERNPG_TABLE|_PAGE_GLOBAL|address; entry &= __supported_pte_mask;set_pmd (pmd,__pmd (entry));
@@ -272,45 +277,41 @@ phys_pmd_init(pmd_t *pmd, unsigned longstatic void __meminit phys_pmd_update (pud_t *pud,unsigned long address,unsigned long end) { -pmd_t *pmd =pmd_offset (pud, (unsigned long )__va (address)); - -if (pmd_none (*pmd)) { -spin_lock (&init_mm.page_table_lock); -phys_pmd_init (pmd, address, end); -spin_unlock (&init_mm.page_table_lock); -__flush_tlb_all (); - } +pmd_t *pmd =pmd_offset (pud,0 ); +spin_lock (&init_mm.page_table_lock); +phys_pmd_init (pmd, address, end); +spin_unlock (&init_mm.page_table_lock); +__flush_tlb_all (); } -static void __meminit phys_pud_init (pud_t *pud,unsigned long address,unsigned long end) +static void __meminit phys_pud_init (pud_t *pud_page,unsigned long addr,unsigned long end) { -long i =pud_index (address); - - pud = pud + i; +int i =pud_index (addr); -if (after_bootmem &&pud_val (*pud)) { -phys_pmd_update (pud, address, end); -return ; - } -for (; i <PTRS_PER_PUD ; pud++, i++) { +for (; i <PTRS_PER_PUD ; i++, addr = (addr &PUD_MASK ) +PUD_SIZE ) {int map; -unsigned long paddr, pmd_phys; +unsigned long pmd_phys; +pud_t *pud = pud_page +pud_index (addr);pmd_t *pmd; - paddr = (address &PGDIR_MASK ) + i*PUD_SIZE ; -if (paddr >= end) +if (addr >= end)break ; -if (!after_bootmem && !e820_any_mapped (paddr, paddr+PUD_SIZE ,0 )) { +if (!after_bootmem && !e820_any_mapped (addr,addr+PUD_SIZE ,0 )) {set_pud (pud,__pud (0 ));continue ; } +if (pud_val (*pud)) { +phys_pmd_update (pud, addr, end); +continue ; + } + pmd =alloc_low_page (&map, &pmd_phys);spin_lock (&init_mm.page_table_lock);set_pud (pud,__pud (pmd_phys | _KERNPG_TABLE)); -phys_pmd_init (pmd, paddr, end); +phys_pmd_init (pmd, addr, end);spin_unlock (&init_mm.page_table_lock);unmap_low_page (map); }
PATCH 137/145 i386: KPROBE_ENTRY ends up putting code into .fixup
In reply to a message not in the archiver
From: Jeremy Fitzhardinge <[email protected]>
KPROBE_ENTRY does a .section .kprobes.text, and expects its users to do a .previous at the end of the function.
Unfortunately, if any code within the function switches sections, for example .fixup, then the .previous ends up putting all subsequent code into .fixup. Worse, any subsequent .fixup code gets intermingled with the code its supposed to be fixing (which is also in .fixup). It's surprising this didn't cause more havok.
The fix is to use .pushsection/.popsection, so this stuff nests properly. A further cleanup would be to get rid of all .section/.previous pairs, since they're inherently fragile.
--- arch/i386/kernel/entry.S | 8 ++++---- arch/x86_64/kernel/entry.S | 12 ++++++------ include/linux/linkage.h | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-)
arch/i386/kernel/entry.S +4 -4
@@ -639,7 +639,7 @@ error_code: call *%edi jmp ret_from_exception CFI_ENDPROC -.previous +.popsection ENTRY(coprocessor_error) RING0_INT_FRAME
@@ -715,7 +715,7 @@ debug_stack_correct: call do_debug jmp ret_from_exception CFI_ENDPROC -.previous +.popsection /* * NMI is doubly nasty. It can happen _while_ we're handling
@@ -812,7 +812,7 @@ KPROBE_ENTRY(int3) call do_int3 jmp ret_from_exception CFI_ENDPROC -.previous +.popsection ENTRY(overflow) RING0_INT_FRAME
@@ -877,7 +877,7 @@ KPROBE_ENTRY(general_protection) CFI_ADJUST_CFA_OFFSET 4 jmp error_code CFI_ENDPROC -.previous +.popsection ENTRY(alignment_check) RING0_EC_FRAME
arch/x86_64/kernel/entry.S +6 -6
@@ -904,7 +904,7 @@ error_kernelspace: je error_swapgs jmp error_sti END(error_entry) - .previous + .popsection /* Reload gs selector with exception handling */ /* edi: new selector */
@@ -1024,7 +1024,7 @@ ENDPROC(execve) KPROBE_ENTRY(page_fault) errorentry do_page_fault END(page_fault) - .previous + .popsection ENTRY(coprocessor_error) zeroentry do_coprocessor_error
@@ -1046,7 +1046,7 @@ KPROBE_ENTRY(debug) paranoidentry do_debug, DEBUG_STACK paranoidexit END(debug) - .previous + .popsection /* runs on exception stack */ KPROBE_ENTRY(nmi)
@@ -1061,7 +1061,7 @@ KPROBE_ENTRY(nmi) CFI_ENDPROC #endif END(nmi) - .previous + .popsection KPROBE_ENTRY(int3) INTR_FRAME
@@ -1071,7 +1071,7 @@ KPROBE_ENTRY(int3) jmp paranoid_exit1 CFI_ENDPROC END(int3) - .previous + .popsection ENTRY(overflow) zeroentry do_overflow
@@ -1120,7 +1120,7 @@ END(stack_segment) KPROBE_ENTRY(general_protection) errorentry do_general_protection END(general_protection) - .previous + .popsection ENTRY(alignment_check) errorentry do_alignment_check
include/linux/linkage.h +1 -1
@@ -35,7 +35,7 @@#endif #define KPROBE_ENTRY (name) \ - .section .kprobes.text, "ax"; \ + .pushsection .kprobes.text, "ax"; \ ENTRY(name)#ifndef END
PATCH 138/145 i386: remove redundant generic_identify() calls when identifying cpus
In reply to a message not in the archiver
From: Magnus Damm <[email protected]>
cpu_dev->c_identify is only called from arch/i386/common.c:identify_cpu(), and this after generic_identify() already has been called. There is no need to call this function twice and hook it in c_identify - but I may be wrong, please double check before applying.
This patch also removes generic_identify() from cpu.h to avoid unnecessary future nesting.
---
arch/i386/kernel/cpu/amd.c | 1 - arch/i386/kernel/cpu/common.c | 2 +- arch/i386/kernel/cpu/cpu.h | 2 -- arch/i386/kernel/cpu/cyrix.c | 2 -- arch/i386/kernel/cpu/intel.c | 1 - arch/i386/kernel/cpu/nexgen.c | 1 - arch/i386/kernel/cpu/transmeta.c | 1 - 7 files changed, 1 insertion(+), 9 deletions(-)
arch/i386/kernel/cpu/amd.c +0 -1
@@ -275,7 +275,6 @@ static struct cpu_dev amd_cpu_dev __init }, }, .c_init = init_amd, - .c_identify = generic_identify, .c_size_cache = amd_size_cache, };
arch/i386/kernel/cpu/common.c +1 -1
@@ -265,7 +265,7 @@ static void __init early_cpu_detect(void } } -void __cpuinit generic_identify (struct cpuinfo_x86 * c) +static void __cpuinit generic_identify (struct cpuinfo_x86 * c) {u32 tfms, xlvl;int ebx;
arch/i386/kernel/cpu/cpu.h +0 -2
@@ -24,7 +24,5 @@ extern struct cpu_dev * cpu_devs [X86_VEextern int get_model_name (struct cpuinfo_x86 *c);extern void display_cacheinfo (struct cpuinfo_x86 *c); -extern void generic_identify (struct cpuinfo_x86 * c); -extern void early_intel_workaround (struct cpuinfo_x86 *c);
arch/i386/kernel/cpu/cyrix.c +0 -2
@@ -427,7 +427,6 @@ static void __init cyrix_identify(structlocal_irq_restore (flags); } } -generic_identify (c); }static struct cpu_dev cyrix_cpu_dev__initdata = {
@@ -457,7 +456,6 @@ static struct cpu_dev nsc_cpu_dev __init .c_vendor = "NSC", .c_ident = { "Geode by NSC" }, .c_init = init_nsc, - .c_identify = generic_identify, };int __init nsc_init_cpu (void )
arch/i386/kernel/cpu/intel.c +0 -1
@@ -263,7 +263,6 @@ static struct cpu_dev intel_cpu_dev __cp }, }, .c_init = init_intel, - .c_identify = generic_identify, .c_size_cache = intel_size_cache, };
arch/i386/kernel/cpu/nexgen.c +0 -1
@@ -38,7 +38,6 @@ static void __init nexgen_identify(strucif (deep_magic_nexgen_probe () ) {strcpy (c->x86_vendor_id,"NexGenDriven" ); } -generic_identify (c); }static struct cpu_dev nexgen_cpu_dev__initdata = {
arch/i386/kernel/cpu/transmeta.c +0 -1
@@ -88,7 +88,6 @@ static void __init init_transmeta(structstatic void __init transmeta_identify (struct cpuinfo_x86 * c) {u32 xlvl; -generic_identify (c);/* Transmeta-defined flags: level 0x80860001 */ xlvl =cpuid_eax (0x80860000 );
PATCH 139/145 x86_64: mark init_amd() as __cpuinit
In reply to a message not in the archiver
From: Magnus Damm <[email protected]>
The init_amd() function is only called from identify_cpu() which is already marked as __cpuinit. So let's mark it as __cpuinit.
---
arch/x86_64/kernel/setup.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
arch/x86_64/kernel/setup.c +1 -1
@@ -674,7 +674,7 @@ static void __init amd_detect_cmp(struct#endif } -static void __init init_amd (struct cpuinfo_x86 *c) +static void __cpuinit init_amd (struct cpuinfo_x86 *c) {unsigned level;
PATCH 140/145 i386: mark cpu_dev structures as __cpuinitdata
In reply to a message not in the archiver
From: Magnus Damm <[email protected]>
The different cpu_dev structures are all used from __cpuinit callers what I can tell. So mark them as __cpuinitdata instead of __initdata. I am a little bit unsure about arch/i386/common.c:default_cpu, especially when it comes to the purpose of this_cpu.
---
arch/i386/kernel/cpu/amd.c | 2 +- arch/i386/kernel/cpu/centaur.c | 2 +- arch/i386/kernel/cpu/common.c | 2 +- arch/i386/kernel/cpu/cyrix.c | 4 ++-- arch/i386/kernel/cpu/nexgen.c | 2 +- arch/i386/kernel/cpu/rise.c | 2 +- arch/i386/kernel/cpu/transmeta.c | 2 +- arch/i386/kernel/cpu/umc.c | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-)
arch/i386/kernel/cpu/amd.c +1 -1
@@ -259,7 +259,7 @@ static unsigned int amd_size_cache(strucreturn size; } -static struct cpu_dev amd_cpu_dev__initdata = { +static struct cpu_dev amd_cpu_dev__cpuinitdata = { .c_vendor ="AMD" , .c_ident = {"AuthenticAMD" }, .c_models = {
arch/i386/kernel/cpu/centaur.c +1 -1
@@ -457,7 +457,7 @@ static unsigned int centaur_size_cache(sreturn size; } -static struct cpu_dev centaur_cpu_dev__initdata = { +static struct cpu_dev centaur_cpu_dev__cpuinitdata = { .c_vendor ="Centaur" , .c_ident = {"CentaurHauls" }, .c_init = init_centaur,
arch/i386/kernel/cpu/common.c +1 -1
@@ -49,7 +49,7 @@ static void default_init(struct cpuinfo_ } } -static struct cpu_dev default_cpu = { +static struct cpu_dev __cpuinitdata default_cpu = { .c_init = default_init, .c_vendor ="Unknown" , };
arch/i386/kernel/cpu/cyrix.c +2 -2
@@ -429,7 +429,7 @@ static void __init cyrix_identify(struct } } -static struct cpu_dev cyrix_cpu_dev__initdata = { +static struct cpu_dev cyrix_cpu_dev__cpuinitdata = { .c_vendor ="Cyrix" , .c_ident = {"CyrixInstead" }, .c_init = init_cyrix,
@@ -452,7 +452,7 @@ static int __init cyrix_exit_cpu(void)late_initcall (cyrix_exit_cpu); -static struct cpu_dev nsc_cpu_dev__initdata = { +static struct cpu_dev nsc_cpu_dev__cpuinitdata = { .c_vendor ="NSC" , .c_ident = {"Geode by NSC" }, .c_init = init_nsc,
arch/i386/kernel/cpu/nexgen.c +1 -1
@@ -40,7 +40,7 @@ static void __init nexgen_identify(struc } } -static struct cpu_dev nexgen_cpu_dev__initdata = { +static struct cpu_dev nexgen_cpu_dev__cpuinitdata = { .c_vendor ="Nexgen" , .c_ident = {"NexGenDriven" }, .c_models = {
arch/i386/kernel/cpu/rise.c +1 -1
@@ -28,7 +28,7 @@ static void __init init_rise(struct cpuiset_bit (X86_FEATURE_CX8 , c->x86_capability); } -static struct cpu_dev rise_cpu_dev__initdata = { +static struct cpu_dev rise_cpu_dev__cpuinitdata = { .c_vendor ="Rise" , .c_ident = {"RiseRiseRise" }, .c_models = {
arch/i386/kernel/cpu/transmeta.c +1 -1
@@ -97,7 +97,7 @@ static void __init transmeta_identify(st } } -static struct cpu_dev transmeta_cpu_dev__initdata = { +static struct cpu_dev transmeta_cpu_dev__cpuinitdata = { .c_vendor ="Transmeta" , .c_ident = {"GenuineTMx86" ,"TransmetaCPU" }, .c_init = init_transmeta,
arch/i386/kernel/cpu/umc.c +1 -1
@@ -10,7 +10,7 @@ static void __init init_umc(struct cpuin } -static struct cpu_dev umc_cpu_dev__initdata = { +static struct cpu_dev umc_cpu_dev__cpuinitdata = { .c_vendor ="UMC" , .c_ident = {"UMC UMC UMC" }, .c_models = {
PATCH 141/145 i386: mark cpu init functions as __cpuinit, data as __cpuinitdata
In reply to a message not in the archiver
From: Magnus Damm <[email protected]>
Mark i386-specific cpu init functions as __cpuinit. They are all only called from arch/i386/common.c:identify_cpu() that already is marked as __cpuinit. This patch also removes the empty function init_umc().
---
arch/i386/kernel/cpu/amd.c | 2 +- arch/i386/kernel/cpu/centaur.c | 20 ++++++++++---------- arch/i386/kernel/cpu/common.c | 2 +- arch/i386/kernel/cpu/cyrix.c | 32 ++++++++++++++++---------------- arch/i386/kernel/cpu/nexgen.c | 2 +- arch/i386/kernel/cpu/rise.c | 2 +- arch/i386/kernel/cpu/transmeta.c | 2 +- arch/i386/kernel/cpu/umc.c | 5 ----- 8 files changed, 31 insertions(+), 36 deletions(-)
arch/i386/kernel/cpu/amd.c +1 -1
@@ -22,7 +22,7 @@extern void vide (void ); __asm__(".align 4\nvide: ret" ); -static void __init init_amd (struct cpuinfo_x86 *c) +static void __cpuinit init_amd (struct cpuinfo_x86 *c) {u32 l, h;int mbytes = num_physpages >> (20 -PAGE_SHIFT );
arch/i386/kernel/cpu/centaur.c +10 -10
@@ -9,7 +9,7 @@#ifdef CONFIG_X86_OOSTORE -static u32 __init power2 (u32 x) +static u32 __cpuinit power2 (u32 x) {u32 s=1 ;while (s<=x)
@@ -22,7 +22,7 @@ static u32 __init power2(u32 x)* Set up an actual MCR */ -static void __init centaur_mcr_insert (int reg,u32 base,u32 size,int key) +static void __cpuinit centaur_mcr_insert (int reg,u32 base,u32 size,int key) {u32 lo, hi;
@@ -40,7 +40,7 @@ static void __init centaur_mcr_insert(in* Shortcut: We know you can't put 4Gig of RAM on a winchip */ -static u32 __init ramtop (void )/* 16388 */ +static u32 __cpuinit ramtop (void )/* 16388 */ {int i;u32 top =0 ;
@@ -91,7 +91,7 @@ static u32 __init ramtop(void) /* 16388* Compute a set of MCR's to give maximum coverage */ -static int __init centaur_mcr_compute (int nr,int key) +static int __cpuinit centaur_mcr_compute (int nr,int key) {u32 mem =ramtop ();u32 root =power2 (mem);
@@ -166,7 +166,7 @@ static int __init centaur_mcr_compute(inreturn ct; } -static void __init centaur_create_optimal_mcr (void ) +static void __cpuinit centaur_create_optimal_mcr (void ) {int i;/*
@@ -189,7 +189,7 @@ static void __init centaur_create_optimawrmsr (MSR_IDT_MCR0 +i,0 ,0 ); } -static void __init winchip2_create_optimal_mcr (void ) +static void __cpuinit winchip2_create_optimal_mcr (void ) {u32 lo, hi;int i;
@@ -227,7 +227,7 @@ static void __init winchip2_create_optim* Handle the MCR key on the Winchip 2. */ -static void __init winchip2_unprotect_mcr (void ) +static void __cpuinit winchip2_unprotect_mcr (void ) {u32 lo, hi;u32 key;
@@ -239,7 +239,7 @@ static void __init winchip2_unprotect_mcwrmsr (MSR_IDT_MCR_CTRL , lo, hi); } -static void __init winchip2_protect_mcr (void ) +static void __cpuinit winchip2_protect_mcr (void ) {u32 lo, hi;
@@ -257,7 +257,7 @@ static void __init winchip2_protect_mcr(#define RNG_ENABLED (1 << 3)#define RNG_ENABLE (1 << 6)/* MSR_VIA_RNG */ -static void __init init_c3 (struct cpuinfo_x86 *c) +static void __cpuinit init_c3 (struct cpuinfo_x86 *c) {u32 lo, hi;
@@ -303,7 +303,7 @@ static void __init init_c3(struct cpuinfdisplay_cacheinfo (c); } -static void __init init_centaur (struct cpuinfo_x86 *c) +static void __cpuinit init_centaur (struct cpuinfo_x86 *c) {enum {ECX8 =1 <<1 ,
arch/i386/kernel/cpu/common.c +1 -1
@@ -36,7 +36,7 @@ struct cpu_dev * cpu_devs[X86_VENDOR_NUMextern int disable_pse; -static void default_init (struct cpuinfo_x86 * c) +static void __cpuinit default_init (struct cpuinfo_x86 * c) {/* Not much we can do here... */ /* Check if at least it has cpuid */
arch/i386/kernel/cpu/cyrix.c +16 -16
@@ -52,25 +52,25 @@ static void __init do_cyrix_devid(unsign* Actually since bugs.h doesn't even reference this perhaps someone should * fix the documentation ??? */ -static unsigned char Cx86_dir0_msb__initdata =0 ; +static unsigned char Cx86_dir0_msb__cpuinitdata =0 ; -static char Cx86_model[][9 ]__initdata = { +static char Cx86_model[][9 ]__cpuinitdata = {"Cx486" ,"Cx486" ,"5x86 " ,"6x86" ,"MediaGX " ,"6x86MX " ,"M II " ,"Unknown" }; -static char Cx486_name[][5 ]__initdata = { +static char Cx486_name[][5 ]__cpuinitdata = {"SLC" ,"DLC" ,"SLC2" ,"DLC2" ,"SRx" ,"DRx" ,"SRx2" ,"DRx2" }; -static char Cx486S_name[][4 ]__initdata = { +static char Cx486S_name[][4 ]__cpuinitdata = {"S" ,"S2" ,"Se" ,"S2e" }; -static char Cx486D_name[][4 ]__initdata = { +static char Cx486D_name[][4 ]__cpuinitdata = {"DX" ,"DX2" ,"?" ,"?" ,"?" ,"DX4" }; -static char Cx86_cb[]__initdata ="?.5x Core/Bus Clock" ; -static char cyrix_model_mult1[]__initdata ="12??43" ; -static char cyrix_model_mult2[]__initdata ="12233445" ; +static char Cx86_cb[]__cpuinitdata ="?.5x Core/Bus Clock" ; +static char cyrix_model_mult1[]__cpuinitdata ="12??43" ; +static char cyrix_model_mult2[]__cpuinitdata ="12233445" ;/* * Reset the slow-loop (SLOP) bit on the 686(L) which is set by some old
@@ -82,7 +82,7 @@ static char cyrix_model_mult2[] __initdaextern void calibrate_delay (void )__init ; -static void __init check_cx686_slop (struct cpuinfo_x86 *c) +static void __cpuinit check_cx686_slop (struct cpuinfo_x86 *c) {unsigned long flags;
@@ -107,7 +107,7 @@ static void __init check_cx686_slop(stru } -static void __init set_cx86_reorder (void ) +static void __cpuinit set_cx86_reorder (void ) {u8 ccr3;
@@ -122,7 +122,7 @@ static void __init set_cx86_reorder(voidsetCx86 (CX86_CCR3 , ccr3); } -static void __init set_cx86_memwb (void ) +static void __cpuinit set_cx86_memwb (void ) {u32 cr0;
@@ -137,7 +137,7 @@ static void __init set_cx86_memwb(void)setCx86 (CX86_CCR2 ,getCx86 (CX86_CCR2 ) |0x14 ); } -static void __init set_cx86_inc (void ) +static void __cpuinit set_cx86_inc (void ) {unsigned char ccr3;
@@ -158,7 +158,7 @@ static void __init set_cx86_inc(void)* Configure later MediaGX and/or Geode processor. */ -static void __init geode_configure (void ) +static void __cpuinit geode_configure (void ) {unsigned long flags;u8 ccr3, ccr4;
@@ -184,14 +184,14 @@ static void __init geode_configure(void)#ifdef CONFIG_PCI -static struct pci_device_id __initdata cyrix_55x0[] = { +static struct pci_device_id __cpuinitdata cyrix_55x0[] = { {PCI_DEVICE (PCI_VENDOR_ID_CYRIX ,PCI_DEVICE_ID_CYRIX_5510 ) }, {PCI_DEVICE (PCI_VENDOR_ID_CYRIX ,PCI_DEVICE_ID_CYRIX_5520 ) }, { }, };#endif -static void __init init_cyrix (struct cpuinfo_x86 *c) +static void __cpuinit init_cyrix (struct cpuinfo_x86 *c) {unsigned char dir0, dir0_msn, dir0_lsn, dir1 =0 ;char *buf = c->x86_model_id;
@@ -346,7 +346,7 @@ static void __init init_cyrix(struct cpu/* * Handle National Semiconductor branded processors */ -static void __init init_nsc (struct cpuinfo_x86 *c) +static void __cpuinit init_nsc (struct cpuinfo_x86 *c) {/* There may be GX1 processors in the wild that are branded * NSC and not Cyrix.
arch/i386/kernel/cpu/nexgen.c +1 -1
@@ -27,7 +27,7 @@ static int __init deep_magic_nexgen_probreturn ret; } -static void __init init_nexgen (struct cpuinfo_x86 * c) +static void __cpuinit init_nexgen (struct cpuinfo_x86 * c) { c->x86_cache_size =256 ;/* A few had 1 MB... */ }
arch/i386/kernel/cpu/rise.c +1 -1
@@ -5,7 +5,7 @@#include "cpu.h" -static void __init init_rise (struct cpuinfo_x86 *c) +static void __cpuinit init_rise (struct cpuinfo_x86 *c) {printk ("CPU: Rise iDragon" );if (c->x86_model >2 )
arch/i386/kernel/cpu/transmeta.c +1 -1
@@ -5,7 +5,7 @@#include <asm/msr.h> #include "cpu.h" -static void __init init_transmeta (struct cpuinfo_x86 *c) +static void __cpuinit init_transmeta (struct cpuinfo_x86 *c) {unsigned int cap_mask, uk, max, dummy;unsigned int cms_rev1, cms_rev2;
arch/i386/kernel/cpu/umc.c +0 -5
@@ -5,10 +5,6 @@/* UMC chips appear to be only either 386 or 486, so no special init takes place. */ -static void __init init_umc (struct cpuinfo_x86 * c) -{ - -}static struct cpu_dev umc_cpu_dev__cpuinitdata = { .c_vendor ="UMC" ,
@@ -21,7 +17,6 @@ static struct cpu_dev umc_cpu_dev __cpui } }, }, - .c_init = init_umc, };int __init umc_init_cpu (void )
PATCH 142/145 i386: mark cpu identify functions as __cpuinit
In reply to a message not in the archiver
From: Magnus Damm <[email protected]>
Mark i386-specific cpu identification functions as __cpuinit. They are all only called from arch/i386/common.c:identify_cpu() that already is marked as __cpuinit.
---
arch/i386/kernel/cpu/cyrix.c | 4 ++-- arch/i386/kernel/cpu/nexgen.c | 4 ++-- arch/i386/kernel/cpu/transmeta.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
arch/i386/kernel/cpu/cyrix.c +2 -2
@@ -12,7 +12,7 @@/* * Read NSC/Cyrix DEVID registers (DIR) to get more detailed info. about the CPU */ -static void __init do_cyrix_devid (unsigned char *dir0,unsigned char *dir1) +static void __cpuinit do_cyrix_devid (unsigned char *dir0,unsigned char *dir1) {unsigned char ccr2, ccr3;unsigned long flags;
@@ -394,7 +394,7 @@ static inline int test_cyrix_52div(void)return (unsigned char ) (test >>8 ) ==0x02 ; } -static void __init cyrix_identify (struct cpuinfo_x86 * c) +static void __cpuinit cyrix_identify (struct cpuinfo_x86 * c) {/* Detect Cyrix with disabled CPUID */ if ( c->x86 ==4 &&test_cyrix_52div () ) {
arch/i386/kernel/cpu/nexgen.c +2 -2
@@ -10,7 +10,7 @@* to have CPUID. (Thanks to Herbert Oppmann) */ -static int __init deep_magic_nexgen_probe (void ) +static int __cpuinit deep_magic_nexgen_probe (void ) {int ret;
@@ -32,7 +32,7 @@ static void __cpuinit init_nexgen(struct c->x86_cache_size =256 ;/* A few had 1 MB... */ } -static void __init nexgen_identify (struct cpuinfo_x86 * c) +static void __cpuinit nexgen_identify (struct cpuinfo_x86 * c) {/* Detect NexGen with old hypercode */ if (deep_magic_nexgen_probe () ) {
arch/i386/kernel/cpu/transmeta.c +1 -1
@@ -85,7 +85,7 @@ static void __cpuinit init_transmeta(str#endif } -static void __init transmeta_identify (struct cpuinfo_x86 * c) +static void __cpuinit transmeta_identify (struct cpuinfo_x86 * c) {u32 xlvl;
PATCH 143/145 i386: mark cpu cache functions as __cpuinit
In reply to a message not in the archiver
From: Magnus Damm <[email protected]>
Mark i386-specific cpu cache functions as __cpuinit. They are all only called from arch/i386/common.c:display_cache_info() that already is marked as __cpuinit.
---
arch/i386/kernel/cpu/amd.c | 2 +- arch/i386/kernel/cpu/centaur.c | 2 +- arch/i386/kernel/cpu/intel.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/i386/kernel/cpu/amd.c +1 -1
@@ -246,7 +246,7 @@ static void __cpuinit init_amd(struct cp num_cache_leaves =3 ; } -static unsigned int amd_size_cache (struct cpuinfo_x86 * c,unsigned int size) +static unsigned int __cpuinit amd_size_cache (struct cpuinfo_x86 * c,unsigned int size) {/* AMD errata T13 (order #21922) */ if ((c->x86 ==6 )) {
arch/i386/kernel/cpu/centaur.c +1 -1
@@ -442,7 +442,7 @@ static void __cpuinit init_centaur(struc } } -static unsigned int centaur_size_cache (struct cpuinfo_x86 * c,unsigned int size) +static unsigned int __cpuinit centaur_size_cache (struct cpuinfo_x86 * c,unsigned int size) {/* VIA C3 CPUs (670-68F) need further shifting. */ if ((c->x86 ==6 ) && ((c->x86_model ==7 ) || (c->x86_model ==8 )))
arch/i386/kernel/cpu/intel.c +1 -1
@@ -198,7 +198,7 @@ static void __cpuinit init_intel(struct } -static unsigned int intel_size_cache (struct cpuinfo_x86 * c,unsigned int size) +static unsigned int __cpuinit intel_size_cache (struct cpuinfo_x86 * c,unsigned int size) {/* Intel PIII Tualatin. This comes in two flavours. * One has 256kb of cache, the other 512. We have no way
PATCH 144/145 i386: Disallow kprobes on NMI handlers
In reply to a message not in the archiver
From: Fernando Luis =?ISO-8859-1?Q?V=E1zquez?= Cao <[email protected]>
A kprobe executes IRET early and that could cause NMI recursion and stack corruption.
Note: This problem was originally spotted by Andi Kleen. This patch
adds fixes not included in his original patch.
[AK: Jan Beulich originally discovered these classes of bugs]
---
--- arch/i386/kernel/mca.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
arch/i386/kernel/mca.c +5 -3
@@ -42,6 +42,7 @@#include <linux/errno.h> #include <linux/kernel.h> #include <linux/mca.h> +#include <linux/kprobes.h> #include <asm/system.h> #include <asm/io.h> #include <linux/proc_fs.h>
@@ -414,7 +415,8 @@ subsys_initcall(mca_init);/*--------------------------------------------------------------------*/ -static void mca_handle_nmi_device (struct mca_device *mca_dev,int check_flag) +static __kprobes void +mca_handle_nmi_device (struct mca_device *mca_dev,int check_flag) {int slot = mca_dev->slot;
@@ -444,7 +446,7 @@ static void mca_handle_nmi_device(struct/*--------------------------------------------------------------------*/ -static int mca_handle_nmi_callback (struct device *dev,void *data) +static int __kprobes mca_handle_nmi_callback (struct device *dev,void *data) {struct mca_device *mca_dev =to_mca_device (dev);unsigned char pos5;
@@ -462,7 +464,7 @@ static int mca_handle_nmi_callback(strucreturn 0 ; } -void mca_handle_nmi (void ) +void __kprobes mca_handle_nmi (void ) {/* First try - scan the various adapters and see if a specific * adapter was responsible for the error.
PATCH 145/145 i386: Disallow kprobes on NMI handlers
In reply to a message not in the archiver
From: Fernando Luis =?ISO-8859-1?Q?V=E1zquez?= Cao <[email protected]> A kprobe executes IRET early and that could cause NMI recursion and stack corruption.
Note: This problem was originally spotted and solved by Andi Kleen in the x86_64 architecture. This patch is an adaption of his patch for i386.
AK: Merged with current code which was a bit different.
AK: Removed printk in nmi handler that shouldn't be there in the first time
AK: Added missing include.
---
--- arch/i386/kernel/entry.S | 2 +- arch/i386/kernel/nmi.c | 6 +++--- arch/i386/kernel/traps.c | 15 +++++++++------ 3 files changed, 13 insertions(+), 10 deletions(-)
arch/i386/kernel/entry.S +1 -1
@@ -725,7 +725,7 @@ debug_stack_correct: * check whether we got an NMI on the debug path where the debug * fault happened on the sysenter path. */ -ENTRY(nmi) +KPROBE_ENTRY(nmi) RING0_INT_FRAME pushl %eax CFI_ADJUST_CFA_OFFSET 4
arch/i386/kernel/nmi.c +3 -3
@@ -22,6 +22,7 @@#include <linux/sysctl.h> #include <linux/percpu.h> #include <linux/dmi.h> +#include <linux/kprobes.h> #include <asm/smp.h> #include <asm/nmi.h>
@@ -882,7 +883,7 @@ EXPORT_SYMBOL(touch_nmi_watchdog);extern void die_nmi (struct pt_regs *,const char *msg); -int nmi_watchdog_tick (struct pt_regs * regs,unsigned reason) +__kprobes int nmi_watchdog_tick (struct pt_regs * regs,unsigned reason) {/*
@@ -962,8 +963,7 @@ int nmi_watchdog_tick (struct pt_regs ** This matches the old behaviour. */ rc =1 ; - }else -printk (KERN_WARNING "Unknown enabled NMI hardware?!\n" ); + } } done:return rc;
arch/i386/kernel/traps.c +9 -6
@@ -680,7 +680,8 @@ gp_in_kernel: } } -static void mem_parity_error (unsigned char reason,struct pt_regs * regs) +static __kprobes void +mem_parity_error (unsigned char reason,struct pt_regs * regs) {printk (KERN_EMERG "Uhhuh. NMI received for unknown reason %02x on " "CPU %d.\n" , reason,smp_processor_id ());
@@ -695,7 +696,8 @@ static void mem_parity_error(unsigned chclear_mem_error (reason); } -static void io_check_error (unsigned char reason,struct pt_regs * regs) +static __kprobes void +io_check_error (unsigned char reason,struct pt_regs * regs) {unsigned long i;
@@ -711,7 +713,8 @@ static void io_check_error(unsigned charoutb (reason,0x61 ); } -static void unknown_nmi_error (unsigned char reason,struct pt_regs * regs) +static __kprobes void +unknown_nmi_error (unsigned char reason,struct pt_regs * regs) {#ifdef CONFIG_MCA /* Might actually be able to figure out what the guilty party
@@ -732,7 +735,7 @@ static void unknown_nmi_error(unsigned cstatic DEFINE_SPINLOCK (nmi_print_lock); -void die_nmi (struct pt_regs *regs,const char *msg) +void __kprobes die_nmi (struct pt_regs *regs,const char *msg) {if (notify_die (DIE_NMIWATCHDOG , msg, regs,0 ,2 ,SIGINT ) ==NOTIFY_STOP )
@@ -764,7 +767,7 @@ void die_nmi (struct pt_regs *regs, consdo_exit (SIGSEGV ); } -static void default_do_nmi (struct pt_regs * regs) +static __kprobes void default_do_nmi (struct pt_regs * regs) {unsigned char reason =0 ;
@@ -802,7 +805,7 @@ static void default_do_nmi(struct pt_regreassert_nmi (); } -fastcall void do_nmi(struct pt_regs * regs, long error_code) +fastcall __kprobes void do_nmi(struct pt_regs * regs, long error_code) {int cpu;
A message that is not in the archive (sent off-list or not yet received): 20060810193518.394E413B90__40006.6926530146$1155241071$gmane$org@wotan.suse.de
Re: [PATCH for review] [6/145] x86_64: Utilize performance counter reservation framework in oprofile
Andi Kleen:
arch/i386/oprofile/nmi_int.c static void nmi_cpu_save_registers(struc · line 101
Quoted 12 lines
Index:
linux/arch/i386/oprofile/nmi_int.c
===================================================================arch/i386/oprofile/nmi_int.c +1
-3@@ -98,15 +98,19 @@ static void nmi_cpu_save_registers(strucunsigned int i;for (i =0 ; i < nr_ctrs; ++i) { -rdmsr (counters[i].addr, - counters[i].saved.low, - counters[i].saved.high); +if (counters[i].addr){
need space ){
arch/i386/oprofile/nmi_int.c static void nmi_cpu_save_registers(struc · line 109
Quoted 11 lines
arch/i386/oprofile/nmi_int.c +5
-3+rdmsr (counters[i].addr, + counters[i].saved.low, + counters[i].saved.high); + } }for (i =0 ; i < nr_ctrls; ++i) { -rdmsr (controls[i].addr, - controls[i].saved.low, - controls[i].saved.high); +if (controls[i].addr){
likewise
Quoted 8 lines
arch/i386/oprofile/nmi_int.c +4
-0+rdmsr (controls[i].addr, + controls[i].saved.low, + controls[i].saved.high); + } } }
arch/i386/oprofile/nmi_int.c static void nmi_restore_registers(struct · line 212
Quoted 7 lines
arch/i386/oprofile/nmi_int.c +1
-3@@ -205,15 +209,19 @@ static void nmi_restore_registers(structunsigned int i;for (i =0 ; i < nr_ctrls; ++i) { -wrmsr (controls[i].addr, - controls[i].saved.low, - controls[i].saved.high); +if (controls[i].addr){
likewise
arch/i386/oprofile/nmi_int.c static void nmi_restore_registers(struct · line 220
Quoted 11 lines
arch/i386/oprofile/nmi_int.c +5
-3+wrmsr (controls[i].addr, + controls[i].saved.low, + controls[i].saved.high); + } }for (i =0 ; i < nr_ctrs; ++i) { -wrmsr (counters[i].addr, - counters[i].saved.low, - counters[i].saved.high); +if (counters[i].addr){
likewise
Quoted 163 lines
arch/i386/oprofile/nmi_int.c +13
-0+wrmsr (counters[i].addr, + counters[i].saved.low, + counters[i].saved.high); + } } }@@ -234,6 +242,7 @@ static void nmi_cpu_shutdown(void * dummapic_write (APIC_LVTPC , saved_lvtpc[cpu]);apic_write (APIC_LVTERR , v);nmi_restore_registers (msrs); + model->shutdown (msrs); }@@ -284,6 +293,14 @@ static int nmi_create_files(struct superstruct dentry * dir;char buf[4 ]; +/* quick little hack to _not_ expose a counter if it is not +* available for use. This should protect userspace app. +* NOTE: assumes 1:1 mapping here (that counters are organized +* sequentially in their struct assignment). +*/ +if (unlikely (!avail_to_resrv_perfctr_nmi_bit (i))) +continue ; +snprintf (buf,sizeof (buf),"%d" , i); dir =oprofilefs_mkdir (sb, root, buf);oprofilefs_create_ulong (sb, dir,"enabled" , &counter_config[i].enabled);Index:
linux/arch/i386/oprofile/op_model_athlon.c
===================================================================arch/i386/oprofile/op_model_athlon.c +42
-12@@ -21,10 +21,12 @@#define NUM_COUNTERS 4#define NUM_CONTROLS 4 +#define CTR_IS_RESERVED (msrs,c) (msrs->counters[(c)].addr ? 1 : 0)#define CTR_READ (l,h,msrs,c) do {rdmsr(msrs->counters[(c)].addr, (l), (h));} while (0)#define CTR_WRITE (l,msrs,c) do {wrmsr(msrs->counters[(c)].addr, -(unsigned int)(l), -1);} while (0)#define CTR_OVERFLOWED (n) (!((n) & (1U<<31))) +#define CTRL_IS_RESERVED (msrs,c) (msrs->controls[(c)].addr ? 1 : 0)#define CTRL_READ (l,h,msrs,c) do {rdmsr(msrs->controls[(c)].addr, (l), (h));} while (0)#define CTRL_WRITE (l,h,msrs,c) do {wrmsr(msrs->controls[(c)].addr, (l), (h));} while (0)#define CTRL_SET_ACTIVE (n) (n |= (1<<22))@@ -40,15 +42,21 @@ static unsigned long reset_value[NUM_COUstatic void athlon_fill_in_addresses (struct op_msrs *const msrs) { - msrs->counters[0 ].addr =MSR_K7_PERFCTR0 ; - msrs->counters[1 ].addr =MSR_K7_PERFCTR1 ; - msrs->counters[2 ].addr =MSR_K7_PERFCTR2 ; - msrs->counters[3 ].addr =MSR_K7_PERFCTR3 ; - - msrs->controls[0 ].addr =MSR_K7_EVNTSEL0 ; - msrs->controls[1 ].addr =MSR_K7_EVNTSEL1 ; - msrs->controls[2 ].addr =MSR_K7_EVNTSEL2 ; - msrs->controls[3 ].addr =MSR_K7_EVNTSEL3 ; +int i; + +for (i=0 ; i <NUM_COUNTERS ; i++) { +if (reserve_perfctr_nmi (MSR_K7_PERFCTR0 + i)) + msrs->counters[i].addr =MSR_K7_PERFCTR0 + i; +else + msrs->counters[i].addr =0 ; + } + +for (i=0 ; i <NUM_CONTROLS ; i++) { +if (reserve_evntsel_nmi (MSR_K7_EVNTSEL0 + i)) + msrs->controls[i].addr =MSR_K7_EVNTSEL0 + i; +else + msrs->controls[i].addr =0 ; + } }@@ -59,19 +67,23 @@ static void athlon_setup_ctrs(struct op_/* clear all counters */ for (i =0 ; i <NUM_CONTROLS ; ++i) { +if (unlikely (!CTRL_IS_RESERVED (msrs,i))) +continue ;CTRL_READ (low, high, msrs, i);CTRL_CLEAR (low);CTRL_WRITE (low, high, msrs, i); } - +/* avoid a false detection of ctr overflows in NMI handler */ for (i =0 ; i <NUM_COUNTERS ; ++i) { +if (unlikely (!CTR_IS_RESERVED (msrs,i))) +continue ;CTR_WRITE (1 , msrs, i); }/* enable active counters */ for (i =0 ; i <NUM_COUNTERS ; ++i) { -if (counter_config[i].enabled) { +if ((counter_config[i].enabled) && (CTR_IS_RESERVED (msrs,i))) { reset_value[i] = counter_config[i].count;CTR_WRITE (counter_config[i].count, msrs, i);@@ -98,6 +110,8 @@ static int athlon_check_ctrs(struct pt_rint i;for (i =0 ; i <NUM_COUNTERS ; ++i) { +if (!reset_value[i]) +continue ;CTR_READ (low, high, msrs, i);if (CTR_OVERFLOWED (low)) {oprofile_add_sample (regs, i);@@ -132,12 +146,27 @@ static void athlon_stop(struct op_msrs c/* Subtle: stop on all counters to avoid race with * setting our pm callback */ for (i =0 ; i <NUM_COUNTERS ; ++i) { +if (!reset_value[i]) +continue ;CTRL_READ (low, high, msrs, i);CTRL_SET_INACTIVE (low);CTRL_WRITE (low, high, msrs, i); } } +static void athlon_shutdown (struct op_msrs const *const msrs) +{ +int i; + +for (i =0 ; i <NUM_COUNTERS ; ++i) { +if (CTR_IS_RESERVED (msrs,i)) +release_perfctr_nmi (MSR_K7_PERFCTR0 + i); + } +for (i =0 ; i <NUM_CONTROLS ; ++i) { +if (CTRL_IS_RESERVED (msrs,i)) +release_evntsel_nmi (MSR_K7_EVNTSEL0 + i); + } +}struct op_x86_model_spec const op_athlon_spec = { .num_counters =NUM_COUNTERS ,@@ -146,5 +175,6 @@ struct op_x86_model_spec const op_athlon .setup_ctrs = &athlon_setup_ctrs, .check_ctrs = &athlon_check_ctrs, .start = &athlon_start, - .stop = &athlon_stop + .stop = &athlon_stop, + .shutdown = &athlon_shutdown };Index:
linux/arch/i386/oprofile/op_model_p4.c
===================================================================arch/i386/oprofile/op_model_p4.c +1
-1@@ -32,7 +32,7 @@#define NUM_CONTROLS_HT2 (NUM_ESCRS_HT2 + NUM_CCCRS_HT2)static unsigned int num_counters =NUM_COUNTERS_NON_HT ; - +static unsigned int num_controls =NUM_CONTROLS_NON_HT ;/* this has to be checked dynamically since the hyper-threadedness of a chip is discovered at
arch/i386/oprofile/op_model_p4.c static unsigned int num_counters = NUM_C · line 43
Quoted 5 lines
arch/i386/oprofile/op_model_p4.c +1
-1@@ -40,8 +40,10 @@ static unsigned int num_counters = NUM_Cstatic inline void setup_num_counters (void ) {#ifdef CONFIG_SMP -if (smp_num_siblings ==2 ) +if (smp_num_siblings ==2 ){
likewise
arch/i386/oprofile/op_model_p4.c static struct p4_counter_binding p4_coun · line 100
Quoted 9 lines
arch/i386/oprofile/op_model_p4.c +2
-0num_counters =NUM_COUNTERS_HT2 ; + num_controls = NUM_CONTROLS_HT2; + }#endif }@@ -97,15 +99,6 @@ static struct p4_counter_binding p4_coun#define NUM_UNUSED_CCCRS NUM_CCCRS_NON_HT - NUM_COUNTERS_NON_HT
maybe (NUM_CCCRS_NON_HT - NUM_COUNTERS_NON_HT) will be better
Quoted 45 lines
arch/i386/oprofile/op_model_p4.c +5
-19-/* All cccr we don't use. */ -static int p4_unused_cccr[NUM_UNUSED_CCCRS ] = { -MSR_P4_BPU_CCCR1 ,MSR_P4_BPU_CCCR3 , -MSR_P4_MS_CCCR1 ,MSR_P4_MS_CCCR3 , -MSR_P4_FLAME_CCCR1 ,MSR_P4_FLAME_CCCR3 , -MSR_P4_IQ_CCCR0 ,MSR_P4_IQ_CCCR1 , -MSR_P4_IQ_CCCR2 ,MSR_P4_IQ_CCCR3 -}; -/* p4 event codes in libop/op_event.h are indices into this table. */ static struct p4_event_binding p4_events[NUM_EVENTS ] = {@@ -372,6 +365,8 @@ static struct p4_event_binding p4_events#define CCCR_OVF_P (cccr) ((cccr) & (1U<<31))#define CCCR_CLEAR_OVF (cccr) ((cccr) &= (~(1U<<31))) +#define CTRL_IS_RESERVED (msrs,c) (msrs->controls[(c)].addr ? 1 : 0) +#define CTR_IS_RESERVED (msrs,c) (msrs->counters[(c)].addr ? 1 : 0)#define CTR_READ (l,h,i) do {rdmsr(p4_counters[(i)].counter_address, (l), (h));} while (0)#define CTR_WRITE (l,i) do {wrmsr(p4_counters[(i)].counter_address, -(u32)(l), -1);} while (0)#define CTR_OVERFLOW_P (ctr) (!((ctr) & 0x80000000))@@ -401,29 +396,34 @@ static unsigned long reset_value[NUM_COUstatic void p4_fill_in_addresses (struct op_msrs *const msrs) {unsigned int i; -unsigned int addr, stag; +unsigned int addr, cccraddr, stag;setup_num_counters (); stag =get_stagger (); -/* the counter registers we pay attention to */ +/* initialize some registers */ for (i =0 ; i < num_counters; ++i) { - msrs->counters[i].addr = - p4_counters[VIRT_CTR (stag, i)].counter_address; + msrs->counters[i].addr =0 ; } - -/* FIXME: bad feeling, we don't save the 10 counters we don't use. */ - -/* 18 CCCR registers */ -for (i =0 , addr =MSR_P4_BPU_CCCR0 + stag; - addr <=MSR_P4_IQ_CCCR5 ; ++i, addr +=addr_increment ()) {
arch/i386/oprofile/op_model_p4.c static unsigned long reset_value[NUM_COU · line 416
Quoted 10 lines
arch/i386/oprofile/op_model_p4.c +7
-1- msrs->controls[i].addr = addr; +for (i =0 ; i < num_controls; ++i) { + msrs->controls[i].addr =0 ; } +/* the counter & cccr registers we pay attention to */ +for (i =0 ; i < num_counters; ++i) { + addr = p4_counters[VIRT_CTR (stag, i)].counter_address; + cccraddr = p4_counters[VIRT_CTR (stag, i)].cccr_address; +if (reserve_perfctr_nmi (addr)){
){
Quoted 15 lines
arch/i386/oprofile/op_model_p4.c +7
-1+ msrs->counters[i].addr = addr; + msrs->controls[i].addr = cccraddr; + } + } +/* 43 ESCR registers in three or four discontiguous group */ for (addr =MSR_P4_BSU_ESCR0 + stag; addr <MSR_P4_IQ_ESCR0 ; ++i, addr +=addr_increment ()) { - msrs->controls[i].addr = addr; +if (reserve_evntsel_nmi (addr)) + msrs->controls[i].addr = addr; }/* no IQ_ESCR0/1 on some models, we save a seconde time BSU_ESCR0/1
arch/i386/oprofile/op_model_p4.c static void p4_fill_in_addresses(struct · line 435
Quoted 6 lines
arch/i386/oprofile/op_model_p4.c +2
-1@@ -431,47 +431,57 @@ static void p4_fill_in_addresses(structif (boot_cpu_data.x86_model >=0x3 ) {for (addr =MSR_P4_BSU_ESCR0 + stag; addr <=MSR_P4_BSU_ESCR1 ; ++i, addr +=addr_increment ()) { - msrs->controls[i].addr = addr; +if (reserve_evntsel_nmi (addr)) + msrs->controls[i].addr = addr;
anyways 'if' opens braces, maybe move init of 'addr' before 'for'
Quoted 33 lines
arch/i386/oprofile/op_model_p4.c +8
-4} }else {for (addr =MSR_P4_IQ_ESCR0 + stag; addr <=MSR_P4_IQ_ESCR1 ; ++i, addr +=addr_increment ()) { - msrs->controls[i].addr = addr; +if (reserve_evntsel_nmi (addr)) + msrs->controls[i].addr = addr; } }for (addr =MSR_P4_RAT_ESCR0 + stag; addr <=MSR_P4_SSU_ESCR0 ; ++i, addr +=addr_increment ()) { - msrs->controls[i].addr = addr; +if (reserve_evntsel_nmi (addr)) + msrs->controls[i].addr = addr; }for (addr =MSR_P4_MS_ESCR0 + stag; addr <=MSR_P4_TC_ESCR1 ; ++i, addr +=addr_increment ()) { - msrs->controls[i].addr = addr; +if (reserve_evntsel_nmi (addr)) + msrs->controls[i].addr = addr; }for (addr =MSR_P4_IX_ESCR0 + stag; addr <=MSR_P4_CRU_ESCR3 ; ++i, addr +=addr_increment ()) { - msrs->controls[i].addr = addr; +if (reserve_evntsel_nmi (addr)) + msrs->controls[i].addr = addr; }/* there are 2 remaining non-contiguously located ESCRs */
arch/i386/oprofile/op_model_p4.c static void p4_fill_in_addresses(struct · line 472
Quoted 10 lines
arch/i386/oprofile/op_model_p4.c +4
-2if (num_counters ==NUM_COUNTERS_NON_HT ) {/* standard non-HT CPUs handle both remaining ESCRs*/ - msrs->controls[i++].addr =MSR_P4_CRU_ESCR5 ; - msrs->controls[i++].addr =MSR_P4_CRU_ESCR4 ; +if (reserve_evntsel_nmi (MSR_P4_CRU_ESCR5 )) + msrs->controls[i++].addr =MSR_P4_CRU_ESCR5 ; +if (reserve_evntsel_nmi (MSR_P4_CRU_ESCR4 )) + msrs->controls[i++].addr =MSR_P4_CRU_ESCR4 ; }else if (stag ==0 ) {
if (!stag)
Quoted 288 lines
arch/i386/oprofile/op_model_p4.c +37
-48/* HT CPUs give the first remainder to the even thread, as the 32nd control register */ - msrs->controls[i++].addr =MSR_P4_CRU_ESCR4 ; +if (reserve_evntsel_nmi (MSR_P4_CRU_ESCR4 )) + msrs->controls[i++].addr =MSR_P4_CRU_ESCR4 ; }else {/* and two copies of the second to the odd thread, for the 22st and 23nd control registers */ - msrs->controls[i++].addr =MSR_P4_CRU_ESCR5 ; - msrs->controls[i++].addr =MSR_P4_CRU_ESCR5 ; +if (reserve_evntsel_nmi (MSR_P4_CRU_ESCR5 )) { + msrs->controls[i++].addr =MSR_P4_CRU_ESCR5 ; + msrs->controls[i++].addr =MSR_P4_CRU_ESCR5 ; + } } }@@ -544,7 +554,6 @@ static void p4_setup_ctrs(struct op_msrs {unsigned int i;unsigned int low, high; -unsigned int addr;unsigned int stag; stag =get_stagger ();@@ -557,59 +566,24 @@ static void p4_setup_ctrs(struct op_msrs/* clear the cccrs we will use */ for (i =0 ; i < num_counters ; i++) { +if (unlikely (!CTRL_IS_RESERVED (msrs,i))) +continue ;rdmsr (p4_counters[VIRT_CTR (stag, i)].cccr_address, low, high);CCCR_CLEAR (low);CCCR_SET_REQUIRED_BITS (low);wrmsr (p4_counters[VIRT_CTR (stag, i)].cccr_address, low, high); } -/* clear cccrs outside our concern */ -for (i = stag ; i <NUM_UNUSED_CCCRS ; i +=addr_increment ()) { -rdmsr (p4_unused_cccr[i], low, high); -CCCR_CLEAR (low); -CCCR_SET_REQUIRED_BITS (low); -wrmsr (p4_unused_cccr[i], low, high); - } -/* clear all escrs (including those outside our concern) */ -for (addr =MSR_P4_BSU_ESCR0 + stag; - addr <MSR_P4_IQ_ESCR0 ; addr +=addr_increment ()) { -wrmsr (addr,0 ,0 ); - } - -/* On older models clear also MSR_P4_IQ_ESCR0/1 */ -if (boot_cpu_data.x86_model <0x3 ) { -wrmsr (MSR_P4_IQ_ESCR0 ,0 ,0 ); -wrmsr (MSR_P4_IQ_ESCR1 ,0 ,0 ); - } - -for (addr =MSR_P4_RAT_ESCR0 + stag; - addr <=MSR_P4_SSU_ESCR0 ; ++i, addr +=addr_increment ()) { -wrmsr (addr,0 ,0 ); - } - -for (addr =MSR_P4_MS_ESCR0 + stag; - addr <=MSR_P4_TC_ESCR1 ; addr +=addr_increment ()){ -wrmsr (addr,0 ,0 ); - } - -for (addr =MSR_P4_IX_ESCR0 + stag; - addr <=MSR_P4_CRU_ESCR3 ; addr +=addr_increment ()){ -wrmsr (addr,0 ,0 ); +for (i = num_counters; i < num_controls; i++) { +if (unlikely (!CTRL_IS_RESERVED (msrs,i))) +continue ; +wrmsr (msrs->controls[i].addr,0 ,0 ); } -if (num_counters ==NUM_COUNTERS_NON_HT ) { -wrmsr (MSR_P4_CRU_ESCR4 ,0 ,0 ); -wrmsr (MSR_P4_CRU_ESCR5 ,0 ,0 ); - }else if (stag ==0 ) { -wrmsr (MSR_P4_CRU_ESCR4 ,0 ,0 ); - }else { -wrmsr (MSR_P4_CRU_ESCR5 ,0 ,0 ); - } -/* setup all counters */ for (i =0 ; i < num_counters ; ++i) { -if (counter_config[i].enabled) { +if ((counter_config[i].enabled) && (CTRL_IS_RESERVED (msrs,i))) { reset_value[i] = counter_config[i].count;pmc_setup_one_p4_counter (i);CTR_WRITE (counter_config[i].count,VIRT_CTR (stag, i));@@ -696,12 +670,32 @@ static void p4_stop(struct op_msrs const stag =get_stagger ();for (i =0 ; i < num_counters; ++i) { +if (!reset_value[i]) +continue ;CCCR_READ (low, high,VIRT_CTR (stag, i));CCCR_SET_DISABLE (low);CCCR_WRITE (low, high,VIRT_CTR (stag, i)); } } +static void p4_shutdown (struct op_msrs const *const msrs) +{ +int i; + +for (i =0 ; i < num_counters ; ++i) { +if (CTR_IS_RESERVED (msrs,i)) +release_perfctr_nmi (msrs->counters[i].addr); + } +/* some of the control registers are specially reserved in +* conjunction with the counter registers (hence the starting offset). +* This saves a few bits. +*/ +for (i = num_counters ; i < num_controls ; ++i) { +if (CTRL_IS_RESERVED (msrs,i)) +release_evntsel_nmi (msrs->controls[i].addr); + } +} +#ifdef CONFIG_SMP struct op_x86_model_spec const op_p4_ht2_spec = {@@ -711,7 +705,8 @@ struct op_x86_model_spec const op_p4_ht2 .setup_ctrs = &p4_setup_ctrs, .check_ctrs = &p4_check_ctrs, .start = &p4_start, - .stop = &p4_stop + .stop = &p4_stop, + .shutdown = &p4_shutdown };#endif @@ -722,5 +717,6 @@ struct op_x86_model_spec const op_p4_spe .setup_ctrs = &p4_setup_ctrs, .check_ctrs = &p4_check_ctrs, .start = &p4_start, - .stop = &p4_stop + .stop = &p4_stop, + .shutdown = &p4_shutdown };Index:
linux/arch/i386/oprofile/op_model_ppro.c
===================================================================arch/i386/oprofile/op_model_ppro.c +53
-12@@ -22,10 +22,12 @@#define NUM_COUNTERS 2#define NUM_CONTROLS 2 +#define CTR_IS_RESERVED (msrs,c) (msrs->counters[(c)].addr ? 1 : 0)#define CTR_READ (l,h,msrs,c) do {rdmsr(msrs->counters[(c)].addr, (l), (h));} while (0)#define CTR_WRITE (l,msrs,c) do {wrmsr(msrs->counters[(c)].addr, -(u32)(l), -1);} while (0)#define CTR_OVERFLOWED (n) (!((n) & (1U<<31))) +#define CTRL_IS_RESERVED (msrs,c) (msrs->controls[(c)].addr ? 1 : 0)#define CTRL_READ (l,h,msrs,c) do {rdmsr((msrs->controls[(c)].addr), (l), (h));} while (0)#define CTRL_WRITE (l,h,msrs,c) do {wrmsr((msrs->controls[(c)].addr), (l), (h));} while (0)#define CTRL_SET_ACTIVE (n) (n |= (1<<22))@@ -41,11 +43,21 @@ static unsigned long reset_value[NUM_COUstatic void ppro_fill_in_addresses (struct op_msrs *const msrs) { - msrs->counters[0 ].addr =MSR_P6_PERFCTR0 ; - msrs->counters[1 ].addr =MSR_P6_PERFCTR1 ; +int i; + +for (i=0 ; i <NUM_COUNTERS ; i++) { +if (reserve_perfctr_nmi (MSR_P6_PERFCTR0 + i)) + msrs->counters[i].addr =MSR_P6_PERFCTR0 + i; +else + msrs->counters[i].addr =0 ; + } - msrs->controls[0 ].addr =MSR_P6_EVNTSEL0 ; - msrs->controls[1 ].addr =MSR_P6_EVNTSEL1 ; +for (i=0 ; i <NUM_CONTROLS ; i++) { +if (reserve_evntsel_nmi (MSR_P6_EVNTSEL0 + i)) + msrs->controls[i].addr =MSR_P6_EVNTSEL0 + i; +else + msrs->controls[i].addr =0 ; + } }@@ -56,6 +68,8 @@ static void ppro_setup_ctrs(struct op_ms/* clear all counters */ for (i =0 ; i <NUM_CONTROLS ; ++i) { +if (unlikely (!CTRL_IS_RESERVED (msrs,i))) +continue ;CTRL_READ (low, high, msrs, i);CTRL_CLEAR (low);CTRL_WRITE (low, high, msrs, i);@@ -63,12 +77,14 @@ static void ppro_setup_ctrs(struct op_ms/* avoid a false detection of ctr overflows in NMI handler */ for (i =0 ; i <NUM_COUNTERS ; ++i) { +if (unlikely (!CTR_IS_RESERVED (msrs,i))) +continue ;CTR_WRITE (1 , msrs, i); }/* enable active counters */ for (i =0 ; i <NUM_COUNTERS ; ++i) { -if (counter_config[i].enabled) { +if ((counter_config[i].enabled) && (CTR_IS_RESERVED (msrs,i))) { reset_value[i] = counter_config[i].count;CTR_WRITE (counter_config[i].count, msrs, i);@@ -81,6 +97,8 @@ static void ppro_setup_ctrs(struct op_msCTRL_SET_UM (low, counter_config[i].unit_mask);CTRL_SET_EVENT (low, counter_config[i].event);CTRL_WRITE (low, high, msrs, i); + }else { + reset_value[i] =0 ; } } }@@ -93,6 +111,8 @@ static int ppro_check_ctrs(struct pt_regint i;for (i =0 ; i <NUM_COUNTERS ; ++i) { +if (!reset_value[i]) +continue ;CTR_READ (low, high, msrs, i);if (CTR_OVERFLOWED (low)) {oprofile_add_sample (regs, i);@@ -118,18 +138,38 @@ static int ppro_check_ctrs(struct pt_regstatic void ppro_start (struct op_msrs const *const msrs) {unsigned int low,high; -CTRL_READ (low, high, msrs,0 ); -CTRL_SET_ACTIVE (low); -CTRL_WRITE (low, high, msrs,0 ); + +if (reset_value[0 ]) { +CTRL_READ (low, high, msrs,0 ); +CTRL_SET_ACTIVE (low); +CTRL_WRITE (low, high, msrs,0 ); + } }static void ppro_stop (struct op_msrs const *const msrs) {unsigned int low,high; -CTRL_READ (low, high, msrs,0 ); -CTRL_SET_INACTIVE (low); -CTRL_WRITE (low, high, msrs,0 ); + +if (reset_value[0 ]) { +CTRL_READ (low, high, msrs,0 ); +CTRL_SET_INACTIVE (low); +CTRL_WRITE (low, high, msrs,0 ); + } +} + +static void ppro_shutdown (struct op_msrs const *const msrs) +{ +int i; + +for (i =0 ; i <NUM_COUNTERS ; ++i) { +if (CTR_IS_RESERVED (msrs,i)) +release_perfctr_nmi (MSR_P6_PERFCTR0 + i); + } +for (i =0 ; i <NUM_CONTROLS ; ++i) { +if (CTRL_IS_RESERVED (msrs,i)) +release_evntsel_nmi (MSR_P6_EVNTSEL0 + i); + } }@@ -140,5 +180,6 @@ struct op_x86_model_spec const op_ppro_s .setup_ctrs = &ppro_setup_ctrs, .check_ctrs = &ppro_check_ctrs, .start = &ppro_start, - .stop = &ppro_stop + .stop = &ppro_stop, + .shutdown = &ppro_shutdown };Index:
linux/arch/i386/oprofile/op_x86_model.h
===================================================================
arch/i386/oprofile/op_x86_model.h struct op_x86_model_spec { · line 46
Quoted 7 lines
arch/i386/oprofile/op_x86_model.h +1
-0@@ -40,6 +40,7 @@ struct op_x86_model_spec { struct op_msrs const * const msrs);void (*start)(struct op_msrs const *const msrs);void (*stop)(struct op_msrs const *const msrs); +void (*shutdown)(struct op_msrs const *const msrs); };extern struct op_x86_model_spec const op_ppro_spec;
i hope code works the way it should ;D
---
-o--=O`C
#oo'L O
<___=E M