Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp3037746lqz; Wed, 3 Apr 2024 16:51:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW80Uopa5gSR8nMwzBEmIknb9UnpMPQF/SSC/UQ4ycfb+RKKvElhR4I/XrjOUS7jvQ4BXHHwMjHwxffnhq7qGb95hMdS11SUlXrm8pqOQ== X-Google-Smtp-Source: AGHT+IH/j9LOfRxYIbpW6YoIjV8dJ/veFxufAOT2yDXRlNVLGCR+KSGHz58E0gYfr36akn154U2h X-Received: by 2002:a17:902:7446:b0:1e2:a7fb:3c81 with SMTP id e6-20020a170902744600b001e2a7fb3c81mr704156plt.7.1712188272871; Wed, 03 Apr 2024 16:51:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712188272; cv=pass; d=google.com; s=arc-20160816; b=DsVvj93qZgyApn5mK4WgV+ssJaTHeJjW9ZbBm7EN2LLfrqVFUsV6amkgvHVcWkSBHl tjgvts4tbVFVLvsBMrYwYMgrlAo7QQg1lWZtQFY6601fecvUMr6DtFsT5/Ye3PcblDTZ dhkOlj1ak+zHLrL0h0AIokG8h+CsrnNvcNnrSo1f9zktW4GprqduGbubioxaFblnloRt r00s0C45QJLWSr0q6O9UEAIWDVUyldE6Hw/uU79jb0yKEyGDfVsGO8F+gS2yyiEKRemB hzEwQ6PNN5hv5RTini3nsnSsAlzxpJHTz/Nxz0TjE7yKkdsahjGLzp9H+RTkjeqcqQUF N53g== 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 :subject:cc:to:from:date:dkim-signature; bh=7bg9mia/d/6AMBgZl3rdevQTC0OKIPI50yZywOxKYWc=; fh=T+bq6qLq4yWW7CWObJDttqu50v3DLVl3ay1piMUotD8=; b=dM7rin/bc/0c7AOQsSp+Bnoy5NRL3RcOnnK5TH3oTTcl8ZwV56wqGULcbaAYiaijx7 W8ReAmfYfcf3S5+4tORFgGG4pYxdnLewMS9yRJmK07s1+8ZQHOylN8plkGbyJYoQSYWX AyxIOHPAQyb1mFAHoAV9WPkU4JsDNjT8KRugAMfxyiY6YtuTJP/RdziKEfYslpJOliFS uNqFvFf1bulwdA3zxbe98zlnYTAAPDLXh3jsHPYIMVwYfcXsQdJH+u5hjG6+yTI88IoW o8thd6ShrcziRc713MCG1zg6lONtQnfQtJFiXcLh2Gb+UOoXVsBYgT1u9wDOZYpwIRvw H18w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RV7GYcjm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-130749-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130749-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 q10-20020a170902daca00b001e09c4eb126si14459248plx.169.2024.04.03.16.51.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 16:51:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130749-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=RV7GYcjm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-130749-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130749-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 C7E97288DDE for ; Wed, 3 Apr 2024 23:50:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A34DE156C59; Wed, 3 Apr 2024 23:44:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RV7GYcjm" 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 C89F6156C4B for ; Wed, 3 Apr 2024 23:44:56 +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=1712187896; cv=none; b=R7EGpEd+ZSGT568UVIeZHx61BSF3NAmYSo/XlJ5dGGIPLXUpc5A5h5PEk0j1CHzhXhgG/57j+AmXCUZXxoogy9rLf8DBIAXejFKNoQGKid/lwJ053h384VJHllFO7dlQbdIOZDaNBwqh6grzW4eq+kK7tSyJBD36B2SPaSpEzHA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712187896; c=relaxed/simple; bh=km9WrjrljLnrGGBMhJMqtSVQkEOEoORatY4UgWPCrhI=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=pvaYXdtTRhggA4dBSLBEUt9khCL0Yu3BZebIc7VNiRCEd+uSRDGduB6USQ9ksEHR5/TGtQV9Az9dtQqkLi3qEWlCdes3AOM1myb3RJpQA5tbPCi9GqeF22zm3rUFZiJukTqcXJ6+nvAiI0U9eyqB6Uk/KcZ8W33eXVKeQjl0jIk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RV7GYcjm; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27297C43390; Wed, 3 Apr 2024 23:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712187896; bh=km9WrjrljLnrGGBMhJMqtSVQkEOEoORatY4UgWPCrhI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RV7GYcjmC1peJ0K+6FY0qq/5hSfZCqUJ2QNUdpb36t3OAFaxi4FIhiRPOlfjWOmB+ /ud3+bqKCOc8B7qynP/pFR9M6i2xUeFZC2o5G/FIWr86jnalK6ebcSYxmezEfEAAwY qEzEr4Q/6wcwSKE6hfjU4gyCyoZQsyrTUL37YxInBx03Rvu/aGC3Dg7ddui9zju7zT u5HYDBHA4woR7MjA0UIH5lJ5bros70GI7v/Mv0q9sIrhKtnwgdp13v6VgBCR22I3rW SSV9EGak+zZhFFO3HON2I/X992RARtXhQdSsERIO7HiMey7dt6+AEbK8dqX8KTWxCm RitZLYXh9l5lQ== Date: Thu, 4 Apr 2024 08:44:50 +0900 From: Masami Hiramatsu (Google) To: Catalin Marinas Cc: Mark Rutland , linux-kernel@vger.kernel.org, Will Deacon , anil.s.keshavamurthy@intel.com, aou@eecs.berkeley.edu, davem@davemloft.net, jarkko@kernel.org, linux-arm-kernel@lists.infradead.org, mhiramat@kernel.org, naveen.n.rao@linux.ibm.com, palmer@dabbelt.com, paul.walmsley@sifive.com Subject: Re: [PATCH v2 1/4] arm64: patching: always use fixmap Message-Id: <20240404084450.802bae64e3ed08197fd0dad1@kernel.org> In-Reply-To: References: <20240403150154.667649-1-mark.rutland@arm.com> <20240403150154.667649-2-mark.rutland@arm.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 3 Apr 2024 18:52:30 +0100 Catalin Marinas wrote: > On Wed, Apr 03, 2024 at 04:01:51PM +0100, Mark Rutland wrote: > > For historical reasons, patch_map() won't bother to fixmap non-image > > addresses when CONFIG_STRICT_MODULE_RWX=n, matching the behaviour prior > > to the introduction of CONFIG_STRICT_MODULE_RWX. However, as arm64 > > doesn't select CONFIG_ARCH_OPTIONAL_KERNEL_RWX, CONFIG_MODULES implies > > CONFIG_STRICT_MODULE_RWX, so any kernel built with module support will > > use the fixmap for any non-image address. > > > > Historically we only used patch_map() for the kernel image and modules, > > but these days its also used by BPF and KPROBES to write to read-only > > pages of executable text. Currently these both depend on CONFIG_MODULES, > > but we'd like to change that in subsequent patches, which will require > > using the fixmap regardless of CONFIG_STRICT_MODULE_RWX. > > > > This patch changes patch_map() to always use the fixmap, and simplifies > > the logic: > > > > * Use is_image_text() directly in the if-else, rather than using a > > temporary boolean variable. > > > > * Use offset_in_page() to get the offset within the mapping. > > > > * Remove uintaddr and cast the address directly when using > > is_image_text(). > > > > For kernels built with CONFIG_MODULES=y, there should be no functional > > change as a result of this patch. > > > > For kernels built with CONFIG_MODULES=n, patch_map() will use the fixmap > > for non-image addresses, but there are no extant users with non-image > > addresses when CONFIG_MODULES=n, and hence there should be no functional > > change as a result of this patch alone. > > > > Signed-off-by: Mark Rutland > > Cc: Catalin Marinas > > Cc: Will Deacon > > --- > > arch/arm64/kernel/patching.c | 10 +++------- > > 1 file changed, 3 insertions(+), 7 deletions(-) > > > > Catalin, Will, this is a prerequisite for the final two patches in the > > series. Are you happy for this go via the tracing tree? > > Fine by me. > > Acked-by: Catalin Marinas Thanks Catalin. I'll pick this series to linux-trace tree. Thank you! -- Masami Hiramatsu (Google)