diff options
author | Paul Mackerras <paulus@samba.org> | 2015-03-27 23:21:04 -0400 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2015-04-21 09:21:32 -0400 |
commit | 1f09c3ed86287d40fef90611cbbee055313f52cf (patch) | |
tree | 556fceeb90dab0172d3ecf540782e39e128d1b93 /arch/powerpc | |
parent | d911f0beddc2a9248dbf375fc50a4bbf30947822 (diff) |
KVM: PPC: Book3S HV: Minor cleanups
* Remove unused kvmppc_vcore::n_busy field.
* Remove setting of RMOR, since it was only used on PPC970 and the
PPC970 KVM support has been removed.
* Don't use r1 or r2 in setting the runlatch since they are
conventionally reserved for other things; use r0 instead.
* Streamline the code a little and remove the ext_interrupt_to_host
label.
* Add some comments about register usage.
* hcall_try_real_mode doesn't need to be global, and can't be
called from C code anyway.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/include/asm/kvm_host.h | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/asm-offsets.c | 1 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s_hv_rmhandlers.S | 44 |
3 files changed, 19 insertions, 28 deletions
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index 2f339ff9b851..3eecd8868b01 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h | |||
@@ -227,7 +227,6 @@ struct kvm_arch { | |||
227 | unsigned long host_sdr1; | 227 | unsigned long host_sdr1; |
228 | int tlbie_lock; | 228 | int tlbie_lock; |
229 | unsigned long lpcr; | 229 | unsigned long lpcr; |
230 | unsigned long rmor; | ||
231 | unsigned long vrma_slb_v; | 230 | unsigned long vrma_slb_v; |
232 | int hpte_setup_done; | 231 | int hpte_setup_done; |
233 | u32 hpt_order; | 232 | u32 hpt_order; |
@@ -271,7 +270,6 @@ struct kvm_arch { | |||
271 | */ | 270 | */ |
272 | struct kvmppc_vcore { | 271 | struct kvmppc_vcore { |
273 | int n_runnable; | 272 | int n_runnable; |
274 | int n_busy; | ||
275 | int num_threads; | 273 | int num_threads; |
276 | int entry_exit_count; | 274 | int entry_exit_count; |
277 | int n_woken; | 275 | int n_woken; |
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 3fea721f0da5..92ec3fcb3415 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c | |||
@@ -505,7 +505,6 @@ int main(void) | |||
505 | DEFINE(KVM_NEED_FLUSH, offsetof(struct kvm, arch.need_tlb_flush.bits)); | 505 | DEFINE(KVM_NEED_FLUSH, offsetof(struct kvm, arch.need_tlb_flush.bits)); |
506 | DEFINE(KVM_ENABLED_HCALLS, offsetof(struct kvm, arch.enabled_hcalls)); | 506 | DEFINE(KVM_ENABLED_HCALLS, offsetof(struct kvm, arch.enabled_hcalls)); |
507 | DEFINE(KVM_LPCR, offsetof(struct kvm, arch.lpcr)); | 507 | DEFINE(KVM_LPCR, offsetof(struct kvm, arch.lpcr)); |
508 | DEFINE(KVM_RMOR, offsetof(struct kvm, arch.rmor)); | ||
509 | DEFINE(KVM_VRMA_SLB_V, offsetof(struct kvm, arch.vrma_slb_v)); | 508 | DEFINE(KVM_VRMA_SLB_V, offsetof(struct kvm, arch.vrma_slb_v)); |
510 | DEFINE(VCPU_DSISR, offsetof(struct kvm_vcpu, arch.shregs.dsisr)); | 509 | DEFINE(VCPU_DSISR, offsetof(struct kvm_vcpu, arch.shregs.dsisr)); |
511 | DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar)); | 510 | DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar)); |
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S index b06fe53fd509..f8267e5b3a50 100644 --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S | |||
@@ -245,9 +245,9 @@ kvm_novcpu_exit: | |||
245 | kvm_start_guest: | 245 | kvm_start_guest: |
246 | 246 | ||
247 | /* Set runlatch bit the minute you wake up from nap */ | 247 | /* Set runlatch bit the minute you wake up from nap */ |
248 | mfspr r1, SPRN_CTRLF | 248 | mfspr r0, SPRN_CTRLF |
249 | ori r1, r1, 1 | 249 | ori r0, r0, 1 |
250 | mtspr SPRN_CTRLT, r1 | 250 | mtspr SPRN_CTRLT, r0 |
251 | 251 | ||
252 | ld r2,PACATOC(r13) | 252 | ld r2,PACATOC(r13) |
253 | 253 | ||
@@ -493,11 +493,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |||
493 | cmpwi r0,0 | 493 | cmpwi r0,0 |
494 | beq 20b | 494 | beq 20b |
495 | 495 | ||
496 | /* Set LPCR and RMOR. */ | 496 | /* Set LPCR. */ |
497 | 10: ld r8,VCORE_LPCR(r5) | 497 | 10: ld r8,VCORE_LPCR(r5) |
498 | mtspr SPRN_LPCR,r8 | 498 | mtspr SPRN_LPCR,r8 |
499 | ld r8,KVM_RMOR(r9) | ||
500 | mtspr SPRN_RMOR,r8 | ||
501 | isync | 499 | isync |
502 | 500 | ||
503 | /* Check if HDEC expires soon */ | 501 | /* Check if HDEC expires soon */ |
@@ -1075,7 +1073,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) | |||
1075 | bne 2f | 1073 | bne 2f |
1076 | mfspr r3,SPRN_HDEC | 1074 | mfspr r3,SPRN_HDEC |
1077 | cmpwi r3,0 | 1075 | cmpwi r3,0 |
1078 | bge ignore_hdec | 1076 | mr r4,r9 |
1077 | bge fast_guest_return | ||
1079 | 2: | 1078 | 2: |
1080 | /* See if this is an hcall we can handle in real mode */ | 1079 | /* See if this is an hcall we can handle in real mode */ |
1081 | cmpwi r12,BOOK3S_INTERRUPT_SYSCALL | 1080 | cmpwi r12,BOOK3S_INTERRUPT_SYSCALL |
@@ -1083,26 +1082,21 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) | |||
1083 | 1082 | ||
1084 | /* External interrupt ? */ | 1083 | /* External interrupt ? */ |
1085 | cmpwi r12, BOOK3S_INTERRUPT_EXTERNAL | 1084 | cmpwi r12, BOOK3S_INTERRUPT_EXTERNAL |
1086 | bne+ ext_interrupt_to_host | 1085 | bne+ guest_exit_cont |
1087 | 1086 | ||
1088 | /* External interrupt, first check for host_ipi. If this is | 1087 | /* External interrupt, first check for host_ipi. If this is |
1089 | * set, we know the host wants us out so let's do it now | 1088 | * set, we know the host wants us out so let's do it now |
1090 | */ | 1089 | */ |
1091 | bl kvmppc_read_intr | 1090 | bl kvmppc_read_intr |
1092 | cmpdi r3, 0 | 1091 | cmpdi r3, 0 |
1093 | bgt ext_interrupt_to_host | 1092 | bgt guest_exit_cont |
1094 | 1093 | ||
1095 | /* Check if any CPU is heading out to the host, if so head out too */ | 1094 | /* Check if any CPU is heading out to the host, if so head out too */ |
1096 | ld r5, HSTATE_KVM_VCORE(r13) | 1095 | ld r5, HSTATE_KVM_VCORE(r13) |
1097 | lwz r0, VCORE_ENTRY_EXIT(r5) | 1096 | lwz r0, VCORE_ENTRY_EXIT(r5) |
1098 | cmpwi r0, 0x100 | 1097 | cmpwi r0, 0x100 |
1099 | bge ext_interrupt_to_host | ||
1100 | |||
1101 | /* Return to guest after delivering any pending interrupt */ | ||
1102 | mr r4, r9 | 1098 | mr r4, r9 |
1103 | b deliver_guest_interrupt | 1099 | blt deliver_guest_interrupt |
1104 | |||
1105 | ext_interrupt_to_host: | ||
1106 | 1100 | ||
1107 | guest_exit_cont: /* r9 = vcpu, r12 = trap, r13 = paca */ | 1101 | guest_exit_cont: /* r9 = vcpu, r12 = trap, r13 = paca */ |
1108 | /* Save more register state */ | 1102 | /* Save more register state */ |
@@ -1763,8 +1757,10 @@ kvmppc_hisi: | |||
1763 | * Returns to the guest if we handle it, or continues on up to | 1757 | * Returns to the guest if we handle it, or continues on up to |
1764 | * the kernel if we can't (i.e. if we don't have a handler for | 1758 | * the kernel if we can't (i.e. if we don't have a handler for |
1765 | * it, or if the handler returns H_TOO_HARD). | 1759 | * it, or if the handler returns H_TOO_HARD). |
1760 | * | ||
1761 | * r5 - r8 contain hcall args, | ||
1762 | * r9 = vcpu, r10 = pc, r11 = msr, r12 = trap, r13 = paca | ||
1766 | */ | 1763 | */ |
1767 | .globl hcall_try_real_mode | ||
1768 | hcall_try_real_mode: | 1764 | hcall_try_real_mode: |
1769 | ld r3,VCPU_GPR(R3)(r9) | 1765 | ld r3,VCPU_GPR(R3)(r9) |
1770 | andi. r0,r11,MSR_PR | 1766 | andi. r0,r11,MSR_PR |
@@ -2024,10 +2020,6 @@ hcall_real_table: | |||
2024 | .globl hcall_real_table_end | 2020 | .globl hcall_real_table_end |
2025 | hcall_real_table_end: | 2021 | hcall_real_table_end: |
2026 | 2022 | ||
2027 | ignore_hdec: | ||
2028 | mr r4,r9 | ||
2029 | b fast_guest_return | ||
2030 | |||
2031 | _GLOBAL(kvmppc_h_set_xdabr) | 2023 | _GLOBAL(kvmppc_h_set_xdabr) |
2032 | andi. r0, r5, DABRX_USER | DABRX_KERNEL | 2024 | andi. r0, r5, DABRX_USER | DABRX_KERNEL |
2033 | beq 6f | 2025 | beq 6f |
@@ -2066,7 +2058,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |||
2066 | li r3, 0 | 2058 | li r3, 0 |
2067 | blr | 2059 | blr |
2068 | 2060 | ||
2069 | _GLOBAL(kvmppc_h_cede) | 2061 | _GLOBAL(kvmppc_h_cede) /* r3 = vcpu pointer, r11 = msr, r13 = paca */ |
2070 | ori r11,r11,MSR_EE | 2062 | ori r11,r11,MSR_EE |
2071 | std r11,VCPU_MSR(r3) | 2063 | std r11,VCPU_MSR(r3) |
2072 | li r0,1 | 2064 | li r0,1 |
@@ -2148,9 +2140,9 @@ _GLOBAL(kvmppc_h_cede) | |||
2148 | * runlatch bit before napping. | 2140 | * runlatch bit before napping. |
2149 | */ | 2141 | */ |
2150 | kvm_do_nap: | 2142 | kvm_do_nap: |
2151 | mfspr r2, SPRN_CTRLF | 2143 | mfspr r0, SPRN_CTRLF |
2152 | clrrdi r2, r2, 1 | 2144 | clrrdi r0, r0, 1 |
2153 | mtspr SPRN_CTRLT, r2 | 2145 | mtspr SPRN_CTRLT, r0 |
2154 | 2146 | ||
2155 | li r0,1 | 2147 | li r0,1 |
2156 | stb r0,HSTATE_HWTHREAD_REQ(r13) | 2148 | stb r0,HSTATE_HWTHREAD_REQ(r13) |
@@ -2282,13 +2274,14 @@ machine_check_realmode: | |||
2282 | 2274 | ||
2283 | /* | 2275 | /* |
2284 | * Check the reason we woke from nap, and take appropriate action. | 2276 | * Check the reason we woke from nap, and take appropriate action. |
2285 | * Returns: | 2277 | * Returns (in r3): |
2286 | * 0 if nothing needs to be done | 2278 | * 0 if nothing needs to be done |
2287 | * 1 if something happened that needs to be handled by the host | 2279 | * 1 if something happened that needs to be handled by the host |
2288 | * -1 if there was a guest wakeup (IPI) | 2280 | * -1 if there was a guest wakeup (IPI) |
2289 | * | 2281 | * |
2290 | * Also sets r12 to the interrupt vector for any interrupt that needs | 2282 | * Also sets r12 to the interrupt vector for any interrupt that needs |
2291 | * to be handled now by the host (0x500 for external interrupt), or zero. | 2283 | * to be handled now by the host (0x500 for external interrupt), or zero. |
2284 | * Modifies r0, r6, r7, r8. | ||
2292 | */ | 2285 | */ |
2293 | kvmppc_check_wake_reason: | 2286 | kvmppc_check_wake_reason: |
2294 | mfspr r6, SPRN_SRR1 | 2287 | mfspr r6, SPRN_SRR1 |
@@ -2324,6 +2317,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |||
2324 | * 0 if no interrupt is pending | 2317 | * 0 if no interrupt is pending |
2325 | * 1 if an interrupt is pending that needs to be handled by the host | 2318 | * 1 if an interrupt is pending that needs to be handled by the host |
2326 | * -1 if there was a guest wakeup IPI (which has now been cleared) | 2319 | * -1 if there was a guest wakeup IPI (which has now been cleared) |
2320 | * Modifies r0, r6, r7, r8, returns value in r3. | ||
2327 | */ | 2321 | */ |
2328 | kvmppc_read_intr: | 2322 | kvmppc_read_intr: |
2329 | /* see if a host IPI is pending */ | 2323 | /* see if a host IPI is pending */ |