public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Yosry Ahmed <yosry.ahmed@linux.dev>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Ken Hofsass <hofsass@google.com>,
	kvm@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] KVM: x86: Add CR3 to guest debug info
Date: Mon, 24 Nov 2025 06:45:22 -0800	[thread overview]
Message-ID: <aSRvguLx26AQB25W@google.com> (raw)
In-Reply-To: <ycaddg27z4z6xsclzklheriy2cr63v6senv7qxh37kvpb7envs@br7durjgj2ux>

On Fri, Nov 21, 2025, Yosry Ahmed wrote:
> On Fri, Nov 21, 2025 at 01:01:40PM -0800, Sean Christopherson wrote:
> > On Fri, Nov 21, 2025, Yosry Ahmed wrote:
> > KVM already provides kvm_run.kvm_valid_regs to let userspace grab register state
> > on exit to userspace.  If userspace is debugging, why not simply save all regs on
> > exit?
> > 
> > If the answer is "because it slows down all other exits", then I would much rather
> > give userspace the ability to conditionally save registers based on the exit reason,
> > e.g. something like this (completely untested, no CAP, etc.)
> 
> I like this approach conceptually, but I think it's an overkill for this
> use case tbh. Especially the memory usage, that's 1K per vCPU for the
> bitmap. I know it can be smaller, but probably not small either because
> it will be a problem if we run out of bits.
> > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> > index 52f6000ab020..452805c1337b 100644
> > --- a/include/uapi/linux/kvm.h
> > +++ b/include/uapi/linux/kvm.h
> > @@ -494,8 +494,12 @@ struct kvm_run {
> >                 struct kvm_sync_regs regs;
> >                 char padding[SYNC_REGS_SIZE_BYTES];
> >         } s;
> > +
> > +       __u64 kvm_save_regs_on_exit[16];

Heh, check your math.  It's 1024 bits, 128 bytes.  Reserving space for 1024 exits
is likely extreme overkill given that KVM is sitting at 40 exits after ~18 years,
so as you say we could cut that down significantly depending on how willing we are
to risk having to add kvm_save_regs_on_exit2 in the future.

  reply	other threads:[~2025-11-24 14:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21 19:32 [PATCH 0/3] KVM: x86: Accelerate reading CR3 for guest debug Yosry Ahmed
2025-11-21 19:32 ` [PATCH 1/3] KVM: x86: Add CR3 to guest debug info Yosry Ahmed
2025-11-21 21:01   ` Sean Christopherson
2025-11-21 23:12     ` Yosry Ahmed
2025-11-24 14:45       ` Sean Christopherson [this message]
2025-11-24 15:35         ` Yosry Ahmed
2025-11-21 19:32 ` [PATCH 2/3] KVM: selftests: Use TEST_ASSERT_EQ() in debug_regs Yosry Ahmed
2025-11-21 19:32 ` [PATCH 3/3] KVM: selftests: Verify CR3 " Yosry Ahmed

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=aSRvguLx26AQB25W@google.com \
    --to=seanjc@google.com \
    --cc=hofsass@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=yosry.ahmed@linux.dev \
    /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