-
Notifications
You must be signed in to change notification settings - Fork 1
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
Panic in FdtHeader::verify() when using with QEMU and RISC-V virt machine #1
Comments
In the QEMU RISC-V FDT case, I see that |
Yes, the spec says:
But there are indeed many dtb implementations that do not conform to this specification. I found I forgot to |
A new verison let dtb = match unsafe { Dtb::from_raw_parts(aligned.as_ptr() as _) } {
Ok(ans) => ans,
Err(HeaderError::LastCompVersion) => {
// ignore!
unsafe { Dtb::from_raw_parts_unchecked(aligned.as_ptr() as _) }
}
Err(e) => panic!("Verify dtb header failed: {e:?}"),
}; |
Cool! I'll try it out shortly and let you know. |
I changed my code to match your example and that seems fine. But if there are many dtb implementations that do not conform to the spec, it might be interesting for you to follow the Robustness principle: be conservative in what you do, be liberal in what you accept from others. You could change line 60 to be:
|
Emm... I'll need to chew it over. If It's necessary to write it this way, I might rather just remove this check. |
A new verison 0.1.3 was published for a new function with a filter closure which allows to ignore some let dtb = unsafe {
Dtb::from_raw_parts_filtered(aligned.as_ptr() as _, |e| {
matches!(
e,
HeaderError::Misaligned(4) | HeaderError::LastCompVersion(16)
)
})
}
.unwrap(); And there is an english readme for you :) |
Awesome, thanks :-) |
Same issue: |
I get a panic in
FdtHeader::verify()
when using with QEMU and RISC-V virt machine:called 'Result::unwrap()' on an 'Err' value: LastCompVersion
which occurs at line 60 while checking the header's minimum compatibility version. Note that this is the standard QEMU FDT for the RISC-V
virt
machine.Version info:
I run QEMU like this:
My code looks like this:
If I change it to:
It seems to work, since I get a dump of the FDT. Is it possible that this library is compatible with FDT versions older than 16? Maybe you can reduce the number?
If this library is compatible only with 16 or later, what parts don't work with older versions?
Thanks.
The text was updated successfully, but these errors were encountered: