From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33C1BDDA9; Thu, 2 Jul 2026 16:40:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010412; cv=none; b=l3FnhwfMtxvlwfNHAZWBX224/FCBuM/1p6IelB1Dv++3ii+dXYOHNsnTO71ll6r4zU/+/d0VNRxnVc/xAJv+8DX4bEIivisFxhcgIBf6s9xKKSjDEargh/VXvQaVy3IoWNR16WBn1NKv8RjERhcNeoKiTbtJdMWpU70XjFMSfCk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010412; c=relaxed/simple; bh=nsyRwzOh2Coci871jFG0uNsZyXiEoR8WXQdPzX9+d5k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p/JMyBzQwR+vN83iJGoTYtahfiyJXMBIPWyCeLcuvGgbLsJ6A0Qcd3CCYKDCK0nLtfz+zD6H+zE9gZsJqmtKbzOjSDMMy6Cdvcwu7CI1J5B6g2vR3fjrxPY+Cm0xRO0FqFZG5737d8HcEEUXSRTQg9S4YSYMyOW0TP21lJ+FIqY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hGslMXv3; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="hGslMXv3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 985EE1F000E9; Thu, 2 Jul 2026 16:40:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783010411; bh=TVZzLsBKCDisreJPxC66lddcVWPqZP/hfx/Iu44QlCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hGslMXv345n2Shc65KEMWEzbA/iNxUr/eV8R7o8eyJkeWAFPQUHZj+MhxWeu0VLSD Flz5+DBtY+UCH1Sdv23G8pJ0g5mISTeRuR70HugZ16t4fDA6u5WN0+MCb3Z6Nn+Vj9 DDZxwAtEoGjkKbp6jgqLooaLtII0C/Lf6VCDsb3A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tom Lendacky , Sean Christopherson , Paolo Bonzini , Jack Wang , Sasha Levin Subject: [PATCH 6.12 098/204] KVM: SEV: Ignore Port I/O requests of length 0 Date: Thu, 2 Jul 2026 18:19:15 +0200 Message-ID: <20260702155120.720202160@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155118.667618796@linuxfoundation.org> References: <20260702155118.667618796@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sean Christopherson commit 3988bd2723de407ae90fa7a6f6029b4e60238c58 upstream. Explicitly ignore Port I/O requests of length '0' (or count '0'), so that setting up the software scratch area (and other code) doesn't have to worry about underflowing the length, and to allow for WARNing on trying to configure the scratch area with len==0. Fixes: 291bd20d5d88 ("KVM: SVM: Add initial support for a VMGEXIT VMEXIT") Cc: stable@vger.kernel.org Reviewed-by: Tom Lendacky Signed-off-by: Sean Christopherson Message-ID: <20260501202250.2115252-5-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Jack Wang Signed-off-by: Sasha Levin --- arch/x86/kvm/svm/sev.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 497a6e70513570..73e49317735173 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -4459,6 +4459,11 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu) control->exit_info_1, control->exit_info_2); ret = -EINVAL; break; + case SVM_EXIT_IOIO: + if (!((control->exit_info_1 & SVM_IOIO_SIZE_MASK) >> SVM_IOIO_SIZE_SHIFT)) + return 1; + + fallthrough; default: ret = svm_invoke_exit_handler(vcpu, exit_code); } @@ -4479,6 +4484,9 @@ int sev_es_string_io(struct vcpu_svm *svm, int size, unsigned int port, int in) if (unlikely(check_mul_overflow(count, size, &bytes))) return -EINVAL; + if (!bytes) + return 1; + r = setup_vmgexit_scratch(svm, in, bytes); if (r) return r; -- 2.53.0