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 <nyh@xxxxxxxxxx> --- 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); -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html