• Ville Syrjälä's avatar
    x86/apm: Don't access __preempt_count with zeroed fs · 6f6060a5
    Ville Syrjälä authored
    APM_DO_POP_SEGS does not restore fs/gs which were zeroed by
    APM_DO_ZERO_SEGS. Trying to access __preempt_count with
    zeroed fs doesn't really work.
    
    Move the ibrs call outside the APM_DO_SAVE_SEGS/APM_DO_RESTORE_SEGS
    invocations so that fs is actually restored before calling
    preempt_enable().
    
    Fixes the following sort of oopses:
    [    0.313581] general protection fault: 0000 [#1] PREEMPT SMP
    [    0.313803] Modules linked in:
    [    0.314040] CPU: 0 PID: 268 Comm: kapmd Not tainted 4.16.0-rc1-triton-bisect-00090-gdd84441a #19
    [    0.316161] EIP: __apm_bios_call_simple+0xc8/0x170
    [    0.316161] EFLAGS: 00210016 CPU: 0
    [    0.316161] EAX: 00000102 EBX: 00000000 ECX: 00000102 EDX: 00000000
    [    0.316161] ESI: 0000530e EDI: dea95f64 EBP: dea95f18 ESP: dea95ef0
    [    0.316161]  DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068
    [    0.316161] CR0: 80050033 CR2: 00000000 CR3: 015d3000 CR4: 000006d0
    [    0.316161] Call Trace:
    [    0.316161]  ? cpumask_weight.constprop...
    6f6060a5
apm.h 1.73 KB