1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use kev::{vcpu::GenericVCpuState, Probe, VmError};
use project2::vmexit::msr;
pub struct X2Apic {}
impl X2Apic {
pub fn attach(ctl: &mut msr::Controller) {
assert!(ctl.insert(0x1B, X2Apic {}));
assert!(ctl.insert(0x808, X2Apic {}));
assert!(ctl.insert(0x80b, X2Apic {}));
assert!(ctl.insert(0x830, X2Apic {}));
assert!(ctl.insert(0x832, X2Apic {}));
assert!(ctl.insert(0x80F, X2Apic {}));
assert!(ctl.insert(0x835, X2Apic {}));
assert!(ctl.insert(0x836, X2Apic {}));
assert!(ctl.insert(0x6e0, X2Apic {}));
}
}
impl msr::Msr for X2Apic {
fn rdmsr(
&self,
index: u32,
_p: &dyn Probe,
_generic_vcpu_state: &mut GenericVCpuState,
) -> Result<u64, VmError> {
match index {
0x1b | 0x808 | 0x80b | 0x830 | 0x80f | 0x835 | 0x836 | 0x832 | 0x6e0 => Ok(0),
_ => todo!("{index:x}"),
}
}
fn wrmsr(
&mut self,
index: u32,
_value: u64,
_p: &dyn Probe,
_generic_vcpu_state: &mut GenericVCpuState,
) -> Result<(), VmError> {
match index {
0x1b | 0x808 | 0x80b | 0x830 | 0x80f | 0x835 | 0x836 | 0x832 | 0x6e0 => (),
_ => todo!("{index:x}"),
}
Ok(())
}
}