pc, pci, virtio, vhost: fixes, features
Subsystems (2)
The following changes since commit 4f50c1673a89b07f376ce5c42d22d79a79cd466d:
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' into staging (2018-05-22 09:43:58 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
for you to fetch changes up to 63b88968f139b6a77f2f81e6f1eedf70c0170a85:
intel-iommu: rework the page walk logic (2018-05-23 17:34:05 +0300)
----------------------------------------------------------------
pc, pci, virtio, vhost: fixes, features
Beginning of merging vDPA, new PCI ID, a new virtio balloon stat, intel iommu rework fixing a couple of security problems (no CVEs yet), fixes all over the place.
----------------------------------------------------------------
Changpeng Liu (1):
contrib/vhost-user-blk: enable protocol feature for vhost-user-blk
Dr. David Alan Gilbert (2):
vhost-user+postcopy: Use qemu_set_nonblock
libvhost-user: Send messages with no data
Gerd Hoffmann (1):
allocate pci id for mdpy
Jonathan Helman (1):
virtio-balloon: add hugetlb page allocation counts
Michael S. Tsirkin (7):
update-linux-headers.sh: drop kvm_para.h hacks include/standard-headers: add asm-x86/kvm_para.h x86/cpu: use standard-headers/asm-x86.kvm_para.h
linux-headers: drop kvm_para.h update-linux-headers.sh: unistd.h, kvm consistency
linux-headers: add unistd.h on all arches
linux-headers: add kvm header for mips
Peter Xu (10):
vhost: add trace for IOTLB miss
intel-iommu: send PSI always even if across PDEs
intel-iommu: remove IntelIOMMUNotifierNode
intel-iommu: add iommu lock
intel-iommu: only do page walk for MAP notifiers
intel-iommu: introduce vtd_page_walk_info
intel-iommu: pass in address space when page walk
intel-iommu: trace domain id during page walk
util: implement simple iova tree
intel-iommu: rework the page walk logic
Richard Henderson (1):
hw/virtio: Fix brace Werror with clang 6.0.0
Ross Zwisler (1):
nvdimm: fix typo in label-size definition
Tiwei Bie (3):
vhost-user: add Net prefix to internal state structure
vhost-user: support receiving file descriptors in slave_read
virtio: support setting memory region based host notifier
Zihan Yang (1):
hw/pci-host/q35: Replace hardcoded value with macro
docs/specs/pci-ids.txt | 1 +
docs/virtio-balloon-stats.txt | 2 +
include/hw/i386/intel_iommu.h | 19 +-
include/hw/mem/nvdimm.h | 2 +-
include/hw/pci/pci.h | 1 +
include/hw/virtio/virtio-bus.h | 2 +
include/hw/virtio/virtio.h | 2 +
include/qemu/iova-tree.h | 134 ++++
.../standard-headers}/asm-x86/kvm_para.h | 49 +-
include/standard-headers/linux/virtio_balloon.h | 4 +-
include/sysemu/kvm.h | 1 -
linux-headers/asm-arm/bitsperlong.h | 1 +
linux-headers/asm-arm/kvm_para.h | 2 -
linux-headers/asm-arm64/bitsperlong.h | 24 +
linux-headers/asm-arm64/kvm_para.h | 1 -
linux-headers/asm-generic/bitsperlong.h | 16 +
linux-headers/asm-generic/kvm_para.h | 4 -
linux-headers/asm-generic/unistd.h | 781 +++++++++++++++++++++
linux-headers/asm-mips/bitsperlong.h | 9 +
linux-headers/asm-mips/kvm.h | 25 +-
linux-headers/asm-mips/kvm_para.h | 5 -
linux-headers/asm-mips/sgidefs.h | 45 ++
linux-headers/asm-mips/unistd.h | 44 +-
linux-headers/asm-powerpc/bitsperlong.h | 13 +
linux-headers/asm-powerpc/epapr_hcalls.h | 99 ---
linux-headers/asm-powerpc/kvm_para.h | 98 ---
linux-headers/asm-s390/bitsperlong.h | 14 +
linux-headers/asm-s390/kvm_para.h | 8 -
linux-headers/asm-s390/unistd_32.h | 1 +
linux-headers/asm-s390/unistd_64.h | 1 +
linux-headers/asm-x86/bitsperlong.h | 14 +
linux-headers/linux/kvm_para.h | 35 -
target/i386/cpu.h | 2 -
target/i386/kvm_i386.h | 6 -
contrib/libvhost-user/libvhost-user.c | 16 +-
contrib/vhost-user-blk/vhost-user-blk.c | 7 +
hw/i386/intel_iommu.c | 396 ++++++++---
hw/i386/kvm/clock.c | 2 +-
hw/mem/nvdimm.c | 2 +-
hw/pci-host/q35.c | 17 +-
hw/virtio/vhost-user.c | 45 +-
hw/virtio/vhost.c | 7 +
hw/virtio/virtio-balloon.c | 2 +
hw/virtio/virtio-pci.c | 22 +
hw/virtio/virtio.c | 13 +
net/vhost-user.c | 38 +-
target/i386/cpu.c | 4 +-
target/i386/kvm.c | 4 +-
util/iova-tree.c | 114 +++
MAINTAINERS | 6 +
hw/i386/trace-events | 5 +-
hw/virtio/trace-events | 1 +
scripts/update-linux-headers.sh | 20 +-
util/Makefile.objs | 1 +
54 files changed, 1731 insertions(+), 456 deletions(-)
create mode 100644 include/qemu/iova-tree.h
rename {linux-headers => include/standard-headers}/asm-x86/kvm_para.h (80%)
create mode 100644 linux-headers/asm-arm/bitsperlong.h
delete mode 100644 linux-headers/asm-arm/kvm_para.h
create mode 100644 linux-headers/asm-arm64/bitsperlong.h
delete mode 100644 linux-headers/asm-arm64/kvm_para.h
create mode 100644 linux-headers/asm-generic/bitsperlong.h
delete mode 100644 linux-headers/asm-generic/kvm_para.h
create mode 100644 linux-headers/asm-generic/unistd.h
create mode 100644 linux-headers/asm-mips/bitsperlong.h
delete mode 100644 linux-headers/asm-mips/kvm_para.h
create mode 100644 linux-headers/asm-mips/sgidefs.h
create mode 100644 linux-headers/asm-powerpc/bitsperlong.h
delete mode 100644 linux-headers/asm-powerpc/epapr_hcalls.h
delete mode 100644 linux-headers/asm-powerpc/kvm_para.h
create mode 100644 linux-headers/asm-s390/bitsperlong.h
delete mode 100644 linux-headers/asm-s390/kvm_para.h
create mode 100644 linux-headers/asm-x86/bitsperlong.h
delete mode 100644 linux-headers/linux/kvm_para.h
create mode 100644 util/iova-tree.c[Qemu-devel] [PULL 01/28] hw/pci-host/q35: Replace hardcoded value with macro
From: Zihan Yang <[email protected]>
During smram region initialization some addresses are hardcoded, replace them with macro to be more clear to readers.
Previous patch forgets about one value and exceeds the line limit of 90 characters. The v2 breaks a few long lines
--- hw/pci-host/q35.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
hw/pci-host/q35.c +11 -6
@@ -535,13 +535,15 @@ static void mch_realize(PCIDevice *d, Error **errp)/* if *disabled* show SMRAM to all CPUs */ memory_region_init_alias (&mch->smram_region,OBJECT (mch),"smram-region" , - mch->pci_address_space,0xa0000 ,0x20000 ); -memory_region_add_subregion_overlap (mch->system_memory,0xa0000 , + mch->pci_address_space,MCH_HOST_BRIDGE_SMRAM_C_BASE , +MCH_HOST_BRIDGE_SMRAM_C_SIZE ); +memory_region_add_subregion_overlap (mch->system_memory,MCH_HOST_BRIDGE_SMRAM_C_BASE , &mch->smram_region,1 );memory_region_set_enabled (&mch->smram_region, true);memory_region_init_alias (&mch->open_high_smram,OBJECT (mch),"smram-open-high" , - mch->ram_memory,0xa0000 ,0x20000 ); + mch->ram_memory,MCH_HOST_BRIDGE_SMRAM_C_BASE , +MCH_HOST_BRIDGE_SMRAM_C_SIZE );memory_region_add_subregion_overlap (mch->system_memory,0xfeda0000 , &mch->open_high_smram,1 );memory_region_set_enabled (&mch->open_high_smram, false);
@@ -550,11 +552,14 @@ static void mch_realize(PCIDevice *d, Error **errp)memory_region_init (&mch->smram,OBJECT (mch),"smram" ,1ull <<32 );memory_region_set_enabled (&mch->smram, true);memory_region_init_alias (&mch->low_smram,OBJECT (mch),"smram-low" , - mch->ram_memory,0xa0000 ,0x20000 ); + mch->ram_memory,MCH_HOST_BRIDGE_SMRAM_C_BASE , +MCH_HOST_BRIDGE_SMRAM_C_SIZE );memory_region_set_enabled (&mch->low_smram, true); -memory_region_add_subregion (&mch->smram,0xa0000 , &mch->low_smram); +memory_region_add_subregion (&mch->smram,MCH_HOST_BRIDGE_SMRAM_C_BASE , + &mch->low_smram);memory_region_init_alias (&mch->high_smram,OBJECT (mch),"smram-high" , - mch->ram_memory,0xa0000 ,0x20000 ); + mch->ram_memory,MCH_HOST_BRIDGE_SMRAM_C_BASE , +MCH_HOST_BRIDGE_SMRAM_C_SIZE );memory_region_set_enabled (&mch->high_smram, true);memory_region_add_subregion (&mch->smram,0xfeda0000 , &mch->high_smram);
Signature · 1 line
MST
[Qemu-devel] [PULL 02/28] allocate pci id for mdpy
In reply to Michael S. TsirkinFrom: Gerd Hoffmann <[email protected]>
mdpy is a sample pci device for vfio-mdev. Not (yet) merged upstream, patch available here:
--- docs/specs/pci-ids.txt | 1 + include/hw/pci/pci.h | 1 + 2 files changed, 2 insertions(+)
docs/specs/pci-ids.txt +1 -0
@@ -62,6 +62,7 @@ PCI devices (other than virtio): 1b36:000a PCI-PCI bridge (multiseat) 1b36:000b PCIe Expander Bridge (-device pxb-pcie) 1b36:000d PCI xhci usb host adapter +1b36:000f mdpy (mdev sample device), linux/samples/vfio-mdev/mdpy.c All these devices are documented in docs/specs.
include/hw/pci/pci.h +1 -0
@@ -101,6 +101,7 @@ extern bool pci_available;#define PCI_DEVICE_ID_REDHAT_PCIE_RP 0x000c#define PCI_DEVICE_ID_REDHAT_XHCI 0x000d#define PCI_DEVICE_ID_REDHAT_PCIE_BRIDGE 0x000e +#define PCI_DEVICE_ID_REDHAT_MDPY 0x000f#define PCI_DEVICE_ID_REDHAT_QXL 0x0100#define FMT_PCIBUS PRIx64
Signature · 1 line
MST
[Qemu-devel] [PULL 03/28] virtio-balloon: add hugetlb page allocation counts
In reply to Michael S. TsirkinFrom: Jonathan Helman <[email protected]>
qemu should read and report hugetlb page allocation counts exported in the following kernel patch:
commit 4c3ca37c4a4394978fd0f005625f6064ed2b9a64
Author: Jonathan Helman <[email protected]>
Date: Mon Mar 19 11:00:35 2018 -0700
virtio_balloon: export hugetlb page allocation counts
Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.
--- docs/virtio-balloon-stats.txt | 2 ++ include/standard-headers/linux/virtio_balloon.h | 4 +++- hw/virtio/virtio-balloon.c | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-)
docs/virtio-balloon-stats.txt +2 -0
@@ -34,6 +34,8 @@ which will return a dictionary containing: - stat-total-memory - stat-available-memory - stat-disk-caches + - stat-htlb-pgalloc + - stat-htlb-pgfail o A key named last-update, which contains the last stats update timestamp in seconds. Since this timestamp is generated by the host,
include/standard-headers/linux/virtio_balloon.h +3 -1
@@ -53,7 +53,9 @@ struct virtio_balloon_config {#define VIRTIO_BALLOON_S_MEMTOT 5/* Total amount of memory */ #define VIRTIO_BALLOON_S_AVAIL 6/* Available memory as in /proc */ #define VIRTIO_BALLOON_S_CACHES 7/* Disk caches */ -#define VIRTIO_BALLOON_S_NR 8 +#define VIRTIO_BALLOON_S_HTLB_PGALLOC 8/* Hugetlb page allocations */ +#define VIRTIO_BALLOON_S_HTLB_PGFAIL 9/* Hugetlb page allocation failures */ +#define VIRTIO_BALLOON_S_NR 10/* * Memory statistics structure.
hw/virtio/virtio-balloon.c +2 -0
@@ -52,6 +52,8 @@ static const char *balloon_stat_names[] = { [VIRTIO_BALLOON_S_MEMTOT] = "stat-total-memory", [VIRTIO_BALLOON_S_AVAIL] = "stat-available-memory", [VIRTIO_BALLOON_S_CACHES] = "stat-disk-caches", + [VIRTIO_BALLOON_S_HTLB_PGALLOC] = "stat-htlb-pgalloc", + [VIRTIO_BALLOON_S_HTLB_PGFAIL] = "stat-htlb-pgfail", [VIRTIO_BALLOON_S_NR] = NULL };
Signature · 1 line
MST
[PULL 07/28] x86/cpu: use standard-headers/asm-x86.kvm_para.h
In reply to Michael S. TsirkinSwitch to the header we imported from Linux,
this allows us to drop a hack in kvm_i386.h.
More code will be dropped in the next patch.
--- include/sysemu/kvm.h | 1 - target/i386/cpu.h | 2 -- target/i386/kvm_i386.h | 6 ------ hw/i386/kvm/clock.c | 2 +- target/i386/cpu.c | 4 +--- target/i386/kvm.c | 4 ++-- 6 files changed, 4 insertions(+), 15 deletions(-)
include/sysemu/kvm.h +0 -1
@@ -22,7 +22,6 @@#ifdef NEED_CPU_H # ifdef CONFIG_KVM # include <linux/kvm.h> -# include <linux/kvm_para.h> # define CONFIG_KVM_IS_POSSIBLE # endif #else
target/i386/cpu.h +0 -2
@@ -688,8 +688,6 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Speculation Control */ #define CPUID_7_0_EDX_SPEC_CTRL_SSBD (1U << 31)/* Speculative Store Bypass Disable */ -#define KVM_HINTS_DEDICATED (1U << 0) -#define CPUID_8000_0008_EBX_IBPB (1U << 12)/* Indirect Branch Prediction Barrier */ #define CPUID_XSAVE_XSAVEOPT (1U << 0)
target/i386/kvm_i386.h +0 -6
@@ -30,12 +30,6 @@#define kvm_pic_in_kernel () 0#define kvm_ioapic_in_kernel () 0 -/* These constants must never be used at runtime if kvm_enabled() is false. -* They exist so we don't need #ifdefs around KVM-specific code that already -* checks kvm_enabled() properly. -*/ -#define KVM_CPUID_FEATURES 0 -#endif /* CONFIG_KVM */ bool kvm_allows_irq0_override (void );
hw/i386/kvm/clock.c +1 -1
@@ -26,7 +26,7 @@#include "qapi/error.h" #include <linux/kvm.h> -#include <linux/kvm_para.h> +#include "standard-headers/asm-x86/kvm_para.h" #define TYPE_KVM_CLOCK "kvmclock"#define KVM_CLOCK (obj) OBJECT_CHECK(KVMClockState, (obj), TYPE_KVM_CLOCK)
target/i386/cpu.c +1 -3
@@ -40,9 +40,7 @@#include "qom/qom-qobject.h" #include "sysemu/arch_init.h" -#if defined(CONFIG_KVM ) -#include <linux/kvm_para.h> -#endif +#include "standard-headers/asm-x86/kvm_para.h" #include "sysemu/sysemu.h" #include "hw/qdev-properties.h"
target/i386/kvm.c +2 -2
@@ -18,7 +18,7 @@#include <sys/utsname.h> #include <linux/kvm.h> -#include <linux/kvm_para.h> +#include "standard-headers/asm-x86/kvm_para.h" #include "qemu-common.h" #include "cpu.h"
@@ -387,7 +387,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function, ret &= ~(1U <<KVM_FEATURE_PV_UNHALT ); } }else if (function ==KVM_CPUID_FEATURES && reg ==R_EDX ) { - ret |=KVM_HINTS_DEDICATED ; + ret |=1U <<KVM_HINTS_DEDICATED ; found =1 ; }
Signature · 1 line
MST
[Qemu-devel] [PULL 04/28] vhost: add trace for IOTLB miss
In reply to Michael S. TsirkinFrom: Peter Xu <[email protected]>
Add some trace points for IOTLB translation for vhost. After vhost-user is setup, the only IO path that QEMU will participate should be the IOMMU translation, so it'll be good we can track this with explicit timestamps when needed to see how long time we take to do the translation, and whether there's anything stuck inside. It might be useful for triaging vhost-user problems.
--- hw/virtio/vhost.c | 7 +++++++ hw/virtio/trace-events | 1 + 2 files changed, 8 insertions(+)
hw/virtio/vhost.c +7 -0
@@ -894,12 +894,15 @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write)rcu_read_lock (); +trace_vhost_iotlb_miss (dev,1 ); + iotlb =address_space_get_iotlb_entry (dev->vdev->dma_as, iova, write);if (iotlb.target_as !=NULL ) { ret =vhost_memory_region_lookup (dev, iotlb.translated_addr, &uaddr, &len);if (ret) { +trace_vhost_iotlb_miss (dev,3 );error_report ("Fail to lookup the translated address " "%" PRIx64, iotlb.translated_addr); goto out;
@@ -911,10 +914,14 @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write) ret =vhost_backend_update_device_iotlb (dev, iova, uaddr, len, iotlb.perm);if (ret) { +trace_vhost_iotlb_miss (dev,4 );error_report ("Fail to update device iotlb" ); goto out; } } + +trace_vhost_iotlb_miss (dev,2 ); + out:rcu_read_unlock ();
hw/virtio/trace-events +1 -0
@@ -6,6 +6,7 @@ vhost_region_add_section(const char *name, uint64_t gpa, uint64_t size, uint64_t vhost_region_add_section_merge(const char *name, uint64_t new_size, uint64_t gpa, uint64_t owr) "%s: size: 0x%"PRIx64 " gpa: 0x%"PRIx64 " owr: 0x%"PRIx64 vhost_region_add_section_aligned(const char *name, uint64_t gpa, uint64_t size, uint64_t host) "%s: 0x%"PRIx64"+0x%"PRIx64" @ 0x%"PRIx64 vhost_section(const char *name, int r) "%s:%d" +vhost_iotlb_miss(void *dev, int step) "%p step %d" # hw/virtio/vhost-user.c vhost_user_postcopy_end_entry(void) ""
Signature · 1 line
MST
[Qemu-devel] [PULL 05/28] update-linux-headers.sh: drop kvm_para.h hacks
In reply to Michael S. TsirkinIt turns out (as will be clear from follow-up patches) we do not really need any kvm para macros host side for now, except on x86, and there we need it unconditionally whether we run on kvm or we don't.
Import the x86 asm/kvm_para.h into standard-headers, follow-up patches remove a bunch of code using this.
--- scripts/update-linux-headers.sh | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
scripts/update-linux-headers.sh +5 -11
@@ -43,6 +43,7 @@ cp_portable() { -e 'limits' \ -e 'linux/kernel' \ -e 'linux/sysinfo' \ + -e 'asm-generic/kvm_para' \ > /dev/null then echo "Unexpected #include in input file $f".
@@ -98,13 +99,9 @@ for arch in $ARCHLIST; do rm -rf "$output/linux-headers/asm-$arch" mkdir -p "$output/linux-headers/asm-$arch" - for header in kvm.h kvm_para.h unistd.h; do + for header in kvm.h unistd.h; do cp "$tmpdir/include/asm/$header" "$output/linux-headers/asm-$arch" done - if [ $arch = powerpc ]; then - cp "$tmpdir/include/asm/epapr_hcalls.h" "$output/linux-headers/asm-powerpc/" - fi - rm -rf "$output/include/standard-headers/asm-$arch" mkdir -p "$output/include/standard-headers/asm-$arch" if [ $arch = s390 ]; then
@@ -121,20 +118,17 @@ for arch in $ARCHLIST; do cp "$tmpdir/include/asm/unistd_32.h" "$output/linux-headers/asm-x86/" cp "$tmpdir/include/asm/unistd_x32.h" "$output/linux-headers/asm-x86/" cp "$tmpdir/include/asm/unistd_64.h" "$output/linux-headers/asm-x86/" + cp_portable "$tmpdir/include/asm/kvm_para.h" "$output/include/standard-headers/asm-$arch" fi done rm -rf "$output/linux-headers/linux" mkdir -p "$output/linux-headers/linux" -for header in kvm.h kvm_para.h vfio.h vfio_ccw.h vhost.h \ +for header in kvm.h vfio.h vfio_ccw.h vhost.h \ psci.h psp-sev.h userfaultfd.h; do cp "$tmpdir/include/linux/$header" "$output/linux-headers/linux" done -rm -rf "$output/linux-headers/asm-generic" -mkdir -p "$output/linux-headers/asm-generic" -for header in kvm_para.h; do - cp "$tmpdir/include/asm-generic/$header" "$output/linux-headers/asm-generic" -done + if [ -L "$linux/source" ]; then cp "$linux/source/COPYING" "$output/linux-headers" else
Signature · 1 line
MST
[Qemu-devel] [PULL 06/28] include/standard-headers: add asm-x86/kvm_para.h
In reply to Michael S. TsirkinImport asm-x86/kvm_para.h from linux where it can
be easily used on Linux and non-Linux platforms.
--- include/standard-headers/asm-x86/kvm_para.h | 121 ++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 include/standard-headers/asm-x86/kvm_para.h
include/standard-headers/asm-x86/kvm_para.h new file +121 -0
@@ -0,0 +1,121 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_X86_KVM_PARA_H +#define _ASM_X86_KVM_PARA_H + +#include "standard-headers/linux/types.h" + +/* This CPUID returns the signature 'KVMKVMKVM' in ebx, ecx, and edx. It +* should be used to determine that a VM is running under KVM. +*/ +#define KVM_CPUID_SIGNATURE 0x40000000 + +/* This CPUID returns two feature bitmaps in eax, edx. Before enabling +* a particular paravirtualization, the appropriate feature bit should +* be checked in eax. The performance hint feature bit should be checked +* in edx. +*/ +#define KVM_CPUID_FEATURES 0x40000001 +#define KVM_FEATURE_CLOCKSOURCE 0 +#define KVM_FEATURE_NOP_IO_DELAY 1 +#define KVM_FEATURE_MMU_OP 2 +/* This indicates that the new set of kvmclock msrs +* are available. The use of 0x11 and 0x12 is deprecated +*/ +#define KVM_FEATURE_CLOCKSOURCE2 3 +#define KVM_FEATURE_ASYNC_PF 4 +#define KVM_FEATURE_STEAL_TIME 5 +#define KVM_FEATURE_PV_EOI 6 +#define KVM_FEATURE_PV_UNHALT 7 +#define KVM_FEATURE_PV_TLB_FLUSH 9 +#define KVM_FEATURE_ASYNC_PF_VMEXIT 10 + +#define KVM_HINTS_DEDICATED 0 + +/* The last 8 bits are used to indicate how to interpret the flags field +* in pvclock structure. If no bits are set, all flags are ignored. +*/ +#define KVM_FEATURE_CLOCKSOURCE_STABLE_BIT 24 + +#define MSR_KVM_WALL_CLOCK 0x11 +#define MSR_KVM_SYSTEM_TIME 0x12 + +#define KVM_MSR_ENABLED 1 +/* Custom MSRs falls in the range 0x4b564d00-0x4b564dff */ +#define MSR_KVM_WALL_CLOCK_NEW 0x4b564d00 +#define MSR_KVM_SYSTEM_TIME_NEW 0x4b564d01 +#define MSR_KVM_ASYNC_PF_EN 0x4b564d02 +#define MSR_KVM_STEAL_TIME 0x4b564d03 +#define MSR_KVM_PV_EOI_EN 0x4b564d04 + +struct kvm_steal_time { +uint64_t steal; +uint32_t version; +uint32_t flags; +uint8_t preempted; +uint8_t uint8_t_pad[3 ]; +uint32_t pad[11 ]; +}; + +#define KVM_VCPU_PREEMPTED (1 << 0) +#define KVM_VCPU_FLUSH_TLB (1 << 1) + +#define KVM_CLOCK_PAIRING_WALLCLOCK 0 +struct kvm_clock_pairing { +int64_t sec; +int64_t nsec; +uint64_t tsc; +uint32_t flags; +uint32_t pad[9 ]; +}; + +#define KVM_STEAL_ALIGNMENT_BITS 5 +#define KVM_STEAL_VALID_BITS ((-1ULL << (KVM_STEAL_ALIGNMENT_BITS + 1))) +#define KVM_STEAL_RESERVED_MASK (((1 << KVM_STEAL_ALIGNMENT_BITS) - 1 ) << 1) + +#define KVM_MAX_MMU_OP_BATCH 32 + +#define KVM_ASYNC_PF_ENABLED (1 << 0) +#define KVM_ASYNC_PF_SEND_ALWAYS (1 << 1) +#define KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT (1 << 2) + +/* Operations for KVM_HC_MMU_OP */ +#define KVM_MMU_OP_WRITE_PTE 1 +#define KVM_MMU_OP_FLUSH_TLB 2 +#define KVM_MMU_OP_RELEASE_PT 3 + +/* Payload for KVM_HC_MMU_OP */ +struct kvm_mmu_op_header { +uint32_t op; +uint32_t pad; +}; + +struct kvm_mmu_op_write_pte { +struct kvm_mmu_op_header header; +uint64_t pte_phys; +uint64_t pte_val; +}; + +struct kvm_mmu_op_flush_tlb { +struct kvm_mmu_op_header header; +}; + +struct kvm_mmu_op_release_pt { +struct kvm_mmu_op_header header; +uint64_t pt_phys; +}; + +#define KVM_PV_REASON_PAGE_NOT_PRESENT 1 +#define KVM_PV_REASON_PAGE_READY 2 + +struct kvm_vcpu_pv_apf_data { +uint32_t reason; +uint8_t pad[60 ]; +uint32_t enabled; +}; + +#define KVM_PV_EOI_BIT 0 +#define KVM_PV_EOI_MASK (0x1 << KVM_PV_EOI_BIT) +#define KVM_PV_EOI_ENABLED KVM_PV_EOI_MASK +#define KVM_PV_EOI_DISABLED 0x0 + +#endif /* _ASM_X86_KVM_PARA_H */
Signature · 1 line
MST
[Qemu-devel] [PULL 08/28] linux-headers: drop kvm_para.h
In reply to Michael S. TsirkinUnused now and can be removed.
--- linux-headers/asm-arm/kvm_para.h | 2 - linux-headers/asm-arm64/kvm_para.h | 1 - linux-headers/asm-generic/kvm_para.h | 4 -- linux-headers/asm-mips/kvm_para.h | 5 -- linux-headers/asm-powerpc/epapr_hcalls.h | 99 -------------------------- linux-headers/asm-powerpc/kvm_para.h | 98 ------------------------- linux-headers/asm-s390/kvm_para.h | 8 --- linux-headers/asm-x86/kvm_para.h | 118 ------------------------------- linux-headers/linux/kvm_para.h | 35 --------- 9 files changed, 370 deletions(-) delete mode 100644 linux-headers/asm-arm/kvm_para.h delete mode 100644 linux-headers/asm-arm64/kvm_para.h delete mode 100644 linux-headers/asm-generic/kvm_para.h delete mode 100644 linux-headers/asm-mips/kvm_para.h delete mode 100644 linux-headers/asm-powerpc/epapr_hcalls.h delete mode 100644 linux-headers/asm-powerpc/kvm_para.h delete mode 100644 linux-headers/asm-s390/kvm_para.h delete mode 100644 linux-headers/asm-x86/kvm_para.h delete mode 100644 linux-headers/linux/kvm_para.h
linux-headers/asm-arm/kvm_para.h deleted +0 -2
@@ -1,2 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#include <asm-generic/kvm_para.h>
linux-headers/asm-arm64/kvm_para.h deleted +0 -1
@@ -1 +0,0 @@ -#include <asm-generic/kvm_para.h>
linux-headers/asm-generic/kvm_para.h deleted +0 -4
@@ -1,4 +0,0 @@ -/* -* There isn't anything here, but the file must not be empty or patch -* will delete it. -*/
linux-headers/asm-mips/kvm_para.h deleted +0 -5
@@ -1,5 +0,0 @@ -#ifndef _ASM_MIPS_KVM_PARA_H -#define _ASM_MIPS_KVM_PARA_H - - -#endif /* _ASM_MIPS_KVM_PARA_H */
linux-headers/asm-powerpc/epapr_hcalls.h deleted +0 -99
99 lines not on this page · raw message
linux-headers/asm-powerpc/kvm_para.h deleted +0 -98
98 lines not on this page · raw message
linux-headers/asm-s390/kvm_para.h deleted +0 -8
@@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* -* User API definitions for paravirtual devices on s390 -* -* Copyright IBM Corp. 2008 -* -* Author(s): Christian Borntraeger <[email protected]> -*/
linux-headers/asm-x86/kvm_para.h deleted +0 -118
118 lines not on this page · raw message
linux-headers/linux/kvm_para.h deleted +0 -35
@@ -1,35 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __LINUX_KVM_PARA_H -#define __LINUX_KVM_PARA_H - -/* -* This header file provides a method for making a hypercall to the host -* Architectures should define: -* - kvm_hypercall0, kvm_hypercall1... -* - kvm_arch_para_features -* - kvm_para_available -*/ - -/* Return values for hypercalls */ -#define KVM_ENOSYS 1000 -#define KVM_EFAULT EFAULT -#define KVM_E2BIG E2BIG -#define KVM_EPERM EPERM -#define KVM_EOPNOTSUPP 95 - -#define KVM_HC_VAPIC_POLL_IRQ 1 -#define KVM_HC_MMU_OP 2 -#define KVM_HC_FEATURES 3 -#define KVM_HC_PPC_MAP_MAGIC_PAGE 4 -#define KVM_HC_KICK_CPU 5 -#define KVM_HC_MIPS_GET_CLOCK_FREQ 6 -#define KVM_HC_MIPS_EXIT_VM 7 -#define KVM_HC_MIPS_CONSOLE_OUTPUT 8 -#define KVM_HC_CLOCK_PAIRING 9 - -/* -* hypercalls use architecture specific -*/ -#include <asm/kvm_para.h> - -#endif /* __LINUX_KVM_PARA_H */
Signature · 1 line
MST
[Qemu-devel] [PULL 09/28] update-linux-headers.sh: unistd.h, kvm consistency
In reply to Michael S. TsirkinRework the update script slightly, add the unistd.h header and its dependencies on all architectures.
This also removes the IA64 and MIPS from a KVM blacklist:
Linux dropped IA64, and there was never a reason to exclude MIPS from kvm specifically - it was excluded due to dependency of its unistd.h on sgidefs.h, which we also import.
--- scripts/update-linux-headers.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
scripts/update-linux-headers.sh +12 -6
@@ -84,11 +84,6 @@ for arch in $ARCHLIST; do continue fi - # Blacklist architectures which have KVM headers but are actually dead - if [ "$arch" = "ia64" -o "$arch" = "mips" ]; then - continue - fi - if [ "$arch" = x86 ]; then arch_var=SRCARCH else
@@ -99,9 +94,14 @@ for arch in $ARCHLIST; do rm -rf "$output/linux-headers/asm-$arch" mkdir -p "$output/linux-headers/asm-$arch" - for header in kvm.h unistd.h; do + for header in kvm.h unistd.h bitsperlong.h; do cp "$tmpdir/include/asm/$header" "$output/linux-headers/asm-$arch" done + + if [ $arch = mips ]; then + cp "$tmpdir/include/asm/sgidefs.h" "$output/linux-headers/asm-mips/" + fi + rm -rf "$output/include/standard-headers/asm-$arch" mkdir -p "$output/include/standard-headers/asm-$arch" if [ $arch = s390 ]; then
@@ -129,6 +129,12 @@ for header in kvm.h vfio.h vfio_ccw.h vhost.h \ cp "$tmpdir/include/linux/$header" "$output/linux-headers/linux" done +rm -rf "$output/linux-headers/asm-generic" +mkdir -p "$output/linux-headers/asm-generic" +for header in unistd.h bitsperlong.h; do + cp "$tmpdir/include/asm-generic/$header" "$output/linux-headers/asm-generic" +done + if [ -L "$linux/source" ]; then cp "$linux/source/COPYING" "$output/linux-headers" else
Signature · 1 line
MST
[Qemu-devel] [PULL 12/28] vhost-user: add Net prefix to internal state structure
In reply to Michael S. TsirkinFrom: Tiwei Bie <[email protected]>
We are going to introduce a shared vhost user state which will be named as 'VhostUserState'. So add 'Net' prefix to the existing internal state structure in the vhost-user netdev to avoid conflict.
--- net/vhost-user.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
net/vhost-user.c +19 -19
@@ -20,38 +20,38 @@#include "qemu/option.h" #include "trace.h" -typedef struct VhostUserState { +typedef struct NetVhostUserState {NetClientState nc;CharBackend chr;/* only queue index 0 */ VHostNetState *vhost_net;guint watch;uint64_t acked_features;bool started; -}VhostUserState ; +}NetVhostUserState ;VHostNetState *vhost_user_get_vhost_net (NetClientState *nc) { -VhostUserState *s =DO_UPCAST (VhostUserState, nc, nc); +NetVhostUserState *s =DO_UPCAST (NetVhostUserState, nc, nc);assert (nc->info->type ==NET_CLIENT_DRIVER_VHOST_USER );return s->vhost_net; }uint64_t vhost_user_get_acked_features (NetClientState *nc) { -VhostUserState *s =DO_UPCAST (VhostUserState, nc, nc); +NetVhostUserState *s =DO_UPCAST (NetVhostUserState, nc, nc);assert (nc->info->type ==NET_CLIENT_DRIVER_VHOST_USER );return s->acked_features; }static void vhost_user_stop (int queues,NetClientState *ncs[]) { -VhostUserState *s; +NetVhostUserState *s;int i;for (i =0 ; i < queues; i++) {assert (ncs[i]->info->type ==NET_CLIENT_DRIVER_VHOST_USER ); - s =DO_UPCAST (VhostUserState, nc, ncs[i]); + s =DO_UPCAST (NetVhostUserState, nc, ncs[i]);if (s->vhost_net) {/* save acked features */
@@ -68,7 +68,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[], CharBackend *be) {VhostNetOptions options;struct vhost_net *net =NULL ; -VhostUserState *s; +NetVhostUserState *s;int max_queues;int i;
@@ -77,7 +77,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[], CharBackend *be)for (i =0 ; i < queues; i++) {assert (ncs[i]->info->type ==NET_CLIENT_DRIVER_VHOST_USER ); - s =DO_UPCAST (VhostUserState, nc, ncs[i]); + s =DO_UPCAST (NetVhostUserState, nc, ncs[i]); options.net_backend = ncs[i]; options.opaque = be;
@@ -123,7 +123,7 @@ static ssize_t vhost_user_receive(NetClientState *nc, const uint8_t *buf,without GUEST_ANNOUNCE capability. */ if (size ==60 ) { -VhostUserState *s =DO_UPCAST (VhostUserState, nc, nc); +NetVhostUserState *s =DO_UPCAST (NetVhostUserState, nc, nc);int r;static int display_rarp_failure =1 ;char mac_addr[6 ];
@@ -146,7 +146,7 @@ static ssize_t vhost_user_receive(NetClientState *nc, const uint8_t *buf,static void vhost_user_cleanup (NetClientState *nc) { -VhostUserState *s =DO_UPCAST (VhostUserState, nc, nc); +NetVhostUserState *s =DO_UPCAST (NetVhostUserState, nc, nc);if (s->vhost_net) {vhost_net_cleanup (s->vhost_net);
@@ -180,7 +180,7 @@ static bool vhost_user_has_ufo(NetClientState *nc)static NetClientInfo net_vhost_user_info = { .type =NET_CLIENT_DRIVER_VHOST_USER , - .size =sizeof (VhostUserState), + .size =sizeof (NetVhostUserState), .receive = vhost_user_receive, .cleanup = vhost_user_cleanup, .has_vnet_hdr = vhost_user_has_vnet_hdr,
@@ -190,7 +190,7 @@ static NetClientInfo net_vhost_user_info = {static gboolean net_vhost_user_watch (GIOChannel *chan,GIOCondition cond,void *opaque) { -VhostUserState *s = opaque; +NetVhostUserState *s = opaque;qemu_chr_fe_disconnect (&s->chr);
@@ -203,7 +203,7 @@ static void chr_closed_bh(void *opaque) {const char *name = opaque;NetClientState *ncs[MAX_QUEUE_NUM ]; -VhostUserState *s; +NetVhostUserState *s;Error *err =NULL ;int queues;
@@ -212,7 +212,7 @@ static void chr_closed_bh(void *opaque) MAX_QUEUE_NUM);assert (queues <MAX_QUEUE_NUM ); - s =DO_UPCAST (VhostUserState, nc, ncs[0 ]); + s =DO_UPCAST (NetVhostUserState, nc, ncs[0 ]);qmp_set_link (name, false, &err);vhost_user_stop (queues, ncs);
@@ -229,7 +229,7 @@ static void net_vhost_user_event(void *opaque, int event) {const char *name = opaque;NetClientState *ncs[MAX_QUEUE_NUM ]; -VhostUserState *s; +NetVhostUserState *s;Chardev *chr;Error *err =NULL ;int queues;
@@ -239,7 +239,7 @@ static void net_vhost_user_event(void *opaque, int event) MAX_QUEUE_NUM);assert (queues <MAX_QUEUE_NUM ); - s =DO_UPCAST (VhostUserState, nc, ncs[0 ]); + s =DO_UPCAST (NetVhostUserState, nc, ncs[0 ]); chr =qemu_chr_fe_get_driver (&s->chr);trace_vhost_user_event (chr->label, event);switch (event) {
@@ -283,7 +283,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, {Error *err =NULL ;NetClientState *nc, *nc0 =NULL ; -VhostUserState *s; +NetVhostUserState *s;int i;assert (name);
@@ -296,7 +296,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, nc->queue_index = i;if (!nc0) { nc0 = nc; - s =DO_UPCAST (VhostUserState, nc, nc); + s =DO_UPCAST (NetVhostUserState, nc, nc);if (!qemu_chr_fe_init (&s->chr, chr, &err)) {error_report_err (err);return -1 ;
@@ -305,7 +305,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, } - s =DO_UPCAST (VhostUserState, nc, nc0); + s =DO_UPCAST (NetVhostUserState, nc, nc0); do { if (qemu_chr_fe_wait_connected(&s->chr, &err) < 0) { error_report_err(err);
Signature · 1 line
MST
[Qemu-devel] [PULL 13/28] vhost-user: support receiving file descriptors in slave_read
In reply to Michael S. TsirkinFrom: Tiwei Bie <[email protected]>
--- hw/virtio/vhost-user.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-)
hw/virtio/vhost-user.c +40 -1
@@ -852,14 +852,44 @@ static void slave_read(void *opaque)VhostUserHeader hdr = {0 , };VhostUserPayload payload = {0 , };int size, ret =0 ; +struct iovec iov; +struct msghdr msgh; +int fd =-1 ; +char control[CMSG_SPACE (sizeof (fd))]; +struct cmsghdr *cmsg; +size_t fdsize; + +memset (&msgh,0 ,sizeof (msgh)); + msgh.msg_iov = &iov; + msgh.msg_iovlen =1 ; + msgh.msg_control = control; + msgh.msg_controllen =sizeof (control);/* Read header */ - size =read (u->slave_fd, &hdr,VHOST_USER_HDR_SIZE ); + iov.iov_base = &hdr; + iov.iov_len =VHOST_USER_HDR_SIZE ; + + size =recvmsg (u->slave_fd, &msgh,0 );if (size !=VHOST_USER_HDR_SIZE ) {error_report ("Failed to read from slave." ); goto err; } +if (msgh.msg_flags &MSG_CTRUNC ) { +error_report ("Truncated message." ); + goto err; + } + +for (cmsg =CMSG_FIRSTHDR (&msgh); cmsg !=NULL ; + cmsg =CMSG_NXTHDR (&msgh, cmsg)) { +if (cmsg->cmsg_level ==SOL_SOCKET && + cmsg->cmsg_type ==SCM_RIGHTS ) { + fdsize = cmsg->cmsg_len -CMSG_LEN (0 ); +memcpy (&fd,CMSG_DATA (cmsg), fdsize); +break ; + } + } +if (hdr.size >VHOST_USER_PAYLOAD_SIZE ) { error_report("Failed to read msg header." " Size %d exceeds the maximum %zu.", hdr.size,
@@ -883,9 +913,15 @@ static void slave_read(void *opaque)break ;default :error_report ("Received unexpected msg type." ); +if (fd !=-1 ) { +close (fd); + } ret = -EINVAL ; } +/* Message handlers need to make sure that fd will be consumed. */ + fd =-1 ; +/* * REPLY_ACK feature handling. Other reply types has to be managed * directly in their request handlers.
@@ -918,6 +954,9 @@ err:qemu_set_fd_handler (u->slave_fd,NULL ,NULL ,NULL );close (u->slave_fd); u->slave_fd =-1 ; +if (fd !=-1 ) { +close (fd); + }return ; }
Signature · 1 line
MST
[Qemu-devel] [PULL 14/28] virtio: support setting memory region based host notifier
In reply to Michael S. TsirkinFrom: Tiwei Bie <[email protected]>
This patch introduces the support for setting memory region based host notifiers for virtio device. This is helpful when using a hardware accelerator for a virtio device, because hardware heavily depends on the notification, this will allow the guest driver in the VM to notify the hardware directly.
--- include/hw/virtio/virtio-bus.h | 2 ++ include/hw/virtio/virtio.h | 2 ++ hw/virtio/virtio-pci.c | 22 ++++++++++++++++++++++ hw/virtio/virtio.c | 13 +++++++++++++ 4 files changed, 39 insertions(+)
include/hw/virtio/virtio-bus.h +2 -0
@@ -52,6 +52,8 @@ typedef struct VirtioBusClass {bool (*has_extra_state)(DeviceState *d);bool (*query_guest_notifiers)(DeviceState *d);int (*set_guest_notifiers)(DeviceState *d,int nvqs,bool assign); +int (*set_host_notifier_mr)(DeviceState *d,int n, +MemoryRegion *mr,bool assign);void (*vmstate_change)(DeviceState *d,bool running);/* * Expose the features the transport layer supports before
include/hw/virtio/virtio.h +2 -0
@@ -239,6 +239,8 @@ void virtio_queue_set_align(VirtIODevice *vdev, int n, int align);void virtio_queue_notify (VirtIODevice *vdev,int n);uint16_t virtio_queue_vector (VirtIODevice *vdev,int n);void virtio_queue_set_vector (VirtIODevice *vdev,int n,uint16_t vector); +int virtio_queue_set_host_notifier_mr (VirtIODevice *vdev,int n, +MemoryRegion *mr,bool assign);int virtio_set_status (VirtIODevice *vdev,uint8_t val);void virtio_reset (void *opaque);void virtio_update_irq (VirtIODevice *vdev);
hw/virtio/virtio-pci.c +22 -0
@@ -1037,6 +1037,27 @@ assign_error:return r; } +static int virtio_pci_set_host_notifier_mr (DeviceState *d,int n, +MemoryRegion *mr,bool assign) +{ +VirtIOPCIProxy *proxy =to_virtio_pci_proxy (d); +int offset; + +if (n >=VIRTIO_QUEUE_MAX || !virtio_pci_modern (proxy) || +virtio_pci_queue_mem_mult (proxy) !=memory_region_size (mr)) { +return -1 ; + } + +if (assign) { + offset =virtio_pci_queue_mem_mult (proxy) * n; +memory_region_add_subregion_overlap (&proxy->notify.mr, offset, mr,1 ); + }else { +memory_region_del_subregion (&proxy->notify.mr, mr); + } + +return 0 ; +} +static void virtio_pci_vmstate_change (DeviceState *d,bool running) {VirtIOPCIProxy *proxy =to_virtio_pci_proxy (d);
@@ -2652,6 +2673,7 @@ static void virtio_pci_bus_class_init(ObjectClass *klass, void *data) k->has_extra_state = virtio_pci_has_extra_state; k->query_guest_notifiers = virtio_pci_query_guest_notifiers; k->set_guest_notifiers = virtio_pci_set_guest_notifiers; + k->set_host_notifier_mr = virtio_pci_set_host_notifier_mr; k->vmstate_change = virtio_pci_vmstate_change; k->pre_plugged = virtio_pci_pre_plugged; k->device_plugged = virtio_pci_device_plugged;
hw/virtio/virtio.c +13 -0
@@ -2454,6 +2454,19 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq)return &vq->host_notifier; } +int virtio_queue_set_host_notifier_mr (VirtIODevice *vdev,int n, +MemoryRegion *mr,bool assign) +{ +BusState *qbus =qdev_get_parent_bus (DEVICE (vdev)); +VirtioBusClass *k =VIRTIO_BUS_GET_CLASS (qbus); + +if (k->set_host_notifier_mr) { +return k->set_host_notifier_mr (qbus->parent, n, mr, assign); + } + +return -1 ; +} +void virtio_device_set_child_bus_name (VirtIODevice *vdev,char *bus_name) {g_free (vdev->bus_name);
Signature · 1 line
MST
[Qemu-devel] [PULL 11/28] linux-headers: add kvm header for mips
In reply to Michael S. Tsirkinkvm header for MIPS was manually excluded from auto-updates.
Update it now to 4.17-rc2.
--- linux-headers/asm-mips/kvm.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
linux-headers/asm-mips/kvm.h +22 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive
@@ -19,6 +20,10 @@* Some parts derived from the x86 version of this file. */ +#define __KVM_HAVE_READONLY_MEM + +#define KVM_COALESCED_MMIO_PAGE_OFFSET 1 +/* * for KVM_GET_REGS and KVM_SET_REGS *
@@ -52,9 +57,14 @@ struct kvm_fpu {* Register set = 0: GP registers from kvm_regs (see definitions below). * * Register set = 1: CP0 registers. -* bits[15..8] - Must be zero. -* bits[7..3] - Register 'rd' index. -* bits[2..0] - Register 'sel' index. +* bits[15..8] - COP0 register set. +* +* COP0 register set = 0: Main CP0 registers. +* bits[7..3] - Register 'rd' index. +* bits[2..0] - Register 'sel' index. +* +* COP0 register set = 1: MAARs. +* bits[7..0] - MAAR index. * * Register set = 2: KVM specific registers (see definitions below). *
@@ -113,6 +123,15 @@ struct kvm_fpu {/* +* KVM_REG_MIPS_CP0 - Coprocessor 0 registers. +*/ + +#define KVM_REG_MIPS_MAAR (KVM_REG_MIPS_CP0 | (1 << 8)) +#define KVM_REG_MIPS_CP0_MAAR (n) (KVM_REG_MIPS_MAAR | \ + KVM_REG_SIZE_U64 | (n)) + + +/* * KVM_REG_MIPS_KVM - KVM specific control registers. */
Signature · 1 line
MST
[Qemu-devel] [PULL 15/28] vhost-user+postcopy: Use qemu_set_nonblock
In reply to Michael S. TsirkinFrom: "Dr. David Alan Gilbert" <[email protected]>
Use qemu_set_nonblock rather than a simple fcntl; cleaner and I have no reason to change other flags.
--- hw/virtio/vhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/vhost-user.c +1 -1
@@ -1115,7 +1115,7 @@ static int vhost_user_postcopy_advise(struct vhost_dev *dev, Error **errp)error_setg (errp,"%s: Failed to get ufd" , __func__);return -1 ; } -fcntl (ufd,F_SETFL ,O_NONBLOCK ); +qemu_set_nonblock (ufd);/* register ufd with userfault thread */ u->postcopy_fd.fd = ufd;
Signature · 1 line
MST
[Qemu-devel] [PULL 10/28] linux-headers: add unistd.h on all arches
In reply to Michael S. TsirkinThis adds unistd.h on ARM64 and MIPS and their dependencies.
Updated to Linux 4.17-rc2.
--- linux-headers/asm-arm/bitsperlong.h | 1 + linux-headers/asm-arm64/bitsperlong.h | 24 + linux-headers/asm-generic/bitsperlong.h | 16 + linux-headers/asm-generic/unistd.h | 781 ++++++++++++++++++++++++++++++++ linux-headers/asm-mips/bitsperlong.h | 9 + linux-headers/asm-mips/sgidefs.h | 45 ++ linux-headers/asm-mips/unistd.h | 44 +- linux-headers/asm-powerpc/bitsperlong.h | 13 + linux-headers/asm-s390/bitsperlong.h | 14 + linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/bitsperlong.h | 14 + 12 files changed, 957 insertions(+), 6 deletions(-) create mode 100644 linux-headers/asm-arm/bitsperlong.h create mode 100644 linux-headers/asm-arm64/bitsperlong.h create mode 100644 linux-headers/asm-generic/bitsperlong.h create mode 100644 linux-headers/asm-generic/unistd.h create mode 100644 linux-headers/asm-mips/bitsperlong.h create mode 100644 linux-headers/asm-mips/sgidefs.h create mode 100644 linux-headers/asm-powerpc/bitsperlong.h create mode 100644 linux-headers/asm-s390/bitsperlong.h create mode 100644 linux-headers/asm-x86/bitsperlong.h
linux-headers/asm-arm/bitsperlong.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/bitsperlong.h>
linux-headers/asm-arm64/bitsperlong.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* +* Copyright (C) 2012 ARM Ltd. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef __ASM_BITSPERLONG_H +#define __ASM_BITSPERLONG_H + +#define __BITS_PER_LONG 64 + +#include <asm-generic/bitsperlong.h> + +#endif /* __ASM_BITSPERLONG_H */
linux-headers/asm-generic/bitsperlong.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_BITS_PER_LONG +#define __ASM_GENERIC_BITS_PER_LONG + +/* +* There seems to be no way of detecting this automatically from user +* space, so 64 bit architectures should override this in their +* bitsperlong.h. In particular, an architecture that supports +* both 32 and 64 bit user space must not rely on CONFIG_64BIT +* to decide it, but rather check a compiler provided macro. +*/ +#ifndef __BITS_PER_LONG +#define __BITS_PER_LONG 32 +#endif + +#endif /* __ASM_GENERIC_BITS_PER_LONG */
linux-headers/asm-generic/unistd.h new file +781 -0
781 lines not on this page · raw message
linux-headers/asm-mips/bitsperlong.h new file +9 -0
@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_MIPS_BITSPERLONG_H +#define __ASM_MIPS_BITSPERLONG_H + +#define __BITS_PER_LONG _MIPS_SZLONG + +#include <asm-generic/bitsperlong.h> + +#endif /* __ASM_MIPS_BITSPERLONG_H */
linux-headers/asm-mips/sgidefs.h new file +45 -0
45 lines not on this page · raw message
linux-headers/asm-mips/unistd.h +38 -6
88 lines not on this page · raw message
linux-headers/asm-powerpc/bitsperlong.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_POWERPC_BITSPERLONG_H +#define __ASM_POWERPC_BITSPERLONG_H + +#if defined(__powerpc64__) +# define __BITS_PER_LONG 64 +#else +# define __BITS_PER_LONG 32 +#endif + +#include <asm-generic/bitsperlong.h> + +#endif /* __ASM_POWERPC_BITSPERLONG_H */
linux-headers/asm-s390/bitsperlong.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_S390_BITSPERLONG_H +#define __ASM_S390_BITSPERLONG_H + +#ifndef __s390x__ +#define __BITS_PER_LONG 32 +#else +#define __BITS_PER_LONG 64 +#endif + +#include <asm-generic/bitsperlong.h> + +#endif /* __ASM_S390_BITSPERLONG_H */ +
linux-headers/asm-s390/unistd_32.h +1 -0
@@ -360,5 +360,6 @@#define __NR_s390_guarded_storage 378#define __NR_statx 379#define __NR_s390_sthyi 380 +#define __NR_kexec_file_load 381#endif /* _ASM_S390_UNISTD_32_H */
linux-headers/asm-s390/unistd_64.h +1 -0
@@ -327,5 +327,6 @@#define __NR_s390_guarded_storage 378#define __NR_statx 379#define __NR_s390_sthyi 380 +#define __NR_kexec_file_load 381#endif /* _ASM_S390_UNISTD_64_H */
linux-headers/asm-x86/bitsperlong.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_X86_BITSPERLONG_H +#define __ASM_X86_BITSPERLONG_H + +#if defined(__x86_64__) && !defined(__ILP32__) +# define __BITS_PER_LONG 64 +#else +# define __BITS_PER_LONG 32 +#endif + +#include <asm-generic/bitsperlong.h> + +#endif /* __ASM_X86_BITSPERLONG_H */ +
Signature · 1 line
MST
[Qemu-devel] [PULL 16/28] libvhost-user: Send messages with no data
In reply to Michael S. TsirkinFrom: "Dr. David Alan Gilbert" <[email protected]>
The response to a VHOST_USER_POSTCOPY_ADVISE contains a fd but doesn't
actually contain any data. FIx vu_message_write so that it doesn't
do a 0-byte write() call, since this was ending up with rc=0 that was confusing the error handling code.
--- contrib/libvhost-user/libvhost-user.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
contrib/libvhost-user/libvhost-user.c +9 -7
@@ -323,13 +323,15 @@ vu_message_write(VuDev *dev, int conn_fd, VhostUserMsg *vmsg) rc =sendmsg (conn_fd, &msg,0 ); }while (rc <0 && (errno ==EINTR || errno ==EAGAIN )); -do { -if (vmsg->data) { - rc =write (conn_fd, vmsg->data, vmsg->size); - }else { - rc =write (conn_fd, p +VHOST_USER_HDR_SIZE , vmsg->size); - } - }while (rc <0 && (errno ==EINTR || errno ==EAGAIN )); +if (vmsg->size) { +do { +if (vmsg->data) { + rc =write (conn_fd, vmsg->data, vmsg->size); + }else { + rc =write (conn_fd, p +VHOST_USER_HDR_SIZE , vmsg->size); + } + }while (rc <0 && (errno ==EINTR || errno ==EAGAIN )); + }if (rc <=0 ) {vu_panic (dev,"Error while writing: %s" ,strerror (errno));
Signature · 1 line
MST
[Qemu-devel] [PULL 17/28] hw/virtio: Fix brace Werror with clang 6.0.0
In reply to Michael S. TsirkinFrom: Richard Henderson <[email protected]>
The warning is
hw/virtio/vhost-user.c:1319:26: error: suggest braces
around initialization of subobject [-Werror,-Wmissing-braces]
VhostUserMsg msg = { 0 };
^
{}While the original code is correct, and technically exactly correct as per ISO C89, both GCC and Clang support plain empty set of braces as an extension.
--- hw/virtio/vhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/vhost-user.c +1 -1
@@ -1355,7 +1355,7 @@ static bool vhost_user_requires_shm_log(struct vhost_dev *dev)static int vhost_user_migration_done (struct vhost_dev *dev,char * mac_addr) { -VhostUserMsg msg = {0 }; +VhostUserMsg msg = { };assert (dev->vhost_ops->backend_type ==VHOST_BACKEND_TYPE_USER );
Signature · 1 line
MST
[Qemu-devel] [PULL 19/28] nvdimm: fix typo in label-size definition
In reply to Michael S. TsirkinFrom: Ross Zwisler <[email protected]>
--- include/hw/mem/nvdimm.h | 2 +- hw/mem/nvdimm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/hw/mem/nvdimm.h +1 -1
@@ -48,7 +48,7 @@#define NVDIMM_GET_CLASS (obj) OBJECT_GET_CLASS(NVDIMMClass, (obj), \ TYPE_NVDIMM) -#define NVDIMM_LABLE_SIZE_PROP "label-size" +#define NVDIMM_LABEL_SIZE_PROP "label-size"#define NVDIMM_UNARMED_PROP "unarmed"struct NVDIMMDevice {
hw/mem/nvdimm.c +1 -1
@@ -89,7 +89,7 @@ static void nvdimm_set_unarmed(Object *obj, bool value, Error **errp)static void nvdimm_init (Object *obj) { -object_property_add (obj,NVDIMM_LABLE_SIZE_PROP ,"int" , +object_property_add (obj,NVDIMM_LABEL_SIZE_PROP ,"int" , nvdimm_get_label_size, nvdimm_set_label_size,NULL ,NULL ,NULL ); object_property_add_bool(obj, NVDIMM_UNARMED_PROP,
Signature · 1 line
MST
[Qemu-devel] [PULL 20/28] intel-iommu: send PSI always even if across PDEs
In reply to Michael S. TsirkinFrom: Peter Xu <[email protected]>
SECURITY IMPLICATION: without this patch, any guest with both assigned device and a vIOMMU might encounter stale IO page mappings even if guest has already unmapped the page, which may lead to guest memory corruption. The stale mappings will only be limited to the guest's own memory range, so it should not affect the host memory or other guests on the host.
During IOVA page table walking, there is a special case when the PSI covers one whole PDE (Page Directory Entry, which contains 512 Page Table Entries) or more. In the past, we skip that entry and we don't notify the IOMMU notifiers. This is not correct. We should send UNMAP notification to registered UNMAP notifiers in this case.
For UNMAP only notifiers, this might cause IOTLBs cached in the devices even if they were already invalid. For MAP/UNMAP notifiers like vfio-pci, this will cause stale page mappings.
This special case doesn't trigger often, but it is very easy to be triggered by nested device assignments, since in that case we'll possibly map the whole L2 guest RAM region into the device's IOVA address space (several GBs at least), which is far bigger than normal kernel driver usages of the device (tens of MBs normally).
Without this patch applied to L1 QEMU, nested device assignment to L2 guests will dump some errors like:
qemu-system-x86_64: VFIO_MAP_DMA: -17
qemu-system-x86_64: vfio_dma_map(0x557305420c30, 0xad000, 0x1000,
0x7f89a920d000) = -17 (File exists)
--- hw/i386/intel_iommu.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-)
hw/i386/intel_iommu.c +30 -12
@@ -722,6 +722,15 @@ static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write,typedef int (*vtd_page_walk_hook )(IOMMUTLBEntry *entry,void *private); +static int vtd_page_walk_one (IOMMUTLBEntry *entry,int level, +vtd_page_walk_hook hook_fn,void *private) +{ +assert (hook_fn); +trace_vtd_page_walk_one (level, entry->iova, entry->translated_addr, + entry->addr_mask, entry->perm); +return hook_fn (entry, private); +} +/** * vtd_page_walk_level - walk over specific level for IOVA range *
@@ -781,28 +790,37 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,*/ entry_valid = read_cur | write_cur; + entry.target_as = &address_space_memory; + entry.iova = iova & subpage_mask; + entry.perm =IOMMU_ACCESS_FLAG (read_cur, write_cur); + entry.addr_mask = ~subpage_mask; +if (vtd_is_last_slpte (slpte, level)) { - entry.target_as = &address_space_memory; - entry.iova = iova & subpage_mask;/* NOTE: this is only meaningful if entry_valid == true */ entry.translated_addr =vtd_get_slpte_addr (slpte, aw); - entry.addr_mask = ~subpage_mask; - entry.perm =IOMMU_ACCESS_FLAG (read_cur, write_cur);if (!entry_valid && !notify_unmap) {trace_vtd_page_walk_skip_perm (iova, iova_next); goto next; } -trace_vtd_page_walk_one (level, entry.iova, entry.translated_addr, - entry.addr_mask, entry.perm); -if (hook_fn) { - ret =hook_fn (&entry, private); -if (ret <0 ) { -return ret; - } + ret =vtd_page_walk_one (&entry, level, hook_fn, private); +if (ret <0 ) { +return ret; } }else {if (!entry_valid) { -trace_vtd_page_walk_skip_perm (iova, iova_next); +if (notify_unmap) { +/* +* The whole entry is invalid; unmap it all. +* Translated address is meaningless, zero it. +*/ + entry.translated_addr =0x0 ; + ret =vtd_page_walk_one (&entry, level, hook_fn, private); +if (ret <0 ) { +return ret; + } + }else { +trace_vtd_page_walk_skip_perm (iova, iova_next); + } goto next; } ret = vtd_page_walk_level(vtd_get_slpte_addr(slpte, aw), iova,
Signature · 1 line
MST
[Qemu-devel] [PULL 21/28] intel-iommu: remove IntelIOMMUNotifierNode
In reply to Michael S. TsirkinFrom: Peter Xu <[email protected]>
That is not really necessary. Removing that node struct and put the list entry directly into VTDAddressSpace. It simplfies the code a lot. Since at it, rename the old notifiers_list into vtd_as_with_notifiers.
--- include/hw/i386/intel_iommu.h | 9 ++------- hw/i386/intel_iommu.c | 41 +++++++++++------------------------------ 2 files changed, 13 insertions(+), 37 deletions(-)
include/hw/i386/intel_iommu.h +2 -7
@@ -67,7 +67,6 @@ typedef union VTD_IR_TableEntry VTD_IR_TableEntry;typedef union VTD_IR_MSIAddress VTD_IR_MSIAddress ;typedef struct VTDIrq VTDIrq ;typedef struct VTD_MSIMessage VTD_MSIMessage ; -typedef struct IntelIOMMUNotifierNode IntelIOMMUNotifierNode ;/* Context-Entry */ struct VTDContextEntry {
@@ -93,6 +92,7 @@ struct VTDAddressSpace {MemoryRegion iommu_ir;/* Interrupt region: 0xfeeXXXXX */ IntelIOMMUState *iommu_state;VTDContextCacheEntry context_cache_entry; +QLIST_ENTRY (VTDAddressSpace) next; };struct VTDBus {
@@ -253,11 +253,6 @@ struct VTD_MSIMessage {/* When IR is enabled, all MSI/MSI-X data bits should be zero */ #define VTD_IR_MSI_DATA (0) -struct IntelIOMMUNotifierNode { -VTDAddressSpace *vtd_as; -QLIST_ENTRY (IntelIOMMUNotifierNode) next; -}; -/* The iommu (DMAR) device state struct */ struct IntelIOMMUState {X86IOMMUState x86_iommu;
@@ -295,7 +290,7 @@ struct IntelIOMMUState {GHashTable *vtd_as_by_busptr;/* VTDBus objects indexed by PCIBus* reference */ VTDBus *vtd_as_by_bus_num[VTD_PCI_BUS_MAX ];/* VTDBus objects indexed by bus number */ /* list of registered notifiers */ - QLIST_HEAD(, IntelIOMMUNotifierNode) notifiers_list; + QLIST_HEAD(, VTDAddressSpace) vtd_as_with_notifiers;/* interrupt remapping */ bool intr_enabled;/* Whether guest enabled IR */
hw/i386/intel_iommu.c +11 -30
96 lines not on this page · raw message
Signature · 1 line
MST
[Qemu-devel] [PULL 18/28] contrib/vhost-user-blk: enable protocol feature for vhost-user-blk
In reply to Michael S. TsirkinFrom: Changpeng Liu <[email protected]>
This patch reports the protocol feature that is only advertised by QEMU if the device implements the config ops.
--- contrib/vhost-user-blk/vhost-user-blk.c | 7 +++++++ 1 file changed, 7 insertions(+)
contrib/vhost-user-blk/vhost-user-blk.c +7 -0
@@ -311,6 +311,12 @@ vub_get_features(VuDev *dev)1ull <<VHOST_USER_F_PROTOCOL_FEATURES ; } +static uint64_t +vub_get_protocol_features (VuDev *dev) +{ +return 1ull <<VHOST_USER_PROTOCOL_F_CONFIG ; +} +static int vub_get_config (VuDev *vu_dev,uint8_t *config,uint32_t len) {
@@ -373,6 +379,7 @@ vub_set_config(VuDev *vu_dev, const uint8_t *data,static const VuDevIface vub_iface = { .get_features = vub_get_features, .queue_set_started = vub_queue_set_started, + .get_protocol_features = vub_get_protocol_features, .get_config = vub_get_config, .set_config = vub_set_config, };
Signature · 1 line
MST
[Qemu-devel] [PULL 22/28] intel-iommu: add iommu lock
In reply to Michael S. TsirkinFrom: Peter Xu <[email protected]>
SECURITY IMPLICATION: this patch fixes a potential race when multiple threads access the IOMMU IOTLB cache.
Add a per-iommu big lock to protect IOMMU status. Currently the only thing to be protected is the IOTLB/context cache, since that can be accessed even without BQL, e.g., in IO dataplane.
Note that we don't need to protect device page tables since that's fully controlled by the guest kernel. However there is still possibility that malicious drivers will program the device to not obey the rule. In that case QEMU can't really do anything useful, instead the guest itself will be responsible for all uncertainties.
--- include/hw/i386/intel_iommu.h | 6 +++++ hw/i386/intel_iommu.c | 56 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 9 deletions(-)
include/hw/i386/intel_iommu.h +6 -0
@@ -300,6 +300,12 @@ struct IntelIOMMUState {OnOffAuto intr_eim;/* Toggle for EIM cabability */ bool buggy_eim;/* Force buggy EIM unless eim=off */ uint8_t aw_bits;/* Host/IOVA address width (in bits) */ + +/* +* Protects IOMMU states in general. Currently it protects the +* per-IOMMU IOTLB cache, and context entry cache in VTDAddressSpace. +*/ +QemuMutex iommu_lock; };/* Find the VTD Address space associated with the given bus pointer,
hw/i386/intel_iommu.c +47 -9
171 lines not on this page · raw message
Signature · 1 line
MST
[Qemu-devel] [PULL 23/28] intel-iommu: only do page walk for MAP notifiers
In reply to Michael S. TsirkinFrom: Peter Xu <[email protected]>
For UNMAP-only IOMMU notifiers, we don't need to walk the page tables. Fasten that procedure by skipping the page table walk. That should boost performance for UNMAP-only notifiers like vhost.
--- include/hw/i386/intel_iommu.h | 2 ++ hw/i386/intel_iommu.c | 44 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 5 deletions(-)
include/hw/i386/intel_iommu.h +2 -0
@@ -93,6 +93,8 @@ struct VTDAddressSpace {IntelIOMMUState *iommu_state;VTDContextCacheEntry context_cache_entry;QLIST_ENTRY (VTDAddressSpace) next; +/* Superset of notifier flags that this address space has */ +IOMMUNotifierFlag notifier_flags; };struct VTDBus {
hw/i386/intel_iommu.c +39 -5
73 lines not on this page · raw message
Signature · 1 line
MST
[Qemu-devel] [PULL 24/28] intel-iommu: introduce vtd_page_walk_info
In reply to Michael S. TsirkinFrom: Peter Xu <[email protected]>
During the recursive page walking of IOVA page tables, some stack variables are constant variables and never changed during the whole page walking procedure. Isolate them into a struct so that we don't need to pass those contants down the stack every time and multiple times.
--- hw/i386/intel_iommu.c | 84 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 32 deletions(-)
hw/i386/intel_iommu.c +52 -32
@@ -748,9 +748,27 @@ static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write,typedef int (*vtd_page_walk_hook )(IOMMUTLBEntry *entry,void *private); +/** +* Constant information used during page walking +* +* @hook_fn: hook func to be called when detected page +* @private: private data to be passed into hook func +* @notify_unmap: whether we should notify invalid entries +* @aw: maximum address width +*/ +typedef struct { +vtd_page_walk_hook hook_fn; +void *private; +bool notify_unmap; +uint8_t aw; +}vtd_page_walk_info ; +static int vtd_page_walk_one (IOMMUTLBEntry *entry,int level, -vtd_page_walk_hook hook_fn,void *private) +vtd_page_walk_info *info) { +vtd_page_walk_hook hook_fn = info->hook_fn; +void *private = info->private; +assert (hook_fn);trace_vtd_page_walk_one (level, entry->iova, entry->translated_addr, entry->addr_mask, entry->perm);
@@ -763,17 +781,13 @@ static int vtd_page_walk_one(IOMMUTLBEntry *entry, int level,* @addr: base GPA addr to start the walk * @start: IOVA range start address * @end: IOVA range end address (start <= addr < end) -* @hook_fn: hook func to be called when detected page -* @private: private data to be passed into hook func * @read: whether parent level has read permission * @write: whether parent level has write permission -* @notify_unmap: whether we should notify invalid entries -* @aw: maximum address width +* @info: constant information for the page walk */ static int vtd_page_walk_level (dma_addr_t addr,uint64_t start, -uint64_t end,vtd_page_walk_hook hook_fn, -void *private,uint32_t level,bool read, -bool write,bool notify_unmap,uint8_t aw) +uint64_t end,uint32_t level,bool read, +bool write,vtd_page_walk_info *info) {bool read_cur, write_cur, entry_valid;uint32_t offset;
@@ -823,24 +837,24 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,if (vtd_is_last_slpte (slpte, level)) {/* NOTE: this is only meaningful if entry_valid == true */ - entry.translated_addr =vtd_get_slpte_addr (slpte, aw); -if (!entry_valid && !notify_unmap) { + entry.translated_addr =vtd_get_slpte_addr (slpte, info->aw); +if (!entry_valid && !info->notify_unmap) {trace_vtd_page_walk_skip_perm (iova, iova_next); goto next; } - ret =vtd_page_walk_one (&entry, level, hook_fn, private); + ret =vtd_page_walk_one (&entry, level, info);if (ret <0 ) {return ret; } }else {if (!entry_valid) { -if (notify_unmap) { +if (info->notify_unmap) {/* * The whole entry is invalid; unmap it all. * Translated address is meaningless, zero it. */ entry.translated_addr =0x0 ; - ret =vtd_page_walk_one (&entry, level, hook_fn, private); + ret =vtd_page_walk_one (&entry, level, info);if (ret <0 ) {return ret; }
@@ -849,10 +863,9 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start, } goto next; } - ret =vtd_page_walk_level (vtd_get_slpte_addr (slpte, aw), iova, -MIN (iova_next, end), hook_fn, private, - level -1 , read_cur, write_cur, - notify_unmap, aw); + ret =vtd_page_walk_level (vtd_get_slpte_addr (slpte, info->aw), + iova,MIN (iova_next, end), level -1 , + read_cur, write_cur, info);if (ret <0 ) {return ret; }
@@ -871,28 +884,24 @@ next:* @ce: context entry to walk upon * @start: IOVA address to start the walk * @end: IOVA range end address (start <= addr < end) -* @hook_fn: the hook that to be called for each detected area -* @private: private data for the hook function -* @aw: maximum address width +* @info: page walking information struct */ static int vtd_page_walk (VTDContextEntry *ce,uint64_t start,uint64_t end, -vtd_page_walk_hook hook_fn,void *private, -bool notify_unmap,uint8_t aw) +vtd_page_walk_info *info) {dma_addr_t addr =vtd_ce_get_slpt_base (ce);uint32_t level =vtd_ce_get_level (ce); -if (!vtd_iova_range_check (start, ce, aw)) { +if (!vtd_iova_range_check (start, ce, info->aw)) {return -VTD_FR_ADDR_BEYOND_MGAW ; } -if (!vtd_iova_range_check (end, ce, aw)) { +if (!vtd_iova_range_check (end, ce, info->aw)) {/* Fix end so that it reaches the maximum */ - end =vtd_iova_limit (ce, aw); + end =vtd_iova_limit (ce, info->aw); } -return vtd_page_walk_level (addr, start, end, hook_fn, private, - level, true, true, notify_unmap, aw); +return vtd_page_walk_level (addr, start, end, level, true, true, info); }/* Map a device to its corresponding domain (context-entry) */
@@ -1449,14 +1458,19 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, vtd_as->devfn, &ce);if (!ret && domain_id ==VTD_CONTEXT_ENTRY_DID (ce.hi)) {if (vtd_as_has_map_notifier (vtd_as)) { +vtd_page_walk_info info = { + .hook_fn = vtd_page_invalidate_notify_hook, + .private = (void *)&vtd_as->iommu, + .notify_unmap = true, + .aw = s->aw_bits, + }; +/* * As long as we have MAP notifications registered in * any of our IOMMU notifiers, we need to sync the * shadow page table. */ -vtd_page_walk (&ce, addr, addr + size, - vtd_page_invalidate_notify_hook, - (void *)&vtd_as->iommu, true, s->aw_bits); +vtd_page_walk (&ce, addr, addr + size, &info); }else {/* * For UNMAP-only notifiers, we don't need to walk the
@@ -2924,8 +2938,14 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n) ce.hi, ce.lo);if (vtd_as_has_map_notifier (vtd_as)) {/* This is required only for MAP typed notifiers */ -vtd_page_walk (&ce,0 , ~0ULL , vtd_replay_hook, (void *)n, false, - s->aw_bits); +vtd_page_walk_info info = { + .hook_fn = vtd_replay_hook, + .private = (void *)n, + .notify_unmap = false, + .aw = s->aw_bits, + }; + +vtd_page_walk (&ce,0 , ~0ULL , &info); } }else { trace_vtd_replay_ce_invalid(bus_n, PCI_SLOT(vtd_as->devfn),
Signature · 1 line
MST
[Qemu-devel] [PULL 26/28] intel-iommu: trace domain id during page walk
In reply to Michael S. TsirkinFrom: Peter Xu <[email protected]>
This patch only modifies the trace points.
Previously we were tracing page walk levels. They are redundant since we have page mask (size) already. Now we trace something much more useful which is the domain ID of the page walking. That can be very useful when we trace more than one devices on the same system, so that we can know which map is for which domain.
--- hw/i386/intel_iommu.c | 16 ++++++++++------ hw/i386/trace-events | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-)
hw/i386/intel_iommu.c +10 -6
@@ -756,6 +756,7 @@ typedef int (*vtd_page_walk_hook)(IOMMUTLBEntry *entry, void *private);* @notify_unmap: whether we should notify invalid entries * @as: VT-d address space of the device * @aw: maximum address width +* @domain: domain ID of the page walk */ typedef struct { VTDAddressSpace *as;
@@ -763,17 +764,18 @@ typedef struct {void *private;bool notify_unmap;uint8_t aw; +uint16_t domain_id; } vtd_page_walk_info; -static int vtd_page_walk_one (IOMMUTLBEntry *entry,int level, -vtd_page_walk_info *info) +static int vtd_page_walk_one (IOMMUTLBEntry *entry,vtd_page_walk_info *info) {vtd_page_walk_hook hook_fn = info->hook_fn;void *private = info->private;assert (hook_fn); -trace_vtd_page_walk_one (level, entry->iova, entry->translated_addr, - entry->addr_mask, entry->perm); +trace_vtd_page_walk_one (info->domain_id, entry->iova, + entry->translated_addr, entry->addr_mask, + entry->perm);return hook_fn (entry, private); }
@@ -844,7 +846,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,trace_vtd_page_walk_skip_perm (iova, iova_next); goto next; } - ret =vtd_page_walk_one (&entry, level, info); + ret =vtd_page_walk_one (&entry, info);if (ret <0 ) {return ret; }
@@ -856,7 +858,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,* Translated address is meaningless, zero it. */ entry.translated_addr =0x0 ; - ret =vtd_page_walk_one (&entry, level, info); + ret =vtd_page_walk_one (&entry, info);if (ret <0 ) {return ret; }
@@ -1466,6 +1468,7 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, .notify_unmap = true, .aw = s->aw_bits, .as = vtd_as, + .domain_id = domain_id, };/*
@@ -2947,6 +2950,7 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n) .notify_unmap = false, .aw = s->aw_bits, .as = vtd_as, + .domain_id = VTD_CONTEXT_ENTRY_DID(ce.hi), };vtd_page_walk (&ce,0 , ~0ULL , &info);
hw/i386/trace-events +1 -1
@@ -39,7 +39,7 @@ vtd_fault_disabled(void) "Fault processing disabled for context entry" vtd_replay_ce_valid(uint8_t bus, uint8_t dev, uint8_t fn, uint16_t domain, uint64_t hi, uint64_t lo) "replay valid context device %02"PRIx8":%02"PRIx8".%02"PRIx8" domain 0x%"PRIx16" hi 0x%"PRIx64" lo 0x%"PRIx64 vtd_replay_ce_invalid(uint8_t bus, uint8_t dev, uint8_t fn) "replay invalid context device %02"PRIx8":%02"PRIx8".%02"PRIx8 vtd_page_walk_level(uint64_t addr, uint32_t level, uint64_t start, uint64_t end) "walk (base=0x%"PRIx64", level=%"PRIu32") iova range 0x%"PRIx64" - 0x%"PRIx64 -vtd_page_walk_one(uint32_t level, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "detected page level 0x%"PRIx32" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d" +vtd_page_walk_one(uint16_t domain, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "domain 0x%"PRIu16" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d" vtd_page_walk_skip_read(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to unable to read" vtd_page_walk_skip_perm(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to perm empty" vtd_page_walk_skip_reserve(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to rsrv set"
Signature · 1 line
MST
[Qemu-devel] [PULL 27/28] util: implement simple iova tree
In reply to Michael S. TsirkinFrom: Peter Xu <[email protected]>
Introduce a simplest iova tree implementation based on GTree.
--- include/qemu/iova-tree.h | 134 +++++++++++++++++++++++++++++++++++++++++++++++ util/iova-tree.c | 114 ++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 6 +++ util/Makefile.objs | 1 + 4 files changed, 255 insertions(+) create mode 100644 include/qemu/iova-tree.h create mode 100644 util/iova-tree.c
include/qemu/iova-tree.h new file +134 -0
@@ -0,0 +1,134 @@ +/* +* An very simplified iova tree implementation based on GTree. +* +* Copyright 2018 Red Hat, Inc. +* +* Authors: +* Peter Xu <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +*/ +#ifndef IOVA_TREE_H +#define IOVA_TREE_H + +/* +* Currently the iova tree will only allow to keep ranges +* information, and no extra user data is allowed for each element. A +* benefit is that we can merge adjacent ranges internally within the +* tree. It can save a lot of memory when the ranges are splitted but +* mostly continuous. +* +* Note that current implementation does not provide any thread +* protections. Callers of the iova tree should be responsible +* for the thread safety issue. +*/ + +#include "qemu/osdep.h" +#include "exec/memory.h" +#include "exec/hwaddr.h" + +#define IOVA_OK (0) +#define IOVA_ERR_INVALID (-1)/* Invalid parameters */ +#define IOVA_ERR_OVERLAP (-2)/* IOVA range overlapped */ + +typedef struct IOVATree IOVATree ; +typedef struct DMAMap { +hwaddr iova; +hwaddr translated_addr; +hwaddr size;/* Inclusive */ +IOMMUAccessFlags perm; +} QEMU_PACKED DMAMap; +typedef gboolean (*iova_tree_iterator )(DMAMap *map); + +/** +* iova_tree_new: +* +* Create a new iova tree. +* +* Returns: the tree pointer when succeeded, or NULL if error. +*/ +IOVATree *iova_tree_new (void ); + +/** +* iova_tree_insert: +* +* @tree: the iova tree to insert +* @map: the mapping to insert +* +* Insert an iova range to the tree. If there is overlapped +* ranges, IOVA_ERR_OVERLAP will be returned. +* +* Return: 0 if succeeded, or <0 if error. +*/ +int iova_tree_insert (IOVATree *tree,DMAMap *map); + +/** +* iova_tree_remove: +* +* @tree: the iova tree to remove range from +* @map: the map range to remove +* +* Remove mappings from the tree that are covered by the map range +* provided. The range does not need to be exactly what has inserted, +* all the mappings that are included in the provided range will be +* removed from the tree. Here map->translated_addr is meaningless. +* +* Return: 0 if succeeded, or <0 if error. +*/ +int iova_tree_remove (IOVATree *tree,DMAMap *map); + +/** +* iova_tree_find: +* +* @tree: the iova tree to search from +* @map: the mapping to search +* +* Search for a mapping in the iova tree that overlaps with the +* mapping range specified. Only the first found mapping will be +* returned. +* +* Return: DMAMap pointer if found, or NULL if not found. Note that +* the returned DMAMap pointer is maintained internally. User should +* only read the content but never modify or free the content. Also, +* user is responsible to make sure the pointer is valid (say, no +* concurrent deletion in progress). +*/ +DMAMap *iova_tree_find (IOVATree *tree,DMAMap *map); + +/** +* iova_tree_find_address: +* +* @tree: the iova tree to search from +* @iova: the iova address to find +* +* Similar to iova_tree_find(), but it tries to find mapping with +* range iova=iova & size=0. +* +* Return: same as iova_tree_find(). +*/ +DMAMap *iova_tree_find_address (IOVATree *tree,hwaddr iova); + +/** +* iova_tree_foreach: +* +* @tree: the iova tree to iterate on +* @iterator: the interator for the mappings, return true to stop +* +* Iterate over the iova tree. +* +* Return: 1 if found any overlap, 0 if not, <0 if error. +*/ +void iova_tree_foreach (IOVATree *tree,iova_tree_iterator iterator); + +/** +* iova_tree_destroy: +* +* @tree: the iova tree to destroy +* +* Destroy an existing iova tree. +* +* Return: None. +*/ +void iova_tree_destroy (IOVATree *tree); + +#endif
util/iova-tree.c new file +114 -0
114 lines not on this page · raw message
MAINTAINERS +6 -0
@@ -1783,6 +1783,12 @@ F: include/sysemu/replay.h F: docs/replay.txt F: stubs/replay.c +IOVA Tree +M: Peter Xu <[email protected]> +S: Maintained +F: include/qemu/iova-tree.h +F: util/iova-tree.c + Usermode Emulation ------------------ Overall
util/Makefile.objs +1 -0
@@ -47,4 +47,5 @@ util-obj-y += qht.o util-obj-y += range.o util-obj-y += stats64.o util-obj-y += systemd.o +util-obj-y += iova-tree.o util-obj-$(CONFIG_LINUX) += vfio-helpers.o
Signature · 1 line
MST
[Qemu-devel] [PULL 28/28] intel-iommu: rework the page walk logic
In reply to Michael S. TsirkinFrom: Peter Xu <[email protected]>
This patch fixes a potential small window that the DMA page table might be incomplete or invalid when the guest sends domain/context invalidations to a device. This can cause random DMA errors for assigned devices.
This is a major change to the VT-d shadow page walking logic. It includes but is not limited to:
- For each VTDAddressSpace, now we maintain what IOVA ranges we have mapped and what we have not. With that information, now we only send MAP or UNMAP when necessary. Say, we don't send MAP notifies if we know we have already mapped the range, meanwhile we don't send UNMAP notifies if we know we never mapped the range at all.
- Introduce vtd_sync_shadow_page_table[_range] APIs so that we can call in any places to resync the shadow page table for a device.
- When we receive domain/context invalidation, we should not really run the replay logic, instead we use the new sync shadow page table API to resync the whole shadow page table without unmapping the whole region. After this change, we'll only do the page walk once for each domain invalidations (before this, it can be multiple, depending on number of notifiers per address space).
While at it, the page walking logic is also refactored to be simpler.
--- include/hw/i386/intel_iommu.h | 2 + hw/i386/intel_iommu.c | 213 ++++++++++++++++++++++++++++++------------ hw/i386/trace-events | 3 +- 3 files changed, 159 insertions(+), 59 deletions(-)
include/hw/i386/intel_iommu.h +2 -0
@@ -27,6 +27,7 @@#include "hw/i386/ioapic.h" #include "hw/pci/msi.h" #include "hw/sysbus.h" +#include "qemu/iova-tree.h" #define TYPE_INTEL_IOMMU_DEVICE "intel-iommu"#define INTEL_IOMMU_DEVICE (obj) \
@@ -95,6 +96,7 @@ struct VTDAddressSpace {QLIST_ENTRY (VTDAddressSpace) next;/* Superset of notifier flags that this address space has */ IOMMUNotifierFlag notifier_flags; +IOVATree *iova_tree;/* Traces mapped IOVA ranges */ };struct VTDBus {
hw/i386/intel_iommu.c +155 -58
294 lines not on this page · raw message
hw/i386/trace-events +2 -1
@@ -40,8 +40,9 @@ vtd_replay_ce_valid(uint8_t bus, uint8_t dev, uint8_t fn, uint16_t domain, uint6 vtd_replay_ce_invalid(uint8_t bus, uint8_t dev, uint8_t fn) "replay invalid context device %02"PRIx8":%02"PRIx8".%02"PRIx8 vtd_page_walk_level(uint64_t addr, uint32_t level, uint64_t start, uint64_t end) "walk (base=0x%"PRIx64", level=%"PRIu32") iova range 0x%"PRIx64" - 0x%"PRIx64 vtd_page_walk_one(uint16_t domain, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "domain 0x%"PRIu16" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d" +vtd_page_walk_one_skip_map(uint64_t iova, uint64_t mask, uint64_t translated) "iova 0x%"PRIx64" mask 0x%"PRIx64" translated 0x%"PRIx64 +vtd_page_walk_one_skip_unmap(uint64_t iova, uint64_t mask) "iova 0x%"PRIx64" mask 0x%"PRIx64 vtd_page_walk_skip_read(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to unable to read" -vtd_page_walk_skip_perm(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to perm empty" vtd_page_walk_skip_reserve(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to rsrv set" vtd_switch_address_space(uint8_t bus, uint8_t slot, uint8_t fn, bool on) "Device %02x:%02x.%x switching address space (iommu enabled=%d)" vtd_as_unmap_whole(uint8_t bus, uint8_t slot, uint8_t fn, uint64_t iova, uint64_t size) "Device %02x:%02x.%x start 0x%"PRIx64" size 0x%"PRIx64
Signature · 1 line
MST
[Qemu-devel] [PULL 25/28] intel-iommu: pass in address space when page walk
In reply to Michael S. TsirkinFrom: Peter Xu <[email protected]>
We pass in the VTDAddressSpace too. It'll be used in the follow up patches.
--- hw/i386/intel_iommu.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/i386/intel_iommu.c +4 -0
@@ -754,9 +754,11 @@ typedef int (*vtd_page_walk_hook)(IOMMUTLBEntry *entry, void *private);* @hook_fn: hook func to be called when detected page * @private: private data to be passed into hook func * @notify_unmap: whether we should notify invalid entries +* @as: VT-d address space of the device * @aw: maximum address width */ typedef struct { + VTDAddressSpace *as; vtd_page_walk_hook hook_fn; void *private; bool notify_unmap;
@@ -1463,6 +1465,7 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, .private = (void *)&vtd_as->iommu, .notify_unmap = true, .aw = s->aw_bits, + .as = vtd_as, };/*
@@ -2943,6 +2946,7 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n) .private = (void *)n, .notify_unmap = false, .aw = s->aw_bits, + .as = vtd_as, };vtd_page_walk (&ce,0 , ~0ULL , &info);
Signature · 1 line
MST
Peter Maydell
AppliedQuoted 12 lines · Michael S. Tsirkin
The following changes since commit
4f50c1673a89b07f376ce5c42d22d79a79cd466d:Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' into staging (2018-05-22 09:43:58 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstreamfor you to fetch changes up to
63b88968f139b6a77f2f81e6f1eedf70c0170a85:intel-iommu: rework the page walk logic (2018-05-23 17:34:05 +0300)
Quoted 9 lines
----------------------------------------------------------------
pc, pci, virtio, vhost: fixes, featuresBeginning of merging vDPA, new PCI ID, a new virtio balloon stat, intel iommu rework fixing a couple of security problems (no CVEs yet), fixes all over the place.
Signed-off-by Michael S. Tsirkin <[email protected]>
Applied, thanks.
-- PMM
This series seems to have some coding style problems. See output below for more information:
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PULL 00/28] pc, pci, virtio, vhost: fixes, features
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
t [tag update] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'4c9a6a2ffe intel-iommu: rework the page walk logic5650cac9fb util: implement simple iova tree88534312e0 intel-iommu: trace domain id during page walk 8ac709ee1c intel-iommu: pass in address space when page walk 1947a6e8f5 intel-iommu: introduce vtd_page_walk_info9625294a9c intel-iommu: only do page walk for MAP notifiers dde4ff462d intel-iommu: add iommu lockf2f4e4a75c intel-iommu: remove IntelIOMMUNotifierNodee38afacae2 intel-iommu: send PSI always even if across PDEs 0d36159676 nvdimm: fix typo in label-size definition471bf9c78b contrib/vhost-user-blk: enable protocol feature for vhost-user-blk a9ae0b2add hw/virtio: Fix brace Werror with clang 6.0.0 7cbfe1743d libvhost-user: Send messages with no data195b5bd713 vhost-user+postcopy: Use qemu_set_nonblock011e39054e virtio: support setting memory region based host notifier 7ecf626817 vhost-user: support receiving file descriptors in slave_read 2f00a166ec vhost-user: add Net prefix to internal state structure d30090016d linux-headers: add kvm header for mips6d6f92c8b0 linux-headers: add unistd.h on all arches0e21fd6465 update-linux-headers.sh: unistd.h, kvm consistency 082496d2b5 linux-headers: drop kvm_para.h0365135fac x86/cpu: use standard-headers/asm-x86.kvm_para.h 2317795f33 include/standard-headers: add asm-x86/kvm_para.h 1be5f83d10 update-linux-headers.sh: drop kvm_para.h hacks 964e0ee4cf vhost: add trace for IOTLB misse679e9a70f virtio-balloon: add hugetlb page allocation counts a800e0a24e allocate pci id for mdpyb33c444024 hw/pci-host/q35: Replace hardcoded value with macro
=== OUTPUT BEGIN ===
Checking PATCH 1/28: hw/pci-host/q35: Replace hardcoded value with macro...
WARNING: line over 80 characters
#27: FILE: hw/pci-host/q35.c:538:
+ mch->pci_address_space, MCH_HOST_BRIDGE_SMRAM_C_BASE,
WARNING: line over 80 characters
#29: FILE: hw/pci-host/q35.c:540:
+ memory_region_add_subregion_overlap(mch->system_memory, MCH_HOST_BRIDGE_SMRAM_C_BASE,
total: 0 errors, 2 warnings, 35 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 2/28: allocate pci id for mdpy...
Checking PATCH 3/28: virtio-balloon: add hugetlb page allocation counts... Checking PATCH 4/28: vhost: add trace for IOTLB miss... Checking PATCH 5/28: update-linux-headers.sh: drop kvm_para.h hacks...
ERROR: line over 90 characters
#48: FILE: scripts/update-linux-headers.sh:121:
+ cp_portable "$tmpdir/include/asm/kvm_para.h" "$output/include/standard-headers/asm-$arch"
total: 1 errors, 0 warnings, 44 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 6/28: include/standard-headers: add asm-x86/kvm_para.h...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #13:
new file mode 100644
total: 0 errors, 1 warnings, 121 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 7/28: x86/cpu: use standard-headers/asm-x86.kvm_para.h... Checking PATCH 8/28: linux-headers: drop kvm_para.h...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #12:
deleted file mode 100644
total: 0 errors, 1 warnings, 0 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 9/28: update-linux-headers.sh: unistd.h, kvm consistency... Checking PATCH 10/28: linux-headers: add unistd.h on all arches...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #14:
new file mode 100644
total: 0 errors, 1 warnings, 1017 lines checked
Your patch has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 11/28: linux-headers: add kvm header for mips...
Checking PATCH 12/28: vhost-user: add Net prefix to internal state structure... Checking PATCH 13/28: vhost-user: support receiving file descriptors in slave_read... Checking PATCH 14/28: virtio: support setting memory region based host notifier... Checking PATCH 15/28: vhost-user+postcopy: Use qemu_set_nonblock...
Checking PATCH 16/28: libvhost-user: Send messages with no data...
Checking PATCH 17/28: hw/virtio: Fix brace Werror with clang 6.0.0... Checking PATCH 18/28: contrib/vhost-user-blk: enable protocol feature for vhost-user-blk... Checking PATCH 19/28: nvdimm: fix typo in label-size definition...
Checking PATCH 20/28: intel-iommu: send PSI always even if across PDEs... Checking PATCH 21/28: intel-iommu: remove IntelIOMMUNotifierNode...
Checking PATCH 22/28: intel-iommu: add iommu lock...
Checking PATCH 23/28: intel-iommu: only do page walk for MAP notifiers... Checking PATCH 24/28: intel-iommu: introduce vtd_page_walk_info...
Checking PATCH 25/28: intel-iommu: pass in address space when page walk... Checking PATCH 26/28: intel-iommu: trace domain id during page walk... Checking PATCH 27/28: util: implement simple iova tree...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #32:
new file mode 100644
total: 0 errors, 1 warnings, 265 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 28/28: intel-iommu: rework the page walk logic... === OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Re: [PULL 07/28] x86/cpu: use standard-headers/asm-x86.kvm_para.h
In reply to Michael S. TsirkinQuoted 9 lines · Michael S. Tsirkin
Switch to the header we imported from Linux,
this allows us to drop a hack inkvm_i386.h.
More code will be dropped in the next patch.Signed-off-by Michael S. Tsirkin <[email protected]>
target/i386/cpu.h typedef uint32_t FeatureWordArray[FEATURE_WORDS]; · line 693
Quoted 8 lines
target/i386/cpu.h +0
-2@@ -688,8 +688,6 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Speculation Control */ #define CPUID_7_0_EDX_SPEC_CTRL_SSBD (1U << 31)/* Speculative Store Bypass Disable */ -#define KVM_HINTS_DEDICATED (1U << 0) -#define CPUID_8000_0008_EBX_IBPB (1U << 12)/* Indirect Branch Prediction Barrier */ #define CPUID_XSAVE_XSAVEOPT (1U << 0)
Hi -- this seems like it will break compilation when we next update our copy of the Linux kernel headers, because (as of 4.17-rc6, at least), asm-x86/kvm_para.h doesn't define KVM_HINTS_DEDICATED. Here's the diff I get as part of my attempt to run update-linux-headers:
include/standard-headers/asm-x86/kvm_para.h +1 -1
@@ -29,7 +29,7 @@#define KVM_FEATURE_PV_TLB_FLUSH 9#define KVM_FEATURE_ASYNC_PF_VMEXIT 10 -#define KVM_HINTS_DEDICATED 0 +#define KVM_HINTS_REALTIME 0/* The last 8 bits are used to indicate how to interpret the flags field * in pvclock structure. If no bits are set, all flags are ignored.
I'm not sure what's going on here -- commit 633711e8287 in the kernel just renames the constant, but doesn't that break userspace API ?
thanks
-- PMM
Re: [PULL 07/28] x86/cpu: use standard-headers/asm-x86.kvm_para.h
Quoted 17 lines · Peter Maydell
Quoted 16 lines · Michael S. Tsirkin
Switch to the header we imported from Linux,
this allows us to drop a hack inkvm_i386.h.
More code will be dropped in the next patch.Signed-off-by Michael S. Tsirkin <[email protected]>target/i386/cpu.h +0
-2@@ -688,8 +688,6 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Speculation Control */ #define CPUID_7_0_EDX_SPEC_CTRL_SSBD (1U << 31)/* Speculative Store Bypass Disable */ -#define KVM_HINTS_DEDICATED (1U << 0) -#define CPUID_8000_0008_EBX_IBPB (1U << 12)/* Indirect Branch Prediction Barrier */
Quoted 6 lines
target/i386/cpu.h typedef uint32_t FeatureWordArray[FEATURE_WORDS]; · line 693
Quoted 1 line
target/i386/cpu.h +0
-0#define CPUID_XSAVE_XSAVEOPT (1U << 0)Hi -- this seems like it will break compilation when we next update our copy of the Linux kernel headers, because (as of 4.17-rc6, at least),
asm-x86/kvm_para.hdoesn't defineKVM_HINTS_DEDICATED.
For the moment I'm using this workaround (I wanted to do a header update for something else I'm working on):
target/i386/kvm.c +5 -0
@@ -48,6 +48,11 @@#include "exec/memattrs.h" #include "trace.h" +/* Work around this kernel header constant changing its name */ +#ifndef KVM_HINTS_REALTIME +#define KVM_HINTS_REALTIME KVM_HINTS_DEDICATED +#endif +//#define DEBUG_KVM #ifdef DEBUG_KVM
@@ -387,7 +392,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s,
uint32_t function,
ret &= ~(1U << KVM_FEATURE_PV_UNHALT);
}
} else if (function == KVM_CPUID_FEATURES && reg == R_EDX) {
- ret |= 1U << KVM_HINTS_DEDICATED;
+ ret |= 1U << KVM_HINTS_REALTIME;
found = 1;
}thanks
-- PMM
Re: [PULL 07/28] x86/cpu: use standard-headers/asm-x86.kvm_para.h
Quoted 32 lines · Peter Maydell
Quoted 17 lines · Peter Maydell
Quoted 16 lines · Michael S. Tsirkin
Switch to the header we imported from Linux,
this allows us to drop a hack inkvm_i386.h.
More code will be dropped in the next patch.Signed-off-by Michael S. Tsirkin <[email protected]>target/i386/cpu.h +0
-2@@ -688,8 +688,6 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Speculation Control */ #define CPUID_7_0_EDX_SPEC_CTRL_SSBD (1U << 31)/* Speculative Store Bypass Disable */ -#define KVM_HINTS_DEDICATED (1U << 0) -#define CPUID_8000_0008_EBX_IBPB (1U << 12)/* Indirect Branch Prediction Barrier */ Quoted 6 lines
target/i386/cpu.h typedef uint32_t FeatureWordArray[FEATURE_WORDS]; · line 693
Quoted 1 line
target/i386/cpu.h +0
-0#define CPUID_XSAVE_XSAVEOPT (1U << 0)Hi -- this seems like it will break compilation when we next update our copy of the Linux kernel headers, because (as of 4.17-rc6, at least),
asm-x86/kvm_para.hdoesn't defineKVM_HINTS_DEDICATED.For the moment I'm using this workaround (I wanted to do a header update for something else I'm working on):
target/i386/kvm.c +0
-0@@ -48,6 +48,11 @@#include "exec/memattrs.h"
target/i386/kvm.c line 58
Quoted 10 lines
target/i386/kvm.c +5
-0#include "trace.h" +/* Work around this kernel header constant changing its name */ +#ifndef KVM_HINTS_REALTIME +#define KVM_HINTS_REALTIME KVM_HINTS_DEDICATED +#endif +//#define DEBUG_KVM #ifdef DEBUG_KVM
I don't think we need this chunk.
target/i386/kvm.c uint32_t kvm_arch_get_supported_cpuid(KVMState *s, · line 398
Quoted 9 lines
target/i386/kvm.c +1
-1@@ -387,7 +392,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function, ret &= ~(1U << KVM_FEATURE_PV_UNHALT); } }else if (function ==KVM_CPUID_FEATURES && reg ==R_EDX ) { - ret |=1U <<KVM_HINTS_DEDICATED ; + ret |=1U <<KVM_HINTS_REALTIME ; found =1 ; }
That's the right change when we update this header.
Quoted 2 lines
thanks
-- PMM
Re: [PULL 07/28] x86/cpu: use standard-headers/asm-x86.kvm_para.h
In reply to Peter MaydellQuoted 13 lines · Peter Maydell
Quoted 12 lines · Michael S. Tsirkin
Switch to the header we imported from Linux,
this allows us to drop a hack inkvm_i386.h.
More code will be dropped in the next patch.Signed-off-by Michael S. Tsirkin <[email protected]>target/i386/cpu.h +0
-0@@ -688,8 +688,6 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Speculation Control */ #define CPUID_7_0_EDX_SPEC_CTRL_SSBD (1U << 31)/* Speculative Store Bypass Disable */
Quoted 8 lines
target/i386/cpu.h typedef uint32_t FeatureWordArray[FEATURE_WORDS]; · line 693
Quoted 5 lines
target/i386/cpu.h +0
-2-#define KVM_HINTS_DEDICATED (1U << 0) -#define CPUID_8000_0008_EBX_IBPB (1U << 12)/* Indirect Branch Prediction Barrier */ #define CPUID_XSAVE_XSAVEOPT (1U << 0)Hi -- this seems like it will break compilation when we next update our copy of the Linux kernel headers,
That just means we'll need to update kvm.c when we do it.
Quoted 23 lines
because (as of
4.17-rc6, at least),asm-x86/kvm_para.hdoesn't defineKVM_HINTS_DEDICATED. Here's the diff I get as part of my attempt to run update-linux-headers:include/standard-headers/asm-x86/kvm_para.h +1
-1@@ -29,7 +29,7 @@#define KVM_FEATURE_PV_TLB_FLUSH 9#define KVM_FEATURE_ASYNC_PF_VMEXIT 10 -#define KVM_HINTS_DEDICATED 0 +#define KVM_HINTS_REALTIME 0/* The last 8 bits are used to indicate how to interpret the flags field * in pvclock structure. If no bits are set, all flags are ignored. I'm not sure what's going on here -- commit
633711e8287in the kernel just renames the constant, but doesn't that break userspace API ?thanks
-- PMM
Re: [PULL 07/28] x86/cpu: use standard-headers/asm-x86.kvm_para.h
In reply to Michael S. TsirkinQuoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Peter Maydell
For the moment I'm using this workaround (I wanted to do a header update for something else I'm working on):
target/i386/kvm.c +5
-0@@ -48,6 +48,11 @@#include "exec/memattrs.h" #include "trace.h" +/* Work around this kernel header constant changing its name */ +#ifndef KVM_HINTS_REALTIME +#define KVM_HINTS_REALTIME KVM_HINTS_DEDICATED +#endif +//#define DEBUG_KVM
Quoted 3 lines
target/i386/kvm.c line 58
Quoted 1 line
target/i386/kvm.c +0
-0#ifdef DEBUG_KVM I don't think we need this chunk.
My view is that header update commits should be exactly and only the result of running update-linux-headers, no manual tweaking. If you don't add this chunk before the update, compilation with the update will fail. You can remove the chunk after the update, of course...
thanks
-- PMM
Re: [PULL 07/28] x86/cpu: use standard-headers/asm-x86.kvm_para.h
Quoted 22 lines · Peter Maydell
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Peter Maydell
For the moment I'm using this workaround (I wanted to do a header update for something else I'm working on):
target/i386/kvm.c +5
-0@@ -48,6 +48,11 @@#include "exec/memattrs.h" #include "trace.h" +/* Work around this kernel header constant changing its name */ +#ifndef KVM_HINTS_REALTIME +#define KVM_HINTS_REALTIME KVM_HINTS_DEDICATED +#endif +//#define DEBUG_KVM Quoted 3 lines
target/i386/kvm.c line 58
Quoted 1 line
target/i386/kvm.c +0
-0#ifdef DEBUG_KVM I don't think we need this chunk.
Quoted 7 lines
My view is that header update commits should be exactly and only the result of running update-linux-headers, no manual tweaking. If you don't add this chunk before the update, compilation with the update will fail. You can remove the chunk after the update, of course...
thanks
-- PMM
I see. I guess you did all the work already, do you still need help or will you just go ahead and post it? Or even commit directly, it's a trivial enough patch.
Signature · 1 line
MST
Re: [PULL 07/28] x86/cpu: use standard-headers/asm-x86.kvm_para.h
Quoted 3 lines · Michael S. Tsirkin
I see. I guess you did all the work already, do you still need help or will you just go ahead and post it? Or even commit directly, it's a trivial enough patch.
I'll send a series later this afternoon that does an update to 4.17-rc6; it has a couple of other prerequisites in it, to handle __aligned_u64 in the update script (patch already posted this morning, but I'll put it in the series), and to deal with the kernel headers not yet defining VIRTIO_GPU_CAPSET_VIRGL2.
thanks
-- PMM
Re: [PULL 07/28] x86/cpu: use standard-headers/asm-x86.kvm_para.h
Quoted 10 lines · Peter Maydell
Quoted 3 lines · Michael S. Tsirkin
I see. I guess you did all the work already, do you still need help or will you just go ahead and post it? Or even commit directly, it's a trivial enough patch.
I'll send a series later this afternoon that does an update to 4.17-rc6; it has a couple of other prerequisites in it, to handle
__aligned_u64in the update script (patch already posted this morning, but I'll put it in the series), and to deal with the kernel headers not yet definingVIRTIO_GPU_CAPSET_VIRGL2.
You mean like this:
http://patchwork.ozlabs.org/patch/907121/
?
Quoted 2 lines
thanks
-- PMM
Re: [PULL 07/28] x86/cpu: use standard-headers/asm-x86.kvm_para.h
Quoted 13 lines · Michael S. Tsirkin
Quoted 10 lines · Peter Maydell
Quoted 3 lines · Michael S. Tsirkin
I see. I guess you did all the work already, do you still need help or will you just go ahead and post it? Or even commit directly, it's a trivial enough patch.
I'll send a series later this afternoon that does an update to 4.17-rc6; it has a couple of other prerequisites in it, to handle
__aligned_u64in the update script (patch already posted this morning, but I'll put it in the series), and to deal with the kernel headers not yet definingVIRTIO_GPU_CAPSET_VIRGL2.
Quoted 4 lines
You mean like this:
http://patchwork.ozlabs.org/patch/907121/?
Yes; I missed that (found a mail thread pointing out the problem but not the patch with the fix); I'll pick it up for the series.
thanks
-- PMM
Paolo Bonzini
maintainerRe: [PULL 07/28] x86/cpu: use standard-headers/asm-x86.kvm_para.h
In reply to Peter MaydellQuoted 12 lines · Peter Maydell
include/standard-headers/asm-x86/kvm_para.h +1
-1@@ -29,7 +29,7 @@#define KVM_FEATURE_PV_TLB_FLUSH 9#define KVM_FEATURE_ASYNC_PF_VMEXIT 10 -#define KVM_HINTS_DEDICATED 0 +#define KVM_HINTS_REALTIME 0/* The last 8 bits are used to indicate how to interpret the flags field * in pvclock structure. If no bits are set, all flags are ignored.
Quoted 3 lines
I'm not sure what's going on here -- commit
633711e8287in the kernel just renames the constant, but doesn't that break userspace API ?
No, but only because the constant with the old name was not in any released version. It was added in 4.17-rc1.
Thanks,
Paolo