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 17585C43334 for ; Wed, 13 Jul 2022 23:29:45 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rI36yTXMkD87dfvjJTMnrsBE77SaREZ4d2j9dShyw18=; b=wl4oe9weygvY+g a4RvcpoPxKGYKaIS2Ce5eztNrIv9UDR/AXeqJhj/lMsfZge5c+GOQTu9osbwAI5kUEMTDD2rMTjLP iBqTt0LONGylPBWwjPV7vdJJ0a/2kE+Jr/aFuhG6xuXdhj6Lgia0rA0i0wlXQU6Pk2BPtrc7RAXQj Z23DsF86sEJyLXB8nyW9Y+77srpAeOLBw/nHW5JM72PONOQ8l2Q+C8wquUNXO7AuhGSFWhPvfxxdy 6hr+QSuqqdDawZyumaH9p1irCe14yk2BWNKAgQThYxNVDKovNwHW3Qhydp94ZkRMyE8YKGCQcy12r EHe+9E77mveH/vN8O3Pw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oBlmh-009Azb-Rd; Wed, 13 Jul 2022 23:28:47 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oBlme-009Awu-1l for linux-arm-kernel@lists.infradead.org; Wed, 13 Jul 2022 23:28:45 +0000 Received: by mail-pj1-x1031.google.com with SMTP id o15so617122pjh.1 for ; Wed, 13 Jul 2022 16:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=Ak4pD1sAGbJtouTYh24ktcQT5ElV0uX7d0TTbsmyB58=; b=pqa6ldT5NaD86r8Y1W0Wofi29CJt2zdiWEh6vBWatwROIEnPY27k0T3HvgqPWuVp0R kG6u3AJmLULZsV+9U9kruwRiGIu17wlwVq/p0MTU0xFBzuCAKPInpWr4cKxKn2sgSl8Y K80+Lk+EMaIeLmlZXi1/sFSDA4Yyd8SImO746ASrs/EcBPW5ls0c0BLMBm59ocB8BSrC vdImrW5lh6ldNflGBfdUiKiMhkE/vqlCTPPTSjSRDq+rdaMcksBd9Gr3MdH5XQ7NrzQj o0GWuXSyzFZr4UuW7ILbC8/qHfrWzEB5KMOgxbKQHgM3M/Gos02gPueJpdRccRbff6E4 FluA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Ak4pD1sAGbJtouTYh24ktcQT5ElV0uX7d0TTbsmyB58=; b=jUEBHDNgTGxo3LM6Bo4+nmGKg/9AdvWuT3GAcidx4mYK9vCzKbrBLsB+9Pmr1Kf7ke /P+UOyQ/T/Q1wG2yvti9C6dUeLG6U+Paq5OaGdpnKCdiFXaopqPg2hFw26Io6y1Ncm/2 FFLWUwzeV9W4e87eOf6PPelEFUM1Bzi5ZBFxQwI9CXc2f1R1n9SRnM9U0BTaMAmqhsGv XoZMH4+UEr7FgiwX4Rv8+DqFSinOTGNvymUH9nJKiI8MZwHq2niyZmorvjp6tm3TbVoR E+vwdRTshF3OHQUMycSdrUK3QC6q1lPuikHx99OPtOTtqRgxXVS6m9zFC3nnZyayxAtW mGcQ== X-Gm-Message-State: AJIora8qM7Zzi80A1WgDd9poyVQEBZ4dTRzr+d3rQVq3ssvdmba8L3Nm jNIWobeh6Ptq/c3KWsx6Qgn6CJawyRQ= X-Google-Smtp-Source: AGRyM1ujrgEttQKAJ20SLXjXBkhFc0OlcYTMW+Yr85LgtCZmvPqmTdhr3O9uyXL0UewXMGxxkaAo8Q== X-Received: by 2002:a17:90b:4f81:b0:1f0:1c35:6ae1 with SMTP id qe1-20020a17090b4f8100b001f01c356ae1mr12930742pjb.2.1657754922295; Wed, 13 Jul 2022 16:28:42 -0700 (PDT) Received: from [10.67.48.245] ([192.19.223.252]) by smtp.googlemail.com with ESMTPSA id lp2-20020a17090b4a8200b001e87bd6f6c2sm2028899pjb.50.2022.07.13.16.28.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Jul 2022 16:28:41 -0700 (PDT) Message-ID: <33f4adff-03b0-3726-c4ba-98971ed46b85@gmail.com> Date: Wed, 13 Jul 2022 16:28:11 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v3] ARM: Fix MAX_DMA_ADDRESS overflow Content-Language: en-US To: linux-arm-kernel@lists.infradead.org Cc: Russell King , Andrew Morton , Grygorii Strashko , open list , ssantosh@kernel.org, ardb@kernel.org, linus.walleij@linaro.org, geert+renesas@glider.be References: <20220706203353.247633-1-f.fainelli@gmail.com> From: Florian Fainelli In-Reply-To: <20220706203353.247633-1-f.fainelli@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220713_162844_115526_47E68DEB X-CRM114-Status: GOOD ( 17.57 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 7/6/22 13:33, Florian Fainelli wrote: > Commit 26f09e9b3a06 ("mm/memblock: add memblock memory allocation apis") > added a check to determine whether arm_dma_zone_size is exceeding the > amount of kernel virtual address space available between the upper 4GB > virtual address limit and PAGE_OFFSET in order to provide a suitable > definition of MAX_DMA_ADDRESS that should fit within the 32-bit virtual > address space. The quantity used for comparison was off by a missing > trailing 0, leading to MAX_DMA_ADDRESS to be overflowing a 32-bit > quantity. > > This was caught thanks to CONFIG_DEBUG_VIRTUAL on the bcm2711 platform > where we define a dma_zone_size of 1GB and we have a PAGE_OFFSET value > of 0xc000_0000 (CONFIG_VMSPLIT_3G) leading to MAX_DMA_ADDRESS being > 0x1_0000_0000 which overflows the unsigned long type used throughout > __pa() and then __virt_addr_valid(). Because the virtual address passed > to __virt_addr_valid() would now be 0, the function would loudly warn > and flood the kernel log, thus making the platform unable to boot > properly. > > Fixes: 26f09e9b3a06 ("mm/memblock: add memblock memory allocation apis") > Signed-off-by: Florian Fainelli Shall I send this to RMK's patch system? -- Florian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 818E3C433EF for ; Wed, 13 Jul 2022 23:28:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231335AbiGMX2q (ORCPT ); Wed, 13 Jul 2022 19:28:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbiGMX2o (ORCPT ); Wed, 13 Jul 2022 19:28:44 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA90B115E for ; Wed, 13 Jul 2022 16:28:42 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id y14-20020a17090a644e00b001ef775f7118so6288617pjm.2 for ; Wed, 13 Jul 2022 16:28:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=Ak4pD1sAGbJtouTYh24ktcQT5ElV0uX7d0TTbsmyB58=; b=pqa6ldT5NaD86r8Y1W0Wofi29CJt2zdiWEh6vBWatwROIEnPY27k0T3HvgqPWuVp0R kG6u3AJmLULZsV+9U9kruwRiGIu17wlwVq/p0MTU0xFBzuCAKPInpWr4cKxKn2sgSl8Y K80+Lk+EMaIeLmlZXi1/sFSDA4Yyd8SImO746ASrs/EcBPW5ls0c0BLMBm59ocB8BSrC vdImrW5lh6ldNflGBfdUiKiMhkE/vqlCTPPTSjSRDq+rdaMcksBd9Gr3MdH5XQ7NrzQj o0GWuXSyzFZr4UuW7ILbC8/qHfrWzEB5KMOgxbKQHgM3M/Gos02gPueJpdRccRbff6E4 FluA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Ak4pD1sAGbJtouTYh24ktcQT5ElV0uX7d0TTbsmyB58=; b=omoadw+s05zf4WRAx0jrwrGVHlhPTgMX6aSEeIeqEL4SZGHHFQmJhAGrDk4QeE6BuL LMY2nHMGefyTUIfZjRgAH6+miSW7iKucMbJtqd4mOpyiGF2ZKLoBH2qp4ltBgNH69SzV mZPv7KfUKZ7CB6FXdVLBXTOCYcJGkHxYI2YmCPvoDZRSCf55xkdrszDqp0EsGwEYISU/ l5CdycNaqYVXOHxSAcUngkEZSVH7vUZdfCkuaB/apIAtI+URdNVZ7pi2i7tjHfZ3iw/7 MmFFIj4HRq7mc7mGEPaGu7LPd+sGs0IRlTfw6CD0/Xb5F7pswAYBy24Q1P3u0UttPeNs rdPA== X-Gm-Message-State: AJIora9H8TYA2GpRKBRxtlTH0o+tBBbXE/ieYWPU00BnuqezDUI6lF7A IdgO0IRqoF/6Fya9uAqk620= X-Google-Smtp-Source: AGRyM1ujrgEttQKAJ20SLXjXBkhFc0OlcYTMW+Yr85LgtCZmvPqmTdhr3O9uyXL0UewXMGxxkaAo8Q== X-Received: by 2002:a17:90b:4f81:b0:1f0:1c35:6ae1 with SMTP id qe1-20020a17090b4f8100b001f01c356ae1mr12930742pjb.2.1657754922295; Wed, 13 Jul 2022 16:28:42 -0700 (PDT) Received: from [10.67.48.245] ([192.19.223.252]) by smtp.googlemail.com with ESMTPSA id lp2-20020a17090b4a8200b001e87bd6f6c2sm2028899pjb.50.2022.07.13.16.28.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Jul 2022 16:28:41 -0700 (PDT) Message-ID: <33f4adff-03b0-3726-c4ba-98971ed46b85@gmail.com> Date: Wed, 13 Jul 2022 16:28:11 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v3] ARM: Fix MAX_DMA_ADDRESS overflow Content-Language: en-US To: linux-arm-kernel@lists.infradead.org Cc: Russell King , Andrew Morton , Grygorii Strashko , open list , ssantosh@kernel.org, ardb@kernel.org, linus.walleij@linaro.org, geert+renesas@glider.be References: <20220706203353.247633-1-f.fainelli@gmail.com> From: Florian Fainelli In-Reply-To: <20220706203353.247633-1-f.fainelli@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/6/22 13:33, Florian Fainelli wrote: > Commit 26f09e9b3a06 ("mm/memblock: add memblock memory allocation apis") > added a check to determine whether arm_dma_zone_size is exceeding the > amount of kernel virtual address space available between the upper 4GB > virtual address limit and PAGE_OFFSET in order to provide a suitable > definition of MAX_DMA_ADDRESS that should fit within the 32-bit virtual > address space. The quantity used for comparison was off by a missing > trailing 0, leading to MAX_DMA_ADDRESS to be overflowing a 32-bit > quantity. > > This was caught thanks to CONFIG_DEBUG_VIRTUAL on the bcm2711 platform > where we define a dma_zone_size of 1GB and we have a PAGE_OFFSET value > of 0xc000_0000 (CONFIG_VMSPLIT_3G) leading to MAX_DMA_ADDRESS being > 0x1_0000_0000 which overflows the unsigned long type used throughout > __pa() and then __virt_addr_valid(). Because the virtual address passed > to __virt_addr_valid() would now be 0, the function would loudly warn > and flood the kernel log, thus making the platform unable to boot > properly. > > Fixes: 26f09e9b3a06 ("mm/memblock: add memblock memory allocation apis") > Signed-off-by: Florian Fainelli Shall I send this to RMK's patch system? -- Florian