From: Christian Borntraeger <borntraeger@linux.ibm.com>
To: Ian Rogers <irogers@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: Marc Zyngier <maz@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
linux-perf-users@vger.kernel.org, kvm@vger.kernel.org,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
Hendrik Brueckner <brueckner@linux.ibm.com>
Subject: Re: [RFC PATCH 03/16] KVM: Add NMI-safe guest-to-host IP translation infrastructure
Date: Wed, 2 Dec 2026 09:29:47 +0100 [thread overview]
Message-ID: <68e364c8-9a07-4bef-bc09-559ed1ae1a1c@linux.ibm.com> (raw)
In-Reply-To: <20261201232116.1988791-4-irogers@google.com>
Am 02.12.26 um 00:21 schrieb Ian Rogers:
> Wire up kvm_guest_get_host_ip() in common KVM code and provide the
> NMI-safe primitives architectures need to implement
> kvm_arch_vcpu_get_ip_gpa() for PERF_SAMPLE_HOST_IP.
>
> Because perf PMIs run in NMI or hardirq-disabled context and cannot
> sleep or mix SRCU flavors on kvm->srcu:
>
> - Pair synchronize_srcu_expedited(&kvm->srcu) with
> synchronize_rcu_expedited() in kvm_swap_active_memslots() and add an
> RCU-protected, read-only memslot lookup helper
> (kvm_vcpu_gfn_to_hva_nofault()) so NMI callers never touch kvm->srcu
> or last_used_slot caches.
> - Add kvm_vcpu_read_guest_nofault() using copy_from_user_nofault() so
> arch guest page-table reads are non-faulting, NMI-safe, and support
> KVM_MEM_READONLY memslots.
> - Add a __weak kvm_arch_vcpu_get_ip_gpa() default returning INVALID_GPA
> and wire kvm_guest_get_host_ip() into kvm_guest_cbs.get_host_ip.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> include/linux/kvm_host.h | 3 ++
> virt/kvm/kvm_main.c | 64 ++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 67 insertions(+)
>
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index fe300a22ab0f..c3e5366d01ea 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -1468,6 +1468,8 @@ DEFINE_VCPU_MAP_CLASS(_readonly);
>
> unsigned long kvm_vcpu_gfn_to_hva(struct kvm_vcpu *vcpu, gfn_t gfn);
> unsigned long kvm_vcpu_gfn_to_hva_prot(struct kvm_vcpu *vcpu, gfn_t gfn, bool *writable);
> +int kvm_vcpu_read_guest_nofault(struct kvm_vcpu *vcpu, gpa_t gpa, void *data,
> + unsigned long len);
> int kvm_vcpu_read_guest_page(struct kvm_vcpu *vcpu, gfn_t gfn, void *data, int offset,
> int len);
> int kvm_vcpu_read_guest_atomic(struct kvm_vcpu *vcpu, gpa_t gpa, void *data,
> @@ -1821,6 +1823,7 @@ static inline bool kvm_arch_intc_initialized(struct kvm *kvm)
>
> #ifdef CONFIG_GUEST_PERF_EVENTS
> unsigned long kvm_arch_vcpu_get_ip(struct kvm_vcpu *vcpu);
> +gpa_t kvm_arch_vcpu_get_ip_gpa(struct kvm_vcpu *vcpu);
>
> void __kvm_register_perf_callbacks(unsigned int (*pt_intr_handler)(void),
> void (*mediated_pmi_handler)(void));
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 83e727bf6452..7935d4a346a3 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1658,6 +1658,7 @@ static void kvm_swap_active_memslots(struct kvm *kvm, int as_id)
> mutex_unlock(&kvm->slots_arch_lock);
>
> synchronize_srcu_expedited(&kvm->srcu);
> + synchronize_rcu_expedited();
Probably not critical but maybe limit that to architectures that implement CONFIG_GUEST_PERF_EVENTS.
cc Hendrik. We might want to look at GUEST_PERF_EVENTSfor s390 in general. Right now this
perf_arch_instruction_pointer() returns the _guest_ PSW address when the interrupt hit (or via hw sample)
If we decide to change that, we could re-use the existing gaccess DAT walker to also implement
this here for s390.
This might also be relevant for our arm on s390.
next prev parent reply other threads:[~2026-12-02 8:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 23:21 [RFC PATCH 00/16] perf, kvm: Add PERF_SAMPLE_HOST_IP for host-side guest symbolization Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 01/16] perf/core: Add PERF_SAMPLE_HOST_IP sample format Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 02/16] perf/core, bpf: Support BPF filtering of mmap_data events Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 03/16] KVM: Add NMI-safe guest-to-host IP translation infrastructure Ian Rogers
2026-12-02 8:29 ` Christian Borntraeger [this message]
2026-12-01 23:21 ` [RFC PATCH 04/16] KVM: x86: Implement kvm_arch_vcpu_get_ip_gpa() Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 05/16] KVM: arm64: " Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 06/16] KVM: riscv: " Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 07/16] KVM: loongarch: " Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 08/16] tools headers UAPI: Sync linux/perf_event.h with the kernel sources Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 09/16] perf tools: Add PERF_SAMPLE_HOST_IP parsing, synthesis, and record --host-ip Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 10/16] perf symbol: Support host IP resolution and guest fallback symbolization Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 11/16] perf report, script: Add host_ip, host_dso, and host_sym fields Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 12/16] perf record: Synthesize hypervisor file-backed data mappings for --host-ip Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 13/16] perf record: Filter runtime hypervisor data mmaps with BPF " Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 14/16] perf bpf-filter: Support host_ip in BPF sample filters Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 15/16] perf aslr: Anonymize sampled host_ip values Ian Rogers
2026-12-01 23:21 ` [RFC PATCH 16/16] perf test: Add PERF_SAMPLE_HOST_IP symbolization, sorting, and ASLR tests Ian Rogers
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=68e364c8-9a07-4bef-bc09-559ed1ae1a1c@linux.ibm.com \
--to=borntraeger@linux.ibm.com \
--cc=acme@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brueckner@linux.ibm.com \
--cc=irogers@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=maz@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
/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®