6 #define HWCAP2_FPMR (1UL << 48)
9 uint64_t get_fpmr(void) {
11 __asm__
volatile("mrs %0, s3_3_c4_c4_2" : "=r"(fpmr
));
15 void set_fpmr(uint64_t value
) {
16 __asm__
volatile("msr s3_3_c4_c4_2, %0" ::"r"(value
));
19 // Set F8S1 (bits 0-2) and LSCALE2 (bits 37-32) (to prove we treat fpmr as 64
21 const uint64_t original_fpmr
= (uint64_t)0b101010 << 32 | (uint64_t)0b101;
23 void expr_func() { set_fpmr(original_fpmr
); }
25 int main(int argc
, char *argv
[]) {
26 if (!(getauxval(AT_HWCAP2
) & HWCAP2_FPMR
))
29 // As FPMR controls a bunch of floating point options that are quite
30 // extensive, we're not going to run any floating point ops here. Instead just
31 // update the value from the debugger and check it from this program, and vice
33 set_fpmr(original_fpmr
);
35 // Here the debugger checks it read back the value above, then writes in a new
36 // value. Note that the bits are flipped in the new value.
37 uint64_t new_fpmr
= get_fpmr(); // Set break point at this line.
38 uint64_t expected_fpmr
= ((uint64_t)0b010101 << 32) | (uint64_t)0b010;
40 // If the debugger failed to update the value, exit uncleanly.
41 // This also allows you to run this program standalone to create a core file.
42 if (new_fpmr
!= expected_fpmr
)