From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Nadav Har'El" Subject: [PATCH 15/24] Move register-syncing to a function Date: Sun, 13 Jun 2010 15:30:15 +0300 Message-ID: <201006131230.o5DCUFeK013063@rice.haifa.ibm.com> References: <1276431753-nyh@il.ibm.com> Cc: kvm@vger.kernel.org To: avi@redhat.com Return-path: Received: from mtagate7.uk.ibm.com ([194.196.100.167]:46527 "EHLO mtagate7.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753403Ab0FMMaS (ORCPT ); Sun, 13 Jun 2010 08:30:18 -0400 Received: from d06nrmr1806.portsmouth.uk.ibm.com (d06nrmr1806.portsmouth.uk.ibm.com [9.149.39.193]) by mtagate7.uk.ibm.com (8.13.1/8.13.1) with ESMTP id o5DCUHOT014006 for ; Sun, 13 Jun 2010 12:30:17 GMT Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o5DCUH451286378 for ; Sun, 13 Jun 2010 13:30:17 +0100 Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o5DCUHP7027459 for ; Sun, 13 Jun 2010 13:30:17 +0100 Sender: kvm-owner@vger.kernel.org List-ID: Move code that syncs dirty RSP and RIP registers back to the VMCS, into a function. We will need to call this function from additional places in the next patch. Signed-off-by: Nadav Har'El --- --- .before/arch/x86/kvm/vmx.c 2010-06-13 15:01:29.000000000 +0300 +++ .after/arch/x86/kvm/vmx.c 2010-06-13 15:01:29.000000000 +0300 @@ -5114,6 +5114,15 @@ static void fixup_rmode_irq(struct vcpu_ | vmx->rmode.irq.vector; } +static inline void sync_cached_regs_to_vmcs(struct kvm_vcpu *vcpu) +{ + if (test_bit(VCPU_REGS_RSP, (unsigned long *)&vcpu->arch.regs_dirty)) + vmcs_writel(GUEST_RSP, vcpu->arch.regs[VCPU_REGS_RSP]); + if (test_bit(VCPU_REGS_RIP, (unsigned long *)&vcpu->arch.regs_dirty)) + vmcs_writel(GUEST_RIP, vcpu->arch.regs[VCPU_REGS_RIP]); + vcpu->arch.regs_dirty = 0; +} + #ifdef CONFIG_X86_64 #define R "r" #define Q "q" @@ -5135,10 +5144,7 @@ static void vmx_vcpu_run(struct kvm_vcpu if (vmx->emulation_required && emulate_invalid_guest_state) return; - if (test_bit(VCPU_REGS_RSP, (unsigned long *)&vcpu->arch.regs_dirty)) - vmcs_writel(GUEST_RSP, vcpu->arch.regs[VCPU_REGS_RSP]); - if (test_bit(VCPU_REGS_RIP, (unsigned long *)&vcpu->arch.regs_dirty)) - vmcs_writel(GUEST_RIP, vcpu->arch.regs[VCPU_REGS_RIP]); + sync_cached_regs_to_vmcs(vcpu); /* When single-stepping over STI and MOV SS, we must clear the * corresponding interruptibility bits in the guest state. Otherwise @@ -5246,7 +5252,6 @@ static void vmx_vcpu_run(struct kvm_vcpu vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP) | (1 << VCPU_EXREG_PDPTR)); - vcpu->arch.regs_dirty = 0; vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD); if (vmx->rmode.irq.pending)