kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aaron Lewis <aaronlewis@google.com>
To: david.edmondson@oracle.com, seanjc@google.com, jmattson@google.com
Cc: kvm@vger.kernel.org, Aaron Lewis <aaronlewis@google.com>
Subject: [PATCH v5 0/2] fallback for emulation errors
Date: Fri, 30 Apr 2021 07:37:49 -0700	[thread overview]
Message-ID: <20210430143751.1693253-1-aaronlewis@google.com> (raw)

This patchset allows userspace to be a fallback for handling emulation errors.

v1 -> v2:

 - Added additional documentation for KVM_CAP_EXIT_ON_EMULATION_FAILURE.
 - In prepare_emulation_failure_exit():
   - Created a local variable for vcpu->run.
   - Cleared the flags, emulation_failure.flags.
   - Or'd the instruction bytes flag on to emulation_failure.flags.
 - Updated the comment for KVM_INTERNAL_ERROR_EMULATION flags on how they are
   to be used.
 - Updated the comment for struct emulation_failure.

v2 -> v3:

 - Update documentation for KVM_CAP_EXIT_ON_EMULATION_FAILURE.
 - Fix spacing in prepare_emulation_failure_exit().

v3 -> v4:

 - In prepare_emulation_failure_exit():
   - Clear instruction bytes to 0x90.
   - Copy over insn_size bytes rather than sizeof(ctxt->fetch.data).
 - set_page_table_entry() takes a pte rather than mask.
 - In _vm_get_page_table_entry():
   - Removed check for page aligned addresses only.
   - Added canonical check.
   - Added a check to make sure no reserved bits are set along the walk except
     for the final pte (the pte cannot have the reserved bits checked otherwise
     the test would fail).
   - Added check to ensure superpage bits are clear.
 - Added check in test for 'allow_smaller_maxphyaddr' module parameter.
 - If the is_flds() check fails, only look at the first byte.
 - Don't use labels to increment the RIP.  Decode the instruction well enough to
   ensure it is only 2-bytes.

v4 -> v5:

 - Switch 'insn_size' to u32.
 - Add documentation for how the flags are used.
 - Remove 'max_insn_size' and use 'sizeof(run->emulation_failure.insn_bytes)' instead.
 - Fix typos.
 - Fix canonical check.
 - Add reserved check for bit-7 of PML4E.
 - Add reserved check for bit-63 of all page table levels if EFER.NXE = 0.
 - Remove opcode check (it might be a prefix).
 - Remove labels.
 - Remove detritus (rogue cpuid entry in the test).

Aaron Lewis (2):
  kvm: x86: Allow userspace to handle emulation errors
  selftests: kvm: Allows userspace to handle emulation errors.

 Documentation/virt/kvm/api.rst                |  21 ++
 arch/x86/include/asm/kvm_host.h               |   6 +
 arch/x86/kvm/x86.c                            |  37 ++-
 include/uapi/linux/kvm.h                      |  23 ++
 tools/include/uapi/linux/kvm.h                |  23 ++
 tools/testing/selftests/kvm/.gitignore        |   1 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../selftests/kvm/include/x86_64/processor.h  |   4 +
 .../selftests/kvm/lib/x86_64/processor.c      |  94 ++++++++
 .../kvm/x86_64/emulator_error_test.c          | 219 ++++++++++++++++++
 10 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86_64/emulator_error_test.c

-- 
2.31.1.527.g47e6f16901-goog


             reply	other threads:[~2021-04-30 14:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-30 14:37 Aaron Lewis [this message]
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
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=20210430143751.1693253-1-aaronlewis@google.com \
    --to=aaronlewis@google.com \
    --cc=david.edmondson@oracle.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=seanjc@google.com \
    --subject='Re: [PATCH v5 0/2] fallback for emulation errors' \
    /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

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).