Skip to content

Commit 04cbd06

Browse files
authored
Merge pull request #1698 from seijikun/mr-disk-ioalign-fix
uefi: Fix io-align == 0 edgecase handling for ata & nvme
2 parents a8b8b61 + d6e7bb5 commit 04cbd06

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

uefi/src/proto/ata/pass_thru.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ impl AtaPassThru {
4242
/// The [`AtaPassThruMode`] structure containing configuration details of the protocol.
4343
#[must_use]
4444
pub fn mode(&self) -> AtaPassThruMode {
45-
unsafe { (*self.0.mode).clone() }
45+
let mut mode = unsafe { (*self.0.mode).clone() };
46+
mode.io_align = mode.io_align.max(1); // 0 and 1 is the same, says UEFI spec
47+
mode
4648
}
4749

4850
/// Retrieves the I/O buffer alignment required by this SCSI channel.

uefi/src/proto/nvme/pass_thru.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ impl NvmePassThru {
4949
/// An instance of [`NvmePassThruMode`] describing the NVMe controller's capabilities.
5050
#[must_use]
5151
pub fn mode(&self) -> NvmePassThruMode {
52-
unsafe { (*self.0.mode).clone() }
52+
let mut mode = unsafe { (*self.0.mode).clone() };
53+
mode.io_align = mode.io_align.max(1); // 0 and 1 is the same, says UEFI spec
54+
mode
5355
}
5456

5557
/// Retrieves the alignment requirements for I/O buffers.

0 commit comments

Comments
 (0)