You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@teaclave.apache.org by "ivila (via GitHub)" <gi...@apache.org> on 2025/01/20 08:46:18 UTC
[PR] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
ivila opened a new pull request, #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164
1. make optee_utee::net::{TcpStream, UdpSocket} support no-std
2. update tcp_client-rs and udp_socket-rs to support running at no-std
this PR close #162
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1922950287
##########
examples/udp_socket-rs/ta/src/main.rs:
##########
@@ -52,17 +53,64 @@ fn destroy() {
fn invoke_command(cmd_id: u32, _params: &mut Parameters) -> Result<()> {
trace_println!("[+] TA invoke command");
match Command::from(cmd_id) {
- Command::Start => {
- udp_socket();
- Ok(())
- }
+ Command::Start => udp_socket(),
_ => Err(Error::new(ErrorKind::BadParameters)),
}
}
-fn udp_socket() {
- let mut stream = UdpSocket::connect("127.0.0.1", 34254).unwrap();
- stream.write_all(b"[TA]: Hello, Teaclave!").unwrap();
+#[cfg(not(target_os = "optee"))]
+fn udp_socket() -> Result<()> {
+ use alloc::string::String;
+ use alloc::vec::Vec;
+ use optee_utee::net::Setup;
+
+ let setup = Setup::new_v4("127.0.0.1", 34254)?;
+ let mut stream = UdpSocket::open(setup).map_err(|err| {
Review Comment:
> Seems the API design aligns with the OP-TEE raw API. Is it possible to make it consistent with the `std` API similar to `std::net`? then the TA code can remain mostly unchanged for both `std` and `no-std`?
Actually, we cannot. This is a pain point in Rust: `std::io::Error` doesn't live in core because it uses unwinding, meaning many things cannot be used in no_std, especially `std::io::{Read, Write}`. Therefore, we cannot make them the same, because in std, the return error type should be `std::io::Error`, but we cannot use it in no_std.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1923662576
##########
examples/tcp_client-rs/ta/src/main.rs:
##########
@@ -15,16 +15,27 @@
// specific language governing permissions and limitations
// under the License.
+#![cfg_attr(not(target_os = "optee"), no_std)]
#![no_main]
+cfg_block::cfg_block! {
+ if #[cfg(target_os = "optee")] {
Review Comment:
Can we have some short comment to explain the `if else` block for developers? They may be confused about the `target_os = "optee"` constraints, we can just clarify they represent `no-std` and `std`.
##########
examples/tcp_client-rs/ta/src/main.rs:
##########
@@ -15,16 +15,27 @@
// specific language governing permissions and limitations
// under the License.
+#![cfg_attr(not(target_os = "optee"), no_std)]
#![no_main]
+cfg_block::cfg_block! {
+ if #[cfg(target_os = "optee")] {
+ use std::io::{Read, Write};
+ } else {
+ extern crate alloc;
+ use optee_utee::net::{StdCompactConnect, StdCompactWrite, StdCompactRead};
+ use alloc::vec::Vec;
+ use alloc::string::String;
+ }
+}
+
+
Review Comment:
Seems one redundant blank line here
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "b49020 (via GitHub)" <gi...@apache.org>.
b49020 commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1924892452
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_v4(address, port)
+ }
+}
+
+impl std::io::Read for TcpStream {
+ fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
+ match self.recv(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+}
+
+impl std::io::Write for TcpStream {
+ fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
+ match self.send(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+ fn flush(&mut self) -> std::io::Result<()> {
+ Ok(())
+ }
+}
+
+impl UdpSocket {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_v4(address, port)
+ }
+}
+
+impl std::io::Read for UdpSocket {
+ fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
+ match self.recv(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+}
+
+impl std::io::Write for UdpSocket {
+ fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
+ match self.send(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+ fn flush(&mut self) -> std::io::Result<()> {
+ Ok(())
+ }
+}
+
+impl Into<std::io::Error> for SocketError {
Review Comment:
I don't see any current use-case of `std::io::Error` currently in example TAs but rather we use OP-TEE specific error traits. So let's drop it until there is a real user.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1923020340
##########
examples/udp_socket-rs/ta/src/main.rs:
##########
@@ -74,13 +122,33 @@ fn udp_socket() {
response.extend_from_slice(&chunk[..n]);
break;
}
- Err(_) => {
- trace_println!("Error");
- panic!();
+ Err(err) => {
+ trace_println!("failed to read due to {:?}", err);
+ return Err(ErrorKind::Generic.into());
}
}
}
trace_println!("{}", String::from_utf8_lossy(&response));
+ Ok(())
}
include!(concat!(env!("OUT_DIR"), "/user_ta_header.rs"));
+
+/// Workaround for those rustc bugs:
+/// * https://github.com/rust-lang/rust/issues/47493
Review Comment:
Have you tries this workaround in the issue? https://github.com/rust-lang/rust/issues/47493#issuecomment-606385776
##########
examples/udp_socket-rs/ta/src/main.rs:
##########
@@ -74,13 +122,33 @@ fn udp_socket() {
response.extend_from_slice(&chunk[..n]);
break;
}
- Err(_) => {
- trace_println!("Error");
- panic!();
+ Err(err) => {
+ trace_println!("failed to read due to {:?}", err);
+ return Err(ErrorKind::Generic.into());
}
}
}
trace_println!("{}", String::from_utf8_lossy(&response));
+ Ok(())
}
include!(concat!(env!("OUT_DIR"), "/user_ta_header.rs"));
+
+/// Workaround for those rustc bugs:
+/// * https://github.com/rust-lang/rust/issues/47493
Review Comment:
Have you tried this workaround in the issue? https://github.com/rust-lang/rust/issues/47493#issuecomment-606385776
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r2000383363
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
Yes and an issue is opened for tracking this: https://github.com/apache/incubator-teaclave-trustzone-sdk/issues/174
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1928145670
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
> The image comes from OP-TEE repo buildroot outputs, with default building configuration. Could you provide the build configuration flags to build the ipv6 modules if you're also using buildroot? I'm also working on rebuilding the image.
I believe IPv6 support is already enabled in the Linux kernel by default(not in the kernel itself but the modules). The issue seems to be that the modules were not installed into the root filesystem (no `/lib/modules` inside `rootfs.cpio.uboot`). To fix this, we likely just need to run `make INSTALL_MOD_PATH=${PATH_TO_ROOTFS} modules_install` in the Linux kernel build process.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1923269574
##########
examples/udp_socket-rs/ta/src/main.rs:
##########
@@ -52,17 +53,64 @@ fn destroy() {
fn invoke_command(cmd_id: u32, _params: &mut Parameters) -> Result<()> {
trace_println!("[+] TA invoke command");
match Command::from(cmd_id) {
- Command::Start => {
- udp_socket();
- Ok(())
- }
+ Command::Start => udp_socket(),
_ => Err(Error::new(ErrorKind::BadParameters)),
}
}
-fn udp_socket() {
- let mut stream = UdpSocket::connect("127.0.0.1", 34254).unwrap();
- stream.write_all(b"[TA]: Hello, Teaclave!").unwrap();
+#[cfg(not(target_os = "optee"))]
+fn udp_socket() -> Result<()> {
+ use alloc::string::String;
+ use alloc::vec::Vec;
+ use optee_utee::net::Setup;
+
+ let setup = Setup::new_v4("127.0.0.1", 34254)?;
+ let mut stream = UdpSocket::open(setup).map_err(|err| {
Review Comment:
Changes made, but I split them into three traits in case we only need the `connect` method at times and want to avoid conflicts with other `Read/Write` traits (for example, the `io::{Read, Write}` in `http_io`).
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "b49020 (via GitHub)" <gi...@apache.org>.
b49020 commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1924858643
##########
optee-utee/src/net/optee_no_std.rs:
##########
@@ -0,0 +1,150 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+use super::{Setup, Socket, SocketAdapter, SocketError};
+
+/// A trait used for convenience; import it so that the code remains consistent
+/// with the std version (with the only difference being the return error type).
+///
+/// Take TcpStream as example:
+/// ```no_run
+/// use optee_utee::net::TcpStream;
+///
+/// fn connect_without_compact_trait(host: &str, port: u16) -> Result<TcpStream, SocketError> {
+/// let setup = Setup::new_v4(host, port)?;
+/// TcpStream::open(setup)
+/// }
+///
+/// fn connect_with_compact_trait(host: &str, port: u16) -> Result<TcpStream, SocketError> {
+/// use optee_utee::net::StdCompactConnect;
+///
+/// TcpStream::connect_v4(host, port)
+/// }
+/// ```
+pub trait StdCompactConnect: Sized {
+ fn connect_v4(address: &str, port: u16) -> Result<Self, SocketError>;
+ fn connect_v6(address: &str, port: u16) -> Result<Self, SocketError>;
+ fn connect(address: &str, port: u16) -> Result<Self, SocketError> {
+ Self::connect_v4(address, port)
+ }
+}
+
+/// A trait used for convenience; import it so that the code remains consistent
+/// with the std version (with the only difference being the return error type).
+///
+/// Take TcpStream as example:
+/// ```no_run
+/// use optee_utee::net::TcpStream;
+///
+/// fn write_without_compact_trait(stream: &mut Stream, mut buf: &[u8]) -> Result<usize, SocketError> {
+/// use optee_utee::ErrorKind;
+///
+/// while !buf.is_empty() {
+/// match stream.send(buf) {
+/// Ok(0) => return Err(SocketError::Tee(ErrorKind::Generic)),
+/// Ok(n) => buf = &buf[n..],
+/// Err(e) => return Err(e),
+/// }
+/// }
+/// Ok(())
+/// }
+///
+/// fn write_with_compact_trait(stream: &mut Stream, buf: &[u8]) -> Result<usize, SocketError> {
+/// use optee_utee::net::StdCompactWrite;
+///
+/// stream.write_all(buf)
+/// }
+/// ```
+pub trait StdCompactWrite {
+ fn write(&mut self, buf: &[u8]) -> Result<usize, SocketError>;
+ fn write_all(&mut self, mut buf: &[u8]) -> Result<(), SocketError> {
+ while !buf.is_empty() {
+ match self.write(buf)? {
+ 0 => return Err(SocketError::Tee(crate::ErrorKind::Generic)),
+ n => buf = &buf[n..],
+ }
+ }
+ Ok(())
+ }
+}
+
+/// A trait used for convenience; import it so that the code remains consistent
+/// with the std version (with the only difference being the return error type).
+///
+/// Take TcpStream as example:
+/// ```no_run
+/// use optee_utee::net::TcpStream;
+///
+/// fn read_without_compact_trait(stream: &mut Stream, mut buf: &mut [u8]) -> Result<usize, SocketError> {
+/// use optee_utee::ErrorKind;
+///
+/// while !buf.is_empty() {
+/// match stream.read(buf) {
+/// Ok(0) => break;
+/// Ok(n) => buf = &mut buf[n..],
+/// Err(e) => return Err(e),
+/// }
+/// }
+/// if !buf.is_empty() {
+/// return Err(SocketError::Tee(ErrorKind::Generic));
+/// }
+/// Ok(())
+/// }
+///
+/// fn write_with_compact_trait(stream: &mut Stream, buf: &mut [u8]) -> Result<usize, SocketError> {
Review Comment:
Typo s/write_/read_/
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH commented on PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#issuecomment-2642243400
> > It happens occasionally; simply retry, and the test will eventually pass.
>
> Okay, looks like it's related to custom OP-TEE toolchain target OS config option for std TAs. @DemesneGH can you take a look at this issue? We should be able to merge this PR while filing a corresponding issue such that we can keep track of it.
This PR is merged and a new issue is created. https://github.com/apache/incubator-teaclave-trustzone-sdk/issues/166
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH merged PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1928145670
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
> The image comes from OP-TEE repo buildroot outputs, with default building configuration. Could you provide the build configuration flags to build the ipv6 modules if you're also using buildroot? I'm also working on rebuilding the image.
I believe IPv6 support is already enabled in the Linux kernel by default(not in the kernel itself but the modules). The issue seems to be that the modules were not installed into the root filesystem (no `/lib/modules` inside `rootfs.cpio.uboot`). To fix this, we likely just need to run `make INSTALL_MOD_PATH=${PATH_TO_ROOTFS} modules_install` in the Linux kernel build process.
Oh, sorry, I didn't notice that OP-TEE buildroot do not use default config, let me just try and update you later.
@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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#issuecomment-2614182131
Force update for ipv6 test and some comments. There are some more changes in those files:
1. `ci/ci.sh`: move `tcp_client-rs` and `udp_client-rs` out of STD only.
2. `examples/tcp_client-rs`: add ipv6 test.
3. `examples/udp_client-rs`: add ipv6 test.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1922949853
##########
examples/udp_socket-rs/ta/src/main.rs:
##########
@@ -52,17 +53,64 @@ fn destroy() {
fn invoke_command(cmd_id: u32, _params: &mut Parameters) -> Result<()> {
trace_println!("[+] TA invoke command");
match Command::from(cmd_id) {
- Command::Start => {
- udp_socket();
- Ok(())
- }
+ Command::Start => udp_socket(),
_ => Err(Error::new(ErrorKind::BadParameters)),
}
}
-fn udp_socket() {
- let mut stream = UdpSocket::connect("127.0.0.1", 34254).unwrap();
- stream.write_all(b"[TA]: Hello, Teaclave!").unwrap();
+#[cfg(not(target_os = "optee"))]
+fn udp_socket() -> Result<()> {
+ use alloc::string::String;
+ use alloc::vec::Vec;
+ use optee_utee::net::Setup;
+
+ let setup = Setup::new_v4("127.0.0.1", 34254)?;
+ let mut stream = UdpSocket::open(setup).map_err(|err| {
Review Comment:
Actually, we cannot. This is a pain point in Rust: `std::io::Error` doesn't live in core because it uses unwinding, meaning many things cannot be used in no_std, especially `std::io::{Read, Write}`. Therefore, we cannot make them the same, because in std, the return error type should be `std::io::Error`, but we cannot use it in no_std.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1923009085
##########
examples/udp_socket-rs/ta/src/main.rs:
##########
@@ -52,17 +53,64 @@ fn destroy() {
fn invoke_command(cmd_id: u32, _params: &mut Parameters) -> Result<()> {
trace_println!("[+] TA invoke command");
match Command::from(cmd_id) {
- Command::Start => {
- udp_socket();
- Ok(())
- }
+ Command::Start => udp_socket(),
_ => Err(Error::new(ErrorKind::BadParameters)),
}
}
-fn udp_socket() {
- let mut stream = UdpSocket::connect("127.0.0.1", 34254).unwrap();
- stream.write_all(b"[TA]: Hello, Teaclave!").unwrap();
+#[cfg(not(target_os = "optee"))]
+fn udp_socket() -> Result<()> {
+ use alloc::string::String;
+ use alloc::vec::Vec;
+ use optee_utee::net::Setup;
+
+ let setup = Setup::new_v4("127.0.0.1", 34254)?;
+ let mut stream = UdpSocket::open(setup).map_err(|err| {
Review Comment:
We don't need to implement `std::io::{Read, Write}` like what we do in `std`. How about making the API compatible? like:
```
// the no_std TcpStream:
pub struct TcpStream {
...
}
impl TcpStream {
pub fn connect(address: &str, port: u16) -> Result<Self, SocketError> {...}
pub fn read(&mut self, buf: &mut [u8]) -> Result<Self, SocketError> {...}
pub fn write(&mut self, buf: &[u8]) -> Result<Self, SocketError> {...}
...
}
```
In examples we don't need to modify the main code:
```
// use different TcpStream
#[cfg(not(target_os = "optee"))]
use optee_utee::net::no_std::TcpStream; // module name can be adjusted, just example here
#[cfg(target_os = "optee")]
use optee_utee::net::std::TcpStream;
// expose the same API for examples
let mut stream = TcpStream::connect(xxxx);
stream.write(xxx);
stream.read(xxx);
```
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1925200757
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_v4(address, port)
+ }
+}
+
+impl std::io::Read for TcpStream {
+ fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
+ match self.recv(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+}
+
+impl std::io::Write for TcpStream {
+ fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
+ match self.send(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+ fn flush(&mut self) -> std::io::Result<()> {
+ Ok(())
+ }
+}
+
+impl UdpSocket {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_v4(address, port)
+ }
+}
+
+impl std::io::Read for UdpSocket {
+ fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
+ match self.recv(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+}
+
+impl std::io::Write for UdpSocket {
+ fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
+ match self.send(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+ fn flush(&mut self) -> std::io::Result<()> {
+ Ok(())
+ }
+}
+
+impl Into<std::io::Error> for SocketError {
Review Comment:
This simplifies the `try` operation in this file; otherwise, we would need to write many `map_err` calls. However, it's fine to remove it if necessary.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1922436398
##########
examples/udp_socket-rs/ta/src/main.rs:
##########
@@ -52,17 +53,64 @@ fn destroy() {
fn invoke_command(cmd_id: u32, _params: &mut Parameters) -> Result<()> {
trace_println!("[+] TA invoke command");
match Command::from(cmd_id) {
- Command::Start => {
- udp_socket();
- Ok(())
- }
+ Command::Start => udp_socket(),
_ => Err(Error::new(ErrorKind::BadParameters)),
}
}
-fn udp_socket() {
- let mut stream = UdpSocket::connect("127.0.0.1", 34254).unwrap();
- stream.write_all(b"[TA]: Hello, Teaclave!").unwrap();
+#[cfg(not(target_os = "optee"))]
+fn udp_socket() -> Result<()> {
+ use alloc::string::String;
+ use alloc::vec::Vec;
+ use optee_utee::net::Setup;
+
+ let setup = Setup::new_v4("127.0.0.1", 34254)?;
+ let mut stream = UdpSocket::open(setup).map_err(|err| {
Review Comment:
Seems the API design aligns with the OP-TEE raw API. Is it possible to make it consistent with the `std` API similar to `std::net`? then the TA code can remain mostly unchanged for both `std` and `no-std`?
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1922949853
##########
examples/udp_socket-rs/ta/src/main.rs:
##########
@@ -52,17 +53,64 @@ fn destroy() {
fn invoke_command(cmd_id: u32, _params: &mut Parameters) -> Result<()> {
trace_println!("[+] TA invoke command");
match Command::from(cmd_id) {
- Command::Start => {
- udp_socket();
- Ok(())
- }
+ Command::Start => udp_socket(),
_ => Err(Error::new(ErrorKind::BadParameters)),
}
}
-fn udp_socket() {
- let mut stream = UdpSocket::connect("127.0.0.1", 34254).unwrap();
- stream.write_all(b"[TA]: Hello, Teaclave!").unwrap();
+#[cfg(not(target_os = "optee"))]
+fn udp_socket() -> Result<()> {
+ use alloc::string::String;
+ use alloc::vec::Vec;
+ use optee_utee::net::Setup;
+
+ let setup = Setup::new_v4("127.0.0.1", 34254)?;
+ let mut stream = UdpSocket::open(setup).map_err(|err| {
Review Comment:
Actually, we cannot. This is a pain point in Rust: `std::io::Error` doesn't live in core because it uses unwinding, meaning many things cannot be used in no_std, especially `std::io::{Read, Write}`. Therefore, we cannot make them the same, because in std, the return error type should be `std::io::Error`, but we cannot use it in no_std.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "b49020 (via GitHub)" <gi...@apache.org>.
b49020 commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1924873752
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
Shouldn't here be `TEE_IP_VERSION_6` instead? It really looks like we need an example test-case for IP v6 testing.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "b49020 (via GitHub)" <gi...@apache.org>.
b49020 commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1924870877
##########
optee-utee/src/net/optee_no_std.rs:
##########
@@ -0,0 +1,150 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+use super::{Setup, Socket, SocketAdapter, SocketError};
+
+/// A trait used for convenience; import it so that the code remains consistent
+/// with the std version (with the only difference being the return error type).
+///
+/// Take TcpStream as example:
+/// ```no_run
+/// use optee_utee::net::TcpStream;
+///
+/// fn connect_without_compact_trait(host: &str, port: u16) -> Result<TcpStream, SocketError> {
+/// let setup = Setup::new_v4(host, port)?;
+/// TcpStream::open(setup)
+/// }
+///
+/// fn connect_with_compact_trait(host: &str, port: u16) -> Result<TcpStream, SocketError> {
+/// use optee_utee::net::StdCompactConnect;
+///
+/// TcpStream::connect_v4(host, port)
+/// }
+/// ```
+pub trait StdCompactConnect: Sized {
+ fn connect_v4(address: &str, port: u16) -> Result<Self, SocketError>;
+ fn connect_v6(address: &str, port: u16) -> Result<Self, SocketError>;
+ fn connect(address: &str, port: u16) -> Result<Self, SocketError> {
+ Self::connect_v4(address, port)
+ }
+}
+
+/// A trait used for convenience; import it so that the code remains consistent
+/// with the std version (with the only difference being the return error type).
+///
+/// Take TcpStream as example:
+/// ```no_run
+/// use optee_utee::net::TcpStream;
+///
+/// fn write_without_compact_trait(stream: &mut Stream, mut buf: &[u8]) -> Result<usize, SocketError> {
+/// use optee_utee::ErrorKind;
+///
+/// while !buf.is_empty() {
+/// match stream.send(buf) {
+/// Ok(0) => return Err(SocketError::Tee(ErrorKind::Generic)),
+/// Ok(n) => buf = &buf[n..],
+/// Err(e) => return Err(e),
+/// }
+/// }
+/// Ok(())
+/// }
+///
+/// fn write_with_compact_trait(stream: &mut Stream, buf: &[u8]) -> Result<usize, SocketError> {
+/// use optee_utee::net::StdCompactWrite;
+///
+/// stream.write_all(buf)
+/// }
+/// ```
+pub trait StdCompactWrite {
+ fn write(&mut self, buf: &[u8]) -> Result<usize, SocketError>;
+ fn write_all(&mut self, mut buf: &[u8]) -> Result<(), SocketError> {
+ while !buf.is_empty() {
+ match self.write(buf)? {
+ 0 => return Err(SocketError::Tee(crate::ErrorKind::Generic)),
+ n => buf = &buf[n..],
+ }
+ }
+ Ok(())
+ }
+}
+
+/// A trait used for convenience; import it so that the code remains consistent
+/// with the std version (with the only difference being the return error type).
+///
+/// Take TcpStream as example:
+/// ```no_run
+/// use optee_utee::net::TcpStream;
+///
+/// fn read_without_compact_trait(stream: &mut Stream, mut buf: &mut [u8]) -> Result<usize, SocketError> {
+/// use optee_utee::ErrorKind;
+///
+/// while !buf.is_empty() {
+/// match stream.read(buf) {
+/// Ok(0) => break;
+/// Ok(n) => buf = &mut buf[n..],
+/// Err(e) => return Err(e),
+/// }
+/// }
+/// if !buf.is_empty() {
+/// return Err(SocketError::Tee(ErrorKind::Generic));
+/// }
+/// Ok(())
+/// }
+///
+/// fn write_with_compact_trait(stream: &mut Stream, buf: &mut [u8]) -> Result<usize, SocketError> {
+/// use optee_utee::net::StdCompactRead;
+///
+/// stream.read_exact(buf)
+/// }
+/// ```
+pub trait StdCompactRead {
+ fn read(&mut self, buf: &mut [u8]) -> Result<usize, SocketError>;
+ fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<(), SocketError> {
+ while !buf.is_empty() {
+ match self.read(buf)? {
+ 0 => break,
+ n => buf = &mut buf[n..],
+ }
+ }
+ if !buf.is_empty() {
+ return Err(SocketError::Tee(crate::ErrorKind::Generic));
+ }
+ Ok(())
+ }
+}
+
+impl<T: SocketAdapter<Setup = Setup>> StdCompactConnect for Socket<T> {
+ fn connect_v4(address: &str, port: u16) -> Result<Self, SocketError> {
+ let setup = Setup::new_v4(address, port)?;
+ Self::open(setup)
+ }
+ fn connect_v6(address: &str, port: u16) -> Result<Self, SocketError> {
+ let setup = Setup::new_v4(address, port)?;
Review Comment:
Shouldn't it be `new_v6` instead here?
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1926516877
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
After testing, I am 100% sure that the reason is modules missing(which result in ipv6 module not loaded).

Can we update the [image](https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/) we are using, fix the missing modules? I think update rootfs is enough.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1925214693
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_v4(address, port)
+ }
+}
+
+impl std::io::Read for TcpStream {
+ fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
+ match self.recv(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+}
+
+impl std::io::Write for TcpStream {
+ fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
+ match self.send(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+ fn flush(&mut self) -> std::io::Result<()> {
+ Ok(())
+ }
+}
+
+impl UdpSocket {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_v4(address, port)
+ }
+}
+
+impl std::io::Read for UdpSocket {
+ fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
+ match self.recv(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+}
+
+impl std::io::Write for UdpSocket {
+ fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
+ match self.send(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+ fn flush(&mut self) -> std::io::Result<()> {
+ Ok(())
+ }
+}
+
+impl Into<std::io::Error> for SocketError {
Review Comment:
If we decide to keep it, I will add comment here for description.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1926482560
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
Currently stuck in enable ipv6 support in qemu, any suggestion? @DemesneGH @b49020
I try binding a ipv6 address in host, result is:
```shell
called `Result::unwrap()` on an `Err` value: Os { code: 97, kind: Uncategorized, message: "Address family not supported by protocol" }
```
I try connecting to `ipv6.google.com`, result is cannot make the connection.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#issuecomment-2641823179
@DemesneGH @b49020 Any updates
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "b49020 (via GitHub)" <gi...@apache.org>.
b49020 commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1928151987
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
OP-TEE buildroot setup doesn't package any kernel modules but rather only relies of kernel built-in modules only. Give following change a try if it works for you:
```
build$ git diff
diff --git a/kconfigs/qemu.conf b/kconfigs/qemu.conf
index 418888c..b2a7e00 100644
--- a/kconfigs/qemu.conf
+++ b/kconfigs/qemu.conf
@@ -3,6 +3,7 @@ CONFIG_OPTEE=y
### Enable 9P VFS
CONFIG_NET_9P=y
CONFIG_NET_9P_VIRTIO=y
+CONFIG_IPV6=y
CONFIG_9P_FS=y
CONFIG_9P_FS_POSIX_ACL=y
CONFIG_HW_RANDOM=y
```
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
OP-TEE buildroot setup doesn't package any kernel modules but rather only relies on kernel built-in modules only. Give following change a try if it works for you:
```
build$ git diff
diff --git a/kconfigs/qemu.conf b/kconfigs/qemu.conf
index 418888c..b2a7e00 100644
--- a/kconfigs/qemu.conf
+++ b/kconfigs/qemu.conf
@@ -3,6 +3,7 @@ CONFIG_OPTEE=y
### Enable 9P VFS
CONFIG_NET_9P=y
CONFIG_NET_9P_VIRTIO=y
+CONFIG_IPV6=y
CONFIG_9P_FS=y
CONFIG_9P_FS_POSIX_ACL=y
CONFIG_HW_RANDOM=y
```
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1928590737
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
> The `optee-qemuv8-4.2.0-ubuntu-24.04.tar.gz` image has been updated, please just retry the ci test for ipv6.
OK, will try it.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "b49020 (via GitHub)" <gi...@apache.org>.
b49020 commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1924865439
##########
optee-utee/src/net/optee_no_std.rs:
##########
@@ -0,0 +1,150 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+use super::{Setup, Socket, SocketAdapter, SocketError};
+
+/// A trait used for convenience; import it so that the code remains consistent
+/// with the std version (with the only difference being the return error type).
+///
+/// Take TcpStream as example:
+/// ```no_run
+/// use optee_utee::net::TcpStream;
+///
+/// fn connect_without_compact_trait(host: &str, port: u16) -> Result<TcpStream, SocketError> {
+/// let setup = Setup::new_v4(host, port)?;
+/// TcpStream::open(setup)
+/// }
+///
+/// fn connect_with_compact_trait(host: &str, port: u16) -> Result<TcpStream, SocketError> {
+/// use optee_utee::net::StdCompactConnect;
+///
+/// TcpStream::connect_v4(host, port)
+/// }
+/// ```
+pub trait StdCompactConnect: Sized {
Review Comment:
I suppose by name here you meant "Std compatible connect", right? If yes then we should rename it rather as s/StdCompactConnect/StdCompatConnect/. Same applies to other trait names as well.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "b49020 (via GitHub)" <gi...@apache.org>.
b49020 commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1925266584
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_v4(address, port)
+ }
+}
+
+impl std::io::Read for TcpStream {
+ fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
+ match self.recv(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+}
+
+impl std::io::Write for TcpStream {
+ fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
+ match self.send(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+ fn flush(&mut self) -> std::io::Result<()> {
+ Ok(())
+ }
+}
+
+impl UdpSocket {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_v4(address, port)
+ }
+}
+
+impl std::io::Read for UdpSocket {
+ fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
+ match self.recv(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+}
+
+impl std::io::Write for UdpSocket {
+ fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
+ match self.send(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+ fn flush(&mut self) -> std::io::Result<()> {
+ Ok(())
+ }
+}
+
+impl Into<std::io::Error> for SocketError {
Review Comment:
Okay I see, we need it for mapping errors. Lets keep it.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "b49020 (via GitHub)" <gi...@apache.org>.
b49020 commented on PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#issuecomment-2641958111
There is CI failure related to 64-bit std TAs, you should be able to look into it. However, FWIW:
`Reviewed-by: Sumit Garg <su...@linaro.org>`
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1928165412
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
> OP-TEE buildroot setup doesn't package any kernel modules but rather only relies of kernel built-in modules only. Give following change a try if it works for you:
>
> ```
> build$ git diff
> diff --git a/kconfigs/qemu.conf b/kconfigs/qemu.conf
> index 418888c..b2a7e00 100644
> --- a/kconfigs/qemu.conf
> +++ b/kconfigs/qemu.conf
> @@ -3,6 +3,7 @@ CONFIG_OPTEE=y
> ### Enable 9P VFS
> CONFIG_NET_9P=y
> CONFIG_NET_9P_VIRTIO=y
> +CONFIG_IPV6=y
> CONFIG_9P_FS=y
> CONFIG_9P_FS_POSIX_ACL=y
> CONFIG_HW_RANDOM=y
> ```
Yes, it works, so just change kconfig with `CONFIG_IPV6=y` is enough @DemesneGH @b49020
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1928205478
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
The `optee-qemuv8-4.2.0-ubuntu-24.04.tar.gz` image has been updated, please just retry the ci test for ipv6.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1925192117
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
Yeah, I will add them in this commit, just try both v4 and v6 in the examples.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1928881628
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
Sorry for the wrong image, new image re-uploaded.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1928916952
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
> Sorry for the wrong image, new image re-uploaded.
It works! Thanks for your effort!
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "b49020 (via GitHub)" <gi...@apache.org>.
b49020 commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1924874621
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_v4(address, port)
+ }
+}
+
+impl std::io::Read for TcpStream {
+ fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
+ match self.recv(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+}
+
+impl std::io::Write for TcpStream {
+ fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
+ match self.send(buf) {
+ Ok(v) => Ok(v as usize),
+ Err(err) => Err(Into::<std::io::Error>::into(err)),
+ }
+ }
+ fn flush(&mut self) -> std::io::Result<()> {
+ Ok(())
+ }
+}
+
+impl UdpSocket {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
Ditto here, need to be fixed for v6.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#issuecomment-2642150491
Can we retry the failed test? I think it’s simply a lag that causes digest-rs to exceed the 5-second limit, resulting in a Ctrl-C (signal 2).
All the tests in the CI passed on my repository, check [here](https://github.com/ivila/incubator-teaclave-trustzone-sdk/actions/runs/13194518687)

--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#issuecomment-2642043217
> There is CI failure related to 64-bit std TAs, you should be able to look into it. However, FWIW:
>
> `Reviewed-by: Sumit Garg <su...@linaro.org>`
The error is `error: failed to get bitcode from object file for LTO (could not find requested section)`

It happens occasionally; simply retry, and the test will eventually pass.
PS: the CI is passed at my repositories, check [here](https://github.com/ivila/incubator-teaclave-trustzone-sdk/actions/runs/13191824930):

--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "b49020 (via GitHub)" <gi...@apache.org>.
b49020 commented on PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#issuecomment-2642050140
> It happens occasionally; simply retry, and the test will eventually pass.
Okay, looks like it's related to custom OP-TEE toolchain target OS config option for std TAs. @DemesneGH can you take a look at this issue? We should be able to merge this PR while filing a corresponding issue such that we can keep track of it.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1999963755
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
> Okay so the OP-TEE buildroot setup requires an update here. If you succeed with IPv6 testing then please push those changes to upstream OP-TEE buildroot setup too.
@DemesneGH I think we forget this step😂
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1926482560
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
Currently stuck in enable ipv6 support in qemu, any suggestion? @DemesneGH @b49020
I try binding a ipv6 address in host, result is:
```shell
called `Result::unwrap()` on an `Err` value: Os { code: 97, kind: Uncategorized, message: "Address family not supported by protocol" }
```
I try connecting to `ipv6.google.com`, result is cannot make the connection.
PS: I think the reason is that we load no modules in the kernel(while a ipv6 module required to be loaded).
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "b49020 (via GitHub)" <gi...@apache.org>.
b49020 commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1928145123
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
Okay so the OP-TEE buildroot setup requires an update here. If you succeed with IPv6 testing then please push those changes to upstream OP-TEE buildroot setup too.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1928131209
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
The image comes from OP-TEE repo buildroot outputs, with default building configuration. Could you provide the build configuration flags to build the ipv6 modules if you're also using buildroot? I'm also working on rebuilding the image.
--
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] optee-utee: support no-std net. [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #164:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1928145670
##########
optee-utee/src/net/optee_std.rs:
##########
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_sys as raw;
+
+use super::optee::Setup;
+use super::SocketError;
+use super::{TcpStream, UdpSocket};
+use alloc::format;
+
+impl TcpStream {
+ fn connect_with_ip_version(
+ address: &str,
+ port: u16,
+ ip_version: raw::TEE_ipSocket_ipVersion,
+ ) -> std::io::Result<Self> {
+ let setup = Setup::new(address, port, ip_version)
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Invalid address"))?;
+ Ok(Self::open(setup).map_err(|err| Into::<std::io::Error>::into(err))?)
+ }
+ pub fn connect_v4(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
+ }
+ pub fn connect_v6(address: &str, port: u16) -> std::io::Result<Self> {
+ Self::connect_with_ip_version(address, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
Review Comment:
> The image comes from OP-TEE repo buildroot outputs, with default building configuration. Could you provide the build configuration flags to build the ipv6 modules if you're also using buildroot? I'm also working on rebuilding the image.
I believe IPv6 support is already enabled in the Linux kernel by default. The issue seems to be that the modules were not installed into the root filesystem (no `/lib/modules` inside `rootfs.cpio.uboot`). To fix this, we likely just need to run `make INSTALL_MOD_PATH=${PATH_TO_ROOTFS} modules_install` in the Linux kernel build process.
--
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