You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, unknown flags in bitfields (e.g. CR4) get automatically cleared by the library. This means that if part of the kernel uses a flag this library is not yet aware of, changing flags with this library will corrupt the environment.
This doesn't matter if all parts of the kernel use (the same version of) this crate to access the registers, but that doesn't always need to be the case. I think it would be safer to make sure unknown flags are kept unchanged (by adding a mask with all bits set? I'm not sure about that part).
The text was updated successfully, but these errors were encountered:
Thanks for reporting! I agree that this is a problem.
So we need to change Cr4 (and the other bitflag types) somehow. We could wrap them in a struct that also saves the unknown flags and ORs both values together before saving: struct Cr4 { other_flags: usize; flags: Cr4Flags; }. The other_flags field is the result of an XOR of the original value and the result of from_bits_truncate. Alternatively we could create our own bitflags macro with a from_bits_ignore function, which ignores unknown bits instead of dropping them.
Currently, unknown flags in bitfields (e.g.
CR4
) get automatically cleared by the library. This means that if part of the kernel uses a flag this library is not yet aware of, changing flags with this library will corrupt the environment.This doesn't matter if all parts of the kernel use (the same version of) this crate to access the registers, but that doesn't always need to be the case. I think it would be safer to make sure unknown flags are kept unchanged (by adding a mask with all bits set? I'm not sure about that part).
The text was updated successfully, but these errors were encountered: