diff options
author | James Hogan <james.hogan@imgtec.com> | 2015-02-09 11:35:20 -0500 |
---|---|---|
committer | James Hogan <james.hogan@imgtec.com> | 2015-03-27 17:25:13 -0400 |
commit | b86ecb3766abd9138289ff2a18381d25b73f4622 (patch) | |
tree | fd0ca41fd27fd00c94a6d2022ecd04c8266ed9f8 | |
parent | c771607af959f282704268a209743560d3264eb3 (diff) |
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
-rw-r--r-- | arch/mips/include/asm/kvm_host.h | 2 | ||||
-rw-r--r-- | arch/mips/kvm/tlb.c | 6 | ||||
-rw-r--r-- | arch/mips/kvm/trap_emul.c | 12 |
3 files changed, 20 insertions, 0 deletions
diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h index 3f58ee1ebfab..fb79d67de192 100644 --- a/arch/mips/include/asm/kvm_host.h +++ b/arch/mips/include/asm/kvm_host.h | |||
@@ -585,6 +585,8 @@ struct kvm_mips_callbacks { | |||
585 | const struct kvm_one_reg *reg, s64 *v); | 585 | const struct kvm_one_reg *reg, s64 *v); |
586 | int (*set_one_reg)(struct kvm_vcpu *vcpu, | 586 | int (*set_one_reg)(struct kvm_vcpu *vcpu, |
587 | const struct kvm_one_reg *reg, s64 v); | 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 | extern struct kvm_mips_callbacks *kvm_mips_callbacks; | 591 | extern struct kvm_mips_callbacks *kvm_mips_callbacks; |
590 | int kvm_mips_emulation_init(struct kvm_mips_callbacks **install_callbacks); | 592 | int kvm_mips_emulation_init(struct kvm_mips_callbacks **install_callbacks); |
diff --git a/arch/mips/kvm/tlb.c b/arch/mips/kvm/tlb.c index b6beb0e07b1b..aed0ac2a4972 100644 --- a/arch/mips/kvm/tlb.c +++ b/arch/mips/kvm/tlb.c | |||
@@ -733,6 +733,9 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) | |||
733 | } | 733 | } |
734 | } | 734 | } |
735 | 735 | ||
736 | /* restore guest state to registers */ | ||
737 | kvm_mips_callbacks->vcpu_set_regs(vcpu); | ||
738 | |||
736 | local_irq_restore(flags); | 739 | local_irq_restore(flags); |
737 | 740 | ||
738 | } | 741 | } |
@@ -751,6 +754,9 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) | |||
751 | vcpu->arch.preempt_entryhi = read_c0_entryhi(); | 754 | vcpu->arch.preempt_entryhi = read_c0_entryhi(); |
752 | vcpu->arch.last_sched_cpu = cpu; | 755 | vcpu->arch.last_sched_cpu = cpu; |
753 | 756 | ||
757 | /* save guest state in registers */ | ||
758 | kvm_mips_callbacks->vcpu_get_regs(vcpu); | ||
759 | |||
754 | if (((cpu_context(cpu, current->mm) ^ asid_cache(cpu)) & | 760 | if (((cpu_context(cpu, current->mm) ^ asid_cache(cpu)) & |
755 | ASID_VERSION_MASK)) { | 761 | ASID_VERSION_MASK)) { |
756 | kvm_debug("%s: Dropping MMU Context: %#lx\n", __func__, | 762 | kvm_debug("%s: Dropping MMU Context: %#lx\n", __func__, |
diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c index 8e0968428a78..0d2729d202f4 100644 --- a/arch/mips/kvm/trap_emul.c +++ b/arch/mips/kvm/trap_emul.c | |||
@@ -552,6 +552,16 @@ static int kvm_trap_emul_set_one_reg(struct kvm_vcpu *vcpu, | |||
552 | return ret; | 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 | static struct kvm_mips_callbacks kvm_trap_emul_callbacks = { | 565 | static struct kvm_mips_callbacks kvm_trap_emul_callbacks = { |
556 | /* exit handlers */ | 566 | /* exit handlers */ |
557 | .handle_cop_unusable = kvm_trap_emul_handle_cop_unusable, | 567 | .handle_cop_unusable = kvm_trap_emul_handle_cop_unusable, |
@@ -578,6 +588,8 @@ static struct kvm_mips_callbacks kvm_trap_emul_callbacks = { | |||
578 | .irq_clear = kvm_mips_irq_clear_cb, | 588 | .irq_clear = kvm_mips_irq_clear_cb, |
579 | .get_one_reg = kvm_trap_emul_get_one_reg, | 589 | .get_one_reg = kvm_trap_emul_get_one_reg, |
580 | .set_one_reg = kvm_trap_emul_set_one_reg, | 590 | .set_one_reg = kvm_trap_emul_set_one_reg, |
591 | .vcpu_get_regs = kvm_trap_emul_vcpu_get_regs, | ||
592 | .vcpu_set_regs = kvm_trap_emul_vcpu_set_regs, | ||
581 | }; | 593 | }; |
582 | 594 | ||
583 | int kvm_mips_emulation_init(struct kvm_mips_callbacks **install_callbacks) | 595 | int kvm_mips_emulation_init(struct kvm_mips_callbacks **install_callbacks) |