From nobody Thu Apr 2 02:52:35 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 BAEE63C3450; Mon, 30 Mar 2026 10:46:05 +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=1774867567; cv=none; b=hkRr8XFi+QzQM1p32A85bcpJBRCOBpPH3vOvj89SqjHMgO2Yt8a83txX27tKaEX7mW7ChJn10iRQhSpR9mof6parH30E2+eAPPPy1WwSF8uXXRP6g6oTz8ElzzRmU9hBt5PPfVjaWtjosG6Wkiq+1l4TpWwaaGkkrilkTKQXsz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774867567; c=relaxed/simple; bh=U0pz+SSUhvDl1dcqDStPwPkI0si86B1ac5zbs0g7Fns=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=X5kdxlhWcn5iRwp0Aqop6wZi3YAUfwYkKO1AAju+ATw/XkUhhnttaZ4vcF8bonX0sQ6ZK6yK23PWQpNHrSb1c2pVXNih0tNJdkT8v3wNfHyEkc5RLh2FWH8scd3Hs6qkkZFl1b88GO285VpbXFsOiM5h98YlmyUGaX/ZjqEKr/o= 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=pJAwBinB; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=vUiOlZqB; 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="pJAwBinB"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="vUiOlZqB" Date: Mon, 30 Mar 2026 10:46:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774867564; 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=L1+KP2CmE19I2nfjvOYfk0vpdA4v6EHi1OXR4ASia0w=; b=pJAwBinBWtYguvy1KFyGoZ//03qg9Vijvf3P1+jYeiVmeMxs1D/gmO0n0Z8uavkMgAaAqG tlxdTSnW2NyOiJ8ZmiZXHxMecPxUvYY6j+legtVyB3MeziTfqPa+/rWO9zydB8qABi3f2l olP2jQgwdb+JxkKEwfmmxIPNL/9am77NuzDNLk9D9WQseFzYi7k7saqcOnUtop81Z9wG8q QbOLS58nUYq8XUp95/cjRIH7iD6LBPeofSXprEmkSTjTZPs6APM862U7I8KyJ4h4oOOysJ e8MAfUUUmcCb/61CUWSTvrJeO03fADpCY3ymyReXNYtuZEVtG6xEyXxoV3RURw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774867564; 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=L1+KP2CmE19I2nfjvOYfk0vpdA4v6EHi1OXR4ASia0w=; b=vUiOlZqB9HY/OlR6N+4zoqUDozQEfr26gmPNSZGQHC3UiR3D+etRmM6Hi06Fwsf29GpSt+ +HOoWQkUnn1ZiICg== 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] x86/sev: Create a function to clear/zero the RMP Cc: Tom Lendacky , "Tycho Andersen (AMD)" , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260324161301.1353976-2-tycho@kernel.org> References: <20260324161301.1353976-2-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: <177486756300.1647592.15186160945562141759.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: 9c016c3f4928f436b9ad20f30a5a9d538490fbb4 Gitweb: https://git.kernel.org/tip/9c016c3f4928f436b9ad20f30a5a9d538= 490fbb4 Author: Tom Lendacky AuthorDate: Tue, 24 Mar 2026 10:12:55 -06:00 Committer: Borislav Petkov (AMD) CommitterDate: Sat, 28 Mar 2026 22:10:56 +01:00 x86/sev: Create a function to clear/zero the RMP In preparation for delayed SNP initialization and disablement on shutdown, create a function, clear_rmp(), that clears the RMP bookkeeping area and the RMP entries. Signed-off-by: Tom Lendacky Signed-off-by: Tycho Andersen (AMD) Signed-off-by: Borislav Petkov (AMD) Link: https://patch.msgid.link/20260324161301.1353976-2-tycho@kernel.org --- arch/x86/virt/svm/sev.c | 41 ++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c index e35fac0..0256069 100644 --- a/arch/x86/virt/svm/sev.c +++ b/arch/x86/virt/svm/sev.c @@ -242,6 +242,32 @@ void __init snp_fixup_e820_tables(void) } } =20 +static void clear_rmp(void) +{ + unsigned int i; + u64 val; + + if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP)) + return; + + /* Clearing the RMP while SNP is enabled will cause an exception */ + rdmsrq(MSR_AMD64_SYSCFG, val); + if (WARN_ON_ONCE(val & MSR_AMD64_SYSCFG_SNP_EN)) + return; + + memset(rmp_bookkeeping, 0, RMPTABLE_CPU_BOOKKEEPING_SZ); + + for (i =3D 0; i < rst_max_index; i++) { + struct rmp_segment_desc *desc; + + desc =3D rmp_segment_table[i]; + if (!desc) + continue; + + memset(desc->rmp_entry, 0, desc->size); + } +} + static bool __init alloc_rmp_segment_desc(u64 segment_pa, u64 segment_size= , u64 pa) { u64 rst_index, rmp_segment_size_max; @@ -484,7 +510,6 @@ static bool __init setup_rmptable(void) */ int __init snp_rmptable_init(void) { - unsigned int i; u64 val; =20 if (WARN_ON_ONCE(!cc_platform_has(CC_ATTR_HOST_SEV_SNP))) @@ -504,19 +529,7 @@ int __init snp_rmptable_init(void) if (val & MSR_AMD64_SYSCFG_SNP_EN) goto skip_enable; =20 - /* Zero out the RMP bookkeeping area */ - memset(rmp_bookkeeping, 0, RMPTABLE_CPU_BOOKKEEPING_SZ); - - /* Zero out the RMP entries */ - for (i =3D 0; i < rst_max_index; i++) { - struct rmp_segment_desc *desc; - - desc =3D rmp_segment_table[i]; - if (!desc) - continue; - - memset(desc->rmp_entry, 0, desc->size); - } + clear_rmp(); =20 /* MtrrFixDramModEn must be enabled on all the CPUs prior to enabling SNP= . */ on_each_cpu(mfd_enable, NULL, 1);