mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	James Clark <james.clark@linaro.org>,
	Thomas Gleixner <tglx@kernel.org>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Pavel Machek <pavel@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Johan Hovold <johan@kernel.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Jiayuan Chen <jiayuan.chen@linux.dev>,
	"Steven Rostedt (Google)" <rostedt@goodmis.org>,
	"Vineeth Pillai (Google)" <vineeth@bitbyteword.org>,
	Frederic Weisbecker <frederic@kernel.org>,
	Andi Kleen <ak@linux.intel.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org, driver-core@lists.linux.dev
Subject: [PATCH 0/6] perf/x86/intel/pt: Fix tracing across kexec, kdump and suspend
Date: Mon,  2 Nov 2026 09:40:33 +0200	[thread overview]
Message-ID: <20261102074039.26983-1-adrian.hunter@intel.com> (raw)

Hi

Intel PT writes trace data directly to physical memory, so tracing must
be stopped whenever the trace buffers or the hardware state describing
them can no longer be relied on.  This series fixes several cases where
that does not currently happen:

  - tracing can survive kexec and kdump.  After kexec, Intel PT
    continues writing into buffers configured by the old kernel,
    corrupting memory that the new kernel may have reused

  - suspend-related state loss can leave the driver's cached PT MSR
    state out of sync with hardware, allowing tracing to restart with
    reset output registers and corrupt memory (typically beginning at
    page 0)

  - races can leave TraceEn set in hardware after perf believes tracing
    has stopped, preventing tracing from being reliably disabled and
    potentially causing subsequent PT MSR accesses to #GP

The fixes stop relying solely on perf's software state where it is not
authoritative: TraceEn is cleared directly in hardware during shutdown
and emergency-stop paths, tracing is prevented from restarting once
shutdown begins, cached PT MSR state is invalidated whenever hardware
state may have been lost, and active tracing is stopped and restarted
across suspend on the CPU that remains online.

The first patch is a general irq_work fix, not specific to Intel PT. It
re-raises a lost irq_work self-interrupt after resume, preventing
irq_work from remaining permanently pending if the interrupt state is
lost across suspend.  The final Intel PT suspend fix depends on it.

All patches are marked for stable.  The last patch also depends on commit
2e17bf3a469a ("perf/x86/intel/pt: Fix stop/start with no update") and
its two preparatory patches.

An alternative to the last patch would be for perf core to schedule out
all active events from a syscore suspend callback, and schedule them
back in from the syscore resume callback.  That would be a more general
change, but the last patch keeps the fix within the Intel PT driver.

AI disclosure: all issues addressed by this series were identified using
AI assistance, and AI was also used in development of the patches.
Problems described with reproducer examples in the individual changelogs
were reproduced and fixes validated.  The race fixed by
"perf/x86/intel/pt: Clear TraceEn in hardware in cpu_emergency_stop_pt()"
was identified by analysis and has not been reproduced.


Adrian Hunter (6):
      irq_work: Re-raise pending irq_work after system resume
      perf/x86/intel/pt: Stop tracing if VMXON has not yet happened
      perf/x86/intel/pt: Stop tracing at syscore shutdown
      perf/x86/intel/pt: Clear TraceEn in hardware in cpu_emergency_stop_pt()
      perf/x86/intel/pt: Reset stale MSR state on CPU start and resume
      perf/x86/intel/pt: Stop tracing across system suspend

 arch/x86/events/intel/core.c      |   9 ++
 arch/x86/events/intel/pt.c        | 170 ++++++++++++++++++++++++++++++++++++--
 arch/x86/events/intel/pt.h        |   6 +-
 arch/x86/events/perf_event.h      |   4 +
 arch/x86/include/asm/perf_event.h |   3 +
 arch/x86/power/cpu.c              |   3 +-
 drivers/base/syscore.c            |  10 +++
 include/linux/irq_work.h          |   2 +
 include/linux/perf_event.h        |   6 --
 kernel/irq_work.c                 |  12 +++
 10 files changed, 208 insertions(+), 17 deletions(-)

base-commit: f96ebf32b3135db4c9eeb868e4cb98e5dfe79ac0


Regards
Adrian

             reply	other threads:[~2026-11-02  7:40 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02  7:40 Adrian Hunter [this message]
2026-11-02  7:40 ` [PATCH 1/6] irq_work: Re-raise pending irq_work after system resume Adrian Hunter
2026-11-02  9:06   ` Peter Zijlstra
2026-11-02 10:54     ` Adrian Hunter
2026-11-02 16:39       ` Sebastian Andrzej Siewior
2026-11-02  7:40 ` [PATCH 2/6] perf/x86/intel/pt: Stop tracing if VMXON has not yet happened Adrian Hunter
2026-11-02  9:57   ` Peter Zijlstra
2026-11-02 11:04     ` Adrian Hunter
2026-11-02 11:07       ` Peter Zijlstra
2026-11-02  7:40 ` [PATCH 3/6] perf/x86/intel/pt: Stop tracing at syscore shutdown Adrian Hunter
2026-11-02 10:04   ` Peter Zijlstra
2026-11-02 10:23     ` Adrian Hunter
2026-11-02 11:01       ` Peter Zijlstra
2026-11-02 16:15   ` Andi Kleen
2026-11-02 16:27     ` Adrian Hunter
2026-11-02 17:45       ` Andi Kleen
2026-11-02 18:13         ` Adrian Hunter
2026-11-02  7:40 ` [PATCH 4/6] perf/x86/intel/pt: Clear TraceEn in hardware in cpu_emergency_stop_pt() Adrian Hunter
2026-11-02 10:07   ` Peter Zijlstra
2026-11-02 18:41     ` Adrian Hunter
2026-11-02  7:40 ` [PATCH 5/6] perf/x86/intel/pt: Reset stale MSR state on CPU start and resume Adrian Hunter
2026-11-02  7:40 ` [PATCH 6/6] perf/x86/intel/pt: Stop tracing across system suspend Adrian Hunter
2026-11-02 10:10 ` [PATCH 0/6] perf/x86/intel/pt: Fix tracing across kexec, kdump and suspend Peter Zijlstra
2026-11-02 12:22   ` Adrian Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261102074039.26983-1-adrian.hunter@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bigeasy@linutronix.de \
    --cc=bp@alien8.de \
    --cc=dakr@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=driver-core@lists.linux.dev \
    --cc=frederic@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jiayuan.chen@linux.dev \
    --cc=johan@kernel.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=pavel@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@kernel.org \
    --cc=vineeth@bitbyteword.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®