Commit Graph

250 Commits

Author SHA1 Message Date
bouyer 92f2ec54ee Re-apply
http://mail-index.netbsd.org/source-changes/2012/11/25/msg039125.html
http://mail-index.netbsd.org/source-changes/2012/11/25/msg039126.html
they're not involved in i386 domU hang shown by ATF.
2013-01-13 21:01:05 +00:00
bouyer 8b981bb8d6 Revert these commits from november 2012:
http://mail-index.netbsd.org/source-changes/2012/11/25/msg039125.html
http://mail-index.netbsd.org/source-changes/2012/11/25/msg039126.html
http://mail-index.netbsd.org/source-changes/2012/11/25/msg039142.html

they cause a i386PAE domU to hang while running ATF tests, as shown in
http://www-soc.lip6.fr/~bouyer/NetBSD-tests/xen/HEAD/

(we should pay more attention to test results, myself first).
2013-01-12 21:09:10 +00:00
bouyer 763123ba32 Back out this commit:
http://mail-index.netbsd.org/source-changes/2012/12/28/msg039950.html
which cause a panic when running tests on amd64, as shown on:
http://www-soc.lip6.fr/~bouyer/NetBSD-tests/xen/HEAD/
(i386 hangs for unrelated reasons).
2013-01-12 17:39:46 +00:00
cherry ceab76fbae Simplify the xen event handler callback by:
- moving the interrupt handler callback traversal into a separate
   function.
 - using evt_iterate_bits() to scan through the pending bitfield
 - removing cross-cpu pending actions - events recieved on the wrong
   vcpu are re-routed via hypervisor_send_event().
 - simplifying nested while() loops by encapsulating them in
   equivalent functions.

Many thanks for multiple reviews by bouyer@ and jym@
2012-12-28 06:29:56 +00:00
cherry e0ec031843 Remove unused header evtchn.h from intr.h 2012-12-27 06:42:14 +00:00
cherry 5629a5ffd3 Make hypervisor_set_ipending() and its consumers cpu unaware. This syncs syntax with semantics 2012-11-25 08:39:35 +00:00
cherry d204c4c45c Remove e a redundant layer of function calling in the event handling path 2012-11-10 16:28:06 +00:00
jdc 4be6ce2eeb Adapt to the changed signature of pckbc_cnattach(). 2012-10-13 17:58:53 +00:00
dsl 4911d2e6ef Remove all references to KVM86.
It was only ever used by APMBIOS - and then only if an option was selected.
Probably didn't work well at all!
2012-10-03 18:58:30 +00:00
rmind 4dc5d07777 Rename kcpuset_copybits() to kcpuset_export_u32() and thus be more specific
about the interface.
2012-09-16 22:09:33 +00:00
bouyer d010654c5e Redo previous the correct way: Xen expects a u_long * for vcpumask,
so use 2 uint32_t on LP64.
2012-08-21 09:06:02 +00:00
rmind 6ff25eebbe Fix Xen build. Make xcpumask uint32_t, fits 32 CPUs (can increase). 2012-08-21 01:17:46 +00:00
mlelstv 8ce4433821 Do not call setroot() from MD code and from MI code, which has
unwanted sideeffects in the RB_ASKNAME case. This fixes PR/46732.

No longer wrap MD cpu_rootconf(), as hp300 port stores reboot information
as a side effect. Instead call MI rootconf() from MD code which makes
rootconf() now a wrapper to setroot().

Adjust several MD routines to set the global booted_device,booted_partition
variables instead of passing partial information to setroot().

Make cpu_rootconf(9) describe the calling order.
2012-07-29 18:05:39 +00:00
jym 6f78ccc10d Use setter to set xenguest_handles. 2012-06-30 23:36:20 +00:00
jym 4b5a093d68 Extend the xpmap API, as described in [1]. This change is mechanical and
avoids exposing the MD phys_to_machine/machine_to_phys tables directly.
Added:

- xpmap_ptom handles PFN (pseudo physical) to MFN (machine frame number)
translations, and is under control of the domain.
- xpmap_mtop is its counterpart (MFN to PFN), and is under control of
hypervisor.

xpmap_ptom_map()      map a pseudo-phys address to a machine address
xpmap_ptom_unmap()    unmap a pseudo-phys address (invalidation)
xpmap_ptom_isvalid()  check for pseudo-phys address validity

The parameters are physical/machine addresses, like bus_dma/bus_space(9).
As x86 MFNs are tracked by u_long (Xen's choice) while machine addresses
can be 64 bits entities (PAE), use ptoa() to avoid truncation when bit
shifting by PAGE_SHIFT.

I kept the same namespace (xpmap_) to avoid code churn.

[1] http://mail-index.netbsd.org/port-xen/2009/05/09/msg004951.html

XXX will document ptoa/atop/trunc_page separately.
2012-06-30 22:50:36 +00:00
jym b6169c060b Retire XEN_COMPAT_030001 as detailed on port-xen@:
http://mail-index.netbsd.org/port-xen/2012/06/25/msg007431.html

The xen_p2m API comes next.

ok bouyer@.
Tested on i386 PAE and amd64 (Xen 3.3 on private test bed, and
Xen 3.4 for Amazon EC2).

FWIW, Amazon always reported:

hypervisor0 at mainbus0: Xen version 3.4.3-kaos_t1micro

multiple times for Europe and US West-1, so I guess they are now at
3.4 (32 and 64 bits).
2012-06-27 00:37:07 +00:00
jym 23a2531c0e Enable the map/unmap recursive mapping functions for all Xen ports for
save/restore.

For an unknown reason (to me) Xen refuses to update VM translations
when the entry is pointing back to itself (which is precisely
what our recursive VM model does). So enable the functions that take
care of this, which will avoid all sort of memory corruption upon restore
leading domU to trample upon itself.

Save/restore works again for amd64. The occasional domU frontend corruption is
still present, but is harmless to dom0. Now we have a working shell and
ddb inside domU, that helps debugging a tiny bit.

XXX pull-up to -6.
2012-06-24 18:31:52 +00:00
jym 39b8d4bd9a Update comment: we stopped using xcall to sync PTP between CPUs.
pmap_kpm_sync_xcall => xen_kpm_sync
2012-06-24 13:56:10 +00:00
mlelstv 5741661f64 Make detection of root on wedges (dk(4)) machine independent. Remove
MD code for x86, xen, sparc64.
2012-06-10 17:05:18 +00:00
rmind e75fa0930a Few fixes for Xen:
- cpu_load_pmap: use atomic kcpuset(9) operations; fixes rare crashes.
- Add kcpuset_copybits(9) and replace xen_kcpuset2bits().  Avoids incorrect
  ncpu problem in early boot.  Also, micro-optimises xen_mcast_invlpg() and
  xen_mcast_tlbflush() routines.

Tested by chs@.
2012-06-06 22:22:41 +00:00
rmind 0c79472223 - Convert x86 MD code, mainly pmap(9) e.g. TLB shootdown code, to use
kcpuset(9) and thus replace hardcoded CPU bitmasks.  This removes the
  limitation of maximum CPUs.

- Support up to 256 CPUs on amd64 architecture by default.

Bug fixes, improvements, completion of Xen part and testing on 64-core
AMD Opteron(tm) Processor 6282 SE (also, as Xen HVM domU with 128 CPUs)
by Manuel Bouyer.
2012-04-20 22:23:24 +00:00
jym 5b037abc92 Split the map/unmap code from the sync/flush code: move xpq_flush_queue()
calls after pmap_{,un}map_recursive_entries() so that pmap's handlers
handle the flush themselves.

Now pmap_{,un}map_recursive_entries() do what their names imply, nothing more.

Fix pmap_xen_suspend()'s comment: APDPs are now gone.

pmap's handlers are called deep during kernel save/restore. We already
are at IPL_VM + kpreemption disabled. No need to wrap the xpq_flush_queue()
with splvm/splx.
2012-03-11 17:14:30 +00:00
jym 9506b7bd53 Typo fix. 2012-03-11 16:16:44 +00:00
bouyer dfde48d707 Add some more KASSERT() 2012-03-02 16:38:14 +00:00
bouyer 6132369235 MMUEXT_INVLPG_MULTI and MMUEXT_TLB_FLUSH_MULTI use a long as cpu mask,
not uint32_t, so  pass a pointer of the right type.
While there, cleanup includes and delete local, redundant define of PG_k.
2012-03-02 16:37:38 +00:00
bouyer d50505c826 The code assumes that ci_index is also the Xen's cpunum, and that
cpunum is less than XEN_LEGACY_MAX_VCPUS. KASSERT both.
2012-02-25 18:57:50 +00:00
bouyer d8304c6be9 Don't maintain ci_cpumask for physical CPUs, it's not used. 2012-02-24 11:43:06 +00:00
bouyer b0388defd1 Get rid of phycpus_attached bitmask; it's maintained but not used and
will limit the number of physical CPUs to 32 without good reasons.
2012-02-24 11:31:23 +00:00
cherry a9b15e0f47 (xen) - remove the (*xpq_cpu)() shim.We hasten the %fs/%gs setup process during boot.Although this is hacky, it lets us use the non-xen specificpmap_pte_xxx() functions in pmap code (and others). 2012-02-24 08:06:07 +00:00
bouyer fa9d8fcc5b On Xen, there is variable-sized Xen data after the kernel's text+data+bss
(this include the physical->machine table).
(vaddr_t)(KERNBASE + NKL2_KIMG_ENTRIES * NBPD_L2) is after text+data+bss but,
on a domU with lots of RAM (more than 4GB) (so large
xpmap_phys_to_machine_mapping table) this can point to some of Xen's data
setup at bootstrap (either the xpmap_phys_to_machine_mapping table,
some page shared with the hypervisor, or our kernel page table). Using it for
early_zerop will cause of these pages to be unmapped after bootstrap.
This will cause a kernel page fault for the domU, either immediatly or
eventually much later, depending on where early_zerop points to.
To fix this, account for early_zerop when building the bootstrap pages,
and its VA from here.

May fix PR port-xen/38699
2012-02-23 18:59:21 +00:00
cherry ad6a7fcd5d Cleanup.
- Remove cruft from native x86 origin.
 - Remove access to privileged MSRs.
 - Cleanup stale comments.
2012-02-23 07:30:30 +00:00
cherry b82beb15c7 cpu_load_pmap() should not be used to load pmap_kernel(), since in the
x86 model, its mappings are shared across pmaps. KASSERT() for this
and remove unused codepaths.
2012-02-23 04:10:51 +00:00
bouyer 94e365bdd2 use pmap_protect() instead of pmap_kenter_pa() to remap R/O an exiting
page. This gets rid of the last "mapping already present" warnings.
2012-02-22 18:29:31 +00:00
bouyer 5dfe2dddcc Avoid early use of xen_kpm_sync(); locks are not available at this time.
Don't call cpu_init() twice.

Makes LOCKDEBUG kernels boot again
2012-02-21 19:10:13 +00:00
bouyer d3ccea851c Apply patch proposed in PR port-xen/45975 (this does not solve the exact
problem reported here but is part of the solution):
xen_kpm_sync() is not working as expected,
leading to races between CPUs.
1 the check (xpq_cpu != &x86_curcpu) is always false because we
  have different x86_curcpu symbols with different addresses in the kernel.
  Fortunably, all addresses dissaemble to the same code.
  Because of this we always use the code intended for bootstrap, which doesn't
  use cross-calls or lock.

2 once 1 above is fixed, xen_kpm_sync() will use xcalls to sync other CPUs,
  which cause it to sleep and pmap.c doesn't like that. It triggers this
  KASSERT() in pmap_unmap_ptes():
  KASSERT(pmap->pm_ncsw == curlwp->l_ncsw);
3 pmap->pm_cpus is not safe for the purpose of xen_kpm_sync(), which
  needs to know on which CPU a pmap is loaded *now*:
  pmap->pm_cpus is cleared before cpu_load_pmap() is called to switch
  to a new pmap, leaving a window where a pmap is still in a CPU's
  ci_kpm_pdir but not in pm_cpus. As a virtual CPU may be preempted
  by the hypervisor at any time, it can be large enough to let another
  CPU free the PTP and reuse it as a normal page.

To fix 2), avoid cross-calls and IPIs completely, and instead
use a mutex to update all CPU's ci_kpm_pdir from the local CPU.
It's safe because we just need to update the table page, a tlbflush IPI will
happen later. As a side effect, we don't need a different code for bootstrap,
fixing 1). The mutex added to struct cpu needs a small headers reorganisation.

to fix 3), introduce a pm_xen_ptp_cpus which is updated from
cpu_pmap_load(), whith the ci_kpm_mtx mutex held. Checking it with
ci_kpm_mtx held will avoid overwriting the wrong pmap's ci_kpm_pdir.

While there I removed the unused pmap_is_active() function;
and added some more details to DIAGNOSTIC panics.
2012-02-17 18:40:18 +00:00
jym b3430e5626 PAT flags are not under control of Xen domains currently, so there is no
point in enabling them.

Avoids:
- a warning logged by hypervisor when a domain attempts to modify the PAT
MSR.
- an error during domain resuming, where a PAT flag has been set on a page
while the hypervisor does not allow it.

ok releng@.
2012-02-13 23:54:58 +00:00
cherry cbdea16d58 Update comments to remove references to alternate pte space. 2012-01-28 12:15:19 +00:00
cherry 6bed7d4e8c stop using alternate pde mapping in xen pmap 2012-01-28 07:19:17 +00:00
cherry c9bb90d5c5 Do not clobber pmap_kernel()'s pdir unnecessarily while syncing per-cpu pdirs 2012-01-22 18:16:34 +00:00
bouyer a3e0c29742 add a missing splvm()/splx() to protect the xpq queue. 2012-01-19 22:04:05 +00:00
cherry 2504a10c74 relocate pte_lock initialisation to the earliest points after %fs is first usable in the XEN bootpath 2012-01-12 19:49:37 +00:00
cherry 66e35f7978 Make cross-cpu pte access MP safe.
XXX: review cases of use of pmap_set_pte() vs direct use of xpq_queue_pte_update()
2012-01-09 13:04:13 +00:00
cherry 0e1fd236aa Harden cross-cpu L3 sync - avoid optimisations that may race.
Update ci->ci_kpm_pdir from user pmap, not global pmap_kernel() entry which may get clobbered by other CPUs.
XXX: Look into why we use pmap_kernel() userspace entries at all.
2012-01-09 12:58:49 +00:00
cherry d515295709 revert previous commit. DIAGNOSTIC should only do strict checks, not muffle current ones 2012-01-09 04:39:14 +00:00
cherry 44fb314fb7 Address those pesky DIAGNOSTIC messages. \n
Take a performance hit at fork() for not DTRT. \n
Note: Only applicable for kernels built with "options DIAGNOSTIC" \n
2012-01-06 15:15:27 +00:00
cherry 84d4985e86 Use macro PDP_SIZE instead of numeric constant, for unshared PAE L3 entries.
Thanks jym@
2012-01-04 10:30:23 +00:00
cherry b83ccb0e45 Never cut-paste code from email!
Use the right count (0 -> 2) of l3 unshared userland entries for per-cpu initialisation.
2011-12-30 19:18:35 +00:00
cherry d827fd25ea Force pae l3 page allocation for new vcpus to be < 4G, so they fit in 32bits 2011-12-30 18:01:20 +00:00
cherry d12f2f3b2f per-cpu shadow directory pages should be updated locally via cross-calls. Do this. 2011-12-30 16:55:21 +00:00
cherry 7603d0cfb3 Remove spurious (debug) printf() 2011-12-30 12:16:19 +00:00