Commit Graph

1137 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
jakllsch
f970281f99 remove trailing whitespace 2012-12-05 01:46:22 +00:00
royger
f301a1b2e9 xen: prevent adding duplicate xenwatches
When a xenstore watch triggers, the event is processed on process_msg
and if a valid handle it's found the handler is queued for execution
on the pending xen watches queue (watch_events).

This may present a problem if we trigger a xenwatch several times and
then disconnect the device. If several xenwatch events are added to
the watch_events queue and the device is disconnected afterwards, the
first processed xenwatch event will disconnect the device, remove the
watch and free all resources. This triggers a panic if there are
pending xenwatch events for that device already queued in the local
queue of the function xenwatch_thread, since when the next watch that
has the same handler tries to execute we get a panic due to the fact
that the device is already disconnected and all resources had been
freed:

xenbus_watch: 0xffffa0000b7cd1d0
xbw_callback: 0xffffffff80755dd4
otherend_changed: backend/vif/1/0
backend/vif/1/0/state 6
backend/vif/1/0 -> Closed
backend/vif/1/0 -> backend_device, b_detach: 0xffffffff8075a2bf
xenbus_watch: 0xffffa0000b7cd1d0
xbw_callback: 0xfc5ec02183e547a8
fatal protection fault in supervisor mode
trap type 4 code 0 rip ffffffff80756596 cs e030 rflags 10246 cr2
7f7ff7b4c020 ilevel 0 rsp ffffa000e6d82c50
curlwp 0xffffa0000a72d580 pid 0 lid 36 lowest kstack
0xffffa000e6d7f000
kernel: protection fault trap, code=0
Stopped in pid 0.36 (system) at netbsd:xenwatch_thread+0xc7:    call
*10(%rax
)
xenwatch_thread() at netbsd:xenwatch_thread+0xc7
ds          f
es          5987
fs          2c40
gs          1460
rdi         ffffa0000b7cd1d0
rsi         ffffa0000a5477f0
rbp         ffffa000e6d82c70
rbx         ffffa0000b7c14c0
rdx         2
rcx         f
rax         ffffa0000b7cd1d0
r8          78
r9          ffffffef
r10         deadbeef
r11         1
r12         ffffa000e6d82c50
r13         ffffa0000a72d580
r14         ffffa0000a72d580
r15         0
rip         ffffffff80756596    xenwatch_thread+0xc7
cs          e030
rflags      10246
rsp         ffffa000e6d82c50
ss          e02b
netbsd:xenwatch_thread+0xc7:    call    *10(%rax)
2012-11-28 16:26:59 +00:00
cherry
aaa3520e6b Do not escalate the local spl while taking the interrupt handler list
lock. Re-entrance is protected against within the events handler
framework by toggling interrupts/events, so we don't need (and cannot
use) the spl framework in that path. The other consumers (interrupt
registration/removal code) are not spl sensitive wrt this lock.
2012-11-25 20:56:33 +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
8b26a56d50 hypervisor_set_ipending() should not set the pending flag across cpus. The reason for this is that the pending flag update is not atomic, or protected by a lock. Since its current (mis)use in evtchn_do_event() across cpus is to notify the remote cpu of an interrupt, we use hypervisor_send_event() instead, to trigger an event on the remote cpu, which in turn invokes evtchn_do_event() on that cpu and DTRT on it.
On the local cpu, we protect hypervisor_set_ipending() from re-entry via cli(). Remove a redundant and unprotected call to hypervisor_set_ipending().

Thanks to jym@ for spotting this discrepancy while reviewing a related patch.

See: http://mail-index.netbsd.org/tech-kern/2012/11/12/msg014374.html
2012-11-25 07:48:46 +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
royger
cbd5ff4886 xen: don't use grants 0-8
Not all grants from the first frame can be used, grants from 0 to 8
(both included) are reserved for external tools. Using this grants
caused system crashes and fs corruption.

Closes PR port-xen/47057 and port-xen/47056
Reviewed by bouyer@
2012-10-24 13:07:46 +00:00
drochner
035939be53 put binary compatibility support for the old AMD-only CPU microcode
update API inside COMPAT_60
2012-10-17 20:19:55 +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
drochner
312c339026 Extend the CPU microcode update framework to support Intel x86 CPUs.
Contrary to the AMD implementation, it doesn't use xcalls to distribute
the update to all CPUs but relies on cpuctl(8) to bind itself to the
right CPU -- to keep it simple and avoid possible problems with
hyperthreading.
Also, it doesn't parse the vendor supplied file to pick the right
part for the present CPU model but relies on userland to prepare
files with specific filenames. I'll commit a pkg for this in a minute
(pkgsrc/sysutils/intel-microcode).
The ioctl interface changed; compatibility is provided (should be
limited to COMPAT_NETBSD6 as soon as this is available).
2012-08-29 17:13:21 +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
matt
efbf8fe2cd Fix some -fno-common fallout. 2012-07-28 02:08:50 +00:00
jym
82b5b80a5d Add more ratechecks to avoid console spam when the backend gets a
stream of errors.

Remove the unused xbdi_errps (error per second) variable. Errors should
rather be tracked in absolute, with a threshold that forces a time penalty
to the xbdback thread when frontend goes nuts.
2012-07-23 01:31:01 +00:00
jym
ede9b84cdc Don't leak stack content when reading the Xen suspend value.
XXX pull-up to -6.
2012-07-22 19:30:19 +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
sborrill
469cc9aebf Fix problem where devices with ID 0 were skipped as invalid as it didn't
distinguish between numerical zero and invalid numeric string.
2012-06-07 14:05:13 +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
sborrill
100e1d86bf Sort vif and vbd device IDs numerically so that attach order does not depend
on the order they are passed in through xenstore. While this works for
hand-crafted Xen configuration files, it does not work for XenServer, XCP or
EC2 instances. This means that adding an extra virtual disk can make the
domU unbootable.

ID is actually based on the Linux device major/minor so this approach isn't
entirely correct (for instance, you can specify devices to be non-contiguous
which doesn't fit too well with our autoconf approach), but it works as a
first approximation.

Tested by me on XenServer and riz@ on EC2. OK bouyer@
2012-06-05 10:58:56 +00:00
elric
7fd7d3916e Update xdb_xenbus.c to new usage of routines in dksubr.c. 2012-05-25 15:03:38 +00:00
cegger
b2cdc990ec destroy mutex and cv first.
Fixes LOCKDEBUG crash when a guest shut down.
2012-05-23 10:01:51 +00:00
jym
8cf41b7663 Merge i386 and amd64 version of db_memrw.c.
Use this opportunity to skip calculating the VA of the page. Let the CPU
deal with the invalidation itself through invlpg + destination address to
avoid converting between canonical/non canonical forms.
2012-05-07 17:45:28 +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
riz
2658d1ab38 Retrive and print the hypervisor "extra" (teeny) version.
From Manuel Bouyer.
2012-04-06 03:20:43 +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
jakllsch
24400823a3 As per xpci_conf_read, use size argument in xpci_conf_write. 2012-03-05 16:53:59 +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
d13f34107d Fix locking; xengnt_get_entry() needs to have the lock held to avoid
allocating the same entry twice. xengnt_more_entries() also needs the lock
for the same reason.
2012-02-23 19:17:32 +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