Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6131981pxb; Mon, 14 Feb 2022 16:25:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHX6ZErA1K8Kko4wp+Zu22SFwPjAyRr5+BYQk/CV5zSkINH92AUxouK6fWH2Ro7bQfDqO/ X-Received: by 2002:a05:6402:40d6:: with SMTP id z22mr1395041edb.243.1644884702758; Mon, 14 Feb 2022 16:25:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644884702; cv=none; d=google.com; s=arc-20160816; b=pkU46oeT7Wn876FnRP64Ta5iY336M0Fj2ED+7fg++cJ9ja30xq65ZLgeVvanDR9IY+ L+Bm+sC/kXkjc92iofnCVmmPCcwRBna1dwQctKbdGGUNIDQF2oG4c6l+QOfo78yq1f3E GJRULx6NQBkV0VDmYa4dW0vmgI6CMbgJ3R4zjbA3v7coj0IDMYm7JOUJONKCRZXyJAH4 kw5SdpDJE+QWml/1HO9HcOQhJVdVz/oYpsZxbDza9g3tDsRmMkclUWnOJy1Q9eNFwGND nJkcHo0QDi5ylhzg+6Urg+uPki0C04sQ50+1Lrc3YW/lAsaq/pBr6hthvaJJGFAHNNJ0 3a9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=moNgRt/ZLEOBsvTByTxtoOs0vPE/zSrseOi9CrHk4fo=; b=sG8oQKuSkcj77rNQ+ynT7gcqCQqm98N79EyNoL8bYfU0qxbIPKNsfovMYJ4b3qPkoT 4x892fYRR+5FlfGhGUAhBb7vN8tJfuri7ahOqT13e4sYxoDrY7rAIpnanUDXdJBrevN1 EyKH35wsyTCz7TXTrKiofEWoKxSY8lXKqbYhbG/hbRAOQKoVnyYuO/dLQJiOCGnKUi4l 9ufg/FahzREWrYVQX8fM2BXr3rfMt1DsRXlweLOYZ5KJfDmSULXVI20V+t7PHVRQW2s3 DGqdjg/Mi/VxAhvcNdFPObs0h0wWrPub3tCn9Uue8Bmv9UXK1Kq2dzxDizVXz43WGZgt GuMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b="yoV/X27M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8si1198938edv.134.2022.02.14.16.24.32; Mon, 14 Feb 2022 16:25:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b="yoV/X27M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232198AbiBNXlf (ORCPT + 99 others); Mon, 14 Feb 2022 18:41:35 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:56724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbiBNXlc (ORCPT ); Mon, 14 Feb 2022 18:41:32 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E950114762 for ; Mon, 14 Feb 2022 15:41:21 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id w1so11744849plb.6 for ; Mon, 14 Feb 2022 15:41:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=moNgRt/ZLEOBsvTByTxtoOs0vPE/zSrseOi9CrHk4fo=; b=yoV/X27MeBo7oIZfSwmeTrP3dQ/+GNhABFP1Nj4ylCVxf+C2qf+1N2m4gY5+NP0SYS MTK4VhrCChxql5dGYbg2D/eflP6WJWuMp2HL0yU5jMyfg1js+SOnqY4uf7Gk6Zwx1Dha q4Lc2suIJTeaK30TCLCX+YU6f52bh1A2KKlRcqLvwx9shfV9qXx7trZePAdXWgFVf+Ox 0I7NDimuv+L78rDIfRcfFwGh8LpACXzlYn3M5dQl6uoQSjAyLPkT6f6GYvmvp8XpH8Mn /hO7TOJBxKJlBjRLSz044qvnAiXd6Tf7e5mp5HyrSrhs83jUk6p7RGp15qN0Bso40VyC Gq+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=moNgRt/ZLEOBsvTByTxtoOs0vPE/zSrseOi9CrHk4fo=; b=gtz18q6GET+mMS8Y2Pdg1Tubi7wTyNysl03cCfujf6A3zaYs7IgvUZu2HIwm+8OQCt aAsDx/ZQNuBvblim7w1iuFDWotF1btJ88UaKUP3Rqx0pi2DnLBHHIwOlP0gV93xjvIzV Alel3Ye7Y+1WgV8NXt5nTsKDVPa4eqo+V0kQu7FLt6AqTan+Dw8ecTHBrWGKJ/i4xeQK GgwkZyXEeIRyV1XhgjCoJBq1qvmzYf7qAlUN/uKvosilPi+Kt7e36ZN1DapPb3BfVo/v VQm1fUqpG9sBMdfyi/m58JLYKzbDtu1ZtgxrTNtzSgACMcB5s+ECLSjXtMdnb5cdDH18 A5sQ== X-Gm-Message-State: AOAM533++BSRjv3qUVjkJFdKevYg3A8tL+gIoiRHmdWmWdFOLlANd+8H VtFUqK0r/ODJWg2zmg8kjiEyXA== X-Received: by 2002:a17:90b:2496:b0:1b9:a6dd:ae7 with SMTP id nt22-20020a17090b249600b001b9a6dd0ae7mr1233912pjb.35.1644882080753; Mon, 14 Feb 2022 15:41:20 -0800 (PST) Received: from localhost ([12.3.194.138]) by smtp.gmail.com with ESMTPSA id 13sm36798718pfm.161.2022.02.14.15.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 15:41:19 -0800 (PST) Date: Mon, 14 Feb 2022 15:41:19 -0800 (PST) X-Google-Original-Date: Mon, 14 Feb 2022 15:40:54 PST (-0800) Subject: Re: [PATCH] riscv: mm: remove the BUG_ON check of mapping the last 4K bytes of memory In-Reply-To: <36519886-cedc-a3e3-70d2-712f8a6d3a10@ghiti.fr> CC: jszhang@kernel.org, Paul Walmsley , aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org From: Palmer Dabbelt To: alex@ghiti.fr Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 25 Jan 2022 08:10:41 PST (-0800), alex@ghiti.fr wrote: > > On 1/25/22 16:55, Jisheng Zhang wrote: >> remove the BUG_ON check of mapping the last 4K bytes of the addressable >> memory since "this is true for every kernel actually" as pointed out >> by Alexandre. >> >> Signed-off-by: Jisheng Zhang >> Reviewed-by: Alexandre Ghiti >> --- >> arch/riscv/mm/init.c | 8 -------- >> 1 file changed, 8 deletions(-) >> >> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c >> index cf4d018b7d66..8347d0fda8cd 100644 >> --- a/arch/riscv/mm/init.c >> +++ b/arch/riscv/mm/init.c >> @@ -811,14 +811,6 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa) >> BUG_ON((PAGE_OFFSET % PGDIR_SIZE) != 0); >> BUG_ON((kernel_map.phys_addr % PMD_SIZE) != 0); >> >> -#ifdef CONFIG_64BIT >> - /* >> - * The last 4K bytes of the addressable memory can not be mapped because >> - * of IS_ERR_VALUE macro. >> - */ >> - BUG_ON((kernel_map.virt_addr + kernel_map.size) > ADDRESS_SPACE_END - SZ_4K); >> -#endif > > > This BUG_ON seems pretty legit to me: I re-read the exchanges we had, > and I see that I didn't notice that in your v2, you actually removed the > BUG_ON. So that's my bad, what I meant in the first place was that the > BUG_ON is true for 32-bit and 64-bit kernels actually. There's actually an ifndef 64BIT above that sort of handles this case (though I didn't check to see if we're getting the limits correct, so it may not work properly). That's shrinking the memory, rather than just firing a BUG, and it's not really any more code so we should go that way for both. I could see leaving a BUG in there, maybe just explicitly using IS_ERR_VALUE as that's really what we're checking for (though if that's not 4K a bunch of stuff will break, so maybe it just doesn't matter). > Sorry my RB was not right on this one :( > > Alex > > >> - >> pt_ops_set_early(); >> >> /* Setup early PGD for fixmap */