diff options
author | Michael Neuling <mikey@neuling.org> | 2014-01-08 05:25:32 -0500 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2014-01-27 10:01:20 -0500 |
commit | 7b490411c37f7ab7965cbdfe5e3ec28eadb6db5b (patch) | |
tree | 04f0462eeb7c6d07b158726fbfa323d9dc68227d | |
parent | 7b37a1232273912dd57cd72b82fe70407bff7683 (diff) |
KVM: PPC: Book3S HV: Add new state for transactional memory
Add new state for transactional memory (TM) to kvm_vcpu_arch. Also add
asm-offset bits that are going to be required.
This also moves the existing TFHAR, TFIAR and TEXASR SPRs into a
CONFIG_PPC_TRANSACTIONAL_MEM section. This requires some code changes to
ensure we still compile with CONFIG_PPC_TRANSACTIONAL_MEM=N. Much of the added
the added #ifdefs are removed in a later patch when the bulk of the TM code is
added.
Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
[agraf: fix merge conflict]
Signed-off-by: Alexander Graf <agraf@suse.de>
-rw-r--r-- | arch/powerpc/include/asm/kvm_host.h | 24 | ||||
-rw-r--r-- | arch/powerpc/kernel/asm-offsets.c | 19 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s_hv.c | 4 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s_hv_rmhandlers.S | 75 |
4 files changed, 114 insertions, 8 deletions
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index 7726a3bc8ff0..1eaea2dea174 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h | |||
@@ -475,9 +475,6 @@ struct kvm_vcpu_arch { | |||
475 | ulong ppr; | 475 | ulong ppr; |
476 | ulong pspb; | 476 | ulong pspb; |
477 | ulong fscr; | 477 | ulong fscr; |
478 | ulong tfhar; | ||
479 | ulong tfiar; | ||
480 | ulong texasr; | ||
481 | ulong ebbhr; | 478 | ulong ebbhr; |
482 | ulong ebbrr; | 479 | ulong ebbrr; |
483 | ulong bescr; | 480 | ulong bescr; |
@@ -526,6 +523,27 @@ struct kvm_vcpu_arch { | |||
526 | u64 siar; | 523 | u64 siar; |
527 | u64 sdar; | 524 | u64 sdar; |
528 | u64 sier; | 525 | u64 sier; |
526 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM | ||
527 | u64 tfhar; | ||
528 | u64 texasr; | ||
529 | u64 tfiar; | ||
530 | |||
531 | u32 cr_tm; | ||
532 | u64 lr_tm; | ||
533 | u64 ctr_tm; | ||
534 | u64 amr_tm; | ||
535 | u64 ppr_tm; | ||
536 | u64 dscr_tm; | ||
537 | u64 tar_tm; | ||
538 | |||
539 | ulong gpr_tm[32]; | ||
540 | |||
541 | struct thread_fp_state fp_tm; | ||
542 | |||
543 | struct thread_vr_state vr_tm; | ||
544 | u32 vrsave_tm; /* also USPRG0 */ | ||
545 | |||
546 | #endif | ||
529 | 547 | ||
530 | #ifdef CONFIG_KVM_EXIT_TIMING | 548 | #ifdef CONFIG_KVM_EXIT_TIMING |
531 | struct mutex exit_timing_lock; | 549 | struct mutex exit_timing_lock; |
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index a60a2fdae5bd..687f2ebf0cce 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c | |||
@@ -521,9 +521,6 @@ int main(void) | |||
521 | DEFINE(VCPU_PPR, offsetof(struct kvm_vcpu, arch.ppr)); | 521 | DEFINE(VCPU_PPR, offsetof(struct kvm_vcpu, arch.ppr)); |
522 | DEFINE(VCPU_FSCR, offsetof(struct kvm_vcpu, arch.fscr)); | 522 | DEFINE(VCPU_FSCR, offsetof(struct kvm_vcpu, arch.fscr)); |
523 | DEFINE(VCPU_PSPB, offsetof(struct kvm_vcpu, arch.pspb)); | 523 | DEFINE(VCPU_PSPB, offsetof(struct kvm_vcpu, arch.pspb)); |
524 | DEFINE(VCPU_TFHAR, offsetof(struct kvm_vcpu, arch.tfhar)); | ||
525 | DEFINE(VCPU_TFIAR, offsetof(struct kvm_vcpu, arch.tfiar)); | ||
526 | DEFINE(VCPU_TEXASR, offsetof(struct kvm_vcpu, arch.texasr)); | ||
527 | DEFINE(VCPU_EBBHR, offsetof(struct kvm_vcpu, arch.ebbhr)); | 524 | DEFINE(VCPU_EBBHR, offsetof(struct kvm_vcpu, arch.ebbhr)); |
528 | DEFINE(VCPU_EBBRR, offsetof(struct kvm_vcpu, arch.ebbrr)); | 525 | DEFINE(VCPU_EBBRR, offsetof(struct kvm_vcpu, arch.ebbrr)); |
529 | DEFINE(VCPU_BESCR, offsetof(struct kvm_vcpu, arch.bescr)); | 526 | DEFINE(VCPU_BESCR, offsetof(struct kvm_vcpu, arch.bescr)); |
@@ -545,6 +542,22 @@ int main(void) | |||
545 | DEFINE(VCPU_SLB_E, offsetof(struct kvmppc_slb, orige)); | 542 | DEFINE(VCPU_SLB_E, offsetof(struct kvmppc_slb, orige)); |
546 | DEFINE(VCPU_SLB_V, offsetof(struct kvmppc_slb, origv)); | 543 | DEFINE(VCPU_SLB_V, offsetof(struct kvmppc_slb, origv)); |
547 | DEFINE(VCPU_SLB_SIZE, sizeof(struct kvmppc_slb)); | 544 | DEFINE(VCPU_SLB_SIZE, sizeof(struct kvmppc_slb)); |
545 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM | ||
546 | DEFINE(VCPU_TFHAR, offsetof(struct kvm_vcpu, arch.tfhar)); | ||
547 | DEFINE(VCPU_TFIAR, offsetof(struct kvm_vcpu, arch.tfiar)); | ||
548 | DEFINE(VCPU_TEXASR, offsetof(struct kvm_vcpu, arch.texasr)); | ||
549 | DEFINE(VCPU_GPR_TM, offsetof(struct kvm_vcpu, arch.gpr_tm)); | ||
550 | DEFINE(VCPU_FPRS_TM, offsetof(struct kvm_vcpu, arch.fp_tm.fpr)); | ||
551 | DEFINE(VCPU_VRS_TM, offsetof(struct kvm_vcpu, arch.vr_tm.vr)); | ||
552 | DEFINE(VCPU_VRSAVE_TM, offsetof(struct kvm_vcpu, arch.vrsave_tm)); | ||
553 | DEFINE(VCPU_CR_TM, offsetof(struct kvm_vcpu, arch.cr_tm)); | ||
554 | DEFINE(VCPU_LR_TM, offsetof(struct kvm_vcpu, arch.lr_tm)); | ||
555 | DEFINE(VCPU_CTR_TM, offsetof(struct kvm_vcpu, arch.ctr_tm)); | ||
556 | DEFINE(VCPU_AMR_TM, offsetof(struct kvm_vcpu, arch.amr_tm)); | ||
557 | DEFINE(VCPU_PPR_TM, offsetof(struct kvm_vcpu, arch.ppr_tm)); | ||
558 | DEFINE(VCPU_DSCR_TM, offsetof(struct kvm_vcpu, arch.dscr_tm)); | ||
559 | DEFINE(VCPU_TAR_TM, offsetof(struct kvm_vcpu, arch.tar_tm)); | ||
560 | #endif | ||
548 | 561 | ||
549 | #ifdef CONFIG_PPC_BOOK3S_64 | 562 | #ifdef CONFIG_PPC_BOOK3S_64 |
550 | #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE | 563 | #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE |
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 3195e4f8a2ed..f4a4c5c82fb2 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c | |||
@@ -875,6 +875,7 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id, | |||
875 | case KVM_REG_PPC_IAMR: | 875 | case KVM_REG_PPC_IAMR: |
876 | *val = get_reg_val(id, vcpu->arch.iamr); | 876 | *val = get_reg_val(id, vcpu->arch.iamr); |
877 | break; | 877 | break; |
878 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM | ||
878 | case KVM_REG_PPC_TFHAR: | 879 | case KVM_REG_PPC_TFHAR: |
879 | *val = get_reg_val(id, vcpu->arch.tfhar); | 880 | *val = get_reg_val(id, vcpu->arch.tfhar); |
880 | break; | 881 | break; |
@@ -884,6 +885,7 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id, | |||
884 | case KVM_REG_PPC_TEXASR: | 885 | case KVM_REG_PPC_TEXASR: |
885 | *val = get_reg_val(id, vcpu->arch.texasr); | 886 | *val = get_reg_val(id, vcpu->arch.texasr); |
886 | break; | 887 | break; |
888 | #endif | ||
887 | case KVM_REG_PPC_FSCR: | 889 | case KVM_REG_PPC_FSCR: |
888 | *val = get_reg_val(id, vcpu->arch.fscr); | 890 | *val = get_reg_val(id, vcpu->arch.fscr); |
889 | break; | 891 | break; |
@@ -1033,6 +1035,7 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id, | |||
1033 | case KVM_REG_PPC_IAMR: | 1035 | case KVM_REG_PPC_IAMR: |
1034 | vcpu->arch.iamr = set_reg_val(id, *val); | 1036 | vcpu->arch.iamr = set_reg_val(id, *val); |
1035 | break; | 1037 | break; |
1038 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM | ||
1036 | case KVM_REG_PPC_TFHAR: | 1039 | case KVM_REG_PPC_TFHAR: |
1037 | vcpu->arch.tfhar = set_reg_val(id, *val); | 1040 | vcpu->arch.tfhar = set_reg_val(id, *val); |
1038 | break; | 1041 | break; |
@@ -1042,6 +1045,7 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id, | |||
1042 | case KVM_REG_PPC_TEXASR: | 1045 | case KVM_REG_PPC_TEXASR: |
1043 | vcpu->arch.texasr = set_reg_val(id, *val); | 1046 | vcpu->arch.texasr = set_reg_val(id, *val); |
1044 | break; | 1047 | break; |
1048 | #endif | ||
1045 | case KVM_REG_PPC_FSCR: | 1049 | case KVM_REG_PPC_FSCR: |
1046 | vcpu->arch.fscr = set_reg_val(id, *val); | 1050 | vcpu->arch.fscr = set_reg_val(id, *val); |
1047 | break; | 1051 | break; |
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S index ecb76357c9d0..dfa144cb199b 100644 --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S | |||
@@ -701,13 +701,15 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) | |||
701 | ld r6, VCPU_VTB(r4) | 701 | ld r6, VCPU_VTB(r4) |
702 | mtspr SPRN_IC, r5 | 702 | mtspr SPRN_IC, r5 |
703 | mtspr SPRN_VTB, r6 | 703 | mtspr SPRN_VTB, r6 |
704 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM | ||
704 | ld r5, VCPU_TFHAR(r4) | 705 | ld r5, VCPU_TFHAR(r4) |
705 | ld r6, VCPU_TFIAR(r4) | 706 | ld r6, VCPU_TFIAR(r4) |
706 | ld r7, VCPU_TEXASR(r4) | 707 | ld r7, VCPU_TEXASR(r4) |
707 | ld r8, VCPU_EBBHR(r4) | ||
708 | mtspr SPRN_TFHAR, r5 | 708 | mtspr SPRN_TFHAR, r5 |
709 | mtspr SPRN_TFIAR, r6 | 709 | mtspr SPRN_TFIAR, r6 |
710 | mtspr SPRN_TEXASR, r7 | 710 | mtspr SPRN_TEXASR, r7 |
711 | #endif | ||
712 | ld r8, VCPU_EBBHR(r4) | ||
711 | mtspr SPRN_EBBHR, r8 | 713 | mtspr SPRN_EBBHR, r8 |
712 | ld r5, VCPU_EBBRR(r4) | 714 | ld r5, VCPU_EBBRR(r4) |
713 | ld r6, VCPU_BESCR(r4) | 715 | ld r6, VCPU_BESCR(r4) |
@@ -1118,13 +1120,15 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) | |||
1118 | std r5, VCPU_IC(r9) | 1120 | std r5, VCPU_IC(r9) |
1119 | std r6, VCPU_VTB(r9) | 1121 | std r6, VCPU_VTB(r9) |
1120 | std r7, VCPU_TAR(r9) | 1122 | std r7, VCPU_TAR(r9) |
1123 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM | ||
1121 | mfspr r5, SPRN_TFHAR | 1124 | mfspr r5, SPRN_TFHAR |
1122 | mfspr r6, SPRN_TFIAR | 1125 | mfspr r6, SPRN_TFIAR |
1123 | mfspr r7, SPRN_TEXASR | 1126 | mfspr r7, SPRN_TEXASR |
1124 | mfspr r8, SPRN_EBBHR | ||
1125 | std r5, VCPU_TFHAR(r9) | 1127 | std r5, VCPU_TFHAR(r9) |
1126 | std r6, VCPU_TFIAR(r9) | 1128 | std r6, VCPU_TFIAR(r9) |
1127 | std r7, VCPU_TEXASR(r9) | 1129 | std r7, VCPU_TEXASR(r9) |
1130 | #endif | ||
1131 | mfspr r8, SPRN_EBBHR | ||
1128 | std r8, VCPU_EBBHR(r9) | 1132 | std r8, VCPU_EBBHR(r9) |
1129 | mfspr r5, SPRN_EBBRR | 1133 | mfspr r5, SPRN_EBBRR |
1130 | mfspr r6, SPRN_BESCR | 1134 | mfspr r6, SPRN_BESCR |
@@ -1497,6 +1501,73 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |||
1497 | 1: addi r8,r8,16 | 1501 | 1: addi r8,r8,16 |
1498 | .endr | 1502 | .endr |
1499 | 1503 | ||
1504 | /* Save DEC */ | ||
1505 | mfspr r5,SPRN_DEC | ||
1506 | mftb r6 | ||
1507 | extsw r5,r5 | ||
1508 | add r5,r5,r6 | ||
1509 | std r5,VCPU_DEC_EXPIRES(r9) | ||
1510 | |||
1511 | BEGIN_FTR_SECTION | ||
1512 | b 8f | ||
1513 | END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) | ||
1514 | /* Turn on TM so we can access TFHAR/TFIAR/TEXASR */ | ||
1515 | mfmsr r8 | ||
1516 | li r0, 1 | ||
1517 | rldimi r8, r0, MSR_TM_LG, 63-MSR_TM_LG | ||
1518 | mtmsrd r8 | ||
1519 | |||
1520 | /* Save POWER8-specific registers */ | ||
1521 | mfspr r5, SPRN_IAMR | ||
1522 | mfspr r6, SPRN_PSPB | ||
1523 | mfspr r7, SPRN_FSCR | ||
1524 | std r5, VCPU_IAMR(r9) | ||
1525 | stw r6, VCPU_PSPB(r9) | ||
1526 | std r7, VCPU_FSCR(r9) | ||
1527 | mfspr r5, SPRN_IC | ||
1528 | mfspr r6, SPRN_VTB | ||
1529 | mfspr r7, SPRN_TAR | ||
1530 | std r5, VCPU_IC(r9) | ||
1531 | std r6, VCPU_VTB(r9) | ||
1532 | std r7, VCPU_TAR(r9) | ||
1533 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM | ||
1534 | mfspr r5, SPRN_TFHAR | ||
1535 | mfspr r6, SPRN_TFIAR | ||
1536 | mfspr r7, SPRN_TEXASR | ||
1537 | std r5, VCPU_TFHAR(r9) | ||
1538 | std r6, VCPU_TFIAR(r9) | ||
1539 | std r7, VCPU_TEXASR(r9) | ||
1540 | #endif | ||
1541 | mfspr r8, SPRN_EBBHR | ||
1542 | std r8, VCPU_EBBHR(r9) | ||
1543 | mfspr r5, SPRN_EBBRR | ||
1544 | mfspr r6, SPRN_BESCR | ||
1545 | mfspr r7, SPRN_CSIGR | ||
1546 | mfspr r8, SPRN_TACR | ||
1547 | std r5, VCPU_EBBRR(r9) | ||
1548 | std r6, VCPU_BESCR(r9) | ||
1549 | std r7, VCPU_CSIGR(r9) | ||
1550 | std r8, VCPU_TACR(r9) | ||
1551 | mfspr r5, SPRN_TCSCR | ||
1552 | mfspr r6, SPRN_ACOP | ||
1553 | mfspr r7, SPRN_PID | ||
1554 | mfspr r8, SPRN_WORT | ||
1555 | std r5, VCPU_TCSCR(r9) | ||
1556 | std r6, VCPU_ACOP(r9) | ||
1557 | stw r7, VCPU_GUEST_PID(r9) | ||
1558 | std r8, VCPU_WORT(r9) | ||
1559 | 8: | ||
1560 | |||
1561 | /* Save and reset AMR and UAMOR before turning on the MMU */ | ||
1562 | BEGIN_FTR_SECTION | ||
1563 | mfspr r5,SPRN_AMR | ||
1564 | mfspr r6,SPRN_UAMOR | ||
1565 | std r5,VCPU_AMR(r9) | ||
1566 | std r6,VCPU_UAMOR(r9) | ||
1567 | li r6,0 | ||
1568 | mtspr SPRN_AMR,r6 | ||
1569 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | ||
1570 | |||
1500 | /* Unset guest mode */ | 1571 | /* Unset guest mode */ |
1501 | li r0, KVM_GUEST_MODE_NONE | 1572 | li r0, KVM_GUEST_MODE_NONE |
1502 | stb r0, HSTATE_IN_GUEST(r13) | 1573 | stb r0, HSTATE_IN_GUEST(r13) |