mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Stefan Teodorescu <fane@google.com>
Subject: [PATCH] KVM: SEV: Ratelimit all #VMGEXIT-induced info and error messages
Date: Thu, 22 Oct 2026 13:30:28 -0700	[thread overview]
Message-ID: <20261022203028.595318-1-seanjc@google.com> (raw)

Ratelimit all of the kernel log messages related to #VMGEXIT and/or GHCB
handling, as they can all be triggered at will by the guest.

Fixes: 8f423a80d299 ("KVM: SVM: Support MMIO for an SEV-ES guest")
Fixes: 8640ca588b03 ("KVM: SVM: Add AP_JUMP_TABLE support in prep for AP booting")
Fixes: e1d71116b64a ("KVM: SVM: Add support for SEV-ES GHCB MSR protocol function 0x100")
Fixes: 8d1a36e42be6 ("KVM: SEV: Add GHCB handling for termination requests")
Reported-by: Stefan Teodorescu <fane@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 arch/x86/kvm/svm/sev.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 6427db390b1c..469a313fe7ab 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -3654,14 +3654,14 @@ static int setup_vmgexit_scratch(struct vcpu_svm *svm, bool sync, u64 min_len)
 
 	scratch_gpa_beg = svm->sev_es.sw_scratch;
 	if (!scratch_gpa_beg) {
-		pr_err("vmgexit: scratch gpa not provided\n");
+		pr_err_ratelimited("vmgexit: scratch gpa not provided\n");
 		goto e_scratch;
 	}
 
 	scratch_gpa_end = scratch_gpa_beg + min_len;
 	if (scratch_gpa_end < scratch_gpa_beg) {
-		pr_err("vmgexit: scratch length (%#llx) not valid for scratch address (%#llx)\n",
-		       min_len, scratch_gpa_beg);
+		pr_err_ratelimited("vmgexit: scratch length (%#llx) not valid for scratch address (%#llx)\n",
+				   min_len, scratch_gpa_beg);
 		goto e_scratch;
 	}
 
@@ -3680,8 +3680,8 @@ static int setup_vmgexit_scratch(struct vcpu_svm *svm, bool sync, u64 min_len)
 		 */
 		if (scratch_gpa_beg < ghcb_scratch_beg ||
 		    scratch_gpa_end > ghcb_scratch_end) {
-			pr_err("vmgexit: scratch area is outside of GHCB shared buffer area (%#llx - %#llx)\n",
-			       scratch_gpa_beg, scratch_gpa_end);
+			pr_err_ratelimited("vmgexit: scratch area is outside of GHCB shared buffer area (%#llx - %#llx)\n",
+					   scratch_gpa_beg, scratch_gpa_end);
 			goto e_scratch;
 		}
 
@@ -3701,8 +3701,8 @@ static int setup_vmgexit_scratch(struct vcpu_svm *svm, bool sync, u64 min_len)
 		 * limit the size
 		 */
 		if (min_len > GHCB_SCRATCH_AREA_LIMIT) {
-			pr_err("vmgexit: scratch area exceeds KVM limits (%#llx requested, %#llx limit)\n",
-			       min_len, GHCB_SCRATCH_AREA_LIMIT);
+			pr_err_ratelimited("vmgexit: scratch area exceeds KVM limits (%#llx requested, %#llx limit)\n",
+					   min_len, GHCB_SCRATCH_AREA_LIMIT);
 			goto e_scratch;
 		}
 		scratch_va = kvzalloc(min_len, GFP_KERNEL_ACCOUNT);
@@ -3711,7 +3711,7 @@ static int setup_vmgexit_scratch(struct vcpu_svm *svm, bool sync, u64 min_len)
 
 		if (kvm_read_guest(svm->vcpu.kvm, scratch_gpa_beg, scratch_va, min_len)) {
 			/* Unable to copy scratch area from guest */
-			pr_err("vmgexit: kvm_read_guest for scratch area failed\n");
+			pr_err_ratelimited("vmgexit: kvm_read_guest for scratch area failed\n");
 
 			kvfree(scratch_va);
 			return -EFAULT;
@@ -4509,8 +4509,8 @@ static int sev_handle_vmgexit_msr_protocol(struct vcpu_svm *svm)
 		reason_code = get_ghcb_msr_bits(svm,
 						GHCB_MSR_TERM_REASON_MASK,
 						GHCB_MSR_TERM_REASON_POS);
-		pr_info("SEV-ES guest requested termination: %#llx:%#llx\n",
-			reason_set, reason_code);
+		pr_info_ratelimited("SEV-ES guest requested termination: %#llx:%#llx\n",
+				    reason_set, reason_code);
 
 		goto out_terminate;
 	}
@@ -4678,8 +4678,8 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu)
 			svm_vmgexit_success(svm, sev->ap_jump_table);
 			break;
 		default:
-			pr_err("svm: vmgexit: unsupported AP jump table request - exit_info_1=%#llx\n",
-			       control->exit_info_1);
+			pr_err_ratelimited("svm: vmgexit: unsupported AP jump table request - exit_info_1=%#llx\n",
+					   control->exit_info_1);
 			svm_vmgexit_bad_input(svm, GHCB_ERR_INVALID_INPUT);
 		}
 		return 1;
@@ -4688,8 +4688,8 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu)
 		svm_vmgexit_success(svm, GHCB_HV_FT_SUPPORTED);
 		return 1;
 	case SVM_VMGEXIT_TERM_REQUEST:
-		pr_info("SEV-ES guest requested termination: reason %#llx info %#llx\n",
-			control->exit_info_1, control->exit_info_2);
+		pr_info_ratelimited("SEV-ES guest requested termination: reason %#llx info %#llx\n",
+				    control->exit_info_1, control->exit_info_2);
 		vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT;
 		vcpu->run->system_event.type = KVM_SYSTEM_EVENT_SEV_TERM;
 		vcpu->run->system_event.ndata = 1;

base-commit: 7e60162b16f9da0d2fa83da5c1723b6853a0ac1d
-- 
2.56.0.257.gf7497c7d27-goog


                 reply	other threads:[~2026-10-22 20:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261022203028.595318-1-seanjc@google.com \
    --to=seanjc@google.com \
    --cc=fane@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®