aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/xen
Commit message (Collapse)AuthorAgeFilesLines
* xen/acpi: implement hook to notify Xen about entering sleep stateRoger Pau Monné3 days1-0/+75
| | | | | | | | | | | | | | | | | | | | | | | | | This is required so that ACPI power-off (entering S5) works as expected, as the ACPI PM1a and PM1b blocks might not be accessible by dom0 directly. Additionally, Xen also needs to do cleanup before entering a sleep state, so it needs to be notified about it. With this patch FreeBSD dom0 now powers off the host correctly: acpi0: Powering system off... (XEN) [ 85.686598] arch/x86/hvm/emulate.c:415:d0v0 fixup p2m mapping for page fedc6 added (XEN) [ 85.687606] arch/x86/hvm/emulate.c:415:d0v0 fixup p2m mapping for page fbc10 added (XEN) [ 85.692357] Preparing system for ACPI S5 state. (XEN) [ 85.692702] Disabling non-boot CPUs ... (XEN) [ 85.694471] Broke affinity for IRQ9, new: {0-7} [...] (XEN) [ 85.903118] Entering ACPI S5 state. Should be a non-functional change when not running as a Xen dom0. Reviewed by: kib Sponsored by: Citrix Systems R&D MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D55504
* sys/xen: Use __printflike() instead of format(printf)Alex Richardson2025-12-281-1/+1
| | | | | | | | The __printflike macro sets the format to freebsd_kprintf which recent clang understands and warns about. Fixes the following error: `passing 'printf' format string where 'freebsd_kprintf' format string is expected [-Werror,-Wformat]` MFC after: 1 week
* xen: Use proper prototype for SYSINIT functionsZhenlei Huang2025-10-131-4/+2
| | | | | | | The only possible return value of function xen_intr_init() is 0. Make it return void to match the prototype of SYSINIT. MFC after: 1 week
* power: Add stype parameter in power_suspend/resume eventhandlersAymeric Wibo2025-10-061-3/+4
| | | | | | | | | | Add enum sleep_type stype parameter in power_suspend/resume event handlers, as with the introduction of s2idle there are more than one type of suspend. Reviewed by: bz Approved by: bz Sponsored by: The FreeBSD Foundation
* machine/stdarg.h -> sys/stdarg.hBrooks Davis2025-06-114-7/+4
| | | | | | | | | | | | | Switch to using sys/stdarg.h for va_list type and va_* builtins. Make an attempt to insert the include in a sensible place. Where style(9) was followed this is easy, where it was ignored, aim for the first block of sys/*.h headers and don't get too fussy or try to fix other style bugs. Reviewed by: imp Exp-run by: antoine (PR 286274) Pull Request: https://github.com/freebsd/freebsd-src/pull/1595
* xen: Add support for platform device with id 5853:0002Frediano Ziglio2025-05-081-1/+2
| | | | | | | | | | According to https://xenbits.xen.org/docs/unstable/man/xen-pci-device-reservations.7.html the Xen Platform Device can either be 5853:0001 or 5853:0002. Currently kernel only recognises 5853:0001. Add detection for 5853:0002. Tested with XenServer and different machine templates. Reviewed by: royger
* efi: Move to using efi_guid_t in ioctl definitionsWarner Losh2025-05-011-3/+3
| | | | | | | | | | | | | | | | | Start using efi_guid_t instead of struct uuid in the ioctl definitions. These are binarily the same, but have different structure definitions. EFI prefers this form, and to allow more sharing with EDK2, make this slight addition. I've not really defined new IOCTLs for this. They are the same size, but I have defined new function. Also fix in-kernel uses of uuid to efi_guid_t for anything related to ioctl. Sponsored by: Netflix Reviewed by: tsoome, kib Differential Revision: https://reviews.freebsd.org/D50057
* xen/netfront: use iflladdr_event to send ARPsGleb Smirnoff2024-12-161-22/+6
| | | | | | | | | Avoids usage of arp_ifinit() and if_foreach_addr_type(). The former isn't encouraged to be used in drivers and the latter is about to change to not expose struct ifaddr. Reviewed by: royger, ehem_freebsd_m5p.com Differential Revision: https://reviews.freebsd.org/D48053
* Replace calls to bus_generic_attach with bus_attach_childrenJohn Baldwin2024-12-063-7/+8
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47675
* Replace calls to bus_generic_probe with bus_identify_childrenJohn Baldwin2024-12-062-5/+3
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47674
* device_pager: user iterators to free device pagesDoug Moore2024-11-212-25/+2
| | | | | | | | | | | Change cdev_mgtdev_page_free_page to take an iterator, rather than an object and page, so that removing the page from the object radix tree can take advantage of locality with iterators. Define a general-purpose function to free all pages, which can be used in several places. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D47692
* xen/blk{front,back}: fix usage of sector sizes different than 512bRoger Pau Monné2024-10-082-18/+47
| | | | | | | | | | | | | | | | | | | | The units of the size reported in the 'sectors' xenbus node is always 512b, regardless of the value of the 'sector-size' node. The sector offsets in the ring requests are also always based on 512b sectors, regardless of the 'sector-size' reported in xenbus. Fix both blkfront and blkback to assume 512b sectors in the required fields. The blkif.h public header has been recently updated in upstream Xen repository to fix the regressions in the specification introduced by later modifications, and clarify the base units of xenstore and shared ring fields. PR: 280884 Reported by: Christian Kujau MFC after: 1 week Sponsored by: Cloud Software Group Reviewed by: markj Differential revision: https://reviews.freebsd.org/D46756
* xen: remove PV suspend/resume support copyrightRoger Pau Monné2024-10-071-34/+1
| | | | | | | | | | | | | | | | Thew code for PV suspend/resume support has long been removed, also remove the copyright notice associated with it. There are still two copyright blocks with (to my understanding) slightly different wordings of the BSD 2 clause license. I however don't feel like merging them due to those wording differences. The removal of the PV suspend/resume code was done in ed95805e90ec0f61683cd402a42e6f915339de7d. Sponsored by: Cloud Software Group Reviewed by: imp Differential revision: https://reviews.freebsd.org/D46860
* xen: expose support for poweroff/reboot/suspend on xenbusRoger Pau Monné2024-10-071-0/+25
| | | | | | | | | | Some toolstacks won't attempt the signal power actions on xenbus unless the VM explicitly exposes support for them. FreeBSD supports all power actions, hence signal on xenbus such support by setting the nodes to the value of "1". Sponsored by: Cloud Software Group Reviewed by: markj Differential review: https://reviews.freebsd.org/D46859
* dev_pager: define free_page for mgt devicesDoug Moore2024-08-212-2/+2
| | | | | | | | | Callers of cdev_pager_free_page in the kernel always have object->type == OBJT_MGTDEVICE. Define a function for them to call that skips the runtime type check in cdev_pager_free. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D46389
* xen/netfront: Decouple XENNET tags from mbuf lifetimesMark Johnston2024-08-021-1/+9
| | | | | | | | | | | | | | | | | | | | netmap's generic mode tries to improve performance by minimizing mbuf allocations. In service of this goal, it maintains an extra reference to the mbuf and polls the counter to see if the driver has released its reference by calling m_freem(). As a result, the extref destructor is not called when expected by the netfront driver, and mbufs tags are not freed. Modify the tx path to release its mbuf tags promptly when reclaiming tx descriptors. They are drawn from a fixed-size pool, so otherwise are quickly exhausted when a netfront interface is in netmap generic mode. Co-authored by: royger MFC after: 2 weeks Fixes: dabb3db7a817 ("xen/netfront: deal with mbuf data crossing a page boundary") Sponsored by: Cloud Software Group Sponsored by: Klara, Inc. Sponsored by: Zenarmor
* xen: introduce a per-arch scratch mapping rangesRoger Pau Monné2024-07-301-6/+71
| | | | | | | | | | | | | | | | | | | The current approach is to create foreign mappings in any unpopulated address on the memory map. This however can cause issues, as late-loaded drivers could then found their MMIO region has been stolen to be used as foreign mapping scratch space (due to the Xen drivers having started first). Add a local resource manager to the xenpv bus driver, architectures can add suitable resources to that resource manager at boot in order to be used in preference of the generic MMIO resource allocator. No functional change, as the introduced scratch mapping range is not yet populated. Sponsored by: Cloud Software Group MFC after: 1 week Reviewed by: Elliott Mitchell <ehem+freebsd@m5p.com> Differential revision: https://reviews.freebsd.org/D46122
* Deprecate contigfree(9) in favour of free(9)Bjoern A. Zeeb2024-07-261-6/+2
| | | | | | | | | | | | | | | As of 9e6544dd6e02c46b805d11ab925c4f3b18ad7a4b contigfree(9) is no longer needed and should not be used anymore. We leave a wrapper for 3rd party code in at least 15.x but remove (almost) all other cases from the tree. This leaves one use of contigfree(9) untouched; that was the original trigger for 9e6544dd6e02 and is handled in D45813 (to be committed seperately later). Sponsored by: The FreeBSD Foundation Reviewed by: markj, kib Tested by: pho (10h stress test run) Differential Revision: https://reviews.freebsd.org/D46099
* newbus: globally replace device_add_child(..., -1) with DEVICE_UNIT_ANYWarner Losh2024-07-251-0/+688
| | | | Sponsored by: Netflix
* xen/debug: remove usage of sbuf_{clear,finish}() on drained sbufRoger Pau Monné2024-05-091-4/+6
| | | | | | | | | | | | | | | | | Using sbuf_clear() on a drained sbuf is explicitly prohibited, and using sbuf_finish() after printing a trace leads to a single trace being printed, as after calling sbuf_finish() further attempts to use the same sbuf will lead to a panic. While there also switch to using xen_emergency_print() instead of attempting to write directly to the hypervisor console. xen_emergency_print() can be implemented per-arch to use a different mechanism than the console hypercall (note the default implementation still uses the console hypercall). Fixes: df62b8a25f47 ('xen: add a handler for the debug interrupt') Sponsored by: Cloud Software Group Reviewed by: markj Differential review: https://reviews.freebsd.org/D45060
* x86/xen: fix accounted interrupt timeRoger Pau Monné2024-04-161-1/+20
| | | | | | | | | | | | | | | | | | | | | | The current addition to the interrupt nesting level in xen_arch_intr_handle_upcall() needs to be compensated in xen_intr_handle_upcall(), otherwise interrupts dispatched by the upcall handler end up seeing a td_intr_nesting_level of 2 or more, which makes them assume there's been an interrupt nesting. Such extra interrupt nesting count lead to statclock() reporting idle time as interrupt, as the call from interrupt context will always be seen as a nested one (td->td_intr_nesting_level >= 2) due to the nesting count increase done by both xen_arch_intr_handle_upcall() and intr_execute_handlers(). Fix this by adjusting the nested interrupt count before dispatching interrupts from xen_intr_handle_upcall(). PR: 277231 Reported by: Matthew Grooms <mgrooms@shrew.net> Fixes: af610cabf1f4 ('xen/intr: adjust xen_intr_handle_upcall() to match driver filter') Sponsored by: Cloud Software Group Reviewed by: Elliott Mitchell <ehem+freebsd@m5p.com>
* x86/xen: introduce non-hypercall based emergency printRoger Pau Monné2024-02-221-5/+10
| | | | | | | | | | | | | | | | | | | | | The current xc_printf() function uses an hypercall in order to send character buffers to the hypervisor for it to print on the hypervisor console (if the hypervisor is configured to print such messages). This requires the hypercall page to be initialized, which is extra work and can go wrong. On x86 instead of using the console IO hypercall use the debug console IO port, also called "port E9 hack". This allows sending characters to Xen using an outb instruction, without any initialization required. Keep the previous hypervisor based implementation by using the weak attribute, which allows each architecture to provide an alternate (arch-specific) implementation. Sponsored by: Cloud Software Group Reviewed by: markj Differential revision: https://reviews.freebsd.org/D43929
* x86/xen: fix out of bounds access to the event channel masks on resumeRoger Pau Monné2024-02-221-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When resuming from migration or suspension all regular event channels ports are reset to the INVALID_EVTCHN value, and drivers should re-initialize them according to the new value provided by the other end of the connection. However, the driver would first attempt to unbind the event channel handler before attempting to bind it using the newly provided port. This unbind uses the stale event channel port that has been set to INVALID_EVTCHN for some operations (notably as a result of the handler removal the interrupt subsystem ends up calling disable intr and source PIC hooks). This was fine when INVALID_EVTCHN was 0, as then the operation would just result in pointless setting of the 0 bit in the different event channel related control arrays (evtchn_{pending,mask} for example). However with the change to define INVALID_EVTCHN as ~0 the write is no longer pointless, and we end up triggering a page-fault, or corrupting random data that happens to be mapped at the array position + ~0 bits. In hindsight the change of INVALID_EVTCHN from 0 to ~0 was way more risky than initially assessed, and I believe has end up resulting in more fragile code for no real benefit. Fix the disable intr and source wrappers to check whether the event channel is valid before attempting to use it. Also introduce some extra KASSERTs in several array accesses in order to avoid out of bounds accesses if INVALID_EVTCHN ever reaches those functions. Fixes: 1797ff962769 ('xen/intr: cleanup event channel number use') MFC after: 1 week Sponsored by: Cloud Software Group Reviewed by: markj Differential revision: https://reviews.freebsd.org/D43928
* netpfil: Use accessor functions and named constants for all tcphdr flagsRichard Scheffenegger2023-12-251-2/+2
| | | | | | | | | | | | | Update all remaining references to the struct tcphdr th_x2 field. This completes the compatibilty of various aspects with AccECN (TH_AE), after the internal ipfw "re-checksum required" was moved to use the TH_RES1 flag. No functional change. Reviewed By: tuexen, #transport, glebius Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D43172
* gntdev: Handle errors from suword32() in gntdev_alloc_gref()Mark Johnston2023-12-261-5/+7
| | | | | | | | | | | | | | Try to copy out output values before handling errors, and check that we did so successfully. In particular, it doesn't seem sensible to ignore errors here, otherwise userspace won't have any way to refer to the allocations. This is in preparation for annotating copyin() and related functions with __result_use_check. Reviewed by: royger MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43145
* xen: add atomic #defines to accomodate differing xen_ulong_t sizesElliott Mitchell2023-12-151-3/+3
| | | | | | | | Alas, ARM declared xen_ulong_t to be 64-bits long, unlike i386 where it matches the word size. As a result, compatibility wrappers are needed for Xen atomic operations. Reviewed by: royger
* xen/intr: correct type of evtchn_enabledElliott Mitchell2023-12-151-1/+1
| | | | | | | evtchn_enabled needs to match the type of Xen's evtchn_mask. As Xen's headers have a type for this, use Xen's type. Reviewed by: royger
* xen/dev: remove __unused from driver argument of identify functionsElliott Mitchell2023-11-285-5/+5
| | | | | | | The driver argument is most certainly now used by these functions. When originally implemented it might have been unused, but not now. Reviewed by: royger
* xen/dev: switch to DEVMETHOD_ENDElliott Mitchell2023-11-284-4/+7
| | | | | | | Switch to the preferred end of the device method table. These hadn't been updated previously. Reviewed by: royger
* xen/intr: remove xenpci headersElliott Mitchell2023-11-281-2/+0
| | | | | | | | | These were needed in the past, since that time the interrupt code has been successfully isolated from the Xen/PCI code. As such a bit of straightforward cleanup. Differential Revision: https://reviews.freebsd.org/D32923 Reviewed by: royger
* xen/intr: correct misuses of Xen handle pointer typeElliott Mitchell2023-11-282-3/+3
| | | | | | | | | | Fix a few spots where handle pointers were incorrectly used. Luckily these appear rarely triggered given how long they've been lurking. Fixes: 76acc41fb7c7 ("Implement vector callback for PVHVM and unify event channel implementations") Fixes: 9f40021f288c ("Introduce a new, HVM compatible, paravirtualized timer driver for Xen.") MFC after: 2 weeks Reviewed by: royger
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-2714-14/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* xen: improve shutdown hookMitchell Horne2023-11-231-5/+11
| | | | | | | | | | | | | Make better use of the shutdown flags. In particular this now handles standard reboot where RB_POWERCYCLE is not set, and indicates a crash when the system has panicked. While here, give the function a prefix. Reviewed by: royger, markj MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42343
* xen-netfront: attempt to make cleanup idempotentRoger Pau Monné2023-11-061-5/+22
| | | | | | | | | | | | | | | | Current cleanup code assumes that all the fields are allocated and/or setup by the time cleanup is called, but this is not always true: a failure in mid-setup of the device will cause the functions to be called with possibly uninitialized fields. Fix the functions to cope with such sate, while also attempting to make the cleanup idempotent. Finally fix an error path during setup that would not mark the device as closed, and hence prevents the kernel from finishing booting. Fixes: 96375eac945c ("xen-netfront: add multiqueue support") Sponsored by: Citrix Systems R&D
* xen: fix initialization of grant table frame arrayRoger Pau Monné2023-11-061-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The current sizing of the array used to store grant table frames is broken, as the calculation: max_nr_glist_frames = (boot_max_nr_grant_frames * GREFS_PER_GRANT_FRAME / (PAGE_SIZE / sizeof(grant_ref_t))); Is plain bogus, for once grant_ref_t is the type of the grant reference, but not the entry used to store such references in the grant frames. But even if the above calculation is switched to use grant_entry_v1_t, it would end up as: max_nr_glist_frames = (boot_max_nr_grant_frames * (PAGE_SIZE / sizeof(grant_entry_v1_t)) / (PAGE_SIZE / sizeof(grant_entry_v1_t))); Which is pointless (note GREFS_PER_GRANT_FRAME has been expanded to (PAGE_SIZE / sizeof(grant_entry_v1_t))). Just use boot_max_nr_grant_frames directly to size the grant table frames array. Fixes: 30d1eefe3937 ("Import OS interfaces to Xen services.") Sponsored by: Citrix Systems R&D
* netfront: fix the support for disabling LRO at boot timeDoug Rabson2023-10-201-2/+6
| | | | | | | | | | | | | | The driver has a tunable hw.xn.enable_lro which is intended to control whether LRO is enabled. This is currently non-functional - even if its set to zero, the driver still requests LRO support from the backend. This change fixes the feature so that if enable_lro is set to zero, LRO no longer appears in the interface capabilities and LRO is not requested from the backend. PR: 273046 MFC after: 1 week Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D41439
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-1622-44/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-163-6/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-129-9/+9
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* Mechanically convert Xen netfront/netback(4) to IfAPIJustin Hibbits2023-04-242-150/+153
| | | | | | Reviewed by: zlei Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D37800
* xen/intr: move sys/x86/xen/xen_intr.c to sys/dev/xen/bus/Julien Grall2023-04-141-0/+1131
| | | | | | | | | | | | The event channel source code or equivalent is needed on all architectures. Since much of this is viable to share, get this moved out of x86-land. Each interrupt interface then needs a distinct back-end implementation. Reviewed by: royger Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com> Original implementation: Julien Grall <julien@xen.org>, 2014-01-13 17:41:04 Differential Revision: https://reviews.freebsd.org/D30236
* xen/intr: move interrupt allocation/release to architectureElliott Mitchell2023-04-141-0/+3
| | | | | | | | | | | | | | | | Simply moving the interrupt allocation and release functions into files which belong to the architecture. Since x86 interrupt handling is quite distinct from other architectures, this is a crucial necessary step. Identifying the border between x86 and architecture-independent is actually quite tricky. Similarly, getting the prototypes for the border right is also quite tricky. Inspired by the work of Julien Grall <julien@xen.org>, 2015-10-20 09:14:56, but heavily adjusted. Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D30936
* xen/intr: move x86 PIC interface to xen_arch_intr.c, introduce wrappersJulien Grall2023-04-141-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The x86 PIC interface is very much x86-specific and not used by other architectures. Since most of xen_intr.c can be shared with other architectures, the PIC interface needs to be broken off. Introduce wrappers for calls into the architecture-dependent interrupt layer. All architectures need roughly the same functionality, but the interface is slightly different between architectures. Due to the wrappers being so thin, all of them are implemented as inline in arch-intr.h. The original implementation was done by Julien Grall in 2015, but this has required major updating. Removal of PVHv1 meant substantial portions disappeared. The original implementation took care of moving interrupt allocation to xen_arch_intr.c, but this has required massive rework and was broken off. In the original implementation the wrappers were normal functions. Some had empty stubs in xen_intr.c and were removed. Reviewed by: royger Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com> Original implementation: Julien Grall <julien@xen.org>, 2015-10-20 09:14:56 Differential Revision: https://reviews.freebsd.org/D30909
* xen/intr: move evtchn_type to intr-internal.hElliott Mitchell2023-04-141-0/+9
| | | | | | | | | | | | The evtchn_type enum is only touched by the Xen interrupt code. Other event channel uses no longer need the value, so that has been moved to restrict its use. Copyright note. The current evtchn_type was introduced at 76acc41fb7c7 by Justin T. Gibbs. This in turn appears to have been heavily inspired by 30d1eefe3937 done by Kip Macy. Reviewed by: royger
* xen/intr: introduce dev/xen/bus/intr-internal.hJulien Grall2023-04-141-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the xenisrc structure which needs to be shared between the core Xen interrupt code and architecture-dependent code into a separate header. A similar situation exists for the NR_EVENT_CHANNELS constant. Turn xi_intsrc into a type definition named xi_arch to reflect the new purpose of being an architectural variable for the interrupt source. This was originally implemented by Julien Grall, but has been heavily modified. The core side was renamed "intr-internal.h" and is #include'd by "arch-intr.h" instead of the other way around. This allows the architecture to add function definitions which use struct xenisrc. The original version only moved xi_intsrc into xen_arch_isrc_t. Moving xi_vector was done by the submitter. The submitter had also moved xi_activehi and xi_edgetrigger into xen_arch_isrc_t. Those disappeared with the removal of PVHv1 support. Copyright note. The current xenisrc structure was introduced at 76acc41fb7c7 by Justin T. Gibbs. Traces remain, but the strength of Copyright claims from before 2013 seem pretty weak. Reviewed by: royger Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com>, 2021-03-17 19:09:01 Original implementation: Julien Grall <julien@xen.org>, 2015-10-20 09:14:56 Differential Revision: https://reviews.freebsd.org/D30648 [royger] - Adjust some line lengths - Fix comment about NR_EVENT_CHANNELS after movement. - Use #include instead of symlinks.
* xen/intr: adjust xen_intr_handle_upcall() to match driver filterElliott Mitchell2023-04-141-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | xen_intr_handle_upcall() has two interfaces. It needs to be called by the x86 assembly code invoked by the APIC. Second, it needs to be called as a driver_filter_t for the XenPCI code and for architectures besides x86. Unfortunately the driver_filter_t interface was implemented as a wrapper around the x86-APIC interface. Now create a simple wrapper for the x86-APIC code, which calls an architecture-independent xen_intr_handle_upcall(). When called via intr_event_handle(), driver_filter_t functions expect preemption to be disabled. This removes the need for critical_enter()/critical_exit() when called this way. The lapic_eoi() call is only needed on x86 in some cases when invoked directly as an APIC vector handler. Additionally driver_filter_t functions have no need to handle interrupt counters. The intrcnt_add() calling function was reworked to match the current situation. intrcnt_add() is now only called via one path. The increment/decrement of curthread->td_intr_nesting_level had previously been left out. Appears this was mostly harmless, but this was noticed during implementation and has been added. CONFIG_X86 is a leftover from use with Linux. While the barrier isn't needed for FreeBSD on x86, it will be needed for FreeBSD on other architectures. Copyright note. xen_intr_intrcnt_add() was introduced at 76acc41fb7c7 by Justin T. Gibbs. xen_intrcnt_init() was introduced at fd036deac1695 by John Baldwin. sys/x86/xen/xen_arch_intr.c was originally created by Julien Grall in 2015 for the purpose of holding the x86 interrupt interface. Later it was found xen_intr_handle_upcall() was better earlier, and the x86 interrupt interface better later. As such the filename and header list belong to Julien Grall, but what those were created for is later. Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D30006
* xen: introduce XEN_CPUID_TO_VCPUID()/XEN_VCPUID()Julien Grall2023-04-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Part of the series for allowing FreeBSD/ARM to run on Xen. On ARM the function is a trivial pass-through, other architectures need distinct implementations. While implementing XEN_VCPUID() as a call to XEN_CPUID_TO_VCPUID() works, that involves multiple accesses to the PCPU region. As such make this a distinct macro. Only callers in machine independent code have been switched. Add a wrapper for the x86 PIC interface to use matching the old prototype. Partially inspired by the work of Julien Grall <julien@xen.org>, 2015-08-01 09:45:06, but XEN_VCPUID() was redone by Elliott Mitchell on 2022-06-13 12:51:57. Reviewed by: royger Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com> Original implementation: Julien Grall <julien@xen.org>, 2014-04-19 08:57:40 Original implementation: Julien Grall <julien@xen.org>, 2014-04-19 14:32:01 Differential Revision: https://reviews.freebsd.org/D29404
* xen: switch to using core atomics for synchronizationElliott Mitchell2023-03-292-20/+16
| | | | | | | | | | | | | | Now that the atomic macros are always genuinely atomic on x86, they can be used for synchronization with Xen. A single core VM isn't too unusual, but actual single core hardware is uncommon. Replace an open-coding of evtchn_clear_port() with the inline. Substantially inspired by work done by Julien Grall <julien@xen.org>, 2014-01-13 17:40:58. Reviewed by: royger MFC after: 1 week
* xen: bump used interface versionRoger Pau Monné2023-03-093-7/+5
| | | | | | | | | This is required for a further change that will make use of a field that was added in version 0x00040d00. No functional change expected. Sponsored by: Citrix Systems R&D
* xen/timer: rename "timer.c" to "xen_timer.c"Elliott Mitchell2023-02-051-1/+1
| | | | | | | | | The better to avoid conflicting with other files given how "timer.c" isn't a very unique name. ARM and RISC-V both have timer.c files. Reviewed by: royger, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/609 Differential Revision: https://reviews.freebsd.org/D36258