63
63
* +--------------------------------------------------+
64
64
*/
65
65
66
+ /* vsbl binary layout:
67
+ *
68
+ * +--------------------------------------------------+ <--vSBL Top
69
+ * | |offset: Top - 0x10 (reset vector) |
70
+ * + STAGEINIT |------------------------------------+
71
+ * | (0x10000) |other |
72
+ * +--------------------------------------------------+
73
+ * | |
74
+ * + PAYLOAD +
75
+ * |(0x100000) |
76
+ * +--------------------------------------------------+
77
+ * | |
78
+ * + vFastboot +
79
+ * |(0x200000) |
80
+ * +--------------------------------------------------+
81
+ */
82
+
66
83
/* Check default e820 table in sw_load_common.c for info about ctx->lowmem */
67
84
#define CONFIGPAGE_OFF (ctx ) ((ctx)->lowmem - 4*KB)
68
85
#define VSBL_ENTRY_OFF (ctx ) ((ctx)->lowmem - 6*KB)
69
86
#define BOOTARGS_OFF (ctx ) ((ctx)->lowmem - 8*KB)
70
87
#define E820_TABLE_OFF (ctx ) ((ctx)->lowmem - 12*KB)
71
88
#define GUEST_PART_INFO_OFF (ctx ) ((ctx)->lowmem - 16*KB)
72
- /* vsbl real entry is saved in the first 4 bytes of vsbl image */
73
- #define VSBL_OFF (ctx ) (16 *MB)
89
+ /* vsbl real entry is reset vector, which is (VSBL_TOP - 16) */
90
+ #define VSBL_TOP (ctx ) (64 *MB)
74
91
75
92
struct vsbl_para {
76
93
uint64_t e820_table_address ;
@@ -149,7 +166,7 @@ acrn_prepare_guest_part_info(struct vmctx *ctx)
149
166
guest_part_info_size = len ;
150
167
151
168
fseek (fp , 0 , SEEK_SET );
152
- read = fread (ctx -> baseaddr + GUEST_PART_INFO_OFF (ctx ),
169
+ read = fread (ctx -> baseaddr + GUEST_PART_INFO_OFF (ctx ),
153
170
sizeof (char ), len , fp );
154
171
if (read < len ) {
155
172
fprintf (stderr ,
@@ -199,7 +216,7 @@ acrn_prepare_vsbl(struct vmctx *ctx)
199
216
200
217
fseek (fp , 0 , SEEK_END );
201
218
len = ftell (fp );
202
- if (( len + VSBL_OFF ( ctx )) > GUEST_PART_INFO_OFF ( ctx )) {
219
+ if (len > ( 8 * MB )) {
203
220
fprintf (stderr ,
204
221
"SW_LOAD ERR: too large vsbl file\n" );
205
222
fclose (fp );
@@ -209,7 +226,7 @@ acrn_prepare_vsbl(struct vmctx *ctx)
209
226
vsbl_size = len ;
210
227
211
228
fseek (fp , 0 , SEEK_SET );
212
- read = fread (ctx -> baseaddr + VSBL_OFF (ctx ),
229
+ read = fread (ctx -> baseaddr + VSBL_TOP (ctx ) - vsbl_size ,
213
230
sizeof (char ), len , fp );
214
231
if (read < len ) {
215
232
fprintf (stderr ,
@@ -219,7 +236,7 @@ acrn_prepare_vsbl(struct vmctx *ctx)
219
236
}
220
237
fclose (fp );
221
238
printf ("SW_LOAD: partition blob %s size %d copy to guest 0x%lx\n" ,
222
- vsbl_path , vsbl_size , VSBL_OFF (ctx ));
239
+ vsbl_path , vsbl_size , VSBL_TOP (ctx ) - vsbl_size );
223
240
224
241
return 0 ;
225
242
}
@@ -230,8 +247,6 @@ acrn_sw_load_vsbl(struct vmctx *ctx)
230
247
int ret ;
231
248
struct e820_entry * e820 ;
232
249
struct vsbl_para * vsbl_para ;
233
- uint64_t vsbl_start_addr =
234
- (uint64_t )ctx -> baseaddr + VSBL_OFF (ctx );
235
250
uint64_t * vsbl_entry =
236
251
(uint64_t * )(ctx -> baseaddr + VSBL_ENTRY_OFF (ctx ));
237
252
uint64_t * cfg_offset =
@@ -275,13 +290,15 @@ acrn_sw_load_vsbl(struct vmctx *ctx)
275
290
if (ret )
276
291
return ret ;
277
292
278
- vsbl_para -> vsbl_address = VSBL_OFF (ctx );
293
+ vsbl_para -> vsbl_address = VSBL_TOP (ctx ) - vsbl_size ;
279
294
vsbl_para -> vsbl_size = vsbl_size ;
280
295
281
296
vsbl_para -> e820_entries = add_e820_entry (e820 , vsbl_para -> e820_entries ,
282
297
vsbl_para -> vsbl_address , vsbl_size , E820_TYPE_RESERVED );
283
298
284
- * vsbl_entry = * ((uint32_t * ) vsbl_start_addr );
299
+
300
+ * vsbl_entry = VSBL_TOP (ctx ) - 16 ; /* reset vector */
301
+ printf ("SW_LOAD: vsbl_entry 0x%lx\n" , * vsbl_entry );
285
302
286
303
vsbl_para -> boot_device_address = boot_blk_bdf ;
287
304
vsbl_para -> trusty_enabled = trusty_enabled ;
0 commit comments