-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Fix implicit_provenance_casts warnings on Xous #159174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+39
−33
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ fn lend_mut_impl( | |
| let mut a1: usize = connection.try_into().unwrap(); | ||
| let mut a2 = InvokeType::LendMut as usize; | ||
| let a3 = opcode; | ||
| let a4 = data.as_mut_ptr() as usize; | ||
| let a4 = data.as_mut_ptr(); | ||
| let a5 = data.len(); | ||
| let a6 = arg1; | ||
| let a7 = arg2; | ||
|
|
@@ -86,7 +86,7 @@ fn lend_impl( | |
| let a1: usize = connection.try_into().unwrap(); | ||
| let a2 = InvokeType::Lend as usize; | ||
| let a3 = opcode; | ||
| let a4 = data.as_ptr() as usize; | ||
| let a4 = data.as_ptr(); | ||
| let a5 = data.len(); | ||
| let a6 = arg1; | ||
| let a7 = arg2; | ||
|
|
@@ -359,15 +359,19 @@ pub(crate) fn do_yield() { | |
| /// This function is safe unless a virtual address is specified. In that case, | ||
| /// the kernel will return an alias to the existing range. This violates Rust's | ||
| /// pointer uniqueness guarantee. | ||
| // The phys argument uses an integer rather than pointer type as pointer | ||
| // provenance only covers virtual memory, not physical memory. | ||
| pub(crate) unsafe fn map_memory<T>( | ||
| phys: Option<core::ptr::NonNull<T>>, | ||
| phys: Option<core::num::NonZeroUsize>, | ||
| virt: Option<core::ptr::NonNull<T>>, | ||
| count: usize, | ||
| flags: MemoryFlags, | ||
| ) -> Result<&'static mut [T], Error> { | ||
| let mut a0 = Syscall::MapMemory as usize; | ||
| let mut a1 = phys.map(|p| p.as_ptr() as usize).unwrap_or_default(); | ||
| let mut a2 = virt.map(|p| p.as_ptr() as usize).unwrap_or_default(); | ||
| let a1 = phys.map_or(0, |p| p.get()); | ||
| let a1_out: *mut T; | ||
| let a2 = virt.map_or(core::ptr::null(), |p| p.as_ptr()); | ||
| let a2_out: usize; | ||
| let a3 = count * size_of::<T>(); | ||
| let a4 = flags.bits(); | ||
| let a5 = 0; | ||
|
|
@@ -378,8 +382,8 @@ pub(crate) unsafe fn map_memory<T>( | |
| core::arch::asm!( | ||
| "ecall", | ||
| inlateout("a0") a0, | ||
| inlateout("a1") a1, | ||
| inlateout("a2") a2, | ||
| inlateout("a1") a1 => a1_out, | ||
| inlateout("a2") a2 => a2_out, | ||
| inlateout("a3") a3 => _, | ||
| inlateout("a4") a4 => _, | ||
| inlateout("a5") a5 => _, | ||
|
|
@@ -391,12 +395,12 @@ pub(crate) unsafe fn map_memory<T>( | |
| let result = a0; | ||
|
|
||
| if result == SyscallResult::MemoryRange as usize { | ||
| let start = core::ptr::with_exposed_provenance_mut::<T>(a1); | ||
| let len = a2 / size_of::<T>(); | ||
| let start = a1_out; | ||
| let len = a2_out / size_of::<T>(); | ||
| let end = unsafe { start.add(len) }; | ||
| Ok(unsafe { core::slice::from_raw_parts_mut(start, len) }) | ||
| } else if result == SyscallResult::Error as usize { | ||
| Err(a1.into()) | ||
| Err(a1_out.addr().into()) | ||
| } else { | ||
| Err(Error::InternalError) | ||
| } | ||
|
|
@@ -408,7 +412,7 @@ pub(crate) unsafe fn map_memory<T>( | |
| /// function returns, even if this function returns Err(). | ||
| pub(crate) unsafe fn unmap_memory<T>(range: *mut [T]) -> Result<(), Error> { | ||
| let mut a0 = Syscall::UnmapMemory as usize; | ||
| let mut a1 = range.as_mut_ptr() as usize; | ||
| let mut a1 = range.as_mut_ptr(); | ||
| let a2 = range.len() * size_of::<T>(); | ||
| let a3 = 0; | ||
| let a4 = 0; | ||
|
|
@@ -435,7 +439,7 @@ pub(crate) unsafe fn unmap_memory<T>(range: *mut [T]) -> Result<(), Error> { | |
| if result == SyscallResult::Ok as usize { | ||
| Ok(()) | ||
| } else if result == SyscallResult::Error as usize { | ||
| Err(a1.into()) | ||
| Err(a1.addr().into()) | ||
| } else { | ||
| Err(Error::InternalError) | ||
| } | ||
|
|
@@ -454,7 +458,8 @@ pub(crate) unsafe fn update_memory_flags<T>( | |
| new_flags: MemoryFlags, | ||
| ) -> Result<(), Error> { | ||
| let mut a0 = Syscall::UpdateMemoryFlags as usize; | ||
| let mut a1 = range.as_mut_ptr() as usize; | ||
| let a1 = range.as_mut_ptr(); | ||
| let a1_out: usize; | ||
| let a2 = range.len() * size_of::<T>(); | ||
| let a3 = new_flags.bits(); | ||
| let a4 = 0; // Process ID is currently None | ||
|
|
@@ -466,7 +471,7 @@ pub(crate) unsafe fn update_memory_flags<T>( | |
| core::arch::asm!( | ||
| "ecall", | ||
| inlateout("a0") a0, | ||
| inlateout("a1") a1, | ||
| inlateout("a1") a1 => a1_out, | ||
| inlateout("a2") a2 => _, | ||
| inlateout("a3") a3 => _, | ||
| inlateout("a4") a4 => _, | ||
|
|
@@ -481,24 +486,25 @@ pub(crate) unsafe fn update_memory_flags<T>( | |
| if result == SyscallResult::Ok as usize { | ||
| Ok(()) | ||
| } else if result == SyscallResult::Error as usize { | ||
| Err(a1.into()) | ||
| Err(a1_out.into()) | ||
| } else { | ||
| Err(Error::InternalError) | ||
| } | ||
| } | ||
|
|
||
| /// Creates a thread with a given stack and up to four arguments. | ||
| pub(crate) fn create_thread( | ||
| start: *mut usize, | ||
| pub(crate) unsafe fn create_thread<T>( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this generic lead to extra machine code due to monomorphisation?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is only a single monomorphic caller. |
||
| start: unsafe extern "C" fn(*mut usize, usize, usize) -> !, | ||
| stack: *mut [u8], | ||
| arg0: usize, | ||
| arg1: usize, | ||
| arg0: *mut T, | ||
| arg1: *const u8, | ||
| arg2: usize, | ||
| arg3: usize, | ||
| ) -> Result<ThreadId, Error> { | ||
| let mut a0 = Syscall::CreateThread as usize; | ||
| let mut a1 = start as usize; | ||
| let a2 = stack.as_mut_ptr() as usize; | ||
| let a1 = start; | ||
| let a1_out: usize; | ||
| let a2 = stack.as_mut_ptr(); | ||
| let a3 = stack.len(); | ||
| let a4 = arg0; | ||
| let a5 = arg1; | ||
|
|
@@ -509,7 +515,7 @@ pub(crate) fn create_thread( | |
| core::arch::asm!( | ||
| "ecall", | ||
| inlateout("a0") a0, | ||
| inlateout("a1") a1, | ||
| inlateout("a1") a1 => a1_out, | ||
| inlateout("a2") a2 => _, | ||
| inlateout("a3") a3 => _, | ||
| inlateout("a4") a4 => _, | ||
|
|
@@ -522,9 +528,9 @@ pub(crate) fn create_thread( | |
| let result = a0; | ||
|
|
||
| if result == SyscallResult::ThreadId as usize { | ||
| Ok(a1.into()) | ||
| Ok(a1_out.into()) | ||
| } else if result == SyscallResult::Error as usize { | ||
| Err(a1.into()) | ||
| Err(a1_out.into()) | ||
| } else { | ||
| Err(Error::InternalError) | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.