From nobody Thu Apr 2 04:19:31 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 76704313E36; Mon, 30 Mar 2026 10:45:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774867559; cv=none; b=fqtlAVmpIga1Jgkjsgk/Q5Npimgbj4JvyDFJy5zykzh+A+ZPG7o+AzMHVfFDW1hCj65UdgOyzKMrDe9+tGmYXQm7kajIos4ZhG7Tyfc89EZq3TYL6Ad4Ez0vVEgXFEgVeek6yDMD+o+tKHzCBkSsaFDGBHm1d6dNPDket0Q3upc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774867559; c=relaxed/simple; bh=T/0jWuK1FCZH5OidAX/lUGs0SAzNsVwdEeWU/YrNkpg=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=u3y1izzq/g0/vQkV5F21fzaDy/PDFb1ZtrrrF9TGwmD6sFq6YrKKH8fArdFFv9A7388zfQDZ9CYzAX5BDnhcYWGKuVPM0w2xdsRIZZuEOxpJDXUhhgnwItKMoifrIdzlH86F7ETmcKZ+YbhGlf9MSgHgMWeGjN+Bje1l/OpJ21k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=EopisGJt; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=YTSgjPv+; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="EopisGJt"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="YTSgjPv+" Date: Mon, 30 Mar 2026 10:45:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774867557; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t+VU2JEp14RQ276zwUg3zv9jk/1+oeg3KF45jEeTSEU=; b=EopisGJtIG+wqK5B51jNfY7JMZ6vmbjg0Z+VUQBHsSw9OUwy/M/IVNCpBi1hOb9tWgc10F AOx9emoQ3DnUapjOGins6PWb55CHYahmPfDivctOimPEHmfCWdKx+MfOJ/rRmf4Ty7MzS1 BDRBthJU73yqs57mlfbV9rAulV+BCy0eeORKev3gTiAnLlo/YPdTx7C9m01kY/O7eYTg46 D62JJ6y4YXR+rzJKQaJAuGF+Oa9/7qH4tBQGgIC5IsY7jupzqnzZ0wSXDUMAPQ+dUU/ZN/ W62/syWDCOOt6THQAokUoSB32wVTUvsOKwUopBRM2wJ+VnN/f6fiNcPJVWBcrg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774867557; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t+VU2JEp14RQ276zwUg3zv9jk/1+oeg3KF45jEeTSEU=; b=YTSgjPv+L6LdWFVD6h7p8X0q6fGW2QXKPvGBghVumqmTFLLzivuXVuaXTtyElsk8LiJRGI I2a2n1iryqKgnsDA== From: "tip-bot2 for Tom Lendacky" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/sev] crypto/ccp: Update HV_FIXED page states to allow freeing of memory Cc: Tom Lendacky , "Tycho Andersen (AMD)" , "Borislav Petkov (AMD)" , Herbert Xu , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260324161301.1353976-8-tycho@kernel.org> References: <20260324161301.1353976-8-tycho@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177486755542.1647592.10693490749430273843.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/sev branch of tip: Commit-ID: c3aa64ab6a5ea553ee70526579908936a3ff9392 Gitweb: https://git.kernel.org/tip/c3aa64ab6a5ea553ee70526579908936a= 3ff9392 Author: Tom Lendacky AuthorDate: Tue, 24 Mar 2026 10:13:01 -06:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 30 Mar 2026 12:10:05 +02:00 crypto/ccp: Update HV_FIXED page states to allow freeing of memory After SNP is disabled, any pages allocated as HV_FIXED can now be freed. Update the page state of these pages and the snp_leak_hv_fixed_pages() function to free pages on SNP_SHUTDOWN. Signed-off-by: Tom Lendacky Signed-off-by: Tycho Andersen (AMD) Signed-off-by: Borislav Petkov (AMD) Acked-by: Herbert Xu Link: https://patch.msgid.link/20260324161301.1353976-8-tycho@kernel.org --- drivers/crypto/ccp/sev-dev.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index cc5c5b3..57f3547 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -1219,7 +1219,7 @@ static void snp_add_hv_fixed_pages(struct sev_device = *sev, struct sev_data_range =20 static void snp_leak_hv_fixed_pages(void) { - struct snp_hv_fixed_pages_entry *entry; + struct snp_hv_fixed_pages_entry *entry, *nentry; =20 /* List is protected by sev_cmd_mutex */ lockdep_assert_held(&sev_cmd_mutex); @@ -1227,10 +1227,16 @@ static void snp_leak_hv_fixed_pages(void) if (list_empty(&snp_hv_fixed_pages)) return; =20 - list_for_each_entry(entry, &snp_hv_fixed_pages, list) - if (entry->page_state =3D=3D HV_FIXED) + list_for_each_entry_safe(entry, nentry, &snp_hv_fixed_pages, list) { + if (entry->free && entry->page_state !=3D HV_FIXED) + __free_pages(entry->page, entry->order); + else __snp_leak_pages(page_to_pfn(entry->page), 1 << entry->order, false); + + list_del(&entry->list); + kfree(entry); + } } =20 bool sev_is_snp_ciphertext_hiding_supported(void) @@ -2077,6 +2083,7 @@ static int __sev_snp_shutdown_locked(int *error, bool= panic) if (data.x86_snp_shutdown) { if (!panic) snp_shutdown(); + snp_hv_fixed_pages_state_update(sev, ALLOCATED); } else { /* * SNP_SHUTDOWN_EX with IOMMU_SNP_SHUTDOWN set to 1 disables SNP