lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZjiE+O9fct5zI4Sf@chao-email>
Date: Mon, 6 May 2024 15:21:28 +0800
From: Chao Gao <chao.gao@...el.com>
To: Reinette Chatre <reinette.chatre@...el.com>
CC: Isaku Yamahata <isaku.yamahata@...el.com>, <kvm@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, <isaku.yamahata@...il.com>, Paolo Bonzini
	<pbonzini@...hat.com>, <erdemaktas@...gle.com>, Sean Christopherson
	<seanjc@...gle.com>, Sagi Shahar <sagis@...gle.com>, Kai Huang
	<kai.huang@...el.com>, <chen.bo@...el.com>, <hang.yuan@...el.com>,
	<tina.zhang@...el.com>, <isaku.yamahata@...ux.intel.com>
Subject: Re: [PATCH v19 101/130] KVM: TDX: handle ept violation/misconfig exit

On Wed, May 01, 2024 at 09:54:07AM -0700, Reinette Chatre wrote:
>diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
>index 499c6cd9633f..ba81e6f68c97 100644
>--- a/arch/x86/kvm/vmx/tdx.c
>+++ b/arch/x86/kvm/vmx/tdx.c
>@@ -1305,11 +1305,20 @@ static int tdx_handle_ept_violation(struct kvm_vcpu *vcpu)
> 	} else {
> 		exit_qual = tdexit_exit_qual(vcpu);
> 		if (exit_qual & EPT_VIOLATION_ACC_INSTR) {
>+			union tdx_exit_reason exit_reason = to_tdx(vcpu)->exit_reason;
>+
>+			/*
>+			 * Instruction fetch in TD from shared memory
>+			 * causes a #PF.
>+			 */

It is better to hoist this comment above the if-statement.

		/*
		 * Instruction fetch in TD from shared memory never causes EPT
		 * violation. Warn if such an EPT violation occurs as the CPU
		 * probably is buggy.
		 */
 		if (exit_qual & EPT_VIOLATION_ACC_INSTR) {
		...
		}


but, I am wondering why KVM needs to perform this check. I prefer to drop this
check if KVM doesn't rely on it to handle EPT violation correctly.

> 			pr_warn("kvm: TDX instr fetch to shared GPA = 0x%lx @ RIP = 0x%lx\n",
> 				tdexit_gpa(vcpu), kvm_rip_read(vcpu));

how about using vcpu_unimpl()? it is a wrapper for printing such a message.

>-			vcpu->run->exit_reason = KVM_EXIT_EXCEPTION;
>-			vcpu->run->ex.exception = PF_VECTOR;
>-			vcpu->run->ex.error_code = exit_qual;
>+			vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
>+			vcpu->run->internal.suberror =
>+				KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON;
>+			vcpu->run->internal.ndata = 2;
>+			vcpu->run->internal.data[0] = exit_reason.full;
>+			vcpu->run->internal.data[1] = exit_qual;
> 			return 0;
> 		}
> 	}
>
>Reinette
>
>[1] https://github.com/kvm-x86/linux/blob/next/arch/x86/kvm/vmx/vmx.c#L6587
>[2] https://github.com/kvm-x86/linux/blob/next/arch/x86/kvm/svm/svm.c#L3436

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ