Skip to content

Commit a8d1061

Browse files
committed
riscv: adjust documents for virtual memory instructions
1 parent 0c00e44 commit a8d1061

File tree

2 files changed

+39
-65
lines changed

2 files changed

+39
-65
lines changed

crates/core_arch/src/riscv/mod.rs

+30-50
Original file line numberDiff line numberDiff line change
@@ -146,165 +146,145 @@ pub unsafe fn sfence_inval_ir() {
146146
asm!(".insn i 0x73, 0, x0, x0, 0x181")
147147
}
148148

149-
/// Loads memory from hypervisor by signed byte integer
149+
/// Loads virtual machine memory by signed byte integer
150150
///
151151
/// This instruction performs an explicit memory access as though `V=1`;
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;
162160
asm!(".insn i 0x73, 0x4, {}, {}, 0x600", out(reg) value, in(reg) src);
163161
value
164162
}
165163

166-
/// Loads memory from hypervisor by unsigned byte integer
164+
/// Loads virtual machine memory by unsigned byte integer
167165
///
168166
/// This instruction performs an explicit memory access as though `V=1`;
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;
179175
asm!(".insn i 0x73, 0x4, {}, {}, 0x601", out(reg) value, in(reg) src);
180176
value
181177
}
182178

183-
/// Loads memory from hypervisor by signed half integer
179+
/// Loads virtual machine memory by signed half integer
184180
///
185181
/// This instruction performs an explicit memory access as though `V=1`;
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;
196190
asm!(".insn i 0x73, 0x4, {}, {}, 0x640", out(reg) value, in(reg) src);
197191
value
198192
}
199193

200-
/// Loads memory from hypervisor by unsigned half integer
194+
/// Loads virtual machine memory by unsigned half integer
201195
///
202196
/// This instruction performs an explicit memory access as though `V=1`;
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;
213205
asm!(".insn i 0x73, 0x4, {}, {}, 0x641", out(reg) value, in(reg) src);
214206
value
215207
}
216208

217-
/// Accesses instruction from hypervisor by unsigned half integer
209+
/// Accesses virtual machine instruction by unsigned half integer
218210
///
219211
/// This instruction performs an explicit memory access as though `V=1`;
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;
230220
asm!(".insn i 0x73, 0x4, {}, {}, 0x643", out(reg) insn, in(reg) src);
231221
insn
232222
}
233223

234-
/// Loads memory from hypervisor by signed word integer
224+
/// Loads virtual machine memory by signed word integer
235225
///
236226
/// This instruction performs an explicit memory access as though `V=1`;
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;
247235
asm!(".insn i 0x73, 0x4, {}, {}, 0x680", out(reg) value, in(reg) src);
248236
value
249237
}
250238

251-
/// Accesses instruction from hypervisor by unsigned word integer
239+
/// Accesses virtual machine instruction by unsigned word integer
252240
///
253241
/// This instruction performs an explicit memory access as though `V=1`;
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;
264250
asm!(".insn i 0x73, 0x4, {}, {}, 0x683", out(reg) insn, in(reg) src);
265251
insn
266252
}
267253

268-
/// Stores memory from hypervisor by byte integer
254+
/// Stores virtual machine memory by byte integer
269255
///
270256
/// This instruction performs an explicit memory access as though `V=1`;
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);
281265
}
282266

283-
/// Stores memory from hypervisor by half integer
267+
/// Stores virtual machine memory by half integer
284268
///
285269
/// This instruction performs an explicit memory access as though `V=1`;
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);
296278
}
297279

298-
/// Stores memory from hypervisor by word integer
280+
/// Stores virtual machine memory by word integer
299281
///
300282
/// This instruction performs an explicit memory access as though `V=1`;
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

+9-15
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,48 @@
11
//! RISC-V RV64 specific intrinsics
22
use crate::arch::asm;
33

4-
/// Loads memory from hypervisor by unsigned word integer
4+
/// Loads virtual machine memory by unsigned word integer
55
///
66
/// This instruction performs an explicit memory access as though `V=1`;
77
/// i.e., with the address translation and protection, and the endianness, that apply to memory
88
/// accesses in either VS-mode or VU-mode.
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;
1917
asm!(".insn i 0x73, 0x4, {}, {}, 0x681", out(reg) value, in(reg) src);
2018
value
2119
}
2220

23-
/// Loads memory from hypervisor by unsigned double integer
21+
/// Loads virtual machine memory by unsigned double integer
2422
///
2523
/// This instruction performs an explicit memory access as though `V=1`;
2624
/// i.e., with the address translation and protection, and the endianness, that apply to memory
2725
/// accesses in either VS-mode or VU-mode.
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;
3834
asm!(".insn i 0x73, 0x4, {}, {}, 0x6C0", out(reg) value, in(reg) src);
3935
value
4036
}
4137

42-
/// Stores memory from hypervisor by double integer
38+
/// Stores virtual machine memory by double integer
4339
///
4440
/// This instruction performs an explicit memory access as though `V=1`;
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)