From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC60841B8F9 for ; Tue, 18 Aug 2026 08:12:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787040779; cv=none; b=OYWXPawbNTKz6AfSqPE3HNC7oQI8VfosdwajPHXQWQeUurLa4xr9SKUY25kD7sXjUXGNFM/uVYKp34cFdfDxGFiF+tzN3t0iPU5SSvVGggN7tKEdgpm6S1bEsz3lF59ssSlcZdBL6o+7rCkULGq26EPETPkReMDimbJzoB9kFIo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787040779; c=relaxed/simple; bh=M2Ifb8ZR+HwA/H1LGAE2C/jP4eVMt+pmNz86ycTCoCc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ANIDJ8CfIMO4T/PTsEHQkIWYroZ5KviWonevt8b/Tjvu8y85jCkMt5jMb6oUbtpfUcK+T1q60nlAW01h93QNPBcPFqeH2Hti3XcXXogFLc02wwIsHViEzKfdxVVnib1Y1BvepkqaYYq+oVTg9x/W5d/g020QinoRbIm9dHMxOQA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=gnN6T+rM; arc=none smtp.client-ip=209.85.215.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gnN6T+rM" Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cbb467e56aaso3114588a12.1 for ; Tue, 18 Aug 2026 01:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787040776; x=1787645576; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7jHUMARs30oMku7rrAHEp5fhgY0hNDCAk+0nqtnlfj0=; b=gnN6T+rMWPC9082m84vAj6qSPGwgYKFL0R3y2e9DnWVFll1c292pkFZzqIqV6j2Kn7 joXyDi2OZsHAP3gR6/bAnDfhT5EFZ7FeNqCTQEIr4/Di6EVKaUxvzvxHDPkcX6xK4aX1 c5x6GfldgEZOe0isDF8u7kM4aHxm4ha/CVia1ABdaE2g55PlNZveRsGLYE8hVt6IaNgI EE7xqC3Tfcg4IenrM6Ius5i/RfjCGoy0YOrGjkd0nsCyXXmrHda28GWBpkM6sFTbuDOw HdTxwvPlhi6NNu91IN3q08/9vXveGdBCUNW5wyOLgK9BeQWHh4NRmyIk0vLYfF5eepFf 021Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787040776; x=1787645576; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=7jHUMARs30oMku7rrAHEp5fhgY0hNDCAk+0nqtnlfj0=; b=TkwALR4f3cHAnGpHoOQ/J2X/VuxUztYRawA/vCD5wjy3vxCZCh9QqbgisIAuHDygWV m72kHD3YjsMJG0/19w6yuE6GYCA+apPbfBSApQ38cICJzpGYy9Vr/66V27Mu02c1e1gT VOW+BLc0fmzPOZf4fvoRp28gDyA526a6vKY02we8+ats2ULMgpURXijP6NB0GMHAwguG nvFVhP8uLMJB4BIIA9NJq7LPOKQo5iG2Pl4pZF3WWyqBcEGh38X+4oQV1h8EUTcZbXg/ rz7AQ5G6M8z8dh3otk0MTpan8b5MLsWt3WodFAQFawGG2tty449x+/it1iy8tjeIgJ+u bSpw== X-Forwarded-Encrypted: i=1; AHgh+Rp/zeYmOqanzfTRlYeBzex9Z5ZPWGFAlzuGDHPNrctSI3k5OIvOLSHu2Y4n1Sne3XFuY4UhSXgQlLw9IEo=@vger.kernel.org X-Gm-Message-State: AOJu0Yyu1DKUx9fozLIOetTzhHbUvrnEsaNHeRYAhANSUSib1DWPYGy6 rAhaYTgN5ev5qHSARhSLgf3vgKxtPRkvvCckgJkgqurYqK/2Bf9QoEXd0yr2C7z9Ut6H+oJ3g70 a8id9P73FYl9Sj1lQBkxKACuV2A== X-Received: from pgdh4.prod.google.com ([2002:a05:6a02:5184:b0:c9a:37aa:b17d]) (user=ackerleytng job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:6f8b:b0:3cc:4d86:389c with SMTP id adf61e73a8af0-3ccda4b542amr9870906637.13.1787040776115; Tue, 18 Aug 2026 01:12:56 -0700 (PDT) Date: Tue, 18 Aug 2026 08:12:35 +0000 In-Reply-To: <20260818-gmem-no-return-page-v1-0-4f8d939efdbc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260818-gmem-no-return-page-v1-0-4f8d939efdbc@google.com> X-Developer-Key: i=ackerleytng@google.com; a=ed25519; pk=sAZDYXdm6Iz8FHitpHeFlCMXwabodTm7p8/3/8xUxuU= X-Developer-Signature: v=1; a=ed25519-sha256; t=1787040773; l=2004; i=ackerleytng@google.com; s=20260225; h=from:subject:message-id; bh=M2Ifb8ZR+HwA/H1LGAE2C/jP4eVMt+pmNz86ycTCoCc=; b=NMp2JIOD4jsbFJI/klpvqjQYI52qH+FRAQ3nl2QtSwfyO9la4WUlSpaEfhVwNd0VJlP0lcaCT c2/EcIXTH8fCy1k0RKSRKA3SJNRZKxQY4GJqvWPjQUHmryAYp7Y8Bq7 X-Mailer: b4 0.16.0 Message-ID: <20260818-gmem-no-return-page-v1-1-4f8d939efdbc@google.com> Subject: [PATCH 1/4] KVM: SEV: Treat unassigned RMP entry as benign race on PSMASH failure From: Ackerley Tng To: Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Ashish Kalra , Michael Roth , Brijesh Singh , Marc Zyngier , Oliver Upton , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , David Hildenbrand , Fuad Tabba , Yan Zhao , "Edgecombe, Rick P" , Vishal Annapurve Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Ackerley Tng Content-Type: text/plain; charset="utf-8" When handling an RMP fault, KVM attempts to split a 2MB page via PSMASH. If PSMASH fails, the only expected return value is FAIL_BADADDR, which does not distinguish the reason for the bad address. Hence, another RMP entry lookup is required to determine whether the failure was benign. Specifically, KVM re-checks the RMP entry to determine if another CPU raced and already smashed the entry into 4KB pages. A concurrent operation (such as guest_memfd truncation or hole punching) can also race and transition the page to shared, removing the page from the RMP table and causing PSMASH to fail. This can happen even if the page is still referenced by KVM, because guest_memfd reclaim transitions the RMP entry to shared when the folio is removed from the page cache. Treat an unassigned RMP entry as an expected race when re-checking after a failed PSMASH, and skip logging an error warning. Fixes: c63cf135cc99 ("KVM: SEV: Add support to handle RMP nested page faults") Signed-off-by: Ackerley Tng --- arch/x86/kvm/svm/sev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index fcb41dfde4c02..b2738362a928b 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -5074,10 +5074,11 @@ void sev_handle_rmp_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u64 error_code) /* * Look it up again. If it's 4K now then the PSMASH may have * raced with another process and the issue has already resolved - * itself. + * itself. If it's not assigned, then this must have raced with + * another process that made this page shared. */ if (!snp_lookup_rmpentry(pfn, &assigned, &rmp_level) && - assigned && rmp_level == PG_LEVEL_4K) + ((assigned && rmp_level == PG_LEVEL_4K) || !assigned)) goto out; pr_warn_ratelimited("SEV: Unable to split RMP entry for GPA 0x%llx PFN 0x%llx ret %d\n", -- 2.55.0.699.gb54405d56f-goog