x86, ext: fix buf overflow in fp80 ops; pad fp80_t in fputils
Review Request #3690 - Created Oct. 28, 2016 and submitted
| Information | |
|---|---|
| Tony Gutierrez | |
| gem5 | |
| default | |
| Reviewers | |
| Default | |
Changeset 11894:be1b22d0c36a
---------------------------
x86, ext: fix buf overflow in fp80 ops; pad fp80_t in fputilsthe compiler seems to align the fp80_t data struct, so here we add
explicit padding to avoid confusion.storeFloat80() will try to write all 16B of the fp80_t to the bits[] array
of the calling instruction. this happens because storeFloat80() points its
local fp80_t* to the memory the caller allocated for bits[], which is only
10B, thus we get an overflow that is flagged by clang's asan. here we
get the fp80 value first, the memcpy() the bits[] of fp80_t to the mem
allocated by the caller.some of the x86 FP ops also use char to represent 8b types, while the fp80
struct uses uint8_t, so here we make the x86 ops use uint8_t as well.
Description: |
|
||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+3 -3) |
Description: |
|
|---|
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+11 -9) |
Tested on X86 booting FreeBSD reverting my own simple workaround.
I can say that gem5 does no longer panic when booting FreeBSD FS with this patch applied.
I cannot say whether it works correctly currently.
However it improves the situation :)
Any thoughts? Otherwise I'll ship this soon.
Thanks for fixing this. The only technical issue I have with this patch is that it uses bit fields, which have slightly undefined semantics. I would like to avoid that if possible. I think it would be fine to just add a uitn8_t array instead after se. A non-technical issue is that we should make sure this is included in the upstream library and then pulled into ext. Could you post a pull request to https://github.com/andysan/libfputils ?
-
ext/fputils/include/fputils/fptypes.h (Diff revision 3) -
I would prefer it if we could avoid bit annotation here. The C spec seems to specify that: "The order of allocation of bit-fields within a unit (high-order to low-order or low-order to high-order) is implementation-defined."
A better solution would probably be to add a 6 byt uint8_t pad array.
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 4 (+13 -8) |
-
src/arch/x86/isa/microops/fpop.isa (Diff revision 4) -
Are these changes really needed?
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 5 (+5 -5) |
Ship It!
