Bogus struct page layout on 32-bit

2021-04-09 Thread Matthew Wilcox
On Sat, Apr 10, 2021 at 06:45:35AM +0800, kernel test robot wrote:
> >> include/linux/mm_types.h:274:1: error: static_assert failed due to 
> >> requirement '__builtin_offsetof(struct page, lru) == 
> >> __builtin_offsetof(struct folio, lru)' "offsetof(struct page, lru) == 
> >> offsetof(struct folio, lru)"
>FOLIO_MATCH(lru, lru);
>include/linux/mm_types.h:272:2: note: expanded from macro 'FOLIO_MATCH'
>static_assert(offsetof(struct page, pg) == offsetof(struct folio, 
> fl))

Well, this is interesting.  pahole reports:

struct page {
long unsigned int  flags;/* 0 4 */
/* XXX 4 bytes hole, try to pack */
union {
struct {
struct list_head lru;/* 8 8 */
...
struct folio {
union {
struct {
long unsigned int flags; /* 0 4 */
struct list_head lru;/* 4 8 */

so this assert has absolutely done its job.

But why has this assert triggered?  Why is struct page layout not what
we thought it was?  Turns out it's the dma_addr added in 2019 by commit
c25fff7171be ("mm: add dma_addr_t to struct page").  On this particular
config, it's 64-bit, and ppc32 requires alignment to 64-bit.  So
the whole union gets moved out by 4 bytes.

Unfortunately, we can't just fix this by putting an 'unsigned long pad'
in front of it.  It still aligns the entire union to 8 bytes, and then
it skips another 4 bytes after the pad.

We can fix it like this ...

+++ b/include/linux/mm_types.h
@@ -96,11 +96,12 @@ struct page {
unsigned long private;
};
struct {/* page_pool used by netstack */
+   unsigned long _page_pool_pad;
/**
 * @dma_addr: might require a 64-bit value even on
 * 32-bit architectures.
 */
-   dma_addr_t dma_addr;
+   dma_addr_t dma_addr __packed;
};
struct {/* slab, slob and slub */
union {

but I don't know if GCC is smart enough to realise that dma_addr is now
on an 8 byte boundary and it can use a normal instruction to access it,
or whether it'll do something daft like use byte loads to access it.

We could also do:

+   dma_addr_t dma_addr __packed __aligned(sizeof(void *));

and I see pahole, at least sees this correctly:

struct {
long unsigned int _page_pool_pad; /* 4 4 */
dma_addr_t dma_addr __attribute__((__aligned__(4))); /* 
8 8 */
} __attribute__((__packed__)) __attribute__((__aligned__(4)));  

This presumably affects any 32-bit architecture with a 64-bit phys_addr_t
/ dma_addr_t.  Advice, please?


Re: [PATCH v6 32/48] KVM: PPC: Book3S HV P9: Read machine check registers while MSR[RI] is 0

2021-04-09 Thread Nicholas Piggin
Excerpts from Alexey Kardashevskiy's message of April 9, 2021 6:55 pm:
> 
> 
> On 05/04/2021 11:19, Nicholas Piggin wrote:
>> SRR0/1, DAR, DSISR must all be protected from machine check which can
>> clobber them. Ensure MSR[RI] is clear while they are live.
>> 
>> Signed-off-by: Nicholas Piggin 
>> ---
>>   arch/powerpc/kvm/book3s_hv.c   | 11 +++--
>>   arch/powerpc/kvm/book3s_hv_interrupt.c | 33 +++---
>>   arch/powerpc/kvm/book3s_hv_ras.c   |  2 ++
>>   3 files changed, 41 insertions(+), 5 deletions(-)
>> 
>> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
>> index d6eecedaa5a5..5f0ac6567a06 100644
>> --- a/arch/powerpc/kvm/book3s_hv.c
>> +++ b/arch/powerpc/kvm/book3s_hv.c
>> @@ -3567,11 +3567,16 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu 
>> *vcpu, u64 time_limit,
>>  mtspr(SPRN_BESCR, vcpu->arch.bescr);
>>  mtspr(SPRN_WORT, vcpu->arch.wort);
>>  mtspr(SPRN_TIDR, vcpu->arch.tid);
>> -mtspr(SPRN_DAR, vcpu->arch.shregs.dar);
>> -mtspr(SPRN_DSISR, vcpu->arch.shregs.dsisr);
>>  mtspr(SPRN_AMR, vcpu->arch.amr);
>>  mtspr(SPRN_UAMOR, vcpu->arch.uamor);
>>   
>> +/*
>> + * DAR, DSISR, and for nested HV, SPRGs must be set with MSR[RI]
>> + * clear (or hstate set appropriately to catch those registers
>> + * being clobbered if we take a MCE or SRESET), so those are done
>> + * later.
>> + */
>> +
>>  if (!(vcpu->arch.ctrl & 1))
>>  mtspr(SPRN_CTRLT, mfspr(SPRN_CTRLF) & ~1);
>>   
>> @@ -3614,6 +3619,8 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, 
>> u64 time_limit,
>>  hvregs.vcpu_token = vcpu->vcpu_id;
>>  }
>>  hvregs.hdec_expiry = time_limit;
>> +mtspr(SPRN_DAR, vcpu->arch.shregs.dar);
>> +mtspr(SPRN_DSISR, vcpu->arch.shregs.dsisr);
>>  trap = plpar_hcall_norets(H_ENTER_NESTED, __pa(),
>>__pa(>arch.regs));
>>  kvmhv_restore_hv_return_state(vcpu, );
>> diff --git a/arch/powerpc/kvm/book3s_hv_interrupt.c 
>> b/arch/powerpc/kvm/book3s_hv_interrupt.c
>> index 6fdd93936e16..e93d2a6456ff 100644
>> --- a/arch/powerpc/kvm/book3s_hv_interrupt.c
>> +++ b/arch/powerpc/kvm/book3s_hv_interrupt.c
>> @@ -132,6 +132,7 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 
>> time_limit, unsigned long lpc
>>  s64 hdec;
>>  u64 tb, purr, spurr;
>>  u64 *exsave;
>> +bool ri_set;
>>  unsigned long msr = mfmsr();
>>  int trap;
>>  unsigned long host_hfscr = mfspr(SPRN_HFSCR);
>> @@ -203,9 +204,6 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 
>> time_limit, unsigned long lpc
>>   */
>>  mtspr(SPRN_HDEC, hdec);
>>   
>> -mtspr(SPRN_SRR0, vcpu->arch.shregs.srr0);
>> -mtspr(SPRN_SRR1, vcpu->arch.shregs.srr1);
>> -
>>  start_timing(vcpu, >arch.rm_entry);
>>   
>>  vcpu->arch.ceded = 0;
>> @@ -231,6 +229,13 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 
>> time_limit, unsigned long lpc
>>   */
>>  mtspr(SPRN_HDSISR, HDSISR_CANARY);
>>   
>> +__mtmsrd(0, 1); /* clear RI */
>> +
>> +mtspr(SPRN_DAR, vcpu->arch.shregs.dar);
>> +mtspr(SPRN_DSISR, vcpu->arch.shregs.dsisr);
>> +mtspr(SPRN_SRR0, vcpu->arch.shregs.srr0);
>> +mtspr(SPRN_SRR1, vcpu->arch.shregs.srr1);
>> +
>>  accumulate_time(vcpu, >arch.guest_time);
>>   
>>  local_paca->kvm_hstate.in_guest = KVM_GUEST_MODE_GUEST_HV_FAST;
>> @@ -248,7 +253,13 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 
>> time_limit, unsigned long lpc
>>   
>>  /* 0x2 bit for HSRR is only used by PR and P7/8 HV paths, clear it */
>>  trap = local_paca->kvm_hstate.scratch0 & ~0x2;
>> +
>> +/* HSRR interrupts leave MSR[RI] unchanged, SRR interrupts clear it. */
>> +ri_set = false;
>>  if (likely(trap > BOOK3S_INTERRUPT_MACHINE_CHECK)) {
>> +if (trap != BOOK3S_INTERRUPT_SYSCALL &&
>> +(vcpu->arch.shregs.msr & MSR_RI))
>> +ri_set = true;
>>  exsave = local_paca->exgen;
>>  } else if (trap == BOOK3S_INTERRUPT_SYSTEM_RESET) {
>>  exsave = local_paca->exnmi;
>> @@ -258,6 +269,22 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 
>> time_limit, unsigned long lpc
>>   
>>  vcpu->arch.regs.gpr[1] = local_paca->kvm_hstate.scratch1;
>>  vcpu->arch.regs.gpr[3] = local_paca->kvm_hstate.scratch2;
>> +
>> +/*
>> + * Only set RI after reading machine check regs (DAR, DSISR, SRR0/1)
>> + * and hstate scratch (which we need to move into exsave to make
>> + * re-entrant vs SRESET/MCE)
>> + */
>> +if (ri_set) {
>> +if (unlikely(!(mfmsr() & MSR_RI))) {
>> +__mtmsrd(MSR_RI, 1);
>> +WARN_ON_ONCE(1);
>> +}
>> +} else {
>> +WARN_ON_ONCE(mfmsr() & MSR_RI);
>> +__mtmsrd(MSR_RI, 1);
>> +}
>> +
>>  

Re: [PATCH v6 30/48] KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C

2021-04-09 Thread Nicholas Piggin
Excerpts from Alexey Kardashevskiy's message of April 9, 2021 1:57 pm:
> 
> 
> On 05/04/2021 11:19, Nicholas Piggin wrote:
>> Almost all logic is moved to C, by introducing a new in_guest mode for
>> the P9 path that branches very early in the KVM interrupt handler to
>> P9 exit code.
>> 
>> The main P9 entry and exit assembly is now only about 160 lines of low
>> level stack setup and register save/restore, plus a bad-interrupt
>> handler.
>> 
>> There are two motivations for this, the first is just make the code more
>> maintainable being in C. The second is to reduce the amount of code
>> running in a special KVM mode, "realmode". In quotes because with radix
>> it is no longer necessarily real-mode in the MMU, but it still has to be
>> treated specially because it may be in real-mode, and has various
>> important registers like PID, DEC, TB, etc set to guest. This is hostile
>> to the rest of Linux and can't use arbitrary kernel functionality or be
>> instrumented well.
>> 
>> This initial patch is a reasonably faithful conversion of the asm code,
>> but it does lack any loop to return quickly back into the guest without
>> switching out of realmode in the case of unimportant or easily handled
>> interrupts. As explained in previous changes, handling HV interrupts
>> in real mode is not so important for P9.
>> 
>> Use of Linux 64s interrupt entry code register conventions including
>> paca EX_ save areas are brought into the KVM code. There is no point
>> shuffling things into different paca save areas and making up a
>> different calling convention for KVM.
>> 
>> Signed-off-by: Nicholas Piggin 
>> ---
>>   arch/powerpc/include/asm/asm-prototypes.h |   3 +-
>>   arch/powerpc/include/asm/kvm_asm.h|   3 +-
>>   arch/powerpc/include/asm/kvm_book3s_64.h  |   8 +
>>   arch/powerpc/include/asm/kvm_host.h   |   7 +-
>>   arch/powerpc/kernel/security.c|   5 +-
>>   arch/powerpc/kvm/Makefile |   1 +
>>   arch/powerpc/kvm/book3s_64_entry.S| 247 ++
>>   arch/powerpc/kvm/book3s_hv.c  |   9 +-
>>   arch/powerpc/kvm/book3s_hv_interrupt.c| 218 +++
>>   arch/powerpc/kvm/book3s_hv_rmhandlers.S   | 125 +--
>>   10 files changed, 501 insertions(+), 125 deletions(-)
>>   create mode 100644 arch/powerpc/kvm/book3s_hv_interrupt.c
>> 
>> diff --git a/arch/powerpc/include/asm/asm-prototypes.h 
>> b/arch/powerpc/include/asm/asm-prototypes.h
>> index 939f3c94c8f3..7c74c80ed994 100644
>> --- a/arch/powerpc/include/asm/asm-prototypes.h
>> +++ b/arch/powerpc/include/asm/asm-prototypes.h
>> @@ -122,6 +122,7 @@ extern s32 patch__call_flush_branch_caches3;
>>   extern s32 patch__flush_count_cache_return;
>>   extern s32 patch__flush_link_stack_return;
>>   extern s32 patch__call_kvm_flush_link_stack;
>> +extern s32 patch__call_kvm_flush_link_stack_p9;
>>   extern s32 patch__memset_nocache, patch__memcpy_nocache;
>>   
>>   extern long flush_branch_caches;
>> @@ -142,7 +143,7 @@ void kvmhv_load_host_pmu(void);
>>   void kvmhv_save_guest_pmu(struct kvm_vcpu *vcpu, bool pmu_in_use);
>>   void kvmhv_load_guest_pmu(struct kvm_vcpu *vcpu);
>>   
>> -int __kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu);
>> +void kvmppc_p9_enter_guest(struct kvm_vcpu *vcpu);
>>   
>>   long kvmppc_h_set_dabr(struct kvm_vcpu *vcpu, unsigned long dabr);
>>   long kvmppc_h_set_xdabr(struct kvm_vcpu *vcpu, unsigned long dabr,
>> diff --git a/arch/powerpc/include/asm/kvm_asm.h 
>> b/arch/powerpc/include/asm/kvm_asm.h
>> index a3633560493b..b4f9996bd331 100644
>> --- a/arch/powerpc/include/asm/kvm_asm.h
>> +++ b/arch/powerpc/include/asm/kvm_asm.h
>> @@ -146,7 +146,8 @@
>>   #define KVM_GUEST_MODE_GUEST   1
>>   #define KVM_GUEST_MODE_SKIP2
>>   #define KVM_GUEST_MODE_GUEST_HV3
>> -#define KVM_GUEST_MODE_HOST_HV  4
>> +#define KVM_GUEST_MODE_GUEST_HV_FAST4 /* ISA v3.0 with host radix 
>> mode */
>> +#define KVM_GUEST_MODE_HOST_HV  5
>>   
>>   #define KVM_INST_FETCH_FAILED  -1
>>   
>> diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h 
>> b/arch/powerpc/include/asm/kvm_book3s_64.h
>> index 9bb9bb370b53..c214bcffb441 100644
>> --- a/arch/powerpc/include/asm/kvm_book3s_64.h
>> +++ b/arch/powerpc/include/asm/kvm_book3s_64.h
>> @@ -153,9 +153,17 @@ static inline bool kvmhv_vcpu_is_radix(struct kvm_vcpu 
>> *vcpu)
>>  return radix;
>>   }
>>   
>> +int __kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu);
>> +
>>   #define KVM_DEFAULT_HPT_ORDER  24  /* 16MB HPT by default */
>>   #endif
>>   
>> +/*
>> + * Invalid HDSISR value which is used to indicate when HW has not set the 
>> reg.
>> + * Used to work around an errata.
>> + */
>> +#define HDSISR_CANARY   0x7fff
>> +
>>   /*
>>* We use a lock bit in HPTE dword 0 to synchronize updates and
>>* accesses to each HPTE, and another bit to indicate non-present
>> diff --git a/arch/powerpc/include/asm/kvm_host.h 
>> b/arch/powerpc/include/asm/kvm_host.h
>> index 

Re: [PATCH v4] powerpc/traps: Enhance readability for trap types

2021-04-09 Thread Nicholas Piggin
Thanks for working on this, I think it's a nice cleanup and helps
non-powerpc people understand the code a bit better.

Excerpts from Xiongwei Song's message of April 10, 2021 12:28 am:
> From: Xiongwei Song 
> 
> Create a new header named traps.h, define macros to list ppc interrupt
> types in traps.h, replace the references of the trap hex values with these
> macros.
> 
> Referred the hex numbers in arch/powerpc/kernel/exceptions-64e.S,
> arch/powerpc/kernel/exceptions-64s.S and
> arch/powerpc/include/asm/kvm_asm.h.
> 
> Reported-by: kernel test robot 

It now looks like lkp asked for this whole cleanup patch. I would
put [kernel test robot ] in your v3->4 changelog
item.

> Signed-off-by: Xiongwei Song 
> ---
> 
> v3-v4:
> Fix compile issue:
> arch/powerpc/kernel/process.c:1473:14: error: 'INTERRUPT_MACHINE_CHECK' 
> undeclared (first use in this function); did you mean 'TAINT_MACHINE_CHECK'?
> I didn't add "Reported-by: kernel test robot " here,
> because it's improper for this patch.

[...]

> diff --git a/arch/powerpc/include/asm/traps.h 
> b/arch/powerpc/include/asm/traps.h
> new file mode 100644
> index ..2e64e10afcef
> --- /dev/null
> +++ b/arch/powerpc/include/asm/traps.h
> @@ -0,0 +1,32 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_PPC_TRAPS_H
> +#define _ASM_PPC_TRAPS_H

These could go in interrupt.h.

> +#if defined(CONFIG_BOOKE) || defined(CONFIG_4xx)
> +#define INTERRUPT_MACHINE_CHECK   0x000
> +#define INTERRUPT_CRITICAL_INPUT  0x100
> +#define INTERRUPT_ALTIVEC_UNAVAIL 0x200
> +#define INTERRUPT_PERFMON 0x260
> +#define INTERRUPT_DOORBELL0x280
> +#define INTERRUPT_DEBUG   0xd00
> +#else
> +#define INTERRUPT_SYSTEM_RESET0x100
> +#define INTERRUPT_MACHINE_CHECK   0x200

[...]

> @@ -1469,7 +1470,9 @@ static void __show_regs(struct pt_regs *regs)
>   trap = TRAP(regs);
>   if (!trap_is_syscall(regs) && cpu_has_feature(CPU_FTR_CFAR))
>   pr_cont("CFAR: "REG" ", regs->orig_gpr3);
> - if (trap == 0x200 || trap == 0x300 || trap == 0x600) {
> + if (trap == INTERRUPT_MACHINE_CHECK ||
> + trap == INTERRUPT_DATA_STORAGE ||
> + trap == INTERRUPT_ALIGNMENT) {
>   if (IS_ENABLED(CONFIG_4xx) || IS_ENABLED(CONFIG_BOOKE))
>   pr_cont("DEAR: "REG" ESR: "REG" ", regs->dar, 
> regs->dsisr);
>   else

This is now a change in behaviour because previously BOOKE/4xx tested
0x200, but now it tests 0.

That looks wrong for 4xx. 64e does put 0x000 there but I wonder if it 
should use 0x200 instead. Bit difficult to test this stuff, I do have
some MCE injection patches for QEMU for 64s, might be able to look at
porting them to 64e although I have no idea about booke machine checks.

Anyway I don't think this patch should change generated code at all.
Either change the code first with smaller patches, or make sure you
keep the tests the same.

Thanks,
Nick


Re: [PATCH v3] powerpc/traps: Enhance readability for trap types

2021-04-09 Thread Michael Ellerman
Christophe Leroy  writes:
> Le 08/04/2021 à 16:07, Xiongwei Song a écrit :
>> From: Xiongwei Song 
>> 
>> Create a new header named traps.h, define macros to list ppc interrupt
>> types in traps.h, replace the reference of the trap hex values with these
>> macros.
...
>> diff --git a/arch/powerpc/include/asm/interrupt.h 
>> b/arch/powerpc/include/asm/interrupt.h
>> index 7c633896d758..5ce9898bc9a6 100644
>> --- a/arch/powerpc/include/asm/interrupt.h
>> +++ b/arch/powerpc/include/asm/interrupt.h
>> @@ -8,6 +8,7 @@
>>   #include 
>>   #include 
>>   #include 
>> +#include 
>>   
>>   struct interrupt_state {
>>   #ifdef CONFIG_PPC_BOOK3E_64
>> @@ -59,7 +60,7 @@ static inline void interrupt_enter_prepare(struct pt_regs 
>> *regs, struct interrup
>>   * CT_WARN_ON comes here via program_check_exception,
>>   * so avoid recursion.
>>   */
>> -if (TRAP(regs) != 0x700)
>> +if (TRAP(regs) != INTERRUPT_PROGRAM)
>>  CT_WARN_ON(ct_state() != CONTEXT_KERNEL);
>>  }
>>   #endif
>> @@ -156,7 +157,8 @@ static inline void interrupt_nmi_enter_prepare(struct 
>> pt_regs *regs, struct inte
>>  /* Don't do any per-CPU operations until interrupt state is fixed */
>>   #endif
>>  /* Allow DEC and PMI to be traced when they are soft-NMI */
>> -if (TRAP(regs) != 0x900 && TRAP(regs) != 0xf00 && TRAP(regs) != 0x260) {
>> +if (TRAP(regs) != INTERRUPT_DECREMENTER &&
>> +TRAP(regs) != INTERRUPT_PERFMON) {
>
> I think too long names hinder readability, see later for suggestions.

I asked for the longer names :)

I think they make it easier for people who are less familiar with the
architecture than us to make sense of the names.

And there's only a couple of cases where it requires splitting a line,
and they could be converted to use switch if we think it's a problem.

>> diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
>> index 0c0b1c2cfb49..641b3feef7ee 100644
>> --- a/arch/powerpc/mm/fault.c
>> +++ b/arch/powerpc/mm/fault.c
>> @@ -588,20 +589,24 @@ void __bad_page_fault(struct pt_regs *regs, int sig)
>>  /* kernel has accessed a bad area */
>>   
>>  switch (TRAP(regs)) {
>> -case 0x300:
>> -case 0x380:
>> -case 0xe00:
>> +case INTERRUPT_DATA_STORAGE:
>> +#ifdef CONFIG_PPC_BOOK3S
>> +case INTERRUPT_DATA_SEGMENT:
>> +case INTERRUPT_H_DATA_STORAGE:
>> +#endif
>
> It would be better to avoid #ifdefs when none where necessary before.

Yes I agree.

I think these can all be avoided by defining most of the values
regardless of what platform we're building for. Only the values that
overlap need to be kept behind an ifdef.

cheers


Re: [PATCH v2 1/1] kernel.h: Split out panic and oops helpers

2021-04-09 Thread Thomas Bogendoerfer
On Fri, Apr 09, 2021 at 01:02:50PM +0300, Andy Shevchenko wrote:
> kernel.h is being used as a dump for all kinds of stuff for a long time.
> Here is the attempt to start cleaning it up by splitting out panic and
> oops helpers.
> 
> There are several purposes of doing this:
> - dropping dependency in bug.h
> - dropping a loop by moving out panic_notifier.h
> - unload kernel.h from something which has its own domain
> 
> At the same time convert users tree-wide to use new headers, although
> for the time being include new header back to kernel.h to avoid twisted
> indirected includes for existing users.
> 
> Signed-off-by: Andy Shevchenko 
> Reviewed-by: Bjorn Andersson 
> Acked-by: Mike Rapoport 
> Acked-by: Corey Minyard 
> Acked-by: Christian Brauner 
> Acked-by: Arnd Bergmann 
> Acked-by: Kees Cook 
> Acked-by: Wei Liu 
> Acked-by: Rasmus Villemoes 
> Signed-off-by: Andrew Morton 
> ---
> v2:
>  - fixed all errors with allmodconfig on x86_64 (Andrew)
>  - checked with allyesconfig on x86_64
>  - additionally grepped source code for panic notifier list usage
>and converted all users
>  - elaborated commit message (Luis)
>  - collected given tags (incl. Andrew's SoB, see below)
> 
> I added Andrew's SoB since part of the fixes I took from him. Andrew,
> feel free to amend or tell me how you want me to do.
> 
>  arch/mips/kernel/relocate.c   |  1 +
>  arch/mips/sgi-ip22/ip22-reset.c   |  1 +
>  arch/mips/sgi-ip32/ip32-reset.c   |  1 +

Acked-by: Thomas Bogendoerfer 

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.[ RFC1925, 2.3 ]


Re: [PATCH v2 1/1] kernel.h: Split out panic and oops helpers

2021-04-09 Thread Helge Deller

On 4/9/21 12:02 PM, Andy Shevchenko wrote:

kernel.h is being used as a dump for all kinds of stuff for a long time.
Here is the attempt to start cleaning it up by splitting out panic and
oops helpers.

There are several purposes of doing this:
- dropping dependency in bug.h
- dropping a loop by moving out panic_notifier.h
- unload kernel.h from something which has its own domain

At the same time convert users tree-wide to use new headers, although
for the time being include new header back to kernel.h to avoid twisted
indirected includes for existing users.

Signed-off-by: Andy Shevchenko 
Reviewed-by: Bjorn Andersson 
Acked-by: Mike Rapoport 
Acked-by: Corey Minyard 
Acked-by: Christian Brauner 
Acked-by: Arnd Bergmann 
Acked-by: Kees Cook 
Acked-by: Wei Liu 
Acked-by: Rasmus Villemoes 
Signed-off-by: Andrew Morton 


Acked-by: Helge Deller  # parisc

Helge


Re: [PATCH v2 1/1] kernel.h: Split out panic and oops helpers

2021-04-09 Thread Luis Chamberlain
On Fri, Apr 09, 2021 at 01:02:50PM +0300, Andy Shevchenko wrote:
> kernel.h is being used as a dump for all kinds of stuff for a long time.
> Here is the attempt to start cleaning it up by splitting out panic and
> oops helpers.
> 
> There are several purposes of doing this:
> - dropping dependency in bug.h
> - dropping a loop by moving out panic_notifier.h
> - unload kernel.h from something which has its own domain
> 
> At the same time convert users tree-wide to use new headers, although
> for the time being include new header back to kernel.h to avoid twisted
> indirected includes for existing users.
> 
> Signed-off-by: Andy Shevchenko 
> Reviewed-by: Bjorn Andersson 
> Acked-by: Mike Rapoport 
> Acked-by: Corey Minyard 
> Acked-by: Christian Brauner 
> Acked-by: Arnd Bergmann 
> Acked-by: Kees Cook 
> Acked-by: Wei Liu 
> Acked-by: Rasmus Villemoes 
> Signed-off-by: Andrew Morton 

Acked-by: Luis Chamberlain 

  Luis


Re: [PATCH v2 1/1] kernel.h: Split out panic and oops helpers

2021-04-09 Thread Stephen Boyd
Quoting Andy Shevchenko (2021-04-09 03:02:50)
> kernel.h is being used as a dump for all kinds of stuff for a long time.
> Here is the attempt to start cleaning it up by splitting out panic and
> oops helpers.
> 
> There are several purposes of doing this:
> - dropping dependency in bug.h
> - dropping a loop by moving out panic_notifier.h
> - unload kernel.h from something which has its own domain
> 
> At the same time convert users tree-wide to use new headers, although
> for the time being include new header back to kernel.h to avoid twisted
> indirected includes for existing users.
> 
> Signed-off-by: Andy Shevchenko 
> Reviewed-by: Bjorn Andersson 
> Acked-by: Mike Rapoport 
> Acked-by: Corey Minyard 
> Acked-by: Christian Brauner 
> Acked-by: Arnd Bergmann 
> Acked-by: Kees Cook 
> Acked-by: Wei Liu 
> Acked-by: Rasmus Villemoes 
> Signed-off-by: Andrew Morton 
> ---

>  drivers/clk/analogbits/wrpll-cln28hpc.c   |  4 +

Acked-by: Stephen Boyd 


RE: [PATCH -next] soc: fsl: qe: use DEFINE_SPINLOCK() for spinlock

2021-04-09 Thread Leo Li



> -Original Message-
> From: Ye Bin 
> Sent: Friday, April 9, 2021 4:52 AM
> To: yebi...@huawei.com; Qiang Zhao ; Leo Li
> 
> Cc: linuxppc-dev@lists.ozlabs.org; linux-arm-ker...@lists.infradead.org;
> linux-ker...@vger.kernel.org; kernel-janit...@vger.kernel.org; Hulk Robot
> 
> Subject: [PATCH -next] soc: fsl: qe: use DEFINE_SPINLOCK() for spinlock
> 
> spinlock can be initialized automatically with DEFINE_SPINLOCK() rather than
> explicitly calling spin_lock_init().

The previous version has been applied.  Thanks.

> 
> Reported-by: Hulk Robot 
> Signed-off-by: Ye Bin 
> ---
>  drivers/soc/fsl/qe/qe_common.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/fsl/qe/qe_common.c
> b/drivers/soc/fsl/qe/qe_common.c index 654e9246ce6b..a0cb8e746879
> 100644
> --- a/drivers/soc/fsl/qe/qe_common.c
> +++ b/drivers/soc/fsl/qe/qe_common.c
> @@ -26,7 +26,7 @@
>  #include 
> 
>  static struct gen_pool *muram_pool;
> -static spinlock_t cpm_muram_lock;
> +static DEFINE_SPINLOCK(cpm_muram_lock);
>  static void __iomem *muram_vbase;
>  static phys_addr_t muram_pbase;
> 
> @@ -54,7 +54,6 @@ int cpm_muram_init(void)
>   if (muram_pbase)
>   return 0;
> 
> - spin_lock_init(_muram_lock);
>   np = of_find_compatible_node(NULL, NULL, "fsl,cpm-muram-data");
>   if (!np) {
>   /* try legacy bindings */



[Bug 212631] Misaligned floating point loads and store occasionally fail

2021-04-09 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=212631

--- Comment #2 from Trevor Davenport (trevor_davenp...@selinc.com) ---
A git bisect found this has existed for quite a while. 

git bisect start
# bad: [0cc244011f40280b78fc344d5c2aac5a0c659f77] Linux 4.14.229
git bisect bad 0cc244011f40280b78fc344d5c2aac5a0c659f77
# good: [a0c646821e9dedc5368abd2f71f50ebe2c351d19] Linux 4.4.265
git bisect good a0c646821e9dedc5368abd2f71f50ebe2c351d19
# good: [afd2ff9b7e1b367172f18ba7f693dfb62bdcb2dc] Linux 4.4
git bisect good afd2ff9b7e1b367172f18ba7f693dfb62bdcb2dc
# good: [786a72d79140028537382fa63bea63d5640c27d6] Merge tag 'armsoc-dt' of
git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
git bisect good 786a72d79140028537382fa63bea63d5640c27d6
# good: [e0f25a3f2d052e36ff67a9b4db835c3e27e950d8] Merge tag 'hwlock-v4.13' of
git://github.com/andersson/remoteproc
git bisect good e0f25a3f2d052e36ff67a9b4db835c3e27e950d8
# bad: [dd9d064e34a1b1c96d631cca73e2a6efc5834f4a] Merge tag 'staging-4.14-rc6'
of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
git bisect bad dd9d064e34a1b1c96d631cca73e2a6efc5834f4a
# good: [b88f55774f20c0c306e0a95d22ca9ab5f08187c7] Merge tag 'spi-v4.14' of
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
git bisect good b88f55774f20c0c306e0a95d22ca9ab5f08187c7
# good: [b88f55774f20c0c306e0a95d22ca9ab5f08187c7] Merge tag 'spi-v4.14' of
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
git bisect good b88f55774f20c0c306e0a95d22ca9ab5f08187c7
# bad: [cef5d0f952a03d42051141742632078d488b0c6b] Merge branch 'for-linus' of
git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk
git bisect bad cef5d0f952a03d42051141742632078d488b0c6b
# good: [aae3dbb4776e7916b6cd442d00159bea27a695c1] Merge
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
git bisect good aae3dbb4776e7916b6cd442d00159bea27a695c1
# good: [aae3dbb4776e7916b6cd442d00159bea27a695c1] Merge
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
git bisect good aae3dbb4776e7916b6cd442d00159bea27a695c1
# bad: [3645e6d0dc80be4376f87acc9ee527768387c909] Merge tag 'md/4.14-rc1' of
git://git.kernel.org/pub/scm/linux/kernel/git/shli/md
git bisect bad 3645e6d0dc80be4376f87acc9ee527768387c909
# bad: [bac65d9d87b383471d8d29128319508d71b74180] Merge tag 'powerpc-4.14-1' of
git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
git bisect bad bac65d9d87b383471d8d29128319508d71b74180
# good: [57e88b43b81301d9b28f124a5576ac43a1cf9e8d] Merge branch
'x86-platform-for-linus' of
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
git bisect good 57e88b43b81301d9b28f124a5576ac43a1cf9e8d
# good: [f9065c83ccf4a6c1ff5419d216ad8276e99bee6c] powerpc/configs: Explicitly
drop CONFIG_INPUT_MOUSEDEV
git bisect good f9065c83ccf4a6c1ff5419d216ad8276e99bee6c
# good: [d1e1b351f50f9e5941f436f6c63949731979e00c] powerpc/xmon: Add ISA v3.0
SPRs to SPR dump
git bisect good d1e1b351f50f9e5941f436f6c63949731979e00c
# bad: [146e9f1b65478643f2729a97ccb8be60bb4492e5] crypto/nx: Add P9 NX specific
error codes for 842 engine
git bisect bad 146e9f1b65478643f2729a97ccb8be60bb4492e5
# good: [5762e08344bd7c5bfc41030f74c4ab6ce6e461d0] powerpc: Don't update CR0 in
emulation of popcnt, prty, bpermd instructions
git bisect good 5762e08344bd7c5bfc41030f74c4ab6ce6e461d0
# bad: [d2b65ac6526a82965212b632d42687251e122a36] powerpc: Emulate load/store
floating point as integer word instructions
git bisect bad d2b65ac6526a82965212b632d42687251e122a36
# good: [1f41fb790460acf432f826f4aeeff6f7da891ff7] powerpc: Emulate load/store
floating double pair instructions
git bisect good 1f41fb790460acf432f826f4aeeff6f7da891ff7
# good: [d955189ae42796621fb439e5e778ccaeebc2a1e7] powerpc: Handle
opposite-endian processes in emulation code
git bisect good d955189ae42796621fb439e5e778ccaeebc2a1e7
# bad: [31bfdb036f1281831db2532178f0da41f4dc9bed] powerpc: Use instruction
emulation infrastructure to handle alignment faults
git bisect bad 31bfdb036f1281831db2532178f0da41f4dc9bed
# good: [a53d5182e24c22986ad0e99e52f8fe343ee7d7ac] powerpc: Separate out
load/store emulation into its own function
git bisect good a53d5182e24c22986ad0e99e52f8fe343ee7d7ac
# first bad commit: [31bfdb036f1281831db2532178f0da41f4dc9bed] powerpc: Use
instruction emulation infrastructure to handle alignment faults


31bfdb036f1281831db2532178f0da41f4dc9bed is the first bad commit
commit 31bfdb036f1281831db2532178f0da41f4dc9bed
Author: Paul Mackerras 
Date:   Wed Aug 30 14:12:40 2017 +1000

powerpc: Use instruction emulation infrastructure to handle alignment
faults

This replaces almost all of the instruction emulation code in
fix_alignment() with calls to analyse_instr(), emulate_loadstore()
and emulate_dcbz().  The only emulation code left is the SPE
emulation code; analyse_instr() etc. do not handle SPE instructions
at present.

One result of this is that we can now handle alignment faults on
all the new VSX load and store instructions that were added in 

Re: [PATCH v3] powerpc/traps: Enhance readability for trap types

2021-04-09 Thread Segher Boessenkool
On Fri, Apr 09, 2021 at 06:14:19PM +0200, Christophe Leroy wrote:
> >+#define INTERRUPT_SYSTEM_RESET0x100
> 
> INT_SRESET

SRESET exists on many PowerPC, it means "soft reset".  Not the same
thing at all.

I think "INT" is not a great prefix fwiw, there are many things you can
abbr to "INT".

> >+#define INTERRUPT_DATA_SEGMENT0x380
> 
> INT_DSEG

exceptions-64s.S calls this "DSLB" (I remember "DSSI" though -- but neither
is a very official name).  It probably is a good idea to look at that
existing code, not make up even more new names :-)

> >+#define INTERRUPT_DOORBELL0xa00
> 
> INT_DBELL

That saves three characters and makes it very not understandable.


Segher


Re: [PATCHv5 2/2] powerpc/pseries: update device tree before ejecting hotplug uevents

2021-04-09 Thread Michal Suchánek
Hello,

On Fri, Aug 28, 2020 at 04:10:09PM +0800, Pingfan Liu wrote:
> On Thu, Aug 27, 2020 at 3:53 PM Laurent Dufour  wrote:
> >
> > Le 10/08/2020 à 10:52, Pingfan Liu a écrit :
> > > A bug is observed on pseries by taking the following steps on rhel:
> > > -1. drmgr -c mem -r -q 5
> > > -2. echo c > /proc/sysrq-trigger
> > >
> > > And then, the failure looks like:
> > > kdump: saving to /sysroot//var/crash/127.0.0.1-2020-01-16-02:06:14/
> > > kdump: saving vmcore-dmesg.txt
> > > kdump: saving vmcore-dmesg.txt complete
> > > kdump: saving vmcore
> > >   Checking for memory holes : [  0.0 %] / 
> > >   Checking for memory holes : [100.0 %] | 
> > >   Excluding unnecessary pages   : 
> > > [100.0 %] \   Copying data
> > >   : [  0.3 %] -  eta: 38s[   44.337636] hash-mmu: mm: Hashing 
> > > failure ! EA=0x7fffba40 access=0x8004 current=makedumpfile
> > > [   44.337663] hash-mmu: trap=0x300 vsid=0x13a109c ssize=1 base 
> > > psize=2 psize 2 pte=0xc0005504
> > > [   44.337677] hash-mmu: mm: Hashing failure ! EA=0x7fffba40 
> > > access=0x8004 current=makedumpfile
> > > [   44.337692] hash-mmu: trap=0x300 vsid=0x13a109c ssize=1 base 
> > > psize=2 psize 2 pte=0xc0005504
> > > [   44.337708] makedumpfile[469]: unhandled signal 7 at 7fffba40 
> > > nip 7fffbbc4d7fc lr 00011356ca3c code 2
> > > [   44.338548] Core dump to |/bin/false pipe failed
> > > /lib/kdump-lib-initramfs.sh: line 98:   469 Bus error   
> > > $CORE_COLLECTOR /proc/vmcore 
> > > $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete
> > > kdump: saving vmcore failed
> > >
> > > * Root cause *
> > >After analyzing, it turns out that in the current implementation,
> > > when hot-removing lmb, the KOBJ_REMOVE event ejects before the dt 
> > > updating as
> > > the code __remove_memory() comes before drmem_update_dt().
> > > So in kdump kernel, when read_from_oldmem() resorts to
> > > pSeries_lpar_hpte_insert() to install hpte, but fails with -2 due to
> > > non-exist pfn. And finally, low_hash_fault() raise SIGBUS to process, as 
> > > it
> > > can be observed "Bus error"
> > >
> > >  From a viewpoint of listener and publisher, the publisher notifies the
> > > listener before data is ready.  This introduces a problem where udev
> > > launches kexec-tools (due to KOBJ_REMOVE) and loads a stale dt before
> > > updating. And in capture kernel, makedumpfile will access the memory based
> > > on the stale dt info, and hit a SIGBUS error due to an un-existed lmb.
> > >
> > > * Fix *
> > > This bug is introduced by commit 063b8b1251fd
> > > ("powerpc/pseries/memory-hotplug: Only update DT once per memory DLPAR
> > > request"), which tried to combine all the dt updating into one.
> > >
> > > To fix this issue, meanwhile not to introduce a quadratic runtime
> > > complexity by the model:
> > >dlpar_memory_add_by_count
> > >  for_each_drmem_lmb <--
> > >dlpar_add_lmb
> > >  drmem_update_dt(_v1|_v2)
> > >for_each_drmem_lmb   <--
> > > The dt should still be only updated once, and just before the last memory
> > > online/offline event is ejected to user space. Achieve this by tracing the
> > > num of lmb added or removed.
> > >
> > > Signed-off-by: Pingfan Liu 
> > > Cc: Michael Ellerman 
> > > Cc: Hari Bathini 
> > > Cc: Nathan Lynch 
> > > Cc: Nathan Fontenot 
> > > Cc: Laurent Dufour 
> > > To: linuxppc-dev@lists.ozlabs.org
> > > Cc: ke...@lists.infradead.org
> > > ---
> > > v4 -> v5: change dlpar_add_lmb()/dlpar_remove_lmb() prototype to report
> > >whether dt is updated successfully.
> > >Fix a condition boundary check bug
> > > v3 -> v4: resolve a quadratic runtime complexity issue.
> > >This series is applied on next-test branch
> > >   arch/powerpc/platforms/pseries/hotplug-memory.c | 102 
> > > +++-
> > >   1 file changed, 80 insertions(+), 22 deletions(-)
> > >
> > > diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c 
> > > b/arch/powerpc/platforms/pseries/hotplug-memory.c
> > > index 46cbcd1..1567d9f 100644
> > > --- a/arch/powerpc/platforms/pseries/hotplug-memory.c
> > > +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
> > > @@ -350,13 +350,22 @@ static bool lmb_is_removable(struct drmem_lmb *lmb)
> > >   return true;
> > >   }
> > >
> > > -static int dlpar_add_lmb(struct drmem_lmb *);
> > > +enum dt_update_status {
> > > + DT_NOUPDATE,
> > > + DT_TOUPDATE,
> > > + DT_UPDATED,
> > > +};
> > > +
> > > +/* "*dt_update" returns DT_UPDATED if updated */
> > > +static int dlpar_add_lmb(struct drmem_lmb *lmb,
> > > + enum dt_update_status *dt_update);
> > >
> > > -static int dlpar_remove_lmb(struct drmem_lmb *lmb)
> > > +static int dlpar_remove_lmb(struct 

Re: [PATCH v3] powerpc/traps: Enhance readability for trap types

2021-04-09 Thread Christophe Leroy




Le 08/04/2021 à 16:07, Xiongwei Song a écrit :

From: Xiongwei Song 

Create a new header named traps.h, define macros to list ppc interrupt
types in traps.h, replace the reference of the trap hex values with these
macros.

Referred the hex number in arch/powerpc/kernel/exceptions-64e.S,
arch/powerpc/kernel/exceptions-64s.S and
arch/powerpc/include/asm/kvm_asm.h.

v2-v3:
Correct the prefix of trap macros with INTERRUPT_, the previous prefix
is TRAP_, which is not precise. This is suggested by Segher Boessenkool
and Nicholas Piggin.

v1-v2:
Define more trap macros to replace more trap hexs in code, not just for
the __show_regs function. This is suggested by Christophe Leroy.

Signed-off-by: Xiongwei Song 
---
  arch/powerpc/include/asm/interrupt.h  |  9 +---
  arch/powerpc/include/asm/ptrace.h |  3 ++-
  arch/powerpc/include/asm/traps.h  | 32 +++
  arch/powerpc/kernel/interrupt.c   |  3 ++-
  arch/powerpc/kernel/process.c |  5 -
  arch/powerpc/mm/book3s64/hash_utils.c |  5 +++--
  arch/powerpc/mm/fault.c   | 21 +++---
  arch/powerpc/perf/core-book3s.c   |  5 +++--
  arch/powerpc/xmon/xmon.c  | 16 +++---
  9 files changed, 78 insertions(+), 21 deletions(-)
  create mode 100644 arch/powerpc/include/asm/traps.h

diff --git a/arch/powerpc/include/asm/interrupt.h 
b/arch/powerpc/include/asm/interrupt.h
index 7c633896d758..5ce9898bc9a6 100644
--- a/arch/powerpc/include/asm/interrupt.h
+++ b/arch/powerpc/include/asm/interrupt.h
@@ -8,6 +8,7 @@
  #include 
  #include 
  #include 
+#include 
  
  struct interrupt_state {

  #ifdef CONFIG_PPC_BOOK3E_64
@@ -59,7 +60,7 @@ static inline void interrupt_enter_prepare(struct pt_regs 
*regs, struct interrup
 * CT_WARN_ON comes here via program_check_exception,
 * so avoid recursion.
 */
-   if (TRAP(regs) != 0x700)
+   if (TRAP(regs) != INTERRUPT_PROGRAM)
CT_WARN_ON(ct_state() != CONTEXT_KERNEL);
}
  #endif
@@ -156,7 +157,8 @@ static inline void interrupt_nmi_enter_prepare(struct 
pt_regs *regs, struct inte
/* Don't do any per-CPU operations until interrupt state is fixed */
  #endif
/* Allow DEC and PMI to be traced when they are soft-NMI */
-   if (TRAP(regs) != 0x900 && TRAP(regs) != 0xf00 && TRAP(regs) != 0x260) {
+   if (TRAP(regs) != INTERRUPT_DECREMENTER &&
+   TRAP(regs) != INTERRUPT_PERFMON) {


I think too long names hinder readability, see later for suggestions.


state->ftrace_enabled = this_cpu_get_ftrace_enabled();
this_cpu_set_ftrace_enabled(0);
}
@@ -180,7 +182,8 @@ static inline void interrupt_nmi_exit_prepare(struct 
pt_regs *regs, struct inter
nmi_exit();
  
  #ifdef CONFIG_PPC64

-   if (TRAP(regs) != 0x900 && TRAP(regs) != 0xf00 && TRAP(regs) != 0x260)
+   if (TRAP(regs) != INTERRUPT_DECREMENTER &&
+   TRAP(regs) != INTERRUPT_PERFMON)
this_cpu_set_ftrace_enabled(state->ftrace_enabled);
  
  #ifdef CONFIG_PPC_BOOK3S_64

diff --git a/arch/powerpc/include/asm/ptrace.h 
b/arch/powerpc/include/asm/ptrace.h
index f10498e1b3f6..7a17e0365d43 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -21,6 +21,7 @@
  
  #include 

  #include 
+#include 
  
  #ifndef __ASSEMBLY__

  struct pt_regs
@@ -237,7 +238,7 @@ static inline bool trap_is_unsupported_scv(struct pt_regs 
*regs)
  
  static inline bool trap_is_syscall(struct pt_regs *regs)

  {
-   return (trap_is_scv(regs) || TRAP(regs) == 0xc00);
+   return (trap_is_scv(regs) || TRAP(regs) == INTERRUPT_SYSCALL);
  }
  
  static inline bool trap_norestart(struct pt_regs *regs)

diff --git a/arch/powerpc/include/asm/traps.h b/arch/powerpc/include/asm/traps.h
new file mode 100644
index ..cb416a17097c
--- /dev/null
+++ b/arch/powerpc/include/asm/traps.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_PPC_TRAPS_H
+#define _ASM_PPC_TRAPS_H
+
+#if defined(CONFIG_BOOKE) || defined(CONFIG_4xx)
+#define INTERRUPT_MACHINE_CHECK   0x000


I'd prefer shorted names in order to not be obliged to split lines.
Here are some suggestions:

INT_MCE


+#define INTERRUPT_CRITICAL_INPUT  0x100


INT_CRIT


+#define INTERRUPT_ALTIVEC_UNAVAIL 0x200
+#define INTERRUPT_PERFMON 0x260


INT_PERF


+#define INTERRUPT_DOORBELL0x280
+#define INTERRUPT_DEBUG   0xd00
+#elif defined(CONFIG_PPC_BOOK3S)
+#define INTERRUPT_SYSTEM_RESET0x100


INT_SRESET


+#define INTERRUPT_MACHINE_CHECK   0x200


INT_MCE


+#define INTERRUPT_DATA_SEGMENT0x380


INT_DSEG


+#define INTERRUPT_INST_SEGMENT0x480


INT_ISEG


+#define INTERRUPT_DOORBELL0xa00


INT_DBELL


+#define INTERRUPT_TRACE   0xd00


INT_TRACE


+#define INTERRUPT_H_DATA_STORAGE  0xe00
+#define INTERRUPT_PERFMON 0xf00


INT_PERF


+#define 

[Bug 212631] Misaligned floating point loads and store occasionally fail

2021-04-09 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=212631

--- Comment #1 from Trevor Davenport (trevor_davenp...@selinc.com) ---
I can also reproduce this with kernel version 5.11.12.

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

[Bug 212631] New: Misaligned floating point loads and store occasionally fail

2021-04-09 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=212631

Bug ID: 212631
   Summary: Misaligned floating point loads and store occasionally
fail
   Product: Platform Specific/Hardware
   Version: 2.5
Kernel Version: 5.4.110
  Hardware: All
OS: Linux
  Tree: Mainline
Status: NEW
  Severity: normal
  Priority: P1
 Component: PPC-32
  Assignee: platform_ppc...@kernel-bugs.osdl.org
  Reporter: trevor_davenp...@selinc.com
Regression: No

Created attachment 296311
  --> https://bugzilla.kernel.org/attachment.cgi?id=296311=edit
Floating point load test program

On a 32-bit PPC, e300c1 CPU, I am occasionally seeing misaligned floating point
loads/store occasionally fail.  It appears to happen when a process is
preempted.  Reducing preemption cause the issue to be fare less likely to
occur. 

When it fails(in the load case), I've traced it down to do_fp_load.  It fails
when it takes the false branch while it works when taking the true branch (see
https://elixir.bootlin.com/linux/v5.4.110/source/arch/powerpc/lib/sstep.c#L492).

The issue was originally seen on a preempt-rt kernel, but it can be reproduced
on a regular kernel compiled for low latency desktop as well.

The issue can be reproduced with the attached program which just performs an
unaligned FP load.  Eventually it will produce a zero and exit.  

Example output:
 11326b98
 22453191
 3357f78a
 446abd71
 557d70b6
 11326b98
 22453191
 3357f78a
 446abd71
 557d70b6
 11326b98
 22453191
 3357f78a
 
 float-bug: float-bug.c:14: main: Assertion `b[0] != 00' failed.

This has been compiled with gcc 9.3.0.

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

[PATCH v4] powerpc/traps: Enhance readability for trap types

2021-04-09 Thread Xiongwei Song
From: Xiongwei Song 

Create a new header named traps.h, define macros to list ppc interrupt
types in traps.h, replace the references of the trap hex values with these
macros.

Referred the hex numbers in arch/powerpc/kernel/exceptions-64e.S,
arch/powerpc/kernel/exceptions-64s.S and
arch/powerpc/include/asm/kvm_asm.h.

Reported-by: kernel test robot 
Signed-off-by: Xiongwei Song 
---

v3-v4:
Fix compile issue:
arch/powerpc/kernel/process.c:1473:14: error: 'INTERRUPT_MACHINE_CHECK' 
undeclared (first use in this function); did you mean 'TAINT_MACHINE_CHECK'?
I didn't add "Reported-by: kernel test robot " here,
because it's improper for this patch.

v2-v3:
Correct the prefix of trap macros with INTERRUPT_, the previous prefix
is TRAP_, which is not precise. This is suggested by Segher Boessenkool
and Nicholas Piggin.

v1-v2:
Define more trap macros to replace more trap hexs in code, not just for
the __show_regs function. This is suggested by Christophe Leroy.

---
 arch/powerpc/include/asm/interrupt.h  |  9 +---
 arch/powerpc/include/asm/ptrace.h |  3 ++-
 arch/powerpc/include/asm/traps.h  | 32 +++
 arch/powerpc/kernel/interrupt.c   |  3 ++-
 arch/powerpc/kernel/process.c |  5 -
 arch/powerpc/mm/book3s64/hash_utils.c |  5 +++--
 arch/powerpc/mm/fault.c   | 21 +++---
 arch/powerpc/perf/core-book3s.c   |  5 +++--
 arch/powerpc/xmon/xmon.c  | 16 +++---
 9 files changed, 78 insertions(+), 21 deletions(-)
 create mode 100644 arch/powerpc/include/asm/traps.h

diff --git a/arch/powerpc/include/asm/interrupt.h 
b/arch/powerpc/include/asm/interrupt.h
index 05e7fc4ffb50..4fd904fb5d59 100644
--- a/arch/powerpc/include/asm/interrupt.h
+++ b/arch/powerpc/include/asm/interrupt.h
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static inline void nap_adjust_return(struct pt_regs *regs)
 {
@@ -70,7 +71,7 @@ static inline void interrupt_enter_prepare(struct pt_regs 
*regs, struct interrup
 * CT_WARN_ON comes here via program_check_exception,
 * so avoid recursion.
 */
-   if (TRAP(regs) != 0x700)
+   if (TRAP(regs) != INTERRUPT_PROGRAM)
CT_WARN_ON(ct_state() != CONTEXT_KERNEL);
}
 #endif
@@ -175,7 +176,8 @@ static inline void interrupt_nmi_enter_prepare(struct 
pt_regs *regs, struct inte
/* Don't do any per-CPU operations until interrupt state is fixed */
 #endif
/* Allow DEC and PMI to be traced when they are soft-NMI */
-   if (TRAP(regs) != 0x900 && TRAP(regs) != 0xf00 && TRAP(regs) != 0x260) {
+   if (TRAP(regs) != INTERRUPT_DECREMENTER &&
+   TRAP(regs) != INTERRUPT_PERFMON) {
state->ftrace_enabled = this_cpu_get_ftrace_enabled();
this_cpu_set_ftrace_enabled(0);
}
@@ -204,7 +206,8 @@ static inline void interrupt_nmi_exit_prepare(struct 
pt_regs *regs, struct inter
 */
 
 #ifdef CONFIG_PPC64
-   if (TRAP(regs) != 0x900 && TRAP(regs) != 0xf00 && TRAP(regs) != 0x260)
+   if (TRAP(regs) != INTERRUPT_DECREMENTER &&
+   TRAP(regs) != INTERRUPT_PERFMON)
this_cpu_set_ftrace_enabled(state->ftrace_enabled);
 
 #ifdef CONFIG_PPC_BOOK3S_64
diff --git a/arch/powerpc/include/asm/ptrace.h 
b/arch/powerpc/include/asm/ptrace.h
index 95600f3a6523..07ff8629e776 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -21,6 +21,7 @@
 
 #include 
 #include 
+#include 
 
 #ifndef __ASSEMBLY__
 struct pt_regs
@@ -237,7 +238,7 @@ static inline bool trap_is_unsupported_scv(struct pt_regs 
*regs)
 
 static inline bool trap_is_syscall(struct pt_regs *regs)
 {
-   return (trap_is_scv(regs) || TRAP(regs) == 0xc00);
+   return (trap_is_scv(regs) || TRAP(regs) == INTERRUPT_SYSCALL);
 }
 
 static inline bool trap_norestart(struct pt_regs *regs)
diff --git a/arch/powerpc/include/asm/traps.h b/arch/powerpc/include/asm/traps.h
new file mode 100644
index ..2e64e10afcef
--- /dev/null
+++ b/arch/powerpc/include/asm/traps.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_PPC_TRAPS_H
+#define _ASM_PPC_TRAPS_H
+
+#if defined(CONFIG_BOOKE) || defined(CONFIG_4xx)
+#define INTERRUPT_MACHINE_CHECK   0x000
+#define INTERRUPT_CRITICAL_INPUT  0x100
+#define INTERRUPT_ALTIVEC_UNAVAIL 0x200
+#define INTERRUPT_PERFMON 0x260
+#define INTERRUPT_DOORBELL0x280
+#define INTERRUPT_DEBUG   0xd00
+#else
+#define INTERRUPT_SYSTEM_RESET0x100
+#define INTERRUPT_MACHINE_CHECK   0x200
+#define INTERRUPT_DATA_SEGMENT0x380
+#define INTERRUPT_INST_SEGMENT0x480
+#define INTERRUPT_DOORBELL0xa00
+#define INTERRUPT_TRACE   0xd00
+#define INTERRUPT_H_DATA_STORAGE  0xe00
+#define INTERRUPT_PERFMON 0xf00
+#define INTERRUPT_H_FAC_UNAVAIL   0xf80
+#endif
+
+#define INTERRUPT_DATA_STORAGE0x300
+#define INTERRUPT_INST_STORAGE0x400

Re: [PATCH v2 1/1] kernel.h: Split out panic and oops helpers

2021-04-09 Thread Sebastian Reichel
Hi,

On Fri, Apr 09, 2021 at 01:02:50PM +0300, Andy Shevchenko wrote:
> kernel.h is being used as a dump for all kinds of stuff for a long time.
> Here is the attempt to start cleaning it up by splitting out panic and
> oops helpers.
> 
> There are several purposes of doing this:
> - dropping dependency in bug.h
> - dropping a loop by moving out panic_notifier.h
> - unload kernel.h from something which has its own domain
> 
> At the same time convert users tree-wide to use new headers, although
> for the time being include new header back to kernel.h to avoid twisted
> indirected includes for existing users.
> 
> Signed-off-by: Andy Shevchenko 
> Reviewed-by: Bjorn Andersson 
> Acked-by: Mike Rapoport 
> Acked-by: Corey Minyard 
> Acked-by: Christian Brauner 
> Acked-by: Arnd Bergmann 
> Acked-by: Kees Cook 
> Acked-by: Wei Liu 
> Acked-by: Rasmus Villemoes 
> Signed-off-by: Andrew Morton 
> ---
> v2:
>  - fixed all errors with allmodconfig on x86_64 (Andrew)
>  - checked with allyesconfig on x86_64
>  - additionally grepped source code for panic notifier list usage
>and converted all users
>  - elaborated commit message (Luis)
>  - collected given tags (incl. Andrew's SoB, see below)
> 
> I added Andrew's SoB since part of the fixes I took from him. Andrew,
> feel free to amend or tell me how you want me to do.
> 
> [...]
>  drivers/power/reset/ltc2952-poweroff.c|  1 +
> [...]

Acked-by: Sebastian Reichel 

-- Sebastian


signature.asc
Description: PGP signature


[PATCH v2 1/1] kernel.h: Split out panic and oops helpers

2021-04-09 Thread Andy Shevchenko
kernel.h is being used as a dump for all kinds of stuff for a long time.
Here is the attempt to start cleaning it up by splitting out panic and
oops helpers.

There are several purposes of doing this:
- dropping dependency in bug.h
- dropping a loop by moving out panic_notifier.h
- unload kernel.h from something which has its own domain

At the same time convert users tree-wide to use new headers, although
for the time being include new header back to kernel.h to avoid twisted
indirected includes for existing users.

Signed-off-by: Andy Shevchenko 
Reviewed-by: Bjorn Andersson 
Acked-by: Mike Rapoport 
Acked-by: Corey Minyard 
Acked-by: Christian Brauner 
Acked-by: Arnd Bergmann 
Acked-by: Kees Cook 
Acked-by: Wei Liu 
Acked-by: Rasmus Villemoes 
Signed-off-by: Andrew Morton 
---
v2:
 - fixed all errors with allmodconfig on x86_64 (Andrew)
 - checked with allyesconfig on x86_64
 - additionally grepped source code for panic notifier list usage
   and converted all users
 - elaborated commit message (Luis)
 - collected given tags (incl. Andrew's SoB, see below)

I added Andrew's SoB since part of the fixes I took from him. Andrew,
feel free to amend or tell me how you want me to do.

 arch/alpha/kernel/setup.c |  2 +-
 arch/arm64/kernel/setup.c |  1 +
 arch/mips/kernel/relocate.c   |  1 +
 arch/mips/sgi-ip22/ip22-reset.c   |  1 +
 arch/mips/sgi-ip32/ip32-reset.c   |  1 +
 arch/parisc/kernel/pdc_chassis.c  |  1 +
 arch/powerpc/kernel/setup-common.c|  1 +
 arch/s390/kernel/ipl.c|  1 +
 arch/sparc/kernel/sstate.c|  1 +
 arch/um/drivers/mconsole_kern.c   |  1 +
 arch/um/kernel/um_arch.c  |  1 +
 arch/x86/include/asm/desc.h   |  1 +
 arch/x86/kernel/cpu/mshyperv.c|  1 +
 arch/x86/kernel/setup.c   |  1 +
 arch/x86/purgatory/purgatory.c|  2 +
 arch/x86/xen/enlighten.c  |  1 +
 arch/xtensa/platforms/iss/setup.c |  1 +
 drivers/bus/brcmstb_gisb.c|  1 +
 drivers/char/ipmi/ipmi_msghandler.c   |  1 +
 drivers/clk/analogbits/wrpll-cln28hpc.c   |  4 +
 drivers/edac/altera_edac.c|  1 +
 drivers/firmware/google/gsmi.c|  1 +
 drivers/hv/vmbus_drv.c|  1 +
 .../hwtracing/coresight/coresight-cpu-debug.c |  1 +
 drivers/leds/trigger/ledtrig-activity.c   |  1 +
 drivers/leds/trigger/ledtrig-heartbeat.c  |  1 +
 drivers/leds/trigger/ledtrig-panic.c  |  1 +
 drivers/misc/bcm-vk/bcm_vk_dev.c  |  1 +
 drivers/misc/ibmasm/heartbeat.c   |  1 +
 drivers/misc/pvpanic/pvpanic.c|  1 +
 drivers/net/ipa/ipa_smp2p.c   |  1 +
 drivers/parisc/power.c|  1 +
 drivers/power/reset/ltc2952-poweroff.c|  1 +
 drivers/remoteproc/remoteproc_core.c  |  1 +
 drivers/s390/char/con3215.c   |  1 +
 drivers/s390/char/con3270.c   |  1 +
 drivers/s390/char/sclp.c  |  1 +
 drivers/s390/char/sclp_con.c  |  1 +
 drivers/s390/char/sclp_vt220.c|  1 +
 drivers/s390/char/zcore.c |  1 +
 drivers/soc/bcm/brcmstb/pm/pm-arm.c   |  1 +
 drivers/staging/olpc_dcon/olpc_dcon.c |  1 +
 drivers/video/fbdev/hyperv_fb.c   |  1 +
 include/asm-generic/bug.h |  3 +-
 include/linux/kernel.h| 84 +---
 include/linux/panic.h | 98 +++
 include/linux/panic_notifier.h| 12 +++
 kernel/hung_task.c|  1 +
 kernel/kexec_core.c   |  1 +
 kernel/panic.c|  1 +
 kernel/rcu/tree.c |  2 +
 kernel/sysctl.c   |  1 +
 kernel/trace/trace.c  |  1 +
 53 files changed, 167 insertions(+), 85 deletions(-)
 create mode 100644 include/linux/panic.h
 create mode 100644 include/linux/panic_notifier.h

diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index 03dda3beb3bd..5d1296534682 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -46,7 +47,6 @@
 #include 
 #include 
 
-extern struct atomic_notifier_head panic_notifier_list;
 static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
 static struct notifier_block alpha_panic_block = {
alpha_panic_event,
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 61845c0821d9..787bc0f601b3 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 

Re: [PATCH] powerpc/perf: Fix PMU callbacks to clear pending PMI before resetting an overflown PMC

2021-04-09 Thread Athira Rajeev



> On 09-Apr-2021, at 6:38 AM, Nicholas Piggin  wrote:
> 
Hi Nick,

Thanks for checking the patch and sharing review comments.

> I was going to nitpick "overflown" here as something birds do, but some
> sources says overflown is okay for past tense.
> 
> You could use "overflowed" for that, but I understand the issue with the 
> word: you are talking about counters that are currently in an "overflow" 
> state, but the overflow occurred in the past and is not still happening
> so you "overflowing" doesn't exactly fit either.
> 
> overflown kind of works for some reason you can kind of use it for
> present tense!

Ok sure, Yes counter is currently in an “overflow” state.

> 
> Excerpts from Athira Rajeev's message of April 7, 2021 12:47 am:
>> Running perf fuzzer showed below in dmesg logs:
>> "Can't find PMC that caused IRQ"
>> 
>> This means a PMU exception happened, but none of the PMC's (Performance
>> Monitor Counter) were found to be overflown. There are some corner cases
>> that clears the PMCs after PMI gets masked. In such cases, the perf
>> interrupt handler will not find the active PMC values that had caused
>> the overflow and thus leads to this message while replaying.
>> 
>> Case 1: PMU Interrupt happens during replay of other interrupts and
>> counter values gets cleared by PMU callbacks before replay:
>> 
>> During replay of interrupts like timer, __do_irq and doorbell exception, we
>> conditionally enable interrupts via may_hard_irq_enable(). This could
>> potentially create a window to generate a PMI. Since irq soft mask is set
>> to ALL_DISABLED, the PMI will get masked here.
> 
> I wonder if may_hard_irq_enable shouldn't enable if PMI is soft
> disabled. And also maybe replay should not set ALL_DISABLED if
> there are no PMI interrupts pending.
> 
> Still, I think those are a bit more tricky and might take a while
> to get right or just not be worth while, so I think your patch is
> fine.

Ok Nick.
> 
>> We could get IPIs run before
>> perf interrupt is replayed and the PMU events could deleted or stopped.
>> This will change the PMU SPR values and resets the counters. Snippet of
>> ftrace log showing PMU callbacks invoked in "__do_irq":
>> 
>> -0 [051] dns. 132025441306354: __do_irq <-call_do_irq
>> -0 [051] dns. 132025441306430: irq_enter <-__do_irq
>> -0 [051] dns. 132025441306503: irq_enter_rcu <-__do_irq
>> -0 [051] dnH. 132025441306599: xive_get_irq <-__do_irq
>> <<>>
>> -0 [051] dnH. 132025441307770: 
>> generic_smp_call_function_single_interrupt <-smp_ipi_demux_relaxed
>> -0 [051] dnH. 132025441307839: flush_smp_call_function_queue 
>> <-smp_ipi_demux_relaxed
>> -0 [051] dnH. 132025441308057: _raw_spin_lock <-event_function
>> -0 [051] dnH. 132025441308206: power_pmu_disable <-perf_pmu_disable
>> -0 [051] dnH. 132025441308337: power_pmu_del <-event_sched_out
>> -0 [051] dnH. 132025441308407: power_pmu_read <-power_pmu_del
>> -0 [051] dnH. 132025441308477: read_pmc <-power_pmu_read
>> -0 [051] dnH. 132025441308590: isa207_disable_pmc <-power_pmu_del
>> -0 [051] dnH. 132025441308663: write_pmc <-power_pmu_del
>> -0 [051] dnH. 132025441308787: power_pmu_event_idx 
>> <-perf_event_update_userpage
>> -0 [051] dnH. 132025441308859: rcu_read_unlock_strict 
>> <-perf_event_update_userpage
>> -0 [051] dnH. 132025441308975: power_pmu_enable <-perf_pmu_enable
>> <<>>
>> -0 [051] dnH. 132025441311108: irq_exit <-__do_irq
>> -0 [051] dns. 132025441311319: performance_monitor_exception 
>> <-replay_soft_interrupts
>> 
>> Case 2: PMI's masked during local_* operations, example local_add.
>> If the local_add operation happens within a local_irq_save, replay of
>> PMI will be during local_irq_restore. Similar to case 1, this could
>> also create a window before replay where PMU events gets deleted or
>> stopped.
> 
> Here as well perhaps PMIs should be replayed if they are unmasked
> even if other interrupts are still masked. Again that might be more
> complexity than it's worth.
Ok..

> 
>> 
>> Patch adds a fix to update the PMU callback functions (del,stop,enable) to
>> check for pending perf interrupt. If there is an overflown PMC and pending
>> perf interrupt indicated in Paca, clear the PMI bit in paca to drop that
>> sample. In case of power_pmu_del, also clear the MMCR0 PMAO bit which
>> otherwise could lead to spurious interrupts in some corner cases. Example,
>> a timer after power_pmu_del which will re-enable interrupts since PMI is
>> cleared and triggers a PMI again since PMAO bit is still set.
>> 
>> We can't just replay PMI any time. Hence this approach is preferred rather
>> than replaying PMI before resetting overflown PMC. Patch also documents
>> core-book3s on a race condition which can trigger these PMC messages during
>> idle path in PowerNV.
>> 
>> Fixes: f442d004806e ("powerpc/64s: Add support to mask perf interrupts and 
>> replay them")
>> Reported-by: Nageswara R Sastry 
>> Suggested-by: Nicholas Piggin 
>> Suggested-by: Madhavan Srinivasan 
>> Signed-off-by: Athira 

Re: [PATCH 2/2] powerpc: make 'boot_text_mapped' static

2021-04-09 Thread Segher Boessenkool
Hi!

On Thu, Apr 08, 2021 at 07:04:35AM +0200, Christophe Leroy wrote:
> Le 08/04/2021 à 03:18, Yu Kuai a écrit :
> >-int boot_text_mapped __force_data = 0;
> >+static int boot_text_mapped __force_data;
> 
> Are you sure the initialisation to 0 can be removed ? Usually 
> initialisation to 0 is not needed because not initialised variables go in 
> the BSS section which is zeroed at startup. But here the variable is 
> flagged with __force_data so it is not going in the BSS section.

Any non-automatic (i.e. function-scope, not static) variable is
initialised to 0.  See e.g. C11 6.7.9/10 (this has been like that since
times immemorial, C90 anyway).


Segher


Re: [PATCH v3 8/9] mm/mremap: Allow arch runtime override

2021-04-09 Thread Aneesh Kumar K.V

On 4/9/21 3:05 PM, Christophe Leroy wrote:



Le 30/03/2021 à 08:07, Aneesh Kumar K.V a écrit :

Architectures like ppc64 can only support faster mremap only with radix


... only  only ...


translation. Hence allow a runtime check w.r.t support for fast mremap.



will fix that


Signed-off-by: Aneesh Kumar K.V 
---
  arch/arc/include/asm/tlb.h |  5 +
  arch/arm64/include/asm/tlb.h   |  6 ++
  arch/powerpc/include/asm/tlb.h |  6 ++
  arch/x86/include/asm/tlb.h |  5 +
  mm/mremap.c    | 14 +-
  5 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/arch/arc/include/asm/tlb.h b/arch/arc/include/asm/tlb.h
index 975b35d3738d..22b8cfb46cbf 100644
--- a/arch/arc/include/asm/tlb.h
+++ b/arch/arc/include/asm/tlb.h
@@ -9,4 +9,9 @@
  #include 
  #include 
+#define arch_supports_page_tables_move arch_supports_page_tables_move
+static inline bool arch_supports_page_tables_move(void)
+{
+    return true;
+}


I can't see why ARC arch needs that. It neither selects 
CONFIG_HAVE_MOVE_PMD nor CONFIG_HAVE_MOVE_PUD.





ok will fix that (I confused arch/Kconfig with arc/Kconfig )




  #endif /* _ASM_ARC_TLB_H */
diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h
index 61c97d3b58c7..fe209efc6a10 100644
--- a/arch/arm64/include/asm/tlb.h
+++ b/arch/arm64/include/asm/tlb.h
@@ -94,4 +94,10 @@ static inline void __pud_free_tlb(struct mmu_gather 
*tlb, pud_t *pudp,

  }
  #endif
+#define arch_supports_page_tables_move arch_supports_page_tables_move
+static inline bool arch_supports_page_tables_move(void)
+{
+    return true;
+}
+
  #endif
diff --git a/arch/powerpc/include/asm/tlb.h 
b/arch/powerpc/include/asm/tlb.h

index 160422a439aa..058918a7cd3c 100644
--- a/arch/powerpc/include/asm/tlb.h
+++ b/arch/powerpc/include/asm/tlb.h
@@ -83,5 +83,11 @@ static inline int mm_is_thread_local(struct 
mm_struct *mm)

  }
  #endif
+#define arch_supports_page_tables_move arch_supports_page_tables_move
+static inline bool arch_supports_page_tables_move(void)
+{
+    return radix_enabled();
+}
+
  #endif /* __KERNEL__ */
  #endif /* __ASM_POWERPC_TLB_H */
diff --git a/arch/x86/include/asm/tlb.h b/arch/x86/include/asm/tlb.h
index 1bfe979bb9bc..62915238bb36 100644
--- a/arch/x86/include/asm/tlb.h
+++ b/arch/x86/include/asm/tlb.h
@@ -37,4 +37,9 @@ static inline void __tlb_remove_table(void *table)
  free_page_and_swap_cache(table);
  }
+#define arch_supports_page_tables_move arch_supports_page_tables_move
+static inline bool arch_supports_page_tables_move(void)
+{
+    return true;
+}
  #endif /* _ASM_X86_TLB_H */
diff --git a/mm/mremap.c b/mm/mremap.c
index 7ac1df8e6d51..4d812af3e44b 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -25,7 +25,7 @@
  #include 
  #include 
-#include 
+#include 
  #include 
  #include "internal.h"
@@ -221,6 +221,14 @@ static inline void flush_pte_tlb_pwc_range(struct 
vm_area_struct *vma,

  }
  #endif
+#ifndef arch_supports_page_tables_move
+#define arch_supports_page_tables_move arch_supports_page_tables_move
+static inline bool arch_supports_page_tables_move(void)
+{
+    return false;


Can you do

 return IS_ENABLED(CONFIG_HAVE_MOVE_PMD) || 
IS_ENABLED(CONFIG_HAVE_MOVE_PUD);


And then remove the arch_supports_page_tables_move() you have added for 
arc, arm64 and x86 ?





something like below?

#ifndef arch_supports_page_tables_move
#define arch_supports_page_tables_move arch_supports_page_tables_move
static inline bool arch_supports_page_tables_move(void)
{
return IS_ENABLED(CONFIG_HAVE_MOVE_PMD) ||
IS_ENABLED(CONFIG_HAVE_MOVE_PUD);
}
#endif

are remove those from those arch headers.






+}
+#endif
+
  #ifdef CONFIG_HAVE_MOVE_PMD


Next step could be remove that #ifdef and the content of the matching #else
For that we'd just need a stub version of set_pmd_at() and set_pud_at().

  static bool move_normal_pmd(struct vm_area_struct *vma, unsigned 
long old_addr,

    unsigned long new_addr, pmd_t *old_pmd, pmd_t *new_pmd)
@@ -229,6 +237,8 @@ static bool move_normal_pmd(struct vm_area_struct 
*vma, unsigned long old_addr,

  struct mm_struct *mm = vma->vm_mm;
  pmd_t pmd;
+    if (!arch_supports_page_tables_move())
+    return false;
  /*
   * The destination pmd shouldn't be established, free_pgtables()
   * should have released it.
@@ -295,6 +305,8 @@ static bool move_normal_pud(struct vm_area_struct 
*vma, unsigned long old_addr,

  struct mm_struct *mm = vma->vm_mm;
  pud_t pud;
+    if (!arch_supports_page_tables_move())
+    return false;
  /*
   * The destination pud shouldn't be established, free_pgtables()
   * should have released it.





[kbuild] Re: [PATCH net-next v2 1/2] of: net: pass the dst buffer to of_get_mac_address()

2021-04-09 Thread Dan Carpenter
Hi Michael,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Michael-Walle/of-net-support-non-platform-devices-in-of_get_mac_address/20210406-234030
 
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git  
cc0626c2aaed8e475efdd85fa374b497a7192e35
config: x86_64-randconfig-m001-20210406 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 
Reported-by: Dan Carpenter 

smatch warnings:
drivers/net/ethernet/xilinx/xilinx_axienet_main.c:2069 axienet_probe() warn: 
passing a valid pointer to 'PTR_ERR'

vim +/PTR_ERR +2069 drivers/net/ethernet/xilinx/xilinx_axienet_main.c

2be586205ca2b8 Srikanth Thokala2015-05-05  1832  static int 
axienet_probe(struct platform_device *pdev)
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1833  {
8495659bf93c8e Srikanth Thokala2015-05-05  1834 int ret;
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1835 struct device_node *np;
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1836 struct axienet_local 
*lp;
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1837 struct net_device *ndev;
28ef9ebdb64c6f Robert Hancock  2019-06-06  1838 struct resource *ethres;
411b125c6ace1f Michael Walle   2021-04-06  1839 u8 mac_addr[ETH_ALEN];
^^

5fff0151b3244d Andre Przywara  2020-03-24  1840 int addr_width = 32;
8495659bf93c8e Srikanth Thokala2015-05-05  1841 u32 value;
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1842  
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1843 ndev = 
alloc_etherdev(sizeof(*lp));
41de8d4cff21a2 Joe Perches 2012-01-29  1844 if (!ndev)
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1845 return -ENOMEM;
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1846  
95219aa538e11d Srikanth Thokala2015-05-05  1847 
platform_set_drvdata(pdev, ndev);
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1848  
95219aa538e11d Srikanth Thokala2015-05-05  1849 SET_NETDEV_DEV(ndev, 
>dev);
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1850 ndev->flags &= 
~IFF_MULTICAST;  /* clear multicast */
28e24c62ab3062 Eric Dumazet2013-12-02  1851 ndev->features = 
NETIF_F_SG;
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1852 ndev->netdev_ops = 
_netdev_ops;
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1853 ndev->ethtool_ops = 
_ethtool_ops;
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1854  
d894be57ca92c8 Jarod Wilson2016-10-20  1855 /* MTU range: 64 - 9000 
*/
d894be57ca92c8 Jarod Wilson2016-10-20  1856 ndev->min_mtu = 64;
d894be57ca92c8 Jarod Wilson2016-10-20  1857 ndev->max_mtu = 
XAE_JUMBO_MTU;
d894be57ca92c8 Jarod Wilson2016-10-20  1858  
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1859 lp = netdev_priv(ndev);
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1860 lp->ndev = ndev;
95219aa538e11d Srikanth Thokala2015-05-05  1861 lp->dev = >dev;
8a3b7a252dca9f Daniel Borkmann 2012-01-19  1862 lp->options = 
XAE_OPTION_DEFAULTS;
8b09ca823ffb4e Robert Hancock  2019-06-06  1863 lp->rx_bd_num = 
RX_BD_NUM_DEFAULT;
8b09ca823ffb4e Robert Hancock  2019-06-06  1864 lp->tx_bd_num = 
TX_BD_NUM_DEFAULT;
57baf8cc70ea4c Robert Hancock  2021-02-12  1865  
b11bfb9a19f9d7 Robert Hancock  2021-03-25  1866 lp->axi_clk = 
devm_clk_get_optional(>dev, "s_axi_lite_clk");
b11bfb9a19f9d7 Robert Hancock  2021-03-25  1867 if (!lp->axi_clk) {
b11bfb9a19f9d7 Robert Hancock  2021-03-25  1868 /* For backward 
compatibility, if named AXI clock is not present,
b11bfb9a19f9d7 Robert Hancock  2021-03-25  1869  * treat the 
first clock specified as the AXI clock.
b11bfb9a19f9d7 Robert Hancock  2021-03-25  1870  */
b11bfb9a19f9d7 Robert Hancock  2021-03-25  1871 lp->axi_clk = 
devm_clk_get_optional(>dev, NULL);
b11bfb9a19f9d7 Robert Hancock  2021-03-25  1872 }
b11bfb9a19f9d7 Robert Hancock  2021-03-25  1873 if 
(IS_ERR(lp->axi_clk)) {
b11bfb9a19f9d7 Robert Hancock  2021-03-25  1874 ret = 
PTR_ERR(lp->axi_clk);
57baf8cc70ea4c Robert Hancock  2021-02-12  1875 goto 
free_netdev;
57baf8cc70ea4c Robert Hancock  2021-02-12  1876 }
b11bfb9a19f9d7 Robert Hancock  2021-03-25  1877 ret = 
clk_prepare_enable(lp->axi_clk);
57baf8cc70ea4c Robert Hancock  2021-02-12  1878 if (ret) {
b11bfb9a19f9d7 Robert Hancock  2021-03-25  1879 
dev_err(>dev, "Unable to enable AXI clock: %d\n", ret);
57baf8cc70ea4c Robert Hancock  2021-02-12  1880 goto 
free_netdev;
57baf8cc70ea4c Robert Hancock  2021-02-12  1881 }
57baf8cc70ea4c Robert Hancock  2021-02-12  1882  

[PATCH RESEND v8 0/7] dt-bindings: usb: Harmonize xHCI/EHCI/OHCI/DWC3 nodes name

2021-04-09 Thread Serge Semin
As the subject states this series is an attempt to harmonize the xHCI,
EHCI, OHCI and DWC USB3 DT nodes with the DT schema introduced in the
framework of the patchset [1].

Firstly as Krzysztof suggested we've deprecated a support of DWC USB3
controllers with "synopsys,"-vendor prefix compatible string in favor of
the ones with valid "snps,"-prefix. It's done in all the DTS files,
which have been unfortunate to define such nodes.

Secondly we suggest to fix the snps,quirk-frame-length-adjustment property
declaration in the Amlogic meson-g12-common.dtsi DTS file, since it has
been erroneously declared as boolean while having uint32 type. Neil said
it was ok to init that property with 0x20 value.

Thirdly the main part of the patchset concern fixing the xHCI, EHCI/OHCI
and DWC USB3 DT nodes name as in accordance with their DT schema the
corresponding node name is suppose to comply with the Generic USB HCD DT
schema, which requires the USB nodes to have the name acceptable by the
regexp: "^usb(@.*)?". Such requirement had been applicable even before we
introduced the new DT schema in [1], but as we can see it hasn't been
strictly implemented for a lot the DTS files. Since DT schema is now
available the automated DTS validation shall make sure that the rule isn't
violated.

Note most of these patches have been a part of the last three patches of
[1]. But since there is no way to have them merged in in a combined
manner, I had to move them to the dedicated series and split them up so to
be accepted by the corresponding subsystem maintainers one-by-one.

[1] Link: 
https://lore.kernel.org/linux-usb/20201014101402.18271-1-sergey.se...@baikalelectronics.ru/
Changelog v1:
- As Krzysztof suggested I've created a script which checked whether the
  node names had been also updated in all the depended dts files. As a
  result I found two more files which should have been also modified:
  arch/arc/boot/dts/{axc003.dtsi,axc003_idu.dtsi}
- Correct the USB DWC3 nodes name found in
  arch/arm64/boot/dts/apm/{apm-storm.dtsi,apm-shadowcat.dtsi} too.

Link: 
https://lore.kernel.org/linux-usb/20201020115959.2658-1-sergey.se...@baikalelectronics.ru
Changelog v2:
- Drop the patch:
  [PATCH 01/29] usb: dwc3: Discard synopsys,dwc3 compatibility string
  and get back the one which marks the "synopsys,dwc3" compatible string
  as deprecated into the DT schema related series.
- Drop the patches:
  [PATCH 03/29] arm: dts: am437x: Correct DWC USB3 compatible string
  [PATCH 04/29] arm: dts: exynos: Correct DWC USB3 compatible string
  [PATCH 07/29] arm: dts: bcm53x: Harmonize EHCI/OHCI DT nodes name
  [PATCH 08/29] arm: dts: stm32: Harmonize EHCI/OHCI DT nodes name
  [PATCH 16/29] arm: dts: bcm5301x: Harmonize xHCI DT nodes name
  [PATCH 19/29] arm: dts: exynos: Harmonize DWC USB3 DT nodes name
  [PATCH 21/29] arm: dts: ls1021a: Harmonize DWC USB3 DT nodes name
  [PATCH 22/29] arm: dts: omap5: Harmonize DWC USB3 DT nodes name
  [PATCH 24/29] arm64: dts: allwinner: h6: Harmonize DWC USB3 DT nodes name
  [PATCH 26/29] arm64: dts: exynos: Harmonize DWC USB3 DT nodes name
  [PATCH 27/29] arm64: dts: layerscape: Harmonize DWC USB3 DT nodes name
  since they have been applied to the corresponding maintainers repos.
- Fix drivers/usb/dwc3/dwc3-qcom.c to be looking for the "usb@"-prefixed
  sub-node and falling back to the "dwc3@"-prefixed one on failure.

Link: 
https://lore.kernel.org/linux-usb/2020091552.15593-1-sergey.se...@baikalelectronics.ru
Changelog v3:
- Drop the patches:
  [PATCH v2 04/18] arm: dts: hisi-x5hd2: Harmonize EHCI/OHCI DT nodes name
  [PATCH v2 06/18] arm64: dts: hisi: Harmonize EHCI/OHCI DT nodes name
  [PATCH v2 07/18] mips: dts: jz47x: Harmonize EHCI/OHCI DT nodes name
  [PATCH v2 08/18] mips: dts: sead3: Harmonize EHCI/OHCI DT nodes name
  [PATCH v2 09/18] mips: dts: ralink: mt7628a: Harmonize EHCI/OHCI DT nodes name
  [PATCH v2 11/18] arm64: dts: marvell: cp11x: Harmonize xHCI DT nodes name
  [PATCH v2 12/18] arm: dts: marvell: armada-375: Harmonize DWC USB3 DT nodes 
name
  [PATCH v2 16/18] arm64: dts: hi3660: Harmonize DWC USB3 DT nodes name
  since they have been applied to the corresponding maintainers repos.

Link: 
https://lore.kernel.org/linux-usb/20201205155621.3045-1-sergey.se...@baikalelectronics.ru
Changelog v4:
- Just resend.

Link: 
https://lore.kernel.org/linux-usb/20201210091756.18057-1-sergey.se...@baikalelectronics.ru/
Changelog v5:
- Drop the patch:
  [PATCH v4 02/10] arm64: dts: amlogic: meson-g12: Set FL-adj property value
  since it has been applied to the corresponding maintainers repos.
- Get back the patch:
  [PATCH 21/29] arm: dts: ls1021a: Harmonize DWC USB3 DT nodes name
  as it has been missing in the kernel 5.11-rc7
- Rebase onto the kernel 5.11-rc7.

Link: 
https://lore.kernel.org/lkml/20210208135154.6645-1-sergey.se...@baikalelectronics.ru/
Changelog v6:
- Just resend and add linux-usb.vger.kernel.org to the list of Ccecipients.

Link: 

[PATCH RESEND v8 3/7] powerpc: dts: akebono: Harmonize EHCI/OHCI DT nodes name

2021-04-09 Thread Serge Semin
In accordance with the Generic EHCI/OHCI bindings the corresponding node
name is suppose to comply with the Generic USB HCD DT schema, which
requires the USB nodes to have the name acceptable by the regexp:
"^usb(@.*)?" . Make sure the "generic-ehci" and "generic-ohci"-compatible
nodes are correctly named.

Signed-off-by: Serge Semin 
Acked-by: Krzysztof Kozlowski 
---
 arch/powerpc/boot/dts/akebono.dts | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/boot/dts/akebono.dts 
b/arch/powerpc/boot/dts/akebono.dts
index df18f8dc4642..343326c30380 100644
--- a/arch/powerpc/boot/dts/akebono.dts
+++ b/arch/powerpc/boot/dts/akebono.dts
@@ -126,7 +126,7 @@ SATA0: sata@301 {
interrupts = <93 2>;
};
 
-   EHCI0: ehci@3001000 {
+   EHCI0: usb@3001000 {
compatible = "ibm,476gtr-ehci", "generic-ehci";
reg = <0x300 0x1000 0x0 0x1>;
interrupt-parent = <>;
@@ -140,14 +140,14 @@ SD0: sd@300 {
interrupt-parent = <>;
};
 
-   OHCI0: ohci@3001001 {
+   OHCI0: usb@3001001 {
compatible = "ibm,476gtr-ohci", "generic-ohci";
reg = <0x300 0x1001 0x0 0x1>;
interrupt-parent = <>;
interrupts = <89 1>;
};
 
-   OHCI1: ohci@3001002 {
+   OHCI1: usb@3001002 {
compatible = "ibm,476gtr-ohci", "generic-ohci";
reg = <0x300 0x1002 0x0 0x1>;
interrupt-parent = <>;
-- 
2.30.1



Re: [PATCH v4 18/20] x86: Convert to GENERIC_CMDLINE

2021-04-09 Thread Christophe Leroy




Le 08/04/2021 à 21:41, Rob Herring a écrit :

On Fri, Apr 02, 2021 at 03:18:20PM +, Christophe Leroy wrote:

This converts the architecture to GENERIC_CMDLINE.

Signed-off-by: Christophe Leroy 
---
  arch/x86/Kconfig| 45 ++---
  arch/x86/kernel/setup.c | 17 ++--
  2 files changed, 4 insertions(+), 58 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index a20684d56b4b..66b384228ca3 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -104,6 +104,7 @@ config X86
select ARCH_USE_QUEUED_SPINLOCKS
select ARCH_USE_SYM_ANNOTATIONS
select ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
+   select ARCH_WANT_CMDLINE_PREPEND_BY_DEFAULT


Seems to be non-existent kconfig option.


Oops. Added in v5.


@@ -883,18 +881,7 @@ void __init setup_arch(char **cmdline_p)
bss_resource.start = __pa_symbol(__bss_start);
bss_resource.end = __pa_symbol(__bss_stop)-1;
  
-#ifdef CONFIG_CMDLINE_BOOL

-#ifdef CONFIG_CMDLINE_FORCE
-   strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-#else
-   if (builtin_cmdline[0]) {
-   /* append boot loader cmdline to builtin */
-   strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
-   strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
-   strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
-   }
-#endif
-#endif
+   cmdline_build(boot_command_line, boot_command_line);
  
  	strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);

*cmdline_p = command_line;


Once this is all done, I wonder if we can get rid of the strlcpy and
perhaps also cmdline_p.



It seems rather complicated, in init/main.c you have heavy manipulations of command lines which 
seems to be done in setup_command_line() which seems to add stuff in front of command lines, at the 
end we end up with several command lines:


/* Untouched saved command line (eg. for /proc) */
char *saved_command_line;
/* Command line for parameter parsing */
static char *static_command_line;
/* Untouched extra command line */
static char *extra_command_line;

Some of them come from the cmdline_p which others are from boot_command_line.

I think a cleanup on all that stuff would be worth it as a further step.


Re: [PATCH 1/1] powerpc/smp: Set numa node before updating mask

2021-04-09 Thread Srikar Dronamraju
Hey Nathan,

>
> Regardless of your change: at boot time, this set of calls to
> set_numa_node() and set_numa_mem() is redundant, right? Because
> smp_prepare_cpus() has:
>
>   for_each_possible_cpu(cpu) {
>   ...
>   if (cpu_present(cpu)) {
>   set_cpu_numa_node(cpu, numa_cpu_lookup_table[cpu]);
>   set_cpu_numa_mem(cpu,
>   local_memory_node(numa_cpu_lookup_table[cpu]));
>   }
>
> I would rather that, when onlining a CPU that happens to have been
> dynamically added after boot, we enter start_secondary() with conditions
> equivalent to those at boot time. Or as close to that as is practical.
>
> So I'd suggest that pseries_add_processor() be made to update
> these things when the CPUs are marked present, before onlining them.

I did try updating at pseries_add_processor when things were being marked as
present. But looks like the zonelists may not be updated at that time.
I saw couple of crashes in local_memory_node() when dplar adding CPUs.
(Appending the patch that causes these crash to this mail for your reference)

[  293.669901] Kernel attempted to read user page (1508) - exploit attempt? 
(uid: 0)
 [1309/17174]
[  293.669925] BUG: Kernel NULL pointer dereference on read at 0x1508
[  293.669935] Faulting instruction address: 0xc0484ae0
[  293.669947] Oops: Kernel access of bad area, sig: 11 [#1]
[  293.669956] LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries
[  293.669969] Modules linked in: nft_counter nft_compat rpadlpar_io rpaphp
mptcp_diag xsk_diag tcp_diag udp_diag raw_diag inet_diag unix_diag
af_packet_diag netlink_diag bonding tls nft_fib_inet nft_fib_ipv4 nft_ fib_ipv6
nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct
nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 rfkill ip_set
nf_tables nfnetlink dm_multipath pseries_rng xts vmx_c rypto uio_pdrv_genirq
uio binfmt_misc ip_tables xfs libcrc32c sd_mod t10_pi sg ibmvscsi ibmveth
scsi_transport_srp dm_mirror dm_region_hash dm_log dm_mod fuse
[  293.670101] CPU: 17 PID: 3183 Comm: drmgr Not tainted 5.12.0-rc5-master+ #2
[  293.670113] NIP:  c0484ae0 LR: c010a548 CTR: 006dd130
[  293.670121] REGS: c025a9997160 TRAP: 0300   Not tainted  
(5.12.0-rc5-master+)
[  293.670131] MSR:  80009033   CR: 48008422  
XER: 0008
[  293.670155] CFAR: c010a544 DAR: 1508 DSISR: 4000 
IRQMASK: 0
[  293.670155] GPR00: c010a548 c025a9997400 c1f55500 

[  293.670155] GPR04: c1a3c598 0006 0027 
c035873b8018
[  293.670155] GPR08: 0023 c20464f8 0035894d 
c03584c8ffe8
[  293.670155] GPR12: 28008424 c035bf22ce80  

[  293.670155] GPR16:    

[  293.670155] GPR20:    
c1fbc160
[  293.670155] GPR24: 0002 0200 c1fc04c8 
0001
[  293.670155] GPR28: c10c6fc8 c1fc08a0 c02f8fb99e60 
0040
[  293.670263] NIP [c0484ae0] local_memory_node+0x20/0x80
[  293.670281] LR [c010a548] pseries_add_processor+0x368/0x3b0
[  293.670292] Call Trace:
[  293.670297] [c025a9997400] [c010a524] 
pseries_add_processor+0x344/0x3b0 (unreliable)
[  293.670311] [c025a99976c0] [c010a790] 
pseries_smp_notifier+0x200/0x2a0
[  293.670322] [c025a9997780] [c0197288] 
blocking_notifier_call_chain+0xa8/0x110
[  293.670335] [c025a99977d0] [c0b27010] of_attach_node+0xc0/0x110
[  293.670347] [c025a9997830] [c01032a0] dlpar_attach_node+0x30/0x70
[  293.670358] [c025a99978a0] [c0109ac0] dlpar_cpu_add+0x1d0/0x510
[  293.670368] [c025a9997980] [c010a898] dlpar_cpu+0x68/0x6e0
[  293.670377] [c025a9997a80] [c01036b8] 
handle_dlpar_errorlog+0xf8/0x190
[  293.670388] [c025a9997af0] [c0103928] dlpar_store+0x178/0x4a0
[  293.670396] [c025a9997bb0] [c07df050] kobj_attr_store+0x30/0x50
[  293.670408] [c025a9997bd0] [c062f0b0] sysfs_kf_write+0x70/0xb0
[  293.670421] [c025a9997c10] [c062d4e0] 
kernfs_fop_write_iter+0x1d0/0x280
[  293.670432] [c025a9997c60] [c051673c] new_sync_write+0x14c/0x1d0
[  293.670445] [c025a9997d00] [c0519df4] vfs_write+0x264/0x380
[  293.670455] [c025a9997d60] [c051a0ec] ksys_write+0x7c/0x140
[  293.670464] [c025a9997db0] [c0032af0] 
system_call_exception+0x150/0x290
[  293.670475] [c025a9997e10] [c000d45c] 
system_call_common+0xec/0x278
[  293.670486] --- interrupt: c00 at 0x2025bd74

That leaves us with just 

[PATCH -next] [POWERPC] Rename get_property to of_get_property: use DEFINE_SPINLOCK() for spinlock

2021-04-09 Thread Ye Bin
spinlock can be initialized automatically with DEFINE_SPINLOCK()
rather than explicitly calling spin_lock_init().

Reported-by: Hulk Robot 
Signed-off-by: Ye Bin 
---
 drivers/macintosh/via-pmu-led.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c
index ae067ab2373d..2502119cff42 100644
--- a/drivers/macintosh/via-pmu-led.c
+++ b/drivers/macintosh/via-pmu-led.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 
-static spinlock_t pmu_blink_lock;
+static DEFINE_SPINLOCK(pmu_blink_lock);
 static struct adb_request pmu_blink_req;
 /* -1: no change, 0: request off, 1: request on */
 static int requested_change;
@@ -105,8 +105,6 @@ static int __init via_pmu_led_init(void)
return -ENODEV;
}
of_node_put(dt);
-
-   spin_lock_init(_blink_lock);
/* no outstanding req */
pmu_blink_req.complete = 1;
pmu_blink_req.done = pmu_req_done;



[PATCH -next] powerpc/pmac: Make some symbols static

2021-04-09 Thread Zucheng Zheng
ppc_override_l2cr/ppc_override_l2cr_value/has_l2cache symbol is not used
outside of setup.c, so commit marks it static.

Reported-by: Hulk Robot 
Signed-off-by: Zucheng Zheng 
---
 arch/powerpc/platforms/powermac/setup.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/powermac/setup.c 
b/arch/powerpc/platforms/powermac/setup.c
index 86aee3f2483f..db5107c80485 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -71,9 +71,9 @@
 
 #undef SHOW_GATWICK_IRQS
 
-int ppc_override_l2cr = 0;
-int ppc_override_l2cr_value;
-int has_l2cache = 0;
+static int ppc_override_l2cr;
+static int ppc_override_l2cr_value;
+static int has_l2cache;
 
 int pmac_newworld;
 
-- 
2.17.1



[PATCH -next] powerpc/pmac: remove not use symbol

2021-04-09 Thread Zucheng Zheng
sccdbg symbol is not used, so remove it

Reported-by: Hulk Robot 
Signed-off-by: Zucheng Zheng 
---
 arch/powerpc/platforms/powermac/setup.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/arch/powerpc/platforms/powermac/setup.c 
b/arch/powerpc/platforms/powermac/setup.c
index db5107c80485..df9ea37d5708 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -83,10 +83,6 @@ extern struct machdep_calls pmac_md;
 
 #define DEFAULT_ROOT_DEVICE Root_SDA1  /* sda1 - slightly silly choice */
 
-#ifdef CONFIG_PPC64
-int sccdbg;
-#endif
-
 sys_ctrler_t sys_ctrler = SYS_CTRLER_UNKNOWN;
 EXPORT_SYMBOL(sys_ctrler);
 
-- 
2.17.1



Re: [PATCH -next] [POWERPC] Rename get_property to of_get_property: use DEFINE_SPINLOCK() for spinlock

2021-04-09 Thread weiyongjun (A)



Rename get_property to of_get_property: use DEFINE_SPINLOCK() for spinlock

^

Please fix the module name in the patch subject.



spinlock can be initialized automatically with DEFINE_SPINLOCK()


rather than explicitly calling spin_lock_init().

Reported-by: Hulk Robot 
Signed-off-by: Ye Bin 
---
  drivers/macintosh/via-pmu-led.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/macintosh/via-pmu-led.c 
b/drivers/macintosh/via-pmu-led.c

index ae067ab2373d..2502119cff42 100644
--- a/drivers/macintosh/via-pmu-led.c
+++ b/drivers/macintosh/via-pmu-led.c
@@ -27,7 +27,7 @@
  #include 
  #include 
  -static spinlock_t pmu_blink_lock;
+static DEFINE_SPINLOCK(pmu_blink_lock);
  static struct adb_request pmu_blink_req;
  /* -1: no change, 0: request off, 1: request on */
  static int requested_change;
@@ -105,8 +105,6 @@ static int __init via_pmu_led_init(void)
  return -ENODEV;
  }
  of_node_put(dt);
-
-    spin_lock_init(_blink_lock);
  /* no outstanding req */
  pmu_blink_req.complete = 1;
  pmu_blink_req.done = pmu_req_done;



Re: [PATCH -next] [POWERPC] Rename get_property to of_get_property: use DEFINE_SPINLOCK() for spinlock

2021-04-09 Thread weiyongjun (A)

Rename get_property to of_get_property: use DEFINE_SPINLOCK() for spinlock

~

这是啥模块名?


在 2021/4/9 17:51, Ye Bin 写道:

spinlock can be initialized automatically with DEFINE_SPINLOCK()
rather than explicitly calling spin_lock_init().

Reported-by: Hulk Robot 
Signed-off-by: Ye Bin 
---
  drivers/macintosh/via-pmu-led.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c
index ae067ab2373d..2502119cff42 100644
--- a/drivers/macintosh/via-pmu-led.c
+++ b/drivers/macintosh/via-pmu-led.c
@@ -27,7 +27,7 @@
  #include 
  #include 
  
-static spinlock_t pmu_blink_lock;

+static DEFINE_SPINLOCK(pmu_blink_lock);
  static struct adb_request pmu_blink_req;
  /* -1: no change, 0: request off, 1: request on */
  static int requested_change;
@@ -105,8 +105,6 @@ static int __init via_pmu_led_init(void)
return -ENODEV;
}
of_node_put(dt);
-
-   spin_lock_init(_blink_lock);
/* no outstanding req */
pmu_blink_req.complete = 1;
pmu_blink_req.done = pmu_req_done;



[PATCH -next] soc: fsl: qe: use DEFINE_SPINLOCK() for spinlock

2021-04-09 Thread Ye Bin
spinlock can be initialized automatically with DEFINE_SPINLOCK()
rather than explicitly calling spin_lock_init().

Reported-by: Hulk Robot 
Signed-off-by: Ye Bin 
---
 drivers/soc/fsl/qe/qe_common.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/soc/fsl/qe/qe_common.c b/drivers/soc/fsl/qe/qe_common.c
index 654e9246ce6b..a0cb8e746879 100644
--- a/drivers/soc/fsl/qe/qe_common.c
+++ b/drivers/soc/fsl/qe/qe_common.c
@@ -26,7 +26,7 @@
 #include 
 
 static struct gen_pool *muram_pool;
-static spinlock_t cpm_muram_lock;
+static DEFINE_SPINLOCK(cpm_muram_lock);
 static void __iomem *muram_vbase;
 static phys_addr_t muram_pbase;
 
@@ -54,7 +54,6 @@ int cpm_muram_init(void)
if (muram_pbase)
return 0;
 
-   spin_lock_init(_muram_lock);
np = of_find_compatible_node(NULL, NULL, "fsl,cpm-muram-data");
if (!np) {
/* try legacy bindings */



[PATCH -next] macintosh/via-pmu: Use DEFINE_SPINLOCK() for spinlock

2021-04-09 Thread Ye Bin
spinlock can be initialized automatically with DEFINE_SPINLOCK()
rather than explicitly calling spin_lock_init().

Reported-by: Hulk Robot 
Signed-off-by: Ye Bin 
---
 drivers/macintosh/via-pmu.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 73e6ae88fafd..bab913e3541a 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -161,7 +161,7 @@ static unsigned char __iomem *gpio_reg;
 static int gpio_irq = 0;
 static int gpio_irq_enabled = -1;
 static volatile int pmu_suspended;
-static spinlock_t pmu_lock;
+static DEFINE_SPINLOCK(pmu_lock);
 static u8 pmu_intr_mask;
 static int pmu_version;
 static int drop_interrupts;
@@ -306,8 +306,6 @@ int __init find_via_pmu(void)
goto fail;
}
 
-   spin_lock_init(_lock);
-
pmu_has_adb = 1;
 
pmu_intr_mask = PMU_INT_PCEJECT |
@@ -389,8 +387,6 @@ int __init find_via_pmu(void)
 
pmu_kind = PMU_UNKNOWN;
 
-   spin_lock_init(_lock);
-
pmu_has_adb = 1;
 
pmu_intr_mask = PMU_INT_PCEJECT |



Re: [PATCH v6 33/48] KVM: PPC: Book3S HV P9: Improve exit timing accounting coverage

2021-04-09 Thread Alexey Kardashevskiy




On 05/04/2021 11:19, Nicholas Piggin wrote:

The C conversion caused exit timing to become a bit cramped. Expand it
to cover more of the entry and exit code.

Signed-off-by: Nicholas Piggin 



Reviewed-by: Alexey Kardashevskiy 


---
  arch/powerpc/kvm/book3s_hv_interrupt.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv_interrupt.c 
b/arch/powerpc/kvm/book3s_hv_interrupt.c
index e93d2a6456ff..44c77f907f91 100644
--- a/arch/powerpc/kvm/book3s_hv_interrupt.c
+++ b/arch/powerpc/kvm/book3s_hv_interrupt.c
@@ -154,6 +154,8 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 
time_limit, unsigned long lpc
if (hdec < 0)
return BOOK3S_INTERRUPT_HV_DECREMENTER;
  
+	start_timing(vcpu, >arch.rm_entry);

+
if (vc->tb_offset) {
u64 new_tb = tb + vc->tb_offset;
mtspr(SPRN_TBU40, new_tb);
@@ -204,8 +206,6 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 
time_limit, unsigned long lpc
 */
mtspr(SPRN_HDEC, hdec);
  
-	start_timing(vcpu, >arch.rm_entry);

-
vcpu->arch.ceded = 0;
  
  	WARN_ON_ONCE(vcpu->arch.shregs.msr & MSR_HV);

@@ -349,8 +349,6 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 
time_limit, unsigned long lpc
  
  	accumulate_time(vcpu, >arch.rm_exit);
  
-	end_timing(vcpu);

-
/* Advance host PURR/SPURR by the amount used by guest */
purr = mfspr(SPRN_PURR);
spurr = mfspr(SPRN_SPURR);
@@ -415,6 +413,8 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 
time_limit, unsigned long lpc
  
  	switch_mmu_to_host_radix(kvm, host_pidr);
  
+	end_timing(vcpu);

+
return trap;
  }
  EXPORT_SYMBOL_GPL(kvmhv_vcpu_entry_p9);



--
Alexey


Re: [PATCH v3 8/9] mm/mremap: Allow arch runtime override

2021-04-09 Thread Christophe Leroy




Le 30/03/2021 à 08:07, Aneesh Kumar K.V a écrit :

Architectures like ppc64 can only support faster mremap only with radix


... only  only ...


translation. Hence allow a runtime check w.r.t support for fast mremap.

Signed-off-by: Aneesh Kumar K.V 
---
  arch/arc/include/asm/tlb.h |  5 +
  arch/arm64/include/asm/tlb.h   |  6 ++
  arch/powerpc/include/asm/tlb.h |  6 ++
  arch/x86/include/asm/tlb.h |  5 +
  mm/mremap.c| 14 +-
  5 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/arch/arc/include/asm/tlb.h b/arch/arc/include/asm/tlb.h
index 975b35d3738d..22b8cfb46cbf 100644
--- a/arch/arc/include/asm/tlb.h
+++ b/arch/arc/include/asm/tlb.h
@@ -9,4 +9,9 @@
  #include 
  #include 
  
+#define arch_supports_page_tables_move arch_supports_page_tables_move

+static inline bool arch_supports_page_tables_move(void)
+{
+   return true;
+}


I can't see why ARC arch needs that. It neither selects CONFIG_HAVE_MOVE_PMD 
nor CONFIG_HAVE_MOVE_PUD.



  #endif /* _ASM_ARC_TLB_H */
diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h
index 61c97d3b58c7..fe209efc6a10 100644
--- a/arch/arm64/include/asm/tlb.h
+++ b/arch/arm64/include/asm/tlb.h
@@ -94,4 +94,10 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, 
pud_t *pudp,
  }
  #endif
  
+#define arch_supports_page_tables_move arch_supports_page_tables_move

+static inline bool arch_supports_page_tables_move(void)
+{
+   return true;
+}
+
  #endif
diff --git a/arch/powerpc/include/asm/tlb.h b/arch/powerpc/include/asm/tlb.h
index 160422a439aa..058918a7cd3c 100644
--- a/arch/powerpc/include/asm/tlb.h
+++ b/arch/powerpc/include/asm/tlb.h
@@ -83,5 +83,11 @@ static inline int mm_is_thread_local(struct mm_struct *mm)
  }
  #endif
  
+#define arch_supports_page_tables_move arch_supports_page_tables_move

+static inline bool arch_supports_page_tables_move(void)
+{
+   return radix_enabled();
+}
+
  #endif /* __KERNEL__ */
  #endif /* __ASM_POWERPC_TLB_H */
diff --git a/arch/x86/include/asm/tlb.h b/arch/x86/include/asm/tlb.h
index 1bfe979bb9bc..62915238bb36 100644
--- a/arch/x86/include/asm/tlb.h
+++ b/arch/x86/include/asm/tlb.h
@@ -37,4 +37,9 @@ static inline void __tlb_remove_table(void *table)
free_page_and_swap_cache(table);
  }
  
+#define arch_supports_page_tables_move arch_supports_page_tables_move

+static inline bool arch_supports_page_tables_move(void)
+{
+   return true;
+}
  #endif /* _ASM_X86_TLB_H */
diff --git a/mm/mremap.c b/mm/mremap.c
index 7ac1df8e6d51..4d812af3e44b 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -25,7 +25,7 @@
  #include 
  
  #include 

-#include 
+#include 
  #include 
  
  #include "internal.h"

@@ -221,6 +221,14 @@ static inline void flush_pte_tlb_pwc_range(struct 
vm_area_struct *vma,
  }
  #endif
  
+#ifndef arch_supports_page_tables_move

+#define arch_supports_page_tables_move arch_supports_page_tables_move
+static inline bool arch_supports_page_tables_move(void)
+{
+   return false;


Can you do

return IS_ENABLED(CONFIG_HAVE_MOVE_PMD) || 
IS_ENABLED(CONFIG_HAVE_MOVE_PUD);

And then remove the arch_supports_page_tables_move() you have added for arc, 
arm64 and x86 ?


+}
+#endif
+
  #ifdef CONFIG_HAVE_MOVE_PMD


Next step could be remove that #ifdef and the content of the matching #else
For that we'd just need a stub version of set_pmd_at() and set_pud_at().


  static bool move_normal_pmd(struct vm_area_struct *vma, unsigned long 
old_addr,
  unsigned long new_addr, pmd_t *old_pmd, pmd_t *new_pmd)
@@ -229,6 +237,8 @@ static bool move_normal_pmd(struct vm_area_struct *vma, 
unsigned long old_addr,
struct mm_struct *mm = vma->vm_mm;
pmd_t pmd;
  
+	if (!arch_supports_page_tables_move())

+   return false;
/*
 * The destination pmd shouldn't be established, free_pgtables()
 * should have released it.
@@ -295,6 +305,8 @@ static bool move_normal_pud(struct vm_area_struct *vma, 
unsigned long old_addr,
struct mm_struct *mm = vma->vm_mm;
pud_t pud;
  
+	if (!arch_supports_page_tables_move())

+   return false;
/*
 * The destination pud shouldn't be established, free_pgtables()
 * should have released it.



Re: [PATCH v3 5/9] powerpc/mm/book3s64: Update tlb flush routines to take a page walk cache flush argument

2021-04-09 Thread Christophe Leroy




Le 30/03/2021 à 08:07, Aneesh Kumar K.V a écrit :

Signed-off-by: Aneesh Kumar K.V 
---
  .../include/asm/book3s/64/tlbflush-radix.h| 19 ---
  arch/powerpc/include/asm/book3s/64/tlbflush.h | 23 +++
  arch/powerpc/mm/book3s64/radix_hugetlbpage.c  |  4 ++--
  arch/powerpc/mm/book3s64/radix_tlb.c  | 23 ---
  4 files changed, 42 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h 
b/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h
index 8b33601cdb9d..90c91f7b526f 100644
--- a/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h
+++ b/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h
@@ -56,15 +56,18 @@ static inline void radix__flush_all_lpid_guest(unsigned int 
lpid)
  }
  #endif
  
-extern void radix__flush_hugetlb_tlb_range(struct vm_area_struct *vma,

-  unsigned long start, unsigned long 
end);
-extern void radix__flush_tlb_range_psize(struct mm_struct *mm, unsigned long 
start,
-unsigned long end, int psize);
-extern void radix__flush_pmd_tlb_range(struct vm_area_struct *vma,
-  unsigned long start, unsigned long end);
-extern void radix__flush_tlb_range(struct vm_area_struct *vma, unsigned long 
start,
+void radix__flush_hugetlb_tlb_range(struct vm_area_struct *vma,
+   unsigned long start, unsigned long end,
+   bool also_pwc);


No sure 'also_pwc' is a nice name.

What about 'flush_pwc' ?



+void radix__flush_pmd_tlb_range(struct vm_area_struct *vma,
+   unsigned long start, unsigned long end,
+   bool also_pwc);
+void radix__flush_tlb_pwc_range_psize(struct mm_struct *mm, unsigned long 
start,
+ unsigned long end, int psize, bool 
also_pwc);
+void radix__flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
unsigned long end);
-extern void radix__flush_tlb_kernel_range(unsigned long start, unsigned long 
end);
+void radix__flush_tlb_kernel_range(unsigned long start, unsigned long end);
+
  
  extern void radix__local_flush_tlb_mm(struct mm_struct *mm);

  extern void radix__local_flush_all_mm(struct mm_struct *mm);
diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush.h 
b/arch/powerpc/include/asm/book3s/64/tlbflush.h
index 215973b4cb26..efe5336e2b6f 100644
--- a/arch/powerpc/include/asm/book3s/64/tlbflush.h
+++ b/arch/powerpc/include/asm/book3s/64/tlbflush.h
@@ -45,13 +45,30 @@ static inline void tlbiel_all_lpid(bool radix)
hash__tlbiel_all(TLB_INVAL_SCOPE_LPID);
  }
  
+static inline void flush_pmd_tlb_pwc_range(struct vm_area_struct *vma,

+  unsigned long start,
+  unsigned long end,
+  bool also_pwc)
+{
+   if (radix_enabled())
+   return radix__flush_pmd_tlb_range(vma, start, end, also_pwc);
+   return hash__flush_tlb_range(vma, start, end);
+}
  
  #define __HAVE_ARCH_FLUSH_PMD_TLB_RANGE

  static inline void flush_pmd_tlb_range(struct vm_area_struct *vma,
   unsigned long start, unsigned long end)
+{
+   return flush_pmd_tlb_pwc_range(vma, start, end, false);
+}
+
+static inline void flush_hugetlb_tlb_pwc_range(struct vm_area_struct *vma,
+  unsigned long start,
+  unsigned long end,
+  bool also_pwc)
  {
if (radix_enabled())
-   return radix__flush_pmd_tlb_range(vma, start, end);
+   return radix__flush_hugetlb_tlb_range(vma, start, end, 
also_pwc);
return hash__flush_tlb_range(vma, start, end);
  }
  
@@ -60,9 +77,7 @@ static inline void flush_hugetlb_tlb_range(struct vm_area_struct *vma,

   unsigned long start,
   unsigned long end)
  {
-   if (radix_enabled())
-   return radix__flush_hugetlb_tlb_range(vma, start, end);
-   return hash__flush_tlb_range(vma, start, end);
+   return flush_hugetlb_tlb_pwc_range(vma, start, end, false);
  }
  
  static inline void flush_tlb_range(struct vm_area_struct *vma,

diff --git a/arch/powerpc/mm/book3s64/radix_hugetlbpage.c 
b/arch/powerpc/mm/book3s64/radix_hugetlbpage.c
index cb91071eef52..55c5c9c39ae2 100644
--- a/arch/powerpc/mm/book3s64/radix_hugetlbpage.c
+++ b/arch/powerpc/mm/book3s64/radix_hugetlbpage.c
@@ -26,13 +26,13 @@ void radix__local_flush_hugetlb_page(struct vm_area_struct 
*vma, unsigned long v
  }
  
  void radix__flush_hugetlb_tlb_range(struct vm_area_struct *vma, unsigned long start,

-  unsigned long end)
+   

Re: [PATCH v3 4/9] powerpc/mm/book3s64: Fix possible build error

2021-04-09 Thread Christophe Leroy




Le 30/03/2021 à 08:07, Aneesh Kumar K.V a écrit :

Update _tlbiel_pid() such that we can avoid build errors like below when
using this function in other places.

arch/powerpc/mm/book3s64/radix_tlb.c: In function 
‘__radix__flush_tlb_range_psize’:
arch/powerpc/mm/book3s64/radix_tlb.c:114:2: warning: ‘asm’ operand 3 probably 
does not match constraints
   114 |  asm volatile(PPC_TLBIEL(%0, %4, %3, %2, %1)
   |  ^~~
arch/powerpc/mm/book3s64/radix_tlb.c:114:2: error: impossible constraint in 
‘asm’
make[4]: *** [scripts/Makefile.build:271: arch/powerpc/mm/book3s64/radix_tlb.o] 
Error 1
m

With this fix, we can also drop the __always_inline in 
__radix_flush_tlb_range_psize
which was added by commit e12d6d7d46a6 ("powerpc/mm/radix: mark 
__radix__flush_tlb_range_psize() as __always_inline")

Signed-off-by: Aneesh Kumar K.V 


Reviewed-by: Christophe Leroy 


---
  arch/powerpc/mm/book3s64/radix_tlb.c | 26 +-
  1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/mm/book3s64/radix_tlb.c 
b/arch/powerpc/mm/book3s64/radix_tlb.c
index 409e61210789..817a02ef6032 100644
--- a/arch/powerpc/mm/book3s64/radix_tlb.c
+++ b/arch/powerpc/mm/book3s64/radix_tlb.c
@@ -291,22 +291,30 @@ static inline void fixup_tlbie_lpid(unsigned long lpid)
  /*
   * We use 128 set in radix mode and 256 set in hpt mode.
   */
-static __always_inline void _tlbiel_pid(unsigned long pid, unsigned long ric)
+static inline void _tlbiel_pid(unsigned long pid, unsigned long ric)
  {
int set;
  
  	asm volatile("ptesync": : :"memory");
  
-	/*

-* Flush the first set of the TLB, and if we're doing a RIC_FLUSH_ALL,
-* also flush the entire Page Walk Cache.
-*/
-   __tlbiel_pid(pid, 0, ric);
+   switch (ric) {
+   case RIC_FLUSH_PWC:
  
-	/* For PWC, only one flush is needed */

-   if (ric == RIC_FLUSH_PWC) {
+   /* For PWC, only one flush is needed */
+   __tlbiel_pid(pid, 0, RIC_FLUSH_PWC);
ppc_after_tlbiel_barrier();
return;
+   case RIC_FLUSH_TLB:
+   __tlbiel_pid(pid, 0, RIC_FLUSH_TLB);
+   break;
+   case RIC_FLUSH_ALL:
+   default:
+   /*
+* Flush the first set of the TLB, and if
+* we're doing a RIC_FLUSH_ALL, also flush
+* the entire Page Walk Cache.
+*/
+   __tlbiel_pid(pid, 0, RIC_FLUSH_ALL);
}
  
  	if (!cpu_has_feature(CPU_FTR_ARCH_31)) {

@@ -1176,7 +1184,7 @@ void radix__tlb_flush(struct mmu_gather *tlb)
}
  }
  
-static __always_inline void __radix__flush_tlb_range_psize(struct mm_struct *mm,

+static void __radix__flush_tlb_range_psize(struct mm_struct *mm,
unsigned long start, unsigned long end,
int psize, bool also_pwc)
  {



[PATCH -next] powerpc/perf/hv-24x7: Make some symbols static

2021-04-09 Thread Bixuan Cui
The sparse tool complains as follows:

arch/powerpc/perf/hv-24x7.c:229:1: warning:
 symbol '__pcpu_scope_hv_24x7_txn_flags' was not declared. Should it be static?
arch/powerpc/perf/hv-24x7.c:230:1: warning:
 symbol '__pcpu_scope_hv_24x7_txn_err' was not declared. Should it be static?
arch/powerpc/perf/hv-24x7.c:236:1: warning:
 symbol '__pcpu_scope_hv_24x7_hw' was not declared. Should it be static?
arch/powerpc/perf/hv-24x7.c:244:1: warning:
 symbol '__pcpu_scope_hv_24x7_reqb' was not declared. Should it be static?
arch/powerpc/perf/hv-24x7.c:245:1: warning:
 symbol '__pcpu_scope_hv_24x7_resb' was not declared. Should it be static?

This symbol is not used outside of hv-24x7.c, so this
commit marks it static.

Reported-by: Hulk Robot 
Signed-off-by: Bixuan Cui 
---
 arch/powerpc/perf/hv-24x7.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index e5eb33255066..1816f560a465 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -226,14 +226,14 @@ static struct attribute_group event_long_desc_group = {
 
 static struct kmem_cache *hv_page_cache;
 
-DEFINE_PER_CPU(int, hv_24x7_txn_flags);
-DEFINE_PER_CPU(int, hv_24x7_txn_err);
+static DEFINE_PER_CPU(int, hv_24x7_txn_flags);
+static DEFINE_PER_CPU(int, hv_24x7_txn_err);
 
 struct hv_24x7_hw {
struct perf_event *events[255];
 };
 
-DEFINE_PER_CPU(struct hv_24x7_hw, hv_24x7_hw);
+static DEFINE_PER_CPU(struct hv_24x7_hw, hv_24x7_hw);
 
 /*
  * request_buffer and result_buffer are not required to be 4k aligned,
@@ -241,8 +241,8 @@ DEFINE_PER_CPU(struct hv_24x7_hw, hv_24x7_hw);
  * the simplest way to ensure that.
  */
 #define H24x7_DATA_BUFFER_SIZE 4096
-DEFINE_PER_CPU(char, hv_24x7_reqb[H24x7_DATA_BUFFER_SIZE]) __aligned(4096);
-DEFINE_PER_CPU(char, hv_24x7_resb[H24x7_DATA_BUFFER_SIZE]) __aligned(4096);
+static DEFINE_PER_CPU(char, hv_24x7_reqb[H24x7_DATA_BUFFER_SIZE]) 
__aligned(4096);
+static DEFINE_PER_CPU(char, hv_24x7_resb[H24x7_DATA_BUFFER_SIZE]) 
__aligned(4096);
 
 static unsigned int max_num_requests(int interface_version)
 {



[PATCH -next] powerpc/perf: Make symbol 'isa207_pmu_format_attr' static

2021-04-09 Thread Bixuan Cui
The sparse tool complains as follows:

arch/powerpc/perf/isa207-common.c:24:18: warning:
 symbol 'isa207_pmu_format_attr' was not declared. Should it be static?

This symbol is not used outside of isa207-common.c, so this
commit marks it static.

Reported-by: Hulk Robot 
Signed-off-by: Bixuan Cui 
---
 arch/powerpc/perf/isa207-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/perf/isa207-common.c 
b/arch/powerpc/perf/isa207-common.c
index e4f577da33d8..487f9e914b5c 100644
--- a/arch/powerpc/perf/isa207-common.c
+++ b/arch/powerpc/perf/isa207-common.c
@@ -21,7 +21,7 @@ PMU_FORMAT_ATTR(thresh_stop,  "config:32-35");
 PMU_FORMAT_ATTR(thresh_start,  "config:36-39");
 PMU_FORMAT_ATTR(thresh_cmp,"config:40-49");
 
-struct attribute *isa207_pmu_format_attr[] = {
+static struct attribute *isa207_pmu_format_attr[] = {
_attr_event.attr,
_attr_pmcxsel.attr,
_attr_mark.attr,



[PATCH -next] powerpc/pseries/pmem: Make symbol 'drc_pmem_match' static

2021-04-09 Thread Bixuan Cui
The sparse tool complains as follows:

arch/powerpc/platforms/pseries/pmem.c:142:27: warning:
 symbol 'drc_pmem_match' was not declared. Should it be static?

This symbol is not used outside of pmem.c, so this
commit marks it static.

Reported-by: Hulk Robot 
Signed-off-by: Bixuan Cui 
---
 arch/powerpc/platforms/pseries/pmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/pmem.c 
b/arch/powerpc/platforms/pseries/pmem.c
index e1dc5d3254df..439ac72c2470 100644
--- a/arch/powerpc/platforms/pseries/pmem.c
+++ b/arch/powerpc/platforms/pseries/pmem.c
@@ -139,7 +139,7 @@ int dlpar_hp_pmem(struct pseries_hp_errorlog *hp_elog)
return rc;
 }
 
-const struct of_device_id drc_pmem_match[] = {
+static const struct of_device_id drc_pmem_match[] = {
{ .type = "ibm,persistent-memory", },
{}
 };



[PATCH -next] powerpc/pseries: Make symbol '__pcpu_scope_hcall_stats' static

2021-04-09 Thread Bixuan Cui
The sparse tool complains as follows:

arch/powerpc/platforms/pseries/hvCall_inst.c:29:1: warning:
 symbol '__pcpu_scope_hcall_stats' was not declared. Should it be static?

This symbol is not used outside of hvCall_inst.c, so this
commit marks it static.

Reported-by: Hulk Robot 
Signed-off-by: Bixuan Cui 
---
 arch/powerpc/platforms/pseries/hvCall_inst.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/hvCall_inst.c 
b/arch/powerpc/platforms/pseries/hvCall_inst.c
index 2c59b4986ea5..3a50612a78db 100644
--- a/arch/powerpc/platforms/pseries/hvCall_inst.c
+++ b/arch/powerpc/platforms/pseries/hvCall_inst.c
@@ -26,7 +26,7 @@ struct hcall_stats {
 };
 #define HCALL_STAT_ARRAY_SIZE  ((MAX_HCALL_OPCODE >> 2) + 1)
 
-DEFINE_PER_CPU(struct hcall_stats[HCALL_STAT_ARRAY_SIZE], hcall_stats);
+static DEFINE_PER_CPU(struct hcall_stats[HCALL_STAT_ARRAY_SIZE], hcall_stats);
 
 /*
  * Routines for displaying the statistics in debugfs



Re: [PATCH v6 32/48] KVM: PPC: Book3S HV P9: Read machine check registers while MSR[RI] is 0

2021-04-09 Thread Alexey Kardashevskiy




On 05/04/2021 11:19, Nicholas Piggin wrote:

SRR0/1, DAR, DSISR must all be protected from machine check which can
clobber them. Ensure MSR[RI] is clear while they are live.

Signed-off-by: Nicholas Piggin 
---
  arch/powerpc/kvm/book3s_hv.c   | 11 +++--
  arch/powerpc/kvm/book3s_hv_interrupt.c | 33 +++---
  arch/powerpc/kvm/book3s_hv_ras.c   |  2 ++
  3 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index d6eecedaa5a5..5f0ac6567a06 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -3567,11 +3567,16 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, 
u64 time_limit,
mtspr(SPRN_BESCR, vcpu->arch.bescr);
mtspr(SPRN_WORT, vcpu->arch.wort);
mtspr(SPRN_TIDR, vcpu->arch.tid);
-   mtspr(SPRN_DAR, vcpu->arch.shregs.dar);
-   mtspr(SPRN_DSISR, vcpu->arch.shregs.dsisr);
mtspr(SPRN_AMR, vcpu->arch.amr);
mtspr(SPRN_UAMOR, vcpu->arch.uamor);
  
+	/*

+* DAR, DSISR, and for nested HV, SPRGs must be set with MSR[RI]
+* clear (or hstate set appropriately to catch those registers
+* being clobbered if we take a MCE or SRESET), so those are done
+* later.
+*/
+
if (!(vcpu->arch.ctrl & 1))
mtspr(SPRN_CTRLT, mfspr(SPRN_CTRLF) & ~1);
  
@@ -3614,6 +3619,8 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,

hvregs.vcpu_token = vcpu->vcpu_id;
}
hvregs.hdec_expiry = time_limit;
+   mtspr(SPRN_DAR, vcpu->arch.shregs.dar);
+   mtspr(SPRN_DSISR, vcpu->arch.shregs.dsisr);
trap = plpar_hcall_norets(H_ENTER_NESTED, __pa(),
  __pa(>arch.regs));
kvmhv_restore_hv_return_state(vcpu, );
diff --git a/arch/powerpc/kvm/book3s_hv_interrupt.c 
b/arch/powerpc/kvm/book3s_hv_interrupt.c
index 6fdd93936e16..e93d2a6456ff 100644
--- a/arch/powerpc/kvm/book3s_hv_interrupt.c
+++ b/arch/powerpc/kvm/book3s_hv_interrupt.c
@@ -132,6 +132,7 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 
time_limit, unsigned long lpc
s64 hdec;
u64 tb, purr, spurr;
u64 *exsave;
+   bool ri_set;
unsigned long msr = mfmsr();
int trap;
unsigned long host_hfscr = mfspr(SPRN_HFSCR);
@@ -203,9 +204,6 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 
time_limit, unsigned long lpc
 */
mtspr(SPRN_HDEC, hdec);
  
-	mtspr(SPRN_SRR0, vcpu->arch.shregs.srr0);

-   mtspr(SPRN_SRR1, vcpu->arch.shregs.srr1);
-
start_timing(vcpu, >arch.rm_entry);
  
  	vcpu->arch.ceded = 0;

@@ -231,6 +229,13 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 
time_limit, unsigned long lpc
 */
mtspr(SPRN_HDSISR, HDSISR_CANARY);
  
+	__mtmsrd(0, 1); /* clear RI */

+
+   mtspr(SPRN_DAR, vcpu->arch.shregs.dar);
+   mtspr(SPRN_DSISR, vcpu->arch.shregs.dsisr);
+   mtspr(SPRN_SRR0, vcpu->arch.shregs.srr0);
+   mtspr(SPRN_SRR1, vcpu->arch.shregs.srr1);
+
accumulate_time(vcpu, >arch.guest_time);
  
  	local_paca->kvm_hstate.in_guest = KVM_GUEST_MODE_GUEST_HV_FAST;

@@ -248,7 +253,13 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 
time_limit, unsigned long lpc
  
  	/* 0x2 bit for HSRR is only used by PR and P7/8 HV paths, clear it */

trap = local_paca->kvm_hstate.scratch0 & ~0x2;
+
+   /* HSRR interrupts leave MSR[RI] unchanged, SRR interrupts clear it. */
+   ri_set = false;
if (likely(trap > BOOK3S_INTERRUPT_MACHINE_CHECK)) {
+   if (trap != BOOK3S_INTERRUPT_SYSCALL &&
+   (vcpu->arch.shregs.msr & MSR_RI))
+   ri_set = true;
exsave = local_paca->exgen;
} else if (trap == BOOK3S_INTERRUPT_SYSTEM_RESET) {
exsave = local_paca->exnmi;
@@ -258,6 +269,22 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 
time_limit, unsigned long lpc
  
  	vcpu->arch.regs.gpr[1] = local_paca->kvm_hstate.scratch1;

vcpu->arch.regs.gpr[3] = local_paca->kvm_hstate.scratch2;
+
+   /*
+* Only set RI after reading machine check regs (DAR, DSISR, SRR0/1)
+* and hstate scratch (which we need to move into exsave to make
+* re-entrant vs SRESET/MCE)
+*/
+   if (ri_set) {
+   if (unlikely(!(mfmsr() & MSR_RI))) {
+   __mtmsrd(MSR_RI, 1);
+   WARN_ON_ONCE(1);
+   }
+   } else {
+   WARN_ON_ONCE(mfmsr() & MSR_RI);
+   __mtmsrd(MSR_RI, 1);
+   }
+
vcpu->arch.regs.gpr[9] = exsave[EX_R9/sizeof(u64)];
vcpu->arch.regs.gpr[10] = exsave[EX_R10/sizeof(u64)];
vcpu->arch.regs.gpr[11] = exsave[EX_R11/sizeof(u64)];
diff --git a/arch/powerpc/kvm/book3s_hv_ras.c b/arch/powerpc/kvm/book3s_hv_ras.c
index 

[PATCH] [V2]powerpc/dts: fix not include DTC_FLAGS

2021-04-09 Thread Youlin Song
A central rule exists to create `$(obj)/%.dtb` from
`$(src)/%.dts`,DTC_FLAGS flag must be used with it.
See other architecture and Documentation:
arch/microblaze/boot/dts/Makefile
Documentation/kbuild/makefiles.rst +1433

Signed-off-by: Youlin Song 
---
 arch/powerpc/boot/Makefile | 2 --
 arch/powerpc/boot/dts/Makefile | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 2b8da923ceca..a3bc3aec3c0c 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -72,8 +72,6 @@ endif
 
 BOOTCFLAGS += -I$(objtree)/$(obj) -I$(srctree)/$(obj)
 
-DTC_FLAGS  ?= -p 1024
-
 $(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
 $(obj)/ebony.o: BOOTCFLAGS += -mcpu=440
 $(obj)/cuboot-hotfoot.o: BOOTCFLAGS += -mcpu=405
diff --git a/arch/powerpc/boot/dts/Makefile b/arch/powerpc/boot/dts/Makefile
index fb335d05aae8..c21165c0cd76 100644
--- a/arch/powerpc/boot/dts/Makefile
+++ b/arch/powerpc/boot/dts/Makefile
@@ -2,5 +2,6 @@
 
 subdir-y += fsl
 
+DTC_FLAGS   ?= -p 1024
 dtstree:= $(srctree)/$(src)
 dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard 
$(dtstree)/*.dts))
-- 
2.25.1



Re: [PATCH v1 1/1] kernel.h: Split out panic and oops helpers

2021-04-09 Thread Andy Shevchenko
On Thu, Apr 08, 2021 at 11:23:03PM -0700, Andrew Morton wrote:
> On Wed, 7 Apr 2021 11:46:37 +0300 Andy Shevchenko  
> wrote:
> 
> > On Wed, Apr 7, 2021 at 11:17 AM Kees Cook  wrote:
> > >
> > > On Tue, Apr 06, 2021 at 04:31:58PM +0300, Andy Shevchenko wrote:
> > > > kernel.h is being used as a dump for all kinds of stuff for a long time.
> > > > Here is the attempt to start cleaning it up by splitting out panic and
> > > > oops helpers.
> > > >
> > > > At the same time convert users in header and lib folder to use new 
> > > > header.
> > > > Though for time being include new header back to kernel.h to avoid 
> > > > twisted
> > > > indirected includes for existing users.
> > > >
> > > > Signed-off-by: Andy Shevchenko 
> > >
> > > I like it! Do you have a multi-arch CI to do allmodconfig builds to
> > > double-check this?
> > 
> > Unfortunately no, I rely on plenty of bots that are harvesting mailing 
> > lists.
> > 
> > But I will appreciate it if somebody can run this through various build 
> > tests.
> > 
> 
> um, did you try x86_64 allmodconfig?
> 
> I'm up to
> kernelh-split-out-panic-and-oops-helpers-fix-fix-fix-fix-fix-fix-fix.patch
> and counting.


I will try on my side and will fix those, thanks!

> and drivers/leds/trigger/ledtrig-heartbeat.c as well.
> 
> I'll drop it.

No problem, thanks for the report.

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH] powerpc/dts: fix not include DTC_FLAGS

2021-04-09 Thread Sam Song
 In my test, DTC_FLAGS in arch/powerpc/boot/Makefile is not to work,I will
send V2 to removing it.

Michael Ellerman  于2021年4月7日周三 下午7:27写道:

> Youlin Song  writes:
> > I wanted to build the fsl dts in my machine and found that
> > the dtb have not extra space,so uboot will cause about
> > FDT_ERR_NOSPACE issue.
> >
> > Signed-off-by: Youlin Song 
> > ---
> >  arch/powerpc/boot/dts/Makefile | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/arch/powerpc/boot/dts/Makefile
> b/arch/powerpc/boot/dts/Makefile
> > index fb335d05aae8..c21165c0cd76 100644
> > --- a/arch/powerpc/boot/dts/Makefile
> > +++ b/arch/powerpc/boot/dts/Makefile
> > @@ -2,5 +2,6 @@
> >
> >  subdir-y += fsl
> >
> > +DTC_FLAGS   ?= -p 1024
> >  dtstree  := $(srctree)/$(src)
> >  dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(dtstree)/%.dts,%.dtb,
> $(wildcard $(dtstree)/*.dts))
>
> I guess that was missed in 1acf1cf8638a ("powerpc: build .dtb files in dts
> directory").
>
> Which I think means the assignment to DTC_FLAGS in
> arch/powerpc/boot/Makefile is not needed anymore.
>
> Can you send a v2 removing that assignment and explaining that's what
> happened?
>
> cheers
>


Re: [PATCH v2 2/4] powerpc/selftests/perf-hwbreak: Coalesce event creation code

2021-04-09 Thread Daniel Axtens
Hi Ravi,

> perf-hwbreak selftest opens hw-breakpoint event at multiple places for
> which it has same code repeated. Coalesce that code into a function.
>
> Signed-off-by: Ravi Bangoria 
> ---
>  .../selftests/powerpc/ptrace/perf-hwbreak.c   | 78 +--

This doesn't simplify things very much for the code as it stands now,
but I think your next patch adds a bunch of calls to these functions, so
I agree that it makes sense to consolidate them now.

>  1 file changed, 38 insertions(+), 40 deletions(-)
>
> diff --git a/tools/testing/selftests/powerpc/ptrace/perf-hwbreak.c 
> b/tools/testing/selftests/powerpc/ptrace/perf-hwbreak.c
> index c1f324afdbf3..bde475341c8a 100644
> --- a/tools/testing/selftests/powerpc/ptrace/perf-hwbreak.c
> +++ b/tools/testing/selftests/powerpc/ptrace/perf-hwbreak.c
> @@ -34,28 +34,46 @@
>  
>  #define DAWR_LENGTH_MAX ((0x3f + 1) * 8)
>  
> -static inline int sys_perf_event_open(struct perf_event_attr *attr, pid_t 
> pid,
> -   int cpu, int group_fd,
> -   unsigned long flags)
> +static void perf_event_attr_set(struct perf_event_attr *attr,
> + __u32 type, __u64 addr, __u64 len,
> + bool exclude_user)
>  {
> - attr->size = sizeof(*attr);
> - return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
> + memset(attr, 0, sizeof(struct perf_event_attr));
> + attr->type   = PERF_TYPE_BREAKPOINT;
> + attr->size   = sizeof(struct perf_event_attr);
> + attr->bp_type= type;
> + attr->bp_addr= addr;
> + attr->bp_len = len;
> + attr->exclude_kernel = 1;
> + attr->exclude_hv = 1;
> + attr->exclude_guest  = 1;

Only 1 of the calls to perf sets exclude_{kernel,hv,guest} - I assume
there's no issue with setting them always but I wanted to check.

> + attr->exclude_user   = exclude_user;
> + attr->disabled   = 1;
>  }
>  
> - /* setup counters */
> - memset(, 0, sizeof(attr));
> - attr.disabled = 1;
> - attr.type = PERF_TYPE_BREAKPOINT;
> - attr.bp_type = readwriteflag;
> - attr.bp_addr = (__u64)ptr;
> - attr.bp_len = sizeof(int);
> - if (arraytest)
> - attr.bp_len = DAWR_LENGTH_MAX;
> - attr.exclude_user = exclude_user;
> - break_fd = sys_perf_event_open(, 0, -1, -1, 0);
> + break_fd = perf_process_event_open_exclude_user(readwriteflag, 
> (__u64)ptr,
> + arraytest ? DAWR_LENGTH_MAX : sizeof(int),
> + exclude_user);

checkpatch doesn't like this very much:

CHECK: Alignment should match open parenthesis
#103: FILE: tools/testing/selftests/powerpc/ptrace/perf-hwbreak.c:115:
+   break_fd = perf_process_event_open_exclude_user(readwriteflag, 
(__u64)ptr,
+   arraytest ? DAWR_LENGTH_MAX : sizeof(int),

Apart from that, this seems good but I haven't checked in super fine
detail just yet :)

Kind regards,
Daniel


[PATCH -next] powerpc/powernv: make symbol 'mpipl_kobj' static

2021-04-09 Thread Bixuan Cui
The sparse tool complains as follows:

arch/powerpc/platforms/powernv/opal-core.c:74:16: warning:
 symbol 'mpipl_kobj' was not declared.

This symbol is not used outside of opal-core.c, so marks it static.

Reported-by: Hulk Robot 
Signed-off-by: Bixuan Cui 
---
 arch/powerpc/platforms/powernv/opal-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/opal-core.c 
b/arch/powerpc/platforms/powernv/opal-core.c
index 0d9ba70f7251..5b9736bbc2aa 100644
--- a/arch/powerpc/platforms/powernv/opal-core.c
+++ b/arch/powerpc/platforms/powernv/opal-core.c
@@ -71,7 +71,7 @@ static LIST_HEAD(opalcore_list);
 static struct opalcore_config *oc_conf;
 static const struct opal_mpipl_fadump *opalc_metadata;
 static const struct opal_mpipl_fadump *opalc_cpu_metadata;
-struct kobject *mpipl_kobj;
+static struct kobject *mpipl_kobj;
 
 /*
  * Set crashing CPU's signal to SIGUSR1. if the kernel is triggered



[PATCH -next] powerpc/xmon: Make symbol 'spu_inst_dump' static

2021-04-09 Thread Pu Lehui
Fix sparse warning:

arch/powerpc/xmon/xmon.c:4216:1: warning:
 symbol 'spu_inst_dump' was not declared. Should it be static?

This symbol is not used outside of xmon.c, so make it static.

Signed-off-by: Pu Lehui 
---
 arch/powerpc/xmon/xmon.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index bf7d69625a2e..d4ae2a25781f 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -4212,8 +4212,7 @@ static void dump_spu_fields(struct spu *spu)
DUMP_FIELD(spu, "0x%p", pdata);
 }
 
-int
-spu_inst_dump(unsigned long adr, long count, int praddr)
+static int spu_inst_dump(unsigned long adr, long count, int praddr)
 {
return generic_inst_dump(adr, count, praddr, print_insn_spu);
 }
-- 
2.17.1



Re: [PATCH v2 1/4] powerpc/selftests/ptrace-hwbreak: Add testcases for 2nd DAWR

2021-04-09 Thread Daniel Axtens
Hi Ravi,

> Add selftests to test multiple active DAWRs with ptrace interface.

It would be good if somewhere (maybe in the cover letter) you explain
what DAWR stands for and where to find more information about it. I
found the Power ISA v3.1 Book 3 Chapter 9 very helpful.

Apart from that, I don't have any specific comments about this patch. It
looks good to me, it seems to do what it says, and there are no comments
from checkpatch. It is a bit sparse in terms of comments but it is
consistent with the rest of the file so I can't really complain there :)

Reviewed-by: Daniel Axtens 

Kind regards,
Daniel

> Sample o/p:
>   $ ./ptrace-hwbreak
>   ...
>   PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DW ALIGNED, WO, len: 6: Ok
>   PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DW UNALIGNED, RO, len: 6: Ok
>   PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DAWR Overlap, WO, len: 6: Ok
>   PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DAWR Overlap, RO, len: 6: Ok
>
> Signed-off-by: Ravi Bangoria 
> ---
>  .../selftests/powerpc/ptrace/ptrace-hwbreak.c | 79 +++
>  1 file changed, 79 insertions(+)
>
> diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c 
> b/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
> index 2e0d86e0687e..a0635a3819aa 100644
> --- a/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
> +++ b/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
> @@ -194,6 +194,18 @@ static void test_workload(void)
>   big_var[rand() % DAWR_MAX_LEN] = 'a';
>   else
>   cvar = big_var[rand() % DAWR_MAX_LEN];
> +
> + /* PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DW ALIGNED, WO test */
> + gstruct.a[rand() % A_LEN] = 'a';
> +
> + /* PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DW UNALIGNED, RO test */
> + cvar = gstruct.b[rand() % B_LEN];
> +
> + /* PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DAWR Overlap, WO test */
> + gstruct.a[rand() % A_LEN] = 'a';
> +
> + /* PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DAWR Overlap, RO test */
> + cvar = gstruct.a[rand() % A_LEN];
>  }
>  
>  static void check_success(pid_t child_pid, const char *name, const char 
> *type,
> @@ -417,6 +429,69 @@ static void test_sethwdebug_range_aligned(pid_t 
> child_pid)
>   ptrace_delhwdebug(child_pid, wh);
>  }
>  
> +static void test_multi_sethwdebug_range(pid_t child_pid)
> +{
> + struct ppc_hw_breakpoint info1, info2;
> + unsigned long wp_addr1, wp_addr2;
> + char *name1 = "PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DW ALIGNED";
> + char *name2 = "PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DW UNALIGNED";
> + int len1, len2;
> + int wh1, wh2;
> +
> + wp_addr1 = (unsigned long)
> + wp_addr2 = (unsigned long)
> + len1 = A_LEN;
> + len2 = B_LEN;
> + get_ppc_hw_breakpoint(, PPC_BREAKPOINT_TRIGGER_WRITE, wp_addr1, 
> len1);
> + get_ppc_hw_breakpoint(, PPC_BREAKPOINT_TRIGGER_READ, wp_addr2, 
> len2);
> +
> + /* PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DW ALIGNED, WO test */
> + wh1 = ptrace_sethwdebug(child_pid, );
> +
> + /* PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DW UNALIGNED, RO test */
> + wh2 = ptrace_sethwdebug(child_pid, );
> +
> + ptrace(PTRACE_CONT, child_pid, NULL, 0);
> + check_success(child_pid, name1, "WO", wp_addr1, len1);
> +
> + ptrace(PTRACE_CONT, child_pid, NULL, 0);
> + check_success(child_pid, name2, "RO", wp_addr2, len2);
> +
> + ptrace_delhwdebug(child_pid, wh1);
> + ptrace_delhwdebug(child_pid, wh2);
> +}
> +
> +static void test_multi_sethwdebug_range_dawr_overlap(pid_t child_pid)
> +{
> + struct ppc_hw_breakpoint info1, info2;
> + unsigned long wp_addr1, wp_addr2;
> + char *name = "PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DAWR Overlap";
> + int len1, len2;
> + int wh1, wh2;
> +
> + wp_addr1 = (unsigned long)
> + wp_addr2 = (unsigned long)
> + len1 = A_LEN;
> + len2 = A_LEN;
> + get_ppc_hw_breakpoint(, PPC_BREAKPOINT_TRIGGER_WRITE, wp_addr1, 
> len1);
> + get_ppc_hw_breakpoint(, PPC_BREAKPOINT_TRIGGER_READ, wp_addr2, 
> len2);
> +
> + /* PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DAWR Overlap, WO test */
> + wh1 = ptrace_sethwdebug(child_pid, );
> +
> + /* PPC_PTRACE_SETHWDEBUG 2, MODE_RANGE, DAWR Overlap, RO test */
> + wh2 = ptrace_sethwdebug(child_pid, );
> +
> + ptrace(PTRACE_CONT, child_pid, NULL, 0);
> + check_success(child_pid, name, "WO", wp_addr1, len1);
> +
> + ptrace(PTRACE_CONT, child_pid, NULL, 0);
> + check_success(child_pid, name, "RO", wp_addr2, len2);
> +
> + ptrace_delhwdebug(child_pid, wh1);
> + ptrace_delhwdebug(child_pid, wh2);
> +}
> +
>  static void test_sethwdebug_range_unaligned(pid_t child_pid)
>  {
>   struct ppc_hw_breakpoint info;
> @@ -504,6 +579,10 @@ run_tests(pid_t child_pid, struct ppc_debug_info 
> *dbginfo, bool dawr)
>   test_sethwdebug_range_unaligned(child_pid);
>   test_sethwdebug_range_unaligned_dar(child_pid);
>   

Re: [PATCH v1 1/1] kernel.h: Split out panic and oops helpers

2021-04-09 Thread Andrew Morton
On Wed, 7 Apr 2021 11:46:37 +0300 Andy Shevchenko  
wrote:

> On Wed, Apr 7, 2021 at 11:17 AM Kees Cook  wrote:
> >
> > On Tue, Apr 06, 2021 at 04:31:58PM +0300, Andy Shevchenko wrote:
> > > kernel.h is being used as a dump for all kinds of stuff for a long time.
> > > Here is the attempt to start cleaning it up by splitting out panic and
> > > oops helpers.
> > >
> > > At the same time convert users in header and lib folder to use new header.
> > > Though for time being include new header back to kernel.h to avoid twisted
> > > indirected includes for existing users.
> > >
> > > Signed-off-by: Andy Shevchenko 
> >
> > I like it! Do you have a multi-arch CI to do allmodconfig builds to
> > double-check this?
> 
> Unfortunately no, I rely on plenty of bots that are harvesting mailing lists.
> 
> But I will appreciate it if somebody can run this through various build tests.
> 

um, did you try x86_64 allmodconfig?

I'm up to
kernelh-split-out-panic-and-oops-helpers-fix-fix-fix-fix-fix-fix-fix.patch
and counting.

From: Andrew Morton 
Subject: kernelh-split-out-panic-and-oops-helpers-fix

more files need panic_notifier.h

Cc: Andy Shevchenko 
Signed-off-by: Andrew Morton 
---

 arch/x86/xen/enlighten.c|1 +
 drivers/video/fbdev/hyperv_fb.c |1 +
 2 files changed, 2 insertions(+)

--- a/arch/x86/xen/enlighten.c~kernelh-split-out-panic-and-oops-helpers-fix
+++ a/arch/x86/xen/enlighten.c
@@ -6,6 +6,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
--- 
a/drivers/video/fbdev/hyperv_fb.c~kernelh-split-out-panic-and-oops-helpers-fix
+++ a/drivers/video/fbdev/hyperv_fb.c
@@ -52,6 +52,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
_


From: Andrew Morton 
Subject: kernelh-split-out-panic-and-oops-helpers-fix-fix

arch/x86/purgatory/purgatory.c needs kernel.h

Cc: Andy Shevchenko 
Signed-off-by: Andrew Morton 
---

 arch/x86/purgatory/purgatory.c |1 +
 1 file changed, 1 insertion(+)

--- 
a/arch/x86/purgatory/purgatory.c~kernelh-split-out-panic-and-oops-helpers-fix-fix
+++ a/arch/x86/purgatory/purgatory.c
@@ -8,6 +8,7 @@
  *   Vivek Goyal 
  */
 
+#include 
 #include 
 #include 
 #include 
_

From: Andrew Morton 
Subject: kernelh-split-out-panic-and-oops-helpers-fix-fix-fix

drivers/clk/analogbits/wrpll-cln28hpc.c needs minmax.h, math.h and limits.h

Cc: Andy Shevchenko 
Signed-off-by: Andrew Morton 
---

 drivers/clk/analogbits/wrpll-cln28hpc.c |4 
 1 file changed, 4 insertions(+)

--- 
a/drivers/clk/analogbits/wrpll-cln28hpc.c~kernelh-split-out-panic-and-oops-helpers-fix-fix-fix
+++ a/drivers/clk/analogbits/wrpll-cln28hpc.c
@@ -25,6 +25,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+
 #include 
 
 /* MIN_INPUT_FREQ: minimum input clock frequency, in Hz (Fref_min) */
_

From: Andrew Morton 
Subject: kernelh-split-out-panic-and-oops-helpers-fix-fix-fix-fix

drivers/misc/pvpanic/pvpanic.c needs panic_notifier.h

Cc: Andy Shevchenko 
Signed-off-by: Andrew Morton 
---

 drivers/misc/pvpanic/pvpanic.c |1 +
 1 file changed, 1 insertion(+)

--- 
a/drivers/misc/pvpanic/pvpanic.c~kernelh-split-out-panic-and-oops-helpers-fix-fix-fix-fix
+++ a/drivers/misc/pvpanic/pvpanic.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
_
From: Andrew Morton 
Subject: kernelh-split-out-panic-and-oops-helpers-fix-fix-fix-fix-fix

fix drivers/misc/pvpanic/pvpanic.c and drivers/net/ipa/ipa_smp2p.c

Cc: Andy Shevchenko 
Signed-off-by: Andrew Morton 
---

 drivers/net/ipa/ipa_smp2p.c |1 +
 1 file changed, 1 insertion(+)

--- 
a/drivers/net/ipa/ipa_smp2p.c~kernelh-split-out-panic-and-oops-helpers-fix-fix-fix-fix-fix
+++ a/drivers/net/ipa/ipa_smp2p.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
_

From: Andrew Morton 
Subject: kernelh-split-out-panic-and-oops-helpers-fix-fix-fix-fix-fix-fix

fix drivers/power/reset/ltc2952-poweroff.c and drivers/misc/bcm-vk/bcm_vk_dev.c

Cc: Andy Shevchenko 
Signed-off-by: Andrew Morton 
---

 drivers/misc/bcm-vk/bcm_vk_dev.c   |1 +
 drivers/power/reset/ltc2952-poweroff.c |1 +
 2 files changed, 2 insertions(+)

--- 
a/drivers/power/reset/ltc2952-poweroff.c~kernelh-split-out-panic-and-oops-helpers-fix-fix-fix-fix-fix-fix
+++ a/drivers/power/reset/ltc2952-poweroff.c
@@ -52,6 +52,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
--- 
a/drivers/misc/bcm-vk/bcm_vk_dev.c~kernelh-split-out-panic-and-oops-helpers-fix-fix-fix-fix-fix-fix
+++ a/drivers/misc/bcm-vk/bcm_vk_dev.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
_

From: Andrew Morton 
Subject: kernelh-split-out-panic-and-oops-helpers-fix-fix-fix-fix-fix-fix-fix

fix drivers/leds/trigger/ledtrig-panic.c and drivers/firmware/google/gsmi.c

Cc: Andy Shevchenko 
Signed-off-by: Andrew Morton 
---

 drivers/firmware/google/gsmi.c   |1 +
 drivers/leds/trigger/ledtrig-panic.c |