From nobody Sun Nov 24 19:20:40 2024 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 8732816849F for ; Sun, 3 Nov 2024 05:40:52 +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=1730612454; cv=none; b=dli43MTVtLZCjg00UFRFO4xmrVCv9UYAp7rKt8f8Nl15xu83UFJrGPGnFLjHyPJynMtq9eStM4fe+uYoaDd15Nu9LbLU4RaLPUuaXsOevduFhSzzO/b43DWpozzGQVuRNcyIybeUDz1j2E7NVlGKCqAZj6BLPKbKzI0Q7VbydEM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730612454; c=relaxed/simple; bh=lxdlDTIKoz0IVHJ/XpoozLbAx51ZVaHrnOahKZMN/9w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z5o1MTJHL16+3xgKa5UWzRNTgbbj9ID61RAJepS/u3CLD6mVRsftObXpIc6TxQECcUZMKvXr0qn4hGwoIdmZ/11mM7UrpHjjs/v7ELhAX+88C8xPgE1FTFQyie/1bzgnMt3i6/krYscqiqV2vWnAIMJAeKU8OTsdC1kevSjJJ1Y= 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=C7uD+miH; 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="C7uD+miH" 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=ZdZ+nlAayZckzp2Spz6rpIxa9MO+4/e+5j0I1vjYVzw=; b=C7uD+miHpdzhuY8kUB3Jx01O1r yAObd9yToflETXCD8JZVihND7D94qZx3ypGkLw4xgVPaICWvF5pfN3Wlf7ASg+NPiQDmO6N0QDplJ +WYz2QC1k+JQLhsKeCx1L78DSaHCbcBfvE9LjFDESocunEi68Lm3u6dPit8ZRsm6q+8K3tvefWxQC RzCTbUSDTB9TErCocvuHGJ3Oo7vc43UbVExPx++YTG25Lc/7nICWtIRIoRlgugRRszoBSSEJ7f9bJ e8/3pSQNIX2ULMdzcc8F0sydMW/q/c/j3HS51E8hp1pAtzOrbK+yd1SV7hpvQW9DTPRk+/pUcmXVA qHmfjxCA==; 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 1t7TLb-0000000B4NU-46Mw; Sun, 03 Nov 2024 05:40:38 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1t7TLa-0000000FvL9-3Dh7; 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 1/7] x86/kexec: Clean up and document register use in relocate_kernel_64.S Date: Sun, 3 Nov 2024 05:35:26 +0000 Message-ID: <20241103054019.3795299-2-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 desiato.infradead.org. See http://www.infradead.org/rpr.html Content-Type: text/plain; charset="utf-8" From: David Woodhouse Add more comments explaining what each register contains, and save the preserve_context flag to a non-clobbered register sooner, to keep things simpler. Signed-off-by: David Woodhouse Acked-by: Kai Huang --- arch/x86/kernel/relocate_kernel_64.S | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocat= e_kernel_64.S index e9e88c342f75..c065806884f8 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -100,6 +100,9 @@ SYM_CODE_START_NOALIGN(relocate_kernel) movq %r10, CP_PA_SWAP_PAGE(%r11) movq %rdi, CP_PA_BACKUP_PAGES_MAP(%r11) =20 + /* Save the preserve_context to %r11 as swap_pages clobbers %rcx. */ + movq %rcx, %r11 + /* Switch to the identity mapped page tables */ movq %r9, %cr3 =20 @@ -116,6 +119,13 @@ SYM_CODE_END(relocate_kernel) =20 SYM_CODE_START_LOCAL_NOALIGN(identity_mapped) UNWIND_HINT_END_OF_STACK + /* + * %rdi indirection page + * %rdx start address + * %r11 preserve_context + * %r12 host_mem_enc_active + */ + /* set return address to 0 if not preserving context */ pushq $0 /* store the start address on the stack */ @@ -170,8 +180,6 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped) wbinvd .Lsme_off: =20 - /* Save the preserve_context to %r11 as swap_pages clobbers %rcx. */ - movq %rcx, %r11 call swap_pages =20 /* @@ -183,13 +191,14 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped) movq %cr3, %rax movq %rax, %cr3 =20 + testq %r11, %r11 /* preserve_context */ + jnz .Lrelocate + /* * set all of the registers to known values * leave %rsp alone */ =20 - testq %r11, %r11 - jnz .Lrelocate xorl %eax, %eax xorl %ebx, %ebx xorl %ecx, %ecx --=20 2.44.0 From nobody Sun Nov 24 19:20:40 2024 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 12CEF1632C6 for ; Sun, 3 Nov 2024 05:40:48 +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=1730612450; cv=none; b=MkgDIyoDkMyDxvUzqh1caftf1AyX1LVIvvv5KQVUpF9St5Wi+8CMTXxcXANAABf5zhogasys6Em5wpSZYEbJGx+ncoNNc8WfqHfqYukXiMZ/92KW+izgvVA5o95OneEYFigIh20LMnBLsdYZlS7LC2q9bTWtDBpGBh8D+Nz4ahI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730612450; c=relaxed/simple; bh=K1KWT/E7FsmLJnCOu1yHk/7CDe49pdoiyXXYyMdh1tE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rfSmjWv2BHl7ohbPI6IyH6th0UkkbGn9o8ilfhS806Fq7kuHpUSvJdjs/SQk0x8bAAOLAzAzV94O7+PPS4w94Cggut9y8NH8AWLR9WAJMS7cSLlZRnqH6RKNJe5PsmTLrx/MbZ58+JGHRKc6oFyA/knQSiSyF7/coXqdAEVZQ+Q= 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=AtBu14Me; 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="AtBu14Me" 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=KE2zAg0FNUcZu2wRX0Sf0y9yX7Pxf0UAIJCxTS4zamA=; b=AtBu14MeLBRdSkyzOtDpgPhJNB 3hRjG+jBwG+OKjW8af0r6qd4L4MDNIOc9HpqqPZ6yqOwYyY/c+4tNlHrdAdxCEpQtByhqUtTRbUFS 3ADKuLdlOc9fIaltzvdx22MV5t9wu9BRlTxF8Sziq63nS8xaLvhz9f2ZIdSdtxeBOCqj9ePDB/tfc oUwmFYQQ8Jir37/ai4G1WvXIXH4q2VoRyTU0JAkUu/vlotzyEBNfCoRI0QLDmibi9fbrVVa86tqjJ RbcloQZ6NiU8XMnJcYS6Sd1br20KFH4wTmITi5uORr80C90Fr39NU7StdRRpNpGREsP7fqQdfORZ9 +LFYmD2A==; 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 1t7TLb-0000000B4NV-45eL; Sun, 03 Nov 2024 05:40:29 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1t7TLa-0000000FvLD-3WY6; 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 2/7] x86/kexec: Use named labels in swap_pages in relocate_kernel_64.S Date: Sun, 3 Nov 2024 05:35:27 +0000 Message-ID: <20241103054019.3795299-3-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 desiato.infradead.org. See http://www.infradead.org/rpr.html Content-Type: text/plain; charset="utf-8" From: David Woodhouse Make the code a little more readable. Signed-off-by: David Woodhouse Acked-by: Kai Huang --- arch/x86/kernel/relocate_kernel_64.S | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocat= e_kernel_64.S index c065806884f8..e607c0b7d70b 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -271,31 +271,31 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages) movq %rdi, %rcx /* Put the indirection_page in %rcx */ xorl %edi, %edi xorl %esi, %esi - jmp 1f + jmp .Lstart /* Should start with an indirection record */ =20 -0: /* top, read another word for the indirection page */ +.Lloop: /* top, read another word for the indirection page */ =20 movq (%rbx), %rcx addq $8, %rbx -1: +.Lstart: testb $0x1, %cl /* is it a destination page? */ - jz 2f + jz .Lnotdest movq %rcx, %rdi andq $0xfffffffffffff000, %rdi - jmp 0b -2: + jmp .Lloop +.Lnotdest: testb $0x2, %cl /* is it an indirection page? */ - jz 2f + jz .Lnotind movq %rcx, %rbx andq $0xfffffffffffff000, %rbx - jmp 0b -2: + jmp .Lloop +.Lnotind: testb $0x4, %cl /* is it the done indicator? */ - jz 2f - jmp 3f -2: + jz .Lnotdone + jmp .Ldone +.Lnotdone: testb $0x8, %cl /* is it the source indicator? */ - jz 0b /* Ignore it otherwise */ + jz .Lloop /* Ignore it otherwise */ movq %rcx, %rsi /* For ever source page do a copy */ andq $0xfffffffffffff000, %rsi =20 @@ -320,8 +320,8 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages) rep ; movsq =20 lea PAGE_SIZE(%rax), %rsi - jmp 0b -3: + jmp .Lloop +.Ldone: ANNOTATE_UNRET_SAFE ret int3 --=20 2.44.0 From nobody Sun Nov 24 19:20:40 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 From nobody Sun Nov 24 19:20:40 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 45D2D70833 for ; Sun, 3 Nov 2024 05:40:42 +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=1730612443; cv=none; b=WZ72JSWg/cEd0pzcGz8aEzkDplNEeCFxbfaMbpTnEvloTj7+2lbIDa1IBHRZm1YYHWm5cxbym0wOwZQDEf1J4TtjNtaOTRjGSWj4ghFgXQYOD0QWL4wVEQAakv1r3neXr6l0t3JNl/Y6OZCRJHT3Wz4AttGBhaQ9scU0PZVIt+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730612443; c=relaxed/simple; bh=TU9+UXf7+RHIl2GCb3qmVvh9GSTfxpS2NpMu5EjjhVQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rd5YhnSnM/erPjxYCLCitVCNXhuCgGz7kxuJXe6eKPyAlLluoCI6cPmjEo/Wp7MalR5C9eOKJRJ44Gxc7CCgeYQXzZKItYB6K29ETyLG4gqINUsJoP7ssOfsiSq+7S6qRYNVYydB+8ebDI+I/KQz65LDPMzDxWLZIrufssgiRVs= 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=jO9C1c79; 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="jO9C1c79" 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=b9tRHLeN7pxr2xLddlnhC83jvrEl3kzVd1otLRBzbTE=; b=jO9C1c79487FhflAUbwCJXVvep IS2n0bhmHSa0v4UNoWe/2n9mZpNuTvAoBh+a6iE+2qJIoJ5RCVK1Yb3Y/F28Of9qEVlH2Nkme22eD MmdptXVsZXviyiN7cPhxIwAiatf1M4w7DH1STwE4AFwZkl4VVybStgt0rfPaoUgDJ5V74WFtlJuJ1 tUCLZ5Q2obhJgUyNNiqNF0FvgbxzVzHTTUWlsd3ryjyaDToXWuMBJk7x3p60VkG/11V3L4TXdMO+V TbpFwFHmNMQaDRgrB4xHChR6ZWdx3UGuxnpTIdzsp30qH/fFv/8KMiXdFbnvEBamgKGI45dUK9SSr Pxld+mCQ==; 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-0000000HSiN-2SWN; 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-0000000FvLL-3x2L; 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 4/7] x86/kexec: Debugging support: load a GDT Date: Sun, 3 Nov 2024 05:35:29 +0000 Message-ID: <20241103054019.3795299-5-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 are some failure modes which lead to triple-faults in the relocate_kernel function, which is fairly much undebuggable for normal mortals. Adding a GDT in the relocate_kernel environment is step 1 towards being able to catch faults and do something more useful. Signed-off-by: David Woodhouse --- arch/x86/kernel/relocate_kernel_64.S | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocat= e_kernel_64.S index 9b6ed08e00ea..2af4ce593645 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -131,6 +131,21 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped) /* store the start address on the stack */ pushq %rdx =20 +#ifdef DEBUG + /* Create a GDTR (16 bits limit, 64 bits addr) on stack */ + leaq .Lreloc_kernel_gdt(%rip), %r8 + pushq %r8 + pushw (%r8) + + /* Load the GDT, put the stack back */ + lgdt (%rsp) + addq $10, %rsp + + /* Test that we can load segments */ + movq %ds, %rax + movq %rax, %ds +#endif /* DEBUG */ + /* * Clear X86_CR4_CET (if it was set) such that we can clear CR0_WP * below. @@ -331,5 +346,16 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages) int3 SYM_CODE_END(swap_pages) =20 +#ifdef DEBUG +.Lreloc_kernel_gdt: + .word 1f - .Lreloc_kernel_gdt - 1 + .long 0 + .word 0 + .quad 0x00cf9a000000ffff /* __KERNEL32_CS */ + .quad 0x00af9a000000ffff /* __KERNEL_CS */ + .quad 0x00cf92000000ffff /* __KERNEL_DS */ +1: +#endif /* DEBUG */ + .skip KEXEC_CONTROL_CODE_MAX_SIZE - (. - relocate_kernel), 0xcc SYM_CODE_END(relocate_range); --=20 2.44.0 From nobody Sun Nov 24 19:20:40 2024 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 9B951158DB9 for ; Sun, 3 Nov 2024 05:40:46 +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=1730612448; cv=none; b=owxqu7hekP/HLeijMqMHLTw6XokOq2qxvZyqhl8P2awf5wsNfDilx9vfhPcOfVCG2Z/vWeOSArIrbfBxLqo1qYLIB8F2/XrW6zDGsYSvuYe0q5ruWWSEW8nMGqfYjv/nfoLYWSrxC92YDzWwlOUGiAP+qH92hi9ATU8+RbVUY/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730612448; c=relaxed/simple; bh=/6DPqRlMBgCD87uZJerS6ebaGmyjgm2J2S4yV0UY32c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A6WuBLIVImpgwrKLWwMqif1FNrjlo6ZmB01DsYJHGm6m5RUmdt2Lpz7FBbyrjLaFnrTLpMZjKIzkBVSiXPI5s6JN5GBu9odaJhUHzoh69A5u7N1dbet11v0Sb5Tx9WLoazd2eW9lgMkYh48a2F7sQ2piv5Hk+JpmnRO3NHYgJgY= 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=jTF85dx2; 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="jTF85dx2" 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=TT41j7+YieIW7CJdU2V5YhKog/Kk/4ZOf15yuetAirQ=; b=jTF85dx2l1wpjKRQC9BuGBkjal bLBF9euKln0Owji+Yq8mzi3YccZAqy+4NNdJAvSbd3HKY37bdtDKahxWDauL+cb8Z55P0x3XOnGpH VEolZJmCeAxOruk7f5MELUtPNJI9Dj5s7U85MNWOxr08HoY3NuzSTcsipaBwVHdW5CrjmhDtpfPrg akfNXWGI0GLKHo8fir3B0zNdVPIZr/7xzVqMocHRTmlFnHlzSTYyGbRobvUcFOCGnxu+vsLLnlbwn +WW9jnQ3StiPLIi//mCsg2pqxTCPPa7E9fCczeJoKMfDelmqSHXaPDPjqgPChjXjQFpCmxf9kV0ZD lL22GM0g==; 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 1t7TLb-0000000B4NW-475z; Sun, 03 Nov 2024 05:40:34 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1t7TLa-0000000FvLP-44tq; 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 5/7] x86/kexec: Debugging support: Load an IDT and basic exception entry points Date: Sun, 3 Nov 2024 05:35:30 +0000 Message-ID: <20241103054019.3795299-6-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 desiato.infradead.org. See http://www.infradead.org/rpr.html Content-Type: text/plain; charset="utf-8" From: David Woodhouse Signed-off-by: David Woodhouse --- arch/x86/kernel/relocate_kernel_64.S | 110 +++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocat= e_kernel_64.S index 2af4ce593645..2a2a6e693e18 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -117,6 +117,11 @@ SYM_CODE_START_NOALIGN(relocate_kernel) int3 SYM_CODE_END(relocate_kernel) =20 +#ifdef DEBUG + UNWIND_HINT_UNDEFINED + .balign 0x100 /* relocate_kernel will be overwritten with an IDT */ +#endif + SYM_CODE_START_LOCAL_NOALIGN(identity_mapped) UNWIND_HINT_END_OF_STACK /* @@ -144,6 +149,52 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped) /* Test that we can load segments */ movq %ds, %rax movq %rax, %ds + + /* Load address of reloc_kernel, at start of this page, into %r8 */ + lea relocate_kernel(%rip), %r8 + + /* + * Build an IDT descriptor in %rax/%rbx. The address is in the low 16 + * and high 16 bits of %rax, and low 32 of %rbx. The niddle 32 bits + * of %rax hold the selector/ist/flags which are hard-coded below. + */ + movq %r8, %rax // 1234567890abcdef + + andq $-0xFFFF, %rax // 1234567890ab.... + shlq $16, %rax // 567890ab........ + + movq $0x8F000010, %rcx // Present, DPL0, Interrupt Gate, __KERNEL_CS. + orq %rcx, %rax // 567890ab8F000010 + shlq $16, %rax // 90ab8F000010.... + + movq %r8, %rcx + andq $0xffff, %rcx // ............cdef + orq %rcx, %rax // 90ab87000010cdef + + movq %r8, %rbx + shrq $32, %rbx + + /* + * The descriptor was built using the address of relocate_kernel. Add + * the required offset to point to the actual entry points. + */ + addq $(exc_vectors - relocate_kernel), %rax + + /* Loop 16 times to handle exception 0-15 */ + movq $16, %rcx +1: + movq %rax, (%r8) + movq %rbx, 8(%r8) + addq $16, %r8 + addq $6, %rax + loop 1b + + /* Now put an IDTR on the stack (temporarily) to load it */ + subq $0x100, %r8 + pushq %r8 + pushw $0xff + lidt (%rsp) + addq $10, %rsp #endif /* DEBUG */ =20 /* @@ -347,6 +398,65 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages) SYM_CODE_END(swap_pages) =20 #ifdef DEBUG +SYM_CODE_START_LOCAL_NOALIGN(exc_vectors) + /* Each of these is 6 bytes. */ +.macro vec_err exc + UNWIND_HINT_ENTRY + . =3D exc_vectors + (\exc * 6) + nop + nop + pushq $\exc + jmp exc_handler +.endm + +.macro vec_noerr exc + UNWIND_HINT_ENTRY + . =3D exc_vectors + (\exc * 6) + pushq $0 + pushq $\exc + jmp exc_handler +.endm + + vec_noerr 0 // #DE + vec_noerr 1 // #DB + vec_noerr 2 // #NMI + vec_noerr 3 // #BP + vec_noerr 4 // #OF + vec_noerr 5 // #BR + vec_noerr 6 // #UD + vec_noerr 7 // #NM + vec_err 8 // #DF + vec_noerr 9 + vec_err 10 // #TS + vec_err 11 // #NP + vec_err 12 // #SS + vec_err 13 // #GP + vec_err 14 // #PF + vec_noerr 15 +SYM_CODE_END(exc_vectors) + +SYM_CODE_START_LOCAL_NOALIGN(exc_handler) + pushq %rax + pushq %rdx + movw $0x3f8, %dx + movb $'A', %al + outb %al, %dx + popq %rdx + popq %rax + + /* Only return from int3 */ + cmpq $3, (%rsp) + jne .Ldie + + addq $16, %rsp + iretq + +.Ldie: + hlt + jmp .Ldie + +SYM_CODE_END(exc_handler) + .Lreloc_kernel_gdt: .word 1f - .Lreloc_kernel_gdt - 1 .long 0 --=20 2.44.0 From nobody Sun Nov 24 19:20:40 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 728B181ADA for ; Sun, 3 Nov 2024 05:40:42 +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=1730612444; cv=none; b=hdqx+lNiLbAChgquoshOpigix3Mjl4MX1oXcHvFqBK1ndm30Z5/ytmmWhsvohMvDzz17az3xYVqh7IfnjYe1Npbw0zpU1lgsaer9B9tiCC3iMH7KPzo4zeH4tSJldTtFqHV2yls7wl01VfYhMnb7Kr1Fyov/lfxlL9iSGs+DqdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730612444; c=relaxed/simple; bh=mcPNW9RX+97SvkjAMw0BjYMx28R8chRYJbWui/rrz3w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pAKHxcfR+oPw+nzjKUfXyLGKPvOP5zL6dg6yvSUNJ0Bs5BrRE69pH2tt8zyb4hLcF5zA90anAPowWk0RywuNMoYMFs8wNzgaVvX/XHUZRTyH48TCCzZXxYOqdIWjZ2zV6D0Y/78R/H/fT5amrXOTBb/VquPoFx7uAv/RiHumcbI= 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=cQVqYs3p; 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="cQVqYs3p" 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=dGAv5y7FEjvooP2pbPjjc8JKyfn+Npp1FyrVMwjJKLE=; b=cQVqYs3png18QmlyZAXVop7fPA oDBY5zwVYTsZ+PWiEiiYE4NfvupfI5P7WV1J7XMBIeqlbxQbqJw+N2ggGyNjaMv0neEgjqOqLE78v LmSUiFsD0juDKLrWReXTbQPB2ddhy3I9DZ5Pei1Bzgg8zvS30S79aSa0NAlzrCukM1sJC2u3BgVOa 1xI48Yd8SBkqsuyIbsTx6LZf7GSs64OJfkhDdg4pl9oiIkisbcS6aHTHispbbUQDF5ppews8FAd8t eVI1Ju9jCs5YI7eudgXFjzw0XGhzm2MiC5L3NDZ5Q4pEY0RUxz70QR56/5UySiRHCGTIUhL30t6ma eEzWdCuA==; 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-0000000HSiO-2fAR; 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 1t7TLb-0000000FvLT-00Gs; Sun, 03 Nov 2024 05:40:23 +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 6/7] x86/kexec: Debugging support: Dump registers on exception Date: Sun, 3 Nov 2024 05:35:31 +0000 Message-ID: <20241103054019.3795299-7-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 Signed-off-by: David Woodhouse --- arch/x86/kernel/relocate_kernel_64.S | 80 ++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocat= e_kernel_64.S index 2a2a6e693e18..1c18cffe5229 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -398,6 +398,53 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages) SYM_CODE_END(swap_pages) =20 #ifdef DEBUG +/* + * This allows other types of serial ports to be used. + * - %al: Character to be printed (no clobber %rax) + * - %rdx: MMIO address or port. + */ +.macro pr_char + outb %al, %dx +.endm + +/* Print the byte in %bl, clobber %rax */ +SYM_CODE_START_LOCAL_NOALIGN(pr_byte) + movb %bl, %al + nop + andb $0x0f, %al + addb $0x30, %al + cmpb $0x3a, %al + jb 1f + addb $('a' - '0' - 10), %al +1: pr_char + ANNOTATE_UNRET_SAFE + ret +SYM_CODE_END(pr_byte) + +SYM_CODE_START_LOCAL_NOALIGN(pr_qword) + movq $16, %rcx +1: rolq $4, %rbx + call pr_byte + loop 1b + movb $'\n', %al + pr_char + ANNOTATE_UNRET_SAFE + ret +SYM_CODE_END(pr_qword) + +.macro print_reg a, b, c, d, r + movb $\a, %al + pr_char + movb $\b, %al + pr_char + movb $\c, %al + pr_char + movb $\d, %al + pr_char + movq \r, %rbx + call pr_qword +.endm + SYM_CODE_START_LOCAL_NOALIGN(exc_vectors) /* Each of these is 6 bytes. */ .macro vec_err exc @@ -437,11 +484,39 @@ SYM_CODE_END(exc_vectors) =20 SYM_CODE_START_LOCAL_NOALIGN(exc_handler) pushq %rax + pushq %rbx + pushq %rcx pushq %rdx + movw $0x3f8, %dx - movb $'A', %al - outb %al, %dx + + /* rip and exception info */ + print_reg 'E', 'x', 'c', ':', 32(%rsp) + print_reg 'E', 'r', 'r', ':', 40(%rsp) + print_reg 'r', 'i', 'p', ':', 48(%rsp) + + /* We spilled these to the stack */ + print_reg 'r', 'a', 'x', ':', 24(%rsp) + print_reg 'r', 'b', 'x', ':', 16(%rsp) + print_reg 'r', 'c', 'x', ':', 8(%rsp) + print_reg 'r', 'd', 'x', ':', (%rsp) + + /* Other registers */ + print_reg 'r', 's', 'i', ':', %rsi + print_reg 'r', 'd', 'i', ':', %rdi + print_reg 'r', '8', ' ', ':', %r8 + print_reg 'r', '9', ' ', ':', %r9 + print_reg 'r', '1', '0', ':', %r10 + print_reg 'r', '1', '1', ':', %r11 + print_reg 'r', '1', '2', ':', %r12 + print_reg 'r', '1', '3', ':', %r13 + print_reg 'r', '1', '4', ':', %r14 + print_reg 'r', '1', '5', ':', %r15 + print_reg 'c', 'r', '2', ':', %cr2 + popq %rdx + popq %rcx + popq %rbx popq %rax =20 /* Only return from int3 */ @@ -454,7 +529,6 @@ SYM_CODE_START_LOCAL_NOALIGN(exc_handler) .Ldie: hlt jmp .Ldie - SYM_CODE_END(exc_handler) =20 .Lreloc_kernel_gdt: --=20 2.44.0 From nobody Sun Nov 24 19:20:40 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 438825D477 for ; Sun, 3 Nov 2024 05:40:42 +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=1730612443; cv=none; b=CVOSTgA+qKhjUmvRhT6Uply8QNYXSmlfIa1jE7u4sbx3fjHIWrjAo3eBhTNv0xsiuNiTDJ0r32s5p+kd4WBTlUaINwZBO39ZjLBwYSa8U/8LEaFcpc0cyiFoJNO4+rg9nbOUQ7CJU4UFZq8IfJFGnzaNGotT7rAVmdeiNcK6FR0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730612443; c=relaxed/simple; bh=eUvK7XxVTKcmyk5TF3HA5xYJw2+OI3G56q7owZOQKMs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DJDjR7nPw3M0OWlKexHtwhlLYAlw4pc5L9AV1J7wFzxL9WTFu9qsBuXMQaNfhEefBRWZTsOvnkdMZWISwkrGM35KSWRC7raRNMCS+VCzwAlyjcfzO9lkA5KkYMPSBOuJNLD/0g8ERlkqnuZQO99XqW+y/WX3sHL7BktTrupf8Bo= 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=FiIENKfb; 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="FiIENKfb" 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=jRI3DZMe9TgAyx+MV1am49R5haSFhnpyNVcm2C5PrAA=; b=FiIENKfbArtWxRSphJlRQI/Su/ wG0CYZp3+Xq0Cgr125LEeVC4uV7kLzDm68Ny8EuwpeabS40vxeEeM1B1VXiptzWFYe3AkgFrTN+eN U2/qnPMaqRezocIJMZQTAicperZx62gW0fwCNGp/0cupnXni5dmLyV2htrJJzfPk6yEuxvSRwkNqT JSOcE78pO/xDEb0nLG5+VGP+xpneFSyaCCItwgfl9mfh8+RlyWKQtmr9f4OBtWndCw+2hacY22SMO Ea6zU3OC4N+vXdLEwlHQ0Zw5UERJdgJrIueNVm8NKzJ0k/feSUK+WeCCqW0FIiJwwwyK4/WWJf2eW HaONILMw==; 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-0000000HSiP-2uPj; 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 1t7TLb-0000000FvLX-07z2; Sun, 03 Nov 2024 05:40:23 +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 7/7] [DO NOT MERGE] x86/kexec: enable DEBUG Date: Sun, 3 Nov 2024 05:35:32 +0000 Message-ID: <20241103054019.3795299-8-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 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 1c18cffe5229..bba37db6d437 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -14,6 +14,8 @@ #include #include =20 +#define DEBUG + /* * Must be relocatable PIC code callable as a C function, in particular * there must be a plain RET and not jump to return thunk. @@ -195,6 +197,8 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped) pushw $0xff lidt (%rsp) addq $10, %rsp + + int3 #endif /* DEBUG */ =20 /* --=20 2.44.0