From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 C8769421F00 for ; Fri, 29 May 2026 18:36:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780079772; cv=none; b=mikBNF/EricVRmhbFy0c/gyU97SjiEGsHLyJ+tybQyVVWlbfO4aOReuGQb2Qbdr5sqvHVVsi22gBdOxsA+zUdYGbZXaDSjT4BOleKaIjyF00UG//HzpqPtvU9Uhmtm6dHEzjFkbXqh3Ge+1dbiNfyfgSJBtg0JZYGMKDLNIPDFE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780079772; c=relaxed/simple; bh=f+nkgUwG6A0jJd/pAJCpY6wq36Ry3jzJBqYji69OyE0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EIrX936rBiCm7PIdDP043nZLPicE6GyfJJoPNz6AzMVW6A5xsOWCls992NEV6m/FhiT/TFbqrwV8zz9TL3z9jU+FiflHvLRVif0MdZxkay433xjyjjePaDOKyok+4a9OzzBEs905OVYYYIfuZ5jFOjyqXiBcfs8nDbQPbHtg39o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZJjXHS7e; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=t9V0BPG8; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZJjXHS7e"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="t9V0BPG8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780079764; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XndtQXgYoKhYp0VgWVa9fVm5ME+RcvJYRIMg+5FuNQc=; b=ZJjXHS7eeUAEi+rJVgMrE3PaLyzPnHax7jtt2HCX6TGGTSq/l5JMxs0PD0mm5eCVl2ZHPl aJFW7ZTotBAsDUxHreXILnQM4787HSJ8CBVf1yVlLk2GQX06/w1nZf+RZt7N1LPjDJlkgh 7CllZtIBqismyalprbuhmGjQRe3C6uw= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-hc7nUPA4OuCgZXGuQw_fmA-1; Fri, 29 May 2026 14:36:03 -0400 X-MC-Unique: hc7nUPA4OuCgZXGuQw_fmA-1 X-Mimecast-MFC-AGG-ID: hc7nUPA4OuCgZXGuQw_fmA_1780079762 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49058e91639so47813185e9.3 for ; Fri, 29 May 2026 11:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780079762; x=1780684562; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XndtQXgYoKhYp0VgWVa9fVm5ME+RcvJYRIMg+5FuNQc=; b=t9V0BPG8z0yZJ0ofqSQ5ekHVrS4blBDJPDjq1ihIhDlxc9OyT/1UZoUctnB9g4xsT6 JsnySDSL1lRIhzQyPGDx9D0ZCPe0eb6FTr05Dt41WoUd+MXx2PRpDYOqf+QLbvIrTynA JmBnYA9Jz+C6+4j5/kooQt5c9gIzISiMHttZZNIqHU/9ZCZ0hdzwTkHfwSKj+dgL2x7s xlj9TKDWUKSNk1/6Jrhi9hSwCCmvcET4XjwvD5W3FWKfw6LDw0oJlwZB1uKFH6vVTWAY SfEUYd5BAbxuQlO12YKKmy8lIITU0MRmhsfhDyK5fq1WDOEZa0Vk14c9ot9GSOLFmASv rIEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780079762; x=1780684562; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=XndtQXgYoKhYp0VgWVa9fVm5ME+RcvJYRIMg+5FuNQc=; b=Dckl60uibOmQcXkUtukRomCeWnonvkrf2MjmXZHxkjXMPTWq01XJqStzNAXMSbu4qd ABfAbc1TZWgzCF3EQ8Ggz6G1beXm0DnE4cjp4M2LykeiQT+BQw4yvQlS3e2DfIZJVDYr bILdWMsY59/9akVDqwVWNYV9vBuf4x1ajI2mhFANF6TgovykGJGSCU0ius1WHB/7wQud wAJyKxDYfakRqnMTVQV+Bg3qOi6kw3lql2i/1xBZIeW8fP5nrP9NZKgo5FdsOGKG/lef wY66mDYcw8ZZNJ53/rJayyKfge+qDhL1CsEP1gogxRxscsVSdnmQwMBUC7LDDPstpzPS ZJ8g== X-Gm-Message-State: AOJu0YyCPhEaT6ZbW6wQAHiL2n3UaSkFrAW1qVBNRj7uroiS078ZPloX 7WqPPVh8LZE2eWH0/KJGrbQkp/kr2Y0MSspFQoltPht26YdFTaEyeRux8AIwTlHmTlvcYo+EOkN dnXw+GRSos4mZCldLMhd55/Ms28YcYEp0/MmH85I7ubZR3KCZwCcYKEhbEP5YZ5Kz3bXRRNXoQ4 mJ0eMtM66rTbuBmnar+MeGXRWssl/hiwDYqowI6liKs5kD15QXww== X-Gm-Gg: Acq92OEG177R/FQDsr+sKaobhC9+9lrF2MRTWVvLv8mIF/3Vcuwc5PuR1xKYjPta0hL hpkuigEEHGQWn7H3myrwi8aC+qZRicjQI2ZyYQbt7iBO8tSewJk7A4/iJXYgllf0A3MVTkY5iCX uhpyehXHrwe+MHJMzUxmTPj31XG8upUO79LfVlRm+I5RjWwBkVAFlXgvj+ISq5qNjWFXHbSQnjK 9LobVGEO0u4bkkeRDUMiq1FnI3Fj+YQANfWTgqzyupgXzr6hGRRw9LgzUMUp4ZpSSRvL+ELqNt5 KR60U9rdl4DJ4Qwmhx1BRCd1ZpeSKE882n9X7KnKWk/4git/U2HUbMBMcMvG1pImaGHk53ftO70 W7MbkThqoPpxDPGOmnuFnsJbE/oiVUGSC9wUVZvmyWVFRwXBzdW6s7v8GxveBX2/xQSH78KwFZX A7A2ONJ+3CC5t9Cq5dXn9NpqLF+0iPjBySk1hhbQ== X-Received: by 2002:a05:600c:a305:b0:490:7227:100 with SMTP id 5b1f17b1804b1-490a2933b22mr9949155e9.18.1780079761617; Fri, 29 May 2026 11:36:01 -0700 (PDT) X-Received: by 2002:a05:600c:a305:b0:490:7227:100 with SMTP id 5b1f17b1804b1-490a2933b22mr9948755e9.18.1780079761169; Fri, 29 May 2026 11:36:01 -0700 (PDT) Received: from [192.168.10.48] ([151.49.251.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4909d6a0a89sm73788825e9.7.2026.05.29.11.35.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 11:35:59 -0700 (PDT) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, Tom Lendacky , Michael Roth , stable@vger.kernel.org Subject: [PATCH 04/24] KVM: SEV: Ignore Port I/O requests of length '0' Date: Fri, 29 May 2026 20:35:29 +0200 Message-ID: <20260529183549.1104619-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529183549.1104619-1-pbonzini@redhat.com> References: <20260529183549.1104619-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Sean Christopherson 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 --- 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 e6579ca9f364..52703c954856 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -4585,6 +4585,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, control->exit_code); } @@ -4605,6 +4610,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.54.0