aboutsummaryrefslogtreecommitdiff
path: root/sys/x86/include/xen
Commit message (Collapse)AuthorAgeFilesLines
* intr/x86: replace use of vector in interface with intsrcElliott Mitchell2024-05-091-2/+2
| | | | | | | | | | | | | Several x86 interrupt core functions were already operating on intsrc structures. Now switch the remaining 3 to intsrc for consistency. Swap the order of intr_add_handler()'s first two arguments. This matches INTRNG and is more consistent with other functions in this interface. Differential Revision: https://reviews.freebsd.org/D35386 Reviewed by: imp, markj (previous version) Pull Request: https://github.com/freebsd/freebsd-src/pull/1126
* x86/xen: implement early init hookRoger Pau Monné2024-02-221-2/+0
| | | | | | | | | | | | | | | | | | Unify the HVM and PVH early setup, byt making both rely on the hypervisor initialization hook part of identify_hypervisor(). The current initialization takes care of the hypercall page, the sahred info page and does any fixup necessary to metadata video console information if FreeBSD is booted as the initial domain (so the video console is handed from Xen into FreeBSD). Note this has the nice side effect of also allowing to use the Xen console on HVM guests, which allows to get rid of the QEMU emulated uart and still get a nice text console. Sponsored by: Cloud Software Group Reviewed by: markj Differential revision: https://reviews.freebsd.org/D43764
* x86/xen: introduce a Xen early init functionRoger Pau Monné2024-02-221-0/+3
| | | | | | | | | | | | Start by moving the hyeprcall setup to such function. The aim is to have a function that does all the required Xen early initialization for both HVM and PVH, instead of having it scattered across different paths. Sponsored by: Cloud Software Group Reviewed by: markj Differential revision: https://reviews.freebsd.org/D43932
* xen: add atomic #defines to accomodate differing xen_ulong_t sizesElliott Mitchell2023-12-151-0/+10
| | | | | | | | 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/x86: move x86-only variable out of commonElliott Mitchell2023-11-281-0/+3
| | | | | | | | | Commit 27c36a12f15 is an x86-only feature. As such xen_evtchn_needs_ack should only exist on x86. Differential Revision: https://reviews.freebsd.org/D29913 Reviewed by: royger [royger]: adjust comment.
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-161-2/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* xen/intr: move interrupt allocation/release to architectureElliott Mitchell2023-04-141-2/+11
| | | | | | | | | | | | | | | | 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/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: introduce dev/xen/bus/intr-internal.hJulien Grall2023-04-141-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: introduce XEN_CPUID_TO_VCPUID()/XEN_VCPUID()Julien Grall2023-04-141-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | 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/blkback: do not use x86 CPUID in generic codeRoger Pau Monné2022-06-281-0/+2
| | | | | | | | | Move checker for whether Xen creates IOMMU mappings for foreign pages into a helper that's defined in arch-specific code. Reported by: Elliott Mitchell <ehem+freebsd@m5p.com> Fixes: 1d528f95e8ce ('xen/blkback: remove bounce buffering mode') Sponsored by: Citrix Systems R&D
* x86/xen: use x{2}APIC if virtualized by hardwareRoger Pau Monné2022-01-181-0/+2
| | | | | | | | | | | | | Instead of using event channels or hypercalls to deal with IPIs and NMIs. Using a hardware virtualized APIC should be faster than using any PV interface, since the VM exit can be avoided. Xen exposes whether the domain is using hardware assisted x{2}APIC emulation in a CPUID bit. Sponsored by: Citrix Systems R&D
* xen: use an hypercall for shutdown and rebootRoger Pau Monné2022-01-131-7/+0
| | | | | | | | | | | | | | | When running as a Xen guest it's easier to use an hypercall in order to do power management operations (power off, power cycle). Do this for all supported guest types (HVM and PVH). Note that for HVM the power operation could also be done using ACPI, but there's no reason to differentiate between PVH and HVM. While there fix the shutdown handler to properly differentiate between power cycle and power off requests. Reported by: Freddy DISSAUX MFC: 1 week Sponsored by: Citrix Systems R&D
* xen: introduce xen_has_percpu_evtchn()Julien Grall2021-07-281-0/+7
| | | | | | | | | | | | xen_vector_callback_enabled is x86 specific and availability of per-cpu event channel delivery differs on other architectures. Introduce a new helper to check if there's support for per-cpu event channel injection. Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com> Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D29402
* xen/control: introduce xen_pv_shutdown_handler()Julien Grall2021-07-281-0/+7
| | | | | | | | | While x86 only register PV shutdown handler for PV guests. ARM guests are always using HVM and requires the PV shutdown handler. Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com> Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D29406
* xen: introduce xen_pv_disks_disabled()Julien Grall2021-07-281-0/+10
| | | | | | | | | ARM guest is considered as HVM in Freebsd but they only support PV disk (no emulation available). Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com> Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D29403
* xen/netfront: introduce xen_pv_nics_disabled()Julien Grall2021-07-281-0/+10
| | | | | | | | | ARM guest is considered as HVM but it only supports PV nics (no emulation available). Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com> Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D29405
* xen/xen-os: move inclusion of machine/xen-os.h laterElliott Mitchell2021-07-281-0/+4
| | | | | | | | | | | | | Several of x86 enable/disable functions depend upon the xen*domain() functions. As such the xen*domain() functions need to be declared before machine/xen-os.h. Officially declare direct inclusion of machine/xen/xen-os.h verboten as such will break these functions/macros. Remove one such soon to be broken inclusion. Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D29811
* xen: create VM_MEMATTR_XEN for Xen memory mappingsElliott Mitchell2021-07-281-0/+3
| | | | | | | | | | | | | | The requirements for pages shared with Xen/other VMs may vary from architecture to architecture. As such create a macro which various architectures can use. Remove a use of PAT_WRITE_BACK in xenstore.c. This is a x86-ism which shouldn't have been present in a common area. Original idea: Julien Grall <julien@xen.org>, 2014-01-14 06:44:08 Approach suggested by: royger Reviewed by: royger, mhorne Differential Revision: https://reviews.freebsd.org/D29351
* xen: move x86-specific xen_vector_callback_enabled to sys/x86Julien Grall2021-03-151-0/+3
| | | | | | | | This is x86-only and so should not be in the common area. Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com> Reviewed by: royger Differential revision: https://reviews.freebsd.org/D29040
* xen: Code cleanup and small bug fixesRoger Pau Monné2015-10-211-94/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | xen/hypervisor.h: - Remove unused helpers: MULTI_update_va_mapping, is_initial_xendomain, is_running_on_xen - Remove unused define CONFIG_X86_PAE - Remove unused variable xen_start_info: note that it's used inpcifront which is not built at all - Remove forward declaration of HYPERVISOR_crash xen/xen-os.h: - Remove unused define CONFIG_X86_PAE - Drop unused helpers: test_and_clear_bit, clear_bit, force_evtchn_callback - Implement a generic version (based on ofed/include/linux/bitops.h) of set_bit and test_bit and prefix them by xen_ to avoid any use by other code than Xen. Note that It would be worth to investigate a generic implementation in FreeBSD. - Replace barrier() by __compiler_membar() - Replace cpu_relax() by cpu_spinwait(): it's exactly the same as rep;nop = pause xen/xen_intr.h: - Move the prototype of xen_intr_handle_upcall in it: Use by all the platform x86/xen/xen_intr.c: - Use BITSET* for the enabledbits: Avoid to use custom helpers - test_bit/set_bit has been renamed to xen_test_bit/xen_set_bit - Don't export the variable xen_intr_pcpu dev/xen/blkback/blkback.c: - Fix the string format when XBB_DEBUG is enabled: host_addr is typed uint64_t dev/xen/balloon/balloon.c: - Remove set but not used variable - Use the correct type for frame_list: xen_pfn_t represents the frame number on any architecture dev/xen/control/control.c: - Return BUS_PROBE_WILDCARD in xs_probe: Returning 0 in a probe callback means the driver can handle this device. If by any chance xenstore is the first driver, every new device with the driver is unset will use xenstore. dev/xen/grant-table/grant_table.c: - Remove unused cmpxchg - Drop unused include opt_pmap.h: Doesn't exist on ARM64 and it doesn't contain anything required for the code on x86 dev/xen/netfront/netfront.c: - Use the correct type for rx_pfn_array: xen_pfn_t represents the frame number on any architecture dev/xen/netback/netback.c: - Use the correct type for gmfn: xen_pfn_t represents the frame number on any architecture dev/xen/xenstore/xenstore.c: - Return BUS_PROBE_WILDCARD in xctrl_probe: Returning 0 in a probe callback means the driver can handle this device. If by any chance xenstore is the first driver, every new device with the driver is unset will use xenstore. Note that with the changes, x86/include/xen/xen-os.h doesn't contain anymore arch-specific code. Although, a new series will add some helpers that differ between x86 and ARM64, so I've kept the headers for now. Submitted by: Julien Grall <julien.grall@citrix.com> Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D3921 Sponsored by: Citrix Systems R&D Notes: svn path=/head/; revision=289686
* x86/xen: Consolidate xen-os.h in a single placeRoger Pau Monné2015-10-211-0/+132
amd64 and i386 platform code contain very similar xen/xen-os.h The only differences are: - Functions/variables/types which were unused in i386/xen/xen-os.h: * xen_xchg * __xchg_dummy * __xg * __xchg * atomic_t * atomic_inc * rdtscll The functions/variables/types unused in xen-os.h can be dropped and there is no more differences betwen amd64 and i386. The new header is placed in x86/include/xen and each platform will have dummy headers include x86/xen/*.h. This is to be able to include machine/xen/*.h in the PV drivers. Submitted by: Julien Grall <julien.grall@citrix.com> Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D3880 Sponsored by: Citrix Systems R&D Notes: svn path=/head/; revision=289685