Home | History | Annotate | Download | only in x86
History log of /src/sys/arch/xen/x86/xen_intr.c
RevisionDateAuthorComments
 1.31  25-Feb-2023  riastradh xen_intr.c: Use kpreempt_disable/enable around access to curcpu().

curcpu() is not otherwise guaranteed to be stable at these points.

While here, nix nonsensical membars. This need only be synchronized
with interrupts on the same CPU.

Proposed on port-xen:
https://mail-index.netbsd.org/port-xen/2022/07/13/msg010250.html

XXX pullup-8 (in __sti/__cli, __save/restore_flags in include/xen.h)
XXX pullup-9
XXX pullup-10
 1.30  24-May-2022  bouyer branches: 1.30.4;
- msipic_construct_msix_pic(): set mp_table_base to memaddr (without
table_offset), this is what Xen wants
while there use pci_conf_write16() in msi_set_msictl_enablebit() too,
for consistency (it seems that Xen accepts the 32bit write at this point,
but this may change).

- xen_map_msix_pirq(): don't forget to set map_irq.table_base in the
MSI-X case, otherwise Xen maps it as MSI
- call pic_hwunmask() after pirq_establish() in msi/msix case, to make sure
the msi-x vector is unmasked.

Now MSI-X works with Xen so stop disabling it in pci_attach_hook().
 1.29  09-Aug-2021  andvar s/alway /always/
 1.28  01-Aug-2020  jdolecek adjust includes to pull __HAVE_PCI_MSI_MSIX properly
 1.27  07-May-2020  bouyer Change event_set_handler() to take the target CPU parameter. If ci is NULL,
event_set_handler() will choose the CPU and bind the event.
If ci is not NULL the caller is responsible for binding the event.
Use a IPI xcall to register the handlers if needed.
pull in a hack from x86 to force pirq handlers to be mpsafe if registered at
a level != IPL_VM. This is for the com at isa interrupt handler, which
registers at IPL_HIGH and has to way to tell it's mpsafe (taking
KERNEL_LOCK at IPL_HIGH causes deadlocks on MP systems).
 1.26  05-May-2020  bouyer Make DOM0OPS build for PVH/PVHVM too
 1.25  04-May-2020  jdolecek add support for using MSI for XenPV Dom0

use PHYSDEVOP_map_pirq to get the pirq/gsi for MSI/MSI-X, switch also INTx
to use it instead of PHYSDEVOP_alloc_irq_vector

MSI confirmed working with single-vector MSI for wm(4), ahcisata(4), bge(4)

XXX added some provision for MSI-X, but it doesn't actually work (no interrupts
delivered), needs some further investigation; disable MSI-X for XENPV
via flag in x86/pci/pci_machdep.c
 1.24  25-Apr-2020  bouyer Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor
 1.23  21-Apr-2020  jdolecek adjust so that this at least compiles and links with __HAVE_PCI_MSI_MSIX
 1.22  13-Apr-2020  bouyer By default, events are bound to CPU 0 (exept for IPIs and VTIMERs which
are bound to a different CPU at creation time).
Recent MI changes caused the scheduler to choose a different CPU when
probing and attaching xennet devices (I guess it's the xenbus thread which
runs on a different CPU). This cause the callback to be called on a different
CPU than the one expected by the kernel, and the event is ignored.
It is handled when the clock causes the callback to be called on the right
CPU, which is why xennet still run, but slowly.

Change event_set_handler() to do a EVTCHNOP_bind_vcpu if requested to,
and make sure we don't do it for IPIs and VIRQs (for theses, the op fails).
 1.21  06-Apr-2020  jdolecek branches: 1.21.2;
add known_mpsafe parameter also to pirq_establish(), and pass the parameter
to underlying event_set_handler()
 1.20  06-Apr-2020  jdolecek remove restriction on interrupt level for MP-safe interrupt handlers
 1.19  03-Apr-2020  ad Attach xen IPI event counters.
 1.18  23-Dec-2019  thorpej Provide XEN stubs for intr_mask() / intr_unmask().
 1.17  07-Jun-2019  cherry branches: 1.17.2;
Fix build for the XEN3_PVHVM kernel by conditoinally compiling
redundant functions x86_enable_intr()/x86_disable_intr()
 1.16  09-May-2019  bouyer sti/cli are not allowed on Xen, we have to clear/set a bit in the
shared page. Revert x86_disable_intr/x86_enable_intr to plain function
calls on XENPV.
While there, clean up unused functions and macros, and change cli()/sti()
macros to x86_disable_intr/x86_enable_intr.
Makes Xen domU boot again
(http://www-soc.lip6.fr/~bouyer/NetBSD-tests/xen/HEAD/)
 1.15  14-Feb-2019  cherry Welcome XENPVHVM mode.

It is UP only, has xbd(4) and xennet(4) as PV drivers.

The console is com0 at isa and the native portion is very
rudimentary AT architecture, so is probably suboptimal to
run without PV support.
 1.14  12-Feb-2019  cherry Move xen event related code which interfaces with the NetBSD interrupt
subsystem into a separate namespace where it can co-exist with the
native equivalent in PVHVM mode.

On PV, we alias and export the native symbols - this means that
although the namespace is different, the semantics must be identical.

Eg: xen_intr_establish_xname() vs. intr_establish_xname().

The specific functions we need in PVHVM are:

- spllower, xen_spllower (for native as well as XEN event spl
despatch/defer)
- xen_disable_intr()/xen_enable_intr() ,
x86_disable_intr()/x86_enable_intr()
- xen_read_psl()/xen_write_psl(),
x86_read_psl()/x86_write_psl()
- intr_establish() et. al, xen_intr_establish() et. al.

This gives us the ability to manage Paravirtualised drivers such as
xbd(4) as well as fully emulated ones such as wd(4)., for eg
 1.13  26-Dec-2018  cherry Xen can use the native splraise(9) functions.

There is no need for a slower C version.
 1.12  25-Dec-2018  cherry fix i386 build - missed sources migration in previous commit.

allow xen_intr.c to build by bringing in static support functions for
-D INTRSTACKSIZE

This should fix the i386 build now.
 1.11  25-Dec-2018  cherry Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!
 1.10  24-Dec-2018  cherry Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.
 1.9  16-Jan-2009  jym branches: 1.9.58; 1.9.64; 1.9.66;
Replace x86 memory fences in Xen drivers by their Xen equivalents, to reduce
MD dependency:

x86_lfence() => xen_rmb()
x86_sfence() => xen_wmb()
x86_mfence() => xen_mb()

Discussed in
http://mail-index.netbsd.org/port-xen/2009/01/15/msg004655.html

Ok by bouyer@.
 1.8  01-Jul-2008  bouyer branches: 1.8.4;
spllower(): return immediatly if ci->ci_ilevel <= nlevel, as the asm
versions do.
 1.7  25-May-2008  bouyer branches: 1.7.2;
Add a KASSERT(): Xspllower() will reenable interrupts, so make sure it's
not wrong to do so.
 1.6  24-May-2008  bouyer G/C dead code: remove now-unused softintr-related code.
 1.5  28-Apr-2008  martin branches: 1.5.2;
Remove clause 3 and 4 from TNF licenses
 1.4  21-Apr-2008  cegger branches: 1.4.2;
Access Xen's vcpu info structure per-CPU.
Tested on i386 and amd64 (both dom0 and domU) by me.
Xen2 tested (both dom0 and domU) by bouyer.
OK bouyer
 1.3  14-Apr-2008  cegger branches: 1.3.2;
- use POSIX integer types
- ansify functions
 1.2  22-Nov-2007  bouyer branches: 1.2.2; 1.2.4; 1.2.8; 1.2.16; 1.2.22;
Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.
 1.1  17-Oct-2007  bouyer branches: 1.1.2; 1.1.4;
file xen_intr.c was initially added on branch bouyer-xenamd64.
 1.1.4.1  08-Dec-2007  mjf Sync with HEAD.
 1.1.2.1  17-Oct-2007  bouyer Prepare for xenamd64:
- kill xen/i386/identcpu.c, use i386/i386/identcpu.c instead (with a few
#ifndef XEN)
- move some files that can be shared between i386 and amd64 from
xen/i386 to xen/x86 (or to xen/xen for non-cpu-specific code)
- split assembly out of xen/include/hypervisor.h to xen/include/hypercalls.h
- use <xen/...> instead of <machine/...> for cpu-independant include files.

more work needed here, i386-specific files should got out of arch/xen to
arch/xeni386, and more code shared with arch/i386.
 1.2.22.3  17-Jan-2009  mjf Sync with HEAD.
 1.2.22.2  02-Jul-2008  mjf Sync with HEAD.
 1.2.22.1  02-Jun-2008  mjf Sync with HEAD.
 1.2.16.2  09-Jan-2008  matt sync with HEAD
 1.2.16.1  22-Nov-2007  matt file xen_intr.c was added on branch matt-armv6 on 2008-01-09 01:50:16 +0000
 1.2.8.2  07-Dec-2007  yamt sync with head
 1.2.8.1  22-Nov-2007  yamt file xen_intr.c was added on branch yamt-lazymbuf on 2007-12-07 17:27:18 +0000
 1.2.4.2  03-Dec-2007  ad Sync with HEAD.
 1.2.4.1  22-Nov-2007  ad file xen_intr.c was added on branch vmlocking on 2007-12-03 19:04:44 +0000
 1.2.2.2  27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.2.2.1  22-Nov-2007  joerg file xen_intr.c was added on branch jmcneill-pm on 2007-11-27 19:36:22 +0000
 1.3.2.2  04-Jun-2008  yamt sync with head
 1.3.2.1  18-May-2008  yamt sync with head.
 1.4.2.2  04-May-2009  yamt sync with head.
 1.4.2.1  16-May-2008  yamt sync with head.
 1.5.2.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.5.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.7.2.1  03-Jul-2008  simonb Sync with head.
 1.8.4.1  19-Jan-2009  skrll Sync with HEAD.
 1.9.66.4  21-Apr-2020  martin Sync with HEAD
 1.9.66.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.9.66.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.9.66.1  10-Jun-2019  christos Sync with HEAD
 1.9.64.2  18-Jan-2019  pgoyette Synch with HEAD
 1.9.64.1  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.9.58.1  31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1862):

sys/arch/xen/x86/xen_intr.c: revision 1.31 (patch)
sys/arch/xen/include/xen.h (apply patch)

xen_intr.c: Use kpreempt_disable/enable around access to curcpu().

curcpu() is not otherwise guaranteed to be stable at these points.

While here, nix nonsensical membars. This need only be synchronized
with interrupts on the same CPU.

Proposed on port-xen:
https://mail-index.netbsd.org/port-xen/2022/07/13/msg010250.html
 1.17.2.1  31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1679):

sys/arch/xen/x86/xen_intr.c: revision 1.31

xen_intr.c: Use kpreempt_disable/enable around access to curcpu().

curcpu() is not otherwise guaranteed to be stable at these points.

While here, nix nonsensical membars. This need only be synchronized
with interrupts on the same CPU.

Proposed on port-xen:
https://mail-index.netbsd.org/port-xen/2022/07/13/msg010250.html
 1.21.2.10  25-Apr-2020  bouyer sync with bouyer-xenpvh-base2 (HEAD)
 1.21.2.9  20-Apr-2020  bouyer channel %d -> chan %d, for the benefit of 'systat vm'
 1.21.2.8  20-Apr-2020  bouyer Sync with HEAD
 1.21.2.7  19-Apr-2020  bouyer Add per-PIC callbacks for interrupt_get_devname(), interrupt_get_assigned()
and interrupt_get_count(). Implement Xen-specific callbacks for
PIC_XEN and use the x86 one for others.
In event_set_handler(), call intr_allocate_io_intrsource() so that
events appears in interrupt list (intrctl list).
 1.21.2.6  19-Apr-2020  bouyer Add a struct pic * member to struct intrhand.
This will be used for interrupt_get_count()
For Xen remplace pic_type with a pointer to the pic, and add a pointer
to intrhand, in struct pintrhand
Make event_set_handler return the pointer to struct intrhand.
Don't allocate a fake intrhand in xen_intr_establish_xname(), use the
one returned by event_set_handler().
 1.21.2.5  16-Apr-2020  bouyer Reorganise sources to make it possible to include Xen PVHVM support in
native kernels. Among others:
- move xen/include/amd64/hypercall.h to amd64/include/xen and
xen/include/i386/hypercall.h to i386/include/xen
- exclude some native files from the build for xenpv
- add xen to "machine" config statement for amd64 and i386
- split arch/xen/conf/files.xen to arch/xen/conf/files.xen (for pv drivers)
and arch/xen/conf/files.xen.pv (for full pv support)
- add GENERIC_XENHVM kernel config which includes GENERIC and add Xen PV
drivers.
 1.21.2.4  14-Apr-2020  bouyer Remove spllower alias, xen_spllower is gone
 1.21.2.3  12-Apr-2020  bouyer We need to call x86_init_preempt() for all CPUs now.
 1.21.2.2  12-Apr-2020  bouyer Get rid of xen-specific ci_x* interrupt handling:
- use the general SIR mechanism, reserving 3 more slots for IPL_VM, IPL_SCHED
and IPL_HIGH
- remove specific handling from C sources, or change to ipending
- convert IPL number to SIR number in various places
- Remove XUNMASK/XPENDING in assembly or change to IUNMASK/IPENDING
- remove Xen-specific ci_xsources, ci_xmask, ci_xunmask, ci_xpending from
struct cpu_info
- for now remove a KASSERT that there are no pending interrupts in
idle_block(). We can get there with some software interrupts pending
in autoconf XXX needs to be looked at.
 1.21.2.1  11-Apr-2020  bouyer Include ci_isources[] for XenPV too.
Adjust spllower() to XenPV needs, and switch XenPV to the native spllower().
Remove xen_spllower().
 1.30.4.1  31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #267):

sys/arch/xen/x86/xen_intr.c: revision 1.31

xen_intr.c: Use kpreempt_disable/enable around access to curcpu().

curcpu() is not otherwise guaranteed to be stable at these points.

While here, nix nonsensical membars. This need only be synchronized
with interrupts on the same CPU.

Proposed on port-xen:
https://mail-index.netbsd.org/port-xen/2022/07/13/msg010250.html

RSS XML Feed