From patchwork Thu Jun 9 17:43:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 12875869 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 BF074C433EF for ; Thu, 9 Jun 2022 17:44:44 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=TIQ584BKyV/pA68p91tgPOfrI+HRV+r9ewzkcw5omNQ=; b=axwNjsOGo3LcDj 2q+LthB6y9GP/dUMgaLy57rBnyGXOdsDApVN+WN3YkmSxTf5hbB1gkZFZCcojwDxn3pamgt2xyRgv x3SQ/lW9/Ikus4f/BMCvadER4xhPMq87zi/iXgAtY3PpgTsHKtWgNPaKKR6f9ZABHioQGzhB1KYdt 2625bS5iKByVYdBUPaQsl/fUlwk0z1atEZoLf4shpV0JBQe7QZzvQLY8quSD5E4QLkPe0r2qTycub xe85OYmOudAy3frLSnjSFoLi50YsmGwLa4Zvt18/HWlmf3fDEmV4P0/VvILJZq2y1sArimvnkVuoy i+73RGEwHUa4wVfX+FZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzMBy-003GQN-BP; Thu, 09 Jun 2022 17:43:34 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzMBu-003GOc-Ge for linux-arm-kernel@lists.infradead.org; Thu, 09 Jun 2022 17:43:32 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0EA5561C50; Thu, 9 Jun 2022 17:43:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BF92C34114; Thu, 9 Jun 2022 17:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654796609; bh=kSjSVYND0aUR/jtIJPbNEW3wZ+KyFXMXf2xuFQg8sy4=; h=From:To:Cc:Subject:Date:From; b=TJp7ACxmmCD3uQ6+kV8pNFexlqxQ4CWYXnBcG94i2DvnpUo9V9ITKBx5woI2xnPph cIgquEKLgxWBisL8O8Vn22aeyBo95TYMa8B5vAHvkDEUdzD1t/9HcTPXcp6xdwKRoQ 6Zir/9g0ZNndio+QJO7qY0BSZ579nv3EZDbKVnj0ZhQlj65XWJXzC0T5ynbfs+WEmD GIdOu2WedEvLuL+OhI9l0JgltIQ+njmGSRzX3XvR0dX8oSGyFn8tZACXmowYE/EyWH IUOz+Fe9dMEHyC2unDVM+P5jDLIZlRcuUzo+Cn9M/Xwo7ZVRD8VaOck4b/RmKMNonG uHWjMLKQ0Quew== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , will@kernel.org, maz@kernel.org, mark.rutland@arm.com, catalin.marinas@arm.com, keescook@chromium.org Subject: [PATCH v5 0/2] arm64: apply G-to-nG conversion for KPTI with MMU enabled Date: Thu, 9 Jun 2022 19:43:18 +0200 Message-Id: <20220609174320.4035379-1-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1669; h=from:subject; bh=kSjSVYND0aUR/jtIJPbNEW3wZ+KyFXMXf2xuFQg8sy4=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBiojEyoAjqhbYz5txC13/slQymX8Ws79DqL2kpqXFk EMdwXaWJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYqIxMgAKCRDDTyI5ktmPJKb1C/ 96/VkMYg+MiTYgqp1r4kA56/91jxY8poGbxiO0cvqVQaDqwEmnKysyT58mcUcwns6Ulx+8nYGQzKwu jTtk53JsX6PFLVdZ18dgKD7vM3zWDhefqAljT7NgjVfwLF6xCe+4KhakuR+ojBJyGMdtkq9SWYDQc+ 73lCKJPVYr7nVuUlXpuLql//rJmqexJqEm5WLCxW4EML84amP9SXTGmWbjzbeuRic7bfmlKgkx+5wZ zre/HB3skcWaYe0+H9lNjt1RyVdNOS5mZCd3Qtkpsg3IJXmTYmitFxg5R+nZn5KpPxzRdUzQ60NfUQ oEVtVgtYciYnPZXyKo8rEBRd8ig26eap8uQ4vrXneUz9Ls7JboXaljYyZBA1JHr3KLIiMB3ToAP9Tt qlg6JXZmgDs0AMyWv0s12fU4MbND1QqRpCuxipCSVOvzB42cp+9Y2F5/VL2aSs8fQ+BhVhBrytrdPC XBx7FlMeSVEDJMB1a4U3c2LJ9uaimffHQ94fhTBfZdeBI= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220609_104330_668072_61A57040 X-CRM114-Status: GOOD ( 12.06 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rationale for the series is in patch #2. Changes since v4: - fix two bugs in patch #2 Changes since v3 [0]: - fix issue pointed out by Mark in patch #1, and add his Rb/Tb; - move shared flag back into the ID map, as this allows us to revert to the existing synchronization scheme, and drastically simplify the patch - we can move the flag into a separate page later, if needed; - use symbol alias to access __create_pgd_mapping() so we are not forced to expose it in general. Changes since v2 [1]: - reinstate optimization that avoids descending into the same page tables repeatedly when KASAN is enabled; - use broadcast TLB maintenance when doing BBM for the temporary mappings, to prevent potential TLB conflicts on the secondary cores that are running from the same set of temporary page tables; - remove a wait loop in the C code, by using 'num_cpus + 1' as the signal value rather then 0x0; - declutter and simplify the asm helper code, to make it more maintainable. Cc: will@kernel.org Cc: maz@kernel.org Cc: mark.rutland@arm.com Cc: catalin.marinas@arm.com Cc: keescook@chromium.org [0] https://lore.kernel.org/linux-arm-kernel/20220421140339.1329019-1-ardb@kernel.org/ [1] https://lore.kernel.org/linux-arm-kernel/20220413121848.787565-1-ardb@kernel.org/ Ard Biesheuvel (2): arm64: kpti-ng: simplify page table traversal logic arm64: mm: install KPTI nG mappings with MMU enabled arch/arm64/kernel/cpufeature.c | 54 +++++- arch/arm64/mm/mmu.c | 7 + arch/arm64/mm/proc.S | 173 ++++++++++---------- 3 files changed, 145 insertions(+), 89 deletions(-)