From: "Jan Beulich" Subject: [PATCH] x86/LAPIC: drop support for non-integrated APIC Date: Wed, 24 Sep 2014 16:39:53 +0100 Message-ID: <542301E902000078000386E5@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part221759D9.0__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XWofc-00021v-Cz for xen-devel@lists.xenproject.org; Wed, 24 Sep 2014 15:39:56 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part221759D9.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline We never really supported such, even in the 32-bit days. As a minor extra thing move the APIC_SELF_IPI definition out of the middle of Divider COnfiguration Register ones. Signed-off-by: Jan Beulich --- a/xen/arch/x86/apic.c +++ b/xen/arch/x86/apic.c @@ -145,13 +145,9 @@ int get_physical_broadcast(void) =20 int get_maxlvt(void) { - unsigned int v, ver, maxlvt; + unsigned int v =3D apic_read(APIC_LVR); =20 - v =3D apic_read(APIC_LVR); - ver =3D GET_APIC_VERSION(v); - /* 82489DXs do not report # of LVT entries. */ - maxlvt =3D APIC_INTEGRATED(ver) ? GET_APIC_MAXLVT(v) : 2; - return maxlvt; + return GET_APIC_MAXLVT(v); } =20 void clear_local_APIC(void) @@ -217,12 +213,9 @@ void clear_local_APIC(void) if (maxlvt >=3D 6) apic_write_around(APIC_CMCI, APIC_LVT_MASKED); =20 - v =3D GET_APIC_VERSION(apic_read(APIC_LVR)); - if (APIC_INTEGRATED(v)) { /* !82489DX */ - if (maxlvt > 3) /* Due to Pentium errata 3AP and 11AP. */ - apic_write(APIC_ESR, 0); - apic_read(APIC_ESR); - } + if (maxlvt > 3) /* Due to Pentium errata 3AP and 11AP. */ + apic_write(APIC_ESR, 0); + apic_read(APIC_ESR); } =20 void __init connect_bsp_APIC(void) @@ -477,10 +470,7 @@ void __init init_bsp_APIC(void) * Set up the virtual wire mode. */ apic_write_around(APIC_LVT0, APIC_DM_EXTINT); - value =3D APIC_DM_NMI; - if (!APIC_INTEGRATED(ver)) /* 82489DX */ - value |=3D APIC_LVT_LEVEL_TRIGGER; - apic_write_around(APIC_LVT1, value); + apic_write_around(APIC_LVT1, APIC_DM_NMI); } =20 static void apic_pm_activate(void) @@ -555,7 +545,7 @@ void __devinit setup_local_APIC(void) /* * Double-check whether this APIC is really registered. */ - if (!apic_id_registered()) + if (!APIC_INTEGRATED(ver) || !apic_id_registered()) BUG(); =20 /* @@ -671,11 +661,9 @@ void __devinit setup_local_APIC(void) value =3D APIC_DM_NMI; else value =3D APIC_DM_NMI | APIC_LVT_MASKED; - if (!APIC_INTEGRATED(ver)) /* 82489DX */ - value |=3D APIC_LVT_LEVEL_TRIGGER; apic_write_around(APIC_LVT1, value); =20 - if (APIC_INTEGRATED(ver) && !esr_disable) { /* !82489DX */ + if (!esr_disable) { maxlvt =3D get_maxlvt(); if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */ apic_write(APIC_ESR, 0); @@ -694,16 +682,13 @@ void __devinit setup_local_APIC(void) "vector: %#lx after: %#lx\n", oldvalue, value); } else { - if (esr_disable) =20 - /*=20 - * Something untraceble is creating bad interrupts on=20 - * secondary quads ... for the moment, just leave the - * ESR disabled - we can't do anything useful with the - * errors anyway - mbligh - */ - printk("Leaving ESR disabled.\n"); - else - printk("No ESR for 82489DX.\n"); + /* + * Something untraceble is creating bad interrupts on + * secondary quads ... for the moment, just leave the + * ESR disabled - we can't do anything useful with the + * errors anyway - mbligh + */ + printk("Leaving ESR disabled.\n"); } =20 if (nmi_watchdog =3D=3D NMI_LOCAL_APIC) @@ -1096,13 +1081,10 @@ static void __init wait_8254_wraparound( =20 static void __setup_APIC_LVTT(unsigned int clocks) { - unsigned int lvtt_value, tmp_value, ver; + unsigned int lvtt_value, tmp_value; =20 - ver =3D GET_APIC_VERSION(apic_read(APIC_LVR)); /* NB. Xen uses local APIC timer in one-shot mode. */ lvtt_value =3D /*APIC_TIMER_MODE_PERIODIC |*/ LOCAL_TIMER_VECTOR; - if (!APIC_INTEGRATED(ver)) - lvtt_value |=3D SET_APIC_TIMER_BASE(APIC_TIMER_BASE_DIV); =20 if ( tdt_enabled ) { --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -391,17 +391,17 @@ extern void *stack_start; static int wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip) { unsigned long send_status =3D 0, accept_status =3D 0; - int maxlvt, timeout, num_starts, i; + int maxlvt, timeout, i; =20 /* * Be paranoid about clearing APIC errors. */ - if ( APIC_INTEGRATED(apic_version[phys_apicid]) ) - { - apic_read_around(APIC_SPIV); - apic_write(APIC_ESR, 0); - apic_read(APIC_ESR); - } + if ( !APIC_INTEGRATED(apic_version[phys_apicid]) ) + return -ENODEV; + + apic_read_around(APIC_SPIV); + apic_write(APIC_ESR, 0); + apic_read(APIC_ESR); =20 Dprintk("Asserting INIT.\n"); =20 @@ -448,20 +448,9 @@ static int wakeup_secondary_cpu(int phys udelay(10); } =20 - /* - * Should we send STARTUP IPIs ? - * - * Determine this based on the APIC version. - * If we don't have an integrated APIC, don't send the STARTUP IPIs. - */ - num_starts =3D APIC_INTEGRATED(apic_version[phys_apicid]) ? 2 : 0; - - /* Run STARTUP IPI loop. */ - Dprintk("#startup loops: %d.\n", num_starts); - maxlvt =3D get_maxlvt(); =20 - for ( i =3D 0; i < num_starts; i++ ) + for ( i =3D 0; i < 2; i++ ) { Dprintk("Sending STARTUP #%d.\n", i+1); apic_read_around(APIC_SPIV); @@ -761,8 +750,8 @@ void __init smp_prepare_cpus(unsigned in } =20 /* If we couldn't find a local APIC, then get out of here now! */ - if ( APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid]) - && !cpu_has_apic ) + if ( !APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid]) + || !cpu_has_apic ) { printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n", boot_cpu_physical_apicid); --- a/xen/include/asm-x86/apicdef.h +++ b/xen/include/asm-x86/apicdef.h @@ -84,12 +84,6 @@ #define APIC_LVT0 0x350 #define APIC_CMCI 0x2F0 =20 -#define APIC_LVT_TIMER_BASE_MASK (0x3<<18) -#define GET_APIC_TIMER_BASE(x) (((x)>>18)&= 0x3) -#define SET_APIC_TIMER_BASE(x) (((x)<<18))= -#define APIC_TIMER_BASE_CLKIN 0x0 -#define APIC_TIMER_BASE_TMBASE 0x1 -#define APIC_TIMER_BASE_DIV 0x2 #define APIC_TIMER_MODE_MASK (0x3<<17) #define APIC_TIMER_MODE_ONESHOT (0x0<<17) #define APIC_TIMER_MODE_PERIODIC (0x1<<17) @@ -110,10 +104,6 @@ #define APIC_TMICT 0x380 #define APIC_TMCCT 0x390 #define APIC_TDCR 0x3E0 - -/* Only available in x2APIC mode */ -#define APIC_SELF_IPI 0x3F0 - #define APIC_TDR_DIV_TMBASE (1<<2) #define APIC_TDR_DIV_1 0xB #define APIC_TDR_DIV_2 0x0 @@ -124,6 +114,9 @@ #define APIC_TDR_DIV_64 0x9 #define APIC_TDR_DIV_128 0xA =20 +/* Only available in x2APIC mode */ +#define APIC_SELF_IPI 0x3F0 + #define APIC_BASE (fix_to_virt(FIX_APIC_BASE)) =20 /* It's only used in x2APIC mode of an x2APIC unit. */ --=__Part221759D9.0__= Content-Type: text/plain; name="x86-APIC-drop-non-integrated.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-APIC-drop-non-integrated.patch" x86/LAPIC: drop support for non-integrated APIC=0A=0AWe never really = supported such, even in the 32-bit days.=0A=0AAs a minor extra thing move = the APIC_SELF_IPI definition out of the=0Amiddle of Divider COnfiguration = Register ones.=0A=0ASigned-off-by: Jan Beulich =0A=0A---= a/xen/arch/x86/apic.c=0A+++ b/xen/arch/x86/apic.c=0A@@ -145,13 +145,9 @@ = int get_physical_broadcast(void)=0A =0A int get_maxlvt(void)=0A {=0A- = unsigned int v, ver, maxlvt;=0A+ unsigned int v =3D apic_read(APIC_LVR);= =0A =0A- v =3D apic_read(APIC_LVR);=0A- ver =3D GET_APIC_VERSION(v);= =0A- /* 82489DXs do not report # of LVT entries. */=0A- maxlvt =3D = APIC_INTEGRATED(ver) ? GET_APIC_MAXLVT(v) : 2;=0A- return maxlvt;=0A+ = return GET_APIC_MAXLVT(v);=0A }=0A =0A void clear_local_APIC(void)=0A@@ = -217,12 +213,9 @@ void clear_local_APIC(void)=0A if (maxlvt >=3D 6)=0A = apic_write_around(APIC_CMCI, APIC_LVT_MASKED);=0A =0A- v =3D = GET_APIC_VERSION(apic_read(APIC_LVR));=0A- if (APIC_INTEGRATED(v)) { = /* !82489DX */=0A- if (maxlvt > 3) /* Due to Pentium errata = 3AP and 11AP. */=0A- apic_write(APIC_ESR, 0);=0A- = apic_read(APIC_ESR);=0A- }=0A+ if (maxlvt > 3) /* Due to = Pentium errata 3AP and 11AP. */=0A+ apic_write(APIC_ESR, 0);=0A+ = apic_read(APIC_ESR);=0A }=0A =0A void __init connect_bsp_APIC(void)=0A@@ = -477,10 +470,7 @@ void __init init_bsp_APIC(void)=0A * Set up the = virtual wire mode.=0A */=0A apic_write_around(APIC_LVT0, = APIC_DM_EXTINT);=0A- value =3D APIC_DM_NMI;=0A- if (!APIC_INTEGRATED(= ver)) /* 82489DX */=0A- value |=3D APIC_LVT_LEVEL_TRIGG= ER;=0A- apic_write_around(APIC_LVT1, value);=0A+ apic_write_around(AP= IC_LVT1, APIC_DM_NMI);=0A }=0A =0A static void apic_pm_activate(void)=0A@@ = -555,7 +545,7 @@ void __devinit setup_local_APIC(void)=0A /*=0A * = Double-check whether this APIC is really registered.=0A */=0A- if = (!apic_id_registered())=0A+ if (!APIC_INTEGRATED(ver) || !apic_id_regist= ered())=0A BUG();=0A =0A /*=0A@@ -671,11 +661,9 @@ void = __devinit setup_local_APIC(void)=0A value =3D APIC_DM_NMI;=0A = else=0A value =3D APIC_DM_NMI | APIC_LVT_MASKED;=0A- if = (!APIC_INTEGRATED(ver)) /* 82489DX */=0A- value |=3D APIC_LVT_L= EVEL_TRIGGER;=0A apic_write_around(APIC_LVT1, value);=0A =0A- if = (APIC_INTEGRATED(ver) && !esr_disable) { /* !82489DX */=0A+ if = (!esr_disable) {=0A maxlvt =3D get_maxlvt();=0A if (maxlvt = > 3) /* Due to the Pentium erratum 3AP. */=0A apic_write(AP= IC_ESR, 0);=0A@@ -694,16 +682,13 @@ void __devinit setup_local_APIC(void)= =0A "vector: %#lx after: %#lx\n",=0A = oldvalue, value);=0A } else {=0A- if (esr_disable) = =0A- /* =0A- * Something untraceble is creating = bad interrupts on =0A- * secondary quads ... for the moment, = just leave the=0A- * ESR disabled - we can't do anything = useful with the=0A- * errors anyway - mbligh=0A- = */=0A- printk("Leaving ESR disabled.\n");=0A- else=0A- = printk("No ESR for 82489DX.\n");=0A+ /*=0A+ * = Something untraceble is creating bad interrupts on=0A+ * secondary = quads ... for the moment, just leave the=0A+ * ESR disabled - we = can't do anything useful with the=0A+ * errors anyway - mbligh=0A+ = */=0A+ printk("Leaving ESR disabled.\n");=0A }=0A =0A = if (nmi_watchdog =3D=3D NMI_LOCAL_APIC)=0A@@ -1096,13 +1081,10 @@ static = void __init wait_8254_wraparound(=0A =0A static void __setup_APIC_LVTT(unsi= gned int clocks)=0A {=0A- unsigned int lvtt_value, tmp_value, ver;=0A+ = unsigned int lvtt_value, tmp_value;=0A =0A- ver =3D GET_APIC_VERSION(a= pic_read(APIC_LVR));=0A /* NB. Xen uses local APIC timer in one-shot = mode. */=0A lvtt_value =3D /*APIC_TIMER_MODE_PERIODIC |*/ LOCAL_TIMER_V= ECTOR;=0A- if (!APIC_INTEGRATED(ver))=0A- lvtt_value |=3D = SET_APIC_TIMER_BASE(APIC_TIMER_BASE_DIV);=0A =0A if ( tdt_enabled )=0A = {=0A--- a/xen/arch/x86/smpboot.c=0A+++ b/xen/arch/x86/smpboot.c=0A@@ = -391,17 +391,17 @@ extern void *stack_start;=0A static int wakeup_secondary= _cpu(int phys_apicid, unsigned long start_eip)=0A {=0A unsigned long = send_status =3D 0, accept_status =3D 0;=0A- int maxlvt, timeout, = num_starts, i;=0A+ int maxlvt, timeout, i;=0A =0A /*=0A * Be = paranoid about clearing APIC errors.=0A */=0A- if ( APIC_INTEGRATED= (apic_version[phys_apicid]) )=0A- {=0A- apic_read_around(APIC_SPI= V);=0A- apic_write(APIC_ESR, 0);=0A- apic_read(APIC_ESR);=0A-= }=0A+ if ( !APIC_INTEGRATED(apic_version[phys_apicid]) )=0A+ = return -ENODEV;=0A+=0A+ apic_read_around(APIC_SPIV);=0A+ apic_write(A= PIC_ESR, 0);=0A+ apic_read(APIC_ESR);=0A =0A Dprintk("Asserting = INIT.\n");=0A =0A@@ -448,20 +448,9 @@ static int wakeup_secondary_cpu(int = phys=0A udelay(10);=0A }=0A =0A- /*=0A- * Should we = send STARTUP IPIs ?=0A- *=0A- * Determine this based on the APIC = version.=0A- * If we don't have an integrated APIC, don't send the = STARTUP IPIs.=0A- */=0A- num_starts =3D APIC_INTEGRATED(apic_version= [phys_apicid]) ? 2 : 0;=0A-=0A- /* Run STARTUP IPI loop. */=0A- = Dprintk("#startup loops: %d.\n", num_starts);=0A-=0A maxlvt =3D = get_maxlvt();=0A =0A- for ( i =3D 0; i < num_starts; i++ )=0A+ for ( = i =3D 0; i < 2; i++ )=0A {=0A Dprintk("Sending STARTUP = #%d.\n", i+1);=0A apic_read_around(APIC_SPIV);=0A@@ -761,8 +750,8 = @@ void __init smp_prepare_cpus(unsigned in=0A }=0A =0A /* If we = couldn't find a local APIC, then get out of here now! */=0A- if ( = APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])=0A- && = !cpu_has_apic )=0A+ if ( !APIC_INTEGRATED(apic_version[boot_cpu_physical= _apicid])=0A+ || !cpu_has_apic )=0A {=0A printk(KERN_ER= R "BIOS bug, local APIC #%d not detected!...\n",=0A = boot_cpu_physical_apicid);=0A--- a/xen/include/asm-x86/apicdef.h=0A+++ = b/xen/include/asm-x86/apicdef.h=0A@@ -84,12 +84,6 @@=0A #define = APIC_LVT0 0x350=0A #define APIC_CMCI 0x2F0=0A = =0A-#define APIC_LVT_TIMER_BASE_MASK = (0x3<<18)=0A-#define GET_APIC_TIMER_BASE(x) = (((x)>>18)&0x3)=0A-#define SET_APIC_TIMER_BASE(x) = (((x)<<18))=0A-#define APIC_TIMER_BASE_CLKIN = 0x0=0A-#define APIC_TIMER_BASE_TMBASE 0x1=0A-#def= ine APIC_TIMER_BASE_DIV 0x2=0A #define = APIC_TIMER_MODE_MASK (0x3<<17)=0A #define = APIC_TIMER_MODE_ONESHOT (0x0<<17)=0A #define = APIC_TIMER_MODE_PERIODIC (0x1<<17)=0A@@ -110,10 +104,6 @@=0A = #define APIC_TMICT 0x380=0A #define APIC_TMCCT = 0x390=0A #define APIC_TDCR 0x3E0=0A-=0A-/* Only = available in x2APIC mode */=0A-#define APIC_SELF_IPI = 0x3F0=0A-=0A #define APIC_TDR_DIV_TMBASE (1<<2)=0A = #define APIC_TDR_DIV_1 0xB=0A #define = APIC_TDR_DIV_2 0x0=0A@@ -124,6 +114,9 @@=0A #define = APIC_TDR_DIV_64 0x9=0A #define APIC_TDR_DIV_128 = 0xA=0A =0A+/* Only available in x2APIC mode */=0A+#define = APIC_SELF_IPI 0x3F0=0A+=0A #define APIC_BASE (fix_to_virt(FIX_APIC_BASE))= =0A =0A /* It's only used in x2APIC mode of an x2APIC unit. */=0A --=__Part221759D9.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part221759D9.0__=--