On 03.09.2024 09:04, Jiqian Chen wrote: > When dom0 is PVH type and passthrough a device to HVM domU, Qemu code > xen_pt_realize->xc_physdev_map_pirq and libxl code pci_add_dm_done-> > xc_physdev_map_pirq map a pirq for passthrough devices. > In xc_physdev_map_pirq call stack, function hvm_physdev_op has a check > has_pirq(currd), but currd is PVH dom0, PVH has no X86_EMU_USE_PIRQ flag, > so it fails, PHYSDEVOP_map_pirq is not allowed for PVH dom0 in current > codes. > > But it is fine to map interrupts through pirq to a HVM domain whose > XENFEAT_hvm_pirqs is not enabled. Because pirq field is used as a way to > reference interrupts and it is just the way for the device model to > identify which interrupt should be mapped to which domain, however > has_pirq() is just to check if HVM domains route interrupts from > devices(emulated or passthrough) through event channel, so, the has_pirq() > check should not be applied to the PHYSDEVOP_map_pirq issued 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.
As before: When you talk about just Dom0, ... > --- a/xen/arch/x86/hvm/hypercall.c > +++ b/xen/arch/x86/hvm/hypercall.c > @@ -73,6 +73,8 @@ long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) > arg) > { > case PHYSDEVOP_map_pirq: > case PHYSDEVOP_unmap_pirq: > + break; > + > case PHYSDEVOP_eoi: > case PHYSDEVOP_irq_status_query: > case PHYSDEVOP_get_free_pirq: ... that ought to match the code. IOW you've again lost why it is okay(ish) (or even necessary) to also permit the op for non-Dom0 (e.g. a PVH stubdom). Similarly imo Dom0 using this on itself wants discussing. As to my earlier comments regarding your commit message adjustments: I forgot that the change had to be reverted. I'm sorry for that. Jan