[PATCH v7] vpci: Add resizable bar support

2025-02-06 Thread Jiqian Chen
, add handlers for them to support resizing the size of BARs. Signed-off-by: Jiqian Chen --- Hi all, v6->v7 changes: * Deleted codes that add register for PCI_REBAR_CAP, and added comments to explain why. * Added comments to explain why use "continue" when fail to add register f

[PATCH v6] vpci: Add resizable bar support

2025-01-22 Thread Jiqian Chen
, add handlers for them to support resizing the size of BARs. Signed-off-by: Jiqian Chen --- Hi all, v5->v6 changes: * Changed "1UL" to "1ULL" in PCI_REBAR_CTRL_SIZE idefinition for 32 bit architecture. * In rebar_ctrl_write used "bar - pdev->vpci->header.bars&q

[PATCH v5] vpci: Add resizable bar support

2025-01-13 Thread Jiqian Chen
, add handlers for them to support resizing the size of BARs. Signed-off-by: Jiqian Chen --- Hi all, v4->v5 changes: * Called pci_size_mem_bar in rebar_ctrl_write to get addr and size of BAR instead of setting their values directly after writing new size to hardware. * Changed from &qu

[PATCH v4] vpci: Add resizable bar support

2024-12-18 Thread Jiqian Chen
, add handlers for them to support resizing the size of BARs. Signed-off-by: Jiqian Chen --- Hi all, v3->v4 changes: * Removed PCI_REBAR_CAP_SIZES since it was not needed, and added PCI_REBAR_CAP_SHIFT and PCI_REBAR_CTRL_SIZES. * Added parameter resizable_sizes to struct vpci_bar to cache the

[PATCH v3] vpci: Add resizable bar support

2024-12-12 Thread Jiqian Chen
, add handlers for them to support resizing the size of BARs. Signed-off-by: Jiqian Chen --- Hi all, v2->v3 changes: * Used "bar->enabled" to replace "pci_conf_read16(pdev->sbdf, PCI_COMMAND) & PCI_COMMAND_MEMORY", and added comments why it needs this check. * A

[PATCH v2 1/1] vpci: Add resizable bar support

2024-12-01 Thread Jiqian Chen
, add handlers for them to support resizing the size of BARs. Signed-off-by: Jiqian Chen --- Hi all, v2->v1 changes: *In rebar_ctrl_write, to check if memory decoding is enabled, and added some checks for the type of Bar. *Added vpci_hw_write32 to handle PCI_REBAR_CAP's write, since ther

[PATCH] vpci: Add resizable bar support

2024-11-13 Thread Jiqian Chen
o add these two registers and their corresponding handler into vpci. PCI_REBAR_CAP is RO, only provide reading. PCI_REBAR_CTRL only has bar size is RW, so add write function to support setting the new size. Signed-off-by: Jiqian Chen --- xen/drivers/vpci/Makefile | 2 +- xen/drivers/vpci/re

[QEMU PATCH v10] xen/passthrough: use gsi to map pirq when dom0 is PVH

2024-11-05 Thread Jiqian Chen
To solve above problem, use new interface of Xen, xc_pcidev_get_gsi to get gsi and use xc_physdev_map_pirq_gsi to map pirq when dom0 is PVH. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- Hi All, This is v10 to support passthrough on Xen when dom0 is PVH.

[QEMU PATCH v9] xen/passthrough: use gsi to map pirq when dom0 is PVH

2024-10-25 Thread Jiqian Chen
To solve above problem, use new interface of Xen, xc_pcidev_get_gsi to get gsi and use xc_physdev_map_pirq_gsi to map pirq when dom0 is PVH. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- Hi All, This is v9 to support passthrough on Xen when dom0 is PVH. v8-

[QEMU PATCH v8] xen/passthrough: use gsi to map pirq when dom0 is PVH

2024-10-15 Thread Jiqian Chen
To solve above problem, use new interface of Xen, xc_pcidev_get_gsi to get gsi and use xc_physdev_map_pirq_gsi to map pirq when dom0 is PVH. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- Hi All, This is v8 to support passthrough on Xen when dom0 is PVH. v7-

[PATCH v4] xen: Remove dependency between pciback and privcmd

2024-10-12 Thread Jiqian Chen
scall to get gsi from dev") Reported-by: Marek Marczykowski-Górecki Signed-off-by: Jiqian Chen --- v3->v4 changes: Added stubs for xen_acpi_register_get_gsi_func and xen_acpi_get_gsi_from_sbdf when "!CONFIG_XEN_DOM0" in acpi.h to fix 32-bit x86 build error. v2->v3 changes: Adde

[PATCH v3] xen: Remove dependency between pciback and privcmd

2024-10-10 Thread Jiqian Chen
scall to get gsi from dev") Reported-by: Marek Marczykowski-Górecki Signed-off-by: Jiqian Chen --- v2->v3 changes: Added rwlock get_gsi_from_sbdf_lock to avoid races. Called xen_acpi_register_get_gsi_func to register function in xen_pcibk_init and set NULL to hook in xen_pcibk_cleanup when unloa

[PATCH v2] xen: Remove dependency between pciback and privcmd

2024-10-10 Thread Jiqian Chen
to get gsi from dev") Reported-by: Marek Marczykowski-Górecki Signed-off-by: Jiqian Chen --- v1->v2 changes: Added hook xen_acpi_get_gsi_from_sbdf. Changed pcistub_get_gsi_from_sbdf to static and pciback register it as the real hook function. --- drivers/xen/Kconfig

[PATCH] xen: Remove config dependency in XEN_PRIVCMD definition

2024-10-08 Thread Jiqian Chen
ve problem and cover original commit's requirement, just remove that dependency, because the code "IS_REACHABLE(CONFIG_XEN_PCIDEV_BACKEND)" of original commit is enough to meet the requirement. Fixes: 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev") Signed-

[XEN PATCH v16 2/3] tools: Add new function to get gsi from dev

2024-09-29 Thread Jiqian Chen
hat is wrong, because irq is not equal with gsi, they are in different spaces, so pirq mapping fails. And in current codes, there is no method to get gsi for userspace. For above purpose, add new function to get gsi, and the corresponding ioctl is implemented on linux kernel side. Signed-off-by:

[XEN PATCH v16 1/3] x86/irq: allow setting IRQ permissions from GSI instead of pIRQ

2024-09-29 Thread Jiqian Chen
rupts in terms of pIRQs, introduce a new hypercall that allows setting interrupt permissions based on GSI value rather than pIRQ. Note the GSI hypercall parameters is translated to an IRQ value (in case there are ACPI overrides) before doing the checks. Signed-off-by: Jiqian Chen Signed-off-by:

[XEN PATCH v16 3/3] tools: Add new function to do PIRQ (un)map on PVH dom0

2024-09-29 Thread Jiqian Chen
TL_irq_permission requires passing in pirq, it is not suitable for PVH dom0 that doesn't have PIRQs to grant irq permission. To solve this issue, use the another hypercall XEN_DOMCTL_gsi_permission to grant the permission of irq( translate from gsi) to dumU when dom0 has no PIRQs. Signed-off

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

2024-09-29 Thread Jiqian Chen
Best regards, Jiqian Chen v14->v15 changes: Due to the patch#1 of v14 had been merged, so the sequence number of following patches are v14 decrese one. * patch#1: Change to use the commit message wrote by Roger. * patch#2: Change to use the commit message wrote by Roger. Change the c

[KERNEL PATCH v10 1/3] xen/pci: Add a function to reset device for xen

2024-09-23 Thread Jiqian Chen
ction 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: Jiqian Chen Signed-off-by: Huang Rui Signed

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

2024-09-23 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 assigning a device to passthrough, proactively setup the gsi of the device during that process. Signed-off-by: Jiqian Chen Signed-off-by: Huan

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

2024-09-23 Thread Jiqian Chen
et gsi when they have a need. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- v9->v10 changes: Changed the macro wrapping "pcistub_get_gsi_from_sbdf" from "CONFIG_XEN_PCIDEV_BACKEND" to "CONFIG_XEN_ACPI". Adde

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

2024-09-23 Thread Jiqian Chen
ot; to "CONFIG_XEN_ACPI". Added "imply CONFIG_XEN_PCIDEV_BACKEND" for CONFIG_XEN_PRIVCMD Kconfig definition. Added check "if (IS_REACHABLE(CONFIG_XEN_PCIDEV_BACKEND))" before calling pcistub_get_gsi_from_sbdf. Best regards, Jiqian Chen v8->

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

2024-09-12 Thread Jiqian Chen
et gsi when they have a need. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- v8->v9 changes: Changed the syscall name from "IOCTL_PRIVCMD_GSI_FROM_DEV" to "IOCTL_PRIVCMD_PCIDEV_GET_GSI". Also changed the other functions nam

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

2024-09-12 Thread Jiqian Chen
ed the other functions name. Changed the macro wrapping "pcistub_get_gsi_from_sbdf" from "CONFIG_XEN_ACPI" to "CONFIG_XEN_PCIDEV_BACKEND" to fix compile errors reported by CI robot. Changed the parameter gsi of struct privcmd_pcidev_get_gsi from int to u32.

[KERNEL PATCH v9 1/3] xen/pci: Add a function to reset device for xen

2024-09-12 Thread Jiqian Chen
ction 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: Jiqian Chen Signed-off-by: Huang Rui Signed

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

2024-09-12 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 assigning a device to passthrough, proactively setup the gsi of the device during that process. Signed-off-by: Jiqian Chen Signed-off-by: Huan

[RFC XEN PATCH v15 4/4] tools: Add new function to do PIRQ (un)map on PVH dom0

2024-09-11 Thread Jiqian Chen
TL_irq_permission requires passing in pirq, it is not suitable for PVH dom0 that doesn't have PIRQs to grant irq permission. To solve this issue, use the another hypercall XEN_DOMCTL_gsi_permission to grant the permission of irq( translate from gsi) to dumU when dom0 has no PIRQs. Signed-off

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

2024-09-11 Thread Jiqian Chen
hat is wrong, because irq is not equal with gsi, they are in different spaces, so pirq mapping fails. And in current codes, there is no method to get gsi for userspace. For above purpose, add new function to get gsi, and the corresponding ioctl is implemented on linux kernel side. Signed-off-by:

[XEN PATCH v15 1/4] x86/hvm: allow {,un}map_pirq hypercalls unconditionally

2024-09-11 Thread Jiqian Chen
vious callers are not hypercall but emulation based. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- v14->v15 changes: Change to use the commit message wrote by Roger. v13->v14 changes: Modified the commit message. v12->v13 changes: Removed the PHYSDEVO

[XEN PATCH v15 2/4] x86/irq: allow setting IRQ permissions from GSI instead of pIRQ

2024-09-11 Thread Jiqian Chen
rupts in terms of pIRQs, introduce a new hypercall that allows setting interrupt permissions based on GSI value rather than pIRQ. Note the GSI hypercall parameters is translated to an IRQ value (in case there are ACPI overrides) before doing the checks. Signed-off-by: Jiqian Chen Signed-off-by:

[XEN PATCH v15 0/4] Support device passthrough when dom0 is PVH on Xen

2024-09-11 Thread Jiqian Chen
c = libxl__arch_local_domain_has_pirq_notion(gc); if (!rc) {}" to "if (libxl__arch_local_domain_has_pirq_notion(gc) == false) {}" Modified some log prints codes. Best regards, Jiqian Chen v13->v14 changes: * patch#1: Removed the check ( !is_pci_passthrough

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

2024-09-03 Thread Jiqian Chen
ued by dom0. So, allow PHYSDEVOP_map_pirq when dom0 is PVH and also allow PHYSDEVOP_unmap_pirq for the removal device path to unmap pirq. Then the interrupt of a passthrough device can be successfully mapped to pirq for domU. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by:

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

2024-09-03 Thread Jiqian Chen
equal with gsi, they are in different spaces, so pirq mapping fails. And in current codes, there is no method to get gsi for userspace. For above purpose, add new function to get gsi, and the corresponding ioctl is implemented on linux kernel side. Signed-off-by: Jiqian Chen Signed-off-by: Hua

[XEN PATCH v14 1/5] xen/pci: Add hypercall to support reset of pcidev

2024-09-03 Thread Jiqian Chen
iqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- v13->v14 changes: Removed the check ( !is_pci_passthrough_enabled() ). Added if ( dev_reset.flags & ~PCI_DEVICE_RESET_MASK ) to check if the other bits are zero. v12->v13 changes: Deleted all "state" words in ne

[RFC XEN PATCH v14 5/5] tools: Add new function to do PIRQ (un)map on PVH dom0

2024-09-03 Thread Jiqian Chen
_to_irq. And old hypercall XEN_DOMCTL_irq_permission requires passing in pirq, it is not suitable for dom0 that doesn't have PIRQs to grant irq permission. To solve this issue, use the new hypercall XEN_DOMCTL_gsi_permission to grant the permission of irq( translate from gsi) to dumU when dom0 has no PIR

[XEN PATCH v14 3/5] x86/domctl: Add hypercall to set the access of x86 gsi

2024-09-03 Thread Jiqian Chen
gsi) to dumU when dom0 has no PIRQs. Regarding the translation from gsi to irq, it is that if there are ACPI overrides entries then get translation from them, if not gsi are identity mapped into irq. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- CC: Dani

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

2024-09-03 Thread Jiqian Chen
ese one. * patch#3~5: No changes. Best regards, Jiqian Chen v12->v13 changes: Due to major changes in the codes, all the Reviewed-by received before have been removed. Please review them again. * patch#1: Delete all "state" words in new code, because it is not necessary.

[RFC XEN PATCH v13 6/6] tools: Add new function to do PIRQ (un)map on PVH dom0

2024-08-16 Thread Jiqian Chen
_to_irq. And old hypercall XEN_DOMCTL_irq_permission requires passing in pirq, it is not suitable for dom0 that doesn't have PIRQs to grant irq permission. To solve this issue, use the new hypercall XEN_DOMCTL_gsi_permission to grant the permission of irq( translate from gsi) to dumU when dom0 has no PIR

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

2024-08-16 Thread Jiqian Chen
equal with gsi, they are in different spaces, so pirq mapping fails. And in current codes, there is no method to get gsi for userspace. For above purpose, add new function to get gsi, and the corresponding ioctl is implemented on linux kernel side. Signed-off-by: Jiqian Chen Signed-off-by: Hua

[XEN PATCH v13 1/6] xen/pci: Add hypercall to support reset of pcidev

2024-08-16 Thread Jiqian Chen
iqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- v12->v13 changes: Deleted all "state" words in new code, because it is not necessary. Deleted unnecessary parameter reset_type of function vpci_reset_device, and changed this function to inline function Added description

[XEN PATCH v13 4/6] x86/domctl: Add hypercall to set the access of x86 gsi

2024-08-16 Thread Jiqian Chen
gsi) to dumU when dom0 has no PIRQs. Regarding the translation from gsi to irq, it is that if there are ACPI overrides entries then get translation from them, if not gsi are identity mapped into irq. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- CC: Dani

[XEN PATCH v13 3/6] x86/pvh: Add PHYSDEVOP_setup_gsi for PVH dom0

2024-08-16 Thread Jiqian Chen
mp_register_gsi on Xen side is never called, then the gsi is not registered. Callstack is(on linux kernel side) pcistub_probe->pcistub_seize-> pcistub_init_device-> xen_pcibk_reset_device-> xen_pcibk_control_isr->isr_on==0. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-of

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

2024-08-16 Thread Jiqian Chen
ns. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- v12->v13 changes: Removed the PHYSDEVOP_(un)map_pirq restriction check for pvh domU and added a corresponding description in the commit message. v11->v12 changes: Avoid using return, set error code instea

[XEN PATCH v13 0/6] Support device passthrough when dom0 is PVH on Xen

2024-08-16 Thread Jiqian Chen
g "ctx", use the macro "CTX". Add the function libxl__arch_local_romain_ has_pirq_notion to determine if there is a concept of pirq in the domain where xl is located. In the function libxl__arch_hvm_unmap_gsi, before unmap_pirq, use map_pirq to

[RFC XEN PATCH v12 7/7] tools: Add new function to do PIRQ (un)map on PVH dom0

2024-07-08 Thread Jiqian Chen
si) to dumU when dom0 has no PIRQs. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Chen Jiqian --- RFC: it needs to wait for the corresponding third patch on linux kernel side to be merged. https://lore.kernel.org/xen-devel/20240607075109.126277-4-jiqian.c...@amd.com/ This

[RFC XEN PATCH v12 6/7] tools: Add new function to get gsi from dev

2024-07-08 Thread Jiqian Chen
equal with gsi, they are in different spaces, so pirq mapping fails. And in current codes, there is no method to get gsi for userspace. For above purpose, add new function to get gsi, and the corresponding ioctl is implemented on linux kernel side. Signed-off-by: Jiqian Chen Signed-off-by: Hua

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

2024-07-08 Thread Jiqian Chen
oesn't have a notion of PIRQ. So that the interrupt of a passthrough device can be successfully mapped to pirq for domU with a notion of PIRQ when dom0 is PVH Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- xen/arch/x86/hvm/hypercall.c | 6 ++ x

[XEN PATCH v12 1/7] xen/pci: Add hypercall to support reset of pcidev

2024-07-08 Thread Jiqian Chen
e the state of device is reset on dom0 side, dom0 can call this hypercall to notify hypervisor. Signed-off-by: Jiqian Chen 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/driver

[XEN PATCH v12 5/7] tools/libxc: Allow gsi be mapped into a free pirq

2024-07-08 Thread Jiqian Chen
r. Fourth, xen_pt_realize->xc_physdev_map_pirq, it wants to allocate a pirq for gsi, but it isn't necessary to get pirq whose value is equal with the value of gsi. After this patch, it will get a free pirq, and it also can work. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-

[XEN PATCH v12 3/7] x86/pvh: Add PHYSDEVOP_setup_gsi for PVH dom0

2024-07-08 Thread Jiqian Chen
mp_register_gsi on Xen side is never called, then the gsi is not registered. Callstack is(on linux kernel side) pcistub_probe->pcistub_seize-> pcistub_init_device-> xen_pcibk_reset_device-> xen_pcibk_control_isr->isr_on==0. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-of

[XEN PATCH v12 4/7] x86/domctl: Add hypercall to set the access of x86 gsi

2024-07-08 Thread Jiqian Chen
) to dumU when dom0 has no PIRQs. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- CC: Daniel P . Smith Remaining comment @Daniel P . Smith: +ret = -EPERM; +if ( !irq_access_permitted(currd, irq) || + xsm_irq_permission(XSM_HO

[XEN PATCH v12 0/7] Support device passthrough when dom0 is PVH on Xen

2024-07-08 Thread Jiqian Chen
<=0, and remove unnecessary space. Add #define XEN_DOMCTL_GSI_PERMISSION_MASK 1 to get lowest bit. * patch#5: Add explanation of whether the caller of xc_physdev_map_pirq is affected. Best regards, Jiqian Chen v10->v11 changes: * patch#1: Move the curly braces of "case PHYSD

[PATCH for-4.19 v2] x86/physdev: Return pirq that irq was already mapped to

2024-07-08 Thread Jiqian Chen
irq, so it fails. However, the logic before that re-factoring is different, it should return the current_pirq that irq was already mapped to and make the call success. Fixes: 0762e2502f1f ("x86/physdev: factor out the code to allocate and map a pirq") Signed-off-by: Jiqian Chen Signed-off

[PATCH for-4.19] x86/physdev: Return pirq that irq was already mapped to

2024-07-07 Thread Jiqian Chen
irq, so it fails. However, the logic before that re-factoring is different, it should return the current_pirq that irq was already mapped to and make the call success. Fixes: 0762e2502f1f ("x86/physdev: factor out the code to allocate and map a pirq") Signed-off-by: Jiqian Chen Signed-off-by

[XEN PATCH v11 6/8] tools/libxc: Allow gsi be mapped into a free pirq

2024-06-30 Thread Jiqian Chen
problems, one is caller can't get a free pirq value, another is that once the pecific pirq was already mapped to other gsi, then it will fail. So, change xc_physdev_map_pirq to allow to pass negative parameter in and then get a free pirq. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui

[RFC XEN PATCH v11 8/8] tools: Add new function to do PIRQ (un)map on PVH dom0

2024-06-30 Thread Jiqian Chen
si) to dumU when dom0 has no PIRQs. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Chen Jiqian --- RFC: it needs to wait for the corresponding third patch on linux kernel side to be merged. https://lore.kernel.org/xen-devel/20240607075109.126277-4-jiqian.c...@amd.com/ This

[XEN PATCH v11 0/8] Support device passthrough when dom0 is PVH on Xen

2024-06-30 Thread Jiqian Chen
Change the hard-coded 0 to use LIBXL_TOOLSTACK_DOMID. Add libxl__arch_hvm_map_gsi to distinguish x86 related implementations. Add a list pcidev_pirq_list to record the relationship between sbdf and pirq, which can be used to obtain the corresponding pirq when unmap PIRQ. Bes

[XEN PATCH v11 3/8] x86/pvh: Add PHYSDEVOP_setup_gsi for PVH dom0

2024-06-30 Thread Jiqian Chen
c_hwdom_map_gsi-> mp_register_gsi will be called only when the gsi is unmasked, so that the gsi can't work for passthrough device. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- xen/arch/x86/hvm/hypercall.c | 1 + 1 file changed, 1 insertion(+) diff --g

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

2024-06-30 Thread Jiqian Chen
has no X86_EMU_USE_PIRQ flag. So that the interrupt of a passthrough device can be successfully mapped to pirq for domU with X86_EMU_USE_PIRQ flag when dom0 is PVH Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen Reviewed-by: Stefano Stabellini --- xen/arch/x

[RFC XEN PATCH v11 7/8] tools: Add new function to get gsi from dev

2024-06-30 Thread Jiqian Chen
equal with gsi, they are in different spaces, so pirq mapping fails. And in current codes, there is no method to get gsi for userspace. For above purpose, add new function to get gsi, and the corresponding ioctl is implemented on linux kernel side. Signed-off-by: Jiqian Chen Signed-off-by: Hua

[XEN PATCH v11 5/8] x86/domctl: Add XEN_DOMCTL_gsi_permission to grant gsi

2024-06-30 Thread Jiqian Chen
Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- xen/arch/x86/domctl.c | 33 ++ xen/arch/x86/include/asm/io_apic.h | 2 ++ xen/arch/x86/io_apic.c | 17 +++ xen/arch/x86/mpparse.c | 3

[XEN PATCH v11 4/8] x86/physdev: Return pirq that irq was already mapped to

2024-06-30 Thread Jiqian Chen
the allocation is successful. That can help caller to success when caller just want to allocate a free pirq but doesn't know if the irq already has a mapped pirq or not. Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen --- xen/arch/x86/irq.c | 2 ++ 1 file ch

[XEN PATCH v11 1/8] xen/vpci: Clear all vpci status of device

2024-06-30 Thread Jiqian Chen
dom0 can call this hypercall to notify vpci. Signed-off-by: Jiqian Chen 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

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

2024-06-17 Thread Jiqian Chen
hod to get gsi for userspace. For above purpose, add new function to get gsi. And call this function before xc_physdev_(un)map_pirq Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Chen Jiqian --- RFC: it needs review and needs to wait for the corresponding third patch on li

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

2024-06-17 Thread Jiqian Chen
Signed-off-by: Jiqian Chen 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| 15 +++ tools

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

2024-06-17 Thread Jiqian Chen
e upper and lower lines of the struct xen_domctl_gsi_permission definition. All patches have modified signatures as follows: Signed-off-by: Jiqian Chen means I am the author. Signed-off-by: Huang Rui means Rui sent them to upstream firstly. Signed-off-by: Jiqian Chen means I take con

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

2024-06-17 Thread Jiqian Chen
g. So that domU with PIRQ flag can success to map pirq for passthrough devices even dom0 has no PIRQ flag. Signed-off-by: Jiqian Chen 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

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

2024-06-17 Thread Jiqian Chen
evice, setting ioapic affinity and vector will fail. To fix above problem, on Linux kernel side, a new code will need to call PHYSDEVOP_setup_gsi for passthrough devices to register gsi when dom0 is PVH. So, add PHYSDEVOP_setup_gsi into hvm_physdev_op for above purpose. Signed-off-by: Jiqian

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

2024-06-17 Thread Jiqian Chen
dom0 can call this hypercall to notify vpci. Signed-off-by: Jiqian Chen 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

[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 i

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

2024-06-07 Thread Jiqian Chen
n dom0 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.

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

2024-06-07 Thread Jiqian Chen
above 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(+)

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

2024-06-07 Thread Jiqian Chen
dom0 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/v

[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

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

2024-06-07 Thread Jiqian Chen
i 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 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 1/3] xen/pci: Add xen_reset_device_function_state

2024-06-07 Thread Jiqian Chen
ction 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 Revie

[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 100644 --

[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 XEN PATCH v8 5/5] domctl: Add XEN_DOMCTL_gsi_permission to grant gsi

2024-05-16 Thread Jiqian Chen
gned-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 ++

[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 i

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

2024-05-16 Thread Jiqian Chen
dom0 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/v

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

2024-05-16 Thread Jiqian Chen
above 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 +++

[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

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

2024-05-16 Thread Jiqian Chen
n. That 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 u

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

2024-05-14 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 2/2] xen/privcmd: Add new syscall to get gsi from dev

2024-05-14 Thread Jiqian Chen
i 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 ++ dr

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

2024-05-14 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

[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 rev

[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 5/5] domctl: Add XEN_DOMCTL_gsi_permission to grant gsi

2024-04-18 Thread Jiqian Chen
gned-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/

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

2024-04-18 Thread Jiqian Chen
above 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 +++

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

2024-04-18 Thread Jiqian Chen
dom0 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/v

[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 i

[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(!

[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 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 Revie

[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

  1   2   >