From: David Hildenbrand <david@redhat.com>
To: Bandan Das <bsd@redhat.com>, kvm@vger.kernel.org
Cc: pbonzini@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3 v2] KVM: nVMX: Enable VMFUNC for the L1 hypervisor
Date: Mon, 10 Jul 2017 11:17:50 +0200 [thread overview]
Message-ID: <afdcb489-fd32-29d5-4072-3c7a65b0f032@redhat.com> (raw)
In-Reply-To: <20170706230323.29952-3-bsd@redhat.com>
> @@ -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
next prev parent reply other threads:[~2017-07-10 9:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-06 23:03 [PATCH 0/3 v2] Expose VMFUNC to the nested hypervisor Bandan Das
2017-07-06 23:03 ` [PATCH 1/3 v2] KVM: vmx: Enable VMFUNCs Bandan Das
2017-07-10 8:54 ` David Hildenbrand
2017-07-10 9:17 ` Paolo Bonzini
2017-07-10 9:20 ` David Hildenbrand
2017-07-10 9:21 ` Paolo Bonzini
2017-07-06 23:03 ` [PATCH 2/3 v2] KVM: nVMX: Enable VMFUNC for the L1 hypervisor Bandan Das
2017-07-10 9:17 ` David Hildenbrand [this message]
2017-07-10 11:03 ` Paolo Bonzini
2017-07-10 12:15 ` David Hildenbrand
2017-07-06 23:03 ` [PATCH 3/3 v2] KVM: nVMX: Emulate EPTP switching " Bandan Das
2017-07-07 8:30 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=afdcb489-fd32-29d5-4072-3c7a65b0f032@redhat.com \
--to=david@redhat.com \
--cc=bsd@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome