From: Alexander Graf Subject: Re: [PATCH 3/9] Implement GIF, clgi and stgi Date: Mon, 1 Sep 2008 16:02:43 +0200 Message-ID: References: <1220270281-15720-1-git-send-email-agraf@suse.de> <1220270281-15720-2-git-send-email-agraf@suse.de> <1220270281-15720-3-git-send-email-agraf@suse.de> <1220270281-15720-4-git-send-email-agraf@suse.de> <48BBEA06.8090206@qumranet.com> Mime-Version: 1.0 (Apple Message framework v926) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, joro@8bytes.org, anthony@codemonkey.ws To: Avi Kivity Return-path: Received: from cantor2.suse.de ([195.135.220.15]:48297 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751435AbYIAOCp (ORCPT ); Mon, 1 Sep 2008 10:02:45 -0400 In-Reply-To: <48BBEA06.8090206@qumranet.com> Sender: kvm-owner@vger.kernel.org List-ID: On Sep 1, 2008, at 3:11 PM, Avi Kivity wrote: > 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. >> >> + >> + u32 hflags; >> }; >> > > bool gif : 1; > > (or even > > bool gif;)? It's not visible in the patches I sent, but I did use the hflags for a VMLOAD+VMRUN+VMSAVE aggregation hack. It's still somewhat flacky wrt save/restore though, so I didn't send it. Hflags might be useful nevertheless though. > > >> +static int stgi_interception(struct vcpu_svm *svm, struct kvm_run >> *kvm_run) >> +{ >> + svm->next_rip = kvm_rip_read(&svm->vcpu) + 3; >> + skip_emulated_instruction(&svm->vcpu); >> + >> + if (svm->vmcb->save.cpl) { >> + printk(KERN_ERR "%s: invalid cpl 0x%x at ip 0x%lx\n", >> + __func__, svm->vmcb->save.cpl, kvm_rip_read(&svm->vcpu)); >> + kvm_queue_exception(&svm->vcpu, GP_VECTOR); >> + return 1; >> + } >> > > Check before adjusting rip. > >> +static int clgi_interception(struct vcpu_svm *svm, struct kvm_run >> *kvm_run) >> +{ >> + svm->next_rip = kvm_rip_read(&svm->vcpu) + 3; >> + skip_emulated_instruction(&svm->vcpu); >> + >> + if (svm->vmcb->save.cpl) { >> + printk(KERN_ERR "%s: invalid cpl 0x%x at ip 0x%lx\n", >> + __func__, svm->vmcb->save.cpl, kvm_rip_read(&svm->vcpu)); >> + kvm_queue_exception(&svm->vcpu, GP_VECTOR); >> + return 1; >> + } >> > > Ditto. > > Need save/restore support as well. Can be in a different patch, > though. It might be a good idea to share hflags with qemu. I implemented the GIF there already. Alex