1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2013, 2014 Linaro Ltd; <roy.franz@linaro.org>
5 * This file implements the EFI boot stub for the arm64 kernel.
6 * Adapted from ARM version by Mark Salter <msalter@redhat.com>
10 #include <linux/efi.h>
12 #include <asm/memory.h>
13 #include <asm/sysreg.h>
17 static bool system_needs_vamap(void)
19 const u8 *type1_family = efi_get_smbios_string(1, family);
22 * Ampere eMAG, Altra, and Altra Max machines crash in SetTime() if
23 * SetVirtualAddressMap() has not been called prior.
25 if (!type1_family || (
26 strcmp(type1_family, "eMAG") &&
27 strcmp(type1_family, "Altra") &&
28 strcmp(type1_family, "Altra Max")))
31 efi_warn("Working around broken SetVirtualAddressMap()\n");
35 efi_status_t check_platform_features(void)
40 * If we have 48 bits of VA space for TTBR0 mappings, we can map the
41 * UEFI runtime regions 1:1 and so calling SetVirtualAddressMap() is
44 if (VA_BITS_MIN >= 48 && !system_needs_vamap())
47 /* UEFI mandates support for 4 KB granularity, no need to check */
48 if (IS_ENABLED(CONFIG_ARM64_4K_PAGES))
51 tg = (read_cpuid(ID_AA64MMFR0_EL1) >> ID_AA64MMFR0_EL1_TGRAN_SHIFT) & 0xf;
52 if (tg < ID_AA64MMFR0_EL1_TGRAN_SUPPORTED_MIN || tg > ID_AA64MMFR0_EL1_TGRAN_SUPPORTED_MAX) {
53 if (IS_ENABLED(CONFIG_ARM64_64K_PAGES))
54 efi_err("This 64 KB granular kernel is not supported by your CPU\n");
56 efi_err("This 16 KB granular kernel is not supported by your CPU\n");
57 return EFI_UNSUPPORTED;
62 void efi_cache_sync_image(unsigned long image_base,
63 unsigned long alloc_size,
64 unsigned long code_size)
66 u32 ctr = read_cpuid_effective_cachetype();
67 u64 lsize = 4 << cpuid_feature_extract_unsigned_field(ctr,
68 CTR_EL0_DminLine_SHIFT);
71 asm("dc civac, %0" :: "r"(image_base));
74 } while (alloc_size >= lsize);