Skip to content

Commit 2907fca

Browse files
committed
vmm/linux/tee: Handle KVM_EXIT_MEMORY_FAULT exits
Like KVM_EXIT_HYPERCALL, KVM_EXIT_MEMORY_FAULT is used by SEV-SNP guests to set memory regions to private or shared. Allow vCPUs encountering a KVM_EXIT_MEMORY_FAULT to re-use the shared/private memory handler used by KVM_EXIT_HYPERCALL to set regions to private or shared. Signed-off-by: Tyler Fanelli <[email protected]>
1 parent d8496aa commit 2907fca

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/vmm/src/linux/vstate.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,16 @@ impl Vcpu {
12401240
self.io_bus.write(0, u64::from(addr), data);
12411241
Ok(VcpuEmulation::Handled)
12421242
}
1243+
VcpuExit::MemoryFault { gpa, size, flags } => {
1244+
let private = (flags & (1 << 3)/* KVM_EXIT_MEMORY_FAULT */) != 0;
1245+
1246+
let mem_properties = MemoryProperties { gpa, size, private };
1247+
1248+
self.pm_sender.0.send(mem_properties).unwrap();
1249+
let _ = self.pm_sender.1.read().unwrap();
1250+
1251+
Ok(VcpuEmulation::Handled)
1252+
}
12431253
VcpuExit::MmioRead(addr, data) => {
12441254
if let Some(ref mmio_bus) = self.mmio_bus {
12451255
mmio_bus.read(0, addr, data);

0 commit comments

Comments
 (0)