Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753588AbdGJJS3 (ORCPT ); Mon, 10 Jul 2017 05:18:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60240 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753356AbdGJJS1 (ORCPT ); Mon, 10 Jul 2017 05:18:27 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 335B880F7A Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=david@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 335B880F7A Subject: Re: [PATCH 2/3 v2] KVM: nVMX: Enable VMFUNC for the L1 hypervisor To: Bandan Das , kvm@vger.kernel.org Cc: pbonzini@redhat.com, linux-kernel@vger.kernel.org References: <20170706230323.29952-1-bsd@redhat.com> <20170706230323.29952-3-bsd@redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Mon, 10 Jul 2017 11:17:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <20170706230323.29952-3-bsd@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 10 Jul 2017 09:17:54 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1166 Lines: 47 > @@ -7752,7 +7769,29 @@ static int handle_preemption_timer(struct kvm_vcpu *vcpu) > > static int handle_vmfunc(struct kvm_vcpu *vcpu) > { > - kvm_queue_exception(vcpu, UD_VECTOR); > + struct vcpu_vmx *vmx = to_vmx(vcpu); > + struct vmcs12 *vmcs12; > + u32 function = vcpu->arch.regs[VCPU_REGS_RAX]; > + > + /* > + * VMFUNC is only supported for nested guests, but we always enable the > + * secondary control for simplicity; for non-nested mode, fake that we > + * didn't by injecting #UD. > + */ > + if (!is_guest_mode(vcpu)) { > + kvm_queue_exception(vcpu, UD_VECTOR); > + return 1; > + } > + > + vmcs12 = get_vmcs12(vcpu); > + if ((vmcs12->vm_function_control & (1 << function)) == 0) (learned that in c, shifting beyond the type size is undefined) Should we check for function < 64 here? (as SDM mentions) > + goto fail; > + WARN(1, "VMCS12 VM function control should have been zero"); > + > +fail: We will never hit the case !nested_cpu_has_vmfunc(vmcs12) here, correct? > + nested_vmx_vmexit(vcpu, vmx->exit_reason, > + vmcs_read32(VM_EXIT_INTR_INFO), > + vmcs_readl(EXIT_QUALIFICATION)); > return 1; > } > -- Thanks, David