Skip to content

Commit 3ed8266

Browse files
committed
riscv: modify documents for virtual machine load and store functions
1 parent e0f25a9 commit 3ed8266

File tree

2 files changed

+26
-52
lines changed

2 files changed

+26
-52
lines changed

crates/core_arch/src/riscv/mod.rs

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,8 @@ pub unsafe fn sfence_inval_ir() {
152152
/// i.e., with the address translation and protection, and the endianness, that apply to memory
153153
/// accesses in either VS-mode or VU-mode.
154154
///
155-
/// # Unsafety
156-
///
157-
/// This function accesses the virtual supervisor or user via a `HLV.B` instruction which is effectively
158-
/// an unreference to any memory address, thus is wrapped into an unsafe function.
155+
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.B`
156+
/// instruction which is effectively an unreference to any memory address.
159157
#[inline]
160158
pub unsafe fn hlv_b(src: *const i8) -> i8 {
161159
let value: i8;
@@ -169,10 +167,8 @@ pub unsafe fn hlv_b(src: *const i8) -> i8 {
169167
/// i.e., with the address translation and protection, and the endianness, that apply to memory
170168
/// accesses in either VS-mode or VU-mode.
171169
///
172-
/// # Unsafety
173-
///
174-
/// This function accesses the virtual supervisor or user via a `HLV.BU` instruction which is effectively
175-
/// an unreference to any memory address, thus is wrapped into an unsafe function.
170+
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.BU`
171+
/// instruction which is effectively an unreference to any memory address.
176172
#[inline]
177173
pub unsafe fn hlv_bu(src: *const u8) -> u8 {
178174
let value: u8;
@@ -186,10 +182,8 @@ pub unsafe fn hlv_bu(src: *const u8) -> u8 {
186182
/// i.e., with the address translation and protection, and the endianness, that apply to memory
187183
/// accesses in either VS-mode or VU-mode.
188184
///
189-
/// # Unsafety
190-
///
191-
/// This function accesses the virtual supervisor or user via a `HLV.H` instruction which is effectively
192-
/// an unreference to any memory address, thus is wrapped into an unsafe function.
185+
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.H`
186+
/// instruction which is effectively an unreference to any memory address.
193187
#[inline]
194188
pub unsafe fn hlv_h(src: *const i16) -> i16 {
195189
let value: i16;
@@ -203,10 +197,8 @@ pub unsafe fn hlv_h(src: *const i16) -> i16 {
203197
/// i.e., with the address translation and protection, and the endianness, that apply to memory
204198
/// accesses in either VS-mode or VU-mode.
205199
///
206-
/// # Unsafety
207-
///
208-
/// This function accesses the virtual supervisor or user via a `HLV.HU` instruction which is effectively
209-
/// an unreference to any memory address, thus is wrapped into an unsafe function.
200+
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.HU`
201+
/// instruction which is effectively an unreference to any memory address.
210202
#[inline]
211203
pub unsafe fn hlv_hu(src: *const u16) -> u16 {
212204
let value: u16;
@@ -220,10 +212,8 @@ pub unsafe fn hlv_hu(src: *const u16) -> u16 {
220212
/// the memory being read must be executable in both stages of address translation,
221213
/// but read permission is not required.
222214
///
223-
/// # Unsafety
224-
///
225-
/// This function accesses the virtual supervisor or user via a `HLVX.HU` instruction which is effectively
226-
/// an unreference to any memory address, thus is wrapped into an unsafe function.
215+
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLVX.HU`
216+
/// instruction which is effectively an unreference to any memory address.
227217
#[inline]
228218
pub unsafe fn hlvx_hu(src: *const u16) -> u16 {
229219
let insn: u16;
@@ -237,10 +227,8 @@ pub unsafe fn hlvx_hu(src: *const u16) -> u16 {
237227
/// i.e., with the address translation and protection, and the endianness, that apply to memory
238228
/// accesses in either VS-mode or VU-mode.
239229
///
240-
/// # Unsafety
241-
///
242-
/// This function accesses the virtual supervisor or user via a `HLV.W` instruction which is effectively
243-
/// an unreference to any memory address, thus is wrapped into an unsafe function.
230+
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.W`
231+
/// instruction which is effectively an unreference to any memory address.
244232
#[inline]
245233
pub unsafe fn hlv_w(src: *const i32) -> i32 {
246234
let value: i32;
@@ -254,10 +242,8 @@ pub unsafe fn hlv_w(src: *const i32) -> i32 {
254242
/// the memory being read must be executable in both stages of address translation,
255243
/// but read permission is not required.
256244
///
257-
/// # Unsafety
258-
///
259-
/// This function accesses the virtual supervisor or user via a `HLVX.WU` instruction which is effectively
260-
/// an unreference to any memory address, thus is wrapped into an unsafe function.
245+
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLVX.WU`
246+
/// instruction which is effectively an unreference to any memory address.
261247
#[inline]
262248
pub unsafe fn hlvx_wu(src: *const u32) -> u32 {
263249
let insn: u32;
@@ -271,10 +257,8 @@ pub unsafe fn hlvx_wu(src: *const u32) -> u32 {
271257
/// i.e., with the address translation and protection, and the endianness, that apply to memory
272258
/// accesses in either VS-mode or VU-mode.
273259
///
274-
/// # Unsafety
275-
///
276-
/// This function accesses the virtual supervisor or user via a `HSV.B` instruction which is effectively
277-
/// an unreference to any memory address, thus is wrapped into an unsafe function.
260+
/// This function is unsafe for it accesses the virtual supervisor or user via a `HSV.B`
261+
/// instruction which is effectively an unreference to any memory address.
278262
#[inline]
279263
pub unsafe fn hsv_b(dst: *mut i8, src: i8) {
280264
asm!(".insn r 0x73, 0x4, 0x31, x0, {}, {}", in(reg) dst, in(reg) src);
@@ -286,10 +270,8 @@ pub unsafe fn hsv_b(dst: *mut i8, src: i8) {
286270
/// i.e., with the address translation and protection, and the endianness, that apply to memory
287271
/// accesses in either VS-mode or VU-mode.
288272
///
289-
/// # Unsafety
290-
///
291-
/// This function accesses the virtual supervisor or user via a `HSV.H` instruction which is effectively
292-
/// an unreference to any memory address, thus is wrapped into an unsafe function.
273+
/// This function is unsafe for it accesses the virtual supervisor or user via a `HSV.H`
274+
/// instruction which is effectively an unreference to any memory address.
293275
#[inline]
294276
pub unsafe fn hsv_h(dst: *mut i16, src: i16) {
295277
asm!(".insn r 0x73, 0x4, 0x33, x0, {}, {}", in(reg) dst, in(reg) src);
@@ -301,10 +283,8 @@ pub unsafe fn hsv_h(dst: *mut i16, src: i16) {
301283
/// i.e., with the address translation and protection, and the endianness, that apply to memory
302284
/// accesses in either VS-mode or VU-mode.
303285
///
304-
/// # Unsafety
305-
///
306-
/// This function accesses the virtual supervisor or user via a `HSV.W` instruction which is effectively
307-
/// an unreference to any memory address, thus is wrapped into an unsafe function.
286+
/// This function is unsafe for it accesses the virtual supervisor or user via a `HSV.W`
287+
/// instruction which is effectively an unreference to any memory address.
308288
#[inline]
309289
pub unsafe fn hsv_w(dst: *mut i32, src: i32) {
310290
asm!(".insn r 0x73, 0x4, 0x35, x0, {}, {}", in(reg) dst, in(reg) src);

crates/core_arch/src/riscv64/mod.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ use crate::arch::asm;
99
///
1010
/// This operation is not available under RV32 base instruction set.
1111
///
12-
/// # Unsafety
13-
///
14-
/// This function accesses the virtual supervisor or user via a `HLV.WU` instruction which is effectively
15-
/// an unreference to any memory address, thus is wrapped into an unsafe function.
12+
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.WU`
13+
/// instruction which is effectively an unreference to any memory address.
1614
#[inline]
1715
pub unsafe fn hlv_wu(src: *const u32) -> u32 {
1816
let value: u32;
@@ -28,10 +26,8 @@ pub unsafe fn hlv_wu(src: *const u32) -> u32 {
2826
///
2927
/// This operation is not available under RV32 base instruction set.
3028
///
31-
/// # Unsafety
32-
///
33-
/// This function accesses the virtual supervisor or user via a `HLV.D` instruction which is effectively
34-
/// an unreference to any memory address, thus is wrapped into an unsafe function.
29+
/// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.D`
30+
/// instruction which is effectively an unreference to any memory address.
3531
#[inline]
3632
pub unsafe fn hlv_d(src: *const i64) -> i64 {
3733
let value: i64;
@@ -45,10 +41,8 @@ pub unsafe fn hlv_d(src: *const i64) -> i64 {
4541
/// i.e., with the address translation and protection, and the endianness, that apply to memory
4642
/// accesses in either VS-mode or VU-mode.
4743
///
48-
/// # Unsafety
49-
///
50-
/// This function accesses the virtual supervisor or user via a `HSV.D` instruction which is effectively
51-
/// an unreference to any memory address, thus is wrapped into an unsafe function.
44+
/// This function is unsafe for it accesses the virtual supervisor or user via a `HSV.D`
45+
/// instruction which is effectively an unreference to any memory address.
5246
#[inline]
5347
pub unsafe fn hsv_d(dst: *mut i64, src: i64) {
5448
asm!(".insn r 0x73, 0x4, 0x37, x0, {}, {}", in(reg) dst, in(reg) src);

0 commit comments

Comments
 (0)