- Oct 31, 2023
-
-
Andre Przywara authored
Uses the new VGIC KVM device attribute to set the maintenance IRQ. This is fixed to use PPI 9, as a platform decision made by kvmtool, matching the SBSA recommendation. Signed-off-by:Andre Przywara <andre.przywara@arm.com>
-
Andre Przywara authored
When trying to run with "--nested" on a kernel that doesn't support it, at the moment kvmtool will bail out with a not very meaningful error message. Use the kernel's capability mechanism to check this before trying to enable virtual EL2. TO BE SQUASHED once the KVM_CAP_ARM_EL2 value has been finalised. Signed-off-by:Andre Przywara <andre.przywara@arm.com>
-
Andre Przywara authored
Update the kernel headers to include the preliminary nested virt additions, as taken from Marc's arm-platforms.git/kvm-arm64/nv-6.7-WIP branch. Should be replaced with the real headers from the then-mainline Linux tree, once full NV support gets merged. Signed-off-by:Andre Przywara <andre.przywara@arm.com>
-
Andre Przywara authored
The ARMv8.3 architecture update includes support for nested virtualization. Allow the user to specify "--nested" to start a guest in (virtual) EL2 instead of EL1. This will also change the PSCI conduit from HVC to SMC in the device tree. If the kernel does not support nested virtualization, kvmtool will just bail out at this point without a meaningful error message. This will be fixed once the proper KVM_CAP_ARM_EL2 value has been assigned. Signed-off-by:Andre Przywara <andre.przywara@arm.com>
-
- Sep 18, 2023
-
-
Tan En De authored
KVM_PCI_CFG_AREA is registered with kvm__register_mmio during pci__init, but it isn't deregistered during pci__exit. So, this commit is to kvm__deregister_mmio the KVM_PCI_CFG_AREA on pci__exit. Signed-off-by:
Tan En De <ende.tan@starfivetech.com> Link: https://lore.kernel.org/r/20230916052303.1003-1-ende.tan@starfivetech.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Keir Fraser authored
Avoid using VIRTIO_IRQ_{HIGH,LOW} which belong to a different namespace. Instead define VIRTIO_PCI_ISR_QUEUE as a logical extension of the VIRTIO_PCI_ISR_* namespace. Since this bit flag is missing from a header imported verbatim from Linux, define it directly in pci.c. Signed-off-by:Keir Fraser <keirf@google.com> Link: https://lore.kernel.org/r/20230912151623.2558794-4-keirf@google.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Keir Fraser authored
The PCI ISR is defined in the virtio spec as a set of flags which can be bitwise ORed together. Therefore we should avoid clearing previously-set flags. Signed-off-by:
Keir Fraser <keirf@google.com> Link: https://lore.kernel.org/r/20230912151623.2558794-3-keirf@google.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Keir Fraser authored
The PCI legacy IRQ line is level triggered, but is treated as edge triggered via kvm__irq_trigger() for signalling of config changes. Fix this by using kvm__irq_level(), as for queue signalling. Signed-off-by:
Keir Fraser <keirf@google.com> Link: https://lore.kernel.org/r/20230912151623.2558794-2-keirf@google.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Alexandru Elisei authored
It can be useful to disable all network devices, for example, to remove the compat warning for the default network device when the guest does not initialize it. This can be done by passing mode=none to the --network command line option, but without in-depth knowledge of the code, there is no way for the user to know this. Update the help message for -n/--network to explain what mode=none does. Signed-off-by:
Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20230907171655.6996-3-alexandru.elisei@arm.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Alexandru Elisei authored
This reverts commit 15757e8e . Turns out there's a way to disable the default virtio-net device: pass --network mode=none when running a VM. Signed-off-by:
Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20230907171655.6996-2-alexandru.elisei@arm.com Signed-off-by:
Will Deacon <will@kernel.org>
-
- Jul 20, 2023
-
-
Anup Patel authored
Currently, we ensure that guest RAM alloc size is at least 2M for THP which works well for RV64 but breaks hugepage support for RV32. To fix this, we use 4M as hugepage size for RV32. Fixes: 867159a7 ("riscv: Implement Guest/VM arch functions") Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20230712163501.1769737-10-apatel@ventanamicro.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Anup Patel authored
When the Ssaia extension is available expose it to the guest. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20230712163501.1769737-9-apatel@ventanamicro.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Andrew Jones authored
When the Zicboz extension is available expose it to the guest. Also provide the guest the size of the cache block through DT. Signed-off-by:
Andrew Jones <ajones@ventanamicro.com> Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20230712163501.1769737-8-apatel@ventanamicro.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Anup Patel authored
The zbb extension allows software to use basic bitmanip instructions. Let us add the zbb extension to the Guest device tree whenever it is supported by the host. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20230712163501.1769737-7-apatel@ventanamicro.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Anup Patel authored
Let us follow alphabetical order for listing ISA extensions in the isa_info_arr[] array. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20230712163501.1769737-6-apatel@ventanamicro.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Anup Patel authored
We add "--disable-sbi-<xyz>" options to disable various SBI extensions visible to the Guest. This allows users to disable deprecated/redundant SBI extensions. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20230712163501.1769737-5-apatel@ventanamicro.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Anup Patel authored
We add command-line parameter to set custom mvendorid, marchid, and mimpid so that users can show fake CPU type to Guest/VM which does not match underlying Host CPU. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20230712163501.1769737-4-apatel@ventanamicro.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Anup Patel authored
We sync-up Linux headers to get latest KVM RISC-V headers having SBI extension enable/disable, Zbb, Zicboz, and Ssaia support. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20230712163501.1769737-3-apatel@ventanamicro.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Anup Patel authored
Latest x86 UAPI headers uses __DECLARE_FLEX_ARRAY() macro so let us take this macro from Linux UAPI header and add it to include/linux/stddef.h. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20230712163501.1769737-2-apatel@ventanamicro.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Alexandru Elisei authored
Compat messages are there to print a warning when the user creates a virtio device for the VM, but the guest doesn't initialize it. This generally works great, except that kvmtool will always create a virtio-net device, even if the user hasn't specified one, which means that each time kvmtool loads a guest that doesn't probe the network interface, the user will get the compat warning. This can get particularly annoying when running kvm-unit-tests, which doesn't need to use a network interface, and the virtio-net warning is displayed after each test. Let's fix this by skipping the compat message in the case of the automatically created virtio-net device. This lets kvmtool keep the compat warnings as they are, but removes the false positive. Even if the user is relying on kvmtool creating the default virtio-net device, a missing network interface in the guest is very easy to discover. Signed-off-by:
Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20230714152909.31723-1-alexandru.elisei@arm.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Fuad Tabba authored
Calculate the guest ram size based a ratio proportional to the number of pages available, rather than the amount of memory available in bytes, in the host. This is to ensure that the result is always page-aligned. If the result of get_ram_size() isn't aligned to the host page size, it triggers an error in __kvm_set_memory_region(), called via the KVM_SET_USER_MEMORY_REGION ioctl, which requires the size to be page-aligned. Fixes: 18bd8c3b ("kvm tools: Don't use all of host RAM for guests by default") Signed-off-by:
Fuad Tabba <tabba@google.com> Link: https://lore.kernel.org/r/20230717121232.3559948-4-tabba@google.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Fuad Tabba authored
Factor out getting the number of physical pages available for the host into a separate function. This will be used in a subsequent patch. No functional change intended. Signed-off-by:
Fuad Tabba <tabba@google.com> Link: https://lore.kernel.org/r/20230717121232.3559948-3-tabba@google.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Fuad Tabba authored
Factor out getting the page size of the host into a separate function. This will be used in a subsequent patch. No functional change intended. Signed-off-by:
Fuad Tabba <tabba@google.com> Link: https://lore.kernel.org/r/20230717121232.3559948-2-tabba@google.com Signed-off-by:
Will Deacon <will@kernel.org>
-
- Jul 12, 2023
-
-
Alexandru Elisei authored
Add --loglevel command line argument, with the possible values of 'error', 'warning', 'info' or 'debug' to control what messages kvmtool displays. The argument functions similarly to the Linux kernel parameter, when lower verbosity levels hide all message with a higher verbosity (for example, 'warning' hides info and debug messages, allows warning and error messsages). The default level is 'info', to match the current behaviour. --debug has been kept as a legacy option, which might be removed in the future. Reviewed-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Signed-off-by:
Alexandru Elisei <alexandru.elisei@arm.com> Reviewed-by:
Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20230707151119.81208-5-alexandru.elisei@arm.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Alexandru Elisei authored
pr_debug() is special, because it can be suppressed with a command line argument, and because it needs to be a macro to capture the correct filename, function name and line number. Display debug messages with the prefix "Debug", to make it clear that those aren't informational messages. Reviewed-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Signed-off-by:
Alexandru Elisei <alexandru.elisei@arm.com> Reviewed-by:
Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20230707151119.81208-4-alexandru.elisei@arm.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Alexandru Elisei authored
To prepare for allowing finer control over the messages that kvmtool displays, replace printf() and fprintf() with the pr_* macros. Minor changes were made to fix coding style issues that were pet peeves for the author. And use pr_err() in kvm_cpu__init() instead of pr_warning() for fatal errors. Also, fix the message when printing the exit code for KVM_EXIT_UNKNOWN by removing the '0x' part, because it's printing a decimal number, not a hexadecimal one (the format specifier is %llu, not %llx). Signed-off-by:
Alexandru Elisei <alexandru.elisei@arm.com> Reviewed-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Reviewed-by:
Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20230707151119.81208-3-alexandru.elisei@arm.com Signed-off-by:
Will Deacon <will@kernel.org>
-
Alexandru Elisei authored
Of all the pr_* functions, pr_err() is the only function that returns a value, which is -1. The code in parse_options is the only code that relies on pr_err() returning a value, and that value must be exactly -1, because it is being treated differently than the other return values. This makes the code opaque, because it's not immediately obvious where that value comes from, and fragile, as a change in the return value of pr_err would break it. Make pr_err() more like the other functions and don't return a value. Reviewed-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Signed-off-by:
Alexandru Elisei <alexandru.elisei@arm.com> Reviewed-by:
Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20230707151119.81208-2-alexandru.elisei@arm.com Signed-off-by:
Will Deacon <will@kernel.org>
-
- Jul 06, 2023
-
-
Jean-Philippe Brucker authored
The MSI and MSI-X implementations is a bit complex, because it keeps track of capability and vector states as seen by both the guest and the host. Add a few comments about those states and rename them to something more accurate. What's called phys_state at the moment represents the software state maintained by VFIO and kvmtool, rather than the physical MSI capability, so host_state is more correct. To be consistent, rename virt_state to guest_state as well. Signed-off-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Link: https://lore.kernel.org/r/20230628112331.453904-4-jean-philippe@linaro.org Signed-off-by:
Will Deacon <will@kernel.org>
-
Jean-Philippe Brucker authored
MSI vectors can be masked and unmasked individually when using the MSI-X capability, or when the classic MSI capability supports Per-Vector Masking. At the moment we incorrectly initialize the guest's view of the vectors (virt_state) as masked, so when using a MSI capability without Per-Vector Masking, the vectors are never unmasked and MSIs don't work. Initialize them unmasked instead. Since VFIO doesn't support per-vector masking we implement it by disconnecting the irqfd, and keep track of it with the vector's phys_state. Initially the irqfd is not connected so phys_state is masked. Reported-by:
Vivek Gautam <vivek.gautam@arm.com> Signed-off-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Link: https://lore.kernel.org/r/20230628112331.453904-3-jean-philippe@linaro.org Signed-off-by:
Will Deacon <will@kernel.org>
-
- Jun 08, 2023
-
-
Jean-Philippe Brucker authored
Vhost interprets the VIRTIO_F_ACCESS_PLATFORM flag as if accesses need to use vhost-iotlb, and since kvmtool does not implement vhost-iotlb, vhost will fail to access the virtqueue. This fix is preventive. Kvmtool does not set VIRTIO_F_ACCESS_PLATFORM at the moment but the Arm CCA and pKVM changes will likely hit the issue (as experienced with the CCA development tree), so we might as well fix it now. Signed-off-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Link: https://lore.kernel.org/r/20230606130426.978945-18-jean-philippe@linaro.org Signed-off-by:
Will Deacon <will@kernel.org>
-
Jean-Philippe Brucker authored
To signal a virtqueue, a kernel vhost worker writes an eventfd registered by kvmtool with VHOST_SET_VRING_CALL. When MSIs are supported, this eventfd is connected directly to KVM IRQFD to inject the interrupt into the guest. However direct injection does not work when MSIs are not supported. The virtio-mmio transport does not support MSIs at all, and even with virtio-pci, the guest may use INTx if the irqchip does not support MSIs (e.g. irqchip=gicv3 on arm64). In this case, injecting the interrupt requires writing an ISR register in virtio to signal that it is a virtqueue notification rather than a config change. Add a thread that polls the vhost eventfd for interrupts, and notifies the guest. When the guest configures MSIs, disable polling on the eventfd and enable direct injection. Signed-off-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Link: https://lore.kernel.org/r/20230606130426.978945-17-jean-philippe@linaro.org Signed-off-by:
Will Deacon <will@kernel.org>
-
Jean-Philippe Brucker authored
Both ioeventfd and ipc use an epoll thread roughly the same way. In order to add a new epoll user, factor the common bits into epoll.c Slight implementation changes which shouldn't affect behavior: * At the moment ioeventfd mixes file descriptor (for the stop event) and pointers in the epoll_event.data union, which could in theory cause aliasing. Use a pointer for the stop event instead. kvm-ipc uses only file descriptors. It could be changed but since epoll.c compares the stop event pointer first, the risk of aliasing with an fd is much lower there. * kvm-ipc uses EPOLLET, edge-triggered events, but having the stop event level-triggered shouldn't make a difference. Signed-off-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Link: https://lore.kernel.org/r/20230606130426.978945-16-jean-philippe@linaro.org Signed-off-by:
Will Deacon <will@kernel.org>
-
Jean-Philippe Brucker authored
vhost-net requires to open one file descriptor for each TX/RX queue pair. At the moment kvmtool does not support multi-queue vhost: it issues all vhost ioctls on the first pair, and the other pairs are broken. Refuse the enable vhost when the user asks for multi-queue. Using multi-queue vhost-net also requires creating the tap interface with the 'multi_queue' parameter. Signed-off-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Link: https://lore.kernel.org/r/20230606130426.978945-15-jean-philippe@linaro.org Signed-off-by:
Will Deacon <will@kernel.org>
-
Jean-Philippe Brucker authored
The suggested CONFIG options do not exist. Signed-off-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Link: https://lore.kernel.org/r/20230606130426.978945-14-jean-philippe@linaro.org Signed-off-by:
Will Deacon <will@kernel.org>
-
Jean-Philippe Brucker authored
Add a few instructions for testing the devices. Testing devices like vhost-scsi or vsock may seem daunting but is relatively easy. Signed-off-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Link: https://lore.kernel.org/r/20230606130426.978945-13-jean-philippe@linaro.org Signed-off-by:
Will Deacon <will@kernel.org>
-
Jean-Philippe Brucker authored
Move VHOST_GET_FEATURES to get_host_features() so the guest is aware of what will actually be supported. This removes the invalid guess about VIRTIO_NET_F_MRG_RXBUF (if vhost didn't support it, we shouldn't let the guest negotiate it). Note the masking of VHOST_NET_F_VIRTIO_NET_HDR when handing features to vhost. Unfortunately the vhost-net driver interprets VIRTIO_F_ANY_LAYOUT as VHOST_NET_F_VIRTIO_NET_HDR, which is specific to vhost and forces vhost-net to supply the vnet header. Since this is done by tap, we don't want to set the bit. Signed-off-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Link: https://lore.kernel.org/r/20230606130426.978945-12-jean-philippe@linaro.org Signed-off-by:
Will Deacon <will@kernel.org>
-
Jean-Philippe Brucker authored
We should advertise to the guest only the features supported by vhost and kvmtool. Then we should set in vhost only the features acked by the guest. Move vhost feature query to get_host_features(), and vhost feature setting to device start (after the guest has acked features). This fixes vsock because we used to enable all vhost features including VIRTIO_F_ACCESS_PLATFORM, which forces vhost to use vhost-iotlb and isn't supported by kvmtool. Signed-off-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Link: https://lore.kernel.org/r/20230606130426.978945-11-jean-philippe@linaro.org Signed-off-by:
Will Deacon <will@kernel.org>
-
Jean-Philippe Brucker authored
We should advertise to the guest only the features supported by vhost and kvmtool. Then we should set in vhost only the features acked by the guest. Move vhost feature query to get_host_features(), and vhost feature setting to device start (after the guest has acked features). This fixes scsi because we used to enable all vhost features including VIRTIO_SCSI_F_T10_PI which changes the request layout and caused inconsistency between guest and vhost. Signed-off-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Link: https://lore.kernel.org/r/20230606130426.978945-10-jean-philippe@linaro.org Signed-off-by:
Will Deacon <will@kernel.org>
-
Jean-Philippe Brucker authored
The Linux guest does not find any target when 'max_target' is 0. Initialize it to the maximum defined by virtio, "5.6.4 Device configuration layout": max_target SHOULD be less than or equal to 255. Signed-off-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Link: https://lore.kernel.org/r/20230606130426.978945-9-jean-philippe@linaro.org Signed-off-by:
Will Deacon <will@kernel.org>
-
Jean-Philippe Brucker authored
The SCSI backend doesn't call disk_image__new() so the disk ops are NULL. Check for this case on exit. Signed-off-by:
Jean-Philippe Brucker <jean-philippe@linaro.org> Link: https://lore.kernel.org/r/20230606130426.978945-8-jean-philippe@linaro.org Signed-off-by:
Will Deacon <will@kernel.org>
-