Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp218574lqg; Wed, 10 Apr 2024 23:55:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXDRr76b/hhmUgUGB4ZRFKhAsKMtGdVBrP+mNXyZ0L8GhWGFKX0fDv/KK+Ywb4fzBWKTKMLP7ca6PmJ9m96Dim+NdCzqLkUlVh5ueK5UQ== X-Google-Smtp-Source: AGHT+IG4MMJBhwigXdKzkpjuZ5CV4jSnPGCNeyVZWQW7CCM2LbzeYTp4EoerwzU5rOT70kVAP6/8 X-Received: by 2002:a05:6214:e48:b0:69b:213e:a6c7 with SMTP id o8-20020a0562140e4800b0069b213ea6c7mr5238605qvc.26.1712818536039; Wed, 10 Apr 2024 23:55:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712818536; cv=pass; d=google.com; s=arc-20160816; b=ZzG8TGxjA4mEQPmDtStYynPPOUrz0ZZg9KguKAcq6EcmTgIW4mTFhqyfXVJM6WMRc4 Dh6c//Mk/jbMEy1sMxmEqeLKGWZnyszvRgy3NkZSsAOyQSNmDzA25au/QH21Gna0/Wqx 8EG4ZILxu2kB1euAoFt+SgHQwkPQBFHv6lmZpKO3U68ESKnURondFvcNKYIyzYna0AkP PmSLphEDEE65fQejrNxJ+XCWdtuvda2cb+5INJmqOlPoOSpYnVgEuvmZoROsHYPzd5Zs nGJq/QdW81GLO6dPZOK1+6TC+BB3IYufx4l8JGyptLCmkA5evy95eRalEujHYi1HVLWt +GLw== 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=b81UHAgNaJyVxRYho4YvuyM2yymI980tgvur/KwjPio=; fh=YdO+N/xgHGUZo91bKIWUSgUg8Z1p+7IAoQc3PdTUf0o=; b=U4TkOFqweIk5osfyotc2SXTyG+IRs1HTQplPXGq29q3hBbBT2bDPBpRbrLccIau6O4 36QGCf5nWFyv3+x+cSkQF6XJC9YakxORoNN6g1Yw2I7VkE7Ml+wxe4jKnb/gTahpch6E M+yMFosZm1mUFF/e1x7WpFODg7LRweyNbeu3j21uEcnZaTbi21JE7CrSgiYX86e6nBOc Of5awVPu6G6ExC9jle/iq0CURrMPawqDVJnGWqytswqaec5HLYLsvmg7245A4fKLjfaP 4WQswPq8XCMLrZuKLOASHjdJYP0ecLrydOhJDbB/alG2iUOttRzraObkaA0G59vNGI2+ b8Ow==; 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-139888-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139888-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id eu15-20020ad44f4f000000b0069686d347eesi884987qvb.232.2024.04.10.23.55.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 23:55:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139888-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-139888-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139888-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8C6F21C219E1 for ; Thu, 11 Apr 2024 06:55:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C58713DDBA; Thu, 11 Apr 2024 06:55:20 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 1CA4213D622 for ; Thu, 11 Apr 2024 06:55:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712818520; cv=none; b=jMUMTH0R+watiJyC6nGERw+jxsX863qmDeEJD0WtbdJLKFKLFR6OsQkGR2nt/PhZCY7kSSHjoowRO5S0+t10h30GusQaNyy1hGVk/B7LJDbRN7WvDxC7sHFSEjyz73Pg49Dokhys8JKuy9S74NEWz/8rkuL2R7uDS1XPFLBC5ZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712818520; c=relaxed/simple; bh=QKav+5y61ZdnV0RW5NGa87eeulpAiivRJ79CGIruxTs=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=jaKNUcrVp0hii/E+baDOsOxpI1gWCyCUeVpzE70GlXvdHZVeLnSlvVKlh0LxOWkaGPs8KY2tO08pNYEcWnML410mc3i0dwofqrEMcgX5a+WRHXl3EHqcVbu6aONS2vCw4Y68iCN3BZ3DyU4yY1n/x/bDlIboLCdSRhSPV2/80OU= 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.191 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 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 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: dggems702-chm.china.huawei.com (10.3.19.179) 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/ 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 -- 2.34.1