This is an automated email from the ASF dual-hosted git repository.

rduan pushed a commit to branch v2.0.0-preview
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-sgx-sdk.git


The following commit(s) were added to refs/heads/v2.0.0-preview by this push:
     new af7174a5 fix trim_range_commit bug
af7174a5 is described below

commit af7174a535d5ece49c6154c259558b72466c1e65
Author: volcano0dr <[email protected]>
AuthorDate: Tue Mar 11 13:25:27 2025 +0800

    fix trim_range_commit bug
---
 sgx_trts/src/edmm/mem.rs  | 15 ++++++++++++---
 sgx_trts/src/edmm/trim.rs |  2 +-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/sgx_trts/src/edmm/mem.rs b/sgx_trts/src/edmm/mem.rs
index 0d6ac634..2f5e1e57 100644
--- a/sgx_trts/src/edmm/mem.rs
+++ b/sgx_trts/src/edmm/mem.rs
@@ -39,7 +39,10 @@ mod hw {
     use sgx_types::types::ProtectPerm;
 
     pub fn apply_epc_pages(addr: usize, count: usize) -> SgxResult {
-        ensure!(addr != 0 && count != 0, SgxStatus::InvalidParameter);
+        ensure!(
+            addr != 0 && is_page_aligned!(addr) && count != 0,
+            SgxStatus::InvalidParameter
+        );
 
         if let Some(attr) = LayoutTable::new().check_dyn_range(addr, count, 
None) {
             let pages = PageRange::new(
@@ -61,7 +64,10 @@ mod hw {
     }
 
     pub fn trim_epc_pages(addr: usize, count: usize) -> SgxResult {
-        ensure!(addr != 0 && count != 0, SgxStatus::InvalidParameter);
+        ensure!(
+            addr != 0 && is_page_aligned!(addr) && count != 0,
+            SgxStatus::InvalidParameter
+        );
 
         LayoutTable::new()
             .check_dyn_range(addr, count, None)
@@ -85,7 +91,10 @@ mod hw {
     }
 
     pub fn expand_stack_epc_pages(addr: usize, count: usize) -> SgxResult {
-        ensure!(addr != 0 && count != 0, SgxStatus::InvalidParameter);
+        ensure!(
+            addr != 0 && is_page_aligned!(addr) && count != 0,
+            SgxStatus::InvalidParameter
+        );
 
         LayoutTable::new()
             .check_dyn_range(addr, count, None)
diff --git a/sgx_trts/src/edmm/trim.rs b/sgx_trts/src/edmm/trim.rs
index ce278cec..6e51bd80 100644
--- a/sgx_trts/src/edmm/trim.rs
+++ b/sgx_trts/src/edmm/trim.rs
@@ -50,7 +50,7 @@ pub fn trim_range_commit(addr: usize, count: usize) -> 
SgxResult {
     for i in 0..count {
         let mut trim = Box::try_new_in(
             TrimRangeCommitOcall {
-                addr: addr + i * SE_PAGE_SHIFT,
+                addr: addr + (i << SE_PAGE_SHIFT),
             },
             OcAlloc,
         )


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to