From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6EA5FEB64D9 for ; Thu, 15 Jun 2023 11:23:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KWNQTCBpgfyzQPLHE6+4LAFSbk32n4oPXJvBMho4ScI=; b=YezDsidKeY5Xw0 Mad3eTZG9dGQREYVlJ3R7+5EpSJ96kZKDIQc4+YdyfWCKr6aE/bNVU5+MpdwFyGfH8X0OWTVzOVAc w7DEsyFkO6ZYt+ITchr5hZzQ0IHomcuVq/9z/u0AhCkyBDoI8sdFNT4+B22lKEv/nWJBN3z6zwfD/ n+mB7/uGI/Q5V0Z1dlqpA4PSRMCHjZmGPu+KNfir0NsoPi/Gz8BlHnCQEdAHgw8rZ6OHZh9ZU3KFv tl0VpWUbblo+JYO7kyCPYSJ+DsEMJvIi78KxbWee4VC042u1359I0BGLqgoNGyUNH3wPt6PifFDaK NcjSXhVfaJANsXpzSb6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9l4V-00EhBg-0x; Thu, 15 Jun 2023 11:23:23 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q9l4R-00EhAA-1A for linux-arm-kernel@lists.infradead.org; Thu, 15 Jun 2023 11:23:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1wSMp1x/X5GsPwW69sHGixFk978FDxwKHd1UyZIsJC4=; b=VK7zn5XUSrjtkXjoiZXzk3WSuO 2RogLwPxa+D7a56UXsLgNuwYZU5o9dFtJnHdcnTJOCIZTrStq6AIUAQTYVY9HcMb0VwbL0ktWNrYH qjYg7orZp35hTO4RBoPk9IYwUPDz/WapKUJKAhrBrDMeqrg/rvyIZvW+8hTFikHu2Mi9d0WwwfHBS HC8aYuFLlb6RPec6XzCCR+pWGFagOlQcf2jYeUTQe7CU02pPZxQa66/PpfsSSLKN+CUv7+p+Q7Toz 2sJIOQWafoBVfOvm6yWvouZBqppIsC2s6jOy8a8MBcJT0BX3UOkBe9ThSGYZ1/0eFzggIyK4YMttu 8TavhNBA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:52022) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q9l4I-0003C6-2M; Thu, 15 Jun 2023 12:23:10 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q9l4F-0001Px-E1; Thu, 15 Jun 2023 12:23:07 +0100 Date: Thu, 15 Jun 2023 12:23:07 +0100 From: "Russell King (Oracle)" To: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, steve.capper@arm.com, will@kernel.org Subject: Re: [PATCH] arm64: mm: fix VA-range sanity check Message-ID: References: <20230615102628.1052103-1-mark.rutland@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230615102628.1052103-1-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230615_042319_675048_07F2F3FD X-CRM114-Status: GOOD ( 22.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jun 15, 2023 at 11:26:28AM +0100, Mark Rutland wrote: > Both create_mapping_noalloc() and update_mapping_prot() sanity-check the > their 'virt' parameter, but the check itself doesn't make much sense. > The condition used today appears to be a historical accident. > > The sanity-check condition: > > if ((virt >= PAGE_END) && (virt < VMALLOC_START)) { > [ ... warning here ... ] > return; > } > > ... can only be true for the KASAN shadow region or the module region, > and there's no reason to exclude these specifically for creating and > updateing mappings. > > When arm64 support was first upstreamed in commit: > > c1cc1552616d0f35 ("arm64: MMU initialisation") > > ... the condition was: > > if (virt < VMALLOC_START) { > [ ... warning here ... ] > return; > } > > At the time, VMALLOC_START was the lowest kernel address, and this was > checking whether 'virt' would be translated via TTBR1. > > Subsequently in commit: > > 14c127c957c1c607 ("arm64: mm: Flip kernel VA space") > > ... the condition was changed to: > > if ((virt >= VA_START) && (virt < VMALLOC_START)) { > [ ... warning here ... ] > return; > } > > This appear to have been a thinko. The commit moved the linear map to > the bottom of the kernel address space, with VMALLOC_START being at the > halfway point. The old condition would warn for changes to the linear > map below this, and at the time VA_START was the end of the linear map. > > Subsequently we cleaned up the naming of VA_START in commit: > > 77ad4ce69321abbe ("arm64: memory: rename VA_START to PAGE_END") > > ... keeping the erroneous condition as: > > if ((virt >= PAGE_END) && (virt < VMALLOC_START)) { > [ ... warning here ... ] > return; > } > > Correct the condition to check against the start of the TTBR1 address > space, which is currently PAGE_OFFSET. This simplifies the logic, and > more clearly matches the "outside kernel range" message in the warning. > > Signed-off-by: Mark Rutland > Cc: Catalin Marinas > Cc: Russell King > Cc: Steve Capper > Cc: Will Deacon This simplifies the second of the kernel text replication patches! Reviewed-by: Russell King (Oracle) Thanks! -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel