* Re: [PATCH v3 2/2] powerpc/64: add stack protector support
From: Segher Boessenkool @ 2018-09-26 9:28 UTC (permalink / raw)
To: Christophe LEROY
Cc: Russell Currey, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, Andrew Donnellan, linuxppc-dev, linux-kernel
In-Reply-To: <30fb4e6b-0981-c53c-a1db-94138eaad268@c-s.fr>
On Wed, Sep 26, 2018 at 09:58:30AM +0200, Christophe LEROY wrote:
> Segher, any idea about this problem ?
> >>arch/powerpc/platforms/powermac/bootx_init.o: In function `bootx_printf':
> >>/var/lib/jenkins-slave/workspace/snowpatch/snowpatch-linux-
> >>sparse/linux/arch/powerpc/platforms/powermac/bootx_init.c:88:
> >>undefined reference to `__stack_chk_fail_local'
Are you building as PIC? Are you linking libssp_nonshared.a? Why not?
:-)
Segher
^ permalink raw reply
* Re: [PATCH 07/30] memblock: remove _virt from APIs returning virtual address
From: Michal Hocko @ 2018-09-26 9:27 UTC (permalink / raw)
To: Mike Rapoport
Cc: linux-mm, Andrew Morton, Catalin Marinas, Chris Zankel,
David S. Miller, Geert Uytterhoeven, Greentime Hu,
Greg Kroah-Hartman, Guan Xuetao, Ingo Molnar,
James E.J. Bottomley, Jonas Bonn, Jonathan Corbet, Ley Foon Tan,
Mark Salter, Martin Schwidefsky, Matt Turner, Michael Ellerman,
Michal Simek, Palmer Dabbelt, Paul Burton, Richard Kuo,
Richard Weinberger, Rich Felker, Russell King, Serge Semin,
Thomas Gleixner, Tony Luck, Vineet Gupta, Yoshinori Sato,
linux-alpha, linux-arm-kernel, linux-c6x-dev, linux-hexagon,
linux-ia64, linux-kernel, linux-m68k, linux-mips, linux-parisc,
linuxppc-dev, linux-riscv, linux-s390, linux-sh, linux-snps-arc,
linux-um, nios2-dev, openrisc, sparclinux, uclinux-h8-devel
In-Reply-To: <1536927045-23536-8-git-send-email-rppt@linux.vnet.ibm.com>
On Fri 14-09-18 15:10:22, Mike Rapoport wrote:
> The conversion is done using
>
> sed -i 's@memblock_virt_alloc@memblock_alloc@g' \
> $(git grep -l memblock_virt_alloc)
>
> Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
As I've said earlier, I am not entirely thrilled by this change. It is
unnecessary churn. So if nothing else just add a note _why_ you think
this is better.
--
Michal Hocko
SUSE Labs
^ permalink raw reply
* Re: [PATCH 1/2] soc: fsl: qbman: qman_portal: defer probing when qman is not available
From: Alexandre Belloni @ 2018-09-26 9:27 UTC (permalink / raw)
To: Olof Johansson
Cc: Li Yang, Roy Pledge, linuxppc-dev, Linux ARM Mailing List,
Linux Kernel Mailing List
In-Reply-To: <CAOesGMjDKKSNVccu4D579SiwL9zEU7ha7HQCHncvh2r4kpO6fQ@mail.gmail.com>
On 25/09/2018 21:45:56+0200, Olof Johansson wrote:
> Hi,
>
>
> On Thu, Aug 23, 2018 at 11:36 PM Alexandre Belloni
> <alexandre.belloni@bootlin.com> wrote:
> >
> > If the qman driver (qman_ccsr) doesn't probe or fail to probe before
> > qman_portal, qm_ccsr_start will be either NULL or a stale pointer to an
> > unmapped page.
> >
> > This leads to a crash when probing qman_portal as the init_pcfg function
> > calls qman_liodn_fixup that tries to read qman registers.
> >
> > Assume that qman didn't probe when the pool mask is 0.
> >
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > ---
> > drivers/soc/fsl/qbman/qman_portal.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c
> > index a120002b630e..4fc80d2c8feb 100644
> > --- a/drivers/soc/fsl/qbman/qman_portal.c
> > +++ b/drivers/soc/fsl/qbman/qman_portal.c
> > @@ -277,6 +277,8 @@ static int qman_portal_probe(struct platform_device *pdev)
> > }
> >
> > pcfg->pools = qm_get_pools_sdqcr();
> > + if (pcfg->pools == 0)
> > + return -EPROBE_DEFER;
>
> This is quite late in the probe, after a bunch of resources have been claimed.
>
> Note that the ioremaps above this are doing unwinds, and you'll end up
> doing duplicate ioremaps if you come in and probe again.
>
> You should probably unwind those allocations, or move them to devm_*
> or do this check earlier in the function.
>
The actual chance of having that happen is quite small (this was coming
from a non working DT) and I mainly wanted to avoid a crash so the
platform could still boot. I would think moving to devm_ would be the
right thing to do.
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply
* Re: [PATCH 05/30] mm: nobootmem: remove dead code
From: Michal Hocko @ 2018-09-26 9:25 UTC (permalink / raw)
To: Mike Rapoport
Cc: linux-mm, Andrew Morton, Catalin Marinas, Chris Zankel,
David S. Miller, Geert Uytterhoeven, Greentime Hu,
Greg Kroah-Hartman, Guan Xuetao, Ingo Molnar,
James E.J. Bottomley, Jonas Bonn, Jonathan Corbet, Ley Foon Tan,
Mark Salter, Martin Schwidefsky, Matt Turner, Michael Ellerman,
Michal Simek, Palmer Dabbelt, Paul Burton, Richard Kuo,
Richard Weinberger, Rich Felker, Russell King, Serge Semin,
Thomas Gleixner, Tony Luck, Vineet Gupta, Yoshinori Sato,
linux-alpha, linux-arm-kernel, linux-c6x-dev, linux-hexagon,
linux-ia64, linux-kernel, linux-m68k, linux-mips, linux-parisc,
linuxppc-dev, linux-riscv, linux-s390, linux-sh, linux-snps-arc,
linux-um, nios2-dev, openrisc, sparclinux, uclinux-h8-devel
In-Reply-To: <1536927045-23536-6-git-send-email-rppt@linux.vnet.ibm.com>
On Fri 14-09-18 15:10:20, Mike Rapoport wrote:
> Several bootmem functions and macros are not used. Remove them.
>
> Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Acked-by: Michal Hocko <mhocko@suse.com>
--
Michal Hocko
SUSE Labs
^ permalink raw reply
* Re: [PATCH 03/30] mm: remove CONFIG_HAVE_MEMBLOCK
From: Michal Hocko @ 2018-09-26 9:24 UTC (permalink / raw)
To: Mike Rapoport
Cc: linux-mm, Andrew Morton, Catalin Marinas, Chris Zankel,
David S. Miller, Geert Uytterhoeven, Greentime Hu,
Greg Kroah-Hartman, Guan Xuetao, Ingo Molnar,
James E.J. Bottomley, Jonas Bonn, Jonathan Corbet, Ley Foon Tan,
Mark Salter, Martin Schwidefsky, Matt Turner, Michael Ellerman,
Michal Simek, Palmer Dabbelt, Paul Burton, Richard Kuo,
Richard Weinberger, Rich Felker, Russell King, Serge Semin,
Thomas Gleixner, Tony Luck, Vineet Gupta, Yoshinori Sato,
linux-alpha, linux-arm-kernel, linux-c6x-dev, linux-hexagon,
linux-ia64, linux-kernel, linux-m68k, linux-mips, linux-parisc,
linuxppc-dev, linux-riscv, linux-s390, linux-sh, linux-snps-arc,
linux-um, nios2-dev, openrisc, sparclinux, uclinux-h8-devel
In-Reply-To: <1536927045-23536-4-git-send-email-rppt@linux.vnet.ibm.com>
On Fri 14-09-18 15:10:18, Mike Rapoport wrote:
> All architecures use memblock for early memory management. There is no need
> for the CONFIG_HAVE_MEMBLOCK configuration option.
git grep says
arch/csky/Kconfig: select HAVE_MEMBLOCK
> Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Other than that
Acked-by: Michal Hocko <mhocko@suse.com>
--
Michal Hocko
SUSE Labs
^ permalink raw reply
* Re: [PATCH 02/30] mm: remove CONFIG_NO_BOOTMEM
From: Michal Hocko @ 2018-09-26 9:22 UTC (permalink / raw)
To: Mike Rapoport
Cc: linux-mm, Andrew Morton, Catalin Marinas, Chris Zankel,
David S. Miller, Geert Uytterhoeven, Greentime Hu,
Greg Kroah-Hartman, Guan Xuetao, Ingo Molnar,
James E.J. Bottomley, Jonas Bonn, Jonathan Corbet, Ley Foon Tan,
Mark Salter, Martin Schwidefsky, Matt Turner, Michael Ellerman,
Michal Simek, Palmer Dabbelt, Paul Burton, Richard Kuo,
Richard Weinberger, Rich Felker, Russell King, Serge Semin,
Thomas Gleixner, Tony Luck, Vineet Gupta, Yoshinori Sato,
linux-alpha, linux-arm-kernel, linux-c6x-dev, linux-hexagon,
linux-ia64, linux-kernel, linux-m68k, linux-mips, linux-parisc,
linuxppc-dev, linux-riscv, linux-s390, linux-sh, linux-snps-arc,
linux-um, nios2-dev, openrisc, sparclinux, uclinux-h8-devel
In-Reply-To: <1536927045-23536-3-git-send-email-rppt@linux.vnet.ibm.com>
On Fri 14-09-18 15:10:17, Mike Rapoport wrote:
> All achitectures select NO_BOOTMEM which essentially becomes 'Y' for any
> kernel configuration and therefore it can be removed.
git grep suggests that DEFERRED_STRUCT_PAGE_INIT still depends on
NO_BOOTMEM but I have a vague feeling that I've seen a patch to address
that. It would be great to have it folded to this one.
> Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Acked-by: Michal Hocko <mhocko@suse.com>
--
Michal Hocko
SUSE Labs
^ permalink raw reply
* Re: [PATCH v5 18/22] powerpc/mm: Extend pte_fragment functionality to nohash/32
From: Aneesh Kumar K.V @ 2018-09-26 9:01 UTC (permalink / raw)
To: Christophe LEROY, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, aneesh.kumar
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <156d8a34-c40f-553a-0d4a-98433af1a1a2@c-s.fr>
On 9/26/18 1:40 PM, Christophe LEROY wrote:
>
>
> Le 26/09/2018 à 04:48, Aneesh Kumar K.V a écrit :
>> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>>
>>> In order to allow the 8xx to handle pte_fragments, this patch
>>> extends the use of pte_fragments to nohash/32 platforms.
>>>
>>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>>> ---
>>> arch/powerpc/include/asm/mmu_context.h | 2 +-
>>> arch/powerpc/include/asm/nohash/32/mmu-40x.h | 1 +
>>> arch/powerpc/include/asm/nohash/32/mmu-44x.h | 1 +
>>> arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 1 +
>>> arch/powerpc/include/asm/nohash/32/mmu.h | 4 ++-
>>> arch/powerpc/include/asm/nohash/32/pgalloc.h | 52
>>> +++++++++++++---------------
>>> arch/powerpc/include/asm/nohash/32/pgtable.h | 11 ++++--
>>> arch/powerpc/include/asm/nohash/mmu-book3e.h | 1 +
>>> arch/powerpc/mm/Makefile | 3 ++
>>> arch/powerpc/mm/mmu_context_nohash.c | 14 ++++++++
>>> 10 files changed, 57 insertions(+), 33 deletions(-)
>>>
>>> diff --git a/arch/powerpc/include/asm/mmu_context.h
>>> b/arch/powerpc/include/asm/mmu_context.h
>>> index b2f89b621b15..7f2c37a3f99d 100644
>>> --- a/arch/powerpc/include/asm/mmu_context.h
>>> +++ b/arch/powerpc/include/asm/mmu_context.h
>>> @@ -222,7 +222,7 @@ static inline int arch_dup_mmap(struct mm_struct
>>> *oldmm,
>>> return 0;
>>> }
>>> -#ifndef CONFIG_PPC_BOOK3S_64
>>> +#if defined(CONFIG_PPC_BOOK3E_64) || defined(CONFIG_PPC_BOOK3S_32)
>>> static inline void arch_exit_mmap(struct mm_struct *mm)
>>> {
>>> }
>>
>>
>> Can we do that with #ifndef arch_exit_mmap? This should handle every
>> platform that doesn't use pte_frag right?
>
> Yes we can, that means moving arch_exit_mmap() prototype in platform
> specific mmu headers, and adding there a #define arch_exit_mmap
> arch_exit_mmap
>
> Is that your idea ?
>
yes. that way it is easy to find out which platforms really want that to
be a different.
-aneesh
^ permalink raw reply
* Re: [PATCH v5 18/22] powerpc/mm: Extend pte_fragment functionality to nohash/32
From: Christophe LEROY @ 2018-09-26 8:10 UTC (permalink / raw)
To: Aneesh Kumar K.V, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, aneesh.kumar
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <87in2tgeix.fsf@linux.ibm.com>
Le 26/09/2018 à 04:48, Aneesh Kumar K.V a écrit :
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>
>> In order to allow the 8xx to handle pte_fragments, this patch
>> extends the use of pte_fragments to nohash/32 platforms.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> ---
>> arch/powerpc/include/asm/mmu_context.h | 2 +-
>> arch/powerpc/include/asm/nohash/32/mmu-40x.h | 1 +
>> arch/powerpc/include/asm/nohash/32/mmu-44x.h | 1 +
>> arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 1 +
>> arch/powerpc/include/asm/nohash/32/mmu.h | 4 ++-
>> arch/powerpc/include/asm/nohash/32/pgalloc.h | 52 +++++++++++++---------------
>> arch/powerpc/include/asm/nohash/32/pgtable.h | 11 ++++--
>> arch/powerpc/include/asm/nohash/mmu-book3e.h | 1 +
>> arch/powerpc/mm/Makefile | 3 ++
>> arch/powerpc/mm/mmu_context_nohash.c | 14 ++++++++
>> 10 files changed, 57 insertions(+), 33 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
>> index b2f89b621b15..7f2c37a3f99d 100644
>> --- a/arch/powerpc/include/asm/mmu_context.h
>> +++ b/arch/powerpc/include/asm/mmu_context.h
>> @@ -222,7 +222,7 @@ static inline int arch_dup_mmap(struct mm_struct *oldmm,
>> return 0;
>> }
>>
>> -#ifndef CONFIG_PPC_BOOK3S_64
>> +#if defined(CONFIG_PPC_BOOK3E_64) || defined(CONFIG_PPC_BOOK3S_32)
>> static inline void arch_exit_mmap(struct mm_struct *mm)
>> {
>> }
>
>
> Can we do that with #ifndef arch_exit_mmap? This should handle every
> platform that doesn't use pte_frag right?
Yes we can, that means moving arch_exit_mmap() prototype in platform
specific mmu headers, and adding there a #define arch_exit_mmap
arch_exit_mmap
Is that your idea ?
Christophe
>
>
>> diff --git a/arch/powerpc/include/asm/nohash/32/mmu-40x.h b/arch/powerpc/include/asm/nohash/32/mmu-40x.h
>> index 74f4edb5916e..7c77ceed71d6 100644
>> --- a/arch/powerpc/include/asm/nohash/32/mmu-40x.h
>> +++ b/arch/powerpc/include/asm/nohash/32/mmu-40x.h
>> @@ -58,6 +58,7 @@ typedef struct {
>> unsigned int id;
>> unsigned int active;
>> unsigned long vdso_base;
>
> -aneesh
>
^ permalink raw reply
* Re: [PATCH v3 2/2] powerpc/64: add stack protector support
From: Christophe LEROY @ 2018-09-26 7:58 UTC (permalink / raw)
To: Segher Boessenkool
Cc: Russell Currey, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, Andrew Donnellan, linuxppc-dev, linux-kernel
In-Reply-To: <d203ccfce64c8f9fd403162f2fa3807ade7f1d28.camel@russell.cc>
Segher, any idea about this problem ?
Christophe
Le 26/09/2018 à 09:05, Russell Currey a écrit :
> On Tue, 2018-09-25 at 17:56 +0200, Christophe LEROY wrote:
>> Snowpatch reports failure on pmac32_defconfig, as follows:
>>
>> arch/powerpc/platforms/powermac/bootx_init.o: In function `bootx_printf':
>> /var/lib/jenkins-slave/workspace/snowpatch/snowpatch-linux-
>> sparse/linux/arch/powerpc/platforms/powermac/bootx_init.c:88:
>> undefined reference to `__stack_chk_fail_local'
>> arch/powerpc/platforms/powermac/bootx_init.o: In function
>> `bootx_add_display_props':
>> /var/lib/jenkins-slave/workspace/snowpatch/snowpatch-linux-
>> sparse/linux/arch/powerpc/platforms/powermac/bootx_init.c:211:
>> undefined reference to `__stack_chk_fail_local'
>> arch/powerpc/platforms/powermac/bootx_init.o: In function
>> `bootx_scan_dt_build_struct':
>> /var/lib/jenkins-slave/workspace/snowpatch/snowpatch-linux-
>> sparse/linux/arch/powerpc/platforms/powermac/bootx_init.c:350:
>> undefined reference to `__stack_chk_fail_local'
>> arch/powerpc/platforms/powermac/bootx_init.o: In function `bootx_init':
>> /var/lib/jenkins-slave/workspace/snowpatch/snowpatch-linux-
>> sparse/linux/arch/powerpc/platforms/powermac/bootx_init.c:598:
>> undefined reference to `__stack_chk_fail_local'
>> ld: .tmp_vmlinux1: hidden symbol `__stack_chk_fail_local' isn't defined
>> ld: final link failed: Bad value
>> Makefile:1040: recipe for target 'vmlinux' failed
>> make: *** [vmlinux] Error 1
>>
>> I don't have this issue with GCC 8.1, bootx_init.o has references to
>> __stack_chk_fail, not to __stack_chk_fail_local
>>
>> Looking online, it may be due to an old build and a lack of 'make
>> clean', could it be the case here ?
>
> We do make mrproper AND clean, just to be sure :)
>
>>
>> Otherwise, can you retry the build to see if it's happen again ?
>
> I've retried the build and the same thing happens. Our build environment is using
> GCC 7.3 on Ubuntu 18.04. Reproduced on a different machine too, running the same
> OS and compiler.
>
> You can see exactly what gets run here:
> https://github.com/ajdlinux/openpower.xyz-snowpatch/blob/master/kernel-build-sparse.sh
>
> - Russell
>
>>
>> Christophe
>>
>> Le 24/09/2018 à 17:15, Christophe Leroy a écrit :
>>> On PPC64, as register r13 points to the paca_struct at all time,
>>> this patch adds a copy of the canary there, which is copied at
>>> task_switch.
>>> That new canary is then used by using the following GCC options:
>>> -mstack-protector-guard=tls
>>> -mstack-protector-guard-reg=r13
>>> -mstack-protector-guard-offset=offsetof(struct paca_struct, canary))
>>>
>>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>>> ---
>>> arch/powerpc/Kconfig | 2 +-
>>> arch/powerpc/Makefile | 8 ++++++++
>>> arch/powerpc/include/asm/paca.h | 3 +++
>>> arch/powerpc/include/asm/stackprotector.h | 3 +++
>>> arch/powerpc/kernel/asm-offsets.c | 3 +++
>>> arch/powerpc/kernel/entry_64.S | 4 ++++
>>> 6 files changed, 22 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>>> index 3bcb05929931..602eea723624 100644
>>> --- a/arch/powerpc/Kconfig
>>> +++ b/arch/powerpc/Kconfig
>>> @@ -180,7 +180,7 @@ config PPC
>>> select HAVE_ARCH_SECCOMP_FILTER
>>> select HAVE_ARCH_TRACEHOOK
>>> select HAVE_CBPF_JIT if !PPC64
>>> - select HAVE_STACKPROTECTOR if $(cc-option,-mstack-protector-
>>> guard=tls) && PPC32
>>> + select HAVE_STACKPROTECTOR if $(cc-option,-mstack-protector-
>>> guard=tls)
>>> select HAVE_CONTEXT_TRACKING if PPC64
>>> select HAVE_DEBUG_KMEMLEAK
>>> select HAVE_DEBUG_STACKOVERFLOW
>>> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
>>> index 45b8eb4d8fe7..81552c7b46eb 100644
>>> --- a/arch/powerpc/Makefile
>>> +++ b/arch/powerpc/Makefile
>>> @@ -113,7 +113,11 @@ KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET)
>>> endif
>>>
>>> cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard=tls
>>> +ifdef CONFIG_PPC64
>>> +cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r13
>>> +else
>>> cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r2
>>> +endif
>>>
>>> LDFLAGS_vmlinux-y := -Bstatic
>>> LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
>>> @@ -411,8 +415,12 @@ ifdef CONFIG_STACKPROTECTOR
>>> prepare: stack_protector_prepare
>>>
>>> stack_protector_prepare: prepare0
>>> +ifdef CONFIG_PPC64
>>> + $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if
>>> ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
>>> +else
>>> $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if
>>> ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
>>> endif
>>> +endif
>>>
>>> # Use the file '.tmp_gas_check' for binutils tests, as gas won't output
>>> # to stdout and these checks are run even on install targets.
>>> diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
>>> index 6d6b3706232c..98d883e58945 100644
>>> --- a/arch/powerpc/include/asm/paca.h
>>> +++ b/arch/powerpc/include/asm/paca.h
>>> @@ -246,6 +246,9 @@ struct paca_struct {
>>> struct slb_entry *mce_faulty_slbs;
>>> u16 slb_save_cache_ptr;
>>> #endif /* CONFIG_PPC_BOOK3S_64 */
>>> +#ifdef CONFIG_STACKPROTECTOR
>>> + unsigned long canary;
>>> +#endif
>>> } ____cacheline_aligned;
>>>
>>> extern struct paca_struct **paca_ptrs;
>>> diff --git a/arch/powerpc/include/asm/stackprotector.h
>>> b/arch/powerpc/include/asm/stackprotector.h
>>> index 263e2aab1862..e81991955c0d 100644
>>> --- a/arch/powerpc/include/asm/stackprotector.h
>>> +++ b/arch/powerpc/include/asm/stackprotector.h
>>> @@ -29,6 +29,9 @@ static __always_inline void boot_init_stack_canary(void)
>>> canary ^= LINUX_VERSION_CODE;
>>>
>>> current->stack_canary = canary;
>>> +#ifdef CONFIG_PPC64
>>> + get_paca()->canary = canary;
>>> +#endif
>>> }
>>>
>>> #endif /* _ASM_STACKPROTECTOR_H */
>>> diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-
>>> offsets.c
>>> index a992f7a53cf3..773dee55b3f6 100644
>>> --- a/arch/powerpc/kernel/asm-offsets.c
>>> +++ b/arch/powerpc/kernel/asm-offsets.c
>>> @@ -81,6 +81,9 @@ int main(void)
>>> OFFSET(MM, task_struct, mm);
>>> #ifdef CONFIG_STACKPROTECTOR
>>> OFFSET(TASK_CANARY, task_struct, stack_canary);
>>> +#ifdef CONFIG_PPC64
>>> + OFFSET(PACA_CANARY, paca_struct, canary);
>>> +#endif
>>> #endif
>>> OFFSET(MMCONTEXTID, mm_struct, context.id);
>>> #ifdef CONFIG_PPC64
>>> diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
>>> index 77a888bfcb53..573fa879d785 100644
>>> --- a/arch/powerpc/kernel/entry_64.S
>>> +++ b/arch/powerpc/kernel/entry_64.S
>>> @@ -624,6 +624,10 @@ _GLOBAL(_switch)
>>>
>>> addi r6,r4,-THREAD /* Convert THREAD to 'current' */
>>> std r6,PACACURRENT(r13) /* Set new 'current' */
>>> +#if defined(CONFIG_STACKPROTECTOR)
>>> + ld r6, TASK_CANARY(r6)
>>> + std r6, PACA_CANARY(r13)
>>> +#endif
>>>
>>> ld r8,KSP(r4) /* new stack pointer */
>>> #ifdef CONFIG_PPC_BOOK3S_64
>>>
^ permalink raw reply
* Re: [PATCH v3 2/2] powerpc/64: add stack protector support
From: Russell Currey @ 2018-09-26 7:05 UTC (permalink / raw)
To: Christophe LEROY, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, Andrew Donnellan
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <0797fc91-6400-2508-1cc0-4bba78aafbbb@c-s.fr>
On Tue, 2018-09-25 at 17:56 +0200, Christophe LEROY wrote:
> Snowpatch reports failure on pmac32_defconfig, as follows:
>
> arch/powerpc/platforms/powermac/bootx_init.o: In function `bootx_printf':
> /var/lib/jenkins-slave/workspace/snowpatch/snowpatch-linux-
> sparse/linux/arch/powerpc/platforms/powermac/bootx_init.c:88:
> undefined reference to `__stack_chk_fail_local'
> arch/powerpc/platforms/powermac/bootx_init.o: In function
> `bootx_add_display_props':
> /var/lib/jenkins-slave/workspace/snowpatch/snowpatch-linux-
> sparse/linux/arch/powerpc/platforms/powermac/bootx_init.c:211:
> undefined reference to `__stack_chk_fail_local'
> arch/powerpc/platforms/powermac/bootx_init.o: In function
> `bootx_scan_dt_build_struct':
> /var/lib/jenkins-slave/workspace/snowpatch/snowpatch-linux-
> sparse/linux/arch/powerpc/platforms/powermac/bootx_init.c:350:
> undefined reference to `__stack_chk_fail_local'
> arch/powerpc/platforms/powermac/bootx_init.o: In function `bootx_init':
> /var/lib/jenkins-slave/workspace/snowpatch/snowpatch-linux-
> sparse/linux/arch/powerpc/platforms/powermac/bootx_init.c:598:
> undefined reference to `__stack_chk_fail_local'
> ld: .tmp_vmlinux1: hidden symbol `__stack_chk_fail_local' isn't defined
> ld: final link failed: Bad value
> Makefile:1040: recipe for target 'vmlinux' failed
> make: *** [vmlinux] Error 1
>
> I don't have this issue with GCC 8.1, bootx_init.o has references to
> __stack_chk_fail, not to __stack_chk_fail_local
>
> Looking online, it may be due to an old build and a lack of 'make
> clean', could it be the case here ?
We do make mrproper AND clean, just to be sure :)
>
> Otherwise, can you retry the build to see if it's happen again ?
I've retried the build and the same thing happens. Our build environment is using
GCC 7.3 on Ubuntu 18.04. Reproduced on a different machine too, running the same
OS and compiler.
You can see exactly what gets run here:
https://github.com/ajdlinux/openpower.xyz-snowpatch/blob/master/kernel-build-sparse.sh
- Russell
>
> Christophe
>
> Le 24/09/2018 à 17:15, Christophe Leroy a écrit :
> > On PPC64, as register r13 points to the paca_struct at all time,
> > this patch adds a copy of the canary there, which is copied at
> > task_switch.
> > That new canary is then used by using the following GCC options:
> > -mstack-protector-guard=tls
> > -mstack-protector-guard-reg=r13
> > -mstack-protector-guard-offset=offsetof(struct paca_struct, canary))
> >
> > Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> > ---
> > arch/powerpc/Kconfig | 2 +-
> > arch/powerpc/Makefile | 8 ++++++++
> > arch/powerpc/include/asm/paca.h | 3 +++
> > arch/powerpc/include/asm/stackprotector.h | 3 +++
> > arch/powerpc/kernel/asm-offsets.c | 3 +++
> > arch/powerpc/kernel/entry_64.S | 4 ++++
> > 6 files changed, 22 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> > index 3bcb05929931..602eea723624 100644
> > --- a/arch/powerpc/Kconfig
> > +++ b/arch/powerpc/Kconfig
> > @@ -180,7 +180,7 @@ config PPC
> > select HAVE_ARCH_SECCOMP_FILTER
> > select HAVE_ARCH_TRACEHOOK
> > select HAVE_CBPF_JIT if !PPC64
> > - select HAVE_STACKPROTECTOR if $(cc-option,-mstack-protector-
> > guard=tls) && PPC32
> > + select HAVE_STACKPROTECTOR if $(cc-option,-mstack-protector-
> > guard=tls)
> > select HAVE_CONTEXT_TRACKING if PPC64
> > select HAVE_DEBUG_KMEMLEAK
> > select HAVE_DEBUG_STACKOVERFLOW
> > diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> > index 45b8eb4d8fe7..81552c7b46eb 100644
> > --- a/arch/powerpc/Makefile
> > +++ b/arch/powerpc/Makefile
> > @@ -113,7 +113,11 @@ KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET)
> > endif
> >
> > cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard=tls
> > +ifdef CONFIG_PPC64
> > +cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r13
> > +else
> > cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r2
> > +endif
> >
> > LDFLAGS_vmlinux-y := -Bstatic
> > LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
> > @@ -411,8 +415,12 @@ ifdef CONFIG_STACKPROTECTOR
> > prepare: stack_protector_prepare
> >
> > stack_protector_prepare: prepare0
> > +ifdef CONFIG_PPC64
> > + $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if
> > ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
> > +else
> > $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if
> > ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
> > endif
> > +endif
> >
> > # Use the file '.tmp_gas_check' for binutils tests, as gas won't output
> > # to stdout and these checks are run even on install targets.
> > diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
> > index 6d6b3706232c..98d883e58945 100644
> > --- a/arch/powerpc/include/asm/paca.h
> > +++ b/arch/powerpc/include/asm/paca.h
> > @@ -246,6 +246,9 @@ struct paca_struct {
> > struct slb_entry *mce_faulty_slbs;
> > u16 slb_save_cache_ptr;
> > #endif /* CONFIG_PPC_BOOK3S_64 */
> > +#ifdef CONFIG_STACKPROTECTOR
> > + unsigned long canary;
> > +#endif
> > } ____cacheline_aligned;
> >
> > extern struct paca_struct **paca_ptrs;
> > diff --git a/arch/powerpc/include/asm/stackprotector.h
> > b/arch/powerpc/include/asm/stackprotector.h
> > index 263e2aab1862..e81991955c0d 100644
> > --- a/arch/powerpc/include/asm/stackprotector.h
> > +++ b/arch/powerpc/include/asm/stackprotector.h
> > @@ -29,6 +29,9 @@ static __always_inline void boot_init_stack_canary(void)
> > canary ^= LINUX_VERSION_CODE;
> >
> > current->stack_canary = canary;
> > +#ifdef CONFIG_PPC64
> > + get_paca()->canary = canary;
> > +#endif
> > }
> >
> > #endif /* _ASM_STACKPROTECTOR_H */
> > diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-
> > offsets.c
> > index a992f7a53cf3..773dee55b3f6 100644
> > --- a/arch/powerpc/kernel/asm-offsets.c
> > +++ b/arch/powerpc/kernel/asm-offsets.c
> > @@ -81,6 +81,9 @@ int main(void)
> > OFFSET(MM, task_struct, mm);
> > #ifdef CONFIG_STACKPROTECTOR
> > OFFSET(TASK_CANARY, task_struct, stack_canary);
> > +#ifdef CONFIG_PPC64
> > + OFFSET(PACA_CANARY, paca_struct, canary);
> > +#endif
> > #endif
> > OFFSET(MMCONTEXTID, mm_struct, context.id);
> > #ifdef CONFIG_PPC64
> > diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
> > index 77a888bfcb53..573fa879d785 100644
> > --- a/arch/powerpc/kernel/entry_64.S
> > +++ b/arch/powerpc/kernel/entry_64.S
> > @@ -624,6 +624,10 @@ _GLOBAL(_switch)
> >
> > addi r6,r4,-THREAD /* Convert THREAD to 'current' */
> > std r6,PACACURRENT(r13) /* Set new 'current' */
> > +#if defined(CONFIG_STACKPROTECTOR)
> > + ld r6, TASK_CANARY(r6)
> > + std r6, PACA_CANARY(r13)
> > +#endif
> >
> > ld r8,KSP(r4) /* new stack pointer */
> > #ifdef CONFIG_PPC_BOOK3S_64
> >
^ permalink raw reply
* Re: [PATCH v8 0/3] powerpc: Detection and scheduler optimization for POWER9 bigcore
From: Gautham R Shenoy @ 2018-09-26 6:06 UTC (permalink / raw)
To: Dave Hansen
Cc: ego, Aneesh Kumar K.V, Srikar Dronamraju, Michael Ellerman,
Benjamin Herrenschmidt, Michael Neuling, Vaidyanathan Srinivasan,
Akshay Adiga, Shilpasri G Bhat, Oliver O'Halloran,
Nicholas Piggin, Murilo Opsfelder Araujo, Anton Blanchard,
linuxppc-dev, linux-kernel
In-Reply-To: <f2ac8eb0-b28e-a930-0160-09720f73a297@intel.com>
Hello Dave,
On Tue, Sep 25, 2018 at 03:16:30PM -0700, Dave Hansen wrote:
> On 09/22/2018 04:03 AM, Gautham R Shenoy wrote:
> > Without this patchset, the SMT domain would be defined as the group of
> > threads that share L2 cache.
>
> Could you try to make a more clear, concise statement about the current
> state of the art vs. what you want it to be? Right now, the sched
> domains do something like this in terms of ordering:
>
> 1. SMT siblings
> 2. Caches
> 3. NUMA
Yes. you are right. The state of art on POWER9 machines having SMT8
cores is as you described above with
1. SMT siblings sharing L2-cache, called the SMT domain
2. Cores on the same die, called the DIE domain
3. NUMA
>
> It sounds like you don't want SMT siblings to be the things that we use,
> right? Because some siblings share caches and some do not. Right? You
> want something like this:
>
> 1. SMT siblings (sharing L1)
> 2. SMT siblings (sharing L2)
> 3. Other caches
> 4. NUMA
>
Yes, with the patchset the sched-domain hierarchy on POWER9 machines
having SMT8 will be:
1. SMT siblings sharing L1 cache, called the SMT domain
2. SMT siblings sharing L2 cache, called the CACHE domain (introduced in
commit 96d91431d691 "powerpc/smp: Add Power9 scheduler topology")
3. Cores on the same die, called the DIE domain.
4. NUMA
--
Thanks and Regards
gautham.
^ permalink raw reply
* [PATCH v2] powerpc/pseries: Export raw per-CPU VPA data via debugfs
From: Aravinda Prasad @ 2018-09-26 4:45 UTC (permalink / raw)
To: mpe, linuxppc-dev; +Cc: nfont, naveen.n.rao, aravinda
This patch exports the raw per-CPU VPA data via debugfs.
A per-CPU file is created which exports the VPA data of
that CPU to help debug some of the VPA related issues or
to analyze the per-CPU VPA related statistics.
Signed-off-by: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
---
arch/powerpc/platforms/pseries/lpar.c | 57 +++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index d3992ce..8852ebc 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -48,6 +48,7 @@
#include <asm/kexec.h>
#include <asm/fadump.h>
#include <asm/asm-prototypes.h>
+#include <asm/debugfs.h>
#include "pseries.h"
@@ -1028,3 +1029,59 @@ static int __init reserve_vrma_context_id(void)
return 0;
}
machine_device_initcall(pseries, reserve_vrma_context_id);
+
+#ifdef CONFIG_DEBUG_FS
+/* debugfs file interface for vpa data */
+static ssize_t vpa_file_read(struct file *filp, char __user *buf, size_t len,
+ loff_t *pos)
+{
+ int cpu = (long)filp->private_data;
+ struct lppaca *lppaca = &lppaca_of(cpu);
+
+ if (!cpu_online(cpu))
+ return -EINVAL;
+
+ return simple_read_from_buffer(buf, len, pos, lppaca,
+ sizeof(struct lppaca));
+}
+
+static const struct file_operations vpa_fops = {
+ .open = simple_open,
+ .read = vpa_file_read,
+ .llseek = default_llseek,
+};
+
+static int __init vpa_debugfs_init(void)
+{
+ char name[16];
+ long i;
+ static struct dentry *vpa_dir;
+
+ if (!firmware_has_feature(FW_FEATURE_SPLPAR))
+ return 0;
+
+ vpa_dir = debugfs_create_dir("vpa", powerpc_debugfs_root);
+ if (!vpa_dir) {
+ pr_warn("%s: can't create vpa root dir\n", __func__);
+ return -ENOMEM;
+ }
+
+ /* set up the per-cpu vpa file*/
+ for_each_possible_cpu(i) {
+ struct dentry *d;
+
+ sprintf(name, "cpu-%ld", i);
+
+ d = debugfs_create_file(name, 0400, vpa_dir, (void *)i,
+ &vpa_fops);
+ if (!d) {
+ pr_warn("%s: can't create per-cpu vpa file\n",
+ __func__);
+ return -ENOMEM;
+ }
+ }
+
+ return 0;
+}
+machine_arch_initcall(pseries, vpa_debugfs_init);
+#endif /* CONFIG_DEBUG_FS */
^ permalink raw reply related
* Re: [PATCH 4/4] dma-mapping: clear dev->dma_ops in arch_teardown_dma_ops
From: Michael Ellerman @ 2018-09-26 4:20 UTC (permalink / raw)
To: Christoph Hellwig, Guenter Roeck
Cc: Christoph Hellwig, iommu, Greg Kroah-Hartman, Robin Murphy,
linux-kernel, linux-arm-kernel, Marek Szyprowski, Bjorn Helgaas,
linux-pci, Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev
In-Reply-To: <20180925201619.GB8413@lst.de>
Christoph Hellwig <hch@lst.de> writes:
> Looking at the code I think this commit is simply broken for
> architectures not using arch_setup_dma_ops, but instead setting up
> the dma ops through arch specific magic.
I arch_setup_dma_ops() called from of_dma_configure(), but
pci_dma_configure() doesn't call that for this device:
static int pci_dma_configure(struct device *dev)
{
...
if (IS_ENABLED(CONFIG_OF) && bridge->parent &&
bridge->parent->of_node) {
ret = of_dma_configure(dev, bridge->parent->of_node, true);
bridge->parent is NULL.
So I don't think arch_setup_dma_ops() would help here?
> I'll revert the patch.
Thanks.
cheers
^ permalink raw reply
* Re: [PATCH] powerpc/tm: Avoid possible userspace r1 corruption on reclaim
From: Michael Neuling @ 2018-09-26 3:46 UTC (permalink / raw)
To: Michael Ellerman
Cc: linuxppc-dev, Nicholas Piggin, paulus, benh, Breno Leitao,
aneesh.kumar
In-Reply-To: <87d0t14wiz.fsf@concordia.ellerman.id.au>
On Tue, 2018-09-25 at 22:00 +1000, Michael Ellerman wrote:
> Michael Neuling <mikey@neuling.org> writes:
> > Current we store the userspace r1 to PACATMSCRATCH before finally
> > saving it to the thread struct.
> >=20
> > In theory an exception could be taken here (like a machine check or
> > SLB miss) that could write PACATMSCRATCH and hence corrupt the
> > userspace r1. The SLB fault currently doesn't touch PACATMSCRATCH, but
> > others do.
> >=20
> > We've never actually seen this happen but it's theoretically
> > possible. Either way, the code is fragile as it is.
> >=20
> > This patch saves r1 to the kernel stack (which can't fault) before we
> > turn MSR[RI] back on. PACATMSCRATCH is still used but only with
> > MSR[RI] off. We then copy r1 from the kernel stack to the thread
> > struct once we have MSR[RI] back on.
> >=20
> > Suggested-by: Breno Leitao <leitao@debian.org>
> > Signed-off-by: Michael Neuling <mikey@neuling.org>
> > ---
> > arch/powerpc/kernel/tm.S | 8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >=20
> > diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S
> > index 701b0f5b09..8207816a1e 100644
> > --- a/arch/powerpc/kernel/tm.S
> > +++ b/arch/powerpc/kernel/tm.S
> > @@ -178,6 +178,12 @@ _GLOBAL(tm_reclaim)
> > =20
> > std r11, GPR11(r1) /* Temporary stash */
> > =20
> > + /* Move r1 to kernel stack in case PACATMSCRATCH is used once
> > + * we turn on RI
> > + */
>=20
> I see we still need to send you to Comment Formatting Re-Education Camp.
The rest of that file has they style, so I'm just keeping with that. I can
submit a patch later to fix them all up.
> I rewrote it a bit too, to hopefully be clearer?
>=20
> /*
> * Move the saved user r1 to the kernel stack in case PACATMSCRATCH is
> * clobbered by an exception once we turn on MSR_RI below.
> */
> ld r11, PACATMSCRATCH(r13)
> std r11, GPR1(r1)
Yeah, that's clearer... thanks.
Mikey
^ permalink raw reply
* Re: [PATCH v5 18/22] powerpc/mm: Extend pte_fragment functionality to nohash/32
From: Aneesh Kumar K.V @ 2018-09-26 2:48 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, aneesh.kumar
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cda95a5508594e2a2ad5f6f214c435d9a1b44c46.1537892499.git.christophe.leroy@c-s.fr>
Christophe Leroy <christophe.leroy@c-s.fr> writes:
> In order to allow the 8xx to handle pte_fragments, this patch
> extends the use of pte_fragments to nohash/32 platforms.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> arch/powerpc/include/asm/mmu_context.h | 2 +-
> arch/powerpc/include/asm/nohash/32/mmu-40x.h | 1 +
> arch/powerpc/include/asm/nohash/32/mmu-44x.h | 1 +
> arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 1 +
> arch/powerpc/include/asm/nohash/32/mmu.h | 4 ++-
> arch/powerpc/include/asm/nohash/32/pgalloc.h | 52 +++++++++++++---------------
> arch/powerpc/include/asm/nohash/32/pgtable.h | 11 ++++--
> arch/powerpc/include/asm/nohash/mmu-book3e.h | 1 +
> arch/powerpc/mm/Makefile | 3 ++
> arch/powerpc/mm/mmu_context_nohash.c | 14 ++++++++
> 10 files changed, 57 insertions(+), 33 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
> index b2f89b621b15..7f2c37a3f99d 100644
> --- a/arch/powerpc/include/asm/mmu_context.h
> +++ b/arch/powerpc/include/asm/mmu_context.h
> @@ -222,7 +222,7 @@ static inline int arch_dup_mmap(struct mm_struct *oldmm,
> return 0;
> }
>
> -#ifndef CONFIG_PPC_BOOK3S_64
> +#if defined(CONFIG_PPC_BOOK3E_64) || defined(CONFIG_PPC_BOOK3S_32)
> static inline void arch_exit_mmap(struct mm_struct *mm)
> {
> }
Can we do that with #ifndef arch_exit_mmap? This should handle every
platform that doesn't use pte_frag right?
> diff --git a/arch/powerpc/include/asm/nohash/32/mmu-40x.h b/arch/powerpc/include/asm/nohash/32/mmu-40x.h
> index 74f4edb5916e..7c77ceed71d6 100644
> --- a/arch/powerpc/include/asm/nohash/32/mmu-40x.h
> +++ b/arch/powerpc/include/asm/nohash/32/mmu-40x.h
> @@ -58,6 +58,7 @@ typedef struct {
> unsigned int id;
> unsigned int active;
> unsigned long vdso_base;
-aneesh
^ permalink raw reply
* Re: [PATCH v5 17/22] powerpc/mm: Move pgtable_t into platform headers
From: Aneesh Kumar K.V @ 2018-09-26 2:44 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, aneesh.kumar
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <2a231be613ff9763f50acc10dea1175675db3ad1.1537892499.git.christophe.leroy@c-s.fr>
Christophe Leroy <christophe.leroy@c-s.fr> writes:
> This patch move pgtable_t into platform headers.
>
> It gets rid of the CONFIG_PPC_64K_PAGES case for PPC64
> as nohash/64 doesn't support CONFIG_PPC_64K_PAGES.
>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> arch/powerpc/include/asm/book3s/32/mmu-hash.h | 2 ++
> arch/powerpc/include/asm/book3s/64/mmu.h | 9 +++++++++
> arch/powerpc/include/asm/nohash/32/mmu.h | 4 ++++
> arch/powerpc/include/asm/nohash/64/mmu.h | 4 ++++
> arch/powerpc/include/asm/page.h | 14 --------------
> 5 files changed, 19 insertions(+), 14 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/book3s/32/mmu-hash.h b/arch/powerpc/include/asm/book3s/32/mmu-hash.h
> index e38c91388c40..5bd26c218b94 100644
> --- a/arch/powerpc/include/asm/book3s/32/mmu-hash.h
> +++ b/arch/powerpc/include/asm/book3s/32/mmu-hash.h
> @@ -42,6 +42,8 @@ struct ppc_bat {
> u32 batu;
> u32 batl;
> };
> +
> +typedef struct page *pgtable_t;
> #endif /* !__ASSEMBLY__ */
>
> /*
> diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h
> index 9c8c669a6b6a..488e7ed07e96 100644
> --- a/arch/powerpc/include/asm/book3s/64/mmu.h
> +++ b/arch/powerpc/include/asm/book3s/64/mmu.h
> @@ -2,6 +2,8 @@
> #ifndef _ASM_POWERPC_BOOK3S_64_MMU_H_
> #define _ASM_POWERPC_BOOK3S_64_MMU_H_
>
> +#include <asm/page.h>
> +
> #ifndef __ASSEMBLY__
> /*
> * Page size definition
> @@ -24,6 +26,13 @@ struct mmu_psize_def {
> };
> extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
>
> +/*
> + * For BOOK3s 64 with 4k and 64K linux page size
> + * we want to use pointers, because the page table
> + * actually store pfn
> + */
> +typedef pte_t *pgtable_t;
> +
> #endif /* __ASSEMBLY__ */
>
> /* 64-bit classic hash table MMU */
> diff --git a/arch/powerpc/include/asm/nohash/32/mmu.h b/arch/powerpc/include/asm/nohash/32/mmu.h
> index af0e8b54876a..f61f933a4cd8 100644
> --- a/arch/powerpc/include/asm/nohash/32/mmu.h
> +++ b/arch/powerpc/include/asm/nohash/32/mmu.h
> @@ -16,4 +16,8 @@
> #include <asm/nohash/32/mmu-8xx.h>
> #endif
>
> +#ifndef __ASSEMBLY__
> +typedef struct page *pgtable_t;
> +#endif
> +
> #endif /* _ASM_POWERPC_NOHASH_32_MMU_H_ */
> diff --git a/arch/powerpc/include/asm/nohash/64/mmu.h b/arch/powerpc/include/asm/nohash/64/mmu.h
> index 87871d027b75..e6585480dfc4 100644
> --- a/arch/powerpc/include/asm/nohash/64/mmu.h
> +++ b/arch/powerpc/include/asm/nohash/64/mmu.h
> @@ -5,4 +5,8 @@
> /* Freescale Book-E software loaded TLB or Book-3e (ISA 2.06+) MMU */
> #include <asm/nohash/mmu-book3e.h>
>
> +#ifndef __ASSEMBLY__
> +typedef struct page *pgtable_t;
> +#endif
> +
> #endif /* _ASM_POWERPC_NOHASH_64_MMU_H_ */
> diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
> index f6a1265face2..ddfb4b965e5b 100644
> --- a/arch/powerpc/include/asm/page.h
> +++ b/arch/powerpc/include/asm/page.h
> @@ -335,20 +335,6 @@ void arch_free_page(struct page *page, int order);
> #endif
>
> struct vm_area_struct;
> -#ifdef CONFIG_PPC_BOOK3S_64
> -/*
> - * For BOOK3s 64 with 4k and 64K linux page size
> - * we want to use pointers, because the page table
> - * actually store pfn
> - */
> -typedef pte_t *pgtable_t;
> -#else
> -#if defined(CONFIG_PPC_64K_PAGES) && defined(CONFIG_PPC64)
> -typedef pte_t *pgtable_t;
> -#else
> -typedef struct page *pgtable_t;
> -#endif
> -#endif
>
> #include <asm-generic/memory_model.h>
> #endif /* __ASSEMBLY__ */
> --
> 2.13.3
^ permalink raw reply
* Re: [PATCH v5 16/22] powerpc/mm: move platform specific mmu-xxx.h in platform directories
From: Aneesh Kumar K.V @ 2018-09-26 2:44 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, aneesh.kumar
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <a866faa9455b0e59d7d7bca28cb06c09ab5f3589.1537892499.git.christophe.leroy@c-s.fr>
Christophe Leroy <christophe.leroy@c-s.fr> writes:
> The purpose of this patch is to move platform specific
> mmu-xxx.h files in platform directories like pte-xxx.h files.
>
> In the meantime this patch creates common nohash and
> nohash/32 + nohash/64 mmu.h files for future common parts.
>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> arch/powerpc/include/asm/mmu.h | 14 ++------------
> arch/powerpc/include/asm/{ => nohash/32}/mmu-40x.h | 0
> arch/powerpc/include/asm/{ => nohash/32}/mmu-44x.h | 0
> arch/powerpc/include/asm/{ => nohash/32}/mmu-8xx.h | 0
> arch/powerpc/include/asm/nohash/32/mmu.h | 19 +++++++++++++++++++
> arch/powerpc/include/asm/nohash/64/mmu.h | 8 ++++++++
> arch/powerpc/include/asm/{ => nohash}/mmu-book3e.h | 0
> arch/powerpc/include/asm/nohash/mmu.h | 11 +++++++++++
> arch/powerpc/kernel/cpu_setup_fsl_booke.S | 2 +-
> arch/powerpc/kvm/e500.h | 2 +-
> 10 files changed, 42 insertions(+), 14 deletions(-)
> rename arch/powerpc/include/asm/{ => nohash/32}/mmu-40x.h (100%)
> rename arch/powerpc/include/asm/{ => nohash/32}/mmu-44x.h (100%)
> rename arch/powerpc/include/asm/{ => nohash/32}/mmu-8xx.h (100%)
> create mode 100644 arch/powerpc/include/asm/nohash/32/mmu.h
> create mode 100644 arch/powerpc/include/asm/nohash/64/mmu.h
> rename arch/powerpc/include/asm/{ => nohash}/mmu-book3e.h (100%)
> create mode 100644 arch/powerpc/include/asm/nohash/mmu.h
>
> diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
> index 13ea441ac531..2b396de45e9e 100644
> --- a/arch/powerpc/include/asm/mmu.h
> +++ b/arch/powerpc/include/asm/mmu.h
> @@ -326,18 +326,8 @@ static inline void mmu_early_init_devtree(void) { }
> #if defined(CONFIG_PPC_STD_MMU_32)
> /* 32-bit classic hash table MMU */
> #include <asm/book3s/32/mmu-hash.h>
> -#elif defined(CONFIG_40x)
> -/* 40x-style software loaded TLB */
> -# include <asm/mmu-40x.h>
> -#elif defined(CONFIG_44x)
> -/* 44x-style software loaded TLB */
> -# include <asm/mmu-44x.h>
> -#elif defined(CONFIG_PPC_BOOK3E_MMU)
> -/* Freescale Book-E software loaded TLB or Book-3e (ISA 2.06+) MMU */
> -# include <asm/mmu-book3e.h>
> -#elif defined (CONFIG_PPC_8xx)
> -/* Motorola/Freescale 8xx software loaded TLB */
> -# include <asm/mmu-8xx.h>
> +#elif defined(CONFIG_PPC_MMU_NOHASH)
> +#include <asm/nohash/mmu.h>
> #endif
>
> #endif /* __KERNEL__ */
> diff --git a/arch/powerpc/include/asm/mmu-40x.h b/arch/powerpc/include/asm/nohash/32/mmu-40x.h
> similarity index 100%
> rename from arch/powerpc/include/asm/mmu-40x.h
> rename to arch/powerpc/include/asm/nohash/32/mmu-40x.h
> diff --git a/arch/powerpc/include/asm/mmu-44x.h b/arch/powerpc/include/asm/nohash/32/mmu-44x.h
> similarity index 100%
> rename from arch/powerpc/include/asm/mmu-44x.h
> rename to arch/powerpc/include/asm/nohash/32/mmu-44x.h
> diff --git a/arch/powerpc/include/asm/mmu-8xx.h b/arch/powerpc/include/asm/nohash/32/mmu-8xx.h
> similarity index 100%
> rename from arch/powerpc/include/asm/mmu-8xx.h
> rename to arch/powerpc/include/asm/nohash/32/mmu-8xx.h
> diff --git a/arch/powerpc/include/asm/nohash/32/mmu.h b/arch/powerpc/include/asm/nohash/32/mmu.h
> new file mode 100644
> index 000000000000..af0e8b54876a
> --- /dev/null
> +++ b/arch/powerpc/include/asm/nohash/32/mmu.h
> @@ -0,0 +1,19 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_POWERPC_NOHASH_32_MMU_H_
> +#define _ASM_POWERPC_NOHASH_32_MMU_H_
> +
> +#if defined(CONFIG_40x)
> +/* 40x-style software loaded TLB */
> +#include <asm/nohash/32/mmu-40x.h>
> +#elif defined(CONFIG_44x)
> +/* 44x-style software loaded TLB */
> +#include <asm/nohash/32/mmu-44x.h>
> +#elif defined(CONFIG_PPC_BOOK3E_MMU)
> +/* Freescale Book-E software loaded TLB or Book-3e (ISA 2.06+) MMU */
> +#include <asm/nohash/mmu-book3e.h>
> +#elif defined (CONFIG_PPC_8xx)
> +/* Motorola/Freescale 8xx software loaded TLB */
> +#include <asm/nohash/32/mmu-8xx.h>
> +#endif
> +
> +#endif /* _ASM_POWERPC_NOHASH_32_MMU_H_ */
> diff --git a/arch/powerpc/include/asm/nohash/64/mmu.h b/arch/powerpc/include/asm/nohash/64/mmu.h
> new file mode 100644
> index 000000000000..87871d027b75
> --- /dev/null
> +++ b/arch/powerpc/include/asm/nohash/64/mmu.h
> @@ -0,0 +1,8 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_POWERPC_NOHASH_64_MMU_H_
> +#define _ASM_POWERPC_NOHASH_64_MMU_H_
> +
> +/* Freescale Book-E software loaded TLB or Book-3e (ISA 2.06+) MMU */
> +#include <asm/nohash/mmu-book3e.h>
> +
> +#endif /* _ASM_POWERPC_NOHASH_64_MMU_H_ */
> diff --git a/arch/powerpc/include/asm/mmu-book3e.h b/arch/powerpc/include/asm/nohash/mmu-book3e.h
> similarity index 100%
> rename from arch/powerpc/include/asm/mmu-book3e.h
> rename to arch/powerpc/include/asm/nohash/mmu-book3e.h
> diff --git a/arch/powerpc/include/asm/nohash/mmu.h b/arch/powerpc/include/asm/nohash/mmu.h
> new file mode 100644
> index 000000000000..a037cb1efb57
> --- /dev/null
> +++ b/arch/powerpc/include/asm/nohash/mmu.h
> @@ -0,0 +1,11 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_POWERPC_NOHASH_MMU_H_
> +#define _ASM_POWERPC_NOHASH_MMU_H_
> +
> +#ifdef CONFIG_PPC64
> +#include <asm/nohash/64/mmu.h>
> +#else
> +#include <asm/nohash/32/mmu.h>
> +#endif
> +
> +#endif /* _ASM_POWERPC_NOHASH_MMU_H_ */
> diff --git a/arch/powerpc/kernel/cpu_setup_fsl_booke.S b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
> index 8d142e5d84cd..5fbc890d1094 100644
> --- a/arch/powerpc/kernel/cpu_setup_fsl_booke.S
> +++ b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
> @@ -17,7 +17,7 @@
> #include <asm/processor.h>
> #include <asm/cputable.h>
> #include <asm/ppc_asm.h>
> -#include <asm/mmu-book3e.h>
> +#include <asm/nohash/mmu-book3e.h>
> #include <asm/asm-offsets.h>
> #include <asm/mpc85xx.h>
>
> diff --git a/arch/powerpc/kvm/e500.h b/arch/powerpc/kvm/e500.h
> index 94f04fcb373e..962ee90a0dfe 100644
> --- a/arch/powerpc/kvm/e500.h
> +++ b/arch/powerpc/kvm/e500.h
> @@ -20,7 +20,7 @@
> #define KVM_E500_H
>
> #include <linux/kvm_host.h>
> -#include <asm/mmu-book3e.h>
> +#include <asm/nohash/mmu-book3e.h>
> #include <asm/tlb.h>
> #include <asm/cputhreads.h>
>
> --
> 2.13.3
^ permalink raw reply
* Re: [PATCH v5 15/22] powerpc/mm: Avoid useless lock with single page fragments
From: Aneesh Kumar K.V @ 2018-09-26 2:43 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, aneesh.kumar
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <18c62230b394eee9f49832d5dbd518ba69f39a18.1537892499.git.christophe.leroy@c-s.fr>
Christophe Leroy <christophe.leroy@c-s.fr> writes:
> There is no point in taking the page table lock as pte_frag or
> pmd_frag are always NULL when we have only one fragment.
>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> arch/powerpc/mm/pgtable-book3s64.c | 3 +++
> arch/powerpc/mm/pgtable-frag.c | 3 +++
> 2 files changed, 6 insertions(+)
>
> diff --git a/arch/powerpc/mm/pgtable-book3s64.c b/arch/powerpc/mm/pgtable-book3s64.c
> index 723cd324fa34..c43e225e124d 100644
> --- a/arch/powerpc/mm/pgtable-book3s64.c
> +++ b/arch/powerpc/mm/pgtable-book3s64.c
> @@ -239,6 +239,9 @@ static pmd_t *get_pmd_from_cache(struct mm_struct *mm)
> {
> void *pmd_frag, *ret;
>
> + if (PMD_FRAG_NR == 1)
> + return NULL;
> +
> spin_lock(&mm->page_table_lock);
> ret = mm->context.pmd_frag;
> if (ret) {
> diff --git a/arch/powerpc/mm/pgtable-frag.c b/arch/powerpc/mm/pgtable-frag.c
> index d61e7c2a9a79..7544d0d7177d 100644
> --- a/arch/powerpc/mm/pgtable-frag.c
> +++ b/arch/powerpc/mm/pgtable-frag.c
> @@ -34,6 +34,9 @@ static pte_t *get_pte_from_cache(struct mm_struct *mm)
> {
> void *pte_frag, *ret;
>
> + if (PTE_FRAG_NR == 1)
> + return NULL;
> +
> spin_lock(&mm->page_table_lock);
> ret = mm->context.pte_frag;
> if (ret) {
> --
> 2.13.3
^ permalink raw reply
* Re: [PATCH v5 14/22] powerpc/mm: Move pte_fragment_alloc() to a common location
From: Aneesh Kumar K.V @ 2018-09-26 2:43 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, aneesh.kumar
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <de995657691084fe1b8a5c31393a82e52604def8.1537892499.git.christophe.leroy@c-s.fr>
Christophe Leroy <christophe.leroy@c-s.fr> writes:
> In preparation of next patch which generalises the use of
> pte_fragment_alloc() for all, this patch moves the related functions
> in a place that is common to all subarches.
>
> The 8xx will need that for supporting 16k pages, as in that mode
> page tables still have a size of 4k.
>
> Since pte_fragment with only once fragment is not different
> from what is done in the general case, we can easily migrate all
> subarchs to pte fragments.
>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> arch/powerpc/include/asm/book3s/64/pgalloc.h | 1 +
> arch/powerpc/mm/Makefile | 4 +-
> arch/powerpc/mm/mmu_context_book3s64.c | 15 ----
> arch/powerpc/mm/pgtable-book3s64.c | 85 --------------------
> arch/powerpc/mm/pgtable-frag.c | 116 +++++++++++++++++++++++++++
> 5 files changed, 120 insertions(+), 101 deletions(-)
> create mode 100644 arch/powerpc/mm/pgtable-frag.c
>
> diff --git a/arch/powerpc/include/asm/book3s/64/pgalloc.h b/arch/powerpc/include/asm/book3s/64/pgalloc.h
> index bfed4cf3b2f3..6c2808c0f052 100644
> --- a/arch/powerpc/include/asm/book3s/64/pgalloc.h
> +++ b/arch/powerpc/include/asm/book3s/64/pgalloc.h
> @@ -39,6 +39,7 @@ extern struct vmemmap_backing *vmemmap_list;
> extern struct kmem_cache *pgtable_cache[];
> #define PGT_CACHE(shift) pgtable_cache[shift]
>
> +void pte_frag_destroy(void *pte_frag);
> extern pte_t *pte_fragment_alloc(struct mm_struct *, unsigned long, int);
> extern pmd_t *pmd_fragment_alloc(struct mm_struct *, unsigned long);
> extern void pte_fragment_free(unsigned long *, int);
> diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile
> index d0c1ce1297e3..db2f001183d1 100644
> --- a/arch/powerpc/mm/Makefile
> +++ b/arch/powerpc/mm/Makefile
> @@ -15,7 +15,9 @@ obj-$(CONFIG_PPC_MMU_NOHASH) += mmu_context_nohash.o tlb_nohash.o \
> obj-$(CONFIG_PPC_BOOK3E) += tlb_low_$(BITS)e.o
> hash64-$(CONFIG_PPC_NATIVE) := hash_native_64.o
> obj-$(CONFIG_PPC_BOOK3E_64) += pgtable-book3e.o
> -obj-$(CONFIG_PPC_BOOK3S_64) += pgtable-hash64.o hash_utils_64.o slb.o $(hash64-y) mmu_context_book3s64.o pgtable-book3s64.o
> +obj-$(CONFIG_PPC_BOOK3S_64) += pgtable-hash64.o hash_utils_64.o slb.o \
> + $(hash64-y) mmu_context_book3s64.o \
> + pgtable-book3s64.o pgtable-frag.o
> obj-$(CONFIG_PPC_RADIX_MMU) += pgtable-radix.o tlb-radix.o
> obj-$(CONFIG_PPC_STD_MMU_32) += ppc_mmu_32.o hash_low_32.o mmu_context_hash32.o
> obj-$(CONFIG_PPC_STD_MMU) += tlb_hash$(BITS).o
> diff --git a/arch/powerpc/mm/mmu_context_book3s64.c b/arch/powerpc/mm/mmu_context_book3s64.c
> index 510f103d7813..f720c5cc0b5e 100644
> --- a/arch/powerpc/mm/mmu_context_book3s64.c
> +++ b/arch/powerpc/mm/mmu_context_book3s64.c
> @@ -164,21 +164,6 @@ static void destroy_contexts(mm_context_t *ctx)
> }
> }
>
> -static void pte_frag_destroy(void *pte_frag)
> -{
> - int count;
> - struct page *page;
> -
> - page = virt_to_page(pte_frag);
> - /* drop all the pending references */
> - count = ((unsigned long)pte_frag & ~PAGE_MASK) >> PTE_FRAG_SIZE_SHIFT;
> - /* We allow PTE_FRAG_NR fragments from a PTE page */
> - if (atomic_sub_and_test(PTE_FRAG_NR - count, &page->pt_frag_refcount)) {
> - pgtable_page_dtor(page);
> - __free_page(page);
> - }
> -}
> -
> static void pmd_frag_destroy(void *pmd_frag)
> {
> int count;
> diff --git a/arch/powerpc/mm/pgtable-book3s64.c b/arch/powerpc/mm/pgtable-book3s64.c
> index 01d7c0f7c4f0..723cd324fa34 100644
> --- a/arch/powerpc/mm/pgtable-book3s64.c
> +++ b/arch/powerpc/mm/pgtable-book3s64.c
> @@ -317,91 +317,6 @@ void pmd_fragment_free(unsigned long *pmd)
> }
> }
>
> -static pte_t *get_pte_from_cache(struct mm_struct *mm)
> -{
> - void *pte_frag, *ret;
> -
> - spin_lock(&mm->page_table_lock);
> - ret = mm->context.pte_frag;
> - if (ret) {
> - pte_frag = ret + PTE_FRAG_SIZE;
> - /*
> - * If we have taken up all the fragments mark PTE page NULL
> - */
> - if (((unsigned long)pte_frag & ~PAGE_MASK) == 0)
> - pte_frag = NULL;
> - mm->context.pte_frag = pte_frag;
> - }
> - spin_unlock(&mm->page_table_lock);
> - return (pte_t *)ret;
> -}
> -
> -static pte_t *__alloc_for_ptecache(struct mm_struct *mm, int kernel)
> -{
> - void *ret = NULL;
> - struct page *page;
> -
> - if (!kernel) {
> - page = alloc_page(PGALLOC_GFP | __GFP_ACCOUNT);
> - if (!page)
> - return NULL;
> - if (!pgtable_page_ctor(page)) {
> - __free_page(page);
> - return NULL;
> - }
> - } else {
> - page = alloc_page(PGALLOC_GFP);
> - if (!page)
> - return NULL;
> - }
> -
> - atomic_set(&page->pt_frag_refcount, 1);
> -
> - ret = page_address(page);
> - /*
> - * if we support only one fragment just return the
> - * allocated page.
> - */
> - if (PTE_FRAG_NR == 1)
> - return ret;
> - spin_lock(&mm->page_table_lock);
> - /*
> - * If we find pgtable_page set, we return
> - * the allocated page with single fragement
> - * count.
> - */
> - if (likely(!mm->context.pte_frag)) {
> - atomic_set(&page->pt_frag_refcount, PTE_FRAG_NR);
> - mm->context.pte_frag = ret + PTE_FRAG_SIZE;
> - }
> - spin_unlock(&mm->page_table_lock);
> -
> - return (pte_t *)ret;
> -}
> -
> -pte_t *pte_fragment_alloc(struct mm_struct *mm, unsigned long vmaddr, int kernel)
> -{
> - pte_t *pte;
> -
> - pte = get_pte_from_cache(mm);
> - if (pte)
> - return pte;
> -
> - return __alloc_for_ptecache(mm, kernel);
> -}
> -
> -void pte_fragment_free(unsigned long *table, int kernel)
> -{
> - struct page *page = virt_to_page(table);
> -
> - BUG_ON(atomic_read(&page->pt_frag_refcount) <= 0);
> - if (atomic_dec_and_test(&page->pt_frag_refcount)) {
> - if (!kernel)
> - pgtable_page_dtor(page);
> - __free_page(page);
> - }
> -}
> -
> static inline void pgtable_free(void *table, int index)
> {
> switch (index) {
> diff --git a/arch/powerpc/mm/pgtable-frag.c b/arch/powerpc/mm/pgtable-frag.c
> new file mode 100644
> index 000000000000..d61e7c2a9a79
> --- /dev/null
> +++ b/arch/powerpc/mm/pgtable-frag.c
> @@ -0,0 +1,116 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +/*
> + * Handling Page Tables through page fragments
> + *
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/gfp.h>
> +#include <linux/mm.h>
> +#include <linux/percpu.h>
> +#include <linux/hardirq.h>
> +#include <linux/hugetlb.h>
> +#include <asm/pgalloc.h>
> +#include <asm/tlbflush.h>
> +#include <asm/tlb.h>
> +
> +void pte_frag_destroy(void *pte_frag)
> +{
> + int count;
> + struct page *page;
> +
> + page = virt_to_page(pte_frag);
> + /* drop all the pending references */
> + count = ((unsigned long)pte_frag & ~PAGE_MASK) >> PTE_FRAG_SIZE_SHIFT;
> + /* We allow PTE_FRAG_NR fragments from a PTE page */
> + if (atomic_sub_and_test(PTE_FRAG_NR - count, &page->pt_frag_refcount)) {
> + pgtable_page_dtor(page);
> + __free_page(page);
> + }
> +}
> +
> +static pte_t *get_pte_from_cache(struct mm_struct *mm)
> +{
> + void *pte_frag, *ret;
> +
> + spin_lock(&mm->page_table_lock);
> + ret = mm->context.pte_frag;
> + if (ret) {
> + pte_frag = ret + PTE_FRAG_SIZE;
> + /*
> + * If we have taken up all the fragments mark PTE page NULL
> + */
> + if (((unsigned long)pte_frag & ~PAGE_MASK) == 0)
> + pte_frag = NULL;
> + mm->context.pte_frag = pte_frag;
> + }
> + spin_unlock(&mm->page_table_lock);
> + return (pte_t *)ret;
> +}
> +
> +static pte_t *__alloc_for_ptecache(struct mm_struct *mm, int kernel)
> +{
> + void *ret = NULL;
> + struct page *page;
> +
> + if (!kernel) {
> + page = alloc_page(PGALLOC_GFP | __GFP_ACCOUNT);
> + if (!page)
> + return NULL;
> + if (!pgtable_page_ctor(page)) {
> + __free_page(page);
> + return NULL;
> + }
> + } else {
> + page = alloc_page(PGALLOC_GFP);
> + if (!page)
> + return NULL;
> + }
> +
> + atomic_set(&page->pt_frag_refcount, 1);
> +
> + ret = page_address(page);
> + /*
> + * if we support only one fragment just return the
> + * allocated page.
> + */
> + if (PTE_FRAG_NR == 1)
> + return ret;
> + spin_lock(&mm->page_table_lock);
> + /*
> + * If we find pgtable_page set, we return
> + * the allocated page with single fragement
> + * count.
> + */
> + if (likely(!mm->context.pte_frag)) {
> + atomic_set(&page->pt_frag_refcount, PTE_FRAG_NR);
> + mm->context.pte_frag = ret + PTE_FRAG_SIZE;
> + }
> + spin_unlock(&mm->page_table_lock);
> +
> + return (pte_t *)ret;
> +}
> +
> +pte_t *pte_fragment_alloc(struct mm_struct *mm, unsigned long vmaddr, int kernel)
> +{
> + pte_t *pte;
> +
> + pte = get_pte_from_cache(mm);
> + if (pte)
> + return pte;
> +
> + return __alloc_for_ptecache(mm, kernel);
> +}
> +
> +void pte_fragment_free(unsigned long *table, int kernel)
> +{
> + struct page *page = virt_to_page(table);
> +
> + BUG_ON(atomic_read(&page->pt_frag_refcount) <= 0);
> + if (atomic_dec_and_test(&page->pt_frag_refcount)) {
> + if (!kernel)
> + pgtable_page_dtor(page);
> + __free_page(page);
> + }
> +}
> --
> 2.13.3
^ permalink raw reply
* Re: [PATCH v8 0/3] powerpc: Detection and scheduler optimization for POWER9 bigcore
From: Dave Hansen @ 2018-09-25 22:16 UTC (permalink / raw)
To: ego
Cc: Aneesh Kumar K.V, Srikar Dronamraju, Michael Ellerman,
Benjamin Herrenschmidt, Michael Neuling, Vaidyanathan Srinivasan,
Akshay Adiga, Shilpasri G Bhat, Oliver O'Halloran,
Nicholas Piggin, Murilo Opsfelder Araujo, Anton Blanchard,
linuxppc-dev, linux-kernel
In-Reply-To: <20180922110340.GA1402@in.ibm.com>
On 09/22/2018 04:03 AM, Gautham R Shenoy wrote:
> Without this patchset, the SMT domain would be defined as the group of
> threads that share L2 cache.
Could you try to make a more clear, concise statement about the current
state of the art vs. what you want it to be? Right now, the sched
domains do something like this in terms of ordering:
1. SMT siblings
2. Caches
3. NUMA
It sounds like you don't want SMT siblings to be the things that we use,
right? Because some siblings share caches and some do not. Right? You
want something like this:
1. SMT siblings (sharing L1)
2. SMT siblings (sharing L2)
3. Other caches
4. NUMA
^ permalink raw reply
* Re: [PATCH 1/2] soc: fsl: qbman: qman_portal: defer probing when qman is not available
From: Li Yang @ 2018-09-25 22:11 UTC (permalink / raw)
To: Olof Johansson
Cc: alexandre.belloni, Roy Pledge, linuxppc-dev,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE, lkml
In-Reply-To: <CAOesGMjDKKSNVccu4D579SiwL9zEU7ha7HQCHncvh2r4kpO6fQ@mail.gmail.com>
On Tue, Sep 25, 2018 at 2:47 PM Olof Johansson <olof@lixom.net> wrote:
>
> Hi,
>
>
> On Thu, Aug 23, 2018 at 11:36 PM Alexandre Belloni
> <alexandre.belloni@bootlin.com> wrote:
> >
> > If the qman driver (qman_ccsr) doesn't probe or fail to probe before
> > qman_portal, qm_ccsr_start will be either NULL or a stale pointer to an
> > unmapped page.
> >
> > This leads to a crash when probing qman_portal as the init_pcfg function
> > calls qman_liodn_fixup that tries to read qman registers.
> >
> > Assume that qman didn't probe when the pool mask is 0.
> >
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > ---
> > drivers/soc/fsl/qbman/qman_portal.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c
> > index a120002b630e..4fc80d2c8feb 100644
> > --- a/drivers/soc/fsl/qbman/qman_portal.c
> > +++ b/drivers/soc/fsl/qbman/qman_portal.c
> > @@ -277,6 +277,8 @@ static int qman_portal_probe(struct platform_device *pdev)
> > }
> >
> > pcfg->pools = qm_get_pools_sdqcr();
> > + if (pcfg->pools == 0)
> > + return -EPROBE_DEFER;
>
> This is quite late in the probe, after a bunch of resources have been claimed.
>
> Note that the ioremaps above this are doing unwinds, and you'll end up
> doing duplicate ioremaps if you come in and probe again.
>
> You should probably unwind those allocations, or move them to devm_*
> or do this check earlier in the function.
Hi Roy,
Is there any more straightforward indicator on if qman has been
probed? So that we can check it at the begining of the probe?
Regards,
Leo
^ permalink raw reply
* Re: [PATCH 4/4] dma-mapping: clear dev->dma_ops in arch_teardown_dma_ops
From: Christoph Hellwig @ 2018-09-25 20:16 UTC (permalink / raw)
To: Guenter Roeck
Cc: Christoph Hellwig, iommu, Greg Kroah-Hartman, Robin Murphy,
linux-kernel, linux-arm-kernel, Marek Szyprowski, Bjorn Helgaas,
linux-pci, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, linuxppc-dev
In-Reply-To: <20180922150119.GA14761@roeck-us.net>
Looking at the code I think this commit is simply broken for
architectures not using arch_setup_dma_ops, but instead setting up
the dma ops through arch specific magic.
I'll revert the patch.
^ permalink raw reply
* Re: [PATCH 1/2] soc: fsl: qbman: qman_portal: defer probing when qman is not available
From: Olof Johansson @ 2018-09-25 19:45 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Li Yang, Roy Pledge, linuxppc-dev, Linux ARM Mailing List,
Linux Kernel Mailing List
In-Reply-To: <20180823213600.23426-1-alexandre.belloni@bootlin.com>
Hi,
On Thu, Aug 23, 2018 at 11:36 PM Alexandre Belloni
<alexandre.belloni@bootlin.com> wrote:
>
> If the qman driver (qman_ccsr) doesn't probe or fail to probe before
> qman_portal, qm_ccsr_start will be either NULL or a stale pointer to an
> unmapped page.
>
> This leads to a crash when probing qman_portal as the init_pcfg function
> calls qman_liodn_fixup that tries to read qman registers.
>
> Assume that qman didn't probe when the pool mask is 0.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
> drivers/soc/fsl/qbman/qman_portal.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c
> index a120002b630e..4fc80d2c8feb 100644
> --- a/drivers/soc/fsl/qbman/qman_portal.c
> +++ b/drivers/soc/fsl/qbman/qman_portal.c
> @@ -277,6 +277,8 @@ static int qman_portal_probe(struct platform_device *pdev)
> }
>
> pcfg->pools = qm_get_pools_sdqcr();
> + if (pcfg->pools == 0)
> + return -EPROBE_DEFER;
This is quite late in the probe, after a bunch of resources have been claimed.
Note that the ioremaps above this are doing unwinds, and you'll end up
doing duplicate ioremaps if you come in and probe again.
You should probably unwind those allocations, or move them to devm_*
or do this check earlier in the function.
-Olof
^ permalink raw reply
* Re: [RFC PATCH v1 1/9] timer: fix circular header dependency
From: Christophe Leroy @ 2018-09-25 17:48 UTC (permalink / raw)
To: Mark Rutland
Cc: Stephen Boyd, linux-kernel, npiggin, Paul Mackerras, aneesh.kumar,
linux-fsdevel, John Stultz, Thomas Gleixner, linuxppc-dev,
Alexander Viro
In-Reply-To: <d22dc0e6-13ff-2abe-6536-a7b14bb285db@c-s.fr>
On 09/25/2018 12:15 PM, Christophe LEROY wrote:
>
>
> Le 25/09/2018 à 14:11, Mark Rutland a écrit :
>> On Tue, Sep 25, 2018 at 07:34:15AM +0200, Christophe LEROY wrote:
>>>
>>>
>>> Le 24/09/2018 à 17:52, Christophe Leroy a écrit :
>>>> When switching powerpc to CONFIG_THREAD_INFO_IN_TASK, include/sched.h
>>>> has to be included in asm/smp.h for the following change, in order
>>>> to avoid uncomplete definition of task_struct:
>>>>
>>>> -#define raw_smp_processor_id() (current_thread_info()->cpu)
>>>> +#define raw_smp_processor_id() (current->cpu)
>>>>
>>>> But this generates the following compilation error, due to circular
>>>> header dependency.
>>>>
>>>> CC kernel/time/alarmtimer.o
>>>> In file included from ./arch/powerpc/include/asm/smp.h:31,
>>>> from ./include/linux/smp.h:64,
>>>> from ./include/linux/percpu.h:7,
>>>> from ./include/linux/hrtimer.h:22,
>>>> from kernel/time/alarmtimer.c:19:
>>>> ./include/linux/sched.h:558:19: error: field 'dl_timer' has
>>>> incomplete type
>>>> struct hrtimer dl_timer;
>>>> ^~~~~~~~
>>>> ./include/linux/sched.h:567:17: error: field 'inactive_timer' has
>>>> incomplete type
>>>> struct hrtimer inactive_timer;
>>>> ^~~~~~~~~~~~~~
>>>> make[1]: *** [kernel/time/alarmtimer.o] Error 1
>>>> make: *** [kernel/time/alarmtimer.o] Error 2
>>>>
>>>> CC fs/timerfd.o
>>>> In file included from ./arch/powerpc/include/asm/smp.h:31,
>>>> from ./include/linux/smp.h:64,
>>>> from ./include/linux/percpu.h:7,
>>>> from ./include/linux/hrtimer.h:22,
>>>> from ./include/linux/alarmtimer.h:6,
>>>> from fs/timerfd.c:12:
>>>> ./include/linux/sched.h:558:19: error: field 'dl_timer' has
>>>> incomplete type
>>>> struct hrtimer dl_timer;
>>>> ^~~~~~~~
>>>> ./include/linux/sched.h:567:17: error: field 'inactive_timer' has
>>>> incomplete type
>>>> struct hrtimer inactive_timer;
>>>> ^~~~~~~~~~~~~~
>>>> make[1]: *** [fs/timerfd.o] Error 1
>>>> make: *** [fs/timerfd.o] Error 2
>>>>
>>>> This patch fixes it by including linux/hrtimer.h after linux/sched.h
>>>>
>>>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>>>> ---
>>>> Should it be fixed in powerpc instead ? In that case, how ? Any
>>>> idea ?
>>>
>>>
>>> Looks like there are several other places where the problem occurs,
>>> so it
>>> has to be fixed in the powerpc headers instead.
>>>
>>> Seems like RISC arch faced the same issue, and fixed it the following
>>> way:
>>>
>>> /*
>>> * This is particularly ugly: it appears we can't actually get the
>>> definition
>>> * of task_struct here, but we need access to the CPU this task is
>>> running
>>> on.
>>> * Instead of using C we're using asm-offsets.h to get the current
>>> processor
>>> * ID.
>>> */
>>> #define raw_smp_processor_id() (*((int*)((char*)get_current() +
>>> TASK_TI_CPU)))
>>>
>>>
>>> Unless someone has a better idea, I'll fixed it that way.
>>
>> To solve this on arm64 we made the cpu number a percpu variable; see
>> commit:
>>
>> 57c82954e77fa12c ("arm64: make cpu number a percpu variable")
>
> Thanks, I'll have a look
>
>> IIUC, you could do that by placing it in paca_struct.
>
> By the way, it is already in PACA struct for PPC64.
> The issue is with PPC32, up to now it was in current_thread_info:
>
> #ifdef CONFIG_PPC64
> #define raw_smp_processor_id() (local_paca->paca_index)
> #define hard_smp_processor_id() (get_paca()->hw_cpu_id)
> #else
> /* 32-bit */
> extern int smp_hw_index[];
>
> #define raw_smp_processor_id() (current_thread_info()->cpu)
> #define hard_smp_processor_id() (smp_hw_index[smp_processor_id()])
>
> [..]
>
> #endif
>
It seems not that easy. Adding the following leads to the below failure.
I'm having a hard time identifying and fixing the issue. Looks again
like a circular thing, because linux/percpu-defs.h is where
raw_cpu_ptr() is defined.
--- a/arch/powerpc/include/asm/smp.h
+++ b/arch/powerpc/include/asm/smp.h
@@ -83,7 +83,14 @@ int is_cpu_dead(unsigned int cpu);
/* 32-bit */
extern int smp_hw_index[];
-#define raw_smp_processor_id() (current_thread_info()->cpu)
+DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
+
+/*
+ * We don't use this_cpu_read(cpu_number) as that has implicit writes to
+ * preempt_count, and associated (compiler) barriers, that we'd like to
avoid
+ * the expense of. If we're preemptible, the value can be stale at use
anyway.
+ */
+#define raw_smp_processor_id() (*this_cpu_ptr(&cpu_number))
#define hard_smp_processor_id() (smp_hw_index[smp_processor_id()])
static inline int get_hard_smp_processor_id(int cpu)
CC arch/powerpc/kernel/asm-offsets.s
In file included from ././include/linux/compiler_types.h:64:0,
from <command-line>:0:
./include/linux/percpu-rwsem.h: In function
'percpu_down_read_preempt_disable':
./include/linux/percpu-defs.h:254:27: error: implicit declaration of
function 'raw_cpu_ptr' [-Werror=implicit-function-declaration]
#define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
^
./include/linux/compiler-gcc.h:58:26: note: in definition of macro
'RELOC_HIDE'
(typeof(ptr)) (__ptr + (off)); \
^
./include/asm-generic/percpu.h:44:31: note: in expansion of macro
'SHIFT_PERCPU_PTR'
#define arch_raw_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset)
^
./include/asm-generic/percpu.h:31:25: note: in expansion of macro
'per_cpu_offset'
#define __my_cpu_offset per_cpu_offset(raw_smp_processor_id())
^
./arch/powerpc/include/asm/smp.h:93:35: note: in expansion of macro
'this_cpu_ptr'
#define raw_smp_processor_id() (*this_cpu_ptr(&cpu_number))
^
./include/asm-generic/percpu.h:31:40: note: in expansion of macro
'raw_smp_processor_id'
#define __my_cpu_offset per_cpu_offset(raw_smp_processor_id())
^
./include/asm-generic/percpu.h:44:53: note: in expansion of macro
'__my_cpu_offset'
#define arch_raw_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset)
^
./include/linux/percpu-defs.h:244:2: note: in expansion of macro
'arch_raw_cpu_ptr'
arch_raw_cpu_ptr(ptr); \
^
./include/asm-generic/percpu.h:76:3: note: in expansion of macro
'raw_cpu_ptr'
*raw_cpu_ptr(&(pcp)) op val; \
^
./include/asm-generic/percpu.h:225:34: note: in expansion of macro
'raw_cpu_generic_to_op'
#define raw_cpu_add_1(pcp, val) raw_cpu_generic_to_op(pcp, val, +=)
^
./include/linux/percpu-defs.h:379:11: note: in expansion of macro
'raw_cpu_add_1'
case 1: stem##1(variable, __VA_ARGS__);break; \
^
./include/linux/percpu-defs.h:424:32: note: in expansion of macro
'__pcpu_size_call'
#define raw_cpu_add(pcp, val) __pcpu_size_call(raw_cpu_add_, pcp, val)
^
./include/linux/percpu-defs.h:460:2: note: in expansion of macro
'raw_cpu_add'
raw_cpu_add(pcp, val); \
^
./include/linux/percpu-defs.h:499:30: note: in expansion of macro
'__this_cpu_add'
#define __this_cpu_inc(pcp) __this_cpu_add(pcp, 1)
^
./include/linux/percpu-rwsem.h:47:2: note: in expansion of macro
'__this_cpu_inc'
__this_cpu_inc(*sem->read_count);
^
./arch/powerpc/include/asm/smp.h:93:34: error: invalid type argument of
unary '*' (have 'int')
#define raw_smp_processor_id() (*this_cpu_ptr(&cpu_number))
^
[...]
^ permalink raw reply
* [PATCH v5 22/22] powerpc/8xx: set GUARDED attribute in the PMD directly
From: Christophe Leroy @ 2018-09-25 16:51 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
aneesh.kumar
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1537892498.git.christophe.leroy@c-s.fr>
On the 8xx, the GUARDED attribute of the pages is managed in the
L1 entry, therefore to avoid having to copy it into L1 entry
at each TLB miss, we set it in the PMD.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/nohash/32/pte-8xx.h | 3 ++-
arch/powerpc/kernel/head_8xx.S | 9 ---------
arch/powerpc/platforms/Kconfig.cputype | 1 +
3 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/arch/powerpc/include/asm/nohash/32/pte-8xx.h b/arch/powerpc/include/asm/nohash/32/pte-8xx.h
index 8c9872d93257..20d4c1c04726 100644
--- a/arch/powerpc/include/asm/nohash/32/pte-8xx.h
+++ b/arch/powerpc/include/asm/nohash/32/pte-8xx.h
@@ -62,10 +62,11 @@
#define _PMD_PRESENT 0x0001
#define _PMD_PRESENT_MASK _PMD_PRESENT
-#define _PMD_BAD 0x0fd0
+#define _PMD_BAD 0x0fc0
#define _PMD_PAGE_MASK 0x000c
#define _PMD_PAGE_8M 0x000c
#define _PMD_PAGE_512K 0x0004
+#define _PMD_GUARDED 0x0010
#define _PMD_USER 0x0020 /* APG 1 */
#define _PTE_NONE_MASK 0
diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
index 3e38af7489a9..89974c938617 100644
--- a/arch/powerpc/kernel/head_8xx.S
+++ b/arch/powerpc/kernel/head_8xx.S
@@ -452,15 +452,6 @@ DataStoreTLBMiss:
mfspr r10, SPRN_MD_TWC
lwz r10, 0(r10) /* Get the pte */
- /* Insert the Guarded flag into the TWC from the Linux PTE.
- * It is bit 27 of both the Linux PTE and the TWC (at least
- * I got that right :-). It will be better when we can put
- * this into the Linux pgd/pmd and load it in the operation
- * above.
- */
- rlwimi r11, r10, 0, _PAGE_GUARDED
- mtspr SPRN_MD_TWC, r11
-
/* Both _PAGE_ACCESSED and _PAGE_PRESENT has to be set.
* We also need to know if the insn is a load/store, so:
* Clear _PAGE_PRESENT and load that which will
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index d0984546fbec..c92d084a5a23 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -34,6 +34,7 @@ config PPC_8xx
bool "Freescale 8xx"
select FSL_SOC
select SYS_SUPPORTS_HUGETLBFS
+ select PPC_PMD_GUARDED
config 40x
bool "AMCC 40x"
--
2.13.3
^ 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