Tag the exception vector/error code/flags inline asm as volatile so that it's not elided by the compiler. Without "volatile", the compiler may omit the instruction if it inlines the helper and observes that the memory isn't modified between the store in TRY_CATCH() and the load in the helper. Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx> --- lib/x86/desc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/x86/desc.c b/lib/x86/desc.c index 983d4d8..9c1228c 100644 --- a/lib/x86/desc.c +++ b/lib/x86/desc.c @@ -249,7 +249,7 @@ unsigned exception_vector(void) { unsigned char vector; - asm("movb %%gs:4, %0" : "=q"(vector)); + asm volatile("movb %%gs:4, %0" : "=q"(vector)); return vector; } @@ -265,7 +265,7 @@ unsigned exception_error_code(void) { unsigned short error_code; - asm("mov %%gs:6, %0" : "=r"(error_code)); + asm volatile("mov %%gs:6, %0" : "=r"(error_code)); return error_code; } @@ -273,7 +273,7 @@ bool exception_rflags_rf(void) { unsigned char rf_flag; - asm("movb %%gs:5, %b0" : "=q"(rf_flag)); + asm volatile("movb %%gs:5, %b0" : "=q"(rf_flag)); return rf_flag & 1; } -- 2.31.1.498.g6c1eba8ee3d-goog