-
Notifications
You must be signed in to change notification settings - Fork 107
[Deepin-Kernel-SIG] [linux 6.6-y] [HISI] [Backport] Backport FEAT_NMI/perf DDRC/perf CORE/perf uncore/perf BRBE/minios/FEAT_HAFT and FEAT_LS64 module for Kunpeng new SOC #1475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: linux-6.6.y
Are you sure you want to change the base?
Conversation
commit c8b89f40f6393a3e2bb8892e23bb7f6da787b5e7 openEuler In order to use FEAT_NMI we must be able to use ALLINT, require that it behave as though not trapped when it is present. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jie Liu <liujie375@h-partners.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit abffad0b651f06d94330f8cadbdab00dd0c1c11e openEuler Encodings are provided for ALLINT which allow setting of ALLINT.ALLINT using an immediate rather than requiring that a register be loaded with the value to write. Since these don't currently fit within the scheme we have for sysreg generation add manual encodings like we currently do for other similar registers such as SVCR. Since it is required that these immediate versions be encoded with xzr as the source register provide asm wrapper which ensure this is the case. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jie Liu <liujie375@h-partners.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 1c203efa0a421d6a2368653f017143a430137be9 openEuler In order to allow assembly code to ensure that not even superpriorty interrupts can preempt it provide macros for enabling and disabling ALLINT.ALLINT. This is not integrated into the existing DAIF macros since we do not always wish to manage ALLINT along with DAIF and the use of DAIF in the naming of the existing macros might lead to surprises if ALLINT is also managed. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jie Liu <liujie375@h-partners.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 611b58ad24474484e47e99acbbcd34bce12726bd openEuler In order to use NMIs we need to ensure that traps are disabled for it so update HCRX_EL2 to ensure that TALLINT is not set when we detect support for NMIs. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jie Liu <liujie375@h-partners.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 7c694a36239a15ccdb2806ad7a32a43d7a26fe3f openEuler Add a named override for FEAT_NMI, allowing it to be explicitly disabled in case of problems. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jie Liu <liujie375@h-partners.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit f72387e1f8bc992a1b8c6ecc37c90c458e92d455 openEuler Use of FEAT_NMI requires that all the PEs in the system and the GIC have NMI support. This patch implements the PE part of that detection. In order to avoid problematic interactions between real and pseudo NMIs we disable the architected feature if the user has enabled pseudo NMIs on the command line. If this is done on a system where support for the architected feature is detected then a warning is printed during boot in order to help users spot what is likely to be a misconfiguration. In order to allow KVM to offer the feature to guests even if pseudo NMIs are in use by the host we have a separate feature for the raw feature which is used in KVM. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jie Liu <liujie375@h-partners.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 032d8169dbdc3c12142f3dc5b58b9c6d1a52fa59 openEuler FEAT_NMI is not yet useful to guests pending implementation of vGIC support. Mask out the feature from the ID register and prevent guests creating state in ALLINT.ALLINT by activating the trap on write provided in HCRX_EL2.TALLINT when they are running. There is no trap available for reads from ALLINT. We do not need to check for FEAT_HCRX since it is mandatory since v8.7 and FEAT_NMI is a v8.8 feature. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jie Liu <liujie375@h-partners.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit dd8b74f042237727edef1187ffa936c3686d300b openEuler As we do for pseudo NMIs add code to our DAIF management which keeps superpriority interrupts unmasked when we have asynchronous exceptions enabled. Since superpriority interrupts are not masked through DAIF like pseduo NMIs are we also need to modify the assembler macros for managing DAIF to ensure that the masking is done in the assembly code. At present users of the assembly macros always mask pseudo NMIs. There is a difference to the actual handling between pseudo NMIs and superpriority interrupts in the assembly save_and_disable_irq and restore_irq macros, these cover both interrupts and FIQs using DAIF without regard for the use of pseudo NMIs so also mask those but are not updated here to mask superpriority interrupts. Given the names it is not clear that the behaviour with pseudo NMIs is particularly intentional, and in any case these macros are only used in the implementation of alternatives for software PAN while hardware PAN has been mandatory since v8.1 so it is not anticipated that practical systems with support for FEAT_NMI will ever execute the affected code. This should be a conservative set of masked regions, we may be able to relax this in future, but this should represent a good starting point. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jie Liu <liujie375@h-partners.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 2117a37e18658d788b7eee9904b488570086b987 openEuler As we do for pseudo NMIs don't call preempt_schedule_irq() when architechted NMIs are masked. If they are masked then we are calling from a preempting context so skip preemption. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jie Liu <liujie375@h-partners.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit feb4809ad8f4b5d14c643eff47ac208432eac95f openEuler We have documentation at the top of irqflags.h which explains the DAIF masking. Since the additional masking with NMIs is related and also covers the IF in DAIF extend the comment to note what's going on with NMIs though none of the code in irqflags.h is updated to handle NMIs. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jie Liu <liujie375@h-partners.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 8f1897e1dfc2c616c9ef834494c24755b8852be2 openEuler Our goal with superpriority interrupts is to use them as NMIs, taking advantage of the much smaller regions where they are masked to allow prompt handling of the most time critical interrupts. When an interrupt configured with superpriority we will enter EL1 as normal for any interrupt, the presence of a superpriority interrupt is indicated with a status bit in ISR_EL1. We use this to check for the presence of a superpriority interrupt before we unmask anything in elX_interrupt(), reporting without unmasking any interrupts. If no superpriority interrupt is present then we handle normal interrupts as normal, superpriority interrupts will be unmasked while doing so as a result of setting DAIF_PROCCTX. Both IRQs and FIQs may be configured with superpriority so we handle both, passing an additional root handler into the elX_interrupt() function along with the mask for the bit in ISR_EL1 which indicates the presence of the relevant kind of superpriority interrupt. These root handlers can be configured by the interrupt controller similarly to the root handlers for normal interrupts using the newly added set_handle_nmi_irq() and set_handle_nmi_fiq() functions. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jie Liu <liujie375@h-partners.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 77ca8065cb64d1066aa2276e6aecb7c176210922 openEuler Since NMI handling is in some fairly hot paths we provide a Kconfig option which allows support to be compiled out when not needed. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jie Liu <liujie375@h-partners.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 0408b5bc43005221087db0b668aed30d06be9672 openEuler The FEAT_GICv3_NMI GIC feature coupled with the CPU FEAT_NMI enables handling NMI interrupts in HW on aarch64, by adding a superpriority interrupt to the existing GIC priority scheme. Implement GIC driver support for the FEAT_GICv3_NMI feature. Rename gic_supports_nmi() helper function to gic_supports_pseudo_nmis() to make the pseudo NMIs code path clearer and more explicit. Check, through the ARM64 capabilitity infrastructure, if support for FEAT_NMI was detected on the core and the system has not overridden the detection and forced pseudo-NMIs enablement. If FEAT_NMI is detected, it was not overridden (check embedded in the system_uses_nmi() call) and the GIC supports the FEAT_GICv3_NMI feature, install an NMI handler and initialize NMIs related HW GIC registers. Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jie Liu <liujie375@h-partners.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit eefea61569216c047964a2ee1e370b5dc4fb29da openEuler When handling an exception, both daif and allint will be set by hardware. In __gic_handle_irq_from_irqson(), it only consider the Pseudo-NMI by clear daif.I and daif.F and set PMR to GIC_PRIO_IRQOFF to enable Pseudo-NMI and mask IRQ. If the hardwire NMI is enabled, it should also clear allint to enable hardware NMI and mask IRQ before handle a IRQ, otherwise the allint will be set in softirq context and local_irq_enable() can not enable IRQ, and watchdog NMI can not enter too which will cause below hard LOCKUP. And in gic_handle_irq(), it only consider the Pseudo-NMI when an exception has been taken from a context with IRQs disabled. So add a gic_supports_nmi() helper which consider both Pseudo-NMI and hardware NMI. And define PSR_ALLINT_BIT bit and update interrupts_enabled() as well as fast_interrupts_enabled() to consider the ALLINT bit. watchdog: Watchdog detected hard LOCKUP on cpu 1 Modules linked in: Sending NMI from CPU 0 to CPUs 1: Kernel panic - not syncing: Hard LOCKUP CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.6.0-gec40ec8c5e9f deepin-community#295 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace+0x98/0xf8 show_stack+0x20/0x38 dump_stack_lvl+0x48/0x60 dump_stack+0x18/0x28 panic+0x384/0x3e0 nmi_panic+0x94/0xa0 watchdog_hardlockup_check+0x1bc/0x1c8 watchdog_buddy_check_hardlockup+0x68/0x80 watchdog_timer_fn+0x88/0x2f8 __hrtimer_run_queues+0x17c/0x368 hrtimer_run_queues+0xd4/0x158 update_process_times+0x3c/0xc0 tick_periodic+0x44/0xc8 tick_handle_periodic+0x3c/0xb0 arch_timer_handler_virt+0x3c/0x58 handle_percpu_devid_irq+0x90/0x248 generic_handle_domain_irq+0x34/0x58 gic_handle_irq+0x58/0x110 call_on_irq_stack+0x24/0x58 do_interrupt_handler+0x88/0x98 el1_interrupt+0x40/0xc0 el1h_64_irq_handler+0x24/0x30 el1h_64_irq+0x64/0x68 default_idle_call+0x5c/0x160 do_idle+0x220/0x288 cpu_startup_entry+0x40/0x50 rest_init+0xf0/0xf8 arch_call_rest_init+0x18/0x20 start_kernel+0x520/0x668 __primary_switched+0xbc/0xd0 Fixes: dd8b74f04223 ("arm64/nmi: Manage masking for superpriority interrupts along with DAIF") Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> Signed-off-by: Jie Liu <liujie375@h-partners.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 5cc820c154b7894835919d6a64720f198c907714 openEuler Like pseudo NMI, also select HAVE_PERF_EVENTS_NMI for hardware NMI, and update the comment for arch_perf_nmi_is_available(). Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 626602294dca57b664e95ba72ee32435179af627 openEuler
The introduce of FEAT_NMI/FEAT_GICv3_NMI will cause a race problem that
we may handle the normal interrupt in interrupt disabled context due to
the withdraw of NMI interrupt. The flow will be like below:
[interrupt disabled]
<- normal interrupt pending, for example timer interrupt
<- NMI occurs, ISR_EL1.nmi = 1
do_el1_interrupt()
<- NMI withdraw, ISR_EL1.nmi = 0
ISR_EL1.nmi = 0, not an NMI interrupt
gic_handle_irq()
__gic_handle_irq_from_irqson()
irqnr = gic_read_iar() <- Oops, ack and handle an normal interrupt
in interrupt disabled context!
Fix this by checking the interrupt status in __gic_handle_irq_from_irqson()
and ignore the interrupt if we're in interrupt disabled context.
Fixes: 2731a6c26d4e ("irqchip/gic-v3: Implement FEAT_GICv3_NMI support")
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Signed-off-by: Jie Liu <liujie375@h-partners.com>
Signed-off-by: huwentao <wentaohu0417@163.com>
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
…ARM64_NMI closed
commit f7cea6febbbc02eebfd80209c6b44883b3dd6a63 openEuler
A system stall occurrs when using pseudo NMI with CONFIG_ARM64_NMI closed.
If the hardware supports FEAT_NMI, the ALLINT bit in pstate may set or
clear on exception trap whether the software enables it or not, so it is
not safe to use it to check interrupts_enabled() or
fast_interrupts_enabled() when FEAT_NMI not enabled in kernel, so
recover it.
After applying this patch, the system stall not happen again on hardware
with FEAT_NMI feature.
Fixes: b087eeb7a685 ("irqchip/gic-v3: Fix hard LOCKUP caused by NMI being masked")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: zhaolichang <943677312@qq.com>
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
Reviewer's GuideBackports ARM64 FEAT_NMI / GICv3 NMI support and integrates it with the existing GICv3 pseudo-NMI implementation, wiring architected NMIs through the irqchip, entry, cpufeature, and KVM paths so Kunpeng SoCs with GICD_TYPER.NMI can use hardware NMIs while preserving existing pseudo-NMI behaviour elsewhere. Sequence diagram for ARM64 FEAT_NMI IRQ handling via GICv3sequenceDiagram
participant CPU as CPU_core
participant GIC as GICv3_irqchip
participant Entry as entry_common_el1
participant Root as irq_root_handlers
participant GICNMI as gic_handle_nmi_irq
participant CoreNMI as __gic_handle_nmi
participant Gen as generic_handle_domain_nmi
CPU->>GIC: Hardware_superpriority_IRQ(FEAT_NMI)
GIC-->>CPU: Signal_exception_to_EL1
CPU->>Entry: el1h_64_irq_handler
Entry->>Entry: el1_interrupt(regs, ISR_EL1_IS, handle_arch_irq, handle_arch_nmi_irq)
Entry->>Entry: read_sysreg(isr_el1) & ISR_EL1_IS
alt NMI_pending
Entry->>CoreNMI: __el1_nmi(regs, handle_arch_nmi_irq)
CoreNMI->>Root: handle_arch_nmi_irq(regs)
Root->>GICNMI: gic_handle_nmi_irq(regs)
GICNMI->>GICNMI: irqnr = gic_read_nmiar()
GICNMI->>CoreNMI: __gic_handle_nmi(irqnr, regs)
CoreNMI->>Gen: generic_handle_domain_nmi(gic_data.domain, irqnr)
alt NMI_handled
Gen-->>CoreNMI: handled
CoreNMI-->>CPU: return_from_exception
else Unexpected_NMI
Gen-->>CoreNMI: not_handled
CoreNMI->>GIC: gic_deactivate_unhandled(irqnr)
CoreNMI-->>CPU: return_from_exception
end
else No_NMI_pending
Entry->>Root: handle_arch_irq(regs)
Root-->>CPU: handle_regular_IRQ
end
Sequence diagram for GICv3 NMI configuration and selection vs pseudo-NMIsequenceDiagram
participant CPU as Boot_CPU
participant CPFeat as cpufeature_init
participant GIC as gic_v3_init
participant IRQCore as irq_core
CPU->>CPFeat: arm64_features_probe()
CPFeat->>CPFeat: detect ARM64_HAS_NMI from ID_AA64PFR1_EL1.NMI
CPFeat->>CPFeat: use_nmi() decides ARM64_USES_NMI
CPFeat->>CPFeat: nmi_enable() when ARM64_USES_NMI
CPFeat->>CPFeat: system_uses_nmi() enabled
CPU->>GIC: gic_init_bases()
GIC->>GIC: read GICD_TYPER
GIC->>GIC: gic_data.has_nmi = !!(typer & GICD_TYPER_NMI)
GIC->>GIC: gic_enable_nmi_support()
alt HW_FEAT_NMI_available
GIC->>GIC: has_v3_3_nmi() == true
GIC->>GIC: allocate ppi_nmi_refs
GIC->>GIC: skip gic_enable_pseudo_nmis()
else Only_pseudo_NMI_available
GIC->>GIC: has_v3_3_nmi() == false
GIC->>GIC: gic_enable_pseudo_nmis()
GIC->>GIC: static_branch_enable(supports_pseudo_nmis)
end
GIC->>IRQCore: gic_setup_nmi_handler()
alt HW_FEAT_NMI_available
GIC->>IRQCore: set_handle_nmi_irq(gic_handle_nmi_irq)
else No_HW_NMI
GIC-->>IRQCore: do_not_register_nmi_handler
end
Class diagram for key structs and helpers in ARM64 NMI supportclassDiagram
class gic_chip_data {
+u32 nr_redist_regions
+u64 flags
+bool has_rss
+bool has_nmi
+unsigned int ppi_nr
+partition_desc** ppi_descs
}
class cpufeature_helpers {
+bool system_uses_irq_prio_masking()
+bool system_uses_nmi()
}
class gic_nmi_support {
+void gic_irq_configure_nmi(struct irq_data* d, bool enable)
+void gic_irq_enable_nmi(struct irq_data* d)
+void gic_irq_disable_nmi(struct irq_data* d)
+int gic_irq_nmi_setup(struct irq_data* d)
+void gic_irq_nmi_teardown(struct irq_data* d)
+bool gic_supports_pseudo_nmis()
+bool has_v3_3_nmi()
+void gic_enable_pseudo_nmis(void)
+void gic_enable_nmi_support(void)
+void gic_setup_nmi_handler(void)
}
class arch_nmi_core {
+void default_handle_nmi_irq(struct pt_regs* regs)
+void default_handle_nmi_fiq(struct pt_regs* regs)
+int set_handle_nmi_irq(void (*handle_nmi_irq)(struct pt_regs*))
+void (*handle_arch_nmi_irq)(struct pt_regs*)
+void (*handle_arch_nmi_fiq)(struct pt_regs*)
}
class entry_common_nmi {
+void __el1_nmi(struct pt_regs* regs, void (*handler)(struct pt_regs*))
+void el1_interrupt(struct pt_regs* regs, u64 nmi_flag,
void (*handler)(struct pt_regs*),
void (*nmi_handler)(struct pt_regs*))
+void el0_interrupt(struct pt_regs* regs, u64 nmi_flag,
void (*handler)(struct pt_regs*),
void (*nmi_handler)(struct pt_regs*))
}
class nmi_asm_helpers {
+void _allint_clear()
+void _allint_set()
}
gic_chip_data --> gic_nmi_support : used_by
cpufeature_helpers --> gic_nmi_support : controls_has_v3_3_nmi
gic_nmi_support --> arch_nmi_core : calls_set_handle_nmi_irq
arch_nmi_core --> entry_common_nmi : called_from_entry
nmi_asm_helpers --> entry_common_nmi : ALLINT_control
nmi_asm_helpers --> gic_nmi_support : ALLINT_control_for_handlers
cpufeature_helpers --> entry_common_nmi : system_uses_nmi
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- The change to fast_interrupts_enabled in arch/arm64/include/asm/ptrace.h drops the inner parentheses and changes the expression semantics from testing the PSR_F_BIT to
(!pstate) & PSR_F_BIT, which will mis-detect FIQ state; restore the original parenthesisation so the macro still checks(regs->pstate & PSR_F_BIT). - The new helpers in arch/arm64/include/asm/nmi.h use
asm volatile(__msr_s(SYS_ALLINT_CLR, "xzr"));/__msr_s(SYS_ALLINT_SET, ...)inside the asm string, which does not match how sysreg access macros are normally used and is unlikely to assemble correctly; reuse the existingmsr_s/sysreg_*macros or emit a plainmsr_sinstruction string with _stringify(SYS_ALLINT*).
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The change to fast_interrupts_enabled in arch/arm64/include/asm/ptrace.h drops the inner parentheses and changes the expression semantics from testing the PSR_F_BIT to `(!pstate) & PSR_F_BIT`, which will mis-detect FIQ state; restore the original parenthesisation so the macro still checks `(regs->pstate & PSR_F_BIT)`.
- The new helpers in arch/arm64/include/asm/nmi.h use `asm volatile(__msr_s(SYS_ALLINT_CLR, "xzr"));`/`__msr_s(SYS_ALLINT_SET, ...)` inside the asm string, which does not match how sysreg access macros are normally used and is unlikely to assemble correctly; reuse the existing `msr_s`/`sysreg_*` macros or emit a plain `msr_s` instruction string with __stringify(SYS_ALLINT_*).Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
[Upstream commit 17aa34e] On HiSilicon HIP10C platform, the DDRC PMU is a v3 PMU. And only the offset of it's interrupt registers offset quite a different tune DDRC v2 PMUs. The control registeres and events code are the same as v2 PMU. Their modification was unexpected, which caused the interrupt handler to not handle counter overflows correctly (HiSilicon Erratum 162400501). The before DDRC PMU driver will probe v3 as v2. Therefore DDRC v3 interrupt handler cannot work properly. We fixed that by adding new ID HISI0235 to correct the DDRC v3 PMU interrupt register offset (including mask/status/clear registers). Signed-off-by: Junhao He <hejunhao3@huawei.com> (cherry picked from commit aa58bd1c28c317c65a4196215ef29cb85aafb922) Signed-off-by: yeyiyang <850219375@qq.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 4172980] The HiSilicon Uncore PMU framework implements some common functions and exported them to the drivers. Use a specific HISI_PMU namespace for the exported symbols to avoid pollute the generic ones. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Signed-off-by: yeyiyang <850219375@qq.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit f2368a2] Event will be scheduled on CPU of hisi_pmu::on_cpu which is selected from the intersection of hisi_pmu::associated_cpus and online CPUs. So the associated_cpus don't need to be maintained with online CPUs. This will save one update operation if one associated CPU is offlined. Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Signed-off-by: yeyiyang <850219375@qq.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit d91c6db8ca896824da23aab69dde9ce289222299 openEuler This adds the CPU-inspect infrastructure. CPU-inspect is designed to provide a framework for early detection of SDC by proactively executing CPU inspection test cases. Silent Data Corruption (SDC), sometimes referred to as Silent Data Error (SDE), is an industry-wide issue impacting not only long-protected memory, storage, and networking, but also computer CPUs. As with software issues, hardware-induced SDC can contribute to data loss and corruption. An SDC occurs when an impacted CPU inadvertently causes errors in the data it processes. For example, an impacted CPU might miscalculate data (i.e., 1+1=3). There may be no indication of these computational errors unless the software systematically checks for errors [1]. SDC issues have been around for many years, but as chips have become more advanced and compact in size, the transistors and lines have become so tiny that small electrical fluctuations can cause errors. Most of these errors are caused by defects during manufacturing and are screened out by the vendors; others are caught by hardware error detection or correction. However, some errors go undetected by hardware; therefore only detection software can protect against such errors [1]. [1] https://support.google.com/cloud/answer/10759085 To use CPU-inspect, you need to load at least one inspector (the driver that specifically executes the CPU inspection code) Here is an example using CPU-inspect: # Set the cpumask of CPU-inspect to 10-20 echo 10-20 > /sys/devices/system/cpu/cpuinspect/cpumask # set the max cpu utility of inspectiono threads to 50% echo 50 > /sys/devices/system/cpu/cpuinspect/cpu_utility # start the CPU inspection task echo 1 > /sys/devices/system/cpu/cpuinspect/start_patrol # Check the result to see if some faulty cpu are found cat /sys/devices/system/cpu/cpuinspect/result In addition to being readable, the 'result' file in cpuinspect can also be polled. The user that use poll() to monitor 'result' will return when a faulty CPU is found or the inspection task is completed. Signed-off-by: Yu Liao <liaoyu15@huawei.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 133e66ca214b9d084f01c07cd3d57f454a426afb openEuler This inspector implements the execution of inspection instructions in BIOS. Using smc to get group num and execute inspection test cases from arm-trusted-firmware. Signed-off-by: Yu Liao <liaoyu15@huawei.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
…ping CPU commit 5f20541757730418065c3ae77dfdbcde3f523394 openEuler When NOHZ_FULL is enabled, such as in HPC situation, CPUs are divided into housekeeping CPUs and non-housekeeping CPUs. Non-housekeeping CPUs are NOHZ_FULL CPUs and are often monopolized by the userspace process, such HPC application process. Any sort of interruption is not expected. blk_mq_hctx_next_cpu() selects each cpu in 'hctx->cpumask' alternately to schedule the work thread blk_mq_run_work_fn(). When 'hctx->cpumask' contains housekeeping CPU and non-housekeeping CPU at the same time, a housekeeping CPU, which want to request a IO, may schedule a worker on a non-housekeeping CPU. This may affect the performance of the userspace application running on non-housekeeping CPUs. So let's just schedule the worker thread on the current CPU when the current CPU is housekeeping CPU. Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 2dfbfabfced809d6e9672a50cc9edd3435477df0 openEuler The CNA spinlock is enabled base on 'pv_ops' of pvspinlock, and is only supported on x86_64 now, add support for arm64 without pvspinlock. Signed-off-by: Wei Li <liwei391@huawei.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 7b342952fd52859d1bd2ed4b97f7e479d7ec54bf openEuler
Amu fie was set up by a cpufreq policy notifier after the policy was
created. This caused some problems:
1. The cpus related to the same policy would all fail to set up amu fie if
one of them couldn't pass the freq_counters_valid() check.
2. The cpus fail to set up amu fie would never have a chance to set up
again.
When boot with maxcpu=1 restrict, the support amu flags of the offline cpus
would never be setup. After that, when cpufreq policy was being created,
the online cpu might set up amu fie fail because the other cpus related to
the same policy couldn't pass the freq_counters_valid() check. Hotplug the
offline cpus, since the policy was already created, amu_fie_setup() would
never be called again. All cpus couldn't setup amu fie in this situation.
After commit 1f59a0e83600 ("arm64/amu: Use capacity_ref_freq() to set AMU
ratio"), the max_freq stores in policy data is never needed when setting up
amu fie. This indicates that the setting up of amu fie does not depend on
the policy any more. So each cpu can set up amu fie separately during
hotplug and the problems above will be solved.
Fixes: 1eb5dde ("cpufreq: CPPC: Add support for frequency invariance")
Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Signed-off-by: Hongye Lin <linhongye@h-partners.com>
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
|
Note: the commit ("locking/qspinlock: Add CNA support for ARM64 without pvspinlock") and ("Revert "deepin: qspinlock: Disable CNA by default"") modifies out‑of‑tree patches from other vendors and requires careful review. Link: #692 |
[Upstream commit aa47dcd] Update ID_AA64MMFR1_EL1 register fields definition per DDI0601 (ID092424) 2024-09. ID_AA64MMFR1_EL1.ETS adds definition for FEAT_ETS2 and FEAT_ETS3. ID_AA64MMFR1_EL1.HAFDBS adds definition for FEAT_HAFT and FEAT_HDBSS. Reviewed-by: Mark Brown <broonie@kernel.org> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Link: https://lore.kernel.org/r/20241102104235.62560-2-yangyicong@huawei.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 926b66e] TCR2_EL1 introduced some additional controls besides TCR_EL1. Currently only PIE is supported and enabled by writing TCR2_EL1 directly if PIE detected. Introduce a named register 'tcr2' just like 'tcr' we've already had. It'll be initialized to 0 and updated if certain feature detected and needs to be enabled. Touch the TCR2_EL1 registers at last with the updated 'tcr2' value if FEAT_TCR2 supported by checking ID_AA64MMFR3_EL1.TCRX. Then we can extend the support of other features controlled by TCR2_EL1. Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Link: https://lore.kernel.org/r/20241102104235.62560-3-yangyicong@huawei.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit efe7254] Armv8.9/v9.4 introduces the feature Hardware managed Access Flag for Table descriptors (FEAT_HAFT). The feature is indicated by ID_AA64MMFR1_EL1.HAFDBS == 0b0011 and can be enabled by TCR2_EL1.HAFT so it has a dependency on FEAT_TCR2. Adds the Kconfig for FEAT_HAFT and support detecting and enabling the feature. The feature is enabled in __cpu_setup() before MMU on just like HA. A CPU capability is added to notify the user of the feature. Add definition of P{G,4,U,M}D_TABLE_AF bit and set the AF bit when creating the page table, which will save the hardware from having to update them at runtime. This will be ignored if FEAT_HAFT is not enabled. The AF bit of table descriptors cannot be managed by the software per spec, unlike the HA. So this should be used only if it's supported system wide by system_supports_haft(). Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Link: https://lore.kernel.org/r/20241102104235.62560-4-yangyicong@huawei.com Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> [catalin.marinas@arm.com: added the ID check back to __cpu_setup in case of future CPU errata] Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 62df587] With the support of FEAT_HAFT, the NONLEAF_PMD_YOUNG can be enabled on arm64 since the hardware is capable of updating the AF flag for PMD table descriptor. Since the AF bit of the table descriptor shares the same bit position in block descriptors, we only need to implement arch_has_hw_nonleaf_pmd_young() and select related configs. The related pmd_young test/update operations keeps the same with and already implemented for transparent page support. Currently ARCH_HAS_NONLEAF_PMD_YOUNG is used to improve the efficiency of lru-gen aging. Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Link: https://lore.kernel.org/r/20241102104235.62560-5-yangyicong@huawei.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit b349a5a] Young bit operation on PMD table entry is only supported if FEAT_HAFT enabled system wide. Add a warning for notifying the misbehaviour. Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Link: https://lore.kernel.org/r/20241102104235.62560-6-yangyicong@huawei.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit ddadbcd] We have filled all 64 bits of AT_HWCAP2 so in order to support discovery of further features provide the framework to use the already defined AT_HWCAP3 for further CPU features. Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Link: https://lore.kernel.org/r/20241004-arm64-elf-hwcap3-v2-2-799d1daad8b0@kernel.org Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> [conflicts with e218c611e32c8d4315a6d64790b9a86f3d4fa4dc] Signed-off-by: Hongye Lin <linhongye@h-partners.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 3281366] Changes from v1: - Add Acked-by lines. The powerpc toolchain keeps a copy of the HWCAP bit masks in our TCB for fast access by the __builtin_cpu_supports built-in function. The TCB space for the HWCAP entries - which are created in pairs - is an ABI extension, so waiting to create the space for HWCAP3 and HWCAP4 until we need them is problematical. Define AT_HWCAP3 and AT_HWCAP4 in the generic uapi header so they can be used in glibc to reserve space in the powerpc TCB for their future use. I scanned through the Linux and GLIBC source codes looking for unused AT_* values and 29 and 30 did not seem to be used, so they are what I went with. This has received Acked-by's from both GLIBC and Linux kernel developers and no reservations or Nacks from anyone. Arnd, we seem to have consensus on the patch below. Is this something you could take and apply to your tree? Peter Signed-off-by: Peter Bergner <bergner@linux.ibm.com> Acked-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Acked-by: Nicholas Piggin <npiggin@gmail.com> Acked-by: Szabolcs Nagy <szabolcs.nagy@arm.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Commit: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/a406b535-dc55-4856-8ae9-5a063644a1af@linux.ibm.com Signed-off-by: Hongye Lin <linhongye@h-partners.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 4e6e8c2] AT_HWCAP3 and AT_HWCAP4 were recently defined for use on PowerPC in commit 3281366 ("uapi/auxvec: Define AT_HWCAP3 and AT_HWCAP4 aux vector, entries"). Since we want to start using AT_HWCAP3 on arm64 add support for exposing both these new hwcaps via binfmt_elf. Signed-off-by: Mark Brown <broonie@kernel.org> Acked-by: Kees Cook <kees@kernel.org> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Signed-off-by: Hongye Lin <linhongye@h-partners.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 077e22a3c65f623d6c2172a952783dd9898d0f98 openEuler
Instructions introduced by FEAT_{LS64, LS64_V} is controlled by
HCRX_EL2.{EnALS, EnASR}. Configure all of these to allow usage
at EL0/1.
This doesn't mean these instructions are always available in
EL0/1 if provided. The hypervisor still have the control at
runtime.
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Signed-off-by: Hongye Lin <linhongye@h-partners.com>
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 98809b6ac799cdab9f7f09452afec42fe86664af openEuler
Armv8.7 introduces single-copy atomic 64-byte loads and stores
instructions and its variants named under FEAT_{LS64, LS64_V}.
These features are identified by ID_AA64ISAR1_EL1.LS64 and the
use of such instructions in userspace (EL0) can be trapped. In
order to support the use of corresponding instructions in userspace:
- Make ID_AA64ISAR1_EL1.LS64 visbile to userspace
- Add identifying and enabling in the cpufeature list
- Expose these support of these features to userspace through HWCAP3
and cpuinfo
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Signed-off-by: Hongye Lin <linhongye@h-partners.com>
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit db144b9863a522607c0c2769a70473494e54019b openEuler Workaround the issue when compile with CONFIG_FUNCTION_ALIGNMENT_64B Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Signed-off-by: Hongye Lin <linhongye@h-partners.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
commit 2492274e6dc947ae6d7d4dbb46c0abf6ffd533cc openEuler
Using FEAT_{LS64, LS64_V} instructions in a guest is also controlled
by HCRX_EL2.{EnALS, EnASR}. Enable it if guest has related feature.
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Signed-off-by: Hongye Lin <linhongye@h-partners.com>
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
This reverts commit e6a498c. Link: https://gitee.com/OpenCloudOS/OpenCloudOS-Kernel/pulls/567 Signed-off-by: zhaolichang <zhaolichang@huawei.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
|
@sourcery-ai review |
|
Sorry @Avenger-285714, your pull request is larger than the review limit of 150000 diff characters |
|
Sorry @Avenger-285714, your pull request is larger than the review limit of 150000 diff characters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 109 out of 109 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /* The ALLINT field is at the same position in pstate and ALLINT */ | ||
| if (system_uses_nmi()) { | ||
| if (regs->pstate & ALLINT_ALLINT) | ||
| _allint_set(); |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ALLINT_ALLINT is used here to test the ALLINT field, but there is no definition of this macro in the tree, so this code will not compile. A proper bitmask definition for the ALLINT field (in the same style as other sysreg field masks) needs to be added, or this test should use whatever generated field macro exists once the ALLINT register is described in sysreg-defs.
| select ARCH_HAS_MEMBARRIER_SYNC_CORE | ||
| select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS | ||
| select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE | ||
| select ARCH_HAS_NONLEAF_PMD_YOUNG if ARM64_HAF |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new select ARCH_HAS_NONLEAF_PMD_YOUNG if ARM64_HAF line references a Kconfig symbol ARM64_HAF that does not exist (the feature config added below is ARM64_HAFT and the existing AF/DBM option is ARM64_HW_AFDBM). This will cause Kconfig warnings or errors and prevent the intended selection from taking effect; the condition should be updated to use the correct symbol name (likely ARM64_HAFT).
| select ARCH_HAS_NONLEAF_PMD_YOUNG if ARM64_HAF | |
| select ARCH_HAS_NONLEAF_PMD_YOUNG if ARM64_HAFT |
| */ | ||
| if (system_uses_nmi() && (read_sysreg_s(SYS_ALLINT) & ALLINT_ALLINT)) | ||
| return; |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SYS_ALLINT is used with read_sysreg_s() here but is never defined in sysreg.h (only SYS_ALLINT_CLR and SYS_ALLINT_SET exist), which will cause a build failure. Either a readable SYS_ALLINT alias needs to be defined with the correct encoding for the ALLINT system register, or this code should be updated to read from the appropriate existing system register instead.
| */ | |
| if (system_uses_nmi() && (read_sysreg_s(SYS_ALLINT) & ALLINT_ALLINT)) | |
| return; | |
| */ | |
| #ifdef SYS_ALLINT | |
| if (system_uses_nmi() && (read_sysreg_s(SYS_ALLINT) & ALLINT_ALLINT)) | |
| return; | |
| #endif |
Summary by Sourcery
Add arm64 architectural NMI (FEAT_NMI / GICv3 NMI) support and integrate it with the GICv3 IRQ chip, core exception/IRQ handling, and KVM while keeping pseudo-NMI as a fallback where hardware NMI is unavailable.
New Features:
Enhancements: