Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: Add PowerPC Capabilities ELF note

Add the PowerPC name and the PPC_ELFNOTE_CAPABILITIES type in the
kernel binary ELF note. This type is a bitmap that can be used to
advertise kernel capabilities to userland.

This patch also defines PPCCAP_ULTRAVISOR_BIT as being the bit zero.

Suggested-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Claudio Carvalho <cclaudio@linux.ibm.com>
[ maxiwell: Define the 'PowerPC' type in the elfnote.h ]
Signed-off-by: Maxiwell S. Garcia <maxiwell@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190829155021.2915-2-maxiwell@linux.ibm.com

authored by

Claudio Carvalho and committed by
Michael Ellerman
70ed86f4 a102f139

+65 -1
+24
arch/powerpc/include/asm/elfnote.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * PowerPC ELF notes. 4 + * 5 + * Copyright 2019, IBM Corporation 6 + */ 7 + 8 + #ifndef __ASM_POWERPC_ELFNOTE_H__ 9 + #define __ASM_POWERPC_ELFNOTE_H__ 10 + 11 + /* 12 + * These note types should live in a SHT_NOTE segment and have 13 + * "PowerPC" in the name field. 14 + */ 15 + 16 + /* 17 + * The capabilities supported/required by this kernel (bitmap). 18 + * 19 + * This type uses a bitmap as "desc" field. Each bit is described 20 + * in arch/powerpc/kernel/note.S 21 + */ 22 + #define PPC_ELFNOTE_CAPABILITIES 1 23 + 24 + #endif /* __ASM_POWERPC_ELFNOTE_H__ */
+1 -1
arch/powerpc/kernel/Makefile
··· 53 53 dma-common.o 54 54 obj-$(CONFIG_PPC64) += setup_64.o sys_ppc32.o \ 55 55 signal_64.o ptrace32.o \ 56 - paca.o nvram_64.o firmware.o 56 + paca.o nvram_64.o firmware.o note.o 57 57 obj-$(CONFIG_VDSO32) += vdso32/ 58 58 obj-$(CONFIG_PPC_WATCHDOG) += watchdog.o 59 59 obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
+40
arch/powerpc/kernel/note.S
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * PowerPC ELF notes. 4 + * 5 + * Copyright 2019, IBM Corporation 6 + */ 7 + 8 + #include <linux/elfnote.h> 9 + #include <asm/elfnote.h> 10 + 11 + /* 12 + * Ultravisor-capable bit (PowerNV only). 13 + * 14 + * Bit 0 indicates that the powerpc kernel binary knows how to run in an 15 + * ultravisor-enabled system. 16 + * 17 + * In an ultravisor-enabled system, some machine resources are now controlled 18 + * by the ultravisor. If the kernel is not ultravisor-capable, but it ends up 19 + * being run on a machine with ultravisor, the kernel will probably crash 20 + * trying to access ultravisor resources. For instance, it may crash in early 21 + * boot trying to set the partition table entry 0. 22 + * 23 + * In an ultravisor-enabled system, a bootloader could warn the user or prevent 24 + * the kernel from being run if the PowerPC ultravisor capability doesn't exist 25 + * or the Ultravisor-capable bit is not set. 26 + */ 27 + #ifdef CONFIG_PPC_POWERNV 28 + #define PPCCAP_ULTRAVISOR_BIT (1 << 0) 29 + #else 30 + #define PPCCAP_ULTRAVISOR_BIT 0 31 + #endif 32 + 33 + /* 34 + * Add the PowerPC Capabilities in the binary ELF note. It is a bitmap that 35 + * can be used to advertise kernel capabilities to userland. 36 + */ 37 + #define PPC_CAPABILITIES_BITMAP (PPCCAP_ULTRAVISOR_BIT) 38 + 39 + ELFNOTE(PowerPC, PPC_ELFNOTE_CAPABILITIES, 40 + .long PPC_CAPABILITIES_BITMAP)