From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joel Schopp Subject: Re: [PATCH] x86: svm: make wbinvd faster Date: Mon, 2 Mar 2015 10:58:03 -0600 Message-ID: <54F4969B.8080806@amd.com> References: <20150228001917.15247.41063.stgit@joelvmguard2.amd.com> <20150302135925.GA26739@potion.brq.redhat.com> <20150302160319.GA25123@potion.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Gleb Natapov , Paolo Bonzini , , David Kaplan , Joerg Roedel , Marcelo Tosatti , , Borislav Petkov To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Bandan Das Return-path: In-Reply-To: <20150302160319.GA25123@potion.brq.redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 03/02/2015 10:03 AM, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: > 2015-03-02 10:25-0500, Bandan Das: >> Radim Kr=C4=8Dm=C3=A1=C5=99 writes: >>> 2015-03-01 21:29-0500, Bandan Das: >>>> Joel Schopp writes: >>>>> +static int wbinvd_interception(struct vcpu_svm *svm) >>>>> +{ >>>>> + kvm_emulate_wbinvd(&svm->vcpu); >>>>> + skip_emulated_instruction(&svm->vcpu); >>>>> + return 1; >>>>> +} >>>> Can't we merge this to kvm_emulate_wbinvd, and just call that func= tion >>>> directly for both vmx and svm ? >>> kvm_emulate_wbinvd() lives in x86.c and skip_emulated_instruction()= is >>> from svm.c/vmx.c: so we'd have to create a new x86 op and change t= he >>> emulator code as well ... it's probably better like this. >> There's already one - kvm_x86_ops->skip_emulated_instruction > My bad, its usage is inconsistent and I only looked at two close > interceptions where it was used ... kvm_emulate_cpuid() calls > kvm_x86_ops->skip_emulated_instruction(), while kvm_emulate_halt() an= d > kvm_emulate_hypercall() need an external skip. > > We do "skip" the instruction with kvm_emulate(), so automatically > skipping the instruction on kvm_emulate_*() makes sense: > 1. rename kvm_emulate_halt() and kvm_emulate_wbinvd() to accommodat= e > callers that don't want to skip > 2. introduce kvm_emulate_{halt,wbinvd}() and move the skip to to > kvm_emulate_{halt,wbinvd,hypercall}() > > The alternative is to remove kvm_x86_ops->skip_emulated_instruction()= : > 1. remove skip from kvm_emulate_cpuid() and modify callers > 2. move kvm_complete_insn_gp to a header file and use > skip_emulated_instruction directly > 3. remove unused kvm_x86_ops->skip_emulated_instruction() > > Which one do you prefer? I prefer renaming them, ie kvm_emulate_wbinvd_noskip(), and making the= =20 existing ones, ie kvm_emulate_wbinvd() call the noskip verion and add a= =20 skip similar to how wbinvd_interception above does. I can send out a=20 patch later today with that rework.