Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2875120lqz; Wed, 3 Apr 2024 10:59:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWVs09oA3xXEdNbT5OR2D1EIUk1MXL+3pMCwqY+eLPcQVK04znWubvkP/Dc4ZnF2LSMVGOwNNBaz6AoJI3yg8/oZ5AIQKHYLkQRocbYgA== X-Google-Smtp-Source: AGHT+IEyUJR+8yU/eObJaTqfNhKGghWhwNq88OEKicbbR/hlE6w71dNxGPVhAObV8DbFGV2RX5eW X-Received: by 2002:a05:6a00:1d19:b0:6ea:bd59:9389 with SMTP id a25-20020a056a001d1900b006eabd599389mr295981pfx.8.1712167184857; Wed, 03 Apr 2024 10:59:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712167184; cv=pass; d=google.com; s=arc-20160816; b=fvoFRYfXRm87FO0sdvSW/EnN7YiiAKiYTa+qaSnxlJBBF/j5hf/P1oFWv0bap5+lr1 yw+7zAXrLqxorzlBEgyjBkdO0uN8+Ld2+m0kQhg9FDdHnDuYGiWdpz3f6CNSPNwglAcx EFoe81c2NZUW0qthSmn42CEIOuYIyWLbyqXyegS7orgAhmwO0M0FkCeodR4vP5/18QOb FnvZfDECZqmpAsUbCEQXBMbnrSo+FJGNb6Hq0xc9RvXrw12q1QQiKXbLEjaERWSesGRO H4aBOdP7xqqrPYqtODch6/sgEhQT/QvJNOGIdrRYhDu6hOgB2x+U2v9AOazX/eHkKofW wF8Q== 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; bh=0t4m/dnoCMOYhHS6Wefg+T9Exsl/tLQFPVtDKlFZmnk=; fh=AUy4qxsECZ+kLbFqyth/6OTcFhH9M8WAegbEulVhk8A=; b=SeLIvwh5g54/l6MMK+nVy2FNDJoUKrAx4FSoMqoZ7ZY+9u9MiZFGzzpDpiSURZAgOT qe3ukbbLZ0Nu44sQAXXxE7L36tJ3Iie+2FFUYmEuIoruUJo1CwP/hviM6tOoJIIpd6fp L5gaYYTpC5QYC8xDwHeH4TtTf7qE0wVw6gdhTUfW0Iyf4xuy4i0/8dqH5Nzu1/Nsqutm PRKWVUpzb6Y59BXxmkBc69iWeRwS3QE17JMpZsGdg4DiuWU4QGJCwgjGD9y8+O4+r+yV xFVW+44wVCmK7i4lToTLkkx23Smtyu+aNZPA3K24X0kotiJ9ihb0hAkbBaeXIx43HAH+ epyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-130393-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130393-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o24-20020a63e358000000b005f0a512af2bsi8770158pgj.173.2024.04.03.10.59.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 10:59:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130393-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-130393-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130393-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 C6ACB28A03B for ; Wed, 3 Apr 2024 17:56:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB6E51534E6; Wed, 3 Apr 2024 17:52:35 +0000 (UTC) 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 652E5433CB for ; Wed, 3 Apr 2024 17:52:35 +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=1712166755; cv=none; b=jQkg9xpA+hT5DwvqxA8D/RHPsTQ1WOPtk4aHaIM5xuwmPWPzX8k9MQpyBtVfh168xykf5LnLCcS2XDv5X2uQYFsXx1zsY8hLGLf7/YUgwUbnXegu91ZkXEvIhIIduAtG+YhhM18OSiXDk4WFWLASvmeYkYscZYozCgfQ8X7xO0w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712166755; c=relaxed/simple; bh=JUy0awJ1oS9mjfmuuGKejJwXrwXoXCh/aOb7jFwo4AI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=P407LiZbH3I9GJ0vkyArYOXjIp8g+6pzHk3R9H25d6AJP0ZPiH5qh5p0ZlAiirjVOgDc3bxWZlLgWaDStW0vpMJEsHBJGo5uVw7t3Mg17mAVjHOp/inbNXAZXQQoqEUH/5531SVoag0HLnCL3Z+W0JkNv+h5mj18qFLA6fG8rcs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A32A9C433C7; Wed, 3 Apr 2024 17:52:32 +0000 (UTC) Date: Wed, 3 Apr 2024 18:52:30 +0100 From: Catalin Marinas To: Mark Rutland Cc: 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: References: <20240403150154.667649-1-mark.rutland@arm.com> <20240403150154.667649-2-mark.rutland@arm.com> 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-Disposition: inline In-Reply-To: <20240403150154.667649-2-mark.rutland@arm.com> 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