From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH v3 2/4] x86, apicv: add APICv register virtualization support Date: Thu, 6 Dec 2012 08:45:34 +0200 Message-ID: <20121206064534.GX19514@redhat.com> References: <1354518064-3066-1-git-send-email-yang.z.zhang@intel.com> <1354518064-3066-3-git-send-email-yang.z.zhang@intel.com> <20121205002939.GA27994@amt.cnet> <20121205231140.GB26880@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "Zhang, Yang Z" , "kvm@vger.kernel.org" , "Tian, Kevin" To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:57609 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754145Ab2LFGph (ORCPT ); Thu, 6 Dec 2012 01:45:37 -0500 Content-Disposition: inline In-Reply-To: <20121205231140.GB26880@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Dec 05, 2012 at 09:11:40PM -0200, Marcelo Tosatti wrote: > > >> +static int handle_apic_write(struct kvm_vcpu *vcpu) > > >> +{ > > >> + unsigned long exit_qualification = vmcs_readl(EXIT_QUALIFICATION); > > >> + u32 offset = exit_qualification & 0xfff; > > >> + > > >> + /* APIC-write VM exit is trap-like and thus no need to adjust IP */ > > >> + return kvm_apic_write_nodecode(vcpu, offset) == 0; > > >> +} > > > > > > Point of return value == 0? > > if kvm_apic_write_nodecode() handle successfully, it will return zero. Then it will return 1 for this vmexit handle. > > What's wrong? > > If kvm_apic_write_nodecode fails (return 0 for the vmexit handle), > there is an exit to userspace. Why is that necessary? kvm_apic_write_nodecode() returns apic_reg_write() value. apic_reg_write() returns 1 when #GP should be injected if used from MSR, if used from mmio apic_reg_write() is ignored since errors cannot be reported to a cpu. Since kvm_apic_write_nodecode() is used for mmio only make it void and ignore apic_reg_write() return value. -- Gleb.