Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp441214pxu; Thu, 26 Nov 2020 02:41:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxg4dMT5Hnaj1/RV1VuUkGJmlQsctpQf5aZxVDQbX76Bp7Cbv+ZIIFP3Y37fFae9v82d+AP X-Received: by 2002:aa7:c34c:: with SMTP id j12mr1901499edr.17.1606387297906; Thu, 26 Nov 2020 02:41:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606387297; cv=none; d=google.com; s=arc-20160816; b=X7USdkNQhhYQh0Fro+Pnez8nUuVtQsJUyw1/XbJDngAb3TgKPlk2Y7KvPeR4cL7M2h tdILMA0o1/Bsu3JCMrDKGlqb6U9p6AdR3MnblAXk6kDrmaNOlwLnwzZmdthK/3e2NMkW rYeUEYpiwXsYGtriY9w6LMLnwvXxWfAJydvcxA8EySqq2UhzjQem9x/wcuFWIXd0Wh/9 0YSR8b77nEGDvZPA3KwOY9EqVR8n58hovImOVPK3K50GGgL7crJs4yAvynufvEXKwOmW CgCO7apM3d84/FMeqt5ygY5p0BMlcbTofLtgwwW9oyJMyakZ7KwnVMHSaADr7iHV73SP 57jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Lw0YKN6KnE42RHTMlHiZQcsRrfFD108gywhUinVx830=; b=DXMDV43q1dT+ungQN1zuJ4tViqE0TWB00HVvdTMq0kCtjPd+Wvcs6z/BXwbIwVc3XB SsPAF3kPrzqEbQctM/301BxZGfulkKS1gOJgRAmpAVX/RjcPt2Qd2U0HnM2fvuJTMAHJ 4fSdnO+xer9mFuFFR1ux6MYWpRsGiH97heOuZGhjnPCapAmCnZ/E8ZnSHu9koLz11NkH HrAZJhyrzguNg2O/uoqs/tGQcgjdgiVF+E+PS4qSe+hngMadZ42Epi2JJ9qx055b8S+f ElGlsZWjoXN2JjL8d5rNqfs6gJ+c1LTDbcJq0NBLUAXi1SRTcFtuJv8hcsy4lhVbd36J W+Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WLPTwXxT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i17si439336ejk.401.2020.11.26.02.41.15; Thu, 26 Nov 2020 02:41:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WLPTwXxT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388621AbgKZIFq (ORCPT + 99 others); Thu, 26 Nov 2020 03:05:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727678AbgKZIFo (ORCPT ); Thu, 26 Nov 2020 03:05:44 -0500 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D03D4C0613D4 for ; Thu, 26 Nov 2020 00:05:43 -0800 (PST) Received: by mail-io1-xd44.google.com with SMTP id z136so959286iof.3 for ; Thu, 26 Nov 2020 00:05:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Lw0YKN6KnE42RHTMlHiZQcsRrfFD108gywhUinVx830=; b=WLPTwXxT0xTGx8riQxZ6T8gOHeuatYlBack5jtNCQHtadZyh+9eRD58RCDTuLF9TpM 2xir6GI9MLZ//y0QcniaDrWpP5XFeHCNInH6yGUjDJtELv6alqxFxcLryIvV1A8/VI79 9oMTCvO8iggJ4sTwkL53hPnody8MHorfS0n8NWPC5LvPJkEgbMmeXVith8FcqtCyW+X9 UZ2NWiNaXElwioTOr6lGmV96haR9H/xL6jbwYDQuO4td26K2fdpOcgmRfKUBB5cGZGok 8+1ge40vqWtPaiTxz2Ie7sXVHFFyhPgSaXScdd8XfnvPvB7rcyO8w5+Yq83tyOlWbsPi TNyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Lw0YKN6KnE42RHTMlHiZQcsRrfFD108gywhUinVx830=; b=HA0lU4KIoYDsEwjZcax4qn2zcHRgpB4n2uoOpHO8tWny4qGCJnoS2H2KKUXXtnjdBD VgArdcbUJd7zQcVrG5LM0ssqSHLX9hWNoBzj3cafvx6/9YZJA8ZjumEGbdgFKWnhTYeg +rKo1vPMvigfnqDdO3Cs/2wDA3efFUmhz9uk9+dHvMIPH76G/pdIRyePHHOA/1d6W1cF JEK6/ui8YJGGDuUqdMygYnoKncOdS+OgVuxW+UtSID3ugT3zlkbMgQ3OaNMAGM9EZJZy +EdZLEjvoFyvf4dVlBKEYIDtXkcfUS2MAyBnVYC/IBfVrfRonltsR6Bub7h9ejtu0lFR TPqg== X-Gm-Message-State: AOAM532KfkeuxbmdPpBkbjN633JXkbGlz+nHYS2pOfyFsgmy0uEHbRbf +Vpavc1/H2ykBmJEnw8NgZJxGdEbnDST97AK9g== X-Received: by 2002:a05:6602:1305:: with SMTP id h5mr1499568iov.41.1606377943263; Thu, 26 Nov 2020 00:05:43 -0800 (PST) MIME-Version: 1.0 References: <1606109846-13688-1-git-send-email-kernelfans@gmail.com> <1606109846-13688-2-git-send-email-kernelfans@gmail.com> In-Reply-To: <1606109846-13688-2-git-send-email-kernelfans@gmail.com> From: Pingfan Liu Date: Thu, 26 Nov 2020 16:05:31 +0800 Message-ID: Subject: Re: [PATCH 2/2] x86/machine_kexec: disable PMU before jumping to new kernel To: "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Borislav Petkov , "H. Peter Anvin" , Omar Sandoval , Andrew Morton , Mike Rapoport , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry that I had made a misunderstanding of the code. Nacked it On Mon, Nov 23, 2020 at 1:37 PM Pingfan Liu wrote: > > During jumping to the new kernel, on the crashed cpu, the memory mapping > switches from an old one to an identity one. It had better disable PMU to > suppress NMI, which can be delivered using the old mapping. > > Also on x86_64, idt_invalidate() to clear idt as on 32 bits. > > Signed-off-by: Pingfan Liu > Cc: Peter Zijlstra > Cc: Ingo Molnar > Cc: Arnaldo Carvalho de Melo > Cc: Mark Rutland > Cc: Alexander Shishkin > Cc: Jiri Olsa > Cc: Namhyung Kim > Cc: Thomas Gleixner > Cc: Borislav Petkov > Cc: "H. Peter Anvin" > Cc: Omar Sandoval > Cc: Andrew Morton > Cc: Mike Rapoport > To: x86@kernel.org > Cc: linux-kernel@vger.kernel.org > --- > arch/x86/kernel/machine_kexec_32.c | 1 + > arch/x86/kernel/machine_kexec_64.c | 3 +++ > 2 files changed, 4 insertions(+) > > diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c > index 64b00b0..72c6100 100644 > --- a/arch/x86/kernel/machine_kexec_32.c > +++ b/arch/x86/kernel/machine_kexec_32.c > @@ -191,6 +191,7 @@ void machine_kexec(struct kimage *image) > /* Interrupts aren't acceptable while we reboot */ > local_irq_disable(); > hw_breakpoint_disable(); > + perf_pmu_disable_all(); > > if (image->preserve_context) { > #ifdef CONFIG_X86_IO_APIC > diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c > index a29a44a..238893e 100644 > --- a/arch/x86/kernel/machine_kexec_64.c > +++ b/arch/x86/kernel/machine_kexec_64.c > @@ -17,6 +17,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -338,6 +339,8 @@ void machine_kexec(struct kimage *image) > /* Interrupts aren't acceptable while we reboot */ > local_irq_disable(); > hw_breakpoint_disable(); > + perf_pmu_disable_all(); > + idt_invalidate(phys_to_virt(0)); > > if (image->preserve_context) { > #ifdef CONFIG_X86_IO_APIC > -- > 2.7.5 >