Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1700703lqe; Mon, 8 Apr 2024 18:30:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVjahSWb3M4xGLe0MEq+cZI4t0AxWSZXLxox4SBog6YZby6ff2pp1vk4MBPVfUvki27YewoMf5EUREK3x70LvFuznFNFjsEUBG3Lp+srA== X-Google-Smtp-Source: AGHT+IGP5kBIek6EUxBMGynK+2iFsxrgJIQgVp5/mHanDgEJOXMHpvGHCuj6SezCPqLLJTqY/P2Y X-Received: by 2002:a17:906:c14a:b0:a51:d5ce:b79e with SMTP id dp10-20020a170906c14a00b00a51d5ceb79emr3210970ejc.47.1712626212236; Mon, 08 Apr 2024 18:30:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712626212; cv=pass; d=google.com; s=arc-20160816; b=rDcq9TpGyIxWagdlspxIZ/RhpN0Rh+pNO5ePCr+8X4Nmr0V1ZeTryY2oyys3+RsI6c yZS9g2x8cPd/gVIc2Arh+Phkpt9dKZElMNRUxMoANRV1oK2wpx5msU+caN/oM/W4QrFI kAy1NIgIK5eGdu3TXdL/HjKnNgPibB6opUrnzmgtlxQT1zyoPfYxQTU2digm9Ki8NGEo DXRoXaE1DB6P43f0HOIcEPMMR9m6S6fvV6Bp+9KSm9ueOLlXjiFiHs4ZpIl0bQB+HMNV QUGQAQ70f9eoevzTHIF5neutKH2mM/HqTChHGnOigywkiVda1aHuPU9QfIBNWJm6bWDj blhg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=oFk0Y9L7bdJJToGbSUdZ4Hc38pFNTYycMHj6spuN9JU=; fh=RatWSVbNJ1/MmnzWWlcZp/KokkZi2YybezTbDh3X02M=; b=Dgur09bZ83wWX0KItHjbINdb1V455kMCsVjpT//vSMF7NG/1T+Yu+GqakV8IjdoVQW M1gHVsrPiO4vqmi1ekm6IgVooPcdrs6Tcr/V8WX6v9T07Mw7YHKoe+RhtyoAgmoemSM2 YKrVAFd0WmBStr4+cc0ntQkC6ucdJGQZ22lYSpOk7B3Q0ttGo3TkCWiuVMJnI+IdGtoq fJCsIXcRAVAjcEn4pZLbjTXKgufhtxT+cB5t+aOv1zMyH8xeQctiZ8eXMxrIICwwVJ/0 eteg6TSpFwPDT09YIvmZrIoysmKSxVqNzkaOvrff1vUqShHrQrTGYAvS91sXsp671VXE Y/0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-136077-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136077-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y17-20020a17090668d100b00a4e4bc69ac2si4073824ejr.97.2024.04.08.18.30.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 18:30:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136077-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-136077-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136077-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F05E51F2238B for ; Tue, 9 Apr 2024 01:30:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AAE54AD39; Tue, 9 Apr 2024 01:30:01 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5D803A1A8 for ; Tue, 9 Apr 2024 01:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712626201; cv=none; b=skSiw6g0WeudaxVn+Tv+TEm0oYqA9sFOc/x/Ty8DLdiV/I6BIr4pSTmg5lf9Ej0HrIgjwnbN/f6YThCLBM2XxZW6I+E18h2+giDqnkUv4wuK6kUzdbCjExgozrOgv59EjIRGhIk4I27Aebuk4Bmrt80UeeUbuEzlGpWm1zMTTU0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712626201; c=relaxed/simple; bh=EplAmGWlpEPUKAGd06/KPWoiuWne67+H/waOkDyvOBc=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=BK2A4MGdIA8nZ5woAWaoayGN6KIMUyrlKLeW8iaGMGH6AZwxUFHqKaIMD9/gJmSZd6yO7Dl7K5vNjS5Ktdr1qr5uoX7Vto1k5kAEnYPt9QtSsQScGilzGFGyWcJpAvjJWz+E9h+gZSJivW+u0RUJxfGY9vfskjGcckUFHNgkuFU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4VD7cZ06Csz1ymVZ; Tue, 9 Apr 2024 09:27:42 +0800 (CST) Received: from kwepemd200013.china.huawei.com (unknown [7.221.188.133]) by mail.maildlp.com (Postfix) with ESMTPS id 2B2E818002D; Tue, 9 Apr 2024 09:29:56 +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; Tue, 9 Apr 2024 09:29:54 +0800 From: Liao Chang To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , Subject: [PATCH 0/9] Rework the DAIF mask, unmask and track API Date: Tue, 9 Apr 2024 01:23:35 +0000 Message-ID: <20240409012344.3194724-1-liaochang1@huawei.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemd200013.china.huawei.com (7.221.188.133) 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/ 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 -- 2.34.1