Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Kenter local_apic_va to a fake physical page, becau...
details: https://anonhg.NetBSD.org/src/rev/2312f2e5443e
branches: trunk
changeset: 349473:2312f2e5443e
user: maxv <maxv%NetBSD.org@localhost>
date: Sun Dec 11 08:31:53 2016 +0000
description:
Kenter local_apic_va to a fake physical page, because our x86
implementation expects this va to be valid even if no lapic is present;
which probably is a bug in itself, but let's just reproduce the old
behavior and rehide that bug.
diffstat:
sys/arch/amd64/amd64/machdep.c | 10 ++++++++--
sys/arch/i386/i386/machdep.c | 10 ++++++++--
sys/arch/x86/x86/pmap.c | 17 ++++++++++++++---
3 files changed, 30 insertions(+), 7 deletions(-)
diffs (124 lines):
diff -r b2b6eac62550 -r 2312f2e5443e sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c Sun Dec 11 08:30:39 2016 +0000
+++ b/sys/arch/amd64/amd64/machdep.c Sun Dec 11 08:31:53 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.235 2016/12/09 17:57:24 maxv Exp $ */
+/* $NetBSD: machdep.c,v 1.236 2016/12/11 08:31:53 maxv Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.235 2016/12/09 17:57:24 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.236 2016/12/11 08:31:53 maxv Exp $");
/* #define XENDEBUG_LOW */
@@ -1537,6 +1537,7 @@
init_x86_64(paddr_t first_avail)
{
extern void consinit(void);
+ extern paddr_t local_apic_pa;
struct region_descriptor region;
struct mem_segment_descriptor *ldt_segp;
int x;
@@ -1639,6 +1640,11 @@
kpreempt_disable();
+ pmap_kenter_pa(local_apic_va, local_apic_pa,
+ VM_PROT_READ|VM_PROT_WRITE, 0);
+ pmap_update(pmap_kernel());
+ memset((void *)local_apic_va, 0, PAGE_SIZE);
+
pmap_kenter_pa(idt_vaddr, idt_paddr, VM_PROT_READ|VM_PROT_WRITE, 0);
pmap_kenter_pa(gdt_vaddr, gdt_paddr, VM_PROT_READ|VM_PROT_WRITE, 0);
pmap_kenter_pa(ldt_vaddr, ldt_paddr, VM_PROT_READ|VM_PROT_WRITE, 0);
diff -r b2b6eac62550 -r 2312f2e5443e sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Sun Dec 11 08:30:39 2016 +0000
+++ b/sys/arch/i386/i386/machdep.c Sun Dec 11 08:31:53 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.764 2016/11/15 15:00:55 maxv Exp $ */
+/* $NetBSD: machdep.c,v 1.765 2016/12/11 08:31:53 maxv Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.764 2016/11/15 15:00:55 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.765 2016/12/11 08:31:53 maxv Exp $");
#include "opt_beep.h"
#include "opt_compat_ibcs2.h"
@@ -1131,6 +1131,7 @@
init386(paddr_t first_avail)
{
extern void consinit(void);
+ extern paddr_t local_apic_pa;
int x;
#ifndef XEN
union descriptor *tgdt;
@@ -1301,6 +1302,11 @@
cpu_info_primary.ci_pmap = pmap_kernel();
#endif
+ pmap_kenter_pa(local_apic_va, local_apic_pa,
+ VM_PROT_READ|VM_PROT_WRITE, 0);
+ pmap_update(pmap_kernel());
+ memset((void *)local_apic_va, 0, PAGE_SIZE);
+
pmap_kenter_pa(idt_vaddr, idt_paddr, VM_PROT_READ|VM_PROT_WRITE, 0);
pmap_kenter_pa(gdt_vaddr, gdt_paddr, VM_PROT_READ|VM_PROT_WRITE, 0);
pmap_kenter_pa(ldt_vaddr, ldt_paddr, VM_PROT_READ|VM_PROT_WRITE, 0);
diff -r b2b6eac62550 -r 2312f2e5443e sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c Sun Dec 11 08:30:39 2016 +0000
+++ b/sys/arch/x86/x86/pmap.c Sun Dec 11 08:31:53 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.229 2016/11/25 14:26:53 maxv Exp $ */
+/* $NetBSD: pmap.c,v 1.230 2016/12/11 08:31:53 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.229 2016/11/25 14:26:53 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.230 2016/12/11 08:31:53 maxv Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@@ -483,9 +483,10 @@
static vaddr_t virtual_end __read_mostly; /* VA of last free KVA */
/*
- * LAPIC virtual address.
+ * LAPIC virtual address, and fake physical address.
*/
volatile vaddr_t local_apic_va;
+paddr_t local_apic_pa;
/*
* pool that pmap structures are allocated from
@@ -1467,7 +1468,17 @@
static void
pmap_init_lapic(void)
{
+ /*
+ * On CPUs that have no LAPIC, local_apic_va is never kentered. But our
+ * x86 implementation relies a lot on this address to be valid; so just
+ * allocate a fake physical page that will be kentered into
+ * local_apic_va by machdep.
+ *
+ * If the LAPIC is present, the va will be remapped somewhere else
+ * later in lapic_map.
+ */
local_apic_va = pmap_bootstrap_valloc(1);
+ local_apic_pa = pmap_bootstrap_palloc(1);
}
#ifdef __HAVE_DIRECT_MAP
Home |
Main Index |
Thread Index |
Old Index