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 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FF00C10F13 for ; Thu, 11 Apr 2019 15:50:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 487BC20818 for ; Thu, 11 Apr 2019 15:50:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TD2o9+9x"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QfOzE2S5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 487BC20818 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject: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=xAyi6Pyt68EX8igcSahe6C/k5oPG/aIjbQXlGzQGMME=; b=TD2o9+9xq59nnu 90/P2CGN7YmoqKNyJVEKQaKYvxFs5P+Oo2yCRa9pepol+5hZuVW2z2dMdO4c6EhQGJIYEf5KpTCzZ gODav8V+yRILKzlet8tgKVpU6ToHKN2ptyLJzQuuU6zR1Wzntk7HhK+Wmt1RH25qKdj4Qbu7oZdD8 xeotcTMbVw6f/atWzBSBQPKSSnQmnha6M4nZ6f+bfE5eG3OaGYDEuppQxS/2/u6tHoPSnVQwqJGof Y3YhRmuSr/ny+jYeN1qx2t+v7dIpiuAYjGS1sT9ayRJny0phPqn0ivV0lCt2s1txPuDT3hvdx/O7/ TGAFZplgD5jbUwbkK4eQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEbxp-0005oF-FO; Thu, 11 Apr 2019 15:50:09 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEbxl-0004wb-WD for linux-arm-kernel@lists.infradead.org; Thu, 11 Apr 2019 15:50:07 +0000 Received: by mail-wr1-x441.google.com with SMTP id k17so3348227wrx.10 for ; Thu, 11 Apr 2019 08:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/EQm7yBn24AyQ4gJa+QAoQd8hb7b7+NCCHmMY0ePHIA=; b=QfOzE2S5OhZL883tJIOpCAqEQPHg18dstZq8Ati4hXTlHGowHDPLaMfow+YAhUYTIo el5KJh8vECCxw7ZzH1mwFCsjG1mR9nF6kfmDF7Tpr7BhjKE6tDG0ylZYfMw5a5qEBCRV +4KYG78i6T111Lw/6dsT6dGvDZhdHGvtiR2RRruOwHl7Ipj2uX6xJmZ/tAGyPuQylJwg lNaj5H7GH9yv2DCDABa2GaY3SAZfh9L1K2kd7CEtyblDE8ehxL5iIc1wpkeHGH/Hv3+j ZZPFpcK2ioTTcce/ixb032pqSjgEmL5SOpOreWJDx6XvJvYp9KRJIDfHMo+dB9SjLGD8 w2PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/EQm7yBn24AyQ4gJa+QAoQd8hb7b7+NCCHmMY0ePHIA=; b=qegZRFdCTDmH4t96gQWxDoxPH39NRfbti/rE4SMqxfa/4KXOos2i58EBKUNu8SVY1A YO1jNnVRQ1r4ZP4pEUMcAn6sJlBzqCZIYgC7mA2pHpicN0/l8PY/uKtqBpwpoYKbLG3I IKbIxNAlyiTbLccjk0WuF77UbrUCSC0xooWQus6kAcBnUBrsg0SWz0IRgwc5QY/7MXeb 8A4gwM3/vD690VI3FQwWxflChmnxpzGzdEc3X92PaFveY8c7suAijyvf9TMGORN9CavZ 2lxHAyPanKExGhQe1e9WRr4c+1dORJRRWTYDOWFOQYuUlOoxA8TnLG+7QKZFM3hazbvj iGyA== X-Gm-Message-State: APjAAAXIwhFiY7TuvkXhftCjQl7yCEvmR5kn7XOP98YyXUOTQCB9QVYC WPQtjCCFYk+VYhUc7v0ztGwqNA== X-Google-Smtp-Source: APXvYqyMdj1EECdLJ019oPz8B3s1s5SDkZgQgOj/EM6lN4Rm0bcSR0CQtYc/togZDnbud3E5KtE7EA== X-Received: by 2002:a5d:5343:: with SMTP id t3mr30528619wrv.49.1554997803825; Thu, 11 Apr 2019 08:50:03 -0700 (PDT) Received: from apalos (athedsl-165181.home.otenet.gr. [85.75.188.219]) by smtp.gmail.com with ESMTPSA id b134sm10637317wmd.26.2019.04.11.08.50.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Apr 2019 08:50:02 -0700 (PDT) Date: Thu, 11 Apr 2019 18:50:00 +0300 From: Ilias Apalodimas To: Russell King - ARM Linux admin Subject: Re: Memory size and section boundary on armv7 Message-ID: <20190411155000.GA25323@apalos> References: <20190411151320.GA23031@apalos> <20190411154129.xh5eoicmjkpt6ceb@shell.armlinux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190411154129.xh5eoicmjkpt6ceb@shell.armlinux.org.uk> User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190411_085006_108631_C7080083 X-CRM114-Status: GOOD ( 31.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: catalin.marinas@arm.com, labbott@redhat.com, mrutland@arm.com, linux-arm-kernel@lists.infradead.org, ard.biesheuvel@linaro.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Russell, > On Thu, Apr 11, 2019 at 06:13:20PM +0300, Ilias Apalodimas wrote: > > Hello, > > > > While experimenting with u-boot and booting the kernel as an EFI stub i seem to > > hit an issue with memory mapping (map_lowmem). > > > > I can only reproduce the crash when using u-boot's dtb (specified in > > fdtcontroladdr) and pass that to the kernel, instead of loading an external one > > with 'dtb=' on it's command line. > > > > If CONFIG_ARM_LPAE=y, everything works fine. If the latter is not selected > > though the kernel seems to crash only if dtb is placed on a section boundary. > > The reason is crashes is the BUG_ON() on arm_pte_alloc() triggers. > > > > fdt size is 0xc00 in both scenarios. > > So something like this works fine: > > In this case ff000 + c000 + f5000 = 200000 > > [ 0.000000] MAP addr: c7c00000, next c7e00000, phys c7c00000 len 200000 > > [ 0.000000] INI addr: c7e00000, next c7eff000, len ff000 > > [ 0.000000] INI addr: c7f0b000, next c8000000, len f5000 > > [ 0.000000] MAP addr: c8000000, next c8200000, phys c8000000 len 200000 > > > > In this working case kernel maps sizes ff000 and f5000 alloc_init_pte() and > > skips the 0xc000 of the fdt correctly > > > > The non-working case is: > > [ 0.000000] MAP addr: c7e00000, next c7f00000, phys c7e00000 len 100000 > > [ 0.000000] INI addr: c7f0c000, next c8000000, len f4000 > > > > Both entries end up using the same pmd > > > > I am not sure what's the best way to fix that. > > Obviously skipping the alloc_init_pte() once this case is detected fixes things, > > but is there a better idea? > > Well, with the above information, all that I can say is that the > mapping code is quite rightfully BUG_ON()ing - it's working as > designed. > > It seems that alloc_init_pte() is finding that a section mapping has > already been created for the virtual address range, but it is then > being asked to create a page table mapping over the top of it. That > is one BIG no no. Replacing the existing section mapping with a page > table means that the section mapping is destroyed. If we allowed > such replacement, when the section mapping is accessed, we will end > up oopsing the kernel. On the crashing case calling __map_init_section() maps 1mb should the rest be skipped then? > > It is also designed to allow hardware-section sized mappings (making > it possible to map sections on 1MB granularity) but as a single Linux > page table always occupies 2MB, it is not permitted for the unused > half of an aligned 2MB slot to be used for a page table mapping - > hence this BUG_ON(). > > The ARM early mapping routines are intentionally designed such that > areas of memory that they are asked to map are non-overlapping - it > is the caller's responsibility to ensure this. And the case i described falls into 'overlapping'? > > So, this is not a problem with the mapping functions, but the way they > are being used. > Beyond that, it is impossible to say with the above information since: > > 1. You've obviously added some additional printk()s, but you haven't > said where they are or what they mean. What is the difference > between "MAP addr" and "INI addr" ? MAP comes from alloc_init_pmd() when calling () INI comes from the same function when calling alloc_init_pte() > > 2. You haven't included the text of the crash, so there's no way to > know the call path to the BUG_ON(), and hence ascertain where the > duplicated mapping is coming from. > > Please always provide the full unaltered text from any kernel oops, bug > or warning. That's because the BUG_ON never shows up in my console. I added printks before and after the BUG_ON() though and i can only see the first print I can provide a dump_stack() if that helps. Thanks /Ilias _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel