kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Edmondson <dme@dme.org>
To: Aaron Lewis <aaronlewis@google.com>
Cc: Sean Christopherson <seanjc@google.com>,
	Jim Mattson <jmattson@google.com>, kvm list <kvm@vger.kernel.org>
Subject: Re: [PATCH v5 1/2] kvm: x86: Allow userspace to handle emulation errors
Date: Mon, 10 May 2021 10:37:36 +0100	[thread overview]
Message-ID: <cunim3r2alb.fsf@dme.org> (raw)
In-Reply-To: <CAAAPnDFVR9xXEF_3_rEDhNhbe7r7QCEEiJ399Zv6h+ZUX=EfWA@mail.gmail.com>

On Friday, 2021-05-07 at 07:27:07 -07, Aaron Lewis wrote:

>> > +7.24 KVM_CAP_EXIT_ON_EMULATION_FAILURE
>> > +--------------------------------------
>> > +
>> > +:Architectures: x86
>> > +:Parameters: args[0] whether the feature should be enabled or not
>> > +
>> > +When this capability is enabled the in-kernel instruction emulator packs
>> > +the exit struct of KVM_INTERNAL_ERROR with the instruction length and
>> > +instruction bytes when an error occurs while emulating an instruction.  This
>> > +will also happen when the emulation type is set to EMULTYPE_SKIP, but with this
>> > +capability enabled this becomes the default behavior regarless of how the
>>
>> s/regarless/regardless/
>>
>> > +emulation type is set unless it is a VMware #GP; in that case a #GP is injected
>> > +and KVM does not exit to userspace.
>> > +
>> > +When this capability is enabled use the emulation_failure struct instead of the
>> > +internal struct for the exit struct.  They have the same layout, but the
>> > +emulation_failure struct matches the content better.  It also explicitly defines
>> > +the 'flags' field which is used to describe the fields in the struct that are
>> > +valid (ie: if KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES is set in the
>> > +'flags' field then 'insn_size' and 'insn_bytes' has valid data in them.)
>>
>> Starting both paragraphs with "With this capability enabled..." would
>> probably cause me to stop reading if I didn't enable the capability, but
>> as the first paragraph goes on to say, EMULTYPE_SKIP will also cause the
>> instruction to be provided.
>>
>
> What about this instead?

Reads better to me, thanks.

> When this capability is enabled, an emulation failure will result in an exit
> to userspace with KVM_INTERNAL_ERROR (except when the emulator was invoked
> to handle a VMware backdoor instruction). Furthermore, KVM will now provide up
> to 15 instruction bytes for any exit to userspace resulting from an emulation
> failure.  When these exits to userspace occur use the emulation_failure struct
> instead of the internal struct.  They both have the same layout, but the
> emulation_failure struct matches the content better.  It also explicitly
> defines the 'flags' field which is used to describe the fields in the struct
> that are valid (ie: if KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES is
> set in the 'flags' field then both 'insn_size' and 'insn_bytes' have valid data
> in them.)
>
> I left out the part about EMULTYPE_SKIP because that behavior is not
> affected by setting KVM_CAP_EXIT_ON_EMULATION_FAILURE, so I thought it
> wasn't needed in the documentation here.

dme.
-- 
We're up all night to get lucky.

  reply	other threads:[~2021-05-10  9:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-30 14:37 [PATCH v5 0/2] fallback for emulation errors Aaron Lewis
2021-04-30 14:37 ` [PATCH v5 1/2] kvm: x86: Allow userspace to handle " Aaron Lewis
2021-05-05 12:34   ` David Edmondson
2021-05-07 14:27     ` Aaron Lewis
2021-05-10  9:37       ` David Edmondson [this message]
2021-04-30 14:37 ` [PATCH v5 2/2] selftests: kvm: Allows " Aaron Lewis
2021-04-30 17:39   ` Jim Mattson
2021-05-03 18:04     ` Jim Mattson

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=cunim3r2alb.fsf@dme.org \
    --to=dme@dme.org \
    --cc=aaronlewis@google.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).