From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Roman Kisel <romank@linux.microsoft.com>,
Peter Zijlstra <peterz@infradead.org>,
Naman Jain <namjain@linux.microsoft.com>,
"K . Y . Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
mhklinux@outlook.com
Subject: Re: [PATCH] x86/hyperv: Export hv_hypercall_pg unconditionally
Date: Tue, 16 Sep 2025 07:52:42 -0700 [thread overview]
Message-ID: <aMl5ulY1K7cKcMfo@google.com> (raw)
In-Reply-To: <27e50bb7-7f0e-48fb-bdbc-6c6d606e7113@redhat.com>
On Tue, Sep 16, 2025, Paolo Bonzini wrote:
> On 8/27/25 01:04, Roman Kisel wrote:
> > On 8/26/2025 5:07 AM, Peter Zijlstra wrote:
> > > I do not know what OpenHCL is. Nor is it clear from the code what NMIs
> > > can't happen. Anyway, same can be achieved with breakpoints / kprobes.
> > > You can get a trap after setting CR2 and scribble it.
> > >
> > > You simply cannot use CR2 this way.
> >
> > The code in question runs with interrupts disabled, and the kernel runs
> > without the memory swapping when using that module - the kernel is
> > a firmware to host a vTPM for virtual machines. Somewhat similar to SMM.
> > That should've been reflected somewhere in the comments and in Kconfig,
> > we could do better. All in all, the page fault cannot happen in that
> > path thus CR2 won't be trashed.
> >
> > Nor this kind of code can be stepped through in a self-hosted
> > kernel debugger like kgdb. There are other examples of such code iiuc:
>
> As Sean mentioned, you do have to make sure that this is annotated as
> noinstr (not instrumentable). And also just use assembly - KVM started with
> a similar asm block, though without the sketchy "register asm",
Ooh, yeah, don't use "register asm". I missed that when I peeked at the code.
Using "register asm" will most definitely cause problems, because the compiler
doesn't track usage in C code, i.e. will happily use the GPR and clobber your
asm value in the process. That inevitably leads to very confusing and somewhat
transient errors. E.g. if someone inserts a printk for debugging, the call to
printk can clobber the very state it's trying to print.
> and I was initially skeptical but using a dedicated .S file was absolutely
> the right thing to do.
+1000 to putting the assembly in a .S file. I too was a bit skeptical about
moving the entire sequence into proper assembly; thankfully, some non-KVM folks
talked us into it :-)
next prev parent reply other threads:[~2025-09-16 14:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-25 5:52 [PATCH] x86/hyperv: Export hv_hypercall_pg unconditionally Naman Jain
2025-08-25 9:23 ` Christoph Hellwig
2025-08-25 9:42 ` Peter Zijlstra
2025-08-26 11:30 ` Naman Jain
2025-08-26 12:07 ` Peter Zijlstra
2025-08-26 23:04 ` Roman Kisel
2025-09-16 12:48 ` Paolo Bonzini
2025-09-16 14:52 ` Sean Christopherson [this message]
2025-09-18 6:03 ` Naman Jain
2025-09-18 6:47 ` Peter Zijlstra
2025-09-18 14:21 ` James Bottomley
2025-10-06 10:50 ` Naman Jain
2025-10-06 11:10 ` Peter Zijlstra
2025-10-06 11:19 ` Paolo Bonzini
2025-10-06 14:27 ` Naman Jain
2025-09-15 21:46 ` Sean Christopherson
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=aMl5ulY1K7cKcMfo@google.com \
--to=seanjc@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhklinux@outlook.com \
--cc=mingo@redhat.com \
--cc=namjain@linux.microsoft.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=romank@linux.microsoft.com \
--cc=tglx@linutronix.de \
--cc=wei.liu@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.