2021-09-14 22:36:28 +03:00
|
|
|
From f2c459c92298deb7054414bd857fe26723be5dab Mon Sep 17 00:00:00 2001
|
Add support of Baikal-M SoCs
Information about config values was taken from:
From 804820df7bcb3d53a33ecd074b1eac277e938f24 Mon Sep 17 00:00:00 2001
From: Alexey Sheplyakov <asheplyakov@altlinux.org>
Date: Thu, 4 Feb 2021 19:35:14 +0400
Subject: [PATCH] config-aarch64: adjusted for Baikal-M (MBM1.0 board)
* DW_APB_TIMER=y, DW_APB_TIMER_OF=y: SoC clocks
* SERIAL_8250_DW=y: serial console
* I2C_DESIGNWARE_CORE=y, I2C_DESIGNWARE_PLATFORM=y: BMC (board
management controller) and RTC (Real Time Clock) are connected
via I2C.
* GPIO_DWAPB=y: device (PCIe, PHY, etc) reset/configuration
* RTC_DRV_PCF2127=y: RTC compiled in so the kernel automatically
sets the system time from the hardware clock
* TP_BMC=y: amongst other things handles the power button
* DRM_BAIKAL_VDU=m, DRM_BAIKAL_HDMI=m: video unit and HDMI transmitter
* CMA_SIZE_MBYTES=256: video display unit and GPU use system RAM, hence
CMA should reserve enough (contiguous) memory.
Note: CMA reserves memory during very early init, hence the size
has to be hard-coded into CONFIG
* MALI_MIDGARD=m: GPU driver, kernel side of proprietary mali blob.
Note: kernel mode code is GPLv2, so it's fine to distribute it.
* SENSORS_BT1_PVT=m: hardware temperature/voltage sensors
* PCI_BAIKAL=m: PCIe root complex. Compiled as a module since takes
ages (60 seconds or so) to probe the hardware. If compiled in
substantially increases the boot time, and machine is completely
unresponsive during probing PCIe. When built as a module probing
executes concurrently with other boot activities (unless booting
from a PCIe device)
* STMMAC_ETH=m, STMMAC_PLATFORM=m, DWMAC_BAIKAL=m: Ethernet driver
2021-06-22 16:12:03 +03:00
|
|
|
From: Alexey Sheplyakov <asheplyakov@altlinux.org>
|
|
|
|
Date: Tue, 10 Nov 2020 19:05:39 +0400
|
2021-09-14 22:36:28 +03:00
|
|
|
Subject: [PATCH 607/631] Fixed secondary CPUs boot on BE-M1000 SoC
|
Add support of Baikal-M SoCs
Information about config values was taken from:
From 804820df7bcb3d53a33ecd074b1eac277e938f24 Mon Sep 17 00:00:00 2001
From: Alexey Sheplyakov <asheplyakov@altlinux.org>
Date: Thu, 4 Feb 2021 19:35:14 +0400
Subject: [PATCH] config-aarch64: adjusted for Baikal-M (MBM1.0 board)
* DW_APB_TIMER=y, DW_APB_TIMER_OF=y: SoC clocks
* SERIAL_8250_DW=y: serial console
* I2C_DESIGNWARE_CORE=y, I2C_DESIGNWARE_PLATFORM=y: BMC (board
management controller) and RTC (Real Time Clock) are connected
via I2C.
* GPIO_DWAPB=y: device (PCIe, PHY, etc) reset/configuration
* RTC_DRV_PCF2127=y: RTC compiled in so the kernel automatically
sets the system time from the hardware clock
* TP_BMC=y: amongst other things handles the power button
* DRM_BAIKAL_VDU=m, DRM_BAIKAL_HDMI=m: video unit and HDMI transmitter
* CMA_SIZE_MBYTES=256: video display unit and GPU use system RAM, hence
CMA should reserve enough (contiguous) memory.
Note: CMA reserves memory during very early init, hence the size
has to be hard-coded into CONFIG
* MALI_MIDGARD=m: GPU driver, kernel side of proprietary mali blob.
Note: kernel mode code is GPLv2, so it's fine to distribute it.
* SENSORS_BT1_PVT=m: hardware temperature/voltage sensors
* PCI_BAIKAL=m: PCIe root complex. Compiled as a module since takes
ages (60 seconds or so) to probe the hardware. If compiled in
substantially increases the boot time, and machine is completely
unresponsive during probing PCIe. When built as a module probing
executes concurrently with other boot activities (unless booting
from a PCIe device)
* STMMAC_ETH=m, STMMAC_PLATFORM=m, DWMAC_BAIKAL=m: Ethernet driver
2021-06-22 16:12:03 +03:00
|
|
|
|
|
|
|
The secure world on BE-M1000 SoC denies execution attempts outside of
|
|
|
|
the ranges [0x80000000, 0x8FFFFFFF] [0xA0000000, 0xBFFFFFFF]. Thus
|
|
|
|
PSCI calls to boot secondary CPUs fail unless the kernel image resides
|
|
|
|
in one of these (physical) address ranges. However BE-M1000's UEFI
|
|
|
|
PE/COFF loader puts the kernel into the forbidden range. Since the alignment
|
|
|
|
is good enough EFI stub does not try to relocate the kernel. As a result
|
|
|
|
secondary CPUs fail to boot.
|
|
|
|
|
|
|
|
Relocation to a random address is not going to work either. Therefore
|
|
|
|
automatically disable kaslr on "known bad" systems (for now only BE-M1000
|
|
|
|
ones) and forcibly relocate the kernel to a low(er) address.
|
|
|
|
---
|
|
|
|
drivers/firmware/efi/libstub/arm64-stub.c | 61 ++++++++++++++++++++++-
|
|
|
|
1 file changed, 60 insertions(+), 1 deletion(-)
|
|
|
|
|
|
|
|
diff --git a/drivers/firmware/efi/libstub/arm64-stub.c b/drivers/firmware/efi/libstub/arm64-stub.c
|
2021-09-14 22:36:28 +03:00
|
|
|
index c1b57dfb1277..411f1546d171 100644
|
Add support of Baikal-M SoCs
Information about config values was taken from:
From 804820df7bcb3d53a33ecd074b1eac277e938f24 Mon Sep 17 00:00:00 2001
From: Alexey Sheplyakov <asheplyakov@altlinux.org>
Date: Thu, 4 Feb 2021 19:35:14 +0400
Subject: [PATCH] config-aarch64: adjusted for Baikal-M (MBM1.0 board)
* DW_APB_TIMER=y, DW_APB_TIMER_OF=y: SoC clocks
* SERIAL_8250_DW=y: serial console
* I2C_DESIGNWARE_CORE=y, I2C_DESIGNWARE_PLATFORM=y: BMC (board
management controller) and RTC (Real Time Clock) are connected
via I2C.
* GPIO_DWAPB=y: device (PCIe, PHY, etc) reset/configuration
* RTC_DRV_PCF2127=y: RTC compiled in so the kernel automatically
sets the system time from the hardware clock
* TP_BMC=y: amongst other things handles the power button
* DRM_BAIKAL_VDU=m, DRM_BAIKAL_HDMI=m: video unit and HDMI transmitter
* CMA_SIZE_MBYTES=256: video display unit and GPU use system RAM, hence
CMA should reserve enough (contiguous) memory.
Note: CMA reserves memory during very early init, hence the size
has to be hard-coded into CONFIG
* MALI_MIDGARD=m: GPU driver, kernel side of proprietary mali blob.
Note: kernel mode code is GPLv2, so it's fine to distribute it.
* SENSORS_BT1_PVT=m: hardware temperature/voltage sensors
* PCI_BAIKAL=m: PCIe root complex. Compiled as a module since takes
ages (60 seconds or so) to probe the hardware. If compiled in
substantially increases the boot time, and machine is completely
unresponsive during probing PCIe. When built as a module probing
executes concurrently with other boot activities (unless booting
from a PCIe device)
* STMMAC_ETH=m, STMMAC_PLATFORM=m, DWMAC_BAIKAL=m: Ethernet driver
2021-06-22 16:12:03 +03:00
|
|
|
--- a/drivers/firmware/efi/libstub/arm64-stub.c
|
|
|
|
+++ b/drivers/firmware/efi/libstub/arm64-stub.c
|
|
|
|
@@ -11,6 +11,7 @@
|
|
|
|
#include <asm/efi.h>
|
|
|
|
#include <asm/memory.h>
|
|
|
|
#include <asm/sections.h>
|
|
|
|
+#include <linux/libfdt.h>
|
|
|
|
#include <asm/sysreg.h>
|
|
|
|
|
|
|
|
#include "efistub.h"
|
|
|
|
@@ -34,6 +35,31 @@ efi_status_t check_platform_features(void)
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static const char* machines_need_low_alloc[] = {
|
|
|
|
+ "baikal,baikal-m",
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static bool need_low_alloc(void) {
|
|
|
|
+ size_t i;
|
|
|
|
+ const void *fdt;
|
|
|
|
+ const char *match;
|
|
|
|
+
|
|
|
|
+ fdt = get_efi_config_table(DEVICE_TREE_GUID);
|
|
|
|
+ if (!fdt) {
|
|
|
|
+ efi_info("failed to retrive FDT from EFI\n");
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < ARRAY_SIZE(machines_need_low_alloc); i++) {
|
|
|
|
+ match = machines_need_low_alloc[i];
|
|
|
|
+ if (fdt_node_check_compatible(fdt, 0, match) == 0) {
|
|
|
|
+ efi_info("machine %s: forcing kernel relocation to low address\n", match);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/*
|
2021-09-14 22:36:28 +03:00
|
|
|
* Distro versions of GRUB may ignore the BSS allocation entirely (i.e., fail
|
|
|
|
* to provide space, and fail to zero it). Check for this condition by double
|
|
|
|
@@ -79,6 +105,19 @@ static bool check_image_region(u64 base, u64 size)
|
|
|
|
return ret;
|
Add support of Baikal-M SoCs
Information about config values was taken from:
From 804820df7bcb3d53a33ecd074b1eac277e938f24 Mon Sep 17 00:00:00 2001
From: Alexey Sheplyakov <asheplyakov@altlinux.org>
Date: Thu, 4 Feb 2021 19:35:14 +0400
Subject: [PATCH] config-aarch64: adjusted for Baikal-M (MBM1.0 board)
* DW_APB_TIMER=y, DW_APB_TIMER_OF=y: SoC clocks
* SERIAL_8250_DW=y: serial console
* I2C_DESIGNWARE_CORE=y, I2C_DESIGNWARE_PLATFORM=y: BMC (board
management controller) and RTC (Real Time Clock) are connected
via I2C.
* GPIO_DWAPB=y: device (PCIe, PHY, etc) reset/configuration
* RTC_DRV_PCF2127=y: RTC compiled in so the kernel automatically
sets the system time from the hardware clock
* TP_BMC=y: amongst other things handles the power button
* DRM_BAIKAL_VDU=m, DRM_BAIKAL_HDMI=m: video unit and HDMI transmitter
* CMA_SIZE_MBYTES=256: video display unit and GPU use system RAM, hence
CMA should reserve enough (contiguous) memory.
Note: CMA reserves memory during very early init, hence the size
has to be hard-coded into CONFIG
* MALI_MIDGARD=m: GPU driver, kernel side of proprietary mali blob.
Note: kernel mode code is GPLv2, so it's fine to distribute it.
* SENSORS_BT1_PVT=m: hardware temperature/voltage sensors
* PCI_BAIKAL=m: PCIe root complex. Compiled as a module since takes
ages (60 seconds or so) to probe the hardware. If compiled in
substantially increases the boot time, and machine is completely
unresponsive during probing PCIe. When built as a module probing
executes concurrently with other boot activities (unless booting
from a PCIe device)
* STMMAC_ETH=m, STMMAC_PLATFORM=m, DWMAC_BAIKAL=m: Ethernet driver
2021-06-22 16:12:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
+static inline efi_status_t efi_low_alloc(unsigned long size, unsigned long align,
|
|
|
|
+ unsigned long *addr)
|
|
|
|
+{
|
|
|
|
+ /*
|
|
|
|
+ * Don't allocate at 0x0. It will confuse code that
|
|
|
|
+ * checks pointers against NULL. Skip the first 8
|
|
|
|
+ * bytes so we start at a nice even number.
|
|
|
|
+ */
|
|
|
|
+ return efi_low_alloc_above(size, align, addr, 0x8);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
efi_status_t handle_kernel_image(unsigned long *image_addr,
|
|
|
|
unsigned long *image_size,
|
|
|
|
unsigned long *reserve_addr,
|
2021-09-14 22:36:28 +03:00
|
|
|
@@ -88,6 +127,13 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
|
Add support of Baikal-M SoCs
Information about config values was taken from:
From 804820df7bcb3d53a33ecd074b1eac277e938f24 Mon Sep 17 00:00:00 2001
From: Alexey Sheplyakov <asheplyakov@altlinux.org>
Date: Thu, 4 Feb 2021 19:35:14 +0400
Subject: [PATCH] config-aarch64: adjusted for Baikal-M (MBM1.0 board)
* DW_APB_TIMER=y, DW_APB_TIMER_OF=y: SoC clocks
* SERIAL_8250_DW=y: serial console
* I2C_DESIGNWARE_CORE=y, I2C_DESIGNWARE_PLATFORM=y: BMC (board
management controller) and RTC (Real Time Clock) are connected
via I2C.
* GPIO_DWAPB=y: device (PCIe, PHY, etc) reset/configuration
* RTC_DRV_PCF2127=y: RTC compiled in so the kernel automatically
sets the system time from the hardware clock
* TP_BMC=y: amongst other things handles the power button
* DRM_BAIKAL_VDU=m, DRM_BAIKAL_HDMI=m: video unit and HDMI transmitter
* CMA_SIZE_MBYTES=256: video display unit and GPU use system RAM, hence
CMA should reserve enough (contiguous) memory.
Note: CMA reserves memory during very early init, hence the size
has to be hard-coded into CONFIG
* MALI_MIDGARD=m: GPU driver, kernel side of proprietary mali blob.
Note: kernel mode code is GPLv2, so it's fine to distribute it.
* SENSORS_BT1_PVT=m: hardware temperature/voltage sensors
* PCI_BAIKAL=m: PCIe root complex. Compiled as a module since takes
ages (60 seconds or so) to probe the hardware. If compiled in
substantially increases the boot time, and machine is completely
unresponsive during probing PCIe. When built as a module probing
executes concurrently with other boot activities (unless booting
from a PCIe device)
* STMMAC_ETH=m, STMMAC_PLATFORM=m, DWMAC_BAIKAL=m: Ethernet driver
2021-06-22 16:12:03 +03:00
|
|
|
efi_status_t status;
|
|
|
|
unsigned long kernel_size, kernel_memsize = 0;
|
|
|
|
u32 phys_seed = 0;
|
|
|
|
+ bool force_low_reloc = need_low_alloc();
|
|
|
|
+ if (force_low_reloc) {
|
|
|
|
+ if (!efi_nokaslr) {
|
|
|
|
+ efi_info("booting on a broken firmware, KASLR will be disabled\n");
|
|
|
|
+ efi_nokaslr = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
2021-09-14 22:36:28 +03:00
|
|
|
/*
|
|
|
|
* Although relocatable kernels can fix up the misalignment with
|
|
|
|
@@ -112,7 +158,8 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
|
Add support of Baikal-M SoCs
Information about config values was taken from:
From 804820df7bcb3d53a33ecd074b1eac277e938f24 Mon Sep 17 00:00:00 2001
From: Alexey Sheplyakov <asheplyakov@altlinux.org>
Date: Thu, 4 Feb 2021 19:35:14 +0400
Subject: [PATCH] config-aarch64: adjusted for Baikal-M (MBM1.0 board)
* DW_APB_TIMER=y, DW_APB_TIMER_OF=y: SoC clocks
* SERIAL_8250_DW=y: serial console
* I2C_DESIGNWARE_CORE=y, I2C_DESIGNWARE_PLATFORM=y: BMC (board
management controller) and RTC (Real Time Clock) are connected
via I2C.
* GPIO_DWAPB=y: device (PCIe, PHY, etc) reset/configuration
* RTC_DRV_PCF2127=y: RTC compiled in so the kernel automatically
sets the system time from the hardware clock
* TP_BMC=y: amongst other things handles the power button
* DRM_BAIKAL_VDU=m, DRM_BAIKAL_HDMI=m: video unit and HDMI transmitter
* CMA_SIZE_MBYTES=256: video display unit and GPU use system RAM, hence
CMA should reserve enough (contiguous) memory.
Note: CMA reserves memory during very early init, hence the size
has to be hard-coded into CONFIG
* MALI_MIDGARD=m: GPU driver, kernel side of proprietary mali blob.
Note: kernel mode code is GPLv2, so it's fine to distribute it.
* SENSORS_BT1_PVT=m: hardware temperature/voltage sensors
* PCI_BAIKAL=m: PCIe root complex. Compiled as a module since takes
ages (60 seconds or so) to probe the hardware. If compiled in
substantially increases the boot time, and machine is completely
unresponsive during probing PCIe. When built as a module probing
executes concurrently with other boot activities (unless booting
from a PCIe device)
* STMMAC_ETH=m, STMMAC_PLATFORM=m, DWMAC_BAIKAL=m: Ethernet driver
2021-06-22 16:12:03 +03:00
|
|
|
efi_nokaslr = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
- efi_info("KASLR disabled on kernel command line\n");
|
|
|
|
+ if (!force_low_reloc)
|
|
|
|
+ efi_info("KASLR disabled on kernel command line\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-14 22:36:28 +03:00
|
|
|
@@ -138,6 +185,15 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
|
Add support of Baikal-M SoCs
Information about config values was taken from:
From 804820df7bcb3d53a33ecd074b1eac277e938f24 Mon Sep 17 00:00:00 2001
From: Alexey Sheplyakov <asheplyakov@altlinux.org>
Date: Thu, 4 Feb 2021 19:35:14 +0400
Subject: [PATCH] config-aarch64: adjusted for Baikal-M (MBM1.0 board)
* DW_APB_TIMER=y, DW_APB_TIMER_OF=y: SoC clocks
* SERIAL_8250_DW=y: serial console
* I2C_DESIGNWARE_CORE=y, I2C_DESIGNWARE_PLATFORM=y: BMC (board
management controller) and RTC (Real Time Clock) are connected
via I2C.
* GPIO_DWAPB=y: device (PCIe, PHY, etc) reset/configuration
* RTC_DRV_PCF2127=y: RTC compiled in so the kernel automatically
sets the system time from the hardware clock
* TP_BMC=y: amongst other things handles the power button
* DRM_BAIKAL_VDU=m, DRM_BAIKAL_HDMI=m: video unit and HDMI transmitter
* CMA_SIZE_MBYTES=256: video display unit and GPU use system RAM, hence
CMA should reserve enough (contiguous) memory.
Note: CMA reserves memory during very early init, hence the size
has to be hard-coded into CONFIG
* MALI_MIDGARD=m: GPU driver, kernel side of proprietary mali blob.
Note: kernel mode code is GPLv2, so it's fine to distribute it.
* SENSORS_BT1_PVT=m: hardware temperature/voltage sensors
* PCI_BAIKAL=m: PCIe root complex. Compiled as a module since takes
ages (60 seconds or so) to probe the hardware. If compiled in
substantially increases the boot time, and machine is completely
unresponsive during probing PCIe. When built as a module probing
executes concurrently with other boot activities (unless booting
from a PCIe device)
* STMMAC_ETH=m, STMMAC_PLATFORM=m, DWMAC_BAIKAL=m: Ethernet driver
2021-06-22 16:12:03 +03:00
|
|
|
status = EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ if (force_low_reloc) {
|
|
|
|
+ status = efi_low_alloc(*reserve_size,
|
|
|
|
+ min_kimg_align(),
|
|
|
|
+ reserve_addr);
|
|
|
|
+ if (status != EFI_SUCCESS) {
|
|
|
|
+ efi_err("Failed to relocate kernel, expect secondary CPUs boot failure\n");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (status != EFI_SUCCESS) {
|
2021-09-14 22:36:28 +03:00
|
|
|
if (!check_image_region((u64)_text, kernel_memsize)) {
|
|
|
|
efi_err("FIRMWARE BUG: Image BSS overlaps adjacent EFI memory region\n");
|
|
|
|
@@ -162,6 +218,9 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
|
Add support of Baikal-M SoCs
Information about config values was taken from:
From 804820df7bcb3d53a33ecd074b1eac277e938f24 Mon Sep 17 00:00:00 2001
From: Alexey Sheplyakov <asheplyakov@altlinux.org>
Date: Thu, 4 Feb 2021 19:35:14 +0400
Subject: [PATCH] config-aarch64: adjusted for Baikal-M (MBM1.0 board)
* DW_APB_TIMER=y, DW_APB_TIMER_OF=y: SoC clocks
* SERIAL_8250_DW=y: serial console
* I2C_DESIGNWARE_CORE=y, I2C_DESIGNWARE_PLATFORM=y: BMC (board
management controller) and RTC (Real Time Clock) are connected
via I2C.
* GPIO_DWAPB=y: device (PCIe, PHY, etc) reset/configuration
* RTC_DRV_PCF2127=y: RTC compiled in so the kernel automatically
sets the system time from the hardware clock
* TP_BMC=y: amongst other things handles the power button
* DRM_BAIKAL_VDU=m, DRM_BAIKAL_HDMI=m: video unit and HDMI transmitter
* CMA_SIZE_MBYTES=256: video display unit and GPU use system RAM, hence
CMA should reserve enough (contiguous) memory.
Note: CMA reserves memory during very early init, hence the size
has to be hard-coded into CONFIG
* MALI_MIDGARD=m: GPU driver, kernel side of proprietary mali blob.
Note: kernel mode code is GPLv2, so it's fine to distribute it.
* SENSORS_BT1_PVT=m: hardware temperature/voltage sensors
* PCI_BAIKAL=m: PCIe root complex. Compiled as a module since takes
ages (60 seconds or so) to probe the hardware. If compiled in
substantially increases the boot time, and machine is completely
unresponsive during probing PCIe. When built as a module probing
executes concurrently with other boot activities (unless booting
from a PCIe device)
* STMMAC_ETH=m, STMMAC_PLATFORM=m, DWMAC_BAIKAL=m: Ethernet driver
2021-06-22 16:12:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
*image_addr = *reserve_addr;
|
|
|
|
+ if (efi_nokaslr) {
|
|
|
|
+ efi_info("relocating kernel to 0x%lx\n", *image_addr);
|
|
|
|
+ }
|
|
|
|
memcpy((void *)*image_addr, _text, kernel_size);
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
--
|
|
|
|
2.31.1
|
|
|
|
|