Skip to content

[Feature]: Patina should allocate and manage its own stack. #567

Description

@joschock

Feature Overview

The present implementation of patina uses the stack constructed for it by whatever agent loaded the patina core. The location of the stack thus allocated is reported to the core as part of the HOB list.

Once Patina is up and running, it should allocate its own stack (with desirable properties like configurable size and guard pages, etc.) and switch to that stack instead of the one provided by the loader.

Solution Overview

  1. Patina core initialization through init_memory would continue to use the stack provided by the loader.
  2. Once memory services are available in Patina, it should allocate and initialize a new stack and switch to using that stack for the rest of the UEFI lifetime.
  3. The new stack should have desirable security properties (guard page to detect stack overrun, NX mapping).

Some additional desirable elements:

  1. We should try and use an existing crate (e.g. PSM https://crates.io/crates/psm, or perhaps extending our current corosensei fork).
  2. We should try to converge our stack construction so that it is architecturally consistent between construction of the patina core stack and construction of individual stacks for module execution.

Alternatives Considered

Do nothing: present core works well on the loader stack for the most part. But drawbacks include having portions of security story bound up in loader design choices (for example, loader may not add guard page or mark stack as NX).

Urgency

High

Are you going to implement the feature request?

Someone else needs to implement the feature

Do you need maintainer feedback?

No maintainer feedback needed

Anything else?

Marked as high urgency because it may have implications for core API (e.g. start() might need to be divergent) that we should consider sooner rather than later.

Activity

  1. added
    state:needs-triage
    type:feature-request
    on Jul 3, 2025
  2. moved this to Backlog in Patinaon Jul 31, 2025
  3. added this to the Backlog milestone on Jul 31, 2025
  4. added
    urgency:low
    on Aug 1, 2025
  5. makubacki commented on May 27, 2026

    @makubacki
    Collaborator

    @joschock, do you have any updates or thoughts for this issue? I'm auditing potentially stale issues.

  6. joschock commented on May 27, 2026

    @joschock
    ContributorAuthor

    I don't have any updates. I'd be open to feedback from the team on whether this is actually necessary or desirable. I can think of a couple potential ways to implement, but I noted those in the description.

    One element that has been implemented is that we do apply security features to the stack (Guard Page and Stack marked NX). This is part of the motivation for this change, and now that it is implemented independently, it may lessen the motivation or urgency for this feature.

  7. os-d commented on May 27, 2026

    @os-d
    Contributor

    I generically think this is a nice to have, but I don't think it is urgent. We have higher priority (while still being lower priority overall) items in the "don't trust what came before", like using PAT instead of MTRRs for cache attrs on x64

  8. added
    state:help-wanted
    on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:backlogstate:help-wantedstate:needs-triagetype:feature-requesturgency:low

    Projects

    • Status
      Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions