amd-iommu: get rid of pointless IOMMU_PAGING_MODE_LEVEL_X definitions
PATCH 1/1 amd-iommu: get rid of pointless IOMMU_PAGING_MODE_LEVEL_X definitions
The levels are absolute numbers such that IOMMU_PAGING_MODE_LEVEL_X evaluates to X (for the valid range of 0 - 7) so simply use numbers in the code.
No functional change.
NOTE: This patch also adds emacs boilerplate to amd-iommu-defs.h
---
Cc: Suravee Suthikulpanit <[email protected]>
Cc: Brian Woods <[email protected]>
--- xen/drivers/passthrough/amd/iommu_map.c | 26 +++++++++++--------------- xen/drivers/passthrough/amd/pci_amd_iommu.c | 4 +--- xen/include/asm-x86/hvm/svm/amd-iommu-defs.h | 21 +++++++++++---------- 3 files changed, 23 insertions(+), 28 deletions(-)
xen/drivers/passthrough/amd/iommu_map.c +11 -15
@@ -40,7 +40,7 @@ void clear_iommu_pte_present(unsigned long l1_mfn, unsigned long gfn)u64 *table, *pte; table =map_domain_page (_mfn (l1_mfn)); - pte = table +pfn_to_pde_idx (gfn,IOMMU_PAGING_MODE_LEVEL_1 ); + pte = table +pfn_to_pde_idx (gfn,1 ); *pte =0 ;unmap_domain_page (table); }
@@ -84,7 +84,7 @@ static bool_t set_iommu_pde_present(u32 *pde, unsigned long next_mfn,/* FC bit should be enabled in PTE, this helps to solve potential * issues with ATS devices */ -if ( next_level ==IOMMU_PAGING_MODE_LEVEL_0 ) +if ( next_level ==0 )set_field_in_reg_u32 (IOMMU_CONTROL_ENABLED , entry,IOMMU_PTE_FC_MASK ,IOMMU_PTE_FC_SHIFT , &entry); pde[1 ] = entry;
@@ -116,8 +116,7 @@ static bool_t set_iommu_pte_present(unsigned long pt_mfn, unsigned long gfn, pde = (u32 *)(table +pfn_to_pde_idx (gfn, pde_level)); - need_flush =set_iommu_pde_present (pde, next_mfn, -IOMMU_PAGING_MODE_LEVEL_0 , iw, ir); + need_flush =set_iommu_pde_present (pde, next_mfn,0 , iw, ir);unmap_domain_page (table);return need_flush; }
@@ -419,8 +418,7 @@ static int iommu_merge_pages(struct domain *d, unsigned long pt_mfn, }/* setup super page mapping, next level = 0 */ -set_iommu_pde_present ((u32 *)pde, first_mfn, -IOMMU_PAGING_MODE_LEVEL_0 , +set_iommu_pde_present ((u32 *)pde, first_mfn,0 , !!(flags & IOMMUF_writable), !!(flags & IOMMUF_readable));
@@ -447,18 +445,17 @@ static int iommu_pde_from_gfn(struct domain *d, unsigned long pfn, table = hd->arch.root_table; level = hd->arch.paging_mode; -BUG_ON ( table ==NULL || level <IOMMU_PAGING_MODE_LEVEL_1 || - level >IOMMU_PAGING_MODE_LEVEL_6 ); +BUG_ON ( table ==NULL || level <1 || level >6 ); next_table_mfn =mfn_x (page_to_mfn (table)); -if ( level ==IOMMU_PAGING_MODE_LEVEL_1 ) +if ( level ==1 ) { pt_mfn[level] = next_table_mfn;return 0 ; } -while ( level >IOMMU_PAGING_MODE_LEVEL_1 ) +while ( level >1 ) {unsigned int next_level = level -1 ; pt_mfn[level] = next_table_mfn;
@@ -676,8 +673,7 @@ int amd_iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn, }/* Install 4k mapping first */ - need_flush =set_iommu_pte_present (pt_mfn[1 ], gfn, mfn, -IOMMU_PAGING_MODE_LEVEL_1 , + need_flush =set_iommu_pte_present (pt_mfn[1 ], gfn, mfn,1 , !!(flags & IOMMUF_writable), !!(flags & IOMMUF_readable));
@@ -690,8 +686,8 @@ int amd_iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn,if (is_hvm_domain (d) )amd_iommu_flush_pages (d, gfn,0 ); -for ( merge_level =IOMMU_PAGING_MODE_LEVEL_2 ; - merge_level <= hd->arch.paging_mode; merge_level++ ) +for ( merge_level =2 ; merge_level <= hd->arch.paging_mode; + merge_level++ ) {if ( pt_mfn[merge_level] ==0 )break ;
@@ -808,7 +804,7 @@ void amd_iommu_share_p2m(struct domain *d) hd->arch.root_table = p2m_table;/* When sharing p2m with iommu, paging mode = 4 */ - hd->arch.paging_mode =IOMMU_PAGING_MODE_LEVEL_4 ; + hd->arch.paging_mode =4 ;AMD_IOMMU_DEBUG ("Share p2m table with iommu: p2m table = %#lx\n" ,mfn_x (pgd_mfn)); }
xen/drivers/passthrough/amd/pci_amd_iommu.c +1 -3
@@ -240,9 +240,7 @@ static int amd_iommu_domain_init(struct domain *d)/* For pv and dom0, stick with get_paging_mode(max_page) * For HVM dom0, use 2 level page table at first */ - hd->arch.paging_mode =is_hvm_domain (d) ? -IOMMU_PAGING_MODE_LEVEL_2 : -get_paging_mode (max_page); + hd->arch.paging_mode =is_hvm_domain (d) ?2 :get_paging_mode (max_page);return 0 ; }
xen/include/asm-x86/hvm/svm/amd-iommu-defs.h +11 -10
@@ -38,8 +38,7 @@ PAGE_SIZE * (PTE_PER_TABLE_ALIGN(entries) >> PTE_PER_TABLE_SHIFT)#define amd_offset_level_address (offset, level) \ - ((u64)(offset) << (12 + (PTE_PER_TABLE_SHIFT * \ - (level - IOMMU_PAGING_MODE_LEVEL_1)))) + ((uint64_t)(offset) << (12 + (PTE_PER_TABLE_SHIFT * ((level) - 1))))#define PCI_MIN_CAP_OFFSET 0x40#define PCI_MAX_CAP_BLOCKS 48
@@ -450,14 +449,6 @@/* Paging modes */ #define IOMMU_PAGING_MODE_DISABLED 0x0 -#define IOMMU_PAGING_MODE_LEVEL_0 0x0 -#define IOMMU_PAGING_MODE_LEVEL_1 0x1 -#define IOMMU_PAGING_MODE_LEVEL_2 0x2 -#define IOMMU_PAGING_MODE_LEVEL_3 0x3 -#define IOMMU_PAGING_MODE_LEVEL_4 0x4 -#define IOMMU_PAGING_MODE_LEVEL_5 0x5 -#define IOMMU_PAGING_MODE_LEVEL_6 0x6 -#define IOMMU_PAGING_MODE_LEVEL_7 0x7/* Flags */ #define IOMMU_CONTROL_DISABLED 0
@@ -498,3 +489,13 @@#define IOMMU_REG_BASE_ADDR_HIGH_SHIFT 0#endif /* _ASM_X86_64_AMD_IOMMU_DEFS_H */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Ping? Can I get an ack or otherwise from an AMD maintainer?
Quoted 195 lines
-----Original Message-----
From: Paul Durrant [mailto:[email protected]]
Sent: 27 September 2018 13:46
To: [email protected]
Cc: Paul Durrant <[email protected]>; Suravee Suthikulpanit <[email protected]>; Brian Woods <[email protected]>
Subject: [PATCH] amd-iommu: get rid of pointlessIOMMU_PAGING_MODE_LEVEL_XdefinitionsThe levels are absolute numbers such that
IOMMU_PAGING_MODE_LEVEL_Xevaluates to X (for the valid range of 0 - 7) so simply use numbers in the code.No functional change.
NOTE: This patch also adds emacs boilerplate to
amd-iommu-defs.hSigned-off-by Paul Durrant <[email protected]>---
Cc: Suravee Suthikulpanit <[email protected]>
Cc: Brian Woods <[email protected]>--- xen/drivers/passthrough/amd/iommu_map.c | 26 +++++++++++------------ --- xen/drivers/passthrough/amd/pci_amd_iommu.c | 4 +--- xen/include/asm-x86/hvm/svm/amd-iommu-defs.h | 21 +++++++++++---------- 3 files changed, 23 insertions(+), 28 deletions(-)xen/drivers/passthrough/amd/iommu_map.c +1
-1@@ -40,7 +40,7 @@ void clear_iommu_pte_present(unsigned long l1_mfn, unsigned long gfn) u64 *table, *pte; table =map_domain_page (_mfn (l1_mfn)); - pte = table +pfn_to_pde_idx (gfn,IOMMU_PAGING_MODE_LEVEL_1 ); + pte = table +pfn_to_pde_idx (gfn,1 ); *pte =0 ;unmap_domain_page (table);}
xen/drivers/passthrough/amd/iommu_map.c +1
-1@@ -84,7 +84,7 @@ static bool_t set_iommu_pde_present(u32 *pde, unsigned long next_mfn, /* FC bit should be enabled in PTE, this helps to solve potential * issues with ATS devices */ - if ( next_level == IOMMU_PAGING_MODE_LEVEL_0 ) + if ( next_level == 0 ) set_field_in_reg_u32(IOMMU_CONTROL_ENABLED, entry, IOMMU_PTE_FC_MASK, IOMMU_PTE_FC_SHIFT,&entry); pde[1] = entry;xen/drivers/passthrough/amd/iommu_map.c +1
-2@@ -116,8 +116,7 @@ static bool_t set_iommu_pte_present(unsigned long pt_mfn, unsigned long gfn, pde = (u32 *)(table +pfn_to_pde_idx (gfn, pde_level)); - need_flush =set_iommu_pde_present (pde, next_mfn, -IOMMU_PAGING_MODE_LEVEL_0 , iw, ir); + need_flush =set_iommu_pde_present (pde, next_mfn,0 , iw, ir);unmap_domain_page (table);return need_flush;}
xen/drivers/passthrough/amd/iommu_map.c +4
-6@@ -419,8 +418,7 @@ static int iommu_merge_pages(struct domain *d, unsigned long pt_mfn, }/* setup super page mapping, next level = 0 */ -set_iommu_pde_present ((u32 *)pde, first_mfn, -IOMMU_PAGING_MODE_LEVEL_0 , +set_iommu_pde_present ((u32 *)pde, first_mfn,0 , !!(flags & IOMMUF_writable), !!(flags & IOMMUF_readable));@@ -447,18 +445,17 @@ static int iommu_pde_from_gfn(struct domain *d,unsigned long pfn, table = hd->arch.root_table; level = hd->arch.paging_mode; -BUG_ON ( table ==NULL || level <IOMMU_PAGING_MODE_LEVEL_1 || - level >IOMMU_PAGING_MODE_LEVEL_6 ); +BUG_ON ( table ==NULL || level <1 || level >6 ); next_table_mfn =mfn_x (page_to_mfn (table)); -if ( level ==IOMMU_PAGING_MODE_LEVEL_1 ) +if ( level ==1 ) { pt_mfn[level] = next_table_mfn;return 0 ; } -while ( level >IOMMU_PAGING_MODE_LEVEL_1 ) +while ( level >1 ) {unsigned int next_level = level -1 ;pt_mfn[level] = next_table_mfn;xen/drivers/passthrough/amd/iommu_map.c +3
-4@@ -676,8 +673,7 @@ int amd_iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn, }/* Install 4k mapping first */ - need_flush =set_iommu_pte_present (pt_mfn[1 ], gfn, mfn, -IOMMU_PAGING_MODE_LEVEL_1 , + need_flush =set_iommu_pte_present (pt_mfn[1 ], gfn, mfn,1 , !!(flags & IOMMUF_writable), !!(flags & IOMMUF_readable));@@ -690,8 +686,8 @@ int amd_iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn, if ( is_hvm_domain(d) ) amd_iommu_flush_pages(d, gfn, 0); -for ( merge_level =IOMMU_PAGING_MODE_LEVEL_2 ; - merge_level <= hd->arch.paging_mode; merge_level++ ) +for ( merge_level =2 ; merge_level <= hd->arch.paging_mode; + merge_level++ ) {if ( pt_mfn[merge_level] ==0 )break;xen/drivers/passthrough/amd/iommu_map.c +1
-1@@ -808,7 +804,7 @@ void amd_iommu_share_p2m(struct domain *d) hd->arch.root_table = p2m_table;/* When sharing p2m with iommu, paging mode = 4 */ - hd->arch.paging_mode =IOMMU_PAGING_MODE_LEVEL_4 ; + hd->arch.paging_mode =4 ;AMD_IOMMU_DEBUG ("Share p2m table with iommu: p2m table = %#lx\n" ,mfn_x (pgd_mfn)); }xen/drivers/passthrough/amd/pci_amd_iommu.c +1
-3@@ -240,9 +240,7 @@ static int amd_iommu_domain_init(struct domain *d)/* For pv and dom0, stick with get_paging_mode(max_page) * For HVM dom0, use 2 level page table at first */ - hd->arch.paging_mode =is_hvm_domain (d) ? -IOMMU_PAGING_MODE_LEVEL_2 : -get_paging_mode (max_page); + hd->arch.paging_mode =is_hvm_domain (d) ?2 :get_paging_mode (max_page);return 0 ; }xen/include/asm-x86/hvm/svm/amd-iommu-defs.h +1
-2@@ -38,8 +38,7 @@ PAGE_SIZE * (PTE_PER_TABLE_ALIGN(entries) >> PTE_PER_TABLE_SHIFT)#define amd_offset_level_address (offset, level) \ - ((u64)(offset) << (12 + (PTE_PER_TABLE_SHIFT * \ - (level - IOMMU_PAGING_MODE_LEVEL_1)))) + ((uint64_t)(offset) << (12 + (PTE_PER_TABLE_SHIFT * ((level) - 1))))#define PCI_MIN_CAP_OFFSET 0x40#define
PCI_MAX_CAP_BLOCKS48xen/include/asm-x86/hvm/svm/amd-iommu-defs.h +10
-9@@ -450,14 +449,6 @@/* Paging modes */ #define IOMMU_PAGING_MODE_DISABLED 0x0 -#define IOMMU_PAGING_MODE_LEVEL_0 0x0 -#define IOMMU_PAGING_MODE_LEVEL_1 0x1 -#define IOMMU_PAGING_MODE_LEVEL_2 0x2 -#define IOMMU_PAGING_MODE_LEVEL_3 0x3 -#define IOMMU_PAGING_MODE_LEVEL_4 0x4 -#define IOMMU_PAGING_MODE_LEVEL_5 0x5 -#define IOMMU_PAGING_MODE_LEVEL_6 0x6 -#define IOMMU_PAGING_MODE_LEVEL_7 0x7/* Flags */ #define IOMMU_CONTROL_DISABLED 0@@ -498,3 +489,13 @@#define IOMMU_REG_BASE_ADDR_HIGH_SHIFT 0#endif /* _ASM_X86_64_AMD_IOMMU_DEFS_H */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/ --
Quoted 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Ping+1
Quoted 211 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Paul Durrant
Sent: 02 October 2018 13:33
To: Suravee Suthikulpanit <[email protected]>; Brian Woods <[email protected]>
Cc: [email protected]
Subject: Re: [Xen-devel] [PATCH] amd-iommu: get rid of pointlessIOMMU_PAGING_MODE_LEVEL_XdefinitionsPing? Can I get an ack or otherwise from an AMD maintainer?
Quoted 7 lines
-----Original Message-----
From: Paul Durrant [mailto:[email protected]]
Sent: 27 September 2018 13:46
To: [email protected]
Cc: Paul Durrant <[email protected]>; Suravee Suthikulpanit <[email protected]>; Brian Woods <[email protected]>
Subject: [PATCH] amd-iommu: get rid of pointless
IOMMU_PAGING_MODE_LEVEL_XQuoted 8 lines
definitions
The levels are absolute numbers such that
IOMMU_PAGING_MODE_LEVEL_Xevaluates to X (for the valid range of 0 - 7) so simply use numbers in the code.No functional change.
Quoted 8 lines
NOTE: This patch also adds emacs boilerplate to
amd-iommu-defs.hSigned-off-by Paul Durrant <[email protected]>---
Cc: Suravee Suthikulpanit <[email protected]>
Cc: Brian Woods <[email protected]>--- xen/drivers/passthrough/amd/iommu_map.c | 26 +++++++++++------------
xen/drivers/passthrough/amd/iommu_map.c int amd_iommu_map_page(struct domain *d, unsigned
Quoted 78 lines
--- xen/drivers/passthrough/amd/pci_amd_iommu.c | 4 +--- xen/include/asm-x86/hvm/svm/amd-iommu-defs.h | 21 +++++++++++---------- 3 files changed, 23 insertions(+), 28 deletions(-)xen/drivers/passthrough/amd/iommu_map.c +1
-1@@ -40,7 +40,7 @@ void clear_iommu_pte_present(unsigned long l1_mfn, unsigned long gfn) u64 *table, *pte; table =map_domain_page (_mfn (l1_mfn)); - pte = table +pfn_to_pde_idx (gfn,IOMMU_PAGING_MODE_LEVEL_1 ); + pte = table +pfn_to_pde_idx (gfn,1 ); *pte =0 ;unmap_domain_page (table);}
xen/drivers/passthrough/amd/iommu_map.c +1
-1@@ -84,7 +84,7 @@ static bool_t set_iommu_pde_present(u32 *pde, unsigned long next_mfn, /* FC bit should be enabled in PTE, this helps to solve potential * issues with ATS devices */ - if ( next_level == IOMMU_PAGING_MODE_LEVEL_0 ) + if ( next_level == 0 ) set_field_in_reg_u32(IOMMU_CONTROL_ENABLED, entry, IOMMU_PTE_FC_MASK, IOMMU_PTE_FC_SHIFT,&entry); pde[1] = entry;xen/drivers/passthrough/amd/iommu_map.c +1
-2@@ -116,8 +116,7 @@ static bool_t set_iommu_pte_present(unsigned long pt_mfn, unsigned long gfn, pde = (u32 *)(table +pfn_to_pde_idx (gfn, pde_level)); - need_flush =set_iommu_pde_present (pde, next_mfn, -IOMMU_PAGING_MODE_LEVEL_0 , iw, ir); + need_flush =set_iommu_pde_present (pde, next_mfn,0 , iw, ir);unmap_domain_page (table);return need_flush;}
xen/drivers/passthrough/amd/iommu_map.c +4
-6@@ -419,8 +418,7 @@ static int iommu_merge_pages(struct domain *d, unsigned long pt_mfn, }/* setup super page mapping, next level = 0 */ -set_iommu_pde_present ((u32 *)pde, first_mfn, -IOMMU_PAGING_MODE_LEVEL_0 , +set_iommu_pde_present ((u32 *)pde, first_mfn,0 , !!(flags & IOMMUF_writable), !!(flags & IOMMUF_readable));@@ -447,18 +445,17 @@ static int iommu_pde_from_gfn(struct domain *d,unsigned long pfn, table = hd->arch.root_table; level = hd->arch.paging_mode; -BUG_ON ( table ==NULL || level <IOMMU_PAGING_MODE_LEVEL_1 || - level >IOMMU_PAGING_MODE_LEVEL_6 ); +BUG_ON ( table ==NULL || level <1 || level >6 ); next_table_mfn =mfn_x (page_to_mfn (table)); -if ( level ==IOMMU_PAGING_MODE_LEVEL_1 ) +if ( level ==1 ) { pt_mfn[level] = next_table_mfn;return 0 ; } -while ( level >IOMMU_PAGING_MODE_LEVEL_1 ) +while ( level >1 ) {unsigned int next_level = level -1 ;pt_mfn[level] = next_table_mfn;xen/drivers/passthrough/amd/iommu_map.c +0
-0@@ -676,8 +673,7 @@ int amd_iommu_map_page(struct domain *d, unsignedlong
xen/drivers/passthrough/amd/iommu_map.c int amd_iommu_map_page(struct domain *d, unsigned
Quoted 11 lines
xen/drivers/passthrough/amd/iommu_map.c +1
-2gfn, unsigned long mfn, }/* Install 4k mapping first */ - need_flush =set_iommu_pte_present (pt_mfn[1 ], gfn, mfn, -IOMMU_PAGING_MODE_LEVEL_1 , + need_flush =set_iommu_pte_present (pt_mfn[1 ], gfn, mfn,1 , !!(flags & IOMMUF_writable), !!(flags & IOMMUF_readable));@@ -690,8 +686,8 @@ int amd_iommu_map_page(struct domain *d, unsignedlong
Quoted 12 lines
xen/drivers/passthrough/amd/iommu_map.c +2
-2gfn, unsigned long mfn, if ( is_hvm_domain(d) ) amd_iommu_flush_pages(d, gfn, 0); -for ( merge_level =IOMMU_PAGING_MODE_LEVEL_2 ; - merge_level <= hd->arch.paging_mode; merge_level++ ) +for ( merge_level =2 ; merge_level <= hd->arch.paging_mode; + merge_level++ ) {if ( pt_mfn[merge_level] ==0 )break;xen/drivers/passthrough/amd/iommu_map.c void amd_iommu_share_p2m(struct domain *d) · line 808
Quoted 6 lines
xen/drivers/passthrough/amd/iommu_map.c +1
-1@@ -808,7 +804,7 @@ void amd_iommu_share_p2m(struct domain *d) hd->arch.root_table = p2m_table;/* When sharing p2m with iommu, paging mode = 4 */ - hd->arch.paging_mode =IOMMU_PAGING_MODE_LEVEL_4 ; + hd->arch.paging_mode =4 ; AMD_IOMMU_DEBUG("Share p2m table with iommu: p2m table =%#lx\n",
Quoted 64 lines
xen/drivers/passthrough/amd/iommu_map.c +0
-0mfn_x(pgd_mfn)); }xen/drivers/passthrough/amd/pci_amd_iommu.c +1
-3@@ -240,9 +240,7 @@ static int amd_iommu_domain_init(struct domain *d)/* For pv and dom0, stick with get_paging_mode(max_page) * For HVM dom0, use 2 level page table at first */ - hd->arch.paging_mode =is_hvm_domain (d) ? -IOMMU_PAGING_MODE_LEVEL_2 : -get_paging_mode (max_page); + hd->arch.paging_mode =is_hvm_domain (d) ?2 :get_paging_mode (max_page);return 0 ; }xen/include/asm-x86/hvm/svm/amd-iommu-defs.h +1
-2@@ -38,8 +38,7 @@ PAGE_SIZE * (PTE_PER_TABLE_ALIGN(entries) >> PTE_PER_TABLE_SHIFT)#define amd_offset_level_address (offset, level) \ - ((u64)(offset) << (12 + (PTE_PER_TABLE_SHIFT * \ - (level - IOMMU_PAGING_MODE_LEVEL_1)))) + ((uint64_t)(offset) << (12 + (PTE_PER_TABLE_SHIFT * ((level) - 1))))#define PCI_MIN_CAP_OFFSET 0x40#define
PCI_MAX_CAP_BLOCKS48xen/include/asm-x86/hvm/svm/amd-iommu-defs.h +10
-8@@ -450,14 +449,6 @@/* Paging modes */ #define IOMMU_PAGING_MODE_DISABLED 0x0 -#define IOMMU_PAGING_MODE_LEVEL_0 0x0 -#define IOMMU_PAGING_MODE_LEVEL_1 0x1 -#define IOMMU_PAGING_MODE_LEVEL_2 0x2 -#define IOMMU_PAGING_MODE_LEVEL_3 0x3 -#define IOMMU_PAGING_MODE_LEVEL_4 0x4 -#define IOMMU_PAGING_MODE_LEVEL_5 0x5 -#define IOMMU_PAGING_MODE_LEVEL_6 0x6 -#define IOMMU_PAGING_MODE_LEVEL_7 0x7/* Flags */ #define IOMMU_CONTROL_DISABLED 0@@ -498,3 +489,13 @@#define IOMMU_REG_BASE_ADDR_HIGH_SHIFT 0#endif /* _ASM_X86_64_AMD_IOMMU_DEFS_H */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
Quoted 8 lines
Quoted 2 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 9 lines · Paul Durrant
The levels are absolute numbers such that
IOMMU_PAGING_MODE_LEVEL_Xevaluates to X (for the valid range of 0 - 7) so simply use numbers in the code.No functional change.
NOTE: This patch also adds emacs boilerplate to
amd-iommu-defs.hSigned-off-by Paul Durrant <[email protected]>
Is there a strong reason to get rid of these? Some of examples below create seemingly magic numbers in the code. While if you're familiar with the functions this isn't a big deal, otherwise you have to dig further to tell.
xen/drivers/passthrough/amd/iommu_map.c static bool_t set_iommu_pte_present(unsigned long pt_mfn, unsigned long gfn, · line 119
Quoted 3 lines
xen/drivers/passthrough/amd/iommu_map.c +2
-0+ pte = table +pfn_to_pde_idx (gfn,1 ); + need_flush =set_iommu_pde_present (pde, next_mfn,0 , iw, ir);
If there's a general consensus that getting rid of these is better, I don't mind and will agree to it.
Signature · 6 lines
Brian Woods _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 16 lines
-----Original Message-----
From: Woods, Brian [mailto:[email protected]]
Sent: 12 October 2018 18:14
To: Paul Durrant <[email protected]>
Cc: [email protected]; Suthikulpanit, Suravee <[email protected]>; Woods, Brian <[email protected]>
Subject: Re: [PATCH] amd-iommu: get rid of pointlessIOMMU_PAGING_MODE_LEVEL_XdefinitionsQuoted 6 lines · Paul Durrant
The levels are absolute numbers such that
IOMMU_PAGING_MODE_LEVEL_Xevaluates to X (for the valid range of 0 - 7) so simply use numbers in the code.No functional change.
Quoted 9 lines
Quoted 3 lines
NOTE: This patch also adds emacs boilerplate to
amd-iommu-defs.hSigned-off-by Paul Durrant <[email protected]>Is there a strong reason to get rid of these? Some of examples below create seemingly magic numbers in the code. While if you're familiar with the functions this isn't a big deal, otherwise you have to dig further to tell.
The numbers aren't magic though. The spec refers to levels by number rather than any sort of name. If the levels were named then it would be absolutely right to #define <level name> <level number>, but that is not the case. Thus IMO getting rid of the definitions actually makes the code clearer for those (like myself) reading the spec.
Quoted 7 lines
xen/drivers/passthrough/amd/iommu_map.c static bool_t set_iommu_pte_present(unsigned long pt_mfn, unsigned long gfn, · line 119
Quoted 3 lines
xen/drivers/passthrough/amd/iommu_map.c +2
-0+ pte = table +pfn_to_pde_idx (gfn,1 ); + need_flush =set_iommu_pde_present (pde, next_mfn,0 , iw, ir);If there's a general consensus that getting rid of these is better, I don't mind and will agree to it.
Anyone else care to comment?
Paul
Quoted 2 lines
--
Brian Woods
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 35 lines
Quoted 17 lines
Quoted 1 line · On 12.10.18 at 19:18, <[email protected]> wrote:
-----Original Message-----
From: Woods, Brian [mailto:[email protected]]
Sent: 12 October 2018 18:14
To: Paul Durrant <[email protected]>
Cc: [email protected]; Suthikulpanit, Suravee <[email protected]>; Woods, Brian <[email protected]>
Subject: Re: [PATCH] amd-iommu: get rid of pointlessIOMMU_PAGING_MODE_LEVEL_XdefinitionsQuoted 6 lines · Paul Durrant
The levels are absolute numbers such that
IOMMU_PAGING_MODE_LEVEL_Xevaluates to X (for the valid range of 0 - 7) so simply use numbers in the code.No functional change.
Quoted 9 lines
Quoted 3 lines
NOTE: This patch also adds emacs boilerplate to
amd-iommu-defs.hSigned-off-by Paul Durrant <[email protected]>Is there a strong reason to get rid of these? Some of examples below create seemingly magic numbers in the code. While if you're familiar with the functions this isn't a big deal, otherwise you have to dig further to tell.
The numbers aren't magic though. The spec refers to levels by number rather than any sort of name. If the levels were named then it would be absolutely right to #define <level name> <level number>, but that is not the case. Thus IMO getting rid of the definitions actually makes the code clearer for those (like myself) reading the spec.
Quoted 2 lines
Quoted 1 line
+ pte = table +
pfn_to_pde_idx(gfn, 1);
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
+
need_flush=set_iommu_pde_present(pde, next_mfn, 0, iw, ir);If there's a general consensus that getting rid of these is better, I don't mind and will agree to it.
Anyone else care to comment?
I think that, quite the opposite of what is often the case, the amount of manifest constants the AMD IOMMU code uses is quite a bit too large. I therefore welcome this change, and I've been planning some other reduction there (but haven't got to it in a couple of years).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 55 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 25 October 2018 11:29
To: Brian Woods <[email protected]>; Paul Durrant <[email protected]>
Cc: Suravee Suthikulpanit <[email protected]>; xen-devel <xen- [email protected]>
Subject: Re: [Xen-devel] [PATCH] amd-iommu: get rid of pointlessIOMMU_PAGING_MODE_LEVEL_XdefinitionsQuoted 10 lines
Quoted 10 lines
Quoted 1 line · On 12.10.18 at 19:18, <[email protected]> wrote:
-----Original Message-----
From: Woods, Brian [mailto:[email protected]]
Sent: 12 October 2018 18:14
To: Paul Durrant <[email protected]>
Cc: [email protected]; Suthikulpanit, Suravee <[email protected]>; Woods, Brian <[email protected]>
Subject: Re: [PATCH] amd-iommu: get rid of pointlessIOMMU_PAGING_MODE_LEVEL_XdefinitionsQuoted 3 lines
Quoted 3 lines · Paul Durrant
Quoted 2 lines
The levels are absolute numbers such that
IOMMU_PAGING_MODE_LEVEL_Xevaluates to X (for the valid range of 0 - 7) so simply use numbersin
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
the code.
No functional change.
NOTE: This patch also adds emacs boilerplate to
amd-iommu-defs.hSigned-off-by Paul Durrant <[email protected]>Quoted 7 lines
Quoted 5 lines
Is there a strong reason to get rid of these? Some of examples below create seemingly magic numbers in the code. While if you're familiar with the functions this isn't a big deal, otherwise you have to dig further to tell.
The numbers aren't magic though. The spec refers to levels by number
rather
Quoted 1 line
than any sort of name. If the levels were named then it would be
absolutely
Quoted 1 line
right to #define <level name> <level number>, but that is not the case.
Thus IMO
Quoted 11 lines
getting rid of the definitions actually makes the code clearer for those (like myself) reading the spec.
Quoted 7 lines
xen/drivers/passthrough/amd/iommu_map.c static bool_t set_iommu_pte_present(unsigned long pt_mfn, unsigned long gfn, · line 119
Quoted 3 lines
xen/drivers/passthrough/amd/iommu_map.c +2
-0+ pte = table +pfn_to_pde_idx (gfn,1 ); + need_flush =set_iommu_pde_present (pde, next_mfn,0 , iw, ir);If there's a general consensus that getting rid of these is better, I don't mind and will agree to it.
Quoted 7 lines
Quoted 1 line
Anyone else care to comment?
I think that, quite the opposite of what is often the case, the amount of manifest constants the AMD IOMMU code uses is quite a bit too large. I therefore welcome this change, and I've been planning some other reduction there (but haven't got to it in a couple of years).
Brian,
Are you ok to ack this patch now, or would you like more opinions?
Paul
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Woods, Brian
Acked-byQuoted 63 lines · Paul Durrant
Quoted 55 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 25 October 2018 11:29
To: Brian Woods <[email protected]>; Paul Durrant <[email protected]>
Cc: Suravee Suthikulpanit <[email protected]>; xen-devel <xen- [email protected]>
Subject: Re: [Xen-devel] [PATCH] amd-iommu: get rid of pointlessIOMMU_PAGING_MODE_LEVEL_XdefinitionsQuoted 10 lines
Quoted 10 lines
Quoted 1 line · On 12.10.18 at 19:18, <[email protected]> wrote:
-----Original Message-----
From: Woods, Brian [mailto:[email protected]]
Sent: 12 October 2018 18:14
To: Paul Durrant <[email protected]>
Cc: [email protected]; Suthikulpanit, Suravee <[email protected]>; Woods, Brian <[email protected]>
Subject: Re: [PATCH] amd-iommu: get rid of pointlessIOMMU_PAGING_MODE_LEVEL_XdefinitionsQuoted 3 lines
Quoted 3 lines · Paul Durrant
Quoted 2 lines
The levels are absolute numbers such that
IOMMU_PAGING_MODE_LEVEL_Xevaluates to X (for the valid range of 0 - 7) so simply use numbersin
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
the code.
No functional change.
NOTE: This patch also adds emacs boilerplate to
amd-iommu-defs.hSigned-off-by Paul Durrant <[email protected]>Quoted 7 lines
Quoted 5 lines
Is there a strong reason to get rid of these? Some of examples below create seemingly magic numbers in the code. While if you're familiar with the functions this isn't a big deal, otherwise you have to dig further to tell.
The numbers aren't magic though. The spec refers to levels by number
rather
Quoted 1 line
than any sort of name. If the levels were named then it would be
absolutely
Quoted 1 line
right to #define <level name> <level number>, but that is not the case.
Thus IMO
Quoted 11 lines
getting rid of the definitions actually makes the code clearer for those (like myself) reading the spec.
Quoted 7 lines
xen/drivers/passthrough/amd/iommu_map.c static bool_t set_iommu_pte_present(unsigned long pt_mfn, unsigned long gfn, · line 119
Quoted 3 lines
xen/drivers/passthrough/amd/iommu_map.c +2
-0+ pte = table +pfn_to_pde_idx (gfn,1 ); + need_flush =set_iommu_pde_present (pde, next_mfn,0 , iw, ir);If there's a general consensus that getting rid of these is better, I don't mind and will agree to it.
Quoted 7 lines
Quoted 1 line
Anyone else care to comment?
I think that, quite the opposite of what is often the case, the amount of manifest constants the AMD IOMMU code uses is quite a bit too large. I therefore welcome this change, and I've been planning some other reduction there (but haven't got to it in a couple of years).
Quoted 6 lines
Brian,
Are you ok to ack this patch now, or would you like more opinions?
Paul
I'd still rather shorter names rather than getting rid of them all together but,
Signature · 6 lines
Brian Woods _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel