From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 03/27] nVMX: Implement VMXON and VMXOFF Date: Sun, 17 Oct 2010 14:24:50 +0200 Message-ID: <4CBAEB12.7030003@redhat.com> References: <1287309814-nyh@il.ibm.com> <201010171005.o9HA56HQ029295@rice.haifa.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, gleb@redhat.com To: "Nadav Har'El" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:34770 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751300Ab0JQMYz (ORCPT ); Sun, 17 Oct 2010 08:24:55 -0400 In-Reply-To: <201010171005.o9HA56HQ029295@rice.haifa.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On 10/17/2010 12:05 PM, Nadav Har'El wrote: > This patch allows a guest to use the VMXON and VMXOFF instructions, and > emulates them accordingly. Basically this amounts to checking some > prerequisites, and then remembering whether the guest has enabled or disabled > VMX operation. > > > +/* > + * Emulate the VMXON instruction. > + * Currently, we just remember that VMX is active, and do not save or even > + * inspect the argument to VMXON (the so-called "VMXON pointer") because we > + * do not currently need to store anything in that guest-allocated memory > + * region. Consequently, VMCLEAR and VMPTRLD also do not verify that the their > + * argument is different from the VMXON pointer (which the spec says they do). > + */ > +static int handle_vmon(struct kvm_vcpu *vcpu) > +{ > + struct kvm_segment cs; > + struct vcpu_vmx *vmx = to_vmx(vcpu); > + > + /* The Intel VMX Instruction Reference lists a bunch of bits that > + * are prerequisite to running VMXON, most notably CR4.VMXE must be > + * set to 1. Otherwise, we should fail with #UD. We test these now: > + */ > + if (!nested || Is the !nested case needed? Presumably cr4.vmxe will be clear is !nested. > + !kvm_read_cr4_bits(vcpu, X86_CR4_VMXE) || > + !kvm_read_cr0_bits(vcpu, X86_CR0_PE) || > + (vmx_get_rflags(vcpu)& X86_EFLAGS_VM)) { > + kvm_queue_exception(vcpu, UD_VECTOR); > + return 1; > + } > + > + vmx_get_segment(vcpu,&cs, VCPU_SREG_CS); > + if (is_long_mode(vcpu)&& !cs.l) { > + kvm_queue_exception(vcpu, UD_VECTOR); > + return 1; > + } > + > + if (vmx_get_cpl(vcpu)) { > + kvm_inject_gp(vcpu, 0); > + return 1; > + } > + > + vmx->nested.vmxon = true; > + > + skip_emulated_instruction(vcpu); > + return 1; > +} > -- error compiling committee.c: too many arguments to function