hypervisor: x86: add two safety comments

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2022-11-16 21:50:09 +00:00 committed by Liu Wei
parent 6c89c541da
commit 7f2723d9c6

View File

@ -272,6 +272,7 @@ impl LapicState {
use std::io::Cursor; use std::io::Cursor;
use std::mem; use std::mem;
// SAFETY: plain old data type
let sliceu8 = unsafe { let sliceu8 = unsafe {
// This array is only accessed as parts of a u32 word, so interpret it as a u8 array. // This array is only accessed as parts of a u32 word, so interpret it as a u8 array.
// Cursors are only readable on arrays of u8, not i8(c_char). // Cursors are only readable on arrays of u8, not i8(c_char).
@ -290,6 +291,7 @@ impl LapicState {
use std::io::Cursor; use std::io::Cursor;
use std::mem; use std::mem;
// SAFETY: plain old data type
let sliceu8 = unsafe { let sliceu8 = unsafe {
// This array is only accessed as parts of a u32 word, so interpret it as a u8 array. // This array is only accessed as parts of a u32 word, so interpret it as a u8 array.
// Cursors are only readable on arrays of u8, not i8(c_char). // Cursors are only readable on arrays of u8, not i8(c_char).