Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp618605pxu; Sun, 22 Nov 2020 22:23:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxa33Qtdh4H8XijOa19XHfURGtXWY23RlNZ/yLd0yTEEm5dcMdmb7v1QKKQSPXwtPemVZxI X-Received: by 2002:a05:6402:16d5:: with SMTP id r21mr45275458edx.149.1606112629214; Sun, 22 Nov 2020 22:23:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606112629; cv=none; d=google.com; s=arc-20160816; b=Lc1IdOqWIqO082V/6W/ODqkOTXssi6KjtbN9/sMaaoLgKTnE5EmCpYQLyLZ82ca3CF XYgeuPa0o39kV3whK6k50MXAIVN9pRCWsoSo0jdhxBMjUx31meai6ywgiOEjfHj0XXMp i+Kp8KvBokhMuwneZsVRp+8HPjph6IyKwTlABCsIZgHiWAIi8x+SI3/OWk+TAki62nx1 H9DX3gz5eBWARLM7GxSKzgAAc0XWb2clefmUuHh0y3HPM4DWiniTCinz5Po0F4HEqVFo tE1hfkfpbW2qlLvIyRmCAj6fYO10iocBQ3eacdIKqpAwcn7GqRAgAiF37gAqceHSWwyM kelw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=UGBhOw/fRgUFpvRhV+fdWmv9QNQTBHvPX/g8g6YWFD0=; b=C01A3jFVnh9l3Fi7+cuIBgNY2VINIuXR+EP6jn6xqFKC62VjBnAD1DHRjBHA3MGPU1 DNXsB+9sXLiJiNcsuEbZonj8k8KxjSlMmAs3sp4Tj9xk4n62jpJm2rmK/9ajfg8x9umr eMn3xHN4Con5Ywhtb61GFEA7QVrukBFkyYoknOIG2LlrXL8xKO17hb8PuT5j+pv1dNIg 0omKgTiqdKEtcUyou+5cVJwqMyDz89aN0w2tKdUPUHT9/00m5gKvmk//Ciafx6yCylKb okP8r+aKWGVViq+11uwD5zYQppMkfS4p88c2JPyHorm0PPNreYtVVHZRCHtaWmsN8D36 +AqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BWbZn7FY; 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 b15si5932945eja.538.2020.11.22.22.23.26; Sun, 22 Nov 2020 22:23:49 -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=BWbZn7FY; 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 S1727845AbgKWFh6 (ORCPT + 99 others); Mon, 23 Nov 2020 00:37:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725275AbgKWFh6 (ORCPT ); Mon, 23 Nov 2020 00:37:58 -0500 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 553B9C0613CF for ; Sun, 22 Nov 2020 21:37:58 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id s63so3323261pgc.8 for ; Sun, 22 Nov 2020 21:37:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UGBhOw/fRgUFpvRhV+fdWmv9QNQTBHvPX/g8g6YWFD0=; b=BWbZn7FYTpTmB6K5e5yo6bj8Y5+Gs2djnmet9/UNvkvs3x5jvydaorHRslrIdZAwZN k5LxJWu/BfzgNE/ppJCWkzmdJ4sdtGB1ErsyLDNKhFLD7pKzLgpcx2ohwJ0GZoDQ7Vb5 H9qOmA7dFSxTs05oBv7t9dA6XxkmwGnuDn4GkKtQ4WdftFB35BeNhCInQfPqH1rjznke 9KlJsEEIf4IeR+REMJN4ZfFtucFj0u5QWq3mC/t1XlJXSXZAkfpvdq6DM3nfQ8WM2vTs qez8kCsCKYZDVeMvYL2aH60ynGIlJ/eoSXwPfJ/Y+ZQYn4zzdjmLsOow+2iStmoxNGmF xL/Q== 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=UGBhOw/fRgUFpvRhV+fdWmv9QNQTBHvPX/g8g6YWFD0=; b=YS9qOyF8whOBpI0t3saG7dGdjfJ5KiZde6fnEWJ55D6zTrsxH8dHlHGIeLinQSkrfF Z9KvQNpUVQ39/xSP8RAfg8ivb8BGgW7TveEVapouBamXr35BuzmJIz90Smb+NRpeVQNl Dyyuu++IT/jbtuRjr0Fro5BjZ8k1eKVgFeAkQgnS0b6eIqtU7DgmISqKOR/ubHG8ngtT LM2R6gy5pkTZIQxjrweUs6kbU5igcE4n5x4zdOwgGEYTTBBrdocoYkvBDZo0rDAFJfXJ IwKz7rBB9zR8dDg2zJwNJO9JxF3DxRlBHCKdM58cB+ScD/GJbFzNj+tngldjualI5Ok/ qF/Q== X-Gm-Message-State: AOAM533/Tx9bZO9jI7ORwH8XPyVBJhtrLM5x8ozaeTCeJy/WPAJUB8MJ rSiuyQlYyv6ErEFk9b3K3Q== X-Received: by 2002:a63:a1d:: with SMTP id 29mr25891087pgk.162.1606109877897; Sun, 22 Nov 2020 21:37:57 -0800 (PST) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id h18sm5827825pfk.17.2020.11.22.21.37.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Nov 2020 21:37:57 -0800 (PST) From: Pingfan Liu To: x86@kernel.org Cc: Pingfan Liu , 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 , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] x86/machine_kexec: disable PMU before jumping to new kernel Date: Mon, 23 Nov 2020 13:37:26 +0800 Message-Id: <1606109846-13688-2-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1606109846-13688-1-git-send-email-kernelfans@gmail.com> References: <1606109846-13688-1-git-send-email-kernelfans@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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