Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp5579117rwi; Tue, 18 Oct 2022 00:45:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4FoFZ6hfm+FS7jdS9bH2/W/63AlT4ATjbp7tc5HbeEIC3OpgcLYaKkPeCVZ+sPzAHdDZMl X-Received: by 2002:a17:907:e87:b0:78e:2b3c:f672 with SMTP id ho7-20020a1709070e8700b0078e2b3cf672mr1352299ejc.74.1666079149204; Tue, 18 Oct 2022 00:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666079149; cv=none; d=google.com; s=arc-20160816; b=trmJ45c4Zzk7pJH92GVbL6XsohQFoShmK+TcVn74qjknkWrWtfZskEwChD0yHxduz6 dl13918glxOIhlfYulh+tKYdJyLYGbZ9VeLq9UABXHA8D5YWBLIAbQxb6TQjtV9+WNTE hAmmmvsh5tdJ09gHDv/OwEmXunhimqcnF0erlHABgkkbbZcKdS/f4D0nS66UNRRUNaG3 6qCqYumE6qFPE8ZRQr7BG3Ty/OmNfEuLDDMQGpRd3dJKAShflZAd0VBIiePC7EgmE3YD 93xKvDQV13nwRG6OUmGIoMEIuOKJqNHto/KNvrtlKFXB/8EBK7+NU+Y0Hh3R44EPZZod /0Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=p83bT/t9dYdIjirJ4X6tXwroEW+PJkE+3Ptvk+Zsny4=; b=fVIpPS75draXt7WjoodoMdq0ZSdSqjn9Q+u34GYGv1KW8WR7H0v7JhaAB1Xnro1GbM adq/yzBqYQWryYZFuDYOXLocj6HXRZG0uupA0FY7B08Ce++iB5+6oTICHfpsm03XdbGA LBVbrzt6OZrnHEyOfQSnLZNdokE89yJTCfEv7K+AFP3zVPkjFRWTmxpDC27swKuugVf5 XMQ20jXzcVf3/Mb9ObHRVHmMtj83yWZWIYKk7RlUzniSYCDjGKb4RMy4NHmDsZi9pfKd p813zIIvX4XXOYw/tXSNYcw9G/x6P9S+AAhw5HmIgnRNvUL2LtIBHdb1V6lj7Scrv2oB N+vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b="Dg0xT/m3"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=FDeqYWXF; 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 du6-20020a17090772c600b0078c0c866a18si11771809ejc.19.2022.10.18.00.45.23; Tue, 18 Oct 2022 00:45:49 -0700 (PDT) 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=@arndb.de header.s=fm2 header.b="Dg0xT/m3"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=FDeqYWXF; 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 S230016AbiJRHD0 (ORCPT + 99 others); Tue, 18 Oct 2022 03:03:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229719AbiJRHDZ (ORCPT ); Tue, 18 Oct 2022 03:03:25 -0400 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AF12A3F62 for ; Tue, 18 Oct 2022 00:03:24 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 312663200893; Tue, 18 Oct 2022 03:03:23 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute3.internal (MEProxy); Tue, 18 Oct 2022 03:03:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1666076602; x=1666163002; bh=p83bT/t9dY dIjirJ4X6tXwroEW+PJkE+3Ptvk+Zsny4=; b=Dg0xT/m3F5j4DV8ZcG3prmiZlc vq5YYDQqmup1B4rAlOcZl3Josd0kRzHqoYF40jmz2ZQqcvJ9jBDZpPjlX0FTFecs sXQFSkLsZ7PbFy5ZyK9cIpBRn53C9vLSd/kD6PV8Ahr4+kl9yAJMnuW9OLLcKasU T5Wkl3t5FGdj9JlyEeqciZfoxanNSZU5GdTvVcyeZt58GtquB/35b9or5ecztJO9 quJq8NymqfrIzkNDzb/whYz8xo7vqL2Ib9cFoXv2Q8tPx7VTWp5wu99FQCPoxQhc G6v8u9IZksUjSSoVdA927Phge/0Osdamee0EATLLV/eV8Gn6zqqxpUZqDVoQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1666076602; x=1666163002; bh=p83bT/t9dYdIjirJ4X6tXwroEW+P JkE+3Ptvk+Zsny4=; b=FDeqYWXFTI/Rl/LY3fflR4CEXaGAHdBfQ+AMKRPKxn3D +3mX0bJLAS1RdQB43/bkqpSCiiw6uVxwZjUMiYVovs06wLqttHauC52UWjB+w3u+ LmXm3SOQ3AAc3uNhz2OHi0qwOiCdNn8MxfDoATGanGTbgMgm1KHSgRqSJq4Iq1sw l0DnxnuAvmtndROWYq4H4jU/uLvgN2EnP1aTsMxwpq9Um+NVuzbwh5UrOQhiGlEH uSkEmm+M9gtxmZJMFNsfiCCwDaDGIHQ8GvGiNpLi4fv8VqiR8oGI4DWbYrYW/PuB YVFJI5/50w0f+YTgAb0+h0TBj+QAvMrQKFDJbBYc+Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeeltddguddujecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdet rhhnugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrg htthgvrhhnpeevhfffledtgeehfeffhfdtgedvheejtdfgkeeuvefgudffteettdekkeeu feehudenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomheprghrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 476FBB60083; Tue, 18 Oct 2022 03:03:22 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1047-g9e4af4ada4-fm-20221005.001-g9e4af4ad Mime-Version: 1.0 Message-Id: <3fb4afd1-2eea-4a71-a914-f8208b11f9f4@app.fastmail.com> In-Reply-To: <20221017233700.84918-1-giulio.benetti@benettiengineering.com> References: <20221017233700.84918-1-giulio.benetti@benettiengineering.com> Date: Tue, 18 Oct 2022 09:03:01 +0200 From: "Arnd Bergmann" To: "Giulio Benetti" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: "Russell King" , "Anshuman Khandual" , "Andrew Morton" , "Kefeng Wang" , "Russell King" , "Will Deacon" Subject: Re: [PATCH] ARM: mm: fix no-MMU ZERO_PAGE() implementation Content-Type: text/plain X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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, Oct 18, 2022, at 1:37 AM, Giulio Benetti wrote: > Actually in no-MMU SoCs(i.e. i.MXRT) ZERO_PAGE(vaddr) expands to > ``` > virt_to_page(0) > ``` > that in order expands to: > ``` > pfn_to_page(virt_to_pfn(0)) > ``` > and then virt_to_pfn(0) to: > ``` > #define virt_to_pfn(0) \ > ((((unsigned long)(0) - PAGE_OFFSET) >> PAGE_SHIFT) + \ > PHYS_PFN_OFFSET) > ``` > where PAGE_OFFSET and PHYS_PFN_OFFSET are the DRAM offset(0x80000000) and > PAGE_SHIFT is 12. This way we obtain 16MB(0x01000000) summed to the base of > DRAM(0x80000000). > When ZERO_PAGE(0) is then used, for example in bio_add_page(), the page > gets an address that is out of DRAM bounds. > So instead of using fake virtual page 0 let's allocate a dedicated > zero_page during paging_init() and assign it to a global 'struct page * > empty_zero_page' the same way mmu.c does. Then let's move ZERO_PAGE() > definition to the top of pgtable.h to be in common between mmu.c and > nommu.c. > > Signed-off-by: Giulio Benetti Maybe mention commit dc068f462179 ("m68knommu: set ZERO_PAGE() to the allocated zeroed page") for the commit that fixed this first, as well as the previous discussion at https://lore.kernel.org/linux-m68k/2a462b23-5b8e-bbf4-ec7d-778434a3b9d7@google.com/T/#m1266ceb63ad140743174d6b3070364d3c9a5179b It looks like we dropped the ball on this when it came up last. I'm also not sure when we started requiring this, any idea? I can see that microblaze-nommu used BUG() in ZERO_PAGE(), so at whenever microblaze last worked, we clearly did not call it. > +#ifndef __ASSEMBLY__ > +/* > + * ZERO_PAGE is a global shared page that is always zero: used > + * for zero-mapped memory areas etc.. > + */ > +extern struct page *empty_zero_page; > +#define ZERO_PAGE(vaddr) (empty_zero_page) > +#endif In addition to your fix, I see that arm is the only architecture that defines 'empty_zero_page' as a pointer to the page, when everything else just makes it a pointer to the data itself, or an 'extern char empty_zero_page[]' array, which we may want to change for consistency. There are three references to empty_zero_page in architecture independent code, and while we don't seem to use any of them on Arm, they would clearly be wrong if we did: drivers/acpi/scan.c:#define INVALID_ACPI_HANDLE ((acpi_handle)empty_zero_page) drivers/spi/spi-fsl-cpm.c: mspi->dma_dummy_tx = dma_map_single(dev, empty_zero_page, PAGE_SIZE, include/linux/raid/pq.h:# define raid6_empty_zero_page empty_zero_page Arnd