From patchwork Fri Dec 3 10:47:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 12694651 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 A3939C433F5 for ; Fri, 3 Dec 2021 10:49:46 +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:References:In-Reply-To: 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: List-Owner; bh=KaY98e1/TDR8LTM9W4X7vMwvZ9NOfCjs+OwUVu5trY4=; b=s4VLrM2YotGLQW cnaXLgjIFCELJvz1Mh0nDzXJMXRalT3istGGMqoS/bmiF6uDaFfgMY90sNRvulCcV7bfzgBSRnU/l 1uJlj5EWHGe7t2U9Xd/el+Ag3VtkTcD9m+AWbx9SoFc92sn3mRs0P+/crL3ZMGFU+uvusxTYhRdNy ieRVhW8gX9rhxo9Ef42PVNX6ED3rXGDG9tD9zdnEDIugbB3yAj2CIvrato1ZAHsmuwFvzsviqmPIK /agvqQ+pVNSKiTjPmOATy2RPbS2auqqpJfXgco0sIUXMexGE5GvMxCO3JA5z2V0T2SIi+gCYAE4bP t8m4fGp3d+risYA3kMtQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mt67B-00FEx1-6m; Fri, 03 Dec 2021 10:48:29 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mt66O-00FEbH-H8 for linux-arm-kernel@lists.infradead.org; Fri, 03 Dec 2021 10:47:41 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DE4BE15A1; Fri, 3 Dec 2021 02:47:39 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A91563F5A1; Fri, 3 Dec 2021 02:47:38 -0800 (PST) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org, James Morse Cc: andre.przywara@arm.com, ardb@kernel.org, catalin.marinas@arm.com, joey.gouly@arm.com, mark.rutland@arm.com, suzuki.poulose@arm.com, will@kernel.org Subject: [PATCH 4/4] arm64: patching: mask exceptions in patch_machine() Date: Fri, 3 Dec 2021 10:47:23 +0000 Message-Id: <20211203104723.3412383-5-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211203104723.3412383-1-mark.rutland@arm.com> References: <20211203104723.3412383-1-mark.rutland@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211203_024740_638894_CA2A6048 X-CRM114-Status: GOOD ( 12.47 ) 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 To ensure that CPUs remain quiescent during patching, they must not take exceptions. Ensure this by masking DAIF during the code patch_machine() logic. Signed-off-by: Mark Rutland Cc: Andre Przywara Cc: Ard Biesheuvel Cc: Catalin Marinas Cc: James Morse Cc: Joey Gouly Cc: Suzuki K Poulose Cc: Will Deacon --- arch/arm64/kernel/patching.c | 6 ++++++ 1 file changed, 6 insertions(+) James, I think w need something similar for SDEI here, but I wasn't sure what I should use for a save..restore sequence. Any thoughts? Thanks, Mark. diff --git a/arch/arm64/kernel/patching.c b/arch/arm64/kernel/patching.c index 04497dbf14e2..797bca33a13d 100644 --- a/arch/arm64/kernel/patching.c +++ b/arch/arm64/kernel/patching.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -127,9 +128,12 @@ struct patch_machine_info { static int noinstr do_patch_machine(void *arg) { struct patch_machine_info *pmi = arg; + unsigned long flags; int cpu = smp_processor_id(); int ret = 0; + flags = local_daif_save(); + if (pmi->cpu == cpu) { while (arch_atomic_read(&pmi->active)) cpu_relax(); @@ -142,6 +146,8 @@ static int noinstr do_patch_machine(void *arg) isb(); } + local_daif_restore(flags); + return ret; }