linux-mips
[Top] [All Lists]

[PATCH] MIPS: ftrace: Fix icache flush range error

To: linux-mips@linux-mips.org
Subject: [PATCH] MIPS: ftrace: Fix icache flush range error
From: Viller Hsiao <villerhsiao@gmail.com>
Date: Wed, 19 Feb 2014 22:54:38 +0800
Cc: Viller Hsiao <villerhsiao@gmail.com>, Steven Rostedt <rostedt@goodmis.org>, Frederic Weisbecker <fweisbec@gmail.com>, Ingo Molnar <mingo@redhat.com>, Ralf Baechle <ralf@linux-mips.org>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=DOuEyUgN2nu4bje8ZZNNlWcJpchwctpQ8ERXQyM9QJM=; b=eTRQIEqHmCT0Tgd8IWdwd2rcx/sGLAjKFloCHRnwK9NOHCSf/WbEnPzHPXB9fEYENX utJrl/0AQrFLvY97PE/CnpkM0JyJ82kMWiIaPoosL6WI75tpZ8cHccJUHPt8bkbbUd1o 4+bb3s5Qf5gVNsLFS45KZjgutJn+c+bo/VwKMSD/XOKzR05jmIs8IA8o96LainJVVY2T sIrmkJYtnThaLcZZiUhabR4Sa52XhnnhxzNqR/Q5rOCwXVOF2UDGVebLTJRfqlHxyieI 6DY3YYtj4/e9qEx0+IYdUVDN9YfH1+imk446mKXnRi6Uit9Cv9EadCVzAA8MppurmkAx Tngw==
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
In 32-bit machine, the start address of flushing icache is wrong after
calculated address of 2nd modified instruction in function tracer. The
start address is shifted 4 bytes from ordinary calculation.

This causes problem when the address of 1st instruction is the last
word of one cache line. It will not be flushed at this case.

Signed-off-by: Viller Hsiao <villerhsiao@gmail.com>
---
 arch/mips/kernel/ftrace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
index 185ba25..5bdc535 100644
--- a/arch/mips/kernel/ftrace.c
+++ b/arch/mips/kernel/ftrace.c
@@ -107,12 +107,12 @@ static int ftrace_modify_code_2(unsigned long ip, 
unsigned int new_code1,
                                unsigned int new_code2)
 {
        int faulted;
+       unsigned long ip2 = ip + 4;
 
        safe_store_code(new_code1, ip, faulted);
        if (unlikely(faulted))
                return -EFAULT;
-       ip += 4;
-       safe_store_code(new_code2, ip, faulted);
+       safe_store_code(new_code2, ip2, faulted);
        if (unlikely(faulted))
                return -EFAULT;
        flush_icache_range(ip, ip + 8); /* original ip + 12 */
-- 
1.8.4.3


<Prev in Thread] Current Thread [Next in Thread>