All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] s390x/ap: fix hang when mdev attached to guest is removed
@ 2023-06-02 14:11 Tony Krowiak
  2023-06-02 14:11 ` [PATCH v2 1/2] linux-headers: Update with vfio_ap IRQ index mapping Tony Krowiak
  2023-06-02 14:11 ` [PATCH v2 2/2] s390x/ap: Wire up the device request notifier interface Tony Krowiak
  0 siblings, 2 replies; 7+ messages in thread
From: Tony Krowiak @ 2023-06-02 14:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, mjrosato, jjherne, pasic, fiuczy, thuth, farman,
	borntraeger, clg, cohuck, Tony Krowiak

When a user attempts to remove a vfio-ap mediated device attached to a
guest, the operation hangs until the mdev's fd is closed by the guest
(i.e., the guest is shut down). This patch series provides userspace 
(i.e., qemu) code to handle device unplug requests for AP. When notified
that the mdev is being removed, the handler will unplug the device, thus
avoiding the hang condition.

Link: https://lore.kernel.org/r/20230530223538.279198-4-akrowiak@linux.ibm.com

Tony Krowiak (2):
  linux-headers: Update with vfio_ap IRQ index mapping
  s390x/ap: Wire up the device request notifier interface

 hw/vfio/ap.c                                  | 113 ++++++++++++++++++
 include/standard-headers/linux/const.h        |   2 +-
 include/standard-headers/linux/virtio_blk.h   |  18 +--
 .../standard-headers/linux/virtio_config.h    |   6 +
 include/standard-headers/linux/virtio_net.h   |   1 +
 linux-headers/asm-arm64/kvm.h                 |  33 +++++
 linux-headers/asm-riscv/kvm.h                 |  53 +++++++-
 linux-headers/asm-riscv/unistd.h              |   9 ++
 linux-headers/asm-s390/unistd_32.h            |   1 +
 linux-headers/asm-s390/unistd_64.h            |   1 +
 linux-headers/asm-x86/kvm.h                   |   3 +
 linux-headers/linux/const.h                   |   2 +-
 linux-headers/linux/kvm.h                     |  12 +-
 linux-headers/linux/psp-sev.h                 |   7 ++
 linux-headers/linux/userfaultfd.h             |  17 ++-
 linux-headers/linux/vfio.h                    |   9 ++
 16 files changed, 271 insertions(+), 16 deletions(-)

-- 
2.31.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] linux-headers: Update with vfio_ap IRQ index mapping
  2023-06-02 14:11 [PATCH v2 0/2] s390x/ap: fix hang when mdev attached to guest is removed Tony Krowiak
@ 2023-06-02 14:11 ` Tony Krowiak
  2023-07-03 16:31   ` Cédric Le Goater
  2023-06-02 14:11 ` [PATCH v2 2/2] s390x/ap: Wire up the device request notifier interface Tony Krowiak
  1 sibling, 1 reply; 7+ messages in thread
From: Tony Krowiak @ 2023-06-02 14:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, mjrosato, jjherne, pasic, fiuczy, thuth, farman,
	borntraeger, clg, cohuck, Tony Krowiak

Note: This is a placeholder patch that includes unmerged uapi changes.

Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
Link: https://lore.kernel.org/qemu-devel/20230530225544.280031-1-akrowiak@linux.ibm.com/
---
 include/standard-headers/linux/const.h        |  2 +-
 include/standard-headers/linux/virtio_blk.h   | 18 +++----
 .../standard-headers/linux/virtio_config.h    |  6 +++
 include/standard-headers/linux/virtio_net.h   |  1 +
 linux-headers/asm-arm64/kvm.h                 | 33 ++++++++++++
 linux-headers/asm-riscv/kvm.h                 | 53 ++++++++++++++++++-
 linux-headers/asm-riscv/unistd.h              |  9 ++++
 linux-headers/asm-s390/unistd_32.h            |  1 +
 linux-headers/asm-s390/unistd_64.h            |  1 +
 linux-headers/asm-x86/kvm.h                   |  3 ++
 linux-headers/linux/const.h                   |  2 +-
 linux-headers/linux/kvm.h                     | 12 +++--
 linux-headers/linux/psp-sev.h                 |  7 +++
 linux-headers/linux/userfaultfd.h             | 17 +++++-
 linux-headers/linux/vfio.h                    |  9 ++++
 15 files changed, 158 insertions(+), 16 deletions(-)

diff --git a/include/standard-headers/linux/const.h b/include/standard-headers/linux/const.h
index 5e4898725168..1eb84b5087f8 100644
--- a/include/standard-headers/linux/const.h
+++ b/include/standard-headers/linux/const.h
@@ -28,7 +28,7 @@
 #define _BITUL(x)	(_UL(1) << (x))
 #define _BITULL(x)	(_ULL(1) << (x))
 
-#define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
+#define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)
 #define __ALIGN_KERNEL_MASK(x, mask)	(((x) + (mask)) & ~(mask))
 
 #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
diff --git a/include/standard-headers/linux/virtio_blk.h b/include/standard-headers/linux/virtio_blk.h
index 7155b1a4701b..d7be3cf5e42f 100644
--- a/include/standard-headers/linux/virtio_blk.h
+++ b/include/standard-headers/linux/virtio_blk.h
@@ -138,11 +138,11 @@ struct virtio_blk_config {
 
 	/* Zoned block device characteristics (if VIRTIO_BLK_F_ZONED) */
 	struct virtio_blk_zoned_characteristics {
-		uint32_t zone_sectors;
-		uint32_t max_open_zones;
-		uint32_t max_active_zones;
-		uint32_t max_append_sectors;
-		uint32_t write_granularity;
+		__virtio32 zone_sectors;
+		__virtio32 max_open_zones;
+		__virtio32 max_active_zones;
+		__virtio32 max_append_sectors;
+		__virtio32 write_granularity;
 		uint8_t model;
 		uint8_t unused2[3];
 	} zoned;
@@ -239,11 +239,11 @@ struct virtio_blk_outhdr {
  */
 struct virtio_blk_zone_descriptor {
 	/* Zone capacity */
-	uint64_t z_cap;
+	__virtio64 z_cap;
 	/* The starting sector of the zone */
-	uint64_t z_start;
+	__virtio64 z_start;
 	/* Zone write pointer position in sectors */
-	uint64_t z_wp;
+	__virtio64 z_wp;
 	/* Zone type */
 	uint8_t z_type;
 	/* Zone state */
@@ -252,7 +252,7 @@ struct virtio_blk_zone_descriptor {
 };
 
 struct virtio_blk_zone_report {
-	uint64_t nr_zones;
+	__virtio64 nr_zones;
 	uint8_t reserved[56];
 	struct virtio_blk_zone_descriptor zones[];
 };
diff --git a/include/standard-headers/linux/virtio_config.h b/include/standard-headers/linux/virtio_config.h
index 965ee6ae237e..8a7d0dc8b007 100644
--- a/include/standard-headers/linux/virtio_config.h
+++ b/include/standard-headers/linux/virtio_config.h
@@ -97,6 +97,12 @@
  */
 #define VIRTIO_F_SR_IOV			37
 
+/*
+ * This feature indicates that the driver passes extra data (besides
+ * identifying the virtqueue) in its device notifications.
+ */
+#define VIRTIO_F_NOTIFICATION_DATA	38
+
 /*
  * This feature indicates that the driver can reset a queue individually.
  */
diff --git a/include/standard-headers/linux/virtio_net.h b/include/standard-headers/linux/virtio_net.h
index c0e797067aae..2325485f2ca8 100644
--- a/include/standard-headers/linux/virtio_net.h
+++ b/include/standard-headers/linux/virtio_net.h
@@ -61,6 +61,7 @@
 #define VIRTIO_NET_F_GUEST_USO6	55	/* Guest can handle USOv6 in. */
 #define VIRTIO_NET_F_HOST_USO	56	/* Host can handle USO in. */
 #define VIRTIO_NET_F_HASH_REPORT  57	/* Supports hash report */
+#define VIRTIO_NET_F_GUEST_HDRLEN  59	/* Guest provides the exact hdr_len value. */
 #define VIRTIO_NET_F_RSS	  60	/* Supports RSS RX steering */
 #define VIRTIO_NET_F_RSC_EXT	  61	/* extended coalescing info */
 #define VIRTIO_NET_F_STANDBY	  62	/* Act as standby for another device
diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h
index d7e7bb885e20..38e5957526c2 100644
--- a/linux-headers/asm-arm64/kvm.h
+++ b/linux-headers/asm-arm64/kvm.h
@@ -198,6 +198,15 @@ struct kvm_arm_copy_mte_tags {
 	__u64 reserved[2];
 };
 
+/*
+ * Counter/Timer offset structure. Describe the virtual/physical offset.
+ * To be used with KVM_ARM_SET_COUNTER_OFFSET.
+ */
+struct kvm_arm_counter_offset {
+	__u64 counter_offset;
+	__u64 reserved;
+};
+
 #define KVM_ARM_TAGS_TO_GUEST		0
 #define KVM_ARM_TAGS_FROM_GUEST		1
 
@@ -363,6 +372,10 @@ enum {
 	KVM_REG_ARM_VENDOR_HYP_BIT_PTP		= 1,
 };
 
+/* Device Control API on vm fd */
+#define KVM_ARM_VM_SMCCC_CTRL		0
+#define   KVM_ARM_VM_SMCCC_FILTER	0
+
 /* Device Control API: ARM VGIC */
 #define KVM_DEV_ARM_VGIC_GRP_ADDR	0
 #define KVM_DEV_ARM_VGIC_GRP_DIST_REGS	1
@@ -402,6 +415,8 @@ enum {
 #define KVM_ARM_VCPU_TIMER_CTRL		1
 #define   KVM_ARM_VCPU_TIMER_IRQ_VTIMER		0
 #define   KVM_ARM_VCPU_TIMER_IRQ_PTIMER		1
+#define   KVM_ARM_VCPU_TIMER_IRQ_HVTIMER	2
+#define   KVM_ARM_VCPU_TIMER_IRQ_HPTIMER	3
 #define KVM_ARM_VCPU_PVTIME_CTRL	2
 #define   KVM_ARM_VCPU_PVTIME_IPA	0
 
@@ -458,6 +473,24 @@ enum {
 /* run->fail_entry.hardware_entry_failure_reason codes. */
 #define KVM_EXIT_FAIL_ENTRY_CPU_UNSUPPORTED	(1ULL << 0)
 
+enum kvm_smccc_filter_action {
+	KVM_SMCCC_FILTER_HANDLE = 0,
+	KVM_SMCCC_FILTER_DENY,
+	KVM_SMCCC_FILTER_FWD_TO_USER,
+
+};
+
+struct kvm_smccc_filter {
+	__u32 base;
+	__u32 nr_functions;
+	__u8 action;
+	__u8 pad[15];
+};
+
+/* arm64-specific KVM_EXIT_HYPERCALL flags */
+#define KVM_HYPERCALL_EXIT_SMC		(1U << 0)
+#define KVM_HYPERCALL_EXIT_16BIT	(1U << 1)
+
 #endif
 
 #endif /* __ARM_KVM_H__ */
diff --git a/linux-headers/asm-riscv/kvm.h b/linux-headers/asm-riscv/kvm.h
index 92af6f3f057c..f92790c9481a 100644
--- a/linux-headers/asm-riscv/kvm.h
+++ b/linux-headers/asm-riscv/kvm.h
@@ -12,6 +12,7 @@
 #ifndef __ASSEMBLY__
 
 #include <linux/types.h>
+#include <asm/bitsperlong.h>
 #include <asm/ptrace.h>
 
 #define __KVM_HAVE_READONLY_MEM
@@ -52,6 +53,7 @@ struct kvm_riscv_config {
 	unsigned long mvendorid;
 	unsigned long marchid;
 	unsigned long mimpid;
+	unsigned long zicboz_block_size;
 };
 
 /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
@@ -64,7 +66,7 @@ struct kvm_riscv_core {
 #define KVM_RISCV_MODE_S	1
 #define KVM_RISCV_MODE_U	0
 
-/* CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
+/* General CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
 struct kvm_riscv_csr {
 	unsigned long sstatus;
 	unsigned long sie;
@@ -78,6 +80,17 @@ struct kvm_riscv_csr {
 	unsigned long scounteren;
 };
 
+/* AIA CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
+struct kvm_riscv_aia_csr {
+	unsigned long siselect;
+	unsigned long iprio1;
+	unsigned long iprio2;
+	unsigned long sieh;
+	unsigned long siph;
+	unsigned long iprio1h;
+	unsigned long iprio2h;
+};
+
 /* TIMER registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
 struct kvm_riscv_timer {
 	__u64 frequency;
@@ -105,9 +118,29 @@ enum KVM_RISCV_ISA_EXT_ID {
 	KVM_RISCV_ISA_EXT_SVINVAL,
 	KVM_RISCV_ISA_EXT_ZIHINTPAUSE,
 	KVM_RISCV_ISA_EXT_ZICBOM,
+	KVM_RISCV_ISA_EXT_ZICBOZ,
+	KVM_RISCV_ISA_EXT_ZBB,
+	KVM_RISCV_ISA_EXT_SSAIA,
 	KVM_RISCV_ISA_EXT_MAX,
 };
 
+/*
+ * SBI extension IDs specific to KVM. This is not the same as the SBI
+ * extension IDs defined by the RISC-V SBI specification.
+ */
+enum KVM_RISCV_SBI_EXT_ID {
+	KVM_RISCV_SBI_EXT_V01 = 0,
+	KVM_RISCV_SBI_EXT_TIME,
+	KVM_RISCV_SBI_EXT_IPI,
+	KVM_RISCV_SBI_EXT_RFENCE,
+	KVM_RISCV_SBI_EXT_SRST,
+	KVM_RISCV_SBI_EXT_HSM,
+	KVM_RISCV_SBI_EXT_PMU,
+	KVM_RISCV_SBI_EXT_EXPERIMENTAL,
+	KVM_RISCV_SBI_EXT_VENDOR,
+	KVM_RISCV_SBI_EXT_MAX,
+};
+
 /* Possible states for kvm_riscv_timer */
 #define KVM_RISCV_TIMER_STATE_OFF	0
 #define KVM_RISCV_TIMER_STATE_ON	1
@@ -118,6 +151,8 @@ enum KVM_RISCV_ISA_EXT_ID {
 /* If you need to interpret the index values, here is the key: */
 #define KVM_REG_RISCV_TYPE_MASK		0x00000000FF000000
 #define KVM_REG_RISCV_TYPE_SHIFT	24
+#define KVM_REG_RISCV_SUBTYPE_MASK	0x0000000000FF0000
+#define KVM_REG_RISCV_SUBTYPE_SHIFT	16
 
 /* Config registers are mapped as type 1 */
 #define KVM_REG_RISCV_CONFIG		(0x01 << KVM_REG_RISCV_TYPE_SHIFT)
@@ -131,8 +166,12 @@ enum KVM_RISCV_ISA_EXT_ID {
 
 /* Control and status registers are mapped as type 3 */
 #define KVM_REG_RISCV_CSR		(0x03 << KVM_REG_RISCV_TYPE_SHIFT)
+#define KVM_REG_RISCV_CSR_GENERAL	(0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT)
+#define KVM_REG_RISCV_CSR_AIA		(0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT)
 #define KVM_REG_RISCV_CSR_REG(name)	\
 		(offsetof(struct kvm_riscv_csr, name) / sizeof(unsigned long))
+#define KVM_REG_RISCV_CSR_AIA_REG(name)	\
+	(offsetof(struct kvm_riscv_aia_csr, name) / sizeof(unsigned long))
 
 /* Timer registers are mapped as type 4 */
 #define KVM_REG_RISCV_TIMER		(0x04 << KVM_REG_RISCV_TYPE_SHIFT)
@@ -152,6 +191,18 @@ enum KVM_RISCV_ISA_EXT_ID {
 /* ISA Extension registers are mapped as type 7 */
 #define KVM_REG_RISCV_ISA_EXT		(0x07 << KVM_REG_RISCV_TYPE_SHIFT)
 
+/* SBI extension registers are mapped as type 8 */
+#define KVM_REG_RISCV_SBI_EXT		(0x08 << KVM_REG_RISCV_TYPE_SHIFT)
+#define KVM_REG_RISCV_SBI_SINGLE	(0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT)
+#define KVM_REG_RISCV_SBI_MULTI_EN	(0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT)
+#define KVM_REG_RISCV_SBI_MULTI_DIS	(0x2 << KVM_REG_RISCV_SUBTYPE_SHIFT)
+#define KVM_REG_RISCV_SBI_MULTI_REG(__ext_id)	\
+		((__ext_id) / __BITS_PER_LONG)
+#define KVM_REG_RISCV_SBI_MULTI_MASK(__ext_id)	\
+		(1UL << ((__ext_id) % __BITS_PER_LONG))
+#define KVM_REG_RISCV_SBI_MULTI_REG_LAST	\
+		KVM_REG_RISCV_SBI_MULTI_REG(KVM_RISCV_SBI_EXT_MAX - 1)
+
 #endif
 
 #endif /* __LINUX_KVM_RISCV_H */
diff --git a/linux-headers/asm-riscv/unistd.h b/linux-headers/asm-riscv/unistd.h
index 73d7cdd2ec49..950ab3fd4409 100644
--- a/linux-headers/asm-riscv/unistd.h
+++ b/linux-headers/asm-riscv/unistd.h
@@ -43,3 +43,12 @@
 #define __NR_riscv_flush_icache (__NR_arch_specific_syscall + 15)
 #endif
 __SYSCALL(__NR_riscv_flush_icache, sys_riscv_flush_icache)
+
+/*
+ * Allows userspace to query the kernel for CPU architecture and
+ * microarchitecture details across a given set of CPUs.
+ */
+#ifndef __NR_riscv_hwprobe
+#define __NR_riscv_hwprobe (__NR_arch_specific_syscall + 14)
+#endif
+__SYSCALL(__NR_riscv_hwprobe, sys_riscv_hwprobe)
diff --git a/linux-headers/asm-s390/unistd_32.h b/linux-headers/asm-s390/unistd_32.h
index 8e644d65f571..800f3adb2020 100644
--- a/linux-headers/asm-s390/unistd_32.h
+++ b/linux-headers/asm-s390/unistd_32.h
@@ -419,6 +419,7 @@
 #define __NR_landlock_create_ruleset 444
 #define __NR_landlock_add_rule 445
 #define __NR_landlock_restrict_self 446
+#define __NR_memfd_secret 447
 #define __NR_process_mrelease 448
 #define __NR_futex_waitv 449
 #define __NR_set_mempolicy_home_node 450
diff --git a/linux-headers/asm-s390/unistd_64.h b/linux-headers/asm-s390/unistd_64.h
index 51da542fec10..399a6059015e 100644
--- a/linux-headers/asm-s390/unistd_64.h
+++ b/linux-headers/asm-s390/unistd_64.h
@@ -367,6 +367,7 @@
 #define __NR_landlock_create_ruleset 444
 #define __NR_landlock_add_rule 445
 #define __NR_landlock_restrict_self 446
+#define __NR_memfd_secret 447
 #define __NR_process_mrelease 448
 #define __NR_futex_waitv 449
 #define __NR_set_mempolicy_home_node 450
diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h
index 2937e7bf6982..2b3a8f7bd2c0 100644
--- a/linux-headers/asm-x86/kvm.h
+++ b/linux-headers/asm-x86/kvm.h
@@ -557,4 +557,7 @@ struct kvm_pmu_event_filter {
 #define KVM_VCPU_TSC_CTRL 0 /* control group for the timestamp counter (TSC) */
 #define   KVM_VCPU_TSC_OFFSET 0 /* attribute for the TSC offset */
 
+/* x86-specific KVM_EXIT_HYPERCALL flags. */
+#define KVM_EXIT_HYPERCALL_LONG_MODE	BIT(0)
+
 #endif /* _ASM_X86_KVM_H */
diff --git a/linux-headers/linux/const.h b/linux-headers/linux/const.h
index 5e4898725168..1eb84b5087f8 100644
--- a/linux-headers/linux/const.h
+++ b/linux-headers/linux/const.h
@@ -28,7 +28,7 @@
 #define _BITUL(x)	(_UL(1) << (x))
 #define _BITULL(x)	(_ULL(1) << (x))
 
-#define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
+#define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)
 #define __ALIGN_KERNEL_MASK(x, mask)	(((x) + (mask)) & ~(mask))
 
 #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index 599de3c6e3aa..65b145b317ac 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -341,8 +341,11 @@ struct kvm_run {
 			__u64 nr;
 			__u64 args[6];
 			__u64 ret;
-			__u32 longmode;
-			__u32 pad;
+
+			union {
+				__u32 longmode;
+				__u64 flags;
+			};
 		} hypercall;
 		/* KVM_EXIT_TPR_ACCESS */
 		struct {
@@ -1182,6 +1185,7 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224
 #define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225
 #define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226
+#define KVM_CAP_COUNTER_OFFSET 227
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
@@ -1449,7 +1453,7 @@ struct kvm_vfio_spapr_tce {
 #define KVM_CREATE_VCPU           _IO(KVMIO,   0x41)
 #define KVM_GET_DIRTY_LOG         _IOW(KVMIO,  0x42, struct kvm_dirty_log)
 #define KVM_SET_NR_MMU_PAGES      _IO(KVMIO,   0x44)
-#define KVM_GET_NR_MMU_PAGES      _IO(KVMIO,   0x45)
+#define KVM_GET_NR_MMU_PAGES      _IO(KVMIO,   0x45)  /* deprecated */
 #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \
 					struct kvm_userspace_memory_region)
 #define KVM_SET_TSS_ADDR          _IO(KVMIO,   0x47)
@@ -1541,6 +1545,8 @@ struct kvm_s390_ucas_mapping {
 #define KVM_SET_PMU_EVENT_FILTER  _IOW(KVMIO,  0xb2, struct kvm_pmu_event_filter)
 #define KVM_PPC_SVM_OFF		  _IO(KVMIO,  0xb3)
 #define KVM_ARM_MTE_COPY_TAGS	  _IOR(KVMIO,  0xb4, struct kvm_arm_copy_mte_tags)
+/* Available with KVM_CAP_COUNTER_OFFSET */
+#define KVM_ARM_SET_COUNTER_OFFSET _IOW(KVMIO,  0xb5, struct kvm_arm_counter_offset)
 
 /* ioctl for vm fd */
 #define KVM_CREATE_DEVICE	  _IOWR(KVMIO,  0xe0, struct kvm_create_device)
diff --git a/linux-headers/linux/psp-sev.h b/linux-headers/linux/psp-sev.h
index 51d8b3940e14..12ccb70099d4 100644
--- a/linux-headers/linux/psp-sev.h
+++ b/linux-headers/linux/psp-sev.h
@@ -36,6 +36,13 @@ enum {
  * SEV Firmware status code
  */
 typedef enum {
+	/*
+	 * This error code is not in the SEV spec. Its purpose is to convey that
+	 * there was an error that prevented the SEV firmware from being called.
+	 * The SEV API error codes are 16 bits, so the -1 value will not overlap
+	 * with possible values from the specification.
+	 */
+	SEV_RET_NO_FW_CALL = -1,
 	SEV_RET_SUCCESS = 0,
 	SEV_RET_INVALID_PLATFORM_STATE,
 	SEV_RET_INVALID_GUEST_STATE,
diff --git a/linux-headers/linux/userfaultfd.h b/linux-headers/linux/userfaultfd.h
index ba5d0df52fb8..14e402263a8a 100644
--- a/linux-headers/linux/userfaultfd.h
+++ b/linux-headers/linux/userfaultfd.h
@@ -38,7 +38,8 @@
 			   UFFD_FEATURE_MINOR_HUGETLBFS |	\
 			   UFFD_FEATURE_MINOR_SHMEM |		\
 			   UFFD_FEATURE_EXACT_ADDRESS |		\
-			   UFFD_FEATURE_WP_HUGETLBFS_SHMEM)
+			   UFFD_FEATURE_WP_HUGETLBFS_SHMEM |	\
+			   UFFD_FEATURE_WP_UNPOPULATED)
 #define UFFD_API_IOCTLS				\
 	((__u64)1 << _UFFDIO_REGISTER |		\
 	 (__u64)1 << _UFFDIO_UNREGISTER |	\
@@ -203,6 +204,12 @@ struct uffdio_api {
 	 *
 	 * UFFD_FEATURE_WP_HUGETLBFS_SHMEM indicates that userfaultfd
 	 * write-protection mode is supported on both shmem and hugetlbfs.
+	 *
+	 * UFFD_FEATURE_WP_UNPOPULATED indicates that userfaultfd
+	 * write-protection mode will always apply to unpopulated pages
+	 * (i.e. empty ptes).  This will be the default behavior for shmem
+	 * & hugetlbfs, so this flag only affects anonymous memory behavior
+	 * when userfault write-protection mode is registered.
 	 */
 #define UFFD_FEATURE_PAGEFAULT_FLAG_WP		(1<<0)
 #define UFFD_FEATURE_EVENT_FORK			(1<<1)
@@ -217,6 +224,7 @@ struct uffdio_api {
 #define UFFD_FEATURE_MINOR_SHMEM		(1<<10)
 #define UFFD_FEATURE_EXACT_ADDRESS		(1<<11)
 #define UFFD_FEATURE_WP_HUGETLBFS_SHMEM		(1<<12)
+#define UFFD_FEATURE_WP_UNPOPULATED		(1<<13)
 	__u64 features;
 
 	__u64 ioctls;
@@ -297,6 +305,13 @@ struct uffdio_writeprotect {
 struct uffdio_continue {
 	struct uffdio_range range;
 #define UFFDIO_CONTINUE_MODE_DONTWAKE		((__u64)1<<0)
+	/*
+	 * UFFDIO_CONTINUE_MODE_WP will map the page write protected on
+	 * the fly.  UFFDIO_CONTINUE_MODE_WP is available only if the
+	 * write protected ioctl is implemented for the range
+	 * according to the uffdio_register.ioctls.
+	 */
+#define UFFDIO_CONTINUE_MODE_WP			((__u64)1<<1)
 	__u64 mode;
 
 	/*
diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h
index 4a534edbdcba..2658fda219e8 100644
--- a/linux-headers/linux/vfio.h
+++ b/linux-headers/linux/vfio.h
@@ -646,6 +646,15 @@ enum {
 	VFIO_CCW_NUM_IRQS
 };
 
+/*
+ * The vfio-ap bus driver makes use of the following IRQ index mapping.
+ * Unimplemented IRQ types return a count of zero.
+ */
+enum {
+	VFIO_AP_REQ_IRQ_INDEX,
+	VFIO_AP_NUM_IRQS
+};
+
 /**
  * VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 12,
  *					      struct vfio_pci_hot_reset_info)
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] s390x/ap: Wire up the device request notifier interface
  2023-06-02 14:11 [PATCH v2 0/2] s390x/ap: fix hang when mdev attached to guest is removed Tony Krowiak
  2023-06-02 14:11 ` [PATCH v2 1/2] linux-headers: Update with vfio_ap IRQ index mapping Tony Krowiak
@ 2023-06-02 14:11 ` Tony Krowiak
  2023-06-02 14:28   ` Cédric Le Goater
  1 sibling, 1 reply; 7+ messages in thread
From: Tony Krowiak @ 2023-06-02 14:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, mjrosato, jjherne, pasic, fiuczy, thuth, farman,
	borntraeger, clg, cohuck, Tony Krowiak

Let's wire up the device request notifier interface to handle device unplug
requests for AP.

Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
Link: https://lore.kernel.org/qemu-devel/20230530225544.280031-1-akrowiak@linux.ibm.com/
---
 hw/vfio/ap.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 113 insertions(+)

diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index e0dd561e85a3..6e21d1da5a70 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -18,6 +18,8 @@
 #include "hw/vfio/vfio-common.h"
 #include "hw/s390x/ap-device.h"
 #include "qemu/error-report.h"
+#include "qemu/event_notifier.h"
+#include "qemu/main-loop.h"
 #include "qemu/module.h"
 #include "qemu/option.h"
 #include "qemu/config-file.h"
@@ -33,6 +35,7 @@
 struct VFIOAPDevice {
     APDevice apdev;
     VFIODevice vdev;
+    EventNotifier req_notifier;
 };
 
 OBJECT_DECLARE_SIMPLE_TYPE(VFIOAPDevice, VFIO_AP_DEVICE)
@@ -84,10 +87,110 @@ static VFIOGroup *vfio_ap_get_group(VFIOAPDevice *vapdev, Error **errp)
     return vfio_get_group(groupid, &address_space_memory, errp);
 }
 
+static void vfio_ap_req_notifier_handler(void *opaque)
+{
+    VFIOAPDevice *vapdev = opaque;
+    Error *err = NULL;
+
+    if (!event_notifier_test_and_clear(&vapdev->req_notifier)) {
+        return;
+    }
+
+    qdev_unplug(DEVICE(vapdev), &err);
+
+    if (err) {
+        warn_reportf_err(err, VFIO_MSG_PREFIX, vapdev->vdev.name);
+    }
+}
+
+static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,
+                                          unsigned int irq, Error **errp)
+{
+    int fd;
+    size_t argsz;
+    IOHandler *fd_read;
+    EventNotifier *notifier;
+    struct vfio_irq_info *irq_info;
+    VFIODevice *vdev = &vapdev->vdev;
+
+    switch (irq) {
+    case VFIO_AP_REQ_IRQ_INDEX:
+        notifier = &vapdev->req_notifier;
+        fd_read = vfio_ap_req_notifier_handler;
+        break;
+    default:
+        error_setg(errp, "vfio: Unsupported device irq(%d)", irq);
+        return;
+    }
+
+    if (vdev->num_irqs < irq + 1) {
+        error_setg(errp, "vfio: IRQ %u not available (number of irqs %u)",
+                   irq, vdev->num_irqs);
+        return;
+    }
+
+    argsz = sizeof(*irq_info);
+    irq_info = g_malloc0(argsz);
+    irq_info->index = irq;
+    irq_info->argsz = argsz;
+
+    if (ioctl(vdev->fd, VFIO_DEVICE_GET_IRQ_INFO,
+              irq_info) < 0 || irq_info->count < 1) {
+        error_setg_errno(errp, errno, "vfio: Error getting irq info");
+        goto out_free_info;
+    }
+
+    if (event_notifier_init(notifier, 0)) {
+        error_setg_errno(errp, errno,
+                         "vfio: Unable to init event notifier for irq (%d)",
+                         irq);
+        goto out_free_info;
+    }
+
+    fd = event_notifier_get_fd(notifier);
+    qemu_set_fd_handler(fd, fd_read, NULL, vapdev);
+
+    if (vfio_set_irq_signaling(vdev, irq, 0, VFIO_IRQ_SET_ACTION_TRIGGER, fd,
+                               errp)) {
+        qemu_set_fd_handler(fd, NULL, NULL, vapdev);
+        event_notifier_cleanup(notifier);
+    }
+
+out_free_info:
+    g_free(irq_info);
+
+}
+
+static void vfio_ap_unregister_irq_notifier(VFIOAPDevice *vapdev,
+                                            unsigned int irq)
+{
+    Error *err = NULL;
+    EventNotifier *notifier;
+
+    switch (irq) {
+    case VFIO_AP_REQ_IRQ_INDEX:
+        notifier = &vapdev->req_notifier;
+        break;
+    default:
+        error_report("vfio: Unsupported device irq(%d)", irq);
+        return;
+    }
+
+    if (vfio_set_irq_signaling(&vapdev->vdev, irq, 0,
+                               VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) {
+        warn_reportf_err(err, VFIO_MSG_PREFIX, vapdev->vdev.name);
+    }
+
+    qemu_set_fd_handler(event_notifier_get_fd(notifier),
+                        NULL, NULL, vapdev);
+    event_notifier_cleanup(notifier);
+}
+
 static void vfio_ap_realize(DeviceState *dev, Error **errp)
 {
     int ret;
     char *mdevid;
+    Error *err = NULL;
     VFIOGroup *vfio_group;
     APDevice *apdev = AP_DEVICE(dev);
     VFIOAPDevice *vapdev = VFIO_AP_DEVICE(apdev);
@@ -116,6 +219,15 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
         goto out_get_dev_err;
     }
 
+    vfio_ap_register_irq_notifier(vapdev, VFIO_AP_REQ_IRQ_INDEX, &err);
+    if (err) {
+        /*
+         * Report this error, but do not make it a failing condition.
+         * Lack of this IRQ in the host does not prevent normal operation.
+         */
+        error_report_err(err);
+    }
+
     return;
 
 out_get_dev_err:
@@ -129,6 +241,7 @@ static void vfio_ap_unrealize(DeviceState *dev)
     VFIOAPDevice *vapdev = VFIO_AP_DEVICE(apdev);
     VFIOGroup *group = vapdev->vdev.group;
 
+    vfio_ap_unregister_irq_notifier(vapdev, VFIO_AP_REQ_IRQ_INDEX);
     vfio_ap_put_device(vapdev);
     vfio_put_group(group);
 }
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] s390x/ap: Wire up the device request notifier interface
  2023-06-02 14:11 ` [PATCH v2 2/2] s390x/ap: Wire up the device request notifier interface Tony Krowiak
@ 2023-06-02 14:28   ` Cédric Le Goater
  2023-06-02 15:00     ` Anthony Krowiak
  0 siblings, 1 reply; 7+ messages in thread
From: Cédric Le Goater @ 2023-06-02 14:28 UTC (permalink / raw)
  To: Tony Krowiak, qemu-devel
  Cc: qemu-s390x, mjrosato, jjherne, pasic, fiuczy, thuth, farman,
	borntraeger, cohuck

Hello Tony,

On 6/2/23 16:11, Tony Krowiak wrote:
> Let's wire up the device request notifier interface to handle device unplug
> requests for AP.
> 
> Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
> Link: https://lore.kernel.org/qemu-devel/20230530225544.280031-1-akrowiak@linux.ibm.com/
> ---
>   hw/vfio/ap.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 113 insertions(+)
> 
> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
> index e0dd561e85a3..6e21d1da5a70 100644
> --- a/hw/vfio/ap.c
> +++ b/hw/vfio/ap.c
> @@ -18,6 +18,8 @@
>   #include "hw/vfio/vfio-common.h"
>   #include "hw/s390x/ap-device.h"
>   #include "qemu/error-report.h"
> +#include "qemu/event_notifier.h"
> +#include "qemu/main-loop.h"
>   #include "qemu/module.h"
>   #include "qemu/option.h"
>   #include "qemu/config-file.h"
> @@ -33,6 +35,7 @@
>   struct VFIOAPDevice {
>       APDevice apdev;
>       VFIODevice vdev;
> +    EventNotifier req_notifier;
>   };
>   
>   OBJECT_DECLARE_SIMPLE_TYPE(VFIOAPDevice, VFIO_AP_DEVICE)
> @@ -84,10 +87,110 @@ static VFIOGroup *vfio_ap_get_group(VFIOAPDevice *vapdev, Error **errp)
>       return vfio_get_group(groupid, &address_space_memory, errp);
>   }
>   
> +static void vfio_ap_req_notifier_handler(void *opaque)
> +{
> +    VFIOAPDevice *vapdev = opaque;
> +    Error *err = NULL;
> +
> +    if (!event_notifier_test_and_clear(&vapdev->req_notifier)) {
> +        return;
> +    }
> +
> +    qdev_unplug(DEVICE(vapdev), &err);
> +
> +    if (err) {
> +        warn_reportf_err(err, VFIO_MSG_PREFIX, vapdev->vdev.name);
> +    }
> +}
> +
> +static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,
> +                                          unsigned int irq, Error **errp)
> +{
> +    int fd;
> +    size_t argsz;
> +    IOHandler *fd_read;
> +    EventNotifier *notifier;
> +    struct vfio_irq_info *irq_info;
> +    VFIODevice *vdev = &vapdev->vdev;
> +
> +    switch (irq) {

Do you have plan for more interrupts ? If not, you could convert the
'switch' statement to a simple 'if' and remove the fd_read variable.

> +    case VFIO_AP_REQ_IRQ_INDEX:
> +        notifier = &vapdev->req_notifier;
> +        fd_read = vfio_ap_req_notifier_handler;
> +        break;
> +    default:
> +        error_setg(errp, "vfio: Unsupported device irq(%d)", irq);
> +        return;
> +    }
> +
> +    if (vdev->num_irqs < irq + 1) {
> +        error_setg(errp, "vfio: IRQ %u not available (number of irqs %u)",
> +                   irq, vdev->num_irqs);
> +        return;
> +    }
> +
> +    argsz = sizeof(*irq_info);
> +    irq_info = g_malloc0(argsz);
> +    irq_info->index = irq;
> +    irq_info->argsz = argsz;
> +
> +    if (ioctl(vdev->fd, VFIO_DEVICE_GET_IRQ_INFO,
> +              irq_info) < 0 || irq_info->count < 1) {
> +        error_setg_errno(errp, errno, "vfio: Error getting irq info");
> +        goto out_free_info;
> +    }
> +
> +    if (event_notifier_init(notifier, 0)) {
> +        error_setg_errno(errp, errno,
> +                         "vfio: Unable to init event notifier for irq (%d)",
> +                         irq);
> +        goto out_free_info;
> +    }
> +
> +    fd = event_notifier_get_fd(notifier);
> +    qemu_set_fd_handler(fd, fd_read, NULL, vapdev);
> +
> +    if (vfio_set_irq_signaling(vdev, irq, 0, VFIO_IRQ_SET_ACTION_TRIGGER, fd,
> +                               errp)) {
> +        qemu_set_fd_handler(fd, NULL, NULL, vapdev);
> +        event_notifier_cleanup(notifier);
> +    }
> +
> +out_free_info:
> +    g_free(irq_info);
> +
> +}
> +
> +static void vfio_ap_unregister_irq_notifier(VFIOAPDevice *vapdev,
> +                                            unsigned int irq)
> +{
> +    Error *err = NULL;
> +    EventNotifier *notifier;
> +
> +    switch (irq) {
> +    case VFIO_AP_REQ_IRQ_INDEX:
> +        notifier = &vapdev->req_notifier;
> +        break;
> +    default:
> +        error_report("vfio: Unsupported device irq(%d)", irq);
> +        return;
> +    }
> +
> +    if (vfio_set_irq_signaling(&vapdev->vdev, irq, 0,
> +                               VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) {
> +        warn_reportf_err(err, VFIO_MSG_PREFIX, vapdev->vdev.name);
> +    }
> +
> +    qemu_set_fd_handler(event_notifier_get_fd(notifier),
> +                        NULL, NULL, vapdev);
> +    event_notifier_cleanup(notifier);
> +}
> +
>   static void vfio_ap_realize(DeviceState *dev, Error **errp)
>   {
>       int ret;
>       char *mdevid;
> +    Error *err = NULL;
>       VFIOGroup *vfio_group;
>       APDevice *apdev = AP_DEVICE(dev);
>       VFIOAPDevice *vapdev = VFIO_AP_DEVICE(apdev);
> @@ -116,6 +219,15 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
>           goto out_get_dev_err;
>       }
>   
> +    vfio_ap_register_irq_notifier(vapdev, VFIO_AP_REQ_IRQ_INDEX, &err);
> +    if (err) {
> +        /*
> +         * Report this error, but do not make it a failing condition.
> +         * Lack of this IRQ in the host does not prevent normal operation.
> +         */
> +        error_report_err(err);

May be issue a warning instead ?

Thanks,

C.

> +    }
> +
>       return;
>   
>   out_get_dev_err:
> @@ -129,6 +241,7 @@ static void vfio_ap_unrealize(DeviceState *dev)
>       VFIOAPDevice *vapdev = VFIO_AP_DEVICE(apdev);
>       VFIOGroup *group = vapdev->vdev.group;
>   
> +    vfio_ap_unregister_irq_notifier(vapdev, VFIO_AP_REQ_IRQ_INDEX);
>       vfio_ap_put_device(vapdev);
>       vfio_put_group(group);
>   }



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] s390x/ap: Wire up the device request notifier interface
  2023-06-02 14:28   ` Cédric Le Goater
@ 2023-06-02 15:00     ` Anthony Krowiak
  0 siblings, 0 replies; 7+ messages in thread
From: Anthony Krowiak @ 2023-06-02 15:00 UTC (permalink / raw)
  To: Cédric Le Goater, qemu-devel
  Cc: qemu-s390x, mjrosato, jjherne, pasic, fiuczy, thuth, farman,
	borntraeger, cohuck



On 6/2/23 10:28 AM, Cédric Le Goater wrote:
> Hello Tony,
> 
> On 6/2/23 16:11, Tony Krowiak wrote:
>> Let's wire up the device request notifier interface to handle device 
>> unplug
>> requests for AP.
>>
>> Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
>> Link: 
>> https://lore.kernel.org/qemu-devel/20230530225544.280031-1-akrowiak@linux.ibm.com/
>> ---
>>   hw/vfio/ap.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 113 insertions(+)
>>
>> diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
>> index e0dd561e85a3..6e21d1da5a70 100644
>> --- a/hw/vfio/ap.c
>> +++ b/hw/vfio/ap.c
>> @@ -18,6 +18,8 @@
>>   #include "hw/vfio/vfio-common.h"
>>   #include "hw/s390x/ap-device.h"
>>   #include "qemu/error-report.h"
>> +#include "qemu/event_notifier.h"
>> +#include "qemu/main-loop.h"
>>   #include "qemu/module.h"
>>   #include "qemu/option.h"
>>   #include "qemu/config-file.h"
>> @@ -33,6 +35,7 @@
>>   struct VFIOAPDevice {
>>       APDevice apdev;
>>       VFIODevice vdev;
>> +    EventNotifier req_notifier;
>>   };
>>   OBJECT_DECLARE_SIMPLE_TYPE(VFIOAPDevice, VFIO_AP_DEVICE)
>> @@ -84,10 +87,110 @@ static VFIOGroup *vfio_ap_get_group(VFIOAPDevice 
>> *vapdev, Error **errp)
>>       return vfio_get_group(groupid, &address_space_memory, errp);
>>   }
>> +static void vfio_ap_req_notifier_handler(void *opaque)
>> +{
>> +    VFIOAPDevice *vapdev = opaque;
>> +    Error *err = NULL;
>> +
>> +    if (!event_notifier_test_and_clear(&vapdev->req_notifier)) {
>> +        return;
>> +    }
>> +
>> +    qdev_unplug(DEVICE(vapdev), &err);
>> +
>> +    if (err) {
>> +        warn_reportf_err(err, VFIO_MSG_PREFIX, vapdev->vdev.name);
>> +    }
>> +}
>> +
>> +static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,
>> +                                          unsigned int irq, Error 
>> **errp)
>> +{
>> +    int fd;
>> +    size_t argsz;
>> +    IOHandler *fd_read;
>> +    EventNotifier *notifier;
>> +    struct vfio_irq_info *irq_info;
>> +    VFIODevice *vdev = &vapdev->vdev;
>> +
>> +    switch (irq) {
> 
> Do you have plan for more interrupts ? If not, you could convert the
> 'switch' statement to a simple 'if' and remove the fd_read variable.

At this time there are no plans for further interrupts, but the switch 
does make it easy to add them:) On the other hand, I have no problem 
changing this to an 'if' statement. The fd_read variable is used below 
in the call to the qemu_set_fd_handler() function, so I can't get rid of it.

> 
>> +    case VFIO_AP_REQ_IRQ_INDEX:
>> +        notifier = &vapdev->req_notifier;
>> +        fd_read = vfio_ap_req_notifier_handler;
>> +        break;
>> +    default:
>> +        error_setg(errp, "vfio: Unsupported device irq(%d)", irq);
>> +        return;
>> +    }
>> +
>> +    if (vdev->num_irqs < irq + 1) {
>> +        error_setg(errp, "vfio: IRQ %u not available (number of irqs 
>> %u)",
>> +                   irq, vdev->num_irqs);
>> +        return;
>> +    }
>> +
>> +    argsz = sizeof(*irq_info);
>> +    irq_info = g_malloc0(argsz);
>> +    irq_info->index = irq;
>> +    irq_info->argsz = argsz;
>> +
>> +    if (ioctl(vdev->fd, VFIO_DEVICE_GET_IRQ_INFO,
>> +              irq_info) < 0 || irq_info->count < 1) {
>> +        error_setg_errno(errp, errno, "vfio: Error getting irq info");
>> +        goto out_free_info;
>> +    }
>> +
>> +    if (event_notifier_init(notifier, 0)) {
>> +        error_setg_errno(errp, errno,
>> +                         "vfio: Unable to init event notifier for irq 
>> (%d)",
>> +                         irq);
>> +        goto out_free_info;
>> +    }
>> +
>> +    fd = event_notifier_get_fd(notifier);
>> +    qemu_set_fd_handler(fd, fd_read, NULL, vapdev);
>> +
>> +    if (vfio_set_irq_signaling(vdev, irq, 0, 
>> VFIO_IRQ_SET_ACTION_TRIGGER, fd,
>> +                               errp)) {
>> +        qemu_set_fd_handler(fd, NULL, NULL, vapdev);
>> +        event_notifier_cleanup(notifier);
>> +    }
>> +
>> +out_free_info:
>> +    g_free(irq_info);
>> +
>> +}
>> +
>> +static void vfio_ap_unregister_irq_notifier(VFIOAPDevice *vapdev,
>> +                                            unsigned int irq)
>> +{
>> +    Error *err = NULL;
>> +    EventNotifier *notifier;
>> +
>> +    switch (irq) {
>> +    case VFIO_AP_REQ_IRQ_INDEX:
>> +        notifier = &vapdev->req_notifier;
>> +        break;
>> +    default:
>> +        error_report("vfio: Unsupported device irq(%d)", irq);
>> +        return;
>> +    }
>> +
>> +    if (vfio_set_irq_signaling(&vapdev->vdev, irq, 0,
>> +                               VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) {
>> +        warn_reportf_err(err, VFIO_MSG_PREFIX, vapdev->vdev.name);
>> +    }
>> +
>> +    qemu_set_fd_handler(event_notifier_get_fd(notifier),
>> +                        NULL, NULL, vapdev);
>> +    event_notifier_cleanup(notifier);
>> +}
>> +
>>   static void vfio_ap_realize(DeviceState *dev, Error **errp)
>>   {
>>       int ret;
>>       char *mdevid;
>> +    Error *err = NULL;
>>       VFIOGroup *vfio_group;
>>       APDevice *apdev = AP_DEVICE(dev);
>>       VFIOAPDevice *vapdev = VFIO_AP_DEVICE(apdev);
>> @@ -116,6 +219,15 @@ static void vfio_ap_realize(DeviceState *dev, 
>> Error **errp)
>>           goto out_get_dev_err;
>>       }
>> +    vfio_ap_register_irq_notifier(vapdev, VFIO_AP_REQ_IRQ_INDEX, &err);
>> +    if (err) {
>> +        /*
>> +         * Report this error, but do not make it a failing condition.
>> +         * Lack of this IRQ in the host does not prevent normal 
>> operation.
>> +         */
>> +        error_report_err(err);
> 
> May be issue a warning instead ?

Given the comment above - i.e., not a failing condition - it probably 
makes sense to make it a warning.

> 
> Thanks,
> 
> C.
> 
>> +    }
>> +
>>       return;
>>   out_get_dev_err:
>> @@ -129,6 +241,7 @@ static void vfio_ap_unrealize(DeviceState *dev)
>>       VFIOAPDevice *vapdev = VFIO_AP_DEVICE(apdev);
>>       VFIOGroup *group = vapdev->vdev.group;
>> +    vfio_ap_unregister_irq_notifier(vapdev, VFIO_AP_REQ_IRQ_INDEX);
>>       vfio_ap_put_device(vapdev);
>>       vfio_put_group(group);
>>   }
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] linux-headers: Update with vfio_ap IRQ index mapping
  2023-06-02 14:11 ` [PATCH v2 1/2] linux-headers: Update with vfio_ap IRQ index mapping Tony Krowiak
@ 2023-07-03 16:31   ` Cédric Le Goater
  2023-07-03 20:31     ` Anthony Krowiak
  0 siblings, 1 reply; 7+ messages in thread
From: Cédric Le Goater @ 2023-07-03 16:31 UTC (permalink / raw)
  To: Tony Krowiak, qemu-devel
  Cc: qemu-s390x, mjrosato, jjherne, pasic, fiuczy, thuth, farman,
	borntraeger, cohuck

On 6/2/23 16:11, Tony Krowiak wrote:
> Note: This is a placeholder patch that includes unmerged uapi changes.
> 
> Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
> Link: https://lore.kernel.org/qemu-devel/20230530225544.280031-1-akrowiak@linux.ibm.com/

I am preparing a vfio-next tree including these changes plus a linux-headers
update. I am just waiting for the 6.5-rc1 tag to be pushed.

Thanks,

C.

> ---
>   include/standard-headers/linux/const.h        |  2 +-
>   include/standard-headers/linux/virtio_blk.h   | 18 +++----
>   .../standard-headers/linux/virtio_config.h    |  6 +++
>   include/standard-headers/linux/virtio_net.h   |  1 +
>   linux-headers/asm-arm64/kvm.h                 | 33 ++++++++++++
>   linux-headers/asm-riscv/kvm.h                 | 53 ++++++++++++++++++-
>   linux-headers/asm-riscv/unistd.h              |  9 ++++
>   linux-headers/asm-s390/unistd_32.h            |  1 +
>   linux-headers/asm-s390/unistd_64.h            |  1 +
>   linux-headers/asm-x86/kvm.h                   |  3 ++
>   linux-headers/linux/const.h                   |  2 +-
>   linux-headers/linux/kvm.h                     | 12 +++--
>   linux-headers/linux/psp-sev.h                 |  7 +++
>   linux-headers/linux/userfaultfd.h             | 17 +++++-
>   linux-headers/linux/vfio.h                    |  9 ++++
>   15 files changed, 158 insertions(+), 16 deletions(-)
> 
> diff --git a/include/standard-headers/linux/const.h b/include/standard-headers/linux/const.h
> index 5e4898725168..1eb84b5087f8 100644
> --- a/include/standard-headers/linux/const.h
> +++ b/include/standard-headers/linux/const.h
> @@ -28,7 +28,7 @@
>   #define _BITUL(x)	(_UL(1) << (x))
>   #define _BITULL(x)	(_ULL(1) << (x))
>   
> -#define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
> +#define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)
>   #define __ALIGN_KERNEL_MASK(x, mask)	(((x) + (mask)) & ~(mask))
>   
>   #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
> diff --git a/include/standard-headers/linux/virtio_blk.h b/include/standard-headers/linux/virtio_blk.h
> index 7155b1a4701b..d7be3cf5e42f 100644
> --- a/include/standard-headers/linux/virtio_blk.h
> +++ b/include/standard-headers/linux/virtio_blk.h
> @@ -138,11 +138,11 @@ struct virtio_blk_config {
>   
>   	/* Zoned block device characteristics (if VIRTIO_BLK_F_ZONED) */
>   	struct virtio_blk_zoned_characteristics {
> -		uint32_t zone_sectors;
> -		uint32_t max_open_zones;
> -		uint32_t max_active_zones;
> -		uint32_t max_append_sectors;
> -		uint32_t write_granularity;
> +		__virtio32 zone_sectors;
> +		__virtio32 max_open_zones;
> +		__virtio32 max_active_zones;
> +		__virtio32 max_append_sectors;
> +		__virtio32 write_granularity;
>   		uint8_t model;
>   		uint8_t unused2[3];
>   	} zoned;
> @@ -239,11 +239,11 @@ struct virtio_blk_outhdr {
>    */
>   struct virtio_blk_zone_descriptor {
>   	/* Zone capacity */
> -	uint64_t z_cap;
> +	__virtio64 z_cap;
>   	/* The starting sector of the zone */
> -	uint64_t z_start;
> +	__virtio64 z_start;
>   	/* Zone write pointer position in sectors */
> -	uint64_t z_wp;
> +	__virtio64 z_wp;
>   	/* Zone type */
>   	uint8_t z_type;
>   	/* Zone state */
> @@ -252,7 +252,7 @@ struct virtio_blk_zone_descriptor {
>   };
>   
>   struct virtio_blk_zone_report {
> -	uint64_t nr_zones;
> +	__virtio64 nr_zones;
>   	uint8_t reserved[56];
>   	struct virtio_blk_zone_descriptor zones[];
>   };
> diff --git a/include/standard-headers/linux/virtio_config.h b/include/standard-headers/linux/virtio_config.h
> index 965ee6ae237e..8a7d0dc8b007 100644
> --- a/include/standard-headers/linux/virtio_config.h
> +++ b/include/standard-headers/linux/virtio_config.h
> @@ -97,6 +97,12 @@
>    */
>   #define VIRTIO_F_SR_IOV			37
>   
> +/*
> + * This feature indicates that the driver passes extra data (besides
> + * identifying the virtqueue) in its device notifications.
> + */
> +#define VIRTIO_F_NOTIFICATION_DATA	38
> +
>   /*
>    * This feature indicates that the driver can reset a queue individually.
>    */
> diff --git a/include/standard-headers/linux/virtio_net.h b/include/standard-headers/linux/virtio_net.h
> index c0e797067aae..2325485f2ca8 100644
> --- a/include/standard-headers/linux/virtio_net.h
> +++ b/include/standard-headers/linux/virtio_net.h
> @@ -61,6 +61,7 @@
>   #define VIRTIO_NET_F_GUEST_USO6	55	/* Guest can handle USOv6 in. */
>   #define VIRTIO_NET_F_HOST_USO	56	/* Host can handle USO in. */
>   #define VIRTIO_NET_F_HASH_REPORT  57	/* Supports hash report */
> +#define VIRTIO_NET_F_GUEST_HDRLEN  59	/* Guest provides the exact hdr_len value. */
>   #define VIRTIO_NET_F_RSS	  60	/* Supports RSS RX steering */
>   #define VIRTIO_NET_F_RSC_EXT	  61	/* extended coalescing info */
>   #define VIRTIO_NET_F_STANDBY	  62	/* Act as standby for another device
> diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h
> index d7e7bb885e20..38e5957526c2 100644
> --- a/linux-headers/asm-arm64/kvm.h
> +++ b/linux-headers/asm-arm64/kvm.h
> @@ -198,6 +198,15 @@ struct kvm_arm_copy_mte_tags {
>   	__u64 reserved[2];
>   };
>   
> +/*
> + * Counter/Timer offset structure. Describe the virtual/physical offset.
> + * To be used with KVM_ARM_SET_COUNTER_OFFSET.
> + */
> +struct kvm_arm_counter_offset {
> +	__u64 counter_offset;
> +	__u64 reserved;
> +};
> +
>   #define KVM_ARM_TAGS_TO_GUEST		0
>   #define KVM_ARM_TAGS_FROM_GUEST		1
>   
> @@ -363,6 +372,10 @@ enum {
>   	KVM_REG_ARM_VENDOR_HYP_BIT_PTP		= 1,
>   };
>   
> +/* Device Control API on vm fd */
> +#define KVM_ARM_VM_SMCCC_CTRL		0
> +#define   KVM_ARM_VM_SMCCC_FILTER	0
> +
>   /* Device Control API: ARM VGIC */
>   #define KVM_DEV_ARM_VGIC_GRP_ADDR	0
>   #define KVM_DEV_ARM_VGIC_GRP_DIST_REGS	1
> @@ -402,6 +415,8 @@ enum {
>   #define KVM_ARM_VCPU_TIMER_CTRL		1
>   #define   KVM_ARM_VCPU_TIMER_IRQ_VTIMER		0
>   #define   KVM_ARM_VCPU_TIMER_IRQ_PTIMER		1
> +#define   KVM_ARM_VCPU_TIMER_IRQ_HVTIMER	2
> +#define   KVM_ARM_VCPU_TIMER_IRQ_HPTIMER	3
>   #define KVM_ARM_VCPU_PVTIME_CTRL	2
>   #define   KVM_ARM_VCPU_PVTIME_IPA	0
>   
> @@ -458,6 +473,24 @@ enum {
>   /* run->fail_entry.hardware_entry_failure_reason codes. */
>   #define KVM_EXIT_FAIL_ENTRY_CPU_UNSUPPORTED	(1ULL << 0)
>   
> +enum kvm_smccc_filter_action {
> +	KVM_SMCCC_FILTER_HANDLE = 0,
> +	KVM_SMCCC_FILTER_DENY,
> +	KVM_SMCCC_FILTER_FWD_TO_USER,
> +
> +};
> +
> +struct kvm_smccc_filter {
> +	__u32 base;
> +	__u32 nr_functions;
> +	__u8 action;
> +	__u8 pad[15];
> +};
> +
> +/* arm64-specific KVM_EXIT_HYPERCALL flags */
> +#define KVM_HYPERCALL_EXIT_SMC		(1U << 0)
> +#define KVM_HYPERCALL_EXIT_16BIT	(1U << 1)
> +
>   #endif
>   
>   #endif /* __ARM_KVM_H__ */
> diff --git a/linux-headers/asm-riscv/kvm.h b/linux-headers/asm-riscv/kvm.h
> index 92af6f3f057c..f92790c9481a 100644
> --- a/linux-headers/asm-riscv/kvm.h
> +++ b/linux-headers/asm-riscv/kvm.h
> @@ -12,6 +12,7 @@
>   #ifndef __ASSEMBLY__
>   
>   #include <linux/types.h>
> +#include <asm/bitsperlong.h>
>   #include <asm/ptrace.h>
>   
>   #define __KVM_HAVE_READONLY_MEM
> @@ -52,6 +53,7 @@ struct kvm_riscv_config {
>   	unsigned long mvendorid;
>   	unsigned long marchid;
>   	unsigned long mimpid;
> +	unsigned long zicboz_block_size;
>   };
>   
>   /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
> @@ -64,7 +66,7 @@ struct kvm_riscv_core {
>   #define KVM_RISCV_MODE_S	1
>   #define KVM_RISCV_MODE_U	0
>   
> -/* CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
> +/* General CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
>   struct kvm_riscv_csr {
>   	unsigned long sstatus;
>   	unsigned long sie;
> @@ -78,6 +80,17 @@ struct kvm_riscv_csr {
>   	unsigned long scounteren;
>   };
>   
> +/* AIA CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
> +struct kvm_riscv_aia_csr {
> +	unsigned long siselect;
> +	unsigned long iprio1;
> +	unsigned long iprio2;
> +	unsigned long sieh;
> +	unsigned long siph;
> +	unsigned long iprio1h;
> +	unsigned long iprio2h;
> +};
> +
>   /* TIMER registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
>   struct kvm_riscv_timer {
>   	__u64 frequency;
> @@ -105,9 +118,29 @@ enum KVM_RISCV_ISA_EXT_ID {
>   	KVM_RISCV_ISA_EXT_SVINVAL,
>   	KVM_RISCV_ISA_EXT_ZIHINTPAUSE,
>   	KVM_RISCV_ISA_EXT_ZICBOM,
> +	KVM_RISCV_ISA_EXT_ZICBOZ,
> +	KVM_RISCV_ISA_EXT_ZBB,
> +	KVM_RISCV_ISA_EXT_SSAIA,
>   	KVM_RISCV_ISA_EXT_MAX,
>   };
>   
> +/*
> + * SBI extension IDs specific to KVM. This is not the same as the SBI
> + * extension IDs defined by the RISC-V SBI specification.
> + */
> +enum KVM_RISCV_SBI_EXT_ID {
> +	KVM_RISCV_SBI_EXT_V01 = 0,
> +	KVM_RISCV_SBI_EXT_TIME,
> +	KVM_RISCV_SBI_EXT_IPI,
> +	KVM_RISCV_SBI_EXT_RFENCE,
> +	KVM_RISCV_SBI_EXT_SRST,
> +	KVM_RISCV_SBI_EXT_HSM,
> +	KVM_RISCV_SBI_EXT_PMU,
> +	KVM_RISCV_SBI_EXT_EXPERIMENTAL,
> +	KVM_RISCV_SBI_EXT_VENDOR,
> +	KVM_RISCV_SBI_EXT_MAX,
> +};
> +
>   /* Possible states for kvm_riscv_timer */
>   #define KVM_RISCV_TIMER_STATE_OFF	0
>   #define KVM_RISCV_TIMER_STATE_ON	1
> @@ -118,6 +151,8 @@ enum KVM_RISCV_ISA_EXT_ID {
>   /* If you need to interpret the index values, here is the key: */
>   #define KVM_REG_RISCV_TYPE_MASK		0x00000000FF000000
>   #define KVM_REG_RISCV_TYPE_SHIFT	24
> +#define KVM_REG_RISCV_SUBTYPE_MASK	0x0000000000FF0000
> +#define KVM_REG_RISCV_SUBTYPE_SHIFT	16
>   
>   /* Config registers are mapped as type 1 */
>   #define KVM_REG_RISCV_CONFIG		(0x01 << KVM_REG_RISCV_TYPE_SHIFT)
> @@ -131,8 +166,12 @@ enum KVM_RISCV_ISA_EXT_ID {
>   
>   /* Control and status registers are mapped as type 3 */
>   #define KVM_REG_RISCV_CSR		(0x03 << KVM_REG_RISCV_TYPE_SHIFT)
> +#define KVM_REG_RISCV_CSR_GENERAL	(0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT)
> +#define KVM_REG_RISCV_CSR_AIA		(0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT)
>   #define KVM_REG_RISCV_CSR_REG(name)	\
>   		(offsetof(struct kvm_riscv_csr, name) / sizeof(unsigned long))
> +#define KVM_REG_RISCV_CSR_AIA_REG(name)	\
> +	(offsetof(struct kvm_riscv_aia_csr, name) / sizeof(unsigned long))
>   
>   /* Timer registers are mapped as type 4 */
>   #define KVM_REG_RISCV_TIMER		(0x04 << KVM_REG_RISCV_TYPE_SHIFT)
> @@ -152,6 +191,18 @@ enum KVM_RISCV_ISA_EXT_ID {
>   /* ISA Extension registers are mapped as type 7 */
>   #define KVM_REG_RISCV_ISA_EXT		(0x07 << KVM_REG_RISCV_TYPE_SHIFT)
>   
> +/* SBI extension registers are mapped as type 8 */
> +#define KVM_REG_RISCV_SBI_EXT		(0x08 << KVM_REG_RISCV_TYPE_SHIFT)
> +#define KVM_REG_RISCV_SBI_SINGLE	(0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT)
> +#define KVM_REG_RISCV_SBI_MULTI_EN	(0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT)
> +#define KVM_REG_RISCV_SBI_MULTI_DIS	(0x2 << KVM_REG_RISCV_SUBTYPE_SHIFT)
> +#define KVM_REG_RISCV_SBI_MULTI_REG(__ext_id)	\
> +		((__ext_id) / __BITS_PER_LONG)
> +#define KVM_REG_RISCV_SBI_MULTI_MASK(__ext_id)	\
> +		(1UL << ((__ext_id) % __BITS_PER_LONG))
> +#define KVM_REG_RISCV_SBI_MULTI_REG_LAST	\
> +		KVM_REG_RISCV_SBI_MULTI_REG(KVM_RISCV_SBI_EXT_MAX - 1)
> +
>   #endif
>   
>   #endif /* __LINUX_KVM_RISCV_H */
> diff --git a/linux-headers/asm-riscv/unistd.h b/linux-headers/asm-riscv/unistd.h
> index 73d7cdd2ec49..950ab3fd4409 100644
> --- a/linux-headers/asm-riscv/unistd.h
> +++ b/linux-headers/asm-riscv/unistd.h
> @@ -43,3 +43,12 @@
>   #define __NR_riscv_flush_icache (__NR_arch_specific_syscall + 15)
>   #endif
>   __SYSCALL(__NR_riscv_flush_icache, sys_riscv_flush_icache)
> +
> +/*
> + * Allows userspace to query the kernel for CPU architecture and
> + * microarchitecture details across a given set of CPUs.
> + */
> +#ifndef __NR_riscv_hwprobe
> +#define __NR_riscv_hwprobe (__NR_arch_specific_syscall + 14)
> +#endif
> +__SYSCALL(__NR_riscv_hwprobe, sys_riscv_hwprobe)
> diff --git a/linux-headers/asm-s390/unistd_32.h b/linux-headers/asm-s390/unistd_32.h
> index 8e644d65f571..800f3adb2020 100644
> --- a/linux-headers/asm-s390/unistd_32.h
> +++ b/linux-headers/asm-s390/unistd_32.h
> @@ -419,6 +419,7 @@
>   #define __NR_landlock_create_ruleset 444
>   #define __NR_landlock_add_rule 445
>   #define __NR_landlock_restrict_self 446
> +#define __NR_memfd_secret 447
>   #define __NR_process_mrelease 448
>   #define __NR_futex_waitv 449
>   #define __NR_set_mempolicy_home_node 450
> diff --git a/linux-headers/asm-s390/unistd_64.h b/linux-headers/asm-s390/unistd_64.h
> index 51da542fec10..399a6059015e 100644
> --- a/linux-headers/asm-s390/unistd_64.h
> +++ b/linux-headers/asm-s390/unistd_64.h
> @@ -367,6 +367,7 @@
>   #define __NR_landlock_create_ruleset 444
>   #define __NR_landlock_add_rule 445
>   #define __NR_landlock_restrict_self 446
> +#define __NR_memfd_secret 447
>   #define __NR_process_mrelease 448
>   #define __NR_futex_waitv 449
>   #define __NR_set_mempolicy_home_node 450
> diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h
> index 2937e7bf6982..2b3a8f7bd2c0 100644
> --- a/linux-headers/asm-x86/kvm.h
> +++ b/linux-headers/asm-x86/kvm.h
> @@ -557,4 +557,7 @@ struct kvm_pmu_event_filter {
>   #define KVM_VCPU_TSC_CTRL 0 /* control group for the timestamp counter (TSC) */
>   #define   KVM_VCPU_TSC_OFFSET 0 /* attribute for the TSC offset */
>   
> +/* x86-specific KVM_EXIT_HYPERCALL flags. */
> +#define KVM_EXIT_HYPERCALL_LONG_MODE	BIT(0)
> +
>   #endif /* _ASM_X86_KVM_H */
> diff --git a/linux-headers/linux/const.h b/linux-headers/linux/const.h
> index 5e4898725168..1eb84b5087f8 100644
> --- a/linux-headers/linux/const.h
> +++ b/linux-headers/linux/const.h
> @@ -28,7 +28,7 @@
>   #define _BITUL(x)	(_UL(1) << (x))
>   #define _BITULL(x)	(_ULL(1) << (x))
>   
> -#define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
> +#define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)
>   #define __ALIGN_KERNEL_MASK(x, mask)	(((x) + (mask)) & ~(mask))
>   
>   #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
> diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
> index 599de3c6e3aa..65b145b317ac 100644
> --- a/linux-headers/linux/kvm.h
> +++ b/linux-headers/linux/kvm.h
> @@ -341,8 +341,11 @@ struct kvm_run {
>   			__u64 nr;
>   			__u64 args[6];
>   			__u64 ret;
> -			__u32 longmode;
> -			__u32 pad;
> +
> +			union {
> +				__u32 longmode;
> +				__u64 flags;
> +			};
>   		} hypercall;
>   		/* KVM_EXIT_TPR_ACCESS */
>   		struct {
> @@ -1182,6 +1185,7 @@ struct kvm_ppc_resize_hpt {
>   #define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224
>   #define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225
>   #define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226
> +#define KVM_CAP_COUNTER_OFFSET 227
>   
>   #ifdef KVM_CAP_IRQ_ROUTING
>   
> @@ -1449,7 +1453,7 @@ struct kvm_vfio_spapr_tce {
>   #define KVM_CREATE_VCPU           _IO(KVMIO,   0x41)
>   #define KVM_GET_DIRTY_LOG         _IOW(KVMIO,  0x42, struct kvm_dirty_log)
>   #define KVM_SET_NR_MMU_PAGES      _IO(KVMIO,   0x44)
> -#define KVM_GET_NR_MMU_PAGES      _IO(KVMIO,   0x45)
> +#define KVM_GET_NR_MMU_PAGES      _IO(KVMIO,   0x45)  /* deprecated */
>   #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \
>   					struct kvm_userspace_memory_region)
>   #define KVM_SET_TSS_ADDR          _IO(KVMIO,   0x47)
> @@ -1541,6 +1545,8 @@ struct kvm_s390_ucas_mapping {
>   #define KVM_SET_PMU_EVENT_FILTER  _IOW(KVMIO,  0xb2, struct kvm_pmu_event_filter)
>   #define KVM_PPC_SVM_OFF		  _IO(KVMIO,  0xb3)
>   #define KVM_ARM_MTE_COPY_TAGS	  _IOR(KVMIO,  0xb4, struct kvm_arm_copy_mte_tags)
> +/* Available with KVM_CAP_COUNTER_OFFSET */
> +#define KVM_ARM_SET_COUNTER_OFFSET _IOW(KVMIO,  0xb5, struct kvm_arm_counter_offset)
>   
>   /* ioctl for vm fd */
>   #define KVM_CREATE_DEVICE	  _IOWR(KVMIO,  0xe0, struct kvm_create_device)
> diff --git a/linux-headers/linux/psp-sev.h b/linux-headers/linux/psp-sev.h
> index 51d8b3940e14..12ccb70099d4 100644
> --- a/linux-headers/linux/psp-sev.h
> +++ b/linux-headers/linux/psp-sev.h
> @@ -36,6 +36,13 @@ enum {
>    * SEV Firmware status code
>    */
>   typedef enum {
> +	/*
> +	 * This error code is not in the SEV spec. Its purpose is to convey that
> +	 * there was an error that prevented the SEV firmware from being called.
> +	 * The SEV API error codes are 16 bits, so the -1 value will not overlap
> +	 * with possible values from the specification.
> +	 */
> +	SEV_RET_NO_FW_CALL = -1,
>   	SEV_RET_SUCCESS = 0,
>   	SEV_RET_INVALID_PLATFORM_STATE,
>   	SEV_RET_INVALID_GUEST_STATE,
> diff --git a/linux-headers/linux/userfaultfd.h b/linux-headers/linux/userfaultfd.h
> index ba5d0df52fb8..14e402263a8a 100644
> --- a/linux-headers/linux/userfaultfd.h
> +++ b/linux-headers/linux/userfaultfd.h
> @@ -38,7 +38,8 @@
>   			   UFFD_FEATURE_MINOR_HUGETLBFS |	\
>   			   UFFD_FEATURE_MINOR_SHMEM |		\
>   			   UFFD_FEATURE_EXACT_ADDRESS |		\
> -			   UFFD_FEATURE_WP_HUGETLBFS_SHMEM)
> +			   UFFD_FEATURE_WP_HUGETLBFS_SHMEM |	\
> +			   UFFD_FEATURE_WP_UNPOPULATED)
>   #define UFFD_API_IOCTLS				\
>   	((__u64)1 << _UFFDIO_REGISTER |		\
>   	 (__u64)1 << _UFFDIO_UNREGISTER |	\
> @@ -203,6 +204,12 @@ struct uffdio_api {
>   	 *
>   	 * UFFD_FEATURE_WP_HUGETLBFS_SHMEM indicates that userfaultfd
>   	 * write-protection mode is supported on both shmem and hugetlbfs.
> +	 *
> +	 * UFFD_FEATURE_WP_UNPOPULATED indicates that userfaultfd
> +	 * write-protection mode will always apply to unpopulated pages
> +	 * (i.e. empty ptes).  This will be the default behavior for shmem
> +	 * & hugetlbfs, so this flag only affects anonymous memory behavior
> +	 * when userfault write-protection mode is registered.
>   	 */
>   #define UFFD_FEATURE_PAGEFAULT_FLAG_WP		(1<<0)
>   #define UFFD_FEATURE_EVENT_FORK			(1<<1)
> @@ -217,6 +224,7 @@ struct uffdio_api {
>   #define UFFD_FEATURE_MINOR_SHMEM		(1<<10)
>   #define UFFD_FEATURE_EXACT_ADDRESS		(1<<11)
>   #define UFFD_FEATURE_WP_HUGETLBFS_SHMEM		(1<<12)
> +#define UFFD_FEATURE_WP_UNPOPULATED		(1<<13)
>   	__u64 features;
>   
>   	__u64 ioctls;
> @@ -297,6 +305,13 @@ struct uffdio_writeprotect {
>   struct uffdio_continue {
>   	struct uffdio_range range;
>   #define UFFDIO_CONTINUE_MODE_DONTWAKE		((__u64)1<<0)
> +	/*
> +	 * UFFDIO_CONTINUE_MODE_WP will map the page write protected on
> +	 * the fly.  UFFDIO_CONTINUE_MODE_WP is available only if the
> +	 * write protected ioctl is implemented for the range
> +	 * according to the uffdio_register.ioctls.
> +	 */
> +#define UFFDIO_CONTINUE_MODE_WP			((__u64)1<<1)
>   	__u64 mode;
>   
>   	/*
> diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h
> index 4a534edbdcba..2658fda219e8 100644
> --- a/linux-headers/linux/vfio.h
> +++ b/linux-headers/linux/vfio.h
> @@ -646,6 +646,15 @@ enum {
>   	VFIO_CCW_NUM_IRQS
>   };
>   
> +/*
> + * The vfio-ap bus driver makes use of the following IRQ index mapping.
> + * Unimplemented IRQ types return a count of zero.
> + */
> +enum {
> +	VFIO_AP_REQ_IRQ_INDEX,
> +	VFIO_AP_NUM_IRQS
> +};
> +
>   /**
>    * VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 12,
>    *					      struct vfio_pci_hot_reset_info)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] linux-headers: Update with vfio_ap IRQ index mapping
  2023-07-03 16:31   ` Cédric Le Goater
@ 2023-07-03 20:31     ` Anthony Krowiak
  0 siblings, 0 replies; 7+ messages in thread
From: Anthony Krowiak @ 2023-07-03 20:31 UTC (permalink / raw)
  To: Cédric Le Goater, qemu-devel
  Cc: qemu-s390x, mjrosato, jjherne, pasic, fiuczy, thuth, farman,
	borntraeger, cohuck



On 7/3/23 12:31 PM, Cédric Le Goater wrote:
> On 6/2/23 16:11, Tony Krowiak wrote:
>> Note: This is a placeholder patch that includes unmerged uapi changes.
>>
>> Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
>> Link: 
>> https://lore.kernel.org/qemu-devel/20230530225544.280031-1-akrowiak@linux.ibm.com/
> 
> I am preparing a vfio-next tree including these changes plus a 
> linux-headers
> update. I am just waiting for the 6.5-rc1 tag to be pushed.

Good news, thanks.

> 
> Thanks,
> 
> C.
> 
>> ---
>>   include/standard-headers/linux/const.h        |  2 +-
>>   include/standard-headers/linux/virtio_blk.h   | 18 +++----
>>   .../standard-headers/linux/virtio_config.h    |  6 +++
>>   include/standard-headers/linux/virtio_net.h   |  1 +
>>   linux-headers/asm-arm64/kvm.h                 | 33 ++++++++++++
>>   linux-headers/asm-riscv/kvm.h                 | 53 ++++++++++++++++++-
>>   linux-headers/asm-riscv/unistd.h              |  9 ++++
>>   linux-headers/asm-s390/unistd_32.h            |  1 +
>>   linux-headers/asm-s390/unistd_64.h            |  1 +
>>   linux-headers/asm-x86/kvm.h                   |  3 ++
>>   linux-headers/linux/const.h                   |  2 +-
>>   linux-headers/linux/kvm.h                     | 12 +++--
>>   linux-headers/linux/psp-sev.h                 |  7 +++
>>   linux-headers/linux/userfaultfd.h             | 17 +++++-
>>   linux-headers/linux/vfio.h                    |  9 ++++
>>   15 files changed, 158 insertions(+), 16 deletions(-)
>>
>> diff --git a/include/standard-headers/linux/const.h 
>> b/include/standard-headers/linux/const.h
>> index 5e4898725168..1eb84b5087f8 100644
>> --- a/include/standard-headers/linux/const.h
>> +++ b/include/standard-headers/linux/const.h
>> @@ -28,7 +28,7 @@
>>   #define _BITUL(x)    (_UL(1) << (x))
>>   #define _BITULL(x)    (_ULL(1) << (x))
>> -#define __ALIGN_KERNEL(x, a)        __ALIGN_KERNEL_MASK(x, 
>> (typeof(x))(a) - 1)
>> +#define __ALIGN_KERNEL(x, a)        __ALIGN_KERNEL_MASK(x, 
>> (__typeof__(x))(a) - 1)
>>   #define __ALIGN_KERNEL_MASK(x, mask)    (((x) + (mask)) & ~(mask))
>>   #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
>> diff --git a/include/standard-headers/linux/virtio_blk.h 
>> b/include/standard-headers/linux/virtio_blk.h
>> index 7155b1a4701b..d7be3cf5e42f 100644
>> --- a/include/standard-headers/linux/virtio_blk.h
>> +++ b/include/standard-headers/linux/virtio_blk.h
>> @@ -138,11 +138,11 @@ struct virtio_blk_config {
>>       /* Zoned block device characteristics (if VIRTIO_BLK_F_ZONED) */
>>       struct virtio_blk_zoned_characteristics {
>> -        uint32_t zone_sectors;
>> -        uint32_t max_open_zones;
>> -        uint32_t max_active_zones;
>> -        uint32_t max_append_sectors;
>> -        uint32_t write_granularity;
>> +        __virtio32 zone_sectors;
>> +        __virtio32 max_open_zones;
>> +        __virtio32 max_active_zones;
>> +        __virtio32 max_append_sectors;
>> +        __virtio32 write_granularity;
>>           uint8_t model;
>>           uint8_t unused2[3];
>>       } zoned;
>> @@ -239,11 +239,11 @@ struct virtio_blk_outhdr {
>>    */
>>   struct virtio_blk_zone_descriptor {
>>       /* Zone capacity */
>> -    uint64_t z_cap;
>> +    __virtio64 z_cap;
>>       /* The starting sector of the zone */
>> -    uint64_t z_start;
>> +    __virtio64 z_start;
>>       /* Zone write pointer position in sectors */
>> -    uint64_t z_wp;
>> +    __virtio64 z_wp;
>>       /* Zone type */
>>       uint8_t z_type;
>>       /* Zone state */
>> @@ -252,7 +252,7 @@ struct virtio_blk_zone_descriptor {
>>   };
>>   struct virtio_blk_zone_report {
>> -    uint64_t nr_zones;
>> +    __virtio64 nr_zones;
>>       uint8_t reserved[56];
>>       struct virtio_blk_zone_descriptor zones[];
>>   };
>> diff --git a/include/standard-headers/linux/virtio_config.h 
>> b/include/standard-headers/linux/virtio_config.h
>> index 965ee6ae237e..8a7d0dc8b007 100644
>> --- a/include/standard-headers/linux/virtio_config.h
>> +++ b/include/standard-headers/linux/virtio_config.h
>> @@ -97,6 +97,12 @@
>>    */
>>   #define VIRTIO_F_SR_IOV            37
>> +/*
>> + * This feature indicates that the driver passes extra data (besides
>> + * identifying the virtqueue) in its device notifications.
>> + */
>> +#define VIRTIO_F_NOTIFICATION_DATA    38
>> +
>>   /*
>>    * This feature indicates that the driver can reset a queue 
>> individually.
>>    */
>> diff --git a/include/standard-headers/linux/virtio_net.h 
>> b/include/standard-headers/linux/virtio_net.h
>> index c0e797067aae..2325485f2ca8 100644
>> --- a/include/standard-headers/linux/virtio_net.h
>> +++ b/include/standard-headers/linux/virtio_net.h
>> @@ -61,6 +61,7 @@
>>   #define VIRTIO_NET_F_GUEST_USO6    55    /* Guest can handle USOv6 
>> in. */
>>   #define VIRTIO_NET_F_HOST_USO    56    /* Host can handle USO in. */
>>   #define VIRTIO_NET_F_HASH_REPORT  57    /* Supports hash report */
>> +#define VIRTIO_NET_F_GUEST_HDRLEN  59    /* Guest provides the exact 
>> hdr_len value. */
>>   #define VIRTIO_NET_F_RSS      60    /* Supports RSS RX steering */
>>   #define VIRTIO_NET_F_RSC_EXT      61    /* extended coalescing info */
>>   #define VIRTIO_NET_F_STANDBY      62    /* Act as standby for 
>> another device
>> diff --git a/linux-headers/asm-arm64/kvm.h 
>> b/linux-headers/asm-arm64/kvm.h
>> index d7e7bb885e20..38e5957526c2 100644
>> --- a/linux-headers/asm-arm64/kvm.h
>> +++ b/linux-headers/asm-arm64/kvm.h
>> @@ -198,6 +198,15 @@ struct kvm_arm_copy_mte_tags {
>>       __u64 reserved[2];
>>   };
>> +/*
>> + * Counter/Timer offset structure. Describe the virtual/physical offset.
>> + * To be used with KVM_ARM_SET_COUNTER_OFFSET.
>> + */
>> +struct kvm_arm_counter_offset {
>> +    __u64 counter_offset;
>> +    __u64 reserved;
>> +};
>> +
>>   #define KVM_ARM_TAGS_TO_GUEST        0
>>   #define KVM_ARM_TAGS_FROM_GUEST        1
>> @@ -363,6 +372,10 @@ enum {
>>       KVM_REG_ARM_VENDOR_HYP_BIT_PTP        = 1,
>>   };
>> +/* Device Control API on vm fd */
>> +#define KVM_ARM_VM_SMCCC_CTRL        0
>> +#define   KVM_ARM_VM_SMCCC_FILTER    0
>> +
>>   /* Device Control API: ARM VGIC */
>>   #define KVM_DEV_ARM_VGIC_GRP_ADDR    0
>>   #define KVM_DEV_ARM_VGIC_GRP_DIST_REGS    1
>> @@ -402,6 +415,8 @@ enum {
>>   #define KVM_ARM_VCPU_TIMER_CTRL        1
>>   #define   KVM_ARM_VCPU_TIMER_IRQ_VTIMER        0
>>   #define   KVM_ARM_VCPU_TIMER_IRQ_PTIMER        1
>> +#define   KVM_ARM_VCPU_TIMER_IRQ_HVTIMER    2
>> +#define   KVM_ARM_VCPU_TIMER_IRQ_HPTIMER    3
>>   #define KVM_ARM_VCPU_PVTIME_CTRL    2
>>   #define   KVM_ARM_VCPU_PVTIME_IPA    0
>> @@ -458,6 +473,24 @@ enum {
>>   /* run->fail_entry.hardware_entry_failure_reason codes. */
>>   #define KVM_EXIT_FAIL_ENTRY_CPU_UNSUPPORTED    (1ULL << 0)
>> +enum kvm_smccc_filter_action {
>> +    KVM_SMCCC_FILTER_HANDLE = 0,
>> +    KVM_SMCCC_FILTER_DENY,
>> +    KVM_SMCCC_FILTER_FWD_TO_USER,
>> +
>> +};
>> +
>> +struct kvm_smccc_filter {
>> +    __u32 base;
>> +    __u32 nr_functions;
>> +    __u8 action;
>> +    __u8 pad[15];
>> +};
>> +
>> +/* arm64-specific KVM_EXIT_HYPERCALL flags */
>> +#define KVM_HYPERCALL_EXIT_SMC        (1U << 0)
>> +#define KVM_HYPERCALL_EXIT_16BIT    (1U << 1)
>> +
>>   #endif
>>   #endif /* __ARM_KVM_H__ */
>> diff --git a/linux-headers/asm-riscv/kvm.h 
>> b/linux-headers/asm-riscv/kvm.h
>> index 92af6f3f057c..f92790c9481a 100644
>> --- a/linux-headers/asm-riscv/kvm.h
>> +++ b/linux-headers/asm-riscv/kvm.h
>> @@ -12,6 +12,7 @@
>>   #ifndef __ASSEMBLY__
>>   #include <linux/types.h>
>> +#include <asm/bitsperlong.h>
>>   #include <asm/ptrace.h>
>>   #define __KVM_HAVE_READONLY_MEM
>> @@ -52,6 +53,7 @@ struct kvm_riscv_config {
>>       unsigned long mvendorid;
>>       unsigned long marchid;
>>       unsigned long mimpid;
>> +    unsigned long zicboz_block_size;
>>   };
>>   /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
>> @@ -64,7 +66,7 @@ struct kvm_riscv_core {
>>   #define KVM_RISCV_MODE_S    1
>>   #define KVM_RISCV_MODE_U    0
>> -/* CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
>> +/* General CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
>>   struct kvm_riscv_csr {
>>       unsigned long sstatus;
>>       unsigned long sie;
>> @@ -78,6 +80,17 @@ struct kvm_riscv_csr {
>>       unsigned long scounteren;
>>   };
>> +/* AIA CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
>> +struct kvm_riscv_aia_csr {
>> +    unsigned long siselect;
>> +    unsigned long iprio1;
>> +    unsigned long iprio2;
>> +    unsigned long sieh;
>> +    unsigned long siph;
>> +    unsigned long iprio1h;
>> +    unsigned long iprio2h;
>> +};
>> +
>>   /* TIMER registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
>>   struct kvm_riscv_timer {
>>       __u64 frequency;
>> @@ -105,9 +118,29 @@ enum KVM_RISCV_ISA_EXT_ID {
>>       KVM_RISCV_ISA_EXT_SVINVAL,
>>       KVM_RISCV_ISA_EXT_ZIHINTPAUSE,
>>       KVM_RISCV_ISA_EXT_ZICBOM,
>> +    KVM_RISCV_ISA_EXT_ZICBOZ,
>> +    KVM_RISCV_ISA_EXT_ZBB,
>> +    KVM_RISCV_ISA_EXT_SSAIA,
>>       KVM_RISCV_ISA_EXT_MAX,
>>   };
>> +/*
>> + * SBI extension IDs specific to KVM. This is not the same as the SBI
>> + * extension IDs defined by the RISC-V SBI specification.
>> + */
>> +enum KVM_RISCV_SBI_EXT_ID {
>> +    KVM_RISCV_SBI_EXT_V01 = 0,
>> +    KVM_RISCV_SBI_EXT_TIME,
>> +    KVM_RISCV_SBI_EXT_IPI,
>> +    KVM_RISCV_SBI_EXT_RFENCE,
>> +    KVM_RISCV_SBI_EXT_SRST,
>> +    KVM_RISCV_SBI_EXT_HSM,
>> +    KVM_RISCV_SBI_EXT_PMU,
>> +    KVM_RISCV_SBI_EXT_EXPERIMENTAL,
>> +    KVM_RISCV_SBI_EXT_VENDOR,
>> +    KVM_RISCV_SBI_EXT_MAX,
>> +};
>> +
>>   /* Possible states for kvm_riscv_timer */
>>   #define KVM_RISCV_TIMER_STATE_OFF    0
>>   #define KVM_RISCV_TIMER_STATE_ON    1
>> @@ -118,6 +151,8 @@ enum KVM_RISCV_ISA_EXT_ID {
>>   /* If you need to interpret the index values, here is the key: */
>>   #define KVM_REG_RISCV_TYPE_MASK        0x00000000FF000000
>>   #define KVM_REG_RISCV_TYPE_SHIFT    24
>> +#define KVM_REG_RISCV_SUBTYPE_MASK    0x0000000000FF0000
>> +#define KVM_REG_RISCV_SUBTYPE_SHIFT    16
>>   /* Config registers are mapped as type 1 */
>>   #define KVM_REG_RISCV_CONFIG        (0x01 << KVM_REG_RISCV_TYPE_SHIFT)
>> @@ -131,8 +166,12 @@ enum KVM_RISCV_ISA_EXT_ID {
>>   /* Control and status registers are mapped as type 3 */
>>   #define KVM_REG_RISCV_CSR        (0x03 << KVM_REG_RISCV_TYPE_SHIFT)
>> +#define KVM_REG_RISCV_CSR_GENERAL    (0x0 << 
>> KVM_REG_RISCV_SUBTYPE_SHIFT)
>> +#define KVM_REG_RISCV_CSR_AIA        (0x1 << 
>> KVM_REG_RISCV_SUBTYPE_SHIFT)
>>   #define KVM_REG_RISCV_CSR_REG(name)    \
>>           (offsetof(struct kvm_riscv_csr, name) / sizeof(unsigned long))
>> +#define KVM_REG_RISCV_CSR_AIA_REG(name)    \
>> +    (offsetof(struct kvm_riscv_aia_csr, name) / sizeof(unsigned long))
>>   /* Timer registers are mapped as type 4 */
>>   #define KVM_REG_RISCV_TIMER        (0x04 << KVM_REG_RISCV_TYPE_SHIFT)
>> @@ -152,6 +191,18 @@ enum KVM_RISCV_ISA_EXT_ID {
>>   /* ISA Extension registers are mapped as type 7 */
>>   #define KVM_REG_RISCV_ISA_EXT        (0x07 << KVM_REG_RISCV_TYPE_SHIFT)
>> +/* SBI extension registers are mapped as type 8 */
>> +#define KVM_REG_RISCV_SBI_EXT        (0x08 << KVM_REG_RISCV_TYPE_SHIFT)
>> +#define KVM_REG_RISCV_SBI_SINGLE    (0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT)
>> +#define KVM_REG_RISCV_SBI_MULTI_EN    (0x1 << 
>> KVM_REG_RISCV_SUBTYPE_SHIFT)
>> +#define KVM_REG_RISCV_SBI_MULTI_DIS    (0x2 << 
>> KVM_REG_RISCV_SUBTYPE_SHIFT)
>> +#define KVM_REG_RISCV_SBI_MULTI_REG(__ext_id)    \
>> +        ((__ext_id) / __BITS_PER_LONG)
>> +#define KVM_REG_RISCV_SBI_MULTI_MASK(__ext_id)    \
>> +        (1UL << ((__ext_id) % __BITS_PER_LONG))
>> +#define KVM_REG_RISCV_SBI_MULTI_REG_LAST    \
>> +        KVM_REG_RISCV_SBI_MULTI_REG(KVM_RISCV_SBI_EXT_MAX - 1)
>> +
>>   #endif
>>   #endif /* __LINUX_KVM_RISCV_H */
>> diff --git a/linux-headers/asm-riscv/unistd.h 
>> b/linux-headers/asm-riscv/unistd.h
>> index 73d7cdd2ec49..950ab3fd4409 100644
>> --- a/linux-headers/asm-riscv/unistd.h
>> +++ b/linux-headers/asm-riscv/unistd.h
>> @@ -43,3 +43,12 @@
>>   #define __NR_riscv_flush_icache (__NR_arch_specific_syscall + 15)
>>   #endif
>>   __SYSCALL(__NR_riscv_flush_icache, sys_riscv_flush_icache)
>> +
>> +/*
>> + * Allows userspace to query the kernel for CPU architecture and
>> + * microarchitecture details across a given set of CPUs.
>> + */
>> +#ifndef __NR_riscv_hwprobe
>> +#define __NR_riscv_hwprobe (__NR_arch_specific_syscall + 14)
>> +#endif
>> +__SYSCALL(__NR_riscv_hwprobe, sys_riscv_hwprobe)
>> diff --git a/linux-headers/asm-s390/unistd_32.h 
>> b/linux-headers/asm-s390/unistd_32.h
>> index 8e644d65f571..800f3adb2020 100644
>> --- a/linux-headers/asm-s390/unistd_32.h
>> +++ b/linux-headers/asm-s390/unistd_32.h
>> @@ -419,6 +419,7 @@
>>   #define __NR_landlock_create_ruleset 444
>>   #define __NR_landlock_add_rule 445
>>   #define __NR_landlock_restrict_self 446
>> +#define __NR_memfd_secret 447
>>   #define __NR_process_mrelease 448
>>   #define __NR_futex_waitv 449
>>   #define __NR_set_mempolicy_home_node 450
>> diff --git a/linux-headers/asm-s390/unistd_64.h 
>> b/linux-headers/asm-s390/unistd_64.h
>> index 51da542fec10..399a6059015e 100644
>> --- a/linux-headers/asm-s390/unistd_64.h
>> +++ b/linux-headers/asm-s390/unistd_64.h
>> @@ -367,6 +367,7 @@
>>   #define __NR_landlock_create_ruleset 444
>>   #define __NR_landlock_add_rule 445
>>   #define __NR_landlock_restrict_self 446
>> +#define __NR_memfd_secret 447
>>   #define __NR_process_mrelease 448
>>   #define __NR_futex_waitv 449
>>   #define __NR_set_mempolicy_home_node 450
>> diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h
>> index 2937e7bf6982..2b3a8f7bd2c0 100644
>> --- a/linux-headers/asm-x86/kvm.h
>> +++ b/linux-headers/asm-x86/kvm.h
>> @@ -557,4 +557,7 @@ struct kvm_pmu_event_filter {
>>   #define KVM_VCPU_TSC_CTRL 0 /* control group for the timestamp 
>> counter (TSC) */
>>   #define   KVM_VCPU_TSC_OFFSET 0 /* attribute for the TSC offset */
>> +/* x86-specific KVM_EXIT_HYPERCALL flags. */
>> +#define KVM_EXIT_HYPERCALL_LONG_MODE    BIT(0)
>> +
>>   #endif /* _ASM_X86_KVM_H */
>> diff --git a/linux-headers/linux/const.h b/linux-headers/linux/const.h
>> index 5e4898725168..1eb84b5087f8 100644
>> --- a/linux-headers/linux/const.h
>> +++ b/linux-headers/linux/const.h
>> @@ -28,7 +28,7 @@
>>   #define _BITUL(x)    (_UL(1) << (x))
>>   #define _BITULL(x)    (_ULL(1) << (x))
>> -#define __ALIGN_KERNEL(x, a)        __ALIGN_KERNEL_MASK(x, 
>> (typeof(x))(a) - 1)
>> +#define __ALIGN_KERNEL(x, a)        __ALIGN_KERNEL_MASK(x, 
>> (__typeof__(x))(a) - 1)
>>   #define __ALIGN_KERNEL_MASK(x, mask)    (((x) + (mask)) & ~(mask))
>>   #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
>> diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
>> index 599de3c6e3aa..65b145b317ac 100644
>> --- a/linux-headers/linux/kvm.h
>> +++ b/linux-headers/linux/kvm.h
>> @@ -341,8 +341,11 @@ struct kvm_run {
>>               __u64 nr;
>>               __u64 args[6];
>>               __u64 ret;
>> -            __u32 longmode;
>> -            __u32 pad;
>> +
>> +            union {
>> +                __u32 longmode;
>> +                __u64 flags;
>> +            };
>>           } hypercall;
>>           /* KVM_EXIT_TPR_ACCESS */
>>           struct {
>> @@ -1182,6 +1185,7 @@ struct kvm_ppc_resize_hpt {
>>   #define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224
>>   #define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225
>>   #define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226
>> +#define KVM_CAP_COUNTER_OFFSET 227
>>   #ifdef KVM_CAP_IRQ_ROUTING
>> @@ -1449,7 +1453,7 @@ struct kvm_vfio_spapr_tce {
>>   #define KVM_CREATE_VCPU           _IO(KVMIO,   0x41)
>>   #define KVM_GET_DIRTY_LOG         _IOW(KVMIO,  0x42, struct 
>> kvm_dirty_log)
>>   #define KVM_SET_NR_MMU_PAGES      _IO(KVMIO,   0x44)
>> -#define KVM_GET_NR_MMU_PAGES      _IO(KVMIO,   0x45)
>> +#define KVM_GET_NR_MMU_PAGES      _IO(KVMIO,   0x45)  /* deprecated */
>>   #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \
>>                       struct kvm_userspace_memory_region)
>>   #define KVM_SET_TSS_ADDR          _IO(KVMIO,   0x47)
>> @@ -1541,6 +1545,8 @@ struct kvm_s390_ucas_mapping {
>>   #define KVM_SET_PMU_EVENT_FILTER  _IOW(KVMIO,  0xb2, struct 
>> kvm_pmu_event_filter)
>>   #define KVM_PPC_SVM_OFF          _IO(KVMIO,  0xb3)
>>   #define KVM_ARM_MTE_COPY_TAGS      _IOR(KVMIO,  0xb4, struct 
>> kvm_arm_copy_mte_tags)
>> +/* Available with KVM_CAP_COUNTER_OFFSET */
>> +#define KVM_ARM_SET_COUNTER_OFFSET _IOW(KVMIO,  0xb5, struct 
>> kvm_arm_counter_offset)
>>   /* ioctl for vm fd */
>>   #define KVM_CREATE_DEVICE      _IOWR(KVMIO,  0xe0, struct 
>> kvm_create_device)
>> diff --git a/linux-headers/linux/psp-sev.h 
>> b/linux-headers/linux/psp-sev.h
>> index 51d8b3940e14..12ccb70099d4 100644
>> --- a/linux-headers/linux/psp-sev.h
>> +++ b/linux-headers/linux/psp-sev.h
>> @@ -36,6 +36,13 @@ enum {
>>    * SEV Firmware status code
>>    */
>>   typedef enum {
>> +    /*
>> +     * This error code is not in the SEV spec. Its purpose is to 
>> convey that
>> +     * there was an error that prevented the SEV firmware from being 
>> called.
>> +     * The SEV API error codes are 16 bits, so the -1 value will not 
>> overlap
>> +     * with possible values from the specification.
>> +     */
>> +    SEV_RET_NO_FW_CALL = -1,
>>       SEV_RET_SUCCESS = 0,
>>       SEV_RET_INVALID_PLATFORM_STATE,
>>       SEV_RET_INVALID_GUEST_STATE,
>> diff --git a/linux-headers/linux/userfaultfd.h 
>> b/linux-headers/linux/userfaultfd.h
>> index ba5d0df52fb8..14e402263a8a 100644
>> --- a/linux-headers/linux/userfaultfd.h
>> +++ b/linux-headers/linux/userfaultfd.h
>> @@ -38,7 +38,8 @@
>>                  UFFD_FEATURE_MINOR_HUGETLBFS |    \
>>                  UFFD_FEATURE_MINOR_SHMEM |        \
>>                  UFFD_FEATURE_EXACT_ADDRESS |        \
>> -               UFFD_FEATURE_WP_HUGETLBFS_SHMEM)
>> +               UFFD_FEATURE_WP_HUGETLBFS_SHMEM |    \
>> +               UFFD_FEATURE_WP_UNPOPULATED)
>>   #define UFFD_API_IOCTLS                \
>>       ((__u64)1 << _UFFDIO_REGISTER |        \
>>        (__u64)1 << _UFFDIO_UNREGISTER |    \
>> @@ -203,6 +204,12 @@ struct uffdio_api {
>>        *
>>        * UFFD_FEATURE_WP_HUGETLBFS_SHMEM indicates that userfaultfd
>>        * write-protection mode is supported on both shmem and hugetlbfs.
>> +     *
>> +     * UFFD_FEATURE_WP_UNPOPULATED indicates that userfaultfd
>> +     * write-protection mode will always apply to unpopulated pages
>> +     * (i.e. empty ptes).  This will be the default behavior for shmem
>> +     * & hugetlbfs, so this flag only affects anonymous memory behavior
>> +     * when userfault write-protection mode is registered.
>>        */
>>   #define UFFD_FEATURE_PAGEFAULT_FLAG_WP        (1<<0)
>>   #define UFFD_FEATURE_EVENT_FORK            (1<<1)
>> @@ -217,6 +224,7 @@ struct uffdio_api {
>>   #define UFFD_FEATURE_MINOR_SHMEM        (1<<10)
>>   #define UFFD_FEATURE_EXACT_ADDRESS        (1<<11)
>>   #define UFFD_FEATURE_WP_HUGETLBFS_SHMEM        (1<<12)
>> +#define UFFD_FEATURE_WP_UNPOPULATED        (1<<13)
>>       __u64 features;
>>       __u64 ioctls;
>> @@ -297,6 +305,13 @@ struct uffdio_writeprotect {
>>   struct uffdio_continue {
>>       struct uffdio_range range;
>>   #define UFFDIO_CONTINUE_MODE_DONTWAKE        ((__u64)1<<0)
>> +    /*
>> +     * UFFDIO_CONTINUE_MODE_WP will map the page write protected on
>> +     * the fly.  UFFDIO_CONTINUE_MODE_WP is available only if the
>> +     * write protected ioctl is implemented for the range
>> +     * according to the uffdio_register.ioctls.
>> +     */
>> +#define UFFDIO_CONTINUE_MODE_WP            ((__u64)1<<1)
>>       __u64 mode;
>>       /*
>> diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h
>> index 4a534edbdcba..2658fda219e8 100644
>> --- a/linux-headers/linux/vfio.h
>> +++ b/linux-headers/linux/vfio.h
>> @@ -646,6 +646,15 @@ enum {
>>       VFIO_CCW_NUM_IRQS
>>   };
>> +/*
>> + * The vfio-ap bus driver makes use of the following IRQ index mapping.
>> + * Unimplemented IRQ types return a count of zero.
>> + */
>> +enum {
>> +    VFIO_AP_REQ_IRQ_INDEX,
>> +    VFIO_AP_NUM_IRQS
>> +};
>> +
>>   /**
>>    * VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 
>> 12,
>>    *                          struct vfio_pci_hot_reset_info)
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-07-03 20:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-02 14:11 [PATCH v2 0/2] s390x/ap: fix hang when mdev attached to guest is removed Tony Krowiak
2023-06-02 14:11 ` [PATCH v2 1/2] linux-headers: Update with vfio_ap IRQ index mapping Tony Krowiak
2023-07-03 16:31   ` Cédric Le Goater
2023-07-03 20:31     ` Anthony Krowiak
2023-06-02 14:11 ` [PATCH v2 2/2] s390x/ap: Wire up the device request notifier interface Tony Krowiak
2023-06-02 14:28   ` Cédric Le Goater
2023-06-02 15:00     ` Anthony Krowiak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.