aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/xen
Commit message (Collapse)AuthorAgeFilesLines
...
* xen/acpi: only evaluate Processor objects matching online CPUsRoger Pau Monné2022-11-291-0/+29
| | | | | | | | | | | | | | | | Current Xen Processor driver will evaluate any Processor object on the ACPI tables regardless of whether the processor is online or not. Avoid doing so for processors that are not online, as evaluating methods of processors that are not online could lead to accesses to invalid memory, and in any case the data that the driver fetches from the Processor ACPI object only makes sense for processors that are online. Note the CPU related data fetched from Xen using XENPF_get_cpuinfo hypercall could be cached, I leave that as a future optimization. Sponsored by: Citrix Systems R&D Fixes: b93f47eaeef7 ('xen/acpi: upload Cx and Px data to Xen')
* xen/netfront: deal with mbuf data crossing a page boundaryRoger Pau Monné2022-11-031-56/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | There's been a report recently of mbufs with data that crosses a page boundary. It seems those mbufs are generated by the iSCSI target system: https://lists.xenproject.org/archives/html/xen-devel/2021-12/msg01581.html In order to handle those mbufs correctly on netfront use the bus_dma interface and explicitly request that segments must not cross a page boundary. No other requirements are necessary, so it's expected that bus_dma won't need to bounce the data and hence it shouldn't introduce a too big performance penalty. Using bus_dma requires some changes to netfront, mainly in order to accommodate for the fact that now ring slots no longer have a 1:1 match with mbufs, as a single mbuf can use two ring slots if the data buffer crosses a page boundary. Store the first packet of the mbuf chain in every ring slot that's used, and use a mbuf tag in order to store the bus_dma related structures and a refcount to keep track of the pending slots before the mbuf chain can be freed. Reported by: G.R. Tested by: G.R. MFC: 1 week Differential revision: https://reviews.freebsd.org/D33876
* pmap_unmapdev/bios: Accept a pointer instead of a vm_offset_t.John Baldwin2022-09-221-2/+2
| | | | | | | | This matches the return type of pmap_mapdev/bios. Reviewed by: kib, markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D36548
* Adjust function definitions in xen's control.c to avoid clang 15 warningsDimitry Andric2022-07-261-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | With clang 15, the following -Werror warnings are produced: sys/dev/xen/control/control.c:188:15: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] xctrl_poweroff() ^ void sys/dev/xen/control/control.c:194:13: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] xctrl_reboot() ^ void sys/dev/xen/control/control.c:207:14: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] xctrl_suspend() ^ void sys/dev/xen/control/control.c:344:12: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] xctrl_crash() ^ void This is because xctrl_poweroff(), xctrl_reboot(), xctrl_suspend(), and xctrl_crash() are declared with (void) argument lists, but defined with empty argument lists. Make the definitions match the declarations. MFC after: 3 days
* Fix unused variable warning in xen's blkback.cDimitry Andric2022-07-261-3/+0
| | | | | | | | | | | | | | With clang 15, the following -Werror warning is produced: sys/dev/xen/blkback/blkback.c:1561:12: error: variable 'req_seg_idx' set but not used [-Werror,-Wunused-but-set-variable] u_int req_seg_idx; ^ The 'req_seg_idx' variable was used in the for loop later in the xbb_dispatch_io() function, but refactoring in 112cacaee408 got rid of it. Remove the variable since it no longer serves any purpose. MFC after: 3 days
* Fix unused variable warning in xen's blkfront.cDimitry Andric2022-07-261-2/+1
| | | | | | | | | | | | | | With clang 15, the following -Werror warning is produced: sys/dev/xen/blkfront/blkfront.c:602:6: error: variable 'sbp' set but not used [-Werror,-Wunused-but-set-variable] int sbp; ^ The 'sbp' variable was used in the for loop later in the xb_dump() function, but refactoring in e4808c4b2dba got rid of it. Remove the variable since it no longer serves any purpose. MFC after: 3 days
* xen/blkback: do not use x86 CPUID in generic codeRoger Pau Monné2022-06-281-6/+1
| | | | | | | | | 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
* xen/blkback: remove bounce buffering modeRoger Pau Monné2022-06-071-178/+22
| | | | | | | | | | | | | | Remove bounce buffering code for blkback and only attach if Xen creates IOMMU entries for grant mapped pages. Such bounce buffering consumed a non trivial amount of memory and CPU resources to do the memory copy, when it's been a long time since Xen has been creating IOMMU entries for grant maps. Refuse to attach blkback if Xen doesn't advertise that IOMMU entries are created for grant maps. Sponsored by: Citrix Systems R&D
* xen/blkback: fix tear-down issuesRoger Pau Monné2022-06-071-33/+30
| | | | | | | | | | | | | | Handle tearing down a blkback that hasn't been fully initialized. This requires carefully checking that fields are allocated before trying to access them. Also communication memory is allocated before setting XBBF_RING_CONNECTED, so gating it's freeing on XBBF_RING_CONNECTED being set is wrong and will lead to memory leaks. Also stop using xbb_disconnect() in error paths. Use xenbus_dev_fatal and let the normal disconnection procedure take care of the cleanup. Reported by: Ze Dupsys <zedupsys@gmail.com> Sponsored by: Citrix Systems R&D
* kerneldump: remove physical argument from d_dumperMitchell Horne2022-05-131-2/+1
| | | | | | | | | | | The physical address argument is essentially ignored by every dumper method. In addition, the dump routines don't actually pass a real address; every call to dump_append() passes a value of zero for physical. Reviewed by: markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D35173
* xen: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin2022-05-0619-54/+20
|
* xen: Use devclass_find to lookup devclasses in identify.John Baldwin2022-04-252-4/+4
| | | | | | | | While here, use driver->name instead of hardcoding the xenpv and xen_et strings both for devclass_find() and BUS_ADD_CHILD(). Reviewed by: Elliott Mitchell <ehem+freebsd@m5p.com>, imp, royger Differential Revision: https://reviews.freebsd.org/D35001
* xen/acpi: upload Cx and Px data to XenRoger Pau Monné2022-04-121-0/+605
| | | | | | | | | | | | | | | | | | | | | | When FreeBSD is running as dom0 (initial domain) on a Xen system it has access to the native ACPI tables and is the OSPM. However the hypervisor is the entity in charge of the CPU idle and frequency states, and in order to perform this duty it requires information found the ACPI dynamic tables that can only be parsed by the OSPM. Introduce a new Xen specific ACPI driver to fetch the Processor related information and upload it to Xen. Note that this driver needs to take precedence over the generic ACPI CPU driver when running as dom0, so downgrade the probe score of the native driver to BUS_PROBE_DEFAULT in order for the Xen specific driver to use BUS_PROBE_SPECIFIC. Tested on an Intel NUC to successfully parse and upload both the Cx and Px states to Xen. Sponsored by: Citrix Systems R&D Reviewed by: jhb kib Differential revision: https://reviews.freebsd.org/D34841
* xen netback: Remove write-only variables.John Baldwin2022-04-062-11/+5
|
* stack_zero is not needed before stack_saveEric van Gyzen2022-03-261-1/+0
| | | | | | | The man page was recently clarified to commit to this contract. MFC after: 1 week Sponsored by: Dell EMC Isilon
* vfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd)Mateusz Guzik2022-03-241-1/+1
|
* xen: switch to use headers in contribElliott Mitchell2022-02-079-15/+15
| | | | | | | | | | These headers originate with the Xen project and shouldn't be mixed with the main portion of the FreeBSD kernel. Notably they shouldn't be the target of clean-up commits. Switch to use the headers in sys/contrib/xen. Reviewed by: royger
* xen/grant-table: remove explicit linear mapping additionsRoger Pau Monné2022-02-071-22/+6
| | | | | | | | | | | | | | There's no need to explicitly add linear mappings for the grant table area, as the memory is allocated using xenmem_alloc and it should already have a linear mapping that can be obtained using rman_get_virtual. While there also remove the return value of gnttab_map, since there's no return value anymore. Sponsored by: Citrix Systems R&D Reviewed by: Elliott Mitchell <ehem+freebsd@m5p.com> Differential revision: https://reviews.freebsd.org/D29602
* xen: use an hypercall for shutdown and rebootRoger Pau Monné2022-01-131-12/+6
| | | | | | | | | | | | | | | 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/blkfront: Remove CTLFLAG_NEEDGIANT from sysctl.Alexander Motin2021-12-261-1/+1
| | | | | | It only converts bit field into string. It does not need locking. MFC after: 1 week
* xen: plug some of set-but-not-used varsMateusz Guzik2021-12-157-14/+7
| | | | Sponsored by: Rubicon Communications, LLC ("Netgate")
* Create wrapper for Giant taken for newbusWarner Losh2021-12-101-5/+4
| | | | | | | | | | | Create a wrapper for newbus to take giant and for busses to take it too. bus_topo_lock() should be called before interacting with newbus routines and unlocked with bus_topo_unlock(). If you need the topology lock for some reason, bus_topo_mtx() will provide that. Sponsored by: Netflix Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D31831
* xen/dev: remove write-only variableElliott Mitchell2021-11-301-3/+1
| | | | | | | | This was found while looking for driver_filter_t functions which got the trap frame from the argument. This particular instance it isn't even used, so remove now lest someone else get to it first. Reviewed by: mhorne
* xen(4): Fix two typos in source code commentsGordon Bergling2021-11-301-2/+2
| | | | | | - s/segement/segment/ MFC after: 3 days
* vfs: remove the unused thread argument from NDINIT*Mateusz Guzik2021-11-251-1/+1
| | | | | | See b4a58fbf640409a1 ("vfs: remove cn_thread") Bump __FreeBSD_version to 1400043.
* xen/privcmd: fix MMAP_RESOURCE ioctl to copy out resultsRoger Pau Monné2021-11-181-5/+3
| | | | | | | | | | | The current definition for the MMAP_RESOURCE ioctl was wrong as it didn't copy back the result to the caller. Fix the definition and also remove the bogus attempt to copy the result in the implementation. Note such copy back is only needed when querying the size of a resource. Sponsored by: Citrix Systems R&D
* xen/devices: purge uses of intr_machdep.hElliott Mitchell2021-10-212-2/+0
| | | | | | | | Devices in sys/dev should be architecture-independent and NOT #include intr_machdep.h. Reviewed by: mhorne royger Differential Revision: https://reviews.freebsd.org/D29959
* xen/pcifront: purge from treeRoger Pau Monné2021-10-211-688/+0
| | | | | | Xen pcifront has been unhooked from the build for a long time, as it's only used by PV mode which FreeBSD doesn't support. Remove it from the tree.
* Convert vm_page_alloc() callers to use vm_page_alloc_noobj().Mark Johnston2021-10-202-23/+9
| | | | | | | | | | | | | | | Remove page zeroing code from consumers and stop specifying VM_ALLOC_NOOBJ. In a few places, also convert an allocation loop to simply use VM_ALLOC_WAITOK. Similarly, convert vm_page_alloc_domain() callers. Note that callers are now responsible for assigning the pindex. Reviewed by: alc, hselasky, kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31986
* xen: use correct cache attributes for Xen specific memory regionsRoger Pau Monné2021-08-121-1/+8
| | | | | | | | | bus_activate_resource maps memory regions as uncacheable on x86, which is more strict than required for regions allocated using xenmem_alloc, so don't rely on bus_activate_resource and instead map the region using pmap_mapdev_attr and VM_MEMATTR_XEN as the cache attribute. Sponsored by: Citrix Systems R&D
* xen: introduce xen_has_percpu_evtchn()Julien Grall2021-07-281-1/+1
| | | | | | | | | | | | 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: print warning on call of xctrl_suspend()Julien Grall2021-07-281-1/+9
| | | | | | | | | | | | Presently suspend/resume and migration aren't supported on Xen/ARM. As such this shouldn't ever occur. This likely applies to future Xen architectures (RISC-V) and xctrl_suspend() needs dependency on intr_machdep.h fixed. Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com> Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D29599
* xen/grant_table: cleanup max_nr_grant_frames()Elliott Mitchell2021-07-281-4/+1
| | | | | | | | | This is no more or less than returning the smaller of two values. Since this is what min() does, use that to shrink max_nr_grant_frames() down to the single line. Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D29840
* xen/control: introduce xen_pv_shutdown_handler()Julien Grall2021-07-281-1/+1
| | | | | | | | | 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-1/+1
| | | | | | | | | 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-1/+1
| | | | | | | | | 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/xenpv: remove low memory limit for non-x86Elliott Mitchell2021-07-281-1/+5
| | | | | | | | | For embedded devices reserved addresses will be known in advance. More recently added devices will also likely be correctly updated. As a result using any available address is reasonable on non-x86. Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D29304
* xen/control: gate x86 specific code in the preprocessorElliott Mitchell2021-07-281-0/+4
| | | | | | | | | | | Commit 152265223048 was implemented strictly for x86. Unfortunately one of the pieces was mixed into a common area breaking other architectures. For now disable these bits on !x86, this should be cleaned up later. Fixes: 152265223048 ('xen: fix dropping bitmap IPIs during resume') Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D29306
* xen: create VM_MEMATTR_XEN for Xen memory mappingsElliott Mitchell2021-07-283-3/+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/xen/xenpv.c to dev/xen/bus/xenpv.cJulien Grall2021-07-281-0/+200
| | | | | | | | | | Minor changes are necessary to make this processor-independent, but moving the file out of x86 and into common is the first step (so others don't add /more/ x86-isms). Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com> Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D29042
* x86/xen: remove PVHv1 codeRoger Pau Monné2021-05-173-275/+0
| | | | | | | | | | | PVHv1 was officially removed from Xen in 4.9, so just axe the related code from FreeBSD. Note FreeBSD supports PVHv2, which is the replacement for PVHv1. Sponsored by: Citrix Systems R&D Reviewed by: kib, Elliott Mitchell Differential Revision: https://reviews.freebsd.org/D30228
* xen/blkback: fix reconnection of backendRoger Pau Monné2021-05-111-35/+48
| | | | | | | | | | | | | | | | | | | | | | The hotplug script will be executed only once for each backend, regardless of the frontend triggering reconnections. Fix blkback to deal with the hotplug script being executed only once, so that reconnections don't stall waiting for a hotplug script execution that will never happen. As a result of the fix move the initialization of dev_mode, dev_type and dev_name to the watch callback, as they should be set only once the first time the backend connects. This fix is specially relevant for guests wanting to use UEFI OVMF firmware, because OVMF will use Xen PV block devices and disconnect afterwards, thus allowing them to be used by the guest OS. Without this change the guest OS will stall waiting for the block backed to attach. Fixes: de0bad00010c ('blkback: add support for hotplug scripts') MFC after: 1 week Sponsored by: Citrix Systems R&D
* xen/netback: do not attempt to connect in the Initialised stateRoger Pau Monné2021-03-231-1/+1
| | | | | | | | | | | | Only attempt to fetch the configuration data and connect the shared ring once the frontend has switched to the 'Connected' state. This seems to be inline with what Linux netback does, and is required to make newer versions of NetBSD netfront work, since NetBSD only publishes the required configuration before switching to the Connected state. MFC after: 1 week Sponsored by: Citrix Systems R&D
* xnb: Don't pass SIOC{ADD,DEL}MULTI to ifmedia_ioctl().John Baldwin2021-03-221-0/+1
| | | | | | | | | | ifmedia_ioctl() doesn't handle these requests, and this matches what xn does. Reviewed by: royger MFC after: 1 week Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D29296
* xen: remove x86-ism from Xen common codeElliott Mitchell2021-03-011-1/+1
| | | | | | | | PAT_WRITE_BACK is x86-only, whereas sys/dev/xen could be shared between multiple architectures. Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D28831
* xen-blkback: fix leak of grant maps on ring setup failureRoger Pau Monné2021-02-221-0/+21
| | | | | | | | | | | | | | | Multi page rings are mapped using a single hypercall that gets passed an array of grants to map. One of the grants in the array failing to map would lead to the failure of the whole ring setup operation, but there was no cleanup of the rest of the grant maps in the array that could have likely been created as a result of the hypercall. Add proper cleanup on the failure path during ring setup to unmap any grants that could have been created. This is part of XSA-361. Sponsored by: Citrix Systems R&D
* xen/efi: introduce a PV interface for EFI run time services for dom0Roger Pau Monné2021-02-161-0/+255
| | | | | | | | | | | | | FreeBSD when running as a dom0 under Xen is not supposed to access the run time services directly, and instead should proxy the calls through Xen using an hypercall interface that exposes access to selected run time services. Implement the efirt interface on top of the Xen provided hypercalls. Sponsored by: Citrix Systems R&D Reviewed by: kib Differential revision: https://reviews.freebsd.org/D28621
* xen/privcmd: implement the restrict ioctlRoger Pau Monne2021-01-111-0/+82
| | | | | | | | | | | Use an interface compatible with the Linux one so that the user-space libraries already using the Linux interface can be used without much modifications. This allows an open privcmd instance to limit against which domains it can act upon. Sponsored by: Citrix Systems R&D
* xen/privcmd: implement the dm op ioctlRoger Pau Monne2021-01-111-0/+49
| | | | | | | | | | | Use an interface compatible with the Linux one so that the user-space libraries already using the Linux interface can be used without much modifications. This allows user-space to make use of the dm_op family of hypercalls, which are used by device models. Sponsored by: Citrix Systems R&D
* xen/privcmd: implement the map resource ioctlRoger Pau Monne2021-01-111-0/+52
| | | | | | | | | The interface is mostly the same as the Linux ioctl, so that we don't need to modify the user-space libraries that make use of it. The ioctl is just a proxy for the XENMEM_acquire_resource hypercall. Sponsored by: Citrix Systems R&D