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 B01FF410D24 for ; Fri, 29 May 2026 18:35:55 +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=1780079760; cv=none; b=lYahlNEZMMeg2bBWZh4DtuLH+MQ5NcxaNwEX0JE09e0PiUJdpl04iDoMkgtkXsjy02Bq0UcZ3ZyVJi+6BkllA/fNIAfEbARN/4yav6ZcSwoqTtco2wx67GW0nqW6wmu+qzpH0O9j+eYCgJwGtjo5b6adRo+ZaW+bzuLzEz2Pgf8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780079760; c=relaxed/simple; bh=1pUboGVTGTbGNTWIr7911s/ojq1kxLKwC3wwVQmcasg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Isf0zkZeSbULCMnaqXqj1QhuVA6qVkMVXIRz/oucV4VlgDqcb+xFfUzv68yFmgrj/FIGQGgXHnn+NymDvv8NYPMAv3EhxVuLhARjnuKW0o9z8I6KBSZCMJDlf3rI1P3xyfrM3oiELCo5yaRFY26Xywx8imL/2Z1Dk84GbtaGoJ0= 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=AwzVXucN; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=W5k0oFu8; 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="AwzVXucN"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="W5k0oFu8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780079754; 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; bh=ntARZ+6qGDkNDZzF/QBmpzXqfdRaWpB6bSEFpJx2YbI=; b=AwzVXucNitMpZAGkcGsMFJzNINg375aysP2aaSRtQwnVvyYqiooHd6/HB0A/jokJfgVZdq 2mSvwGZzDMFK/Us5b8/ZEl5yEFNDDuwNkf4noBdM3sNACyetPCkGaBTftLaALWRXP+rzGH SquvszYxczRZ7iWV8vgrrs4HdkWzTC8= 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-526-m9cHHWiQN-SOWQbFNve1fw-1; Fri, 29 May 2026 14:35:52 -0400 X-MC-Unique: m9cHHWiQN-SOWQbFNve1fw-1 X-Mimecast-MFC-AGG-ID: m9cHHWiQN-SOWQbFNve1fw_1780079752 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49041d39887so58607145e9.2 for ; Fri, 29 May 2026 11:35:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780079751; x=1780684551; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ntARZ+6qGDkNDZzF/QBmpzXqfdRaWpB6bSEFpJx2YbI=; b=W5k0oFu8g/WGVyCg1GkIKhBVS9lJXA/fCWlGuKTwO/xfrF4VTwt9xeU79s9RKV4M8W +y4AiZ3easMJDBWGnx4d3KwOwTjjCMhxr0rs+9b2JWOgzaeFvjbZ+mPO91sYp3r2s18I QGQTzWa+lS5OhIw0wYHV69MLMSLmt/ORhX34qTjFx2Xwx/DLJpJUOvcISeGx3XjOo2BO ZscL3sY1C7HeWr+ZdNwwyYwwVhrYLqUItFOq5tlVws7SukuYyY2c2JkaFVpb3UMWNVqI YUDkkIXnFzH5A0Y9znUm8OfJlCnDo7MMspGUnKh/hF7JfpZyKaUigEmhkVN/HBX5qhAe oCzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780079751; x=1780684551; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ntARZ+6qGDkNDZzF/QBmpzXqfdRaWpB6bSEFpJx2YbI=; b=aONvpEyXXDJY9XbIFwu5s8EXkfYM7Fus28t4QR1L/GWBpgpnKfuK+ryf4Mj/nyjlzd /hMFe2cgT50A27WFW/uLAUJMrcBS+BoShKfUph7kBEr/cBn8vAeFvlj4aWwJtxGvWYVX MmV9rapSbUvMIhL6N+R5uB5vY6wU46CpzXQtDNBFcf2JHfvuACv6Rb7PIkl4VfM7kUKN FZ4vgnDvL8zAhfS9dniXC7x2tXd2oRmxwPsIU6rt8dTUkWd7XfcPSwXUgCqmgEHsj+i6 rl77mLSrg06MZKxBxDk2cM/be7xWntEYgF9ENb2FErnq12U9Sv/O5V0lF+2iR7ByE4BI IMyA== X-Gm-Message-State: AOJu0YxYCa564CG3k8VteGZDp55LsfTpZ+cvlEIIUmHMA5SJf5ph1q4P 0c/cHY/FpY1AOnGYdsYDTtthYoPATKbjkWZhxlncQ3a04RtM5/fg2mFJkT7kuUe7rFPV3JJwLkz MyC7iNSyyG/+EjPkoVi6oTJqvfRpudtxr8XQf7+r6Gfk5SqlIuW7DtdIB3xEtiJjdnZ/CPUSlts 74npfYYsBaGsCNkoARpx1jK+mVZ+WedVW4dwXvF1xG/HLHLC+2Eg== X-Gm-Gg: Acq92OGb1Ybog1Nn57n/jM9Rg6qnxxzlzSIelZqJ6a425IQc4Sqfs2HtduNbbc1SNH+ Gbx0rSFcG91fffIwKFTyazlSTq2q9MyRqnWZZvCxjaPeJJjcIHJoK0pzXTz0AvdvmNYhwg8fuUl 15nYxq2gMkSRbm+ETUNCEsfvixc2cjWOLoNOSP9njS/A0LErDXZuymqDtO1Sjka5Zh6Gukf8lD2 VU/3fZ/aIezDie9aJtSG5+cM+apXdJS1qWTWTTxllE0ka0w4dvPqD5H4jmVseAFEWn99qx7KAmZ rOv2xx3rfd+vnCKVJVxaGczIScEd8o04EWzHpecvLyKLNMpOKqWuyKkKFqIgD4hpmDnkDdQSjIQ /gOcndDSfxwChUG3coevAygwKc4LhB8L2cj3tsId6AmRDGYaB0Lt4KSOII4wVgJyLlD3A5EbBr6 znr0VZNMoMQDNGhu6q/v66FzUquf9g4Y9dyXCV8g== X-Received: by 2002:a05:600c:1988:b0:490:845e:3a6 with SMTP id 5b1f17b1804b1-490a295013bmr14050305e9.25.1780079751503; Fri, 29 May 2026 11:35:51 -0700 (PDT) X-Received: by 2002:a05:600c:1988:b0:490:845e:3a6 with SMTP id 5b1f17b1804b1-490a295013bmr14049925e9.25.1780079751152; Fri, 29 May 2026 11:35:51 -0700 (PDT) Received: from [192.168.10.48] ([151.49.251.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4909d6f3027sm51925345e9.14.2026.05.29.11.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 11:35:50 -0700 (PDT) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, Tom Lendacky , Michael Roth Subject: [PATCH 00/24] KVM: x86: fix various GHCB issues Date: Fri, 29 May 2026 20:35:25 +0200 Message-ID: <20260529183549.1104619-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The PSC code has a variety of bugs, several of which have to do with not following the spec. It took a while to disentagle and root cause everything (the GHCB ain't exactly the easiest spec to decipher), but here it is. The first 10 patches have just been sent to Linus. For the rest we decided to handle it on-list for 7.2, but it is possible that a clever guest could abuse the bugs to cause the host to leak a pile of pages (limited by how fast the VM can get recreated). This can also be found in a sev-for-7.2 branch of kvm.git Thanks, Paolo, Sean, Mike, Tom Michael Roth (1): KVM: SEV: Require in-GHCB scratch area if GHCB v2+ is in use Sean Christopherson (23): KVM: SEV: Ignore MMIO requests of length '0' KVM: SEV: Reject MMIO requests larger than 8 bytes with GHCB v2+ KVM: SEV: Ignore Port I/O requests of length '0' KVM: SEV: Use the size of the PSC header as the minimum size for PSC requests KVM: SEV: Compute the correct max length of the in-GHCB scratch area KVM: SEV: WARN if KVM attempts to setup scratch area with min_len==0 KVM: SEV: Don't explicitly pass PSC buffer to snp_begin_psc() KVM: SEV: Check PSC request indices against the actual size of the buffer KVM: SEV: Use READ_ONCE() when reading entries/indices from PSC buffer KVM: SEV: Make it more obvious when KVM is writing back the current PSC index KVM: SEV: Add an anonymous "psc" struct to track current PSC metadata KVM: SEV: Read start/end indices of PSC requests exactly once per #VMGEXIT KVM: Don't WARN if memory is dirtied without a vCPU when the VM is dying KVM: SEV: Move sev_free_vcpu() down below sev_es_unmap_ghcb() KVM: SEV: Decouple the need to sync the GHCB SA from the need to free the SA KVM: SEV: Unmap and unpin the GHCB as needed on vCPU free KVM: SEV: Don't terminate SNP VMs on #VMGEXIT without a registered GHCB KVM: SEV: Move GHCB "usage" check out of sev_es_validate_vmgexit() KVM: SEV: Return INVALID_EVENT for SNP-only #VMGEXIT from non-SNP guest KVM: SEV: Return INVALID_INPUT, not MISSING_INPUT, for bad GUEST_REQUEST input(s) KVM: SEV: Handle unknown #VMGEXIT reasons in sev_handle_vmgexit() KVM: SEV: Turn sev_es_validate_vmgexit() into a dedicated predicate KVM: SEV: Remove sometimes-used function-scoped "ret" from #VMGEXIT handler arch/x86/kvm/svm/sev.c | 554 ++++++++++++++++++++++------------------- arch/x86/kvm/svm/svm.h | 9 +- virt/kvm/kvm_main.c | 3 +- 3 files changed, 302 insertions(+), 264 deletions(-) -- 2.54.0