foc: working VM session support for AMD

- kernel: propagate cr0 to VMM on exit in nested paging case
- kernel: disable forceful VM exit on task switch
- vm_session: adjust to kernel changes

Issue #3111
This commit is contained in:
Alexander Boettcher 2019-05-05 14:32:46 +02:00 committed by Christian Helmuth
parent b3f288c035
commit 92510af9d4
3 changed files with 13 additions and 10 deletions

View File

@ -1 +1 @@
9db0c4985349d47251e91e4e61145526668278fc
23f5b19a4853073d9cde790709f5e8d9a6c401d7

View File

@ -2,5 +2,5 @@ LICENSE := GPLv2
VERSION := git
DOWNLOADS := foc.git
URL(foc) := https://github.com/alex-ab/foc.git
REV(foc) := a8411389dffc3c55dc5809d2e849b3afac94ee5d
REV(foc) := 45bf2c699552d1e2891d322bea479d95f8c93d02
DIR(foc) := src/kernel/foc

View File

@ -173,13 +173,13 @@ struct Vcpu : Genode::Thread
CR0_PG = 0 /* 1U << 31 - not needed in case of UG */
};
addr_t const _cr0_mask { CR0_CP | CR0_NM | CR0_NE | CR0_CD };
addr_t const _cr0_mask { CR0_NM | CR0_CD };
addr_t const vmcb_ctrl0 { CTRL0_IO | CTRL0_MSR };
addr_t const vmcb_ctrl1 { 0 };
addr_t vmcb_cr0_shadow { 0 };
addr_t vmcb_cr4_shadow { 0 };
addr_t const vmcb_cr0_mask { _cr0_mask | CR0_TS };
addr_t const vmcb_cr0_mask { _cr0_mask };
addr_t const vmcb_cr0_set { 0 };
addr_t const vmcb_cr4_mask { 0 };
addr_t const vmcb_cr4_set { 0 };
@ -187,7 +187,7 @@ struct Vcpu : Genode::Thread
enum { EXIT_ON_HLT = 1U << 7 };
addr_t const _vmcs_ctrl0 { EXIT_ON_HLT };
addr_t const vmcs_cr0_mask { _cr0_mask | CR0_PE | CR0_PG };
addr_t const vmcs_cr0_mask { _cr0_mask | CR0_CP | CR0_NE | CR0_PE | CR0_PG };
addr_t const vmcs_cr0_set { 0 };
addr_t const vmcs_cr4_mask { CR4_VMX };
@ -273,14 +273,17 @@ struct Vcpu : Genode::Thread
state.efer.value(state.efer.value() | AMD_SVM_ENABLE);
}
if (_vm_type == Virt::SVM) {
vmcb->control_area.intercept_instruction0 = vmcb_ctrl0;
vmcb->control_area.intercept_instruction1 = vmcb_ctrl1;
/* special handling on missing NPT support */
vmcb->control_area.np_enable = svm_np();
if (!vmcb->control_area.np_enable)
if (!vmcb->control_area.np_enable) {
vmcb->control_area.intercept_exceptions |= 1 << 14;
vmcb->control_area.intercept_instruction0 = vmcb_ctrl0;
vmcb->control_area.intercept_rd_crX = 0x0001; /* cr0 */
vmcb->control_area.intercept_wr_crX = 0x0001; /* cr0 */
vmcb->control_area.intercept_rd_crX = 0x0001; /* cr0 */
vmcb->control_area.intercept_wr_crX = 0x0001; /* cr0 */
} else
vmcb->state_save_area.g_pat = 0x7040600070406ull;
}
if (_vm_type == Virt::VMX) {
Fiasco::l4_vm_vmx_write(vmcs, Vmcs::CR0_MASK, vmcs_cr0_mask);