From nobody Thu Apr 9 07:17:15 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 CFBB33314D2; Tue, 10 Mar 2026 10:47:04 +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=1773139626; cv=none; b=FOMHh/o2Te9QX/4Zowzlsi6nO15sReQJH8yAol7EPUlu0OKqs17867XY0WYgCRbq/nAtDX18zlRM/GBtMeG2aYX7aIRal+JL/BpcAMuDZW6UrcM/v0BbbAze3XDJEw7ywRXeANG9GvL5V3ixedb5B+yirwCdC/SlijFMYukMSzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773139626; c=relaxed/simple; bh=vgbN+Xv30GV8m0gMlRSe5YIinDwOqR2yL9EcNaVXL6o=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=SQ5nFW7bRAZZhunpXg1885IsdlxREaJyZosdRfJBmL+yN14IPBCMyP3bGZVraDG917c3DHSM104qwOXHz2qgzkOVHyesJcRnqA2eh84PLxrv9eQPeNrH3AdP30AeGhUPT/homiZWmQSjKpjj589lbBEAf7DGsAx+HCe3YTBAi+g= 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=UBadMTKp; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=sK4OWPgk; 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="UBadMTKp"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="sK4OWPgk" Date: Tue, 10 Mar 2026 10:47:00 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1773139622; 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=wlW3xYAtCJU4+CUKDQeeLlLCm9R1uM2Sw6dNJX+daCk=; b=UBadMTKpM4WQIj2RFg8AoX7s6WUb5MOfJwc09yQeKBdov/5GGezs4JlFixad1+qh0usPrP fOZcvoB+dRdhpn0TFutp+iyIBqL2+BHuuEBaXbB0ssyF044MD7h7S2DSUrH/lOlwdaoaDv LzKbrc21FfHMHf9wTyS53Wj8TPD4nusXdRIvbpKhUPl11dPxUi4Egg74Kc2RgZOY1HUHVg AE3BUlmw+Qubh0poBVegD9FANIbmf4imQb7kvzyWiHXjMqmSLYEbgkgxK2J9F3FrsZOMsF CGdOUigOLqcKZkJXoOey+RNCNR4pApk4HQTyWMwgHYUc9ZooSoqw10fuKwa3Fg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1773139622; 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=wlW3xYAtCJU4+CUKDQeeLlLCm9R1uM2Sw6dNJX+daCk=; b=sK4OWPgk+ZJ7X8zX47MpwW2ZKD1bS5YsLonwL7U/a2T0j9o5DQsQ+c/bMqBlS9Id8GF9XT p2FQxtRQ0b5PNFBg== 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/virt/sev: Keep the RMP table bookkeeping area mapped Cc: Tom Lendacky , "Tycho Andersen (AMD)" , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260309180053.2389118-4-tycho@kernel.org> References: <20260309180053.2389118-4-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: <177313962084.1647592.14731210923889273321.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: cca149429956745293ea94865ff8be6f77cc003d Gitweb: https://git.kernel.org/tip/cca149429956745293ea94865ff8be6f7= 7cc003d Author: Tom Lendacky AuthorDate: Mon, 09 Mar 2026 12:00:45 -06:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 09 Mar 2026 21:49:18 +01:00 x86/virt/sev: Keep the RMP table bookkeeping area mapped In preparation for delayed SNP initialization and disablement on shutdown, = the RMP will need to be cleared each time SNP is disabled. Maintain the mapping= to the RMP bookkeeping area to avoid mapping and unmapping it each time and any possible errors that may arise from that. Signed-off-by: Tom Lendacky Signed-off-by: Tycho Andersen (AMD) Signed-off-by: Borislav Petkov (AMD) Link: https://patch.msgid.link/20260309180053.2389118-4-tycho@kernel.org --- arch/x86/virt/svm/sev.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c index 5e07f10..e35fac0 100644 --- a/arch/x86/virt/svm/sev.c +++ b/arch/x86/virt/svm/sev.c @@ -117,6 +117,8 @@ static u64 rmp_segment_mask; =20 static u64 rmp_cfg; =20 +static void *rmp_bookkeeping __ro_after_init; + /* Mask to apply to a PFN to get the first PFN of a 2MB page */ #define PFN_PMD_MASK GENMASK_ULL(63, PMD_SHIFT - PAGE_SHIFT) =20 @@ -240,23 +242,6 @@ void __init snp_fixup_e820_tables(void) } } =20 -static bool __init clear_rmptable_bookkeeping(void) -{ - void *bk; - - bk =3D memremap(probed_rmp_base, RMPTABLE_CPU_BOOKKEEPING_SZ, MEMREMAP_WB= ); - if (!bk) { - pr_err("Failed to map RMP bookkeeping area\n"); - return false; - } - - memset(bk, 0, RMPTABLE_CPU_BOOKKEEPING_SZ); - - memunmap(bk); - - return true; -} - static bool __init alloc_rmp_segment_desc(u64 segment_pa, u64 segment_size= , u64 pa) { u64 rst_index, rmp_segment_size_max; @@ -474,10 +459,22 @@ e_free: static bool __init setup_rmptable(void) { if (rmp_cfg & MSR_AMD64_SEG_RMP_ENABLED) { - return setup_segmented_rmptable(); + if (!setup_segmented_rmptable()) + return false; } else { - return setup_contiguous_rmptable(); + if (!setup_contiguous_rmptable()) + return false; } + + rmp_bookkeeping =3D memremap(probed_rmp_base, RMPTABLE_CPU_BOOKKEEPING_SZ= , MEMREMAP_WB); + if (!rmp_bookkeeping) { + pr_err("Failed to map RMP bookkeeping area\n"); + free_rmp_segment_table(); + + return false; + } + + return true; } =20 /* @@ -508,10 +505,7 @@ int __init snp_rmptable_init(void) goto skip_enable; =20 /* Zero out the RMP bookkeeping area */ - if (!clear_rmptable_bookkeeping()) { - free_rmp_segment_table(); - return -ENOSYS; - } + memset(rmp_bookkeeping, 0, RMPTABLE_CPU_BOOKKEEPING_SZ); =20 /* Zero out the RMP entries */ for (i =3D 0; i < rst_max_index; i++) {