x86: mpparse and cstate need to use 32bit apic id Instead of going with mpc_config_processor struct. that field ony have 8 bits. We should not change that struct, because it is shared with mptable. Also need to increase MAX_APICS. Signed-off-by: Yinghai Lu Rather than using a fixed value of 512, make this scale with NR_CPUS (which obviously still doesn't cover all theoretically possible systems, but at least allows some build time control). Signed-off-by: Jan Beulich --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -865,7 +865,7 @@ static void set_cx( int get_cpu_id(u8 acpi_id) { int i; - u8 apic_id; + u32 apic_id; apic_id = x86_acpiid_to_apicid[acpi_id]; if ( apic_id == 0xff ) --- a/xen/arch/x86/mpparse.c +++ b/xen/arch/x86/mpparse.c @@ -99,7 +99,8 @@ static int mpc_record; static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] __initdata; /* Return xen's logical cpu_id of the new added cpu or <0 if error */ -static int __devinit MP_processor_info (struct mpc_config_processor *m) +static int __devinit MP_processor_info_x(struct mpc_config_processor *m, + u32 apicidx) { int ver, apicid, cpu = 0; physid_mask_t phys_cpu; @@ -107,7 +108,7 @@ static int __devinit MP_processor_info ( if (!(m->mpc_cpuflag & CPU_ENABLED)) return -EINVAL; - apicid = mpc_apic_id(m, translation_table[mpc_record]); + apicid = mpc_apic_id(m, apicidx, translation_table[mpc_record]); if (m->mpc_featureflag&(1<<0)) Dprintk(" Floating point unit present.\n"); @@ -159,7 +160,7 @@ static int __devinit MP_processor_info ( if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) { Dprintk(" Bootup CPU\n"); - boot_cpu_physical_apicid = m->mpc_apicid; + boot_cpu_physical_apicid = apicid; } ver = m->mpc_apicver; @@ -170,10 +171,10 @@ static int __devinit MP_processor_info ( if (ver == 0x0) { printk(KERN_WARNING "BIOS bug, APIC version is 0 for CPU#%d! " "fixing up to 0x10. (tell your hw vendor)\n", - m->mpc_apicid); + apicid); ver = 0x10; } - apic_version[m->mpc_apicid] = ver; + apic_version[apicid] = ver; phys_cpu = apicid_to_cpu_present(apicid); physids_or(phys_cpu_present_map, phys_cpu_present_map, phys_cpu); @@ -213,6 +214,11 @@ static int __devinit MP_processor_info ( return cpu; } +static int __devinit MP_processor_info(struct mpc_config_processor *m) +{ + return MP_processor_info_x(m, m->mpc_apicid); +} + static void __init MP_bus_info (struct mpc_config_bus *m) { char str[7]; @@ -839,7 +845,7 @@ int __devinit mp_register_lapic ( struct mpc_config_processor processor; int boot_cpu = 0; - if (MAX_APICS - id <= 0) { + if (MAX_APICS <= id) { printk(KERN_WARNING "Processor #%d invalid (max %d)\n", id, MAX_APICS); return -EINVAL; @@ -859,7 +865,7 @@ int __devinit mp_register_lapic ( processor.mpc_reserved[0] = 0; processor.mpc_reserved[1] = 0; - return MP_processor_info(&processor); + return MP_processor_info_x(&processor, id); } void mp_unregister_lapic(uint32_t apic_id, uint32_t cpu) --- a/xen/common/sched_sedf.c +++ b/xen/common/sched_sedf.c @@ -127,7 +127,6 @@ struct sedf_cpu_info { #define PERIOD_BEGIN(inf) ((inf)->deadl_abs - (inf)->period) -#define MIN(x,y) (((x)<(y))?(x):(y)) #define DIV_UP(x,y) (((x) + (y) - 1) / y) #define extra_runs(inf) ((inf->status) & 6) --- a/xen/include/asm-x86/mach-generic/mach_apic.h +++ b/xen/include/asm-x86/mach-generic/mach_apic.h @@ -28,15 +28,15 @@ static inline void enable_apic_mode(void extern u32 bios_cpu_apicid[]; -static inline int mpc_apic_id(struct mpc_config_processor *m, +static inline int mpc_apic_id(struct mpc_config_processor *m, u32 apicid, struct mpc_config_translation *translation_record) { printk("Processor #%d %d:%d APIC version %d\n", - m->mpc_apicid, + apicid, (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, m->mpc_apicver); - return (m->mpc_apicid); + return apicid; } static inline int multi_timer_check(int apic, int irq) --- a/xen/include/asm-x86/mpspec_def.h +++ b/xen/include/asm-x86/mpspec_def.h @@ -14,7 +14,7 @@ #define SMP_MAGIC_IDENT (('_'<<24)|('P'<<16)|('M'<<8)|'_') #define MAX_MPC_ENTRY 1024 -#define MAX_APICS 256 +#define MAX_APICS MAX(256, 4 * NR_CPUS) struct intel_mp_floating { --- a/xen/include/xen/kernel.h +++ b/xen/include/xen/kernel.h @@ -33,6 +33,13 @@ #define max_t(type,x,y) \ ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) +/* + * pre-processor, array size, and bit field width suitable variants; + * please don't use in "normal" expressions. + */ +#define MIN(x,y) ((x) < (y) ? (x) : (y)) +#define MAX(x,y) ((x) > (y) ? (x) : (y)) + /** * container_of - cast a member of a structure out to the containing structure *