^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * PowerPC ELF notes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright 2019, IBM Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/elfnote.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <asm/elfnote.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Ultravisor-capable bit (PowerNV only).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Bit 0 indicates that the powerpc kernel binary knows how to run in an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * ultravisor-enabled system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * In an ultravisor-enabled system, some machine resources are now controlled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * by the ultravisor. If the kernel is not ultravisor-capable, but it ends up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * being run on a machine with ultravisor, the kernel will probably crash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * trying to access ultravisor resources. For instance, it may crash in early
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * boot trying to set the partition table entry 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * In an ultravisor-enabled system, a bootloader could warn the user or prevent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * the kernel from being run if the PowerPC ultravisor capability doesn't exist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * or the Ultravisor-capable bit is not set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #ifdef CONFIG_PPC_POWERNV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define PPCCAP_ULTRAVISOR_BIT (1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define PPCCAP_ULTRAVISOR_BIT 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * Add the PowerPC Capabilities in the binary ELF note. It is a bitmap that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * can be used to advertise kernel capabilities to userland.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define PPC_CAPABILITIES_BITMAP (PPCCAP_ULTRAVISOR_BIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) ELFNOTE(PowerPC, PPC_ELFNOTE_CAPABILITIES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) .long PPC_CAPABILITIES_BITMAP)