Skip to content

kvm: x86: some fixes of hypercall emulation

Hou Wenlong kvm lkml 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 4 repliesIn review
  2. v13 patches 0 repliesSuperseded

Changes in v2 from the cover letter

v1 is wrong edition, sent by mistake

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3kvm: x86: Introduce hypercall x86 ops for handling hypercall not in cpl0arch/x86/include/asm/kvm-x86-ops.h arch/x86/include/asm/kvm_host.h arch/x86/kvm/svm/svm.c +2 more+20 -33 replies
2/3kvm: x86: Refactor kvm_emulate_hypercall() to no skip instructionarch/x86/kvm/x86.c+23 -130 replies
3/3kvm: x86: Emulate hypercall instead of fixing hypercall instructionarch/x86/kvm/emulate.c arch/x86/kvm/kvm_emulate.h arch/x86/kvm/x86.c+18 -211 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/3] kvm: x86: some fixes of hypercall emulation

Currently, use hypercall instruction in guest cpl3 would just skip the instruction, however, that behaviour could trigger a exception in Linux host. It is reasonable for hypervisor to inject a exception, especially in nested guest, L1 guest could behaviour like host.

As for hypercall instruction emulation, hypervisor would replace the wrong instruction with the right instruction instead of the real instruction emulation. It's guest's responsibility to use the right instruction, hypervisor could emulate it but shouldn't modify it without guest's request. At present, Linux guest could use alternative to choose right instruction, and hyperv guest could use hypercall to modify instruction. So just do the real instruction emualtion job for em_hypercall().

change from v1:
v1 is wrong edition, sent by mistake

Hou Wenlong (3):
kvm: x86: Introduce hypercall x86 ops for handling hypercall not in
cpl0
kvm: x86: Refactor kvm_emulate_hypercall() to no skip instruction
kvm: x86: Emulate hypercall instead of fixing hypercall instruction

 arch/x86/include/asm/kvm-x86-ops.h |  1 +
 arch/x86/include/asm/kvm_host.h    |  1 +
 arch/x86/kvm/emulate.c             | 20 +++++------
 arch/x86/kvm/kvm_emulate.h         |  2 +-
 arch/x86/kvm/svm/svm.c             |  6 ++++
 arch/x86/kvm/vmx/vmx.c             |  9 +++++
 arch/x86/kvm/x86.c                 | 55 +++++++++++++++++-------------
 7 files changed, 59 insertions(+), 35 deletions(-)

--
2.31.1