From nobody Tue Feb 10 09:24:52 2026 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 3DFE71922D8 for ; Mon, 25 Nov 2024 10:08:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732529316; cv=none; b=lTIDHOee1D4R2hesEXQ/CAa+McdAG5W4Nze2cp/zIc0wU31s5YVPF4x3KgPPZ9I4fE40++GBeZkrq+4moa0SnJkIk8IY0bjT0ZDw7k1sJTU3c4Q2UQsjcXetZXeyfZMo488P/lPGEHBGJszTvfKkcLbpxkcR18rjcQA/0lTDPSM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732529316; c=relaxed/simple; bh=Jszb8KFN5GzjUkCQ/IcBcaFlVglAOixLKBZmKX8ltN8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A5BohIfc46PjFqdTWyItL6ScPVEd0BntmnrQ9ou2MPGdg2HJ6ilMYJCEvbDSSRSoJyVbL7H5F7bqUo3Emp05uvrCo7rNrGdlMGX7RWmNxs0xv6pK/RY3ox2CyZR346xyB8GTwnAM+8mBA5SHHfZtc59MYU3NB0dQ6NLc5TsNbF8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=desiato.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=hl7HZe6X; arc=none smtp.client-ip=90.155.92.199 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=desiato.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="hl7HZe6X" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=AbThuJMqNCEqi5OCJ2hHO8LahRmj/ISCryb2ADbdx9M=; b=hl7HZe6XNECC9SLo6l+H6IsEXG ZDpSWlnbxn01Fp3GwGSOSwfANQWaYPMaHG0BfDEYH6cAvbP50AAWHTzRlSNKap66Ogrg0klOC9wwG ezBtIewnTuHGYyPF9p6n1f1oI4Zgxpd6Gs3aSSJagXsFKhKpAo53r0Gzyh2uwRe/pNWsqu5mKXAz3 hn1mhZgI3yPxzNYLFn66Lg30u3XhYO4vkpwJpE1yJbguQRb8lSx7UQ5Ys9PrbwmbCJNHuSn/lmblH oIx6dQnUseIWQx+TIO0nCNNpmn59npEMaRObFE1S/ZFAUGHStul8M0FUjnz/uDKX1CoZ5dTMDeoqN PbdmQP4Q==; Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by desiato.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tFW11-000000014f6-03EJ; Mon, 25 Nov 2024 10:08:23 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tFW0z-000000000l2-1p3F; Mon, 25 Nov 2024 10:08:21 +0000 From: David Woodhouse To: kexec@lists.infradead.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , David Woodhouse , "Kirill A. Shutemov" , Kai Huang , Nikolay Borisov , linux-kernel@vger.kernel.org, Simon Horman , Dave Young , Peter Zijlstra , jpoimboe@kernel.org, bsz@amazon.de Subject: [RFC PATCH v3 05/20] x86/kexec: Only swap pages for preserve_context mode Date: Mon, 25 Nov 2024 09:54:35 +0000 Message-ID: <20241125100815.2512-6-dwmw2@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241125100815.2512-1-dwmw2@infradead.org> References: <20241125100815.2512-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 desiato.infradead.org. See http://www.infradead.org/rpr.html Content-Type: text/plain; charset="utf-8" From: David Woodhouse There's no need to swap pages (which involves three memcopies for each page) in the plain kexec case. Just do a single copy from source to destination page. Signed-off-by: David Woodhouse --- arch/x86/kernel/relocate_kernel_64.S | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocat= e_kernel_64.S index fea650f92606..50cc33f2ecb7 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -310,6 +310,9 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages) movq %rdi, %rdx /* Save destination page to %rdx */ movq %rsi, %rax /* Save source page to %rax */ =20 + testq %r11, %r11 /* Only actually swap for preserve_context */ + jz .Lnoswap + /* copy source page to swap page */ movq %r10, %rdi movl $512, %ecx @@ -324,6 +327,7 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages) /* copy swap page to destination page */ movq %rdx, %rdi movq %r10, %rsi +.Lnoswap: movl $512, %ecx rep ; movsq =20 --=20 2.47.0