linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jinyang He <hejinyang@loongson.cn>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Paul Burton <paulburton@kernel.org>
Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 4/5] MIPS: cavium-octeon: Execute the smp handle after jumping to kernel linked address
Date: Mon, 12 Apr 2021 20:28:13 +0800	[thread overview]
Message-ID: <1618230494-6207-5-git-send-email-hejinyang@loongson.cn> (raw)
In-Reply-To: <1618230494-6207-1-git-send-email-hejinyang@loongson.cn>

Once relocation is required, some fixed addresses in `smp handle` will be
affected. For example, octeon_processor_relocated_kernel_entry may cause
the problem of loading wrong memory at old address.

This patch makes smp cpu do two more things, one is to set ST0_KX, another
is to jump to the kernel linked address. They will not destroy the
cavium-octeon platform. This patch adds two platform-related macros,
SMP_IN_KERNEL_ENTRY and smp_in_kernel_handle, which can be used on other
platforms to deal with the SMP CPU in the kernel_entry, if the smp CPU
entered the kernel entry.

Signed-off-by: Jinyang He <hejinyang@loongson.cn>
---
 arch/mips/include/asm/mach-cavium-octeon/kernel-entry-init.h | 7 +++++++
 arch/mips/kernel/head.S                                      | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/arch/mips/include/asm/mach-cavium-octeon/kernel-entry-init.h b/arch/mips/include/asm/mach-cavium-octeon/kernel-entry-init.h
index e66767d..21b9854 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/kernel-entry-init.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/kernel-entry-init.h
@@ -86,6 +86,13 @@
 	dli	v0, 0x27
 	dmtc0	v0, CP0_DCACHE_ERR_REG
 1:
+	.set pop
+.endm
+
+#define SMP_IN_KERNEL_ENTRY
+.macro	smp_in_kernel_entry_handle
+	.set push
+	.set arch=octeon
 	# Get my core id
 	rdhwr	v0, $0
 	# Jump the master to kernel_entry
diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index 0186285..6cfe23e 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -104,6 +104,10 @@ NESTED(kernel_entry, 16, sp)			# kernel entry point
 	jr		t0
 2:
 
+#ifdef SMP_IN_KERNEL_ENTRY
+	smp_in_kernel_entry_handle
+#endif
+
 	PTR_LA		t0, __bss_start		# clear .bss
 	LONG_S		zero, (t0)
 	PTR_LA		t1, __bss_stop - LONGSIZE
-- 
2.1.0


  parent reply	other threads:[~2021-04-12 12:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12 12:28 [PATCH v2 0/5] MIPS: relocate: Add automatic relocation to CONFIG_RELOCATABLE Jinyang He
2021-04-12 12:28 ` [PATCH v2 1/5] MIPS: relocate: Only compile relocs when CONFIG_RELOCATABLE is enabled Jinyang He
2021-04-12 12:28 ` [PATCH v2 2/5] MIPS: relocate: Use CONFIG_RANDOMIZE_BASE to enable kaslr Jinyang He
2021-04-12 12:28 ` [PATCH v2 3/5] MIPS: Jump to kernel linked address by PC relative way Jinyang He
2021-04-12 12:28 ` Jinyang He [this message]
2021-04-12 12:28 ` [PATCH v2 5/5] MIPS: relocate: Add support to auto relocate kernel Jinyang He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1618230494-6207-5-git-send-email-hejinyang@loongson.cn \
    --to=hejinyang@loongson.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=paulburton@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).