update linux headers to v6.10-rc1 and shutdown support for pvpanic
v8 cover update linux headers to v6.10-rc1 and shutdown support for pvpanic
Shutdown requests are normally hardware dependent.
By extending pvpanic to also handle shutdown requests, guests can submit such requests with an easily implementable and cross-platform mechanism.
The background is the usage of minimal Linux kernels with different architectures for testing purposes.
Poweroff support varies highly per architecture and requires a bunch of code to be compiled to work.
pvpanic on the other hand is very small and uniform.
Patch 1 is a fix for scripts/update-linux-headers.sh Patch 2 updates the bundled linux headers to Linux v6.10-rc1.
Patch 3 and 4 are general cleanups, which seem useful even without this proposal being implemented.
They should also be ready to be picked up from the series on their own.
The remaining patches implement the new functionality and update the docs.
The matching driver for Linux is part of Linux v6.10-rc1.
To: Michael S. Tsirkin <[email protected]>
To: Cornelia Huck <[email protected]>
To: Paolo Bonzini <[email protected]>
To: Thomas Huth <[email protected]>
To: Laurent Vivier <[email protected]>
To: Eric Blake <[email protected]>
To: Markus Armbruster <[email protected]>
Changes in v8:
- Import linux headers from v6.10-rc1 (and update series subject)
- Use PVPANIC_SHUTDOWN from new linux headers
- Update Since: tag in QAPI to 9.1
- Link to v7: https://lore.kernel.org/r/[email protected]
Changes in v7:
- Keep standard-header/pvpanic.h
- Predefine PVPANIC_SHUTDOWN in include/hw/misc/pvpanic.h
- Fix alignment in QAPI to comply with newly enforced layout
- Update Since: tag in QAPI to 9.0
- Drop note from pvpanic spec about missing implementation
- Link to v6: https://lore.kernel.org/r/[email protected]
Changes in v6:
- Replace magic constant "4" in tests with PVPANIC_SHUTDOWN
- Link to v5: https://lore.kernel.org/r/[email protected]
Changes in v5:
- Add patch from Alejandro to emit a QMP event.
- Update cover letter.
- Add tests.
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Rebase on 8.2 master
- Resend after tree reopened and holidays
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Drop from Linux imported pvpanic header as discussed with Cornelia and requested by Greg
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Remove RFC status
- Add Ack from Thomas to 2nd patch
- Fix typo in title of 2nd patch
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Alejandro Jimenez (1):
pvpanic: Emit GUEST_PVSHUTDOWN QMP event on pvpanic shutdown signal
Thomas Weißschuh (7):
scripts/update-linux-headers: Copy setup_data.h to correct directory
linux-headers: update to 6.10-rc1
hw/misc/pvpanic: centralize definition of supported events tests/qtest/pvpanic: use centralized definition of supported events hw/misc/pvpanic: add support for normal shutdowns tests/qtest/pvpanic: add tests for pvshutdown event Revert "docs/specs/pvpanic: mark shutdown event as not implemented"
docs/specs/pvpanic.rst | 2 +- hw/misc/pvpanic-isa.c | 3 +- hw/misc/pvpanic-pci.c | 3 +- hw/misc/pvpanic.c | 8 +- include/hw/misc/pvpanic.h | 4 + include/standard-headers/linux/ethtool.h | 55 +++++++++++ include/standard-headers/linux/pci_regs.h | 6 ++ include/standard-headers/linux/pvpanic.h | 7 +- include/standard-headers/linux/virtio_bt.h | 1 - include/standard-headers/linux/virtio_mem.h | 2 + include/standard-headers/linux/virtio_net.h | 143 ++++++++++++++++++++++++++++ include/sysemu/runstate.h | 1 + linux-headers/asm-generic/unistd.h | 5 +- linux-headers/asm-loongarch/kvm.h | 4 + linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-riscv/kvm.h | 1 + linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/kvm.h | 4 +- linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 2 + linux-headers/linux/kvm.h | 4 +- linux-headers/linux/stddef.h | 8 ++ linux-headers/linux/vhost.h | 15 +-- qapi/run-state.json | 14 +++ scripts/update-linux-headers.sh | 2 +- system/runstate.c | 6 ++ tests/qtest/pvpanic-pci-test.c | 44 ++++++++- tests/qtest/pvpanic-test.c | 34 ++++++- 34 files changed, 361 insertions(+), 26 deletions(-)
---
base-commit: 60b54b67c63d8f076152e0f7dccf39854dfc6a77
change-id: 20231104-pvpanic-shutdown-02e4b4cb4949
Best regards,
Signature · 1 line
Thomas Weißschuh <[email protected]>
PATCH v8 1/8 scripts/update-linux-headers: Copy setup_data.h to correct directory
Add the missing "include/" path component, so the files ends up in the correct place like the other headers.
--- scripts/update-linux-headers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/update-linux-headers.sh +1 -1
@@ -158,7 +158,7 @@ for arch in $ARCHLIST; do cp_portable "$hdrdir/bootparam.h" \ "$output/include/standard-headers/asm-$arch" cp_portable "$hdrdir/include/asm/setup_data.h" \ - "$output/standard-headers/asm-x86" + "$output/include/standard-headers/asm-x86" fi if [ $arch = riscv ]; then cp "$hdrdir/include/asm/ptrace.h" "$output/linux-headers/asm-riscv/"
Signature · 1 line
2.45.1
Re: [PATCH v8 1/8] scripts/update-linux-headers: Copy setup_data.h to correct directory
Quoted 14 lines · Thomas Weißschuh
Add the missing "
include/" path component, so the files ends up in the correct place like the other headers.Fixes 66210a1a30f2 ("scripts/update-linux-headers: Add setup_data.h to import list")Signed-off-by Thomas Weißschuh <[email protected]>--- scripts/update-linux-headers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/update-linux-headers.sh +0
-0
scripts/update-linux-headers.sh for arch in $ARCHLIST; do · line 161
Quoted 5 lines
scripts/update-linux-headers.sh +1
-1@@ -158,7 +158,7 @@ for arch in $ARCHLIST; do cp_portable "$hdrdir/bootparam.h" \ "$output/include/standard-headers/asm-$arch" cp_portable "$hdrdir/include/asm/setup_data.h" \ - "$output/standard-headers/asm-x86" + "$output/include/standard-headers/asm-x86"
I just ran into the same issue!
PATCH v8 2/8 linux-headers: update to 6.10-rc1
In reply to Thomas Weißschuh--- include/standard-headers/linux/ethtool.h | 55 +++++++++++ include/standard-headers/linux/pci_regs.h | 6 ++ include/standard-headers/linux/pvpanic.h | 7 +- include/standard-headers/linux/virtio_bt.h | 1 - include/standard-headers/linux/virtio_mem.h | 2 + include/standard-headers/linux/virtio_net.h | 143 ++++++++++++++++++++++++++++ linux-headers/asm-generic/unistd.h | 5 +- linux-headers/asm-loongarch/kvm.h | 4 + linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-riscv/kvm.h | 1 + linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/kvm.h | 4 +- linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 2 + linux-headers/linux/kvm.h | 4 +- linux-headers/linux/stddef.h | 8 ++ linux-headers/linux/vhost.h | 15 +-- 23 files changed, 252 insertions(+), 14 deletions(-)
include/standard-headers/linux/ethtool.h +55 -0
@@ -752,6 +752,61 @@ enum ethtool_module_power_mode { ETHTOOL_MODULE_POWER_MODE_HIGH, }; +/** +* enum ethtool_pse_types - Types of PSE controller. +* @ETHTOOL_PSE_UNKNOWN: Type of PSE controller is unknown +* @ETHTOOL_PSE_PODL: PSE controller which support PoDL +* @ETHTOOL_PSE_C33: PSE controller which support Clause 33 (PoE) +*/ +enum ethtool_pse_types { +ETHTOOL_PSE_UNKNOWN =1 <<0 , +ETHTOOL_PSE_PODL =1 <<1 , +ETHTOOL_PSE_C33 =1 <<2 , +}; + +/** +* enum ethtool_c33_pse_admin_state - operational state of the PoDL PSE +* functions. IEEE 802.3-2022 30.9.1.1.2 aPSEAdminState +* @ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN: state of PSE functions is unknown +* @ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED: PSE functions are disabled +* @ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED: PSE functions are enabled +*/ +enum ethtool_c33_pse_admin_state { +ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN =1 , +ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED , +ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED , +}; + +/** +* enum ethtool_c33_pse_pw_d_status - power detection status of the PSE. +* IEEE 802.3-2022 30.9.1.1.3 aPoDLPSEPowerDetectionStatus: +* @ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN: PSE status is unknown +* @ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED: The enumeration "disabled" +* indicates that the PSE State diagram is in the state DISABLED. +* @ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING: The enumeration "searching" +* indicates the PSE State diagram is in a state other than those +* listed. +* @ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING: The enumeration +* "deliveringPower" indicates that the PSE State diagram is in the +* state POWER_ON. +* @ETHTOOL_C33_PSE_PW_D_STATUS_TEST: The enumeration "test" indicates that +* the PSE State diagram is in the state TEST_MODE. +* @ETHTOOL_C33_PSE_PW_D_STATUS_FAULT: The enumeration "fault" indicates that +* the PSE State diagram is in the state TEST_ERROR. +* @ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT: The enumeration "otherFault" +* indicates that the PSE State diagram is in the state IDLE due to +* the variable error_condition = true. +*/ +enum ethtool_c33_pse_pw_d_status { +ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN =1 , +ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED , +ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING , +ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING , +ETHTOOL_C33_PSE_PW_D_STATUS_TEST , +ETHTOOL_C33_PSE_PW_D_STATUS_FAULT , +ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT , +}; +/** * enum ethtool_podl_pse_admin_state - operational state of the PoDL PSE * functions. IEEE 802.3-2018 30.15.1.1.2 aPoDLPSEAdminState
include/standard-headers/linux/pci_regs.h +6 -0
@@ -1144,8 +1144,14 @@#define PCI_DOE_DATA_OBJECT_HEADER_2_LENGTH 0x0003ffff#define PCI_DOE_DATA_OBJECT_DISC_REQ_3_INDEX 0x000000ff +#define PCI_DOE_DATA_OBJECT_DISC_REQ_3_VER 0x0000ff00#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_VID 0x0000ffff#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_PROTOCOL 0x00ff0000#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_NEXT_INDEX 0xff000000 +/* Compute Express Link (CXL r3.1, sec 8.1.5) */ +#define PCI_DVSEC_CXL_PORT 3 +#define PCI_DVSEC_CXL_PORT_CTL 0x0c +#define PCI_DVSEC_CXL_PORT_CTL_UNMASK_SBR 0x00000001 +#endif /* LINUX_PCI_REGS_H */
include/standard-headers/linux/pvpanic.h +5 -2
@@ -3,7 +3,10 @@#ifndef __PVPANIC_H__#define __PVPANIC_H__ -#define PVPANIC_PANICKED (1 << 0) -#define PVPANIC_CRASH_LOADED (1 << 1) +#include "standard-headers/linux/const.h" + +#define PVPANIC_PANICKED _BITUL(0) +#define PVPANIC_CRASH_LOADED _BITUL(1) +#define PVPANIC_SHUTDOWN _BITUL(2)#endif /* __PVPANIC_H__ */
include/standard-headers/linux/virtio_bt.h +0 -1
@@ -13,7 +13,6 @@enum virtio_bt_config_type {VIRTIO_BT_CONFIG_TYPE_PRIMARY =0 , -VIRTIO_BT_CONFIG_TYPE_AMP =1 , };enum virtio_bt_config_vendor {
include/standard-headers/linux/virtio_mem.h +2 -0
@@ -90,6 +90,8 @@#define VIRTIO_MEM_F_ACPI_PXM 0/* unplugged memory must not be accessed */ #define VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE 1 +/* plugged memory will remain plugged when suspending+resuming */ +#define VIRTIO_MEM_F_PERSISTENT_SUSPEND 2/* --- virtio-mem: guest -> host requests --- */
include/standard-headers/linux/virtio_net.h +143 -0
153 lines not on this page · raw message
linux-headers/asm-generic/unistd.h +4 -1
@@ -842,8 +842,11 @@ __SYSCALL(__NR_lsm_set_self_attr, sys_lsm_set_self_attr)#define __NR_lsm_list_modules 461 __SYSCALL(__NR_lsm_list_modules, sys_lsm_list_modules) +#define __NR_mseal 462 +__SYSCALL(__NR_mseal, sys_mseal) +#undef __NR_syscalls -#define __NR_syscalls 462 +#define __NR_syscalls 463/* * 32 bit systems traditionally used different
linux-headers/asm-loongarch/kvm.h +4 -0
@@ -17,6 +17,8 @@#define KVM_COALESCED_MMIO_PAGE_OFFSET 1#define KVM_DIRTY_LOG_PAGE_OFFSET 64 +#define KVM_GUESTDBG_USE_SW_BP 0x00010000 +/* * for KVM_GET_REGS and KVM_SET_REGS */
@@ -72,6 +74,8 @@ struct kvm_fpu {#define KVM_REG_LOONGARCH_COUNTER (KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U64 | 1)#define KVM_REG_LOONGARCH_VCPU_RESET (KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U64 | 2) +/* Debugging: Special instruction for software breakpoint */ +#define KVM_REG_LOONGARCH_DEBUG_INST (KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U64 | 3)#define LOONGARCH_REG_SHIFT 3#define LOONGARCH_REG_64 (TYPE ,REG ) (TYPE | KVM_REG_SIZE_U64 | (REG << LOONGARCH_REG_SHIFT))
linux-headers/asm-mips/unistd_n32.h +1 -0
@@ -390,5 +390,6 @@#define __NR_lsm_get_self_attr (__NR_Linux + 459)#define __NR_lsm_set_self_attr (__NR_Linux + 460)#define __NR_lsm_list_modules (__NR_Linux + 461) +#define __NR_mseal (__NR_Linux + 462)#endif /* _ASM_UNISTD_N32_H */
linux-headers/asm-mips/unistd_n64.h +1 -0
@@ -366,5 +366,6 @@#define __NR_lsm_get_self_attr (__NR_Linux + 459)#define __NR_lsm_set_self_attr (__NR_Linux + 460)#define __NR_lsm_list_modules (__NR_Linux + 461) +#define __NR_mseal (__NR_Linux + 462)#endif /* _ASM_UNISTD_N64_H */
linux-headers/asm-mips/unistd_o32.h +1 -0
@@ -436,5 +436,6 @@#define __NR_lsm_get_self_attr (__NR_Linux + 459)#define __NR_lsm_set_self_attr (__NR_Linux + 460)#define __NR_lsm_list_modules (__NR_Linux + 461) +#define __NR_mseal (__NR_Linux + 462)#endif /* _ASM_UNISTD_O32_H */
linux-headers/asm-powerpc/unistd_32.h +1 -0
@@ -443,6 +443,7 @@#define __NR_lsm_get_self_attr 459#define __NR_lsm_set_self_attr 460#define __NR_lsm_list_modules 461 +#define __NR_mseal 462#endif /* _ASM_UNISTD_32_H */
linux-headers/asm-powerpc/unistd_64.h +1 -0
@@ -415,6 +415,7 @@#define __NR_lsm_get_self_attr 459#define __NR_lsm_set_self_attr 460#define __NR_lsm_list_modules 461 +#define __NR_mseal 462#endif /* _ASM_UNISTD_64_H */
linux-headers/asm-riscv/kvm.h +1 -0
@@ -167,6 +167,7 @@ enum KVM_RISCV_ISA_EXT_ID {KVM_RISCV_ISA_EXT_ZFA ,KVM_RISCV_ISA_EXT_ZTSO ,KVM_RISCV_ISA_EXT_ZACAS , +KVM_RISCV_ISA_EXT_SSCOFPMF , KVM_RISCV_ISA_EXT_MAX, };
linux-headers/asm-s390/unistd_32.h +1 -0
@@ -434,5 +434,6 @@#define __NR_lsm_get_self_attr 459#define __NR_lsm_set_self_attr 460#define __NR_lsm_list_modules 461 +#define __NR_mseal 462#endif /* _ASM_S390_UNISTD_32_H */
linux-headers/asm-s390/unistd_64.h +1 -0
@@ -382,5 +382,6 @@#define __NR_lsm_get_self_attr 459#define __NR_lsm_set_self_attr 460#define __NR_lsm_list_modules 461 +#define __NR_mseal 462#endif /* _ASM_S390_UNISTD_64_H */
linux-headers/asm-x86/kvm.h +3 -1
@@ -709,7 +709,9 @@ struct kvm_sev_cmd {struct kvm_sev_init {__u64 vmsa_features;__u32 flags; -__u32 pad[9 ]; +__u16 ghcb_version; +__u16 pad1; +__u32 pad2[8 ]; };struct kvm_sev_launch_start {
linux-headers/asm-x86/unistd_32.h +1 -0
@@ -452,6 +452,7 @@#define __NR_lsm_get_self_attr 459#define __NR_lsm_set_self_attr 460#define __NR_lsm_list_modules 461 +#define __NR_mseal 462#endif /* _ASM_UNISTD_32_H */
linux-headers/asm-x86/unistd_64.h +1 -0
@@ -374,6 +374,7 @@#define __NR_lsm_get_self_attr 459#define __NR_lsm_set_self_attr 460#define __NR_lsm_list_modules 461 +#define __NR_mseal 462#endif /* _ASM_UNISTD_64_H */
linux-headers/asm-x86/unistd_x32.h +2 -0
@@ -318,6 +318,7 @@#define __NR_set_mempolicy_home_node (__X32_SYSCALL_BIT + 450)#define __NR_cachestat (__X32_SYSCALL_BIT + 451)#define __NR_fchmodat2 (__X32_SYSCALL_BIT + 452) +#define __NR_map_shadow_stack (__X32_SYSCALL_BIT + 453)#define __NR_futex_wake (__X32_SYSCALL_BIT + 454)#define __NR_futex_wait (__X32_SYSCALL_BIT + 455)#define __NR_futex_requeue (__X32_SYSCALL_BIT + 456)
@@ -326,6 +327,7 @@#define __NR_lsm_get_self_attr (__X32_SYSCALL_BIT + 459)#define __NR_lsm_set_self_attr (__X32_SYSCALL_BIT + 460)#define __NR_lsm_list_modules (__X32_SYSCALL_BIT + 461) +#define __NR_mseal (__X32_SYSCALL_BIT + 462)#define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512)#define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513)#define __NR_ioctl (__X32_SYSCALL_BIT + 514)
linux-headers/linux/kvm.h +2 -2
@@ -1217,9 +1217,9 @@ struct kvm_vfio_spapr_tce {/* Available with KVM_CAP_SPAPR_RESIZE_HPT */ #define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt)#define KVM_PPC_RESIZE_HPT_COMMIT _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt) -/* Available with KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 */ +/* Available with KVM_CAP_PPC_MMU_RADIX or KVM_CAP_PPC_MMU_HASH_V3 */ #define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg) -/* Available with KVM_CAP_PPC_RADIX_MMU */ +/* Available with KVM_CAP_PPC_MMU_RADIX */ #define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info)/* Available with KVM_CAP_PPC_GET_CPU_CHAR */ #define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char)
linux-headers/linux/stddef.h +8 -0
@@ -55,4 +55,12 @@#define __counted_by (m)#endif +#ifndef __counted_by_le +#define __counted_by_le (m) +#endif + +#ifndef __counted_by_be +#define __counted_by_be (m) +#endif +#endif /* _LINUX_STDDEF_H */
linux-headers/linux/vhost.h +8 -7
@@ -179,12 +179,6 @@/* Get the config size */ #define VHOST_VDPA_GET_CONFIG_SIZE _IOR(VHOST_VIRTIO, 0x79, __u32) -/* Get the count of all virtqueues */ -#define VHOST_VDPA_GET_VQS_COUNT _IOR(VHOST_VIRTIO, 0x80, __u32) - -/* Get the number of virtqueue groups. */ -#define VHOST_VDPA_GET_GROUP_NUM _IOR(VHOST_VIRTIO, 0x81, __u32) -/* Get the number of address spaces. */ #define VHOST_VDPA_GET_AS_NUM _IOR(VHOST_VIRTIO, 0x7A, unsigned int)
@@ -228,10 +222,17 @@#define VHOST_VDPA_GET_VRING_DESC_GROUP _IOWR(VHOST_VIRTIO, 0x7F, \ struct vhost_vring_state) + +/* Get the count of all virtqueues */ +#define VHOST_VDPA_GET_VQS_COUNT _IOR(VHOST_VIRTIO, 0x80, __u32) + +/* Get the number of virtqueue groups. */ +#define VHOST_VDPA_GET_GROUP_NUM _IOR(VHOST_VIRTIO, 0x81, __u32) +/* Get the queue size of a specific virtqueue. * userspace set the vring index in vhost_vring_state.index * kernel set the queue size in vhost_vring_state.num */ -#define VHOST_VDPA_GET_VRING_SIZE _IOWR(VHOST_VIRTIO, 0x80, \ +#define VHOST_VDPA_GET_VRING_SIZE _IOWR(VHOST_VIRTIO, 0x82, \ struct vhost_vring_state)#endif
Signature · 1 line
2.45.1
PATCH v8 3/8 hw/misc/pvpanic: centralize definition of supported events
In reply to Thomas WeißschuhThe different components of pvpanic duplicate the list of supported events. Move it to the shared header file to minimize changes when new events are added.
--- hw/misc/pvpanic-isa.c | 3 +-- hw/misc/pvpanic-pci.c | 3 +-- hw/misc/pvpanic.c | 3 +-- include/hw/misc/pvpanic.h | 4 ++++ 4 files changed, 7 insertions(+), 6 deletions(-)
hw/misc/pvpanic-isa.c +1 -2
@@ -21,7 +21,6 @@#include "hw/misc/pvpanic.h" #include "qom/object.h" #include "hw/isa/isa.h" -#include "standard-headers/linux/pvpanic.h" #include "hw/acpi/acpi_aml_interface.h" OBJECT_DECLARE_SIMPLE_TYPE (PVPanicISAState,PVPANIC_ISA_DEVICE )
@@ -102,7 +101,7 @@ static void build_pvpanic_isa_aml(AcpiDevAmlIf *adev, Aml *scope)static Property pvpanic_isa_properties[] = {DEFINE_PROP_UINT16 (PVPANIC_IOPORT_PROP , PVPanicISAState, ioport,0x505 ),DEFINE_PROP_UINT8 ("events" , PVPanicISAState, pvpanic.events, -PVPANIC_PANICKED |PVPANIC_CRASH_LOADED ), +PVPANIC_EVENTS ),DEFINE_PROP_END_OF_LIST (), };
hw/misc/pvpanic-pci.c +1 -2
@@ -21,7 +21,6 @@#include "hw/misc/pvpanic.h" #include "qom/object.h" #include "hw/pci/pci_device.h" -#include "standard-headers/linux/pvpanic.h" OBJECT_DECLARE_SIMPLE_TYPE (PVPanicPCIState,PVPANIC_PCI_DEVICE )
@@ -55,7 +54,7 @@ static void pvpanic_pci_realizefn(PCIDevice *dev, Error **errp)static Property pvpanic_pci_properties[] = {DEFINE_PROP_UINT8 ("events" , PVPanicPCIState, pvpanic.events, -PVPANIC_PANICKED |PVPANIC_CRASH_LOADED ), +PVPANIC_EVENTS ),DEFINE_PROP_END_OF_LIST (), };
hw/misc/pvpanic.c +1 -2
@@ -21,13 +21,12 @@#include "hw/qdev-properties.h" #include "hw/misc/pvpanic.h" #include "qom/object.h" -#include "standard-headers/linux/pvpanic.h" static void handle_event (int event) {static bool logged; -if (event & ~(PVPANIC_PANICKED |PVPANIC_CRASH_LOADED ) && !logged) { +if (event & ~PVPANIC_EVENTS && !logged) {qemu_log_mask (LOG_GUEST_ERROR ,"pvpanic: unknown event %#x.\n" , event); logged = true; }
include/hw/misc/pvpanic.h +4 -0
@@ -18,6 +18,10 @@#include "exec/memory.h" #include "qom/object.h" +#include "standard-headers/linux/pvpanic.h" + +#define PVPANIC_EVENTS (PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) +#define TYPE_PVPANIC_ISA_DEVICE "pvpanic"#define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci"
Signature · 1 line
2.45.1
Re: [PATCH v8 3/8] hw/misc/pvpanic: centralize definition of supported events
Quoted 61 lines · Thomas Weißschuh
The different components of pvpanic duplicate the list of supported events. Move it to the shared header file to minimize changes when new events are added.
Reviewed-by Thomas Huth <[email protected]>Reviewed-by Cornelia Huck <[email protected]>Signed-off-by Thomas Weißschuh <[email protected]>--- hw/misc/pvpanic-isa.c | 3 +-- hw/misc/pvpanic-pci.c | 3 +-- hw/misc/pvpanic.c | 3 +-- include/hw/misc/pvpanic.h | 4 ++++ 4 files changed, 7 insertions(+), 6 deletions(-)hw/misc/pvpanic-isa.c +1
-2@@ -21,7 +21,6 @@#include "hw/misc/pvpanic.h" #include "qom/object.h" #include "hw/isa/isa.h" -#include "standard-headers/linux/pvpanic.h" #include "hw/acpi/acpi_aml_interface.h" OBJECT_DECLARE_SIMPLE_TYPE (PVPanicISAState,PVPANIC_ISA_DEVICE )@@ -102,7 +101,7 @@ static void build_pvpanic_isa_aml(AcpiDevAmlIf *adev, Aml *scope)static Property pvpanic_isa_properties[] = {DEFINE_PROP_UINT16 (PVPANIC_IOPORT_PROP , PVPanicISAState, ioport,0x505 ),DEFINE_PROP_UINT8 ("events" , PVPanicISAState, pvpanic.events, -PVPANIC_PANICKED |PVPANIC_CRASH_LOADED ), +PVPANIC_EVENTS ),DEFINE_PROP_END_OF_LIST (), };hw/misc/pvpanic-pci.c +1
-2@@ -21,7 +21,6 @@#include "hw/misc/pvpanic.h" #include "qom/object.h" #include "hw/pci/pci_device.h" -#include "standard-headers/linux/pvpanic.h" OBJECT_DECLARE_SIMPLE_TYPE (PVPanicPCIState,PVPANIC_PCI_DEVICE )@@ -55,7 +54,7 @@ static void pvpanic_pci_realizefn(PCIDevice *dev, Error **errp)static Property pvpanic_pci_properties[] = {DEFINE_PROP_UINT8 ("events" , PVPanicPCIState, pvpanic.events, -PVPANIC_PANICKED |PVPANIC_CRASH_LOADED ), +PVPANIC_EVENTS ),DEFINE_PROP_END_OF_LIST (), };hw/misc/pvpanic.c +0
-0
hw/misc/pvpanic.c line 24
Quoted 4 lines
hw/misc/pvpanic.c +0
-1@@ -21,13 +21,12 @@#include "hw/qdev-properties.h" #include "hw/misc/pvpanic.h" #include "qom/object.h" -#include "standard-headers/linux/pvpanic.h"
This part is wrong. PVPANIC_PANICKED and PVPANIC_CRASH_LOADED are still used in pvpanic.c directly, so we should include standard-headers/linux/pvpanic.h to avoid depending on which header includes which.
I fixed up the patch.
Quoted 27 lines
hw/misc/pvpanic.c +1
-1static void handle_event (int event) {static bool logged; -if (event & ~(PVPANIC_PANICKED |PVPANIC_CRASH_LOADED ) && !logged) { +if (event & ~PVPANIC_EVENTS && !logged) {qemu_log_mask (LOG_GUEST_ERROR ,"pvpanic: unknown event %#x.\n" , event); logged = true; }include/hw/misc/pvpanic.h +4
-0@@ -18,6 +18,10 @@#include "exec/memory.h" #include "qom/object.h" +#include "standard-headers/linux/pvpanic.h" + +#define PVPANIC_EVENTS (PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) +#define TYPE_PVPANIC_ISA_DEVICE "pvpanic"#define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci"Signature · 2 lines
-- 2.45.1
Re: [PATCH v8 3/8] hw/misc/pvpanic: centralize definition of supported events
Quoted 1 line · Michael S. Tsirkin
On Mon, May 27, 2024 at 08:27:49AM +0200, Thomas Weißschuh wrote:
<snip>
Quoted 7 lines
Quoted 7 lines
hw/misc/pvpanic.c +0
-0@@ -21,13 +21,12 @@#include "hw/qdev-properties.h" #include "hw/misc/pvpanic.h"
Quoted 8 lines
hw/misc/pvpanic.c line 24
Quoted 2 lines
hw/misc/pvpanic.c +0
-1#include "qom/object.h" -#include "standard-headers/linux/pvpanic.h" This part is wrong.
PVPANIC_PANICKEDandPVPANIC_CRASH_LOADEDare still used inpvpanic.cdirectly, so we should includestandard-headers/linux/pvpanic.hto avoid depending on which header includes which.
Ack.
Quoted 1 line
I fixed up the patch.
Thanks!
<snip>
Thomas
PATCH v8 4/8 tests/qtest/pvpanic: use centralized definition of supported events
In reply to Thomas WeißschuhAvoid the necessity to update all tests when new events are added to the device.
--- tests/qtest/pvpanic-pci-test.c | 5 +++-- tests/qtest/pvpanic-test.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)
tests/qtest/pvpanic-pci-test.c +3 -2
@@ -16,6 +16,7 @@#include "qapi/qmp/qdict.h" #include "libqos/pci.h" #include "libqos/pci-pc.h" +#include "hw/misc/pvpanic.h" #include "hw/pci/pci_regs.h" static void test_panic_nopause (void )
@@ -34,7 +35,7 @@ static void test_panic_nopause(void) bar =qpci_iomap (dev,0 ,NULL );qpci_memread (dev, bar,0 , &val,sizeof (val)); - g_assert_cmpuint(val, ==, 3); + g_assert_cmpuint(val, ==, PVPANIC_EVENTS); val =1 ;qpci_memwrite (dev, bar,0 , &val,sizeof (val));
@@ -67,7 +68,7 @@ static void test_panic(void) bar =qpci_iomap (dev,0 ,NULL );qpci_memread (dev, bar,0 , &val,sizeof (val)); - g_assert_cmpuint(val, ==, 3); + g_assert_cmpuint(val, ==, PVPANIC_EVENTS); val =1 ;qpci_memwrite (dev, bar,0 , &val,sizeof (val));
tests/qtest/pvpanic-test.c +3 -2
@@ -10,6 +10,7 @@#include "qemu/osdep.h" #include "libqtest.h" #include "qapi/qmp/qdict.h" +#include "hw/misc/pvpanic.h" static void test_panic_nopause (void ) {
@@ -20,7 +21,7 @@ static void test_panic_nopause(void) qts =qtest_init ("-device pvpanic -action panic=none" ); val =qtest_inb (qts,0x505 ); - g_assert_cmpuint(val, ==, 3); + g_assert_cmpuint(val, ==, PVPANIC_EVENTS);qtest_outb (qts,0x505 ,0x1 );
@@ -43,7 +44,7 @@ static void test_panic(void) qts =qtest_init ("-device pvpanic -action panic=pause" ); val =qtest_inb (qts,0x505 ); - g_assert_cmpuint(val, ==, 3); + g_assert_cmpuint(val, ==, PVPANIC_EVENTS);qtest_outb (qts,0x505 ,0x1 );
Signature · 1 line
2.45.1
PATCH v8 5/8 hw/misc/pvpanic: add support for normal shutdowns
In reply to Thomas WeißschuhShutdown requests are normally hardware dependent.
By extending pvpanic to also handle shutdown requests, guests can submit such requests with an easily implementable and cross-platform mechanism.
--- hw/misc/pvpanic.c | 5 +++++ include/hw/misc/pvpanic.h | 2 +- include/sysemu/runstate.h | 1 + system/runstate.c | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-)
hw/misc/pvpanic.c +5 -0
@@ -40,6 +40,11 @@ static void handle_event(int event)qemu_system_guest_crashloaded (NULL );return ; } + +if (event &PVPANIC_SHUTDOWN ) { +qemu_system_guest_pvshutdown (); +return ; + } }/* return supported events on read */
include/hw/misc/pvpanic.h +1 -1
@@ -20,7 +20,7 @@#include "standard-headers/linux/pvpanic.h" -#define PVPANIC_EVENTS (PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) +#define PVPANIC_EVENTS (PVPANIC_PANICKED | PVPANIC_CRASH_LOADED | PVPANIC_SHUTDOWN)#define TYPE_PVPANIC_ISA_DEVICE "pvpanic"#define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci"
include/sysemu/runstate.h +1 -0
@@ -104,6 +104,7 @@ void qemu_system_killed(int signal, pid_t pid);void qemu_system_reset (ShutdownCause reason);void qemu_system_guest_panicked (GuestPanicInformation *info);void qemu_system_guest_crashloaded (GuestPanicInformation *info); +void qemu_system_guest_pvshutdown (void );bool qemu_system_dump_in_progress (void );#endif
system/runstate.c +5 -0
@@ -585,6 +585,11 @@ void qemu_system_guest_crashloaded(GuestPanicInformation *info)qapi_free_GuestPanicInformation (info); } +void qemu_system_guest_pvshutdown (void ) +{ +qemu_system_shutdown_request (SHUTDOWN_CAUSE_GUEST_SHUTDOWN ); +} +void qemu_system_reset_request (ShutdownCause reason) { if (reboot_action == REBOOT_ACTION_SHUTDOWN &&
Signature · 1 line
2.45.1
PATCH v8 6/8 pvpanic: Emit GUEST_PVSHUTDOWN QMP event on pvpanic shutdown signal
In reply to Thomas WeißschuhFrom: Alejandro Jimenez <[email protected]>
Emit a QMP event on receiving a PVPANIC_SHUTDOWN event. Even though a typical SHUTDOWN event will be sent, it will be indistinguishable from a shutdown originating from other cases (e.g. KVM exit due to KVM_SYSTEM_EVENT_SHUTDOWN) that also issue the guest-shutdown cause.
A management layer application can detect the new GUEST_PVSHUTDOWN event to determine if the guest is using the pvpanic interface to request shutdowns.
--- qapi/run-state.json | 14 ++++++++++++++ system/runstate.c | 1 + 2 files changed, 15 insertions(+)
qapi/run-state.json +14 -0
@@ -462,6 +462,20 @@ { 'event': 'GUEST_CRASHLOADED', 'data': { 'action': 'GuestPanicAction', '*info': 'GuestPanicInformation' } } +## +# @GUEST_PVSHUTDOWN: +# +# Emitted when guest submits a shutdown request via pvpanic interface +# +# Since: 9.1 +# +# Example: +# +# <- { "event": "GUEST_PVSHUTDOWN", +# "timestamp": { "seconds": 1648245259, "microseconds": 893771 } } +## +{ 'event': 'GUEST_PVSHUTDOWN' } + ## # @GuestPanicAction: #
system/runstate.c +1 -0
@@ -587,6 +587,7 @@ void qemu_system_guest_crashloaded(GuestPanicInformation *info)void qemu_system_guest_pvshutdown (void ) { +qapi_event_send_guest_pvshutdown ();qemu_system_shutdown_request (SHUTDOWN_CAUSE_GUEST_SHUTDOWN ); }
Signature · 1 line
2.45.1
PATCH v8 7/8 tests/qtest/pvpanic: add tests for pvshutdown event
In reply to Thomas WeißschuhValidate that a shutdown via the pvpanic device emits the correct QMP events.
--- tests/qtest/pvpanic-pci-test.c | 39 +++++++++++++++++++++++++++++++++++++++ tests/qtest/pvpanic-test.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+)
tests/qtest/pvpanic-pci-test.c +39 -0
@@ -85,11 +85,50 @@ static void test_panic(void)qtest_quit (qts); } +static void test_pvshutdown (void ) +{ +uint8_t val; +QDict *response, *data; +QTestState *qts; +QPCIBus *pcibus; +QPCIDevice *dev; +QPCIBar bar; + + qts =qtest_init ("-device pvpanic-pci,addr=04.0" ); + pcibus =qpci_new_pc (qts,NULL ); + dev =qpci_device_find (pcibus,QPCI_DEVFN (0x4 ,0x0 )); +qpci_device_enable (dev); + bar =qpci_iomap (dev,0 ,NULL ); + +qpci_memread (dev, bar,0 , &val,sizeof (val)); + g_assert_cmpuint(val, ==, PVPANIC_EVENTS); + + val =PVPANIC_SHUTDOWN ; +qpci_memwrite (dev, bar,0 , &val,sizeof (val)); + + response =qtest_qmp_eventwait_ref (qts,"GUEST_PVSHUTDOWN" ); +qobject_unref (response); + + response =qtest_qmp_eventwait_ref (qts,"SHUTDOWN" ); +g_assert (qdict_haskey (response,"data" )); + data =qdict_get_qdict (response,"data" ); +g_assert (qdict_haskey (data,"guest" )); +g_assert (qdict_get_bool (data,"guest" )); +g_assert (qdict_haskey (data,"reason" )); + g_assert_cmpstr(qdict_get_str(data, "reason"), ==, "guest-shutdown"); +qobject_unref (response); + +g_free (dev); +qpci_free_pc (pcibus); +qtest_quit (qts); +} +int main (int argc,char **argv) {g_test_init (&argc, &argv,NULL );qtest_add_func ("/pvpanic-pci/panic" , test_panic);qtest_add_func ("/pvpanic-pci/panic-nopause" , test_panic_nopause); +qtest_add_func ("/pvpanic-pci/pvshutdown" , test_pvshutdown);return g_test_run (); }
tests/qtest/pvpanic-test.c +29 -0
@@ -58,11 +58,40 @@ static void test_panic(void)qtest_quit (qts); } +static void test_pvshutdown (void ) +{ +uint8_t val; +QDict *response, *data; +QTestState *qts; + + qts =qtest_init ("-device pvpanic" ); + + val =qtest_inb (qts,0x505 ); + g_assert_cmpuint(val, ==, PVPANIC_EVENTS); + +qtest_outb (qts,0x505 ,PVPANIC_SHUTDOWN ); + + response =qtest_qmp_eventwait_ref (qts,"GUEST_PVSHUTDOWN" ); +qobject_unref (response); + + response =qtest_qmp_eventwait_ref (qts,"SHUTDOWN" ); +g_assert (qdict_haskey (response,"data" )); + data =qdict_get_qdict (response,"data" ); +g_assert (qdict_haskey (data,"guest" )); +g_assert (qdict_get_bool (data,"guest" )); +g_assert (qdict_haskey (data,"reason" )); + g_assert_cmpstr(qdict_get_str(data, "reason"), ==, "guest-shutdown"); +qobject_unref (response); + +qtest_quit (qts); +} +int main (int argc,char **argv) {g_test_init (&argc, &argv,NULL );qtest_add_func ("/pvpanic/panic" , test_panic);qtest_add_func ("/pvpanic/panic-nopause" , test_panic_nopause); +qtest_add_func ("/pvpanic/pvshutdown" , test_pvshutdown);return g_test_run (); }
Signature · 1 line
2.45.1
PATCH v8 8/8 Revert "docs/specs/pvpanic: mark shutdown event as not implemented"
In reply to Thomas WeißschuhThe missing functionality has been implemented now.
This reverts commit e739d1935c461d0668057e9dbba9d06f728d29ec.
--- docs/specs/pvpanic.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
docs/specs/pvpanic.rst +1 -1
@@ -29,7 +29,7 @@ bit 1 a guest panic has happened and will be handled by the guest; the host should record it or report it, but should not affect the execution of the guest. -bit 2 (to be implemented) +bit 2 a regular guest shutdown has happened and should be processed by the host PCI Interface
Signature · 1 line
2.45.1