Skip to content

Commit d66c1e7

Browse files
committed
Merge tag 'powerpc-5.17-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: - Fix VM debug warnings on boot triggered via __set_fixmap(). - Fix a debug warning in the 64-bit Book3S PMU handling code. - Fix nested guest HFSCR handling with multiple vCPUs on Power9 or later. - Fix decrementer storm caused by a recent change, seen with some configs. Thanks to Alexey Kardashevskiy, Athira Rajeev, Christophe Leroy, Fabiano Rosas, Maxime Bizon, Nicholas Piggin, and Sachin Sant. * tag 'powerpc-5.17-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/64s/interrupt: Fix decrementer storm KVM: PPC: Book3S HV Nested: Fix nested HFSCR being clobbered with multiple vCPUs powerpc/perf: Fix power_pmu_disable to call clear_pmi_irq_pending only if PMI is pending powerpc/fixmap: Fix VM debug warning on unmap
2 parents 216e2ae + 8defc2a commit d66c1e7

File tree

12 files changed

+38
-11
lines changed

12 files changed

+38
-11
lines changed

arch/powerpc/include/asm/book3s/32/pgtable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ static inline bool pte_user(pte_t pte)
178178
#ifndef __ASSEMBLY__
179179

180180
int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
181+
void unmap_kernel_page(unsigned long va);
181182

182183
#endif /* !__ASSEMBLY__ */
183184

arch/powerpc/include/asm/book3s/64/pgtable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,8 @@ static inline int map_kernel_page(unsigned long ea, unsigned long pa, pgprot_t p
10821082
return hash__map_kernel_page(ea, pa, prot);
10831083
}
10841084

1085+
void unmap_kernel_page(unsigned long va);
1086+
10851087
static inline int __meminit vmemmap_create_mapping(unsigned long start,
10861088
unsigned long page_size,
10871089
unsigned long phys)

arch/powerpc/include/asm/fixmap.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ static inline void __set_fixmap(enum fixed_addresses idx,
111111
BUILD_BUG_ON(idx >= __end_of_fixed_addresses);
112112
else if (WARN_ON(idx >= __end_of_fixed_addresses))
113113
return;
114-
115-
map_kernel_page(__fix_to_virt(idx), phys, flags);
114+
if (pgprot_val(flags))
115+
map_kernel_page(__fix_to_virt(idx), phys, flags);
116+
else
117+
unmap_kernel_page(__fix_to_virt(idx));
116118
}
117119

118120
#define __early_set_fixmap __set_fixmap

arch/powerpc/include/asm/kvm_book3s_64.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ struct kvm_nested_guest {
3939
pgd_t *shadow_pgtable; /* our page table for this guest */
4040
u64 l1_gr_to_hr; /* L1's addr of part'n-scoped table */
4141
u64 process_table; /* process table entry for this guest */
42-
u64 hfscr; /* HFSCR that the L1 requested for this nested guest */
4342
long refcnt; /* number of pointers to this struct */
4443
struct mutex tlb_lock; /* serialize page faults and tlbies */
4544
struct kvm_nested_guest *next;

arch/powerpc/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ struct kvm_vcpu_arch {
818818

819819
/* For support of nested guests */
820820
struct kvm_nested_guest *nested;
821+
u64 nested_hfscr; /* HFSCR that the L1 requested for the nested guest */
821822
u32 nested_vcpu_id;
822823
gpa_t nested_io_gpr;
823824
#endif

arch/powerpc/include/asm/nohash/32/pgtable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ extern int icache_44x_need_flush;
6464
#ifndef __ASSEMBLY__
6565

6666
int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
67+
void unmap_kernel_page(unsigned long va);
6768

6869
#endif /* !__ASSEMBLY__ */
6970

arch/powerpc/include/asm/nohash/64/pgtable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ static inline void __ptep_set_access_flags(struct vm_area_struct *vma,
308308
#define __swp_entry_to_pte(x) __pte((x).val)
309309

310310
int map_kernel_page(unsigned long ea, unsigned long pa, pgprot_t prot);
311+
void unmap_kernel_page(unsigned long va);
311312
extern int __meminit vmemmap_create_mapping(unsigned long start,
312313
unsigned long page_size,
313314
unsigned long phys);

arch/powerpc/kernel/time.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,9 @@ DEFINE_INTERRUPT_HANDLER_ASYNC(timer_interrupt)
649649
__this_cpu_inc(irq_stat.timer_irqs_event);
650650
} else {
651651
now = *next_tb - now;
652-
if (now <= decrementer_max)
653-
set_dec_or_work(now);
652+
if (now > decrementer_max)
653+
now = decrementer_max;
654+
set_dec_or_work(now);
654655
__this_cpu_inc(irq_stat.timer_irqs_others);
655656
}
656657

arch/powerpc/kvm/book3s_hv.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,7 +1816,6 @@ static int kvmppc_handle_exit_hv(struct kvm_vcpu *vcpu,
18161816

18171817
static int kvmppc_handle_nested_exit(struct kvm_vcpu *vcpu)
18181818
{
1819-
struct kvm_nested_guest *nested = vcpu->arch.nested;
18201819
int r;
18211820
int srcu_idx;
18221821

@@ -1922,7 +1921,7 @@ static int kvmppc_handle_nested_exit(struct kvm_vcpu *vcpu)
19221921
* it into a HEAI.
19231922
*/
19241923
if (!(vcpu->arch.hfscr_permitted & (1UL << cause)) ||
1925-
(nested->hfscr & (1UL << cause))) {
1924+
(vcpu->arch.nested_hfscr & (1UL << cause))) {
19261925
vcpu->arch.trap = BOOK3S_INTERRUPT_H_EMUL_ASSIST;
19271926

19281927
/*

arch/powerpc/kvm/book3s_hv_nested.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu)
363363
/* set L1 state to L2 state */
364364
vcpu->arch.nested = l2;
365365
vcpu->arch.nested_vcpu_id = l2_hv.vcpu_token;
366-
l2->hfscr = l2_hv.hfscr;
366+
vcpu->arch.nested_hfscr = l2_hv.hfscr;
367367
vcpu->arch.regs = l2_regs;
368368

369369
/* Guest must always run with ME enabled, HV disabled. */

arch/powerpc/mm/pgtable.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,15 @@ void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
206206
__set_pte_at(mm, addr, ptep, pte, 0);
207207
}
208208

209+
void unmap_kernel_page(unsigned long va)
210+
{
211+
pmd_t *pmdp = pmd_off_k(va);
212+
pte_t *ptep = pte_offset_kernel(pmdp, va);
213+
214+
pte_clear(&init_mm, va, ptep);
215+
flush_tlb_kernel_range(va, va + PAGE_SIZE);
216+
}
217+
209218
/*
210219
* This is called when relaxing access to a PTE. It's also called in the page
211220
* fault path when we don't hit any of the major fault cases, ie, a minor

arch/powerpc/perf/core-book3s.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,9 +1355,20 @@ static void power_pmu_disable(struct pmu *pmu)
13551355
* Otherwise provide a warning if there is PMI pending, but
13561356
* no counter is found overflown.
13571357
*/
1358-
if (any_pmc_overflown(cpuhw))
1359-
clear_pmi_irq_pending();
1360-
else
1358+
if (any_pmc_overflown(cpuhw)) {
1359+
/*
1360+
* Since power_pmu_disable runs under local_irq_save, it
1361+
* could happen that code hits a PMC overflow without PMI
1362+
* pending in paca. Hence only clear PMI pending if it was
1363+
* set.
1364+
*
1365+
* If a PMI is pending, then MSR[EE] must be disabled (because
1366+
* the masked PMI handler disabling EE). So it is safe to
1367+
* call clear_pmi_irq_pending().
1368+
*/
1369+
if (pmi_irq_pending())
1370+
clear_pmi_irq_pending();
1371+
} else
13611372
WARN_ON(pmi_irq_pending());
13621373

13631374
val = mmcra = cpuhw->mmcr.mmcra;

0 commit comments

Comments
 (0)