@@ -11,8 +11,12 @@ use core::mem::size_of;
1111use core:: ops:: Range ;
1212use core:: sync:: atomic:: { AtomicU64 , Ordering } ;
1313
14- use kernel:: uapi:: { PF_R , PF_W , PF_X } ;
15- use kernel:: { addr:: PhysicalAddr , error:: Result , page:: Page , prelude:: * , types:: Owned } ;
14+ #[ cfg( CONFIG_DEV_COREDUMP ) ]
15+ use kernel:: {
16+ uapi:: { PF_R , PF_W , PF_X } ,
17+ types:: Owned ,
18+ } ;
19+ use kernel:: { addr:: PhysicalAddr , error:: Result , page:: Page , prelude:: * } ;
1620
1721use crate :: debug:: * ;
1822use crate :: util:: align;
@@ -74,6 +78,7 @@ const HIGH_BITS_PXN: u16 = 1 << 1;
7478const HIGH_BITS_UXN : u16 = 1 << 2 ;
7579const HIGH_BITS_GPU_ACCESS : u16 = 1 << 3 ;
7680
81+ #[ cfg( CONFIG_DEV_COREDUMP ) ]
7782pub ( crate ) const PTE_ADDR_BITS : u64 = ( !UAT_PGMSK as u64 ) & ( !UAT_HIGH_BITS ) ;
7883
7984#[ derive( Debug , Copy , Clone ) ]
@@ -101,16 +106,20 @@ const PROT_GPU_WO: Prot = Prot::from_bits(AP_GPU, 0, 1);
101106const PROT_GPU_RW : Prot = Prot :: from_bits ( AP_GPU , 1 , 0 ) ;
102107const _PROT_GPU_NA: Prot = Prot :: from_bits ( AP_GPU , 1 , 1 ) ;
103108
109+ #[ cfg( CONFIG_DEV_COREDUMP ) ]
104110const PF_RW : u32 = PF_R | PF_W ;
111+ #[ cfg( CONFIG_DEV_COREDUMP ) ]
105112const PF_RX : u32 = PF_R | PF_X ;
106113
107114// For crash dumps
115+ #[ cfg( CONFIG_DEV_COREDUMP ) ]
108116const PROT_TO_PERMS_FW : [ [ u32 ; 4 ] ; 4 ] = [
109117 [ 0 , 0 , 0 , PF_RW ] ,
110118 [ 0 , PF_RW , 0 , PF_RW ] ,
111119 [ PF_RX , PF_RX , 0 , PF_R ] ,
112120 [ PF_RX , PF_RW , 0 , PF_R ] ,
113121] ;
122+ #[ cfg( CONFIG_DEV_COREDUMP ) ]
114123const PROT_TO_PERMS_OS : [ [ u32 ; 4 ] ; 4 ] = [
115124 [ 0 , PF_R , PF_W , PF_RW ] ,
116125 [ PF_R , 0 , PF_RW , PF_RW ] ,
@@ -159,6 +168,7 @@ impl Prot {
159168 }
160169 }
161170
171+ #[ cfg( CONFIG_DEV_COREDUMP ) ]
162172 pub ( crate ) const fn from_pte ( pte : u64 ) -> Self {
163173 Prot {
164174 high_bits : ( pte >> UAT_HIGH_BITS_SHIFT ) as u16 ,
@@ -167,6 +177,7 @@ impl Prot {
167177 }
168178 }
169179
180+ #[ cfg( CONFIG_DEV_COREDUMP ) ]
170181 pub ( crate ) const fn elf_flags ( & self ) -> u32 {
171182 let ap = ( self . ap & 3 ) as usize ;
172183 let uxn = if self . high_bits & HIGH_BITS_UXN != 0 {
@@ -221,6 +232,7 @@ impl Default for Prot {
221232 }
222233}
223234
235+ #[ cfg( CONFIG_DEV_COREDUMP ) ]
224236pub ( crate ) struct DumpedPage {
225237 pub ( crate ) iova : u64 ,
226238 pub ( crate ) pte : u64 ,
@@ -541,6 +553,7 @@ impl UatPageTable {
541553 } )
542554 }
543555
556+ #[ cfg( CONFIG_DEV_COREDUMP ) ]
544557 pub ( crate ) fn dump_pages ( & mut self , iova_range : Range < u64 > ) -> Result < KVVec < DumpedPage > > {
545558 let mut pages = KVVec :: new ( ) ;
546559 let oas_mask = self . oas_mask ;
0 commit comments