]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
firmware: qcom_scm-32: replace open-coded call to __cpuc_flush_dcache_area()
authorRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 24 Jul 2015 09:21:02 +0000 (10:21 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 11 Aug 2015 17:45:00 +0000 (18:45 +0100)
Rathe rthan directly accessing architecture internal functions, provide
an "method"-centric wrapper for qcom_scm-32 to do what's necessary to
ensure that the secure monitor can see the data.  This is called
"secure_flush_area" and ensures that the specified memory area is
coherent across the secure boundary.

Acked-by: Andy Gross <agross@codeaurora.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/include/asm/cacheflush.h
drivers/firmware/qcom_scm-32.c

index c5230a44eecab76d485bbf8af1a955105db9d6d9..d5525bfc7e3e61879d278ae08b446e185c206982 100644 (file)
@@ -502,4 +502,21 @@ static inline void set_kernel_text_ro(void) { }
 void flush_uprobe_xol_access(struct page *page, unsigned long uaddr,
                             void *kaddr, unsigned long len);
 
+/**
+ * secure_flush_area - ensure coherency across the secure boundary
+ * @addr: virtual address
+ * @size: size of region
+ *
+ * Ensure that the specified area of memory is coherent across the secure
+ * boundary from the non-secure side.  This is used when calling secure
+ * firmware where the secure firmware does not ensure coherency.
+ */
+static inline void secure_flush_area(const void *addr, size_t size)
+{
+       phys_addr_t phys = __pa(addr);
+
+       __cpuc_flush_dcache_area((void *)addr, size);
+       outer_flush_range(phys, phys + size);
+}
+
 #endif
index 1bd6f9c3433140e84118d8e45ea0faab413576b9..29e6850665eb344cbbc946273343ec13cef81e12 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/err.h>
 #include <linux/qcom_scm.h>
 
-#include <asm/outercache.h>
 #include <asm/cacheflush.h>
 
 #include "qcom_scm.h"
@@ -219,8 +218,7 @@ static int __qcom_scm_call(const struct qcom_scm_command *cmd)
         * Flush the command buffer so that the secure world sees
         * the correct data.
         */
-       __cpuc_flush_dcache_area((void *)cmd, cmd->len);
-       outer_flush_range(cmd_addr, cmd_addr + cmd->len);
+       secure_flush_area(cmd, cmd->len);
 
        ret = smc(cmd_addr);
        if (ret < 0)