Skip to content

KVM: nSVM: Fix save/restore of NextRIP & interrupt shadow

Yosry Ahmed kvm lkml stable 2 versions – Applied

Status from this message: Applied to kvm-x86 nested (except for patch 3), thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest5 patches 2 repliesApplied
  2. v14 patches 13 repliesSuperseded

Changes in v2 from the cover letter

- Split patch 1 into a minimal fix without code movement for stable, and code movement patch (patch 3) [Sean].
- Comments and changelog updates [Sean].

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/5KVM: nSVM: Sync NextRIP to cached vmcb12 after VMRUN of L2arch/x86/kvm/svm/svm.c+10 -00 replies
2/5KVM: nSVM: Sync interrupt shadow to cached vmcb12 after VMRUN of L2arch/x86/kvm/svm/nested.c+1 -00 replies
3/5KVM: nSVM: Move sync'ing to vmcb12 cache after completing interruptsarch/x86/kvm/svm/nested.c arch/x86/kvm/svm/svm.c+18 -181 reply
4/5KVM: selftests: Extend state_test to check vGIFtools/testing/selftests/kvm/x86/state_test.c+24 -00 replies
5/5KVM: selftests: Extend state_test to check next_riptools/testing/selftests/kvm/x86/state_test.c+11 -00 replies

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/5] KVM: nSVM: Fix save/restore of NextRIP & interrupt shadow

NextRIP and interrupt shadow are both not sync'd correctly to the cached vmcb12 after VMRUN of L2. Sync the cached vmcb12 is the payload of nested state, these fields are not saved/restored correctly.

Sync both fields correctly, and extend state_test to check vGIF (already sync'd field) and next_rip. Checking the interrupt shadow would be tricky, as GUEST_SYNC() executes several instructions before exiting to L0, so the interrupt shadow will be consumed before the test can check for it. L2 could execute STI followed directly by in/out, but that would not handle transitioning between L2 and L2 correctly (see ucall_arch_do_ucall()).

I updated patch 1 to be a minimal fix without moving code around, but I kept the code movement in patch 3 as it leaves the code in better shape until a more significant rework/cleanup is done. It also leaves the FIXME in a more appropriate spot. If you feel strongly, feel free to drop patch 3, but I'd rather we keep it.

v1 -> v2:
- Split patch 1 into a minimal fix without code movement for stable, and code movement patch (patch 3) [Sean].
- Comments and changelog updates [Sean].

v1: https://lore.kernel.org/kvm/[email protected]/

Yosry Ahmed (5):
KVM: nSVM: Sync NextRIP to cached vmcb12 after VMRUN of L2
KVM: nSVM: Sync interrupt shadow to cached vmcb12 after VMRUN of L2
KVM: nSVM: Move sync'ing to vmcb12 cache after completing interrupts
KVM: selftests: Extend state_test to check vGIF
KVM: selftests: Extend state_test to check next_rip

 arch/x86/kvm/svm/nested.c                    | 11 ++++--
 arch/x86/kvm/svm/svm.c                       | 26 +++++++++------
 tools/testing/selftests/kvm/x86/state_test.c | 35 ++++++++++++++++++++
 3 files changed, 59 insertions(+), 13 deletions(-)

base-commit: e944fe2c09f405a2e2d147145c9b470084bc4c9a

Signature · 1 line
2.53.0.239.g8d8fc8a987-goog