Re: [PATCH 1/3] powerpc/vdso: augment VDSO32 functions to support 64 bits build

2021-12-21 Thread Christophe Leroy


Le 21/12/2021 à 20:36, Segher Boessenkool a écrit :
> On Tue, Dec 21, 2021 at 05:49:33PM +, Christophe Leroy wrote:
>> diff --git a/arch/powerpc/kernel/vdso32/datapage.S 
>> b/arch/powerpc/kernel/vdso32/datapage.S
>> index 65244416ab94..db8e167f0166 100644
>> --- a/arch/powerpc/kernel/vdso32/datapage.S
>> +++ b/arch/powerpc/kernel/vdso32/datapage.S
>> @@ -30,11 +30,15 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map)
>>  mr. r4,r3
>>  get_datapager3
>>  mtlrr12
>> +#ifdef __powerpc64__
>> +addir3,r3,CFG_SYSCALL_MAP64
>> +#else
>>  addir3,r3,CFG_SYSCALL_MAP32
>> +#endif
>> +crclr   cr0*4+so
>>  beqlr
>>  li  r0,NR_syscalls
>>  stw r0,0(r4)
>> -crclr   cr0*4+so
>>  blr
> 
> This now clears cr0.3 if r3 is zero on entry.  Is that on purpose?

All crclr where added by commit 5d66da3d71e6 ("[PATCH] powerpc: Make the 
vDSO functions set error code (#2)")

It looks like it was properly added to ppc64's version of 
__kernel_get_syscall_map() but for ppc32 CR.SO was left undefined in 
case of early exit of __kernel_get_syscall_map()

So yes, I think the change is on purpose.

> 
> Rest looks good.
> 
> Reviewed-by: Segher Boessenkool 
> 

Thanks
Christophe

Re: [PATCH 4/8] sched: powerpc: Remove unused TASK_SIZE_OF

2021-12-21 Thread Christophe Leroy


Le 22/12/2021 à 04:02, Guo Ren a écrit :
> On Wed, Dec 22, 2021 at 2:43 AM Christophe Leroy
>  wrote:
>>
>>
>>
>> Le 21/12/2021 à 18:00, guo...@kernel.org a écrit :
>>> From: Guo Ren 
>>>
>>> This macro isn't used in Linux sched, now. Delete in
>>> include/linux/sched.h and arch's include/asm.
>>>
>>> Signed-off-by: Guo Ren 
>>> ---
>>>arch/powerpc/include/asm/task_size_64.h | 6 ++
>>>1 file changed, 2 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/arch/powerpc/include/asm/task_size_64.h 
>>> b/arch/powerpc/include/asm/task_size_64.h
>>> index c993482237ed..7e2eca4fac4d 100644
>>> --- a/arch/powerpc/include/asm/task_size_64.h
>>> +++ b/arch/powerpc/include/asm/task_size_64.h
>>> @@ -44,12 +44,10 @@
>>> */
>>>#define TASK_SIZE_USER32 (0x0001UL - (1 * PAGE_SIZE))
>>>
>>> -#define TASK_SIZE_OF(tsk)\
>>> - (test_tsk_thread_flag(tsk, TIF_32BIT) ? TASK_SIZE_USER32 :  \
>>> +#define TASK_SIZE\
>>> + (test_tsk_thread_flag(current, TIF_32BIT) ? TASK_SIZE_USER32 :  \
>>>TASK_SIZE_USER64)
>>
>> I think you should use test_thread_flag() instead.
>>
>> Or even better: use is_32bit_task() and bring back this macro as a
>> single line, something like:
>>
>> #define TASK_SIZE (is_32bit_task() ? TASK_SIZE_USER32 : TASK_SIZE_USER64)
> Okay, looks better. I would fix it in the next version.

Note that is_32bit_task() exists on powerpc, parisc and sparc.

For other ones you can still use test_thread_flag() instead of 
test_tsk_thread_flag(current)

Re: [PATCH 4/8] sched: powerpc: Remove unused TASK_SIZE_OF

2021-12-21 Thread Guo Ren
On Wed, Dec 22, 2021 at 2:43 AM Christophe Leroy
 wrote:
>
>
>
> Le 21/12/2021 à 18:00, guo...@kernel.org a écrit :
> > From: Guo Ren 
> >
> > This macro isn't used in Linux sched, now. Delete in
> > include/linux/sched.h and arch's include/asm.
> >
> > Signed-off-by: Guo Ren 
> > ---
> >   arch/powerpc/include/asm/task_size_64.h | 6 ++
> >   1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/powerpc/include/asm/task_size_64.h 
> > b/arch/powerpc/include/asm/task_size_64.h
> > index c993482237ed..7e2eca4fac4d 100644
> > --- a/arch/powerpc/include/asm/task_size_64.h
> > +++ b/arch/powerpc/include/asm/task_size_64.h
> > @@ -44,12 +44,10 @@
> >*/
> >   #define TASK_SIZE_USER32 (0x0001UL - (1 * PAGE_SIZE))
> >
> > -#define TASK_SIZE_OF(tsk)\
> > - (test_tsk_thread_flag(tsk, TIF_32BIT) ? TASK_SIZE_USER32 :  \
> > +#define TASK_SIZE\
> > + (test_tsk_thread_flag(current, TIF_32BIT) ? TASK_SIZE_USER32 :  \
> >   TASK_SIZE_USER64)
>
> I think you should use test_thread_flag() instead.
>
> Or even better: use is_32bit_task() and bring back this macro as a
> single line, something like:
>
> #define TASK_SIZE (is_32bit_task() ? TASK_SIZE_USER32 : TASK_SIZE_USER64)
Okay, looks better. I would fix it in the next version.

>
> >
> > -#define TASK_SIZE TASK_SIZE_OF(current)
> > -
> >   #define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4))
> >   #define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(DEFAULT_MAP_WINDOW_USER64 / 
> > 4))
> >
> >



-- 
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/


[powerpc:merge] BUILD SUCCESS 6963dbc89ab1337394f51957136084c8854b6e7f

2021-12-21 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
merge
branch HEAD: 6963dbc89ab1337394f51957136084c8854b6e7f  Automatic merge of 
'next' into merge (2021-12-21 22:22)

elapsed time: 806m

configs tested: 118
configs skipped: 3

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm  allyesconfig
arm  allmodconfig
arm64   defconfig
arm64allyesconfig
arm cm_x300_defconfig
mipsmalta_qemu_32r6_defconfig
sh   se7712_defconfig
m68k   m5275evb_defconfig
powerpc  ppc44x_defconfig
arm  alldefconfig
powerpc mpc832x_rdb_defconfig
powerpc  storcenter_defconfig
powerpc   eiger_defconfig
powerpc stx_gp3_defconfig
sh sh7710voipgw_defconfig
mips rt305x_defconfig
mips   gcw0_defconfig
mips   bmips_be_defconfig
powerpc skiroot_defconfig
mips  maltaaprp_defconfig
m68k alldefconfig
sh  urquell_defconfig
sh shx3_defconfig
powerpc mpc85xx_cds_defconfig
powerpc tqm8541_defconfig
arm   versatile_defconfig
armneponset_defconfig
powerpc  ep88xc_defconfig
mips  pic32mzda_defconfig
arm bcm2835_defconfig
arm  pcm027_defconfig
arm ezx_defconfig
xtensa  defconfig
xtensa virt_defconfig
arm  randconfig-c002-20211220
ia64defconfig
ia64 allmodconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nds32 allnoconfig
nios2   defconfig
arc  allyesconfig
nds32   defconfig
nios2allyesconfig
cskydefconfig
alpha   defconfig
alphaallyesconfig
xtensa   allyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
parisc  defconfig
s390 allmodconfig
parisc   allyesconfig
s390defconfig
s390 allyesconfig
i386 allyesconfig
sparcallyesconfig
sparc   defconfig
i386defconfig
i386   debian-10.3-kselftests
i386  debian-10.3
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc  allmodconfig
powerpc   allnoconfig
i386 randconfig-a002-20211220
i386 randconfig-a003-20211220
i386 randconfig-a001-20211220
i386 randconfig-a004-20211220
i386 randconfig-a005-20211220
i386 randconfig-a006-20211220
i386 randconfig-a012-20211221
i386 randconfig-a011-20211221
i386 randconfig-a013-20211221
i386 randconfig-a014-20211221
i386 randconfig-a016-20211221
i386 randconfig-a015-20211221
x86_64   randconfig-a001-20211220
x86_64   randconfig-a003-20211220
x86_64   randconfig-a005-20211220
x86_64   randconfig-a004-20211220
x86_64   randconfig-a002-20211220
x86_64   randconfig-a006-20211220
arc  randconfig-r043-20211221
riscvrandconfig-r042-20211221
s390 randconfig-r044-20211221
riscvnommu_k210_defconfig
riscvallyesconfig
riscvnommu_virt_defconfig
riscv allnoconfig
riscv   defconfig
riscv  rv32_defconfig
riscvallmodconfig
um i386_defconfig
um   x86_64_defconfig
x86_64

[powerpc:next-test] BUILD SUCCESS WITH WARNING 9c4c79c450672b18889a42e6b16a0254ed9721e0

2021-12-21 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
next-test
branch HEAD: 9c4c79c450672b18889a42e6b16a0254ed9721e0  selftests/powerpc: Add a 
test of sigreturning to an unaligned address

Warning reports:

https://lore.kernel.org/lkml/202112220137.x16y07dp-...@intel.com

Warning in current branch:

arch/powerpc/perf/core-book3s.c:2455:6: warning: no previous prototype for 
'power_pmu_wants_prompt_pmi' [-Wmissing-prototypes]

Warning ids grouped by kconfigs:

gcc_recent_errors
`-- powerpc-allyesconfig
`-- 
arch-powerpc-perf-core-book3s.c:warning:no-previous-prototype-for-power_pmu_wants_prompt_pmi

elapsed time: 720m

configs tested: 115
configs skipped: 3

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
sh espt_defconfig
mips loongson1c_defconfig
armrealview_defconfig
powerpc  storcenter_defconfig
shedosk7705_defconfig
powerpc mpc832x_rdb_defconfig
powerpc   eiger_defconfig
powerpc stx_gp3_defconfig
sh sh7710voipgw_defconfig
arm  alldefconfig
mips rt305x_defconfig
mips   gcw0_defconfig
mips   bmips_be_defconfig
powerpc skiroot_defconfig
mips  maltaaprp_defconfig
mips  bmips_stb_defconfig
um   alldefconfig
arm  ixp4xx_defconfig
m68kq40_defconfig
powerpc   lite5200b_defconfig
arm  pcm027_defconfig
powerpc  katmai_defconfig
arm assabet_defconfig
shshmin_defconfig
powerpcsam440ep_defconfig
m68km5407c3_defconfig
powerpc tqm8548_defconfig
sh   se7780_defconfig
arm  randconfig-c002-20211220
ia64 allmodconfig
ia64defconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nds32 allnoconfig
nios2   defconfig
arc  allyesconfig
nds32   defconfig
cskydefconfig
alpha   defconfig
alphaallyesconfig
nios2allyesconfig
xtensa   allyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
parisc  defconfig
s390 allyesconfig
s390 allmodconfig
parisc   allyesconfig
s390defconfig
i386 allyesconfig
sparcallyesconfig
sparc   defconfig
i386defconfig
i386   debian-10.3-kselftests
i386  debian-10.3
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc  allmodconfig
powerpc   allnoconfig
x86_64   randconfig-a001-20211220
x86_64   randconfig-a003-20211220
x86_64   randconfig-a005-20211220
x86_64   randconfig-a006-20211220
x86_64   randconfig-a004-20211220
x86_64   randconfig-a002-20211220
i386 randconfig-a006-20211220
i386 randconfig-a004-20211220
i386 randconfig-a002-20211220
i386 randconfig-a003-20211220
i386 randconfig-a005-20211220
i386 randconfig-a001-20211220
arc  randconfig-r043-20211220
arc  randconfig-r043-20211221
riscvrandconfig-r042-20211221
s390 randconfig-r044-20211221
riscvnommu_k210_defconfig
riscvallyesconfig
riscvnommu_virt_defconfig
riscv allnoconfig
riscv   defconfig
riscv  rv32_defconfig
riscvallmodconfig
um   x86_64_defconfig
um i386_defconfig

[powerpc:next] BUILD SUCCESS 18678591846d668649fbd4f87b4a4c470818d386

2021-12-21 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
next
branch HEAD: 18678591846d668649fbd4f87b4a4c470818d386  selftests/powerpc: skip 
tests for unavailable mitigations.

elapsed time: 720m

configs tested: 115
configs skipped: 3

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
sh espt_defconfig
mips loongson1c_defconfig
armrealview_defconfig
powerpc  storcenter_defconfig
shedosk7705_defconfig
powerpc mpc832x_rdb_defconfig
powerpc   eiger_defconfig
powerpc stx_gp3_defconfig
sh sh7710voipgw_defconfig
arm  alldefconfig
mips rt305x_defconfig
mips   gcw0_defconfig
mips   bmips_be_defconfig
powerpc skiroot_defconfig
mips  maltaaprp_defconfig
mips  bmips_stb_defconfig
um   alldefconfig
arm  ixp4xx_defconfig
m68kq40_defconfig
powerpc   lite5200b_defconfig
arm  pcm027_defconfig
powerpc  katmai_defconfig
arm assabet_defconfig
shshmin_defconfig
powerpcsam440ep_defconfig
m68km5407c3_defconfig
powerpc tqm8548_defconfig
sh   se7780_defconfig
arm  randconfig-c002-20211220
ia64 allmodconfig
ia64defconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nds32 allnoconfig
nios2   defconfig
arc  allyesconfig
nds32   defconfig
nios2allyesconfig
cskydefconfig
alpha   defconfig
alphaallyesconfig
xtensa   allyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
parisc  defconfig
s390 allyesconfig
s390 allmodconfig
parisc   allyesconfig
s390defconfig
i386 allyesconfig
sparcallyesconfig
sparc   defconfig
i386defconfig
i386   debian-10.3-kselftests
i386  debian-10.3
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc  allmodconfig
powerpc   allnoconfig
x86_64   randconfig-a001-20211220
x86_64   randconfig-a003-20211220
x86_64   randconfig-a005-20211220
x86_64   randconfig-a006-20211220
x86_64   randconfig-a004-20211220
x86_64   randconfig-a002-20211220
i386 randconfig-a006-20211220
i386 randconfig-a004-20211220
i386 randconfig-a002-20211220
i386 randconfig-a003-20211220
i386 randconfig-a005-20211220
i386 randconfig-a001-20211220
arc  randconfig-r043-20211220
arc  randconfig-r043-20211221
riscvrandconfig-r042-20211221
s390 randconfig-r044-20211221
riscvnommu_k210_defconfig
riscvallyesconfig
riscvnommu_virt_defconfig
riscv allnoconfig
riscv   defconfig
riscv  rv32_defconfig
riscvallmodconfig
um   x86_64_defconfig
um i386_defconfig
x86_64   allyesconfig
x86_64rhel-8.3-kselftests
x86_64  defconfig
x86_64   rhel-8.3
x86_64  rhel-8.3-func
x86_64  kexec

clang tested configs:
x86_64   randconfig-a013

[powerpc:fixes-test] BUILD SUCCESS 8d84fca4375e3c35dadc16b8c7eee6821b2a575c

2021-12-21 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
fixes-test
branch HEAD: 8d84fca4375e3c35dadc16b8c7eee6821b2a575c  powerpc/ptdump: Fix 
DEBUG_WX since generic ptdump conversion

elapsed time: 721m

configs tested: 121
configs skipped: 130

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
sh espt_defconfig
mips loongson1c_defconfig
armrealview_defconfig
powerpc  storcenter_defconfig
shedosk7705_defconfig
powerpc mpc832x_rdb_defconfig
powerpc   eiger_defconfig
powerpc stx_gp3_defconfig
sh sh7710voipgw_defconfig
arm  alldefconfig
arm  moxart_defconfig
mipsqi_lb60_defconfig
armmagician_defconfig
mips   ip32_defconfig
mips rt305x_defconfig
mips   gcw0_defconfig
mips   bmips_be_defconfig
powerpc skiroot_defconfig
mips  maltaaprp_defconfig
sh   se7206_defconfig
mipsjmr3927_defconfig
mips   capcella_defconfig
powerpc canyonlands_defconfig
shdreamcast_defconfig
mips   ci20_defconfig
m68kq40_defconfig
powerpc   lite5200b_defconfig
arm  pcm027_defconfig
powerpc  katmai_defconfig
arm assabet_defconfig
shshmin_defconfig
powerpcsam440ep_defconfig
m68km5407c3_defconfig
powerpc tqm8548_defconfig
sh   se7780_defconfig
arm  randconfig-c002-20211220
ia64 allmodconfig
ia64defconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nios2   defconfig
arc  allyesconfig
nds32   defconfig
nios2allyesconfig
cskydefconfig
alpha   defconfig
alphaallyesconfig
xtensa   allyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
parisc  defconfig
s390 allyesconfig
s390 allmodconfig
parisc   allyesconfig
s390defconfig
i386 allyesconfig
sparcallyesconfig
sparc   defconfig
i386defconfig
i386   debian-10.3-kselftests
i386  debian-10.3
nds32 allnoconfig
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc  allmodconfig
powerpc   allnoconfig
x86_64   randconfig-a001-20211220
x86_64   randconfig-a003-20211220
x86_64   randconfig-a005-20211220
x86_64   randconfig-a006-20211220
x86_64   randconfig-a004-20211220
x86_64   randconfig-a002-20211220
i386 randconfig-a013-20211219
i386 randconfig-a011-20211219
i386 randconfig-a016-20211219
i386 randconfig-a015-20211219
i386 randconfig-a014-20211219
i386 randconfig-a012-20211219
arc  randconfig-r043-20211221
riscvrandconfig-r042-20211221
s390 randconfig-r044-20211221
riscvnommu_k210_defconfig
riscvallyesconfig
riscvnommu_virt_defconfig
riscv allnoconfig
riscv   defconfig
riscv  rv32_defconfig
riscvallmodconfig
um   x86_64_defconfig
um i386_defconfig
x86_64   allyesconfig
x86_64

Re: [PATCH] powerpc/cell/axon_msi: replace DEFINE_SIMPLE_ATTRIBUTE with DEFINE_DEBUGFS_ATTRIBUTE

2021-12-21 Thread Michael Ellerman
cgel@gmail.com writes:
> From: Changcheng Deng 
>
> Fix the following coccicheck warning:
> ./arch/powerpc/platforms/cell/axon_msi.c: 456: 0-23: WARNING: fops_msic
> should be defined with DEFINE_DEBUGFS_ATTRIBUTE
>
> Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE for
> debugfs files.

But it also says:

  //# Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
  //# imposes some significant overhead as compared to
  //# DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().

Your patch doesn't change it to use debugfs_create_file_unsafe(),
shouldn't it?

cheers

> diff --git a/arch/powerpc/platforms/cell/axon_msi.c 
> b/arch/powerpc/platforms/cell/axon_msi.c
> index 354a58c1e6f2..47bb0ae8d6c9 100644
> --- a/arch/powerpc/platforms/cell/axon_msi.c
> +++ b/arch/powerpc/platforms/cell/axon_msi.c
> @@ -453,7 +453,7 @@ static int msic_get(void *data, u64 *val)
>   return 0;
>  }
>  
> -DEFINE_SIMPLE_ATTRIBUTE(fops_msic, msic_get, msic_set, "%llu\n");
> +DEFINE_DEBUGFS_ATTRIBUTE(fops_msic, msic_get, msic_set, "%llu\n");
>  
>  void axon_msi_debug_setup(struct device_node *dn, struct axon_msic *msic)
>  {
> -- 
> 2.25.1


Re: [PATCH 1/3] powerpc/vdso: augment VDSO32 functions to support 64 bits build

2021-12-21 Thread Segher Boessenkool
On Tue, Dec 21, 2021 at 05:49:33PM +, Christophe Leroy wrote:
> diff --git a/arch/powerpc/kernel/vdso32/datapage.S 
> b/arch/powerpc/kernel/vdso32/datapage.S
> index 65244416ab94..db8e167f0166 100644
> --- a/arch/powerpc/kernel/vdso32/datapage.S
> +++ b/arch/powerpc/kernel/vdso32/datapage.S
> @@ -30,11 +30,15 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map)
>   mr. r4,r3
>   get_datapager3
>   mtlrr12
> +#ifdef __powerpc64__
> + addir3,r3,CFG_SYSCALL_MAP64
> +#else
>   addir3,r3,CFG_SYSCALL_MAP32
> +#endif
> + crclr   cr0*4+so
>   beqlr
>   li  r0,NR_syscalls
>   stw r0,0(r4)
> - crclr   cr0*4+so
>   blr

This now clears cr0.3 if r3 is zero on entry.  Is that on purpose?

Rest looks good.

Reviewed-by: Segher Boessenkool 


Segher


[Bug 215381] BUG: Unable to handle kernel data access on read at 0x6600cc00000004

2021-12-21 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=215381

--- Comment #1 from Erhard F. (erhar...@mailbox.org) ---
Created attachment 300107
  --> https://bugzilla.kernel.org/attachment.cgi?id=300107=edit
kernel .config (kernel 5.15.10, Talos II)

-- 
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 215381] New: BUG: Unable to handle kernel data access on read at 0x6600cc00000004

2021-12-21 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=215381

Bug ID: 215381
   Summary: BUG: Unable to handle kernel data access on read at
0x6600cc0004
   Product: Platform Specific/Hardware
   Version: 2.5
Kernel Version: 5.15.10
  Hardware: PPC-64
OS: Linux
  Tree: Mainline
Status: NEW
  Severity: normal
  Priority: P1
 Component: PPC-64
  Assignee: platform_ppc...@kernel-bugs.osdl.org
  Reporter: erhar...@mailbox.org
Regression: No

Created attachment 300105
  --> https://bugzilla.kernel.org/attachment.cgi?id=300105=edit
dmesg (kernel 5.15.10, Talos II)

Happened not during boot but shortly afterwards compiling some stuff via ssh.

[...]
BUG: Unable to handle kernel data access on read at 0x6600cc0004
Faulting instruction address: 0xc01398c4
Oops: Kernel access of bad area, sig: 11 [#1]
BE PAGE_SIZE=4K MMU=Radix SMP NR_CPUS=192 NUMA PowerNV
Modules linked in: auth_rpcgss nfsv4 dns_resolver nfs lockd grace sunrpc rfkill
evdev ecb xts snd_hda_codec_hdmi radeon xhci_pci snd_hda_intel ctr
snd_intel_dspcfg xhci_hcd snd_hda_codec snd_hwdep ofpart cbc snd_hda_core
drm_ttm_helper ttm snd_pcm powernv_flash i2c_algo_bit aes_generic ibmpowernv
libaes usbcore drm_kms_helper mtd at24 vmx_crypto snd_timer gf128mul opal_prd
hwmon regmap_i2c snd sysimgblt syscopyarea sysfillrect fb_sys_fops usb_common
soundcore lz4 lz4_compress lz4_decompress zram zsmalloc powernv_cpufreq drm
fuse drm_panel_orientation_quirks backlight configfs
CPU: 22 PID: 55708 Comm: clang Not tainted 5.15.10-gentoo-TalosII #1
NIP:  c01398c4 LR: c0a9b6c0 CTR: 
REGS: c00029dcef10 TRAP: 0380   Not tainted  (5.15.10-gentoo-TalosII)
MSR:  90009032   CR: 28228244  XER: 00ae
CFAR: c0a9b6bc IRQMASK: 0 
GPR00: c0315d88 c00029dcf1b0 c1256d00 006600cc 
GPR04: cd966370 3fff8dc0   
GPR08: 0009 dead4ead c00c  
GPR12: 88228244 c0002007ff7f6500 c00029dcf710 c0002595e660 
GPR16: c12a5bc0 3fff8dc3e000 c00025436080 3fff8dc5e000 
GPR20: 4000  c000297de4a0 006600cc 
GPR24: c1260985  c12a5b28  
GPR28: c00029dcf710 c12a5bc0 cd966370 006600cc 
NIP [c01398c4] .do_raw_spin_lock+0x14/0x1d0
LR [c0a9b6c0] ._raw_spin_lock+0x10/0x30
Call Trace:
[c00029dcf1b0] [00c8] 0xc8 (unreliable)
[c00029dcf230] [c029d9d4] .finish_fault+0x3e4/0x4f0
[c00029dcf2a0] [c0315d88] .__split_huge_pmd+0xe8/0x1190
[c00029dcf430] [c029a5bc] .unmap_page_range+0x43c/0xfe0
[c00029dcf5c0] [c029b618] .unmap_vmas+0xd8/0x200
[c00029dcf6a0] [c02a8324] .unmap_region+0xc4/0x160
[c00029dcf7c0] [c02ab5fc] .__do_munmap+0x1fc/0x5f0
[c00029dcf880] [c02aba70] .__vm_munmap+0x80/0x110
[c00029dcf940] [c03ef160] .elf_map+0xa0/0x120
[c00029dcf9d0] [c03f1168] .load_elf_binary+0xbf8/0x1fa0
[c00029dcfb40] [c034ecc8] .bprm_execve+0x2a8/0x700
[c00029dcfc10] [c034fcc8] .do_execveat_common.isra.0+0x188/0x230
[c00029dcfcd0] [c0350dfc] .__se_sys_execve+0x3c/0x50
[c00029dcfd40] [c002de48] .system_call_exception+0x1c8/0x530
[c00029dcfe10] [c000c068] system_call_vectored_common+0xe8/0x278
--- interrupt: 3000 at 0x3fffbd817c0c
NIP:  3fffbd817c0c LR:  CTR: 
REGS: c00029dcfe80 TRAP: 3000   Not tainted  (5.15.10-gentoo-TalosII)
MSR:  9000f032   CR: 42220442  XER:

IRQMASK: 0 
GPR00: 000b 3fffbd12dd20 3fffbd935300 2cbe3700 
GPR04: 2cc377e0 2cbe2cc0 0008 0001 
GPR08: 0001    
GPR12:  3fffbda03810  0020 
GPR16: 100514a0 005c  100348d4 
GPR20:  3fffbd125000 3fffea78ba68  
GPR24: 3fffbd12de10  3fffea78b638 3fffea78ba18 
GPR28: 2cc182c0 3fffea78ba68 0001 0010 
NIP [3fffbd817c0c] 0x3fffbd817c0c
LR [] 0x0
--- interrupt: 3000
Instruction dump:
f9430010 792907c6 6529 6129 f9230004 4e800020 6000 fbe1fff8 
f821ff81 3d20dead 7c7f1b78 61294ead <81430004> 7c0a4800 408200d4 e95f0010 
---[ end trace 063d70c8fce39c11 ]---

# inxi -bZ
System:Host: T1000 Kernel: 5.15.10-TalosII ppc64 bits: 64 Console: tty 2
Distro: Gentoo Base System release 2.7 
Machine:   Type: PowerPC Device System: T2P9D01 REV 1.01 details: PowerNV
T2P9D01 REV 1.01 rev: 2.2 (pvr 004e 1202) 
CPU: 

Re: [PATCH 1/2] mm/cma: provide option to opt out from exposing pages on activation failure

2021-12-21 Thread David Hildenbrand
On 20.12.21 20:34, Hari Bathini wrote:
> Commit 072355c1cf2d ("mm/cma: expose all pages to the buddy if
> activation of an area fails") started exposing all pages to buddy
> allocator on CMA activation failure. But there can be CMA users that
> want to handle the reserved memory differently on CMA allocation
> failure. Provide an option to opt out from exposing pages to buddy
> for such cases.

Can you elaborate why that is important and what the target user can
actually do with it?

It certainly cannot do CMA allocations :)

-- 
Thanks,

David / dhildenb



Re: [PATCH 4/8] sched: powerpc: Remove unused TASK_SIZE_OF

2021-12-21 Thread Christophe Leroy


Le 21/12/2021 à 18:00, guo...@kernel.org a écrit :
> From: Guo Ren 
> 
> This macro isn't used in Linux sched, now. Delete in
> include/linux/sched.h and arch's include/asm.
> 
> Signed-off-by: Guo Ren 
> ---
>   arch/powerpc/include/asm/task_size_64.h | 6 ++
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/task_size_64.h 
> b/arch/powerpc/include/asm/task_size_64.h
> index c993482237ed..7e2eca4fac4d 100644
> --- a/arch/powerpc/include/asm/task_size_64.h
> +++ b/arch/powerpc/include/asm/task_size_64.h
> @@ -44,12 +44,10 @@
>*/
>   #define TASK_SIZE_USER32 (0x0001UL - (1 * PAGE_SIZE))
>   
> -#define TASK_SIZE_OF(tsk)\
> - (test_tsk_thread_flag(tsk, TIF_32BIT) ? TASK_SIZE_USER32 :  \
> +#define TASK_SIZE\
> + (test_tsk_thread_flag(current, TIF_32BIT) ? TASK_SIZE_USER32 :  \
>   TASK_SIZE_USER64)

I think you should use test_thread_flag() instead.

Or even better: use is_32bit_task() and bring back this macro as a 
single line, something like:

#define TASK_SIZE (is_32bit_task() ? TASK_SIZE_USER32 : TASK_SIZE_USER64)

>   
> -#define TASK_SIZE TASK_SIZE_OF(current)
> -
>   #define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4))
>   #define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(DEFAULT_MAP_WINDOW_USER64 / 
> 4))
>   
> 

Re: [PATCH 1/8] sched: Remove unused TASK_SIZE_OF

2021-12-21 Thread Arnd Bergmann
On Tue, Dec 21, 2021 at 6:00 PM  wrote:
>
> From: Guo Ren 
>
> This macro isn't used in Linux, now. Delete in include/linux/sched.h
> and arch's include/asm. This would confuse people who are
> implementing the COMPAT feature for architecture.
>
> Signed-off-by: Guo Ren 

It would help to list how long it has been unused for. Looking through
the git history, I see commit a06db751c321 ("pagemap: check
permissions and capabilities at open time") removing the last user.

I would normally offer to take the entire series through the asm-generic
tree, as I do for this kind of cross-architecture work. I'll probably
not have time before the merge window to pick it up though, so it
may be better to go through the architecture trees, or possibly
linux-mm for anything that fails to get picked up.

For the series:

Review-by: Arnd Bergmann 


[PATCH 3/3] powerpc/vdso: Merge vdso64 and vdso32 into a single directory

2021-12-21 Thread Christophe Leroy
merge vdso64 into vdso32 and rename it vdso.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/Makefile |  4 +-
 arch/powerpc/kernel/Makefile  |  6 +-
 .../kernel/{vdso64 => vdso}/.gitignore|  2 +
 arch/powerpc/kernel/{vdso32 => vdso}/Makefile | 35 +
 .../kernel/{vdso32 => vdso}/cacheflush.S  |  0
 .../kernel/{vdso32 => vdso}/datapage.S|  0
 .../{vdso32 => vdso}/gen_vdso32_offsets.sh|  0
 .../gen_vdso64_offsets.sh}|  0
 arch/powerpc/kernel/{vdso32 => vdso}/getcpu.S |  0
 .../kernel/{vdso32 => vdso}/gettimeofday.S|  0
 arch/powerpc/kernel/{vdso32 => vdso}/note.S   |  0
 .../kernel/{vdso32 => vdso}/sigtramp32.S  |  0
 .../{vdso64/sigtramp.S => vdso/sigtramp64.S}  |  0
 .../kernel/{vdso32 => vdso}/vdso32.lds.S  |  0
 .../kernel/{vdso64 => vdso}/vdso64.lds.S  |  0
 .../kernel/{vdso32 => vdso}/vgettimeofday.c   |  0
 arch/powerpc/kernel/vdso32/.gitignore |  3 -
 arch/powerpc/kernel/vdso32_wrapper.S  |  2 +-
 arch/powerpc/kernel/vdso64/Makefile   | 56 --
 arch/powerpc/kernel/vdso64/cacheflush.S   | 75 ---
 arch/powerpc/kernel/vdso64/datapage.S | 59 ---
 arch/powerpc/kernel/vdso64/getcpu.S   | 33 
 arch/powerpc/kernel/vdso64/gettimeofday.S | 58 --
 arch/powerpc/kernel/vdso64/note.S |  1 -
 arch/powerpc/kernel/vdso64/vgettimeofday.c| 29 ---
 arch/powerpc/kernel/vdso64_wrapper.S  |  2 +-
 26 files changed, 44 insertions(+), 321 deletions(-)
 rename arch/powerpc/kernel/{vdso64 => vdso}/.gitignore (72%)
 rename arch/powerpc/kernel/{vdso32 => vdso}/Makefile (56%)
 rename arch/powerpc/kernel/{vdso32 => vdso}/cacheflush.S (100%)
 rename arch/powerpc/kernel/{vdso32 => vdso}/datapage.S (100%)
 rename arch/powerpc/kernel/{vdso32 => vdso}/gen_vdso32_offsets.sh (100%)
 rename arch/powerpc/kernel/{vdso64/gen_vdso_offsets.sh => 
vdso/gen_vdso64_offsets.sh} (100%)
 rename arch/powerpc/kernel/{vdso32 => vdso}/getcpu.S (100%)
 rename arch/powerpc/kernel/{vdso32 => vdso}/gettimeofday.S (100%)
 rename arch/powerpc/kernel/{vdso32 => vdso}/note.S (100%)
 rename arch/powerpc/kernel/{vdso32 => vdso}/sigtramp32.S (100%)
 rename arch/powerpc/kernel/{vdso64/sigtramp.S => vdso/sigtramp64.S} (100%)
 rename arch/powerpc/kernel/{vdso32 => vdso}/vdso32.lds.S (100%)
 rename arch/powerpc/kernel/{vdso64 => vdso}/vdso64.lds.S (100%)
 rename arch/powerpc/kernel/{vdso32 => vdso}/vgettimeofday.c (100%)
 delete mode 100644 arch/powerpc/kernel/vdso32/.gitignore
 delete mode 100644 arch/powerpc/kernel/vdso64/Makefile
 delete mode 100644 arch/powerpc/kernel/vdso64/cacheflush.S
 delete mode 100644 arch/powerpc/kernel/vdso64/datapage.S
 delete mode 100644 arch/powerpc/kernel/vdso64/getcpu.S
 delete mode 100644 arch/powerpc/kernel/vdso64/gettimeofday.S
 delete mode 100644 arch/powerpc/kernel/vdso64/note.S
 delete mode 100644 arch/powerpc/kernel/vdso64/vgettimeofday.c

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index e02568f17334..e668612812d6 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -419,9 +419,9 @@ ifeq ($(KBUILD_EXTMOD),)
 prepare: vdso_prepare
 vdso_prepare: prepare0
$(if $(CONFIG_VDSO32),$(Q)$(MAKE) \
-   $(build)=arch/powerpc/kernel/vdso32 
include/generated/vdso32-offsets.h)
+   $(build)=arch/powerpc/kernel/vdso 
include/generated/vdso32-offsets.h)
$(if $(CONFIG_PPC64),$(Q)$(MAKE) \
-   $(build)=arch/powerpc/kernel/vdso64 
include/generated/vdso64-offsets.h)
+   $(build)=arch/powerpc/kernel/vdso 
include/generated/vdso64-offsets.h)
 endif
 
 archprepare: checkbin
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 5fa68c2ef1f8..c626c55e35fc 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -194,8 +194,8 @@ targets += prom_init_check
 clean-files := vmlinux.lds
 
 # Force dependency (incbin is bad)
-$(obj)/vdso32_wrapper.o : $(obj)/vdso32/vdso32.so.dbg
-$(obj)/vdso64_wrapper.o : $(obj)/vdso64/vdso64.so.dbg
+$(obj)/vdso32_wrapper.o : $(obj)/vdso/vdso32.so.dbg
+$(obj)/vdso64_wrapper.o : $(obj)/vdso/vdso64.so.dbg
 
 # for cleaning
-subdir- += vdso32 vdso64
+subdir- += vdso
diff --git a/arch/powerpc/kernel/vdso64/.gitignore 
b/arch/powerpc/kernel/vdso/.gitignore
similarity index 72%
rename from arch/powerpc/kernel/vdso64/.gitignore
rename to arch/powerpc/kernel/vdso/.gitignore
index 84151a7ba31d..dd9bdd67758b 100644
--- a/arch/powerpc/kernel/vdso64/.gitignore
+++ b/arch/powerpc/kernel/vdso/.gitignore
@@ -1,3 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
+vdso32.lds
+vdso32.so.dbg
 vdso64.lds
 vdso64.so.dbg
diff --git a/arch/powerpc/kernel/vdso32/Makefile 
b/arch/powerpc/kernel/vdso/Makefile
similarity index 56%
rename from arch/powerpc/kernel/vdso32/Makefile
rename to arch/powerpc/kernel/vdso/Makefile
index 7d7b38d90ca5..954974287ee7 100644
--- 

[PATCH 2/3] powerpc/vdso: Rework VDSO32 makefile to add a prefix to object files

2021-12-21 Thread Christophe Leroy
In order to merge vdso32 and vdso64 build in following patch, rework
Makefile is order to add -32 suffix to VDSO32 object files.

Also change sigtramp.S to sigtramp32.S as VDSO64 sigtramp.S is too
different to be squashed into VDSO32 sigtramp.S at the first place.

gen_vdso_offsets.sh also becomes gen_vdso32_offsets.sh

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/vdso32/Makefile   | 47 +--
 ..._vdso_offsets.sh => gen_vdso32_offsets.sh} |  0
 .../vdso32/{sigtramp.S => sigtramp32.S}   |  0
 3 files changed, 21 insertions(+), 26 deletions(-)
 rename arch/powerpc/kernel/vdso32/{gen_vdso_offsets.sh => 
gen_vdso32_offsets.sh} (100%)
 rename arch/powerpc/kernel/vdso32/{sigtramp.S => sigtramp32.S} (100%)

diff --git a/arch/powerpc/kernel/vdso32/Makefile 
b/arch/powerpc/kernel/vdso32/Makefile
index 7d9a6fee0e3d..7d7b38d90ca5 100644
--- a/arch/powerpc/kernel/vdso32/Makefile
+++ b/arch/powerpc/kernel/vdso32/Makefile
@@ -5,15 +5,16 @@
 ARCH_REL_TYPE_ABS := 
R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN|R_PPC_REL24
 include $(srctree)/lib/vdso/Makefile
 
-obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o getcpu.o
+obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o 
note-32.o getcpu-32.o
 
 ifneq ($(c-gettimeofday-y),)
-  CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
-  CFLAGS_vgettimeofday.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
-  CFLAGS_vgettimeofday.o += $(call cc-option, -fno-stack-protector)
-  CFLAGS_vgettimeofday.o += -DDISABLE_BRANCH_PROFILING
-  CFLAGS_vgettimeofday.o += -ffreestanding -fasynchronous-unwind-tables
-  CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE)
+  CFLAGS_vgettimeofday-32.o += -include $(c-gettimeofday-y)
+  CFLAGS_vgettimeofday-32.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
+  CFLAGS_vgettimeofday-32.o += $(call cc-option, -fno-stack-protector)
+  CFLAGS_vgettimeofday-32.o += -DDISABLE_BRANCH_PROFILING
+  CFLAGS_vgettimeofday-32.o += -ffreestanding -fasynchronous-unwind-tables
+  CFLAGS_REMOVE_vgettimeofday-32.o = $(CC_FLAGS_FTRACE)
+  CFLAGS_REMOVE_vgettimeofday-32.o += -mcmodel=medium -mabi=elfv1 -mabi=elfv2 
-mcall-aixdesc
 endif
 
 # Build rules
@@ -24,13 +25,7 @@ else
 VDSOCC := $(CC)
 endif
 
-CC32FLAGS :=
-ifdef CONFIG_PPC64
-CC32FLAGS += -m32
-KBUILD_CFLAGS := $(filter-out -mcmodel=medium -mabi=elfv1 -mabi=elfv2 
-mcall-aixdesc,$(KBUILD_CFLAGS))
-endif
-
-targets := $(obj-vdso32) vdso32.so.dbg vgettimeofday.o
+targets := $(obj-vdso32) vdso32.so.dbg vgettimeofday-32.o
 obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
 
 GCOV_PROFILE := n
@@ -38,36 +33,36 @@ KCOV_INSTRUMENT := n
 UBSAN_SANITIZE := n
 KASAN_SANITIZE := n
 
-ccflags-y := -shared -fno-common -fno-builtin -nostdlib \
-   -Wl,-soname=linux-vdso32.so.1 -Wl,--hash-style=both
-asflags-y := -D__VDSO32__ -s
+ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both
+
+CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32
+AS32FLAGS := -D__VDSO32__ -s
 
-obj-y += vdso32_wrapper.o
 targets += vdso32.lds
 CPPFLAGS_vdso32.lds += -P -C -Upowerpc
 
 # link rule for the .so file, .lds has to be first
-$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday.o 
FORCE
+$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) 
$(obj)/vgettimeofday-32.o FORCE
$(call if_changed,vdso32ld_and_check)
 
 # assembly rules for the .S files
-$(obj-vdso32): %.o: %.S FORCE
+$(obj-vdso32): %-32.o: %.S FORCE
$(call if_changed_dep,vdso32as)
-$(obj)/vgettimeofday.o: %.o: %.c FORCE
+$(obj)/vgettimeofday-32.o: %-32.o: %.c FORCE
$(call if_changed_dep,vdso32cc)
 
 # Generate VDSO offsets using helper script
-gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
-quiet_cmd_vdsosym = VDSOSYM $@
-  cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
+gen-vdso32sym := $(srctree)/$(src)/gen_vdso32_offsets.sh
+quiet_cmd_vdso32sym = VDSO32SYM $@
+  cmd_vdso32sym = $(NM) $< | $(gen-vdso32sym) | LC_ALL=C sort > $@
 
 include/generated/vdso32-offsets.h: $(obj)/vdso32.so.dbg FORCE
-   $(call if_changed,vdsosym)
+   $(call if_changed,vdso32sym)
 
 # actual build commands
 quiet_cmd_vdso32ld_and_check = VDSO32L $@
   cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ 
-Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check)
 quiet_cmd_vdso32as = VDSO32A $@
-  cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $<
+  cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $<
 quiet_cmd_vdso32cc = VDSO32C $@
   cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $<
diff --git a/arch/powerpc/kernel/vdso32/gen_vdso_offsets.sh 
b/arch/powerpc/kernel/vdso32/gen_vdso32_offsets.sh
similarity index 100%
rename from arch/powerpc/kernel/vdso32/gen_vdso_offsets.sh
rename to 

[PATCH 1/3] powerpc/vdso: augment VDSO32 functions to support 64 bits build

2021-12-21 Thread Christophe Leroy
VDSO64 cacheflush.S datapage.S gettimeofday.S and vgettimeofday.c
are very similar to their VDSO32 counterpart.

VDSO32 counterpart is already more complete than the VDSO64 version
as it supports both PPC32 vdso and 32 bits VDSO for PPC64.

Use compat macros wherever necessary in PPC32 files
so that they can also be used to build VDSO64.

vdso64/note.S is already a link to vdso32/note.S so
no change is required.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/include/asm/asm-compat.h  |  2 ++
 arch/powerpc/kernel/vdso32/cacheflush.S|  4 ++--
 arch/powerpc/kernel/vdso32/datapage.S  | 10 --
 arch/powerpc/kernel/vdso32/getcpu.S|  4 ++--
 arch/powerpc/kernel/vdso32/gettimeofday.S  |  8 ++--
 arch/powerpc/kernel/vdso32/vgettimeofday.c | 23 ++
 6 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/include/asm/asm-compat.h 
b/arch/powerpc/include/asm/asm-compat.h
index 2b736d9fbb1b..2bc53c646ccd 100644
--- a/arch/powerpc/include/asm/asm-compat.h
+++ b/arch/powerpc/include/asm/asm-compat.h
@@ -21,6 +21,7 @@
 #define PPC_STLCX  stringify_in_c(stdcx.)
 #define PPC_CNTLZL stringify_in_c(cntlzd)
 #define PPC_MTOCRF(FXM, RS) MTOCRF((FXM), RS)
+#define PPC_SRLstringify_in_c(srd)
 #define PPC_LR_STKOFF  16
 #define PPC_MIN_STKFRM 112
 
@@ -54,6 +55,7 @@
 #define PPC_STLCX  stringify_in_c(stwcx.)
 #define PPC_CNTLZL stringify_in_c(cntlzw)
 #define PPC_MTOCRF stringify_in_c(mtcrf)
+#define PPC_SRLstringify_in_c(srw)
 #define PPC_LR_STKOFF  4
 #define PPC_MIN_STKFRM 16
 
diff --git a/arch/powerpc/kernel/vdso32/cacheflush.S 
b/arch/powerpc/kernel/vdso32/cacheflush.S
index f340e82d1981..d4e43ab2d5df 100644
--- a/arch/powerpc/kernel/vdso32/cacheflush.S
+++ b/arch/powerpc/kernel/vdso32/cacheflush.S
@@ -46,7 +46,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
add r8,r8,r5/* ensure we get enough */
 #ifdef CONFIG_PPC64
lwz r9,CFG_DCACHE_LOGBLOCKSZ(r10)
-   srw.r8,r8,r9/* compute line count */
+   PPC_SRL.r8,r8,r9/* compute line count */
 #else
srwi.   r8, r8, L1_CACHE_SHIFT
mr  r7, r6
@@ -72,7 +72,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
subfr8,r6,r4/* compute length */
add r8,r8,r5
lwz r9,CFG_ICACHE_LOGBLOCKSZ(r10)
-   srw.r8,r8,r9/* compute line count */
+   PPC_SRL.r8,r8,r9/* compute line count */
crclr   cr0*4+so
beqlr   /* nothing to do? */
 #endif
diff --git a/arch/powerpc/kernel/vdso32/datapage.S 
b/arch/powerpc/kernel/vdso32/datapage.S
index 65244416ab94..db8e167f0166 100644
--- a/arch/powerpc/kernel/vdso32/datapage.S
+++ b/arch/powerpc/kernel/vdso32/datapage.S
@@ -30,11 +30,15 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map)
mr. r4,r3
get_datapager3
mtlrr12
+#ifdef __powerpc64__
+   addir3,r3,CFG_SYSCALL_MAP64
+#else
addir3,r3,CFG_SYSCALL_MAP32
+#endif
+   crclr   cr0*4+so
beqlr
li  r0,NR_syscalls
stw r0,0(r4)
-   crclr   cr0*4+so
blr
   .cfi_endproc
 V_FUNCTION_END(__kernel_get_syscall_map)
@@ -49,8 +53,10 @@ V_FUNCTION_BEGIN(__kernel_get_tbfreq)
mflrr12
   .cfi_register lr,r12
get_datapager3
+#ifndef __powerpc64__
lwz r4,(CFG_TB_TICKS_PER_SEC + 4)(r3)
-   lwz r3,CFG_TB_TICKS_PER_SEC(r3)
+#endif
+   PPC_LL  r3,CFG_TB_TICKS_PER_SEC(r3)
mtlrr12
crclr   cr0*4+so
blr
diff --git a/arch/powerpc/kernel/vdso32/getcpu.S 
b/arch/powerpc/kernel/vdso32/getcpu.S
index ff5e214fec41..8e08ccf19062 100644
--- a/arch/powerpc/kernel/vdso32/getcpu.S
+++ b/arch/powerpc/kernel/vdso32/getcpu.S
@@ -19,8 +19,8 @@
 V_FUNCTION_BEGIN(__kernel_getcpu)
   .cfi_startproc
mfspr   r5,SPRN_SPRG_VDSO_READ
-   cmpwi   cr0,r3,0
-   cmpwi   cr1,r4,0
+   PPC_LCMPI   cr0,r3,0
+   PPC_LCMPI   cr1,r4,0
clrlwi  r6,r5,16
rlwinm  r7,r5,16,31-15,31-0
beq cr0,1f
diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S 
b/arch/powerpc/kernel/vdso32/gettimeofday.S
index d21d08140a5e..c875312274aa 100644
--- a/arch/powerpc/kernel/vdso32/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso32/gettimeofday.S
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 /*
- * Userland implementation of gettimeofday() for 32 bits processes in a
- * ppc64 kernel for use in the vDSO
+ * Userland implementation of gettimeofday() for processes
+ * for use in the vDSO
  *
  * Copyright (C) 2004 Benjamin Herrenschmuidt (b...@kernel.crashing.org,
  *IBM Corp.
@@ -41,9 +41,11 @@ V_FUNCTION_END(__kernel_clock_gettime)
  * int __kernel_clock_gettime64(clockid_t clock_id, struct __timespec64 *ts);
  *
  */
+#ifndef __powerpc64__
 

[PATCH 8/8] sched: mips: Remove unused TASK_SIZE_OF

2021-12-21 Thread guoren
From: Guo Ren 

This macro isn't used in Linux sched, now. Delete in
include/linux/sched.h and arch's include/asm.

Signed-off-by: Guo Ren 
---
 arch/mips/include/asm/processor.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/mips/include/asm/processor.h 
b/arch/mips/include/asm/processor.h
index 4bb24579d12e..8871fc5b0baa 100644
--- a/arch/mips/include/asm/processor.h
+++ b/arch/mips/include/asm/processor.h
@@ -61,9 +61,6 @@ extern int arch_dup_task_struct(struct task_struct *dst, 
struct task_struct *src
 #define TASK_SIZE (test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 : 
TASK_SIZE64)
 #define STACK_TOP_MAX  TASK_SIZE64
 
-#define TASK_SIZE_OF(tsk)  \
-   (test_tsk_thread_flag(tsk, TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE64)
-
 #define TASK_IS_32BIT_ADDR test_thread_flag(TIF_32BIT_ADDR)
 
 #endif
-- 
2.25.1



[PATCH 7/8] sched: arm64: Remove unused TASK_SIZE_OF

2021-12-21 Thread guoren
From: Guo Ren 

This macro isn't used in Linux sched, now. Delete in
include/linux/sched.h and arch's include/asm.

Signed-off-by: Guo Ren 
---
 arch/arm64/include/asm/processor.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm64/include/asm/processor.h 
b/arch/arm64/include/asm/processor.h
index 6f41b65f9962..d24dfb49237d 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -65,8 +65,6 @@
 #endif /* CONFIG_ARM64_64K_PAGES */
 #define TASK_SIZE  (test_thread_flag(TIF_32BIT) ? \
TASK_SIZE_32 : TASK_SIZE_64)
-#define TASK_SIZE_OF(tsk)  (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
-   TASK_SIZE_32 : TASK_SIZE_64)
 #define DEFAULT_MAP_WINDOW (test_thread_flag(TIF_32BIT) ? \
TASK_SIZE_32 : DEFAULT_MAP_WINDOW_64)
 #else
-- 
2.25.1



[PATCH 6/8] sched: parisc: Remove unused TASK_SIZE_OF

2021-12-21 Thread guoren
From: Guo Ren 

This macro isn't used in Linux sched, now. Delete in
include/linux/sched.h and arch's include/asm.

Signed-off-by: Guo Ren 
---
 arch/parisc/include/asm/processor.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/parisc/include/asm/processor.h 
b/arch/parisc/include/asm/processor.h
index b669f4b9040b..d9c8dc76ee6a 100644
--- a/arch/parisc/include/asm/processor.h
+++ b/arch/parisc/include/asm/processor.h
@@ -23,8 +23,7 @@
 
 #define HAVE_ARCH_PICK_MMAP_LAYOUT
 
-#define TASK_SIZE_OF(tsk)   ((tsk)->thread.task_size)
-#define TASK_SIZE  TASK_SIZE_OF(current)
+#define TASK_SIZE   (current->thread.task_size)
 #define TASK_UNMAPPED_BASE  (current->thread.map_base)
 
 #define DEFAULT_TASK_SIZE32(0xFFF0UL)
-- 
2.25.1



[PATCH 5/8] sched: s390: Remove unused TASK_SIZE_OF

2021-12-21 Thread guoren
From: Guo Ren 

This macro isn't used in Linux sched, now. Delete in
include/linux/sched.h and arch's include/asm.

Signed-off-by: Guo Ren 
---
 arch/s390/include/asm/processor.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/s390/include/asm/processor.h 
b/arch/s390/include/asm/processor.h
index f54c152bf2bf..605bc57a5ffc 100644
--- a/arch/s390/include/asm/processor.h
+++ b/arch/s390/include/asm/processor.h
@@ -88,11 +88,10 @@ extern void __bpon(void);
  * User space process size: 2GB for 31 bit, 4TB or 8PT for 64 bit.
  */
 
-#define TASK_SIZE_OF(tsk)  (test_tsk_thread_flag(tsk, TIF_31BIT) ? \
+#define TASK_SIZE  (test_tsk_thread_flag(current, TIF_31BIT) ? \
_REGION3_SIZE : TASK_SIZE_MAX)
 #define TASK_UNMAPPED_BASE (test_thread_flag(TIF_31BIT) ? \
(_REGION3_SIZE >> 1) : (_REGION2_SIZE 
>> 1))
-#define TASK_SIZE  TASK_SIZE_OF(current)
 #define TASK_SIZE_MAX  (-PAGE_SIZE)
 
 #define STACK_TOP  (test_thread_flag(TIF_31BIT) ? \
-- 
2.25.1



[PATCH 4/8] sched: powerpc: Remove unused TASK_SIZE_OF

2021-12-21 Thread guoren
From: Guo Ren 

This macro isn't used in Linux sched, now. Delete in
include/linux/sched.h and arch's include/asm.

Signed-off-by: Guo Ren 
---
 arch/powerpc/include/asm/task_size_64.h | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/task_size_64.h 
b/arch/powerpc/include/asm/task_size_64.h
index c993482237ed..7e2eca4fac4d 100644
--- a/arch/powerpc/include/asm/task_size_64.h
+++ b/arch/powerpc/include/asm/task_size_64.h
@@ -44,12 +44,10 @@
  */
 #define TASK_SIZE_USER32 (0x0001UL - (1 * PAGE_SIZE))
 
-#define TASK_SIZE_OF(tsk)  \
-   (test_tsk_thread_flag(tsk, TIF_32BIT) ? TASK_SIZE_USER32 :  \
+#define TASK_SIZE  \
+   (test_tsk_thread_flag(current, TIF_32BIT) ? TASK_SIZE_USER32 :  \
TASK_SIZE_USER64)
 
-#define TASK_SIZE TASK_SIZE_OF(current)
-
 #define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4))
 #define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(DEFAULT_MAP_WINDOW_USER64 / 4))
 
-- 
2.25.1



[PATCH 3/8] sched: sparc: Remove unused TASK_SIZE_OF

2021-12-21 Thread guoren
From: Guo Ren 

This macro isn't used in Linux, now. Delete in
include/linux/sched.h and arch's include/asm.

Signed-off-by: Guo Ren 
---
 arch/sparc/include/asm/processor_64.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/sparc/include/asm/processor_64.h 
b/arch/sparc/include/asm/processor_64.h
index ae851e8fce4c..628349fc4cdd 100644
--- a/arch/sparc/include/asm/processor_64.h
+++ b/arch/sparc/include/asm/processor_64.h
@@ -27,9 +27,6 @@
 #define VPTE_SIZE  (1 << (VA_BITS - PAGE_SHIFT + 3))
 #endif
 
-#define TASK_SIZE_OF(tsk) \
-   (test_tsk_thread_flag(tsk,TIF_32BIT) ? \
-(1UL << 32UL) : ((unsigned long)-VPTE_SIZE))
 #define TASK_SIZE \
(test_thread_flag(TIF_32BIT) ? \
 (1UL << 32UL) : ((unsigned long)-VPTE_SIZE))
-- 
2.25.1



[PATCH 2/8] sched: x86: Remove unused TASK_SIZE_OF

2021-12-21 Thread guoren
From: Guo Ren 

This macro isn't used in Linux, now. Delete in
include/linux/sched.h and arch's include/asm.

Signed-off-by: Guo Ren 
---
 arch/x86/include/asm/page_64_types.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/include/asm/page_64_types.h 
b/arch/x86/include/asm/page_64_types.h
index e9e2c3ba5923..6191cf417c31 100644
--- a/arch/x86/include/asm/page_64_types.h
+++ b/arch/x86/include/asm/page_64_types.h
@@ -74,8 +74,6 @@
IA32_PAGE_OFFSET : DEFAULT_MAP_WINDOW)
 #define TASK_SIZE  (test_thread_flag(TIF_ADDR32) ? \
IA32_PAGE_OFFSET : TASK_SIZE_MAX)
-#define TASK_SIZE_OF(child)((test_tsk_thread_flag(child, TIF_ADDR32)) ? \
-   IA32_PAGE_OFFSET : TASK_SIZE_MAX)
 
 #define STACK_TOP  TASK_SIZE_LOW
 #define STACK_TOP_MAX  TASK_SIZE_MAX
-- 
2.25.1



[PATCH 1/8] sched: Remove unused TASK_SIZE_OF

2021-12-21 Thread guoren
From: Guo Ren 

This macro isn't used in Linux, now. Delete in include/linux/sched.h
and arch's include/asm. This would confuse people who are
implementing the COMPAT feature for architecture.

Signed-off-by: Guo Ren 
---
 include/linux/sched.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 78c351e35fec..8e5689d06ac8 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2166,10 +2166,6 @@ static inline bool vcpu_is_preempted(int cpu)
 extern long sched_setaffinity(pid_t pid, const struct cpumask *new_mask);
 extern long sched_getaffinity(pid_t pid, struct cpumask *mask);
 
-#ifndef TASK_SIZE_OF
-#define TASK_SIZE_OF(tsk)  TASK_SIZE
-#endif
-
 #ifdef CONFIG_SMP
 /* Returns effective CPU energy utilization, as seen by the scheduler */
 unsigned long sched_cpu_util(int cpu, unsigned long max);
-- 
2.25.1



[PATCH 0/8] sched: Remove unused TASK_SIZE_OF

2021-12-21 Thread guoren
From: Guo Ren 

This macro isn't used in Linux, now. Delete in include/linux/sched.h
and arch's include/asm. This would confuse people who are
implementing the COMPAT feature for architecture.

Guo Ren (8):
  sched: Remove unused TASK_SIZE_OF
  sched: x86: Remove unused TASK_SIZE_OF
  sched: sparc: Remove unused TASK_SIZE_OF
  sched: powerpc: Remove unused TASK_SIZE_OF
  sched: s390: Remove unused TASK_SIZE_OF
  sched: parisc: Remove unused TASK_SIZE_OF
  sched: arm64: Remove unused TASK_SIZE_OF
  sched: mips: Remove unused TASK_SIZE_OF

 arch/arm64/include/asm/processor.h  | 2 --
 arch/mips/include/asm/processor.h   | 3 ---
 arch/parisc/include/asm/processor.h | 3 +--
 arch/powerpc/include/asm/task_size_64.h | 6 ++
 arch/s390/include/asm/processor.h   | 3 +--
 arch/sparc/include/asm/processor_64.h   | 3 ---
 arch/x86/include/asm/page_64_types.h| 2 --
 include/linux/sched.h   | 4 
 8 files changed, 4 insertions(+), 22 deletions(-)

-- 
2.25.1



[PATCH] powerpc/cell/axon_msi: replace DEFINE_SIMPLE_ATTRIBUTE with DEFINE_DEBUGFS_ATTRIBUTE

2021-12-21 Thread cgel . zte
From: Changcheng Deng 

Fix the following coccicheck warning:
./arch/powerpc/platforms/cell/axon_msi.c: 456: 0-23: WARNING: fops_msic
should be defined with DEFINE_DEBUGFS_ATTRIBUTE

Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE for
debugfs files.

Reported-by: Zeal Robot 
Signed-off-by: Changcheng Deng 
---
 arch/powerpc/platforms/cell/axon_msi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/cell/axon_msi.c 
b/arch/powerpc/platforms/cell/axon_msi.c
index 354a58c1e6f2..47bb0ae8d6c9 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -453,7 +453,7 @@ static int msic_get(void *data, u64 *val)
return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(fops_msic, msic_get, msic_set, "%llu\n");
+DEFINE_DEBUGFS_ATTRIBUTE(fops_msic, msic_get, msic_set, "%llu\n");
 
 void axon_msi_debug_setup(struct device_node *dn, struct axon_msic *msic)
 {
-- 
2.25.1



Re: [PATCH 13/17] kernel/cpu: add num_possible_cpus counter

2021-12-21 Thread Peter Zijlstra
On Sat, Dec 18, 2021 at 01:20:09PM -0800, Yury Norov wrote:
> Similarly to the online cpus, the cpu_possible_mask is actively used
> in the kernel. This patch adds a counter for possible cpus, so that
> users that call num_possible_cpus() would know the result immediately,
> instead of calling the bitmap_weight for the mask underlying.

So what user actually cares about performance here enough to warrant
this?


> +EXPORT_SYMBOL(set_cpu_possible);

NAK


Re: [PATCH 14/17] kernel/cpu: add num_present_cpu counter

2021-12-21 Thread Peter Zijlstra
On Sat, Dec 18, 2021 at 01:20:10PM -0800, Yury Norov wrote:
> +EXPORT_SYMBOL(set_cpu_present);

NAK


Re: [PATCH 15/17] kernel/cpu: add num_active_cpu counter

2021-12-21 Thread Peter Zijlstra
On Sat, Dec 18, 2021 at 01:20:11PM -0800, Yury Norov wrote:
> Similarly to the online cpus, the cpu_active_mask is actively used
> in the kernel. This patch adds a counter for active cpus, so that
> users that call num_active_cpus() would know the result immediately,
> instead of calling the bitmap_weight for the mask.

Who cares about num_active_cpus() ?

> +EXPORT_SYMBOL(set_cpu_active);

NAK, this should *never*ever* be used from a module.



Re: [PATCH] tpm: Fix kexec crash due to access to ops NULL pointer (powerpc)

2021-12-21 Thread Stefan Berger



On 12/21/21 09:01, Stefan Berger wrote:


On 12/21/21 03:47, Jarkko Sakkinen wrote:

On Sat, Dec 11, 2021 at 08:28:04PM -0500, Stefan Berger wrote:
Fix the following crash on kexec by checking chip->ops for a NULL 
pointer

in tpm_chip_start() and returning an error code if this is the case.

BUG: Kernel NULL pointer dereference on read at 0x0060
Faulting instruction address: 0xc099a06c
Oops: Kernel access of bad area, sig: 11 [#1]
...
NIP [c099a06c] tpm_chip_start+0x2c/0x140
  LR [c099a808] tpm_chip_unregister+0x108/0x170
Call Trace:
[c000188bfa00] [c2b03930] fw_devlink_strict+0x0/0x8 
(unreliable)

[c000188bfa30] [c099a808] tpm_chip_unregister+0x108/0x170
[c000188bfa70] [c09a3874] tpm_ibmvtpm_remove+0x34/0x130
[c000188bfae0] [c0110dbc] vio_bus_remove+0x5c/0xb0
[c000188bfb20] [c09bc154] device_shutdown+0x1d4/0x3a8
[c000188bfbc0] [c0196e14] kernel_restart_prepare+0x54/0x70

The referenced patch below introduced a function to shut down the 
VIO bus.
The bus shutdown now calls tpm_del_char_device (via 
tpm_chip_unregister)
after a call to tpm_class_shutdown, which already set chip->ops to 
NULL.
The crash occurrs when tpm_del_char_device calls tpm_chip_start with 
the

chip->ops NULL pointer.

Fixes: 39d0099f9439 ("powerpc/pseries: Add shutdown() to vio_driver 
and vio_bus")

Signed-off-by: Stefan Berger 
---
  drivers/char/tpm/tpm-chip.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index ddaeceb7e109..cca1bde296ee 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -101,6 +101,9 @@ int tpm_chip_start(struct tpm_chip *chip)
  {
  int ret;
  +    if (!chip->ops)
+    return -EINVAL;

This triggers to all drivers, not just tpm_ibmvtpm, i.e. the fix has
side-effects.


What are those side-effects?


I am asking because if one entered tpm_chip_start() with chip->ops = 
NULL it would crash any system. So now the side-effect is that one can 
call this function without crashing the system but gets an -EINVAL back.


Another alternative that prevents these crashes is this change here 
including code deduplication:


diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index ddaeceb7e109..888d37293091 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -296,7 +296,7 @@ static int tpm_class_shutdown(struct device *dev)
    struct tpm_chip *chip = container_of(dev, struct tpm_chip, dev);

    down_write(>ops_sem);
-   if (chip->flags & TPM_CHIP_FLAG_TPM2) {
+   if (chip->ops && chip->flags & TPM_CHIP_FLAG_TPM2) {
    if (!tpm_chip_start(chip)) {
    tpm2_shutdown(chip, TPM2_SU_CLEAR);
    tpm_chip_stop(chip);
@@ -473,15 +473,7 @@ static void tpm_del_char_device(struct tpm_chip *chip)
    mutex_unlock(_lock);

    /* Make the driver uncallable. */
-   down_write(>ops_sem);
-   if (chip->flags & TPM_CHIP_FLAG_TPM2) {
-   if (!tpm_chip_start(chip)) {
-   tpm2_shutdown(chip, TPM2_SU_CLEAR);
-   tpm_chip_stop(chip);
-   }
-   }
-   chip->ops = NULL;
-   up_write(>ops_sem);
+   tpm_class_shutdown(>dev);
 }

 static void tpm_del_legacy_sysfs(struct tpm_chip *chip)



    Stefan



Re: [PATCH] tpm: Fix kexec crash due to access to ops NULL pointer (powerpc)

2021-12-21 Thread Stefan Berger



On 12/21/21 03:47, Jarkko Sakkinen wrote:

On Sat, Dec 11, 2021 at 08:28:04PM -0500, Stefan Berger wrote:

Fix the following crash on kexec by checking chip->ops for a NULL pointer
in tpm_chip_start() and returning an error code if this is the case.

BUG: Kernel NULL pointer dereference on read at 0x0060
Faulting instruction address: 0xc099a06c
Oops: Kernel access of bad area, sig: 11 [#1]
...
NIP [c099a06c] tpm_chip_start+0x2c/0x140
  LR [c099a808] tpm_chip_unregister+0x108/0x170
Call Trace:
[c000188bfa00] [c2b03930] fw_devlink_strict+0x0/0x8 (unreliable)
[c000188bfa30] [c099a808] tpm_chip_unregister+0x108/0x170
[c000188bfa70] [c09a3874] tpm_ibmvtpm_remove+0x34/0x130
[c000188bfae0] [c0110dbc] vio_bus_remove+0x5c/0xb0
[c000188bfb20] [c09bc154] device_shutdown+0x1d4/0x3a8
[c000188bfbc0] [c0196e14] kernel_restart_prepare+0x54/0x70

The referenced patch below introduced a function to shut down the VIO bus.
The bus shutdown now calls tpm_del_char_device (via tpm_chip_unregister)
after a call to tpm_class_shutdown, which already set chip->ops to NULL.
The crash occurrs when tpm_del_char_device calls tpm_chip_start with the
chip->ops NULL pointer.

Fixes: 39d0099f9439 ("powerpc/pseries: Add shutdown() to vio_driver and 
vio_bus")
Signed-off-by: Stefan Berger 
---
  drivers/char/tpm/tpm-chip.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index ddaeceb7e109..cca1bde296ee 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -101,6 +101,9 @@ int tpm_chip_start(struct tpm_chip *chip)
  {
int ret;
  
+	if (!chip->ops)

+   return -EINVAL;

This triggers to all drivers, not just tpm_ibmvtpm, i.e. the fix has
side-effects.


What are those side-effects?

  Stefan



/Jarkko



[PATCH 1/3] powerpc/64s: Mask NIP before checking against SRR0

2021-12-21 Thread Michael Ellerman
When CONFIG_PPC_RFI_SRR_DEBUG=y we check that NIP and SRR0 match when
returning from interrupts. This can trigger falsely if NIP has either of
its two low bits set via sigreturn or ptrace, while SRR0 has its low two
bits masked in hardware.

As a quick fix make sure to mask the low bits before doing the check.

Fixes: 59dc5bfca0cb ("powerpc/64s: avoid reloading (H)SRR registers if they are 
still valid")
Reported-by: Sachin Sant 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/interrupt_64.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/kernel/interrupt_64.S 
b/arch/powerpc/kernel/interrupt_64.S
index 2ad223597ca2..4fd65d39d5d3 100644
--- a/arch/powerpc/kernel/interrupt_64.S
+++ b/arch/powerpc/kernel/interrupt_64.S
@@ -30,6 +30,7 @@
.ifc \srr,srr
mfspr   r11,SPRN_SRR0
ld  r12,_NIP(r1)
+   clrrdi  r12,r12,2
 100:   tdner11,r12
EMIT_BUG_ENTRY 100b,__FILE__,__LINE__,(BUGFLAG_WARNING | BUGFLAG_ONCE)
mfspr   r11,SPRN_SRR1
@@ -39,6 +40,7 @@
.else
mfspr   r11,SPRN_HSRR0
ld  r12,_NIP(r1)
+   clrrdi  r12,r12,2
 100:   tdner11,r12
EMIT_BUG_ENTRY 100b,__FILE__,__LINE__,(BUGFLAG_WARNING | BUGFLAG_ONCE)
mfspr   r11,SPRN_HSRR1
-- 
2.31.1



[PATCH 2/3] powerpc/64s: Use EMIT_WARN_ENTRY for SRR debug warnings

2021-12-21 Thread Michael Ellerman
When CONFIG_PPC_RFI_SRR_DEBUG=y we check the SRR values before returning
from interrupts. This is done in asm using EMIT_BUG_ENTRY, and passing
BUGFLAG_WARNING.

However that fails to create an exception table entry for the warning,
and so do_program_check() fails the exception table search and proceeds
to call _exception(), resulting in an oops like:

  Oops: Exception in kernel mode, sig: 5 [#1]
  LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries
  Modules linked in:
  CPU: 2 PID: 1204 Comm: sigreturn_unali Tainted: P  
5.16.0-rc2-00194-g91ca3d4f77c5 #12
  NIP:  c000c5b0 LR:  CTR: 
  ...
  NIP [c000c5b0] system_call_common+0x150/0x268
  LR [] 0x0
  Call Trace:
  [cdb73e10] [c000c558] system_call_common+0xf8/0x268 
(unreliable)
  ...
  Instruction dump:
  7cc803a6 888d0931 2c24 4082001c 3880 988d0931 e8810170 e8a10178
  7c9a03a6 7cbb03a6 7d7a02a6 e9810170 <7f0b6088> 7d7b02a6 e9810178 7f0b6088

We should instead use EMIT_WARN_ENTRY, which creates an exception table
entry for the warning, allowing the warning to be correctly recognised,
and the code to resume after printing the warning.

Note however that because this warning is buried deep in the interrupt
return path, we are not able to recover from it (due to MSR_RI being
clear), so we still end up in die() with an unrecoverable exception.

Fixes: 59dc5bfca0cb ("powerpc/64s: avoid reloading (H)SRR registers if they are 
still valid")
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/interrupt_64.S | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/interrupt_64.S 
b/arch/powerpc/kernel/interrupt_64.S
index 4fd65d39d5d3..be5ff1521505 100644
--- a/arch/powerpc/kernel/interrupt_64.S
+++ b/arch/powerpc/kernel/interrupt_64.S
@@ -32,21 +32,21 @@
ld  r12,_NIP(r1)
clrrdi  r12,r12,2
 100:   tdner11,r12
-   EMIT_BUG_ENTRY 100b,__FILE__,__LINE__,(BUGFLAG_WARNING | BUGFLAG_ONCE)
+   EMIT_WARN_ENTRY 100b,__FILE__,__LINE__,(BUGFLAG_WARNING | BUGFLAG_ONCE)
mfspr   r11,SPRN_SRR1
ld  r12,_MSR(r1)
 100:   tdner11,r12
-   EMIT_BUG_ENTRY 100b,__FILE__,__LINE__,(BUGFLAG_WARNING | BUGFLAG_ONCE)
+   EMIT_WARN_ENTRY 100b,__FILE__,__LINE__,(BUGFLAG_WARNING | BUGFLAG_ONCE)
.else
mfspr   r11,SPRN_HSRR0
ld  r12,_NIP(r1)
clrrdi  r12,r12,2
 100:   tdner11,r12
-   EMIT_BUG_ENTRY 100b,__FILE__,__LINE__,(BUGFLAG_WARNING | BUGFLAG_ONCE)
+   EMIT_WARN_ENTRY 100b,__FILE__,__LINE__,(BUGFLAG_WARNING | BUGFLAG_ONCE)
mfspr   r11,SPRN_HSRR1
ld  r12,_MSR(r1)
 100:   tdner11,r12
-   EMIT_BUG_ENTRY 100b,__FILE__,__LINE__,(BUGFLAG_WARNING | BUGFLAG_ONCE)
+   EMIT_WARN_ENTRY 100b,__FILE__,__LINE__,(BUGFLAG_WARNING | BUGFLAG_ONCE)
.endif
 #endif
 .endm
-- 
2.31.1



[PATCH 3/3] selftests/powerpc: Add a test of sigreturning to an unaligned address

2021-12-21 Thread Michael Ellerman
Add a test of sigreturning to an unaligned address (low two bits set).
This should have no effect because the hardware will mask those bits.
However it previously falsely triggered a warning when
CONFIG_PPC_RFI_SRR_DEBUG=y.

Signed-off-by: Michael Ellerman 
---
 .../selftests/powerpc/signal/.gitignore   |  1 +
 .../testing/selftests/powerpc/signal/Makefile |  1 +
 .../powerpc/signal/sigreturn_unaligned.c  | 43 +++
 3 files changed, 45 insertions(+)
 create mode 100644 tools/testing/selftests/powerpc/signal/sigreturn_unaligned.c

diff --git a/tools/testing/selftests/powerpc/signal/.gitignore 
b/tools/testing/selftests/powerpc/signal/.gitignore
index 8f6c816099a4..9d0915777fed 100644
--- a/tools/testing/selftests/powerpc/signal/.gitignore
+++ b/tools/testing/selftests/powerpc/signal/.gitignore
@@ -5,3 +5,4 @@ sigfuz
 sigreturn_vdso
 sig_sc_double_restart
 sigreturn_kernel
+sigreturn_unaligned
diff --git a/tools/testing/selftests/powerpc/signal/Makefile 
b/tools/testing/selftests/powerpc/signal/Makefile
index 84e201572466..f679d260afc8 100644
--- a/tools/testing/selftests/powerpc/signal/Makefile
+++ b/tools/testing/selftests/powerpc/signal/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 TEST_GEN_PROGS := signal signal_tm sigfuz sigreturn_vdso sig_sc_double_restart
 TEST_GEN_PROGS += sigreturn_kernel
+TEST_GEN_PROGS += sigreturn_unaligned
 
 CFLAGS += -maltivec
 $(OUTPUT)/signal_tm: CFLAGS += -mhtm
diff --git a/tools/testing/selftests/powerpc/signal/sigreturn_unaligned.c 
b/tools/testing/selftests/powerpc/signal/sigreturn_unaligned.c
new file mode 100644
index ..6e58ee4f0fdf
--- /dev/null
+++ b/tools/testing/selftests/powerpc/signal/sigreturn_unaligned.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Test sigreturn to an unaligned address, ie. low 2 bits set.
+ * Nothing bad should happen.
+ * This was able to trigger warnings with CONFIG_PPC_RFI_SRR_DEBUG=y.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "utils.h"
+
+
+static void sigusr1_handler(int signo, siginfo_t *info, void *ptr)
+{
+   ucontext_t *uc = ptr;
+
+   UCONTEXT_NIA(uc) |= 3;
+}
+
+static int test_sigreturn_unaligned(void)
+{
+   struct sigaction action;
+
+   memset(, 0, sizeof(action));
+   action.sa_sigaction = sigusr1_handler;
+   action.sa_flags = SA_SIGINFO;
+
+   FAIL_IF(sigaction(SIGUSR1, , NULL) == -1);
+
+   raise(SIGUSR1);
+
+   return 0;
+}
+
+int main(void)
+{
+   return test_harness(test_sigreturn_unaligned, "sigreturn_unaligned");
+}
-- 
2.31.1



Re: [PATCH v3 0/6] powerpc/64s: interrupt speedups

2021-12-21 Thread Michael Ellerman
On Thu, 23 Sep 2021 00:54:46 +1000, Nicholas Piggin wrote:
> Here's a few stragglers. The first patch was submitted already but had
> some bugs with unrecoverable exceptions on HPT (current->blah being
> accessed before MSR[RI] was enabled). Those should be fixed now.
> 
> The others are generally for helping asynch interrupts, which are a bit
> harder to measure well but important for IO and IPIs.
> 
> [...]

Applied to powerpc/next.

[1/6] powerpc/64/interrupt: make normal synchronous interrupts enable MSR[EE] 
if possible
  https://git.kernel.org/powerpc/c/4423eb5ae32ec613af3fceee2fe84234e417ee55
[2/6] powerpc/64s/interrupt: handle MSR EE and RI in interrupt entry wrapper
  https://git.kernel.org/powerpc/c/ff0b0d6e1a7bc202241a9b1e28d1da4b744e0312
[3/6] powerpc/64s/perf: add power_pmu_wants_prompt_pmi to say whether perf 
wants PMIs to be soft-NMI
  https://git.kernel.org/powerpc/c/5a7745b96f43c69f9b4875bcf516a0341acbc3fb
[4/6] powerpc/64s/interrupt: Don't enable MSR[EE] in irq handlers unless perf 
is in use
  https://git.kernel.org/powerpc/c/0faf20a1ad1647c0fc0f5a367c71e5e84deaf899
[5/6] powerpc/64/interrupt: reduce expensive debug tests
  https://git.kernel.org/powerpc/c/ecb1057c0f9a0f3f052294de6cc2eb43ecf7547b
[6/6] powerpc/64s/interrupt: avoid saving CFAR in some asynchronous interrupts
  https://git.kernel.org/powerpc/c/af47d79b041deccc31e0dddc6310a654c13d04b6

cheers


Re: [PATCH] powerpc/pseries/vas: Don't print an error when VAS is unavailable

2021-12-21 Thread Michael Ellerman
On Fri, 26 Nov 2021 15:21:33 +1000, Nicholas Piggin wrote:
> KVM does not support VAS so guests always print a useless error on boot
> 
> vas: HCALL(398) error -2, query_type 0, result buffer 0x57f2000
> 
> Change this to only print the message if the error is not H_FUNCTION.
> 
> 
> [...]

Applied to powerpc/next.

[1/1] powerpc/pseries/vas: Don't print an error when VAS is unavailable
  https://git.kernel.org/powerpc/c/0a006ace634dcaf1bbf9125fb8089a4a50bf33d6

cheers


Re: [PATCH] powerpc/pseries: use slab context cpumask allocation in CPU hotplug init

2021-12-21 Thread Michael Ellerman
On Fri, 5 Nov 2021 23:29:23 +1000, Nicholas Piggin wrote:
> Slab is up at this point, using the bootmem allocator triggers a
> warning. Switch to using the regular cpumask allocator.
> 
> 

Applied to powerpc/next.

[1/1] powerpc/pseries: use slab context cpumask allocation in CPU hotplug init
  https://git.kernel.org/powerpc/c/3b54c71537d7beaaca8be9c57a81045e2b641655

cheers


Re: [PATCH]selftests/powerpc: skip tests for unavailable mitigations.

2021-12-21 Thread Michael Ellerman
On Mon, 13 Dec 2021 22:12:23 +0530, Sachin Sant wrote:
> Mitigation patching test iterates over a set of mitigations irrespective
> of whether a certain mitigation is supported/available in the kernel.
> This causes following messages on a kernel where some mitigations
> are unavailable:
> 
>   Spawned threads enabling/disabling mitigations ...
>   cat: entry_flush: No such file or directory
>   cat: uaccess_flush: No such file or directory
>   Waiting for timeout ...
>   OK
> 
> [...]

Applied to powerpc/next.

[1/1] selftests/powerpc: skip tests for unavailable mitigations.
  https://git.kernel.org/powerpc/c/18678591846d668649fbd4f87b4a4c470818d386

cheers


Re: [PATCH 0/4] perf: Add new macros for mem_hops field

2021-12-21 Thread Michael Ellerman
On Mon, 6 Dec 2021 14:47:45 +0530, Kajol Jain wrote:
> Patchset adds new macros for mem_hops field which can be
> used to represent remote-node, socket and board level details.
> 
> Currently the code had macro for HOPS_0, which corresponds
> to data coming from another core but same node.
> Add new macros for HOPS_1 to HOPS_3 to represent
> remote-node, socket and board level data.
> 
> [...]

Patches 1, 3 and 4 applied to powerpc/next.

[1/4] perf: Add new macros for mem_hops field
  https://git.kernel.org/powerpc/c/cb1c4aba055f928ffae0c868e8dfe08eeab302e7
[3/4] powerpc/perf: Add encodings to represent data based on newer composite 
PERF_MEM_LVLNUM* fields
  https://git.kernel.org/powerpc/c/4a20ee106154ac1765dea97932faad29f0ba57fc
[4/4] powerpc/perf: Add data source encodings for power10 platform
  https://git.kernel.org/powerpc/c/6ed05a8efda56e5be11081954929421de19cce88

cheers


Re: [PATCH] tpm: Fix kexec crash due to access to ops NULL pointer (powerpc)

2021-12-21 Thread Jarkko Sakkinen
On Sat, Dec 11, 2021 at 08:28:04PM -0500, Stefan Berger wrote:
> Fix the following crash on kexec by checking chip->ops for a NULL pointer
> in tpm_chip_start() and returning an error code if this is the case.
> 
> BUG: Kernel NULL pointer dereference on read at 0x0060
> Faulting instruction address: 0xc099a06c
> Oops: Kernel access of bad area, sig: 11 [#1]
> ...
> NIP [c099a06c] tpm_chip_start+0x2c/0x140
>  LR [c099a808] tpm_chip_unregister+0x108/0x170
> Call Trace:
> [c000188bfa00] [c2b03930] fw_devlink_strict+0x0/0x8 (unreliable)
> [c000188bfa30] [c099a808] tpm_chip_unregister+0x108/0x170
> [c000188bfa70] [c09a3874] tpm_ibmvtpm_remove+0x34/0x130
> [c000188bfae0] [c0110dbc] vio_bus_remove+0x5c/0xb0
> [c000188bfb20] [c09bc154] device_shutdown+0x1d4/0x3a8
> [c000188bfbc0] [c0196e14] kernel_restart_prepare+0x54/0x70
> 
> The referenced patch below introduced a function to shut down the VIO bus.
> The bus shutdown now calls tpm_del_char_device (via tpm_chip_unregister)
> after a call to tpm_class_shutdown, which already set chip->ops to NULL.
> The crash occurrs when tpm_del_char_device calls tpm_chip_start with the
> chip->ops NULL pointer.
> 
> Fixes: 39d0099f9439 ("powerpc/pseries: Add shutdown() to vio_driver and 
> vio_bus")
> Signed-off-by: Stefan Berger 
> ---
>  drivers/char/tpm/tpm-chip.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
> index ddaeceb7e109..cca1bde296ee 100644
> --- a/drivers/char/tpm/tpm-chip.c
> +++ b/drivers/char/tpm/tpm-chip.c
> @@ -101,6 +101,9 @@ int tpm_chip_start(struct tpm_chip *chip)
>  {
>   int ret;
>  
> + if (!chip->ops)
> + return -EINVAL;

This triggers to all drivers, not just tpm_ibmvtpm, i.e. the fix has
side-effects.

/Jarkko



Re: [PATCH kernel v4] KVM: PPC: Merge powerpc's debugfs entry content into generic entry

2021-12-21 Thread Cédric Le Goater

-   xive->dentry = debugfs_create_file(name, S_IRUGO, arch_debugfs_dir,
+   xive->dentry = debugfs_create_file("xive", S_IRUGO, 
xive->kvm->debugfs_dentry,
   xive, _debug_fops);


The KVM XIVE device implements a "xics-on-xive" interface, the XICS hcalls
on top of the XIVE native PowerNV (OPAL) interface, and ...


-   pr_debug("%s: created %s\n", __func__, name);
-   kfree(name);
+   pr_debug("%s: created\n", __func__);
   }
   
   static void kvmppc_xive_init(struct kvm_device *dev)

diff --git a/arch/powerpc/kvm/book3s_xive_native.c 
b/arch/powerpc/kvm/book3s_xive_native.c
index 99db9ac49901..e86f5b6c2ae1 100644
--- a/arch/powerpc/kvm/book3s_xive_native.c
+++ b/arch/powerpc/kvm/book3s_xive_native.c
@@ -1259,19 +1259,10 @@ DEFINE_SHOW_ATTRIBUTE(xive_native_debug);
   
   static void xive_native_debugfs_init(struct kvmppc_xive *xive)

   {
-   char *name;
-
-   name = kasprintf(GFP_KERNEL, "kvm-xive-%p", xive);
-   if (!name) {
-   pr_err("%s: no memory for name\n", __func__);
-   return;
-   }
-
-   xive->dentry = debugfs_create_file(name, 0444, arch_debugfs_dir,
+   xive->dentry = debugfs_create_file("xive", 0444, 
xive->kvm->debugfs_dentry,
   xive, _native_debug_fops);


... the KVM XIVE *native* device implements a "xive" interface", the one
using MMIOs for interrupt management.

May be it's worth making the difference in the user interface ?



The content of these xive files is quite different so I kept the same
name as before, I can change if you think it is worth it, should I? 


It's not very important. The contents differ anyhow.


You
are probably the only person who looked at it recently (or ever?) :) Thanks,


and you just did ! :)

Cheers,

C.