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]
Date: Wed, 3 Apr 2024 18:27:26 -0700
From: Isaku Yamahata <isaku.yamahata@...el.com>
To: Chao Gao <chao.gao@...el.com>
Cc: 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 105/130] KVM: TDX: handle KVM hypercall with
 TDG.VP.VMCALL

On Tue, Apr 02, 2024 at 04:52:46PM +0800,
Chao Gao <chao.gao@...el.com> wrote:

> >+static int tdx_emulate_vmcall(struct kvm_vcpu *vcpu)
> >+{
> >+	unsigned long nr, a0, a1, a2, a3, ret;
> >+
> 
> do you need to emulate xen/hyper-v hypercalls here?


No. kvm_emulate_hypercall() handles xen/hyper-v hypercalls,
__kvm_emulate_hypercall() doesn't.

> Nothing tells userspace that xen/hyper-v hypercalls are not supported and
> so userspace may expose related CPUID leafs to TD guests.
> 
> >+	/*
> >+	 * ABI for KVM tdvmcall argument:
> >+	 * In Guest-Hypervisor Communication Interface(GHCI) specification,
> >+	 * Non-zero leaf number (R10 != 0) is defined to indicate
> >+	 * vendor-specific.  KVM uses this for KVM hypercall.  NOTE: KVM
> >+	 * hypercall number starts from one.  Zero isn't used for KVM hypercall
> >+	 * number.
> >+	 *
> >+	 * R10: KVM hypercall number
> >+	 * arguments: R11, R12, R13, R14.
> >+	 */
> >+	nr = kvm_r10_read(vcpu);
> >+	a0 = kvm_r11_read(vcpu);
> >+	a1 = kvm_r12_read(vcpu);
> >+	a2 = kvm_r13_read(vcpu);
> >+	a3 = kvm_r14_read(vcpu);
> >+
> >+	ret = __kvm_emulate_hypercall(vcpu, nr, a0, a1, a2, a3, true, 0);
> >+
> >+	tdvmcall_set_return_code(vcpu, ret);
> >+
> >+	if (nr == KVM_HC_MAP_GPA_RANGE && !ret)
> >+		return 0;
> 
> Can you add a comment to call out that KVM_HC_MAP_GPA_RANGE is redirected to
> the userspace?

Yes, this is confusing.  We should refactor kvm_emulate_hypercall() more so that
the caller shouldn't care about the return value like this.  Will refactor it
and update this patch.
-- 
Isaku Yamahata <isaku.yamahata@...el.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ