From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 575138287E for ; Sat, 23 May 2026 05:36:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779514620; cv=none; b=ETUvMwE7AHOpq+IVi8MQ0x9mv0tuv+1Gz/lAgwgBDy/sVNjuQ/ul22V7FNOz37ZnhLge8lqi4NP7FrFApGEp7NVuhynS9VhPaaczLw+h2pZDKJu0Mjc1QFTs7JG+iicGS+F6hqWRRtr5HDzfxoMYKifBrF44tr9e7DOKzjCQ+6Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779514620; c=relaxed/simple; bh=K1iy/7Us+v9iabohnw6QHdQ4FKbTQ+1yjGBvyFrzzaw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=djG5X6yyAlMpRcAeE/h+XvSG9aprDv6c13l44bO2mLP5B14zOPCjtm1eYLIch0pxsSCtA1f3DV7nnJHcjX+NOBxKpbhbkdLL3PjHhP/KTqewmQbBSAdVJqHsb6Aj0fuEyovjEJRsWaaiE+E4EbNT+Iv0m6bSTce3y6nitiTY1VQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=rQ8PAWkF; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rQ8PAWkF" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-45d96d21e82so4521328f8f.0 for ; Fri, 22 May 2026 22:36:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779514618; x=1780119418; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LfCXYx65YgeEukMHypUmArLMk/VIi+xGB6BZmr+icPM=; b=rQ8PAWkFYtCSvihyR3Nf21St1nM3N2XyrNwWp8eAh+Z7W3C51MJKlyyTV5sNh4nf/e OU2OhCghSunIuXKUdvO5m1HMc8NB4beWjqIGZXMcTIgvi4F5AkZQ5jZnsr0ktvmOUQka fgz3Aspqm5+Cn9ti8uEA0ccnHJpPONqqeS2NGUGSGLiQHg7pA5XMlaIR6GJ7vyFe11jW DOg05O70HxJsAIKheBwB4um7XLvk+bRHXiHEq/hKF/6sQMkrZmKKbx8o31Rev1AID48c 2FuEpWgQFLb6VKHQk3h6Q37OGPb4MdkpMQHe3HbYZeEpPwqEERKsXVXmcDEZiOGLVyHM 5t3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779514618; x=1780119418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=LfCXYx65YgeEukMHypUmArLMk/VIi+xGB6BZmr+icPM=; b=Rb/jccWGHNHUIj0R7ij8kwWMD+vhOcEKBhyYHWs+VN/QaUBTy904BfQlkNOjPYSbrw GYU+OKRipyrVOcL+QC6wJ+FyLUOUTz24rQqZq5o4fXbwLHS/AA/3qZq1iyC1nBbKhenX 2hui0U4eH2iZ8cTdmrBXvVpLKE82r/dlGxcu/nmqE69ZGG3O4dYmbZAjtWfDcXesjMaT mrDKB+t9lthyRMD4iLsxxIaRjxWhkriM0mdBTaAWPiHVBMrZbZjn4+qJ4TbMhkfIr6r/ NGouhsq76otAZvoRBkX+wopNbqhga+lFAz13yDTgxvU+btnr0VeF33krU+1fPlD+YjyY 7wsg== X-Gm-Message-State: AOJu0YzchbgQTgXbDM3DWJwXFjKpq6nkbFEIivPpe4WGzaVzURXScaeq Xyac0ER/0EPRtsyGaERyXqQfx3SE7S7VCQGUM8bMVxmYa25dYoQwMU9UXozT/yHx X-Gm-Gg: Acq92OHBKAX4xY173sBojBCeKz/iCEOmB0rqtirrQBHS7syKo0nIzLlfV741jmDOUn+ OvnhQfmGab7+AVtyxHY8e+pzlcCFn6ak9t/CfGhQ2foCuToBFMYKuaPLL6Mrrff0CnsMLEmjLLj mqGG4UBjBzxr/y8whWbNYoct5tejbN9hNLUvv3YugvWfCyX+bJrdgWAvAiVlf9J0zgxECiVlSxD RiG/u9ml1X2I99tBvkTCxwXNU9mB0tOerD2BSdKFaHURtT1XlPQaiQDJvNFw9/LRhBkWbMtDA6/ 98zmA5KPfaTExHrXyzDU7vTUxY0gaa1Ncd5ZkvvxRAjzOOWgO2TcmMDg7QUcjexDHrdGt9dXOh1 1mkjzyQ0IiNATaB2wqkg1T5hoYnco7eg3Xp0uJJ43dOVTkbiWjaAUbVywEuaeZFF6UWa9Ll3nGg +2wJpJhp0r8lr7yph0GXwBQ7sWFmAscBghf3RsZ33b7MuBtOHcFCcDNU4Dop0sNWqjFJI+5ZhZK WSr5Q== X-Received: by 2002:a05:6000:2007:b0:43e:a81d:c475 with SMTP id ffacd0b85a97d-45eb3673201mr10681423f8f.6.1779514617661; Fri, 22 May 2026 22:36:57 -0700 (PDT) Received: from localhost (brnt-04-b2-v4wan-170138-cust2432.vm7.cable.virginm.net. [94.175.9.129]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45eb6d5e484sm9473519f8f.30.2026.05.22.22.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 22:36:56 -0700 (PDT) From: Stafford Horne To: LKML Cc: Linux OpenRISC , Stafford Horne , stable@vger.kernel.org, Peter Zijlstra , Josh Poimboeuf , Jason Baron , Alice Ryhl , Steven Rostedt , Ard Biesheuvel , Jonas Bonn , Stefan Kristiansson , chenmiao Subject: [PATCH 3/3] openrisc: Fix jump_label smp syncing Date: Sat, 23 May 2026 06:36:18 +0100 Message-ID: <20260523053624.630443-4-shorne@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260523053624.630443-1-shorne@gmail.com> References: <20260523053624.630443-1-shorne@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The original commit 8c30b0018f9d ("openrisc: Add jump label support") copies from arm64 and does not properly consider how icache invalidation on remote cores works in OpenRISC. On OpenRISC remote icaches need to be invalidated otherwise static key's may remain state after updating. Fix SMP cache syncing by: 1. Properly invalidate remote core icaches on SMP systems by using icache_all_inv. The old code uses kick_all_cpus_sync() which runs a no-op IPI function call on remote CPU's which does execute a lot of code and flushes many cache lines in the process, but does not flush all and it's not correct on OpenRISC. 2. For architectures that do not have WRITETHROUGH caches be sure to flush the dcache after patching. To test this I first reproduced the issue using a custom test module [0]. The test confirmed that some icache lines maintained stale static_key code sequences after calling static_branch_enable(). After this patch there are no longer jump_label coherency issues. [0] https://github.com/stffrdhrn/or1k-utils/tree/master/tests/smp_static_key_test Cc: stable@vger.kernel.org # depends on openrisc: Add icache_all_inv Fixes: 8c30b0018f9d ("openrisc: Add jump label support") Signed-off-by: Stafford Horne --- arch/openrisc/kernel/jump_label.c | 2 +- arch/openrisc/kernel/patching.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/openrisc/kernel/jump_label.c b/arch/openrisc/kernel/jump_label.c index ab7137c23b46..9cb63f2d2e2b 100644 --- a/arch/openrisc/kernel/jump_label.c +++ b/arch/openrisc/kernel/jump_label.c @@ -47,5 +47,5 @@ bool arch_jump_label_transform_queue(struct jump_entry *entry, void arch_jump_label_transform_apply(void) { - kick_all_cpus_sync(); + icache_all_inv(); } diff --git a/arch/openrisc/kernel/patching.c b/arch/openrisc/kernel/patching.c index d186172beb33..5db027b78bc4 100644 --- a/arch/openrisc/kernel/patching.c +++ b/arch/openrisc/kernel/patching.c @@ -49,6 +49,9 @@ static int __patch_insn_write(void *addr, u32 insn) waddr = patch_map(addr, FIX_TEXT_POKE0); ret = copy_to_kernel_nofault(waddr, &insn, OPENRISC_INSN_SIZE); + if (!IS_ENABLED(CONFIG_DCACHE_WRITETHROUGH)) + local_dcache_range_flush((unsigned long)waddr, + (unsigned long)waddr + OPENRISC_INSN_SIZE); local_icache_range_inv((unsigned long)waddr, (unsigned long)waddr + OPENRISC_INSN_SIZE); -- 2.53.0