29ff1ea8fc
- P19-init-startup-hardening: Replace panic-grade expect/unwrap in init startup paths (getns, register_scheme_to_ns, setrens, filename parsing) with graceful error handling and logging - P19-acpid-startup-hardening: Replace panic-grade calls in acpid with graceful degradation (rxsdt read failure → warn + exit 0, SDT parse → error + exit 1, I/O privilege → fatal, scheme registration → fatal, setrens → warn + continue, event loop errors → log + continue) - P18-9-msi-allocation-resilience: Regenerate with git diff -U0 -w format for maximum context resilience - fetch.rs: Change --fuzz=0 to --fuzz=3 for resilient patch application - AGENTS.md: Document robust patch generation technique as mandatory - Add P4/P5/P6/P7 patches (estale, dmi, i2c, ps2d hardening) - Add P21 kernel x2apic SMP fix patch - Multiple local recipe source improvements (redox-drm, driver-manager, driver-acpi, thermald) - Config updates for redbear-mini and redbear-device-services - Subsystem assessment document
52 lines
2.1 KiB
Diff
52 lines
2.1 KiB
Diff
diff --git a/drivers/acpid/src/aml_physmem.rs b/drivers/acpid/src/aml_physmem.rs
|
|
--- a/drivers/acpid/src/aml_physmem.rs
|
|
+++ b/drivers/acpid/src/aml_physmem.rs
|
|
@@ -143,7 +143,7 @@
|
|
#[derive(Clone)]
|
|
pub struct AmlPhysMemHandler {
|
|
page_cache: Arc<Mutex<AmlPageCache>>,
|
|
- pci_fd: Arc<Option<libredox::Fd>>,
|
|
+ pci_fd: Arc<parking_lot::RwLock<Option<libredox::Fd>>>,
|
|
aml_mutexes: Arc<Mutex<FxHashMap<u32, Arc<AmlMutex>>>>,
|
|
next_mutex_handle: Arc<AtomicU32>,
|
|
}
|
|
@@ -163,16 +163,10 @@
|
|
/// Read from a physical address.
|
|
/// Generic parameter must be u8, u16, u32 or u64.
|
|
impl AmlPhysMemHandler {
|
|
- pub fn new(pci_fd_opt: Option<&libredox::Fd>, page_cache: Arc<Mutex<AmlPageCache>>) -> Self {
|
|
- let pci_fd = if let Some(pci_fd) = pci_fd_opt {
|
|
- Some(libredox::Fd::new(pci_fd.raw()))
|
|
- } else {
|
|
- log::error!("pci_fd is not registered");
|
|
- None
|
|
- };
|
|
+ pub fn new(pci_fd: Arc<parking_lot::RwLock<Option<libredox::Fd>>>, page_cache: Arc<Mutex<AmlPageCache>>) -> Self {
|
|
Self {
|
|
page_cache,
|
|
- pci_fd: Arc::new(pci_fd),
|
|
+ pci_fd,
|
|
aml_mutexes: Arc::new(Mutex::new(FxHashMap::default())),
|
|
next_mutex_handle: Arc::new(AtomicU32::new(1)),
|
|
}
|
|
@@ -218,7 +212,8 @@
|
|
|
|
fn read_pci(&self, addr: PciAddress, off: u16, value: &mut [u8]) {
|
|
let metadata = Self::pci_call_metadata(1, addr, off);
|
|
- match &*self.pci_fd {
|
|
+ let guard = self.pci_fd.read();
|
|
+ match guard.as_ref() {
|
|
Some(pci_fd) => match pci_fd.call_ro(value, syscall::CallFlags::empty(), &metadata) {
|
|
Ok(_) => {}
|
|
Err(err) => {
|
|
@@ -236,7 +231,8 @@
|
|
|
|
fn write_pci(&self, addr: PciAddress, off: u16, value: &[u8]) {
|
|
let metadata = Self::pci_call_metadata(2, addr, off);
|
|
- match &*self.pci_fd {
|
|
+ let guard = self.pci_fd.read();
|
|
+ match guard.as_ref() {
|
|
Some(pci_fd) => match pci_fd.call_wo(value, syscall::CallFlags::empty(), &metadata) {
|
|
Ok(_) => {}
|
|
Err(err) => {
|