From patchwork Thu Apr 11 06:48:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Chang" X-Patchwork-Id: 13625478 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 62FE4CD128A for ; Thu, 11 Apr 2024 06:55:51 +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=FQKiyyDZgOj2Y6TpEy1Ib3ditoX9T/51+S/lzXP9iHk=; b=IplhUx/vYFt0aE IP0x4Qx9lih7Me/10Xx+vugUpMUFTFLQgM6Z/BZ1domSthWdSjU2pQfYaw4AkGjTBG6wtaFCj+v7L ix0elQgMa6nvPepYV8Sqn5knOXOO4j5yiP27mzuNz5MB+N5T+l9bIxqYyFDoyn92yJNQX9A+Vnvdv 4GYrgGV1T1AopWTmkyQjTrOXdmG0aK+zu3RQD5DAqMqn2G10MnWMhx/wFraosk9ty1oBiakhqDYnI to8CNnxIyC+jQMTVoUnb2F3tkew9pChMR9zoQ6aUu0gM4thpzk6Ee0zTubvZynalKlEA14xGrdsk8 jecziaVuDFqgdUU0sPLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruoLS-0000000Agj5-1qIl; Thu, 11 Apr 2024 06:55:38 +0000 Received: from szxga05-in.huawei.com ([45.249.212.191]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruoLE-0000000AgWe-3jyl for linux-arm-kernel@lists.infradead.org; Thu, 11 Apr 2024 06:55:29 +0000 Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4VFVkF5RFcz2NW75; Thu, 11 Apr 2024 14:52:21 +0800 (CST) Received: from kwepemd200013.china.huawei.com (unknown [7.221.188.133]) by mail.maildlp.com (Postfix) with ESMTPS id 30338180063; Thu, 11 Apr 2024 14:55:14 +0800 (CST) Received: from huawei.com (10.67.174.28) by kwepemd200013.china.huawei.com (7.221.188.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Thu, 11 Apr 2024 14:55:12 +0800 From: Liao Chang To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , Subject: [PATCH v2 0/9] Rework the DAIF mask, unmask and track API Date: Thu, 11 Apr 2024 06:48:49 +0000 Message-ID: <20240411064858.3232574-1-liaochang1@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.28] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemd200013.china.huawei.com (7.221.188.133) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_235525_468044_141249FF X-CRM114-Status: GOOD ( 12.84 ) 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 This patch series reworks the DAIF mask, unmask, and track API for the upcoming FEAT_NMI extension added in Armv8.8. As platform and virtualization[1] supports for FEAT_NMI is emerging, and Mark Brown's FEAT_NMI patch series[2] highlighted the need for clean up the existing hacking style approach about DAIF management code before adding NMI functionality, furthermore, we discover some subtle bugs during 'perf' and 'ipi_backtrace' transition from PSEUDO_NMI to FEAT_NMI, in summary, all of these emphasize the importance of rework. This series of reworking patches follows the suggestion from Mark Rutland mentioned in Mark Brown's patchset. In summary, he think the better way for DAIF manangement look likes as following: (a) Adding entry-specific helpers to manipulate abstract exception masks covering DAIF + PMR + ALLINT. Those need unmask-at-entry and mask-at-exit behaviour, and today only need to manage DAIF + PMR. It should be possible to do this ahead of ALLINT / NMI support. (b) Adding new "logical exception mask" helpers that treat DAIF + PMR + ALLINT as separate elements. This patches cherry-pick a part of Mark Brown' FEAT_NMI series, in order to pass compilation and basic testing, includes perf and ipi_backtrace. [1] https://lore.kernel.org/all/20240407081733.3231820-1-ruanjinjie@huawei.com/ [2] https://lore.kernel.org/linux-arm-kernel/Y4sH5qX5bK9xfEBp@lpieralisi/ v2->v1: Add SoB tags following the origin author's SoBs. Jinjie Ruan (1): arm64/cpufeature: Simplify detect PE support for FEAT_NMI Liao Chang (5): arm64/cpufeature: Use alternatives to check enabled ARM64_HAS_NMI feature arm64: daifflags: Add logical exception masks covering DAIF + PMR + ALLINT arm64: Unify exception masking at entry and exit of exception arm64: Deprecate old local_daif_{mask,save,restore} irqchip/gic-v3: Improve the maintainability of NMI masking in GIC driver Mark Brown (3): arm64/sysreg: Add definitions for immediate versions of MSR ALLINT arm64/cpufeature: Detect PE support for FEAT_NMI arm64/nmi: Add Kconfig for NMI arch/arm64/Kconfig | 17 ++ arch/arm64/include/asm/cpufeature.h | 6 + arch/arm64/include/asm/daifflags.h | 296 ++++++++++++++++++++++----- arch/arm64/include/asm/nmi.h | 27 +++ arch/arm64/include/asm/sysreg.h | 2 + arch/arm64/include/uapi/asm/ptrace.h | 1 + arch/arm64/kernel/acpi.c | 10 +- arch/arm64/kernel/cpufeature.c | 58 +++++- arch/arm64/kernel/debug-monitors.c | 7 +- arch/arm64/kernel/entry-common.c | 96 +++++---- arch/arm64/kernel/entry.S | 2 - arch/arm64/kernel/hibernate.c | 6 +- arch/arm64/kernel/irq.c | 2 +- arch/arm64/kernel/machine_kexec.c | 2 +- arch/arm64/kernel/setup.c | 2 +- arch/arm64/kernel/smp.c | 6 +- arch/arm64/kernel/suspend.c | 6 +- arch/arm64/kvm/hyp/vgic-v3-sr.c | 6 +- arch/arm64/kvm/hyp/vhe/switch.c | 4 +- arch/arm64/mm/mmu.c | 6 +- arch/arm64/tools/cpucaps | 2 + drivers/irqchip/irq-gic-v3.c | 6 +- 22 files changed, 438 insertions(+), 132 deletions(-) create mode 100644 arch/arm64/include/asm/nmi.h