Implement ERRATA_772415 quirk for VTD
v10 cover Implement ERRATA_772415 quirk for VTD
Hi,
Based on Cédric's suggestions[1], The nesting series v8 is split to "base nesting series" + "ERRATA_772415_SPR17 quirk series", this is the ERRATA_772415_SPR17 quirk series.
On a system influenced by ERRATA_772415, IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17 is repored by IOMMU_DEVICE_GET_HW_INFO. Due to this errata, even the readonly range mapped on second stage page table could still be written.
Reference from 4th Gen Intel Xeon Processor Scalable Family Specification
Update, Errata Details, SPR17.
Link https://edc.intel.com/content/www/us/en/design/products-and-solutions/processors-and-chipsets/eagle-stream/sapphire-rapids-specification-update/
Backup link https://cdrdv2.intel.com/v1/dl/getContent/772415
Also copied the SPR17 details from above link:
"Problem: When remapping hardware is configured by system software in scalable mode as Nested (PGTT=011b) and with PWSNP field Set in the PASID-table-entry, it may Set Accessed bit and Dirty bit (and Extended Access bit if enabled) in first-stage page-table entries even when second-stage mappings indicate that corresponding first-stage page-table is Read-Only.
Implication: Due to this erratum, pages mapped as Read-only in second-stage page-tables may be modified by remapping hardware Access/Dirty bit updates.
Workaround: None identified. System software enabling nested translations for a VM should ensure that there are no read-only pages in the corresponding second-stage mappings."
QEMU code can be found at [2], it's based after below two series:
[PATCH v10 00/19] intel_iommu: Enable first stage translation for passthrough device [PATCH v6 0/9] vfio: relax the vIOMMU check
Thanks
Zhenzhong
Changelog:
v10:
- All headers under include/hw/ have been moved to include/hw/core/, do the same for iommu.h (Cédric)
v9:
This is a new split from nesting series, see the link[3] for history changelog.
[1] https://lore.kernel.org/qemu-devel/[email protected]/
[2] https://github.com/yiliu1765/qemu/tree/zhenzhong/iommufd_nesting_ERRATA_772415.v10
[3] https://lore.kernel.org/qemu-devel/[email protected]/
Zhenzhong Duan (4):
hw/pci: Introduce pci_device_get_host_iommu_quirks()
intel_iommu_accel: Implement get_host_iommu_quirks() callback vfio/listener: Bypass readonly region for dirty tracking Workaround for ERRATA_772415_SPR17
docs/devel/vfio-iommufd.rst | 9 ++++++ hw/i386/intel_iommu_accel.h | 5 ++++ include/hw/core/iommu.h | 5 ++++ include/hw/pci/pci.h | 31 ++++++++++++++++++++ include/hw/vfio/vfio-container.h | 1 + include/hw/vfio/vfio-device.h | 3 ++ hw/i386/intel_iommu.c | 2 ++ hw/i386/intel_iommu_accel.c | 21 ++++++++++++++ hw/pci/pci.c | 12 ++++++++ hw/vfio/device.c | 14 +++++++++ hw/vfio/iommufd.c | 9 +++++- hw/vfio/listener.c | 50 +++++++++++++++++++++++++------- hw/vfio/trace-events | 1 + 13 files changed, 151 insertions(+), 12 deletions(-)
Signature · 1 line
2.47.1
PATCH v10 1/4 hw/pci: Introduce pci_device_get_host_iommu_quirks()
In VFIO core, we call iommufd_backend_get_device_info() to return vendor specific hardware information data, but it's not good to retrieve this raw data in VFIO core.
Introduce a new PCIIOMMUOps optional callback, get_host_iommu_quirk() which allows to retrieve the vendor specific hardware information data and convert it into bitmaps defined with enum host_iommu_quirks.
pci_device_get_host_iommu_quirks() is a wrapper that can be called on a PCI device potentially protected by a vIOMMU.
--- include/hw/core/iommu.h | 5 +++++ include/hw/pci/pci.h | 31 +++++++++++++++++++++++++++++++ hw/pci/pci.c | 12 ++++++++++++ 3 files changed, 48 insertions(+)
include/hw/core/iommu.h +5 -0
@@ -22,4 +22,9 @@ enum viommu_flags { VIOMMU_FLAG_WANT_NESTING_PARENT = BIT_ULL(0), }; +/* Host IOMMU quirks. Extracted from host IOMMU capabilities */ +enum host_iommu_quirks { +HOST_IOMMU_QUIRK_NESTING_PARENT_BYPASS_RO =BIT_ULL (0 ), +}; +#endif /* HW_IOMMU_H */
include/hw/pci/pci.h +31 -0
@@ -474,6 +474,23 @@ typedef struct PCIIOMMUOps {* enum viommu_flags. */ uint64_t (*get_viommu_flags)(void *opaque); +/** +* @get_host_iommu_quirks: get host IOMMU quirks +* +* Optional callback, if not implemented, then vIOMMU doesn't support +* converting @type specific hardware information data into a standard +* bitmap format. +* +* @type: IOMMU hardware info type +* +* @caps: IOMMU @type specific hardware information data +* +* @size: size of @caps +* +* Returns: bitmap with each bit representing a host IOMMU quirk defined in +* enum host_iommu_quirks +*/ +uint64_t (*get_host_iommu_quirks)(uint32_t type,void *caps,uint32_t size);/** * @get_iotlb_info: get properties required to initialize a device IOTLB. *
@@ -666,6 +683,20 @@ void pci_device_unset_iommu_device(PCIDevice *dev);*/ uint64_t pci_device_get_viommu_flags (PCIDevice *dev); +/** +* pci_device_get_host_iommu_quirks: get host IOMMU quirks. +* +* Returns: bitmap with each bit representing a host IOMMU quirk defined in +* enum host_iommu_quirks. Or 0 if vIOMMU doesn't convert any. +* +* @dev: PCI device pointer. +* @type: IOMMU hardware info type +* @caps: IOMMU @type specific hardware information data +* @size: size of @caps +*/ +uint64_t pci_device_get_host_iommu_quirks (PCIDevice *dev,uint32_t type, +void *caps,uint32_t size); +/** * pci_iommu_get_iotlb_info: get properties required to initialize a * device IOTLB.
hw/pci/pci.c +12 -0
@@ -3032,6 +3032,18 @@ uint64_t pci_device_get_viommu_flags(PCIDevice *dev)return 0 ; } +uint64_t pci_device_get_host_iommu_quirks (PCIDevice *dev,uint32_t type, +void *caps,uint32_t size) +{ +PCIBus *iommu_bus; + +pci_device_get_iommu_bus_devfn (dev, &iommu_bus,NULL ,NULL ); +if (iommu_bus && iommu_bus->iommu_ops->get_host_iommu_quirks) { +return iommu_bus->iommu_ops->get_host_iommu_quirks (type, caps, size); + } +return 0 ; +} +int pci_pri_request_page (PCIDevice *dev,uint32_t pasid,bool priv_req,bool exec_req,hwaddr addr,bool lpig,uint16_t prgi,bool is_read,bool is_write)
Signature · 1 line
2.47.1
PATCH v10 2/4 intel_iommu_accel: Implement get_host_iommu_quirks() callback
In reply to Zhenzhong DuanImplement get_host_iommu_quirks() callback to retrieve the vendor specific hardware information data and convert it into bitmaps defined with enum host_iommu_quirks. It will be used by VFIO in subsequent patch.
--- hw/i386/intel_iommu_accel.h | 5 +++++ hw/i386/intel_iommu.c | 2 ++ hw/i386/intel_iommu_accel.c | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+)
hw/i386/intel_iommu_accel.h +5 -0
@@ -20,6 +20,7 @@ bool vtd_propagate_guest_pasid(VTDAddressSpace *vtd_as, Error **errp);void vtd_flush_host_piotlb_all_locked (IntelIOMMUState *s,uint16_t domain_id,uint32_t pasid,hwaddr addr,uint64_t npages,bool ih); +void vtd_iommu_ops_update_accel (PCIIOMMUOps *ops);#else static inline bool vtd_check_hiod_accel(IntelIOMMUState *s, VTDHostIOMMUDevice *vtd_hiod,
@@ -47,5 +48,9 @@ static inline void vtd_flush_host_piotlb_all_locked(IntelIOMMUState *s, uint64_t npages, bool ih) { } + +static inline void vtd_iommu_ops_update_accel (PCIIOMMUOps *ops) +{ +}#endif #endif
hw/i386/intel_iommu.c +2 -0
@@ -5590,6 +5590,8 @@ static void vtd_class_init(ObjectClass *klass, const void *data) x86_class->int_remap = vtd_int_remap;set_bit (DEVICE_CATEGORY_MISC , dc->categories); dc->desc ="Intel IOMMU (VT-d) DMA Remapping device" ; + +vtd_iommu_ops_update_accel (&vtd_iommu_ops); }static const TypeInfo vtd_info = {
hw/i386/intel_iommu_accel.c +21 -0
@@ -12,6 +12,7 @@#include "system/iommufd.h" #include "intel_iommu_internal.h" #include "intel_iommu_accel.h" +#include "hw/core/iommu.h" #include "hw/pci/pci_bus.h" #include "trace.h"
@@ -249,3 +250,23 @@ void vtd_flush_host_piotlb_all_locked(IntelIOMMUState *s, uint16_t domain_id,g_hash_table_foreach (s->vtd_address_spaces, vtd_flush_host_piotlb_locked, &piotlb_info); } + +static uint64_t vtd_get_host_iommu_quirks (uint32_t type, +void *caps,uint32_t size) +{ +struct iommu_hw_info_vtd *vtd = caps; +uint64_t quirks =0 ; + +if (type ==IOMMU_HW_INFO_TYPE_INTEL_VTD && +sizeof (struct iommu_hw_info_vtd ) <= size && + vtd->flags &IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17 ) { + quirks |=HOST_IOMMU_QUIRK_NESTING_PARENT_BYPASS_RO ; + } + +return quirks; +} + +void vtd_iommu_ops_update_accel (PCIIOMMUOps *ops) +{ + ops->get_host_iommu_quirks = vtd_get_host_iommu_quirks; +}
Signature · 1 line
2.47.1
PATCH v10 3/4 vfio/listener: Bypass readonly region for dirty tracking
In reply to Zhenzhong DuanWhen doing dirty tracking or calculating dirty tracking range, readonly regions can be bypassed, because corresponding DMA mappings are readonly and never become dirty.
This can optimize dirty tracking a bit for passthrough device.
--- hw/vfio/listener.c | 48 ++++++++++++++++++++++++++++++++++---------- hw/vfio/trace-events | 1 + 2 files changed, 38 insertions(+), 11 deletions(-)
hw/vfio/listener.c +37 -11
@@ -76,8 +76,13 @@ static bool vfio_log_sync_needed(const VFIOContainer *bcontainer)return true; } -static bool vfio_listener_skipped_section (MemoryRegionSection *section) +static bool vfio_listener_skipped_section (MemoryRegionSection *section, +bool bypass_ro) { +if (bypass_ro && section->readonly) { +return true; + } +return (!memory_region_is_ram (section->mr) && !memory_region_is_iommu (section->mr)) || memory_region_is_protected(section->mr) ||
@@ -368,9 +373,9 @@ static bool vfio_known_safe_misalignment(MemoryRegionSection *section) }static bool vfio_listener_valid_section (MemoryRegionSection *section, -const char *name) +bool bypass_ro,const char *name) { -if (vfio_listener_skipped_section (section)) { +if (vfio_listener_skipped_section (section, bypass_ro)) { trace_vfio_listener_region_skip(name, section->offset_within_address_space, section->offset_within_address_space +
@@ -497,7 +502,7 @@ void vfio_container_region_add(VFIOContainer *bcontainer,int ret;Error *err =NULL ; -if (!vfio_listener_valid_section (section,"region_add" )) { +if (!vfio_listener_valid_section (section, false,"region_add" )) {return ; }
@@ -663,7 +668,7 @@ static void vfio_listener_region_del(MemoryListener *listener,int ret;bool try_unmap = true; -if (!vfio_listener_valid_section (section,"region_del" )) { +if (!vfio_listener_valid_section (section, false,"region_del" )) {return ; }
@@ -722,9 +727,10 @@ static void vfio_listener_region_del(MemoryListener *listener, }/* -* Fake an IOTLB entry for identity mapping which is needed by dirty -* tracking when switch out of PT domain. In fact, in unmap_bitmap, -* only translated_addr field is used to set dirty bitmap. +* Fake an IOTLB entry for writable identity mapping which is needed +* by dirty tracking when switch out of PT domain. In fact, in +* unmap_bitmap, only translated_addr field is used to set dirty +* bitmap. * * Note: When switch into PT domain from DMA domain, the whole IOMMU * MR is deleted without iotlb, before that happen, we depend on
@@ -733,7 +739,8 @@ static void vfio_listener_region_del(MemoryListener *listener,* it is triggered during switching to block domain because vtd does * not support direct switching from DMA to PT domain. */ -if (global_dirty_tracking &&memory_region_is_ram (section->mr)) { +if (global_dirty_tracking &&memory_region_is_ram (section->mr) && + !section->readonly) { entry.iova = iova; entry.translated_addr = iova; iotlb = &entry;
@@ -841,7 +848,8 @@ static void vfio_dirty_tracking_update(MemoryListener *listener,container_of (listener, VFIODirtyRangesListener, listener);hwaddr iova, end; -if (!vfio_listener_valid_section (section,"tracking_update" ) || +/* Bypass readonly section as it never becomes dirty */ +if (!vfio_listener_valid_section (section, true,"tracking_update" ) || !vfio_get_section_iova_range (dirty->bcontainer, section, &iova, &end,NULL )) {return ;
@@ -1100,6 +1108,19 @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)if (!mr) { goto out_unlock; } + +/* +* The mapping is readonly when either it's a readonly mapping in guest +* or mapped target is readonly, bypass it for dirty tracking as it +* never becomes dirty. +*/ +if (!(iotlb->perm &IOMMU_WO ) || mr->readonly) { +trace_vfio_iommu_map_dirty_notify_skip_ro (iova, + iova + iotlb->addr_mask); +rcu_read_unlock (); +return ; + } + translated_addr =memory_region_get_ram_addr (mr) + xlat; ret = vfio_container_query_dirty_bitmap(bcontainer, iova, iotlb->addr_mask + 1,
@@ -1235,7 +1256,12 @@ static void vfio_listener_log_sync(MemoryListener *listener,int ret;Error *local_err =NULL ; -if (vfio_listener_skipped_section (section)) { +/* +* Bypass readonly section as it never becomes dirty, iommu memory section +* is RW and never bypassed. The readonly mappings in iommu MR are bypassed +* in vfio_iommu_map_dirty_notify(). +*/ +if (vfio_listener_skipped_section (section, true)) {return ; }
hw/vfio/trace-events +1 -0
@@ -103,6 +103,7 @@ vfio_listener_region_del(uint64_t start, uint64_t end) "region_del 0x%"PRIx64" - vfio_device_dirty_tracking_update(uint64_t start, uint64_t end, uint64_t min, uint64_t max) "section 0x%"PRIx64" - 0x%"PRIx64" -> update [0x%"PRIx64" - 0x%"PRIx64"]" vfio_device_dirty_tracking_start(int nr_ranges, uint64_t min32, uint64_t max32, uint64_t min64, uint64_t max64, uint64_t minpci, uint64_t maxpci) "nr_ranges %d 32:[0x%"PRIx64" - 0x%"PRIx64"], 64:[0x%"PRIx64" - 0x%"PRIx64"], pci64:[0x%"PRIx64" - 0x%"PRIx64"]" vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64 +vfio_iommu_map_dirty_notify_skip_ro(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64 # container.c vfio_container_query_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t backend_flag, uint64_t bitmap_size, uint64_t translated_addr, uint64_t dirty_pages) "iova=0x%"PRIx64" size=0x%"PRIx64" backend_flag=0x%"PRIx64" bitmap_size=0x%"PRIx64" gpa=0x%"PRIx64" dirty_pages=%"PRIu64
Signature · 1 line
2.47.1
PATCH v10 4/4 Workaround for ERRATA_772415_SPR17
In reply to Zhenzhong DuanOn a system influenced by ERRATA_772415, IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17 is repored by IOMMU_DEVICE_GET_HW_INFO. Due to this errata, even the readonly range mapped on second stage page table could still be written.
Reference from 4th Gen Intel Xeon Processor Scalable Family Specification
Update, Errata Details, SPR17.
Link https://edc.intel.com/content/www/us/en/design/products-and-solutions/processors-and-chipsets/eagle-stream/sapphire-rapids-specification-update/
Backup https://cdrdv2.intel.com/v1/dl/getContent/772415
Also copied the SPR17 details from above link:
"Problem: When remapping hardware is configured by system software in scalable mode as Nested (PGTT=011b) and with PWSNP field Set in the PASID-table-entry, it may Set Accessed bit and Dirty bit (and Extended Access bit if enabled) in first-stage page-table entries even when second-stage mappings indicate that corresponding first-stage page-table is Read-Only.
Implication: Due to this erratum, pages mapped as Read-only in second-stage page-tables may be modified by remapping hardware Access/Dirty bit updates.
Workaround: None identified. System software enabling nested translations for a VM should ensure that there are no read-only pages in the corresponding second-stage mappings."
Introduce a helper vfio_device_get_host_iommu_quirk_bypass_ro to check if readonly mappings should be bypassed.
--- docs/devel/vfio-iommufd.rst | 9 +++++++++ include/hw/vfio/vfio-container.h | 1 + include/hw/vfio/vfio-device.h | 3 +++ hw/vfio/device.c | 14 ++++++++++++++ hw/vfio/iommufd.c | 9 ++++++++- hw/vfio/listener.c | 6 ++++-- 6 files changed, 39 insertions(+), 3 deletions(-)
docs/devel/vfio-iommufd.rst +9 -0
@@ -181,3 +181,12 @@ otherwise below error shows: .. code-block:: none qemu-system-x86_64: -device vfio-pci,host=0000:02:00.0,bus=bridge1,iommufd=iommufd0: vfio 0000:02:00.0: Failed to set vIOMMU: Host device downstream to a PCI bridge is unsupported when x-flts=on + +If host IOMMU has ERRATA_772415_SPR17, running guest with "intel_iommu=on,sm_off" +is unsupported, kexec or reboot guest from "intel_iommu=on,sm_on" to +"intel_iommu=on,sm_off" is also unsupported. Configure scalable mode off as +below if it's not needed by guest: + +.. code-block:: bash + + -device intel-iommu,x-scalable-mode=off
include/hw/vfio/vfio-container.h +1 -0
@@ -52,6 +52,7 @@ struct VFIOContainer { QLIST_HEAD(, VFIODevice) device_list;GList *iova_ranges;NotifierWithReturn cpr_reboot_notifier; +bool bypass_ro; };#define TYPE_VFIO_IOMMU "vfio-iommu"
include/hw/vfio/vfio-device.h +3 -0
@@ -268,6 +268,9 @@ void vfio_device_prepare(VFIODevice *vbasedev, VFIOContainer *bcontainer,void vfio_device_unprepare (VFIODevice *vbasedev);bool vfio_device_get_viommu_flags_want_nesting (VFIODevice *vbasedev); +bool vfio_device_get_host_iommu_quirk_bypass_ro (VFIODevice *vbasedev, +uint32_t type,void *caps, +uint32_t size);int vfio_device_get_region_info (VFIODevice *vbasedev,int index,struct vfio_region_info **info);
hw/vfio/device.c +14 -0
@@ -533,6 +533,20 @@ bool vfio_device_get_viommu_flags_want_nesting(VFIODevice *vbasedev)return false; } +bool vfio_device_get_host_iommu_quirk_bypass_ro (VFIODevice *vbasedev, +uint32_t type,void *caps, +uint32_t size) +{ +VFIOPCIDevice *vdev =vfio_pci_from_vfio_device (vbasedev); + +if (vdev) { +return !!(pci_device_get_host_iommu_quirks (PCI_DEVICE (vdev), type, + caps, size) & +HOST_IOMMU_QUIRK_NESTING_PARENT_BYPASS_RO ); + } +return false; +} +/* * Traditional ioctl() based io */
hw/vfio/iommufd.c +8 -1
@@ -351,6 +351,7 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *vbasedev,VFIOContainer *bcontainer =VFIO_IOMMU (container);uint32_t type, flags =0 ;uint64_t hw_caps; +VendorCaps caps;VFIOIOASHwpt *hwpt;uint32_t hwpt_id;int ret;
@@ -396,7 +397,8 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *vbasedev,* instead. */ if (!iommufd_backend_get_device_info (vbasedev->iommufd, vbasedev->devid, - &type,NULL ,0 , &hw_caps, errp)) { + &type, &caps,sizeof (caps), &hw_caps, + errp)) {return false; }
@@ -411,6 +413,11 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *vbasedev,*/ if (vfio_device_get_viommu_flags_want_nesting (vbasedev)) { flags |=IOMMU_HWPT_ALLOC_NEST_PARENT ; + +if (vfio_device_get_host_iommu_quirk_bypass_ro (vbasedev, type, + &caps,sizeof (caps))) { + bcontainer->bypass_ro = true; + } }if (cpr_is_incoming ()) {
hw/vfio/listener.c +4 -2
@@ -502,7 +502,8 @@ void vfio_container_region_add(VFIOContainer *bcontainer,int ret;Error *err =NULL ; -if (!vfio_listener_valid_section (section, false,"region_add" )) { +if (!vfio_listener_valid_section (section, bcontainer->bypass_ro, +"region_add" )) {return ; }
@@ -668,7 +669,8 @@ static void vfio_listener_region_del(MemoryListener *listener,int ret;bool try_unmap = true; -if (!vfio_listener_valid_section (section, false,"region_del" )) { +if (!vfio_listener_valid_section (section, bcontainer->bypass_ro, +"region_del" )) {return ; }
Signature · 1 line
2.47.1
Quoted 57 lines · Zhenzhong Duan
Hi,
Based on Cédric's suggestions[1], The nesting series v8 is split to "base nesting series" + "
ERRATA_772415_SPR17quirk series", this is theERRATA_772415_SPR17quirk series.On a system influenced by
ERRATA_772415,IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17is repored byIOMMU_DEVICE_GET_HW_INFO. Due to this errata, even the readonly range mapped on second stage page table could still be written.Reference from 4th Gen Intel Xeon Processor Scalable Family Specification
Update, Errata Details, SPR17.
Link https://edc.intel.com/content/www/us/en/design/products-and-solutions/processors-and-chipsets/eagle-stream/sapphire-rapids-specification-update/
Backup link https://cdrdv2.intel.com/v1/dl/getContent/772415Also copied the SPR17 details from above link:
"Problem: When remapping hardware is configured by system software in scalable mode as Nested (PGTT=011b) and with PWSNP field Set in the PASID-table-entry, it may Set Accessed bit and Dirty bit (and Extended Access bit if enabled) in first-stage page-table entries even when second-stage mappings indicate that corresponding first-stage page-table is Read-Only.Implication: Due to this erratum, pages mapped as Read-only in second-stage page-tables may be modified by remapping hardware Access/Dirty bit updates.
Workaround: None identified. System software enabling nested translations for a VM should ensure that there are no read-only pages in the corresponding second-stage mappings."
QEMU code can be found at [2], it's based after below two series:
[PATCH v10 00/19]
intel_iommu: Enable first stage translation for passthrough device [PATCH v6 0/9] vfio: relax the vIOMMU checkThanks
ZhenzhongChangelog:
v10:
- All headers underinclude/hw/have been moved toinclude/hw/core/, do the same foriommu.h(Cédric)v9:
This is a new split from nesting series, see the link[3] for history changelog.[1] https://lore.kernel.org/qemu-devel/[email protected]/
[2] https://github.com/yiliu1765/qemu/tree/zhenzhong/iommufd_nesting_ERRATA_772415.v10
[3] https://lore.kernel.org/qemu-devel/[email protected]/Zhenzhong Duan (4):
hw/pci: Introducepci_device_get_host_iommu_quirks()
intel_iommu_accel: Implementget_host_iommu_quirks()callback vfio/listener: Bypass readonly region for dirty tracking Workaround forERRATA_772415_SPR17
Quoted 14 lines
docs/devel/vfio-iommufd.rst | 9 ++++++ hw/i386/intel_iommu_accel.h | 5 ++++ include/hw/core/iommu.h | 5 ++++ include/hw/pci/pci.h | 31 ++++++++++++++++++++ include/hw/vfio/vfio-container.h | 1 + include/hw/vfio/vfio-device.h | 3 ++ hw/i386/intel_iommu.c | 2 ++ hw/i386/intel_iommu_accel.c | 21 ++++++++++++++ hw/pci/pci.c | 12 ++++++++ hw/vfio/device.c | 14 +++++++++ hw/vfio/iommufd.c | 9 +++++- hw/vfio/listener.c | 50 +++++++++++++++++++++++++------- hw/vfio/trace-events | 1 + 13 files changed, 151 insertions(+), 12 deletions(-)
Thanks,
C.
Cédric Le Goater
AppliedQuoted 57 lines · Zhenzhong Duan
Hi,
Based on Cédric's suggestions[1], The nesting series v8 is split to "base nesting series" + "
ERRATA_772415_SPR17quirk series", this is theERRATA_772415_SPR17quirk series.On a system influenced by
ERRATA_772415,IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17is repored byIOMMU_DEVICE_GET_HW_INFO. Due to this errata, even the readonly range mapped on second stage page table could still be written.Reference from 4th Gen Intel Xeon Processor Scalable Family Specification
Update, Errata Details, SPR17.
Link https://edc.intel.com/content/www/us/en/design/products-and-solutions/processors-and-chipsets/eagle-stream/sapphire-rapids-specification-update/
Backup link https://cdrdv2.intel.com/v1/dl/getContent/772415Also copied the SPR17 details from above link:
"Problem: When remapping hardware is configured by system software in scalable mode as Nested (PGTT=011b) and with PWSNP field Set in the PASID-table-entry, it may Set Accessed bit and Dirty bit (and Extended Access bit if enabled) in first-stage page-table entries even when second-stage mappings indicate that corresponding first-stage page-table is Read-Only.Implication: Due to this erratum, pages mapped as Read-only in second-stage page-tables may be modified by remapping hardware Access/Dirty bit updates.
Workaround: None identified. System software enabling nested translations for a VM should ensure that there are no read-only pages in the corresponding second-stage mappings."
QEMU code can be found at [2], it's based after below two series:
[PATCH v10 00/19]
intel_iommu: Enable first stage translation for passthrough device [PATCH v6 0/9] vfio: relax the vIOMMU checkThanks
ZhenzhongChangelog:
v10:
- All headers underinclude/hw/have been moved toinclude/hw/core/, do the same foriommu.h(Cédric)v9:
This is a new split from nesting series, see the link[3] for history changelog.[1] https://lore.kernel.org/qemu-devel/[email protected]/
[2] https://github.com/yiliu1765/qemu/tree/zhenzhong/iommufd_nesting_ERRATA_772415.v10
[3] https://lore.kernel.org/qemu-devel/[email protected]/Zhenzhong Duan (4):
hw/pci: Introducepci_device_get_host_iommu_quirks()
intel_iommu_accel: Implementget_host_iommu_quirks()callback vfio/listener: Bypass readonly region for dirty tracking Workaround forERRATA_772415_SPR17
Quoted 15 lines
docs/devel/vfio-iommufd.rst | 9 ++++++ hw/i386/intel_iommu_accel.h | 5 ++++ include/hw/core/iommu.h | 5 ++++ include/hw/pci/pci.h | 31 ++++++++++++++++++++ include/hw/vfio/vfio-container.h | 1 + include/hw/vfio/vfio-device.h | 3 ++ hw/i386/intel_iommu.c | 2 ++ hw/i386/intel_iommu_accel.c | 21 ++++++++++++++ hw/pci/pci.c | 12 ++++++++ hw/vfio/device.c | 14 +++++++++ hw/vfio/iommufd.c | 9 +++++- hw/vfio/listener.c | 50 +++++++++++++++++++++++++------- hw/vfio/trace-events | 1 + 13 files changed, 151 insertions(+), 12 deletions(-)
Applied to vfio-next.
Thanks,
C.