Project

General

Profile

ExynosModemIsolation » History » Version 4

Paul Kocialkowski, 03/15/2013 11:27 PM

1 1 Paul Kocialkowski
h1. S5PC110 Hardware Design
2
3
This explains the hardware design found in many S5PC110 phones.
4
5
h2. Hardware design matrix
6
7
|_. *Chip* |_. Controlled by the CPU |_. Controlled by the modem |_. Connected to the modem |
8
| GPS | Yes | No | No? |
9
| Audio CODEC | Yes | No | Yes |
10
| NAND | Yes | No | No |
11 3 Paul Kocialkowski
| RAM | Yes | Yes (96Mib at least) | Yes |
12 1 Paul Kocialkowski
| WiFi/Bluetooth | Yes | No | No |
13
| Sensors | Yes | No | No |
14
| NFC | Yes | No | No |
15
| Camera | Yes | No | No |
16
17
h2. Modem isolation
18
19 2 Paul Kocialkowski
The modem (XMM 6160) is separated from the SoC and communicates with it via serial over 16Mib of shared memory: this is bad since it means that RAM is compromised (at least 80Mib + 16Mib = 96Mib) and can be used to spy.
20 1 Paul Kocialkowski
Regarding audio, the modem is connected to the CODEC but cannot control it (the SoC has to enable routing from/to the modem).
21
There is no evidence that the GPS is connected to the modem, but since we cannot check on the hardware, there is no proof it's not connected to it either. The SoC is able to control the GPS power though, so we can keep it off.
22
Since the SoC has to load the modem firmware over the (fake) serial, and following the datasheets, the modem is not connected to the NAND.
23
24
h2. Shared RAM issue
25
26 3 Paul Kocialkowski
The modem is able to spy on (at least) 96 Mib of the main memory. So far, we cannot tell:
27
* if it can only spy 80Mib or the full memory
28 1 Paul Kocialkowski
* if it can be fixed or not
29
30 4 Paul Kocialkowski
The Linux kernel is being loaded at the beginning of the shared memory bank (0x30000000), however the kernel should be off when it loads.
31
32 1 Paul Kocialkowski
h3. Kernel details
33
34
@kernel-crespo/arch/arm/mach-s5pv210/dev-herring-phone.c@:
35
<pre>
36
static struct resource mdmctl_res[] = {
37
[...]
38
        [2] = {
39
                .name = "onedram",
40
                .start = (S5PV210_PA_SDRAM + 0x05000000),
41
                .end = (S5PV210_PA_SDRAM + 0x05000000 + SZ_16M - 1),
42
                .flags = IORESOURCE_MEM,
43
        },
44
};
45
</pre>
46
47
* S5PV210_PA_SDRAM is 0x30000000
48 3 Paul Kocialkowski
* 0x05000000 is 80Mib
49 1 Paul Kocialkowski
* mdmctl_res goes in a platform device struct which is passed to the modem driver:
50
51
<pre>
52
static struct platform_device modemctl = {
53
        .name = "modemctl",
54
        .id = -1,
55
        .num_resources = ARRAY_SIZE(mdmctl_res),
56
        .resource = mdmctl_res,
57
        .dev = {
58
                .platform_data = &mdmctl_data,
59
        },
60
};
61
</pre>
62
63
And in the board file (in kernel-crespo/arch/arm/mach-s5pv210/mach-herring.c) we have: 
64
<pre>
65
static void __init herring_fixup(struct machine_desc *desc,
66
                struct tag *tags, char **cmdline,
67
                struct meminfo *mi)
68
{
69
        mi->bank[0].start = 0x30000000;
70
        mi->bank[0].size = 80 * SZ_1M;
71
        mi->bank[0].node = 0;
72
</pre>
73
74 3 Paul Kocialkowski
So we can suppose that there is at least one ram chip that is shared between the modem and the main CPU. Avoiding the use of this memory bank would result in loosing 80Mib of memory.
75 4 Paul Kocialkowski
76
h3. Fix attempt
77
78
An ideal fix fix would be to lose that 80Mib of RAM so that the shared memory can still be used for SoC/Modem communication but can't spy on the SoC data on RAM. The fact that it's the kernel loading address makes the task more difficult (it may require the bootloader cooperation, which is non-free).
79
80
The current diff with the Nexus S kernel is here, but it doesn't boot at all with the following changes (and mkbootimg changes):
81
82
<pre>
83
diff --git a/arch/arm/configs/herring_defconfig b/arch/arm/configs/herring_defconfig
84
old mode 100755
85
new mode 100644
86
index 11abbf0..99bf3f5
87
--- a/arch/arm/configs/herring_defconfig
88
+++ b/arch/arm/configs/herring_defconfig
89
@@ -1,7 +1,7 @@
90
 #
91
 # Automatically generated make config: don't edit
92
 # Linux kernel version: 2.6.35.7
93
-# Fri Jun  3 07:07:08 2011
94
+# Sun Apr  8 14:40:16 2012
95
 #
96
 CONFIG_ARM=y
97
 CONFIG_HAVE_PWM=y
98
@@ -418,8 +418,8 @@ CONFIG_ALIGNMENT_TRAP=y
99
 #
100
 CONFIG_ZBOOT_ROM_TEXT=0
101
 CONFIG_ZBOOT_ROM_BSS=0
102
-CONFIG_CMDLINE="console=ttyFIQ0"
103
-# CONFIG_CMDLINE_FORCE is not set
104
+CONFIG_CMDLINE="console=ttyFIQ0 no_console_suspend earlyprintk=serial,ttySAC2,115200 androidboot.serialno=3733BAB66DE200EC androidboot.bootloader=I9020XXKA3 androidboot.baseband=I9020XXKB3 androidboot.info=0x4,0x0,1 androidboot.carrier=EUR gain_code=3 s3cfb.bootloaderfb=0x34a00000 mach-herring.lcd_type=0x00000000 oem_state=unlocked"
105
+CONFIG_CMDLINE_FORCE=y
106
 # CONFIG_XIP_KERNEL is not set
107
 # CONFIG_KEXEC is not set
108
 
109
@@ -823,8 +823,6 @@ CONFIG_UEVENT_HELPER_PATH=""
110
 CONFIG_STANDALONE=y
111
 CONFIG_PREVENT_FIRMWARE_BUILD=y
112
 # CONFIG_FW_LOADER is not set
113
-# CONFIG_FIRMWARE_IN_KERNEL is not set
114
-CONFIG_EXTRA_FIRMWARE=""
115
 # CONFIG_DEBUG_DRIVER is not set
116
 # CONFIG_DEBUG_DEVRES is not set
117
 # CONFIG_SYS_HYPERVISOR is not set
118
@@ -835,7 +833,7 @@ CONFIG_MTD=y
119
 CONFIG_MTD_CONCAT=y
120
 CONFIG_MTD_PARTITIONS=y
121
 # CONFIG_MTD_REDBOOT_PARTS is not set
122
-# CONFIG_MTD_CMDLINE_PARTS is not set
123
+CONFIG_MTD_CMDLINE_PARTS=y
124
 # CONFIG_MTD_AFS_PARTS is not set
125
 # CONFIG_MTD_AR7_PARTS is not set
126
 
127
@@ -1191,6 +1189,7 @@ CONFIG_DEVKMEM=y
128
 CONFIG_SERIAL_SAMSUNG=y
129
 CONFIG_SERIAL_SAMSUNG_UARTS_4=y
130
 CONFIG_SERIAL_SAMSUNG_UARTS=4
131
+# CONFIG_SERIAL_SAMSUNG_DEBUG is not set
132
 CONFIG_SERIAL_SAMSUNG_CONSOLE=y
133
 CONFIG_SERIAL_S5PV210=y
134
 # CONFIG_SERIAL_MAX3100 is not set
135
@@ -2046,7 +2045,9 @@ CONFIG_HAVE_ARCH_KGDB=y
136
 CONFIG_DEBUG_USER=y
137
 CONFIG_DEBUG_ERRORS=y
138
 # CONFIG_DEBUG_STACK_USAGE is not set
139
-# CONFIG_DEBUG_LL is not set
140
+CONFIG_DEBUG_LL=y
141
+CONFIG_EARLY_PRINTK=y
142
+# CONFIG_DEBUG_ICEDCC is not set
143
 CONFIG_OC_ETM=y
144
 CONFIG_DEBUG_S3C_UART=2
145
 
146
diff --git a/arch/arm/mach-s5pv210/dev-herring-phone.c b/arch/arm/mach-s5pv210/dev-herring-phone.c
147
index f8798b3..ecef636 100755
148
--- a/arch/arm/mach-s5pv210/dev-herring-phone.c
149
+++ b/arch/arm/mach-s5pv210/dev-herring-phone.c
150
@@ -48,8 +48,8 @@ static struct resource mdmctl_res[] = {
151
 	},
152
 	[2] = {
153
 		.name = "onedram",
154
-		.start = (S5PV210_PA_SDRAM + 0x05000000),
155
-		.end = (S5PV210_PA_SDRAM + 0x05000000 + SZ_16M - 1),
156
+		.start = (0x30000000  + 0x05000000),
157
+		.end = (0x30000000  + 0x05000000 + SZ_16M - 1),
158
 		.flags = IORESOURCE_MEM,
159
 	},
160
 };
161
diff --git a/arch/arm/mach-s5pv210/mach-herring.c b/arch/arm/mach-s5pv210/mach-herring.c
162
index c3a0182..67fa1cf 100755
163
--- a/arch/arm/mach-s5pv210/mach-herring.c
164
+++ b/arch/arm/mach-s5pv210/mach-herring.c
165
@@ -5494,21 +5494,17 @@ static void __init herring_fixup(struct machine_desc *desc,
166
 		struct tag *tags, char **cmdline,
167
 		struct meminfo *mi)
168
 {
169
-	mi->bank[0].start = 0x30000000;
170
-	mi->bank[0].size = 80 * SZ_1M;
171
+	mi->bank[0].start = 0x40000000;
172
+	mi->bank[0].size = 256 * SZ_1M;
173
 	mi->bank[0].node = 0;
174
 
175
-	mi->bank[1].start = 0x40000000;
176
-	mi->bank[1].size = 256 * SZ_1M;
177
-	mi->bank[1].node = 1;
178
-
179
-	mi->bank[2].start = 0x50000000;
180
+	mi->bank[1].start = 0x50000000;
181
 	/* 1M for ram_console buffer */
182
-	mi->bank[2].size = 127 * SZ_1M;
183
-	mi->bank[2].node = 2;
184
-	mi->nr_banks = 3;
185
+	mi->bank[1].size = 127 * SZ_1M;
186
+	mi->bank[1].node = 1;
187
+	mi->nr_banks = 2;
188
 
189
-	ram_console_start = mi->bank[2].start + mi->bank[2].size;
190
+	ram_console_start = mi->bank[1].start + mi->bank[1].size;
191
 	ram_console_size = SZ_1M - SZ_4K;
192
 
193
 	pm_debug_scratchpad = ram_console_start + ram_console_size;
194
</pre>
195
196
<pre>
197
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
198
index fff6d1b..c09d935 100755
199
--- a/BoardConfigCommon.mk
200
+++ b/BoardConfigCommon.mk
201
@@ -51,10 +51,10 @@ DEFAULT_FB_NUM := 2
202
 
203
 BOARD_NAND_PAGE_SIZE := 4096 -s 128
204
 
205
-BOARD_KERNEL_BASE := 0x30000000
206
+BOARD_KERNEL_BASE := 0x40000000
207
 BOARD_KERNEL_PAGESIZE := 4096
208
-BOARD_KERNEL_CMDLINE := console=ttyFIQ0 no_console_suspend
209
-
210
+BOARD_KERNEL_CMDLINE := console=ttyFIQ0 no_console_suspend earlyprintk=serial,ttySAC2,115200 bootmem_debug
211
+BOARD_FORCE_RAMDISK_ADDRESS := 0x41000000
212
 #TARGET_RECOVERY_UI_LIB := librecovery_ui_crespo
213
 TARGET_RELEASETOOLS_EXTENSIONS := device/samsung/crespo
214
</pre>