Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Move the virtual address of the LAPIC page out of t...



details:   https://anonhg.NetBSD.org/src/rev/2a0af155ce08
branches:  trunk
changeset: 349148:2a0af155ce08
user:      maxv <maxv%NetBSD.org@localhost>
date:      Fri Nov 25 14:12:55 2016 +0000

description:
Move the virtual address of the LAPIC page out of the data segment on amd64
and i386. The old design was error-prone, and it didn't allow us to map the
data segment with large pages.

Now, the VA is allocated dynamically in the pmap bootstrap code, and entered
manually later. We go from using &local_apic to using *local_apic_va, and we
therefore need one more level of indirection in the asm code.

Discussed on tech-kern.

diffstat:

 sys/arch/amd64/amd64/locore.S      |  12 +-----------
 sys/arch/amd64/amd64/vector.S      |  14 +++++++++-----
 sys/arch/amd64/include/i82093reg.h |   5 +++--
 sys/arch/i386/i386/locore.S        |  14 ++------------
 sys/arch/i386/i386/vector.S        |  22 ++++++++++++++--------
 sys/arch/i386/include/i82093reg.h  |   5 +++--
 sys/arch/x86/include/i82489var.h   |   9 ++++-----
 sys/arch/x86/x86/lapic.c           |   6 +++---
 sys/arch/x86/x86/pmap.c            |  18 ++++++++++++++++--
 9 files changed, 55 insertions(+), 50 deletions(-)

diffs (truncated from 335 to 300 lines):

diff -r 30075b30c7fb -r 2a0af155ce08 sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S     Fri Nov 25 14:10:31 2016 +0000
+++ b/sys/arch/amd64/amd64/locore.S     Fri Nov 25 14:12:55 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.113 2016/11/11 11:34:51 maxv Exp $        */
+/*     $NetBSD: locore.S,v 1.114 2016/11/25 14:12:55 maxv Exp $        */
 
 /*
  * Copyright-o-rama!
@@ -313,16 +313,6 @@
  */
        .data
 
-#if NLAPIC > 0
-       .align  PAGE_SIZE
-       .globl  _C_LABEL(local_apic)
-
-       .type   _C_LABEL(local_apic), @object
-LABEL(local_apic)
-       .space  PAGE_SIZE
-END(local_apic)
-#endif
-
        .globl  _C_LABEL(tablesize)
        .globl  _C_LABEL(nox_flag)
        .globl  _C_LABEL(cputype)
diff -r 30075b30c7fb -r 2a0af155ce08 sys/arch/amd64/amd64/vector.S
--- a/sys/arch/amd64/amd64/vector.S     Fri Nov 25 14:10:31 2016 +0000
+++ b/sys/arch/amd64/amd64/vector.S     Fri Nov 25 14:12:55 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vector.S,v 1.47 2016/08/19 19:04:57 maxv Exp $ */
+/*     $NetBSD: vector.S,v 1.48 2016/11/25 14:12:55 maxv Exp $ */
 
 /*-
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -123,7 +123,8 @@
        pushq   $0
        pushq   $T_ASTFLT
        INTRENTRY
-       movl    $0,_C_LABEL(local_apic)+LAPIC_EOI
+       movq    _C_LABEL(local_apic_va),%rbx
+       movl    $0,LAPIC_EOI(%rbx)
        movl    CPUVAR(ILEVEL),%ebx
        cmpl    $IPL_HIGH,%ebx
        jae     2f
@@ -149,7 +150,8 @@
        INTRENTRY
        movl    $0xf,%eax
        movq    %rax,%cr8
-       movl    $0,_C_LABEL(local_apic)+LAPIC_EOI
+       movq    _C_LABEL(local_apic_va),%rbx
+       movl    $0,LAPIC_EOI(%rbx)
        sti
        call    _C_LABEL(ddb_ipi)
        xorl    %eax,%eax
@@ -174,7 +176,8 @@
        pushq   $0
        pushq   $T_ASTFLT
        INTRENTRY
-       movl    $0,_C_LABEL(local_apic)+LAPIC_EOI
+       movq    _C_LABEL(local_apic_va),%rbx
+       movl    $0,LAPIC_EOI(%rbx)
        movl    CPUVAR(ILEVEL),%ebx
        cmpl    $IPL_CLOCK,%ebx
        jae     2f
@@ -203,7 +206,8 @@
        pushq   $0
        pushq   $T_ASTFLT
        INTRENTRY
-       movl    $0,_C_LABEL(local_apic)+LAPIC_EOI
+       movq    _C_LABEL(local_apic_va),%rax
+       movl    $0,LAPIC_EOI(%rax)
        callq   _C_LABEL(pmap_tlb_intr)
        INTRFASTEXIT
 IDTVEC_END(intr_lapic_tlb)
diff -r 30075b30c7fb -r 2a0af155ce08 sys/arch/amd64/include/i82093reg.h
--- a/sys/arch/amd64/include/i82093reg.h        Fri Nov 25 14:10:31 2016 +0000
+++ b/sys/arch/amd64/include/i82093reg.h        Fri Nov 25 14:12:55 2016 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: i82093reg.h,v 1.6 2016/08/11 15:45:39 maxv Exp $ */
+/*      $NetBSD: i82093reg.h,v 1.7 2016/11/25 14:12:55 maxv Exp $ */
 
 #include <x86/i82093reg.h>
 
@@ -9,7 +9,8 @@
 #endif
 
 #define ioapic_asm_ack(num) \
-       movl    $0,_C_LABEL(local_apic)+LAPIC_EOI
+       movq    _C_LABEL(local_apic_va),%rax    ; \
+       movl    $0,LAPIC_EOI(%rax)
 
 #ifdef MULTIPROCESSOR
 
diff -r 30075b30c7fb -r 2a0af155ce08 sys/arch/i386/i386/locore.S
--- a/sys/arch/i386/i386/locore.S       Fri Nov 25 14:10:31 2016 +0000
+++ b/sys/arch/i386/i386/locore.S       Fri Nov 25 14:12:55 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.140 2016/11/11 11:34:51 maxv Exp $        */
+/*     $NetBSD: locore.S,v 1.141 2016/11/25 14:12:55 maxv Exp $        */
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.140 2016/11/11 11:34:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.141 2016/11/25 14:12:55 maxv Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_copy_symtab.h"
@@ -270,16 +270,6 @@
  */
        .data
 
-#if NLAPIC > 0
-       .align  PAGE_SIZE
-       .globl  _C_LABEL(local_apic)
-
-       .type   _C_LABEL(local_apic), @object
-LABEL(local_apic)
-       .space  PAGE_SIZE
-END(local_apic)
-#endif
-
        .globl  _C_LABEL(tablesize)
        .globl  _C_LABEL(nox_flag)
        .globl  _C_LABEL(cputype)
diff -r 30075b30c7fb -r 2a0af155ce08 sys/arch/i386/i386/vector.S
--- a/sys/arch/i386/i386/vector.S       Fri Nov 25 14:10:31 2016 +0000
+++ b/sys/arch/i386/i386/vector.S       Fri Nov 25 14:12:55 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vector.S,v 1.67 2016/11/13 12:38:14 maxv Exp $ */
+/*     $NetBSD: vector.S,v 1.68 2016/11/25 14:12:55 maxv Exp $ */
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.67 2016/11/13 12:38:14 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.68 2016/11/25 14:12:55 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -162,7 +162,8 @@
        pushl   $0
        pushl   $T_ASTFLT
        INTRENTRY
-       movl    $0,_C_LABEL(local_apic)+LAPIC_EOI
+       movl    _C_LABEL(local_apic_va),%ebx
+       movl    $0,LAPIC_EOI(%ebx)
        movl    CPUVAR(ILEVEL),%ebx
        cmpl    $IPL_HIGH,%ebx
        jae     2f
@@ -188,7 +189,8 @@
        pushl   $0
        pushl   $T_ASTFLT
        INTRENTRY
-       movl    $0,_C_LABEL(local_apic)+LAPIC_EOI
+       movl    _C_LABEL(local_apic_va),%eax
+       movl    $0,LAPIC_EOI(%eax)
        call    _C_LABEL(pmap_tlb_intr)
        INTRFASTEXIT
 IDTVEC_END(intr_lapic_tlb)
@@ -205,12 +207,15 @@
        movzwl  (%eax),%eax
        GET_TSS
        pushl   %eax
-       movl    $0xff,_C_LABEL(local_apic)+LAPIC_TPRI
-       movl    $0,_C_LABEL(local_apic)+LAPIC_EOI
+       movl    _C_LABEL(local_apic_va),%ebx
+       movl    $0xff,LAPIC_TPRI(%ebx)
+       movl    _C_LABEL(local_apic_va),%ebx
+       movl    $0,LAPIC_EOI(%ebx)
        sti
        call    _C_LABEL(ddb_ipi_tss)
        addl    $4,%esp
-       movl    $0,_C_LABEL(local_apic)+LAPIC_TPRI
+       movl    _C_LABEL(local_apic_va),%ebx
+       movl    $0,LAPIC_TPRI(%ebx)
        iret
        jmp     1b
 IDTVEC_END(intrddbipi)
@@ -233,7 +238,8 @@
        pushl   $0
        pushl   $T_ASTFLT
        INTRENTRY
-       movl    $0,_C_LABEL(local_apic)+LAPIC_EOI
+       movl    _C_LABEL(local_apic_va),%ebx
+       movl    $0,LAPIC_EOI(%ebx)
        movl    CPUVAR(ILEVEL),%ebx
        cmpl    $IPL_CLOCK,%ebx
        jae     2f
diff -r 30075b30c7fb -r 2a0af155ce08 sys/arch/i386/include/i82093reg.h
--- a/sys/arch/i386/include/i82093reg.h Fri Nov 25 14:10:31 2016 +0000
+++ b/sys/arch/i386/include/i82093reg.h Fri Nov 25 14:12:55 2016 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: i82093reg.h,v 1.8 2008/07/03 14:02:25 drochner Exp $ */
+/*      $NetBSD: i82093reg.h,v 1.9 2016/11/25 14:12:55 maxv Exp $ */
 
 #include <x86/i82093reg.h>
 
@@ -9,7 +9,8 @@
 #endif
 
 #define ioapic_asm_ack(num) \
-       movl    $0,_C_LABEL(local_apic)+LAPIC_EOI
+       movl    _C_LABEL(local_apic_va),%eax    ; \
+       movl    $0,LAPIC_EOI(%eax)
 
 #ifdef MULTIPROCESSOR
 
diff -r 30075b30c7fb -r 2a0af155ce08 sys/arch/x86/include/i82489var.h
--- a/sys/arch/x86/include/i82489var.h  Fri Nov 25 14:10:31 2016 +0000
+++ b/sys/arch/x86/include/i82489var.h  Fri Nov 25 14:12:55 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i82489var.h,v 1.15 2016/10/16 10:51:31 maxv Exp $      */
+/*     $NetBSD: i82489var.h,v 1.16 2016/11/25 14:12:56 maxv Exp $      */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -40,20 +40,19 @@
 static __inline void i82489_writereg(int, uint32_t);
 
 #ifdef _KERNEL
-extern volatile uint32_t local_apic[];
+extern volatile vaddr_t local_apic_va;
 #endif
 
 static __inline uint32_t
 i82489_readreg(int reg)
 {
-       return *((volatile uint32_t *)(((volatile uint8_t *)local_apic)
-           + reg));
+       return *((volatile uint32_t *)(local_apic_va + reg));
 }
 
 static __inline void
 i82489_writereg(int reg, uint32_t val)
 {
-       *((volatile uint32_t *)(((volatile uint8_t *)local_apic) + reg)) = val;
+       *((volatile uint32_t *)(local_apic_va + reg)) = val;
 }
 
 #define lapic_cpu_number()     (i82489_readreg(LAPIC_ID) >> LAPIC_ID_SHIFT)
diff -r 30075b30c7fb -r 2a0af155ce08 sys/arch/x86/x86/lapic.c
--- a/sys/arch/x86/x86/lapic.c  Fri Nov 25 14:10:31 2016 +0000
+++ b/sys/arch/x86/x86/lapic.c  Fri Nov 25 14:12:55 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lapic.c,v 1.53 2016/10/15 09:50:27 maxv Exp $  */
+/*     $NetBSD: lapic.c,v 1.54 2016/11/25 14:12:56 maxv Exp $  */
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.53 2016/10/15 09:50:27 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.54 2016/11/25 14:12:56 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"                /* for MPDEBUG */
@@ -93,7 +93,7 @@
 lapic_map(paddr_t lapic_base)
 {
        pt_entry_t *pte;
-       vaddr_t va = (vaddr_t)&local_apic;
+       vaddr_t va = local_apic_va;
 
        /*
         * If the CPU has an APIC MSR, use it and ignore the supplied value:
diff -r 30075b30c7fb -r 2a0af155ce08 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c   Fri Nov 25 14:10:31 2016 +0000
+++ b/sys/arch/x86/x86/pmap.c   Fri Nov 25 14:12:55 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.227 2016/11/17 16:32:06 maxv Exp $  */
+/*     $NetBSD: pmap.c,v 1.228 2016/11/25 14:12:56 maxv Exp $  */
 
 /*-
  * Copyright (c) 2008, 2010, 2016 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.227 2016/11/17 16:32:06 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.228 2016/11/25 14:12:56 maxv Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -483,6 +483,11 @@
 static vaddr_t virtual_end __read_mostly;      /* VA of last free KVA */
 
 /*
+ * LAPIC virtual address.
+ */
+volatile vaddr_t local_apic_va;



Home | Main Index | Thread Index | Old Index