summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2026-05-29 20:35:36 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2026-06-03 16:43:55 +0200
commit17d62e0b157f262dd8c7586cb882ece72a5b10c2 (patch)
tree72f7b005eff1acb436715d0de03c3ea75fbdedcc
parente43ffb69e0438cddd72aaa30898b4dc446f664f8 (diff)
downloadlinux-17d62e0b157f262dd8c7586cb882ece72a5b10c2.tar.gz
linux-17d62e0b157f262dd8c7586cb882ece72a5b10c2.zip
KVM: SEV: Make it more obvious when KVM is writing back the current PSC index
Increment the guest-visible "cur_entry" index outside of the for-loop when processing Page State Change entries, and add a comment to make it more obvious which code is operating on trusted data, and which code is touching guest-accessible data. No functional change intended. Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Reviewed-by: Michael Roth <michael.roth@amd.com> Signed-off-by: Sean Christopherson <seanjc@google.com> Message-ID: <20260501202250.2115252-12-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-ID: <20260529183549.1104619-12-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/x86/kvm/svm/sev.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 62b5befe0eed..1982d13e71d9 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -3947,7 +3947,7 @@ next_range:
}
/* Find the start of the next range which needs processing. */
- for (idx = idx_start; idx <= idx_end; idx++, hdr->cur_entry++) {
+ for (idx = idx_start; idx <= idx_end; idx++) {
entry_start = READ_ONCE(entries[idx]);
gfn = entry_start.gfn;
@@ -3974,6 +3974,14 @@ next_range:
if (npages)
break;
+
+ /*
+ * Increment the guest-visible index to communicate the current
+ * entry back to the guest, e.g. in case of failure. No need
+ * for READ_ONCE() as KVM doesn't consume the field, i.e. a
+ * misbehaving guest can only break itself.
+ */
+ hdr->cur_entry++;
}
if (idx > idx_end) {