Skip to content

[patina_internal_cpu] remove alloc usage#1423

Open
kuqin12 wants to merge 7 commits intoOpenDevicePartnership:mainfrom
kuqin12:bu3
Open

[patina_internal_cpu] remove alloc usage#1423
kuqin12 wants to merge 7 commits intoOpenDevicePartnership:mainfrom
kuqin12:bu3

Conversation

@kuqin12
Copy link
Contributor

@kuqin12 kuqin12 commented Mar 20, 2026

Description

Patina internal CPU hosts the interrupt manager and other fundamental functionalities, which should not work on top of the allocator.

Admittedly, the current crate can support more advanced components that works on top of exception forwarding, but this should not be treated as a required dependency.

  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?

How This Was Tested

This was tested on QEMU Q35 and booted to UEFI shell.

Integration Instructions

N/A

@patina-automation
Copy link
Contributor

patina-automation bot commented Mar 20, 2026

✅ QEMU Validation Passed

All QEMU validation jobs completed successfully.

Note: Q35 is only built on Windows hosts (QEMU boot is disabled due to a QEMU vfat issue).

Workflow run: https://github.com/OpenDevicePartnership/patina/actions/runs/23473278105

Boot Time to EFI Shell

Platform Elapsed
Q35 (Linux Host) 28.4s
SBSA (Linux Host) 34.3s

Dependencies

Repository Ref
patina bc74533
patina-dxe-core-qemu 4f98fff
patina-fw-patcher 3b8900d
patina-qemu firmware v2.0.0
patina-qemu build script b20729a

This comment was automatically generated by the Patina QEMU PR Validation Post workflow.

@codecov
Copy link

codecov bot commented Mar 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kuqin12 kuqin12 marked this pull request as ready for review March 24, 2026 00:10
@kuqin12 kuqin12 requested review from cfernald and os-d March 24, 2026 00:10
error::EfiError,
};
#[cfg(feature = "alloc")]
use patina_paging::PageTable;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design-wise it seems weird to have:

#[cfg(feature = "alloc")]
use patina_paging::PageTable;

But no cfg gate in core/patina_internal_cpu/src/interrupts/x64/interrupt_manager.rs:

use patina_paging::PageTable;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that this is imported so the PageTable trait is in scope for .dump_page_tables() to resolve in let _ = pt.dump_page_tables(far & !(UEFI_PAGE_MASK as u64), UEFI_PAGE_SIZE as u64); later in the file.

Is that the case? If so, that would no longer work with this behind alloc and that code not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good observation. Indeed you are right that original inclusion was needed to resolve the dump_page_tables call. Will remove the change as it is not enforcing the alloc usage in the first place.

As per why this was not caught anywhere, this is because patina has default set to ['alloc']. So as long as any subcrate pulling in patina, it will pick up the default feature and enable alloc globally. I will create a sub-issue and handle that in a separate PR.

#[derive(Default, Copy, Clone, IntoService)]
#[service(dyn Cpu)]
#[derive(Default, Copy, Clone)]
#[cfg_attr(feature = "alloc", derive(IntoService))]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is okay, but it would be a little more direct/clear to have something like a patina_component feature that is dependent on alloc. However, that adds more features/complexity. Feel free to ignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire patina_component is guarded behind "alloc" feature as of today. But I agree that we should mention it somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants