Home | History | Annotate | Download | only in xenbus
History log of /src/sys/arch/xen/xenbus/xenbus_comms.h
RevisionDateAuthorComments
 1.8  13-May-2020  jdolecek don't reinitialize mutexes/cv on resume

part of PR port-xen/55207
 1.7  06-May-2020  bouyer Convert remaining splfoo/splx and tsleep/wakeup to mutex and condvar.
Mark kernel threads and interrupt handlers MPSAFE.
 1.6  20-Sep-2011  jym Merge jym-xensuspend branch in -current. ok bouyer@.

Goal: save/restore support in NetBSD domUs, for i386, i386 PAE and amd64.

Executive summary:
- split all Xen drivers (xenbus(4), grant tables, xbd(4), xennet(4))
in two parts: suspend and resume, and hook them to pmf(9).
- modify pmap so that Xen hypervisor does not cry out loud in case
it finds "unexpected" recursive memory mappings
- provide a sysctl(7), machdep.xen.suspend, to command suspend from
userland via powerd(8). Note: a suspend can only be handled correctly
when dom0 requested it, so provide a mechanism that will prevent
kernel to blindly validate user's commands

The code is still in experimental state, use at your own risk: restore
can corrupt backend communications rings; this can completely thrash
dom0 as it will loop at a high interrupt level trying to honor
all domU requests.

XXX PAE suspend does not work in amd64 currently, due to (yet again!)
page validation issues with hypervisor. Will fix.

XXX secondary CPUs are not suspended, I will write the handlers
in sync with cherry's Xen MP work.

Tested under i386 and amd64, bear in mind ring corruption though.

No build break expected, GENERICs and XEN* kernels should be fine.
./build.sh distribution still running. In any case: sorry if it does
break for you, contact me directly for reports.
 1.5  24-Oct-2008  jym branches: 1.5.8;
- rename init_events() to events_init(), to better reflect netbsd semantics

- change unbind_[pv]irq_from_evtch() so that they now return the event
channel the [PV]IRQ was bound to. It reflects the opposite behaviour of the
bind_[pv]irq_to_evtch() functions.

- remove xenbus_suspend() and xenbus_resume() prototypes, as they are not
used anywhere else, and will conflict with the xenbus pmf(9) handlers.

- make start_info aligned on a page boundary, as Xen expects it to be so.

- mask event channel during xbd detach before removing its handler (can
avoid spurious events).

- add the "protocol" entry in xenstore during xbd initialization. Normally
created during domU's boot by xentools, it is under domU's responsibility
in all other cases (save/restore, hot plugging, etc.).

- modifications to xs_init(), so that it can properly return an error.

Reviewed by Christoph (cegger@).
 1.4  16-Apr-2008  cegger branches: 1.4.4; 1.4.10;
device_t / softc split
reviewed, tested and approved by bouyer
 1.3  09-Apr-2006  bouyer branches: 1.3.2; 1.3.8; 1.3.14; 1.3.68;
start xenbus support for domain0: allocate the page and the event channel,
and export theses via /kern/xen/xsd_mfn and /kern/xen/xsd_port.
 1.2  06-Mar-2006  bouyer branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Adapt for NetBSD and add glue for config(9). Enough to get guest domain
virtual devices probed and attached, domain0 and xenstore watch needs to
be done.
 1.1  06-Mar-2006  bouyer branches: 1.1.1;
Initial revision
 1.1.1.1  06-Mar-2006  bouyer Import xenbus sources, from linux sparse tree in the 20060107 xen-3.0
snapshot.
 1.2.8.2  07-Apr-2006  tron Apply patch (requested by bouyer in ticket #1245):
Pull up Xen3 domU support. This adds support for the Xen-3 memory bootstrap,
xenstore, and block and network device frontend. Xen-3 support is turned
on by 'options XEN3', which disable Xen-2 support.
Changes affecting non-xen3 specific code:
- xbd and xennet at hypervisor now attaches with xbd_hypervisor and
xennet_hypervisor
- x86_atomic_* renamed to xen_atomic_*
- use genassim.cf to pull in more constant from include files for assembly
- Map the shared info page from locore.S instead of the 0xffffffff hack
in xen_machdep.c
- remove some unused code
- some __asm__ __volatile__ -> __asm volatile and __inline__ -> inline
- more debug code
 1.2.8.1  06-Mar-2006  tron file xenbus_comms.h was added on branch netbsd-3 on 2006-04-07 12:51:26 +0000
 1.2.6.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.2.4.3  11-Apr-2006  yamt sync with head
 1.2.4.2  13-Mar-2006  yamt sync with head.
 1.2.4.1  06-Mar-2006  yamt file xenbus_comms.h was added on branch yamt-pdpolicy on 2006-03-13 09:07:07 +0000
 1.2.2.1  19-Apr-2006  elad sync with head - hopefully this will work
 1.3.68.2  17-Jan-2009  mjf Sync with HEAD.
 1.3.68.1  02-Jun-2008  mjf Sync with HEAD.
 1.3.14.2  09-Sep-2006  rpaulo sync with head
 1.3.14.1  09-Apr-2006  rpaulo file xenbus_comms.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:06 +0000
 1.3.8.2  21-Jun-2006  yamt sync with head.
 1.3.8.1  09-Apr-2006  yamt file xenbus_comms.h was added on branch yamt-lazymbuf on 2006-06-21 14:58:23 +0000
 1.3.2.2  22-Apr-2006  simonb Sync with head.
 1.3.2.1  09-Apr-2006  simonb file xenbus_comms.h was added on branch simonb-timecounters on 2006-04-22 11:38:11 +0000
 1.4.10.1  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.4.4.1  04-May-2009  yamt sync with head.
 1.5.8.3  01-Nov-2009  jym - Upgrade suspend/resume code to comply with Xen2 removal.
- Add support for PAE domUs suspend/resume.
- Fix an issue regarding initialization of the xbd ring I/O that could end
badly during resume, with invalid block operations submitted to dom0 backend.

NetBSD supports PAE under x86_32 by considering the L2 page as being
4 pages long instead of 1.

Xen validates the page types during resume. Sadly, the hypervisor handles
alternative recursive mappings (== PG/PD entries pointing to pages other
than self) inadequately, which could lead to incorrect page pinning.

As a result, the important change with this patch is to clear these alternative
mappings during suspend, and reset them back to their former self upon
resume. For PAE, approx. all 4 PDIR_SLOT_PTEs could be considered as
alternative recursive mappings.

See comments in pmap.c for further details.

Now, let the testing and bug hunting begin.
 1.5.8.2  01-Nov-2009  jym Sync with HEAD.
 1.5.8.1  09-Feb-2009  jym Initial code for xen save/restore/migrate facilities.

- split the attach code of frontends in two half: one that is only needed
during autoconf(9) attach/detach phases, and one used at each save/restore
of device state (between suspend and resume).

Applies to hypervisor, xencons, xenbus, xbd, and xennet.

- add a rwlock(9) ("ptom_lock") to protect the different parts in the kernel
that manipulate MFNs (which could change between a suspend and a resume,
without the kernel noticing it). Parts that require MFNs acquire a reader lock,
while suspend code will acquire a writer lock to ensure that no-other parts
in kernel still use MFNs.

- integrate the suspend code with sysmon.

- various things in pmap(9), and clock.

TODO:
- factorize code a bit more inside frontends drivers.
- remove all alternative recursive (APDP_PDE) mappings found in PD/PT during
suspend, as Xen does not support them.
- abstract the ptom_lock locking, it is only required when kernel preemption
is enabled, or on MP systems.

Current code works mostly. You may experience difficulties in some corner
cases (dom0 warnings about xennet interface errors, and Xen tools failing to
validate NetBSD's alternative pmaps).

RSS XML Feed