Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Remove the non-PAE-i386 code of Xen. The branches a...
details: https://anonhg.NetBSD.org/src/rev/4f5ed84a2f72
branches: trunk
changeset: 991703:4f5ed84a2f72
user: maxv <maxv%NetBSD.org@localhost>
date: Thu Jul 26 17:20:08 2018 +0000
description:
Remove the non-PAE-i386 code of Xen. The branches are reordered so that
__x86_64__ comes first, eg:
#if defined(PAE)
/* i386+PAE */
#elif defined(__x86_64__)
/* amd64 */
#else
/* i386 */
#endif
becomes
#ifdef __x86_64__
/* amd64 */
#else
/* i386+PAE */
#endif
Tested on i386pae-domU and amd64-dom0.
diffstat:
sys/arch/x86/x86/pmap.c | 32 ++++------------
sys/arch/xen/include/i386/hypercalls.h | 10 +----
sys/arch/xen/include/xenpmap.h | 12 +-----
sys/arch/xen/x86/cpu.c | 50 ++++++++----------------
sys/arch/xen/x86/x86_xpmap.c | 68 +++++++++++++--------------------
sys/arch/xen/x86/xen_pmap.c | 20 ++++-----
6 files changed, 63 insertions(+), 129 deletions(-)
diffs (truncated from 538 to 300 lines):
diff -r 61a31791c8c0 -r 4f5ed84a2f72 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c Thu Jul 26 16:22:49 2018 +0000
+++ b/sys/arch/x86/x86/pmap.c Thu Jul 26 17:20:08 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.294 2018/07/26 08:22:19 maxv Exp $ */
+/* $NetBSD: pmap.c,v 1.295 2018/07/26 17:20:08 maxv Exp $ */
/*
* Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -157,7 +157,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.294 2018/07/26 08:22:19 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.295 2018/07/26 17:20:08 maxv Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@@ -4540,7 +4540,7 @@
pte = pmap_pa2pte(pa) | PG_V | PG_RW;
pmap_pte_set(&pdep[i], pte);
-#if defined(XEN) && (defined(PAE) || defined(__x86_64__))
+#ifdef XEN
if (level == PTP_LEVELS && i >= PDIR_SLOT_KERN) {
if (__predict_true(
cpu_info_primary.ci_flags & CPUF_PRESENT)) {
@@ -4551,18 +4551,17 @@
* too early; update primary CPU
* PMD only (without locks)
*/
-#ifdef PAE
- pd_entry_t *cpu_pdep =
- &cpu_info_primary.ci_kpm_pdir[l2tol2(i)];
-#endif
#ifdef __x86_64__
pd_entry_t *cpu_pdep =
&cpu_info_primary.ci_kpm_pdir[i];
+#else
+ pd_entry_t *cpu_pdep =
+ &cpu_info_primary.ci_kpm_pdir[l2tol2(i)];
#endif
pmap_pte_set(cpu_pdep, pte);
}
}
-#endif /* XEN && (PAE || __x86_64__) */
+#endif
KASSERT(level != PTP_LEVELS || nkptp[level - 1] +
pl_i(VM_MIN_KERNEL_ADDRESS, level) == i);
@@ -4620,7 +4619,7 @@
needed_kptp[i] = target_nptp - nkptp[i];
}
-#if defined(XEN) && (defined(__x86_64__) || defined(PAE))
+#ifdef XEN
/* only pmap_kernel(), or the per-cpu map, has kernel entries */
cpm = kpm;
#else
@@ -4643,21 +4642,6 @@
/* nothing, kernel entries are never entered in user pmap */
#else
int pdkidx;
-#ifndef PAE
- /*
- * for PAE this is not needed, because pmap_alloc_level()
- * already did update the per-CPU tables
- */
- if (cpm != kpm) {
- for (pdkidx = PDIR_SLOT_KERN + old;
- pdkidx < PDIR_SLOT_KERN + nkptp[PTP_LEVELS - 1];
- pdkidx++) {
- pmap_pte_set(&kpm->pm_pdir[pdkidx],
- cpm->pm_pdir[pdkidx]);
- }
- pmap_pte_flush();
- }
-#endif /* !PAE */
mutex_enter(&pmaps_lock);
LIST_FOREACH(pm, &pmaps, pm_list) {
diff -r 61a31791c8c0 -r 4f5ed84a2f72 sys/arch/xen/include/i386/hypercalls.h
--- a/sys/arch/xen/include/i386/hypercalls.h Thu Jul 26 16:22:49 2018 +0000
+++ b/sys/arch/xen/include/i386/hypercalls.h Thu Jul 26 17:20:08 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hypercalls.h,v 1.15 2012/06/27 00:37:09 jym Exp $ */
+/* $NetBSD: hypercalls.h,v 1.16 2018/07/26 17:20:08 maxv Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -266,11 +266,7 @@
unsigned long pte_low, pte_hi;
pte_low = new_val & 0xffffffff;
-#ifdef PAE
pte_hi = new_val >> 32;
-#else
- pte_hi = 0;
-#endif
_hypercall(__HYPERVISOR_update_va_mapping,
_harg("1" (page_nr), "2" (pte_low), "3" (pte_hi), "4" (flags)),
@@ -319,11 +315,7 @@
unsigned long pte_low, pte_hi;
pte_low = new_val & 0xffffffff;
-#ifdef PAE
pte_hi = new_val >> 32;
-#else
- pte_hi = 0;
-#endif
_hypercall(__HYPERVISOR_update_va_mapping_otherdomain,
_harg("1" (page_nr), "2" (pte_low), "3" (pte_hi), "4" (flags), "5" (domid)),
diff -r 61a31791c8c0 -r 4f5ed84a2f72 sys/arch/xen/include/xenpmap.h
--- a/sys/arch/xen/include/xenpmap.h Thu Jul 26 16:22:49 2018 +0000
+++ b/sys/arch/xen/include/xenpmap.h Thu Jul 26 17:20:08 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xenpmap.h,v 1.39 2017/03/08 18:00:49 maxv Exp $ */
+/* $NetBSD: xenpmap.h,v 1.40 2018/07/26 17:20:08 maxv Exp $ */
/*
*
@@ -61,9 +61,7 @@
void pmap_map_recursive_entries(void);
void pmap_unmap_recursive_entries(void);
-#if defined(PAE) || defined(__x86_64__)
void xen_kpm_sync(struct pmap *, int);
-#endif /* PAE || __x86_64__ */
#define xpq_queue_pin_l1_table(pa) \
xpq_queue_pin_table(pa, MMUEXT_PIN_L1_TABLE)
@@ -135,11 +133,7 @@
mcl->args[2] = flags;
#else
mcl->args[1] = (new_val & 0xffffffff);
-#ifdef PAE
mcl->args[2] = (new_val >> 32);
-#else
- mcl->args[2] = 0;
-#endif
mcl->args[3] = flags;
#endif
}
@@ -157,11 +151,7 @@
mcl->args[3] = domid;
#else
mcl->args[1] = (new_val & 0xffffffff);
-#ifdef PAE
mcl->args[2] = (new_val >> 32);
-#else
- mcl->args[2] = 0;
-#endif
mcl->args[3] = flags;
mcl->args[4] = domid;
#endif
diff -r 61a31791c8c0 -r 4f5ed84a2f72 sys/arch/xen/x86/cpu.c
--- a/sys/arch/xen/x86/cpu.c Thu Jul 26 16:22:49 2018 +0000
+++ b/sys/arch/xen/x86/cpu.c Thu Jul 26 17:20:08 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.123 2018/07/24 12:24:45 bouyer Exp $ */
+/* $NetBSD: cpu.c,v 1.124 2018/07/26 17:20:09 maxv Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.123 2018/07/24 12:24:45 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.124 2018/07/26 17:20:09 maxv Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@@ -423,9 +423,7 @@
/* No user PGD mapped for this CPU yet */
ci->ci_xen_current_user_pgd = 0;
#endif
-#if defined(__x86_64__) || defined(PAE)
mutex_init(&ci->ci_kpm_mtx, MUTEX_DEFAULT, IPL_VM);
-#endif
pmap_reference(pmap_kernel());
ci->ci_pmap = pmap_kernel();
ci->ci_tlbstate = TLBSTATE_STALE;
@@ -984,11 +982,7 @@
initctx->ctrlreg[0] = pcb->pcb_cr0;
initctx->ctrlreg[1] = 0; /* "resuming" from kernel - no User cr3. */
initctx->ctrlreg[2] = (vaddr_t)targeteip;
-#ifdef PAE
initctx->ctrlreg[3] = xen_pfn_to_cr3(x86_btop(xpmap_ptom(ci->ci_pae_l3_pdirpa)));
-#else
- initctx->ctrlreg[3] = xen_pfn_to_cr3(x86_btop(xpmap_ptom(pcb->pcb_cr3)));
-#endif
initctx->ctrlreg[4] = /* CR4_PAE | */CR4_OSFXSR | CR4_OSXMMEXCPT;
/* Xen callbacks */
@@ -1118,19 +1112,16 @@
void
cpu_load_pmap(struct pmap *pmap, struct pmap *oldpmap)
{
- KASSERT(pmap != pmap_kernel());
-
-#if defined(__x86_64__) || defined(PAE)
struct cpu_info *ci = curcpu();
cpuid_t cid = cpu_index(ci);
+ KASSERT(pmap != pmap_kernel());
+
mutex_enter(&ci->ci_kpm_mtx);
/* make new pmap visible to xen_kpm_sync() */
kcpuset_atomic_set(pmap->pm_xen_ptp_cpus, cid);
-#endif
#ifdef i386
-#ifdef PAE
{
int i;
paddr_t l3_pd = xpmap_ptom_masked(ci->ci_pae_l3_pdirpa);
@@ -1141,10 +1132,7 @@
}
tlbflush();
}
-#else /* PAE */
- lcr3(pmap_pdirpa(pmap, 0));
-#endif /* PAE */
-#endif /* i386 */
+#endif
#ifdef __x86_64__
{
@@ -1176,15 +1164,13 @@
tlbflush();
}
-#endif /* __x86_64__ */
+#endif
-#if defined(__x86_64__) || defined(PAE)
/* old pmap no longer visible to xen_kpm_sync() */
if (oldpmap != pmap_kernel()) {
kcpuset_atomic_clear(oldpmap->pm_xen_ptp_cpus, cid);
}
mutex_exit(&ci->ci_kpm_mtx);
-#endif
}
/*
@@ -1209,27 +1195,26 @@
void
pmap_cpu_init_late(struct cpu_info *ci)
{
-#if defined(PAE) || defined(__x86_64__)
/*
* The BP has already its own PD page allocated during early
* MD startup.
*/
-#if defined(__x86_64__)
+#ifdef __x86_64__
/* Setup per-cpu normal_pdes */
int i;
extern pd_entry_t * const normal_pdes[];
for (i = 0;i < PTP_LEVELS - 1;i++) {
ci->ci_normal_pdes[i] = normal_pdes[i];
}
-#endif /* __x86_64__ */
+#endif
if (ci == &cpu_info_primary)
return;
KASSERT(ci != NULL);
-#if defined(PAE)
+#if defined(i386)
cpu_alloc_l3_page(ci);
KASSERT(ci->ci_pae_l3_pdirpa != 0);
@@ -1239,7 +1224,7 @@
ci->ci_pae_l3_pdir[i] =
xpmap_ptom_masked(pmap_kernel()->pm_pdirpa[i]) | PG_V;
}
-#endif /* PAE */
+#endif
ci->ci_kpm_pdir = (pd_entry_t *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
UVM_KMF_WIRED | UVM_KMF_ZERO | UVM_KMF_NOWAIT);
@@ -1251,7 +1236,7 @@
ci->ci_kpm_pdirpa = vtophys((vaddr_t)ci->ci_kpm_pdir);
KASSERT(ci->ci_kpm_pdirpa != 0);
-#if defined(__x86_64__)
+#ifdef __x86_64__
extern pt_entry_t xpmap_pg_nx;
/* Copy over the pmap_kernel() shadow L4 entries */
@@ -1260,7 +1245,7 @@
/* Recursive kernel mapping */
ci->ci_kpm_pdir[PDIR_SLOT_PTE] = xpmap_ptom_masked(ci->ci_kpm_pdirpa)
Home |
Main Index |
Thread Index |
Old Index