* [powerpc:next-test] BUILD SUCCESS c9818c0abfb0c3500684bb2bc75981123d63134d
From: kernel test robot @ 2020-10-20 5:19 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next-test
branch HEAD: c9818c0abfb0c3500684bb2bc75981123d63134d powerpc/64s: Convert some cpu_setup() and cpu_restore() functions to C
elapsed time: 997m
configs tested: 209
configs skipped: 3
The following configs have been built successfully.
More configs may be tested in the coming days.
gcc tested configs:
arm defconfig
arm64 allyesconfig
arm64 defconfig
arm allyesconfig
arm allmodconfig
xtensa xip_kc705_defconfig
mips ar7_defconfig
arm mmp2_defconfig
powerpc ppc64e_defconfig
mips nlm_xlr_defconfig
nds32 alldefconfig
c6x evmc6457_defconfig
powerpc redwood_defconfig
parisc generic-32bit_defconfig
arm am200epdkit_defconfig
mips ip27_defconfig
s390 allyesconfig
arm rpc_defconfig
sh apsh4ad0a_defconfig
arc tb10x_defconfig
arm keystone_defconfig
mips malta_qemu_32r6_defconfig
m68k allmodconfig
mips decstation_64_defconfig
powerpc mpc837x_mds_defconfig
riscv nommu_virt_defconfig
m68k m5475evb_defconfig
powerpc g5_defconfig
csky alldefconfig
powerpc eiger_defconfig
powerpc tqm8540_defconfig
arm neponset_defconfig
powerpc mgcoge_defconfig
arm spitz_defconfig
xtensa audio_kc705_defconfig
sh sh7785lcr_32bit_defconfig
powerpc kmeter1_defconfig
nios2 defconfig
powerpc mpc5200_defconfig
arm pxa3xx_defconfig
sh landisk_defconfig
openrisc or1ksim_defconfig
arm nhk8815_defconfig
powerpc mpc834x_itx_defconfig
arm palmz72_defconfig
powerpc acadia_defconfig
arm collie_defconfig
nios2 3c120_defconfig
mips malta_kvm_defconfig
arm sama5_defconfig
sh migor_defconfig
powerpc makalu_defconfig
powerpc bluestone_defconfig
arm corgi_defconfig
powerpc ep88xc_defconfig
sh sh03_defconfig
sh sh7710voipgw_defconfig
powerpc tqm8xx_defconfig
sh alldefconfig
m68k sun3x_defconfig
powerpc holly_defconfig
mips lemote2f_defconfig
mips ip28_defconfig
sh kfr2r09-romimage_defconfig
arm lpd270_defconfig
sh se7751_defconfig
arm ep93xx_defconfig
arm integrator_defconfig
sh ap325rxa_defconfig
arm moxart_defconfig
powerpc pasemi_defconfig
um i386_defconfig
mips e55_defconfig
powerpc mpc832x_rdb_defconfig
mips cu1000-neo_defconfig
mips bcm47xx_defconfig
mips ip32_defconfig
sh se7780_defconfig
mips tb0287_defconfig
arm hisi_defconfig
arm badge4_defconfig
h8300 alldefconfig
alpha alldefconfig
arm pcm027_defconfig
sh shmin_defconfig
arm sunxi_defconfig
sparc defconfig
arm realview_defconfig
mips tb0226_defconfig
sh shx3_defconfig
arm efm32_defconfig
powerpc amigaone_defconfig
powerpc powernv_defconfig
sh j2_defconfig
mips cavium_octeon_defconfig
arm omap2plus_defconfig
sh ecovec24-romimage_defconfig
arm cns3420vb_defconfig
m68k bvme6000_defconfig
arm s5pv210_defconfig
powerpc ps3_defconfig
sh rsk7269_defconfig
arm mvebu_v7_defconfig
m68k mvme147_defconfig
arc allyesconfig
sh se7724_defconfig
powerpc ppc40x_defconfig
powerpc mpc85xx_cds_defconfig
sh se7750_defconfig
sh kfr2r09_defconfig
powerpc mpc512x_defconfig
powerpc socrates_defconfig
c6x evmc6678_defconfig
powerpc skiroot_defconfig
arm zeus_defconfig
powerpc katmai_defconfig
mips maltaup_xpa_defconfig
arm tegra_defconfig
powerpc mpc866_ads_defconfig
mips nlm_xlp_defconfig
sh rsk7264_defconfig
sh magicpanelr2_defconfig
powerpc mpc8272_ads_defconfig
sh sdk7786_defconfig
arm oxnas_v6_defconfig
arc nsimosci_hs_defconfig
arm vt8500_v6_v7_defconfig
mips workpad_defconfig
mips loongson1b_defconfig
h8300 edosk2674_defconfig
powerpc currituck_defconfig
powerpc iss476-smp_defconfig
arm spear3xx_defconfig
arm colibri_pxa300_defconfig
powerpc ge_imp3a_defconfig
mips allmodconfig
mips mpc30x_defconfig
alpha defconfig
mips tb0219_defconfig
sh urquell_defconfig
nios2 10m50_defconfig
sparc64 defconfig
arm omap1_defconfig
mips vocore2_defconfig
sh edosk7705_defconfig
m68k m5407c3_defconfig
sh se7343_defconfig
arc nsimosci_defconfig
ia64 allmodconfig
ia64 defconfig
ia64 allyesconfig
m68k defconfig
m68k allyesconfig
nds32 allnoconfig
c6x allyesconfig
nds32 defconfig
nios2 allyesconfig
csky defconfig
alpha allyesconfig
xtensa allyesconfig
h8300 allyesconfig
arc defconfig
sh allmodconfig
parisc defconfig
parisc allyesconfig
s390 defconfig
i386 allyesconfig
sparc allyesconfig
i386 defconfig
mips allyesconfig
powerpc allyesconfig
powerpc allmodconfig
powerpc allnoconfig
x86_64 randconfig-a004-20201019
x86_64 randconfig-a002-20201019
x86_64 randconfig-a006-20201019
x86_64 randconfig-a003-20201019
x86_64 randconfig-a005-20201019
x86_64 randconfig-a001-20201019
i386 randconfig-a006-20201019
i386 randconfig-a005-20201019
i386 randconfig-a001-20201019
i386 randconfig-a003-20201019
i386 randconfig-a004-20201019
i386 randconfig-a002-20201019
i386 randconfig-a015-20201019
i386 randconfig-a013-20201019
i386 randconfig-a016-20201019
i386 randconfig-a012-20201019
i386 randconfig-a011-20201019
i386 randconfig-a014-20201019
riscv nommu_k210_defconfig
riscv allyesconfig
riscv allnoconfig
riscv defconfig
riscv rv32_defconfig
riscv allmodconfig
x86_64 rhel
x86_64 allyesconfig
x86_64 rhel-7.6-kselftests
x86_64 defconfig
x86_64 rhel-8.3
x86_64 kexec
clang tested configs:
x86_64 randconfig-a016-20201019
x86_64 randconfig-a015-20201019
x86_64 randconfig-a012-20201019
x86_64 randconfig-a013-20201019
x86_64 randconfig-a011-20201019
x86_64 randconfig-a014-20201019
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply
* [powerpc:fixes] BUILD SUCCESS 358ab796ce78ba271a6ff82834183ffb2cb68c4c
From: kernel test robot @ 2020-10-20 5:13 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git fixes
branch HEAD: 358ab796ce78ba271a6ff82834183ffb2cb68c4c powerpc/powernv/dump: Handle multiple writes to ack attribute
elapsed time: 993m
configs tested: 223
configs skipped: 3
The following configs have been built successfully.
More configs may be tested in the coming days.
gcc tested configs:
arm defconfig
arm64 allyesconfig
arm64 defconfig
arm allyesconfig
arm allmodconfig
xtensa xip_kc705_defconfig
mips ar7_defconfig
arm mmp2_defconfig
powerpc ppc64e_defconfig
mips nlm_xlr_defconfig
nds32 alldefconfig
c6x evmc6457_defconfig
parisc generic-32bit_defconfig
arm am200epdkit_defconfig
powerpc redwood_defconfig
arc haps_hs_smp_defconfig
mips malta_kvm_defconfig
powerpc storcenter_defconfig
sh sh7710voipgw_defconfig
mips ip27_defconfig
s390 allyesconfig
arm rpc_defconfig
sh apsh4ad0a_defconfig
arc tb10x_defconfig
arm keystone_defconfig
mips malta_qemu_32r6_defconfig
m68k allmodconfig
mips decstation_64_defconfig
powerpc mpc837x_mds_defconfig
riscv nommu_virt_defconfig
m68k m5475evb_defconfig
powerpc g5_defconfig
csky alldefconfig
powerpc eiger_defconfig
powerpc tqm8540_defconfig
arm neponset_defconfig
powerpc mgcoge_defconfig
arm spitz_defconfig
xtensa audio_kc705_defconfig
sh sh7785lcr_32bit_defconfig
powerpc kmeter1_defconfig
nios2 defconfig
arm pxa_defconfig
arc vdk_hs38_smp_defconfig
arm pxa255-idp_defconfig
m68k bvme6000_defconfig
arm magician_defconfig
powerpc mpc5200_defconfig
arm pxa3xx_defconfig
sh landisk_defconfig
openrisc or1ksim_defconfig
arm nhk8815_defconfig
powerpc mpc834x_itx_defconfig
arm palmz72_defconfig
powerpc acadia_defconfig
arm collie_defconfig
nios2 3c120_defconfig
arm sama5_defconfig
sh migor_defconfig
powerpc makalu_defconfig
powerpc bluestone_defconfig
arm corgi_defconfig
powerpc ep88xc_defconfig
sh sh03_defconfig
powerpc tqm8xx_defconfig
sh alldefconfig
m68k sun3x_defconfig
powerpc holly_defconfig
mips lemote2f_defconfig
mips ip28_defconfig
sh kfr2r09-romimage_defconfig
arm lpd270_defconfig
sh se7751_defconfig
arm ep93xx_defconfig
arm integrator_defconfig
sh ap325rxa_defconfig
arm moxart_defconfig
powerpc pasemi_defconfig
um i386_defconfig
mips e55_defconfig
powerpc mpc832x_rdb_defconfig
mips cu1000-neo_defconfig
mips bcm47xx_defconfig
mips ip32_defconfig
sh se7780_defconfig
xtensa generic_kc705_defconfig
mips jazz_defconfig
arm multi_v5_defconfig
powerpc cell_defconfig
arm alldefconfig
mips tb0287_defconfig
arm hisi_defconfig
arm badge4_defconfig
h8300 alldefconfig
alpha alldefconfig
arm pcm027_defconfig
sh shmin_defconfig
arm sunxi_defconfig
sparc defconfig
arm realview_defconfig
mips tb0226_defconfig
sh shx3_defconfig
arm efm32_defconfig
powerpc amigaone_defconfig
powerpc powernv_defconfig
sh j2_defconfig
mips cavium_octeon_defconfig
arm omap2plus_defconfig
sh ecovec24-romimage_defconfig
arm cns3420vb_defconfig
arm s5pv210_defconfig
powerpc ps3_defconfig
sh rsk7269_defconfig
arm mvebu_v7_defconfig
m68k mvme147_defconfig
arc allyesconfig
sh se7724_defconfig
powerpc ppc40x_defconfig
powerpc mpc85xx_cds_defconfig
sh se7750_defconfig
sh kfr2r09_defconfig
powerpc mpc512x_defconfig
powerpc socrates_defconfig
c6x evmc6678_defconfig
powerpc skiroot_defconfig
arm zeus_defconfig
powerpc katmai_defconfig
mips maltaup_xpa_defconfig
arm tegra_defconfig
powerpc mpc866_ads_defconfig
mips nlm_xlp_defconfig
sh rsk7264_defconfig
sh magicpanelr2_defconfig
powerpc mpc8272_ads_defconfig
sh sdk7786_defconfig
arm oxnas_v6_defconfig
arc nsimosci_hs_defconfig
arm vt8500_v6_v7_defconfig
mips workpad_defconfig
mips loongson1b_defconfig
h8300 edosk2674_defconfig
powerpc currituck_defconfig
powerpc iss476-smp_defconfig
arm spear3xx_defconfig
arm colibri_pxa300_defconfig
powerpc ge_imp3a_defconfig
mips allmodconfig
mips mpc30x_defconfig
alpha defconfig
mips tb0219_defconfig
sh urquell_defconfig
nios2 10m50_defconfig
sparc64 defconfig
arm omap1_defconfig
mips vocore2_defconfig
sh edosk7705_defconfig
powerpc akebono_defconfig
mips bigsur_defconfig
sh dreamcast_defconfig
m68k m5407c3_defconfig
sh se7343_defconfig
arc nsimosci_defconfig
ia64 allmodconfig
ia64 defconfig
ia64 allyesconfig
m68k defconfig
m68k allyesconfig
nds32 allnoconfig
c6x allyesconfig
nds32 defconfig
nios2 allyesconfig
csky defconfig
alpha allyesconfig
xtensa allyesconfig
h8300 allyesconfig
arc defconfig
sh allmodconfig
parisc defconfig
parisc allyesconfig
s390 defconfig
i386 allyesconfig
sparc allyesconfig
i386 defconfig
mips allyesconfig
powerpc allyesconfig
powerpc allmodconfig
powerpc allnoconfig
x86_64 randconfig-a004-20201019
x86_64 randconfig-a002-20201019
x86_64 randconfig-a006-20201019
x86_64 randconfig-a003-20201019
x86_64 randconfig-a005-20201019
x86_64 randconfig-a001-20201019
i386 randconfig-a006-20201019
i386 randconfig-a005-20201019
i386 randconfig-a001-20201019
i386 randconfig-a003-20201019
i386 randconfig-a004-20201019
i386 randconfig-a002-20201019
i386 randconfig-a015-20201019
i386 randconfig-a013-20201019
i386 randconfig-a016-20201019
i386 randconfig-a012-20201019
i386 randconfig-a011-20201019
i386 randconfig-a014-20201019
riscv nommu_k210_defconfig
riscv allyesconfig
riscv allnoconfig
riscv defconfig
riscv rv32_defconfig
riscv allmodconfig
x86_64 rhel
x86_64 allyesconfig
x86_64 rhel-7.6-kselftests
x86_64 defconfig
x86_64 rhel-8.3
x86_64 kexec
clang tested configs:
x86_64 randconfig-a016-20201019
x86_64 randconfig-a015-20201019
x86_64 randconfig-a012-20201019
x86_64 randconfig-a013-20201019
x86_64 randconfig-a011-20201019
x86_64 randconfig-a014-20201019
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply
* Re: [PATCH 6/8] powerpc/signal64: Replace setup_trampoline() w/ unsafe_setup_trampoline()
From: Christophe Leroy @ 2020-10-20 5:02 UTC (permalink / raw)
To: Christopher M. Riedl, linuxppc-dev; +Cc: Daniel Axtens
In-Reply-To: <C6HDEHRYN1HT.16V34IHMSGUK8@geist>
Le 20/10/2020 à 04:42, Christopher M. Riedl a écrit :
> On Fri Oct 16, 2020 at 10:56 AM CDT, Christophe Leroy wrote:
>>
>>
>> Le 15/10/2020 à 17:01, Christopher M. Riedl a écrit :
>>> From: Daniel Axtens <dja@axtens.net>
>>>
>>> Previously setup_trampoline() performed a costly KUAP switch on every
>>> uaccess operation. These repeated uaccess switches cause a significant
>>> drop in signal handling performance.
>>>
>>> Rewrite setup_trampoline() to assume that a userspace write access
>>> window is open. Replace all uaccess functions with their 'unsafe'
>>> versions to avoid the repeated uaccess switches.
>>>
>>> Signed-off-by: Daniel Axtens <dja@axtens.net>
>>> Signed-off-by: Christopher M. Riedl <cmr@codefail.de>
>>> ---
>>> arch/powerpc/kernel/signal_64.c | 32 +++++++++++++++++++-------------
>>> 1 file changed, 19 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
>>> index bd92064e5576..6d4f7a5c4fbf 100644
>>> --- a/arch/powerpc/kernel/signal_64.c
>>> +++ b/arch/powerpc/kernel/signal_64.c
>>> @@ -600,30 +600,33 @@ static long restore_tm_sigcontexts(struct task_struct *tsk,
>>> /*
>>> * Setup the trampoline code on the stack
>>> */
>>> -static long setup_trampoline(unsigned int syscall, unsigned int __user *tramp)
>>> +#define unsafe_setup_trampoline(syscall, tramp, e) \
>>> + unsafe_op_wrap(__unsafe_setup_trampoline(syscall, tramp), e)
>>> +static long notrace __unsafe_setup_trampoline(unsigned int syscall,
>>> + unsigned int __user *tramp)
>>> {
>>> int i;
>>> - long err = 0;
>>>
>>> /* bctrl # call the handler */
>>> - err |= __put_user(PPC_INST_BCTRL, &tramp[0]);
>>> + unsafe_put_user(PPC_INST_BCTRL, &tramp[0], err);
>>> /* addi r1, r1, __SIGNAL_FRAMESIZE # Pop the dummy stackframe */
>>> - err |= __put_user(PPC_INST_ADDI | __PPC_RT(R1) | __PPC_RA(R1) |
>>> - (__SIGNAL_FRAMESIZE & 0xffff), &tramp[1]);
>>> + unsafe_put_user(PPC_INST_ADDI | __PPC_RT(R1) | __PPC_RA(R1) |
>>> + (__SIGNAL_FRAMESIZE & 0xffff), &tramp[1], err);
>>> /* li r0, __NR_[rt_]sigreturn| */
>>> - err |= __put_user(PPC_INST_ADDI | (syscall & 0xffff), &tramp[2]);
>>> + unsafe_put_user(PPC_INST_ADDI | (syscall & 0xffff), &tramp[2], err);
>>> /* sc */
>>> - err |= __put_user(PPC_INST_SC, &tramp[3]);
>>> + unsafe_put_user(PPC_INST_SC, &tramp[3], err);
>>>
>>> /* Minimal traceback info */
>>> for (i=TRAMP_TRACEBACK; i < TRAMP_SIZE ;i++)
>>> - err |= __put_user(0, &tramp[i]);
>>> + unsafe_put_user(0, &tramp[i], err);
>>>
>>> - if (!err)
>>> - flush_icache_range((unsigned long) &tramp[0],
>>> - (unsigned long) &tramp[TRAMP_SIZE]);
>>> + flush_icache_range((unsigned long)&tramp[0],
>>> + (unsigned long)&tramp[TRAMP_SIZE]);
>>
>> This flush should be done outside the user_write_access block.
>>
>
> Hmm, I suppose that means setup_trampoline() cannot be completely
> "unsafe". I'll see if I can re-arrange the code which calls this
> function to avoid an additional uaccess block instead and push the
> start()/end() into setup_trampoline() directly.
I think we shouldn't put too much effort on setup_trampoline(). Nowadays 99.999% of applications use
the VDSO. Using the trampoline on stack requires to unmap the VDSO and remap the STACK RW. That's
really a corner case, I think it would be good enough to call it outside the main access begin/end
block, and let it do its own access_begin/end.
This corner functionnality can be tested using the sigreturn_vdso selftest in selftests/powerpc/signal/
Christophe
>
>>>
>>> - return err;
>>> + return 0;
>>> +err:
>>> + return 1;
>>> }
>>>
>>> /*
>>> @@ -888,7 +891,10 @@ int handle_rt_signal64(struct ksignal *ksig, sigset_t *set,
>>> if (vdso64_rt_sigtramp && tsk->mm->context.vdso_base) {
>>> regs->nip = tsk->mm->context.vdso_base + vdso64_rt_sigtramp;
>>> } else {
>>> - err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
>>> + if (!user_write_access_begin(frame, sizeof(struct rt_sigframe)))
>>> + return -EFAULT;
>>> + err |= __unsafe_setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
>>> + user_write_access_end();
>>> if (err)
>>> goto badframe;
>>> regs->nip = (unsigned long) &frame->tramp[0];
>>>
>>
>> Christophe
>
^ permalink raw reply
* Re: [PATCH 1/8] powerpc/uaccess: Add unsafe_copy_from_user
From: Christopher M. Riedl @ 2020-10-20 3:00 UTC (permalink / raw)
To: Christophe Leroy, linuxppc-dev
In-Reply-To: <5dc712e9-4d08-b436-3137-d1ac100f2bfb@csgroup.eu>
On Fri Oct 16, 2020 at 10:17 AM CDT, Christophe Leroy wrote:
>
>
> Le 15/10/2020 à 17:01, Christopher M. Riedl a écrit :
> > Implement raw_copy_from_user_allowed() which assumes that userspace read
> > access is open. Use this new function to implement raw_copy_from_user().
> > Finally, wrap the new function to follow the usual "unsafe_" convention
> > of taking a label argument. The new raw_copy_from_user_allowed() calls
> > __copy_tofrom_user() internally, but this is still safe to call in user
> > access blocks formed with user_*_access_begin()/user_*_access_end()
> > since asm functions are not instrumented for tracing.
>
> Would objtool accept that if it was implemented on powerpc ?
>
> __copy_tofrom_user() is a function which is optimised for larger memory
> copies (using dcbz, etc ...)
> Do we need such an optimisation for unsafe_copy_from_user() ? Or can we
> do a simple loop as done for
> unsafe_copy_to_user() instead ?
I tried using a simple loop based on your unsafe_copy_to_user()
implementation. Similar to the copy_{vsx,fpr}_from_user() results there
is a hit to signal handling performance. The results with the loop are
in the 'unsafe-signal64-copy' column:
| | hash | radix |
| -------------------- | ------ | ------ |
| linuxppc/next | 289014 | 158408 |
| unsafe-signal64 | 298506 | 253053 |
| unsafe-signal64-copy | 197029 | 177002 |
Similar to the copy_{vsx,fpr}_from_user() patch I don't fully understand
why this performs so badly yet.
Implementation:
unsafe_copy_from_user(d, s, l, e) \
do { \
u8 *_dst = (u8 *)(d); \
const u8 __user *_src = (u8 __user*)(s); \
size_t _len = (l); \
int _i; \
\
for (_i = 0; _i < (_len & ~(sizeof(long) - 1)); _i += sizeof(long)) \
unsafe_get_user(*(long*)(_dst + _i), (long __user *)(_src + _i), e); \
if (IS_ENABLED(CONFIG_PPC64) && (_len & 4)) { \
unsafe_get_user(*(u32*)(_dst + _i), (u32 __user *)(_src + _i), e); \
_i += 4; \
} \
if (_len & 2) { \
unsafe_get_user(*(u16*)(_dst + _i), (u16 __user *)(_src + _i), e); \
_i += 2; \
} \
if (_len & 1) \
unsafe_get_user(*(u8*)(_dst + _i), (u8 __user *)(_src + _i), e); \
} while (0)
>
> Christophe
>
> >
> > Signed-off-by: Christopher M. Riedl <cmr@codefail.de>
> > ---
> > arch/powerpc/include/asm/uaccess.h | 28 +++++++++++++++++++---------
> > 1 file changed, 19 insertions(+), 9 deletions(-)
> >
> > diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
> > index 26781b044932..66940b4eb692 100644
> > --- a/arch/powerpc/include/asm/uaccess.h
> > +++ b/arch/powerpc/include/asm/uaccess.h
> > @@ -418,38 +418,45 @@ raw_copy_in_user(void __user *to, const void __user *from, unsigned long n)
> > }
> > #endif /* __powerpc64__ */
> >
> > -static inline unsigned long raw_copy_from_user(void *to,
> > - const void __user *from, unsigned long n)
> > +static inline unsigned long
> > +raw_copy_from_user_allowed(void *to, const void __user *from, unsigned long n)
> > {
> > - unsigned long ret;
> > if (__builtin_constant_p(n) && (n <= 8)) {
> > - ret = 1;
> > + unsigned long ret = 1;
> >
> > switch (n) {
> > case 1:
> > barrier_nospec();
> > - __get_user_size(*(u8 *)to, from, 1, ret);
> > + __get_user_size_allowed(*(u8 *)to, from, 1, ret);
> > break;
> > case 2:
> > barrier_nospec();
> > - __get_user_size(*(u16 *)to, from, 2, ret);
> > + __get_user_size_allowed(*(u16 *)to, from, 2, ret);
> > break;
> > case 4:
> > barrier_nospec();
> > - __get_user_size(*(u32 *)to, from, 4, ret);
> > + __get_user_size_allowed(*(u32 *)to, from, 4, ret);
> > break;
> > case 8:
> > barrier_nospec();
> > - __get_user_size(*(u64 *)to, from, 8, ret);
> > + __get_user_size_allowed(*(u64 *)to, from, 8, ret);
> > break;
> > }
> > if (ret == 0)
> > return 0;
> > }
> >
> > + return __copy_tofrom_user((__force void __user *)to, from, n);
> > +}
> > +
> > +static inline unsigned long
> > +raw_copy_from_user(void *to, const void __user *from, unsigned long n)
> > +{
> > + unsigned long ret;
> > +
> > barrier_nospec();
> > allow_read_from_user(from, n);
> > - ret = __copy_tofrom_user((__force void __user *)to, from, n);
> > + ret = raw_copy_from_user_allowed(to, from, n);
> > prevent_read_from_user(from, n);
> > return ret;
> > }
> > @@ -571,6 +578,9 @@ user_write_access_begin(const void __user *ptr, size_t len)
> > #define unsafe_get_user(x, p, e) unsafe_op_wrap(__get_user_allowed(x, p), e)
> > #define unsafe_put_user(x, p, e) __put_user_goto(x, p, e)
> >
> > +#define unsafe_copy_from_user(d, s, l, e) \
> > + unsafe_op_wrap(raw_copy_from_user_allowed(d, s, l), e)
> > +
> > #define unsafe_copy_to_user(d, s, l, e) \
> > do { \
> > u8 __user *_dst = (u8 __user *)(d); \
> >
^ permalink raw reply
* Re: [PATCH 8/8] powerpc/signal64: Rewrite rt_sigreturn() to minimise uaccess switches
From: Christopher M. Riedl @ 2020-10-20 2:45 UTC (permalink / raw)
To: Christophe Leroy, linuxppc-dev
In-Reply-To: <bdc30b81-65bd-1cc0-b31a-61300e8c010a@csgroup.eu>
On Fri Oct 16, 2020 at 11:07 AM CDT, Christophe Leroy wrote:
>
>
> Le 15/10/2020 à 17:01, Christopher M. Riedl a écrit :
> > From: Daniel Axtens <dja@axtens.net>
> >
> > Add uaccess blocks and use the 'unsafe' versions of functions doing user
> > access where possible to reduce the number of times uaccess has to be
> > opened/closed.
> >
> > Signed-off-by: Daniel Axtens <dja@axtens.net>
> > Signed-off-by: Christopher M. Riedl <cmr@codefail.de>
> > ---
> > arch/powerpc/kernel/signal_64.c | 23 +++++++++++++++--------
> > 1 file changed, 15 insertions(+), 8 deletions(-)
> >
> > diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
> > index 3b97e3681a8f..0f4ff7a5bfc1 100644
> > --- a/arch/powerpc/kernel/signal_64.c
> > +++ b/arch/powerpc/kernel/signal_64.c
> > @@ -779,18 +779,22 @@ SYSCALL_DEFINE0(rt_sigreturn)
> > */
> > regs->msr &= ~MSR_TS_MASK;
> >
> > - if (__get_user(msr, &uc->uc_mcontext.gp_regs[PT_MSR]))
> > + if (!user_read_access_begin(uc, sizeof(*uc)))
> > goto badframe;
> > +
> > + unsafe_get_user(msr, &uc->uc_mcontext.gp_regs[PT_MSR], badframe_block);
> > +
> > if (MSR_TM_ACTIVE(msr)) {
> > /* We recheckpoint on return. */
> > struct ucontext __user *uc_transact;
> >
> > /* Trying to start TM on non TM system */
> > if (!cpu_has_feature(CPU_FTR_TM))
> > - goto badframe;
> > + goto badframe_block;
> > +
> > + unsafe_get_user(uc_transact, &uc->uc_link, badframe_block);
> > + user_read_access_end();
>
> user_access_end() only in the if branch ?
>
> >
> > - if (__get_user(uc_transact, &uc->uc_link))
> > - goto badframe;
> > if (restore_tm_sigcontexts(current, &uc->uc_mcontext,
> > &uc_transact->uc_mcontext))
> > goto badframe;
> > @@ -810,12 +814,13 @@ SYSCALL_DEFINE0(rt_sigreturn)
> > * causing a TM bad thing.
> > */
> > current->thread.regs->msr &= ~MSR_TS_MASK;
> > +
> > +#ifndef CONFIG_PPC_TRANSACTIONAL_MEM
> > if (!user_read_access_begin(uc, sizeof(*uc)))
>
> The matching user_read_access_end() is not in the same #ifndef ? That's
> dirty and hard to follow.
> Can you re-organise the code to avoid all those nesting ?
Yes, thanks for pointing this out. I really wanted to avoid changing too
much of the logic inside these functions. But I suppose I ended up
creating a mess - I will fix this in the next spin.
>
> > - return -EFAULT;
> > - if (__unsafe_restore_sigcontext(current, NULL, 1, &uc->uc_mcontext)) {
> > - user_read_access_end();
> > goto badframe;
> > - }
> > +#endif
> > + unsafe_restore_sigcontext(current, NULL, 1, &uc->uc_mcontext,
> > + badframe_block);
> > user_read_access_end();
> > }
> >
> > @@ -825,6 +830,8 @@ SYSCALL_DEFINE0(rt_sigreturn)
> > set_thread_flag(TIF_RESTOREALL);
> > return 0;
> >
> > +badframe_block:
> > + user_read_access_end();
> > badframe:
> > signal_fault(current, regs, "rt_sigreturn", uc);
> >
> >
>
> Christophe
^ permalink raw reply
* Re: [PATCH 7/8] powerpc/signal64: Rewrite handle_rt_signal64() to minimise uaccess switches
From: Christopher M. Riedl @ 2020-10-20 2:44 UTC (permalink / raw)
To: Christophe Leroy, linuxppc-dev; +Cc: Daniel Axtens
In-Reply-To: <1cedcf43-4594-5db1-d248-7c06a572aecc@csgroup.eu>
On Fri Oct 16, 2020 at 11:00 AM CDT, Christophe Leroy wrote:
>
>
> Le 15/10/2020 à 17:01, Christopher M. Riedl a écrit :
> > From: Daniel Axtens <dja@axtens.net>
> >
> > Add uaccess blocks and use the 'unsafe' versions of functions doing user
> > access where possible to reduce the number of times uaccess has to be
> > opened/closed.
> >
> > There is no 'unsafe' version of copy_siginfo_to_user, so move it
> > slightly to allow for a "longer" uaccess block.
> >
> > Signed-off-by: Daniel Axtens <dja@axtens.net>
> > Signed-off-by: Christopher M. Riedl <cmr@codefail.de>
> > ---
> > arch/powerpc/kernel/signal_64.c | 54 ++++++++++++++++-----------------
> > 1 file changed, 27 insertions(+), 27 deletions(-)
> >
> > diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
> > index 6d4f7a5c4fbf..3b97e3681a8f 100644
> > --- a/arch/powerpc/kernel/signal_64.c
> > +++ b/arch/powerpc/kernel/signal_64.c
> > @@ -843,46 +843,42 @@ int handle_rt_signal64(struct ksignal *ksig, sigset_t *set,
> > /* Save the thread's msr before get_tm_stackpointer() changes it */
> > unsigned long msr = regs->msr;
> > #endif
> > -
> > frame = get_sigframe(ksig, tsk, sizeof(*frame), 0);
> > - if (!access_ok(frame, sizeof(*frame)))
> > + if (!user_write_access_begin(frame, sizeof(*frame)))
> > goto badframe;
> >
> > - err |= __put_user(&frame->info, &frame->pinfo);
> > - err |= __put_user(&frame->uc, &frame->puc);
> > - err |= copy_siginfo_to_user(&frame->info, &ksig->info);
> > - if (err)
> > - goto badframe;
> > + unsafe_put_user(&frame->info, &frame->pinfo, badframe_block);
> > + unsafe_put_user(&frame->uc, &frame->puc, badframe_block);
> >
> > /* Create the ucontext. */
> > - err |= __put_user(0, &frame->uc.uc_flags);
> > - err |= __save_altstack(&frame->uc.uc_stack, regs->gpr[1]);
> > + unsafe_put_user(0, &frame->uc.uc_flags, badframe_block);
> > + unsafe_save_altstack(&frame->uc.uc_stack, regs->gpr[1], badframe_block);
> > +
> > #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
> > if (MSR_TM_ACTIVE(msr)) {
> > /* The ucontext_t passed to userland points to the second
> > * ucontext_t (for transactional state) with its uc_link ptr.
> > */
> > - err |= __put_user(&frame->uc_transact, &frame->uc.uc_link);
> > + unsafe_put_user(&frame->uc_transact, &frame->uc.uc_link, badframe_block);
> > + user_write_access_end();
>
> Whaou. Doing this inside an #ifdef sequence is dirty.
> Can you reorganise code to avoid that and to avoid nesting #ifdef/#endif
> and the if/else as I did in
> signal32 ?
Hopefully yes - next spin!
>
> > err |= setup_tm_sigcontexts(&frame->uc.uc_mcontext,
> > &frame->uc_transact.uc_mcontext,
> > tsk, ksig->sig, NULL,
> > (unsigned long)ksig->ka.sa.sa_handler,
> > msr);
> > + if (!user_write_access_begin(frame, sizeof(struct rt_sigframe)))
> > + goto badframe;
> > +
> > } else
> > #endif
> > {
> > - err |= __put_user(0, &frame->uc.uc_link);
> > -
> > - if (!user_write_access_begin(frame, sizeof(struct rt_sigframe)))
> > - return -EFAULT;
> > - err |= __unsafe_setup_sigcontext(&frame->uc.uc_mcontext, tsk,
> > - ksig->sig, NULL,
> > - (unsigned long)ksig->ka.sa.sa_handler, 1);
> > - user_write_access_end();
> > + unsafe_put_user(0, &frame->uc.uc_link, badframe_block);
> > + unsafe_setup_sigcontext(&frame->uc.uc_mcontext, tsk, ksig->sig,
> > + NULL, (unsigned long)ksig->ka.sa.sa_handler,
> > + 1, badframe_block);
> > }
> > - err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
> > - if (err)
> > - goto badframe;
> > +
> > + unsafe_copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set), badframe_block);
> >
> > /* Make sure signal handler doesn't get spurious FP exceptions */
> > tsk->thread.fp_state.fpscr = 0;
> > @@ -891,15 +887,17 @@ int handle_rt_signal64(struct ksignal *ksig, sigset_t *set,
> > if (vdso64_rt_sigtramp && tsk->mm->context.vdso_base) {
> > regs->nip = tsk->mm->context.vdso_base + vdso64_rt_sigtramp;
> > } else {
> > - if (!user_write_access_begin(frame, sizeof(struct rt_sigframe)))
> > - return -EFAULT;
> > - err |= __unsafe_setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
> > - user_write_access_end();
> > - if (err)
> > - goto badframe;
> > + unsafe_setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0],
> > + badframe_block);
> > regs->nip = (unsigned long) &frame->tramp[0];
> > }
> >
> > + user_write_access_end();
> > +
> > + /* Save the siginfo outside of the unsafe block. */
> > + if (copy_siginfo_to_user(&frame->info, &ksig->info))
> > + goto badframe;
> > +
> > /* Allocate a dummy caller frame for the signal handler. */
> > newsp = ((unsigned long)frame) - __SIGNAL_FRAMESIZE;
> > err |= put_user(regs->gpr[1], (unsigned long __user *)newsp);
> > @@ -939,6 +937,8 @@ int handle_rt_signal64(struct ksignal *ksig, sigset_t *set,
> >
> > return 0;
> >
> > +badframe_block:
> > + user_write_access_end();
> > badframe:
> > signal_fault(current, regs, "handle_rt_signal64", frame);
> >
> >
>
>
> Christophe
^ permalink raw reply
* Re: [PATCH 6/8] powerpc/signal64: Replace setup_trampoline() w/ unsafe_setup_trampoline()
From: Christopher M. Riedl @ 2020-10-20 2:42 UTC (permalink / raw)
To: Christophe Leroy, linuxppc-dev; +Cc: Daniel Axtens
In-Reply-To: <c447ee06-a581-1f5f-42c7-814a1f570fe0@csgroup.eu>
On Fri Oct 16, 2020 at 10:56 AM CDT, Christophe Leroy wrote:
>
>
> Le 15/10/2020 à 17:01, Christopher M. Riedl a écrit :
> > From: Daniel Axtens <dja@axtens.net>
> >
> > Previously setup_trampoline() performed a costly KUAP switch on every
> > uaccess operation. These repeated uaccess switches cause a significant
> > drop in signal handling performance.
> >
> > Rewrite setup_trampoline() to assume that a userspace write access
> > window is open. Replace all uaccess functions with their 'unsafe'
> > versions to avoid the repeated uaccess switches.
> >
> > Signed-off-by: Daniel Axtens <dja@axtens.net>
> > Signed-off-by: Christopher M. Riedl <cmr@codefail.de>
> > ---
> > arch/powerpc/kernel/signal_64.c | 32 +++++++++++++++++++-------------
> > 1 file changed, 19 insertions(+), 13 deletions(-)
> >
> > diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
> > index bd92064e5576..6d4f7a5c4fbf 100644
> > --- a/arch/powerpc/kernel/signal_64.c
> > +++ b/arch/powerpc/kernel/signal_64.c
> > @@ -600,30 +600,33 @@ static long restore_tm_sigcontexts(struct task_struct *tsk,
> > /*
> > * Setup the trampoline code on the stack
> > */
> > -static long setup_trampoline(unsigned int syscall, unsigned int __user *tramp)
> > +#define unsafe_setup_trampoline(syscall, tramp, e) \
> > + unsafe_op_wrap(__unsafe_setup_trampoline(syscall, tramp), e)
> > +static long notrace __unsafe_setup_trampoline(unsigned int syscall,
> > + unsigned int __user *tramp)
> > {
> > int i;
> > - long err = 0;
> >
> > /* bctrl # call the handler */
> > - err |= __put_user(PPC_INST_BCTRL, &tramp[0]);
> > + unsafe_put_user(PPC_INST_BCTRL, &tramp[0], err);
> > /* addi r1, r1, __SIGNAL_FRAMESIZE # Pop the dummy stackframe */
> > - err |= __put_user(PPC_INST_ADDI | __PPC_RT(R1) | __PPC_RA(R1) |
> > - (__SIGNAL_FRAMESIZE & 0xffff), &tramp[1]);
> > + unsafe_put_user(PPC_INST_ADDI | __PPC_RT(R1) | __PPC_RA(R1) |
> > + (__SIGNAL_FRAMESIZE & 0xffff), &tramp[1], err);
> > /* li r0, __NR_[rt_]sigreturn| */
> > - err |= __put_user(PPC_INST_ADDI | (syscall & 0xffff), &tramp[2]);
> > + unsafe_put_user(PPC_INST_ADDI | (syscall & 0xffff), &tramp[2], err);
> > /* sc */
> > - err |= __put_user(PPC_INST_SC, &tramp[3]);
> > + unsafe_put_user(PPC_INST_SC, &tramp[3], err);
> >
> > /* Minimal traceback info */
> > for (i=TRAMP_TRACEBACK; i < TRAMP_SIZE ;i++)
> > - err |= __put_user(0, &tramp[i]);
> > + unsafe_put_user(0, &tramp[i], err);
> >
> > - if (!err)
> > - flush_icache_range((unsigned long) &tramp[0],
> > - (unsigned long) &tramp[TRAMP_SIZE]);
> > + flush_icache_range((unsigned long)&tramp[0],
> > + (unsigned long)&tramp[TRAMP_SIZE]);
>
> This flush should be done outside the user_write_access block.
>
Hmm, I suppose that means setup_trampoline() cannot be completely
"unsafe". I'll see if I can re-arrange the code which calls this
function to avoid an additional uaccess block instead and push the
start()/end() into setup_trampoline() directly.
> >
> > - return err;
> > + return 0;
> > +err:
> > + return 1;
> > }
> >
> > /*
> > @@ -888,7 +891,10 @@ int handle_rt_signal64(struct ksignal *ksig, sigset_t *set,
> > if (vdso64_rt_sigtramp && tsk->mm->context.vdso_base) {
> > regs->nip = tsk->mm->context.vdso_base + vdso64_rt_sigtramp;
> > } else {
> > - err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
> > + if (!user_write_access_begin(frame, sizeof(struct rt_sigframe)))
> > + return -EFAULT;
> > + err |= __unsafe_setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
> > + user_write_access_end();
> > if (err)
> > goto badframe;
> > regs->nip = (unsigned long) &frame->tramp[0];
> >
>
> Christophe
^ permalink raw reply
* Re: [PATCH 2/8] powerpc/signal: Add unsafe_copy_{vsx,fpr}_from_user()
From: Christopher M. Riedl @ 2020-10-20 2:01 UTC (permalink / raw)
To: Christophe Leroy, linuxppc-dev
In-Reply-To: <5e15b794-e33e-a871-3296-df1154b7d408@csgroup.eu>
On Fri Oct 16, 2020 at 10:48 AM CDT, Christophe Leroy wrote:
>
>
> Le 15/10/2020 à 17:01, Christopher M. Riedl a écrit :
> > Reuse the "safe" implementation from signal.c except for calling
> > unsafe_copy_from_user() to copy into a local buffer. Unlike the
> > unsafe_copy_{vsx,fpr}_to_user() functions the "copy from" functions
> > cannot use unsafe_get_user() directly to bypass the local buffer since
> > doing so significantly reduces signal handling performance.
>
> Why can't the functions use unsafe_get_user(), why does it significantly
> reduces signal handling
> performance ? How much significant ? I would expect that not going
> through an intermediate memory
> area would be more efficient
>
Here is a comparison, 'unsafe-signal64-regs' avoids the intermediate buffer:
| | hash | radix |
| -------------------- | ------ | ------ |
| linuxppc/next | 289014 | 158408 |
| unsafe-signal64 | 298506 | 253053 |
| unsafe-signal64-regs | 254898 | 220831 |
I have not figured out the 'why' yet. As you mentioned in your series,
technically calling __copy_tofrom_user() is overkill for these
operations. The only obvious difference between unsafe_put_user() and
unsafe_get_user() is that we don't have asm-goto for the 'get' variant.
Instead we wrap with unsafe_op_wrap() which inserts a conditional and
then goto to the label.
Implemenations:
#define unsafe_copy_fpr_from_user(task, from, label) do { \
struct task_struct *__t = task; \
u64 __user *buf = (u64 __user *)from; \
int i; \
\
for (i = 0; i < ELF_NFPREG - 1; i++) \
unsafe_get_user(__t->thread.TS_FPR(i), &buf[i], label); \
unsafe_get_user(__t->thread.fp_state.fpscr, &buf[i], label); \
} while (0)
#define unsafe_copy_vsx_from_user(task, from, label) do { \
struct task_struct *__t = task; \
u64 __user *buf = (u64 __user *)from; \
int i; \
\
for (i = 0; i < ELF_NVSRHALFREG ; i++) \
unsafe_get_user(__t->thread.fp_state.fpr[i][TS_VSRLOWOFFSET], \
&buf[i], label); \
} while (0)
> Christophe
>
>
> >
> > Signed-off-by: Christopher M. Riedl <cmr@codefail.de>
> > ---
> > arch/powerpc/kernel/signal.h | 33 +++++++++++++++++++++++++++++++++
> > 1 file changed, 33 insertions(+)
> >
> > diff --git a/arch/powerpc/kernel/signal.h b/arch/powerpc/kernel/signal.h
> > index 2559a681536e..e9aaeac0da37 100644
> > --- a/arch/powerpc/kernel/signal.h
> > +++ b/arch/powerpc/kernel/signal.h
> > @@ -53,6 +53,33 @@ unsigned long copy_ckfpr_from_user(struct task_struct *task, void __user *from);
> > &buf[i], label);\
> > } while (0)
> >
> > +#define unsafe_copy_fpr_from_user(task, from, label) do { \
> > + struct task_struct *__t = task; \
> > + u64 __user *__f = (u64 __user *)from; \
> > + u64 buf[ELF_NFPREG]; \
> > + int i; \
> > + \
> > + unsafe_copy_from_user(buf, __f, ELF_NFPREG * sizeof(double), \
> > + label); \
> > + for (i = 0; i < ELF_NFPREG - 1; i++) \
> > + __t->thread.TS_FPR(i) = buf[i]; \
> > + __t->thread.fp_state.fpscr = buf[i]; \
> > +} while (0)
> > +
> > +#define unsafe_copy_vsx_from_user(task, from, label) do { \
> > + struct task_struct *__t = task; \
> > + u64 __user *__f = (u64 __user *)from; \
> > + u64 buf[ELF_NVSRHALFREG]; \
> > + int i; \
> > + \
> > + unsafe_copy_from_user(buf, __f, \
> > + ELF_NVSRHALFREG * sizeof(double), \
> > + label); \
> > + for (i = 0; i < ELF_NVSRHALFREG ; i++) \
> > + __t->thread.fp_state.fpr[i][TS_VSRLOWOFFSET] = buf[i]; \
> > +} while (0)
> > +
> > +
> > #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
> > #define unsafe_copy_ckfpr_to_user(to, task, label) do { \
> > struct task_struct *__t = task; \
> > @@ -80,6 +107,10 @@ unsigned long copy_ckfpr_from_user(struct task_struct *task, void __user *from);
> > unsafe_copy_to_user(to, (task)->thread.fp_state.fpr, \
> > ELF_NFPREG * sizeof(double), label)
> >
> > +#define unsafe_copy_fpr_from_user(task, from, label) \
> > + unsafe_copy_from_user((task)->thread.fp_state.fpr, from \
> > + ELF_NFPREG * sizeof(double), label)
> > +
> > static inline unsigned long
> > copy_fpr_to_user(void __user *to, struct task_struct *task)
> > {
> > @@ -115,6 +146,8 @@ copy_ckfpr_from_user(struct task_struct *task, void __user *from)
> > #else
> > #define unsafe_copy_fpr_to_user(to, task, label) do { } while (0)
> >
> > +#define unsafe_copy_fpr_from_user(task, from, label) do { } while (0)
> > +
> > static inline unsigned long
> > copy_fpr_to_user(void __user *to, struct task_struct *task)
> > {
> >
^ permalink raw reply
* [PATCH v3] soc: fsl: dpio: Get the cpumask through cpumask_of(cpu)
From: Yi Wang @ 2020-10-20 2:18 UTC (permalink / raw)
To: Roy.Pledge, leoyang.li
Cc: wang.yi59, jiang.xuexin, Hao Si, linux-kernel, Lin Chen,
xue.zhihong, linuxppc-dev, linux-arm-kernel
[-- Attachment #1.1: Type: text/plain, Size: 3858 bytes --]
From: Hao Si <si.hao@zte.com.cn>
The local variable 'cpumask_t mask' is in the stack memory, and its address
is assigned to 'desc->affinity' in 'irq_set_affinity_hint()'.
But the memory area where this variable is located is at risk of being
modified.
During LTP testing, the following error was generated:
Unable to handle kernel paging request at virtual address ffff000012e9b790
Mem abort info:
ESR = 0x96000007
Exception class = DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
Data abort info:
ISV = 0, ISS = 0x00000007
CM = 0, WnR = 0
swapper pgtable: 4k pages, 48-bit VAs, pgdp = 0000000075ac5e07
[ffff000012e9b790] pgd=00000027dbffe003, pud=00000027dbffd003,
pmd=00000027b6d61003, pte=0000000000000000
Internal error: Oops: 96000007 [#1] PREEMPT SMP
Modules linked in: xt_conntrack
Process read_all (pid: 20171, stack limit = 0x0000000044ea4095)
CPU: 14 PID: 20171 Comm: read_all Tainted: G B W
Hardware name: NXP Layerscape LX2160ARDB (DT)
pstate: 80000085 (Nzcv daIf -PAN -UAO)
pc : irq_affinity_hint_proc_show+0x54/0xb0
lr : irq_affinity_hint_proc_show+0x4c/0xb0
sp : ffff00001138bc10
x29: ffff00001138bc10 x28: 0000ffffd131d1e0
x27: 00000000007000c0 x26: ffff8025b9480dc0
x25: ffff8025b9480da8 x24: 00000000000003ff
x23: ffff8027334f8300 x22: ffff80272e97d000
x21: ffff80272e97d0b0 x20: ffff8025b9480d80
x19: ffff000009a49000 x18: 0000000000000000
x17: 0000000000000000 x16: 0000000000000000
x15: 0000000000000000 x14: 0000000000000000
x13: 0000000000000000 x12: 0000000000000040
x11: 0000000000000000 x10: ffff802735b79b88
x9 : 0000000000000000 x8 : 0000000000000000
x7 : ffff000009a49848 x6 : 0000000000000003
x5 : 0000000000000000 x4 : ffff000008157d6c
x3 : ffff00001138bc10 x2 : ffff000012e9b790
x1 : 0000000000000000 x0 : 0000000000000000
Call trace:
irq_affinity_hint_proc_show+0x54/0xb0
seq_read+0x1b0/0x440
proc_reg_read+0x80/0xd8
__vfs_read+0x60/0x178
vfs_read+0x94/0x150
ksys_read+0x74/0xf0
__arm64_sys_read+0x24/0x30
el0_svc_common.constprop.0+0xd8/0x1a0
el0_svc_handler+0x34/0x88
el0_svc+0x10/0x14
Code: f9001bbf 943e0732 f94066c2 b4000062 (f9400041)
---[ end trace b495bdcb0b3b732b ]---
Kernel panic - not syncing: Fatal exception
SMP: stopping secondary CPUs
SMP: failed to stop secondary CPUs 0,2-4,6,8,11,13-15
Kernel Offset: disabled
CPU features: 0x0,21006008
Memory Limit: none
---[ end Kernel panic - not syncing: Fatal exception ]---
Fix it by using 'cpumask_of(cpu)' to get the cpumask.
Signed-off-by: Hao Si <si.hao@zte.com.cn>
Signed-off-by: Lin Chen <chen.lin5@zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
---
v3: Use cpumask_of(cpu) to get the pre-defined cpumask in the static
cpu_bit_bitmap array.
v2: Place 'cpumask_t mask' in the driver's private data and while at it,
rename it to cpu_mask.
drivers/soc/fsl/dpio/dpio-driver.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/soc/fsl/dpio/dpio-driver.c b/drivers/soc/fsl/dpio/dpio-driver.c
index 7b642c3..7f397b4 100644
--- a/drivers/soc/fsl/dpio/dpio-driver.c
+++ b/drivers/soc/fsl/dpio/dpio-driver.c
@@ -95,7 +95,6 @@ static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu)
{
int error;
struct fsl_mc_device_irq *irq;
- cpumask_t mask;
irq = dpio_dev->irqs[0];
error = devm_request_irq(&dpio_dev->dev,
@@ -112,9 +111,7 @@ static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu)
}
/* set the affinity hint */
- cpumask_clear(&mask);
- cpumask_set_cpu(cpu, &mask);
- if (irq_set_affinity_hint(irq->msi_desc->irq, &mask))
+ if (irq_set_affinity_hint(irq->msi_desc->irq, cpumask_of(cpu)))
dev_err(&dpio_dev->dev,
"irq_set_affinity failed irq %d cpu %d\n",
irq->msi_desc->irq, cpu);
--
2.15.2
^ permalink raw reply related
* Re: [PATCH 3/8] powerpc: Mark functions called inside uaccess blocks w/ 'notrace'
From: Christopher M. Riedl @ 2020-10-20 1:59 UTC (permalink / raw)
To: Christophe Leroy, linuxppc-dev
In-Reply-To: <30d9ccba-20a5-37b4-1629-d0f9e0da4c84@csgroup.eu>
On Fri Oct 16, 2020 at 4:02 AM CDT, Christophe Leroy wrote:
>
>
> Le 15/10/2020 à 17:01, Christopher M. Riedl a écrit :
> > Functions called between user_*_access_begin() and user_*_access_end()
> > should be either inlined or marked 'notrace' to prevent leaving
> > userspace access exposed. Mark any such functions relevant to signal
> > handling so that subsequent patches can call them inside uaccess blocks.
>
> Is it enough to mark it "notrace" ? I see that when I activate KASAN,
> there are still KASAN calls in
> those functions.
>
Maybe not enough after all :(
> In my series for 32 bits, I re-ordered stuff in order to do all those
> calls before doing the
> _access_begin(), can't you do the same on PPC64 ? (See
> https://patchwork.ozlabs.org/project/linuxppc-dev/patch/f6eac65781b4a57220477c8864bca2b57f29a5d5.1597770847.git.christophe.leroy@csgroup.eu/)
>
Yes, I will give this another shot in the next spin.
> Christophe
>
> >
> > Signed-off-by: Christopher M. Riedl <cmr@codefail.de>
> > ---
> > arch/powerpc/kernel/process.c | 20 ++++++++++----------
> > arch/powerpc/mm/mem.c | 4 ++--
> > 2 files changed, 12 insertions(+), 12 deletions(-)
> >
> > diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
> > index ba2c987b8403..bf5d9654bd2c 100644
> > --- a/arch/powerpc/kernel/process.c
> > +++ b/arch/powerpc/kernel/process.c
> > @@ -84,7 +84,7 @@ extern unsigned long _get_SP(void);
> > */
> > bool tm_suspend_disabled __ro_after_init = false;
> >
> > -static void check_if_tm_restore_required(struct task_struct *tsk)
> > +static void notrace check_if_tm_restore_required(struct task_struct *tsk)
> > {
> > /*
> > * If we are saving the current thread's registers, and the
> > @@ -151,7 +151,7 @@ void notrace __msr_check_and_clear(unsigned long bits)
> > EXPORT_SYMBOL(__msr_check_and_clear);
> >
> > #ifdef CONFIG_PPC_FPU
> > -static void __giveup_fpu(struct task_struct *tsk)
> > +static void notrace __giveup_fpu(struct task_struct *tsk)
> > {
> > unsigned long msr;
> >
> > @@ -163,7 +163,7 @@ static void __giveup_fpu(struct task_struct *tsk)
> > tsk->thread.regs->msr = msr;
> > }
> >
> > -void giveup_fpu(struct task_struct *tsk)
> > +void notrace giveup_fpu(struct task_struct *tsk)
> > {
> > check_if_tm_restore_required(tsk);
> >
> > @@ -177,7 +177,7 @@ EXPORT_SYMBOL(giveup_fpu);
> > * Make sure the floating-point register state in the
> > * the thread_struct is up to date for task tsk.
> > */
> > -void flush_fp_to_thread(struct task_struct *tsk)
> > +void notrace flush_fp_to_thread(struct task_struct *tsk)
> > {
> > if (tsk->thread.regs) {
> > /*
> > @@ -234,7 +234,7 @@ static inline void __giveup_fpu(struct task_struct *tsk) { }
> > #endif /* CONFIG_PPC_FPU */
> >
> > #ifdef CONFIG_ALTIVEC
> > -static void __giveup_altivec(struct task_struct *tsk)
> > +static void notrace __giveup_altivec(struct task_struct *tsk)
> > {
> > unsigned long msr;
> >
> > @@ -246,7 +246,7 @@ static void __giveup_altivec(struct task_struct *tsk)
> > tsk->thread.regs->msr = msr;
> > }
> >
> > -void giveup_altivec(struct task_struct *tsk)
> > +void notrace giveup_altivec(struct task_struct *tsk)
> > {
> > check_if_tm_restore_required(tsk);
> >
> > @@ -285,7 +285,7 @@ EXPORT_SYMBOL(enable_kernel_altivec);
> > * Make sure the VMX/Altivec register state in the
> > * the thread_struct is up to date for task tsk.
> > */
> > -void flush_altivec_to_thread(struct task_struct *tsk)
> > +void notrace flush_altivec_to_thread(struct task_struct *tsk)
> > {
> > if (tsk->thread.regs) {
> > preempt_disable();
> > @@ -300,7 +300,7 @@ EXPORT_SYMBOL_GPL(flush_altivec_to_thread);
> > #endif /* CONFIG_ALTIVEC */
> >
> > #ifdef CONFIG_VSX
> > -static void __giveup_vsx(struct task_struct *tsk)
> > +static void notrace __giveup_vsx(struct task_struct *tsk)
> > {
> > unsigned long msr = tsk->thread.regs->msr;
> >
> > @@ -317,7 +317,7 @@ static void __giveup_vsx(struct task_struct *tsk)
> > __giveup_altivec(tsk);
> > }
> >
> > -static void giveup_vsx(struct task_struct *tsk)
> > +static void notrace giveup_vsx(struct task_struct *tsk)
> > {
> > check_if_tm_restore_required(tsk);
> >
> > @@ -352,7 +352,7 @@ void enable_kernel_vsx(void)
> > }
> > EXPORT_SYMBOL(enable_kernel_vsx);
> >
> > -void flush_vsx_to_thread(struct task_struct *tsk)
> > +void notrace flush_vsx_to_thread(struct task_struct *tsk)
> > {
> > if (tsk->thread.regs) {
> > preempt_disable();
> > diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
> > index ddc32cc1b6cf..da2345a2abc6 100644
> > --- a/arch/powerpc/mm/mem.c
> > +++ b/arch/powerpc/mm/mem.c
> > @@ -378,7 +378,7 @@ static inline bool flush_coherent_icache(unsigned long addr)
> > * @start: the start address
> > * @stop: the stop address (exclusive)
> > */
> > -static void invalidate_icache_range(unsigned long start, unsigned long stop)
> > +static void notrace invalidate_icache_range(unsigned long start, unsigned long stop)
> > {
> > unsigned long shift = l1_icache_shift();
> > unsigned long bytes = l1_icache_bytes();
> > @@ -402,7 +402,7 @@ static void invalidate_icache_range(unsigned long start, unsigned long stop)
> > * @start: the start address
> > * @stop: the stop address (exclusive)
> > */
> > -void flush_icache_range(unsigned long start, unsigned long stop)
> > +void notrace flush_icache_range(unsigned long start, unsigned long stop)
> > {
> > if (flush_coherent_icache(start))
> > return;
> >
^ permalink raw reply
* Re: [PATCH] powerpc/boot: move the .got section to after the .dynamic section
From: Fāng-ruì Sòng @ 2020-10-19 23:56 UTC (permalink / raw)
To: Bill Wendling; +Cc: Alan Modra, linuxppc-dev, Paul Mackerras
In-Reply-To: <20201017000151.150788-1-morbo@google.com>
On Fri, Oct 16, 2020 at 5:01 PM Bill Wendling <morbo@google.com> wrote:
>
> Both .dynamic and .got are RELRO sections and should be placed together,
> and LLD emits an error:
>
> ld.lld: error: section: .got is not contiguous with other relro sections
>
> Place them together to avoid this.
>
> Cc: Fangrui Song <maskray@google.com>
> Cc: Alan Modra <amodra@gmail.com>
> Signed-off-by: Bill Wendling <morbo@google.com>
> ---
> arch/powerpc/boot/zImage.lds.S | 21 +++++++++++----------
> 1 file changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/arch/powerpc/boot/zImage.lds.S b/arch/powerpc/boot/zImage.lds.S
> index a21f3a76e06f..d6f072865627 100644
> --- a/arch/powerpc/boot/zImage.lds.S
> +++ b/arch/powerpc/boot/zImage.lds.S
> @@ -34,6 +34,17 @@ SECTIONS
> __dynamic_start = .;
> *(.dynamic)
> }
> +
> +#ifdef CONFIG_PPC64_BOOT_WRAPPER
> + . = ALIGN(256);
> + .got :
> + {
> + __toc_start = .;
> + *(.got)
> + *(.toc)
> + }
> +#endif
> +
> .hash : { *(.hash) }
> .interp : { *(.interp) }
> .rela.dyn :
> @@ -76,16 +87,6 @@ SECTIONS
> _esm_blob_end = .;
> }
>
> -#ifdef CONFIG_PPC64_BOOT_WRAPPER
> - . = ALIGN(256);
> - .got :
> - {
> - __toc_start = .;
> - *(.got)
> - *(.toc)
> - }
> -#endif
The kernel does not require this but normally all read-only sections
precede SHF_WRITE sections.
.dynamic and .got have the SHF_WRITE flag and should be placed here.
Ideally, the order is: R RX RW(RELRO) RW(non-RELRO) (LLD order)
For comparison:
GNU ld -z separate-code order: R RX R RW(RELRO) RW(non-RELRO) (GNU
ld>=2.31 enables -z separate-code by default for Linux x86)
GNU ld -z noseparate-code order: RX RW(RELRO) RW(non-RELRO)
(AFAIK The only reason .dynamic is writable is due to DT_DEBUG (whose
purpose is questionable nowadays). mips .dynamic is read-only. LLD has
an option -z rodynamic to make .dynamic readonly)
> . = ALIGN(4096);
> .bss :
> {
> --
> 2.29.0.rc1.297.gfa9743e501-goog
>
^ permalink raw reply
* Re: [PATCH 1/2] ASoC: dt-bindings: fsl_spdif: Add new compatible string for i.MX8QM
From: Rob Herring @ 2020-10-19 21:14 UTC (permalink / raw)
To: Shengjiu Wang
Cc: devicetree, alsa-devel, timur, Xiubo.Lee, festevam, broonie,
lgirdwood, tiwai, nicoleotsuka, robh+dt, perex, linuxppc-dev,
linux-kernel
In-Reply-To: <1602739728-4433-1-git-send-email-shengjiu.wang@nxp.com>
On Thu, 15 Oct 2020 13:28:47 +0800, Shengjiu Wang wrote:
> Add new compatible string "fsl,imx8qm-spdif" for supporting spdif
> module on i.MX8QM.
>
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> ---
> Documentation/devicetree/bindings/sound/fsl,spdif.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
Acked-by: Rob Herring <robh@kernel.org>
^ permalink raw reply
* Re: [PATCH 3/3] powerpc: Fix pre-update addressing in inline assembly
From: Segher Boessenkool @ 2020-10-19 20:24 UTC (permalink / raw)
To: Christophe Leroy; +Cc: Paul Mackerras, linuxppc-dev, linux-kernel
In-Reply-To: <fbcdb173cc42da62f00285dfef8c2f7d4960b5c7.1603109522.git.christophe.leroy@csgroup.eu>
On Mon, Oct 19, 2020 at 12:12:48PM +0000, Christophe Leroy wrote:
> In several places, inline assembly uses the "%Un" modifier
> to enable the use of instruction with pre-update addressing,
Calling this "pre-update" is misleading: the register is not updated
before the address is generated (or the memory access done!), and the
addressing is exactly the same as the "non-u" insn would use. It is
called an "update form" instruction, because (at the same time as doing
the memory access, logically anyway) it writes back the address used to
the base register.
> but the associated "<>" constraint is missing.
But that is just fine. Pointless, sure, but not a bug.
> Use UPD_CONSTR macro everywhere %Un modifier is used.
Eww. My poor stomach.
Have you verified that update form is *correct* in all these, and that
we even *want* this there?
Segher
^ permalink raw reply
* Re: [PATCH 2/3] powerpc: Fix incorrect stw{, ux, u, x} instructions in __set_pte_at
From: Segher Boessenkool @ 2020-10-19 20:14 UTC (permalink / raw)
To: Christophe Leroy; +Cc: Paul Mackerras, linuxppc-dev, linux-kernel
In-Reply-To: <1b26e1b8544ea46ad0da102d1367694cd23c222c.1603109522.git.christophe.leroy@csgroup.eu>
On Mon, Oct 19, 2020 at 12:12:47PM +0000, Christophe Leroy wrote:
> From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>
> The placeholder for instruction selection should use the second
> argument's operand, which is %1, not %0. This could generate incorrect
> assembly code if the instruction selection for argument %0 ever differs
> from argument %1.
"Instruction selection" isn't correct here... "if the memory addressing
of operand 0 is a different form from that of operand 1", perhaps?
The patch looks fine of course :-)
Acked-by: Segher Boessenkool <segher@kernel.crashing.org>
Segher
^ permalink raw reply
* Re: [PATCH 1/3] powerpc/uaccess: Don't use "m<>" constraint with GCC 4.9
From: Segher Boessenkool @ 2020-10-19 20:10 UTC (permalink / raw)
To: Christophe Leroy; +Cc: Paul Mackerras, linuxppc-dev, linux-kernel
In-Reply-To: <5ffcb064f695d5285bf1faab91bffa3f9245fc26.1603109522.git.christophe.leroy@csgroup.eu>
On Mon, Oct 19, 2020 at 12:12:46PM +0000, Christophe Leroy wrote:
> GCC 4.9 sometimes fails to build with "m<>" constraint in
> inline assembly.
> --- a/arch/powerpc/include/asm/uaccess.h
> +++ b/arch/powerpc/include/asm/uaccess.h
> @@ -223,7 +223,7 @@ do { \
> "1: " op "%U1%X1 %0,%1 # put_user\n" \
> EX_TABLE(1b, %l2) \
> : \
> - : "r" (x), "m<>" (*addr) \
> + : "r" (x), "m"UPD_CONSTR (*addr) \
> : \
> : label)
>
> @@ -294,7 +294,7 @@ extern long __get_user_bad(void);
> ".previous\n" \
> EX_TABLE(1b, 3b) \
> : "=r" (err), "=r" (x) \
> - : "m<>" (*addr), "i" (-EFAULT), "0" (err))
> + : "m"UPD_CONSTR (*addr), "i" (-EFAULT), "0" (err))
Wow, ugly! But these are the only two places that use this, so
Acked-by: Segher Boessenkool <segher@kernel.crashing.org>
I just hope that we get rid of 4.9 before we would use this a lot more ;-)
Segher
^ permalink raw reply
* Re: [PATCH 3/3] powerpc: Fix pre-update addressing in inline assembly
From: Christophe Leroy @ 2020-10-19 18:23 UTC (permalink / raw)
To: kernel test robot, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman
Cc: clang-built-linux, linuxppc-dev, kbuild-all, linux-kernel
In-Reply-To: <202010192300.35IC9AK7-lkp@intel.com>
Le 19/10/2020 à 17:35, kernel test robot a écrit :
> Hi Christophe,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on powerpc/next]
> [also build test ERROR on linus/master next-20201016]
> [cannot apply to kvm-ppc/kvm-ppc-next mpe/next v5.9]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-uaccess-Don-t-use-m-constraint-with-GCC-4-9/20201019-201504
> base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
> config: powerpc64-randconfig-r012-20201019 (attached as .config)
> compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 094e9f4779eb9b5c6a49014f2f80b8cbb833572f)
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # install powerpc64 cross compiling tool for clang build
> # apt-get install binutils-powerpc64-linux-gnu
> # https://github.com/0day-ci/linux/commit/d57fd8d270993414b8c0414d7be4b03cc3de1856
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review Christophe-Leroy/powerpc-uaccess-Don-t-use-m-constraint-with-GCC-4-9/20201019-201504
> git checkout d57fd8d270993414b8c0414d7be4b03cc3de1856
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
>
> In file included from arch/powerpc/kernel/asm-offsets.c:14:
> In file included from include/linux/compat.h:14:
> In file included from include/linux/sem.h:5:
> In file included from include/uapi/linux/sem.h:5:
> In file included from include/linux/ipc.h:5:
> In file included from include/linux/spinlock.h:51:
> In file included from include/linux/preempt.h:78:
> In file included from ./arch/powerpc/include/generated/asm/preempt.h:1:
> In file included from include/asm-generic/preempt.h:5:
> In file included from include/linux/thread_info.h:21:
> In file included from arch/powerpc/include/asm/current.h:13:
> In file included from arch/powerpc/include/asm/paca.h:31:
> In file included from arch/powerpc/include/asm/atomic.h:13:
> In file included from arch/powerpc/include/asm/ppc_asm.h:9:
> In file included from arch/powerpc/include/asm/processor.h:40:
>>> arch/powerpc/include/asm/ptrace.h:288:20: error: use of undeclared identifier 'THREAD_SIZE'
> return ((addr & ~(THREAD_SIZE - 1)) ==
> ^
> arch/powerpc/include/asm/ptrace.h:289:35: error: use of undeclared identifier 'THREAD_SIZE'
> (kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1)));
Most likely a circular inclusion problem.
I'll have to put it in a header that doesn't include pile of other stuff. The least bad candidate
seems to be asm-const.h
Christophe
> ^
> In file included from arch/powerpc/kernel/asm-offsets.c:21:
> include/linux/mman.h:137:9: warning: division by zero is undefined [-Wdivision-by-zero]
> _calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED ) |
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/mman.h:115:21: note: expanded from macro '_calc_vm_trans'
> : ((x) & (bit1)) / ((bit1) / (bit2))))
> ^ ~~~~~~~~~~~~~~~~~
> include/linux/mman.h:138:9: warning: division by zero is undefined [-Wdivision-by-zero]
> _calc_vm_trans(flags, MAP_SYNC, VM_SYNC );
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/mman.h:115:21: note: expanded from macro '_calc_vm_trans'
> : ((x) & (bit1)) / ((bit1) / (bit2))))
> ^ ~~~~~~~~~~~~~~~~~
> 2 warnings and 2 errors generated.
> make[2]: *** [scripts/Makefile.build:117: arch/powerpc/kernel/asm-offsets.s] Error 1
> make[2]: Target '__build' not remade because of errors.
> make[1]: *** [Makefile:1202: prepare0] Error 2
> make[1]: Target 'prepare' not remade because of errors.
> make: *** [Makefile:185: __sub-make] Error 2
> make: Target 'prepare' not remade because of errors.
>
> vim +/THREAD_SIZE +288 arch/powerpc/include/asm/ptrace.h
>
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 275
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 276 /**
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 277 * regs_within_kernel_stack() - check the address in the stack
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 278 * @regs: pt_regs which contains kernel stack pointer.
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 279 * @addr: address which is checked.
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 280 *
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 281 * regs_within_kernel_stack() checks @addr is within the kernel stack page(s).
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 282 * If @addr is within the kernel stack, it returns true. If not, returns false.
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 283 */
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 284
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 285 static inline bool regs_within_kernel_stack(struct pt_regs *regs,
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 286 unsigned long addr)
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 287 {
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 @288 return ((addr & ~(THREAD_SIZE - 1)) ==
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 289 (kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1)));
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 290 }
> 359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 291
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
>
^ permalink raw reply
* Re: [PATCH] asm-generic: Force inlining of get_order() to work around gcc10 poor decision
From: Segher Boessenkool @ 2020-10-19 17:55 UTC (permalink / raw)
To: Christophe Leroy
Cc: linux-arch, Arnd Bergmann, Linux Kernel Mailing List,
Masahiro Yamada, Joel Stanley, Andrew Morton, linuxppc-dev
In-Reply-To: <188e00e1-ae41-693e-1d05-f8d87e7ee696@csgroup.eu>
On Mon, Oct 19, 2020 at 10:54:40AM +0200, Christophe Leroy wrote:
> Le 19/10/2020 à 10:32, Segher Boessenkool a écrit :
> >The kernel should just use __always_inline if that is what it *wants*;
> >that is true here most likely. GCC could perhaps improve its heuristics
> >so that it no longer thinks these functions are often too big for
> >inlining (they *are* pretty big, but not after basic optimisations with
> >constant integer arguments).
>
> Yes I guess __always_inline is to be added on functions like this defined
> in headers for exactly that, and that's the purpose of this patch.
>
> However I find it odd that get_order() is outlined by GCC even in some
> object files that don't use it at all, for instance in fs/pipe.o
It is (arguably) too big too always inline if you do not consider that
__builtin_constant_p will remove half of the function one way or
another. Not sure if that is what happens here, but now we have a PR
(thanks!) and we will find out.
Segher
^ permalink raw reply
* Re: [PATCH 11/20] dt-bindings: usb: dwc3: Add synopsys,dwc3 compatible string
From: Serge Semin @ 2020-10-19 16:22 UTC (permalink / raw)
To: Rob Herring
Cc: Neil Armstrong, linux-kernel, Pavel Parkhomenko, Kevin Hilman,
Krzysztof Kozlowski, Andy Gross, linux-snps-arc, devicetree,
Mathias Nyman, Lad Prabhakar, Alexey Malahov, Bjorn Andersson,
linux-arm-kernel, Roger Quadros, Felipe Balbi, Greg Kroah-Hartman,
Yoshihiro Shimoda, linux-usb, linux-mips, Serge Semin,
Manu Gautam, linuxppc-dev
In-Reply-To: <20201016185340.GA1734346@bogus>
On Fri, Oct 16, 2020 at 01:53:40PM -0500, Rob Herring wrote:
> On Thu, Oct 15, 2020 at 12:35:54AM +0300, Serge Semin wrote:
> > On Wed, Oct 14, 2020 at 10:18:18PM +0200, Krzysztof Kozlowski wrote:
> > > On Wed, Oct 14, 2020 at 01:13:53PM +0300, Serge Semin wrote:
> > > > The DWC USB3 driver and some DTS files like Exynos 5250, Keystone k2e, etc
> > > > expects the DWC USB3 DT node to have the compatible string with the
> > > > "synopsys" vendor prefix. Let's add the corresponding compatible string to
> > > > the controller DT schema, but mark it as deprecated seeing the Synopsys,
> > > > Inc. is presented with just "snps" vendor prefix.
> > >
> >
> > > Instead of adding deprecated schema just correct the DTSes to use snps.
> > > The "synopsys" is not even in vendor prefixes.
> >
> > Yeah, it's not, but the driver and some dts'es use it this way. I am not sure
> > that the solution suggested by you is much better than mine. So let's hear the
> > Rob'es opinion out in this matter. @Rob, what do you think?
>
> I think we should fix the dts files given there's only 5.
Ok. I'll do that.
-Sergey
>
> Rob
^ permalink raw reply
* Re: [PATCH 1/4] KVM: PPC: Book3S HV: Make struct kernel_param_ops definition const
From: Paolo Bonzini @ 2020-10-19 16:01 UTC (permalink / raw)
To: Joe Perches, Paul Mackerras
Cc: kvm-ppc, Athira Rajeev, Tianjia Zhang, Ram Pai, linux-kernel,
Sean Christopherson, Bharata B Rao, Davidlohr Bueso,
Nicholas Piggin, Laurent Dufour, linuxppc-dev
In-Reply-To: <d130e88dd4c82a12d979da747cc0365c72c3ba15.1601770305.git.joe@perches.com>
On 04/10/20 02:18, Joe Perches wrote:
> This should be const, so make it so.
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> arch/powerpc/kvm/book3s_hv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 4ba06a2a306c..2b215852cdc9 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -111,7 +111,7 @@ module_param(one_vm_per_core, bool, S_IRUGO | S_IWUSR);
> MODULE_PARM_DESC(one_vm_per_core, "Only run vCPUs from the same VM on a core (requires indep_threads_mode=N)");
>
> #ifdef CONFIG_KVM_XICS
> -static struct kernel_param_ops module_param_ops = {
> +static const struct kernel_param_ops module_param_ops = {
> .set = param_set_int,
> .get = param_get_int,
> };
>
Queued, thanks.
Paolo
^ permalink raw reply
* Re: [PATCH] drm/amd/display: Fix missing declaration of enable_kernel_vsx()
From: Christophe Leroy @ 2020-10-19 15:40 UTC (permalink / raw)
To: kernel test robot, Harry Wentland, Leo Li, Alex Deucher,
Christian König, David Airlie, Daniel Vetter
Cc: linuxppc-dev, amd-gfx, kbuild-all, linux-kernel, dri-devel
In-Reply-To: <202010192006.INRpAG6V-lkp@intel.com>
Le 19/10/2020 à 14:52, kernel test robot a écrit :
> Hi Christophe,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on linus/master]
> [also build test ERROR on v5.9 next-20201016]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/drm-amd-display-Fix-missing-declaration-of-enable_kernel_vsx/20201019-174155
> base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 7cf726a59435301046250c42131554d9ccc566b8
> config: arc-randconfig-r013-20201019 (attached as .config)
> compiler: arceb-elf-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://github.com/0day-ci/linux/commit/33f0ea8bebc4132d957107f55776d8f1e02df928
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review Christophe-Leroy/drm-amd-display-Fix-missing-declaration-of-enable_kernel_vsx/20201019-174155
> git checkout 33f0ea8bebc4132d957107f55776d8f1e02df928
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
>
> In file included from drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services_types.h:29,
> from drivers/gpu/drm/amd/amdgpu/../include/dm_pp_interface.h:26,
> from drivers/gpu/drm/amd/amdgpu/amdgpu.h:67,
> from drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c:40:
>>> drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h:36:10: fatal error: asm/switch-to.h: No such file or directory
> 36 | #include <asm/switch-to.h>
> | ^~~~~~~~~~~~~~~~~
> compilation terminated.
Argh ! Yes that's a typo. And anyway it fixes nothing because <asm/switch_to.h> is already included.
The issue is that enable_kernel_vsx() is only declared when CONFIG_VSX is set. The simplest solution
will probably be to declare it at all time.
Christophe
>
> vim +36 drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h
>
> 34
> 35 #include <asm/byteorder.h>
> > 36 #include <asm/switch-to.h>
> 37
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
>
^ permalink raw reply
* Re: [PATCH 3/3] powerpc: Fix pre-update addressing in inline assembly
From: kernel test robot @ 2020-10-19 15:35 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman
Cc: clang-built-linux, linuxppc-dev, kbuild-all, linux-kernel
In-Reply-To: <fbcdb173cc42da62f00285dfef8c2f7d4960b5c7.1603109522.git.christophe.leroy@csgroup.eu>
[-- Attachment #1: Type: text/plain, Size: 5813 bytes --]
Hi Christophe,
I love your patch! Yet something to improve:
[auto build test ERROR on powerpc/next]
[also build test ERROR on linus/master next-20201016]
[cannot apply to kvm-ppc/kvm-ppc-next mpe/next v5.9]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-uaccess-Don-t-use-m-constraint-with-GCC-4-9/20201019-201504
base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc64-randconfig-r012-20201019 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 094e9f4779eb9b5c6a49014f2f80b8cbb833572f)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install powerpc64 cross compiling tool for clang build
# apt-get install binutils-powerpc64-linux-gnu
# https://github.com/0day-ci/linux/commit/d57fd8d270993414b8c0414d7be4b03cc3de1856
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christophe-Leroy/powerpc-uaccess-Don-t-use-m-constraint-with-GCC-4-9/20201019-201504
git checkout d57fd8d270993414b8c0414d7be4b03cc3de1856
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from arch/powerpc/kernel/asm-offsets.c:14:
In file included from include/linux/compat.h:14:
In file included from include/linux/sem.h:5:
In file included from include/uapi/linux/sem.h:5:
In file included from include/linux/ipc.h:5:
In file included from include/linux/spinlock.h:51:
In file included from include/linux/preempt.h:78:
In file included from ./arch/powerpc/include/generated/asm/preempt.h:1:
In file included from include/asm-generic/preempt.h:5:
In file included from include/linux/thread_info.h:21:
In file included from arch/powerpc/include/asm/current.h:13:
In file included from arch/powerpc/include/asm/paca.h:31:
In file included from arch/powerpc/include/asm/atomic.h:13:
In file included from arch/powerpc/include/asm/ppc_asm.h:9:
In file included from arch/powerpc/include/asm/processor.h:40:
>> arch/powerpc/include/asm/ptrace.h:288:20: error: use of undeclared identifier 'THREAD_SIZE'
return ((addr & ~(THREAD_SIZE - 1)) ==
^
arch/powerpc/include/asm/ptrace.h:289:35: error: use of undeclared identifier 'THREAD_SIZE'
(kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1)));
^
In file included from arch/powerpc/kernel/asm-offsets.c:21:
include/linux/mman.h:137:9: warning: division by zero is undefined [-Wdivision-by-zero]
_calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED ) |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:115:21: note: expanded from macro '_calc_vm_trans'
: ((x) & (bit1)) / ((bit1) / (bit2))))
^ ~~~~~~~~~~~~~~~~~
include/linux/mman.h:138:9: warning: division by zero is undefined [-Wdivision-by-zero]
_calc_vm_trans(flags, MAP_SYNC, VM_SYNC );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:115:21: note: expanded from macro '_calc_vm_trans'
: ((x) & (bit1)) / ((bit1) / (bit2))))
^ ~~~~~~~~~~~~~~~~~
2 warnings and 2 errors generated.
make[2]: *** [scripts/Makefile.build:117: arch/powerpc/kernel/asm-offsets.s] Error 1
make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1202: prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:185: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
vim +/THREAD_SIZE +288 arch/powerpc/include/asm/ptrace.h
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 275
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 276 /**
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 277 * regs_within_kernel_stack() - check the address in the stack
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 278 * @regs: pt_regs which contains kernel stack pointer.
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 279 * @addr: address which is checked.
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 280 *
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 281 * regs_within_kernel_stack() checks @addr is within the kernel stack page(s).
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 282 * If @addr is within the kernel stack, it returns true. If not, returns false.
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 283 */
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 284
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 285 static inline bool regs_within_kernel_stack(struct pt_regs *regs,
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 286 unsigned long addr)
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 287 {
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 @288 return ((addr & ~(THREAD_SIZE - 1)) ==
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 289 (kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1)));
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 290 }
359e4284a3f37ab Mahesh Salgaonkar 2010-04-07 291
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 26981 bytes --]
^ permalink raw reply
* Re: [PATCH] drm/amd/display: Fix missing declaration of enable_kernel_vsx()
From: kernel test robot @ 2020-10-19 14:06 UTC (permalink / raw)
To: Christophe Leroy, Harry Wentland, Leo Li, Alex Deucher,
Christian König, David Airlie, Daniel Vetter
Cc: kbuild-all, linux-kernel, amd-gfx, clang-built-linux, dri-devel,
linuxppc-dev
In-Reply-To: <1a5d454cf080a00c04ae488ef6e98d5fcc933550.1603100151.git.christophe.leroy@csgroup.eu>
[-- Attachment #1: Type: text/plain, Size: 2488 bytes --]
Hi Christophe,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.9 next-20201016]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/drm-amd-display-Fix-missing-declaration-of-enable_kernel_vsx/20201019-174155
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 7cf726a59435301046250c42131554d9ccc566b8
config: x86_64-randconfig-a015-20201019 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 094e9f4779eb9b5c6a49014f2f80b8cbb833572f)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/33f0ea8bebc4132d957107f55776d8f1e02df928
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christophe-Leroy/drm-amd-display-Fix-missing-declaration-of-enable_kernel_vsx/20201019-174155
git checkout 33f0ea8bebc4132d957107f55776d8f1e02df928
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/tonga_baco.c:23:
In file included from drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgpu.h:67:
In file included from drivers/gpu/drm/amd/amdgpu/../include/dm_pp_interface.h:26:
In file included from drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services_types.h:29:
>> drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h:36:10: fatal error: 'asm/switch-to.h' file not found
#include <asm/switch-to.h>
^~~~~~~~~~~~~~~~~
1 error generated.
vim +36 drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h
34
35 #include <asm/byteorder.h>
> 36 #include <asm/switch-to.h>
37
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32643 bytes --]
^ permalink raw reply
* Re: [PATCH v4 2/2] lkdtm/powerpc: Add SLB multihit test
From: Michal Suchánek @ 2020-10-19 13:15 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, Ganesh Goudar, keescook, npiggin, mahesh
In-Reply-To: <87362azdjm.fsf@mpe.ellerman.id.au>
On Mon, Oct 19, 2020 at 09:59:57PM +1100, Michael Ellerman wrote:
> Hi Ganesh,
>
> Some comments below ...
>
> Ganesh Goudar <ganeshgr@linux.ibm.com> writes:
> > To check machine check handling, add support to inject slb
> > multihit errors.
> >
> > Cc: Kees Cook <keescook@chromium.org>
> > Reviewed-by: Michal Suchánek <msuchanek@suse.de>
> > Co-developed-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
> > Signed-off-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
> > Signed-off-by: Ganesh Goudar <ganeshgr@linux.ibm.com>
> > ---
> > drivers/misc/lkdtm/Makefile | 1 +
> > drivers/misc/lkdtm/core.c | 3 +
> > drivers/misc/lkdtm/lkdtm.h | 3 +
> > drivers/misc/lkdtm/powerpc.c | 156 ++++++++++++++++++++++++
> > tools/testing/selftests/lkdtm/tests.txt | 1 +
> > 5 files changed, 164 insertions(+)
> > create mode 100644 drivers/misc/lkdtm/powerpc.c
> >
> ..
> > diff --git a/drivers/misc/lkdtm/powerpc.c b/drivers/misc/lkdtm/powerpc.c
> > new file mode 100644
> > index 000000000000..f388b53dccba
> > --- /dev/null
> > +++ b/drivers/misc/lkdtm/powerpc.c
> > @@ -0,0 +1,156 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +
> > +#include "lkdtm.h"
> > +#include <linux/slab.h>
> > +#include <linux/vmalloc.h>
>
> Usual style is to include the linux headers first and then the local header.
>
> > +
> > +/* Gets index for new slb entry */
> > +static inline unsigned long get_slb_index(void)
> > +{
> > + unsigned long index;
> > +
> > + index = get_paca()->stab_rr;
> > +
> > + /*
> > + * simple round-robin replacement of slb starting at SLB_NUM_BOLTED.
> > + */
> > + if (index < (mmu_slb_size - 1))
> > + index++;
> > + else
> > + index = SLB_NUM_BOLTED;
> > + get_paca()->stab_rr = index;
> > + return index;
> > +}
>
> I'm not sure we need that really?
>
> We can just always insert at SLB_MUM_BOLTED and SLB_NUM_BOLTED + 1.
>
> Or we could allocate from the top down using mmu_slb_size - 1, and
> mmu_slb_size - 2.
>
>
> > +#define slb_esid_mask(ssize) \
> > + (((ssize) == MMU_SEGSIZE_256M) ? ESID_MASK : ESID_MASK_1T)
> > +
> > +/* Form the operand for slbmte */
> > +static inline unsigned long mk_esid_data(unsigned long ea, int ssize,
> > + unsigned long slot)
> > +{
> > + return (ea & slb_esid_mask(ssize)) | SLB_ESID_V | slot;
> > +}
> > +
> > +#define slb_vsid_shift(ssize) \
> > + ((ssize) == MMU_SEGSIZE_256M ? SLB_VSID_SHIFT : SLB_VSID_SHIFT_1T)
> > +
> > +/* Form the operand for slbmte */
> > +static inline unsigned long mk_vsid_data(unsigned long ea, int ssize,
> > + unsigned long flags)
> > +{
> > + return (get_kernel_vsid(ea, ssize) << slb_vsid_shift(ssize)) | flags |
> > + ((unsigned long)ssize << SLB_VSID_SSIZE_SHIFT);
> > +}
>
> I realise it's not much code, but I'd rather those were in a header,
> rather than copied from slb.c. That way they can never skew vs the
> versions in slb.c
>
> Best place I think would be arch/powerpc/include/asm/book3s/64/mmu-hash.h
>
>
> > +
> > +/* Inserts new slb entry */
>
> It inserts two.
>
> > +static void insert_slb_entry(char *p, int ssize)
> > +{
> > + unsigned long flags, entry;
> > +
> > + flags = SLB_VSID_KERNEL | mmu_psize_defs[MMU_PAGE_64K].sllp;
>
> That won't work if the kernel is built for 4K pages. Or at least it
> won't work the way we want it to.
>
> You should use mmu_linear_psize.
>
> But for vmalloc you should use mmu_vmalloc_psize, so it will need to be
> a parameter.
>
> > + preempt_disable();
> > +
> > + entry = get_slb_index();
> > + asm volatile("slbmte %0,%1" :
> > + : "r" (mk_vsid_data((unsigned long)p, ssize, flags)),
> > + "r" (mk_esid_data((unsigned long)p, ssize, entry))
> > + : "memory");
> > +
> > + entry = get_slb_index();
> > + asm volatile("slbmte %0,%1" :
> > + : "r" (mk_vsid_data((unsigned long)p, ssize, flags)),
> > + "r" (mk_esid_data((unsigned long)p, ssize, entry))
> > + : "memory");
> > + preempt_enable();
> > + /*
> > + * This triggers exception, If handled correctly we must recover
> > + * from this error.
> > + */
> > + p[0] = '!';
>
> That doesn't belong in here, it should be done by the caller.
>
> That would also mean p could be unsigned long in here, so you wouldn't
> have to cast it four times.
>
> > +}
> > +
> > +/* Inject slb multihit on vmalloc-ed address i.e 0xD00... */
> > +static void inject_vmalloc_slb_multihit(void)
> > +{
> > + char *p;
> > +
> > + p = vmalloc(2048);
>
> vmalloc() allocates whole pages, so it may as well be vmalloc(PAGE_SIZE).
>
> > + if (!p)
> > + return;
>
> That's unlikely, but it should be an error that's propagated up to the caller.
>
> > +
> > + insert_slb_entry(p, MMU_SEGSIZE_1T);
> > + vfree(p);
> > +}
> > +
> > +/* Inject slb multihit on kmalloc-ed address i.e 0xC00... */
> > +static void inject_kmalloc_slb_multihit(void)
> > +{
> > + char *p;
> > +
> > + p = kmalloc(2048, GFP_KERNEL);
> > + if (!p)
> > + return;
> > +
> > + insert_slb_entry(p, MMU_SEGSIZE_1T);
> > + kfree(p);
> > +}
> > +
> > +/*
> > + * Few initial SLB entries are bolted. Add a test to inject
> > + * multihit in bolted entry 0.
> > + */
> > +static void insert_dup_slb_entry_0(void)
> > +{
> > + unsigned long test_address = 0xC000000000000000;
>
> Should use PAGE_OFFSET;
>
> > + volatile unsigned long *test_ptr;
>
> Does it need to be a volatile?
> The slbmte should act as a compiler barrier (it has a memory clobber)
> and a CPU barrier as well?
>
> > + unsigned long entry, i = 0;
> > + unsigned long esid, vsid;
>
> Please group your variables:
>
> unsigned long esid, vsid, entry, test_address, i;
> volatile unsigned long *test_ptr;
>
> And then initialise them as appropriate.
>
> > + test_ptr = (unsigned long *)test_address;
> > + preempt_disable();
> > +
> > + asm volatile("slbmfee %0,%1" : "=r" (esid) : "r" (i));
> > + asm volatile("slbmfev %0,%1" : "=r" (vsid) : "r" (i));
>
> Why do we need to read them out of the SLB rather than just computing
> the values?
It ensures that the entry is perfect duplicate without copying even more
code from other parts of the kernel, doesn't it?
Especially when inserting only one duplicate as suggested later it
ensures that the test really does what it should.
>
> > + entry = get_slb_index();
> > +
> > + /* for i !=0 we would need to mask out the old entry number */
>
> Or you could just compute esid and then it wouldn't be an issue.
>
> > + asm volatile("slbmte %0,%1" :
> > + : "r" (vsid),
> > + "r" (esid | entry)
> > + : "memory");
>
> At this point we've just inserted a duplicate of entry 0. So you don't
> need to insert a third entry do you?
This code was obviously adapted from the previous one which needed two
entries in case there was none for the memory region to start with.
Addin only one duplicate should suffice and it can be easily tested that
it still generates a MCE.
>
> > + asm volatile("slbmfee %0,%1" : "=r" (esid) : "r" (i));
> > + asm volatile("slbmfev %0,%1" : "=r" (vsid) : "r" (i));
> > + entry = get_slb_index();
> > +
> > + /* for i !=0 we would need to mask out the old entry number */
> > + asm volatile("slbmte %0,%1" :
> > + : "r" (vsid),
> > + "r" (esid | entry)
> > + : "memory");
> > +
> > + pr_info("%s accessing test address 0x%lx: 0x%lx\n",
> > + __func__, test_address, *test_ptr);
>
> This prints the first two instructions of the kernel. I happen to know
> what values they should have, but most people won't understand what
> they're seeing. A better test would be to read the value at the top of
> the function and then load it again here and check we got the right
> thing.
It does not really matter what we read back so long as the compiler does
not optimize out the read. The point here is to access an address in the
range covered by the SLB entry 0. The failure case is that the system
crashes and the test never finishes.
Thanks
Michal
^ permalink raw reply
* Re: [PATCH] drm/amd/display: Fix missing declaration of enable_kernel_vsx()
From: kernel test robot @ 2020-10-19 12:52 UTC (permalink / raw)
To: Christophe Leroy, Harry Wentland, Leo Li, Alex Deucher,
Christian König, David Airlie, Daniel Vetter
Cc: linuxppc-dev, amd-gfx, kbuild-all, linux-kernel, dri-devel
In-Reply-To: <1a5d454cf080a00c04ae488ef6e98d5fcc933550.1603100151.git.christophe.leroy@csgroup.eu>
[-- Attachment #1: Type: text/plain, Size: 2296 bytes --]
Hi Christophe,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.9 next-20201016]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/drm-amd-display-Fix-missing-declaration-of-enable_kernel_vsx/20201019-174155
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 7cf726a59435301046250c42131554d9ccc566b8
config: arc-randconfig-r013-20201019 (attached as .config)
compiler: arceb-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/33f0ea8bebc4132d957107f55776d8f1e02df928
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christophe-Leroy/drm-amd-display-Fix-missing-declaration-of-enable_kernel_vsx/20201019-174155
git checkout 33f0ea8bebc4132d957107f55776d8f1e02df928
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services_types.h:29,
from drivers/gpu/drm/amd/amdgpu/../include/dm_pp_interface.h:26,
from drivers/gpu/drm/amd/amdgpu/amdgpu.h:67,
from drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c:40:
>> drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h:36:10: fatal error: asm/switch-to.h: No such file or directory
36 | #include <asm/switch-to.h>
| ^~~~~~~~~~~~~~~~~
compilation terminated.
vim +36 drivers/gpu/drm/amd/amdgpu/../display/dc/os_types.h
34
35 #include <asm/byteorder.h>
> 36 #include <asm/switch-to.h>
37
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 31866 bytes --]
^ permalink raw reply
* [PATCH 1/3] powerpc/uaccess: Don't use "m<>" constraint with GCC 4.9
From: Christophe Leroy @ 2020-10-19 12:12 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linuxppc-dev, linux-kernel
GCC 4.9 sometimes fails to build with "m<>" constraint in
inline assembly.
CC lib/iov_iter.o
In file included from ./arch/powerpc/include/asm/cmpxchg.h:6:0,
from ./arch/powerpc/include/asm/atomic.h:11,
from ./include/linux/atomic.h:7,
from ./include/linux/crypto.h:15,
from ./include/crypto/hash.h:11,
from lib/iov_iter.c:2:
lib/iov_iter.c: In function 'iovec_from_user.part.30':
./arch/powerpc/include/asm/uaccess.h:287:2: error: 'asm' operand has impossible constraints
__asm__ __volatile__( \
^
./include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
# define unlikely(x) __builtin_expect(!!(x), 0)
^
./arch/powerpc/include/asm/uaccess.h:583:34: note: in expansion of macro 'unsafe_op_wrap'
#define unsafe_get_user(x, p, e) unsafe_op_wrap(__get_user_allowed(x, p), e)
^
./arch/powerpc/include/asm/uaccess.h:329:10: note: in expansion of macro '__get_user_asm'
case 4: __get_user_asm(x, (u32 __user *)ptr, retval, "lwz"); break; \
^
./arch/powerpc/include/asm/uaccess.h:363:3: note: in expansion of macro '__get_user_size_allowed'
__get_user_size_allowed(__gu_val, __gu_addr, __gu_size, __gu_err); \
^
./arch/powerpc/include/asm/uaccess.h:100:2: note: in expansion of macro '__get_user_nocheck'
__get_user_nocheck((x), (ptr), sizeof(*(ptr)), false)
^
./arch/powerpc/include/asm/uaccess.h:583:49: note: in expansion of macro '__get_user_allowed'
#define unsafe_get_user(x, p, e) unsafe_op_wrap(__get_user_allowed(x, p), e)
^
lib/iov_iter.c:1663:3: note: in expansion of macro 'unsafe_get_user'
unsafe_get_user(len, &uiov[i].iov_len, uaccess_end);
^
make[1]: *** [scripts/Makefile.build:283: lib/iov_iter.o] Error 1
Define a UPD_CONSTR macro that is "<>" by default and
only "" with GCC prior to GCC 5.
Fixes: fcf1f26895a4 ("powerpc/uaccess: Add pre-update addressing to __put_user_asm_goto()")
Fixes: 2f279eeb68b8 ("powerpc/uaccess: Add pre-update addressing to __get_user_asm() and __put_user_asm()")
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/include/asm/ppc_asm.h | 14 ++++++++++++++
arch/powerpc/include/asm/uaccess.h | 4 ++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 511786f0e40d..471c7c57fc98 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -803,6 +803,20 @@ END_FTR_SECTION_NESTED(CPU_FTR_CELL_TB_BUG, CPU_FTR_CELL_TB_BUG, 96)
#endif /* !CONFIG_PPC_BOOK3E */
+#else /* __ASSEMBLY */
+
+/*
+ * Inline assembly memory constraint
+ *
+ * GCC 4.9 doesn't properly handle pre update memory constraint "m<>"
+ *
+ */
+#if defined(GCC_VERSION) && GCC_VERSION < 50000
+#define UPD_CONSTR ""
+#else
+#define UPD_CONSTR "<>"
+#endif
+
#endif /* __ASSEMBLY__ */
/*
diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
index 604d705f1bb8..8f27ea48fadb 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -223,7 +223,7 @@ do { \
"1: " op "%U1%X1 %0,%1 # put_user\n" \
EX_TABLE(1b, %l2) \
: \
- : "r" (x), "m<>" (*addr) \
+ : "r" (x), "m"UPD_CONSTR (*addr) \
: \
: label)
@@ -294,7 +294,7 @@ extern long __get_user_bad(void);
".previous\n" \
EX_TABLE(1b, 3b) \
: "=r" (err), "=r" (x) \
- : "m<>" (*addr), "i" (-EFAULT), "0" (err))
+ : "m"UPD_CONSTR (*addr), "i" (-EFAULT), "0" (err))
#ifdef __powerpc64__
#define __get_user_asm2(x, addr, err) \
--
2.25.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox