From patchwork Mon Feb 12 02:55:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 199570 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2204394dyd; Sun, 11 Feb 2024 18:57:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IH83RmCXsvaEkNKJA+9kBPPTKXMMbxH4LT1SKSIfSPPkzKgDq+zjHXwBcubNDCLAm6+fDM6 X-Received: by 2002:a05:6870:3a13:b0:219:b381:2483 with SMTP id du19-20020a0568703a1300b00219b3812483mr5875628oab.48.1707706669482; Sun, 11 Feb 2024 18:57:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707706669; cv=pass; d=google.com; s=arc-20160816; b=TDzBfcW2y31uhxntD9JdMUjT48Xs6LWRFkuGQK3wzE8kfYOsazzvwHf9TuPYeswaE1 eo8zDzZi8QEB/cQMGD2WB1+HxAJi+fzISqvI8EoxzNn/hk20ydhDLGDc+yd15XD/aaPV F1BGHO432jGUvpWLp6QCJ/fXWfr/U5qCg3XwThh7BpqjPfDO1cC34MABClAlG/TjW4lm 0gqi7fc6tGOYKdU5ydRMXyXhIQpgBs5k38E5hYL3qm2j3pUKZBRnNjJ/aUnYWMvE0oOk yQFwcwFgEVzFO823irBi9B7b+aIrxILEZt1IXXSqzRSOCgL5Cif1x+L0b5onQuBFjDaM qKXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=v3jsL0pNyfGhwaczyVRVtmiz/UJ7sxnmY3C1nRyOzZg=; fh=E0Jh0YU6jz1auF8Zs4MfYzdAQn02NLjy744Gj0byF9E=; b=pJHGYuSdGd90mtxMmoNUdFFI71QvPVDu0CNx9fVWLq2dPzBEfgBSUAI7W4o3oxpvHE Zaw1KU2YIO2nLAKRY49zZEUd7vx2xaE34ZGGgTN9HK6SYrYraE7Wmxk/9uhBc5EwUuH4 c7B6i8LvnXPxT+Btiw+wX8QC2EUGw4GTccKmmebmYkwuBwEJc2qG84FHVhoCW/HcP8qK GgR8KNLi4DoJCP3T+zoNyE9NoP8piHbLU3fcJlK+3Q+uptyNw5YMO4ySffOO/tR7hNLa 1T3gAa5dHnSsUUncd+lkl7GnaiMMsCcp4zRNqOAYjEwSHEwNhC87reS8aN3y7UQbJsIJ ijQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=d6e9FAYj; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-61075-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61075-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com X-Forwarded-Encrypted: i=2; AJvYcCUrgxBNC7X3lirOAzB27tRCxfTXJQpSSKDBh2cF7hQqg7hgjdxs/AbJwzwb4YkYX4iArWAMeM97hNcATT+/ckUOZeEQUQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l26-20020a63ba5a000000b005dc491389a5si5901522pgu.812.2024.02.11.18.57.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 18:57:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61075-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=d6e9FAYj; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-61075-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61075-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A8CE5288B47 for ; Mon, 12 Feb 2024 02:56:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0634610782; Mon, 12 Feb 2024 02:55:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="d6e9FAYj" Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (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 F385B747F for ; Mon, 12 Feb 2024 02:55:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707706534; cv=none; b=apjWj3RpqXZ2VjkjBcMvVofWcpGHjIxYTn00Mmd8sXMqlsD+13oAeOdCutoHZh7o4Lbt9iXh8SB6hn6bYmuJdQ/OF1xhsUnyl8P1J6iT65md6mPESyI7QMKQC0UeKkujXXUliPfxX2kHFTvQe5rESdGmP/Bwp54/nVsbVoWTlP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707706534; c=relaxed/simple; bh=7b51flB5NoWMAjsCNRFa3fvRfjAAoQvzjuCZ5CXigcc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jGxLsZoqQprgymTqV0pTHGuo8GvqC4XVE0VwnQfzee0w7l0Uaee3k8P4TPKr7yKCedNEPzmD3OpP5/okpQSwIobQgmdA9zuCE8e0ijtDlyudVn994+sB0VOdmKRe6/y+sO6MV77YCWjwmae9cO3yMd83AvMxq5iUZ4EYeiF1Ess= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=d6e9FAYj; arc=none smtp.client-ip=209.85.222.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-785d5e6c87cso46968685a.2 for ; Sun, 11 Feb 2024 18:55:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1707706532; x=1708311332; 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=v3jsL0pNyfGhwaczyVRVtmiz/UJ7sxnmY3C1nRyOzZg=; b=d6e9FAYj70r6vTzZCrdhlUuY6UyjH6pzaAbExIMCgaMLRCT+odisfpv2YZQ423K8lF X04tg6VB+4+ccMOYOQn/idjcJagiwONzKpi0qpQjEbNgFtbhnhY9u2urs+WdYA0POuUS T9K/hLU9erlZTfTw+D9cgzPtBuBDBbAg2J+37tuPss9RbZ1o0o6YehYP8PxQwJNS04uh TifzPUc4awNFXT/8dSpbpHZLWcGMzi4lzcHV6H1MPGIHtHvKx6u+MqSZPmaebby0xlrb /qu3IJtmhRc+o638Or/VClSSSRcsCVLXo/f3MkvwMeP16ix5soE9nTtCQUEAOEc4klPl YbBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707706532; x=1708311332; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v3jsL0pNyfGhwaczyVRVtmiz/UJ7sxnmY3C1nRyOzZg=; b=ke9NhIpd+2xqgvm133PA4JisPDFubFSuBP+RsYK5Y/R3KOnMbKCU/WHEluxtOTmIF3 n/Y3APMBetrBgt8VRStBS8L2UYxt/bB1Anon4JanoBllUrxyZjAJvAoW2kiickJeoGmh W9wffhZNn5iGn9caG22wxip/WR+PzuTsHZvfD+zAkXwmIr1fLb2Ym4+mwbzKx1ONB15T o4voUw6mzBlgKcYOCxGrDlr3TUdTMPBlyxJWjfgAqNuvG8WdkyIAOKIG0S+Vy0N7iqLK wyig4VBijkiQUzwS4q4UryW8raOp3Xc6gXV9cpKL01NMDLFzcj1KTAo6P3xYsNXxQ2GC yFtg== X-Gm-Message-State: AOJu0YzJdNv2IkKhuEHuNwycer9aUIn6MInqJ2QgntYp5nTDif02gRMg Cwp10KVWNL0oQkTUIIJp3rfwYkdw3FTBwSVriuii802irtcQpc3PVYfj5vH1jvI= X-Received: by 2002:ae9:e905:0:b0:785:cb7c:8554 with SMTP id x5-20020ae9e905000000b00785cb7c8554mr5700867qkf.14.1707706531837; Sun, 11 Feb 2024 18:55:31 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWy6qXPXNq8zE7X4aCqdUsGkzZSwcuXpP36Aqhia9FpyMYlSA46fzz3fov1YRllNfE3l79P88bKmGeSWd+kTI+Bsjos0Hy63ENvtL9y4gwO8qWroxFx2r63uA7nX8YAmOUoULqR8j1rZ9/GKNNLLoqSM22Fxp4u5cvUscnfQytng3hHRougX121AExZPirXPuRcnFvb3QyZVPOBI1Wlvt4AwcFcltkbtfd46crhuW1wpeiDCtayROslVQJRF68X9aZUTc6/tizcK4QUVA== Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id lb3-20020a170902fa4300b001d9af77893esm4906443plb.58.2024.02.11.18.55.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 18:55:31 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Samuel Holland , Ard Biesheuvel , Jason Baron , Josh Poimboeuf , Peter Zijlstra , Steven Rostedt Subject: [PATCH 1/7] riscv: jump_label: Batch icache maintenance Date: Sun, 11 Feb 2024 18:55:12 -0800 Message-ID: <20240212025529.1971876-2-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212025529.1971876-1-samuel.holland@sifive.com> References: <20240212025529.1971876-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790660228249594385 X-GMAIL-MSGID: 1790660228249594385 Switch to the batched version of the jump label update functions so instruction cache maintenance is deferred until the end of the update. Signed-off-by: Samuel Holland Reviewed-by: Björn Töpel --- arch/riscv/include/asm/jump_label.h | 2 ++ arch/riscv/include/asm/patch.h | 1 + arch/riscv/kernel/jump_label.c | 16 ++++++++++++---- arch/riscv/kernel/patch.c | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/arch/riscv/include/asm/jump_label.h b/arch/riscv/include/asm/jump_label.h index 4a35d787c019..6290b26f4a14 100644 --- a/arch/riscv/include/asm/jump_label.h +++ b/arch/riscv/include/asm/jump_label.h @@ -12,6 +12,8 @@ #include #include +#define HAVE_JUMP_LABEL_BATCH + #define JUMP_LABEL_NOP_SIZE 4 static __always_inline bool arch_static_branch(struct static_key * const key, diff --git a/arch/riscv/include/asm/patch.h b/arch/riscv/include/asm/patch.h index e88b52d39eac..9f5d6e14c405 100644 --- a/arch/riscv/include/asm/patch.h +++ b/arch/riscv/include/asm/patch.h @@ -6,6 +6,7 @@ #ifndef _ASM_RISCV_PATCH_H #define _ASM_RISCV_PATCH_H +int patch_insn_write(void *addr, const void *insn, size_t len); int patch_text_nosync(void *addr, const void *insns, size_t len); int patch_text_set_nosync(void *addr, u8 c, size_t len); int patch_text(void *addr, u32 *insns, int ninsns); diff --git a/arch/riscv/kernel/jump_label.c b/arch/riscv/kernel/jump_label.c index e6694759dbd0..11ad789c60c6 100644 --- a/arch/riscv/kernel/jump_label.c +++ b/arch/riscv/kernel/jump_label.c @@ -9,13 +9,14 @@ #include #include #include +#include #include #define RISCV_INSN_NOP 0x00000013U #define RISCV_INSN_JAL 0x0000006fU -void arch_jump_label_transform(struct jump_entry *entry, - enum jump_label_type type) +bool arch_jump_label_transform_queue(struct jump_entry *entry, + enum jump_label_type type) { void *addr = (void *)jump_entry_code(entry); u32 insn; @@ -24,7 +25,7 @@ void arch_jump_label_transform(struct jump_entry *entry, long offset = jump_entry_target(entry) - jump_entry_code(entry); if (WARN_ON(offset & 1 || offset < -524288 || offset >= 524288)) - return; + return true; insn = RISCV_INSN_JAL | (((u32)offset & GENMASK(19, 12)) << (12 - 12)) | @@ -36,6 +37,13 @@ void arch_jump_label_transform(struct jump_entry *entry, } mutex_lock(&text_mutex); - patch_text_nosync(addr, &insn, sizeof(insn)); + patch_insn_write(addr, &insn, sizeof(insn)); mutex_unlock(&text_mutex); + + return true; +} + +void arch_jump_label_transform_apply(void) +{ + flush_icache_all(); } diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c index 37e87fdcf6a0..bccd9ed04a05 100644 --- a/arch/riscv/kernel/patch.c +++ b/arch/riscv/kernel/patch.c @@ -188,7 +188,7 @@ int patch_text_set_nosync(void *addr, u8 c, size_t len) } NOKPROBE_SYMBOL(patch_text_set_nosync); -static int patch_insn_write(void *addr, const void *insn, size_t len) +int patch_insn_write(void *addr, const void *insn, size_t len) { size_t patched = 0; size_t size; From patchwork Mon Feb 12 02:55:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 199572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2204630dyd; Sun, 11 Feb 2024 18:58:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGawzgWKA9c6cR8UyWbdaZRIefl9vl+7ZJKmqmQuvDsgtUcvkjiYO4HgIr2rSGlCACrCgX/ X-Received: by 2002:a05:6358:428e:b0:179:20bb:d0b6 with SMTP id s14-20020a056358428e00b0017920bbd0b6mr8113095rwc.6.1707706724395; Sun, 11 Feb 2024 18:58:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707706724; cv=pass; d=google.com; s=arc-20160816; b=ge2Z6dj6rNyAmfCD5d0HsPcbk3EAUvx8d5KFUVH32uDNHCY7GD5IT+nOWYu3aVgqXz 4VmovMcCtlZaw9TPYtZCChTlDEStR4gWQwHycc0FrS9b9bW2/W5sFwRZLZZcLkgDlvHy L2KfQpABAvOoTwhEO5O44UnIQGoVBOdVY8Rv0UCXF0WWB7EaDqWMso7okngx3CyPf/Lz qPiptpdOxzxBczhqc2T+xK+oW0K3JvshUGhPSWtpC23nwW8r8Q73HCZKtsrHoEkOM4Cj O2JwyJrOFTZV+A/wZzq8zJpy5TAoroiDuawgEu1uS05evxbYxBp7+TBzMDlKgCRMv+2R Nslw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Sgb+qYVoGLQC+1tIvOKXrFPvpE4GtMMkuDMIpMcBDRo=; fh=tnpOyJ9R/m/kaHe8FMrbAxeeKyfaK2QEhFDXFfTi02U=; b=MhT/ZN0r1cn7Rjo14L7sn8yDO0LA0knoqYOgUUq/xl7chSmFotmYzKJA+RsPv0s+ba 1lK9TAJ2oSiAs60PNkK9E3YWh3Gi9OiIHIf26BTuQdoCjaDNcYJ1aVu0Ew1BADLfugYI IladBHvOMgnaJ9ZMXKmDXUkuBimE3ECAGpoi/DycA9V1KS098f2Lf8FEEz4tdmQE0EhZ BlmMiJvOkMgL9FAhQpOTi50tJP5TT7q7b7nIjP7MZDjNIPaflqfs06E1uCogPXD+v/a4 lPivyPgkPyzP1EsJ2Oaylu+s8lhbLLzh4Q/EwX9ed1nmxsWsYY66Na3QhvezIC2atJlI ZMnw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=NGBdhqY5; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-61076-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61076-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com X-Forwarded-Encrypted: i=2; AJvYcCVr0/t2ugoYvdjO7ONCPCbgLMsBfKzWiiYbiRG4JDxn9Y2YLFZcKq6n7iYmepsA2Vg4Bh6mihyJvziqxsj+Wj4HNNx7/w== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e27-20020a63745b000000b005be09b723b7si5593090pgn.636.2024.02.11.18.58.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 18:58:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61076-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=NGBdhqY5; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-61076-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61076-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 823A0B24885 for ; Mon, 12 Feb 2024 02:56:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 987D4FC03; Mon, 12 Feb 2024 02:55:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="NGBdhqY5" Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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 775C879C3 for ; Mon, 12 Feb 2024 02:55:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707706534; cv=none; b=bsXpsBZbdPWFihsfADrc1pO63KjZof9wloBZgnaKnFLU9gfD8iTXboyfikPADSizyRsj1AwDCUs2trifbwmUkO1FDxdZyu2+5Pg+XujQtv6LzXXkJKf47tGvHz3wwnIAIl8hkMczhrNxImPBaPJu278obb8z7xcBRk/jXwIwp/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707706534; c=relaxed/simple; bh=n3r4IK6ZdfJZ49ePBivk4JOiueXOYcZlaqlhYNq/7s8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i6rFnLwY6AKh3OCdqRWIOzm6I5P3MAIWYs8fwS6Pf0rHii9IrElRfdufvdM7cfAe5pZI7fp4DcZ5c93R8RoUQQMiqoX8ENXq6OuY1eYUyOh+Ozv5MqPoWUh/AxLZeZJ8THz+RQvLE19BWRHo4s1DRHgmcssBKQcEX2a38hmixjQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=NGBdhqY5; arc=none smtp.client-ip=209.85.216.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-296c58a11d0so2047993a91.3 for ; Sun, 11 Feb 2024 18:55:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1707706533; x=1708311333; 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=Sgb+qYVoGLQC+1tIvOKXrFPvpE4GtMMkuDMIpMcBDRo=; b=NGBdhqY5Zm4fwJUdWKqcdylMeJGosVeVEy8p4/9cRwlgcK9iXgyaHvxbyNa+kmc1Si bysc8S/vp3j1DdCD2NpuJlc4zqaIHsv6FQKa6z6cAU+Tcme/uy48+dJTPI0SVJ12NKfr OY5GhSTJyK4+OIZRPM8VP6XUXl0uSOB+FptxpqnM5viAH6zz6SUUjOG5a0E9+3g61t1g AMwZr0nxZPF5lReR9gRQyne5Lk3VxR7xEc4vn5NIN4DtuiHfO+3HZ8DSRV/eMWC1Edld eXxJNY+BQk3GexBOcpv8CgcISfoITJLi4iIvkAiR5wToheuPiUJnByVB8sWkhVSUjrPZ 5XSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707706533; x=1708311333; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Sgb+qYVoGLQC+1tIvOKXrFPvpE4GtMMkuDMIpMcBDRo=; b=NDdu95L/jmxdv7G8CFd3ZzRmyu9RYYRZHjUtJLszhrnFa09xhrpdED9w0KBBKmQ9IO zgTuFre8myjp9o+E6fLVimZHBJVbu3AkcnWJBrOHLu9NiOqYBek5nJ8nRm9PMUjDXWUn Zy04mgmviyzK4wXJn6J++XZ89VCDZ6/Zdwoo1P2FzXLM6FoH/Ni3rCjIfKUs2+0vdyIK 3mGSDa/xYZpHdii740ipW/4Jwjy6q9KbrmuR8qZFFdkfXXWbzvMGeJnOdzycENDurE+B UTi0nu+IJC8L4ZI3H5XY4bxSL4er7ooIA0AdF+h1At05bl9TfE93UUevoxva4fcxQjNH GoVg== X-Gm-Message-State: AOJu0YxasUWDTpFzd8KrhwAAvTx2853AHoRT1cDC3ECtjGjYJip40bBq w9N1jwEWrODOp8tLKhoKEiTxb74nB0NzWqPHXc1BjNnqAGnU/r7/LMBxiy0gIeA= X-Received: by 2002:a17:902:da87:b0:1da:2216:f1f8 with SMTP id j7-20020a170902da8700b001da2216f1f8mr6131279plx.39.1707706532745; Sun, 11 Feb 2024 18:55:32 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWltAXxT4Z5I23HaZAeyreKKr5A6zwnhZx747qv+QqQBOZ2ZZtcTpQ4qqJvcBK3aCnVPXPXY4cKY2s6M2O3dDjODm7lW2CSHWdxxVXcnzqZm36pZpUdtXgFNxzdUykLDhghcMVP9m15 Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id lb3-20020a170902fa4300b001d9af77893esm4906443plb.58.2024.02.11.18.55.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 18:55:32 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Samuel Holland Subject: [PATCH 2/7] riscv: jump_label: Simplify assembly syntax Date: Sun, 11 Feb 2024 18:55:13 -0800 Message-ID: <20240212025529.1971876-3-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212025529.1971876-1-samuel.holland@sifive.com> References: <20240212025529.1971876-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790660286539057969 X-GMAIL-MSGID: 1790660286539057969 The idiomatic way to write "jal zero" is "j". Signed-off-by: Samuel Holland Reviewed-by: Björn Töpel --- arch/riscv/include/asm/jump_label.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/jump_label.h b/arch/riscv/include/asm/jump_label.h index 6290b26f4a14..1c768d02bd0c 100644 --- a/arch/riscv/include/asm/jump_label.h +++ b/arch/riscv/include/asm/jump_label.h @@ -46,7 +46,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key * const ke " .option push \n\t" " .option norelax \n\t" " .option norvc \n\t" - "1: jal zero, %l[label] \n\t" + "1: j %l[label] \n\t" " .option pop \n\t" " .pushsection __jump_table, \"aw\" \n\t" " .align " RISCV_LGPTR " \n\t" From patchwork Mon Feb 12 02:55:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 199569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2204094dyd; Sun, 11 Feb 2024 18:56:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX/WKeTYN+iI96b26OdIwOn14Pmv0HGsmzuRPKU/50w875NybKCHwr+I+zQWS+B3CEtNhpoYSfPG292FPn7oNnCLvvDeQ== X-Google-Smtp-Source: AGHT+IHuJlXUZEJPGpiNaKUVAXRvWo0ykUOqL7qd0b4EcOJ9/j9Rf6NQc3HAsWTOFGSjDZpbuqA5 X-Received: by 2002:a05:620a:677:b0:783:f753:813b with SMTP id a23-20020a05620a067700b00783f753813bmr4783841qkh.64.1707706598227; Sun, 11 Feb 2024 18:56:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707706598; cv=pass; d=google.com; s=arc-20160816; b=MaUUHerDWcCyFmJxm3aH3No3zFO1vG8mRyW2vJ9IyIOQm0NETiG964UH6PjjwYki0X 3r+1u+vJ0OGP6lPlaKg83USs+nuK2xJvOZDsIAgQ80qgT3fYca+Ph0Ur/JKC2yFPIyw6 KTMWOfz8asSTJsPs8ZkeCJi8gUCFvk9aWw2CXgQ2HdzgcLpIY9kmx1A5DrS/T64LDXln roXsW66KQQQ+l6nWeVgYJlgVbfgT7gqSA621rkF9F6nxaFLwMvO/3eAAN9loL03/PlbZ fHSg3GHJJVvPpW8qWWPe5nIy5f/vR7jyQBLns1wLmkYQClTu85CrcutoDXVhU3uhGgFk 3KPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dyWEpJBZa6N5gG6vKnxq0FYgwkGh/wmTGuSHlmGCra0=; fh=5hvfg/Zixbr7D1fmIyi954j4Jr9hzeVRmN4mkxlSt7U=; b=BwZSJQkMor6osrd98LRBKTzyxmp6X055X+UDP5ik/PC5t2eeDjkrj7ujljgGX3g9Ts 9iFUSZbS6T+MZP9IzSWn/hOAe3rOPUnB1VpEaFJPg6pr+lHhjtCEQpeyrBNIRY2pv4Bw Ox+3a8H7fzqTUS2HorifmX5yUPQ6LvIxNry9E2rcVuHMwEeoB5qW97Hdwgyj/lGlsFjY //AeEMnGA39q7nsIIFRQsKYUPucYEflxnNOza2j0U9ueycz9BQ1ssKERjuRx7i5bGhBK iswmauwGLNhwUzVyDNuKMSXW/219Fquqs+fTvIuEyoImeLNTe5mM211PvHg4+XJBPMYL b66A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=bMMscS28; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-61077-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61077-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com X-Forwarded-Encrypted: i=2; AJvYcCWagADOb47op/tTBkVe1LI2Gy5kNmPqRTpnDO/w+rb0rLBzI9gFJP1fvPqQtePO/Y2SeaJI4yqkP3bTVYT7nC5rRWfKEg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h15-20020a05620a13ef00b00785d7692a94si1161670qkl.323.2024.02.11.18.56.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 18:56:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61077-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=bMMscS28; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-61077-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61077-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 09FA31C21640 for ; Mon, 12 Feb 2024 02:56:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D48610A1D; Mon, 12 Feb 2024 02:55:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="bMMscS28" Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 5BC6279F9 for ; Mon, 12 Feb 2024 02:55:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707706535; cv=none; b=ghHA7AroQGwIUH+dM7Wfoo6cz17lLu14SSLCfxFeOLiC7R87FH2emmDESYBqDE82vgs42XWNP7oKgZzVb9J8vjqvh3AZ4YWzybCICrOtgAs4+C38PKYoGyQCEYFXYDGzFG5UIC0LzXPg7s2QVxNczMipTCefB+Qfz7PJ63pu+z4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707706535; c=relaxed/simple; bh=hGoXyhdOZzkX3SM1U+B5MT4w/IBhEMz7O05oyr3ELpo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cFFVCM787g95Bx04rYcZtAW2AqFGe7NyZj50t65eiintkls+FnrZiGYijjzmM0TjwJDrMwFabOU7sM+XG3yshhS97n5De/mbCo7xeH3zJI6aZmm6pI0mQQm8QKijPKkEZwPL2dhMfpBUXPxGrHWxmXhGLwTIBF2zsJQV/kJXB3U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=bMMscS28; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d7354ba334so23827625ad.1 for ; Sun, 11 Feb 2024 18:55:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1707706533; x=1708311333; 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=dyWEpJBZa6N5gG6vKnxq0FYgwkGh/wmTGuSHlmGCra0=; b=bMMscS28ybqZed+IqfZ7jZKNX0g7EIzEqtxxZFAj+qIfU9LC35OF1R9gUFycjHUOBi Ju+NPeFKADCulqAAQp5fwII+5c+FmRPjb5lkm45/rDPAIomSj+T+11VsozZhWK3PBygP uXct7LhbF/2J+VGPmUClSiqqoLIwIFpwzkOwLIMQVsjZ6Yd9EDHMSaWtbTpduftCsFPO grpqZPJqDhZoXhgmbWl8O4q1rozy76l5bGQvAldBRWNkOPyNxMavAgeTvhajZQeC/ei8 +8rVSLow/+NZ0qPrMDzkQY4EdbI9dHw1WZuSfW1pyk6YlkTG/9EK/LZrUkkYkKtt4UdU Exbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707706533; x=1708311333; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dyWEpJBZa6N5gG6vKnxq0FYgwkGh/wmTGuSHlmGCra0=; b=q21cMQrtuvJQdwEhaSnJEfmMSo5SEjpVyKJn8Q2zi1PGw3THqAXOOjSgoqGFCYbhva IhviF6U1KfLYqJjpKB7NfB4YQk7VP0XjCqJ/jHxXCYofsY1tnYN8+4dUWfkFT8SQe5uq L1sg+3aBVQCzxOnYj5C/RwX+ugfOQJlBlvtPc1+HfuumIoT4rT6CBYFlLYREwyHWAG97 QiVSKwb5tjN9g57yq1Zq2Qt09OYeKE0vYLwcglBqX1xV4FCp1t6PkcXrV2t2ErQCPhPo UkSbdyaCQMWLsWV0k070MpcWy8+CrAOfSEXKx5pr2Gpc62sxT4OChyfJe+iU0nEnGOxJ rLpA== X-Forwarded-Encrypted: i=1; AJvYcCUUiVyzJ0gjNEi71wXykTvC/K0asAdQVgHF/SYjLArUZcdb69uy0GoIPkIAeEHCxgFd6/tNkZnJzrZgSWyh6p5IsqbuNBAIPFKGoQbf X-Gm-Message-State: AOJu0Yz/0mQyU9WjZl7wdt4fWx5ih/lU9x6Pwgm7viL9o19BooaopzWw EtGoD+LytUfxxwiY3b+NU4imn+9T5yCGDFMOLhubKd0JyxMMQYKHnlDX1IC15Es= X-Received: by 2002:a17:902:e543:b0:1da:2a91:8c08 with SMTP id n3-20020a170902e54300b001da2a918c08mr2970896plf.3.1707706533677; Sun, 11 Feb 2024 18:55:33 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUuWR7ifv90QrNgp9OEt3yI6Kuwl8TrHbiwLrMId33GgFSjH88KNG50sMejjWgECWoCB1ug+/IqU9OjHkK5Vn/juEDCGgYKNrlq73OyQmooS6Cdg7mXmU3LW3vffu4GbXxiPKCchb2+ Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id lb3-20020a170902fa4300b001d9af77893esm4906443plb.58.2024.02.11.18.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 18:55:33 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Samuel Holland Subject: [PATCH 3/7] riscv: kprobes: Use patch_text_nosync() for insn slots Date: Sun, 11 Feb 2024 18:55:14 -0800 Message-ID: <20240212025529.1971876-4-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212025529.1971876-1-samuel.holland@sifive.com> References: <20240212025529.1971876-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790660153766042046 X-GMAIL-MSGID: 1790660153766042046 These instructions are not yet visible to the rest of the system, so there is no need to do the whole stop_machine() dance. Signed-off-by: Samuel Holland Reviewed-by: Björn Töpel --- arch/riscv/kernel/probes/kprobes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kernel/probes/kprobes.c b/arch/riscv/kernel/probes/kprobes.c index 2f08c14a933d..cbf8197072bf 100644 --- a/arch/riscv/kernel/probes/kprobes.c +++ b/arch/riscv/kernel/probes/kprobes.c @@ -28,9 +28,9 @@ static void __kprobes arch_prepare_ss_slot(struct kprobe *p) p->ainsn.api.restore = (unsigned long)p->addr + offset; - patch_text(p->ainsn.api.insn, &p->opcode, 1); - patch_text((void *)((unsigned long)(p->ainsn.api.insn) + offset), - &insn, 1); + patch_text_nosync(p->ainsn.api.insn, &p->opcode, 1); + patch_text_nosync(p->ainsn.api.insn + offset, + &insn, 1); } static void __kprobes arch_prepare_simulate(struct kprobe *p) From patchwork Mon Feb 12 02:55:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 199571 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2204486dyd; Sun, 11 Feb 2024 18:58:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGAeJu+QH0AWnXwDtEQSAAegFkx8wuYtCtmz/Jf8Dco86tIpX7FaQs3Pg5PoVsUruAzLoAs X-Received: by 2002:a05:6358:800e:b0:179:2d7b:26f3 with SMTP id g14-20020a056358800e00b001792d7b26f3mr10035718rwn.3.1707706687658; Sun, 11 Feb 2024 18:58:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707706687; cv=pass; d=google.com; s=arc-20160816; b=JHJ1R+D1mZPqysJuZpQxnIm3YeD5jePuRMixTgiRU1y8zT3uACXe7s4t0hTY1Tp3gt GdvayO8MlvXMB6OdFOjgpvOvq4JZ1Av/5adkWU96KQFSUftEvxWQPwb97S7PhNzvzf6M POqy8PumVIAd5eQzV5OzHZC7oIMbveuNkbYdnc/jrz2zhUijmW29KfxJc2S0I+zDUgw4 aMdGF/ivGFkNjQtLnIfTLiXfB+ERNcsfqlkjz2csdxLSV2WIt0CGyMHHUFCyf7bqKoDP 4fAmFJ0bJKcv8SlkUr2Ajx1n3e5tKOp62JVrC/RAQ3rdCIw2fgBzRZnUKCBYHcxlE01M Ko4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=+lt2Zw8ci3FBMgsxbvxJ1Pjg/pitk5ttZsMbyNXtz18=; fh=GfnoV3bVeztZVYqNfb7w8Bq+fUYK2hqXjgsgUsyaeDY=; b=uGl7ltlBbhiKlV5swamCRpZgwlTr/c1I5/TgAl6+ZDwRQG+/wl5/jZ8JISCLye1dCb FJ5w1V1PjiabahddC0sVDgeFDK7YpIrOitryqS9yykrG4dw8tpWer+Zaz/OALSrkM7Pz xWAjqcWF+ER+C5CbwrbIv/WqZVvcrhnep/z3BGffbKNQZ14KTYfaTMcZkOrfGyhxtNTH 9SCSXAjvl44MmOfhQiwJG9mR6nEsLbq2Eq09kyDP4KqbWXHPZ0fHG7+qbog3pFjGkM1n h8JxkWSJoBBDxy62wpg9uEosvL9lms9CopBjofku5Y1kvQ8iCVBf1iHV2dlV84yVlHx/ C5kQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=Q7u+4E6n; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-61078-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61078-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com X-Forwarded-Encrypted: i=2; AJvYcCUnBTx2NEAdZWuJTm9wx9yuKa5eb3zSQbiFl0C0e3qkE4U3gKvCBuC0mcj4jYj491qgwmMFEWalsEHNBDvXhkwOLf24Yg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j8-20020a17090ae60800b00296645ac0e4si5482911pjy.67.2024.02.11.18.58.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 18:58:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61078-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=Q7u+4E6n; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-61078-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61078-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4AD84287486 for ; Mon, 12 Feb 2024 02:56:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A258A4C9C; Mon, 12 Feb 2024 02:55:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="Q7u+4E6n" Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 4E6D48C1D for ; Mon, 12 Feb 2024 02:55:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707706536; cv=none; b=K3T7nGeGFkfUHlnDEKVHNEPyF1CPGXNDpNAbkHD+Hz+Vk4sFcGgweln2PkiUWu6bWOJSIBADoDUxvC96lF3KmJp5u4reFu3jne654nMw8aeKSUAgQVTODB8XLRJyN41TfpontE3PnTxGlQrQND1WECEbh8v9c/5zCEufswY84OA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707706536; c=relaxed/simple; bh=FfLB9kZNEE0mzUFK+6fXY29r9iKKYgvLMRPENpobDoM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sxu1rN8gQBjmRQ0TOyc7o/83TmMGorQPdfBIU1/T04oUjtpwfzRHOSU50jy397BCoie4iP+JPX1hbGzJSVoeNhhEY2vDwF4+yMdO3uX8PbAFXG1con6vh1UHYVdfNyKtttr0suJookR2aMLCmu+H3AHZYeeYkTVYrsAmrnoqOoM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=Q7u+4E6n; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1d944e8f367so18143685ad.0 for ; Sun, 11 Feb 2024 18:55:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1707706534; x=1708311334; 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=+lt2Zw8ci3FBMgsxbvxJ1Pjg/pitk5ttZsMbyNXtz18=; b=Q7u+4E6nEn57xSQ+jMaSfTXNIAVVT0XnUvDBRjdVYgxj0LIJBffye3IRLZGCBGtB8/ Mw4pq5OZaT4df8C0IaaV0JH0KEdNf93I8u6O2dAIMCgJEsdugdkx4I6uOcZTtiEKLKpX jd7tDJ2eZI3M75NZghyXG3MTBW2vXXfXaWKYu12767MNsCJreS3fV3ag583Q5z4tLCJc PurLBSewSqSwS9lc+jHgJQfe4an8NF1wzfdv2e+XS+/2BLzOHT3NEHnoWvs7RtcACH1g AcSI+B9G3lQNievwnhnM4VSAC256pZE65P9o1p4ZMkF1fFsfX8VDL34TlJMBLrabjKDN Ympg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707706534; x=1708311334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+lt2Zw8ci3FBMgsxbvxJ1Pjg/pitk5ttZsMbyNXtz18=; b=aAnlAw5/n2aAMjnk0rP70BwHG0HLFGusagzCs5VKJfwfOGONAm9RCfwDHviV4n3Hk6 w4ab9LJbwrXav01G/6qHH5whb+g/zf3siylps8NlYsN6m7+WVQ9+qy7ePmNHUymj2o5E pJIdcYJ1uJ0D/Q5L5hckRxBaAzrR+L3xSSgzyFvZF5m8doIau0z64kVAKeZz0g63G33n Ovny1bYRHfnHQKyBS8YrWNDfrE4A64r4FfJHaTZxcw7YnkgxfeLkOG9oXrd5P9IZ1g35 W/h84d240C/Joh/d7Tm5rfE/qwpMBy+os3L49YwaMqbXMjPCki09H464GrKAor1eh8Ou QE8A== X-Gm-Message-State: AOJu0YwscDd3YKVV7EiO/MqSa2YaDG4c/DXd/8eqTQCMR61Aob+iUIo4 rR8NKVjiVAglm3kAiyceipk1YxghAHTfKxQ4OZP/jNVkSXUOp6HQ2YdFBVpNmEc= X-Received: by 2002:a17:902:c412:b0:1da:2bd6:a450 with SMTP id k18-20020a170902c41200b001da2bd6a450mr2170203plk.32.1707706534554; Sun, 11 Feb 2024 18:55:34 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUFMcthFL4l/bTCJyUVKIFRBG6Uzr3J1H/8KTDyjhZF+VEX0+59ZHlo17zAIHsqjff6iEJHbL5ZnLE1y5qPIbZtcNiH5g1S2cNMGOkIIb1/slKb0HWnZF9jNLbDe4rF1SmjOZQImKvG Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id lb3-20020a170902fa4300b001d9af77893esm4906443plb.58.2024.02.11.18.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 18:55:34 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Samuel Holland Subject: [PATCH 4/7] riscv: Simplify text patching loops Date: Sun, 11 Feb 2024 18:55:15 -0800 Message-ID: <20240212025529.1971876-5-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212025529.1971876-1-samuel.holland@sifive.com> References: <20240212025529.1971876-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790660247735894295 X-GMAIL-MSGID: 1790660247735894295 This reduces the number of variables and makes the code easier to parse. Signed-off-by: Samuel Holland --- arch/riscv/kernel/patch.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c index bccd9ed04a05..7f030b46eae5 100644 --- a/arch/riscv/kernel/patch.c +++ b/arch/riscv/kernel/patch.c @@ -155,7 +155,6 @@ NOKPROBE_SYMBOL(__patch_insn_write); static int patch_insn_set(void *addr, u8 c, size_t len) { - size_t patched = 0; size_t size; int ret = 0; @@ -163,11 +162,12 @@ static int patch_insn_set(void *addr, u8 c, size_t len) * __patch_insn_set() can only work on 2 pages at a time so call it in a * loop with len <= 2 * PAGE_SIZE. */ - while (patched < len && !ret) { - size = min_t(size_t, PAGE_SIZE * 2 - offset_in_page(addr + patched), len - patched); - ret = __patch_insn_set(addr + patched, c, size); + while (len && !ret) { + size = min_t(size_t, PAGE_SIZE * 2 - offset_in_page(addr), len); + ret = __patch_insn_set(addr, c, size); - patched += size; + addr += size; + len -= size; } return ret; @@ -190,7 +190,6 @@ NOKPROBE_SYMBOL(patch_text_set_nosync); int patch_insn_write(void *addr, const void *insn, size_t len) { - size_t patched = 0; size_t size; int ret = 0; @@ -198,11 +197,13 @@ int patch_insn_write(void *addr, const void *insn, size_t len) * Copy the instructions to the destination address, two pages at a time * because __patch_insn_write() can only handle len <= 2 * PAGE_SIZE. */ - while (patched < len && !ret) { - size = min_t(size_t, PAGE_SIZE * 2 - offset_in_page(addr + patched), len - patched); - ret = __patch_insn_write(addr + patched, insn + patched, size); + while (len && !ret) { + size = min_t(size_t, PAGE_SIZE * 2 - offset_in_page(addr), len); + ret = __patch_insn_write(addr, insn, size); - patched += size; + addr += size; + insn += size; + len -= size; } return ret; From patchwork Mon Feb 12 02:55:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 199573 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2204928dyd; Sun, 11 Feb 2024 18:59:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVY8rKwT8qh7OlOIRGpPp6X7GzVD+/f7dCyCI91eLGwG4EnZHhlU8df5/Z4EC81NjsSr2NR/Oq+d49V2Mm2bSZQthaDOA== X-Google-Smtp-Source: AGHT+IGJbKrP2YJH0jfA6SZtpmfDwcRfvQYhxTOLXrv1DLS9wgeF+8p/56Mhe5B0dB7azPBAUGqj X-Received: by 2002:a05:6a20:d708:b0:19e:bc25:c7de with SMTP id iz8-20020a056a20d70800b0019ebc25c7demr9646838pzb.48.1707706797118; Sun, 11 Feb 2024 18:59:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707706797; cv=pass; d=google.com; s=arc-20160816; b=w9wDYzWPAgZqY0B9h/2Qj6ImHx4SXGEr8B7yscxvzrqfA1aVf3wfBVueE+eO6gGF1W zT/72o96qBUvSnkZxr7y37Bi4b3rTlgWLmmaMQ0L4cTjHD3Torq3RPwNL9fGil1XWosK 09Kd8sQVoUG0rbX99Km408Ct6g41oQFe/IENy/35e7C9TMAsCcUHNP1NQgoRWjrQMlqb uIl8twOJ7BlseMcHiU1lWRoZhlg9PzZUa/2CjI0+eJpxPCqTle/7Q91R3EZHPYgR5uZF IWJBElC8HTvXAHzFQeVlswaee5bmFrsZZLAhEK3Jl1e7I4z4vfJxd/6qTR+USKtOBfV8 i1bA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6J8NdLE0ucNiNKFND0rK4zdkXC5jx9zUaL7zwsJdJPc=; fh=mop92PRpdkC2sJnDe0LQnOg4p21ndKzlf3YIxxEpJIw=; b=jB4nNwfHQ2nKjSs+z6mBpM/fQJjnHKFrbsiysqKcEqMD8tomL0qjNwGHd2tSVxCFA7 hufNzX9d0HnigX89AsMbiDEn4lkAujkJUDIjU4sXxA55tYef+jRXcxP8UHmQ7Ii7tyyR RMYIfWi3rJJ4Z/i0Zx6sJe4PDTMb/J/3GtxEtpJmtuKHZinniRMqbV+gG/EJQWhYADVP eZ8E/f8jI8ek4zyJFCwwhzXcOpw8JxvEwv/XrM0UXBDvOe3tM9pdU2YFdsFCAiQPW00n 5oWjLrGt4iIfDuqlhApaygR+r2QXlscOXMXHkF3a8SMUGgKQBwbzO5/a2voJZsRWeZb3 CHDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=PahwK4Ny; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-61079-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61079-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com X-Forwarded-Encrypted: i=2; AJvYcCURPcMqlvDf293fMBPCsUAyvyCky5IIk9E1VcBiLHhO55tlFMK++Bqok0VELhCDFL4E78Vi/TberVrFgciUZJap7TYv/Q== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c21-20020a056a000ad500b006e03381d1ddsi4346288pfl.343.2024.02.11.18.59.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 18:59:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61079-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=PahwK4Ny; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-61079-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61079-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id F3F12B22857 for ; Mon, 12 Feb 2024 02:57:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CB3D7483; Mon, 12 Feb 2024 02:55:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="PahwK4Ny" Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 2BAB1D516 for ; Mon, 12 Feb 2024 02:55:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707706537; cv=none; b=HIB3XobClhaymFEw6ve9Fy3XjmgOSFgseZmXLu86/uhLbpurUnfZFTZ+BchmmN7srS2jOuW+Qsz69J95Cp/zpmSidDfKz3Now98u2kYlQEK+/H3kTM8W/bWNRSPQG4sTWq8KTybMIo+2nvU62K0ub8venmF70K32lAlmzdOcW1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707706537; c=relaxed/simple; bh=AXO7VsflvKGWTnEvz0+V2dNgfy1ulMK/F7UiLVzpIV0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S9wARA3NhP8ICjWUH6yiJUTZX88l0ePeHe5EqGsypIM/osdx3qbcN+/SrWTtLMoUZlWWgCKhwBhVD0NUmwSYrc5tmOm73PE247BUz0RWz++0ClMGN5kj2mScB/qJEL/pAIF7xnLG1pYJLKT2qbnfI+0KWlGs15AQUZe1iwD6YKY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=PahwK4Ny; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1d953fa3286so21300365ad.2 for ; Sun, 11 Feb 2024 18:55:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1707706535; x=1708311335; 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=6J8NdLE0ucNiNKFND0rK4zdkXC5jx9zUaL7zwsJdJPc=; b=PahwK4NyuQ04a94ZVkBg4mEywR/its8gyuo29TCJ/e+ePRZn8l6xK6IWUJqJybOS4F jG4XsUxVw0Lsck4UQaXaVTpH6bLu3cwQ5Uh0AtCjpaCoEkduPPtFSU0FC8RgCJ2r8lX3 UxxXpxa7nljntlZNP+UrtM1PSimWng9GA0iEtai+Y7eheAgFOEYAUY5N1DtWTrKwVvhP ZYCeu5dlM5Yy4/Eu3DwwquIw0Zdeh9JhvatjA+Wqemw4w/BvfeFJYunENmvcxPPDbkCd RSHaLwsURRGW2qwRygAUONw5jKoQ22F0KVpMcuHTh0VW2CXG8so0AHr4tRm9bqLLhZS8 HB3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707706535; x=1708311335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6J8NdLE0ucNiNKFND0rK4zdkXC5jx9zUaL7zwsJdJPc=; b=nHS9X4TECGOGbzvQlCeUbHqd318FjnrIj1526V4w2DzZZZux9CHi/6PpVz6890FCgg OWcNxr8P5osHoRWjHM/WFgvD87zL56+DhGqsRyNZ+HX9FJ4Yz5CA721TjXZq4PPp5Cyo mBlllXUN42m2tZHN2tRsUwpFezVTWNfnSVlxUuDM5ta8CSIMmqmBMP8f68Z6366G4SzG u8RljJS1E4OfLtdyY4cv84/MxF5HV62Zvj6K+5Rb5/rU/hKBI4ycPDALzpO8GfRNhcWu Cctpa2biEa+N+AwGzFyYQQmUg99Su3XxMIsUUV74vUWDcLTjqzqB6Aq0CqJ/RY8Chxar y/3g== X-Forwarded-Encrypted: i=1; AJvYcCVYIOH7KAgy6VRjba9TEPLCsQLydCUZTUZQQmAlfpvOs9kvSUoHc7gp3mkj0AhtNJD/WKECfc1sXCoLKTj7mSJ9sI6jCYBuYnWj+qu1 X-Gm-Message-State: AOJu0YyEzVYn9WD0i2tV5+6RHWguYsufEnX1HCExeAKS6BAkTAqmAtBK o54vHEYnoTIQNciJIMmDQF0udo0bbtjHhkXBWAlUksk4SD0E8yGkH9ZUHsZuimc= X-Received: by 2002:a17:903:25d2:b0:1d9:ed80:607f with SMTP id jc18-20020a17090325d200b001d9ed80607fmr5933876plb.41.1707706535523; Sun, 11 Feb 2024 18:55:35 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXMVP8J2/uywWjIa8v+LtUBwTbCg6k4nUS11lldS4d4SPpgOkiUESJKifpQiePYf+5sb5RPwR8/2RD7ppjseWiDMb+tH3c47JIEhVd/KYoxUfEzqxLbMUoa1Z6QGicm0wv/0P7m6Mt2up3tJ9kh5+AfUU29Up1ThFadmZrNYH3Ghb/6ZESNPzpIMTLZVkLg6+08WA== Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id lb3-20020a170902fa4300b001d9af77893esm4906443plb.58.2024.02.11.18.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 18:55:35 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Samuel Holland , Daniel Borkmann , bpf@vger.kernel.org Subject: [PATCH 5/7] riscv: Pass patch_text() the length in bytes Date: Sun, 11 Feb 2024 18:55:16 -0800 Message-ID: <20240212025529.1971876-6-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212025529.1971876-1-samuel.holland@sifive.com> References: <20240212025529.1971876-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790660362497882084 X-GMAIL-MSGID: 1790660362497882084 patch_text_nosync() already handles an arbitrary length of code, so this removes a superfluous loop and reduces the number of icache flushes. Signed-off-by: Samuel Holland Reviewed-by: Björn Töpel --- arch/riscv/include/asm/patch.h | 2 +- arch/riscv/kernel/patch.c | 15 +++++---------- arch/riscv/kernel/probes/kprobes.c | 20 +++++++++++--------- arch/riscv/net/bpf_jit_comp64.c | 7 ++++--- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/arch/riscv/include/asm/patch.h b/arch/riscv/include/asm/patch.h index 9f5d6e14c405..7228e266b9a1 100644 --- a/arch/riscv/include/asm/patch.h +++ b/arch/riscv/include/asm/patch.h @@ -9,7 +9,7 @@ int patch_insn_write(void *addr, const void *insn, size_t len); int patch_text_nosync(void *addr, const void *insns, size_t len); int patch_text_set_nosync(void *addr, u8 c, size_t len); -int patch_text(void *addr, u32 *insns, int ninsns); +int patch_text(void *addr, u32 *insns, size_t len); extern int riscv_patch_in_stop_machine; diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c index 7f030b46eae5..9aa0050225c0 100644 --- a/arch/riscv/kernel/patch.c +++ b/arch/riscv/kernel/patch.c @@ -19,7 +19,7 @@ struct patch_insn { void *addr; u32 *insns; - int ninsns; + size_t len; atomic_t cpu_count; }; @@ -227,15 +227,10 @@ NOKPROBE_SYMBOL(patch_text_nosync); static int patch_text_cb(void *data) { struct patch_insn *patch = data; - unsigned long len; - int i, ret = 0; + int ret = 0; if (atomic_inc_return(&patch->cpu_count) == num_online_cpus()) { - for (i = 0; ret == 0 && i < patch->ninsns; i++) { - len = GET_INSN_LENGTH(patch->insns[i]); - ret = patch_text_nosync(patch->addr + i * len, - &patch->insns[i], len); - } + ret = patch_text_nosync(patch->addr, patch->insns, patch->len); atomic_inc(&patch->cpu_count); } else { while (atomic_read(&patch->cpu_count) <= num_online_cpus()) @@ -247,13 +242,13 @@ static int patch_text_cb(void *data) } NOKPROBE_SYMBOL(patch_text_cb); -int patch_text(void *addr, u32 *insns, int ninsns) +int patch_text(void *addr, u32 *insns, size_t len) { int ret; struct patch_insn patch = { .addr = addr, .insns = insns, - .ninsns = ninsns, + .len = len, .cpu_count = ATOMIC_INIT(0), }; diff --git a/arch/riscv/kernel/probes/kprobes.c b/arch/riscv/kernel/probes/kprobes.c index cbf8197072bf..a64461fa715c 100644 --- a/arch/riscv/kernel/probes/kprobes.c +++ b/arch/riscv/kernel/probes/kprobes.c @@ -23,14 +23,14 @@ post_kprobe_handler(struct kprobe *, struct kprobe_ctlblk *, struct pt_regs *); static void __kprobes arch_prepare_ss_slot(struct kprobe *p) { + size_t len = GET_INSN_LENGTH(p->opcode); u32 insn = __BUG_INSN_32; - unsigned long offset = GET_INSN_LENGTH(p->opcode); - p->ainsn.api.restore = (unsigned long)p->addr + offset; + p->ainsn.api.restore = (unsigned long)p->addr + len; - patch_text_nosync(p->ainsn.api.insn, &p->opcode, 1); - patch_text_nosync(p->ainsn.api.insn + offset, - &insn, 1); + patch_text_nosync(p->ainsn.api.insn, &p->opcode, len); + patch_text_nosync(p->ainsn.api.insn + len, + &insn, GET_INSN_LENGTH(insn)); } static void __kprobes arch_prepare_simulate(struct kprobe *p) @@ -117,16 +117,18 @@ void *alloc_insn_page(void) /* install breakpoint in text */ void __kprobes arch_arm_kprobe(struct kprobe *p) { - u32 insn = (p->opcode & __INSN_LENGTH_MASK) == __INSN_LENGTH_32 ? - __BUG_INSN_32 : __BUG_INSN_16; + size_t len = GET_INSN_LENGTH(p->opcode); + u32 insn = len == 4 ? __BUG_INSN_32 : __BUG_INSN_16; - patch_text(p->addr, &insn, 1); + patch_text(p->addr, &insn, len); } /* remove breakpoint from text */ void __kprobes arch_disarm_kprobe(struct kprobe *p) { - patch_text(p->addr, &p->opcode, 1); + size_t len = GET_INSN_LENGTH(p->opcode); + + patch_text(p->addr, &p->opcode, len); } void __kprobes arch_remove_kprobe(struct kprobe *p) diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c index 719a97e7edb2..43be2585f0d4 100644 --- a/arch/riscv/net/bpf_jit_comp64.c +++ b/arch/riscv/net/bpf_jit_comp64.c @@ -14,6 +14,7 @@ #include "bpf_jit.h" #define RV_FENTRY_NINSNS 2 +#define RV_FENTRY_NBYTES (RV_FENTRY_NINSNS * 4) #define RV_REG_TCC RV_REG_A6 #define RV_REG_TCC_SAVED RV_REG_S6 /* Store A6 in S6 if program do calls */ @@ -681,7 +682,7 @@ int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type poke_type, if (ret) return ret; - if (memcmp(ip, old_insns, RV_FENTRY_NINSNS * 4)) + if (memcmp(ip, old_insns, RV_FENTRY_NBYTES)) return -EFAULT; ret = gen_jump_or_nops(new_addr, ip, new_insns, is_call); @@ -690,8 +691,8 @@ int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type poke_type, cpus_read_lock(); mutex_lock(&text_mutex); - if (memcmp(ip, new_insns, RV_FENTRY_NINSNS * 4)) - ret = patch_text(ip, new_insns, RV_FENTRY_NINSNS); + if (memcmp(ip, new_insns, RV_FENTRY_NBYTES)) + ret = patch_text(ip, new_insns, RV_FENTRY_NBYTES); mutex_unlock(&text_mutex); cpus_read_unlock(); From patchwork Mon Feb 12 02:55:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 199574 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2204987dyd; Sun, 11 Feb 2024 19:00:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUKacJnvt7dR1HQ8tM2Gr7mCby5WPOg+CClYhnWHe5iqpfHNI7qxWcTO7L5OgrO3VQ+Ti6 X-Received: by 2002:a54:449a:0:b0:3c0:3d8b:1c84 with SMTP id v26-20020a54449a000000b003c03d8b1c84mr6579oiv.37.1707706806724; Sun, 11 Feb 2024 19:00:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707706806; cv=pass; d=google.com; s=arc-20160816; b=FCmQ/xSPV0zr0lLpJaO0n6xV76gEn0nKxmf7lv1/X52CaMVby8X5XAPYbNCEYXK88d vM6KLz0MR0j8QHpiGGG2VR3DO5bpcQbRLs26+zMWTO+xYSSU6x/EkAm8f24Q6Gtz6dpp aSgWffNQshK38m+FzSAhWPIWO1zQZzdaWMY+5MxWoulwSmbvykvmhq9gwTvbpa35YaJX cRgLqOp+yreqXRXEbaLCszdNsV9huSLZmPDm7lT13dxrbSPWuyNTHPmCzDbYZ28gelfA LLhlNxBmv/F1QY5Pw0JxIyRzQb2iGoyHawwZC9WfZfUo39b5CrKpkMAcKPBIdykyxF+X z58Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=PK2hM2nZE9ySNRKSB/nk6SwrsE+3tTyo2UQmA0OZOPw=; fh=Un8Sj/w/eMhmgKEn2iLGiTpQGgV5YIRkrxRlNBcN1Hg=; b=bxfaT625mIx5KW3/xiE6TncJBsrK2Qp9JtvC/9ZIx7gkpyYReKBHcMva2HNFT4kYxB b97GgW/HsAaFITnQ2jbe86jSYJmCPUkasR65e0ddi6muKmSkt9zJYOUaTwi8kctXa1ql 0vLlf+GAjceduGgaOsgxFFcYllBeF8PRxCo6hnCJLEtRxjcIKyDF0mSUFe2pSEm/+C2o ilrjK6eVudKtJqIfp3oinRI4pN4GSa5XQcAfp//Ghlh04rHvroZDQpjaYRUWFPOuWm1b 0L22SwI0YIXmKpJ09fFVRD5dcVnmr82ubWSog9j2xIpScAVgvGLYvzn4dMLFI4eiDOsl WlHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=BZQ0LUb3; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-61080-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61080-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com X-Forwarded-Encrypted: i=2; AJvYcCVpsNfebFXAmapVvmfM96KzzM9oP12sV0EBW8uGn7NdjPcFUPjlqhjc7rU+Em0rJiaSb6uBZcgwaLMcMvMgXQJEwUCuJA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c21-20020a056a000ad500b006e03381d1ddsi4346288pfl.343.2024.02.11.19.00.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 19:00:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61080-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=BZQ0LUb3; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-61080-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61080-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 56368B22A57 for ; Mon, 12 Feb 2024 02:57:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9A5363DD; Mon, 12 Feb 2024 02:55:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="BZQ0LUb3" Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (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 79686F9FD for ; Mon, 12 Feb 2024 02:55:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707706539; cv=none; b=Z+0meDHxbuMvR3hFA9FVyRj0BaRNm6NoDjvXcfKjSffxew3cjEGwjA/sn388gpuoOxkebVqbknt7oUQKJ31MQei4LQGPBTDtqvrQZ6Zrb6TbXzEHO/bLXYWMyZs/YI1Q0Yd9tdXOaYCzMSj0WPRxqTTVGfioAgpsTQsoH2C86Ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707706539; c=relaxed/simple; bh=IaMQ9U5EU7ibbNGTdLeyIyKmzolIE/sYWan1D8m1xQU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IXQtLKVGgbo5xEkWyOY6DEovJA+9hQDeTsNtipDc/EodrSLxBVphZwJT+TLQjh9JhgeeAy+pZWHW1Vl59725oLu/WBl8FaVz39T5PI1w6Pk0QQ4z+Yeu7m2D4qfVUWMKYNQ9+qffl+opkjPODAkslq7X0qEMZAi83ii2He1D/is= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=BZQ0LUb3; arc=none smtp.client-ip=209.85.222.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-7838af983c1so241469385a.3 for ; Sun, 11 Feb 2024 18:55:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1707706536; x=1708311336; 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=PK2hM2nZE9ySNRKSB/nk6SwrsE+3tTyo2UQmA0OZOPw=; b=BZQ0LUb3v3O9HrUfsj1ReEptXshrZriu2nmMmrdL1GfVzrMorI45Olgm2Na1EvgPPn pd7xwKyesShxNrH33csfgkBbWkXrPMvDmZan3ESNWq3uhraTKlyGmChE9RsB/Asv8NmD uqnpexoLZb+JNlN4o5VauLAC4GwAoTAOG2fA9iWISXcMRkLv0XFIB29KfxVMtdoayWS+ sWSUQkNEXtYwUDIqhwxbr6EMS9g44AU5nLVO7h4t7QR9+I8H5T+vuuIooBwDZLgCzxgR Tl6AbLC7v+3VxUhyHOOZukxkgc5oQW5FRMmgczhjdveFSBE31CTD8lTdW1opTd25P5AP ipag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707706536; x=1708311336; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PK2hM2nZE9ySNRKSB/nk6SwrsE+3tTyo2UQmA0OZOPw=; b=cQc+CGEgeYmb8/n9x673gMCfxP7rUB/NF80Zctux+fi3NQSBYLMLnoOtltD8iViFsI +xhIeVaHS/j/Ty2Oc5nqIN4p1WX4IHy9AsGvW+/4IGPDsdFlT87yZ7pYaheFTUMIQlGX lSdLSv3CNgeNCpu2qPvOYHjWYrqE6B4pCXfywkKk9qpqgB2jQbIliWWPWeWF3+yc6WE4 VuShbdtl+sn4ZE5EspsOUcJsH8xb3J1k8w0h/3WtWzlssVd45oshjcX97AihnW609E1R k0cI6jQBr5bpEVppwu/Ic1EaFNufZowB5O0UPgj/PVvPWVpCEr8OloauHCqD1ka4VSIU hCEw== X-Gm-Message-State: AOJu0Yx7NB74OhoCBCYHKc/6+AUYO8PueGZhHud/sUoulnzWeqYEH/ZG Q2piBe43KWIZgYHsOv/EQEO6DUnC0JqH3MyNT6pl3RiMfQ5g8tS3ek/g9uOxsvM= X-Received: by 2002:a05:620a:4492:b0:785:afa3:6c0b with SMTP id x18-20020a05620a449200b00785afa36c0bmr8529739qkp.52.1707706536469; Sun, 11 Feb 2024 18:55:36 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX+KlvTiXx022Iyrq5kcQK+MzTTlcaxsSbYU2t+6MhI5RpPjrlocOnjYKK/WCv3H83/9SWx7WX/BFI+bbrFB0A4cr9omAmYvnt7rtoYc7xaGrWDlBZz5xD632qkgPpJq6IWM1seYeIr Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id lb3-20020a170902fa4300b001d9af77893esm4906443plb.58.2024.02.11.18.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 18:55:36 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Samuel Holland Subject: [PATCH 6/7] riscv: Use offset_in_page() in text patching functions Date: Sun, 11 Feb 2024 18:55:17 -0800 Message-ID: <20240212025529.1971876-7-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212025529.1971876-1-samuel.holland@sifive.com> References: <20240212025529.1971876-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790660372173384876 X-GMAIL-MSGID: 1790660372173384876 This is a bit easier to parse than the equivalent bit manipulation. Signed-off-by: Samuel Holland Reviewed-by: Björn Töpel --- arch/riscv/kernel/patch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c index 9aa0050225c0..b0cf050738aa 100644 --- a/arch/riscv/kernel/patch.c +++ b/arch/riscv/kernel/patch.c @@ -54,7 +54,7 @@ static __always_inline void *patch_map(void *addr, const unsigned int fixmap) BUG_ON(!page); return (void *)set_fixmap_offset(fixmap, page_to_phys(page) + - (uintaddr & ~PAGE_MASK)); + offset_in_page(addr)); } static void patch_unmap(int fixmap) @@ -65,8 +65,8 @@ NOKPROBE_SYMBOL(patch_unmap); static int __patch_insn_set(void *addr, u8 c, size_t len) { + bool across_pages = (offset_in_page(addr) + len) > PAGE_SIZE; void *waddr = addr; - bool across_pages = (((uintptr_t)addr & ~PAGE_MASK) + len) > PAGE_SIZE; /* * Only two pages can be mapped at a time for writing. @@ -98,8 +98,8 @@ NOKPROBE_SYMBOL(__patch_insn_set); static int __patch_insn_write(void *addr, const void *insn, size_t len) { + bool across_pages = (offset_in_page(addr) + len) > PAGE_SIZE; void *waddr = addr; - bool across_pages = (((uintptr_t) addr & ~PAGE_MASK) + len) > PAGE_SIZE; int ret; /* From patchwork Mon Feb 12 02:55:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 199575 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2205046dyd; Sun, 11 Feb 2024 19:00:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNbtfTFJ2QQcpKwlCBVLyxlUn0FJwh2ipvBArqmkSfHPdowC7zuAgOi/vof1NF4Z7ynoUE X-Received: by 2002:a05:6e02:12c7:b0:363:acc1:5003 with SMTP id i7-20020a056e0212c700b00363acc15003mr8259162ilm.31.1707706814816; Sun, 11 Feb 2024 19:00:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707706814; cv=pass; d=google.com; s=arc-20160816; b=CoZUTfAtiMYGDUB5iR0EewggMeUP+wFusOnkW20gyD/EQpdjItdiYhd00ydyOOjHoR WSF4+cEbRLmOXunbcLJ8ktuUFfcqN+XqDeazuJQ0V8VXqOa3W0s+Wm9L825iELQk74GC btkLWpUT7knBYsypgj08yz54I/AP+5yi4tPRH6Nn/Uu+wASdcTqY1s4oXA/Ynqj0i0jV KnDt3t0IWwvk80eVmNqBQ9DLeeyhs25mrG4CTFAt26xM3JLP2lPBAzNYM5kNk4HF9KZK c5ZdpjrOBv7vnBnbbSbmTAFsryTH4NIHa5SIzwCMiOMSXGtQYY1apbZHVEWH7MpvzKk2 fQWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Ox1XwYN/8KUHgBEQv3P+eTmNJiT79C/wgnmP2bJX61k=; fh=6Nr/YHUofWqpFH30Oh0uZo2/UFEcCKkOeWriYrLDzvk=; b=Qx/0xV9OLm/P6QOLF3eg0ddpFJ+sirB5JzINei8XT9Z5/Oj9oRxgPEHxRsKXN16eTg 1Jv6q676vkvAn9w0D867YiFpKBV+DGxXVVsybNLylHBmERrJ2hLLQ51JUv3MphNmpAiP p1AO7rryfUV7PlYCDBUfkz/QCuT6srZdiQxLZtWQ9EKRYYPGgMz23mZdK+TiVw+eiO7h 9U2ymjOpBh+zv926f7zGCYc3GcY8xaHX3T2NbfaYWh94RPaF90hCkkJgIE73JER1hQym TW8VlcBl5UfteMkWfIQ3tE6OB0M+pLwW9D8HzkjRMuWv9X5ePszOaeXcZ2igX/FJ3bsl /tIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=jdyyW5hJ; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-61081-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61081-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com X-Forwarded-Encrypted: i=2; AJvYcCXjMOp4sJvZx1v0GoCtlebvTLF8KQxzpMpJcn53b15AZuonp0Q+WszMV7K02R8x8otJhs7nIM9hVwFhy/nDGAhla/acMA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id p24-20020a637f58000000b005dc4c1f8c5dsi5840373pgn.579.2024.02.11.19.00.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 19:00:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61081-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=jdyyW5hJ; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-61081-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61081-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8E8D3B22AF2 for ; Mon, 12 Feb 2024 02:57:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CDBA111B1; Mon, 12 Feb 2024 02:55:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="jdyyW5hJ" Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 2596D107B4 for ; Mon, 12 Feb 2024 02:55:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707706539; cv=none; b=d0QwOqwc8MHFz31MNzYVfPqqgNScRsHllhHzvuvrLgZepEhVR1K+B5ept3jLqS2IOXXdr+Qszad6WYail9QG4kQCtSEiE6HhWwTPrYo43t2I4NVcRB8BNxWhcwJ+Gm9HGb+PnF/feTOlXDesuU/RpJuV5kSF5zn+msUPdE+vE5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707706539; c=relaxed/simple; bh=UttEtih3z9yX90IGUQyC21qiA8cAYwBHPSzo6eqGVuk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sWG5OWYLI3QFcGFeR/6oCt2sTglsg4srNViO6/kk3a+ws5UAlM2A5eE97ifRbl+9qntb9Wx7co4GsFU7OfkpSECe0LJivjLbPWcnz5LqFi4wMJqIvIkSibZ1uxjXXPn+C+kKRLTrSvjvqb9ai3FbmCjpdvAJhk+YRofsJVxnn4Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=jdyyW5hJ; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1d93ddd76adso18932705ad.2 for ; Sun, 11 Feb 2024 18:55:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1707706537; x=1708311337; 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=Ox1XwYN/8KUHgBEQv3P+eTmNJiT79C/wgnmP2bJX61k=; b=jdyyW5hJtNaKAH3J7syG/qH9SJm1y82cwy/l/Y2OrkSZijS9isSYbqq51rd7dL9DH0 zk0qNHhYTqIp99/FvZKxPyrJvGgg5Bhy9bDCARh67WOf4pSK0R0s4SVsx0ILwSz+Jzxz bg5PA9RTDcp+mAkr4TFok10bwCDIkq0zEUaWdfAc3RaiQNqlpX20or6uVVcZlNbZxcdR CU+xAavVv0/BcMrgBxxirvIu5sCW23STdP8wBu0XwtXEsoR0NY9AbRzxyf+IFsTSAz2U GC67csQb7c8HL/FZNEOAqSyXrvN8c2WbQFRgiKC4JAbcd+3g7nf+Tq0P0CP7ZfTVIHhF vxdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707706537; x=1708311337; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ox1XwYN/8KUHgBEQv3P+eTmNJiT79C/wgnmP2bJX61k=; b=lef/ic9RTsz+vhGDfUKkssBu/LSHx3n+U2pxC+tnqSIp0DPimNz9RXSTGWLW8l/Jd6 /J/8iHFaTAwgvF22wpqPmjE/AxrU62wG/iXfb/pM7LvJXFB6xziRQpS3GkPf6kEOypd4 tf9mvHMC5n4h4O6q6H3j0NsmLh4kyp3kfld7aYGHD1A3LPKTqg5GPY4axkrH+Amga6+Q bfz8gcEMZ8H+KjZWf16DgrqNNqdrRfIt6sVbD5DkrxECC/V7xM+9QwM5m7qDjP60/8Cr M9kgedDJzjAQIYj8NwYxC1Hsj0i7hsvdKr2wIW820fI926kegOF6f/XwHuHamYue3hJF mqgQ== X-Gm-Message-State: AOJu0Yz/WFUEuj7z+sqh8harzDbbdrjSI47MI/SztsCBhcGfZ+Ha74yJ 8Lqs1MEn8NvOYScdBnd/SEoIR/v739IGG5xTekeLBcY+TrIXRPP9OhZEli2uxy8= X-Received: by 2002:a17:902:ec91:b0:1d9:a148:48a with SMTP id x17-20020a170902ec9100b001d9a148048amr6334084plg.24.1707706537479; Sun, 11 Feb 2024 18:55:37 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWSKmmJnT8/3BSU7Qh0RzNAg0qQ1juI97gXPgba5vC2fWKScLl4PX6qPshaybpKTz5/v3owJsCFEwiJlXAtPYFw/embDaV2OphOMNya5Shdc8dllDXVfo1lnQ+DisEUKB9rWLv40/ii Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id lb3-20020a170902fa4300b001d9af77893esm4906443plb.58.2024.02.11.18.55.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 18:55:37 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Samuel Holland Subject: [PATCH 7/7] riscv: Remove extra variable in patch_text_nosync() Date: Sun, 11 Feb 2024 18:55:18 -0800 Message-ID: <20240212025529.1971876-8-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212025529.1971876-1-samuel.holland@sifive.com> References: <20240212025529.1971876-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790660380945584747 X-GMAIL-MSGID: 1790660380945584747 This cast is superfluous, and is incorrect anyway if compressed instructions may be present. Signed-off-by: Samuel Holland Reviewed-by: Björn Töpel --- arch/riscv/kernel/patch.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c index b0cf050738aa..80755aa627d2 100644 --- a/arch/riscv/kernel/patch.c +++ b/arch/riscv/kernel/patch.c @@ -176,13 +176,11 @@ NOKPROBE_SYMBOL(patch_insn_set); int patch_text_set_nosync(void *addr, u8 c, size_t len) { - u32 *tp = addr; int ret; - ret = patch_insn_set(tp, c, len); - + ret = patch_insn_set(addr, c, len); if (!ret) - flush_icache_range((uintptr_t)tp, (uintptr_t)tp + len); + flush_icache_range((uintptr_t)addr, (uintptr_t)addr + len); return ret; } @@ -212,13 +210,11 @@ NOKPROBE_SYMBOL(patch_insn_write); int patch_text_nosync(void *addr, const void *insns, size_t len) { - u32 *tp = addr; int ret; - ret = patch_insn_write(tp, insns, len); - + ret = patch_insn_write(addr, insns, len); if (!ret) - flush_icache_range((uintptr_t) tp, (uintptr_t) tp + len); + flush_icache_range((uintptr_t)addr, (uintptr_t)addr + len); return ret; }