From patchwork Wed Apr 22 14:35:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 185694 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp833593ilf; Wed, 22 Apr 2020 07:35:52 -0700 (PDT) X-Received: by 2002:aa7:96e8:: with SMTP id i8mr27612099pfq.222.1587566152307; Wed, 22 Apr 2020 07:35:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587566152; cv=none; d=google.com; s=arc-20160816; b=SLGMBtHGqs89eSjF6DaCiOAUSpfK6gBetroZqYl56Z06RnoNjj7NgVQdLyOpfqqnvU mN+ABjM3v0urc5fXpJAOR+NqI+D1EM5p44qAXk8mETZBv7slGZ5CS92vJaX8raBZFZQd Nb7nzdqGSOxftiVoxy+7OSZrj+tXjFdflum9QMwWEIFg6j0uDbM63SpkbwHAxpitJwPX wLG8c0MaH6n4x14rZDukZIKOtGNQ4kFkOGO0MqeDaEwKBg1pYDaa/Fgsp6j6Lt6kF0hA 1RhZZXK7n0hE1BmPHOXakc5pYeCrQ3dmXSdNX799cxrCl2E7ffmgHndeXdmcA9B0c0Fi feGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EKk8wf3cz8RUWzn1IoJAXdPdtXtapZhuXqAKZvlxhk0=; b=oP7+3LDUQLxvrBFuhBBrOnnF0A8HNPd1W1AZdioc4mWy4Hri/DqckcdemwK7hQalZJ 2QoGtvDyN33ae6cqiP2E8zvPb9M1pTlJGq4dB2m/szznjbwjlmiR95CMqP9jhwxKQW3l +QhnYkMn/siTwfdsr28jc6A/r/rF2nAWF/Dw4TSJ5RjwROoF1ZyY+6IbMZWJeqKHaeR2 YO1jnIUNSBW62m3I4rwEYIkFfW9wSObAyFX4S9L6kaFCusK9rBOGyK5hgRclUkbHuslI lyn8VFYTq8/smWgE819IZ9tN/y2crm0RCzRNtJo0Zq/lwKBwX6Oh+bFmrh4fYn2WSY9j zCfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q8wWVk1c; spf=pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=sumit.garg@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c2sor7528139pgh.54.2020.04.22.07.35.52 for (Google Transport Security); Wed, 22 Apr 2020 07:35:52 -0700 (PDT) Received-SPF: pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q8wWVk1c; spf=pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=sumit.garg@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EKk8wf3cz8RUWzn1IoJAXdPdtXtapZhuXqAKZvlxhk0=; b=Q8wWVk1ckEkvNGo5uhA1JXDfkNoPrE1CsY1IwOXg92Q4y4AdjWHDV2+/nSZNGB6XTB yrD5WujSF1M0Mz8D0BlZQF1S16h3hTVjLyWqTaT9JlvXZffmX/3vHWYkVbChjJ9Tizd2 iqqPczIw+Kk/UDDdId8MC50u+viNXYq/lGRFNbMEAbLw7fG6gFp1Z5WMK6EGvLQQSCgB PrKLan3ZRMz+C3rjN+QpI//nIShjjPFw1kD1n/MJADcdY+4ydS4DH2LxH3WJmwO+6IaY cO0V+wPMQE9JGH0MGA3Uniy2rCgRrCmDCwORW3VbesffeQ5M/3lCLDOkj/IwLXQJXK5R qnTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EKk8wf3cz8RUWzn1IoJAXdPdtXtapZhuXqAKZvlxhk0=; b=fg9MpD8nadIAfmGcaowQesLH2YGxtxeo4iaBKB2gxFpHMnRANr+LoQntFL1qRg3W9K 68xlBuv9GZvTPl67RFsTH3Qpk9sWVHW0R6amUIf291limBzDIFKfMiy29a43rts6SSZy e3Pyjt9ngkjhVp/e3HHP/SD8XZZ9oOVy2FDtUXCJ9MFqnMnjkw79peD5vdEX4UZnK0zl xK9Cu6ZGDuVLJUVcOZj4IjsJ2MZykS0MR62xhttI16AuTH0lzMGR/9B7sbRNL0XtGFc5 RiO6bSyUkQrROt+5+Dvp/yjkp8QNcksYQ4tkFuaHhQJU3E1cE+ZDe8P4Gc5A1qh/CiSv +IzA== X-Gm-Message-State: AGi0PuZ7ZLwQ69jOiSFKgdHp5v+1NkpS2x2xh7W5BFcIy29bRgkIr/DP 4cgsdXSFl+lyedeqb/j1vCL4XjHN X-Google-Smtp-Source: APiQypIGpdwJVGb3tVlbi4DwamFnWduPC0rVhLqqQD6QG7bYffklXl6F8G0lQOfP67Z2bDs1Al436w== X-Received: by 2002:a63:bf4a:: with SMTP id i10mr27932901pgo.120.1587566151867; Wed, 22 Apr 2020 07:35:51 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([117.252.71.186]) by smtp.gmail.com with ESMTPSA id j13sm5723573pje.1.2020.04.22.07.35.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2020 07:35:50 -0700 (PDT) From: Sumit Garg To: daniel.thompson@linaro.org Cc: patches@linaro.org, Sumit Garg Subject: [RFC 1/4] arm64: smp: Introduce a new IPI as IPI_CALL_NMI_FUNC Date: Wed, 22 Apr 2020 20:05:20 +0530 Message-Id: <1587566123-9935-2-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1587566123-9935-1-git-send-email-sumit.garg@linaro.org> References: <1587566123-9935-1-git-send-email-sumit.garg@linaro.org> Introduce a new inter processor interrupt as IPI_CALL_NMI_FUNC that can be invoked to run special handlers in NMI context. One such handler example is kgdb_nmicallback() which is invoked in order to round up CPUs to enter kgdb context. As currently pseudo NMIs are supported on specific arm64 platforms which incorporates GICv3 or later version of interrupt controller. In case a particular platform doesn't support pseudo NMIs, IPI_CALL_NMI_FUNC will act as a normal IPI which can still be used to invoke special handlers. Signed-off-by: Sumit Garg --- arch/arm64/include/asm/hardirq.h | 2 +- arch/arm64/include/asm/smp.h | 1 + arch/arm64/kernel/smp.c | 20 +++++++++++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/arch/arm64/include/asm/hardirq.h b/arch/arm64/include/asm/hardirq.h index 87ad961..abaa23a 100644 --- a/arch/arm64/include/asm/hardirq.h +++ b/arch/arm64/include/asm/hardirq.h @@ -13,7 +13,7 @@ #include #include -#define NR_IPI 7 +#define NR_IPI 8 typedef struct { unsigned int __softirq_pending; diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h index 40d5ba0..cc32776 100644 --- a/arch/arm64/include/asm/smp.h +++ b/arch/arm64/include/asm/smp.h @@ -108,6 +108,7 @@ extern void secondary_entry(void); extern void arch_send_call_function_single_ipi(int cpu); extern void arch_send_call_function_ipi_mask(const struct cpumask *mask); +extern void arch_send_call_nmi_func_ipi_mask(const struct cpumask *mask); #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL extern void arch_send_wakeup_ipi_mask(const struct cpumask *mask); diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 061f60f..42fe7bb 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -74,7 +74,8 @@ enum ipi_msg_type { IPI_CPU_CRASH_STOP, IPI_TIMER, IPI_IRQ_WORK, - IPI_WAKEUP + IPI_WAKEUP, + IPI_CALL_NMI_FUNC }; #ifdef CONFIG_HOTPLUG_CPU @@ -798,6 +799,7 @@ static const char *ipi_types[NR_IPI] __tracepoint_string = { S(IPI_TIMER, "Timer broadcast interrupts"), S(IPI_IRQ_WORK, "IRQ work interrupts"), S(IPI_WAKEUP, "CPU wake-up interrupts"), + S(IPI_CALL_NMI_FUNC, "NMI function call interrupts"), }; static void smp_cross_call(const struct cpumask *target, unsigned int ipinr) @@ -856,6 +858,11 @@ void arch_irq_work_raise(void) } #endif +void arch_send_call_nmi_func_ipi_mask(const struct cpumask *mask) +{ + smp_cross_call(mask, IPI_CALL_NMI_FUNC); +} + static void local_cpu_stop(void) { set_cpu_online(smp_processor_id(), false); @@ -960,6 +967,17 @@ void handle_IPI(int ipinr, struct pt_regs *regs) break; #endif + case IPI_CALL_NMI_FUNC: + /* Handle it as a normal interrupt if not in NMI context */ + if (!in_nmi()) + irq_enter(); + + /* nop, IPI handlers for special features can be added here. */ + + if (!in_nmi()) + irq_exit(); + break; + default: pr_crit("CPU%u: Unknown IPI message 0x%x\n", cpu, ipinr); break; From patchwork Wed Apr 22 14:35:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 185695 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp833669ilf; Wed, 22 Apr 2020 07:35:56 -0700 (PDT) X-Received: by 2002:a4a:9605:: with SMTP id q5mr21380452ooi.16.1587566155885; Wed, 22 Apr 2020 07:35:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587566155; cv=none; d=google.com; s=arc-20160816; b=0xWZRX4t7yB9OwoZBmdhfGg4lRE4TavDZSwhZb51ToGDzVGJv/Asrsge4g6rDbWcoN xk8q5rCv7455/B+kY8MT7LhqLRSrQvQv9c+5K1iHZ2d/GVKZAwt02ac8AsxS7qtr4V2i iHvXQMAcOiVKB75cCXnbgNkO+ffu7rBTbqHPa06aFwtT5ohExv5yE22PcjTeZLXPfPmD NdnF0dJ5ouwDM0cinD52TQqtbhd3hxHkbgVKBFxlfdO90V2M7N/f4vwTGZMIwYsVP0PO FDszdfW7AngQn6O0y58C9yEh5FkHluyB5qcyensB5pu+/QKOE4yG2u8De9lXnxZLoC8z yyAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iZlX3qI3DOrQp2dXg0tXmAB1b4Jn5t/S/MWmmmiRunE=; b=eCS8oYt1wd50wtR0+dHQfL6Y78b2opY+AJoHK0xjKQ5lvt7VFQL4mmZqNP3tnZsqE7 mR2ox+O7WLXLtRxmOIssWTAe+vvm14M+VVEuQbJ9CT322K33qVmCjPUtUFtQTL/hdarT xfyR1K+m3XfuscEOgcvqBroAtv0uFJMuibh28zH/XylYXc5o9ykovvuzqLrBB4T0xI0c 4h8SSz865nkyyaezaovdsmrsFHb7aRL6ogDAXTlvqOLsb2fiNK4s8tDl1g0Yocf1EvlV 5hB+v4H7c6pUxXf4zhcguDEyIT/tAWitO16sSTbKNRzAwspnUwGVv386ZPMan3EWq21X vkWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QVzwvPie; spf=pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=sumit.garg@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c188sor5940247oif.59.2020.04.22.07.35.55 for (Google Transport Security); Wed, 22 Apr 2020 07:35:55 -0700 (PDT) Received-SPF: pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QVzwvPie; spf=pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=sumit.garg@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iZlX3qI3DOrQp2dXg0tXmAB1b4Jn5t/S/MWmmmiRunE=; b=QVzwvPieJ1w/H+7J2TE+7hOJr96Z6m2GANC6JfXnBkSgKWaK0EjJpophaIxYqAgZUP EZl3KcCQxYi78mmr+LCdCF945bZm0htZRanTD6tPCQD0jSZNDhmeVq2vPZOgLYkqzpRY M3obVswJMAba9yRFeRsiHrsk1G7TEwA4L7awfruMoXYtOIZaYrvhXiQKFCQQekV1Zzqd XrhClhIcHp5ml2hV4oWVdFKPdSQlhKoTAkx0CdvwdMNB3S/uggBdT81fZsRV+5QitI0I 9eyqScIP1sltyiYlAVP/MsPO/NrZHbVWhHv5JR/q6+Gjsy2yZ2WfJj5WFGDRfXN5uosS BUgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iZlX3qI3DOrQp2dXg0tXmAB1b4Jn5t/S/MWmmmiRunE=; b=bjtx6FBmUat0+HfrqYwn8oWior9MaqYyXhX87a0mqR3bHjStLrlWdXO0wkXmc/PHlU ffMJv4l4rXxmgZfWtrWLUsJJL5QcfsC9w7BbOOIaZ3fC2+kCvUpBAMoef3WH7tnBUQo1 QT9PxQVQNAqdyWLUF+EZqQguwRS2WcsLhqeD4mXLRdtbIoAI7etZZtMTcDdyT4+qQ12O 4ZPCgRzn1DNropWFakAyGdOotTOLi7+x9Ma0D7Msjp7WxZ/NTISyXde6ulXnmw8ZamtO 4EUZK5ue69c01j3rkHJe7H48zMrWsfSSq5LoFBWikA3tN7/NvFChF95ytVhSdQ3FUpkB zWUA== X-Gm-Message-State: AGi0PuZln92k33cV1YEbeQnYGqp0x6mordMW9g84qns0JLwsy9u34gxP 5LTAT6hA5MYiPVOUsEdnRIpxO6U8 X-Google-Smtp-Source: APiQypKbMLbHO0br4DeQmQP8x4NX3RI4CcvMObuiKwVlHd/XqBytzk8eCWkY2MFsJX5hmtYKMaRMgQ== X-Received: by 2002:a63:6e81:: with SMTP id j123mr28090959pgc.333.1587566155515; Wed, 22 Apr 2020 07:35:55 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([117.252.71.186]) by smtp.gmail.com with ESMTPSA id j13sm5723573pje.1.2020.04.22.07.35.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2020 07:35:54 -0700 (PDT) From: Sumit Garg To: daniel.thompson@linaro.org Cc: patches@linaro.org, Sumit Garg Subject: [RFC 2/4] irqchip/gic-v3: Add support to handle SGI as pseudo NMI Date: Wed, 22 Apr 2020 20:05:21 +0530 Message-Id: <1587566123-9935-3-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1587566123-9935-1-git-send-email-sumit.garg@linaro.org> References: <1587566123-9935-1-git-send-email-sumit.garg@linaro.org> With pseudo NMIs enabled, interrupt controller can be configured to deliver SGI as a pseudo NMI. So add corresponding handling for SGIs. Signed-off-by: Sumit Garg --- drivers/irqchip/irq-gic-v3.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index d7006ef..be361bf 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -609,17 +609,29 @@ static inline void gic_handle_nmi(u32 irqnr, struct pt_regs *regs) if (irqs_enabled) nmi_enter(); - if (static_branch_likely(&supports_deactivate_key)) - gic_write_eoir(irqnr); /* * Leave the PSR.I bit set to prevent other NMIs to be * received while handling this one. * PSR.I will be restored when we ERET to the * interrupted context. */ - err = handle_domain_nmi(gic_data.domain, irqnr, regs); - if (err) - gic_deactivate_unhandled(irqnr); + if (likely(irqnr > 15)) { + if (static_branch_likely(&supports_deactivate_key)) + gic_write_eoir(irqnr); + + err = handle_domain_nmi(gic_data.domain, irqnr, regs); + if (err) + gic_deactivate_unhandled(irqnr); + } else { + gic_write_eoir(irqnr); + if (static_branch_likely(&supports_deactivate_key)) + gic_write_dir(irqnr); +#ifdef CONFIG_SMP + handle_IPI(irqnr, regs); +#else + WARN_ONCE(true, "Unexpected SGI received!\n"); +#endif + } if (irqs_enabled) nmi_exit(); From patchwork Wed Apr 22 14:35:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 185696 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp833739ilf; Wed, 22 Apr 2020 07:35:59 -0700 (PDT) X-Received: by 2002:a17:902:8202:: with SMTP id x2mr1413975pln.287.1587566159772; Wed, 22 Apr 2020 07:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587566159; cv=none; d=google.com; s=arc-20160816; b=JUdY+SD+n7mzDigfjzTxIVod9r9q2cTaMHcT1RhS2QyGRyWNsFdeQLrFkQK4VF3CWc jK+H1en4uDV4HYBCdbP0uT0BRvUAVWuLqlLpbq1U9ge04/9cqRLjczabRZxGRaAcd79O rQenLBLqzwFmqg/9q3lq4EukMHvtbyBUZDbhrr1IRmBdamDTLaJF6qOabcAZxZ6JqKLe dMzkWo008u8AobCK64sogAa9c2I8+GKvdf88q0esG9BXA0AZ+cQaes4ZItLKfWFmne93 3YZtmGLmMYpfnPeOyB2ZVIfrCtfAN0Q2qTXOyWcUUv4t0LGtYtOi/vXP5p7GWDZu9X3n 6pQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VxQ4o9PvJLeDXlCdKC6FnBvF+Rh/OB42QR1xOvGVmug=; b=iZ+GfjMvm13rfXaSIo6yLW9wznsYZ6Z0/ehXq5cpVSj78AvWQ+5wc0T/2wYcb7rSrT 9aozylax881JiBlL1Qc1noyRTrbK40N0fsR2Cc+xb8+Zbiq+fovHk9IRKfwrIT5tl/zI WveC2PiI8f/LUbu9jtVcH4h8V27tzDlBRS1Ibbi7tATnYDKoMp6hpxYKcMd2WrWx058h bRgUtZ3xCvC9TwqvDCK31CoMvrCh9ZymqN4WxNjoqgpRu052BtpgeaQxQ1HJgkMpsd+z +dIY+C0aeX7Ajrgflh2cn41QzXK999j2rcusfZ4HIu8xG0X5gKB1eAMkUrwwqnXSRtsA MDqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hg7a3JtB; spf=pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=sumit.garg@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m5sor8288307pls.56.2020.04.22.07.35.59 for (Google Transport Security); Wed, 22 Apr 2020 07:35:59 -0700 (PDT) Received-SPF: pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hg7a3JtB; spf=pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=sumit.garg@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VxQ4o9PvJLeDXlCdKC6FnBvF+Rh/OB42QR1xOvGVmug=; b=hg7a3JtB5sI2XDMCGh/9KzAX5xyYdxAvzVKH79Qn2+NyjekgcoOmY32cdhRTQckNTq t0MoxDPbPT/KUCREA4arEk7k5dwJSo0MLjmpmptbQmn9P4L3RbQ/DCeKMD/pGBJosUDT VnecFCYa4yJif6WWCt/5xQGoLAWpHYg3p0q8ojT4yko5K4G25BxOMB4mWIE/e5ZZOQNH Ol+9uNoVVp/FVxXAr3EZhXr3lfpBbNHlOVORI5d3xOVCNGDEwadF74ctwS/6CwzPa6mD cg77Sd1X7SdcAplO7WA04ct6Pu7HLxPJ4WHpJRVNDdONT80KN74lTQHKIR0XsKjxJnY7 e7DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VxQ4o9PvJLeDXlCdKC6FnBvF+Rh/OB42QR1xOvGVmug=; b=M+5Re4VvQpSlKvcphniB3kqkKn+dkP+HuWbav02PgB5MzCX9FxSkTR/jW9+41MWw4z 3dTl0KDN4BYtN2rIISiqodkeiKAry8pc9A1W/XGo0jKmtn4M0oP72pUgGzV8LfizBXnG qImkpbGZ8NOict406CG1beEzbaQe9qbjHz+Eh9X9tqQ++QbsjgW6Oj4a1//dequZU0AO jjZ6dwNClRIT/u0LKil8oBIKfgHRfHiDAbJ/YD9D4nS3CuEgUAB8GLg7VoYG1U0QtjzA JLbPIkTZiqNpMJDMKVK7XVT2M/ob42vikadtlM3Y9PDIKVjhhS1NhK+MtUqXlE203zpU GLVQ== X-Gm-Message-State: AGi0Pua3VQwAY/zljNIBMtZpsH2WeRfBWpSp8vqYHq7GYgxeutLJb56N jNocpHPWpFCoZPOXSkGM0lYun1wM X-Google-Smtp-Source: APiQypK6NjFfZDKs0UkF/9bpotSFxHPVESWWIb4eILaVJCslpqzkS8kNGsgUsWYG3xtHbqP3qYJ0HQ== X-Received: by 2002:a17:902:d201:: with SMTP id t1mr5671220ply.328.1587566159437; Wed, 22 Apr 2020 07:35:59 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([117.252.71.186]) by smtp.gmail.com with ESMTPSA id j13sm5723573pje.1.2020.04.22.07.35.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2020 07:35:58 -0700 (PDT) From: Sumit Garg To: daniel.thompson@linaro.org Cc: patches@linaro.org, Sumit Garg Subject: [RFC 3/4] irqchip/gic-v3: Enable arch specific IPI as pseudo NMI Date: Wed, 22 Apr 2020 20:05:22 +0530 Message-Id: <1587566123-9935-4-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1587566123-9935-1-git-send-email-sumit.garg@linaro.org> References: <1587566123-9935-1-git-send-email-sumit.garg@linaro.org> Add support to mark arch specific IPI as pseudo NMI. Currently its used to allows arm64 specific IPI_CALL_NMI_FUNC to be marked as pseudo NMI. Signed-off-by: Sumit Garg --- arch/arm64/kernel/smp.c | 5 +++++ drivers/irqchip/irq-gic-v3.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) -- 2.7.4 diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 42fe7bb..27c8ee1 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -802,6 +802,11 @@ static const char *ipi_types[NR_IPI] __tracepoint_string = { S(IPI_CALL_NMI_FUNC, "NMI function call interrupts"), }; +int arch_get_ipinr_nmi(void) +{ + return IPI_CALL_NMI_FUNC; +} + static void smp_cross_call(const struct cpumask *target, unsigned int ipinr) { trace_ipi_raise(target, ipi_types[ipinr]); diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index be361bf..a3d2cf3 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -1048,6 +1048,11 @@ static int gic_dist_supports_lpis(void) !gicv3_nolpi); } +int __weak arch_get_ipinr_nmi(void) +{ + return -1; +} + static void gic_cpu_init(void) { void __iomem *rbase; @@ -1072,6 +1077,15 @@ static void gic_cpu_init(void) gic_cpu_config(rbase, gic_data.ppi_nr + 16, gic_redist_wait_for_rwp); + if (gic_supports_nmi()) { + int ipinr; + + ipinr = arch_get_ipinr_nmi(); + if (ipinr >= 0 && ipinr < 16) + writeb_relaxed(GICD_INT_NMI_PRI, + rbase + GICD_IPRIORITYR + ipinr); + } + /* initialise system registers */ gic_cpu_sys_reg_init(); } From patchwork Wed Apr 22 14:35:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 185697 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp833816ilf; Wed, 22 Apr 2020 07:36:04 -0700 (PDT) X-Received: by 2002:a9d:6302:: with SMTP id q2mr6943307otk.181.1587566164362; Wed, 22 Apr 2020 07:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587566164; cv=none; d=google.com; s=arc-20160816; b=wiF7wnIiXJbaLPeMKUJiGc4NxM1HqeD06n+G/ktF+3TEU6YkJ961f4v4ZME+0tC1C8 cixDT9zf2lbeaO+XTdWL/M130J+8udvveO9rX9nRHlqZ0EW4JPGyp7j4tljhr4M3qWqQ HLOQcCIYzELOxGIdQeBs1ca6igSlgNJgGpaUOOeh/ADsenCGMtbSf7qMhZrjHpetrThu NCldZTCyqimNz/eN8Tv15VR7UFo7w7AM54iUskXYEavhnKVZgqLQCnAPyD2Y51i3rsfb KR0xxswNNnMxrfxMsA568X2ZXnSV+kqx5OLxFFssXvMyPjkvdZx9Lj0fzgIPZD3u8F3B CowA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tC4rQoO7pOMrbHgj3hoz18UuBgFHtPdML5UTOcQ928s=; b=yAf6bE87UR/GG8mPKQOhdUyeC6wGzkaw/6ifM8EYR+Q0wgz9uuB5Gw/zUSgJ1X9hxT COUH460rax6fZOnuOkcoo3Tcmgw4d7M46QW3h+zuZCyN+1JNHaOfIEiGt1U4V9DXkxu0 wbonbpIMG33mk/kP1mbZQ9Htvuc9WpFsz+0/FKscMI7Qwon7ky8cSKGvTLPXQYVd2jbv KMiVpNglADxmFfAbDuvxlMUhSQ7WNeDwB8WioyToJGtW3cYFx1mrVJpkCtns0SliIFG9 yF427fUGgV6uvnSQVmib3AKGPWZSJsme9iXHgXCt7PFe47AOLNerK9iYjyHd6e6hUvmD LlVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rv94Azr6; spf=pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=sumit.garg@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p2sor4649513otq.52.2020.04.22.07.36.04 for (Google Transport Security); Wed, 22 Apr 2020 07:36:04 -0700 (PDT) Received-SPF: pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rv94Azr6; spf=pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=sumit.garg@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tC4rQoO7pOMrbHgj3hoz18UuBgFHtPdML5UTOcQ928s=; b=Rv94Azr6weHWGOFhI/CSlZZJf+ibgxneVZKMYLXDZ/hgqS1/yZSqbbs+7O6kjMFhfe R6ctPpHL+XqbQ+ebUra5iCuiYENiMUuz67nMF6O0HDxIXLHHFacbIYPTFF049Qc8lSh1 qjE2haos7NtaDV+Hd17qGXXOfshWa2XC2KB8cFnf7JQkfVLywngWLSsvkXeoXwPQ7Whr 4O8JbVqeOez+WeI8ZwC8tbHTwmx4vgCzfT8sDUfIRfF50pbId8p2pO1Q5UKZ6TqBJhki Mm2Zd/Lt6/JLcwL7s3gAPGG0bESoMjw8ktJKLEoB+gr26DFYGWJ+ij71+MkPUZAJDcqX kdlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tC4rQoO7pOMrbHgj3hoz18UuBgFHtPdML5UTOcQ928s=; b=EfsyB9NKhpoG8JNusRHv54+jUDkJXnaU0O1DvwT48CN6ghOZ0kW2mRlKJYSCxK0Yz+ yOyW+ekNcfr4yLuh6PfqJMc2+zO3fLWXl3xBngAUpY5WLCEr1XYsqvSmhuY8q0qXKcqL UVqCbJJNRqVm5UUKXwRNNGmc9B+QepD5W9hVF3H+cMY1NJK8/Ft+D5gCUEXOZfDgJ8+d 6uQ8jwO9k8zPpA8bRCjeIvkWiVsWVidiCYCf0P+iWB5WTvWygC7acqWAUQKwJevvi3/s CAULR/zrvHdA6Ba/cKIc05glrcYku87NT4NqXheU2NldcC9pscW/F9veruqwqjEXu6WM Y4qQ== X-Gm-Message-State: AGi0Pua5XpXz0Mh2HwbWH+z/KWU63VmUmNlqxGLEZ/j5/MgKVR+E3H36 QosrJb7RGp9xb5JweigoSNfcRYt8 X-Google-Smtp-Source: APiQypLH5DBE6FuhH6+JxXzLb8Tjnc+FNRFQbMIsfNJ+Yqh6YbnAGK5ivF+fkypqujhvSfzEguw8fg== X-Received: by 2002:a17:902:d716:: with SMTP id w22mr27545017ply.200.1587566163976; Wed, 22 Apr 2020 07:36:03 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([117.252.71.186]) by smtp.gmail.com with ESMTPSA id j13sm5723573pje.1.2020.04.22.07.36.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2020 07:36:03 -0700 (PDT) From: Sumit Garg To: daniel.thompson@linaro.org Cc: patches@linaro.org, Sumit Garg Subject: [RFC 4/4] arm64: kgdb: Round up cpus using IPI_CALL_NMI_FUNC Date: Wed, 22 Apr 2020 20:05:23 +0530 Message-Id: <1587566123-9935-5-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1587566123-9935-1-git-send-email-sumit.garg@linaro.org> References: <1587566123-9935-1-git-send-email-sumit.garg@linaro.org> arm64 platforms with GICv3 or later supports pseudo NMIs which can be leveraged to round up CPUs which are stuck in hard lockup state with interrupts disabled that wouldn't be possible with a normal IPI. So instead switch to round up CPUs using IPI_CALL_NMI_FUNC. And in case a particular arm64 platform doesn't supports pseudo NMIs, IPI_CALL_NMI_FUNC will act as a normal IPI which maintains existing kgdb functionality. Also, one thing to note here is that with CPUs running in NMI context, kernel has special handling for printk() which involves CPU specific buffers and defering printk() until exit from NMI context. But with kgdb we don't want to defer printk() especially backtrace on corresponding CPUs. So switch to normal printk() context instead prior to entering kgdb context. Signed-off-by: Sumit Garg --- arch/arm64/kernel/kgdb.c | 12 ++++++++++++ arch/arm64/kernel/smp.c | 17 ++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c index 4311992..d6be647 100644 --- a/arch/arm64/kernel/kgdb.c +++ b/arch/arm64/kernel/kgdb.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -353,3 +354,14 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt) return aarch64_insn_write((void *)bpt->bpt_addr, *(u32 *)bpt->saved_instr); } + +#ifdef CONFIG_SMP +void kgdb_roundup_cpus(void) +{ + struct cpumask mask; + + cpumask_copy(&mask, cpu_online_mask); + cpumask_clear_cpu(raw_smp_processor_id(), &mask); + arch_send_call_nmi_func_ipi_mask(&mask); +} +#endif diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 27c8ee1..c7158f6e8 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -976,9 +977,19 @@ void handle_IPI(int ipinr, struct pt_regs *regs) /* Handle it as a normal interrupt if not in NMI context */ if (!in_nmi()) irq_enter(); - - /* nop, IPI handlers for special features can be added here. */ - +#ifdef CONFIG_KGDB + if (atomic_read(&kgdb_active) != -1) { + /* + * For kgdb to work properly, we need printk to operate + * in normal context. + */ + if (in_nmi()) + printk_nmi_exit(); + kgdb_nmicallback(raw_smp_processor_id(), regs); + if (in_nmi()) + printk_nmi_enter(); + } +#endif if (!in_nmi()) irq_exit(); break;