From: Sean Christopherson <seanjc@google.com>
To: "Jürgen Groß" <jgross@suse.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
linux-kernel@vger.kernel.org, x86@kernel.org,
kvm@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H . Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH] KVM/x86: don't use a literal 1 instead of RET_PF_RETRY
Date: Fri, 8 Nov 2024 14:12:55 -0800 [thread overview]
Message-ID: <Zy6M57VglxCSaZky@google.com> (raw)
In-Reply-To: <854e43f7-0eed-4a1b-8ede-37c538791396@suse.com>
On Fri, Nov 08, 2024, Jürgen Groß wrote:
> On 08.11.24 19:44, Sean Christopherson wrote:
> > On Fri, Nov 08, 2024, Paolo Bonzini wrote:
> > > Queued, thanks.
> >
> > Noooo! Can you un-queue?
> >
> > The return from kvm_mmu_page_fault() is NOT RET_PF_xxx, it's KVM outer 0/1/-errno.
> > I.e. '1' is saying "resume the guest", it has *nothing* to do with RET_PF_RETRY.
> > E.g. that path also handles RET_PF_FIXED, RET_PF_SPURIOUS, etc.
>
> And what about the existing "return RET_PF_RETRY" further up?
Oof. Works by coincidence. The intent in that case is to retry the fault, but
the fact that RET_PF_RETRY happens to be '1' is mostly luck. Returning a postive
value other than '1' should work, but as called out by the comments for the enum,
using '0' for CONTINUE isn't a hard requirement. E.g. if for some reason we used
'0' for RET_PF_RETRY, this code would break.
* Note, all values must be greater than or equal to zero so as not to encroach
* on -errno return values. Somewhat arbitrarily use '0' for CONTINUE, which
* will allow for efficient machine code when checking for CONTINUE, e.g.
* "TEST %rax, %rax, JNZ", as all "stop!" values are non-zero.
FWIW, you are far from the first person to complain about KVM's mostly-undocumented
0/1/-errno return encoding scheme. The problems is that it's so pervasive
throughout KVM, that in some cases it's not easy to understand if a function is
actually using that scheme, or just happens to return similar values. I.e.
converting to enums (or #defines) would require a lot of work and churn.
next prev parent reply other threads:[~2024-11-08 22:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-08 16:13 [PATCH] KVM/x86: don't use a literal 1 instead of RET_PF_RETRY Juergen Gross
2024-11-08 17:13 ` Paolo Bonzini
2024-11-08 18:44 ` Sean Christopherson
2024-11-08 19:18 ` Jürgen Groß
2024-11-08 22:12 ` Sean Christopherson [this message]
2024-11-09 7:06 ` Jürgen Groß
2024-11-09 8:03 ` Paolo Bonzini
2024-11-09 9:29 ` Jürgen Groß
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=Zy6M57VglxCSaZky@google.com \
--to=seanjc@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--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