diff options
author | Paul Mackerras <paulus@samba.org> | 2012-11-04 13:15:43 -0500 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2012-12-05 19:34:01 -0500 |
commit | b0a94d4e23201c7559bb8f8657cfb629561288f2 (patch) | |
tree | 33a2706900728e9218fca06bde3c8a47fb86254a /arch/powerpc/kvm/book3s_emulate.c | |
parent | 1cc8ed0b13ae6e076a1dd1f18da508b48c7aa05a (diff) |
KVM: PPC: Book3S PR: Emulate PURR, SPURR and DSCR registers
This adds basic emulation of the PURR and SPURR registers. We assume
we are emulating a single-threaded core, so these advance at the same
rate as the timebase. A Linux kernel running on a POWER7 expects to
be able to access these registers and is not prepared to handle a
program interrupt on accessing them.
This also adds a very minimal emulation of the DSCR (data stream
control register). Writes are ignored and reads return zero.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kvm/book3s_emulate.c')
-rw-r--r-- | arch/powerpc/kvm/book3s_emulate.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c index b9a989dc76cc..d31a716f7f2b 100644 --- a/arch/powerpc/kvm/book3s_emulate.c +++ b/arch/powerpc/kvm/book3s_emulate.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <asm/kvm_book3s.h> | 22 | #include <asm/kvm_book3s.h> |
23 | #include <asm/reg.h> | 23 | #include <asm/reg.h> |
24 | #include <asm/switch_to.h> | 24 | #include <asm/switch_to.h> |
25 | #include <asm/time.h> | ||
25 | 26 | ||
26 | #define OP_19_XOP_RFID 18 | 27 | #define OP_19_XOP_RFID 18 |
27 | #define OP_19_XOP_RFI 50 | 28 | #define OP_19_XOP_RFI 50 |
@@ -395,6 +396,12 @@ int kvmppc_core_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val) | |||
395 | (mfmsr() & MSR_HV)) | 396 | (mfmsr() & MSR_HV)) |
396 | vcpu->arch.hflags |= BOOK3S_HFLAG_DCBZ32; | 397 | vcpu->arch.hflags |= BOOK3S_HFLAG_DCBZ32; |
397 | break; | 398 | break; |
399 | case SPRN_PURR: | ||
400 | to_book3s(vcpu)->purr_offset = spr_val - get_tb(); | ||
401 | break; | ||
402 | case SPRN_SPURR: | ||
403 | to_book3s(vcpu)->spurr_offset = spr_val - get_tb(); | ||
404 | break; | ||
398 | case SPRN_GQR0: | 405 | case SPRN_GQR0: |
399 | case SPRN_GQR1: | 406 | case SPRN_GQR1: |
400 | case SPRN_GQR2: | 407 | case SPRN_GQR2: |
@@ -412,6 +419,7 @@ int kvmppc_core_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val) | |||
412 | case SPRN_CTRLF: | 419 | case SPRN_CTRLF: |
413 | case SPRN_CTRLT: | 420 | case SPRN_CTRLT: |
414 | case SPRN_L2CR: | 421 | case SPRN_L2CR: |
422 | case SPRN_DSCR: | ||
415 | case SPRN_MMCR0_GEKKO: | 423 | case SPRN_MMCR0_GEKKO: |
416 | case SPRN_MMCR1_GEKKO: | 424 | case SPRN_MMCR1_GEKKO: |
417 | case SPRN_PMC1_GEKKO: | 425 | case SPRN_PMC1_GEKKO: |
@@ -483,9 +491,15 @@ int kvmppc_core_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val) | |||
483 | *spr_val = to_book3s(vcpu)->hid[5]; | 491 | *spr_val = to_book3s(vcpu)->hid[5]; |
484 | break; | 492 | break; |
485 | case SPRN_CFAR: | 493 | case SPRN_CFAR: |
486 | case SPRN_PURR: | 494 | case SPRN_DSCR: |
487 | *spr_val = 0; | 495 | *spr_val = 0; |
488 | break; | 496 | break; |
497 | case SPRN_PURR: | ||
498 | *spr_val = get_tb() + to_book3s(vcpu)->purr_offset; | ||
499 | break; | ||
500 | case SPRN_SPURR: | ||
501 | *spr_val = get_tb() + to_book3s(vcpu)->purr_offset; | ||
502 | break; | ||
489 | case SPRN_GQR0: | 503 | case SPRN_GQR0: |
490 | case SPRN_GQR1: | 504 | case SPRN_GQR1: |
491 | case SPRN_GQR2: | 505 | case SPRN_GQR2: |