KVM: nVMX: Defer error from VM-entry MSR-load area to until after hardware verifies VMCS guest state-area
PATCH 1/1 KVM: nVMX: Defer error from VM-entry MSR-load area to until after hardware verifies VMCS guest state-area
Some VM-entry checks can be offloaded from KVM to hardware. But if we want to do that, the current implementation of KVM creates a priority issue where the order in which VM-entry checks need to be performed according to the SDM, is not maintained. VM-entry fails in nested_vmx_enter_non_root_mode() if an error is encountered while processing the entries in VM-entry MSR-load area. This leads to VM-exit due to a VM-entry check that is supposed to be done after any guest-state checks done in hardware. This patch fixes this priority issue so that checks that can be offloaded to hardware can now be offloaded.
[PATCH] nVMX: Defer error from VM-entry MSR-load area to until after
arch/x86/kvm/vmx/nested.c | 34 +++++++++++++++++++++++++++++++--- arch/x86/kvm/vmx/nested.h | 14 ++++++++++++-- arch/x86/kvm/vmx/vmcs.h | 6 ++++++ 3 files changed, 49 insertions(+), 5 deletions(-)
Krish Sadhukhan (1):
nVMX: Defer error from VM-entry MSR-load area to until after hardware verifies VMCS guest state-area
PATCH 1/1 nVMX: Defer error from VM-entry MSR-load area to until after hardware verifies VMCS guest state-area
According to section “VM Entries” in Intel SDM vol 3C, VM-entry checks are performed in a certain order. Checks on MSRs that are loaded on VM-entry from VM-entry MSR-load area, should be done after verifying VMCS controls, host-state area and guest-state area. As KVM relies on CPU hardware to perform some of these checks, we need to defer VM-exit due to invalid VM-entry MSR-load area to until after CPU hardware completes the earlier checks and is ready to do VMLAUNCH/VMRESUME.
In order to defer errors arising from invalid VM-entry MSR-load area in vmcs12, we set up a single invalid entry, which is illegal according to section "Loading MSRs in Intel SDM vol 3C, in VM-entry MSR-load area of vmcs02. This will cause the CPU hardware to VM-exit with "VM-entry failure due to MSR loading" after it completes checks on VMCS controls, host-state area and guest-state area. We reflect a synthesized Exit Qualification to our guest.
--- arch/x86/kvm/vmx/nested.c | 34 +++++++++++++++++++++++++++++++--- arch/x86/kvm/vmx/nested.h | 14 ++++++++++++-- arch/x86/kvm/vmx/vmcs.h | 6 ++++++ 3 files changed, 49 insertions(+), 5 deletions(-)
arch/x86/kvm/vmx/nested.c +31 -3
@@ -3054,12 +3054,40 @@ int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) goto vmentry_fail_vmexit_guest_mode;if (from_vmentry) { - exit_reason =EXIT_REASON_MSR_LOAD_FAIL ; exit_qual =nested_vmx_load_msr (vcpu, vmcs12->vm_entry_msr_load_addr, vmcs12->vm_entry_msr_load_count); -if (exit_qual) - goto vmentry_fail_vmexit_guest_mode; +if (exit_qual) { +/* +* According to section “VM Entries” in Intel SDM +* vol 3C, VM-entry checks are performed in a certain +* order. Checks on MSRs that are loaded on VM-entry +* from VM-entry MSR-load area, should be done after +* verifying VMCS controls, host-state area and +* guest-state area. As KVM relies on CPU hardware to +* perform some of these checks, we need to defer +* VM-exit due to invalid VM-entry MSR-load area to +* until after CPU hardware completes the earlier +* checks and is ready to do VMLAUNCH/VMRESUME. +* +* In order to defer errors arising from invalid +* VM-entry MSR-load area in vmcs12, we set up a +* single invalid entry, which is illegal according +* to section "Loading MSRs in Intel SDM vol 3C, in +* VM-entry MSR-load area of vmcs02. This will cause +* the CPU hardware to VM-exit with "VM-entry +* failure due to MSR loading" after it completes +* checks on VMCS controls, host-state area and +* guest-state area. +*/ + vmx->loaded_vmcs->invalid_msr_load_area.index = +MSR_FS_BASE ; + vmx->loaded_vmcs->invalid_msr_load_area.value = + exit_qual; +vmcs_write32 (VM_ENTRY_MSR_LOAD_COUNT ,1 ); +vmcs_write64 (VM_ENTRY_MSR_LOAD_ADDR , +__pa (&(vmx->loaded_vmcs->invalid_msr_load_area))); + } }else {/* * The MMU is not initialized to point at the right entities yet and
arch/x86/kvm/vmx/nested.h +12 -2
@@ -64,7 +64,9 @@ static inline bool nested_ept_ad_enabled(struct kvm_vcpu *vcpu)static inline int nested_vmx_reflect_vmexit (struct kvm_vcpu *vcpu,u32 exit_reason) { +u32 exit_qual;u32 exit_intr_info =vmcs_read32 (VM_EXIT_INTR_INFO ); +struct vcpu_vmx *vmx =to_vmx (vcpu);/* * At this point, the exit interruption info in exit_intr_info
@@ -81,8 +83,16 @@ static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu,vmcs_read32 (VM_EXIT_INTR_ERROR_CODE ); } -nested_vmx_vmexit (vcpu, exit_reason, exit_intr_info, -vmcs_readl (EXIT_QUALIFICATION )); + exit_qual =vmcs_readl (EXIT_QUALIFICATION ); + +if (vmx->loaded_vmcs->invalid_msr_load_area.index ==MSR_FS_BASE && + (exit_reason == (VMX_EXIT_REASONS_FAILED_VMENTRY | +EXIT_REASON_MSR_LOAD_FAIL ))) { + exit_qual = vmx->loaded_vmcs->invalid_msr_load_area.value; + } + +nested_vmx_vmexit (vcpu, exit_reason, exit_intr_info, exit_qual); +return 1 ; }
arch/x86/kvm/vmx/vmcs.h +6 -0
@@ -70,6 +70,12 @@ struct loaded_vmcs {struct list_head loaded_vmcss_on_cpu_link;struct vmcs_host_state host_state;struct vmcs_controls_shadow controls_shadow; +/* +* This field is used to set up an invalid VM-entry MSR-load area +* for vmcs02 if an error is detected while processing the entries +* in VM-entry MSR-load area of vmcs12. +*/ +struct vmx_msr_entry invalid_msr_load_area; };static inline bool is_exception_n (u32 intr_info,u8 vector)
Signature · 1 line
2.20.1
Re: [PATCH] nVMX: Defer error from VM-entry MSR-load area to until after hardware verifies VMCS guest state-area
Quoted 9 lines · Krish Sadhukhan
According to section “VM Entries” in Intel SDM vol 3C, VM-entry checks are performed in a certain order. Checks on MSRs that are loaded on VM-entry from VM-entry MSR-load area, should be done after verifying VMCS controls, host-state area and guest-state area. As KVM relies on CPU hardware to perform some of these checks, we need to defer VM-exit due to invalid VM-entry MSR-load area to until after CPU hardware completes the earlier checks and is ready to do VMLAUNCH/VMRESUME.
Quoted 7 lines
In order to defer errors arising from invalid VM-entry MSR-load area in vmcs12, we set up a single invalid entry, which is illegal according to section "Loading MSRs in Intel SDM vol 3C, in VM-entry MSR-load area of vmcs02. This will cause the CPU hardware to VM-exit with "VM-entry failure due to MSR loading" after it completes checks on VMCS controls, host-state area and guest-state area. We reflect a synthesized Exit Qualification to our guest.
This change addresses the priority inversion, but it still potentially leaves guest MSRs incorrectly loaded with values from the VMCS12 VM-entry MSR-load area when a higher priority error condition would have precluded any processing of the VM-entry MSR-load area.
Quoted 39 lines
Suggested-by Jim Mattson <[email protected]>Signed-off-by Krish Sadhukhan <[email protected]>Reviewed-by Mihai Carabas <[email protected]>Reviewed-by Liran Alon <[email protected]>--- arch/x86/kvm/vmx/nested.c | 34 +++++++++++++++++++++++++++++++--- arch/x86/kvm/vmx/nested.h | 14 ++++++++++++-- arch/x86/kvm/vmx/vmcs.h | 6 ++++++ 3 files changed, 49 insertions(+), 5 deletions(-)arch/x86/kvm/vmx/nested.c +15
-3@@ -3054,12 +3054,40 @@ int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) goto vmentry_fail_vmexit_guest_mode;if (from_vmentry) { - exit_reason =EXIT_REASON_MSR_LOAD_FAIL ; exit_qual =nested_vmx_load_msr (vcpu, vmcs12->vm_entry_msr_load_addr, vmcs12->vm_entry_msr_load_count); -if (exit_qual) - goto vmentry_fail_vmexit_guest_mode; +if (exit_qual) { +/* +* According to section “VM Entries” in Intel SDM +* vol 3C, VM-entry checks are performed in a certain +* order. Checks on MSRs that are loaded on VM-entry +* from VM-entry MSR-load area, should be done after +* verifying VMCS controls, host-state area and +* guest-state area. As KVM relies on CPU hardware to +* perform some of these checks, we need to defer +* VM-exit due to invalid VM-entry MSR-load area to +* until after CPU hardware completes the earlier +* checks and is ready to do VMLAUNCH/VMRESUME. +* +* In order to defer errors arising from invalid +* VM-entry MSR-load area in vmcs12, we set up a
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3084
Quoted 10 lines
arch/x86/kvm/vmx/nested.c +10
-0+* single invalid entry, which is illegal according +* to section "Loading MSRs in Intel SDM vol 3C, in +* VM-entry MSR-load area of vmcs02. This will cause +* the CPU hardware to VM-exit with "VM-entry +* failure due to MSR loading" after it completes +* checks on VMCS controls, host-state area and +* guest-state area. +*/ + vmx->loaded_vmcs->invalid_msr_load_area.index = +MSR_FS_BASE ;
Can this field be statically populated during initialization?
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3086
Quoted 2 lines
arch/x86/kvm/vmx/nested.c +2
-0+ vmx->loaded_vmcs->invalid_msr_load_area.value = + exit_qual;
This seems awkward. Why not save 16 bytes per loaded_vmcs by allocating one invalid_msr_load_area system-wide and just add a 4 byte field to struct nested_vmx to store this value?
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3090
Quoted 4 lines
arch/x86/kvm/vmx/nested.c +4
-0+vmcs_write32 (VM_ENTRY_MSR_LOAD_COUNT ,1 ); +vmcs_write64 (VM_ENTRY_MSR_LOAD_ADDR , +__pa (&(vmx->loaded_vmcs->invalid_msr_load_area))); + }
Do you need to set vmx->nested.dirty_vmcs12 to ensure that prepare_vmcs02_constant_state() will be called at the next emulated VM-entry, to undo this change to VM_ENTRY_MSR_LOAD_ADDR?
Quoted 18 lines
arch/x86/kvm/vmx/nested.c +0
-0}else {/* * The MMU is not initialized to point at the right entities yet and arch/x86/kvm/vmx/nested.h +2
-0@@ -64,7 +64,9 @@ static inline bool nested_ept_ad_enabled(struct kvm_vcpu *vcpu)static inline int nested_vmx_reflect_vmexit (struct kvm_vcpu *vcpu,u32 exit_reason) { +u32 exit_qual;u32 exit_intr_info =vmcs_read32 (VM_EXIT_INTR_INFO ); +struct vcpu_vmx *vmx =to_vmx (vcpu);/* * At this point, the exit interruption info in exit_intr_info
arch/x86/kvm/vmx/nested.h static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu, · line 90
Quoted 10 lines
arch/x86/kvm/vmx/nested.h +5
-2@@ -81,8 +83,16 @@ static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu,vmcs_read32 (VM_EXIT_INTR_ERROR_CODE ); } -nested_vmx_vmexit (vcpu, exit_reason, exit_intr_info, -vmcs_readl (EXIT_QUALIFICATION )); + exit_qual =vmcs_readl (EXIT_QUALIFICATION ); + +if (vmx->loaded_vmcs->invalid_msr_load_area.index ==MSR_FS_BASE && + (exit_reason == (VMX_EXIT_REASONS_FAILED_VMENTRY | +EXIT_REASON_MSR_LOAD_FAIL ))) {
Is the second conjunct sufficient? i.e. Isn't there a bug in kvm if the second conjunct is true and the first is not?
Quoted 13 lines
arch/x86/kvm/vmx/nested.h +5
-0+ exit_qual = vmx->loaded_vmcs->invalid_msr_load_area.value; + } + +nested_vmx_vmexit (vcpu, exit_reason, exit_intr_info, exit_qual); +return 1 ; }arch/x86/kvm/vmx/vmcs.h +0
-0
arch/x86/kvm/vmx/vmcs.h struct loaded_vmcs { · line 79
Quoted 10 lines
arch/x86/kvm/vmx/vmcs.h +6
-0@@ -70,6 +70,12 @@ struct loaded_vmcs {struct list_head loaded_vmcss_on_cpu_link;struct vmcs_host_state host_state;struct vmcs_controls_shadow controls_shadow; +/* +* This field is used to set up an invalid VM-entry MSR-load area +* for vmcs02 if an error is detected while processing the entries +* in VM-entry MSR-load area of vmcs12. +*/ +struct vmx_msr_entry invalid_msr_load_area; };
I'd suggest allocating just one invalid_msr_load_area system-wide, as mentioned above.
Quoted 4 lines
arch/x86/kvm/vmx/vmcs.h +0
-1static inline bool is_exception_n (u32 intr_info,u8 vector) --2.20.1
Re: [PATCH] nVMX: Defer error from VM-entry MSR-load area to until after hardware verifies VMCS guest state-area
Quoted 17 lines · Jim Mattson
Quoted 8 lines · Krish Sadhukhan
According to section “VM Entries” in Intel SDM vol 3C, VM-entry checks are performed in a certain order. Checks on MSRs that are loaded on VM-entry from VM-entry MSR-load area, should be done after verifying VMCS controls, host-state area and guest-state area. As KVM relies on CPU hardware to perform some of these checks, we need to defer VM-exit due to invalid VM-entry MSR-load area to until after CPU hardware completes the earlier checks and is ready to do VMLAUNCH/VMRESUME.
Quoted 7 lines
In order to defer errors arising from invalid VM-entry MSR-load area in vmcs12, we set up a single invalid entry, which is illegal according to section "Loading MSRs in Intel SDM vol 3C, in VM-entry MSR-load area of vmcs02. This will cause the CPU hardware to VM-exit with "VM-entry failure due to MSR loading" after it completes checks on VMCS controls, host-state area and guest-state area. We reflect a synthesized Exit Qualification to our guest.
Quoted 4 lines
This change addresses the priority inversion, but it still potentially leaves guest MSRs incorrectly loaded with values from the VMCS12 VM-entry MSR-load area when a higher priority error condition would have precluded any processing of the VM-entry MSR-load area.
May be, we should not load any guest MSR until we have checked the entire vmcs12 MSR-load area in nested_vmx_load_msr() ?
Quoted 43 lines
Quoted 43 lines
Suggested-by Jim Mattson <[email protected]>Signed-off-by Krish Sadhukhan <[email protected]>Reviewed-by Mihai Carabas <[email protected]>Reviewed-by Liran Alon <[email protected]>--- arch/x86/kvm/vmx/nested.c | 34 +++++++++++++++++++++++++++++++--- arch/x86/kvm/vmx/nested.h | 14 ++++++++++++-- arch/x86/kvm/vmx/vmcs.h | 6 ++++++ 3 files changed, 49 insertions(+), 5 deletions(-)arch/x86/kvm/vmx/nested.c +18
-3@@ -3054,12 +3054,40 @@ int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) goto vmentry_fail_vmexit_guest_mode;if (from_vmentry) { - exit_reason =EXIT_REASON_MSR_LOAD_FAIL ; exit_qual =nested_vmx_load_msr (vcpu, vmcs12->vm_entry_msr_load_addr, vmcs12->vm_entry_msr_load_count); -if (exit_qual) - goto vmentry_fail_vmexit_guest_mode; +if (exit_qual) { +/* +* According to section “VM Entries” in Intel SDM +* vol 3C, VM-entry checks are performed in a certain +* order. Checks on MSRs that are loaded on VM-entry +* from VM-entry MSR-load area, should be done after +* verifying VMCS controls, host-state area and +* guest-state area. As KVM relies on CPU hardware to +* perform some of these checks, we need to defer +* VM-exit due to invalid VM-entry MSR-load area to +* until after CPU hardware completes the earlier +* checks and is ready to do VMLAUNCH/VMRESUME. +* +* In order to defer errors arising from invalid +* VM-entry MSR-load area in vmcs12, we set up a +* single invalid entry, which is illegal according +* to section "Loading MSRs in Intel SDM vol 3C, in +* VM-entry MSR-load area of vmcs02. This will cause
Quoted 8 lines
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3084
Quoted 7 lines
arch/x86/kvm/vmx/nested.c +7
-0+* the CPU hardware to VM-exit with "VM-entry +* failure due to MSR loading" after it completes +* checks on VMCS controls, host-state area and +* guest-state area. +*/ + vmx->loaded_vmcs->invalid_msr_load_area.index = +MSR_FS_BASE ;Can this field be statically populated during initialization?
Yes.
Quoted 6 lines
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3086
Quoted 3 lines
arch/x86/kvm/vmx/nested.c +2
-0+ vmx->loaded_vmcs->invalid_msr_load_area.value = + exit_qual;This seems awkward. Why not save 16 bytes per
loaded_vmcsby allocating oneinvalid_msr_load_areasystem-wide and just add a 4 byte field to structnested_vmxto store this value?
OK.
Quoted 8 lines
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3090
Quoted 5 lines
arch/x86/kvm/vmx/nested.c +4
-0+vmcs_write32 (VM_ENTRY_MSR_LOAD_COUNT ,1 ); +vmcs_write64 (VM_ENTRY_MSR_LOAD_ADDR , +__pa (&(vmx->loaded_vmcs->invalid_msr_load_area))); + }Do you need to set
vmx->nested.dirty_vmcs12to ensure thatprepare_vmcs02_constant_state()will be called at the next emulated VM-entry, to undo this change toVM_ENTRY_MSR_LOAD_ADDR?
Yes.
Quoted 22 lines
Quoted 22 lines
arch/x86/kvm/vmx/nested.c +0
-0}else {/* * The MMU is not initialized to point at the right entities yet and arch/x86/kvm/vmx/nested.h +2
-0@@ -64,7 +64,9 @@ static inline bool nested_ept_ad_enabled(struct kvm_vcpu *vcpu)static inline int nested_vmx_reflect_vmexit (struct kvm_vcpu *vcpu,u32 exit_reason) { +u32 exit_qual;u32 exit_intr_info =vmcs_read32 (VM_EXIT_INTR_INFO ); +struct vcpu_vmx *vmx =to_vmx (vcpu);/* * At this point, the exit interruption info in exit_intr_info @@ -81,8 +83,16 @@ static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu,vmcs_read32 (VM_EXIT_INTR_ERROR_CODE ); }
Quoted 9 lines
arch/x86/kvm/vmx/nested.h static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu, · line 90
Quoted 7 lines
arch/x86/kvm/vmx/nested.h +5
-2-nested_vmx_vmexit (vcpu, exit_reason, exit_intr_info, -vmcs_readl (EXIT_QUALIFICATION )); + exit_qual =vmcs_readl (EXIT_QUALIFICATION ); + +if (vmx->loaded_vmcs->invalid_msr_load_area.index ==MSR_FS_BASE && + (exit_reason == (VMX_EXIT_REASONS_FAILED_VMENTRY | +EXIT_REASON_MSR_LOAD_FAIL ))) {Is the second conjunct sufficient? i.e. Isn't there a bug in kvm if the second conjunct is true and the first is not?
If the first conjunct isn't true and the second one is, it means it's a hardware-detected MSR-load error. Right ? So won't that be handled the same way it is handled currently in KVM ?
Quoted 31 lines
Quoted 14 lines
arch/x86/kvm/vmx/nested.h +5
-0+ exit_qual = vmx->loaded_vmcs->invalid_msr_load_area.value; + } + +nested_vmx_vmexit (vcpu, exit_reason, exit_intr_info, exit_qual); +return 1 ; }arch/x86/kvm/vmx/vmcs.h +0
-0arch/x86/kvm/vmx/vmcs.h struct loaded_vmcs { · line 79
Quoted 10 lines
arch/x86/kvm/vmx/vmcs.h +6
-0@@ -70,6 +70,12 @@ struct loaded_vmcs {struct list_head loaded_vmcss_on_cpu_link;struct vmcs_host_state host_state;struct vmcs_controls_shadow controls_shadow; +/* +* This field is used to set up an invalid VM-entry MSR-load area +* for vmcs02 if an error is detected while processing the entries +* in VM-entry MSR-load area of vmcs12. +*/ +struct vmx_msr_entry invalid_msr_load_area; };I'd suggest allocating just one
invalid_msr_load_areasystem-wide, as mentioned above.Quoted 4 lines
arch/x86/kvm/vmx/vmcs.h +0
-1static inline bool is_exception_n (u32 intr_info,u8 vector) --2.20.1
Re: [PATCH] nVMX: Defer error from VM-entry MSR-load area to until after hardware verifies VMCS guest state-area
Quoted 21 lines · Krish Sadhukhan
Quoted 17 lines · Jim Mattson
Quoted 15 lines · Krish Sadhukhan
According to section “VM Entries” in Intel SDM vol 3C, VM-entry checks are performed in a certain order. Checks on MSRs that are loaded on VM-entry from VM-entry MSR-load area, should be done after verifying VMCS controls, host-state area and guest-state area. As KVM relies on CPU hardware to perform some of these checks, we need to defer VM-exit due to invalid VM-entry MSR-load area to until after CPU hardware completes the earlier checks and is ready to do VMLAUNCH/VMRESUME.
In order to defer errors arising from invalid VM-entry MSR-load area in vmcs12, we set up a single invalid entry, which is illegal according to section "Loading MSRs in Intel SDM vol 3C, in VM-entry MSR-load area of vmcs02. This will cause the CPU hardware to VM-exit with "VM-entry failure due to MSR loading" after it completes checks on VMCS controls, host-state area and guest-state area. We reflect a synthesized Exit Qualification to our guest.
Quoted 7 lines
Quoted 4 lines
This change addresses the priority inversion, but it still potentially leaves guest MSRs incorrectly loaded with values from the VMCS12 VM-entry MSR-load area when a higher priority error condition would have precluded any processing of the VM-entry MSR-load area.
May be, we should not load any guest MSR until we have checked the entire vmcs12 MSR-load area in
nested_vmx_load_msr()?
That's not sufficient. We shouldn't load any guest MSR until all of the checks on host state, controls, and guest state have passed. Since we defer the guest state checks to hardware, that makes the proper ordering a bit problematic. Instead, you can try to arrange to undo the guest MSR loads if a higher priority error is discovered. That won't be trivial.
Quoted 106 lines
Quoted 43 lines
Quoted 43 lines
Suggested-by Jim Mattson <[email protected]>Signed-off-by Krish Sadhukhan <[email protected]>Reviewed-by Mihai Carabas <[email protected]>Reviewed-by Liran Alon <[email protected]>--- arch/x86/kvm/vmx/nested.c | 34 +++++++++++++++++++++++++++++++--- arch/x86/kvm/vmx/nested.h | 14 ++++++++++++-- arch/x86/kvm/vmx/vmcs.h | 6 ++++++ 3 files changed, 49 insertions(+), 5 deletions(-)arch/x86/kvm/vmx/nested.c +18
-3@@ -3054,12 +3054,40 @@ int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) goto vmentry_fail_vmexit_guest_mode;if (from_vmentry) { - exit_reason =EXIT_REASON_MSR_LOAD_FAIL ; exit_qual =nested_vmx_load_msr (vcpu, vmcs12->vm_entry_msr_load_addr, vmcs12->vm_entry_msr_load_count); -if (exit_qual) - goto vmentry_fail_vmexit_guest_mode; +if (exit_qual) { +/* +* According to section “VM Entries” in Intel SDM +* vol 3C, VM-entry checks are performed in a certain +* order. Checks on MSRs that are loaded on VM-entry +* from VM-entry MSR-load area, should be done after +* verifying VMCS controls, host-state area and +* guest-state area. As KVM relies on CPU hardware to +* perform some of these checks, we need to defer +* VM-exit due to invalid VM-entry MSR-load area to +* until after CPU hardware completes the earlier +* checks and is ready to do VMLAUNCH/VMRESUME. +* +* In order to defer errors arising from invalid +* VM-entry MSR-load area in vmcs12, we set up a +* single invalid entry, which is illegal according +* to section "Loading MSRs in Intel SDM vol 3C, in +* VM-entry MSR-load area of vmcs02. This will cause Quoted 8 lines
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3084
Quoted 7 lines
arch/x86/kvm/vmx/nested.c +7
-0+* the CPU hardware to VM-exit with "VM-entry +* failure due to MSR loading" after it completes +* checks on VMCS controls, host-state area and +* guest-state area. +*/ + vmx->loaded_vmcs->invalid_msr_load_area.index = +MSR_FS_BASE ;Can this field be statically populated during initialization?
Yes.
Quoted 6 lines
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3086
Quoted 3 lines
arch/x86/kvm/vmx/nested.c +2
-0+ vmx->loaded_vmcs->invalid_msr_load_area.value = + exit_qual;This seems awkward. Why not save 16 bytes per
loaded_vmcsby allocating oneinvalid_msr_load_areasystem-wide and just add a 4 byte field to structnested_vmxto store this value?OK.
Quoted 8 lines
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3090
Quoted 5 lines
arch/x86/kvm/vmx/nested.c +4
-0+vmcs_write32 (VM_ENTRY_MSR_LOAD_COUNT ,1 ); +vmcs_write64 (VM_ENTRY_MSR_LOAD_ADDR , +__pa (&(vmx->loaded_vmcs->invalid_msr_load_area))); + }Do you need to set
vmx->nested.dirty_vmcs12to ensure thatprepare_vmcs02_constant_state()will be called at the next emulated VM-entry, to undo this change toVM_ENTRY_MSR_LOAD_ADDR?Yes.
Quoted 22 lines
Quoted 22 lines
arch/x86/kvm/vmx/nested.c +0
-0}else {/* * The MMU is not initialized to point at the right entities yet and arch/x86/kvm/vmx/nested.h +2
-0@@ -64,7 +64,9 @@ static inline bool nested_ept_ad_enabled(struct kvm_vcpu *vcpu)static inline int nested_vmx_reflect_vmexit (struct kvm_vcpu *vcpu,u32 exit_reason) { +u32 exit_qual;u32 exit_intr_info =vmcs_read32 (VM_EXIT_INTR_INFO ); +struct vcpu_vmx *vmx =to_vmx (vcpu);/* * At this point, the exit interruption info in exit_intr_info @@ -81,8 +83,16 @@ static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu,vmcs_read32 (VM_EXIT_INTR_ERROR_CODE ); }Quoted 9 lines
arch/x86/kvm/vmx/nested.h static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu, · line 90
Quoted 7 lines
arch/x86/kvm/vmx/nested.h +5
-2-nested_vmx_vmexit (vcpu, exit_reason, exit_intr_info, -vmcs_readl (EXIT_QUALIFICATION )); + exit_qual =vmcs_readl (EXIT_QUALIFICATION ); + +if (vmx->loaded_vmcs->invalid_msr_load_area.index ==MSR_FS_BASE && + (exit_reason == (VMX_EXIT_REASONS_FAILED_VMENTRY | +EXIT_REASON_MSR_LOAD_FAIL ))) {Is the second conjunct sufficient? i.e. Isn't there a bug in kvm if the second conjunct is true and the first is not?
Quoted 3 lines
If the first conjunct isn't true and the second one is, it means it's a hardware-detected MSR-load error. Right ? So won't that be handled the same way it is handled currently in KVM ?
I believe that KVM will currently forward such an error to L1, which is wrong, since L1 has no control over vmcs02's VM-entry MSR-load area. The assumption is that this will never happen, because L0 is too careful.
Quoted 32 lines
Quoted 31 lines
Quoted 14 lines
arch/x86/kvm/vmx/nested.h +5
-0+ exit_qual = vmx->loaded_vmcs->invalid_msr_load_area.value; + } + +nested_vmx_vmexit (vcpu, exit_reason, exit_intr_info, exit_qual); +return 1 ; }arch/x86/kvm/vmx/vmcs.h +0
-0arch/x86/kvm/vmx/vmcs.h struct loaded_vmcs { · line 79
Quoted 10 lines
arch/x86/kvm/vmx/vmcs.h +6
-0@@ -70,6 +70,12 @@ struct loaded_vmcs {struct list_head loaded_vmcss_on_cpu_link;struct vmcs_host_state host_state;struct vmcs_controls_shadow controls_shadow; +/* +* This field is used to set up an invalid VM-entry MSR-load area +* for vmcs02 if an error is detected while processing the entries +* in VM-entry MSR-load area of vmcs12. +*/ +struct vmx_msr_entry invalid_msr_load_area; };I'd suggest allocating just one
invalid_msr_load_areasystem-wide, as mentioned above.Quoted 4 lines
arch/x86/kvm/vmx/vmcs.h +0
-1static inline bool is_exception_n (u32 intr_info,u8 vector) --2.20.1
Re: [PATCH] nVMX: Defer error from VM-entry MSR-load area to until after hardware verifies VMCS guest state-area
Quoted 25 lines · Jim Mattson
Quoted 23 lines · Krish Sadhukhan
Quoted 21 lines · Jim Mattson
Quoted 8 lines · Krish Sadhukhan
According to section “VM Entries” in Intel SDM vol 3C, VM-entry checks are performed in a certain order. Checks on MSRs that are loaded on VM-entry from VM-entry MSR-load area, should be done after verifying VMCS controls, host-state area and guest-state area. As KVM relies on CPU hardware to perform some of these checks, we need to defer VM-exit due to invalid VM-entry MSR-load area to until after CPU hardware completes the earlier checks and is ready to do VMLAUNCH/VMRESUME.
Quoted 7 lines
In order to defer errors arising from invalid VM-entry MSR-load area in vmcs12, we set up a single invalid entry, which is illegal according to section "Loading MSRs in Intel SDM vol 3C, in VM-entry MSR-load area of vmcs02. This will cause the CPU hardware to VM-exit with "VM-entry failure due to MSR loading" after it completes checks on VMCS controls, host-state area and guest-state area. We reflect a synthesized Exit Qualification to our guest.
This change addresses the priority inversion, but it still potentially leaves guest MSRs incorrectly loaded with values from the VMCS12 VM-entry MSR-load area when a higher priority error condition would have precluded any processing of the VM-entry MSR-load area.
Quoted 8 lines
Quoted 2 lines
May be, we should not load any guest MSR until we have checked the entire vmcs12 MSR-load area in
nested_vmx_load_msr()?That's not sufficient. We shouldn't load any guest MSR until all of the checks on host state, controls, and guest state have passed. Since we defer the guest state checks to hardware, that makes the proper ordering a bit problematic. Instead, you can try to arrange to undo the guest MSR loads if a higher priority error is discovered. That won't be trivial.
We discussed about undoing guest MSR loads in an earlier thread. You said that some MSR updates couldn't be rolled back. If we can't rollback some MSR updates and if that leads to an undefined guest configuration, may be we should return to L0 and mark it as a hardware failure, like what we currently do for some VM-entry failures in vmx_handle_exit():
if (exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY) { dump_vmcs();
vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY; vcpu->run->fail_entry.hardware_entry_failure_reason = exit_reason;
return 0;
}
Quoted 98 lines
Quoted 98 lines
Quoted 42 lines
Quoted 42 lines
Suggested-by Jim Mattson<[email protected]>Signed-off-by Krish Sadhukhan<[email protected]>Reviewed-by Mihai Carabas<[email protected]>Reviewed-by Liran Alon<[email protected]>--- arch/x86/kvm/vmx/nested.c | 34 +++++++++++++++++++++++++++++++--- arch/x86/kvm/vmx/nested.h | 14 ++++++++++++-- arch/x86/kvm/vmx/vmcs.h | 6 ++++++ 3 files changed, 49 insertions(+), 5 deletions(-)arch/x86/kvm/vmx/nested.c +18
-3@@ -3054,12 +3054,40 @@ int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) goto vmentry_fail_vmexit_guest_mode;if (from_vmentry) { - exit_reason =EXIT_REASON_MSR_LOAD_FAIL ; exit_qual =nested_vmx_load_msr (vcpu, vmcs12->vm_entry_msr_load_addr, vmcs12->vm_entry_msr_load_count); -if (exit_qual) - goto vmentry_fail_vmexit_guest_mode; +if (exit_qual) { +/* +* According to section “VM Entries” in Intel SDM +* vol 3C, VM-entry checks are performed in a certain +* order. Checks on MSRs that are loaded on VM-entry +* from VM-entry MSR-load area, should be done after +* verifying VMCS controls, host-state area and +* guest-state area. As KVM relies on CPU hardware to +* perform some of these checks, we need to defer +* VM-exit due to invalid VM-entry MSR-load area to +* until after CPU hardware completes the earlier +* checks and is ready to do VMLAUNCH/VMRESUME. +* +* In order to defer errors arising from invalid +* VM-entry MSR-load area in vmcs12, we set up a +* single invalid entry, which is illegal according +* to section "Loading MSRs in Intel SDM vol 3C, in +* VM-entry MSR-load area of vmcs02. This will cause Quoted 8 lines
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3084
Quoted 7 lines
arch/x86/kvm/vmx/nested.c +7
-0+* the CPU hardware to VM-exit with "VM-entry +* failure due to MSR loading" after it completes +* checks on VMCS controls, host-state area and +* guest-state area. +*/ + vmx->loaded_vmcs->invalid_msr_load_area.index = +MSR_FS_BASE ;Can this field be statically populated during initialization?
Yes.
Quoted 5 lines
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3086
Quoted 2 lines
arch/x86/kvm/vmx/nested.c +2
-0+ vmx->loaded_vmcs->invalid_msr_load_area.value = + exit_qual;This seems awkward. Why not save 16 bytes per
loaded_vmcsby allocating oneinvalid_msr_load_areasystem-wide and just add a 4 byte field to structnested_vmxto store this value?OK.
Quoted 7 lines
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3090
Quoted 4 lines
arch/x86/kvm/vmx/nested.c +4
-0+vmcs_write32 (VM_ENTRY_MSR_LOAD_COUNT ,1 ); +vmcs_write64 (VM_ENTRY_MSR_LOAD_ADDR , +__pa (&(vmx->loaded_vmcs->invalid_msr_load_area))); + }Do you need to set
vmx->nested.dirty_vmcs12to ensure thatprepare_vmcs02_constant_state()will be called at the next emulated VM-entry, to undo this change toVM_ENTRY_MSR_LOAD_ADDR?Yes.
Quoted 30 lines
Quoted 18 lines
arch/x86/kvm/vmx/nested.c +0
-0}else {/* * The MMU is not initialized to point at the right entities yet and arch/x86/kvm/vmx/nested.h +2
-0@@ -64,7 +64,9 @@ static inline bool nested_ept_ad_enabled(struct kvm_vcpu *vcpu)static inline int nested_vmx_reflect_vmexit (struct kvm_vcpu *vcpu,u32 exit_reason) { +u32 exit_qual;u32 exit_intr_info =vmcs_read32 (VM_EXIT_INTR_INFO ); +struct vcpu_vmx *vmx =to_vmx (vcpu);/* * At this point, the exit interruption info in exit_intr_info arch/x86/kvm/vmx/nested.h static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu, · line 90
Quoted 10 lines
arch/x86/kvm/vmx/nested.h +5
-2@@ -81,8 +83,16 @@ static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu,vmcs_read32 (VM_EXIT_INTR_ERROR_CODE ); } -nested_vmx_vmexit (vcpu, exit_reason, exit_intr_info, -vmcs_readl (EXIT_QUALIFICATION )); + exit_qual =vmcs_readl (EXIT_QUALIFICATION ); + +if (vmx->loaded_vmcs->invalid_msr_load_area.index ==MSR_FS_BASE && + (exit_reason == (VMX_EXIT_REASONS_FAILED_VMENTRY | +EXIT_REASON_MSR_LOAD_FAIL ))) {Is the second conjunct sufficient? i.e. Isn't there a bug in kvm if the second conjunct is true and the first is not?
Quoted 6 lines
Quoted 3 lines
If the first conjunct isn't true and the second one is, it means it's a hardware-detected MSR-load error. Right ? So won't that be handled the same way it is handled currently in KVM ?
I believe that KVM will currently forward such an error to L1, which is wrong, since L1 has no control over vmcs02's VM-entry MSR-load area.
You are right. I hadn't noticed it until you mentioned.
Quoted 32 lines
The assumption is that this will never happen, because L0 is too
careful.Quoted 30 lines
Quoted 30 lines
Quoted 13 lines
arch/x86/kvm/vmx/nested.h +5
-0+ exit_qual = vmx->loaded_vmcs->invalid_msr_load_area.value; + } + +nested_vmx_vmexit (vcpu, exit_reason, exit_intr_info, exit_qual); +return 1 ; }arch/x86/kvm/vmx/vmcs.h +0
-0arch/x86/kvm/vmx/vmcs.h struct loaded_vmcs { · line 79
Quoted 10 lines
arch/x86/kvm/vmx/vmcs.h +6
-0@@ -70,6 +70,12 @@ struct loaded_vmcs {struct list_head loaded_vmcss_on_cpu_link;struct vmcs_host_state host_state;struct vmcs_controls_shadow controls_shadow; +/* +* This field is used to set up an invalid VM-entry MSR-load area +* for vmcs02 if an error is detected while processing the entries +* in VM-entry MSR-load area of vmcs12. +*/ +struct vmx_msr_entry invalid_msr_load_area; };I'd suggest allocating just one
invalid_msr_load_areasystem-wide, as mentioned above.Quoted 4 lines
arch/x86/kvm/vmx/vmcs.h +0
-1static inline bool is_exception_n (u32 intr_info,u8 vector) --2.20.1
Re: [PATCH] nVMX: Defer error from VM-entry MSR-load area to until after hardware verifies VMCS guest state-area
Quoted 38 lines · Krish Sadhukhan
Quoted 25 lines · Jim Mattson
Quoted 23 lines · Krish Sadhukhan
Quoted 21 lines · Jim Mattson
Quoted 8 lines · Krish Sadhukhan
According to section “VM Entries” in Intel SDM vol 3C, VM-entry checks are performed in a certain order. Checks on MSRs that are loaded on VM-entry from VM-entry MSR-load area, should be done after verifying VMCS controls, host-state area and guest-state area. As KVM relies on CPU hardware to perform some of these checks, we need to defer VM-exit due to invalid VM-entry MSR-load area to until after CPU hardware completes the earlier checks and is ready to do VMLAUNCH/VMRESUME.
Quoted 7 lines
In order to defer errors arising from invalid VM-entry MSR-load area in vmcs12, we set up a single invalid entry, which is illegal according to section "Loading MSRs in Intel SDM vol 3C, in VM-entry MSR-load area of vmcs02. This will cause the CPU hardware to VM-exit with "VM-entry failure due to MSR loading" after it completes checks on VMCS controls, host-state area and guest-state area. We reflect a synthesized Exit Qualification to our guest.
This change addresses the priority inversion, but it still potentially leaves guest MSRs incorrectly loaded with values from the VMCS12 VM-entry MSR-load area when a higher priority error condition would have precluded any processing of the VM-entry MSR-load area.
Quoted 8 lines
Quoted 2 lines
May be, we should not load any guest MSR until we have checked the entire vmcs12 MSR-load area in
nested_vmx_load_msr()?That's not sufficient. We shouldn't load any guest MSR until all of the checks on host state, controls, and guest state have passed. Since we defer the guest state checks to hardware, that makes the proper ordering a bit problematic. Instead, you can try to arrange to undo the guest MSR loads if a higher priority error is discovered. That won't be trivial.
Quoted 5 lines
We discussed about undoing guest MSR loads in an earlier thread. You said that some MSR updates couldn't be rolled back. If we can't rollback some MSR updates and if that leads to an undefined guest configuration, may be we should return to L0 and mark it as a hardware failure, like what we currently do for some VM-entry failures in
vmx_handle_exit():
The MSR loads that can't be rolled back are mainly the ones with side-effects, like IA32_PRED_CMD. I think these are mostly benign (except, perhaps, from a performance perspective). I think it's worth investigating rollback as a partial solution to this problem.
Quoted 151 lines
if (exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY) { dump_vmcs(); vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY; vcpu->run->fail_entry.hardware_entry_failure_reason = exit_reason; return 0; }Quoted 98 lines
Quoted 98 lines
Quoted 42 lines
Quoted 42 lines
Suggested-by Jim Mattson<[email protected]>Signed-off-by Krish Sadhukhan<[email protected]>Reviewed-by Mihai Carabas<[email protected]>Reviewed-by Liran Alon<[email protected]>--- arch/x86/kvm/vmx/nested.c | 34 +++++++++++++++++++++++++++++++--- arch/x86/kvm/vmx/nested.h | 14 ++++++++++++-- arch/x86/kvm/vmx/vmcs.h | 6 ++++++ 3 files changed, 49 insertions(+), 5 deletions(-)arch/x86/kvm/vmx/nested.c +18
-3@@ -3054,12 +3054,40 @@ int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) goto vmentry_fail_vmexit_guest_mode;if (from_vmentry) { - exit_reason =EXIT_REASON_MSR_LOAD_FAIL ; exit_qual =nested_vmx_load_msr (vcpu, vmcs12->vm_entry_msr_load_addr, vmcs12->vm_entry_msr_load_count); -if (exit_qual) - goto vmentry_fail_vmexit_guest_mode; +if (exit_qual) { +/* +* According to section “VM Entries” in Intel SDM +* vol 3C, VM-entry checks are performed in a certain +* order. Checks on MSRs that are loaded on VM-entry +* from VM-entry MSR-load area, should be done after +* verifying VMCS controls, host-state area and +* guest-state area. As KVM relies on CPU hardware to +* perform some of these checks, we need to defer +* VM-exit due to invalid VM-entry MSR-load area to +* until after CPU hardware completes the earlier +* checks and is ready to do VMLAUNCH/VMRESUME. +* +* In order to defer errors arising from invalid +* VM-entry MSR-load area in vmcs12, we set up a +* single invalid entry, which is illegal according +* to section "Loading MSRs in Intel SDM vol 3C, in +* VM-entry MSR-load area of vmcs02. This will cause Quoted 8 lines
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3084
Quoted 7 lines
arch/x86/kvm/vmx/nested.c +7
-0+* the CPU hardware to VM-exit with "VM-entry +* failure due to MSR loading" after it completes +* checks on VMCS controls, host-state area and +* guest-state area. +*/ + vmx->loaded_vmcs->invalid_msr_load_area.index = +MSR_FS_BASE ;Can this field be statically populated during initialization?
Yes.
Quoted 5 lines
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3086
Quoted 2 lines
arch/x86/kvm/vmx/nested.c +2
-0+ vmx->loaded_vmcs->invalid_msr_load_area.value = + exit_qual;This seems awkward. Why not save 16 bytes per
loaded_vmcsby allocating oneinvalid_msr_load_areasystem-wide and just add a 4 byte field to structnested_vmxto store this value?OK.
Quoted 7 lines
arch/x86/kvm/vmx/nested.c int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) · line 3090
Quoted 4 lines
arch/x86/kvm/vmx/nested.c +4
-0+vmcs_write32 (VM_ENTRY_MSR_LOAD_COUNT ,1 ); +vmcs_write64 (VM_ENTRY_MSR_LOAD_ADDR , +__pa (&(vmx->loaded_vmcs->invalid_msr_load_area))); + }Do you need to set
vmx->nested.dirty_vmcs12to ensure thatprepare_vmcs02_constant_state()will be called at the next emulated VM-entry, to undo this change toVM_ENTRY_MSR_LOAD_ADDR?Yes.
Quoted 30 lines
Quoted 18 lines
arch/x86/kvm/vmx/nested.c +0
-0}else {/* * The MMU is not initialized to point at the right entities yet and arch/x86/kvm/vmx/nested.h +2
-0@@ -64,7 +64,9 @@ static inline bool nested_ept_ad_enabled(struct kvm_vcpu *vcpu)static inline int nested_vmx_reflect_vmexit (struct kvm_vcpu *vcpu,u32 exit_reason) { +u32 exit_qual;u32 exit_intr_info =vmcs_read32 (VM_EXIT_INTR_INFO ); +struct vcpu_vmx *vmx =to_vmx (vcpu);/* * At this point, the exit interruption info in exit_intr_info arch/x86/kvm/vmx/nested.h static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu, · line 90
Quoted 10 lines
arch/x86/kvm/vmx/nested.h +5
-2@@ -81,8 +83,16 @@ static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu,vmcs_read32 (VM_EXIT_INTR_ERROR_CODE ); } -nested_vmx_vmexit (vcpu, exit_reason, exit_intr_info, -vmcs_readl (EXIT_QUALIFICATION )); + exit_qual =vmcs_readl (EXIT_QUALIFICATION ); + +if (vmx->loaded_vmcs->invalid_msr_load_area.index ==MSR_FS_BASE && + (exit_reason == (VMX_EXIT_REASONS_FAILED_VMENTRY | +EXIT_REASON_MSR_LOAD_FAIL ))) {Is the second conjunct sufficient? i.e. Isn't there a bug in kvm if the second conjunct is true and the first is not?
Quoted 6 lines
Quoted 3 lines
If the first conjunct isn't true and the second one is, it means it's a hardware-detected MSR-load error. Right ? So won't that be handled the same way it is handled currently in KVM ?
I believe that KVM will currently forward such an error to L1, which is wrong, since L1 has no control over vmcs02's VM-entry MSR-load area.
You are right. I hadn't noticed it until you mentioned.
Quoted 32 lines
The assumption is that this will never happen, because L0 is too
careful.Quoted 30 lines
Quoted 30 lines
Quoted 13 lines
arch/x86/kvm/vmx/nested.h +5
-0+ exit_qual = vmx->loaded_vmcs->invalid_msr_load_area.value; + } + +nested_vmx_vmexit (vcpu, exit_reason, exit_intr_info, exit_qual); +return 1 ; }arch/x86/kvm/vmx/vmcs.h +0
-0arch/x86/kvm/vmx/vmcs.h struct loaded_vmcs { · line 79
Quoted 10 lines
arch/x86/kvm/vmx/vmcs.h +6
-0@@ -70,6 +70,12 @@ struct loaded_vmcs {struct list_head loaded_vmcss_on_cpu_link;struct vmcs_host_state host_state;struct vmcs_controls_shadow controls_shadow; +/* +* This field is used to set up an invalid VM-entry MSR-load area +* for vmcs02 if an error is detected while processing the entries +* in VM-entry MSR-load area of vmcs12. +*/ +struct vmx_msr_entry invalid_msr_load_area; };I'd suggest allocating just one
invalid_msr_load_areasystem-wide, as mentioned above.Quoted 4 lines
arch/x86/kvm/vmx/vmcs.h +0
-1static inline bool is_exception_n (u32 intr_info,u8 vector) --2.20.1