From: Wei Wang2 Subject: [PATCH 1/3] AMD IOMMU: Allocate I/O pagetable from domheap instead of xenheap Date: Fri, 9 Jan 2009 16:42:48 +0100 Message-ID: <1231515769.3380.195.camel@gran.amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-LOb/sCMoxKEj22XgQmOY" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel List-Id: xen-devel@lists.xenproject.org --=-LOb/sCMoxKEj22XgQmOY Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Changes to header files. Signed-off-by: Wei Wang (reviewed by Wei Huang) --=20 AMD GmbH, Germany Operating System Research Center Legal Information: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34 85609 Dornach b. M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Jochen Polster, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis M=C3=BCnchen Registergericht M=C3=BCnchen, HRB Nr. 43632 --=-LOb/sCMoxKEj22XgQmOY Content-Disposition: attachment; filename="iommu_header.patch" Content-Type: text/x-patch; name="iommu_header.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit diff -r f827181eadd4 xen/include/asm-x86/hvm/svm/amd-iommu-proto.h --- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h Mon Dec 15 11:37:14 2008 +0000 +++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h Thu Dec 18 14:50:51 2008 +0100 @@ -23,6 +23,7 @@ #include #include +#include #define for_each_amd_iommu(amd_iommu) \ list_for_each_entry(amd_iommu, \ @@ -59,7 +60,7 @@ int __init amd_iommu_setup_shared_tables /* mapping functions */ int amd_iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn); int amd_iommu_unmap_page(struct domain *d, unsigned long gfn); -void *amd_iommu_get_vptr_from_page_table_entry(u32 *entry); +u64 amd_iommu_get_next_table_from_pte(u32 *entry); int amd_iommu_reserve_domain_unity_map(struct domain *domain, unsigned long phys_addr, unsigned long size, int iw, int ir); int amd_iommu_sync_p2m(struct domain *d); @@ -69,8 +70,7 @@ void amd_iommu_set_dev_table_entry(u32 * void amd_iommu_set_dev_table_entry(u32 *dte, u64 root_ptr, u64 intremap_ptr, u16 domain_id, u8 sys_mgt, u8 dev_ex, u8 paging_mode); int amd_iommu_is_dte_page_translation_valid(u32 *entry); -void invalidate_dev_table_entry(struct amd_iommu *iommu, - u16 devic_id); +void invalidate_dev_table_entry(struct amd_iommu *iommu, u16 devic_id); /* send cmd to iommu */ int send_iommu_command(struct amd_iommu *iommu, u32 cmd[]); @@ -117,4 +117,36 @@ static inline unsigned long region_to_pa return (PAGE_ALIGN(addr + size) - (addr & PAGE_MASK)) >> PAGE_SHIFT; } +static inline struct page_info* alloc_amd_iommu_pgtable(void) +{ + struct page_info *pg; + void *vaddr; + + pg = alloc_domheap_page(NULL, 0); + vaddr = map_domain_page(page_to_mfn(pg)); + if ( !vaddr ) + return 0; + memset(vaddr, 0, PAGE_SIZE); + unmap_domain_page(vaddr); + return pg; +} + +static inline void free_amd_iommu_pgtable(struct page_info *pg) +{ + if ( pg != 0 ) + free_domheap_page(pg); +} + +static inline void* __alloc_amd_iommu_tables(int order) +{ + void *buf; + buf = alloc_xenheap_pages(order); + return buf; +} + +static inline void __free_amd_iommu_tables(void *table, int order) +{ + free_xenheap_pages(table, order); +} + #endif /* _ASM_X86_64_AMD_IOMMU_PROTO_H */ diff -r f827181eadd4 xen/include/xen/hvm/iommu.h --- a/xen/include/xen/hvm/iommu.h Mon Dec 15 11:37:14 2008 +0000 +++ b/xen/include/xen/hvm/iommu.h Thu Dec 18 14:50:51 2008 +0100 @@ -40,7 +40,7 @@ struct hvm_iommu { /* amd iommu support */ int domain_id; int paging_mode; - void *root_table; + struct page_info *root_table; bool_t p2m_synchronized; /* iommu_ops */ --=-LOb/sCMoxKEj22XgQmOY Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-LOb/sCMoxKEj22XgQmOY--