Skip to content

Commit 0e93b4b

Browse files
committed
Merge git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull kvm powerpc fixes from Marcelo Tosatti: "Urgent KVM PPC updates, quoting Alexander Graf: There are a few bugs in 3.4 that really should be fixed before people can be all happy and fuzzy about KVM on PowerPC. These fixes are: * fix POWER7 bare metal with PR=y * fix deadlock on HV=y book3s_64 mode in low memory cases * fix invalid MMU scope of PR=y mode on book3s_64, possibly eading to memory corruption" * git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: PPC: Book3S HV: Fix bug leading to deadlock in guest HPT updates powerpc/kvm: Fix VSID usage in 64-bit "PR" KVM KVM: PPC: Book3S: PR: Fix hsrr code KVM: PPC: Fix PR KVM on POWER7 bare metal KVM: PPC: Book3S: PR: Handle EMUL_ASSIST
2 parents b724cc1 + 51bfd29 commit 0e93b4b

File tree

4 files changed

+40
-23
lines changed

4 files changed

+40
-23
lines changed

arch/powerpc/include/asm/kvm_book3s.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,13 @@ struct kvmppc_vcpu_book3s {
8181
u64 sdr1;
8282
u64 hior;
8383
u64 msr_mask;
84-
u64 vsid_next;
8584
#ifdef CONFIG_PPC_BOOK3S_32
8685
u32 vsid_pool[VSID_POOL_SIZE];
86+
u32 vsid_next;
8787
#else
88-
u64 vsid_first;
89-
u64 vsid_max;
88+
u64 proto_vsid_first;
89+
u64 proto_vsid_max;
90+
u64 proto_vsid_next;
9091
#endif
9192
int context_id[SID_CONTEXTS];
9293

arch/powerpc/kvm/book3s_64_mmu_host.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,14 @@ static struct kvmppc_sid_map *create_sid_map(struct kvm_vcpu *vcpu, u64 gvsid)
194194
backwards_map = !backwards_map;
195195

196196
/* Uh-oh ... out of mappings. Let's flush! */
197-
if (vcpu_book3s->vsid_next == vcpu_book3s->vsid_max) {
198-
vcpu_book3s->vsid_next = vcpu_book3s->vsid_first;
197+
if (vcpu_book3s->proto_vsid_next == vcpu_book3s->proto_vsid_max) {
198+
vcpu_book3s->proto_vsid_next = vcpu_book3s->proto_vsid_first;
199199
memset(vcpu_book3s->sid_map, 0,
200200
sizeof(struct kvmppc_sid_map) * SID_MAP_NUM);
201201
kvmppc_mmu_pte_flush(vcpu, 0, 0);
202202
kvmppc_mmu_flush_segments(vcpu);
203203
}
204-
map->host_vsid = vcpu_book3s->vsid_next++;
204+
map->host_vsid = vsid_scramble(vcpu_book3s->proto_vsid_next++, 256M);
205205

206206
map->guest_vsid = gvsid;
207207
map->valid = true;
@@ -319,9 +319,10 @@ int kvmppc_mmu_init(struct kvm_vcpu *vcpu)
319319
return -1;
320320
vcpu3s->context_id[0] = err;
321321

322-
vcpu3s->vsid_max = ((vcpu3s->context_id[0] + 1) << USER_ESID_BITS) - 1;
323-
vcpu3s->vsid_first = vcpu3s->context_id[0] << USER_ESID_BITS;
324-
vcpu3s->vsid_next = vcpu3s->vsid_first;
322+
vcpu3s->proto_vsid_max = ((vcpu3s->context_id[0] + 1)
323+
<< USER_ESID_BITS) - 1;
324+
vcpu3s->proto_vsid_first = vcpu3s->context_id[0] << USER_ESID_BITS;
325+
vcpu3s->proto_vsid_next = vcpu3s->proto_vsid_first;
325326

326327
kvmppc_mmu_hpte_init(vcpu);
327328

arch/powerpc/kvm/book3s_hv_rm_mmu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ long kvmppc_h_bulk_remove(struct kvm_vcpu *vcpu)
463463
/* insert R and C bits from PTE */
464464
rcbits = rev->guest_rpte & (HPTE_R_R|HPTE_R_C);
465465
args[j] |= rcbits << (56 - 5);
466+
hp[0] = 0;
466467
continue;
467468
}
468469

arch/powerpc/kvm/book3s_segment.S

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ kvmppc_interrupt:
197197
/* Save guest PC and MSR */
198198
#ifdef CONFIG_PPC64
199199
BEGIN_FTR_SECTION
200-
andi. r0,r12,0x2
200+
andi. r0, r12, 0x2
201+
cmpwi cr1, r0, 0
201202
beq 1f
202203
mfspr r3,SPRN_HSRR0
203204
mfspr r4,SPRN_HSRR1
@@ -250,6 +251,12 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
250251
beq ld_last_prev_inst
251252
cmpwi r12, BOOK3S_INTERRUPT_ALIGNMENT
252253
beq- ld_last_inst
254+
#ifdef CONFIG_PPC64
255+
BEGIN_FTR_SECTION
256+
cmpwi r12, BOOK3S_INTERRUPT_H_EMUL_ASSIST
257+
beq- ld_last_inst
258+
END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
259+
#endif
253260

254261
b no_ld_last_inst
255262

@@ -316,23 +323,17 @@ no_dcbz32_off:
316323
* Having set up SRR0/1 with the address where we want
317324
* to continue with relocation on (potentially in module
318325
* space), we either just go straight there with rfi[d],
319-
* or we jump to an interrupt handler with bctr if there
320-
* is an interrupt to be handled first. In the latter
321-
* case, the rfi[d] at the end of the interrupt handler
322-
* will get us back to where we want to continue.
326+
* or we jump to an interrupt handler if there is an
327+
* interrupt to be handled first. In the latter case,
328+
* the rfi[d] at the end of the interrupt handler will
329+
* get us back to where we want to continue.
323330
*/
324331

325-
cmpwi r12, BOOK3S_INTERRUPT_EXTERNAL
326-
beq 1f
327-
cmpwi r12, BOOK3S_INTERRUPT_DECREMENTER
328-
beq 1f
329-
cmpwi r12, BOOK3S_INTERRUPT_PERFMON
330-
1: mtctr r12
331-
332332
/* Register usage at this point:
333333
*
334334
* R1 = host R1
335335
* R2 = host R2
336+
* R10 = raw exit handler id
336337
* R12 = exit handler id
337338
* R13 = shadow vcpu (32-bit) or PACA (64-bit)
338339
* SVCPU.* = guest *
@@ -342,12 +343,25 @@ no_dcbz32_off:
342343
PPC_LL r6, HSTATE_HOST_MSR(r13)
343344
PPC_LL r8, HSTATE_VMHANDLER(r13)
344345

345-
/* Restore host msr -> SRR1 */
346+
#ifdef CONFIG_PPC64
347+
BEGIN_FTR_SECTION
348+
beq cr1, 1f
349+
mtspr SPRN_HSRR1, r6
350+
mtspr SPRN_HSRR0, r8
351+
END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
352+
#endif
353+
1: /* Restore host msr -> SRR1 */
346354
mtsrr1 r6
347355
/* Load highmem handler address */
348356
mtsrr0 r8
349357

350358
/* RFI into the highmem handler, or jump to interrupt handler */
351-
beqctr
359+
cmpwi r12, BOOK3S_INTERRUPT_EXTERNAL
360+
beqa BOOK3S_INTERRUPT_EXTERNAL
361+
cmpwi r12, BOOK3S_INTERRUPT_DECREMENTER
362+
beqa BOOK3S_INTERRUPT_DECREMENTER
363+
cmpwi r12, BOOK3S_INTERRUPT_PERFMON
364+
beqa BOOK3S_INTERRUPT_PERFMON
365+
352366
RFI
353367
kvmppc_handler_trampoline_exit_end:

0 commit comments

Comments
 (0)