From 4e4da9dcd0e1c8b1670113f28f6c823b624b9a80 Mon Sep 17 00:00:00 2001 From: patrick Date: Fri, 28 Apr 2023 10:19:07 +0000 Subject: [PATCH] Fix memory constraints in the inline-assembly stub that calls into secure mode. Without this change the compiler doesn't realize that the memory behind the array that contains the return values might have changed and optimizes the access away. With this change it properly access the array to retrieve the returned values. ok drahn@ --- sys/dev/fdt/qcscm.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/sys/dev/fdt/qcscm.c b/sys/dev/fdt/qcscm.c index 35096350fb1..4c590869515 100644 --- a/sys/dev/fdt/qcscm.c +++ b/sys/dev/fdt/qcscm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qcscm.c,v 1.2 2023/01/21 10:34:49 kettenis Exp $ */ +/* $OpenBSD: qcscm.c,v 1.3 2023/04/28 10:19:07 patrick Exp $ */ /* * Copyright (c) 2022 Patrick Wildt * @@ -189,20 +189,19 @@ void qcscm_smc_exec(uint64_t *in, uint64_t *out) { __asm( - "ldp x0, x1, [%0, %2]\n" - "ldp x2, x3, [%0, %3]\n" - "ldp x4, x5, [%0, %4]\n" - "ldp x6, x7, [%0, %5]\n" + "ldp x0, x1, [%0, #0]\n" + "ldp x2, x3, [%0, #16]\n" + "ldp x4, x5, [%0, #32]\n" + "ldp x6, x7, [%0, #48]\n" "smc #0\n" - "stp x0, x1, [%1, %2]\n" - "stp x2, x3, [%1, %3]\n" - "stp x4, x5, [%1, %4]\n" - "stp x6, x7, [%1, %5]\n" :: - "r" (in), "r" (out), - "i"(0), "i"(16), "i"(32), "i"(48), - "m" (*in), "m" (*out) : + "stp x0, x1, [%1, #0]\n" + "stp x2, x3, [%1, #16]\n" + "stp x4, x5, [%1, #32]\n" + "stp x6, x7, [%1, #48]\n" :: + "r" (in), "r" (out) : "x0", "x1", "x2", "x3", - "x4", "x5", "x6", "x7"); + "x4", "x5", "x6", "x7", + "memory"); } int -- 2.20.1