[QEMU PATCH v3 0/1] S3 support

2023-07-19 Thread Jiqian Chen
v3: Hi all, Thanks for Michael S. Tsirkin's advice. V3 makes below changes: * Remove changes in file include/standard-headers/linux/virtio_gpu.h I am not supposed to edit this file and it will be imported after the patches of linux kernel was merged. Best regards, Jiqian Chen. v2: link

[QEMU PATCH v3 0/1] virtgpu: do not destroy resources when guest suspend

2023-07-19 Thread Jiqian Chen
a new feature flag VIRTIO_GPU_F_FREEZING, so that guest and host can negotiate whenever freezing is supported or not. Signed-off-by: Jiqian Chen --- hw/display/virtio-gpu-base.c | 3 ++ hw/display/virtio-gpu-gl.c | 9 +- hw/display/virtio-gpu-virgl.c | 7 + hw/display/virtio-gpu.c

[LINUX KERNEL PATCH v3 0/1] add S3 support for virtgpu

2023-07-20 Thread Jiqian Chen
v3: Hi all, Thanks for Gerd Hoffmann's advice. V3 makes below changes: * Use enum for freeze mode, so this can be extended with more modes in the future. * Rename functions and paratemers with "_S3" postfix. And no functional changes. Best regards, Jiqian Chen. v2: Hi all, Than

[LINUX KERNEL PATCH v3 1/1] virtgpu: init vq during resume and notify qemu guest status

2023-07-20 Thread Jiqian Chen
ture flag VIRTIO_GPU_F_FREEZE_S3, so that guest and host can negotiate whenever freeze_S3 is supported or not. Signed-off-by: Jiqian Chen --- drivers/gpu/drm/virtio/virtgpu_debugfs.c | 1 + drivers/gpu/drm/virtio/virtgpu_drv.c | 39 drivers/gpu/drm/virtio/virtgpu_drv.h

[QEMU PATCH v4 1/1] virtgpu: do not destroy resources when guest suspend

2023-07-20 Thread Jiqian Chen
it added a new feature flag VIRTIO_GPU_F_FREEZE_S3, so that guest and host can negotiate whenever freeze_S3 is supported or not. Signed-off-by: Jiqian Chen --- hw/display/virtio-gpu-base.c | 3 ++ hw/display/virtio-gpu-gl.c | 10 ++- hw/display/virtio-gpu-virgl.c | 7 + hw/display

[QEMU PATCH v4 0/1] S3 support

2023-07-20 Thread Jiqian Chen
l.org/lkml/20230720115805.8206-1-jiqian.c...@amd.com/T/#t Best regards, Jiqian Chen. v3: link, https://lore.kernel.org/qemu-devel/20230719074726.1613088-1-jiqian.c...@amd.com/T/#t Hi all, Thanks for Michael S. Tsirkin's advice. V3 makes below changes: * Remove changes in file include/standa

[LINUX KERNEL PATCH 0/1] add S3 support for virtgpu

2023-06-08 Thread Jiqian Chen
://lore.kernel.org/qemu-devel/20230608025655.1674357-2-jiqian.c...@amd.com/ Best regards, Jiqian Chen. Jiqian Chen (1): virtgpu: init vq during resume and notify qemu guest status drivers/gpu/drm/virtio/virtgpu_drv.c | 32 drivers/gpu/drm/virtio/virtgpu_drv.h |

[LINUX KERNEL PATCH 1/1] virtgpu: init vq during resume and notify qemu guest status

2023-06-08 Thread Jiqian Chen
to false to notify Qemu that guest exited suspending, and then Qemu will keep its origin actions. As a result, the display can come back and everything of guest can come back to the time when guest was suspended. Signed-off-by: Jiqian Chen --- drivers/gpu/drm/virtio/virtgpu_d

[QEMU PATCH 1/1] virtgpu: do not destroy resources when guest suspend

2023-06-07 Thread Jiqian Chen
destroying resources and resetting renderer when guest calls into virtio_gpu_gl_reset. If guest is during resuming, it sets freezing to false, and then virtio_gpu_gl_reset will keep its origin actions and has no other impaction. Signed-off-by: Jiqian Chen --- hw/display/virtio-gpu-gl.c

[QEMU PATCH 0/1]

2023-06-07 Thread Jiqian Chen
hat guest is suspending, it will not destroy resources and will not reset renderer. If freezing is set to false, Qemu will do its origin actions, and has no other impaction. And now, display can come back and applications can continue their status after guest resumes. Jiqian Chen (1): virtgpu: do not

[QEMU PATCH v2 0/1] S3 support

2023-06-30 Thread Jiqian Chen
lso needs hot-plug support. * Add a new feature flag VIRTIO_GPU_F_FREEZING, so that guest and host can negotiate whenever freezing is supported or not. Best regards, Jiqian Chen. v1: link: https://lore.kernel.org/qemu-devel/20230608025655.1674357-1-jiqian.c...@amd.com/ Hi all, I am work

[QEMU PATCH v2 1/1] virtgpu: do not destroy resources when guest suspend

2023-06-30 Thread Jiqian Chen
a new feature flag VIRTIO_GPU_F_FREEZING, so that guest and host can negotiate whenever freezing is supported or not. Signed-off-by: Jiqian Chen --- hw/display/virtio-gpu-base.c| 3 ++ hw/display/virtio-gpu-gl.c | 9 +++- hw/display/virtio-gpu-virgl.c

[LINUX KERNEL PATCH v2 0/1] add S3 support for virtgpu

2023-06-30 Thread Jiqian Chen
ing is supported or not. V2 of Qemu patch https://lore.kernel.org/qemu-devel/20230630070016.841459-1-jiqian.c...@amd.com/T/#t Best regards, Jiqian Chen. v1: link: https://lore.kernel.org/lkml/20230608063857.1677973-1-jiqian.c...@amd.com/ Hi all, I am working to implement virtgpu S3 function on

[LINUX KERNEL PATCH v2 1/1] virtgpu: init vq during resume and notify qemu guest status

2023-06-30 Thread Jiqian Chen
ture flag VIRTIO_GPU_F_FREEZING, so that guest and host can negotiate whenever freezing is supported or not. Signed-off-by: Jiqian Chen --- drivers/gpu/drm/virtio/virtgpu_debugfs.c | 1 + drivers/gpu/drm/virtio/virtgpu_drv.c | 37 drivers/gpu/drm/virtio/virtgpu_drv.h

[RFC KERNEL PATCH v3 0/3] Support device passthrough when dom0 is PVH on Xen

2023-12-10 Thread Jiqian Chen
m/ and xen https://lore.kernel.org/xen-devel/20230312075455.450187-6-ray.hu...@amd.com/) About the v2 patch of qemu, just change an included head file, other are similar to the v1 ( qemu https://lore.kernel.org/xen-devel/20230312092244.451465-19-ray.hu...@amd.com/), just call xc_physdev_gsi_from

[RFC KERNEL PATCH v3 1/3] xen/pci: Add xen_reset_device_state function

2023-12-10 Thread Jiqian Chen
in pcistub_init_device. Because when using "pci-assignable-add" to assign a passthrough device in Xen, it will reset passthrough device and the vpci state will out of date, and then device will fail to restore bar state. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- drivers

[RFC KERNEL PATCH v3 2/3] xen/pvh: Setup gsi and map pirq for passthrough device

2023-12-10 Thread Jiqian Chen
Rui Signed-off-by: Jiqian Chen --- arch/x86/xen/enlighten_pvh.c | 116 + drivers/acpi/pci_irq.c | 2 +- drivers/xen/xen-pciback/pci_stub.c | 8 ++ include/linux/acpi.h | 1 + include/xen/acpi.h | 1 + 5 files changed,

[RFC KERNEL PATCH v3 3/3] PCI/sysfs: Add gsi sysfs for pci_dev

2023-12-10 Thread Jiqian Chen
There is a need for some scenarios to use gsi sysfs. For example, when xen passthrough a device to dumU, it will use gsi to map pirq, but currently userspace can't get gsi number. So, add gsi sysfs for that and for other potential scenarios. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen

[RFC XEN PATCH v3 1/3] xen/vpci: Clear all vpci status of device

2023-12-10 Thread Jiqian Chen
can call this hypercall to notify vpci. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- xen/arch/x86/hvm/hypercall.c | 1 + xen/drivers/pci/physdev.c| 35 +++ xen/drivers/vpci/vpci.c | 9 + xen/include/public/physdev.h | 8

[RFC XEN PATCH v3 0/3] Support device passthrough when dom0 is PVH on Xen

2023-12-10 Thread Jiqian Chen
20230312120157.452859-6-ray.hu...@amd.com/ and xen https://lore.kernel.org/xen-devel/20230312075455.450187-6-ray.hu...@amd.com/) About the v2 patch of qemu, just change an included head file, other are similar to the v1 ( qemu https://lore.kernel.org/xen-devel/20230312092244.451465-19-ray.hu...@amd.

[RFC XEN PATCH v3 3/3] libxl: Use gsi instead of irq for mapping pirq

2023-12-10 Thread Jiqian Chen
rom gsi sysfs. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- tools/libs/light/libxl_pci.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c index 96cb4da079..9e75f0c263 100644 --- a/tools/l

[RFC XEN PATCH v3 2/3] x86/pvh: Add (un)map_pirq and setup_gsi for PVH dom0

2023-12-10 Thread Jiqian Chen
stered, but the gsi of a passthrough device must be configured for it to be able to be mapped into a hvm domU. So, add PHYSDEVOP_setup_gsi for PVH dom0, because PVH dom0 will setup gsi during assigning a device to passthrough. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- xen/arch/x

[RFC QEMU PATCH v3 0/1] Support device passthrough when dom0 is PVH on Xen

2023-12-10 Thread Jiqian Chen
ide: https://lore.kernel.org/xen-devel/20231124104136.3263722-1-jiqian.c...@amd.com/T/#t Jiqian Chen (1): xen: Use gsi instead of irq for mapping pirq hw/xen/xen-host-pci-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.34.1

[RFC QEMU PATCH v3 1/1] xen: Use gsi instead of irq for mapping pirq

2023-12-10 Thread Jiqian Chen
gsi sysfs. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- hw/xen/xen-host-pci-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xen/xen-host-pci-device.c b/hw/xen/xen-host-pci-device.c index 8c6e9a1716..e270ac2631 100644 --- a/hw/xen/xen-host-pci-device.c ++

[RFC KERNEL PATCH v4 0/3] Support device passthrough when dom0 is PVH on Xen

2024-01-04 Thread Jiqian Chen
https://lore.kernel.org/xen-devel/20230312092244.451465-19-ray.hu...@amd.com/), just call xc_physdev_gsi_from_irq() to get gsi from irq. Jiqian Chen (3): xen/pci: Add xen_reset_device_state function xen/pvh: Setup gsi for passthrough device PCI/sysfs: Add gsi sysfs for pci_dev arch/x86

[RFC KERNEL PATCH v4 3/3] PCI/sysfs: Add gsi sysfs for pci_dev

2024-01-04 Thread Jiqian Chen
There is a need for some scenarios to use gsi sysfs. For example, when xen passthrough a device to dumU, it will use gsi to map pirq, but currently userspace can't get gsi number. So, add gsi sysfs for that and for other potential scenarios. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen

[RFC KERNEL PATCH v4 2/3] xen/pvh: Setup gsi for passthrough device

2024-01-04 Thread Jiqian Chen
In PVH dom0, the gsis don't get registered, but the gsi of a passthrough device must be configured for it to be able to be mapped into a domU. When assign a device to passthrough, proactively setup the gsi of the device during that process. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen

[RFC KERNEL PATCH v4 1/3] xen/pci: Add xen_reset_device_state function

2024-01-04 Thread Jiqian Chen
in pcistub_init_device. Because when using "pci-assignable-add" to assign a passthrough device in Xen, it will reset passthrough device and the vpci state will out of date, and then device will fail to restore bar state. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- drivers

[RFC XEN PATCH v4 2/5] x86/pvh: Allow (un)map_pirq when caller isn't DOMID_SELF

2024-01-04 Thread Jiqian Chen
Huang Rui Signed-off-by: Jiqian Chen --- xen/arch/x86/hvm/hypercall.c | 27 +-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index 6ad5b4d5f11f..632a68be3cc4 100644 --- a/xen/arch/x86/hvm/hyper

[RFC XEN PATCH v4 4/5] domctl: Use gsi to grant/revoke irq permission

2024-01-04 Thread Jiqian Chen
ion. And change the caller of XEN_DOMCTL_irq_permission to pass gsi to it instead of pirq. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- tools/libs/light/libxl_pci.c | 6 -- tools/libs/light/libxl_x86.c | 5 - xen/common/domctl.c | 12 ++-- 3 files changed,

[RFC XEN PATCH v4 0/5] Support device passthrough when dom0 is PVH on Xen

2024-01-04 Thread Jiqian Chen
l/20230312075455.450187-6-ray.hu...@amd.com/) About the v2 patch of qemu, just change an included head file, other are similar to the v1 ( qemu https://lore.kernel.org/xen-devel/20230312092244.451465-19-ray.hu...@amd.com/), just call xc_physdev_gsi_from_irq() to get gsi from irq. Jiqian Chen (5):

[RFC XEN PATCH v4 1/5] xen/vpci: Clear all vpci status of device

2024-01-04 Thread Jiqian Chen
can call this hypercall to notify vpci. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- xen/arch/x86/hvm/hypercall.c | 1 + xen/drivers/pci/physdev.c| 34 ++ xen/drivers/vpci/vpci.c | 9 + xen/include/public/physdev.h | 7

[RFC XEN PATCH v4 5/5] libxl: Use gsi instead of irq for mapping pirq

2024-01-04 Thread Jiqian Chen
rom gsi sysfs. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- tools/libs/light/libxl_pci.c | 15 +-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c index e1341d1e9850..ab51dc099725 100644 --- a/to

[RFC XEN PATCH v4 3/5] x86/pvh: Add PHYSDEVOP_setup_gsi for PVH dom0

2024-01-04 Thread Jiqian Chen
purpose. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- xen/arch/x86/hvm/hypercall.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index 632a68be3cc4..e27d3ca15185 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen

[RFC QEMU PATCH v4 1/1] xen: Use gsi instead of irq for mapping pirq

2024-01-04 Thread Jiqian Chen
use gsi number that read from gsi sysfs if it exists. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- hw/xen/xen-host-pci-device.c | 7 +++ hw/xen/xen-host-pci-device.h | 1 + hw/xen/xen_pt.c | 6 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/hw/

[RFC QEMU PATCH v4 0/1] Support device passthrough when dom0 is PVH on Xen

2024-01-04 Thread Jiqian Chen
uccess. This v2 on qemu side is the same as the v1 ( qemu https://lore.kernel.org/xen-devel/20230312092244.451465-19-ray.hu...@amd.com/), just call xc_physdev_gsi_from_irq() to get gsi from irq. Jiqian Chen (1): xen: Use gsi instead of irq for mapping pirq hw/xen/xen-host-pci-device

[RFC XEN PATCH v5 2/5] x86/pvh: Allow (un)map_pirq when dom0 is PVH

2024-01-11 Thread Jiqian Chen
ng Rui Signed-off-by: Jiqian Chen --- xen/arch/x86/hvm/hypercall.c | 2 ++ xen/arch/x86/physdev.c | 22 ++ 2 files changed, 24 insertions(+) diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index 6ad5b4d5f11f..493998b42ec5 100644 --- a/xen/arch/x

[RFC XEN PATCH v5 3/5] x86/pvh: Add PHYSDEVOP_setup_gsi for PVH dom0

2024-01-11 Thread Jiqian Chen
purpose. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- xen/arch/x86/hvm/hypercall.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index 493998b42ec5..46f51ee459f6 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen

[RFC XEN PATCH v5 4/5] libxl: Use gsi instead of irq for mapping pirq

2024-01-11 Thread Jiqian Chen
rom gsi sysfs. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen Reviewed-by: Stefano Stabellini --- tools/libs/light/libxl_pci.c | 25 +++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c in

[RFC XEN PATCH v5 5/5] domctl: Add XEN_DOMCTL_gsi_permission to grant gsi

2024-01-11 Thread Jiqian Chen
Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- tools/include/xenctrl.h | 5 + tools/libs/ctrl/xc_domain.c | 15 +++ tools/libs/light/libxl_pci.c | 16 ++-- xen/arch/x86/domctl.c| 31 +++ xen/include/public/domctl.h |

[RFC XEN PATCH v5 0/5] Support device passthrough when dom0 is PVH on Xen

2024-01-11 Thread Jiqian Chen
59-6-ray.hu...@amd.com/ and xen https://lore.kernel.org/xen-devel/20230312075455.450187-6-ray.hu...@amd.com/) About the v2 patch of qemu, just change an included head file, other are similar to the v1 ( qemu https://lore.kernel.org/xen-devel/20230312092244.451465-19-ray.hu...@amd.com/), just c

[RFC XEN PATCH v5 1/5] xen/vpci: Clear all vpci status of device

2024-01-11 Thread Jiqian Chen
can call this hypercall to notify vpci. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- xen/arch/x86/hvm/hypercall.c | 1 + xen/drivers/pci/physdev.c| 36 xen/drivers/vpci/vpci.c | 10 ++ xen/include/public/physdev.h | 7

[RFC QEMU PATCH v2 0/1] Support device passthrough when dom0 is PVH on Xen

2023-11-24 Thread Jiqian Chen
xc_physdev_gsi_from_irq() to get gsi from irq. v2 on kernel side: https://lore.kernel.org/lkml/20231124103123.3263471-1-jiqian.c...@amd.com/T/#t v2 on Xen side: https://lore.kernel.org/xen-devel/20231124104136.3263722-1-jiqian.c...@amd.com/T/#t Jiqian Chen (1): xen/pci: get gsi from irq for passthrough

[RFC QEMU PATCH v2 1/1] xen/pci: get gsi from irq for passthrough devices

2023-11-24 Thread Jiqian Chen
irq in current code, that is irq not gsi, so it will fail when mapping. For above reason, on Xen side, we add a new function to translate irq to gsi. And at here, we call that function to get the correct gsi number. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui --- hw/xen/xen-host-pci-devic

[RFC KERNEL PATCH v2 3/3] xen/privcmd: Add new syscall to get gsi from irq

2023-11-24 Thread Jiqian Chen
can get that translation when they have a need. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui --- arch/x86/include/asm/apic.h | 7 ++ arch/x86/include/asm/xen/pci.h | 5 arch/x86/kernel/acpi/boot.c | 2 +- arch/x86/pci/xen.c |

[RFC KERNEL PATCH v2 1/3] xen/pci: Add xen_reset_device_state function

2023-11-24 Thread Jiqian Chen
that function in pcistub_init_device. Because when we use "pci-assignable-add" to assign a passthrough device in Xen, it will reset passthrough device and the vpci state will out of date, and then device will fail to restore bar state. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui --- d

[RFC KERNEL PATCH v2 0/3] Support device passthrough when dom0 is PVH on Xen

2023-11-24 Thread Jiqian Chen
.kernel.org/xen-devel/20230312075455.450187-6-ray.hu...@amd.com/) About the v2 patch of qemu, just change an included head file, other are similar to the v1 ( qemu https://lore.kernel.org/xen-devel/20230312092244.451465-19-ray.hu...@amd.com/), just call xc_physdev_gsi_from_irq() to get gsi from irq. Ji

[RFC KERNEL PATCH v2 2/3] xen/pvh: Unmask irq for passthrough device in PVH dom0

2023-11-24 Thread Jiqian Chen
n PVH dom0. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui --- drivers/xen/xen-pciback/pci_stub.c | 7 +++ include/linux/irq.h| 1 + kernel/irq/chip.c | 1 + kernel/irq/internals.h | 1 - kernel/irq/irqdesc.c | 2 +- 5 files cha

[RFC XEN PATCH v2 1/3] xen/vpci: Clear all vpci status of device

2023-11-24 Thread Jiqian Chen
, dom0 can call this hypercall to notify vpci. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui --- xen/arch/x86/hvm/hypercall.c | 1 + xen/drivers/passthrough/pci.c | 21 + xen/drivers/pci/physdev.c | 14 ++ xen/drivers/vpci/vpci.c | 9

[RFC XEN PATCH v2 2/3] x86/pvh: Open PHYSDEVOP_map_pirq for PVH dom0

2023-11-24 Thread Jiqian Chen
currd is PVH dom0 and PVH has no X86_EMU_USE_PIRQ flag, it will fail at has_pirq check. So, I think we may need to allow PHYSDEVOP_map_pirq when currd is dom0 (at present dom0 is PVH). Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui --- xen/arch/x86/hvm/hypercall.c | 2 ++ 1 file chan

[RFC XEN PATCH v2 0/3] Support device passthrough when dom0 is PVH on Xen

2023-11-24 Thread Jiqian Chen
/lore.kernel.org/xen-devel/20230312120157.452859-6-ray.hu...@amd.com/ and xen https://lore.kernel.org/xen-devel/20230312075455.450187-6-ray.hu...@amd.com/) About the v2 patch of qemu, just change an included head file, other are similar to the v1 ( qemu https://lore.kernel.org/xen-devel/202303

[RFC XEN PATCH v2 3/3] tools: Add new function to get gsi from irq

2023-11-24 Thread Jiqian Chen
ore xc_physdev_map_pirq Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui --- tools/include/xen-sys/Linux/privcmd.h | 7 +++ tools/include/xencall.h | 2 ++ tools/include/xenctrl.h | 2 ++ tools/libs/call/core.c| 5 + tools/libs/call/libxencall.

[RFC QEMU PATCH v6 0/1] Support device passthrough when dom0 is PVH on Xen

2024-04-18 Thread Jiqian Chen
Hi All, This is v6 series to support passthrough on Xen when dom0 is PVH. v5->v6 changes: * Due to changes in the implementation of obtaining gsi in the kernel and Xen. Change to use xc_physdev_gsi_from_irq, instead of gsi sysfs. Best regards, Jiqian Chen v4->v5 changes: * Add

[RFC QEMU PATCH v6 1/1] xen/pci: get gsi from irq for passthrough devices

2024-04-18 Thread Jiqian Chen
new function supported by Xen tools. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- hw/xen/xen-host-pci-device.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/xen/xen-host-pci-device.c b/hw/xen/xen-host-pci-device.c index 8c6e9a1716a2..5e9aa9679e3e 100644 --- a

[RFC XEN PATCH v7 4/5] tools: Add new function to get gsi from irq

2024-04-18 Thread Jiqian Chen
In PVH dom0, it uses the linux local interrupt mechanism, when it allocs irq for a gsi, it is dynamic, and follow the principle of applying first, distributing first. And irq number is alloced from small to large, but the applying gsi number is not, may gsi 38 comes before gsi 28, that causes the

[XEN PATCH v7 1/5] xen/vpci: Clear all vpci status of device

2024-04-18 Thread Jiqian Chen
can call this hypercall to notify vpci. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen Reviewed-by: Stewart Hildebrand Reviewed-by: Stefano Stabellini --- xen/arch/x86/hvm/hypercall.c | 1 + xen/drivers/pci/physdev.c| 36 xen/drivers/vpci/vpci.c

[XEN PATCH v7 2/5] x86/pvh: Allow (un)map_pirq when dom0 is PVH

2024-04-18 Thread Jiqian Chen
ng Rui Signed-off-by: Jiqian Chen Reviewed-by: Stefano Stabellini --- xen/arch/x86/hvm/hypercall.c | 2 ++ xen/arch/x86/physdev.c | 24 2 files changed, 26 insertions(+) diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index 56fbb69ab201..d49fb8

[RFC XEN PATCH v7 0/5] Support device passthrough when dom0 is PVH on Xen

2024-04-18 Thread Jiqian Chen
Best regards, Jiqian Chen v5->v6 changes: * patch#1: Add Reviewed-by Stefano and Stewart. Rebase code and change old function vpci_remove_device, vpci_add_handlers to vpci_deassign_device, vpci_assign_device * patch#2: Add Reviewed-by Stefano * patch#3: Remove unnecessary "ASSERT(!

[RFC XEN PATCH v7 5/5] domctl: Add XEN_DOMCTL_gsi_permission to grant gsi

2024-04-18 Thread Jiqian Chen
off-by: Huang Rui Signed-off-by: Jiqian Chen --- tools/include/xenctrl.h | 5 tools/libs/ctrl/xc_domain.c | 15 tools/libs/light/libxl_pci.c | 46 xen/arch/x86/domctl.c| 31 xen/include/public/domct

[RFC XEN PATCH v7 3/5] x86/pvh: Add PHYSDEVOP_setup_gsi for PVH dom0

2024-04-18 Thread Jiqian Chen
purpose. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- xen/arch/x86/hvm/hypercall.c | 5 + 1 file changed, 5 insertions(+) diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index d49fb8b548a3..98e3c6b176ff 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen

[RFC KERNEL PATCH v6 2/3] xen/pvh: Setup gsi for passthrough device

2024-04-18 Thread Jiqian Chen
In PVH dom0, the gsis don't get registered, but the gsi of a passthrough device must be configured for it to be able to be mapped into a domU. When assign a device to passthrough, proactively setup the gsi of the device during that process. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen

[RFC KERNEL PATCH v6 0/3] Support device passthrough when dom0 is PVH on Xen

2024-04-18 Thread Jiqian Chen
Hi All, This is v6 series to support passthrough on Xen when dom0 is PVH. v5->v6 change: * patch#3: change to add a new syscall to translate irq to gsi, instead adding a new gsi sysfs. Best regards, Jiqian Chen v4->v5 changes: * patch#1: Add Reviewed-by Stefano * patch#2: Add Re

[RFC KERNEL PATCH v6 3/3] xen/privcmd: Add new syscall to get gsi from irq

2024-04-18 Thread Jiqian Chen
to gsi for userspace. For above purpose, record the relationship of gsi and irq when PVH dom0 do acpi_register_gsi_ioapic for devices and adds a new syscall into privcmd to let userspace can get that translation when they have a need. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen

[KERNEL PATCH v6 1/3] xen/pci: Add xen_reset_device_state function

2024-04-18 Thread Jiqian Chen
in pcistub_init_device. Because when using "pci-assignable-add" to assign a passthrough device in Xen, it will reset passthrough device and the vpci state will out of date, and then device will fail to restore bar state. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen Reviewed-b

[RFC KERNEL PATCH v7 2/2] xen/privcmd: Add new syscall to get gsi from dev

2024-05-15 Thread Jiqian Chen
for userspace. For above purpose, record gsi of pcistub devices when init pcistub and add a new syscall into privcmd to let userspace can get gsi when they have a need. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen --- drivers/xen/privcmd.c | 28 ++ drivers

[RFC KERNEL PATCH v7 0/2] Support device passthrough when dom0 is PVH on Xen

2024-05-15 Thread Jiqian Chen
we can return that gsi. Best regards, Jiqian Chen v5->v6 change: * patch#3: change to add a new syscall to translate irq to gsi, instead adding a new gsi sysfs. v4->v5 changes: * patch#1: Add Reviewed-by Stefano * patch#2: Add Reviewed-by Stefano * patch#3: No changes v3->v4 chan

[RFC KERNEL PATCH v7 1/2] xen/pvh: Setup gsi for passthrough device

2024-05-15 Thread Jiqian Chen
In PVH dom0, the gsis don't get registered, but the gsi of a passthrough device must be configured for it to be able to be mapped into a domU. When assign a device to passthrough, proactively setup the gsi of the device during that process. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen

[RFC QEMU PATCH v7 0/1] Support device passthrough when dom0 is PVH on Xen

2024-05-16 Thread Jiqian Chen
Hi All, This is v7 series to support passthrough on Xen when dom0 is PVH. v6->v7 changes: * Due to changes in the implementation of obtaining gsi in the kernel and Xen. Change to use xc_physdev_gsi_from_dev, that requires passing in sbdf instead of irq. Best regards, Jiqian Chen v5-

[RFC QEMU PATCH v7 1/1] xen/pci: get gsi for passthrough devices

2024-05-16 Thread Jiqian Chen
ion supported by Xen tools. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- hw/xen/xen-host-pci-device.c | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/hw/xen/xen-host-pci-device.c b/hw/xen/xen-host-pci-device.c index 8c6e9a1716a2..2fe6a60434ba 100

[XEN PATCH v8 2/5] x86/pvh: Allow (un)map_pirq when dom0 is PVH

2024-05-16 Thread Jiqian Chen
ng Rui Signed-off-by: Jiqian Chen Reviewed-by: Stefano Stabellini --- xen/arch/x86/hvm/hypercall.c | 2 ++ xen/arch/x86/physdev.c | 24 2 files changed, 26 insertions(+) diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index 56fbb69ab201..d49fb8

[RFC XEN PATCH v8 4/5] tools: Add new function to get gsi from dev

2024-05-16 Thread Jiqian Chen
In PVH dom0, it uses the linux local interrupt mechanism, when it allocs irq for a gsi, it is dynamic, and follow the principle of applying first, distributing first. And irq number is alloced from small to large, but the applying gsi number is not, may gsi 38 comes before gsi 28, that causes the

[RFC XEN PATCH v8 5/5] domctl: Add XEN_DOMCTL_gsi_permission to grant gsi

2024-05-16 Thread Jiqian Chen
off-by: Huang Rui Signed-off-by: Jiqian Chen --- tools/include/xenctrl.h | 5 +++ tools/libs/ctrl/xc_domain.c | 15 tools/libs/light/libxl_pci.c | 72 xen/arch/x86/domctl.c| 31 xen/include/public/domctl.h | 9 +

[XEN PATCH v8 3/5] x86/pvh: Add PHYSDEVOP_setup_gsi for PVH dom0

2024-05-16 Thread Jiqian Chen
purpose. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- xen/arch/x86/hvm/hypercall.c | 5 + 1 file changed, 5 insertions(+) diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index d49fb8b548a3..98e3c6b176ff 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen

[XEN PATCH v8 1/5] xen/vpci: Clear all vpci status of device

2024-05-16 Thread Jiqian Chen
can call this hypercall to notify vpci. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen Reviewed-by: Stewart Hildebrand Reviewed-by: Stefano Stabellini --- xen/arch/x86/hvm/hypercall.c | 1 + xen/drivers/pci/physdev.c| 36 xen/drivers/vpci/vpci.c

[XEN PATCH v8 0/5] Support device passthrough when dom0 is PVH on Xen

2024-05-16 Thread Jiqian Chen
at gets more intuitive code logic. Best regards, Jiqian Chen v6->v7 changes: * patch#4: Due to changes in the implementation of obtaining gsi in the kernel. Change to add a new function to get gsi from irq, instead of gsi sysfs. * patch#5: Fix the issue with variable usage,

[QEMU PATCH v5 0/1] Support device passthrough when dom0 is PVH on Xen

2024-03-28 Thread Jiqian Chen
o get gsi. Then xc_physdev_map_pirq() will success. This v2 on qemu side is the same as the v1 (qemu https://lore.kernel.org/xen-devel/20230312092244.451465-19-ray.hu...@amd.com/), just call xc_physdev_gsi_from_irq() to get gsi from irq. Jiqian Chen (1): xen: Use gsi instead of irq for map

[RFC QEMU PATCH v5 1/1] xen: Use gsi instead of irq for mapping pirq

2024-03-28 Thread Jiqian Chen
use gsi number that read from gsi sysfs if it exists. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen Reviewed-by: Stefano Stabellini --- RFC: discussions ongoing on the Linux side where/how to expose the gsi --- hw/xen/xen-host-pci-device.c | 7 +++ hw/xen/xen-host-pci-device.h | 1 +

[RFC XEN PATCH v6 3/5] x86/pvh: Add PHYSDEVOP_setup_gsi for PVH dom0

2024-03-28 Thread Jiqian Chen
purpose. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- xen/arch/x86/hvm/hypercall.c | 5 + 1 file changed, 5 insertions(+) diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index 493998b42ec5..7d4e41f66885 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen

[RFC XEN PATCH v6 0/5] Support device passthrough when dom0 is PVH on Xen

2024-03-28 Thread Jiqian Chen
nel.org/xen-devel/20230312075455.450187-6-ray.hu...@amd.com/) About the v2 patch of qemu, just change an included head file, other are similar to the v1 ( qemu https://lore.kernel.org/xen-devel/20230312092244.451465-19-ray.hu...@amd.com/), just call xc_physdev_gsi_from_irq() to get gsi fro

[XEN PATCH v6 2/5] x86/pvh: Allow (un)map_pirq when dom0 is PVH

2024-03-28 Thread Jiqian Chen
ng Rui Signed-off-by: Jiqian Chen Reviewed-by: Stefano Stabellini --- xen/arch/x86/hvm/hypercall.c | 2 ++ xen/arch/x86/physdev.c | 24 2 files changed, 26 insertions(+) diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index 6ad5b4d5f11f..493998

[RFC XEN PATCH v6 5/5] domctl: Add XEN_DOMCTL_gsi_permission to grant gsi

2024-03-28 Thread Jiqian Chen
off-by: Huang Rui Signed-off-by: Jiqian Chen --- tools/include/xenctrl.h | 5 tools/libs/ctrl/xc_domain.c | 15 +++ tools/libs/light/libxl_pci.c | 52 +--- xen/arch/x86/domctl.c| 31 + xen/include/public/domctl.h |

[RFC XEN PATCH v6 4/5] libxl: Use gsi instead of irq for mapping pirq

2024-03-28 Thread Jiqian Chen
rom gsi sysfs. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen Reviewed-by: Stefano Stabellini --- RFC: discussions ongoing on the Linux side where/how to expose the gsi --- tools/libs/light/libxl_pci.c | 16 ++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/to

[XEN PATCH v6 1/5] xen/vpci: Clear all vpci status of device

2024-03-28 Thread Jiqian Chen
can call this hypercall to notify vpci. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen Reviewed-by: Stewart Hildebrand Reviewed-by: Stefano Stabellini --- xen/arch/x86/hvm/hypercall.c | 1 + xen/drivers/pci/physdev.c| 36 xen/drivers/vpci/vpci.c

[RFC KERNEL PATCH v5 0/3] Support device passthrough when dom0 is PVH on Xen

2024-03-28 Thread Jiqian Chen
similar to the v1 ( qemu https://lore.kernel.org/xen-devel/20230312092244.451465-19-ray.hu...@amd.com/), just call xc_physdev_gsi_from_irq() to get gsi from irq. Jiqian Chen (3): xen/pci: Add xen_reset_device_state function xen/pvh: Setup gsi for passthrough device PCI/sysfs: Add

[RFC KERNEL PATCH v5 2/3] xen/pvh: Setup gsi for passthrough device

2024-03-28 Thread Jiqian Chen
In PVH dom0, the gsis don't get registered, but the gsi of a passthrough device must be configured for it to be able to be mapped into a domU. When assign a device to passthrough, proactively setup the gsi of the device during that process. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen

[RFC KERNEL PATCH v5 3/3] PCI/sysfs: Add gsi sysfs for pci_dev

2024-03-28 Thread Jiqian Chen
There is a need for some scenarios to use gsi sysfs. For example, when xen passthrough a device to dumU, it will use gsi to map pirq, but currently userspace can't get gsi number. So, add gsi sysfs for that and for other potential scenarios. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen

[KERNEL PATCH v5 1/3] xen/pci: Add xen_reset_device_state function

2024-03-28 Thread Jiqian Chen
in pcistub_init_device. Because when using "pci-assignable-add" to assign a passthrough device in Xen, it will reset passthrough device and the vpci state will out of date, and then device will fail to restore bar state. Co-developed-by: Huang Rui Signed-off-by: Jiqian Chen Reviewed-b

[RFC KERNEL PATCH v8 0/2] Support device passthrough when dom0 is PVH on Xen

2024-06-07 Thread Jiqian Chen
h#2: is the patch#1 of v7. Use CONFIG_XEN_ACPI instead of CONFIG_ACPI to wrap codes. * patch#3: is the patch#2 of v7. In function privcmd_ioctl_gsi_from_dev, return -EINVAL when not confige CONFIG_XEN_ACPI. use PCI_BUS_NUM PCI_SLOT PCI_FUNC instead of open coding. Best regards, Jiq

[RFC KERNEL PATCH v8 3/3] xen/privcmd: Add new syscall to get gsi from dev

2024-06-07 Thread Jiqian Chen
for userspace. For above purpose, record gsi of pcistub devices when init pcistub and add a new syscall into privcmd to let userspace can get gsi when they have a need. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- RFC: it need review and need to wait for previous patch of this series

[RFC KERNEL PATCH v8 1/3] xen/pci: Add xen_reset_device_function_state

2024-06-07 Thread Jiqian Chen
in pcistub_init_device. Because when using "pci-assignable-add" to assign a passthrough device in Xen, it will reset passthrough device and the vpci state will out of date, and then device will fail to restore bar state. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen Reviewed-b

[RFC KERNEL PATCH v8 2/3] xen/pvh: Setup gsi for passthrough device

2024-06-07 Thread Jiqian Chen
In PVH dom0, the gsis don't get registered, but the gsi of a passthrough device must be configured for it to be able to be mapped into a domU. When assign a device to passthrough, proactively setup the gsi of the device during that process. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen

[RFC XEN PATCH v9 5/5] domctl: Add XEN_DOMCTL_gsi_permission to grant gsi

2024-06-07 Thread Jiqian Chen
om0 is not PV or dom0 has not PIRQ flag. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- RFC: it needs review and needs to wait for the corresponding third patch on linux kernel side to be merged. --- tools/include/xenctrl.h| 5 +++ tools/libs/ctrl/xc_domain.c|

[XEN PATCH v9 0/5] Support device passthrough when dom0 is PVH on Xen

2024-06-07 Thread Jiqian Chen
dd gsi_2_irq to transform gsi to irq, instead of considering gsi == irq. Add explicit padding to struct xen_domctl_gsi_permission. Best regards, Jiqian Chen v7->v8 changes: * patch#2: Add the domid check(domid == DOMID_SELF) to prevent self map when guest doesn't use pirq.

[XEN PATCH v9 2/5] x86/pvh: Allow (un)map_pirq when dom0 is PVH

2024-06-07 Thread Jiqian Chen
Q flag. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen Reviewed-by: Stefano Stabellini --- xen/arch/x86/hvm/hypercall.c | 6 ++ xen/arch/x86/physdev.c | 24 2 files changed, 30 insertions(+) diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hyper

[RFC XEN PATCH v9 4/5] tools: Add new function to get gsi from dev

2024-06-07 Thread Jiqian Chen
In PVH dom0, it uses the linux local interrupt mechanism, when it allocs irq for a gsi, it is dynamic, and follow the principle of applying first, distributing first. And irq number is alloced from small to large, but the applying gsi number is not, may gsi 38 comes before gsi 28, that causes the

[XEN PATCH v9 1/5] xen/vpci: Clear all vpci status of device

2024-06-07 Thread Jiqian Chen
can call this hypercall to notify vpci. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen Reviewed-by: Stewart Hildebrand Reviewed-by: Stefano Stabellini --- xen/arch/x86/hvm/hypercall.c | 1 + xen/drivers/pci/physdev.c| 43 xen/drivers/vpci/vpci.c

[XEN PATCH v9 3/5] x86/pvh: Add PHYSDEVOP_setup_gsi for PVH dom0

2024-06-07 Thread Jiqian Chen
purpose. Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- The code link that will call this hypercall on linux kernel side is as follows https://lore.kernel.org/lkml/20240607075109.126277-3-jiqian.c...@amd.com/T/#u --- xen/arch/x86/hvm/hypercall.c | 1 + 1 file changed, 1 insertion(+) diff