lkml.org 
[lkml]   [2008]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 8/24] i386: convert hardware exception 7 to an interrupt gate
    Date
    From: Alexander van Heukelum <heukelum@fastmail.fm>

    Handle no coprocessor exception with interrupt initially off.

    device_not_available in entry_32.S calls either math_state_restore
    or math_emulate. This patch adds an extra indirection to be
    able to re-enable interrupts explicitly in traps_32.c

    Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
    ---
    arch/x86/kernel/entry_32.S | 15 ++-------------
    arch/x86/kernel/traps_32.c | 14 +++++++++++++-
    2 files changed, 15 insertions(+), 14 deletions(-)

    diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
    index 109792b..5a88585 100644
    --- a/arch/x86/kernel/entry_32.S
    +++ b/arch/x86/kernel/entry_32.S
    @@ -760,20 +760,9 @@ ENTRY(device_not_available)
    RING0_INT_FRAME
    pushl $-1 # mark this as an int
    CFI_ADJUST_CFA_OFFSET 4
    - SAVE_ALL
    - GET_CR0_INTO_EAX
    - testl $0x4, %eax # EM (math emulation bit)
    - jne device_not_available_emulate
    - preempt_stop(CLBR_ANY)
    - call math_state_restore
    - jmp ret_from_exception
    -device_not_available_emulate:
    - pushl $0 # temporary storage for ORIG_EIP
    + pushl $do_device_not_available
    CFI_ADJUST_CFA_OFFSET 4
    - call math_emulate
    - addl $4, %esp
    - CFI_ADJUST_CFA_OFFSET -4
    - jmp ret_from_exception
    + jmp error_code
    CFI_ENDPROC
    END(device_not_available)

    diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
    index 5d8d057..3ddd71b 100644
    --- a/arch/x86/kernel/traps_32.c
    +++ b/arch/x86/kernel/traps_32.c
    @@ -46,6 +46,7 @@
    #include <linux/edac.h>
    #endif

    +#include <asm/processor-flags.h>
    #include <asm/arch_hooks.h>
    #include <asm/stacktrace.h>
    #include <asm/processor.h>
    @@ -1234,6 +1235,17 @@ asmlinkage void math_emulate(long arg)

    #endif /* CONFIG_MATH_EMULATION */

    +void __kprobes do_device_not_available(struct pt_regs *regs, long error)
    +{
    + if (read_cr0() & X86_CR0_EM) {
    + conditional_sti(regs);
    + math_emulate(0);
    + } else {
    + math_state_restore(); /* interrupts still off */
    + conditional_sti(regs);
    + }
    +}
    +
    void __init trap_init(void)
    {
    int i;
    @@ -1253,7 +1265,7 @@ void __init trap_init(void)
    set_system_intr_gate(4, &overflow); /* int4 can be called from all */
    set_intr_gate(5, &bounds);
    set_intr_gate(6, &invalid_op);
    - set_trap_gate(7, &device_not_available);
    + set_intr_gate(7, &device_not_available);
    set_task_gate(8, GDT_ENTRY_DOUBLEFAULT_TSS);
    set_trap_gate(9, &coprocessor_segment_overrun);
    set_trap_gate(10, &invalid_TSS);
    --
    1.5.4.3


    \
     
     \ /
      Last update: 2008-09-10 05:05    [W:0.086 / U:29.388 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site