arch_randomize_brk() is only needed for hash on book3s/64, for other
platforms the one provided by the default mmap layout is good enough.
Move it to hash_utils.c and use randomize_page() like the generic one.
And properly opt out the radix case instead of making an assumption
on mmu_highuser_ssize.
Also change to a 32M range like most other architectures instead of 8M.
Signed-off-by: Christophe Leroy <redacted>
---
Applies on top of series "powerpc: Make hash MMU code build configurable"
arch/powerpc/kernel/process.c | 41 ---------------------------
arch/powerpc/mm/book3s64/hash_utils.c | 19 +++++++++++++
2 files changed, 19 insertions(+), 41 deletions(-)
@@ -2313,42 +2311,3 @@ unsigned long arch_align_stack(unsigned long sp)sp-=get_random_int()&~PAGE_MASK;returnsp&~0xf;}--staticinlineunsignedlongbrk_rnd(void)-{-unsignedlongrnd=0;--/* 8MB for 32bit, 1GB for 64bit */-if(is_32bit_task())-rnd=(get_random_long()%(1UL<<(23-PAGE_SHIFT)));-else-rnd=(get_random_long()%(1UL<<(30-PAGE_SHIFT)));--returnrnd<<PAGE_SHIFT;-}--unsignedlongarch_randomize_brk(structmm_struct*mm)-{-unsignedlongbase=mm->brk;-unsignedlongret;--#ifdef CONFIG_PPC_BOOK3S_64-/*-*Ifweareusing1TBsegmentsandweareallowedtorandomise-*theheap,wecanputitabove1TBsoitisbackedbya1TB-*segment.Otherwisetheheapwillbeinthebottom1TB-*whichalwaysuses256MBsegmentsandthismayresultina-*performancepenalty.-*/-if(!radix_enabled()&&!is_32bit_task()&&(mmu_highuser_ssize==MMU_SEGSIZE_1T))-base=max_t(unsignedlong,mm->brk,1UL<<SID_SHIFT_1T);-#endif--ret=PAGE_ALIGN(base+brk_rnd());--if(ret<mm->brk)-returnmm->brk;--returnret;-}-
From: Krzysztof Wilczyński <hidden> Date: 2021-12-08 21:19:20
Hello Christophe,
Today drivers/pci/controller/pci-xgene.c defines SZ_1T
Move it into linux/sizes.h so that it can be re-used elsewhere.
Sounds like a good idea!
By the way, there was an earlier version of this patch, did something
happened? I think you simply extracted these changes from the other
series, correct?
On Wed, Dec 08, 2021 at 02:32:42PM +0000, Christophe Leroy wrote:
Today drivers/pci/controller/pci-xgene.c defines SZ_1T
Move it into linux/sizes.h so that it can be re-used elsewhere.
Cc: Toan Le <toan@os.amperecomputing.com>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Christophe Leroy <redacted>
I guess this needs to go with the [2/2] patch, since it also uses
SZ_1T.
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Le 08/12/2021 à 22:19, Krzysztof Wilczyński a écrit :
Hello Christophe,
quoted
Today drivers/pci/controller/pci-xgene.c defines SZ_1T
Move it into linux/sizes.h so that it can be re-used elsewhere.
Sounds like a good idea!
By the way, there was an earlier version of this patch, did something
happened? I think you simply extracted these changes from the other
series, correct?
arch_randomize_brk() is only needed for hash on book3s/64, for other
platforms the one provided by the default mmap layout is good enough.
Move it to hash_utils.c and use randomize_page() like the generic one.
And properly opt out the radix case instead of making an assumption
on mmu_highuser_ssize.
Also change to a 32M range like most other architectures instead of 8M.
Signed-off-by: Christophe Leroy <redacted>
---
Applies on top of series "powerpc: Make hash MMU code build configurable"
I was obviously dreaming when I sent this patch.
It definitely requires CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT so
should come at the end of the other series.
@@ -2313,42 +2311,3 @@ unsigned long arch_align_stack(unsigned long sp)sp-=get_random_int()&~PAGE_MASK;returnsp&~0xf;}--staticinlineunsignedlongbrk_rnd(void)-{-unsignedlongrnd=0;--/* 8MB for 32bit, 1GB for 64bit */-if(is_32bit_task())-rnd=(get_random_long()%(1UL<<(23-PAGE_SHIFT)));-else-rnd=(get_random_long()%(1UL<<(30-PAGE_SHIFT)));--returnrnd<<PAGE_SHIFT;-}--unsignedlongarch_randomize_brk(structmm_struct*mm)-{-unsignedlongbase=mm->brk;-unsignedlongret;--#ifdef CONFIG_PPC_BOOK3S_64-/*-*Ifweareusing1TBsegmentsandweareallowedtorandomise-*theheap,wecanputitabove1TBsoitisbackedbya1TB-*segment.Otherwisetheheapwillbeinthebottom1TB-*whichalwaysuses256MBsegmentsandthismayresultina-*performancepenalty.-*/-if(!radix_enabled()&&!is_32bit_task()&&(mmu_highuser_ssize==MMU_SEGSIZE_1T))-base=max_t(unsignedlong,mm->brk,1UL<<SID_SHIFT_1T);-#endif--ret=PAGE_ALIGN(base+brk_rnd());--if(ret<mm->brk)-returnmm->brk;--returnret;-}-