-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
eir/riscv: Add ISA checks for RVA22 compliance #753
base: master
Are you sure you want to change the base?
Conversation
bc40497
to
c245a95
Compare
// All bits need to be enabled to ensure RVA22 compliance | ||
struct RiscVBits { | ||
bool i, m, a, f, d, c, zicsr, zicntr, ziccif, ziccrse, ziccamoa, zicclsm, za64rs, zihpm, zihintpause, zic64b, zicbom, zicbop, zicboz; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nicer to use an enum
to assign an index to these extensions. Then we can use a boolean array with n
entries instead of n
separate bool
s.
That would also simplify the if (!(bits.i && bits.m && bits.a && bits.f && bits.d && bits.c && bits.zicsr && bits.zicntr && bits.ziccif && bits.ziccrse && bits.ziccamoa && bits.zicclsm && bits.za64rs && bits.zihpm && bits.zihintpause && bits.zic64b && bits.zicbom && bits.zicbop && bits.zicboz))
(e.g., you could use a loop or std::all_of
to check against a static array of extensions needed for RVA22).
if (total >= data_.size()) | ||
return frg::null_opt; | ||
} | ||
return frg::string_view{off total}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not do a bounds check - I guess we'd need to do something like strnlen(off total, data_.size() - total)
.
@@ -192,6 194,17 @@ struct DeviceTreeProperty { | |||
return v.load(); | |||
} | |||
|
|||
frg::optional<frg::string_view> asString(size_t index = 0) { | |||
size_t total = 0; | |||
const char* off = reinterpret_cast<const char*>(data_.data()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We right-align pointers :^)
return frg::string_view(node.name()) == "cpus"; | ||
}, [&](auto cpus) { | ||
cpus.discoverSubnodes([](auto node) { | ||
return frg::string_view(node.name()).starts_with("cpu@"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is probably fine for now where we'll assume all cores support the same set of base extensions, but it might be nice to look for the correct one using the HART ID that gets provided by the boot protocol somehow - on UEFI, it's a configuration table (RISCV_EFI_BOOT_PROTOCOL
, GUID { 0xccd15fec, 0x6f73, 0x4eec, { 0x83, 0x95, 0x3e, 0x69, 0xe4, 0xb9, 0x40, 0xbf } }
)
bits.zicsr && bits.zicntr && bits.ziccif && bits.ziccrse && | ||
bits.ziccamoa && bits.zicclsm && bits.za64rs && bits.zihpm && | ||
bits.zihintpause && bits.zic64b && bits.zicbom && bits.zicbop && bits.zicboz)) { | ||
panicLogger() << "Processor doesn't support all RVA22 extensions!" << frg::endlog; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required
This PR adds a check in
initProcessorEarly
for riscv64 to confirm that the machine we're running on is actually RVA22 compliant and can execute thor.