Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions src/kboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,37 @@ static int dt_set_chosen(void)
if (fdt_setprop(dt, node, "asahi,m1n1-stage2-version", m1n1_version, strlen(m1n1_version) + 1))
bail("FDT: couldn't set asahi,m1n1-stage2-version\n");

if (dt_set_rng_seed_sep(node))
return dt_set_rng_seed_adt(node);
if (dt_set_rng_seed_sep(node)) {
if (dt_set_rng_seed_adt(node))
bail("FDT: couldn't set random seed");
}

if (!cpu_features->apple_sysregs_unlocked) {
/*
* M4 and later lose architectural state in WFI and WFIT. Add the
* bootargs to prevent Linux from crashing in the idle loop and delay
* function.
*/
const char to_append[] = " idle=nop arm64.nowfxt";
printf("FDT: appending to bootargs:%s\n", to_append);

/*
* fdt_appendprop_string would create another property value:
* "a", "b". But we want "ab", so manually create or grow the prop,
* then overwrite the \0 of the existing string.
*/
int oldlen, newlen;
void *prop_data;

if (!fdt_get_property(dt, node, "bootargs", &oldlen) || oldlen < 1)
oldlen = 1;
newlen = oldlen + sizeof(to_append) - 1;

if (fdt_setprop_placeholder(dt, node, "bootargs", newlen, &prop_data))
bail("FDT: failed to append to 'bootargs' property\n");

strncpy(prop_data + oldlen - 1, to_append, sizeof(to_append));
}

return 0;
}
Expand Down