Andrew Geissler | ea144b03 | 2023-01-27 16:03:57 -0600 | [diff] [blame^] | 1 | From a6daca56b77d7f1b26483f10eb33ebdd6e157d3e Mon Sep 17 00:00:00 2001 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 2 | From: Peter Hoyes <Peter.Hoyes@arm.com> |
| 3 | Date: Fri, 10 Dec 2021 16:37:26 +0000 |
| 4 | Subject: [PATCH 5/9] armv8: Make disabling HVC configurable when switching to |
| 5 | EL1 |
| 6 | |
| 7 | On the BASER_FVP there is no EL3, so HVC is used to provide PSCI |
| 8 | services. Therefore we cannot disable hypercalls. |
| 9 | |
| 10 | Create CONFIG_ARMV8_DISABLE_HVC (dependent on CONFIG_ARMV8_TO_EL1) to |
| 11 | control whether to disable HVC exceptions in HCR_EL2->HCD |
| 12 | |
| 13 | Issue-Id: SCM-3728 |
| 14 | Upstream-Status: Inappropriate [other] |
| 15 | Implementation pending further discussion |
| 16 | Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com> |
| 17 | Change-Id: I463d82f1db8a3cafcab40a9c0c208753569cc300 |
| 18 | --- |
| 19 | arch/arm/cpu/armv8/Kconfig | 9 +++++++++ |
| 20 | arch/arm/include/asm/macro.h | 10 ++++++++-- |
| 21 | configs/vexpress_aemv8r_defconfig | 1 + |
| 22 | 3 files changed, 18 insertions(+), 2 deletions(-) |
| 23 | |
| 24 | diff --git a/arch/arm/cpu/armv8/Kconfig b/arch/arm/cpu/armv8/Kconfig |
Andrew Geissler | ea144b03 | 2023-01-27 16:03:57 -0600 | [diff] [blame^] | 25 | index dec4be0e30..95c03487a2 100644 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 26 | --- a/arch/arm/cpu/armv8/Kconfig |
| 27 | +++ b/arch/arm/cpu/armv8/Kconfig |
Andrew Geissler | ea144b03 | 2023-01-27 16:03:57 -0600 | [diff] [blame^] | 28 | @@ -208,4 +208,13 @@ config ARMV8_CE_SHA256 |
| 29 | |
| 30 | endif |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 31 | |
| 32 | +config ARMV8_DISABLE_HVC |
| 33 | + bool "Disable HVC calls before switching to EL1" |
| 34 | + depends on ARMV8_SWITCH_TO_EL1 |
| 35 | + default y |
| 36 | + help |
| 37 | + If switching to EL1 before loading the operating system, disable taking |
| 38 | + hypercalls back to EL2. May be disabled if, for example, PSCI services are |
| 39 | + running at EL2. |
| 40 | + |
| 41 | endif |
| 42 | diff --git a/arch/arm/include/asm/macro.h b/arch/arm/include/asm/macro.h |
| 43 | index 1a1edc9870..7167739210 100644 |
| 44 | --- a/arch/arm/include/asm/macro.h |
| 45 | +++ b/arch/arm/include/asm/macro.h |
| 46 | @@ -296,9 +296,12 @@ lr .req x30 |
| 47 | ldr \tmp2, =(ID_AA64ISAR1_EL1_GPI | ID_AA64ISAR1_EL1_GPA | \ |
| 48 | ID_AA64ISAR1_EL1_API | ID_AA64ISAR1_EL1_APA) |
| 49 | tst \tmp, \tmp2 |
| 50 | - mov \tmp2, #(HCR_EL2_RW_AARCH64 | HCR_EL2_HCD_DIS) |
| 51 | + mov \tmp2, #(HCR_EL2_RW_AARCH64) |
| 52 | orr \tmp, \tmp2, #(HCR_EL2_APK | HCR_EL2_API) |
| 53 | csel \tmp, \tmp2, \tmp, eq |
| 54 | +#ifdef CONFIG_ARMV8_DISABLE_HVC |
| 55 | + orr \tmp, \tmp, #(HCR_EL2_HCD_DIS) |
| 56 | +#endif |
| 57 | msr hcr_el2, \tmp |
| 58 | |
| 59 | /* Return to the EL1_SP1 mode from EL2 */ |
| 60 | @@ -311,7 +314,10 @@ lr .req x30 |
| 61 | |
| 62 | 1: |
| 63 | /* Initialize HCR_EL2 */ |
| 64 | - ldr \tmp, =(HCR_EL2_RW_AARCH32 | HCR_EL2_HCD_DIS) |
| 65 | + ldr \tmp, =(HCR_EL2_RW_AARCH32) |
| 66 | +#ifdef CONFIG_ARMV8_DISABLE_HVC |
| 67 | + orr \tmp, \tmp, #(HCR_EL2_HCD_DIS) |
| 68 | +#endif |
| 69 | msr hcr_el2, \tmp |
| 70 | |
| 71 | /* Return to AArch32 Supervisor mode from EL2 */ |
| 72 | diff --git a/configs/vexpress_aemv8r_defconfig b/configs/vexpress_aemv8r_defconfig |
Andrew Geissler | ea144b03 | 2023-01-27 16:03:57 -0600 | [diff] [blame^] | 73 | index 6044f82b00..6226f6b2c1 100644 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 74 | --- a/configs/vexpress_aemv8r_defconfig |
| 75 | +++ b/configs/vexpress_aemv8r_defconfig |
Andrew Geissler | ea144b03 | 2023-01-27 16:03:57 -0600 | [diff] [blame^] | 76 | @@ -18,3 +18,4 @@ CONFIG_SYS_PBSIZE=541 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 77 | CONFIG_VIRTIO_MMIO=y |
| 78 | CONFIG_ARMV8_EXCEPTION_VECTORS=n |
| 79 | CONFIG_ARMV8_SWITCH_TO_EL1=y |
| 80 | +CONFIG_ARMV8_DISABLE_HVC=n |
| 81 | -- |
| 82 | 2.25.1 |
| 83 | |