Project

General

Profile

BootloadersIncompatibleWithLinux » History » Version 16

Denis 'GNUtoo' Carikli, 06/12/2020 07:38 PM

1 7 Denis 'GNUtoo' Carikli
h1. BootloaderIncompatibleWithLinux
2 1 Denis 'GNUtoo' Carikli
3 8 Denis 'GNUtoo' Carikli
h2. Devices with the Exynos 4412
4 1 Denis 'GNUtoo' Carikli
5 8 Denis 'GNUtoo' Carikli
h3. Introduction
6
7 3 Denis 'GNUtoo' Carikli
The bootloader of the following devices is incompatible with upstream Linux:
8 1 Denis 'GNUtoo' Carikli
* Galaxy SIII (GT-I9300)
9
* Galaxy SIII 4G (GT-I9305)
10
* Galaxy Note II (GT-N7100)
11
* Galaxy Note II 4G (GT-N7105)
12
13
When jumping to Linux, the booloader still has:
14
* the instruction cache on
15
* the data cache on
16
* the MMU on
17 2 Denis 'GNUtoo' Carikli
18
"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:
19
* "The MMU must be off."
20 1 Denis 'GNUtoo' Carikli
* "Data cache must be off."
21 5 Denis 'GNUtoo' Carikli
22 1 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.
23 5 Denis 'GNUtoo' Carikli
24 8 Denis 'GNUtoo' Carikli
h3. Supporting s-boot
25 3 Denis 'GNUtoo' Carikli
26 10 Denis 'GNUtoo' Carikli
To workaround that we need to:
27 3 Denis 'GNUtoo' Carikli
* "to disable the caches":https://git.replicant.us/contrib/replicant-9/kernel_replicant_linux/commit/?id=85006537f34367710e7c9ae4aa0791ca5101ef46
28 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
29 3 Denis 'GNUtoo' Carikli
30 10 Denis 'GNUtoo' Carikli
However as the kernel evolved we needed to patch it more and more:
31 11 Denis 'GNUtoo' Carikli
* The patch disabling the caches "was not necessary on Linux 3.4":http://lkml.iu.edu/hypermail/linux/kernel/1212.1/02099.html
32 3 Denis 'GNUtoo' Carikli
* Disabling CONFIG_GCC_PLUGINS was also not necessary on older kernel where the option was not even present
33 6 Denis 'GNUtoo' Carikli
34
So it's not a viable option in the long run.
35
36 9 Denis 'GNUtoo' Carikli
h2. Devices with the Exynos 4412
37
38 14 Denis 'GNUtoo' Carikli
The bootloader of the following devices seems[1] to be incompatible with upstream Linux:
39 1 Denis 'GNUtoo' Carikli
* Galaxy SII (GT-I9100)
40 14 Denis 'GNUtoo' Carikli
41
However we don't have details yet on what is wrong there (caches, MMU, etc).
42 12 Denis 'GNUtoo' Carikli
43 15 Kurtis Hanna
fn1^. from #replicant on freenode: <pcercuei> I'm trying to boot a mainline kernel [on the GT-I9100], for some reason it only works if I boot it with u-boot
44 12 Denis 'GNUtoo' Carikli
45 6 Denis 'GNUtoo' Carikli
h2. Longer term options
46
47
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.
48 1 Denis 'GNUtoo' Carikli
49
Having u-boot would also enable many benefits, such as the ability to have Replicant images that run on multiple devices.
50
51 8 Denis 'GNUtoo' Carikli
As u-boot is capable of running in different ways, when upstreaming the code we will need to make sure that it can run as boot.img but also in other ways depending on the device.
52
53
For instance on midas, u-boot can also run with the nonfree and non-redistributable BL1. So it might be interesting to support that as well with the same code because:
54
* Other people are interested in that so we could collaborate on the same code even if it doesn't run the same way
55
* If we manage to get rid of the BL1 at some point, many of the upstreaming work will already been done.
56 16 Denis 'GNUtoo' Carikli
57
We will track the upstreaming status for midas in this bug: #2050