You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@teaclave.apache.org by "asir66 (via GitHub)" <gi...@apache.org> on 2025/11/13 08:15:35 UTC

[PR] examples: enable message-passing-interface-rs example for no-std and promote it to a common example [teaclave-trustzone-sdk]

asir66 opened a new pull request, #254:
URL: https://github.com/apache/teaclave-trustzone-sdk/pull/254

   # Summary
   
   This PR enables the message-passing-interface-rs example to work in `no_std` environments and promotes it to a common example shared across different targets.
   
   ## Changes
   
   - Modified the message-passing-interface-rs example to be compatible with `no_std`.
   - Moved the example into the common examples directory for better reusability.
   - Adjusted build configuration and dependencies accordingly.
   
   Specifically, the serde_json dependency in the proto crate was separated to distinguish between host and TA dependencies, allowing finer control over no_std and feature configurations.
   
   Can you help me review this PR? @DemesneGH 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org


Re: [PR] examples: enable message-passing-interface-rs example for no-std and promote it to a common example [teaclave-trustzone-sdk]

Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH commented on PR #254:
URL: https://github.com/apache/teaclave-trustzone-sdk/pull/254#issuecomment-3526556093

   BTW don't forget to move it into common examples in `examples/Makefile` to trigger the no-std build😃


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org


Re: [PR] examples: enable message-passing-interface-rs example for no-std and promote it to a common example [teaclave-trustzone-sdk]

Posted by "asir66 (via GitHub)" <gi...@apache.org>.
asir66 commented on PR #254:
URL: https://github.com/apache/teaclave-trustzone-sdk/pull/254#issuecomment-3526587337

   Think you for your help


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org


Re: [PR] examples: enable message-passing-interface-rs example for no-std and promote it to a common example [teaclave-trustzone-sdk]

Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH commented on code in PR #254:
URL: https://github.com/apache/teaclave-trustzone-sdk/pull/254#discussion_r2522374990


##########
examples/message_passing_interface-rs/ta/Makefile:
##########
@@ -47,3 +57,5 @@ sign: strip
 
 clean:
 	@cargo clean
+

Review Comment:
   Remove the extra empty lines



##########
examples/message_passing_interface-rs/ta/src/main.rs:
##########
@@ -71,21 +74,27 @@ fn invoke_command(cmd_id: u32, params: &mut Parameters) -> Result<()> {
     let mut p1 = unsafe { params.1.as_memref()? };
     let mut p2 = unsafe { params.2.as_value()? };
 
-    let input: proto::EnclaveInput = proto::serde_json::from_slice(p0.buffer()).map_err(|e| {
+    let input: proto::EnclaveInput = serde_json::from_slice(p0.buffer()).map_err(|e| {
         trace_println!("Failed to deserialize input: {}", e);
         ErrorKind::BadFormat
     })?;
     let output = handle_invoke(Command::from(cmd_id), input)?;
 
-    let output_vec = proto::serde_json::to_vec(&output).map_err(|e| {
+    let output_vec = serde_json::to_vec(&output).map_err(|e| {
         trace_println!("Failed to serialize output: {}", e);
         ErrorKind::BadFormat
     })?;
-    p1.buffer().write_all(&output_vec).map_err(|e| {
-        trace_println!("Failed to write output: {}", e);
-        ErrorKind::BadParameters
-    })?;
-    p2.set_a(output_vec.len() as u32);
+
+    let len = output_vec.len();
+    if len > p1.buffer().len() {
+        trace_println!("Buffer too small, cannot copy all bytes");
+        return Err(ErrorKind::BadParameters.into());
+    }
+
+    p1.buffer()[..len].copy_from_slice(&output_vec);
+    p1.set_updated_size(len);
+
+    p2.set_a(len as u32);

Review Comment:
   Remove the p2 from both ta and host, it makes sense to use `p1.set_updated_size(len);` to return the length.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org


Re: [PR] examples: enable message-passing-interface-rs example for no-std and promote it to a common example [teaclave-trustzone-sdk]

Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH commented on PR #254:
URL: https://github.com/apache/teaclave-trustzone-sdk/pull/254#issuecomment-3527863533

   Merged, thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org


Re: [PR] examples: enable message-passing-interface-rs example for no-std and promote it to a common example [teaclave-trustzone-sdk]

Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH merged PR #254:
URL: https://github.com/apache/teaclave-trustzone-sdk/pull/254


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org