@@ -713,18 +713,18 @@ static bool tdx_cache_flush_required(void)
713
713
return true;
714
714
}
715
715
716
- static bool try_accept_one (phys_addr_t * start , unsigned long len ,
717
- enum pg_level pg_level )
716
+ static unsigned long try_accept_one (phys_addr_t start , unsigned long len ,
717
+ enum pg_level pg_level )
718
718
{
719
719
unsigned long accept_size = page_level_size (pg_level );
720
720
u64 tdcall_rcx ;
721
721
u8 page_size ;
722
722
723
- if (!IS_ALIGNED (* start , accept_size ))
724
- return false ;
723
+ if (!IS_ALIGNED (start , accept_size ))
724
+ return 0 ;
725
725
726
726
if (len < accept_size )
727
- return false ;
727
+ return 0 ;
728
728
729
729
/*
730
730
* Pass the page physical address to the TDX module to accept the
@@ -743,15 +743,14 @@ static bool try_accept_one(phys_addr_t *start, unsigned long len,
743
743
page_size = 2 ;
744
744
break ;
745
745
default :
746
- return false ;
746
+ return 0 ;
747
747
}
748
748
749
- tdcall_rcx = * start | page_size ;
749
+ tdcall_rcx = start | page_size ;
750
750
if (__tdx_module_call (TDX_ACCEPT_PAGE , tdcall_rcx , 0 , 0 , 0 , NULL ))
751
- return false ;
751
+ return 0 ;
752
752
753
- * start += accept_size ;
754
- return true;
753
+ return accept_size ;
755
754
}
756
755
757
756
/*
@@ -788,21 +787,22 @@ static bool tdx_enc_status_changed(unsigned long vaddr, int numpages, bool enc)
788
787
*/
789
788
while (start < end ) {
790
789
unsigned long len = end - start ;
790
+ unsigned long accept_size ;
791
791
792
792
/*
793
793
* Try larger accepts first. It gives chance to VMM to keep
794
- * 1G/2M SEPT entries where possible and speeds up process by
795
- * cutting number of hypercalls (if successful).
794
+ * 1G/2M Secure EPT entries where possible and speeds up
795
+ * process by cutting number of hypercalls (if successful).
796
796
*/
797
797
798
- if (try_accept_one (& start , len , PG_LEVEL_1G ))
799
- continue ;
800
-
801
- if (try_accept_one (& start , len , PG_LEVEL_2M ))
802
- continue ;
803
-
804
- if (!try_accept_one (& start , len , PG_LEVEL_4K ))
798
+ accept_size = try_accept_one (start , len , PG_LEVEL_1G );
799
+ if (!accept_size )
800
+ accept_size = try_accept_one (start , len , PG_LEVEL_2M );
801
+ if (!accept_size )
802
+ accept_size = try_accept_one (start , len , PG_LEVEL_4K );
803
+ if (!accept_size )
805
804
return false;
805
+ start += accept_size ;
806
806
}
807
807
808
808
return true;
0 commit comments