From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH 3/9] Implement GIF, clgi and stgi v5 Date: Thu, 30 Oct 2008 13:02:25 -0500 Message-ID: <4909F6B1.4060503@codemonkey.ws> References: <1224522290-11740-1-git-send-email-agraf@suse.de> <1224522290-11740-2-git-send-email-agraf@suse.de> <1224522290-11740-3-git-send-email-agraf@suse.de> <1224522290-11740-4-git-send-email-agraf@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, joro@8bytes.org, avi@redhat.com To: Alexander Graf Return-path: Received: from yx-out-2324.google.com ([74.125.44.28]:44361 "EHLO yx-out-2324.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758388AbYJ3SCa (ORCPT ); Thu, 30 Oct 2008 14:02:30 -0400 Received: by yx-out-2324.google.com with SMTP id 8so303441yxm.1 for ; Thu, 30 Oct 2008 11:02:29 -0700 (PDT) In-Reply-To: <1224522290-11740-4-git-send-email-agraf@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: Alexander Graf wrote: > This patch implements the GIF flag and the clgi and stgi instructions that > set this flag. Only if the flag is set (default), interrupts can be received by > the CPU. > > To keep the information about that somewhere, this patch adds a new hidden > flags vector. that is used to store information that does not go into the > vmcb, but is SVM specific. > > v2 moves the hflags to x86 generic code > v3 makes use of the new permission helper > > Signed-off-by: Alexander Graf > --- > arch/x86/kvm/svm.c | 42 +++++++++++++++++++++++++++++++++++++++--- > include/asm-x86/kvm_host.h | 3 +++ > 2 files changed, 42 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index a00421b..62bfa2b 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -614,6 +614,8 @@ static void init_vmcb(struct vcpu_svm *svm) > save->cr4 = 0; > } > force_new_asid(&svm->vcpu); > + > + svm->vcpu.arch.hflags = HF_GIF_MASK; > } > > static int svm_vcpu_reset(struct kvm_vcpu *vcpu) > @@ -1233,6 +1235,36 @@ static int nested_svm_do(struct vcpu_svm *svm, > return retval; > } > > +static int stgi_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run) > +{ > + if (nested_svm_check_permissions(svm)) > + return 1; > + > + svm->next_rip = kvm_rip_read(&svm->vcpu) + 3; > + skip_emulated_instruction(&svm->vcpu); > + > + svm->vcpu.arch.hflags |= HF_GIF_MASK; > + > + return 1; > +} > It feels a little strange to see this here instead of an implementation of stgi/clgi in x86_emulate. Any reason for not going that route? GIF somehow needs exposure to userspace too, right? Otherwise, when using -no-kernel-apic, userspace may try to inject an interrupt when the guest cannot handle it, right? Regards, Anthony Liguori