Project

General

Profile

BootloadersIncompatibleWithLinux » History » Version 6

Denis 'GNUtoo' Carikli, 03/18/2020 03:49 PM

1 1 Denis 'GNUtoo' Carikli
h1. MidasBootloaderIncompatibleWithLinux
2
3
h2. Introduction
4
5 3 Denis 'GNUtoo' Carikli
The bootloader of the following devices is incompatible with upstream Linux:
6 1 Denis 'GNUtoo' Carikli
* Galaxy SIII (GT-I9300)
7
* Galaxy SIII 4G (GT-I9305)
8
* Galaxy Note II (GT-N7100)
9
* Galaxy Note II 4G (GT-N7105)
10
11
When jumping to Linux, the booloader still has:
12
* the instruction cache on
13
* the data cache on
14
* the MMU on
15 2 Denis 'GNUtoo' Carikli
16
"Documentation/arm/booting.rst":https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/Documentation/arm/booting.rst which is there "since 2003":https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?h=v2.6.0&id=c90594cab75e043c6651f4c3d7218bd67dc4005f states that:
17
* "The MMU must be off."
18 1 Denis 'GNUtoo' Carikli
* "Data cache must be off."
19 3 Denis 'GNUtoo' Carikli
20 5 Denis 'GNUtoo' Carikli
And upstream Linux "won't accept patches":https://www.openwall.com/lists/kernel-hardening/2019/06/14/9 to disable the MMU, or the data cache in Linux as they have very good reasons to do that, and they are supposed to be already disabled.
21
22 3 Denis 'GNUtoo' Carikli
h2. Supporting s-boot
23
24
To workaround that: 
25
* "to disable the caches":https://git.replicant.us/contrib/replicant-9/kernel_replicant_linux/commit/?id=85006537f34367710e7c9ae4aa0791ca5101ef46
26 4 Denis 'GNUtoo' Carikli
* "to disable CONFIG_GCC_PLUGINS":https://www.openwall.com/lists/kernel-hardening/2019/06/14/4 or "CONFIG_STACKPROTECTOR_PER_TASK":https://www.openwall.com/lists/kernel-hardening/2019/06/14/6
27 3 Denis 'GNUtoo' Carikli
28
However as the kernel evolved we need to patch it more and more:
29
* The patch disabling the caches "was not necessary on Linux 3.4":lkml.iu.edu/hypermail/linux/kernel/1212.1/02099.html
30
* Disabling CONFIG_GCC_PLUGINS was also not necessary on older kernel where the option was not even present
31 6 Denis 'GNUtoo' Carikli
32
So it's not a viable option in the long run.
33
34
h2. Longer term options
35
36
As u-boot disables the instruction cache in the boot commands before jumping to Linux, we might be able to replace the boot.img by u-boot to workaround the stock bootloader issues.
37
38
Having u-boot would also enable many benefits, such as the ability to have Replicant images that run on multiple devices.
39
40
As u-boot is capable of running in different ways, when upstreamming the code we will need to make sure that it can run as boot.img but also with the nonfree and non-redistributable BL1 because other people are interested in that and that, if we manage to get rid of the BL1 at some point, many of the upstreaming work will already been done.