@@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <linux/arm-smccc.h>
#include <linux/linkage.h>
#include <asm/alternative.h>
@@ -974,10 +975,11 @@ el1_sync: // Guest trapped into EL2
lsr x2, x1, #ESR_ELx_EC_SHIFT
cmp x2, #ESR_ELx_EC_HVC64
+ ccmp x2, #ESR_ELx_EC_HVC32, #4, ne
b.ne el1_trap
- mrs x3, vttbr_el2 // If vttbr is valid, the 64bit guest
- cbnz x3, el1_trap // called HVC
+ mrs x3, vttbr_el2 // If vttbr is valid, the guest
+ cbnz x3, el1_hvc_guest // called HVC
/* Here, we're pretty sure the host called HVC. */
pop x2, x3
@@ -1003,6 +1005,20 @@ el1_sync: // Guest trapped into EL2
pop lr, xzr
2: eret
+el1_hvc_guest:
+ /*
+ * Fastest possible path for ARM_SMCCC_ARCH_WORKAROUND_1.
+ * The workaround has already been applied on the host,
+ * so let's quickly get back to the guest. We don't bother
+ * restoring x3, as it can be clobbered anyway.
+ */
+ ldr x3, [sp] // Guest's x0
+ eor w3, w3, #ARM_SMCCC_ARCH_WORKAROUND_1
+ cbnz w3, el1_trap
+ mov x0, x3
+ add sp, sp, #16
+ eret
+
el1_trap:
/*
* x1: ESR
@@ -57,9 +57,6 @@
#define ARM_SMCCC_OWNER_TRUSTED_OS 50
#define ARM_SMCCC_OWNER_TRUSTED_OS_END 63
-#ifndef __ASSEMBLY__
-#include <linux/linkage.h>
-#include <linux/types.h>
#define ARM_SMCCC_QUIRK_NONE 0
#define ARM_SMCCC_QUIRK_QCOM_A6 1 /* Save/restore register a6 */
@@ -81,6 +78,9 @@
ARM_SMCCC_SMC_32, \
0, 0x8000)
+#ifndef __ASSEMBLY__
+#include <linux/linkage.h>
+#include <linux/types.h>
/**
* struct arm_smccc_res - Result from SMC/HVC call
* @a0-a3 result values from registers 0 to 3