From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Nadav Har'El" Subject: [PATCH 16/29] nVMX: Move register-syncing to a function Date: Thu, 27 Jan 2011 10:38:03 +0200 Message-ID: <201101270838.p0R8c345002627@rice.haifa.ibm.com> References: <1296116987-nyh@il.ibm.com> Cc: gleb@redhat.com, avi@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mtagate3.uk.ibm.com ([194.196.100.163]:38550 "EHLO mtagate3.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751818Ab1A0IiH (ORCPT ); Thu, 27 Jan 2011 03:38:07 -0500 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate3.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p0R8c5W4026614 for ; Thu, 27 Jan 2011 08:38:05 GMT Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p0R8c8TT1851622 for ; Thu, 27 Jan 2011 08:38:08 GMT Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p0R8c48m005677 for ; Thu, 27 Jan 2011 01:38:05 -0700 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 --- arch/x86/kvm/vmx.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) --- .before/arch/x86/kvm/vmx.c 2011-01-26 18:06:04.000000000 +0200 +++ .after/arch/x86/kvm/vmx.c 2011-01-26 18:06:04.000000000 +0200 @@ -5172,6 +5172,15 @@ static void vmx_cancel_injection(struct vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 0); } +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" @@ -5193,10 +5202,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 @@ -5308,7 +5314,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) | (1 << VCPU_EXREG_CR3)); - vcpu->arch.regs_dirty = 0; vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);