From patchwork Mon Dec 5 20:12:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13065060 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 37B57C4332F for ; Mon, 5 Dec 2022 20:13:23 +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=QJhAcEy/jqHLih4XgmFyW9YHWUgr6bT0XsC9UTrOlo4=; b=FdaPu2kYQX3jJ3 LP09Ofq6U0cX1mF7KzK0QJt56wq5lGXBCDuqxs7y18ygncoFf9fJROXAAGeq2Y2wxR/yYpNJv/cnJ WvzVS1/n11nl8dJdyRGzq2+zfNrCGZxyGHEmglvrscMgg8SOpoppBFiSLayvNtSbrnlp9mfWOH+gS x386/fWCpEkT4NBCPQe2asaC71SkPtrMqhSkQbll6CMqH9PSxjUchSi87NZjy/3OFJ1TQxyz7oMBw DOsygureJtLNT986h3e/iJjIAqcWXkputg+T08sTVcXbe14IMcDRGY5m+Bua22bYIJs0gUfuga1bU aantHNWoewPQkCJNLERg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2HpB-00A4dX-6Z; Mon, 05 Dec 2022 20:12:25 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2Hp7-00A4Th-Oi for linux-arm-kernel@lists.infradead.org; Mon, 05 Dec 2022 20:12:23 +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 ams.source.kernel.org (Postfix) with ESMTPS id 36D3FB811E3; Mon, 5 Dec 2022 20:12:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52DCEC433D6; Mon, 5 Dec 2022 20:12:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670271139; bh=nXlidHvAKRSH+hnyeVxJwIn22hAVhBTWUOE+g1ZVpSY=; h=From:To:Cc:Subject:Date:From; b=jap6pZNRebQfrztQOJS2DNOvrVlNMvP9OaJlmusBnYO8OaSwcnPz2fR5rUk63jAhY 0jH7JFOjzXohl8l0NhazTR/ih1NSaJa5XJybFPQD8b9k7Op2bTpVGbMkD1UZdcYL0A IlN8JGLn/B2qIrl7r9gZSi9gXLjaMe0XSTz9PwRLqC4OVDVzKdV1qxjDugbHpsE0X3 as/qPB3pFXeHOSI3L/clxasEqylHXbXGKKmDRsYsg9ulcdT7bDWJmgX16YGIXyX8Sy YHeNmVPw95qWc9gkLVDt3Assox2qJYX+hVh2Vsny0JyATxSx8MHnK2UV5gOfMS3vPh umYUKCgModCNA== From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, Ard Biesheuvel , Sami Tolvanen , Kees Cook Subject: [PATCH 0/2] arm64: efi: Robustify EFI runtime wrapper code Date: Mon, 5 Dec 2022 21:12:08 +0100 Message-Id: <20221205201210.463781-1-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1079; i=ardb@kernel.org; h=from:subject; bh=nXlidHvAKRSH+hnyeVxJwIn22hAVhBTWUOE+g1ZVpSY=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjjlCWKpikSzgv/OddSsuJEDlsH8hNbkBHq/isH3Li MRmQ2FCJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY45QlgAKCRDDTyI5ktmPJIEDC/ wJ6z/eFUTShuOKC8NskBZqpqLqgIawl+bLOluLP/Dgr2j2zJ7S91fWsc6SnDUnVUpGCy37HwPF0dHt T7oCQbWj6cYOVYyvFxnQsdD8s71XWzIK2l8sxeFoSmx8suCcOa/8XyG/cpVHwg18Tp0eOZWb8Uww8v Q1WWNzc/uhcZLy6ilEtfUJzka/fNg07tgmFg1lguqgSr01C8zGHuaR0HOlwODSXd/wXTi/KpyMD7El /s3ZTXvuMlPsvR3mf88h7Lr/XD/o6V0YMWvwxNFxcXdC1lqvAgU4PTsUUX9vm+Od8v5jqJYpFPJlxk dqKvX7vrzIarwjZyV1zc/s0da7qHTCIjqlTR2wsDaonMzaPnwcc4+g6agPl2QK1iYo7OcUTHdYRU4R SJOFbeax8XJZ9bfYBI5Qz1dSOuac6YcvUHVwrMzUIcebSp7Hk+ccBMKu9BEnbyDqilaiumXaBlxXYG BtAQbmPcgxmEx6G9MqR7NRpxo0kN1d4j3q0OSsIiOjsW8= 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-20221205_121221_983451_9EBB59B6 X-CRM114-Status: UNSURE ( 9.48 ) X-CRM114-Notice: Please train this message. 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 Make the EFI runtime wrapper code more robust, by switching to a dedicated stack and dealing with sync exceptions occurring in firmware by unwinding it. While at it, move the backup copy of register X18 onto the base of that stack too so we can can restore it if needed without reloading it from the ordinary stack. Patch #2 is a v2 of a patch that got merged and reverted again in v6.1-rc. This supersedes 'arm64: efi: Move runtime services asm wrapper out of .text' Cc: Sami Tolvanen Cc: Kees Cook Ard Biesheuvel (2): arm64: efi: Execute runtime services from a dedicated stack arm64: efi: Recover from synchronous exceptions occurring in firmware arch/arm64/include/asm/efi.h | 11 +++++ arch/arm64/kernel/efi-rt-wrapper.S | 38 ++++++++++++++-- arch/arm64/kernel/efi.c | 47 ++++++++++++++++++++ arch/arm64/mm/fault.c | 4 ++ drivers/firmware/efi/runtime-wrappers.c | 1 + 5 files changed, 98 insertions(+), 3 deletions(-)