Changeset 2b4a9f26 in mainline for kernel/arch/ia32/include/asm.h


Ignore:
Timestamp:
2010-05-20T19:30:18Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
42bbbe2
Parents:
b10e6e31
Message:

Add interrupts-disabled spinlocks whose purpose is the semantic distinction between spinlocks acquired always with interrupts disabled and normal spinlocks.
The compile-time distinction is implemented by the means of the type system and basic code correctness properties can be checked by the debugging assertions during run-time (with CONFIG_DEBUG)

  • Correct bracketing of top-level interrupts-disabled spinlocks
  • Correctness of the use of nested interrupts-disabled spinlocks (interrupts must be actually disabled)
  • Basic consistency of places where the interrupt level is restored

The API encapsulates the physical manipulation with the interrupt levels and also two common locking patterns

  • Sequential unlocking of spinlock A before locking of spinlock B without restoring original interrupt level (irq_spinlock_pass())
  • Hand-over-hand locking of two locks in the correct locking order, e.g. if A precedes B, then locking of B before unlocking A (irq_spinlock_exchange())

A new HAL function interrupts_disabled() should be implemented in each port to support the run-time checks of correctly disabled interrupts while locking nested interrupts-disabled spinlocks
(only in debug builds, not used in non-debug builds).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/include/asm.h

    rb10e6e31 r2b4a9f26  
    3838
    3939#include <arch/pm.h>
     40#include <arch/cpu.h>
    4041#include <typedefs.h>
    4142#include <config.h>
     
    299300}
    300301
     302/** Check interrupts state.
     303 *
     304 * @return True if interrupts are disabled.
     305 *
     306 */
     307static inline bool interrupts_disabled(void)
     308{
     309        ipl_t v;
     310       
     311        asm volatile (
     312                "pushf\n"
     313                "popl %[v]\n"
     314                : [v] "=r" (v)
     315        );
     316       
     317        return ((v & EFLAGS_IF) == 0);
     318}
     319
    301320/** Write to MSR */
    302321static inline void write_msr(uint32_t msr, uint64_t value)
Note: See TracChangeset for help on using the changeset viewer.