All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: nVMX: Consolidate nested MTF checks to helper function
@ 2020-02-24 20:27 Oliver Upton
  2020-02-25  0:02 ` Krish Sadhukhan
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Oliver Upton @ 2020-02-24 20:27 UTC (permalink / raw)
  To: kvm; +Cc: Paolo Bonzini, Oliver Upton

commit 5ef8acbdd687 ("KVM: nVMX: Emulate MTF when performing
instruction emulation") introduced a helper to check the MTF
VM-execution control in vmcs12. Change pre-existing check in
nested_vmx_exit_reflected() to instead use the helper.

Signed-off-by: Oliver Upton <oupton@google.com>
---
 arch/x86/kvm/vmx/nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index e920d7834d73..b9caad70ac7c 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -5627,7 +5627,7 @@ bool nested_vmx_exit_reflected(struct kvm_vcpu *vcpu, u32 exit_reason)
 	case EXIT_REASON_MWAIT_INSTRUCTION:
 		return nested_cpu_has(vmcs12, CPU_BASED_MWAIT_EXITING);
 	case EXIT_REASON_MONITOR_TRAP_FLAG:
-		return nested_cpu_has(vmcs12, CPU_BASED_MONITOR_TRAP_FLAG);
+		return nested_cpu_has_mtf(vmcs12);
 	case EXIT_REASON_MONITOR_INSTRUCTION:
 		return nested_cpu_has(vmcs12, CPU_BASED_MONITOR_EXITING);
 	case EXIT_REASON_PAUSE_INSTRUCTION:
-- 
2.25.0.265.gbab2e86ba0-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: nVMX: Consolidate nested MTF checks to helper function
  2020-02-24 20:27 [PATCH] KVM: nVMX: Consolidate nested MTF checks to helper function Oliver Upton
@ 2020-02-25  0:02 ` Krish Sadhukhan
  2020-02-25  1:37 ` kbuild test robot
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Krish Sadhukhan @ 2020-02-25  0:02 UTC (permalink / raw)
  To: Oliver Upton, kvm; +Cc: Paolo Bonzini



On 02/24/2020 12:27 PM, Oliver Upton wrote:
> commit 5ef8acbdd687 ("KVM: nVMX: Emulate MTF when performing
> instruction emulation") introduced a helper to check the MTF
> VM-execution control in vmcs12. Change pre-existing check in
> nested_vmx_exit_reflected() to instead use the helper.
>
> Signed-off-by: Oliver Upton <oupton@google.com>
> ---
>   arch/x86/kvm/vmx/nested.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index e920d7834d73..b9caad70ac7c 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -5627,7 +5627,7 @@ bool nested_vmx_exit_reflected(struct kvm_vcpu *vcpu, u32 exit_reason)
>   	case EXIT_REASON_MWAIT_INSTRUCTION:
>   		return nested_cpu_has(vmcs12, CPU_BASED_MWAIT_EXITING);
>   	case EXIT_REASON_MONITOR_TRAP_FLAG:
> -		return nested_cpu_has(vmcs12, CPU_BASED_MONITOR_TRAP_FLAG);
> +		return nested_cpu_has_mtf(vmcs12);
>   	case EXIT_REASON_MONITOR_INSTRUCTION:
>   		return nested_cpu_has(vmcs12, CPU_BASED_MONITOR_EXITING);
>   	case EXIT_REASON_PAUSE_INSTRUCTION:
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: nVMX: Consolidate nested MTF checks to helper function
  2020-02-24 20:27 [PATCH] KVM: nVMX: Consolidate nested MTF checks to helper function Oliver Upton
  2020-02-25  0:02 ` Krish Sadhukhan
@ 2020-02-25  1:37 ` kbuild test robot
  2020-02-25  3:23 ` kbuild test robot
  2020-03-14 11:14 ` Paolo Bonzini
  3 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2020-02-25  1:37 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 9440 bytes --]

Hi Oliver,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on kvm/linux-next]
[also build test ERROR on vhost/linux-next v5.6-rc3 next-20200224]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Oliver-Upton/KVM-nVMX-Consolidate-nested-MTF-checks-to-helper-function/20200225-042912
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git linux-next
config: x86_64-rhel (attached as .config)
compiler: gcc-7 (Debian 7.5.0-5) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   arch/x86/kvm/vmx/nested.c: In function 'nested_vmx_exit_reflected':
>> arch/x86/kvm/vmx/nested.c:5592:10: error: implicit declaration of function 'nested_cpu_has_mtf'; did you mean 'nested_cpu_has_vid'? [-Werror=implicit-function-declaration]
      return nested_cpu_has_mtf(vmcs12);
             ^~~~~~~~~~~~~~~~~~
             nested_cpu_has_vid
   cc1: all warnings being treated as errors

vim +5592 arch/x86/kvm/vmx/nested.c

  5477	
  5478	/*
  5479	 * Return 1 if we should exit from L2 to L1 to handle an exit, or 0 if we
  5480	 * should handle it ourselves in L0 (and then continue L2). Only call this
  5481	 * when in is_guest_mode (L2).
  5482	 */
  5483	bool nested_vmx_exit_reflected(struct kvm_vcpu *vcpu, u32 exit_reason)
  5484	{
  5485		u32 intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
  5486		struct vcpu_vmx *vmx = to_vmx(vcpu);
  5487		struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
  5488	
  5489		if (vmx->nested.nested_run_pending)
  5490			return false;
  5491	
  5492		if (unlikely(vmx->fail)) {
  5493			trace_kvm_nested_vmenter_failed(
  5494				"hardware VM-instruction error: ",
  5495				vmcs_read32(VM_INSTRUCTION_ERROR));
  5496			return true;
  5497		}
  5498	
  5499		/*
  5500		 * The host physical addresses of some pages of guest memory
  5501		 * are loaded into the vmcs02 (e.g. vmcs12's Virtual APIC
  5502		 * Page). The CPU may write to these pages via their host
  5503		 * physical address while L2 is running, bypassing any
  5504		 * address-translation-based dirty tracking (e.g. EPT write
  5505		 * protection).
  5506		 *
  5507		 * Mark them dirty on every exit from L2 to prevent them from
  5508		 * getting out of sync with dirty tracking.
  5509		 */
  5510		nested_mark_vmcs12_pages_dirty(vcpu);
  5511	
  5512		trace_kvm_nested_vmexit(kvm_rip_read(vcpu), exit_reason,
  5513					vmcs_readl(EXIT_QUALIFICATION),
  5514					vmx->idt_vectoring_info,
  5515					intr_info,
  5516					vmcs_read32(VM_EXIT_INTR_ERROR_CODE),
  5517					KVM_ISA_VMX);
  5518	
  5519		switch (exit_reason) {
  5520		case EXIT_REASON_EXCEPTION_NMI:
  5521			if (is_nmi(intr_info))
  5522				return false;
  5523			else if (is_page_fault(intr_info))
  5524				return !vmx->vcpu.arch.apf.host_apf_reason && enable_ept;
  5525			else if (is_debug(intr_info) &&
  5526				 vcpu->guest_debug &
  5527				 (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))
  5528				return false;
  5529			else if (is_breakpoint(intr_info) &&
  5530				 vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP)
  5531				return false;
  5532			return vmcs12->exception_bitmap &
  5533					(1u << (intr_info & INTR_INFO_VECTOR_MASK));
  5534		case EXIT_REASON_EXTERNAL_INTERRUPT:
  5535			return false;
  5536		case EXIT_REASON_TRIPLE_FAULT:
  5537			return true;
  5538		case EXIT_REASON_INTERRUPT_WINDOW:
  5539			return nested_cpu_has(vmcs12, CPU_BASED_INTR_WINDOW_EXITING);
  5540		case EXIT_REASON_NMI_WINDOW:
  5541			return nested_cpu_has(vmcs12, CPU_BASED_NMI_WINDOW_EXITING);
  5542		case EXIT_REASON_TASK_SWITCH:
  5543			return true;
  5544		case EXIT_REASON_CPUID:
  5545			return true;
  5546		case EXIT_REASON_HLT:
  5547			return nested_cpu_has(vmcs12, CPU_BASED_HLT_EXITING);
  5548		case EXIT_REASON_INVD:
  5549			return true;
  5550		case EXIT_REASON_INVLPG:
  5551			return nested_cpu_has(vmcs12, CPU_BASED_INVLPG_EXITING);
  5552		case EXIT_REASON_RDPMC:
  5553			return nested_cpu_has(vmcs12, CPU_BASED_RDPMC_EXITING);
  5554		case EXIT_REASON_RDRAND:
  5555			return nested_cpu_has2(vmcs12, SECONDARY_EXEC_RDRAND_EXITING);
  5556		case EXIT_REASON_RDSEED:
  5557			return nested_cpu_has2(vmcs12, SECONDARY_EXEC_RDSEED_EXITING);
  5558		case EXIT_REASON_RDTSC: case EXIT_REASON_RDTSCP:
  5559			return nested_cpu_has(vmcs12, CPU_BASED_RDTSC_EXITING);
  5560		case EXIT_REASON_VMREAD:
  5561			return nested_vmx_exit_handled_vmcs_access(vcpu, vmcs12,
  5562				vmcs12->vmread_bitmap);
  5563		case EXIT_REASON_VMWRITE:
  5564			return nested_vmx_exit_handled_vmcs_access(vcpu, vmcs12,
  5565				vmcs12->vmwrite_bitmap);
  5566		case EXIT_REASON_VMCALL: case EXIT_REASON_VMCLEAR:
  5567		case EXIT_REASON_VMLAUNCH: case EXIT_REASON_VMPTRLD:
  5568		case EXIT_REASON_VMPTRST: case EXIT_REASON_VMRESUME:
  5569		case EXIT_REASON_VMOFF: case EXIT_REASON_VMON:
  5570		case EXIT_REASON_INVEPT: case EXIT_REASON_INVVPID:
  5571			/*
  5572			 * VMX instructions trap unconditionally. This allows L1 to
  5573			 * emulate them for its L2 guest, i.e., allows 3-level nesting!
  5574			 */
  5575			return true;
  5576		case EXIT_REASON_CR_ACCESS:
  5577			return nested_vmx_exit_handled_cr(vcpu, vmcs12);
  5578		case EXIT_REASON_DR_ACCESS:
  5579			return nested_cpu_has(vmcs12, CPU_BASED_MOV_DR_EXITING);
  5580		case EXIT_REASON_IO_INSTRUCTION:
  5581			return nested_vmx_exit_handled_io(vcpu, vmcs12);
  5582		case EXIT_REASON_GDTR_IDTR: case EXIT_REASON_LDTR_TR:
  5583			return nested_cpu_has2(vmcs12, SECONDARY_EXEC_DESC);
  5584		case EXIT_REASON_MSR_READ:
  5585		case EXIT_REASON_MSR_WRITE:
  5586			return nested_vmx_exit_handled_msr(vcpu, vmcs12, exit_reason);
  5587		case EXIT_REASON_INVALID_STATE:
  5588			return true;
  5589		case EXIT_REASON_MWAIT_INSTRUCTION:
  5590			return nested_cpu_has(vmcs12, CPU_BASED_MWAIT_EXITING);
  5591		case EXIT_REASON_MONITOR_TRAP_FLAG:
> 5592			return nested_cpu_has_mtf(vmcs12);
  5593		case EXIT_REASON_MONITOR_INSTRUCTION:
  5594			return nested_cpu_has(vmcs12, CPU_BASED_MONITOR_EXITING);
  5595		case EXIT_REASON_PAUSE_INSTRUCTION:
  5596			return nested_cpu_has(vmcs12, CPU_BASED_PAUSE_EXITING) ||
  5597				nested_cpu_has2(vmcs12,
  5598					SECONDARY_EXEC_PAUSE_LOOP_EXITING);
  5599		case EXIT_REASON_MCE_DURING_VMENTRY:
  5600			return false;
  5601		case EXIT_REASON_TPR_BELOW_THRESHOLD:
  5602			return nested_cpu_has(vmcs12, CPU_BASED_TPR_SHADOW);
  5603		case EXIT_REASON_APIC_ACCESS:
  5604		case EXIT_REASON_APIC_WRITE:
  5605		case EXIT_REASON_EOI_INDUCED:
  5606			/*
  5607			 * The controls for "virtualize APIC accesses," "APIC-
  5608			 * register virtualization," and "virtual-interrupt
  5609			 * delivery" only come from vmcs12.
  5610			 */
  5611			return true;
  5612		case EXIT_REASON_EPT_VIOLATION:
  5613			/*
  5614			 * L0 always deals with the EPT violation. If nested EPT is
  5615			 * used, and the nested mmu code discovers that the address is
  5616			 * missing in the guest EPT table (EPT12), the EPT violation
  5617			 * will be injected with nested_ept_inject_page_fault()
  5618			 */
  5619			return false;
  5620		case EXIT_REASON_EPT_MISCONFIG:
  5621			/*
  5622			 * L2 never uses directly L1's EPT, but rather L0's own EPT
  5623			 * table (shadow on EPT) or a merged EPT table that L0 built
  5624			 * (EPT on EPT). So any problems with the structure of the
  5625			 * table is L0's fault.
  5626			 */
  5627			return false;
  5628		case EXIT_REASON_INVPCID:
  5629			return
  5630				nested_cpu_has2(vmcs12, SECONDARY_EXEC_ENABLE_INVPCID) &&
  5631				nested_cpu_has(vmcs12, CPU_BASED_INVLPG_EXITING);
  5632		case EXIT_REASON_WBINVD:
  5633			return nested_cpu_has2(vmcs12, SECONDARY_EXEC_WBINVD_EXITING);
  5634		case EXIT_REASON_XSETBV:
  5635			return true;
  5636		case EXIT_REASON_XSAVES: case EXIT_REASON_XRSTORS:
  5637			/*
  5638			 * This should never happen, since it is not possible to
  5639			 * set XSS to a non-zero value---neither in L1 nor in L2.
  5640			 * If if it were, XSS would have to be checked against
  5641			 * the XSS exit bitmap in vmcs12.
  5642			 */
  5643			return nested_cpu_has2(vmcs12, SECONDARY_EXEC_XSAVES);
  5644		case EXIT_REASON_PREEMPTION_TIMER:
  5645			return false;
  5646		case EXIT_REASON_PML_FULL:
  5647			/* We emulate PML support to L1. */
  5648			return false;
  5649		case EXIT_REASON_VMFUNC:
  5650			/* VM functions are emulated through L2->L0 vmexits. */
  5651			return false;
  5652		case EXIT_REASON_ENCLS:
  5653			/* SGX is never exposed to L1 */
  5654			return false;
  5655		case EXIT_REASON_UMWAIT:
  5656		case EXIT_REASON_TPAUSE:
  5657			return nested_cpu_has2(vmcs12,
  5658				SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE);
  5659		default:
  5660			return true;
  5661		}
  5662	}
  5663	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 44218 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: nVMX: Consolidate nested MTF checks to helper function
  2020-02-24 20:27 [PATCH] KVM: nVMX: Consolidate nested MTF checks to helper function Oliver Upton
  2020-02-25  0:02 ` Krish Sadhukhan
  2020-02-25  1:37 ` kbuild test robot
@ 2020-02-25  3:23 ` kbuild test robot
  2020-03-14 11:14 ` Paolo Bonzini
  3 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2020-02-25  3:23 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 9360 bytes --]

Hi Oliver,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on kvm/linux-next]
[also build test ERROR on vhost/linux-next v5.6-rc3 next-20200224]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Oliver-Upton/KVM-nVMX-Consolidate-nested-MTF-checks-to-helper-function/20200225-042912
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git linux-next
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (git://gitmirror/llvm_project 1df947ab403a9ec3bb1bf4cd83610a997dc4f3bc)
reproduce:
        # FIXME the reproduce steps for clang is not ready yet

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> arch/x86/kvm/vmx/nested.c:5592:10: error: implicit declaration of function 'nested_cpu_has_mtf' [-Werror,-Wimplicit-function-declaration]
                   return nested_cpu_has_mtf(vmcs12);
                          ^
   1 error generated.

vim +/nested_cpu_has_mtf +5592 arch/x86/kvm/vmx/nested.c

  5477	
  5478	/*
  5479	 * Return 1 if we should exit from L2 to L1 to handle an exit, or 0 if we
  5480	 * should handle it ourselves in L0 (and then continue L2). Only call this
  5481	 * when in is_guest_mode (L2).
  5482	 */
  5483	bool nested_vmx_exit_reflected(struct kvm_vcpu *vcpu, u32 exit_reason)
  5484	{
  5485		u32 intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
  5486		struct vcpu_vmx *vmx = to_vmx(vcpu);
  5487		struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
  5488	
  5489		if (vmx->nested.nested_run_pending)
  5490			return false;
  5491	
  5492		if (unlikely(vmx->fail)) {
  5493			trace_kvm_nested_vmenter_failed(
  5494				"hardware VM-instruction error: ",
  5495				vmcs_read32(VM_INSTRUCTION_ERROR));
  5496			return true;
  5497		}
  5498	
  5499		/*
  5500		 * The host physical addresses of some pages of guest memory
  5501		 * are loaded into the vmcs02 (e.g. vmcs12's Virtual APIC
  5502		 * Page). The CPU may write to these pages via their host
  5503		 * physical address while L2 is running, bypassing any
  5504		 * address-translation-based dirty tracking (e.g. EPT write
  5505		 * protection).
  5506		 *
  5507		 * Mark them dirty on every exit from L2 to prevent them from
  5508		 * getting out of sync with dirty tracking.
  5509		 */
  5510		nested_mark_vmcs12_pages_dirty(vcpu);
  5511	
  5512		trace_kvm_nested_vmexit(kvm_rip_read(vcpu), exit_reason,
  5513					vmcs_readl(EXIT_QUALIFICATION),
  5514					vmx->idt_vectoring_info,
  5515					intr_info,
  5516					vmcs_read32(VM_EXIT_INTR_ERROR_CODE),
  5517					KVM_ISA_VMX);
  5518	
  5519		switch (exit_reason) {
  5520		case EXIT_REASON_EXCEPTION_NMI:
  5521			if (is_nmi(intr_info))
  5522				return false;
  5523			else if (is_page_fault(intr_info))
  5524				return !vmx->vcpu.arch.apf.host_apf_reason && enable_ept;
  5525			else if (is_debug(intr_info) &&
  5526				 vcpu->guest_debug &
  5527				 (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))
  5528				return false;
  5529			else if (is_breakpoint(intr_info) &&
  5530				 vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP)
  5531				return false;
  5532			return vmcs12->exception_bitmap &
  5533					(1u << (intr_info & INTR_INFO_VECTOR_MASK));
  5534		case EXIT_REASON_EXTERNAL_INTERRUPT:
  5535			return false;
  5536		case EXIT_REASON_TRIPLE_FAULT:
  5537			return true;
  5538		case EXIT_REASON_INTERRUPT_WINDOW:
  5539			return nested_cpu_has(vmcs12, CPU_BASED_INTR_WINDOW_EXITING);
  5540		case EXIT_REASON_NMI_WINDOW:
  5541			return nested_cpu_has(vmcs12, CPU_BASED_NMI_WINDOW_EXITING);
  5542		case EXIT_REASON_TASK_SWITCH:
  5543			return true;
  5544		case EXIT_REASON_CPUID:
  5545			return true;
  5546		case EXIT_REASON_HLT:
  5547			return nested_cpu_has(vmcs12, CPU_BASED_HLT_EXITING);
  5548		case EXIT_REASON_INVD:
  5549			return true;
  5550		case EXIT_REASON_INVLPG:
  5551			return nested_cpu_has(vmcs12, CPU_BASED_INVLPG_EXITING);
  5552		case EXIT_REASON_RDPMC:
  5553			return nested_cpu_has(vmcs12, CPU_BASED_RDPMC_EXITING);
  5554		case EXIT_REASON_RDRAND:
  5555			return nested_cpu_has2(vmcs12, SECONDARY_EXEC_RDRAND_EXITING);
  5556		case EXIT_REASON_RDSEED:
  5557			return nested_cpu_has2(vmcs12, SECONDARY_EXEC_RDSEED_EXITING);
  5558		case EXIT_REASON_RDTSC: case EXIT_REASON_RDTSCP:
  5559			return nested_cpu_has(vmcs12, CPU_BASED_RDTSC_EXITING);
  5560		case EXIT_REASON_VMREAD:
  5561			return nested_vmx_exit_handled_vmcs_access(vcpu, vmcs12,
  5562				vmcs12->vmread_bitmap);
  5563		case EXIT_REASON_VMWRITE:
  5564			return nested_vmx_exit_handled_vmcs_access(vcpu, vmcs12,
  5565				vmcs12->vmwrite_bitmap);
  5566		case EXIT_REASON_VMCALL: case EXIT_REASON_VMCLEAR:
  5567		case EXIT_REASON_VMLAUNCH: case EXIT_REASON_VMPTRLD:
  5568		case EXIT_REASON_VMPTRST: case EXIT_REASON_VMRESUME:
  5569		case EXIT_REASON_VMOFF: case EXIT_REASON_VMON:
  5570		case EXIT_REASON_INVEPT: case EXIT_REASON_INVVPID:
  5571			/*
  5572			 * VMX instructions trap unconditionally. This allows L1 to
  5573			 * emulate them for its L2 guest, i.e., allows 3-level nesting!
  5574			 */
  5575			return true;
  5576		case EXIT_REASON_CR_ACCESS:
  5577			return nested_vmx_exit_handled_cr(vcpu, vmcs12);
  5578		case EXIT_REASON_DR_ACCESS:
  5579			return nested_cpu_has(vmcs12, CPU_BASED_MOV_DR_EXITING);
  5580		case EXIT_REASON_IO_INSTRUCTION:
  5581			return nested_vmx_exit_handled_io(vcpu, vmcs12);
  5582		case EXIT_REASON_GDTR_IDTR: case EXIT_REASON_LDTR_TR:
  5583			return nested_cpu_has2(vmcs12, SECONDARY_EXEC_DESC);
  5584		case EXIT_REASON_MSR_READ:
  5585		case EXIT_REASON_MSR_WRITE:
  5586			return nested_vmx_exit_handled_msr(vcpu, vmcs12, exit_reason);
  5587		case EXIT_REASON_INVALID_STATE:
  5588			return true;
  5589		case EXIT_REASON_MWAIT_INSTRUCTION:
  5590			return nested_cpu_has(vmcs12, CPU_BASED_MWAIT_EXITING);
  5591		case EXIT_REASON_MONITOR_TRAP_FLAG:
> 5592			return nested_cpu_has_mtf(vmcs12);
  5593		case EXIT_REASON_MONITOR_INSTRUCTION:
  5594			return nested_cpu_has(vmcs12, CPU_BASED_MONITOR_EXITING);
  5595		case EXIT_REASON_PAUSE_INSTRUCTION:
  5596			return nested_cpu_has(vmcs12, CPU_BASED_PAUSE_EXITING) ||
  5597				nested_cpu_has2(vmcs12,
  5598					SECONDARY_EXEC_PAUSE_LOOP_EXITING);
  5599		case EXIT_REASON_MCE_DURING_VMENTRY:
  5600			return false;
  5601		case EXIT_REASON_TPR_BELOW_THRESHOLD:
  5602			return nested_cpu_has(vmcs12, CPU_BASED_TPR_SHADOW);
  5603		case EXIT_REASON_APIC_ACCESS:
  5604		case EXIT_REASON_APIC_WRITE:
  5605		case EXIT_REASON_EOI_INDUCED:
  5606			/*
  5607			 * The controls for "virtualize APIC accesses," "APIC-
  5608			 * register virtualization," and "virtual-interrupt
  5609			 * delivery" only come from vmcs12.
  5610			 */
  5611			return true;
  5612		case EXIT_REASON_EPT_VIOLATION:
  5613			/*
  5614			 * L0 always deals with the EPT violation. If nested EPT is
  5615			 * used, and the nested mmu code discovers that the address is
  5616			 * missing in the guest EPT table (EPT12), the EPT violation
  5617			 * will be injected with nested_ept_inject_page_fault()
  5618			 */
  5619			return false;
  5620		case EXIT_REASON_EPT_MISCONFIG:
  5621			/*
  5622			 * L2 never uses directly L1's EPT, but rather L0's own EPT
  5623			 * table (shadow on EPT) or a merged EPT table that L0 built
  5624			 * (EPT on EPT). So any problems with the structure of the
  5625			 * table is L0's fault.
  5626			 */
  5627			return false;
  5628		case EXIT_REASON_INVPCID:
  5629			return
  5630				nested_cpu_has2(vmcs12, SECONDARY_EXEC_ENABLE_INVPCID) &&
  5631				nested_cpu_has(vmcs12, CPU_BASED_INVLPG_EXITING);
  5632		case EXIT_REASON_WBINVD:
  5633			return nested_cpu_has2(vmcs12, SECONDARY_EXEC_WBINVD_EXITING);
  5634		case EXIT_REASON_XSETBV:
  5635			return true;
  5636		case EXIT_REASON_XSAVES: case EXIT_REASON_XRSTORS:
  5637			/*
  5638			 * This should never happen, since it is not possible to
  5639			 * set XSS to a non-zero value---neither in L1 nor in L2.
  5640			 * If if it were, XSS would have to be checked against
  5641			 * the XSS exit bitmap in vmcs12.
  5642			 */
  5643			return nested_cpu_has2(vmcs12, SECONDARY_EXEC_XSAVES);
  5644		case EXIT_REASON_PREEMPTION_TIMER:
  5645			return false;
  5646		case EXIT_REASON_PML_FULL:
  5647			/* We emulate PML support to L1. */
  5648			return false;
  5649		case EXIT_REASON_VMFUNC:
  5650			/* VM functions are emulated through L2->L0 vmexits. */
  5651			return false;
  5652		case EXIT_REASON_ENCLS:
  5653			/* SGX is never exposed to L1 */
  5654			return false;
  5655		case EXIT_REASON_UMWAIT:
  5656		case EXIT_REASON_TPAUSE:
  5657			return nested_cpu_has2(vmcs12,
  5658				SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE);
  5659		default:
  5660			return true;
  5661		}
  5662	}
  5663	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 72215 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: nVMX: Consolidate nested MTF checks to helper function
  2020-02-24 20:27 [PATCH] KVM: nVMX: Consolidate nested MTF checks to helper function Oliver Upton
                   ` (2 preceding siblings ...)
  2020-02-25  3:23 ` kbuild test robot
@ 2020-03-14 11:14 ` Paolo Bonzini
  3 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2020-03-14 11:14 UTC (permalink / raw)
  To: Oliver Upton, kvm

On 24/02/20 21:27, Oliver Upton wrote:
> commit 5ef8acbdd687 ("KVM: nVMX: Emulate MTF when performing
> instruction emulation") introduced a helper to check the MTF
> VM-execution control in vmcs12. Change pre-existing check in
> nested_vmx_exit_reflected() to instead use the helper.
> 
> Signed-off-by: Oliver Upton <oupton@google.com>
> ---
>  arch/x86/kvm/vmx/nested.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index e920d7834d73..b9caad70ac7c 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -5627,7 +5627,7 @@ bool nested_vmx_exit_reflected(struct kvm_vcpu *vcpu, u32 exit_reason)
>  	case EXIT_REASON_MWAIT_INSTRUCTION:
>  		return nested_cpu_has(vmcs12, CPU_BASED_MWAIT_EXITING);
>  	case EXIT_REASON_MONITOR_TRAP_FLAG:
> -		return nested_cpu_has(vmcs12, CPU_BASED_MONITOR_TRAP_FLAG);
> +		return nested_cpu_has_mtf(vmcs12);
>  	case EXIT_REASON_MONITOR_INSTRUCTION:
>  		return nested_cpu_has(vmcs12, CPU_BASED_MONITOR_EXITING);
>  	case EXIT_REASON_PAUSE_INSTRUCTION:
> 

Queued, thanks.

Paolo


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: nVMX: Consolidate nested MTF checks to helper function
@ 2020-02-25  3:11 linmiaohe
  0 siblings, 0 replies; 6+ messages in thread
From: linmiaohe @ 2020-02-25  3:11 UTC (permalink / raw)
  To: Oliver Upton; +Cc: Paolo Bonzini, kvm

Oliver Upton <oupton@google.com> writes:
>commit 5ef8acbdd687 ("KVM: nVMX: Emulate MTF when performing instruction emulation") introduced a helper to check the MTF VM-execution control in vmcs12. Change pre-existing check in
>nested_vmx_exit_reflected() to instead use the helper.
>
>Signed-off-by: Oliver Upton <oupton@google.com>
>---

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-03-15  3:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24 20:27 [PATCH] KVM: nVMX: Consolidate nested MTF checks to helper function Oliver Upton
2020-02-25  0:02 ` Krish Sadhukhan
2020-02-25  1:37 ` kbuild test robot
2020-02-25  3:23 ` kbuild test robot
2020-03-14 11:14 ` Paolo Bonzini
2020-02-25  3:11 linmiaohe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.