From patchwork Wed Jul 13 15:32:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 972692 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6DFfPUw008128 for ; Wed, 13 Jul 2011 15:41:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755778Ab1GMPlF (ORCPT ); Wed, 13 Jul 2011 11:41:05 -0400 Received: from tx2ehsobe001.messaging.microsoft.com ([65.55.88.11]:7126 "EHLO TX2EHSOBE001.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755537Ab1GMPlD (ORCPT ); Wed, 13 Jul 2011 11:41:03 -0400 Received: from mail150-tx2-R.bigfish.com (10.9.14.247) by TX2EHSOBE001.bigfish.com (10.9.40.21) with Microsoft SMTP Server id 14.1.225.22; Wed, 13 Jul 2011 15:41:02 +0000 Received: from mail150-tx2 (localhost.localdomain [127.0.0.1]) by mail150-tx2-R.bigfish.com (Postfix) with ESMTP id 58A1744895D; Wed, 13 Jul 2011 15:40:59 +0000 (UTC) X-SpamScore: 1 X-BigFish: VPS1(zzzz1202hzz8275dhz32i668h839h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: CIP:163.181.249.109; KIP:(null); UIP:(null); IPVD:NLI; H:ausb3twp02.amd.com; RD:none; EFVD:NLI Received: from mail150-tx2 (localhost.localdomain [127.0.0.1]) by mail150-tx2 (MessageSwitch) id 1310571198986631_6951; Wed, 13 Jul 2011 15:33:18 +0000 (UTC) Received: from TX2EHSMHS046.bigfish.com (unknown [10.9.14.250]) by mail150-tx2.bigfish.com (Postfix) with ESMTP id 34D441960065; Wed, 13 Jul 2011 15:33:18 +0000 (UTC) Received: from ausb3twp02.amd.com (163.181.249.109) by TX2EHSMHS046.bigfish.com (10.9.99.146) with Microsoft SMTP Server id 14.1.225.22; Wed, 13 Jul 2011 15:33:15 +0000 X-WSS-ID: 0LOA37B-02-9JJ-02 X-M-MSG: Received: from sausexedgep02.amd.com (sausexedgep02-ext.amd.com [163.181.249.73]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ausb3twp02.amd.com (Axway MailGate 3.8.1) with ESMTP id 2424AC8220; Wed, 13 Jul 2011 10:33:11 -0500 (CDT) Received: from SAUSEXDAG04.amd.com (163.181.55.4) by sausexedgep02.amd.com (163.181.36.59) with Microsoft SMTP Server (TLS) id 8.3.106.1; Wed, 13 Jul 2011 10:34:13 -0500 Received: from storexhtp01.amd.com (172.24.4.3) by sausexdag04.amd.com (163.181.55.4) with Microsoft SMTP Server (TLS) id 14.1.289.1; Wed, 13 Jul 2011 08:33:13 -0700 Received: from gwo.osrc.amd.com (165.204.16.204) by storexhtp01.amd.com (172.24.4.3) with Microsoft SMTP Server id 8.3.83.0; Wed, 13 Jul 2011 11:33:12 -0400 Received: from lemmy.osrc.amd.com (lemmy.osrc.amd.com [165.204.15.93]) by gwo.osrc.amd.com (Postfix) with ESMTP id 3066949C5EE; Wed, 13 Jul 2011 16:33:11 +0100 (BST) Received: by lemmy.osrc.amd.com (Postfix, from userid 1000) id 264C0100200; Wed, 13 Jul 2011 17:33:11 +0200 (CEST) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: , , Joerg Roedel Subject: [PATCH 6/7] KVM: SVM: Rework hflags handling Date: Wed, 13 Jul 2011 17:32:24 +0200 Message-ID: <1310571145-28930-7-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1310571145-28930-1-git-send-email-joerg.roedel@amd.com> References: <1310571145-28930-1-git-send-email-joerg.roedel@amd.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 13 Jul 2011 15:41:25 +0000 (UTC) From: Joerg Roedel This patch moves the unsetting of the hflags used for nesting into the #vmexit path instead of doing everything in the vmrun path. Signed-off-by: Joerg Roedel --- arch/x86/kvm/svm.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index f2cca2c..c83315a 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -2256,6 +2256,8 @@ static int nested_svm_vmexit(struct vcpu_svm *svm) mark_all_dirty(svm->vmcb); + svm->vcpu.arch.hflags &= ~(HF_VINTR_MASK | HF_HIF_MASK); + nested_svm_unmap(page); nested_svm_uninit_mmu_context(&svm->vcpu); @@ -2317,6 +2319,7 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm) struct vmcb *nested_vmcb; struct page *page; u64 vmcb_gpa; + u64 rflags; vmcb_gpa = svm->vmcb->save.rax; @@ -2350,6 +2353,8 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm) kvm_clear_exception_queue(&svm->vcpu); kvm_clear_interrupt_queue(&svm->vcpu); + rflags = kvm_get_rflags(&svm->vcpu); + /* * Save the old vmcb, so we don't need to pick what we save, but can * restore everything when a VMEXIT occurs @@ -2357,7 +2362,7 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm) svm->host_vmcb->save.efer = svm->vcpu.arch.efer; svm->host_vmcb->save.cr0 = kvm_read_cr0(&svm->vcpu); svm->host_vmcb->save.cr4 = svm->vcpu.arch.cr4; - svm->host_vmcb->save.rflags = kvm_get_rflags(&svm->vcpu); + svm->host_vmcb->save.rflags = rflags; svm->host_vmcb->save.rax = svm->vcpu.arch.regs[VCPU_REGS_RAX]; svm->host_vmcb->save.rsp = svm->vcpu.arch.regs[VCPU_REGS_RSP]; svm->host_vmcb->save.rip = svm->vcpu.arch.regs[VCPU_REGS_RIP]; @@ -2365,17 +2370,11 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm) if (!npt_enabled) svm->host_vmcb->save.cr3 = kvm_read_cr3(&svm->vcpu); - if (kvm_get_rflags(&svm->vcpu) & X86_EFLAGS_IF) - svm->vcpu.arch.hflags |= HF_HIF_MASK; - else - svm->vcpu.arch.hflags &= ~HF_HIF_MASK; + svm->vcpu.arch.hflags |= rflags & X86_EFLAGS_IF ? HF_HIF_MASK : 0; - if (nested_vmcb->control.int_ctl & V_INTR_MASKING_MASK) + if (nested_vmcb->control.int_ctl & V_INTR_MASKING_MASK) { svm->vcpu.arch.hflags |= HF_VINTR_MASK; - else - svm->vcpu.arch.hflags &= ~HF_VINTR_MASK; - if (svm->vcpu.arch.hflags & HF_VINTR_MASK) { /* We only want the cr8 intercept bits of the guest */ clr_cr_intercept(svm, INTERCEPT_CR8_READ); clr_cr_intercept(svm, INTERCEPT_CR8_WRITE);