From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACB303793BF; Mon, 9 Feb 2026 14:44:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770648285; cv=none; b=itOFV8P4zXW4sL8q2hM+kG1Vr/KCinA84sBv2LJeEP6J3JtPgc34osbxGrpSSkMManrx8jE+vwhv0zyzZipQCvjwaXS8iMyUainVvvwztfhgUD1BUg9z8pX2yLtHBmL7cAsccYc+D7cw+hRPFhFtJDbnOK/Tha5KcuO4KPEhw+I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770648285; c=relaxed/simple; bh=CfjOj9Ey/B3/gt2Kdx+o09oUU8Xm2juFGRDgCBbLjxw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dPRlnQcVQL4Y/c7cQdZwv1Nvx0Ou1C41vbfjGfPq09MfDbTqM1ZdtWRwxC0zde0eXLO6/XWraFYR0an2BP6YVmCtSF2Z0IHbYq57Mk2LLcYzuNtju8Y3SVpoZTROFjNjvreSCn4JwWutYsMFXIA92yeJ6Q5O+X3P8OmAfXZAcOc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wzkPKE1o; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="wzkPKE1o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34DBFC116C6; Mon, 9 Feb 2026 14:44:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1770648285; bh=CfjOj9Ey/B3/gt2Kdx+o09oUU8Xm2juFGRDgCBbLjxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wzkPKE1osve4k/vv0lTWSSPSnc7ej0oyUxdY+UPJoXVkgj2QtfHvHGqOJQjq8Y1Jo /6mgt/ZKkqirFi2p94wC68NFim3bdQGt70lEeyf72i5yDVHKD1ijTq/aQfBrtwYJkP pWP2YIF7U99scKrLM5KC15cVGPGx9yanTyH1EveM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Guo Ren , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Palmer Dabbelt , Rahul Sharma Subject: [PATCH 6.1 61/69] riscv: uprobes: Add missing fence.i after building the XOL buffer Date: Mon, 9 Feb 2026 15:24:29 +0100 Message-ID: <20260209142304.120172564@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260209142301.913348974@linuxfoundation.org> References: <20260209142301.913348974@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Björn Töpel commit 7d1d19a11cfbfd8bae1d89cc010b2cc397cd0c48 upstream. The XOL (execute out-of-line) buffer is used to single-step the replaced instruction(s) for uprobes. The RISC-V port was missing a proper fence.i (i$ flushing) after constructing the XOL buffer, which can result in incorrect execution of stale/broken instructions. This was found running the BPF selftests "test_progs: uprobe_autoattach, attach_probe" on the Spacemit K1/X60, where the uprobes tests randomly blew up. Reviewed-by: Guo Ren Fixes: 74784081aac8 ("riscv: Add uprobes supported") Signed-off-by: Björn Töpel Link: https://lore.kernel.org/r/20250419111402.1660267-2-bjorn@kernel.org Signed-off-by: Palmer Dabbelt Signed-off-by: Rahul Sharma Signed-off-by: Greg Kroah-Hartman --- arch/riscv/kernel/probes/uprobes.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) --- a/arch/riscv/kernel/probes/uprobes.c +++ b/arch/riscv/kernel/probes/uprobes.c @@ -161,6 +161,7 @@ void arch_uprobe_copy_ixol(struct page * /* Initialize the slot */ void *kaddr = kmap_atomic(page); void *dst = kaddr + (vaddr & ~PAGE_MASK); + unsigned long start = (unsigned long)dst; memcpy(dst, src, len); @@ -170,13 +171,6 @@ void arch_uprobe_copy_ixol(struct page * *(uprobe_opcode_t *)dst = __BUG_INSN_32; } + flush_icache_range(start, start + len); kunmap_atomic(kaddr); - - /* - * We probably need flush_icache_user_page() but it needs vma. - * This should work on most of architectures by default. If - * architecture needs to do something different it can define - * its own version of the function. - */ - flush_dcache_page(page); }