lkl: pci: Never override IORESOURCE_IO#597
Merged
thehajime merged 1 commit intolkl:masterfrom Apr 26, 2025
Merged
Conversation
PCI resources can be a mix of I/O and memory resources: pci 0000:00:00.0: reg 0x10: [mem 0xc1060000-0xc1060fff pref] pci 0000:00:00.0: reg 0x14: [io 0x6040-0x607f] pci 0000:00:00.0: reg 0x18: [mem 0xc1040000-0xc105ffff] pci 0000:00:00.0: reg 0x30: [mem 0xffff0000-0xffffffff pref] In this case, the remapped_resource variable, which is filled with the address of the remapped memory resource in the first PCI BAR, should not be used for the I/O resource in the second PCI BAR. For the specific PCI device, the current code will cause errors in the device probe routine. First, the I/O resource is overridden by some invalid values, then the call to pci_request_regions will think the I/O resource is illegal and fail immediately because the I/O port is not in the normal [0, 0xffff] region. e100 0000:00:00.0: BAR 1: can't reserve [io 0xc1060000-0xc106003f] 0000:00:00.0 (uninitialized): Cannot obtain PCI resources, aborting e100: probe of 0000:00:00.0 failed with error -16 Fixes: 96de6a9 ("lkl: add PCI device interface and a vfio backend driver") Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
0ae7829 to
8aba507
Compare
tavip
approved these changes
Apr 25, 2025
thehajime
approved these changes
Apr 26, 2025
Member
|
Thanks @lrh2000 ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PCI resources can be a mix of I/O and memory resources:
In this case, the remapped_resource variable, which is filled with the address of the remapped memory resource in the first PCI BAR, should not be used for the I/O resource in the second PCI BAR.
For the specific PCI device, the current code will cause errors in the device probe routine. First, the I/O resource is overridden by some invalid values, then the call to pci_request_regions will think the I/O resource is illegal and fail immediately because the I/O port is not in the normal [0, 0xffff] region.
Fixes: 96de6a9 ("lkl: add PCI device interface and a vfio backend driver")