Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1336082pxb; Tue, 26 Oct 2021 07:14:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxESIfXXA4/g+MIxWJrwmu4m4nTffBFTmZg4KZ4AIGpyDXdiW6XMNI0EoryfMKpVb3SY/lN X-Received: by 2002:a17:902:930c:b0:13e:42b4:9149 with SMTP id bc12-20020a170902930c00b0013e42b49149mr22561578plb.86.1635257675862; Tue, 26 Oct 2021 07:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635257675; cv=none; d=google.com; s=arc-20160816; b=w55Zf0T0EF48IzAdPWkv/ejR86Fq9Q0V7GxinKVD9ZpMw2lp45NrLU0fgZFknAR3bB PMcMMXaS2HSwUZw6Iz92Wj86GfqXbtzuQFuq9mP+kpXaNdQuzFX6OAk9gpYf5zi7lH3n M+mJBXfiv3I+Ie66nDCWE4EfcdAxxDmV0SozoYpbPh216/Y0rfaF70izvE0L/sQFTo4a 8ILzCKBst5mEq12BLoK6VjN2dIzZSTH8r1BmuvlVjiLGxJUro/UfLmEzwdtJVD2bFj8n ixgmmPqQwxpiYintk09y2TpXDi9T587TTqVKcS3s7wwVoGMkX5VnUFYeHO+U7Kjg3lh1 agFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bHEangHscPHEDpQmdZ382qrx5zo6GEWR0uEpI3hNTX4=; b=XuSGR7Kn0y6GaLBWsU8B7mePk5YIYAY9o5XVQJ8Fc4lZvhJ7VJ91dhs3ex+vuB4TO1 MewBk3twksR1V04V8+nWzduJ91UDIdSdnRNvY93HY3GsPETJwi2yE7W0gaaSePTaybUx OkvGU81IretUGEROXkKHaKebKiXP5GtVvKzRh7buaDqsYjNWBK8l1ML5TzxnXKl8JaRI gT96HJRyj+r4/ZXorAKwaVkY3gPddhRCG0/DOTw8Pgf1xl3jVUTrfOEpvD3RlDbbtuQh 61J5D6RuHe2wKCplhA4ySHE6JynaWIr3rx5O1+uj7fovsNL7AdQWuAIEpdD1OyoR24Ms kQOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pyHubQDH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si15875921plg.136.2021.10.26.07.14.22; Tue, 26 Oct 2021 07:14:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pyHubQDH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235302AbhJZK6r (ORCPT + 99 others); Tue, 26 Oct 2021 06:58:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:60400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235288AbhJZK6p (ORCPT ); Tue, 26 Oct 2021 06:58:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0382B61057 for ; Tue, 26 Oct 2021 10:56:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635245782; bh=bHEangHscPHEDpQmdZ382qrx5zo6GEWR0uEpI3hNTX4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=pyHubQDHDEQzntrtaQe3b1Y0xwYV7HAqPS0sJb794Ts1M/hueN30v3GgWrw3ikaME EzL3XjycnJthE7OQgJUeX98RU6c9v4TbL80Emfae9i8GxcMwrHu8Usi64LFibYR7JE c7A/tMjA24pPP0oZPHyINn5eAgkakbw41jPnHcUknog0zd8nUWCFkG2rbs3WuTjDXs zD95SQ7fif89vBYVzTwuxDEGKN6RC2OQhkjlwUgKYWIhy2xrc4KinaRoHBo6IIJfh7 7t3a8NAr0+FJs0RcRmlkuhaEZXNFHR2wK0GNOIg/HAagnfm4aLEs7h/98tigrcA2jD aPCNEt1kQXDXw== Received: by mail-ot1-f47.google.com with SMTP id w12-20020a056830410c00b0054e7ceecd88so19247812ott.2 for ; Tue, 26 Oct 2021 03:56:21 -0700 (PDT) X-Gm-Message-State: AOAM531bY47AGBnHyu2bPQe6Vwe1ScCYrP+Rqvtw2kOXZQ1BeFEWxBCv Co2nFpDtN9QUavptjglndPMC0ntEVz2+BFJtvv8= X-Received: by 2002:a9d:5911:: with SMTP id t17mr18903898oth.30.1635245781230; Tue, 26 Oct 2021 03:56:21 -0700 (PDT) MIME-Version: 1.0 References: <20211020054942.1608637-1-quanyang.wang@windriver.com> <8905597e-49a9-c898-c78d-3d2f51180133@windriver.com> In-Reply-To: From: Ard Biesheuvel Date: Tue, 26 Oct 2021 12:56:08 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] ARM: add BUILD_BUG_ON to check if fixmap range spans multiple pmds To: "Russell King (Oracle)" Cc: Quanyang Wang , Linus Walleij , Thomas Gleixner , Linux ARM , linux-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 Oct 2021 at 12:55, Russell King (Oracle) wrote: > > On Tue, Oct 26, 2021 at 06:38:16PM +0800, Quanyang Wang wrote: > > Hi Ard, > > > > On 10/26/21 6:12 PM, Ard Biesheuvel wrote: > > > On Tue, 26 Oct 2021 at 11:53, Quanyang Wang wrote: > > > > > > > > Hi, > > > > Sorry for the inconvenience. > > > > > > > > On 10/26/21 4:59 PM, Russell King (Oracle) wrote: > > > > > On Sun, Oct 24, 2021 at 11:44:31PM +0200, Linus Walleij wrote: > > > > > > On Wed, Oct 20, 2021 at 7:50 AM wrote: > > > > > > > > > > > > > From: Quanyang Wang > > > > > > > > > > > > > > Not only the early fixmap range, but also the fixmap range should be > > > > > > > checked if it spans multiple pmds. When enabling CONFIG_DEBUG_HIGHMEM, > > > > > > > some systems which contain up to 16 CPUs will crash. > > > > > > > > > > > > > > Signed-off-by: Quanyang Wang > > > > > > > > > > > > Looks reasonable to me. > > > > > > Reviewed-by: Linus Walleij > > > > > > > > > > > > Please submit this patch into Russell's patch tracker. > > > > > > > > > > ... and has totally broken what looks like _all_ ARM kernel builds. > > > > This patch is intended to trigger build error when it check the value of > > > > __end_of_fixmap_region is equal or larger than 256. > > > > > > Why? The fixmap region is larger than one PMD, so why do we need to cap it? > > In __kmap_local_pfn_prot, arch_kmap_local_set_pte(&init_mm, vaddr, kmap_pte > > - idx, pteval) is used to set pteval. > > But the ptep is calculated by "kmap_pte - idx", which means all ptes must be > > placed next to each other and no gaps. But for ARM, the ptes for the range > > "0xffe00000~0xfff00000" is not next to the ptes for the range > > "0xffc80000~0xffdfffff". > > > > When the idx is larger than 256, virtual address is in 0xffdxxxxx, access > > this address will crash since its pteval isn't set correctly. > > Thanks for the explanation. > > Sadly, this does seem to be correct. Even if the PTE tables are > located next to each other in memory, they _still_ won't be a > contiguous array of entries due to being interleaved with the Linux > PTE table and the hardware PTE table. > > Since the address range 0xffe00000-0xfff00000 is already half of one > PTE table containing 512 contiguous entries, we are limited to 256 > fixmap PTEs maximum. If we have more than that we will start trampling > over memory below the PTE table _and_ we will start corrupting Linux > PTE entries in the 0xfff00000-0xffffffff range. > > I suspect this hasn't been seen because of a general lack of ARM > systems with more than 4 CPUs. > But doesn't that make it a kmap_local regression? Or do you think this issue existed before that as well?