From nobody Sun Nov 24 21:33:25 2024 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 145451531CC for ; Sun, 3 Nov 2024 05:40:44 +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=1730612446; cv=none; b=A9naq4KAHSSLhiPybH9dM6ekXoXSwtZOnIkXx+h7LvN8tdpG4k8/FvH0YNTFDgYx65EGdww/XDbSGryCQ2sUho7lEIw4igX8qdcem2PqlkkWiObIqWlUbCtgl0npCc8Mqcc2TdY9Fr1wrLrK7srH8Pin+WallF7igzJtAQsXbsw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730612446; c=relaxed/simple; bh=3jKXr8+uj4T9k+ibhY4/UveZxPJppdSPbV3QgYP1dDI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fRvOt0XDiDP611omz4iZ3iLdIVEorCEadNd14kqlx7F6tG25vWKWAEV8y+v/LUYJgaFCmcL0d3xIxw5uHeF7tefxYVAyH9zj9WzyUXSxRu3poW7sCNUtNDDqut0YqyM/V8ywmfGWB3+hqGLGzjgWYwEEORw47B3SfQ6ta3+GPdc= 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=tzF/f4Z7; 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="tzF/f4Z7" 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:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=EAnjyRllEKGF0bSHoHw2dKzQG9JAUcHgHIvCWu8G9Wg=; b=tzF/f4Z7GbwLXKV6nLIyILNUb3 wCwGmvdvZCNmyTD4Jp7WHkgUt6nW0fnmcY/k4XiTBruK0dMYD/NnIn7w3rdr+90UVl8ylBycDzHEJ ck7p1ufEdGR470rfRe6oYAMc99X1eTt02mrFnm6KYf8TtLbCNluI+pnMhFRrZJmOCu1+TnWuVJVUQ ZaQF/8Y+29Fnd+LDJOszZZcb4a/LqGyjvHV8NZIfDVPCtbw6S02+K9XJ9xuIH2HJSOEyWIo+6RDNg 8gwIqJLB9zqA5orFYN++RcfD55/z7pAqKMuIo2kAE/lGbfb/yLm6PaaYa8Em6/LpEZ3azKbd5+ndS awWJYTPA==; 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 1t7TLa-0000000HSiM-2Nhs; Sun, 03 Nov 2024 05:40:23 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1t7TLa-0000000FvLH-3pEI; Sun, 03 Nov 2024 05:40:22 +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 Subject: [RFC PATCH 3/7] x86/kexec: Only swap pages for preserve_context mode Date: Sun, 3 Nov 2024 05:35:28 +0000 Message-ID: <20241103054019.3795299-4-dwmw2@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241103054019.3795299-1-dwmw2@infradead.org> References: <20241103054019.3795299-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 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 e607c0b7d70b..9b6ed08e00ea 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -302,6 +302,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 */ + jnz .Lnoswap + /* copy source page to swap page */ movq %r10, %rdi movl $512, %ecx @@ -316,6 +319,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.44.0