diff options
Diffstat (limited to 'arch/powerpc/kvm/book3s_hv_rmhandlers.S')
-rw-r--r-- | arch/powerpc/kvm/book3s_hv_rmhandlers.S | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S index 12d7e4c8dc54..16719af88bcc 100644 --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S | |||
@@ -172,6 +172,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |||
172 | 172 | ||
173 | kvmppc_primary_no_guest: | 173 | kvmppc_primary_no_guest: |
174 | /* We handle this much like a ceded vcpu */ | 174 | /* We handle this much like a ceded vcpu */ |
175 | /* put the HDEC into the DEC, since HDEC interrupts don't wake us */ | ||
176 | mfspr r3, SPRN_HDEC | ||
177 | mtspr SPRN_DEC, r3 | ||
175 | /* set our bit in napping_threads */ | 178 | /* set our bit in napping_threads */ |
176 | ld r5, HSTATE_KVM_VCORE(r13) | 179 | ld r5, HSTATE_KVM_VCORE(r13) |
177 | lbz r7, HSTATE_PTID(r13) | 180 | lbz r7, HSTATE_PTID(r13) |
@@ -223,6 +226,12 @@ kvm_novcpu_wakeup: | |||
223 | cmpdi r3, 0 | 226 | cmpdi r3, 0 |
224 | bge kvm_novcpu_exit | 227 | bge kvm_novcpu_exit |
225 | 228 | ||
229 | /* See if our timeslice has expired (HDEC is negative) */ | ||
230 | mfspr r0, SPRN_HDEC | ||
231 | li r12, BOOK3S_INTERRUPT_HV_DECREMENTER | ||
232 | cmpwi r0, 0 | ||
233 | blt kvm_novcpu_exit | ||
234 | |||
226 | /* Got an IPI but other vcpus aren't yet exiting, must be a latecomer */ | 235 | /* Got an IPI but other vcpus aren't yet exiting, must be a latecomer */ |
227 | ld r4, HSTATE_KVM_VCPU(r13) | 236 | ld r4, HSTATE_KVM_VCPU(r13) |
228 | cmpdi r4, 0 | 237 | cmpdi r4, 0 |
@@ -1493,10 +1502,10 @@ kvmhv_do_exit: /* r12 = trap, r13 = paca */ | |||
1493 | cmpwi r3,0x100 /* Are we the first here? */ | 1502 | cmpwi r3,0x100 /* Are we the first here? */ |
1494 | bge 43f | 1503 | bge 43f |
1495 | cmpwi r12,BOOK3S_INTERRUPT_HV_DECREMENTER | 1504 | cmpwi r12,BOOK3S_INTERRUPT_HV_DECREMENTER |
1496 | beq 40f | 1505 | beq 43f |
1497 | li r0,0 | 1506 | li r0,0 |
1498 | mtspr SPRN_HDEC,r0 | 1507 | mtspr SPRN_HDEC,r0 |
1499 | 40: | 1508 | |
1500 | /* | 1509 | /* |
1501 | * Send an IPI to any napping threads, since an HDEC interrupt | 1510 | * Send an IPI to any napping threads, since an HDEC interrupt |
1502 | * doesn't wake CPUs up from nap. | 1511 | * doesn't wake CPUs up from nap. |
@@ -2124,6 +2133,27 @@ _GLOBAL(kvmppc_h_cede) /* r3 = vcpu pointer, r11 = msr, r13 = paca */ | |||
2124 | /* save FP state */ | 2133 | /* save FP state */ |
2125 | bl kvmppc_save_fp | 2134 | bl kvmppc_save_fp |
2126 | 2135 | ||
2136 | /* | ||
2137 | * Set DEC to the smaller of DEC and HDEC, so that we wake | ||
2138 | * no later than the end of our timeslice (HDEC interrupts | ||
2139 | * don't wake us from nap). | ||
2140 | */ | ||
2141 | mfspr r3, SPRN_DEC | ||
2142 | mfspr r4, SPRN_HDEC | ||
2143 | mftb r5 | ||
2144 | cmpw r3, r4 | ||
2145 | ble 67f | ||
2146 | mtspr SPRN_DEC, r4 | ||
2147 | 67: | ||
2148 | /* save expiry time of guest decrementer */ | ||
2149 | extsw r3, r3 | ||
2150 | add r3, r3, r5 | ||
2151 | ld r4, HSTATE_KVM_VCPU(r13) | ||
2152 | ld r5, HSTATE_KVM_VCORE(r13) | ||
2153 | ld r6, VCORE_TB_OFFSET(r5) | ||
2154 | subf r3, r6, r3 /* convert to host TB value */ | ||
2155 | std r3, VCPU_DEC_EXPIRES(r4) | ||
2156 | |||
2127 | #ifdef CONFIG_KVM_BOOK3S_HV_EXIT_TIMING | 2157 | #ifdef CONFIG_KVM_BOOK3S_HV_EXIT_TIMING |
2128 | ld r4, HSTATE_KVM_VCPU(r13) | 2158 | ld r4, HSTATE_KVM_VCPU(r13) |
2129 | addi r3, r4, VCPU_TB_CEDE | 2159 | addi r3, r4, VCPU_TB_CEDE |
@@ -2181,6 +2211,15 @@ kvm_end_cede: | |||
2181 | /* load up FP state */ | 2211 | /* load up FP state */ |
2182 | bl kvmppc_load_fp | 2212 | bl kvmppc_load_fp |
2183 | 2213 | ||
2214 | /* Restore guest decrementer */ | ||
2215 | ld r3, VCPU_DEC_EXPIRES(r4) | ||
2216 | ld r5, HSTATE_KVM_VCORE(r13) | ||
2217 | ld r6, VCORE_TB_OFFSET(r5) | ||
2218 | add r3, r3, r6 /* convert host TB to guest TB value */ | ||
2219 | mftb r7 | ||
2220 | subf r3, r7, r3 | ||
2221 | mtspr SPRN_DEC, r3 | ||
2222 | |||
2184 | /* Load NV GPRS */ | 2223 | /* Load NV GPRS */ |
2185 | ld r14, VCPU_GPR(R14)(r4) | 2224 | ld r14, VCPU_GPR(R14)(r4) |
2186 | ld r15, VCPU_GPR(R15)(r4) | 2225 | ld r15, VCPU_GPR(R15)(r4) |