@@ -50,6 +50,7 @@ const UAT_IASMSK: u64 = (1u64 << UAT_IAS) - 1;
5050const PTE_TYPE_BITS : u64 = 3 ;
5151const PTE_TYPE_LEAF_TABLE : u64 = 3 ;
5252
53+ const UAT_NON_GLOBAL : u64 = 1 << 11 ;
5354const UAT_AP_SHIFT : u32 = 6 ;
5455const UAT_AP_BITS : u64 = 3 << UAT_AP_SHIFT ;
5556const UAT_HIGH_BITS_SHIFT : u32 = 52 ;
@@ -452,6 +453,16 @@ impl UatPageTable {
452453 self . with_pages ( iova_range, true , false , |_, _| Ok ( ( ) ) )
453454 }
454455
456+ fn pte_bits ( & self ) -> u64 {
457+ if self . ttb_owned {
458+ // Owned page tables are userspace, so non-global
459+ PTE_TYPE_LEAF_TABLE | UAT_NON_GLOBAL
460+ } else {
461+ // The sole non-owned page table is kernelspace, so global
462+ PTE_TYPE_LEAF_TABLE
463+ }
464+ }
465+
455466 pub ( crate ) fn map_pages (
456467 & mut self ,
457468 iova_range : Range < u64 > ,
@@ -470,6 +481,8 @@ impl UatPageTable {
470481 return Err ( EINVAL ) ;
471482 }
472483
484+ let pte_bits = self . pte_bits ( ) ;
485+
473486 self . with_pages ( iova_range, true , false , |iova, ptes| {
474487 for ( idx, pte) in ptes. iter ( ) . enumerate ( ) {
475488 let ptev = pte. load ( Ordering :: Relaxed ) ;
@@ -480,10 +493,7 @@ impl UatPageTable {
480493 ptev
481494 ) ;
482495 }
483- pte. store (
484- phys | prot. as_pte ( ) | PTE_TYPE_LEAF_TABLE ,
485- Ordering :: Relaxed ,
486- ) ;
496+ pte. store ( phys | prot. as_pte ( ) | pte_bits, Ordering :: Relaxed ) ;
487497 if !one_page {
488498 phys += UAT_PGSZ as PhysicalAddr ;
489499 }
0 commit comments