1
0
Fork 0
mirror of https://gitlab.com/bztsrc/bootboot.git synced 2023-02-13 20:54:32 -05:00

Added 'nosmp=1' environment option on x86

This commit is contained in:
bzt 2020-11-02 19:21:07 +01:00
parent 9d1f62138a
commit 4bd9e167c0
10 changed files with 45 additions and 15 deletions

View file

@ -313,6 +313,10 @@ if (currentcoreid == bootboot.bspid) {
Az x86_64-on a 'currentcoreid' a Local Apic Id (cpuid[eax=1].ebx >> 24), míg AArch64-on ez az (mpidr_el1 & 3).
Mivel több hibabejelentés is érkezett az SMP kapcsán bugos gépek miatt, ezért az x86 betöltők megértik a `nosmp=1` környezeti
opciót is. Ha meg van adva, akkor csak egy mag indul el. Ez az opció el lesz távolítva, amint a problémákra lesz kerülőmegoldás,
és az SMP inicializálás megfelelően működik minden gépen.
Telepítés
---------

View file

@ -314,6 +314,10 @@ if (currentcoreid == bootboot.bspid) {
On x86_64, 'currentcoreid' is the Local Apic Id (cpuid[eax=1].ebx >> 24), on AArch64 that's (mpidr_el1 & 3).
Because there were multiple reports with SMP issues on buggy machines, the x86 loaders also support `nosmp=1` in the environment.
If given, then only one core will be booted. This option will be removed once the issues are workarounded and SMP
initialized properly on all machines.
Installation
------------

BIN
dist/bootboot.bin vendored

Binary file not shown.

BIN
dist/bootboot.efi vendored

Binary file not shown.

BIN
dist/bootboot.rom vendored

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -2,7 +2,7 @@
extern unsigned char binary_boot_bin[512];
extern unsigned char binary_bootboot_bin[12288];
extern unsigned char binary_bootboot_efi[100932];
extern unsigned char binary_bootboot_efi[100950];
extern unsigned char binary_bootboot_img[34712];
extern unsigned char binary_LICENCE_broadcom[1594];
extern unsigned char binary_bootcode_bin[52480];

View file

@ -1620,11 +1620,11 @@ end if
jmp .getnext
;get kernel's filename
@@: cmp dword[esi], 'kern'
jne .next
jne @f
cmp word[esi+4], 'el'
jne .next
jne @f
cmp byte[esi+6], '='
jne .next
jne @f
add esi, 7
mov edi, kernel
.copy: lodsb
@ -1643,6 +1643,13 @@ end if
.copyend: xor al, al
stosb
jmp .getnext
@@: cmp dword[esi], 'nosm'
jne .next
cmp word[esi+4], 'p='
jne .next
cmp byte[esi+6], '1'
jne .next
mov byte[nosmp], 1
.next: inc esi
;failsafe
.getnext: cmp esi, 0A000h
@ -1889,6 +1896,10 @@ end if
repnz stosd
; clear flags
mov byte [bsp_done], al
cmp byte [nosmp], al
jne .nosmp
; try ACPI first
mov esi, dword [bootboot.acpi_ptr]
or esi, esi
@ -2667,6 +2678,7 @@ cntdev: db 0
hasinitrd: db 0
hasconfig: db 0
iscdrom: db 0
nosmp: db 0
bsp_done: ;flag to indicate APs can run
fattype: db 0
bkp: dd ' '

View file

@ -244,7 +244,7 @@ uint64_t *paging = (uint64_t*)0x4000;
int reqwidth = 1024, reqheight = 768;
char *kernelname="sys/core";
unsigned char *kne;
unsigned char *kne, nosmp=0;
// alternative environment name
char *cfgname="sys/config";
@ -562,6 +562,11 @@ void ParseEnvironment(uint8_t *env)
*env=0;
env++;
}
// skip SMP initialization
if(!memcmp(env,"nosmp=1",7)){
env+=7;
nosmp=1;
}
}
}
@ -1121,7 +1126,7 @@ gzerr: panic("Unable to uncompress");
}
}
}
if(bootboot->numcores > 1 && lapic_addr) {
if(!nosmp && bootboot->numcores > 1 && lapic_addr) {
DBG(" * SMP numcores %d\n", bootboot->numcores);
memcpy((uint8_t*)0x1000, &ap_trampoline, 128);
// send Broadcast INIT IPI

View file

@ -378,7 +378,7 @@ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;
EFI_FILE_HANDLE RootDir;
EFI_FILE_PROTOCOL *Root;
SIMPLE_INPUT_INTERFACE *CI;
unsigned char *kne, bsp_done=0;
unsigned char *kne, bsp_done=0, nosmp=0;
// default environment variables. M$ states that 1024x768 must be supported
int reqwidth = 1024, reqheight = 768;
@ -1079,6 +1079,11 @@ ParseEnvironment(unsigned char *cfg, int len, INTN argc, CHAR16 **argv)
*ptr=0;
ptr++;
}
// skip SMP initialization
if(!CompareMem(ptr,(const CHAR8 *)"nosmp=1",7)){
ptr+=7;
nosmp=1;
}
}
return EFI_SUCCESS;
}
@ -1862,7 +1867,7 @@ gzerr: return report(EFI_COMPROMISED_DATA,L"Unable to uncompress");
// Symmetric Multi Processing support
#if USE_MP_SERVICES
status = uefi_call_wrapper(BS->LocateProtocol, 3, &mpspGuid, NULL, (void**)&mp);
if(!EFI_ERROR(status) && mp) {
if(!nosmp && !EFI_ERROR(status) && mp) {
// override default values in bootboot struct
status = uefi_call_wrapper(mp->GetNumberOfProcessors, 3, mp, &i, &j);
if(!EFI_ERROR(status)) {
@ -1886,12 +1891,13 @@ gzerr: return report(EFI_COMPROMISED_DATA,L"Unable to uncompress");
}
}
}
}
} else
bootboot->numcores = 1;
#else
UINT8 *ptr = (UINT8*)bootboot->arch.x86_64.acpi_ptr, *pe, *data;
UINT64 r, lapic_addr=0, ap_code = 0x8000;
ZeroMem(lapic_ids, sizeof(lapic_ids));
if(ptr && (ptr[0]=='X' || ptr[0]=='R') && ptr[1]=='S' && ptr[2]=='D' && ptr[3]=='T') {
if(!nosmp && ptr && (ptr[0]=='X' || ptr[0]=='R') && ptr[1]=='S' && ptr[2]=='D' && ptr[3]=='T') {
pe = ptr; ptr += 36;
// iterate on ACPI table pointers
for(r = *((uint32_t*)(pe + 4)); ptr < pe + r; ptr += pe[0] == 'X' ? 8 : 4) {
@ -1917,7 +1923,7 @@ gzerr: return report(EFI_COMPROMISED_DATA,L"Unable to uncompress");
status = uefi_call_wrapper(BS->AllocatePages, 4, 2, 1, 1, (EFI_PHYSICAL_ADDRESS*)&ap_code);
if(EFI_ERROR(status)) ap_code = 0;
}
if(bootboot->numcores > 1 && lapic_addr && ap_code) {
if(!nosmp && bootboot->numcores > 1 && lapic_addr && ap_code) {
DBG(L" * SMP numcores %d\n", bootboot->numcores);
CopyMem((uint8_t*)0x8000, &ap_trampoline, 256);
// save UEFI's 64 bit system registers for the trampoline code
@ -2056,7 +2062,6 @@ get_memory_map:
// green dot on the top left corner
*((uint64_t*)(bootboot->fb_ptr)) = *((uint64_t*)(bootboot->fb_ptr + bootboot->fb_scanline)) = 0x0000FF000000FF00UL;
// start APs
if(bootboot->numcores > 1) {
// send Broadcast INIT IPI