LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* 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 14/30] memblock: add align parameter to memblock_alloc_node()
From: Michal Hocko @ 2018-09-26  9:31 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-15-git-send-email-rppt@linux.vnet.ibm.com>

On Fri 14-09-18 15:10:29, Mike Rapoport wrote:
> With the align parameter memblock_alloc_node() can be used as drop in
> replacement for alloc_bootmem_pages_node() and __alloc_bootmem_node(),
> which is done in the following patches.

/me confused. Why do we need this patch at all? Maybe it should be
folded into the later patch you are refereing here?

> Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
> ---
>  include/linux/bootmem.h | 4 ++--
>  mm/sparse.c             | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
> index 7d91f0f..3896af2 100644
> --- a/include/linux/bootmem.h
> +++ b/include/linux/bootmem.h
> @@ -157,9 +157,9 @@ static inline void * __init memblock_alloc_from_nopanic(
>  }
>  
>  static inline void * __init memblock_alloc_node(
> -						phys_addr_t size, int nid)
> +		phys_addr_t size, phys_addr_t align, int nid)
>  {
> -	return memblock_alloc_try_nid(size, 0, BOOTMEM_LOW_LIMIT,
> +	return memblock_alloc_try_nid(size, align, BOOTMEM_LOW_LIMIT,
>  					    BOOTMEM_ALLOC_ACCESSIBLE, nid);
>  }
>  
> diff --git a/mm/sparse.c b/mm/sparse.c
> index 04e97af..509828f 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -68,7 +68,7 @@ static noinline struct mem_section __ref *sparse_index_alloc(int nid)
>  	if (slab_is_available())
>  		section = kzalloc_node(array_size, GFP_KERNEL, nid);
>  	else
> -		section = memblock_alloc_node(array_size, nid);
> +		section = memblock_alloc_node(array_size, 0, nid);
>  
>  	return section;
>  }
> -- 
> 2.7.4
> 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply

* Re: [PATCH 14/30] memblock: add align parameter to memblock_alloc_node()
From: Michal Hocko @ 2018-09-26  9:36 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: <20180926093127.GO6278@dhcp22.suse.cz>

On Wed 26-09-18 11:31:27, Michal Hocko wrote:
> On Fri 14-09-18 15:10:29, Mike Rapoport wrote:
> > With the align parameter memblock_alloc_node() can be used as drop in
> > replacement for alloc_bootmem_pages_node() and __alloc_bootmem_node(),
> > which is done in the following patches.
> 
> /me confused. Why do we need this patch at all? Maybe it should be
> folded into the later patch you are refereing here?

OK, I can see 1536927045-23536-17-git-send-email-rppt@linux.vnet.ibm.com
now. If you are going to repost for whatever reason please merge those
two. Also I would get rid of the implicit "0 implies SMP_CACHE_BYTES"
behavior. It is subtle and you have to dig deep to find that out. Why
not make it explicit?
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply

* Re: [PATCH 16/30] memblock: replace __alloc_bootmem_node with appropriate memblock_ API
From: Michal Hocko @ 2018-09-26  9:37 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-17-git-send-email-rppt@linux.vnet.ibm.com>

On Fri 14-09-18 15:10:31, Mike Rapoport wrote:
> Use memblock_alloc_try_nid whenever goal (i.e. minimal address is
> specified) and memblock_alloc_node otherwise.
> 
> 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 21/30] memblock: replace alloc_bootmem with memblock_alloc
From: Michal Hocko @ 2018-09-26  9:38 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-22-git-send-email-rppt@linux.vnet.ibm.com>

On Fri 14-09-18 15:10:36, Mike Rapoport wrote:
> The alloc_bootmem(size) is a shortcut for allocation of SMP_CACHE_BYTES
> aligned memory. When the align parameter of memblock_alloc() is 0, the
> alignment is implicitly set to SMP_CACHE_BYTES and thus alloc_bootmem(size)
> and memblock_alloc(size, 0) are equivalent.
> 
> The conversion is done using the following semantic patch:
> 
> @@
> expression size;
> @@
> - alloc_bootmem(size)
> + memblock_alloc(size, 0)

As mentioned in other email, please make it explicit SMP_CACHE_BYTES.

> Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
> ---
>  arch/alpha/kernel/core_marvel.c     | 4 ++--
>  arch/alpha/kernel/pci-noop.c        | 4 ++--
>  arch/alpha/kernel/pci.c             | 4 ++--
>  arch/alpha/kernel/pci_iommu.c       | 4 ++--
>  arch/ia64/kernel/mca.c              | 4 ++--
>  arch/ia64/mm/tlb.c                  | 4 ++--
>  arch/m68k/sun3/sun3dvma.c           | 3 ++-
>  arch/microblaze/mm/init.c           | 2 +-
>  arch/mips/kernel/setup.c            | 2 +-
>  arch/um/drivers/net_kern.c          | 2 +-
>  arch/um/drivers/vector_kern.c       | 2 +-
>  arch/um/kernel/initrd.c             | 2 +-
>  arch/x86/kernel/acpi/boot.c         | 3 ++-
>  arch/x86/kernel/apic/io_apic.c      | 2 +-
>  arch/x86/kernel/e820.c              | 2 +-
>  arch/x86/platform/olpc/olpc_dt.c    | 2 +-
>  arch/xtensa/platforms/iss/network.c | 2 +-
>  drivers/macintosh/smu.c             | 2 +-
>  init/main.c                         | 4 ++--
>  19 files changed, 28 insertions(+), 26 deletions(-)
> 
> diff --git a/arch/alpha/kernel/core_marvel.c b/arch/alpha/kernel/core_marvel.c
> index bdebb8c2..1f00c94 100644
> --- a/arch/alpha/kernel/core_marvel.c
> +++ b/arch/alpha/kernel/core_marvel.c
> @@ -82,7 +82,7 @@ mk_resource_name(int pe, int port, char *str)
>  	char *name;
>  	
>  	sprintf(tmp, "PCI %s PE %d PORT %d", str, pe, port);
> -	name = alloc_bootmem(strlen(tmp) + 1);
> +	name = memblock_alloc(strlen(tmp) + 1, 0);
>  	strcpy(name, tmp);
>  
>  	return name;
> @@ -117,7 +117,7 @@ alloc_io7(unsigned int pe)
>  		return NULL;
>  	}
>  
> -	io7 = alloc_bootmem(sizeof(*io7));
> +	io7 = memblock_alloc(sizeof(*io7), 0);
>  	io7->pe = pe;
>  	raw_spin_lock_init(&io7->irq_lock);
>  
> diff --git a/arch/alpha/kernel/pci-noop.c b/arch/alpha/kernel/pci-noop.c
> index c7c5879..59cbfc2 100644
> --- a/arch/alpha/kernel/pci-noop.c
> +++ b/arch/alpha/kernel/pci-noop.c
> @@ -33,7 +33,7 @@ alloc_pci_controller(void)
>  {
>  	struct pci_controller *hose;
>  
> -	hose = alloc_bootmem(sizeof(*hose));
> +	hose = memblock_alloc(sizeof(*hose), 0);
>  
>  	*hose_tail = hose;
>  	hose_tail = &hose->next;
> @@ -44,7 +44,7 @@ alloc_pci_controller(void)
>  struct resource * __init
>  alloc_resource(void)
>  {
> -	return alloc_bootmem(sizeof(struct resource));
> +	return memblock_alloc(sizeof(struct resource), 0);
>  }
>  
>  SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus,
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index c668c3b..4cc3eb9 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -392,7 +392,7 @@ alloc_pci_controller(void)
>  {
>  	struct pci_controller *hose;
>  
> -	hose = alloc_bootmem(sizeof(*hose));
> +	hose = memblock_alloc(sizeof(*hose), 0);
>  
>  	*hose_tail = hose;
>  	hose_tail = &hose->next;
> @@ -403,7 +403,7 @@ alloc_pci_controller(void)
>  struct resource * __init
>  alloc_resource(void)
>  {
> -	return alloc_bootmem(sizeof(struct resource));
> +	return memblock_alloc(sizeof(struct resource), 0);
>  }
>  
>  
> diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
> index 0c05493..5d178c7 100644
> --- a/arch/alpha/kernel/pci_iommu.c
> +++ b/arch/alpha/kernel/pci_iommu.c
> @@ -79,7 +79,7 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base,
>  		printk("%s: couldn't allocate arena from node %d\n"
>  		       "    falling back to system-wide allocation\n",
>  		       __func__, nid);
> -		arena = alloc_bootmem(sizeof(*arena));
> +		arena = memblock_alloc(sizeof(*arena), 0);
>  	}
>  
>  	arena->ptes = memblock_alloc_node(sizeof(*arena), align, nid);
> @@ -92,7 +92,7 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base,
>  
>  #else /* CONFIG_DISCONTIGMEM */
>  
> -	arena = alloc_bootmem(sizeof(*arena));
> +	arena = memblock_alloc(sizeof(*arena), 0);
>  	arena->ptes = memblock_alloc_from(mem_size, align, 0);
>  
>  #endif /* CONFIG_DISCONTIGMEM */
> diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
> index 5586926..7120976 100644
> --- a/arch/ia64/kernel/mca.c
> +++ b/arch/ia64/kernel/mca.c
> @@ -361,9 +361,9 @@ static ia64_state_log_t ia64_state_log[IA64_MAX_LOG_TYPES];
>  
>  #define IA64_LOG_ALLOCATE(it, size) \
>  	{ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)] = \
> -		(ia64_err_rec_t *)alloc_bootmem(size); \
> +		(ia64_err_rec_t *)memblock_alloc(size, 0); \
>  	ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX(it)] = \
> -		(ia64_err_rec_t *)alloc_bootmem(size);}
> +		(ia64_err_rec_t *)memblock_alloc(size, 0);}
>  #define IA64_LOG_LOCK_INIT(it) spin_lock_init(&ia64_state_log[it].isl_lock)
>  #define IA64_LOG_LOCK(it)      spin_lock_irqsave(&ia64_state_log[it].isl_lock, s)
>  #define IA64_LOG_UNLOCK(it)    spin_unlock_irqrestore(&ia64_state_log[it].isl_lock,s)
> diff --git a/arch/ia64/mm/tlb.c b/arch/ia64/mm/tlb.c
> index acf10eb..5554863 100644
> --- a/arch/ia64/mm/tlb.c
> +++ b/arch/ia64/mm/tlb.c
> @@ -59,8 +59,8 @@ struct ia64_tr_entry *ia64_idtrs[NR_CPUS];
>  void __init
>  mmu_context_init (void)
>  {
> -	ia64_ctx.bitmap = alloc_bootmem((ia64_ctx.max_ctx+1)>>3);
> -	ia64_ctx.flushmap = alloc_bootmem((ia64_ctx.max_ctx+1)>>3);
> +	ia64_ctx.bitmap = memblock_alloc((ia64_ctx.max_ctx + 1) >> 3, 0);
> +	ia64_ctx.flushmap = memblock_alloc((ia64_ctx.max_ctx + 1) >> 3, 0);
>  }
>  
>  /*
> diff --git a/arch/m68k/sun3/sun3dvma.c b/arch/m68k/sun3/sun3dvma.c
> index 8546922..72d9458 100644
> --- a/arch/m68k/sun3/sun3dvma.c
> +++ b/arch/m68k/sun3/sun3dvma.c
> @@ -267,7 +267,8 @@ void __init dvma_init(void)
>  
>  	list_add(&(hole->list), &hole_list);
>  
> -	iommu_use = alloc_bootmem(IOMMU_TOTAL_ENTRIES * sizeof(unsigned long));
> +	iommu_use = memblock_alloc(IOMMU_TOTAL_ENTRIES * sizeof(unsigned long),
> +				   0);
>  
>  	dvma_unmap_iommu(DVMA_START, DVMA_SIZE);
>  
> diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
> index df6de7c..8c7f074 100644
> --- a/arch/microblaze/mm/init.c
> +++ b/arch/microblaze/mm/init.c
> @@ -377,7 +377,7 @@ void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask)
>  	if (mem_init_done)
>  		p = kzalloc(size, mask);
>  	else {
> -		p = alloc_bootmem(size);
> +		p = memblock_alloc(size, 0);
>  		if (p)
>  			memset(p, 0, size);
>  	}
> diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
> index a717c90..a6bc2f6 100644
> --- a/arch/mips/kernel/setup.c
> +++ b/arch/mips/kernel/setup.c
> @@ -909,7 +909,7 @@ static void __init resource_init(void)
>  		if (end >= HIGHMEM_START)
>  			end = HIGHMEM_START - 1;
>  
> -		res = alloc_bootmem(sizeof(struct resource));
> +		res = memblock_alloc(sizeof(struct resource), 0);
>  
>  		res->start = start;
>  		res->end = end;
> diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
> index 3ef1b48..ef19a39 100644
> --- a/arch/um/drivers/net_kern.c
> +++ b/arch/um/drivers/net_kern.c
> @@ -650,7 +650,7 @@ static int __init eth_setup(char *str)
>  		return 1;
>  	}
>  
> -	new = alloc_bootmem(sizeof(*new));
> +	new = memblock_alloc(sizeof(*new), 0);
>  
>  	INIT_LIST_HEAD(&new->list);
>  	new->index = n;
> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> index c84133c..9d77579 100644
> --- a/arch/um/drivers/vector_kern.c
> +++ b/arch/um/drivers/vector_kern.c
> @@ -1575,7 +1575,7 @@ static int __init vector_setup(char *str)
>  				 str, error);
>  		return 1;
>  	}
> -	new = alloc_bootmem(sizeof(*new));
> +	new = memblock_alloc(sizeof(*new), 0);
>  	INIT_LIST_HEAD(&new->list);
>  	new->unit = n;
>  	new->arguments = str;
> diff --git a/arch/um/kernel/initrd.c b/arch/um/kernel/initrd.c
> index 6f6e789..844056c 100644
> --- a/arch/um/kernel/initrd.c
> +++ b/arch/um/kernel/initrd.c
> @@ -36,7 +36,7 @@ int __init read_initrd(void)
>  		return 0;
>  	}
>  
> -	area = alloc_bootmem(size);
> +	area = memblock_alloc(size, 0);
>  
>  	if (load_initrd(initrd, area, size) == -1)
>  		return 0;
> diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
> index 3b20607..fd887c1 100644
> --- a/arch/x86/kernel/acpi/boot.c
> +++ b/arch/x86/kernel/acpi/boot.c
> @@ -932,7 +932,8 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table)
>  	 * the resource tree during the lateinit timeframe.
>  	 */
>  #define HPET_RESOURCE_NAME_SIZE 9
> -	hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
> +	hpet_res = memblock_alloc(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE,
> +				  0);
>  
>  	hpet_res->name = (void *)&hpet_res[1];
>  	hpet_res->flags = IORESOURCE_MEM;
> diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
> index e25118f..8c74509 100644
> --- a/arch/x86/kernel/apic/io_apic.c
> +++ b/arch/x86/kernel/apic/io_apic.c
> @@ -2578,7 +2578,7 @@ static struct resource * __init ioapic_setup_resources(void)
>  	n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource);
>  	n *= nr_ioapics;
>  
> -	mem = alloc_bootmem(n);
> +	mem = memblock_alloc(n, 0);
>  	res = (void *)mem;
>  
>  	mem += sizeof(struct resource) * nr_ioapics;
> diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
> index c88c23c..7ea8748 100644
> --- a/arch/x86/kernel/e820.c
> +++ b/arch/x86/kernel/e820.c
> @@ -1094,7 +1094,7 @@ void __init e820__reserve_resources(void)
>  	struct resource *res;
>  	u64 end;
>  
> -	res = alloc_bootmem(sizeof(*res) * e820_table->nr_entries);
> +	res = memblock_alloc(sizeof(*res) * e820_table->nr_entries, 0);
>  	e820_res = res;
>  
>  	for (i = 0; i < e820_table->nr_entries; i++) {
> diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
> index d6ee929..140cd76 100644
> --- a/arch/x86/platform/olpc/olpc_dt.c
> +++ b/arch/x86/platform/olpc/olpc_dt.c
> @@ -141,7 +141,7 @@ void * __init prom_early_alloc(unsigned long size)
>  		 * fast enough on the platforms we care about while minimizing
>  		 * wasted bootmem) and hand off chunks of it to callers.
>  		 */
> -		res = alloc_bootmem(chunk_size);
> +		res = memblock_alloc(chunk_size, 0);
>  		BUG_ON(!res);
>  		prom_early_allocated += chunk_size;
>  		memset(res, 0, chunk_size);
> diff --git a/arch/xtensa/platforms/iss/network.c b/arch/xtensa/platforms/iss/network.c
> index d027ddd..206b9d4 100644
> --- a/arch/xtensa/platforms/iss/network.c
> +++ b/arch/xtensa/platforms/iss/network.c
> @@ -646,7 +646,7 @@ static int __init iss_net_setup(char *str)
>  		return 1;
>  	}
>  
> -	new = alloc_bootmem(sizeof(*new));
> +	new = memblock_alloc(sizeof(*new), 0);
>  	if (new == NULL) {
>  		pr_err("Alloc_bootmem failed\n");
>  		return 1;
> diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
> index e8ae2e5..332fcca 100644
> --- a/drivers/macintosh/smu.c
> +++ b/drivers/macintosh/smu.c
> @@ -493,7 +493,7 @@ int __init smu_init (void)
>  		goto fail_np;
>  	}
>  
> -	smu = alloc_bootmem(sizeof(struct smu_device));
> +	smu = memblock_alloc(sizeof(struct smu_device), 0);
>  
>  	spin_lock_init(&smu->lock);
>  	INIT_LIST_HEAD(&smu->cmd_list);
> diff --git a/init/main.c b/init/main.c
> index d0b92bd..99a9e99 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -768,8 +768,8 @@ static int __init initcall_blacklist(char *str)
>  		str_entry = strsep(&str, ",");
>  		if (str_entry) {
>  			pr_debug("blacklisting initcall %s\n", str_entry);
> -			entry = alloc_bootmem(sizeof(*entry));
> -			entry->buf = alloc_bootmem(strlen(str_entry) + 1);
> +			entry = memblock_alloc(sizeof(*entry), 0);
> +			entry->buf = memblock_alloc(strlen(str_entry) + 1, 0);
>  			strcpy(entry->buf, str_entry);
>  			list_add(&entry->next, &blacklisted_initcalls);
>  		}
> -- 
> 2.7.4
> 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply

* Re: [PATCH 29/30] mm: remove include/linux/bootmem.h
From: Michal Hocko @ 2018-09-26  9:38 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-30-git-send-email-rppt@linux.vnet.ibm.com>

On Fri 14-09-18 15:10:44, Mike Rapoport wrote:
> Move remaining definitions and declarations from include/linux/bootmem.h
> into include/linux/memblock.h and remove the redundant header.
> 
> The includes were replaced with the semantic patch below and then
> semi-automated removal of duplicated '#include <linux/memblock.h>
> 
> @@
> @@
> - #include <linux/bootmem.h>
> + #include <linux/memblock.h>
> 
> 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 v3 2/2] powerpc/64: add stack protector support
From: Christophe LEROY @ 2018-09-26  9:41 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: Russell Currey, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Andrew Donnellan, linuxppc-dev, linux-kernel
In-Reply-To: <20180926092806.GM23155@gate.crashing.org>



Le 26/09/2018 à 11:28, Segher Boessenkool a écrit :
> 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?

Spotted, thanks.

arch/powerpc/platforms/powermac/Makefile contains:

CFLAGS_bootx_init.o  		+= -fPIC

Does it mean we should add -lssp_nonshared to LDFLAGS_vmlinux ?

Or maybe stack protection on bootx_init doesn't make much sense and we 
could just do the following ?

CFLAGS_bootx_init.o  		+= -fPIC $(call cc-option, -fno-stack-protector)

Christophe


> 
> :-)
> 
> 
> Segher
> 

^ permalink raw reply

* Re: [PATCH 00/30] mm: remove bootmem allocator
From: Michal Hocko @ 2018-09-26  9:41 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-1-git-send-email-rppt@linux.vnet.ibm.com>

On Fri 14-09-18 15:10:15, Mike Rapoport wrote:
[...]
>  326 files changed, 866 insertions(+), 2539 deletions(-)
>  delete mode 100644 include/linux/bootmem.h
>  delete mode 100644 mm/bootmem.c
>  delete mode 100644 mm/nobootmem.c

I _really_ love this part the most! Not only we got rid of the
translation which always has been a headache but also this nicely shows
how having multiple allocators hurt. I believe further cleanups on top
will make the boot allocator even a place where you look and your eyes
do not want to jump out.

I have only went through patches without my acks from the previous
iteration and there are only minor comments. This looks good overall.

Nice work Mike!
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply

* Re: [PATCH v2 5/6] powerpc/powernv: hold device_hotplug_lock when calling memtrace_offline_pages()
From: David Hildenbrand @ 2018-09-26 10:09 UTC (permalink / raw)
  To: Balbir Singh
  Cc: linux-mm, linux-kernel, linux-doc, linuxppc-dev, linux-acpi,
	xen-devel, devel, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Rashmica Gupta, Michael Neuling
In-Reply-To: <20180925121504.GH8537@350D>

On 25/09/2018 14:15, Balbir Singh wrote:
> On Tue, Sep 25, 2018 at 11:14:56AM +0200, David Hildenbrand wrote:
>> Let's perform all checking + offlining + removing under
>> device_hotplug_lock, so nobody can mess with these devices via
>> sysfs concurrently.
>>
>> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> Cc: Paul Mackerras <paulus@samba.org>
>> Cc: Michael Ellerman <mpe@ellerman.id.au>
>> Cc: Rashmica Gupta <rashmica.g@gmail.com>
>> Cc: Balbir Singh <bsingharora@gmail.com>
>> Cc: Michael Neuling <mikey@neuling.org>
>> Reviewed-by: Pavel Tatashin <pavel.tatashin@microsoft.com>
>> Reviewed-by: Rashmica Gupta <rashmica.g@gmail.com>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>>  arch/powerpc/platforms/powernv/memtrace.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
>> index fdd48f1a39f7..d84d09c56af9 100644
>> --- a/arch/powerpc/platforms/powernv/memtrace.c
>> +++ b/arch/powerpc/platforms/powernv/memtrace.c
>> @@ -70,6 +70,7 @@ static int change_memblock_state(struct memory_block *mem, void *arg)
>>  	return 0;
>>  }
>>  
>> +/* called with device_hotplug_lock held */
>>  static bool memtrace_offline_pages(u32 nid, u64 start_pfn, u64 nr_pages)
>>  {
>>  	u64 end_pfn = start_pfn + nr_pages - 1;
>> @@ -111,6 +112,7 @@ static u64 memtrace_alloc_node(u32 nid, u64 size)
>>  	end_pfn = round_down(end_pfn - nr_pages, nr_pages);
>>  
>>  	for (base_pfn = end_pfn; base_pfn > start_pfn; base_pfn -= nr_pages) {
>> +		lock_device_hotplug();
> 
> Why not grab the lock before the for loop? That way we can avoid bad cases like a
> large node being scanned for a small number of pages (nr_pages). Ideally we need
> a cond_resched() in the loop, but I guess offline_pages() has one.

Yes, it does.

I can move it out of the loop, thanks!

> 
> Acked-by: Balbir Singh <bsingharora@gmail.com>
> 


-- 

Thanks,

David / dhildenb

^ permalink raw reply

* Re: [PATCH 4/4] dma-mapping: clear dev->dma_ops in arch_teardown_dma_ops
From: Robin Murphy @ 2018-09-26 10:45 UTC (permalink / raw)
  To: Christoph Hellwig, Guenter Roeck
  Cc: iommu, Greg Kroah-Hartman, linux-kernel, linux-arm-kernel,
	Marek Szyprowski, Bjorn Helgaas, linux-pci,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	linuxppc-dev
In-Reply-To: <20180925201619.GB8413@lst.de>

On 25/09/18 21:16, Christoph Hellwig wrote:
> 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.

Ugh, sorry about missing that too. Ack to a revert - thinking about 
those PPC symptoms, it might actually be that other architectures could 
also get into the same pickle just by unbinding and rebinding a driver 
(e.g. switching to VFIO then back again).

Robin.

^ permalink raw reply

* [PATCH -next] PCI/AER: Remove duplicated include from err.c
From: YueHaibing @ 2018-09-26 11:00 UTC (permalink / raw)
  To: Russell Currey, Sam Bobroff, Oliver O'Halloran, Bjorn Helgaas
  Cc: YueHaibing, linuxppc-dev, linux-pci, kernel-janitors

Remove duplicated include.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/pci/pcie/err.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index 4da2a62b..773197a 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -12,7 +12,6 @@
 
 #include <linux/pci.h>
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/aer.h>

^ permalink raw reply related

* Re: Re: [PATCH] kdb: use correct pointer when 'btc' calls 'btt'
From: Daniel Thompson @ 2018-09-26 11:11 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Jason Wessel, Michael Ellerman, linux-kernel, linuxppc-dev,
	kgdb-bugreport, stable, me
In-Reply-To: <20180916190610.vzqxwps7zqy2zc6o@holly.lan>

On 16/09/2018 20:06, Daniel Thompson wrote:
> On Fri, Sep 14, 2018 at 12:35:44PM +0000, Christophe Leroy wrote:
>> On a powerpc 8xx, 'btc' fails as follows:
>>
>> Entering kdb (current=0x(ptrval), pid 282) due to Keyboard Entry
>> kdb> btc
>> btc: cpu status: Currently on cpu 0
>> Available cpus: 0
>> kdb_getarea: Bad address 0x0
>>
>> when booting the kernel with 'debug_boot_weak_hash', it fails as well
>>
>> Entering kdb (current=0xba99ad80, pid 284) due to Keyboard Entry
>> kdb> btc
>> btc: cpu status: Currently on cpu 0
>> Available cpus: 0
>> kdb_getarea: Bad address 0xba99ad80
>>
>> On other platforms, Oopses have been observed too, see
>> https://github.com/linuxppc/linux/issues/139
>>
>> This is due to btc calling 'btt' with %p pointer as an argument.
>>
>> This patch replaces %p by %px to get the real pointer value as
>> expected by 'btt'
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> Cc: <stable@vger.kernel.org> # 4.15+
> 
> Would a Fixes: be better here?
> Fixes: ad67b74d2469d9b82 ("printk: hash addresses printed with %p")

Christophe, When you add the Fixes: could you also add my

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


Thanks.


> 
> No blame attached to Tobin, but the fixes makes it super clear what
> changed and why this breaks kdb (which was not explicitly called out
> the patch description).
> 
> 
> Daniel.
> 
>> ---
>>   kernel/debug/kdb/kdb_bt.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/kernel/debug/kdb/kdb_bt.c b/kernel/debug/kdb/kdb_bt.c
>> index 6ad4a9fcbd6f..7921ae4fca8d 100644
>> --- a/kernel/debug/kdb/kdb_bt.c
>> +++ b/kernel/debug/kdb/kdb_bt.c
>> @@ -179,14 +179,14 @@ kdb_bt(int argc, const char **argv)
>>   				kdb_printf("no process for cpu %ld\n", cpu);
>>   				return 0;
>>   			}
>> -			sprintf(buf, "btt 0x%p\n", KDB_TSK(cpu));
>> +			sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu));
>>   			kdb_parse(buf);
>>   			return 0;
>>   		}
>>   		kdb_printf("btc: cpu status: ");
>>   		kdb_parse("cpu\n");
>>   		for_each_online_cpu(cpu) {
>> -			sprintf(buf, "btt 0x%p\n", KDB_TSK(cpu));
>> +			sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu));
>>   			kdb_parse(buf);
>>   			touch_nmi_watchdog();
>>   		}
>> -- 
>> 2.13.3
>>

^ permalink raw reply

* Re: [PATCH] kdb: use correct pointer when 'btc' calls 'btt'
From: Christophe LEROY @ 2018-09-26 11:19 UTC (permalink / raw)
  To: Daniel Thompson
  Cc: Jason Wessel, Michael Ellerman, linux-kernel, linuxppc-dev,
	kgdb-bugreport, stable, me
In-Reply-To: <5f0e0241-b7ab-b5fa-de0e-01abdbc85770@linaro.org>



Le 26/09/2018 à 13:11, Daniel Thompson a écrit :
> On 16/09/2018 20:06, Daniel Thompson wrote:
>> On Fri, Sep 14, 2018 at 12:35:44PM +0000, Christophe Leroy wrote:
>>> On a powerpc 8xx, 'btc' fails as follows:
>>>
>>> Entering kdb (current=0x(ptrval), pid 282) due to Keyboard Entry
>>> kdb> btc
>>> btc: cpu status: Currently on cpu 0
>>> Available cpus: 0
>>> kdb_getarea: Bad address 0x0
>>>
>>> when booting the kernel with 'debug_boot_weak_hash', it fails as well
>>>
>>> Entering kdb (current=0xba99ad80, pid 284) due to Keyboard Entry
>>> kdb> btc
>>> btc: cpu status: Currently on cpu 0
>>> Available cpus: 0
>>> kdb_getarea: Bad address 0xba99ad80
>>>
>>> On other platforms, Oopses have been observed too, see
>>> https://github.com/linuxppc/linux/issues/139
>>>
>>> This is due to btc calling 'btt' with %p pointer as an argument.
>>>
>>> This patch replaces %p by %px to get the real pointer value as
>>> expected by 'btt'
>>>
>>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>>> Cc: <stable@vger.kernel.org> # 4.15+
>>
>> Would a Fixes: be better here?
>> Fixes: ad67b74d2469d9b82 ("printk: hash addresses printed with %p")
> 
> Christophe, When you add the Fixes: could you also add my
> 
> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


Ok, thanks for the review, but do I have to do anything really ?

The Fixes: and now your Reviewed-by: appear automatically in patchwork 
(https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=65715), 
so I believe they'll be automatically included when Jason or someone 
else takes the patch, no ?

Christophe

> 
> 
> Thanks.
> 
> 
>>
>> No blame attached to Tobin, but the fixes makes it super clear what
>> changed and why this breaks kdb (which was not explicitly called out
>> the patch description).
>>
>>
>> Daniel.
>>
>>> ---
>>>   kernel/debug/kdb/kdb_bt.c | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/kernel/debug/kdb/kdb_bt.c b/kernel/debug/kdb/kdb_bt.c
>>> index 6ad4a9fcbd6f..7921ae4fca8d 100644
>>> --- a/kernel/debug/kdb/kdb_bt.c
>>> +++ b/kernel/debug/kdb/kdb_bt.c
>>> @@ -179,14 +179,14 @@ kdb_bt(int argc, const char **argv)
>>>                   kdb_printf("no process for cpu %ld\n", cpu);
>>>                   return 0;
>>>               }
>>> -            sprintf(buf, "btt 0x%p\n", KDB_TSK(cpu));
>>> +            sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu));
>>>               kdb_parse(buf);
>>>               return 0;
>>>           }
>>>           kdb_printf("btc: cpu status: ");
>>>           kdb_parse("cpu\n");
>>>           for_each_online_cpu(cpu) {
>>> -            sprintf(buf, "btt 0x%p\n", KDB_TSK(cpu));
>>> +            sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu));
>>>               kdb_parse(buf);
>>>               touch_nmi_watchdog();
>>>           }
>>> -- 
>>> 2.13.3
>>>

^ permalink raw reply

* [PATCH v4 1/2] powerpc/32: add stack protector support
From: Christophe Leroy @ 2018-09-26 11:40 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

This functionality was tentatively added in the past
(commit 6533b7c16ee5 ("powerpc: Initial stack protector
(-fstack-protector) support")) but had to be reverted
(commit f2574030b0e3 ("powerpc: Revert the initial stack
protector support") because of GCC implementing it differently
whether it had been built with libc support or not.

Now, GCC offers the possibility to manually set the
stack-protector mode (global or tls) regardless of libc support.

This time, the patch selects HAVE_STACKPROTECTOR only if
-mstack-protector-guard=tls is supported by GCC.

On PPC32, as register r2 points to current task_struct at
all time, the stack_canary located inside task_struct can be
used directly by using the following GCC options:
-mstack-protector-guard=tls
-mstack-protector-guard-reg=r2
-mstack-protector-guard-offset=offsetof(struct task_struct, stack_canary))

The protector is disabled for prom_init and bootx_init as
it is too early to handle it properly.

 $ echo CORRUPT_STACK > /sys/kernel/debug/provoke-crash/DIRECT
[  134.943666] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: lkdtm_CORRUPT_STACK+0x64/0x64
[  134.943666]
[  134.955414] CPU: 0 PID: 283 Comm: sh Not tainted 4.18.0-s3k-dev-12143-ga3272be41209 #835
[  134.963380] Call Trace:
[  134.965860] [c6615d60] [c001f76c] panic+0x118/0x260 (unreliable)
[  134.971775] [c6615dc0] [c001f654] panic+0x0/0x260
[  134.976435] [c6615dd0] [c032c368] lkdtm_CORRUPT_STACK_STRONG+0x0/0x64
[  134.982769] [c6615e00] [ffffffff] 0xffffffff

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 v4: disable stack protector in bootx_init

 v3: the offset is now defined by a rule in the Makefile. No need anymore
     to take stack_canary out of the randomised area of task_struct

 arch/powerpc/Kconfig                      |  1 +
 arch/powerpc/Makefile                     | 10 +++++++++
 arch/powerpc/include/asm/stackprotector.h | 34 +++++++++++++++++++++++++++++++
 arch/powerpc/kernel/Makefile              |  2 ++
 arch/powerpc/kernel/asm-offsets.c         |  3 +++
 arch/powerpc/platforms/powermac/Makefile  |  1 +
 6 files changed, 51 insertions(+)
 create mode 100644 arch/powerpc/include/asm/stackprotector.h

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index a80669209155..3bcb05929931 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -180,6 +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_CONTEXT_TRACKING		if PPC64
 	select HAVE_DEBUG_KMEMLEAK
 	select HAVE_DEBUG_STACKOVERFLOW
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 07d9dce7eda6..45b8eb4d8fe7 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -112,6 +112,9 @@ KBUILD_LDFLAGS	+= -m elf$(BITS)$(LDEMULATION)
 KBUILD_ARFLAGS	+= --target=elf$(BITS)-$(GNUTARGET)
 endif
 
+cflags-$(CONFIG_STACKPROTECTOR)	+= -mstack-protector-guard=tls
+cflags-$(CONFIG_STACKPROTECTOR)	+= -mstack-protector-guard-reg=r2
+
 LDFLAGS_vmlinux-y := -Bstatic
 LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
 LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y)
@@ -404,6 +407,13 @@ archclean:
 
 archprepare: checkbin
 
+ifdef CONFIG_STACKPROTECTOR
+prepare: stack_protector_prepare
+
+stack_protector_prepare: prepare0
+	$(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
+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.
 TOUT	:= .tmp_gas_check
diff --git a/arch/powerpc/include/asm/stackprotector.h b/arch/powerpc/include/asm/stackprotector.h
new file mode 100644
index 000000000000..263e2aab1862
--- /dev/null
+++ b/arch/powerpc/include/asm/stackprotector.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * GCC stack protector support.
+ *
+ */
+
+#ifndef _ASM_STACKPROTECTOR_H
+#define _ASM_STACKPROTECTOR_H
+
+#include <linux/random.h>
+#include <linux/version.h>
+#include <asm/reg.h>
+#include <asm/current.h>
+#include <asm/paca.h>
+
+/*
+ * Initialize the stackprotector canary value.
+ *
+ * NOTE: this must only be called from functions that never return,
+ * and it must always be inlined.
+ */
+static __always_inline void boot_init_stack_canary(void)
+{
+	unsigned long canary;
+
+	/* Try to get a semi random initial value. */
+	get_random_bytes(&canary, sizeof(canary));
+	canary ^= mftb();
+	canary ^= LINUX_VERSION_CODE;
+
+	current->stack_canary = canary;
+}
+
+#endif	/* _ASM_STACKPROTECTOR_H */
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 1e64cfe22a83..85ffa488dfb5 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -20,6 +20,8 @@ CFLAGS_prom_init.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
 CFLAGS_btext.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
 CFLAGS_prom.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
 
+CFLAGS_prom_init.o += $(call cc-option, -fno-stack-protector)
+
 ifdef CONFIG_FUNCTION_TRACER
 # Do not trace early boot code
 CFLAGS_REMOVE_cputable.o = $(CC_FLAGS_FTRACE)
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index ba9d0fc98730..a992f7a53cf3 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -79,6 +79,9 @@ int main(void)
 {
 	OFFSET(THREAD, task_struct, thread);
 	OFFSET(MM, task_struct, mm);
+#ifdef CONFIG_STACKPROTECTOR
+	OFFSET(TASK_CANARY, task_struct, stack_canary);
+#endif
 	OFFSET(MMCONTEXTID, mm_struct, context.id);
 #ifdef CONFIG_PPC64
 	DEFINE(SIGSEGV, SIGSEGV);
diff --git a/arch/powerpc/platforms/powermac/Makefile b/arch/powerpc/platforms/powermac/Makefile
index 561a67d65e4d..923bfb340433 100644
--- a/arch/powerpc/platforms/powermac/Makefile
+++ b/arch/powerpc/platforms/powermac/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 CFLAGS_bootx_init.o  		+= -fPIC
+CFLAGS_bootx_init.o  		+= $(call cc-option, -fno-stack-protector)
 
 ifdef CONFIG_FUNCTION_TRACER
 # Do not trace early boot code
-- 
2.13.3

^ permalink raw reply related

* [PATCH v4 2/2] powerpc/64: add stack protector support
From: Christophe Leroy @ 2018-09-26 11:40 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev
In-Reply-To: <d6c43ab708bf9ae1266c745fece457ed2da43d7c.1537961921.git.christophe.leroy@c-s.fr>

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
-- 
2.13.3

^ permalink raw reply related

* Re: [PATCH 02/30] mm: remove CONFIG_NO_BOOTMEM
From: Mike Rapoport @ 2018-09-26 11:48 UTC (permalink / raw)
  To: Michal Hocko
  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: <20180926092239.GK6278@dhcp22.suse.cz>

On Wed, Sep 26, 2018 at 11:22:39AM +0200, Michal Hocko wrote:
> 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.

Yes, Alexander has already fixed that at [1]

[1] https://lkml.org/lkml/2018/9/25/1073
 
> > Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
> 
> Acked-by: Michal Hocko <mhocko@suse.com>
> -- 
> Michal Hocko
> SUSE Labs
> 

-- 
Sincerely yours,
Mike.

^ permalink raw reply

* Re: [PATCH v3 2/2] powerpc/64: add stack protector support
From: Michael Ellerman @ 2018-09-26 11:50 UTC (permalink / raw)
  To: Christophe LEROY, Segher Boessenkool
  Cc: Russell Currey, Benjamin Herrenschmidt, Paul Mackerras,
	Andrew Donnellan, linuxppc-dev, linux-kernel
In-Reply-To: <284752d1-6c32-bdca-72d3-4d8616b26fbf@c-s.fr>

Christophe LEROY <christophe.leroy@c-s.fr> writes:
> Le 26/09/2018 =C3=A0 11:28, Segher Boessenkool a =C3=A9crit=C2=A0:
>> On Wed, Sep 26, 2018 at 09:58:30AM +0200, Christophe LEROY wrote:
>>> Segher, any idea about this problem ?
>>=20
>>>>> arch/powerpc/platforms/powermac/bootx_init.o: In function `bootx_prin=
tf':
>>>>> /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'
>>=20
>> Are you building as PIC?  Are you linking libssp_nonshared.a?  Why not?
>
> Spotted, thanks.
>
> arch/powerpc/platforms/powermac/Makefile contains:
>
> CFLAGS_bootx_init.o  		+=3D -fPIC
...
>
> Or maybe stack protection on bootx_init doesn't make much sense and we=20
> could just do the following ?
>
> CFLAGS_bootx_init.o  		+=3D -fPIC $(call cc-option, -fno-stack-protector)

That would be fine by me.

cheers

^ permalink raw reply

* Re: [PATCH v3 2/2] powerpc/64: add stack protector support
From: Christophe LEROY @ 2018-09-26 11:53 UTC (permalink / raw)
  To: Michael Ellerman, Segher Boessenkool
  Cc: Russell Currey, Benjamin Herrenschmidt, Paul Mackerras,
	Andrew Donnellan, linuxppc-dev, linux-kernel
In-Reply-To: <87o9ckfpek.fsf@concordia.ellerman.id.au>



Le 26/09/2018 à 13:50, Michael Ellerman a écrit :
> Christophe LEROY <christophe.leroy@c-s.fr> writes:
>> Le 26/09/2018 à 11:28, Segher Boessenkool a écrit :
>>> 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?
>>
>> Spotted, thanks.
>>
>> arch/powerpc/platforms/powermac/Makefile contains:
>>
>> CFLAGS_bootx_init.o  		+= -fPIC
> ...
>>
>> Or maybe stack protection on bootx_init doesn't make much sense and we
>> could just do the following ?
>>
>> CFLAGS_bootx_init.o  		+= -fPIC $(call cc-option, -fno-stack-protector)
> 
> That would be fine by me.

Yes, that's what I did in v4, sent a few minutes ago. Indeed the same 
was already done for prom_init, which is similar.

Christophe

^ permalink raw reply

* Re: [PATCH 03/30] mm: remove CONFIG_HAVE_MEMBLOCK
From: Mike Rapoport @ 2018-09-26 11:54 UTC (permalink / raw)
  To: Michal Hocko
  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: <20180926092404.GL6278@dhcp22.suse.cz>

On Wed, Sep 26, 2018 at 11:24:04AM +0200, Michal Hocko wrote:
> 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
 
Not only that, there are other bootmem leftovers in csky.
I've sent the patch with the necessary fixups [1]

[1] https://lkml.kernel.org/lkml/20180926112744.GC4628@rapoport-lnx/

> > Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
> 
> Other than that
> Acked-by: Michal Hocko <mhocko@suse.com>
> -- 
> Michal Hocko
> SUSE Labs
> 

-- 
Sincerely yours,
Mike.

^ permalink raw reply

* Re: [v02] REPOST powerpc/migration: Handle unitialized timer reset
From: Michael Ellerman @ 2018-09-26 12:13 UTC (permalink / raw)
  To: Michael Bringmann, linuxppc-dev
  Cc: Nathan Fontenot, Michael Bringmann, minkim, Thomas Falcon,
	Tyrel Datwyler
In-Reply-To: <6a7769a5-c8bc-f857-61cc-a76cdd98b28c@linux.vnet.ibm.com>

On Thu, 2018-09-20 at 16:45:13 UTC, Michael Bringmann wrote:
> After migration of a powerpc LPAR, the kernel executes code to
> update the system state to reflect new platform characteristics.
> Such changes include modifications to device tree properties
> provided to the system by PHYP.  Property notifications received
> by the powerpc 'migration_store' code are passed along to the
> kernel in general through a call to 'of_update_property' which
> in turn passes such events back to all modules through entries like
> the '.notifier_call' function within the NUMA module.  When the
> NUMA module updates its state, it resets its event timer.  If this
> occurs after a previous call to 'stop_topology_update' or on a
> system without VPHN enabled, the code runs into an unitialized
> timer structure and crashes.  This patch adds a safety check
> along this path toward the problem code.
> 
> Note: This crash was observed on every LPM in the 4.17-rc7 kernel
> (and in the 4.18 kernel) of a system with dedicated CPUs enabled.
> An example crash log without the patch is as follows.
> 
...
> 
> Signed-off-by: Michael Bringmann <mwb@linux.vnet.ibm.com>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/8604895a34d92f5e186ceb931b0d1b

cheers

^ permalink raw reply

* Re: powerpc/tm: Fix userspace r13 corruption
From: Michael Ellerman @ 2018-09-26 12:13 UTC (permalink / raw)
  To: Michael Neuling
  Cc: Michael Neuling, Nicholas Piggin, aneesh.kumar, Breno Leitao,
	linuxppc-dev
In-Reply-To: <20180924072704.6200-1-mikey@neuling.org>

On Mon, 2018-09-24 at 07:27:04 UTC, Michael Neuling wrote:
> When we treclaim we store the userspace checkpointed r13 to a scratch
> SPR and then later save the scratch SPR to the user thread struct.
> 
> Unfortunately, this doesn't work as accessing the user thread struct
> can take an SLB fault and the SLB fault handler will write the same
> scratch SPRG that now contains the userspace r13.
> 
> To fix this, we store r13 to the kernel stack (which can't fault)
> before we access the user thread struct.
> 
> Found by running P8 guest + powervm + disable_1tb_segments + TM. Seen
> as a random userspace segfault with r13 looking like a kernel address.
> 
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> Reviewed-by: Breno Leitao <leitao@debian.org>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/cf13435b730a502e814c63c84d93db

cheers

^ permalink raw reply

* Re: powerpc/tm: Avoid possible userspace r1 corruption on reclaim
From: Michael Ellerman @ 2018-09-26 12:13 UTC (permalink / raw)
  To: Michael Neuling
  Cc: Michael Neuling, Nicholas Piggin, aneesh.kumar, Breno Leitao,
	linuxppc-dev
In-Reply-To: <20180925093647.23723-1-mikey@neuling.org>

On Tue, 2018-09-25 at 09:36:47 UTC, Michael Neuling wrote:
> Current we store the userspace r1 to PACATMSCRATCH before finally
> saving it to the thread struct.
> 
> 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.
> 
> We've never actually seen this happen but it's theoretically
> possible. Either way, the code is fragile as it is.
> 
> 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.
> 
> Suggested-by: Breno Leitao <leitao@debian.org>
> Signed-off-by: Michael Neuling <mikey@neuling.org>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/96dc89d526ef77604376f06220e3d2

cheers

^ permalink raw reply

* Re: powerpc/numa: Use associativity if VPHN hcall is successful
From: Michael Ellerman @ 2018-09-26 12:13 UTC (permalink / raw)
  To: Srikar Dronamraju, Paul Mackerras
  Cc: linuxppc-dev, Harish, Satheesh Rajendran, Srikar Dronamraju,
	Michael Bringmann
In-Reply-To: <1537878315-10783-1-git-send-email-srikar@linux.vnet.ibm.com>

On Tue, 2018-09-25 at 12:25:15 UTC, Srikar Dronamraju wrote:
> Currently associativity is used to lookup node-id even if the preceding
> VPHN hcall failed. However this can cause CPU to be made part of the
> wrong node, (most likely to be node 0). This is because VPHN is not
> enabled on kvm guests.
> 
> With 2ea6263 ("powerpc/topology: Get topology for shared processors at
> boot"), associativity is used to set to the wrong node. Hence KVM guest
> topology is broken.
> 
> For example : A 4 node KVM guest before would have reported.
> 
> [root@localhost ~]#  numactl -H
> available: 4 nodes (0-3)
> node 0 cpus: 0 1 2 3
> node 0 size: 1746 MB
> node 0 free: 1604 MB
> node 1 cpus: 4 5 6 7
> node 1 size: 2044 MB
> node 1 free: 1765 MB
> node 2 cpus: 8 9 10 11
> node 2 size: 2044 MB
> node 2 free: 1837 MB
> node 3 cpus: 12 13 14 15
> node 3 size: 2044 MB
> node 3 free: 1903 MB
> node distances:
> node   0   1   2   3
>   0:  10  40  40  40
>   1:  40  10  40  40
>   2:  40  40  10  40
>   3:  40  40  40  10
> 
> would now report
> 
> [root@localhost ~]# numactl -H
> available: 4 nodes (0-3)
> node 0 cpus: 0 2 3 4 5 6 7 8 9 10 11 12 13 14 15
> node 0 size: 1746 MB
> node 0 free: 1244 MB
> node 1 cpus:
> node 1 size: 2044 MB
> node 1 free: 2032 MB
> node 2 cpus: 1
> node 2 size: 2044 MB
> node 2 free: 2028 MB
> node 3 cpus:
> node 3 size: 2044 MB
> node 3 free: 2032 MB
> node distances:
> node   0   1   2   3
>   0:  10  40  40  40
>   1:  40  10  40  40
>   2:  40  40  10  40
>   3:  40  40  40  10
> 
> Fix this by skipping associativity lookup if the VPHN hcall failed.
> 
> Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/2483ef056f6e42f61cd266452e2841

cheers

^ permalink raw reply

* [PATCH] powerpc: xive: Move a dereference below a NULL test
From: zhong jiang @ 2018-09-26 12:09 UTC (permalink / raw)
  To: mpe, paulus, akpm; +Cc: npiggin, fbarrat, fthain, linuxppc-dev, linux-kernel

It is safe to move dereference below a NULL test.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 arch/powerpc/sysdev/xive/common.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
index 959a2a6..9824074 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -1010,12 +1010,13 @@ static void xive_ipi_eoi(struct irq_data *d)
 {
 	struct xive_cpu *xc = __this_cpu_read(xive_cpu);
 
-	DBG_VERBOSE("IPI eoi: irq=%d [0x%lx] (HW IRQ 0x%x) pending=%02x\n",
-		    d->irq, irqd_to_hwirq(d), xc->hw_ipi, xc->pending_prio);
-
 	/* Handle possible race with unplug and drop stale IPIs */
 	if (!xc)
 		return;
+
+	DBG_VERBOSE("IPI eoi: irq=%d [0x%lx] (HW IRQ 0x%x) pending=%02x\n",
+		    d->irq, irqd_to_hwirq(d), xc->hw_ipi, xc->pending_prio);
+
 	xive_do_source_eoi(xc->hw_ipi, &xc->ipi_data);
 	xive_do_queue_eoi(xc);
 }
-- 
1.7.12.4

^ permalink raw reply related

* [PATCH] powerpc: Move a dereference below a NULL test
From: zhong jiang @ 2018-09-26 11:46 UTC (permalink / raw)
  To: paulus, benh, mpe; +Cc: linuxppc-dev, linux-kernel

It is safe to move dereference below a NULL test.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 arch/powerpc/kernel/cacheinfo.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
index a8f20e5..7f19714 100644
--- a/arch/powerpc/kernel/cacheinfo.c
+++ b/arch/powerpc/kernel/cacheinfo.c
@@ -401,14 +401,13 @@ static struct cache *cache_lookup_or_instantiate(struct device_node *node,
 	struct cache *cache;
 
 	cache = cache_lookup_by_node(node);
+	if (!cache)
+		cache = cache_do_one_devnode(node, level);
 
 	WARN_ONCE(cache && cache->level != level,
 		  "cache level mismatch on lookup (got %d, expected %d)\n",
 		  cache->level, level);
 
-	if (!cache)
-		cache = cache_do_one_devnode(node, level);
-
 	return cache;
 }
 
-- 
1.7.12.4

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox