Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(virtio-pci): next_ptr + cfg_ptr offsets #1218

Merged
merged 1 commit into from
May 22, 2024
Merged

fix(virtio-pci): next_ptr + cfg_ptr offsets #1218

merged 1 commit into from
May 22, 2024

Conversation

jounathaen
Copy link
Member

These are two Bugs, where I am wondering how Hermit has event worked before... 🤔

@jounathaen jounathaen force-pushed the virtio-bugfix branch 2 times, most recently from 8c42956 to 7cd62fd Compare May 21, 2024 15:11
);
let notify_off_multiplier = cap
.device
.read_register(u16::try_from(cap.origin.cfg_ptr).unwrap() + 16);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do is 16 correct and cap.origin.cap_struct.cap_len wrong?

Is the following line also wrong?

https://github.com/hermit-os/kernel/blob/main/src/drivers/virtio/transport/pci.rs#L950-L952

Copy link
Member Author

Choose a reason for hiding this comment

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

This needs to read the last 4 bytes of the struct. Adding cap_len results in reading the first byte of the next struct. Likely that the other calculation is also incorrect.

Copy link
Member

Choose a reason for hiding this comment

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

I have fixed the other two uses of cfg_ptr too in the latest commits. Could you take a look?

Copy link
Member Author

@jounathaen jounathaen May 22, 2024

Choose a reason for hiding this comment

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

A little verbose, but looks good 👍

Copy link
Member

@mkroening mkroening left a comment

Choose a reason for hiding this comment

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

Can we squash the commits if they don't pass CI individually? :)

@jounathaen
Copy link
Member Author

Before merging, can sbdy test if this breaks something with QEMU? I don't have a test setup at hand

@mkroening
Copy link
Member

Before merging, can sbdy test if this breaks something with QEMU? I don't have a test setup at hand

CI passes and we test virtio-net-pci there, so everything should be fine, I think?

@mkroening mkroening changed the title Virtio bugfix fix(virtio): offsets from cfg_ptr May 22, 2024
@mkroening mkroening changed the title fix(virtio): offsets from cfg_ptr fix(virtio-pci): offsets from cfg_ptr May 22, 2024
@mkroening mkroening self-assigned this May 22, 2024
@mkroening mkroening requested a review from stlankes May 22, 2024 08:41
Bugfix: Use correct pointer in PCI capability, not the one to the proceeding element
Bugfix: Virtio Capabilities - use correct offsets from `cfg_ptr`

Co-authored-by: Martin Kröning <[email protected]>
Signed-off-by: Martin Kröning <[email protected]>
@mkroening mkroening changed the title fix(virtio-pci): offsets from cfg_ptr fix(virtio-pci): next_ptr + cfg_ptr offsets May 22, 2024
@mkroening mkroening enabled auto-merge May 22, 2024 09:00
@mkroening mkroening added this pull request to the merge queue May 22, 2024
Merged via the queue into main with commit 791221b May 22, 2024
13 checks passed
@mkroening mkroening deleted the virtio-bugfix branch May 22, 2024 13:01
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.

3 participants