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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD3C2C433F5 for ; Tue, 26 Oct 2021 10:56:19 +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 8F9D160FBF for ; Tue, 26 Oct 2021 10:56:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8F9D160FBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=qbK45mFIlXrD/qAdP2I4v8JbIrskksPANzZ0BMJofKw=; b=wYclNJ1oNuvEq4 IS7Z4w7OADy98GgGE5avr4ul962YbzO7EYSDi3Z4bWd2rIILsN0K3f0DCB7xvvtPqan0JAuVxU/hS hMNTODyYouqJBdpuP5WsDsW10L2Sg11CRlU8vjE9yOGL72cd0/Zf7E5iBfpOUAl5j3bvA2KdfNIC8 YzNrY+E1t1LgE0VpdTFIRrTEkQ2K4ACGpbDtb05X2+JM0xH3U14jOgFNzmXgddLHpqPkHondKMh8u thmE6KhDupaF4IWx57/EdTGksUENNmXIaKsKnHDAkifkVXhWgHAtFv/1GUpCMLQVJ6dhsP+dce4Ze Rw+Zj3EtJhCS4tVRHUPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfK6l-001YO2-SR; Tue, 26 Oct 2021 10:55:08 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfK6i-001YMr-4C for linux-arm-kernel@lists.infradead.org; Tue, 26 Oct 2021 10:55:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=BgAzzl6wRqxUxzR+IGdueyRkHJqVdMrKxqLgk3s7/Nk=; b=zUwYgeHSs3+mVr3lx1lL3YyPko OT9n0I9lxvCPg3zq9XyRSG41pqEYZ5bv1L9QBCUbegw0iMyjnCgFv6PgJXHk1ThkKy6KUD093mKnR 2fBAp9WaipMXhKVEYfrgokR2goJKaa45EYGKSW5T4ph8pdefRUts0D7QctufIHAy7rxQdIZrQTjkI +8c9c4bNlT7JInm9LkY2M3bxNTY0IZhY9Q/GkLwJaCSbeG12pAclzFUZvjL0MvYCEKMNh5p7hIN8b h5hy4D2859lQP61E8Fzw7/UcV7Qm4Wysk/sS7lvdYCa8znDp+FyvHvCMbfKWsKcZXCmlY5iDR+x+p +bcQfTpg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:55310) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mfK6c-0005HY-A6; Tue, 26 Oct 2021 11:54:58 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mfK6a-0006h0-Su; Tue, 26 Oct 2021 11:54:56 +0100 Date: Tue, 26 Oct 2021 11:54:56 +0100 From: "Russell King (Oracle)" To: Quanyang Wang Cc: Ard Biesheuvel , Linus Walleij , Thomas Gleixner , Linux ARM , linux-kernel Subject: Re: [PATCH] ARM: add BUILD_BUG_ON to check if fixmap range spans multiple pmds Message-ID: References: <20211020054942.1608637-1-quanyang.wang@windriver.com> <8905597e-49a9-c898-c78d-3d2f51180133@windriver.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <8905597e-49a9-c898-c78d-3d2f51180133@windriver.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211026_035504_199089_54DB3D0D X-CRM114-Status: GOOD ( 30.64 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel