From nobody Thu Dec 18 00:06:28 2025 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 251C721B1A7 for ; Thu, 9 Jan 2025 14:08:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736431717; cv=none; b=VAGtJgZyqnwhjBr2sC3C2HWVJ6Ml/rGaeAmwZYX7tuO05CCIIvFisi/vjDSYYSHwIwiO2O1sUtSaOiMIiI0pGq7wvszUhhEQIEV8BRFT4+JRK43KCikoyZ33ktulKSZ8xP2VIRr4uXw+GDYEdV5PhhD3ADBANTZRQB84CE5qeQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736431717; c=relaxed/simple; bh=g/Tb1scAluPn+1pgI2bFIEcG4fxvjCU1ZiUBIcliJgc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SJcPgEhHpJkfwZyHnKG/aR+5IR0plt3qMgO01n5qCNqPzzv9a9mIO3bBirWOBGwt4eQazfCRjhrzwYj3gu6Gx7wviXUomGe0b/sievJohteJ6vPUUzc7Gixci3ZblVpfHoLK+5tE/pD25nxSIAvgB3Ml0rAzFV3tNPWu/VbU15Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=casper.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=X10vdTEH; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=casper.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="X10vdTEH" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:To:From:Reply-To: Cc:Content-Type:Content-ID:Content-Description; bh=4GPX4uH5hPGTEsJKbCTX7Iw1UzlZ9qs8SxieW1Q8mSw=; b=X10vdTEH3d8k/EovQ7NgJsE1gp /eYVbxf/SQQRz1A+vrsYn6w9+3KdWDJsWoZ3UbUl17CWnLRKk1AUfECnEo9/hWsD0L4CxBHoaQHiz Ooh7xWg0e7BAgsTKQXg3cCmMz7dl2xaeDxYSYNYJgS46pjdMw/eaaJ80+Kxt4YFM8w8Uh4+R9FBBQ wAcV08AjhrsBWj5E1+bvokq5Nke3q4hjHOxSbBRJpo5/HLGARwDXMV+qlozDq0U7pu7LnyNPceJCL Av6pBMgufuj8o2vg5svMeqVFOU+t5S0gPekQZ/JY02Zz3k6RjPhlkuoB3VTns9eNRPUQv0bFz53pf D29t6BpQ==; Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by casper.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tVtCZ-00000006IQG-2Uet; Thu, 09 Jan 2025 14:07:59 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tVtCY-0000000Bx5x-2Ygt; Thu, 09 Jan 2025 14:07:58 +0000 From: David Woodhouse To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Eric Biederman , David Woodhouse , Sourabh Jain , Hari Bathini , Michael Ellerman , Thomas Zimmermann , Andrew Morton , Baoquan He , Yuntao Wang , David Kaplan , Tao Liu , "Kirill A . Shutemov" , Kai Huang , Ard Biesheuvel , Josh Poimboeuf , Breno Leitao , Wei Yang , Rong Xu , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kernel@vger.kernel.org, kexec@lists.infradead.org, Simon Horman , Dave Young , Peter Zijlstra , bsz@amazon.de, nathan@kernel.org Subject: [PATCH v2 2/9] x86/kexec: Ensure preserve_context flag is set on return to kernel Date: Thu, 9 Jan 2025 14:04:14 +0000 Message-ID: <20250109140757.2841269-3-dwmw2@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250109140757.2841269-1-dwmw2@infradead.org> References: <20250109140757.2841269-1-dwmw2@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Content-Type: text/plain; charset="utf-8" From: David Woodhouse The swap_pages function will only actually *swap*, as its name implies, if the preserve_context flag in the %r11 register is non-zero. On the way back from a ::preserve_context kexec, ensure that the %r11 register is non-zero so that the pages get swapped back. Fixes: 9e5683e2d0b5 ("x86/kexec: Only swap pages for ::preserve_context mod= e") Signed-off-by: David Woodhouse --- arch/x86/kernel/relocate_kernel_64.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocat= e_kernel_64.S index 9bd601dd8659..6fce4b459652 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -220,6 +220,7 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped) movq kexec_pa_table_page(%rip), %rax movq %rax, %cr3 lea PAGE_SIZE(%r8), %rsp + movl $1, %r11d /* Ensure preserve_context flag is set */ call swap_pages movq kexec_va_control_page(%rip), %rax addq $(virtual_mapped - relocate_kernel), %rax --=20 2.47.0