Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp326306lqd; Wed, 24 Apr 2024 03:44:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV9NQBl9fbg0MwS84gypkaiVAZpGyypprB/T0Smnfv9QU8AnccdNOABCrWcP6JfWV4WY7DCTeMW8Rgib8mluqjzkhyy/MOQzN4plfvRfQ== X-Google-Smtp-Source: AGHT+IG7EOStspYSVlRo0Xpnnh3qYOyBWx3NscDC9RNMQfUJYur4IRMyqpy07HPYTga5MrnUfmbt X-Received: by 2002:a17:902:b08a:b0:1e2:8841:8d67 with SMTP id p10-20020a170902b08a00b001e288418d67mr2261278plr.32.1713955466671; Wed, 24 Apr 2024 03:44:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713955466; cv=pass; d=google.com; s=arc-20160816; b=S97hGv/4SgS96uDcl9tbldEWXnNnaKJ2R3nyonp2VibyIlto3Lk2zyIk7Vt+jQMWuU DUkM+tadVb5QpgVLfnW2GsJMzWrp3PtqR1hjxiLY3Lme6/JuEeudGe605mIuoUTFXb0P a93NxwJpQ8Tb6KM/TzFpo/MiAwrrodybJAY+ca6IAWc4+XszRgHM81rNi+yb6+ZNfts3 TMnZ/owSTI41YLlYv1gQhcw7B36+fGCugDp3pGi9oYzmFWQAIbbulSR+tEZyXm1AA51B n+U8wHbN4J2VbHMM1v+QTxXk8gZzKxGN8ew4UWY8epDbCEbWiUuDt0EJp0Kb8V0HJkuF C1Bw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=sgXh8bVgv0D2EMIa9gZ0LqtiWV89IFniXEDU6j5i00I=; fh=6i7dt3O0S5Vuc/kSsDNX46bfuLeKuDrGb7pgmBROIg0=; b=YBC2vo51uUwrP9YLiMO2Vaa6x7cWR8VdiKIWXDk1XiWUs8Dt8ge/rIzly1ng8OKz9y OHsj07jxHOEKuZrxy5CvHRH9+nCmGSe/nWdkKL+zrjF0UIUCHB4Du/RY2naYjbz+vqZG 6PDac0DWbOdOmSyd1PV9tonNB1FZlAb8VRjPZBt+73wOGbzQJjHjZTM6ImyUclsBw4EY /UZmMhAKQMkCmGU+oJ1yU97/0/FBr5XcOB+mqhyjLYYF7vPLaFd4gPyqC0ewguiq5+RN tNFSMSvH21A0qha4cezt6ADwN4jVw+ruEWzv9/Cyx0AsZBxQDTatcnWLiUECj38QXf+n BZuA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RreylLs9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-156745-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156745-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p14-20020a170902780e00b001e43c7fbfe6si10713518pll.280.2024.04.24.03.44.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 03:44:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156745-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RreylLs9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-156745-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156745-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 C66BA283B1F for ; Wed, 24 Apr 2024 10:44:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 874B5159594; Wed, 24 Apr 2024 10:44:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RreylLs9" 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 B372D13D530 for ; Wed, 24 Apr 2024 10:44:20 +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=1713955460; cv=none; b=Qxoz6OCV/ZjPGhxbOZS5nTNCgvEt84Lru35/3u0SlXPZTFZFyOdqHaZO6gLZUjtIzPdkJX84DFK+OjK4Zi1vCwoO9OeXr/5NWF1wIcnDaaQylpMW/G8oJqJk6XkGnlhEyntqClgl/rm6OmNVJkzog+YX8hnbj5aFO2KasmZJXew= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713955460; c=relaxed/simple; bh=pxcrTqMySGCVkz1+SW4pSfn2o4/wRsYgarTqYSbPgQA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=C5ZK4gnaQ45kkhq48wwmCEsL8ZDRI/416/OiRYzi9pQqkgsWIGNMhs0Epvi5WjP27G6ofktUSov1NwQQFpNxBHvVmAhC/5iGLiWxCRtJ/T5djLqJK+eEGu2RtTGaknesNQXXwQMHTzAj+lqW8AvpBA8u61nVCjhy0sCDhNB9NEU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RreylLs9; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B97BC2BD10; Wed, 24 Apr 2024 10:44:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713955460; bh=pxcrTqMySGCVkz1+SW4pSfn2o4/wRsYgarTqYSbPgQA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RreylLs9xzJy/N92arsIpcrRr9Eft5sVAPuRoXNMRC+wsHuoXbZKtd9NrNegHaxq5 C1PlsMzOzln2xI+/S2iCTQM+/Y88ByW97BworA81gprotEl5e1G/ZaMSu+5LPbNkUY yBO+o3CardxQqod2+v+poeXCR5CUs/hKoDtgJIbl5sEmWepjoVz4U6txp8swtxQbjv 4mVbxj6wFF+xbx5cBSqmh2lhshM2AVyTRS9WtZgprvysx2mf5lBfWpYI2Wq1wMP2E3 y1jsgSm31soPp0PZPLMtpEa8UeiqRZ9jCgmTU/bKy+gIXLRD6INAyUL77berQa3Dun efbB6mBoXIKsA== Date: Wed, 24 Apr 2024 11:44:17 +0100 From: Conor Dooley To: Samuel Holland Cc: Palmer Dabbelt , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 4/7] riscv: Simplify text patching loops Message-ID: <20240424-cranial-punch-27b38726d3f7@spud> References: <20240327160520.791322-1-samuel.holland@sifive.com> <20240327160520.791322-5-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="McmlA8K/qaTnrTZf" Content-Disposition: inline In-Reply-To: <20240327160520.791322-5-samuel.holland@sifive.com> --McmlA8K/qaTnrTZf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Mar 27, 2024 at 09:04:43AM -0700, Samuel Holland wrote: > This reduces the number of variables and makes the code easier to parse. >=20 > Signed-off-by: Samuel Holland > --- >=20 > Changes in v2: > - Further simplify patch_insn_set()/patch_insn_write() loop conditions > - Use min() instead of min_t() since both sides are unsigned long >=20 > arch/riscv/kernel/patch.c | 37 +++++++++++++++++++++---------------- > 1 file changed, 21 insertions(+), 16 deletions(-) >=20 > diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c > index 9a1bce1adf5a..0d1700d1934c 100644 > --- a/arch/riscv/kernel/patch.c > +++ b/arch/riscv/kernel/patch.c > @@ -155,22 +155,24 @@ NOKPROBE_SYMBOL(__patch_insn_write); > =20 > static int patch_insn_set(void *addr, u8 c, size_t len) > { > - size_t patched =3D 0; > size_t size; > - int ret =3D 0; > =20 > /* > * __patch_insn_set() can only work on 2 pages at a time so call it in a > * loop with len <=3D 2 * PAGE_SIZE. > */ > - while (patched < len && !ret) { > - size =3D min_t(size_t, PAGE_SIZE * 2 - offset_in_page(addr + patched),= len - patched); > - ret =3D __patch_insn_set(addr + patched, c, size); > - > - patched +=3D size; > } > =20 > - return ret; > } Weren't these actively wrong before, if a non-ultimate __patch_insn_set() failed we'd just ignore the error? Reviewed-by: Conor Dooley Thanks, Conor. --McmlA8K/qaTnrTZf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZijigAAKCRB4tDGHoIJi 0q57AP0UAhx5QNtAbU133ScLNzELZcym+MIXcLM8EZQCAH/skQEA2EtGNG7wt3yz kRcpFCV6rRc3Ypqb47F4ogt+DiOoCA8= =FbM0 -----END PGP SIGNATURE----- --McmlA8K/qaTnrTZf--