* [PATCH v2 0/3] Buggy bootloader workaround v2 @ 2020-05-27 6:34 Jiaxun Yang 2020-05-27 6:34 ` [PATCH v2 1/3] MIPS: head.S: Always jump to kernel_entry at head of text Jiaxun Yang ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: Jiaxun Yang @ 2020-05-27 6:34 UTC (permalink / raw) To: linux-mips Cc: Jiaxun Yang, Thomas Bogendoerfer, Kees Cook, Borislav Petkov, Heiko Carstens, linux-kernel v2: Fixed typo due to keyboard failure. Jiaxun Yang (3): MIPS: head.S: Always jump to kernel_entry at head of text MIPS: Move kernel head into a standalone section MIPS: Loongson64: select NO_EXCEPT_FILL arch/mips/Kconfig | 1 + arch/mips/kernel/head.S | 6 ++---- arch/mips/kernel/vmlinux.lds.S | 8 ++++++-- 3 files changed, 9 insertions(+), 6 deletions(-) -- 2.27.0.rc0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/3] MIPS: head.S: Always jump to kernel_entry at head of text 2020-05-27 6:34 [PATCH v2 0/3] Buggy bootloader workaround v2 Jiaxun Yang @ 2020-05-27 6:34 ` Jiaxun Yang 2020-05-27 11:41 ` Thomas Bogendoerfer 2020-05-27 6:34 ` [PATCH v2 2/3] MIPS: Move kernel head into a standalone section Jiaxun Yang 2020-05-27 6:34 ` [PATCH v2 3/3] MIPS: Loongson64: select NO_EXCEPT_FILL Jiaxun Yang 2 siblings, 1 reply; 9+ messages in thread From: Jiaxun Yang @ 2020-05-27 6:34 UTC (permalink / raw) To: linux-mips Cc: Jiaxun Yang, Thomas Bogendoerfer, Kees Cook, Borislav Petkov, Heiko Carstens, Fangrui Song, linux-kernel Buggy loaders like early version of PMON2000 sometimes ignore elf_entry and goto start of text directly. That would help with dealing with these loaders. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> --- arch/mips/kernel/head.S | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S index 3b02ffe46304..c7c2795837e7 100644 --- a/arch/mips/kernel/head.S +++ b/arch/mips/kernel/head.S @@ -69,7 +69,6 @@ EXPORT(_stext) -#ifdef CONFIG_BOOT_RAW /* * Give us a fighting chance of running if execution beings at the * kernel load address. This is needed because this platform does @@ -77,7 +76,6 @@ EXPORT(_stext) */ FEXPORT(__kernel_entry) j kernel_entry -#endif /* CONFIG_BOOT_RAW */ __REF -- 2.27.0.rc0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/3] MIPS: head.S: Always jump to kernel_entry at head of text 2020-05-27 6:34 ` [PATCH v2 1/3] MIPS: head.S: Always jump to kernel_entry at head of text Jiaxun Yang @ 2020-05-27 11:41 ` Thomas Bogendoerfer 0 siblings, 0 replies; 9+ messages in thread From: Thomas Bogendoerfer @ 2020-05-27 11:41 UTC (permalink / raw) To: Jiaxun Yang Cc: linux-mips, Kees Cook, Borislav Petkov, Heiko Carstens, Fangrui Song, linux-kernel On Wed, May 27, 2020 at 02:34:32PM +0800, Jiaxun Yang wrote: > Buggy loaders like early version of PMON2000 sometimes ignore > elf_entry and goto start of text directly. so select BOOT_RAW on those broken platforms, no need for this change. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ] ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 2/3] MIPS: Move kernel head into a standalone section 2020-05-27 6:34 [PATCH v2 0/3] Buggy bootloader workaround v2 Jiaxun Yang 2020-05-27 6:34 ` [PATCH v2 1/3] MIPS: head.S: Always jump to kernel_entry at head of text Jiaxun Yang @ 2020-05-27 6:34 ` Jiaxun Yang 2020-05-27 11:53 ` Thomas Bogendoerfer 2020-05-27 6:34 ` [PATCH v2 3/3] MIPS: Loongson64: select NO_EXCEPT_FILL Jiaxun Yang 2 siblings, 1 reply; 9+ messages in thread From: Jiaxun Yang @ 2020-05-27 6:34 UTC (permalink / raw) To: linux-mips Cc: Jiaxun Yang, Thomas Bogendoerfer, Kees Cook, Borislav Petkov, Heiko Carstens, Fangrui Song, linux-kernel That's what already done by Arm64 and other architectures. That would allow us put more things like PE headers safely into the header. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> --- arch/mips/kernel/head.S | 4 ++-- arch/mips/kernel/vmlinux.lds.S | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S index c7c2795837e7..8081a905a71c 100644 --- a/arch/mips/kernel/head.S +++ b/arch/mips/kernel/head.S @@ -59,6 +59,8 @@ #endif .endm + __HEAD +_head: #ifndef CONFIG_NO_EXCEPT_FILL /* * Reserved space for exception handlers. @@ -67,8 +69,6 @@ .fill 0x400 #endif -EXPORT(_stext) - /* * Give us a fighting chance of running if execution beings at the * kernel load address. This is needed because this platform does diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index f185a85a27c1..b9ace667b82b 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -57,8 +57,12 @@ SECTIONS #endif . = LINKER_LOAD_ADDRESS; /* read-only */ - _text = .; /* Text and read-only data */ - .text : { + .head.text : { + _text = .; + HEAD_TEXT + } + .text : { /* Real text segment */ + _stext = .; /* Text and read-only data */ TEXT_TEXT SCHED_TEXT CPUIDLE_TEXT -- 2.27.0.rc0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/3] MIPS: Move kernel head into a standalone section 2020-05-27 6:34 ` [PATCH v2 2/3] MIPS: Move kernel head into a standalone section Jiaxun Yang @ 2020-05-27 11:53 ` Thomas Bogendoerfer 2020-05-27 12:05 ` Jiaxun Yang 0 siblings, 1 reply; 9+ messages in thread From: Thomas Bogendoerfer @ 2020-05-27 11:53 UTC (permalink / raw) To: Jiaxun Yang Cc: linux-mips, Kees Cook, Borislav Petkov, Heiko Carstens, Fangrui Song, linux-kernel On Wed, May 27, 2020 at 02:34:33PM +0800, Jiaxun Yang wrote: > That's what already done by Arm64 and other architectures. > That would allow us put more things like PE headers safely into > the header. > > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> > --- > arch/mips/kernel/head.S | 4 ++-- > arch/mips/kernel/vmlinux.lds.S | 8 ++++++-- > 2 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S > index c7c2795837e7..8081a905a71c 100644 > --- a/arch/mips/kernel/head.S > +++ b/arch/mips/kernel/head.S > @@ -59,6 +59,8 @@ > #endif > .endm > > + __HEAD > +_head: > #ifndef CONFIG_NO_EXCEPT_FILL > /* > * Reserved space for exception handlers. I'm adding the missing piece, why this change ist broken: * Necessary for machines which link their kernels at KSEG0. by putting something in front of that will probably break platforms making use of "feature". If we can make sure, we don't need it anymore, we should first remove this and then add __HEAD part. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/3] MIPS: Move kernel head into a standalone section 2020-05-27 11:53 ` Thomas Bogendoerfer @ 2020-05-27 12:05 ` Jiaxun Yang 2020-05-27 13:33 ` Thomas Bogendoerfer 0 siblings, 1 reply; 9+ messages in thread From: Jiaxun Yang @ 2020-05-27 12:05 UTC (permalink / raw) To: Thomas Bogendoerfer Cc: linux-mips, Kees Cook, Borislav Petkov, Heiko Carstens, Fangrui Song, linux-kernel On Wed, 27 May 2020 13:53:54 +0200 Thomas Bogendoerfer <tsbogend@alpha.franken.de> wrote: > On Wed, May 27, 2020 at 02:34:33PM +0800, Jiaxun Yang wrote: > > That's what already done by Arm64 and other architectures. > > That would allow us put more things like PE headers safely into > > the header. > > > > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> > > --- > > arch/mips/kernel/head.S | 4 ++-- > > arch/mips/kernel/vmlinux.lds.S | 8 ++++++-- > > 2 files changed, 8 insertions(+), 4 deletions(-) > > > > diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S > > index c7c2795837e7..8081a905a71c 100644 > > --- a/arch/mips/kernel/head.S > > +++ b/arch/mips/kernel/head.S > > @@ -59,6 +59,8 @@ > > #endif > > .endm > > > > + __HEAD > > +_head: > > #ifndef CONFIG_NO_EXCEPT_FILL > > /* > > * Reserved space for exception handlers. > > I'm adding the missing piece, why this change ist broken: > > * Necessary for machines which link their kernels at KSEG0. > > by putting something in front of that will probably break platforms > making use of "feature". If we can make sure, we don't need it > anymore, we should first remove this and then add __HEAD part. __HEAD is just marking the section of code. It will not add anything to the binary. Btw: I just noticed this patch may break relocatable kernel. I'll delay it for next merge window. Thanks. > > Thomas. > -- Jiaxun Yang ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/3] MIPS: Move kernel head into a standalone section 2020-05-27 12:05 ` Jiaxun Yang @ 2020-05-27 13:33 ` Thomas Bogendoerfer 0 siblings, 0 replies; 9+ messages in thread From: Thomas Bogendoerfer @ 2020-05-27 13:33 UTC (permalink / raw) To: Jiaxun Yang Cc: linux-mips, Kees Cook, Borislav Petkov, Heiko Carstens, Fangrui Song, linux-kernel On Wed, May 27, 2020 at 08:05:22PM +0800, Jiaxun Yang wrote: > On Wed, 27 May 2020 13:53:54 +0200 > Thomas Bogendoerfer <tsbogend@alpha.franken.de> wrote: > > > On Wed, May 27, 2020 at 02:34:33PM +0800, Jiaxun Yang wrote: > > > That's what already done by Arm64 and other architectures. > > > That would allow us put more things like PE headers safely into > > > the header. > > > > > > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> > > > --- > > > arch/mips/kernel/head.S | 4 ++-- > > > arch/mips/kernel/vmlinux.lds.S | 8 ++++++-- > > > 2 files changed, 8 insertions(+), 4 deletions(-) > > > > > > diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S > > > index c7c2795837e7..8081a905a71c 100644 > > > --- a/arch/mips/kernel/head.S > > > +++ b/arch/mips/kernel/head.S > > > @@ -59,6 +59,8 @@ > > > #endif > > > .endm > > > > > > + __HEAD > > > +_head: > > > #ifndef CONFIG_NO_EXCEPT_FILL > > > /* > > > * Reserved space for exception handlers. > > > > I'm adding the missing piece, why this change ist broken: > > > > * Necessary for machines which link their kernels at KSEG0. > > > > by putting something in front of that will probably break platforms > > making use of "feature". If we can make sure, we don't need it > > anymore, we should first remove this and then add __HEAD part. > > __HEAD is just marking the section of code. > It will not add anything to the binary. oops, should have looked it up first. You mentioned PE headers and I thought it will be added this way. > Btw: I just noticed this patch may break relocatable kernel. I'll delay > it for next merge window. ok. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ] ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 3/3] MIPS: Loongson64: select NO_EXCEPT_FILL 2020-05-27 6:34 [PATCH v2 0/3] Buggy bootloader workaround v2 Jiaxun Yang 2020-05-27 6:34 ` [PATCH v2 1/3] MIPS: head.S: Always jump to kernel_entry at head of text Jiaxun Yang 2020-05-27 6:34 ` [PATCH v2 2/3] MIPS: Move kernel head into a standalone section Jiaxun Yang @ 2020-05-27 6:34 ` Jiaxun Yang 2020-05-27 11:47 ` Thomas Bogendoerfer 2 siblings, 1 reply; 9+ messages in thread From: Jiaxun Yang @ 2020-05-27 6:34 UTC (permalink / raw) To: linux-mips Cc: Jiaxun Yang, Thomas Bogendoerfer, Kees Cook, Borislav Petkov, Heiko Carstens, Fangrui Song, linux-kernel Loongson64 load kernel at 0x82000000 and allocate exception vectors by ebase. So we don't need to reserve space for exception vectors at head of kernel. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> --- arch/mips/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 3ca59b610a67..0e385f7b7691 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -462,6 +462,7 @@ config MACH_LOONGSON64 select IRQ_MIPS_CPU select NR_CPUS_DEFAULT_64 select USE_GENERIC_EARLY_PRINTK_8250 + select NO_EXCEPT_FILL select SYS_HAS_CPU_LOONGSON64 select SYS_HAS_EARLY_PRINTK select SYS_SUPPORTS_SMP -- 2.27.0.rc0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] MIPS: Loongson64: select NO_EXCEPT_FILL 2020-05-27 6:34 ` [PATCH v2 3/3] MIPS: Loongson64: select NO_EXCEPT_FILL Jiaxun Yang @ 2020-05-27 11:47 ` Thomas Bogendoerfer 0 siblings, 0 replies; 9+ messages in thread From: Thomas Bogendoerfer @ 2020-05-27 11:47 UTC (permalink / raw) To: Jiaxun Yang Cc: linux-mips, Kees Cook, Borislav Petkov, Heiko Carstens, Fangrui Song, linux-kernel On Wed, May 27, 2020 at 02:34:34PM +0800, Jiaxun Yang wrote: > Loongson64 load kernel at 0x82000000 and allocate exception vectors > by ebase. So we don't need to reserve space for exception vectors > at head of kernel. > > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> > --- > arch/mips/Kconfig | 1 + > 1 file changed, 1 insertion(+) applied to mips-next. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ] ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-05-27 13:34 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-05-27 6:34 [PATCH v2 0/3] Buggy bootloader workaround v2 Jiaxun Yang 2020-05-27 6:34 ` [PATCH v2 1/3] MIPS: head.S: Always jump to kernel_entry at head of text Jiaxun Yang 2020-05-27 11:41 ` Thomas Bogendoerfer 2020-05-27 6:34 ` [PATCH v2 2/3] MIPS: Move kernel head into a standalone section Jiaxun Yang 2020-05-27 11:53 ` Thomas Bogendoerfer 2020-05-27 12:05 ` Jiaxun Yang 2020-05-27 13:33 ` Thomas Bogendoerfer 2020-05-27 6:34 ` [PATCH v2 3/3] MIPS: Loongson64: select NO_EXCEPT_FILL Jiaxun Yang 2020-05-27 11:47 ` Thomas Bogendoerfer
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).