[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 10/18] AMD/IOMMU: walk trees upon page fault
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Fri, 3 Dec 2021 10:03:57 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WI9aRrIp3kYZU1ve/fDRSPtNCQR2u1WhLMi3rVoaJtw=; b=gCnu5ahXcY2Ub8O3R8nop5Yl+pICi2PVKuR3DAshqy1A2tUmf6e3vk6TQdkHG7xhzo59fjEk0B5nlD5hzBVFP0f9QJ2ABMYEHOYv/a8u3MNaUyVsNCtL1+h/D7lMo48nJ6o+xelsCtxpAarqNnND8nM1sciCEqK2XB8JrGsJDeiLnt3mfMD/rpwZIZLxtOX4lFGN7DzmsONW/wypYeuVRGcXSnsfcMkhzNMQH9mq/wboksX4DVv09rQg8zTda/tv5j5pkUO1WXPBW9nRdOA2yYe6MFLvhFdbIFgDh445o4UAn4nc7llpPbl+ZlNBCQaMvwjzSzdmOtbnEM/dTYYU/Q==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J9TdPtrTwL++mRb4i4Y7AYj+tFdw85fhLjcf0cA6CGXxCHMVhu7IPAnJSUMVf6jv0aqZ3DcFbPtLQxBz/3iJNgzPQznpabtqEt6E1sa10oIIYk9XWm/Y2yRKXKZFGsNXe6riRR04NIQV8Gumlq0xnVi/BFetOL8z9IMop6E+TbnCiUBSP68t01Y2JmxQISpDAkyjpVbKKuHjeASwFL/T3oJplNXRPa6kGJWbRWBA/YzGmkKX8+/IvhcCHWNSM8RWRRrgoN0v5I8V+s7XGIo5cOvgzFjJ+9yVLAy83Ug/0fp8dFSKTQ7iqtzDyjddfkS5yZnAOUL7M15wu+GcnR0iqQ==
- Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>
- Delivery-date: Fri, 03 Dec 2021 09:04:30 +0000
- Ironport-data: A9a23:Kcmemqh91P3ruSlxgyuBWWYFX161uBcKZh0ujC45NGQN5FlHY01je htvCGDVPKyMajDzfYp/bYmxoBkFu57SyNFlHQQ+rnxnHigb9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oAMKRCQ7InQLlbGILes1htZGEk0F0/NtTo5w7Rg29Qw24Dia++wk YiaT/P3aQfNNwFcagr424rbwP+4lK2v0N+wlgVWicFj5DcypVFMZH4sDfjZw0/DaptVBoaHq 9Prl9lVyI97EyAFUbtJmp6jGqEDryW70QKm0hK6UID66vROS7BbPg/W+5PwZG8O4whlkeydx /0XvJacag4mEZHulfkCAyRpTS9/YJBJreqvzXiX6aR/zmXDenrohf5vEFs3LcsT/eMf7WNmr KJCbmpXN1ba2rzwkOnTpupE36zPKOHxO4wSoDd4xCzxBvc6W5HTBa7N4Le02R9t15oWQKeCN qL1bxJFdwyQYC9uJ2wYGbwwpMbxmmP/KR9X/Qf9Sa0fvDGIkV0ZPKLWGMLcZ9iiVchT2EGCq Qru72n/Rx0XKtGb4T6E6W63wP/CmzvhX4AfH6H+8eRl6HWRzGEODBwdVXOgvOK0zEW5Xrpix 1c8o3R06/JorQryE4e7D0bQTGO4UgA0AdNaP84z5y6x6KfJ/FakNzYKT2N8Z4lz3CMpfgAC2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bESt6+Ti2PZYrVQseVvsprY/ds2p00dMj2CAJsQiTuRZDzrdnGfE2J9dOYE/d enl4F6jgvlXU5SQtWwB3EDUeSGj9rXlKj+aRpDIxI88gGBgR6h9ba/SnGjr1ojegIK5Y1n3X nOkgT/6Knmm/anyiXE32uWy5hNgtPuxvZKGcTJoMkILTfHjBquee1aKve/lQFwhNvqxEchkd HKrRtlF8Nv60nJdmXwmhfp0xmI6kdZ11bSjXujxVfzq83wQzw3T+Bbg5hCTxff4008+Plhza NixQuixtRqJCKFuB64y8nDVhlsmEbxi2Eli/Qvg3tWVpZbQKNNrLYY4FheHP47bW3HAbgcYa lT5fznlbVrmQvwVQGagoAv+q3hYp0LJGbGfqBY0fbllgS/nxhCvjwlLYIk7zM9HakGOup5Dt L/Q9BVfYF1P78rhJ1GdZU8qOuMeyXwqEH3QSqvyWqOLtBzB5uKke+x3IkI
- Ironport-sdr: qqRnkPFvuRsHRAXyYFZ5dwLfOjRXbbYOympJQt9/7LfsKqbcEXZrrN+mF29qNeefkb+eunaf12 GZbEQxAj/7T54dJnlfABdnMU+ko5gP+Mc6AMIwcAAZ/8qZQPhcZ+5n+CTcYrze6uO6tNSykMwV ujQXHl4lS02xVk7lGUlFdTholW7lWeI7OqMBh5+NskI1/5eMbokOeruB0HIpY2RACxTS1rMifz 1mmFwfevU7rrR43wGtVuksDBudZb4vDocVyr1sagM7CBxQjuV+Hs8RdFO6Imn2vXooFrvmph4A DseDg9OZISf9nJZO0FslP9eK
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Fri, Sep 24, 2021 at 11:51:15AM +0200, Jan Beulich wrote:
> This is to aid diagnosing issues and largely matches VT-d's behavior.
> Since I'm adding permissions output here as well, take the opportunity
> and also add their displaying to amd_dump_page_table_level().
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>
> --- a/xen/drivers/passthrough/amd/iommu.h
> +++ b/xen/drivers/passthrough/amd/iommu.h
> @@ -243,6 +243,8 @@ int __must_check amd_iommu_flush_iotlb_p
> unsigned long page_count,
> unsigned int flush_flags);
> int __must_check amd_iommu_flush_iotlb_all(struct domain *d);
> +void amd_iommu_print_entries(const struct amd_iommu *iommu, unsigned int
> dev_id,
> + dfn_t dfn);
>
> /* device table functions */
> int get_dma_requestor_id(uint16_t seg, uint16_t bdf);
> --- a/xen/drivers/passthrough/amd/iommu_init.c
> +++ b/xen/drivers/passthrough/amd/iommu_init.c
> @@ -573,6 +573,9 @@ static void parse_event_log_entry(struct
> (flags & 0x002) ? " NX" : "",
> (flags & 0x001) ? " GN" : "");
>
> + if ( iommu_verbose )
> + amd_iommu_print_entries(iommu, device_id, daddr_to_dfn(addr));
> +
> for ( bdf = 0; bdf < ivrs_bdf_entries; bdf++ )
> if ( get_dma_requestor_id(iommu->seg, bdf) == device_id )
> pci_check_disable_device(iommu->seg, PCI_BUS(bdf),
> --- a/xen/drivers/passthrough/amd/iommu_map.c
> +++ b/xen/drivers/passthrough/amd/iommu_map.c
> @@ -363,6 +363,50 @@ int amd_iommu_unmap_page(struct domain *
> return 0;
> }
>
> +void amd_iommu_print_entries(const struct amd_iommu *iommu, unsigned int
> dev_id,
> + dfn_t dfn)
> +{
> + mfn_t pt_mfn;
> + unsigned int level;
> + const struct amd_iommu_dte *dt = iommu->dev_table.buffer;
> +
> + if ( !dt[dev_id].tv )
> + {
> + printk("%pp: no root\n", &PCI_SBDF2(iommu->seg, dev_id));
> + return;
> + }
> +
> + pt_mfn = _mfn(dt[dev_id].pt_root);
> + level = dt[dev_id].paging_mode;
> + printk("%pp root @ %"PRI_mfn" (%u levels) dfn=%"PRI_dfn"\n",
> + &PCI_SBDF2(iommu->seg, dev_id), mfn_x(pt_mfn), level, dfn_x(dfn));
> +
> + while ( level )
> + {
> + const union amd_iommu_pte *pt = map_domain_page(pt_mfn);
> + unsigned int idx = pfn_to_pde_idx(dfn_x(dfn), level);
> + union amd_iommu_pte pte = pt[idx];
Don't you need to take a lock here (mapping_lock maybe?) in order to
prevent changes to the IOMMU page tables while walking them?
Thanks, Roger.
|