x86 passthrough code cleanup
cover x86 passthrough code cleanup
Hi all
At some point I would like to make CONFIG_HVM and CONFIG_PV work. The passthrough code is one of the road blocks for that work.
A short discussion on #xendevel made me think that having host side code regardless of if HVM (the primary user) is configured is desirable because PV guests may still have limited use of the hardware, hence this series.
What I want is to have clear hierarchy of the code and split the host side and the guest side code, and start to use CONFIG_HVM where applicable. Luckily the amount of work seemed to be smaller than I had expected.
RFC because there are a few open questions. Please see individual patches.
Wei.
Wei Liu (10):
passthrough: rearrange x86 code
passthrough: split out x86 PCI code to x86/pci.c x86/passthrough: io.c is used for HVM only x86/passthrough: arch_pci_clean_irqs is HVM only x86/passthrough: move hvm_dpci_isairq_eoi passthrough/amd: remove guest iommu support passthrough/amd: split out hvm code from iommu_map.c passthrough/amd: make clear_iommu_pte_present static passthrough/intel: put some code under CONFIG_HVM
x86: check hvm domain before calling pt_irq_destroy_bind
MAINTAINERS | 8 +-
xen/arch/x86/domctl.c | 4 +
xen/drivers/passthrough/Makefile | 3 -
xen/drivers/passthrough/amd/iommu_guest.c | 927 ---------------------
xen/drivers/passthrough/pci.c | 51 +-
xen/drivers/passthrough/x86/Makefile | 5 +
xen/drivers/passthrough/{ => x86}/amd/Makefile | 2 +-
xen/drivers/passthrough/x86/amd/hvm.c | 108 +++
xen/drivers/passthrough/x86/amd/iommu.h | 32 +
xen/drivers/passthrough/{ => x86}/amd/iommu_acpi.c | 0
xen/drivers/passthrough/{ => x86}/amd/iommu_cmd.c | 2 +-
.../passthrough/{ => x86}/amd/iommu_detect.c | 0
xen/drivers/passthrough/{ => x86}/amd/iommu_init.c | 21 +-
xen/drivers/passthrough/{ => x86}/amd/iommu_intr.c | 0
xen/drivers/passthrough/{ => x86}/amd/iommu_map.c | 107 +--
.../passthrough/{ => x86}/amd/pci_amd_iommu.c | 2 +-
xen/drivers/passthrough/{ => x86}/io.c | 45 +
xen/drivers/passthrough/x86/pci.c | 74 ++
xen/drivers/passthrough/{ => x86}/vtd/Makefile | 0
xen/drivers/passthrough/{ => x86}/vtd/dmar.c | 0
xen/drivers/passthrough/{ => x86}/vtd/dmar.h | 0
xen/drivers/passthrough/{ => x86}/vtd/extern.h | 0
xen/drivers/passthrough/{ => x86}/vtd/intremap.c | 0
xen/drivers/passthrough/{ => x86}/vtd/iommu.c | 17 +-
xen/drivers/passthrough/{ => x86}/vtd/iommu.h | 0
xen/drivers/passthrough/{ => x86}/vtd/qinval.c | 2 +-
xen/drivers/passthrough/{ => x86}/vtd/quirks.c | 0
xen/drivers/passthrough/{ => x86}/vtd/utils.c | 0
xen/drivers/passthrough/{ => x86}/vtd/vtd.h | 0
xen/drivers/passthrough/{ => x86}/vtd/x86/Makefile | 0
xen/drivers/passthrough/{ => x86}/vtd/x86/ats.c | 2 +-
xen/drivers/passthrough/{ => x86}/vtd/x86/vtd.c | 45 -
xen/include/asm-x86/amd-iommu.h | 51 --
xen/include/asm-x86/hvm/svm/amd-iommu-proto.h | 8 -
xen/include/asm-x86/iommu.h | 1 -
xen/include/xen/iommu.h | 1 -
xen/include/xen/pci.h | 2 +
37 files changed, 310 insertions(+), 1210 deletions(-)
delete mode 100644 xen/drivers/passthrough/amd/iommu_guest.c
rename xen/drivers/passthrough/{ => x86}/amd/Makefile (86%)
create mode 100644 xen/drivers/passthrough/x86/amd/hvm.c
create mode 100644 xen/drivers/passthrough/x86/amd/iommu.h
rename xen/drivers/passthrough/{ => x86}/amd/iommu_acpi.c (100%)
rename xen/drivers/passthrough/{ => x86}/amd/iommu_cmd.c (99%)
rename xen/drivers/passthrough/{ => x86}/amd/iommu_detect.c (100%)
rename xen/drivers/passthrough/{ => x86}/amd/iommu_init.c (99%)
rename xen/drivers/passthrough/{ => x86}/amd/iommu_intr.c (100%)
rename xen/drivers/passthrough/{ => x86}/amd/iommu_map.c (86%)
rename xen/drivers/passthrough/{ => x86}/amd/pci_amd_iommu.c (99%)
rename xen/drivers/passthrough/{ => x86}/io.c (96%)
create mode 100644 xen/drivers/passthrough/x86/pci.c
rename xen/drivers/passthrough/{ => x86}/vtd/Makefile (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/dmar.c (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/dmar.h (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/extern.h (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/intremap.c (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/iommu.c (99%)
rename xen/drivers/passthrough/{ => x86}/vtd/iommu.h (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/qinval.c (99%)
rename xen/drivers/passthrough/{ => x86}/vtd/quirks.c (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/utils.c (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/vtd.h (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/x86/Makefile (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/x86/ats.c (99%)
rename xen/drivers/passthrough/{ => x86}/vtd/x86/vtd.c (72%)Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 1/10 passthrough: rearrange x86 code
Clean up the hierarchy of the directory: put vtd, amd and io.c under x86. Adjust makefile and MAINTAINERS.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Suravee Suthikulpanit <[email protected]>
Cc: Kevin Tian <[email protected]>
---
MAINTAINERS | 8 ++++----
xen/drivers/passthrough/Makefile | 3 ---
xen/drivers/passthrough/x86/Makefile | 4 ++++
xen/drivers/passthrough/{ => x86}/amd/Makefile | 0
xen/drivers/passthrough/{ => x86}/amd/iommu_acpi.c | 0
xen/drivers/passthrough/{ => x86}/amd/iommu_cmd.c | 2 +-
xen/drivers/passthrough/{ => x86}/amd/iommu_detect.c | 0
xen/drivers/passthrough/{ => x86}/amd/iommu_guest.c | 0
xen/drivers/passthrough/{ => x86}/amd/iommu_init.c | 0
xen/drivers/passthrough/{ => x86}/amd/iommu_intr.c | 0
xen/drivers/passthrough/{ => x86}/amd/iommu_map.c | 2 +-
xen/drivers/passthrough/{ => x86}/amd/pci_amd_iommu.c | 2 +-
xen/drivers/passthrough/{ => x86}/io.c | 0
xen/drivers/passthrough/{ => x86}/vtd/Makefile | 0
xen/drivers/passthrough/{ => x86}/vtd/dmar.c | 0
xen/drivers/passthrough/{ => x86}/vtd/dmar.h | 0
xen/drivers/passthrough/{ => x86}/vtd/extern.h | 0
xen/drivers/passthrough/{ => x86}/vtd/intremap.c | 0
xen/drivers/passthrough/{ => x86}/vtd/iommu.c | 2 +-
xen/drivers/passthrough/{ => x86}/vtd/iommu.h | 0
xen/drivers/passthrough/{ => x86}/vtd/qinval.c | 2 +-
xen/drivers/passthrough/{ => x86}/vtd/quirks.c | 0
xen/drivers/passthrough/{ => x86}/vtd/utils.c | 0
xen/drivers/passthrough/{ => x86}/vtd/vtd.h | 0
xen/drivers/passthrough/{ => x86}/vtd/x86/Makefile | 0
xen/drivers/passthrough/{ => x86}/vtd/x86/ats.c | 2 +-
xen/drivers/passthrough/{ => x86}/vtd/x86/vtd.c | 0
27 files changed, 14 insertions(+), 13 deletions(-)
rename xen/drivers/passthrough/{ => x86}/amd/Makefile (100%)
rename xen/drivers/passthrough/{ => x86}/amd/iommu_acpi.c (100%)
rename xen/drivers/passthrough/{ => x86}/amd/iommu_cmd.c (99%)
rename xen/drivers/passthrough/{ => x86}/amd/iommu_detect.c (100%)
rename xen/drivers/passthrough/{ => x86}/amd/iommu_guest.c (100%)
rename xen/drivers/passthrough/{ => x86}/amd/iommu_init.c (100%)
rename xen/drivers/passthrough/{ => x86}/amd/iommu_intr.c (100%)
rename xen/drivers/passthrough/{ => x86}/amd/iommu_map.c (99%)
rename xen/drivers/passthrough/{ => x86}/amd/pci_amd_iommu.c (99%)
rename xen/drivers/passthrough/{ => x86}/io.c (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/Makefile (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/dmar.c (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/dmar.h (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/extern.h (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/intremap.c (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/iommu.c (99%)
rename xen/drivers/passthrough/{ => x86}/vtd/iommu.h (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/qinval.c (99%)
rename xen/drivers/passthrough/{ => x86}/vtd/quirks.c (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/utils.c (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/vtd.h (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/x86/Makefile (100%)
rename xen/drivers/passthrough/{ => x86}/vtd/x86/ats.c (99%)
rename xen/drivers/passthrough/{ => x86}/vtd/x86/vtd.c (100%)MAINTAINERS +4 -4
@@ -143,7 +143,7 @@ F: tools/libacpi/ AMD IOMMU M: Suravee Suthikulpanit <[email protected]> S: Maintained -F: xen/drivers/passthrough/amd/ +F: xen/drivers/passthrough/x86/amd/ AMD SVM M: Boris Ostrovsky <[email protected]>
@@ -222,7 +222,7 @@ F: xen/include/asm-x86/tboot.h INTEL(R) VT FOR DIRECTED I/O (VT-D) M: Kevin Tian <[email protected]> S: Supported -F: xen/drivers/passthrough/vtd/ +F: xen/drivers/passthrough/x86/vtd/ INTEL(R) VT FOR X86 (VT-X) M: Jun Nakajima <[email protected]>
@@ -237,10 +237,10 @@ IOMMU VENDOR INDEPENDENT CODE M: Jan Beulich <[email protected]> S: Supported F: xen/drivers/passthrough/ -X: xen/drivers/passthrough/amd/ X: xen/drivers/passthrough/arm/ -X: xen/drivers/passthrough/vtd/ X: xen/drivers/passthrough/device_tree.c +X: xen/drivers/passthrough/x86/amd/ +X: xen/drivers/passthrough/x86/vtd/ F: xen/include/xen/iommu.h KCONFIG
xen/drivers/passthrough/Makefile +0 -3
@@ -1,9 +1,6 @@ -subdir-$(CONFIG_X86) += vtd -subdir-$(CONFIG_X86) += amd subdir-$(CONFIG_X86) += x86 subdir-$(CONFIG_ARM) += arm obj-y += iommu.o -obj-$(CONFIG_X86) += io.o obj-$(CONFIG_HAS_PCI) += pci.o obj-$(CONFIG_HAS_DEVICE_TREE) += device_tree.o
xen/drivers/passthrough/x86/Makefile +4 -0
@@ -1,2 +1,6 @@ +subdir-y += vtd +subdir-y += amd + obj-y += ats.o +obj-y += io.o obj-y += iommu.o
xen/drivers/passthrough/x86/amd/Makefile renamed from xen/drivers/passthrough/amd/Makefile +0 -0
xen/drivers/passthrough/x86/amd/iommu_acpi.c renamed from xen/drivers/passthrough/amd/iommu_acpi.c +0 -0
xen/drivers/passthrough/x86/amd/iommu_cmd.c renamed from xen/drivers/passthrough/amd/iommu_cmd.c +1 -1
@@ -20,7 +20,7 @@#include <xen/sched.h> #include <asm/amd-iommu.h> #include <asm/hvm/svm/amd-iommu-proto.h> -#include "../ats.h" +#include "../../ats.h" static int queue_iommu_command (struct amd_iommu *iommu,u32 cmd[]) {
xen/drivers/passthrough/x86/amd/iommu_detect.c renamed from xen/drivers/passthrough/amd/iommu_detect.c +0 -0
xen/drivers/passthrough/x86/amd/iommu_guest.c renamed from xen/drivers/passthrough/amd/iommu_guest.c +0 -0
xen/drivers/passthrough/x86/amd/iommu_init.c renamed from xen/drivers/passthrough/amd/iommu_init.c +0 -0
xen/drivers/passthrough/x86/amd/iommu_intr.c renamed from xen/drivers/passthrough/amd/iommu_intr.c +0 -0
xen/drivers/passthrough/x86/amd/iommu_map.c renamed from xen/drivers/passthrough/amd/iommu_map.c +1 -1
@@ -22,7 +22,7 @@#include <asm/p2m.h> #include <asm/amd-iommu.h> #include <asm/hvm/svm/amd-iommu-proto.h> -#include "../ats.h" +#include "../../ats.h" #include <xen/pci.h> /* Given pfn and page table level, return pde index */
xen/drivers/passthrough/x86/amd/pci_amd_iommu.c renamed from xen/drivers/passthrough/amd/pci_amd_iommu.c +1 -1
@@ -25,7 +25,7 @@#include <xen/softirq.h> #include <asm/amd-iommu.h> #include <asm/hvm/svm/amd-iommu-proto.h> -#include "../ats.h" +#include "../../ats.h" static bool_t __read_mostly init_done;
xen/drivers/passthrough/x86/io.c renamed from xen/drivers/passthrough/io.c +0 -0
xen/drivers/passthrough/x86/vtd/Makefile renamed from xen/drivers/passthrough/vtd/Makefile +0 -0
xen/drivers/passthrough/x86/vtd/dmar.c renamed from xen/drivers/passthrough/vtd/dmar.c +0 -0
xen/drivers/passthrough/x86/vtd/dmar.h renamed from xen/drivers/passthrough/vtd/dmar.h +0 -0
xen/drivers/passthrough/x86/vtd/extern.h renamed from xen/drivers/passthrough/vtd/extern.h +0 -0
xen/drivers/passthrough/x86/vtd/intremap.c renamed from xen/drivers/passthrough/vtd/intremap.c +0 -0
xen/drivers/passthrough/x86/vtd/iommu.c renamed from xen/drivers/passthrough/vtd/iommu.c +1 -1
@@ -39,7 +39,7 @@#include "dmar.h" #include "extern.h" #include "vtd.h" -#include "../ats.h" +#include "../../ats.h" struct mapped_rmrr {struct list_head list;
xen/drivers/passthrough/x86/vtd/iommu.h renamed from xen/drivers/passthrough/vtd/iommu.h +0 -0
xen/drivers/passthrough/x86/vtd/qinval.c renamed from xen/drivers/passthrough/vtd/qinval.c +1 -1
@@ -27,7 +27,7 @@#include "dmar.h" #include "vtd.h" #include "extern.h" -#include "../ats.h" +#include "../../ats.h" #define VTD_QI_TIMEOUT 1
xen/drivers/passthrough/x86/vtd/quirks.c renamed from xen/drivers/passthrough/vtd/quirks.c +0 -0
xen/drivers/passthrough/x86/vtd/utils.c renamed from xen/drivers/passthrough/vtd/utils.c +0 -0
xen/drivers/passthrough/x86/vtd/vtd.h renamed from xen/drivers/passthrough/vtd/vtd.h +0 -0
xen/drivers/passthrough/x86/vtd/x86/Makefile renamed from xen/drivers/passthrough/vtd/x86/Makefile +0 -0
xen/drivers/passthrough/x86/vtd/x86/ats.c renamed from xen/drivers/passthrough/vtd/x86/ats.c +1 -1
@@ -26,7 +26,7 @@#include "../dmar.h" #include "../vtd.h" #include "../extern.h" -#include "../../ats.h" +#include "../../../ats.h" static LIST_HEAD (ats_dev_drhd_units);
xen/drivers/passthrough/x86/vtd/x86/vtd.c renamed from xen/drivers/passthrough/vtd/x86/vtd.c +0 -0
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH RFC 01/10] passthrough: rearrange x86 code
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 21.02.18 at 22:46, <[email protected]> wrote:
Clean up the hierarchy of the directory: put vtd, amd and
io.cunder x86. Adjust makefile andMAINTAINERS.
Considering the history in particular of VT-d, I'm not convinced of this move:
x86 and ia64 did share the bulk of the VT-d code back when ia64 was still in the tree. Arguably the AMD IOMMU is less likely to be leveraged for some non-x86 architecture, but I think it would better stay the way it is as well.
As to io.c - it's not currently needed by ARM, but there doesn't look to be that many x86-specific code in there. I would prefer if the ARM folks could judge whether that's code they're never going to use, in which case moving it to x86/ would be fine with me.
What I don't understand here at all is how this movement of code relates to the PV/HVM splitting.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 2/10 passthrough: split out x86 PCI code to x86/pci.c
In reply to Wei LiuMove the functions that reference x86 hvm data structures to its own file. Rename pci_clean_dpci_irqs to arch_pci_clean_irqs.
There is still one location in that file which references arch.hvm_domain, but it is fine because ARM guest is HVM.
---
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
ARM doesn't select HAS_PCI, that's why ARM build is not broken by this. AIUI ARM will select HAS_PCI at some point, hence I only move the x86 bits.
--- xen/drivers/passthrough/pci.c | 51 +---------------------------- xen/drivers/passthrough/x86/Makefile | 1 + xen/drivers/passthrough/x86/pci.c | 62 ++++++++++++++++++++++++++++++++++++ xen/include/xen/pci.h | 2 ++ 4 files changed, 66 insertions(+), 50 deletions(-) create mode 100644 xen/drivers/passthrough/x86/pci.c
xen/drivers/passthrough/pci.c +1 -50
@@ -22,7 +22,6 @@#include <xen/iommu.h> #include <xen/irq.h> #include <xen/vm_event.h> -#include <asm/hvm/irq.h> #include <xen/delay.h> #include <xen/keyhandler.h> #include <xen/event.h>
@@ -798,54 +797,6 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn)return ret; } -static int pci_clean_dpci_irq (struct domain *d, -struct hvm_pirq_dpci *pirq_dpci,void *arg) -{ -struct dev_intx_gsi_link *digl, *tmp; - -pirq_guest_unbind (d,dpci_pirq (pirq_dpci)); - -if (pt_irq_need_timer (pirq_dpci->flags) ) -kill_timer (&pirq_dpci->timer); - - list_for_each_entry_safe ( digl, tmp, &pirq_dpci->digl_list, list ) - { -list_del (&digl->list); -xfree (digl); - } - -return pt_pirq_softirq_active (pirq_dpci) ? -ERESTART :0 ; -} - -static int pci_clean_dpci_irqs (struct domain *d) -{ -struct hvm_irq_dpci *hvm_irq_dpci =NULL ; - -if ( !iommu_enabled ) -return 0 ; - -if ( !is_hvm_domain (d) ) -return 0 ; - -spin_lock (&d->event_lock); - hvm_irq_dpci =domain_get_irq_dpci (d); -if ( hvm_irq_dpci !=NULL ) - { -int ret =pt_pirq_iterate (d, pci_clean_dpci_irq,NULL ); - -if ( ret ) - { -spin_unlock (&d->event_lock); -return ret; - } - -hvm_domain_irq (d)->dpci =NULL ; -free_hvm_irq_dpci (hvm_irq_dpci); - } -spin_unlock (&d->event_lock); -return 0 ; -} -int pci_release_devices (struct domain *d) {struct pci_dev *pdev;
@@ -853,7 +804,7 @@ int pci_release_devices(struct domain *d)int ret;pcidevs_lock (); - ret =pci_clean_dpci_irqs (d); + ret =arch_pci_clean_irqs (d);if ( ret ) {pcidevs_unlock ();
xen/drivers/passthrough/x86/Makefile +1 -0
@@ -4,3 +4,4 @@ subdir-y += amd obj-y += ats.o obj-y += io.o obj-y += iommu.o +obj-y += pci.o
xen/drivers/passthrough/x86/pci.c new file +62 -0
62 lines not on this page · raw message
xen/include/xen/pci.h +2 -0
@@ -153,6 +153,8 @@ struct pci_dev *pci_get_pdev_by_domain(const struct domain *, int seg, int bus, int devfn);void pci_check_disable_device (u16 seg,u8 bus,u8 devfn); +int arch_pci_clean_irqs (struct domain *d); +uint8_t pci_conf_read8 (unsigned int seg,unsigned int bus,unsigned int dev,unsigned int func,unsigned int reg);
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH RFC 02/10] passthrough: split out x86 PCI code to x86/pci.c
Hi,
Quoted 2 lines · Wei Liu
Move the functions that reference x86 hvm data structures to its own file. Rename
pci_clean_dpci_irqstoarch_pci_clean_irqs.
NIT: Double space.
Quoted 3 lines
There is still one location in that file which references arch.hvm_domain, but it is fine because ARM guest is HVM.
I guess you mean hvm_domain.mem_sharing_enabled? If so, we don't support memory sharing on ARM. This would need to be stub.
Quoted 11 lines
Signed-off-by Wei Liu <[email protected]>---
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>ARM doesn't select
HAS_PCI, that's why ARM build is not broken by this. AIUI ARM will selectHAS_PCIat some point, hence I only move the x86 bits.
Potentially there are more x86-ism in that code such as the way to handle MSI. Anyway, this patch makes sense from an Arm perspective:
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH RFC 02/10] passthrough: split out x86 PCI code to x86/pci.c
In reply to Wei LiuQuoted 14 lines
Quoted 1 line
Quoted 1 line · On 21.02.18 at 22:46, <[email protected]> wrote:
Move the functions that reference x86 hvm data structures to its own file. Rename
pci_clean_dpci_irqstoarch_pci_clean_irqs.There is still one location in that file which references arch.hvm_domain, but it is fine because ARM guest is HVM.
Signed-off-by Wei Liu <[email protected]>---
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Quoted 3 lines
ARM doesn't select
HAS_PCI, that's why ARM build is not broken by this. AIUI ARM will selectHAS_PCIat some point, hence I only move the x86 bits.
The fact that this change doesn't actually affect ARM is again an indication that the decision whether the code you move here is x86-specific depends on what parts of PCI pass-through ARM is actually going to want to (re-)use. I'd again prefer to take that decision either when ARM actually implements that, or based on the ARM folks clearly foreseeing that this code is not coming close to anything they may want use.
xen/drivers/passthrough/pci.c int pci_release_devices(struct domain *d) · line 807
Quoted 6 lines
xen/drivers/passthrough/pci.c +1
-1@@ -853,7 +804,7 @@ int pci_release_devices(struct domain *d)int ret;pcidevs_lock (); - ret =pci_clean_dpci_irqs (d); + ret =arch_pci_clean_irqs (d);
One note regarding the naming: I'd prefer if "dpci" remained part of the name, unless you mean to get rid of it altogether from the code base. That'll help (a little) with visually separating code pieces belonging to the host side of PCI from those belonging to the passed through side of it (granted - they aren't entirely independent anyway).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH RFC 02/10] passthrough: split out x86 PCI code to x86/pci.c
Hi,
Quoted 18 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 21.02.18 at 22:46, <[email protected]> wrote:
Move the functions that reference x86 hvm data structures to its own file. Rename
pci_clean_dpci_irqstoarch_pci_clean_irqs.There is still one location in that file which references arch.hvm_domain, but it is fine because ARM guest is HVM.
Signed-off-by Wei Liu <[email protected]>---
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>Quoted 3 lines
ARM doesn't select
HAS_PCI, that's why ARM build is not broken by this. AIUI ARM will selectHAS_PCIat some point, hence I only move the x86 bits.
Quoted 7 lines
The fact that this change doesn't actually affect ARM is again an indication that the decision whether the code you move here is x86-specific depends on what parts of PCI pass-through ARM is actually going to want to (re-)use. I'd again prefer to take that decision either when ARM actually implements that, or based on the ARM folks clearly foreseeing that this code is not coming close to anything they may want use.
I can't see any use of that code on Arm. There are potential to move x86-ism outside, but this patch is already a good start.
I already gave my acked-by on a separate e-mail.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 3/10 x86/passthrough: io.c is used for HVM only
In reply to Wei Liu---
This file has a few functions that are called in other places. We need to provide stubs for them at some point. Currently the declarations are in different places. What is the preferred name / location for the stubs?
--- xen/drivers/passthrough/x86/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/x86/Makefile +1 -1
@@ -2,6 +2,6 @@ subdir-y += vtd subdir-y += amd obj-y += ats.o -obj-y += io.o +obj-$(CONFIG_HVM) += io.o obj-y += iommu.o obj-y += pci.o
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH RFC 03/10] x86/passthrough: io.c is used for HVM only
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 21.02.18 at 22:46, <[email protected]> wrote:
Signed-off-by Wei Liu <[email protected]>---
This file has a few functions that are called in other places. We need to provide stubs for them at some point. Currently the declarations are in different places. What is the preferred name / location for the stubs?
Perhaps dpci.h, and maybe this file should also be named dpci.c? I've never understood on what grounds its current name was chosen.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 4/10 x86/passthrough: arch_pci_clean_irqs is HVM only
In reply to Wei LiuProvide a !CONFIG_HVM stub in preparation for future usage.
--- xen/drivers/passthrough/x86/pci.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
xen/drivers/passthrough/x86/pci.c +12 -0
@@ -4,6 +4,8 @@#include <asm/hvm/irq.h> +#ifdef CONFIG_HVM +static int pci_clean_dpci_irq (struct domain *d,struct hvm_pirq_dpci *pirq_dpci,void *arg) {
@@ -52,6 +54,16 @@ int arch_pci_clean_irqs(struct domain *d) return 0; } +#else + +int arch_pci_clean_irqs (struct domain *d) +{ +ASSERT (!is_hvm_domain (d)); +return 0 ; +} + +#endif +/* * Local variables: * mode: C
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 5/10 x86/passthrough: move hvm_dpci_isairq_eoi
In reply to Wei LiuThis function is not Intel specific. Move it to io.c along side its sole user. Remove declaration in iommu.h.
---
Cc: Kevin Tian <[email protected]>
--- xen/drivers/passthrough/x86/io.c | 45 +++++++++++++++++++++++++++++++ xen/drivers/passthrough/x86/vtd/x86/vtd.c | 45 ------------------------------- xen/include/xen/iommu.h | 1 - 3 files changed, 45 insertions(+), 46 deletions(-)
xen/drivers/passthrough/x86/io.c +45 -0
@@ -51,6 +51,51 @@ enum {STATE_RUN }; +static int _hvm_dpci_isairq_eoi (struct domain *d, +struct hvm_pirq_dpci *pirq_dpci,void *arg) +{ +struct hvm_irq *hvm_irq =hvm_domain_irq (d); +unsigned int isairq = (long )arg; +const struct dev_intx_gsi_link *digl; + + list_for_each_entry ( digl, &pirq_dpci->digl_list, list ) + { +unsigned int link =hvm_pci_intx_link (digl->device, digl->intx); + +if ( hvm_irq->pci_link.route[link] == isairq ) + { +hvm_pci_intx_deassert (d, digl->device, digl->intx); +if ( --pirq_dpci->pending ==0 ) + { +stop_timer (&pirq_dpci->timer); +pirq_guest_eoi (dpci_pirq (pirq_dpci)); + } + } + } + +return 0 ; +} + +static void hvm_dpci_isairq_eoi (struct domain *d,unsigned int isairq) +{ +struct hvm_irq_dpci *dpci =NULL ; + +ASSERT (isairq <NR_ISAIRQS ); +if ( !iommu_enabled) +return ; + +spin_lock (&d->event_lock); + + dpci =domain_get_irq_dpci (d); + +if ( dpci &&test_bit (isairq, dpci->isairq_map) ) + { +/* Multiple mirq may be mapped to one isa irq */ +pt_pirq_iterate (d, _hvm_dpci_isairq_eoi, (void *)(long )isairq); + } +spin_unlock (&d->event_lock); +} +/* * This can be called multiple times, but the softirq is only raised once. * That is until the STATE_SCHED state has been cleared. The state can be
xen/drivers/passthrough/x86/vtd/x86/vtd.c +0 -45
51 lines not on this page · raw message
xen/include/xen/iommu.h +0 -1
@@ -99,7 +99,6 @@ int hvm_do_IRQ_dpci(struct domain *, struct pirq *);int pt_irq_create_bind (struct domain *,const struct xen_domctl_bind_pt_irq *);int pt_irq_destroy_bind (struct domain *,const struct xen_domctl_bind_pt_irq *); -void hvm_dpci_isairq_eoi (struct domain *d,unsigned int isairq);struct hvm_irq_dpci *domain_get_irq_dpci (const struct domain *);void free_hvm_irq_dpci (struct hvm_irq_dpci *dpci);bool_t pt_irq_need_timer (uint32_t flags);
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH RFC 05/10] x86/passthrough: move hvm_dpci_isairq_eoi
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 21.02.18 at 22:46, <[email protected]> wrote:
This function is not Intel specific. Move it to
io.calong side its sole user. Remove declaration iniommu.h.Signed-off-by Wei Liu <[email protected]>
(with whatever path name adjustments are necessary depending on the disposition of patches earlier in the series)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 6/10 passthrough/amd: remove guest iommu support
In reply to Wei LiuIt is never used and it is getting in the way of cleaning up.
The only callsite of guest_iommu_add_ppr_log has no effect because guest iommu is not initialised.
---
Cc: Suravee Suthikulpanit <[email protected]>
--- xen/drivers/passthrough/x86/amd/Makefile | 1 - xen/drivers/passthrough/x86/amd/iommu_guest.c | 927 -------------------------- xen/drivers/passthrough/x86/amd/iommu_init.c | 21 +- xen/include/asm-x86/amd-iommu.h | 51 -- xen/include/asm-x86/hvm/svm/amd-iommu-proto.h | 8 - xen/include/asm-x86/iommu.h | 1 - 6 files changed, 6 insertions(+), 1003 deletions(-) delete mode 100644 xen/drivers/passthrough/x86/amd/iommu_guest.c
xen/drivers/passthrough/x86/amd/Makefile +0 -1
@@ -5,4 +5,3 @@ obj-y += pci_amd_iommu.o obj-bin-y += iommu_acpi.init.o obj-y += iommu_intr.o obj-y += iommu_cmd.o -obj-y += iommu_guest.o
xen/drivers/passthrough/x86/amd/iommu_guest.c deleted +0 -927
927 lines not on this page · raw message
xen/drivers/passthrough/x86/amd/iommu_init.c +6 -15
@@ -638,12 +638,15 @@ static void iommu_check_event_log(struct amd_iommu *iommu)spin_unlock_irqrestore (&iommu->lock, flags); } +/* +* XXX Originally this function calls (dead) guest_iommu code. It does +* nothing other than zero'ing the entry (and handling erratum). This +* is what is looks like when all dead code is deleted. +*/ void parse_ppr_log_entry (struct amd_iommu *iommu,u32 entry[]) { -u16 device_id; -u8 bus, devfn, code; -struct pci_dev *pdev; +u8 code;int count =0 ; code = get_field_from_reg_u32(entry[1], IOMMU_PPR_LOG_CODE_MASK,
@@ -668,18 +671,6 @@ void parse_ppr_log_entry(struct amd_iommu *iommu, u32 entry[]) IOMMU_PPR_LOG_CODE_SHIFT); } -/* here device_id is physical value */ - device_id =iommu_get_devid_from_cmd (entry[0 ]); - bus =PCI_BUS (device_id); - devfn =PCI_DEVFN2 (device_id); - -pcidevs_lock (); - pdev =pci_get_real_pdev (iommu->seg, bus, devfn); -pcidevs_unlock (); - -if ( pdev ) -guest_iommu_add_ppr_log (pdev->domain, entry); -memset (entry,0 ,IOMMU_PPR_LOG_ENTRY_SIZE ); }
xen/include/asm-x86/amd-iommu.h +0 -51
57 lines not on this page · raw message
xen/include/asm-x86/hvm/svm/amd-iommu-proto.h +0 -8
@@ -130,14 +130,6 @@ void amd_iommu_resume(void);int __must_check amd_iommu_suspend (void );void amd_iommu_crash_shutdown (void ); -/* guest iommu support */ -void amd_iommu_send_guest_cmd (struct amd_iommu *iommu,u32 cmd[]); -void guest_iommu_add_ppr_log (struct domain *d,u32 entry[]); -void guest_iommu_add_event_log (struct domain *d,u32 entry[]); -int guest_iommu_init (struct domain * d); -void guest_iommu_destroy (struct domain *d); -int guest_iommu_set_base (struct domain *d,uint64_t base); -static inline u32 get_field_from_reg_u32 (u32 reg_value,u32 mask,u32 shift) {u32 field;
xen/include/asm-x86/iommu.h +0 -1
@@ -41,7 +41,6 @@ struct arch_iommu/* amd iommu support */ int paging_mode;struct page_info *root_table; -struct guest_iommu *g_iommu; };extern const struct iommu_ops intel_iommu_ops;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH RFC 06/10] passthrough/amd: remove guest iommu support
Wei,
Quoted 16 lines · Wei Liu
It is never used and it is getting in the way of cleaning up.
The only callsite of
guest_iommu_add_ppr_loghas no effect because guest iommu is not initialised.Signed-off-by Wei Liu<[email protected]>---
Cc: Suravee Suthikulpanit<[email protected]>--- xen/drivers/passthrough/x86/amd/Makefile | 1 - xen/drivers/passthrough/x86/amd/iommu_guest.c | 927 -------------------------- xen/drivers/passthrough/x86/amd/iommu_init.c | 21 +- xen/include/asm-x86/amd-iommu.h | 51 -- xen/include/asm-x86/hvm/svm/amd-iommu-proto.h | 8 - xen/include/asm-x86/iommu.h | 1 - 6 files changed, 6 insertions(+), 1003 deletions(-)
Quoted 1 line
delete mode 100644
xen/drivers/passthrough/x86/amd/iommu_guest.c
Would it be too much trouble if we keep this code for now. There is a plan to support IOMMU in guest in the near future. This could be clean up at that point if no longer needed.
Thanks,
Suravee
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 7/10 passthrough/amd: split out hvm code from iommu_map.c
In reply to Wei LiuMove and rename update_paging_mode. Create a local header file for this and other functions that need exporting.
---
Cc: Suravee Suthikulpanit <[email protected]>
--- xen/drivers/passthrough/x86/amd/Makefile | 1 + xen/drivers/passthrough/x86/amd/hvm.c | 108 ++++++++++++++++++++++++++++ xen/drivers/passthrough/x86/amd/iommu.h | 32 +++++++++ xen/drivers/passthrough/x86/amd/iommu_map.c | 103 ++------------------------ 4 files changed, 148 insertions(+), 96 deletions(-) create mode 100644 xen/drivers/passthrough/x86/amd/hvm.c create mode 100644 xen/drivers/passthrough/x86/amd/iommu.h
xen/drivers/passthrough/x86/amd/Makefile +1 -0
@@ -1,3 +1,4 @@ +obj-$(CONFIG_HVM) += hvm.o obj-bin-y += iommu_detect.init.o obj-y += iommu_init.o obj-y += iommu_map.o
xen/drivers/passthrough/x86/amd/hvm.c new file +108 -0
108 lines not on this page · raw message
xen/drivers/passthrough/x86/amd/iommu.h new file +32 -0
@@ -0,0 +1,32 @@ +#ifndef _X86_AMD_IOMMU_H_ +#define _X86_AMD_IOMMU_H_ + +bool_t set_iommu_pde_present (u32 *pde,unsigned long next_mfn, +unsigned int next_level, +bool_t iw,bool_t ir); + +#ifdef CONFIG_HVM + +int hvm_update_paging_mode (struct domain *d,unsigned long gfn); + +#else + +static inline int hvm_update_paging_mode (struct domain *d,unsigned long gfn) +{ +ASSERT_UNREACHABLE (); +return -EINVAL ; +} + +#endif + +#endif + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/drivers/passthrough/x86/amd/iommu_map.c +7 -96
133 lines not on this page · raw message
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH RFC 07/10] passthrough/amd: split out hvm code from iommu_map.c
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 21.02.18 at 22:46, <[email protected]> wrote:
Move and rename
update_paging_mode. Create a local header file for this and other functions that need exporting.
Functions you move into global name space need suitable prefixes - neither hvm_update_paging_mode() nor set_iommu_pde_present() clarify that this is AMD IOMMU specific code.
Also please don't have bool_t or things like u32 in new code you add (here:
the set_iommu_pde_present() prototype).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH RFC 07/10] passthrough/amd: split out hvm code from iommu_map.c
In reply to Wei LiuWei,
Quoted 6 lines · Wei Liu
Move and rename
update_paging_mode. Create a local header file for this and other functions that need exporting.Signed-off-by Wei Liu<[email protected]>---
Cc: Suravee Suthikulpanit<[email protected]>
Quoted 8 lines
--- xen/drivers/passthrough/x86/amd/Makefile | 1 + xen/drivers/passthrough/x86/amd/hvm.c | 108 ++++++++++++++++++++++++++++ xen/drivers/passthrough/x86/amd/iommu.h | 32 +++++++++ xen/drivers/passthrough/x86/amd/iommu_map.c | 103 ++------------------------ 4 files changed, 148 insertions(+), 96 deletions(-)create mode 100644
xen/drivers/passthrough/x86/amd/hvm.ccreate mode 100644xen/drivers/passthrough/x86/amd/iommu.h
I am still not sure why the update_paging_mode need to be moved out of iommu_map.c. Could you please elaborate?
Thanks,
Suravee
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 8/10 passthrough/amd: make clear_iommu_pte_present static
In reply to Wei LiuThere is only one user in the same file.
---
Cc: Suravee Suthikulpanit <[email protected]>
--- xen/drivers/passthrough/x86/amd/iommu_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/x86/amd/iommu_map.c +1 -1
@@ -37,7 +37,7 @@ static unsigned int pfn_to_pde_idx(unsigned long pfn, unsigned int level)return idx; } -void clear_iommu_pte_present (unsigned long l1_mfn,unsigned long gfn) +static void clear_iommu_pte_present (unsigned long l1_mfn,unsigned long gfn) {u64 *table, *pte;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 9/10 passthrough/intel: put some code under CONFIG_HVM
In reply to Wei LiuThe code which references code under arch/x86/hvm/ is surrounded by CONFIG_HVM now.
The basic idea is that in !CONFIG_HVM && CONFIG_PV case we still want to retain the host side IOMMU code so that PV guests can use it if necessary.
---
Cc: Kevin Tian <[email protected]>
--- xen/drivers/passthrough/x86/vtd/iommu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
xen/drivers/passthrough/x86/vtd/iommu.c +14 -1
@@ -32,7 +32,6 @@#include <xen/keyhandler.h> #include <asm/msi.h> #include <asm/irq.h> -#include <asm/hvm/vmx/vmx.h> #include <asm/p2m.h> #include <mach_apic.h> #include "iommu.h"
@@ -41,6 +40,10 @@#include "vtd.h" #include "../../ats.h" +#ifdef CONFIG_HVM +#include <asm/hvm/vmx/vmx.h> +#endif +struct mapped_rmrr {struct list_head list;u64 base, end;
@@ -1873,6 +1876,7 @@ int iommu_pte_flush(struct domain *d, u64 gfn, u64 *pte,return rc; } +#ifdef CONFIG_HVM static int __init vtd_ept_page_compatible (struct iommu *iommu) {u64 ept_cap, vtd_cap = iommu->cap;
@@ -1885,6 +1889,7 @@ static int __init vtd_ept_page_compatible(struct iommu *iommu)return (ept_has_2mb (ept_cap) && opt_hap_2mb) ==cap_sps_2mb (vtd_cap) && (ept_has_1gb(ept_cap) && opt_hap_1gb) == cap_sps_1gb(vtd_cap); } +#endif /* * set VT-d page table directory to EPT table if allowed
@@ -2280,7 +2285,9 @@ int __init intel_vtd_setup(void)if ( !cap_intr_post (iommu->cap) || !cpu_has_cx16 ) iommu_intpost =0 ; +#ifdef CONFIG_HVM if ( !vtd_ept_page_compatible(iommu) ) +#endif iommu_hap_pt_share =0 ; ret =iommu_set_interrupt (drhd);
@@ -2376,14 +2383,18 @@ static int reassign_device_ownership(if ( ret )return ret; +#ifdef CONFIG_HVM if ( !has_arch_pdevs (target) )vmx_pi_hooks_assign (target); +#endif ret =domain_context_mapping (target, devfn, pdev);if ( ret ) { +#ifdef CONFIG_HVM if ( !has_arch_pdevs (target) )vmx_pi_hooks_deassign (target); +#endif return ret; }
@@ -2394,8 +2405,10 @@ static int reassign_device_ownership( pdev->domain = target; } +#ifdef CONFIG_HVM if ( !has_arch_pdevs (source) )vmx_pi_hooks_deassign (source); +#endif return ret; }
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH RFC 09/10] passthrough/intel: put some code under CONFIG_HVM
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 21.02.18 at 22:47, <[email protected]> wrote:
xen/drivers/passthrough/x86/vtd/iommu.c +1
-0@@ -1873,6 +1876,7 @@ int iommu_pte_flush(struct domain *d, u64 gfn, u64 *pte,return rc; } +#ifdef CONFIG_HVM static int __init vtd_ept_page_compatible (struct iommu *iommu) {u64 ept_cap, vtd_cap = iommu->cap;
xen/drivers/passthrough/x86/vtd/iommu.c static int __init vtd_ept_page_compatible(struct iommu *iommu) · line 1892
Quoted 4 lines
xen/drivers/passthrough/x86/vtd/iommu.c +1
-0@@ -1885,6 +1889,7 @@ static int __init vtd_ept_page_compatible(struct iommu *iommu)return (ept_has_2mb (ept_cap) && opt_hap_2mb) ==cap_sps_2mb (vtd_cap) && (ept_has_1gb(ept_cap) && opt_hap_1gb) == cap_sps_1gb(vtd_cap); } +#endif
I think the #ifdef here would better move into the function, such that ...
xen/drivers/passthrough/x86/vtd/iommu.c int __init intel_vtd_setup(void) · line 2291
Quoted 8 lines
xen/drivers/passthrough/x86/vtd/iommu.c +2
-0@@ -2280,7 +2285,9 @@ int __init intel_vtd_setup(void)if ( !cap_intr_post (iommu->cap) || !cpu_has_cx16 ) iommu_intpost =0 ; +#ifdef CONFIG_HVM if ( !vtd_ept_page_compatible(iommu) ) +#endif iommu_hap_pt_share =0 ;
... this one becomes unnecessary. Furthermore iommu_hap_pt_share is a variable that's meaningful for HVM only, so another alternative would be to widen the #ifdef here.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
RFC PATCH 10/10 x86: check hvm domain before calling pt_irq_destroy_bind
In reply to Wei Liu... just like its counter part because that function is HVM only.
There is no risk of corruption because pt_irq_destroy_bind already has proper check in place, but it would be nice to be more explicit before calling the said function.
--- xen/arch/x86/domctl.c | 4 ++++ 1 file changed, 4 insertions(+)
xen/arch/x86/domctl.c +4 -0
@@ -707,6 +707,10 @@ long arch_do_domctl(struct xen_domctl_bind_pt_irq *bind = &domctl->u.bind_pt_irq;int irq =domain_pirq_to_irq (d, bind->machine_irq); + ret = -EINVAL ; +if ( !is_hvm_domain (d) ) +break ; + ret = -EPERM ;if ( irq <=0 || !irq_access_permitted (currd, irq) )break ;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 8 lines
From: Wei Liu
Sent: Thursday, February 22, 2018 5:47 AMHi all
At some point I would like to make
CONFIG_HVMandCONFIG_PVwork. The
passthrough code is one of the road blocks for that work.
Can you elaborate the motivation of this change? why does someone want to disable HVM or PV logic completely from hypervisor?
Quoted 93 lines
A short discussion on #xendevel made me think that having host side code regardless of if HVM (the primary user) is configured is desirable because PV
guests may still have limited use of the hardware, hence this series.What I want is to have clear hierarchy of the code and split the host side and the guest side code, and start to use
CONFIG_HVMwhere applicable. Luckily
the amount of work seemed to be smaller than I had expected.RFC because there are a few open questions. Please see individual patches.
Wei.
Wei Liu (10):
passthrough: rearrange x86 code
passthrough: split out x86 PCI code tox86/pci.cx86/passthrough:io.cis used for HVM only x86/passthrough:arch_pci_clean_irqsis HVM only x86/passthrough: movehvm_dpci_isairq_eoipassthrough/amd: remove guest iommu support passthrough/amd: split out hvm code fromiommu_map.cpassthrough/amd: makeclear_iommu_pte_presentstatic passthrough/intel: put some code underCONFIG_HVM
x86: check hvm domain before callingpt_irq_destroy_bindMAINTAINERS | 8 +- xen/arch/x86/domctl.c | 4 + xen/drivers/passthrough/Makefile | 3 - xen/drivers/passthrough/amd/iommu_guest.c | 927 --------------------- xen/drivers/passthrough/pci.c | 51 +- xen/drivers/passthrough/x86/Makefile | 5 + xen/drivers/passthrough/{ => x86}/amd/Makefile | 2 +- xen/drivers/passthrough/x86/amd/hvm.c | 108 +++ xen/drivers/passthrough/x86/amd/iommu.h | 32 + xen/drivers/passthrough/{ => x86}/amd/iommu_acpi.c | 0 xen/drivers/passthrough/{ => x86}/amd/iommu_cmd.c | 2 +- .../passthrough/{ => x86}/amd/iommu_detect.c | 0 xen/drivers/passthrough/{ => x86}/amd/iommu_init.c | 21 +- xen/drivers/passthrough/{ => x86}/amd/iommu_intr.c | 0 xen/drivers/passthrough/{ => x86}/amd/iommu_map.c | 107 +-- .../passthrough/{ => x86}/amd/pci_amd_iommu.c | 2 +- xen/drivers/passthrough/{ => x86}/io.c | 45 + xen/drivers/passthrough/x86/pci.c | 74 ++ xen/drivers/passthrough/{ => x86}/vtd/Makefile | 0 xen/drivers/passthrough/{ => x86}/vtd/dmar.c | 0 xen/drivers/passthrough/{ => x86}/vtd/dmar.h | 0 xen/drivers/passthrough/{ => x86}/vtd/extern.h | 0 xen/drivers/passthrough/{ => x86}/vtd/intremap.c | 0 xen/drivers/passthrough/{ => x86}/vtd/iommu.c | 17 +- xen/drivers/passthrough/{ => x86}/vtd/iommu.h | 0 xen/drivers/passthrough/{ => x86}/vtd/qinval.c | 2 +- xen/drivers/passthrough/{ => x86}/vtd/quirks.c | 0 xen/drivers/passthrough/{ => x86}/vtd/utils.c | 0 xen/drivers/passthrough/{ => x86}/vtd/vtd.h | 0 xen/drivers/passthrough/{ => x86}/vtd/x86/Makefile | 0 xen/drivers/passthrough/{ => x86}/vtd/x86/ats.c | 2 +- xen/drivers/passthrough/{ => x86}/vtd/x86/vtd.c | 45 - xen/include/asm-x86/amd-iommu.h | 51 -- xen/include/asm-x86/hvm/svm/amd-iommu-proto.h | 8 - xen/include/asm-x86/iommu.h | 1 - xen/include/xen/iommu.h | 1 - xen/include/xen/pci.h | 2 + 37 files changed, 310 insertions(+), 1210 deletions(-) delete mode 100644 xen/drivers/passthrough/amd/iommu_guest.c rename xen/drivers/passthrough/{ => x86}/amd/Makefile (86%) create mode 100644 xen/drivers/passthrough/x86/amd/hvm.c create mode 100644 xen/drivers/passthrough/x86/amd/iommu.h rename xen/drivers/passthrough/{ => x86}/amd/iommu_acpi.c (100%) rename xen/drivers/passthrough/{ => x86}/amd/iommu_cmd.c (99%) rename xen/drivers/passthrough/{ => x86}/amd/iommu_detect.c (100%) rename xen/drivers/passthrough/{ => x86}/amd/iommu_init.c (99%) rename xen/drivers/passthrough/{ => x86}/amd/iommu_intr.c (100%) rename xen/drivers/passthrough/{ => x86}/amd/iommu_map.c (86%) rename xen/drivers/passthrough/{ => x86}/amd/pci_amd_iommu.c (99%) rename xen/drivers/passthrough/{ => x86}/io.c (96%) create mode 100644 xen/drivers/passthrough/x86/pci.c rename xen/drivers/passthrough/{ => x86}/vtd/Makefile (100%) rename xen/drivers/passthrough/{ => x86}/vtd/dmar.c (100%) rename xen/drivers/passthrough/{ => x86}/vtd/dmar.h (100%) rename xen/drivers/passthrough/{ => x86}/vtd/extern.h (100%) rename xen/drivers/passthrough/{ => x86}/vtd/intremap.c (100%) rename xen/drivers/passthrough/{ => x86}/vtd/iommu.c (99%) rename xen/drivers/passthrough/{ => x86}/vtd/iommu.h (100%) rename xen/drivers/passthrough/{ => x86}/vtd/qinval.c (99%) rename xen/drivers/passthrough/{ => x86}/vtd/quirks.c (100%) rename xen/drivers/passthrough/{ => x86}/vtd/utils.c (100%) rename xen/drivers/passthrough/{ => x86}/vtd/vtd.h (100%) rename xen/drivers/passthrough/{ => x86}/vtd/x86/Makefile (100%) rename xen/drivers/passthrough/{ => x86}/vtd/x86/ats.c (99%) rename xen/drivers/passthrough/{ => x86}/vtd/x86/vtd.c (72%)
Quoted 8 lines
--
2.11.0_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 12 lines · Kevin
Quoted 8 lines
From: Wei Liu
Sent: Thursday, February 22, 2018 5:47 AMHi all
At some point I would like to make
CONFIG_HVMandCONFIG_PVwork. The
passthrough code is one of the road blocks for that work.Can you elaborate the motivation of this change? why does someone want to disable HVM or PV logic completely from hypervisor?
At some point in the future, we would like to utilise as many hardware features as possible and have an HVM / PVH only setup. At that point PV code will be necessarily and should be preferably compiled out to reduce code size and attack surface.
Having PV compiled out also enable Xen to reclaim some address space from the PV ABI.
But, we understand that PV is here to stay for at least a while and could be useful for some other niche use cases, so upstream have developed a PV-in-PVH shim to continue to support PV guests. The shim is actually yet another configuration of Xen running as a PVH guest but exposes PV ABI to PV guests. We want to disable HVM code in that case, again, to reduce code size and attach surface.
There is also the long term benefit to make Xen more maintainable and approachable in the future.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 25 lines
From: Wei Liu [mailto:[email protected]]
Sent: Saturday, February 24, 2018 12:08 AMQuoted 12 lines · Kevin
Quoted 8 lines
From: Wei Liu
Sent: Thursday, February 22, 2018 5:47 AMHi all
At some point I would like to make
CONFIG_HVMandCONFIG_PVwork. The
passthrough code is one of the road blocks for that work.Can you elaborate the motivation of this change? why does someone want to disable HVM or PV logic completely from hypervisor?
At some point in the future, we would like to utilise as many hardware features as possible and have an HVM / PVH only setup. At that point PV code will be necessarily and should be preferably compiled out to reduce code size and attack surface.
Having PV compiled out also enable Xen to reclaim some address space from the PV ABI.
Quoted 6 lines
But, we understand that PV is here to stay for at least a while and could be useful for some other niche use cases, so upstream have developed a PV-in-PVH shim to continue to support PV guests. The shim is actually yet another configuration of Xen running as a PVH guest but exposes PV ABI to PV guests. We want to disable HVM code in that case, again, to reduce code size and attach surface.
since it's only temporary, do we really care about code size or attacking surface in such case? or is it worthy of the effort regarding to the gain which you anticipate?
I sort of buy-in CONFIG_PV, but not sure whether CONFIG_HVM is required.
Quoted 9 lines
There is also the long term benefit to make Xen more maintainable and approachable in the future.
See
https://www.slideshare.net/xen_com_mgr/xpdds17-keynote-towards-a-
configurable-and-slimmer-x86-hypervisor-wei-liu-citrixWei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 24.02.18 at 04:23, <[email protected]> wrote:
I sort of buy-in
CONFIG_PV, but not sure whetherCONFIG_HVMis required.
I think the shim is where CONFIG_HVM would want to be turned off.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 32 lines · Kevin
Quoted 25 lines
From: Wei Liu [mailto:[email protected]]
Sent: Saturday, February 24, 2018 12:08 AMQuoted 12 lines · Kevin
Quoted 8 lines
From: Wei Liu
Sent: Thursday, February 22, 2018 5:47 AMHi all
At some point I would like to make
CONFIG_HVMandCONFIG_PVwork. The
passthrough code is one of the road blocks for that work.Can you elaborate the motivation of this change? why does someone want to disable HVM or PV logic completely from hypervisor?
At some point in the future, we would like to utilise as many hardware features as possible and have an HVM / PVH only setup. At that point PV code will be necessarily and should be preferably compiled out to reduce code size and attack surface.
Having PV compiled out also enable Xen to reclaim some address space from the PV ABI.
Quoted 6 lines
But, we understand that PV is here to stay for at least a while and could be useful for some other niche use cases, so upstream have developed a PV-in-PVH shim to continue to support PV guests. The shim is actually yet another configuration of Xen running as a PVH guest but exposes PV ABI to PV guests. We want to disable HVM code in that case, again, to reduce code size and attach surface.
Quoted 4 lines
since it's only temporary, do we really care about code size or attacking surface in such case? or is it worthy of the effort regarding to the gain which you anticipate?
It depends. We don't really know how long the shim is going to live. If it is going to be useful for the next 5 to 10 years after we decide to go HVM / PVH only (which I think that's a reasonable assumption for enterprise usage), it is worthy of the effort.
Quoted 3 lines
I sort of buy-in
CONFIG_PV, but not sure whetherCONFIG_HVMis required.
I kinda agree: CONFIG_PV is more valuable than CONFIG_HVM. But I have already done the heavy-lifting to distinguish PV and HVM code so having CONFIG_HVM work can be seen as a side effect of that.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 11 lines · Kevin
Quoted 8 lines
From: Wei Liu
Sent: Thursday, February 22, 2018 5:47 AMHi all
At some point I would like to make
CONFIG_HVMandCONFIG_PVwork. The
passthrough code is one of the road blocks for that work.Can you elaborate the motivation of this change? why does someone want to disable HVM or PV logic completely from hypervisor?
I can say I recall advocating for this at Xen Summit in Cambridge. I believe I talked about it in Toronto as well. There are a number of users of Xen that would certainly want to ship without all the code associated with PV compiled in. Given the nature of design "compromises" in many parts of x86 systems there is certainly a non-zero sum of people that would likely utilize the ability to remove code that doesn't need to be there. I think every individual on this list who has been involved in the security has been in a room of @intel.com folks has seen features vs security win out many times.
I don't think its a hard stretch of the imagination to see people disabling PV in data centers running newer workloads on PVH and HVM only. I can see the real question being why HVM? That I would say lies with the direction of discretionary access controls in Xen vs mandatory access controls. To solve for the lack of functionality we've grown things like "dmops" and I could certainly see a product like Qubes running only PVH domains in the future.
Since I picked on Qubes I've CC'd Marek.
Signature · 1 line
Doug Goldstein
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 23 lines · Doug Goldstein
Quoted 11 lines · Kevin
Quoted 8 lines
From: Wei Liu
Sent: Thursday, February 22, 2018 5:47 AMHi all
At some point I would like to make
CONFIG_HVMandCONFIG_PVwork. The
passthrough code is one of the road blocks for that work.Can you elaborate the motivation of this change? why does someone want to disable HVM or PV logic completely from hypervisor?
I can say I recall advocating for this at Xen Summit in Cambridge. I believe I talked about it in Toronto as well. There are a number of users of Xen that would certainly want to ship without all the code associated with PV compiled in. Given the nature of design "compromises" in many parts of x86 systems there is certainly a non-zero sum of people that would likely utilize the ability to remove code that doesn't need to be there. I think every individual on this list who has been involved in the security has been in a room of @intel.com folks has seen features vs security win out many times.
Quoted 3 lines
I don't think its a hard stretch of the imagination to see people disabling PV in data centers running newer workloads on PVH and HVM only.
Yes, definitely disabling PV will be useful. Right after being able to use PCI passthrough with PVH.
Quoted 7 lines
I can see the real question being why HVM? That I would say lies with the direction of discretionary access controls in Xen vs mandatory access controls. To solve for the lack of functionality we've grown things like "dmops" and I could certainly see a product like Qubes running only PVH domains in the future.
Since I picked on Qubes I've CC'd Marek.
So, is it going to be an option to have CONFIG_HVM=n and CONFIG_PVH=y at the same time? While currently we do support Windows, so need CONFIG_HVM=y, but I can see in some future/alternative version we could have even that disabled. For example right now we do have CONFIG_SHADOW_PAGING disabled.
Signature · 5 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 37 lines · Marek Marczykowski-Górecki
Quoted 23 lines · Doug Goldstein
Quoted 11 lines · Kevin
Quoted 8 lines
From: Wei Liu
Sent: Thursday, February 22, 2018 5:47 AMHi all
At some point I would like to make
CONFIG_HVMandCONFIG_PVwork. The
passthrough code is one of the road blocks for that work.Can you elaborate the motivation of this change? why does someone want to disable HVM or PV logic completely from hypervisor?
I can say I recall advocating for this at Xen Summit in Cambridge. I believe I talked about it in Toronto as well. There are a number of users of Xen that would certainly want to ship without all the code associated with PV compiled in. Given the nature of design "compromises" in many parts of x86 systems there is certainly a non-zero sum of people that would likely utilize the ability to remove code that doesn't need to be there. I think every individual on this list who has been involved in the security has been in a room of @intel.com folks has seen features vs security win out many times.
Quoted 3 lines
I don't think its a hard stretch of the imagination to see people disabling PV in data centers running newer workloads on PVH and HVM only.
Yes, definitely disabling PV will be useful. Right after being able to use PCI passthrough with PVH.
Quoted 6 lines
I can see the real question being why HVM? That I would say lies with the direction of discretionary access controls in Xen vs mandatory access controls. To solve for the lack of functionality we've grown things like "dmops" and I could certainly see a product like Qubes running only PVH domains in the future.
Quoted 8 lines
Quoted 1 line
Since I picked on Qubes I've CC'd Marek.
So, is it going to be an option to have
CONFIG_HVM=nandCONFIG_PVH=yat the same time? While currently we do support Windows, so needCONFIG_HVM=y, but I can see in some future/alternative version we could have even that disabled. For example right now we do haveCONFIG_SHADOW_PAGINGdisabled.
Hypervisor doesn't distinguish HVM and PVH at this point. More work is needed there. But I expect the debate of what each option covers will take longer than actually writing the code.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Ping?
Any more comment on this?
Quoted 86 lines · Wei Liu
Hi all
At some point I would like to make
CONFIG_HVMandCONFIG_PVwork. The passthrough code is one of the road blocks for that work.A short discussion on #xendevel made me think that having host side code regardless of if HVM (the primary user) is configured is desirable because PV guests may still have limited use of the hardware, hence this series.
What I want is to have clear hierarchy of the code and split the host side and the guest side code, and start to use
CONFIG_HVMwhere applicable. Luckily the amount of work seemed to be smaller than I had expected.RFC because there are a few open questions. Please see individual patches.
Wei.
Wei Liu (10):
passthrough: rearrange x86 code
passthrough: split out x86 PCI code tox86/pci.cx86/passthrough:io.cis used for HVM only x86/passthrough:arch_pci_clean_irqsis HVM only x86/passthrough: movehvm_dpci_isairq_eoipassthrough/amd: remove guest iommu support passthrough/amd: split out hvm code fromiommu_map.cpassthrough/amd: makeclear_iommu_pte_presentstatic passthrough/intel: put some code underCONFIG_HVM
x86: check hvm domain before callingpt_irq_destroy_bindMAINTAINERS | 8 +- xen/arch/x86/domctl.c | 4 + xen/drivers/passthrough/Makefile | 3 - xen/drivers/passthrough/amd/iommu_guest.c | 927 --------------------- xen/drivers/passthrough/pci.c | 51 +- xen/drivers/passthrough/x86/Makefile | 5 + xen/drivers/passthrough/{ => x86}/amd/Makefile | 2 +- xen/drivers/passthrough/x86/amd/hvm.c | 108 +++ xen/drivers/passthrough/x86/amd/iommu.h | 32 + xen/drivers/passthrough/{ => x86}/amd/iommu_acpi.c | 0 xen/drivers/passthrough/{ => x86}/amd/iommu_cmd.c | 2 +- .../passthrough/{ => x86}/amd/iommu_detect.c | 0 xen/drivers/passthrough/{ => x86}/amd/iommu_init.c | 21 +- xen/drivers/passthrough/{ => x86}/amd/iommu_intr.c | 0 xen/drivers/passthrough/{ => x86}/amd/iommu_map.c | 107 +-- .../passthrough/{ => x86}/amd/pci_amd_iommu.c | 2 +- xen/drivers/passthrough/{ => x86}/io.c | 45 + xen/drivers/passthrough/x86/pci.c | 74 ++ xen/drivers/passthrough/{ => x86}/vtd/Makefile | 0 xen/drivers/passthrough/{ => x86}/vtd/dmar.c | 0 xen/drivers/passthrough/{ => x86}/vtd/dmar.h | 0 xen/drivers/passthrough/{ => x86}/vtd/extern.h | 0 xen/drivers/passthrough/{ => x86}/vtd/intremap.c | 0 xen/drivers/passthrough/{ => x86}/vtd/iommu.c | 17 +- xen/drivers/passthrough/{ => x86}/vtd/iommu.h | 0 xen/drivers/passthrough/{ => x86}/vtd/qinval.c | 2 +- xen/drivers/passthrough/{ => x86}/vtd/quirks.c | 0 xen/drivers/passthrough/{ => x86}/vtd/utils.c | 0 xen/drivers/passthrough/{ => x86}/vtd/vtd.h | 0 xen/drivers/passthrough/{ => x86}/vtd/x86/Makefile | 0 xen/drivers/passthrough/{ => x86}/vtd/x86/ats.c | 2 +- xen/drivers/passthrough/{ => x86}/vtd/x86/vtd.c | 45 - xen/include/asm-x86/amd-iommu.h | 51 -- xen/include/asm-x86/hvm/svm/amd-iommu-proto.h | 8 - xen/include/asm-x86/iommu.h | 1 - xen/include/xen/iommu.h | 1 - xen/include/xen/pci.h | 2 + 37 files changed, 310 insertions(+), 1210 deletions(-) delete mode 100644 xen/drivers/passthrough/amd/iommu_guest.c rename xen/drivers/passthrough/{ => x86}/amd/Makefile (86%) create mode 100644 xen/drivers/passthrough/x86/amd/hvm.c create mode 100644 xen/drivers/passthrough/x86/amd/iommu.h rename xen/drivers/passthrough/{ => x86}/amd/iommu_acpi.c (100%) rename xen/drivers/passthrough/{ => x86}/amd/iommu_cmd.c (99%) rename xen/drivers/passthrough/{ => x86}/amd/iommu_detect.c (100%) rename xen/drivers/passthrough/{ => x86}/amd/iommu_init.c (99%) rename xen/drivers/passthrough/{ => x86}/amd/iommu_intr.c (100%) rename xen/drivers/passthrough/{ => x86}/amd/iommu_map.c (86%) rename xen/drivers/passthrough/{ => x86}/amd/pci_amd_iommu.c (99%) rename xen/drivers/passthrough/{ => x86}/io.c (96%) create mode 100644 xen/drivers/passthrough/x86/pci.c rename xen/drivers/passthrough/{ => x86}/vtd/Makefile (100%) rename xen/drivers/passthrough/{ => x86}/vtd/dmar.c (100%) rename xen/drivers/passthrough/{ => x86}/vtd/dmar.h (100%) rename xen/drivers/passthrough/{ => x86}/vtd/extern.h (100%) rename xen/drivers/passthrough/{ => x86}/vtd/intremap.c (100%) rename xen/drivers/passthrough/{ => x86}/vtd/iommu.c (99%)
Quoted 12 lines
rename xen/drivers/passthrough/{ => x86}/vtd/iommu.h (100%) rename xen/drivers/passthrough/{ => x86}/vtd/qinval.c (99%) rename xen/drivers/passthrough/{ => x86}/vtd/quirks.c (100%) rename xen/drivers/passthrough/{ => x86}/vtd/utils.c (100%) rename xen/drivers/passthrough/{ => x86}/vtd/vtd.h (100%) rename xen/drivers/passthrough/{ => x86}/vtd/x86/Makefile (100%) rename xen/drivers/passthrough/{ => x86}/vtd/x86/ats.c (99%) rename xen/drivers/passthrough/{ => x86}/vtd/x86/vtd.c (72%)Signature · 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 08.03.18 at 13:18, <[email protected]> wrote:
Ping?
And I'm sorry again, even less so for any RFCs (there are about 100 older ones as well that want looking at).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel