Patch "powerpc/watchpoints: Disable preemption in thread_change_pc()" has been added to the 6.5-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    powerpc/watchpoints: Disable preemption in thread_change_pc()

to the 6.5-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     powerpc-watchpoints-disable-preemption-in-thread_cha.patch
and it can be found in the queue-6.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 23121b71d1971074a4de343fa753f43ef4f91832
Author: Benjamin Gray <bgray@xxxxxxxxxxxxx>
Date:   Tue Aug 29 16:34:55 2023 +1000

    powerpc/watchpoints: Disable preemption in thread_change_pc()
    
    [ Upstream commit cc879ab3ce39bc39f9b1d238b283f43a5f6f957d ]
    
    thread_change_pc() uses CPU local data, so must be protected from
    swapping CPUs while it is reading the breakpoint struct.
    
    The error is more noticeable after 1e60f3564bad ("powerpc/watchpoints:
    Track perf single step directly on the breakpoint"), which added an
    unconditional __this_cpu_read() call in thread_change_pc(). However the
    existing __this_cpu_read() that runs if a breakpoint does need to be
    re-inserted has the same issue.
    
    Signed-off-by: Benjamin Gray <bgray@xxxxxxxxxxxxx>
    Signed-off-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
    Link: https://msgid.link/20230829063457.54157-2-bgray@xxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
index e1b4e70c8fd0f..0a1e17b334284 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -505,11 +505,13 @@ void thread_change_pc(struct task_struct *tsk, struct pt_regs *regs)
 	struct arch_hw_breakpoint *info;
 	int i;
 
+	preempt_disable();
+
 	for (i = 0; i < nr_wp_slots(); i++) {
 		if (unlikely(tsk->thread.last_hit_ubp[i]))
 			goto reset;
 	}
-	return;
+	goto out;
 
 reset:
 	regs_set_return_msr(regs, regs->msr & ~MSR_SE);
@@ -518,6 +520,9 @@ void thread_change_pc(struct task_struct *tsk, struct pt_regs *regs)
 		__set_breakpoint(i, info);
 		tsk->thread.last_hit_ubp[i] = NULL;
 	}
+
+out:
+	preempt_enable();
 }
 
 static bool is_larx_stcx_instr(int type)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux