Skip to content

KVM: SEV-ES: fixes for string I/O emulation

Paolo Bonzini kvm lkml stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 16 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8KVM: SEV-ES: fix length of string I/Oarch/x86/kvm/svm/sev.c+1 -14 replies
2/8KVM: SEV-ES: rename guest_ins_data to sev_pio_dataarch/x86/include/asm/kvm_host.h arch/x86/kvm/x86.c+3 -31 reply
3/8KVM: x86: leave vcpu->arch.pio.count alone in emulator_pio_in_outarch/x86/kvm/x86.c+9 -41 reply
4/8KVM: SEV-ES: clean up kvm_sev_es_ins/outsarch/x86/kvm/x86.c+15 -162 replies
5/8KVM: x86: split the two parts of emulator_pio_inarch/x86/kvm/x86.c+23 -191 reply
6/8KVM: x86: remove unnecessary arguments from complete_emulator_pio_inarch/x86/kvm/x86.c+5 -41 reply
7/8KVM: SEV-ES: keep INS functions togetherarch/x86/kvm/x86.c+9 -91 reply
8/8KVM: SEV-ES: go over the sev_pio_data buffer in multiple passes if neededarch/x86/include/asm/kvm_host.h arch/x86/kvm/x86.c+57 -171 reply

Reviews trailers per patch

All 8 patches have a Reviewed-by or Acked-by.

PatchTom LendackyMaxim Levitsky
1/8A-b R-b
2/8R-b
3/8R-b
4/8R-b
5/8R-b
6/8R-b
7/8R-b
8/8R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/8] KVM: SEV-ES: fixes for string I/O emulation

This series, namely patches 1 and 8, fix two bugs in string I/O emulation for SEV-ES:

- first, the length is completely off for "rep ins" and "rep outs" operation of size > 1. After setup_vmgexit_scratch, svm->ghcb_sa_len is in bytes, but kvm_sev_es_string_io expects the number of PIO operations.

- second, the size of the GHCB buffer can exceed the size of vcpu->arch.pio_data. If that happens, we need to go over the GHCB buffer in multiple passes.

The second bug was reported by Felix Wilhelm. The first was found by me by code inspection; on one hand it seems *too* egregious so I'll be gladly proven wrong on this, on the other hand... I know I'm bad at code review, but not _that_ bad.

Patches 2 to 7 are a bunch of cleanups to emulator_pio_in and emulator_pio_in_out, so that the final SEV code is a little easier to reason on. Just a little, no big promises.

Tested by booting a SEV-ES guest and with "regular" kvm-unit-tests. For SEV-ES I also bounded the limit to 12 bytes, and checked in the resulting trace that both the read and write paths were hit when booting a guest.

Paolo

Paolo Bonzini (8):
KVM: SEV-ES: fix length of string I/O
KVM: SEV-ES: rename guest_ins_data to sev_pio_data
KVM: x86: leave vcpu->arch.pio.count alone in emulator_pio_in_out
KVM: SEV-ES: clean up kvm_sev_es_ins/outs
KVM: x86: split the two parts of emulator_pio_in
KVM: x86: remove unnecessary arguments from complete_emulator_pio_in
KVM: SEV-ES: keep INS functions together
KVM: SEV-ES: go over the sev_pio_data buffer in multiple passes if
needed

 arch/x86/include/asm/kvm_host.h |   3 +-
 arch/x86/kvm/svm/sev.c          |   2 +-
 arch/x86/kvm/x86.c              | 136 +++++++++++++++++++++-----------
 3 files changed, 95 insertions(+), 46 deletions(-)
Signature · 1 line
2.27.0