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.129.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 AB168426697 for ; Fri, 29 May 2026 18:36:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780079769; cv=none; b=KRlVAxz2uRnhY60TUaSOsfFiwJ3aPoH84g0JjCYKD8T+M+2Y3VC4DQWeq690YY4ELBYj9uhlxBzscsGQ1UwLd+BplHDD5RQH+CLH/b6Ogv9Zups+otZaSxA9KpjzPY9j3e3Hc395SOfHaJ8M/3av+fkBNBR89FgpAJl7By1TlL8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780079769; c=relaxed/simple; bh=Ic42NJxjVTuyyhMYhy6XU5l/gYDKkJGnaGzHHnNqay0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W8M3ve8t+YqGjz/8IRt8ydjuPGYtE8Uhp70P2A/nNUyA7mhtR/lqb07wdXfFbWY8Z9N5M7XfxWSKNBN1jG29ROndC679OYKOZ7BW4X/SpYE6WoZqWXCYAyxZA4veNNcU3KkrjmV9w1+DpuTGygGJ6WtLo4hbkLfkVYUed8afvR0= 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=W5aGWrLk; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=ISL1fgGN; arc=none smtp.client-ip=170.10.129.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="W5aGWrLk"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="ISL1fgGN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780079761; 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=oaDspuaK+51kNrKIJDmVaTpEzuF1DrT0Ap9tU5k1194=; b=W5aGWrLkNyBCswg4maOjNyaCb7IuQ4oYivDIqZs/NErKpmgJ+8gZoZhI4WmHcG6Naq+byY tO2iSeNpkE2r5Zt1rRTiV4OWKuyR28xz/6VPYsJXEYroKWsMNlmkTLhYC1EmoPGcN3F07Z IwXrb7E0d5D1L432VD80O7JmysEr0aY= 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-683-b9uT6MGJMnibF4aYvXR7bw-1; Fri, 29 May 2026 14:36:00 -0400 X-MC-Unique: b9uT6MGJMnibF4aYvXR7bw-1 X-Mimecast-MFC-AGG-ID: b9uT6MGJMnibF4aYvXR7bw_1780079759 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-490261c79fcso56607645e9.0 for ; Fri, 29 May 2026 11:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780079759; x=1780684559; 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=oaDspuaK+51kNrKIJDmVaTpEzuF1DrT0Ap9tU5k1194=; b=ISL1fgGNShxnQjGfQF2kQ7B/utyID71pnDqI5ctnmKMnLPWhl0v5/AZ26TygE50CIQ o3VGT/Iof0LL9/c+H8RDCRDW9HXa8RSLV/CmUjMqwMYCKfvDRAF2zPz9OE+zEAEDhqQD rImawR8DEYDvjnFw9Bb7DcB6tJUahKaO8rax+kT4eL5V4rIrHbsTo/PW4Fc8mDfmT/uS W3Spib4Mh9kMeKSlwXp4h7TwORZITWSu6OaTGLYw+bQzj6K3uFMf19lXznTxJtKCtNww C299CHBLK8uHLRlFZdOgKG5Jspv8R/nTAQpz7EOjJy+YBo5id9ybssMOFGKhfT/g2pUA 9hnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780079759; x=1780684559; 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=oaDspuaK+51kNrKIJDmVaTpEzuF1DrT0Ap9tU5k1194=; b=NIDqkkQ1dZyQEJbmp8F7jKyF+A9IPFOPqwFqLmBWfHj3dnto5cE5vXXrqQYaYlYzUD l5LF5olkQ1V7d7LaOIeT3VWkdAtBiBoLqw9ABpXNZpDZJlXGo3O2TvZqbVpO+PFzrSar YtswodXDTK5eSjACTnOmfJ6LeZEdsuBNuF63MCVy3DOqJScHy458Gm5QZXpTT6bh8vjW S6USp2IQOHKorhgIQ9ufCvIe1G8lbtS2M6adsaBd3hlfdUoy5mK1hg8Fhafp8FtZrbZ2 hH34TCJhykZrDTbOFO1FhjZNPZrTNeOwQu5Y5HUTAigSf1NkSxeVOkxIphWEtfEMCC6v kShw== X-Gm-Message-State: AOJu0Yyz6zeMnqBkIITytB1h9dThSd7DtycBybWHsv4I+pif1Eq8t3+o UkJJBODgmrxBN6lN8Aa3uMhtOZBEzYt81gxIq7QaKMe1rA1mEyJppkT6PEY3nAYSGAHXG3LrOzW ylf/UXICZhSOPlL30OUvUdVMncnUcUQHu6piaZW5wbVfpqai1PJKLjjrxegEHlpOVd1wPXscmwy ZckMu/ArYyGVIAMDYvjzCT4XsV29147f5580v+OK18T5dAKeB0Ew== X-Gm-Gg: Acq92OFh+f7dXMR6CDzPjhokNavVZ4diKZrYJd8naVwp0116X4G4P6wXyS+yVe8AU6v khFIwFz8I4i50buwFzuIkhovfNXT4kMkJtxMkdN3yDJQ2uUbXRjJUn/spjSPgp+TxxOAaeI+C9/ LLTWjXOR/zELYY3ur7gAr8mVz/Oglz9nAGcvfPkDTusXATe4eqQzgAulWGV8UIu3m+1YZyQcVMV vpUHEx+/FbcBRUYK0SP7dl6NgwF54omgxoehLwGo413fmT/TSk+f0Ol6Zvjc6no3rOGzYDbdTIa U+Mf8TOoXKsXGpD4ICA2ERdE0cH0MlysZkblwPgV85dFR4nThwECmg0Ul0/2qU+T3bLCKNxjcRy R9uZVRtjqXrMNuvsGIpxDLheXlKUELVpzJWwODraZ5+E+Y31ALSK9g+8STOaJ+e480O+/2jgdlg ouB5F8D2E4NYLRHUOVA30emiQ/RsGtpfHHHeoa4g== X-Received: by 2002:a05:600c:45c9:b0:490:8b0b:d3b1 with SMTP id 5b1f17b1804b1-490a2a4bac0mr7346715e9.12.1780079759106; Fri, 29 May 2026 11:35:59 -0700 (PDT) X-Received: by 2002:a05:600c:45c9:b0:490:8b0b:d3b1 with SMTP id 5b1f17b1804b1-490a2a4bac0mr7346335e9.12.1780079758656; Fri, 29 May 2026 11:35:58 -0700 (PDT) Received: from [192.168.10.48] ([151.49.251.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4909c114e99sm19737625e9.25.2026.05.29.11.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 11:35:58 -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 03/24] KVM: SEV: Reject MMIO requests larger than 8 bytes with GHCB v2+ Date: Fri, 29 May 2026 20:35:28 +0200 Message-ID: <20260529183549.1104619-4-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 When using GHCB v2+, reject MMIO requests that are larger than 8 bytes. Per the GHCB spec: SW_EXITINFO2 must be less than or equal to 0x7fffffff for version 1 and less than or equal to 0x8 for all other versions. Fixes: 4af663c2f64a ("KVM: SEV: Allow per-guest configuration of GHCB protocol version") Cc: stable@vger.kernel.org Reviewed-by: Tom Lendacky Signed-off-by: Sean Christopherson Message-ID: <20260501202250.2115252-4-seanjc@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/sev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index fb2174b6d1ba..e6579ca9f364 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -4502,6 +4502,11 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu) if (!len) return 1; + if (to_kvm_sev_info(vcpu->kvm)->ghcb_version >= 2 && len > 8) { + svm_vmgexit_bad_input(svm, GHCB_ERR_INVALID_INPUT); + return 1; + } + ret = setup_vmgexit_scratch(svm, !is_write, len); if (ret) break; -- 2.54.0