Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754867AbbHFFro (ORCPT ); Thu, 6 Aug 2015 01:47:44 -0400 Received: from mail4.hitachi.co.jp ([133.145.228.5]:38341 "EHLO mail4.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754751AbbHFFrf (ORCPT ); Thu, 6 Aug 2015 01:47:35 -0400 X-AuditID: 85900ec0-9afc5b9000001a57-5d-55c2f4af8d6f X-Mailbox-Line: From nobody Thu Aug 6 14:45:43 2015 Subject: [V3 PATCH 4/4] x86/apic: Introduce noextnmi boot option To: Jonathan Corbet , Peter Zijlstra , Ingo Molnar , "Eric W. Biederman" , "H. Peter Anvin" , Andrew Morton , Thomas Gleixner , Vivek Goyal From: Hidehiro Kawai Cc: linux-doc@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Michal Hocko , Ingo Molnar , Masami Hiramatsu Date: Thu, 06 Aug 2015 14:45:43 +0900 Message-ID: <20150806054543.25766.38473.stgit@softrs> In-Reply-To: <20150806054543.25766.29590.stgit@softrs> References: <20150806054543.25766.29590.stgit@softrs> User-Agent: StGit/0.16 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: AAAAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2816 Lines: 85 This patch introduces new boot option "noextnmi" which disables external NMI. This option is useful for the dump capture kernel so that an HA application or administrator wouldn't mistakenly shoot down the kernel by NMI. Currently, only x86 supports this option. Signed-off-by: Hidehiro Kawai Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Jonathan Corbet --- Documentation/kernel-parameters.txt | 4 ++++ arch/x86/kernel/apic/apic.c | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 1d6f045..2cbd40b 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -2364,6 +2364,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted. noexec=on: enable non-executable mappings (default) noexec=off: disable non-executable mappings + noextnmi [X86] + Mask external NMI. This option is useful for a + dump capture kernel to be shot down by NMI. + nosmap [X86] Disable SMAP (Supervisor Mode Access Prevention) even if it is supported by processor. diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index dcb5285..a140410 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -82,6 +82,12 @@ static unsigned int disabled_cpu_apicid __read_mostly = BAD_APICID; /* + * Don't enable external NMI via LINT1 on BSP. This is useful for + * the dump capture kernel. + */ +static bool apic_noextnmi; + +/* * Map cpu index to physical APIC ID */ DEFINE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid, BAD_APICID); @@ -1150,6 +1156,8 @@ void __init init_bsp_APIC(void) value = APIC_DM_NMI; if (!lapic_is_integrated()) /* 82489DX */ value |= APIC_LVT_LEVEL_TRIGGER; + if (apic_noextnmi) + value |= APIC_LVT_MASKED; apic_write(APIC_LVT1, value); } @@ -1369,7 +1377,7 @@ void setup_local_APIC(void) /* * only the BP should see the LINT1 NMI signal, obviously. */ - if (!cpu) + if (!cpu && !apic_noextnmi) value = APIC_DM_NMI; else value = APIC_DM_NMI | APIC_LVT_MASKED; @@ -2537,3 +2545,10 @@ static int __init apic_set_disabled_cpu_apicid(char *arg) return 0; } early_param("disable_cpu_apicid", apic_set_disabled_cpu_apicid); + +static int __init apic_set_noextnmi(char *arg) +{ + apic_noextnmi = true; + return 0; +} +early_param("noextnmi", apic_set_noextnmi); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/