diff options
author | James Hogan <james.hogan@imgtec.com> | 2016-06-15 14:30:00 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-06-15 17:58:42 -0400 |
commit | e342925f1777f73befda61b48845b0bc88a33181 (patch) | |
tree | b2f7ee9e779acda4c1abc8f533eed72d5e697aa6 /arch/mips/kvm | |
parent | 4b34bca0e4c7091a06d774342faf8c9a4836af22 (diff) |
MIPS: KVM: Report more accurate CP0_Config fields to guest
Initialise the guest's CP0_Config register with a few more bits of
information from the host. The BE bit should be set on big endian
machines, the VI bit should be set on machines with a virtually tagged
instruction cache, and the reported architecture revision should match
that of the host (since we won't support emulating pre-r6 instruction
encodings on r6 or vice versa).
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/mips/kvm')
-rw-r--r-- | arch/mips/kvm/trap_emul.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c index eb191c4612bb..1dc003ddca91 100644 --- a/arch/mips/kvm/trap_emul.c +++ b/arch/mips/kvm/trap_emul.c | |||
@@ -426,7 +426,7 @@ static int kvm_trap_emul_vcpu_init(struct kvm_vcpu *vcpu) | |||
426 | static int kvm_trap_emul_vcpu_setup(struct kvm_vcpu *vcpu) | 426 | static int kvm_trap_emul_vcpu_setup(struct kvm_vcpu *vcpu) |
427 | { | 427 | { |
428 | struct mips_coproc *cop0 = vcpu->arch.cop0; | 428 | struct mips_coproc *cop0 = vcpu->arch.cop0; |
429 | u32 config1; | 429 | u32 config, config1; |
430 | int vcpu_id = vcpu->vcpu_id; | 430 | int vcpu_id = vcpu->vcpu_id; |
431 | 431 | ||
432 | /* | 432 | /* |
@@ -434,10 +434,20 @@ static int kvm_trap_emul_vcpu_setup(struct kvm_vcpu *vcpu) | |||
434 | * guest will come up as expected, for now we simulate a MIPS 24kc | 434 | * guest will come up as expected, for now we simulate a MIPS 24kc |
435 | */ | 435 | */ |
436 | kvm_write_c0_guest_prid(cop0, 0x00019300); | 436 | kvm_write_c0_guest_prid(cop0, 0x00019300); |
437 | /* Have config1, Cacheable, noncoherent, write-back, write allocate */ | 437 | /* |
438 | kvm_write_c0_guest_config(cop0, MIPS_CONF_M | (0x3 << CP0C0_K0) | | 438 | * Have config1, Cacheable, noncoherent, write-back, write allocate. |
439 | (0x1 << CP0C0_AR) | | 439 | * Endianness, arch revision & virtually tagged icache should match |
440 | (MMU_TYPE_R4000 << CP0C0_MT)); | 440 | * host. |
441 | */ | ||
442 | config = read_c0_config() & MIPS_CONF_AR; | ||
443 | config |= MIPS_CONF_M | (0x3 << CP0C0_K0) | | ||
444 | (MMU_TYPE_R4000 << CP0C0_MT); | ||
445 | #ifdef CONFIG_CPU_BIG_ENDIAN | ||
446 | config |= CONF_BE; | ||
447 | #endif | ||
448 | if (cpu_has_vtag_icache) | ||
449 | config |= MIPS_CONF_VI; | ||
450 | kvm_write_c0_guest_config(cop0, config); | ||
441 | 451 | ||
442 | /* Read the cache characteristics from the host Config1 Register */ | 452 | /* Read the cache characteristics from the host Config1 Register */ |
443 | config1 = (read_c0_config1() & ~0x7f); | 453 | config1 = (read_c0_config1() & ~0x7f); |