File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1526,6 +1526,24 @@ impl CrosEc {
15261526 return_val
15271527 }
15281528
1529+ pub fn validate_gpu_descriptor ( & self , reference_desc : & [ u8 ] ) -> EcResult < bool > {
1530+ let current_desc = self . read_gpu_descriptor ( ) ?;
1531+ let max_len = core:: cmp:: max ( current_desc. len ( ) , reference_desc. len ( ) ) ;
1532+ let mut valid = true ;
1533+ for i in 0 ..max_len {
1534+ let expected = reference_desc. get ( i) ;
1535+ let actual = current_desc. get ( i) ;
1536+ if expected != actual {
1537+ println ! (
1538+ " Offset 0x{:04X}: expected {:02X?}, got {:02X?}" ,
1539+ i, expected, actual
1540+ ) ;
1541+ valid = false ;
1542+ }
1543+ }
1544+ Ok ( valid)
1545+ }
1546+
15291547 pub fn read_gpu_descriptor ( & self ) -> EcResult < Vec < u8 > > {
15301548 let header = self . read_gpu_desc_header ( ) ?;
15311549 if header. magic != [ 0x32 , 0xAC , 0x00 , 0x00 ] {
Original file line number Diff line number Diff line change @@ -1807,7 +1807,15 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
18071807 println ! ( " Size: {:>20} KB" , data. len( ) / 1024 ) ;
18081808 let res = ec. set_gpu_descriptor ( & data, args. dry_run ) ;
18091809 match res {
1810- Ok ( ( ) ) => println ! ( "GPU Descriptor successfully written" ) ,
1810+ Ok ( ( ) ) => {
1811+ println ! ( "GPU Descriptor successfully written" ) ;
1812+ println ! ( "Validating GPU Descriptor..." ) ;
1813+ match ec. validate_gpu_descriptor ( & data) {
1814+ Ok ( true ) => println ! ( " Validation passed" ) ,
1815+ Ok ( false ) => println ! ( " Validation FAILED: read-back mismatch" ) ,
1816+ Err ( err) => println ! ( " Validation error: {:?}" , err) ,
1817+ }
1818+ }
18111819 Err ( err) => println ! ( "GPU Descriptor write failed with error: {:?}" , err) ,
18121820 }
18131821 }
You can’t perform that action at this time.
0 commit comments