Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: KVM: Add vcpu_get_regs/vcpu_set_regs callback

Add a vcpu_get_regs() and vcpu_set_regs() callbacks for loading and
restoring context which may be in hardware registers. This may include
floating point and MIPS SIMD Architecture (MSA) state which may be
accessed directly by the guest (but restored lazily by the hypervisor),
and also dedicated guest registers as provided by the VZ ASE.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Gleb Natapov <gleb@kernel.org>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org

+20
+2
arch/mips/include/asm/kvm_host.h
··· 585 585 const struct kvm_one_reg *reg, s64 *v); 586 586 int (*set_one_reg)(struct kvm_vcpu *vcpu, 587 587 const struct kvm_one_reg *reg, s64 v); 588 + int (*vcpu_get_regs)(struct kvm_vcpu *vcpu); 589 + int (*vcpu_set_regs)(struct kvm_vcpu *vcpu); 588 590 }; 589 591 extern struct kvm_mips_callbacks *kvm_mips_callbacks; 590 592 int kvm_mips_emulation_init(struct kvm_mips_callbacks **install_callbacks);
+6
arch/mips/kvm/tlb.c
··· 733 733 } 734 734 } 735 735 736 + /* restore guest state to registers */ 737 + kvm_mips_callbacks->vcpu_set_regs(vcpu); 738 + 736 739 local_irq_restore(flags); 737 740 738 741 } ··· 753 750 754 751 vcpu->arch.preempt_entryhi = read_c0_entryhi(); 755 752 vcpu->arch.last_sched_cpu = cpu; 753 + 754 + /* save guest state in registers */ 755 + kvm_mips_callbacks->vcpu_get_regs(vcpu); 756 756 757 757 if (((cpu_context(cpu, current->mm) ^ asid_cache(cpu)) & 758 758 ASID_VERSION_MASK)) {
+12
arch/mips/kvm/trap_emul.c
··· 552 552 return ret; 553 553 } 554 554 555 + static int kvm_trap_emul_vcpu_get_regs(struct kvm_vcpu *vcpu) 556 + { 557 + return 0; 558 + } 559 + 560 + static int kvm_trap_emul_vcpu_set_regs(struct kvm_vcpu *vcpu) 561 + { 562 + return 0; 563 + } 564 + 555 565 static struct kvm_mips_callbacks kvm_trap_emul_callbacks = { 556 566 /* exit handlers */ 557 567 .handle_cop_unusable = kvm_trap_emul_handle_cop_unusable, ··· 588 578 .irq_clear = kvm_mips_irq_clear_cb, 589 579 .get_one_reg = kvm_trap_emul_get_one_reg, 590 580 .set_one_reg = kvm_trap_emul_set_one_reg, 581 + .vcpu_get_regs = kvm_trap_emul_vcpu_get_regs, 582 + .vcpu_set_regs = kvm_trap_emul_vcpu_set_regs, 591 583 }; 592 584 593 585 int kvm_mips_emulation_init(struct kvm_mips_callbacks **install_callbacks)