diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md deleted file mode 100644 index bfa6c6b8c..000000000 --- a/.github/copilot-instructions.md +++ /dev/null @@ -1,27 +0,0 @@ -# Aurora Silicon assistant policy: aura - -**Org rulebook:** https://github.com/aurora-silicon/agent-guidelines/blob/main/AGENTS.md (binding; this file only adds repo specifics). - -This is Aurora Silicon's own policy for AI coding assistants working in -this repository. It is the only assistant instruction file this tree -carries. Upstream projects' instruction files are never carried here. - -AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md are -copies of .github/aurora/AGENTS.md. The aurora-agent-policy workflow -puts them back if anything else replaces them, including an upstream -merge. To change the policy, edit .github/aurora/AGENTS.md. - -## Repo specifics - -### Testing and collaboration - -- Use the Context Mode plugin whenever it can reduce low-signal output. -- Fan independent work out to isolated agents and preserve unrelated worktrees. -- Never write unit tests after you write code. -- Highly prefer E2E tests as the sole testing mechanism. Use them to verify - complex features work. At the end of E2E tests, produce a verifiable and - repeatable artifact. -- If you must test a system in isolation, first write down all the ways it - could fail, then write the code. -- Delete low-signal unit tests that would not catch a real bug missed by E2E - tests. Preserve tests that provide distinct failure coverage. diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index bfa6c6b8c..000000000 --- a/AGENTS.md +++ /dev/null @@ -1,27 +0,0 @@ -# Aurora Silicon assistant policy: aura - -**Org rulebook:** https://github.com/aurora-silicon/agent-guidelines/blob/main/AGENTS.md (binding; this file only adds repo specifics). - -This is Aurora Silicon's own policy for AI coding assistants working in -this repository. It is the only assistant instruction file this tree -carries. Upstream projects' instruction files are never carried here. - -AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md are -copies of .github/aurora/AGENTS.md. The aurora-agent-policy workflow -puts them back if anything else replaces them, including an upstream -merge. To change the policy, edit .github/aurora/AGENTS.md. - -## Repo specifics - -### Testing and collaboration - -- Use the Context Mode plugin whenever it can reduce low-signal output. -- Fan independent work out to isolated agents and preserve unrelated worktrees. -- Never write unit tests after you write code. -- Highly prefer E2E tests as the sole testing mechanism. Use them to verify - complex features work. At the end of E2E tests, produce a verifiable and - repeatable artifact. -- If you must test a system in isolation, first write down all the ways it - could fail, then write the code. -- Delete low-signal unit tests that would not catch a real bug missed by E2E - tests. Preserve tests that provide distinct failure coverage. diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index bfa6c6b8c..000000000 --- a/CLAUDE.md +++ /dev/null @@ -1,27 +0,0 @@ -# Aurora Silicon assistant policy: aura - -**Org rulebook:** https://github.com/aurora-silicon/agent-guidelines/blob/main/AGENTS.md (binding; this file only adds repo specifics). - -This is Aurora Silicon's own policy for AI coding assistants working in -this repository. It is the only assistant instruction file this tree -carries. Upstream projects' instruction files are never carried here. - -AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md are -copies of .github/aurora/AGENTS.md. The aurora-agent-policy workflow -puts them back if anything else replaces them, including an upstream -merge. To change the policy, edit .github/aurora/AGENTS.md. - -## Repo specifics - -### Testing and collaboration - -- Use the Context Mode plugin whenever it can reduce low-signal output. -- Fan independent work out to isolated agents and preserve unrelated worktrees. -- Never write unit tests after you write code. -- Highly prefer E2E tests as the sole testing mechanism. Use them to verify - complex features work. At the end of E2E tests, produce a verifiable and - repeatable artifact. -- If you must test a system in isolation, first write down all the ways it - could fail, then write the code. -- Delete low-signal unit tests that would not catch a real bug missed by E2E - tests. Preserve tests that provide distinct failure coverage. diff --git a/GEMINI.md b/GEMINI.md deleted file mode 100644 index bfa6c6b8c..000000000 --- a/GEMINI.md +++ /dev/null @@ -1,27 +0,0 @@ -# Aurora Silicon assistant policy: aura - -**Org rulebook:** https://github.com/aurora-silicon/agent-guidelines/blob/main/AGENTS.md (binding; this file only adds repo specifics). - -This is Aurora Silicon's own policy for AI coding assistants working in -this repository. It is the only assistant instruction file this tree -carries. Upstream projects' instruction files are never carried here. - -AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md are -copies of .github/aurora/AGENTS.md. The aurora-agent-policy workflow -puts them back if anything else replaces them, including an upstream -merge. To change the policy, edit .github/aurora/AGENTS.md. - -## Repo specifics - -### Testing and collaboration - -- Use the Context Mode plugin whenever it can reduce low-signal output. -- Fan independent work out to isolated agents and preserve unrelated worktrees. -- Never write unit tests after you write code. -- Highly prefer E2E tests as the sole testing mechanism. Use them to verify - complex features work. At the end of E2E tests, produce a verifiable and - repeatable artifact. -- If you must test a system in isolation, first write down all the ways it - could fail, then write the code. -- Delete low-signal unit tests that would not catch a real bug missed by E2E - tests. Preserve tests that provide distinct failure coverage. diff --git a/docs/boot-options.md b/docs/boot-options.md index 2d366b3e4..8197400c7 100644 --- a/docs/boot-options.md +++ b/docs/boot-options.md @@ -60,7 +60,10 @@ and a guest at EL1 gets nothing. A hibernation image restores every page the OS saved to the frame it came from, so the boot that resumes it must give the OS the same RAM and keep the same ranges from it. -The payload line `hib=1`, in Stage 2's own lines (Stage 1 does not hand it on), asks +The hibernation layout is on by default on a production Stage 2, so Linux can +hibernate without a test payload line. `hib=0` turns it off. `hib=1`, in Stage 2's +own lines (Stage 1 does not hand it on), also keeps the boot watchdog armed +across the hand-off of a resume boot, and still asks kboot for a fixed layout on T6040: - the CTXR exec window is the part of CTXR_D that every placement of the boot object @@ -86,8 +89,8 @@ tree in the slot. kboot refuses the layout, says why, and boots without it when the window is not the fixed one or is not below the slot, or when aura, the boot arguments, what iBoot and Stage 1 placed, or the heap reach the slot, or when the fixed range meets a carveout or -a firmware range. Without the properties Linux refuses to hibernate. Without `hib=1` -nothing changes, the window included. +a firmware range. Without the properties Linux refuses to hibernate. `hib=0` turns the layout +off and leaves the window as it was without a fixed layout. ## DebugUSB interception (development builds) diff --git a/src/kboot.c b/src/kboot.c index 8ade5e52c..24824e8ee 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -1322,6 +1322,27 @@ void kboot_request_hibernate_layout(bool on) ctxr_exec_request_fixed_window(on && chip_id == T6040); } +/* Whether this boot may resume from a hibernation image (the hib=1 payload line). */ +static bool hib_resume_boot; + +void kboot_request_hibernate_resume_boot(bool on) +{ + hib_resume_boot = on; + if (on) + kboot_request_hibernate_layout(true); +} + +bool kboot_hibernate_resume_boot(void) +{ + return hib_resume_boot; +} + +/* Whether this boot publishes the fixed hibernation layout to Linux. */ +bool kboot_hibernate_layout_requested(void) +{ + return hib_requested; +} + /* Whether [start, end) meets a range iBoot or the firmware owns, saying which. */ static bool hib_fixed_range_taken(u64 start, u64 end) { diff --git a/src/kboot.h b/src/kboot.h index 764dcf871..94eb235bb 100644 --- a/src/kboot.h +++ b/src/kboot.h @@ -26,6 +26,9 @@ struct kernel_header { void kboot_set_initrd(void *start, size_t size); void kboot_request_hibernate_layout(bool on); +bool kboot_hibernate_layout_requested(void); +void kboot_request_hibernate_resume_boot(bool on); +bool kboot_hibernate_resume_boot(void); int kboot_set_chosen(const char *name, const char *value); void kboot_delete_chosen(const char *name); void kboot_set_config_lost(void); diff --git a/src/main.c b/src/main.c index b0881a278..9bf1a2915 100644 --- a/src/main.c +++ b/src/main.c @@ -78,6 +78,13 @@ void get_device_info(void) printf("No chosen node!\n"); } + /* + * A production boot must publish the layout so Linux can hibernate, without + * a test payload line. hib=0 in the payload turns it off. The layout is + * still refused later if this chip or this placement cannot have it. + */ + kboot_request_hibernate_layout(true); + printf("\n"); } @@ -544,7 +551,20 @@ void aura_main(void) if (aura_trial_enabled() && wdt_arm_trial()) printf("WDT: could not arm the trial watchdog\n"); #if defined(CHAINLOADING) && defined(ESP_STAGE2) - /* A plain boot's next stage brings its own watchdog: leave the hardware as Stage 2 found it. */ + /* + * A resume from hibernation (hib=1) hands to a kernel that must unfreeze its own devices + * before it can pet a watchdog; a step that wedges there would otherwise wait for the power + * button. Keep WD2 armed in reset mode across the hand-off, as a trial boot does: the kernel's + * driver finds it running and keeps it fed on a good resume, and a wedged one resets instead. + * The layout is on by default and is not itself a resume; only hib=1 keeps the watchdog. + */ + else if (kboot_hibernate_resume_boot() && wdt_arm_seconds(WDT_BOOT_SECONDS)) + printf("WDT: could not arm the hibernation-resume watchdog\n"); + else if (kboot_hibernate_resume_boot()) + printf("WDT: hibernation-resume watchdog armed until the kernel takes it (%u s)\n", + WDT_BOOT_SECONDS); + /* A plain boot without hib=1 brings its own watchdog: leave the hardware as Stage 2 found it. + */ else if (!aura_trial_enabled()) wdt_disarm_boot(); #endif diff --git a/src/payload.c b/src/payload.c index 1334513de..20edba880 100644 --- a/src/payload.c +++ b/src/payload.c @@ -354,7 +354,10 @@ static bool check_var(u8 **p) } else if (IS_VAR("tso=")) { enable_tso = val[0] == '1'; } else if (IS_VAR("hib=")) { - kboot_request_hibernate_layout(val[0] == '1'); + bool on = val[0] == '1'; + + kboot_request_hibernate_layout(on); + kboot_request_hibernate_resume_boot(on); } else { printf("Unknown variable %.*s\n", (int)(val - (char *)*p - 1), (char *)*p); } diff --git a/tests/python/test_m3_defaults_optout.py b/tests/python/test_m3_defaults_optout.py index bf82b45b5..dd697aad5 100644 --- a/tests/python/test_m3_defaults_optout.py +++ b/tests/python/test_m3_defaults_optout.py @@ -213,6 +213,7 @@ def harness(): /* kboot's handoff: /chosen as dt_set_chosen() writes it, then what the GPU code would see */ static void kboot_set_initrd(void *start, size_t size) {} static void kboot_request_hibernate_layout(bool on) { printf("HIB %d\n", on); } +static void kboot_request_hibernate_resume_boot(bool on) { printf("HIBRESUME %d\n", on); } static int kboot_prepare_dt(void *fdt) { assert(!fdt_open_into(fdt, dt, sizeof(blob))); @@ -1029,9 +1030,11 @@ def test_hib_line_asks_for_the_layout_and_is_no_loss(tools, build): b = boot(tools, build, b"hib=1\n") booted(b) assert hib_requests(b) == ["1"] and set(AIR) <= b.armed + assert [line[10:] for line in b.stdout.splitlines() if line.startswith("HIBRESUME ")] == ["1"] b = boot(tools, build, b"hib=1\nhib=0\n") booted(b) assert hib_requests(b) == ["1", "0"] + assert [line[10:] for line in b.stdout.splitlines() if line.startswith("HIBRESUME ")] == ["1", "0"] @pytest.mark.parametrize("build", STAGE2) diff --git a/tests/python/test_t6040_hibernate_layout.py b/tests/python/test_t6040_hibernate_layout.py index e7eece7a5..936b9f934 100644 --- a/tests/python/test_t6040_hibernate_layout.py +++ b/tests/python/test_t6040_hibernate_layout.py @@ -641,4 +641,5 @@ def test_hib_line_requests_the_layout(): names = payload[payload.index("static const char *const config_names[]"):] assert '"hib="' in names[:names.index("};")] var = payload[payload.index(' } else if (IS_VAR("hib=")) {'):] - assert var.split("\n")[1].strip() == "kboot_request_hibernate_layout(val[0] == '1');" + assert "kboot_request_hibernate_layout(on)" in var[:500] + assert "kboot_request_hibernate_resume_boot(on)" in var[:500]