Skip to content

Commit a8282bf

Browse files
committed
Merge tag 'powerpc-5.2-5' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: "This is a frustratingly large batch at rc5. Some of these were sent earlier but were missed by me due to being distracted by other things, and some took a while to track down due to needing manual bisection on old hardware. But still we clearly need to improve our testing of KVM, and of 32-bit, so that we catch these earlier. Summary: seven fixes, all for bugs introduced this cycle. - The commit to add KASAN support broke booting on 32-bit SMP machines, due to a refactoring that moved some setup out of the secondary CPU path. - A fix for another 32-bit SMP bug introduced by the fast syscall entry implementation for 32-bit BOOKE. And a build fix for the same commit. - Our change to allow the DAWR to be force enabled on Power9 introduced a bug in KVM, where we clobber r3 leading to a host crash. - The same commit also exposed a previously unreachable bug in the nested KVM handling of DAWR, which could lead to an oops in a nested host. - One of the DMA reworks broke the b43legacy WiFi driver on some people's powermacs, fix it by enabling a 30-bit ZONE_DMA on 32-bit. - A fix for TLB flushing in KVM introduced a new bug, as it neglected to also flush the ERAT, this could lead to memory corruption in the guest. Thanks to: Aaro Koskinen, Christoph Hellwig, Christophe Leroy, Larry Finger, Michael Neuling, Suraj Jitindar Singh" * tag 'powerpc-5.2-5' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: KVM: PPC: Book3S HV: Invalidate ERAT when flushing guest TLB entries powerpc: enable a 30-bit ZONE_DMA for 32-bit pmac KVM: PPC: Book3S HV: Only write DAWR[X] when handling h_set_dawr in real mode KVM: PPC: Book3S HV: Fix r3 corruption in h_set_dabr() powerpc/32: fix build failure on book3e with KVM powerpc/booke: fix fast syscall entry on SMP powerpc/32s: fix initial setup of segment registers on secondary CPU
2 parents 693cd8c + 5008711 commit a8282bf

File tree

8 files changed

+31
-9
lines changed

8 files changed

+31
-9
lines changed

arch/powerpc/include/asm/page.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,13 @@ struct vm_area_struct;
319319
#endif /* __ASSEMBLY__ */
320320
#include <asm/slice.h>
321321

322+
/*
323+
* Allow 30-bit DMA for very limited Broadcom wifi chips on many powerbooks.
324+
*/
325+
#ifdef CONFIG_PPC32
326+
#define ARCH_ZONE_DMA_BITS 30
327+
#else
322328
#define ARCH_ZONE_DMA_BITS 31
329+
#endif
323330

324331
#endif /* _ASM_POWERPC_PAGE_H */

arch/powerpc/kernel/head_32.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ __secondary_start:
752752
stw r0,0(r3)
753753

754754
/* load up the MMU */
755+
bl load_segment_registers
755756
bl load_up_mmu
756757

757758
/* ptr to phys current thread */

arch/powerpc/kernel/head_booke.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ END_BTB_FLUSH_SECTION
8383
SAVE_4GPRS(3, r11); \
8484
SAVE_2GPRS(7, r11)
8585

86-
.macro SYSCALL_ENTRY trapno intno
86+
.macro SYSCALL_ENTRY trapno intno srr1
8787
mfspr r10, SPRN_SPRG_THREAD
8888
#ifdef CONFIG_KVM_BOOKE_HV
8989
BEGIN_FTR_SECTION
@@ -94,7 +94,7 @@ BEGIN_FTR_SECTION
9494
mfspr r11, SPRN_SRR1
9595
mtocrf 0x80, r11 /* check MSR[GS] without clobbering reg */
9696
bf 3, 1975f
97-
b kvmppc_handler_BOOKE_INTERRUPT_\intno\()_SPRN_SRR1
97+
b kvmppc_handler_\intno\()_\srr1
9898
1975:
9999
mr r12, r13
100100
lwz r13, THREAD_NORMSAVE(2)(r10)
@@ -145,9 +145,9 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV)
145145
tophys(r11,r11)
146146
addi r11,r11,global_dbcr0@l
147147
#ifdef CONFIG_SMP
148-
lwz r9,TASK_CPU(r2)
149-
slwi r9,r9,3
150-
add r11,r11,r9
148+
lwz r10, TASK_CPU(r2)
149+
slwi r10, r10, 3
150+
add r11, r11, r10
151151
#endif
152152
lwz r12,0(r11)
153153
mtspr SPRN_DBCR0,r12

arch/powerpc/kernel/head_fsl_booke.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ interrupt_base:
409409

410410
/* System Call Interrupt */
411411
START_EXCEPTION(SystemCall)
412-
SYSCALL_ENTRY 0xc00 SYSCALL
412+
SYSCALL_ENTRY 0xc00 BOOKE_INTERRUPT_SYSCALL SPRN_SRR1
413413

414414
/* Auxiliary Processor Unavailable Interrupt */
415415
EXCEPTION(0x2900, AP_UNAVAIL, AuxillaryProcessorUnavailable, \

arch/powerpc/kvm/book3s_hv_builtin.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,7 @@ static void flush_guest_tlb(struct kvm *kvm)
830830
}
831831
}
832832
asm volatile("ptesync": : :"memory");
833+
asm volatile(PPC_INVALIDATE_ERAT : : :"memory");
833834
}
834835

835836
void kvmppc_check_need_tlb_flush(struct kvm *kvm, int pcpu,

arch/powerpc/kvm/book3s_hv_rmhandlers.S

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,17 +2500,28 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
25002500
LOAD_REG_ADDR(r11, dawr_force_enable)
25012501
lbz r11, 0(r11)
25022502
cmpdi r11, 0
2503+
bne 3f
25032504
li r3, H_HARDWARE
2504-
beqlr
2505+
blr
2506+
3:
25052507
/* Emulate H_SET_DABR/X on P8 for the sake of compat mode guests */
25062508
rlwimi r5, r4, 5, DAWRX_DR | DAWRX_DW
25072509
rlwimi r5, r4, 2, DAWRX_WT
25082510
clrrdi r4, r4, 3
25092511
std r4, VCPU_DAWR(r3)
25102512
std r5, VCPU_DAWRX(r3)
2513+
/*
2514+
* If came in through the real mode hcall handler then it is necessary
2515+
* to write the registers since the return path won't. Otherwise it is
2516+
* sufficient to store then in the vcpu struct as they will be loaded
2517+
* next time the vcpu is run.
2518+
*/
2519+
mfmsr r6
2520+
andi. r6, r6, MSR_DR /* in real mode? */
2521+
bne 4f
25112522
mtspr SPRN_DAWR, r4
25122523
mtspr SPRN_DAWRX, r5
2513-
li r3, 0
2524+
4: li r3, 0
25142525
blr
25152526

25162527
_GLOBAL(kvmppc_h_cede) /* r3 = vcpu pointer, r11 = msr, r13 = paca */

arch/powerpc/mm/mem.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ void __init paging_init(void)
248248
(long int)((top_of_ram - total_ram) >> 20));
249249

250250
#ifdef CONFIG_ZONE_DMA
251-
max_zone_pfns[ZONE_DMA] = min(max_low_pfn, 0x7fffffffUL >> PAGE_SHIFT);
251+
max_zone_pfns[ZONE_DMA] = min(max_low_pfn,
252+
((1UL << ARCH_ZONE_DMA_BITS) - 1) >> PAGE_SHIFT);
252253
#endif
253254
max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
254255
#ifdef CONFIG_HIGHMEM

arch/powerpc/platforms/powermac/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ config PPC_PMAC
77
select PPC_INDIRECT_PCI if PPC32
88
select PPC_MPC106 if PPC32
99
select PPC_NATIVE
10+
select ZONE_DMA if PPC32
1011
default y
1112

1213
config PPC_PMAC64

0 commit comments

Comments
 (0)