From patchwork Thu Jul 23 17:33:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Toshi Kani X-Patchwork-Id: 6855251 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9B104C05AC for ; Thu, 23 Jul 2015 17:34:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B0EBA20773 for ; Thu, 23 Jul 2015 17:34:45 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D14FA2077F for ; Thu, 23 Jul 2015 17:34:44 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A32A31829E2; Thu, 23 Jul 2015 10:34:44 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from g9t5009.houston.hp.com (g9t5009.houston.hp.com [15.240.92.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 406111829E1 for ; Thu, 23 Jul 2015 10:34:43 -0700 (PDT) Received: from g4t3433.houston.hp.com (g4t3433.houston.hp.com [16.210.25.219]) by g9t5009.houston.hp.com (Postfix) with ESMTP id BF1304C4; Thu, 23 Jul 2015 17:34:41 +0000 (UTC) Received: from misato.fc.hp.com (misato.fc.hp.com [16.78.168.61]) by g4t3433.houston.hp.com (Postfix) with ESMTP id 3045658; Thu, 23 Jul 2015 17:34:39 +0000 (UTC) From: Toshi Kani To: hpa@zytor.com, tglx@linutronix.de, mingo@redhat.com Subject: [PATCH] x86/panic/reboot: Flush processor caches during panic/reboot Date: Thu, 23 Jul 2015 11:33:30 -0600 Message-Id: <1437672810-9641-1-git-send-email-toshi.kani@hp.com> X-Mailer: git-send-email 2.4.3 Cc: x86@kernel.org, bp@alien8.de, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP During power failure, Asynchronous DRAM Refresh (ADR) flushes the write buffer in memory controllers into NVDIMM, but does not flush processor caches. While the kernel and application code need to take care of processor cache flush, they may not be able to do so during panic or reboot. Add processor cache flush (wbinvd) to the stop-CPUs interfaces, native_stop_other_cpus() and nmi_shootdown_cpus(), which are called during panic and reboot as follows. These wbinvd()s are called on each CPU after its irq/APIC is disabled. - panic() + smp_send_stop() o native_stop_other_cpus() o stop_this_cpu() - native_machine_restart() - native_machine_halt() - native_machine_power_off() + native_machine_shutdown() + stop_other_cpus() o native_stop_other_cpus() o stop_this_cpu() - native_machine_crash_shutdown() + kdump_nmi_shootdown_cpus() o nmi_shootdown_cpus() o crash_nmi_callback() Note, the cpu offline path, mwait_play_dead(), already calls wbinvd(). Signed-off-by: Toshi Kani Cc: Thomas Gleixner Cc: H. Peter Anvin Cc: Ingo Molnar Cc: Borislav Petkov Cc: linux-nvdimm --- arch/x86/kernel/process.c | 2 ++ arch/x86/kernel/reboot.c | 5 +++++ arch/x86/kernel/smp.c | 2 ++ 3 files changed, 9 insertions(+) diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 397688b..3a1f381 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -320,6 +320,8 @@ void stop_this_cpu(void *dummy) set_cpu_online(smp_processor_id(), false); disable_local_APIC(); + wbinvd(); + for (;;) halt(); } diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index 86db4bc..5ef4d4b 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c @@ -737,6 +737,9 @@ static int crash_nmi_callback(unsigned int val, struct pt_regs *regs) shootdown_callback(cpu, regs); atomic_dec(&waiting_for_crash_ipi); + + wbinvd(); + /* Assume hlt works */ halt(); for (;;) @@ -780,6 +783,8 @@ void nmi_shootdown_cpus(nmi_shootdown_cb callback) smp_send_nmi_allbutself(); + wbinvd(); + msecs = 1000; /* Wait at most a second for the other cpus to stop */ while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) { mdelay(1); diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c index 15aaa69..41e7ca8 100644 --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c @@ -244,6 +244,8 @@ finish: local_irq_save(flags); disable_local_APIC(); local_irq_restore(flags); + + wbinvd(); } /*