17 May, 2012

1 commit

  • Commit ff9a184c ("ARM: 7400/1: vfp: clear fpscr length and stride bits
    on entry to sig handler") flushes the VFP state prior to entering a
    signal handler so that a VFP operation inside the handler will trap and
    force a restore of ABI-compliant registers. Reflushing and disabling VFP
    on the sigreturn path is predicated on the saved thread state indicating
    that VFP was used by the handler -- however for SMP platforms this is
    only set on context-switch, making the check unreliable and causing VFP
    register corruption in userspace since the register values are not
    necessarily those restored from the sigframe.

    This patch unconditionally flushes the VFP state after a signal handler.
    Since we already perform the flush before the handler and the flushing
    itself happens lazily, the redundant flush when VFP is not used by the
    handler is essentially a nop.

    Reported-by: Jon Medhurst
    Signed-off-by: Jon Medhurst
    Signed-off-by: Will Deacon
    Signed-off-by: Russell King

    Will Deacon
     

12 May, 2012

1 commit

  • The vfp_enable function enables access to the VFP co-processor register
    space (cp10 and cp11) on the current CPU and must be called with
    preemption disabled. Unfortunately, the vfp_init late initcall does not
    disable preemption and can lead to an oops during boot if thread
    migration occurs at the wrong time and we end up attempting to access
    the FPSID on a CPU with VFP access disabled.

    This patch fixes the initcall to call vfp_enable from a non-preemptible
    context on each CPU and adds a BUG_ON(preemptible) to ensure that any
    similar problems are easily spotted in the future.

    Cc: stable@vger.kernel.org
    Reported-by: Hyungwoo Yang
    Signed-off-by: Hyungwoo Yang
    Signed-off-by: Will Deacon
    Signed-off-by: Russell King

    Will Deacon
     

23 Apr, 2012

2 commits

  • The ARM PCS mandates that the length and stride bits of the fpscr are
    cleared on entry to and return from a public interface. Although signal
    handlers run asynchronously with respect to the interrupted function,
    the handler itself expects to run as though it has been called like a
    normal function.

    This patch updates the state mirroring the VFP hardware before entry to
    a signal handler so that it adheres to the PCS. Furthermore, we disable
    VFP to ensure that we trap on any floating point operation performed by
    the signal handler and synchronise the hardware appropriately. A check
    is inserted after the signal handler to avoid redundant flushing if VFP
    was not used.

    Reported-by: Peter Maydell
    Signed-off-by: Will Deacon
    Signed-off-by: Russell King

    Will Deacon
     
  • The user VFP state must be preserved (subject to ucontext modifications)
    across invocation of a signal handler and this is currently handled by
    vfp_{preserve,restore}_context in signal.c

    Since this code requires intimate low-level knowledge of the VFP state,
    this patch moves it into vfpmodule.c.

    Signed-off-by: Will Deacon
    Signed-off-by: Russell King

    Will Deacon
     

29 Mar, 2012

2 commits


01 Nov, 2011

1 commit

  • Building these files does not reveal a hidden need for
    any of these. Since module.h brings in the whole kitchen
    sink, it just needlessly adds 30k+ lines to the cpp burden.

    There are probably lots more, but ARM files of mach-* and plat-*
    don't get coverage via a simple yesconfig build. They will have
    to be cleaned up and tested via using their respective configs.

    Signed-off-by: Paul Gortmaker

    Paul Gortmaker
     

29 Oct, 2011

1 commit

  • …git-cur/linux-2.6-arm

    * 'devel-stable' of http://ftp.arm.linux.org.uk/pub/linux/arm/kernel/git-cur/linux-2.6-arm: (178 commits)
    ARM: 7139/1: fix compilation with CONFIG_ARM_ATAG_DTB_COMPAT and large TEXT_OFFSET
    ARM: gic, local timers: use the request_percpu_irq() interface
    ARM: gic: consolidate PPI handling
    ARM: switch from NO_MACH_MEMORY_H to NEED_MACH_MEMORY_H
    ARM: mach-s5p64x0: remove mach/memory.h
    ARM: mach-s3c64xx: remove mach/memory.h
    ARM: plat-mxc: remove mach/memory.h
    ARM: mach-prima2: remove mach/memory.h
    ARM: mach-zynq: remove mach/memory.h
    ARM: mach-bcmring: remove mach/memory.h
    ARM: mach-davinci: remove mach/memory.h
    ARM: mach-pxa: remove mach/memory.h
    ARM: mach-ixp4xx: remove mach/memory.h
    ARM: mach-h720x: remove mach/memory.h
    ARM: mach-vt8500: remove mach/memory.h
    ARM: mach-s5pc100: remove mach/memory.h
    ARM: mach-tegra: remove mach/memory.h
    ARM: plat-tcc: remove mach/memory.h
    ARM: mach-mmp: remove mach/memory.h
    ARM: mach-cns3xxx: remove mach/memory.h
    ...

    Fix up mostly pretty trivial conflicts in:
    - arch/arm/Kconfig
    - arch/arm/include/asm/localtimer.h
    - arch/arm/kernel/Makefile
    - arch/arm/mach-shmobile/board-ap4evb.c
    - arch/arm/mach-u300/core.c
    - arch/arm/mm/dma-mapping.c
    - arch/arm/mm/proc-v7.S
    - arch/arm/plat-omap/Kconfig
    largely due to some CONFIG option renaming (ie CONFIG_PM_SLEEP ->
    CONFIG_ARM_CPU_SUSPEND for the arm-specific suspend code etc) and
    addition of NEED_MACH_MEMORY_H next to HAVE_IDE.

    Linus Torvalds
     

02 Oct, 2011

1 commit

  • Distros are starting to ship with toolchains defaulting to
    hardfloat. Using such a compiler to build the kernel fails
    in the VFP directory with

    arch/arm/vfp/entry.S:1:0: sorry, unimplemented: -mfloat-abi=hard and VFP

    Adding -mfloat-abi=soft to the gcc command line fixes this.

    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

23 Sep, 2011

2 commits


23 Jul, 2011

1 commit


10 Jul, 2011

4 commits

  • Prevent a preemption event causing the initialized VFP state being
    overwritten by ensuring that the VFP hardware access is disabled
    prior to starting initialization. We can then do this in safety
    while still allowing preemption to occur.

    Signed-off-by: Russell King

    Russell King
     
  • Fix a hole in the VFP thread migration. Lets define two threads.

    Thread 1, we'll call 'interesting_thread' which is a thread which is
    running on CPU0, using VFP (so vfp_current_hw_state[0] =
    &interesting_thread->vfpstate) and gets migrated off to CPU1, where
    it continues execution of VFP instructions.

    Thread 2, we'll call 'new_cpu0_thread' which is the thread which takes
    over on CPU0. This has also been using VFP, and last used VFP on CPU0,
    but doesn't use it again.

    The following code will be executed twice:

    cpu = thread->cpu;

    /*
    * On SMP, if VFP is enabled, save the old state in
    * case the thread migrates to a different CPU. The
    * restoring is done lazily.
    */
    if ((fpexc & FPEXC_EN) && vfp_current_hw_state[cpu]) {
    vfp_save_state(vfp_current_hw_state[cpu], fpexc);
    vfp_current_hw_state[cpu]->hard.cpu = cpu;
    }
    /*
    * Thread migration, just force the reloading of the
    * state on the new CPU in case the VFP registers
    * contain stale data.
    */
    if (thread->vfpstate.hard.cpu != cpu)
    vfp_current_hw_state[cpu] = NULL;

    The first execution will be on CPU0 to switch away from 'interesting_thread'.
    interesting_thread->cpu will be 0.

    So, vfp_current_hw_state[0] points at interesting_thread->vfpstate.
    The hardware state will be saved, along with the CPU number (0) that
    it was executing on.

    'thread' will be 'new_cpu0_thread' with new_cpu0_thread->cpu = 0.
    Also, because it was executing on CPU0, new_cpu0_thread->vfpstate.hard.cpu = 0,
    and so the thread migration check is not triggered.

    This means that vfp_current_hw_state[0] remains pointing at interesting_thread.

    The second execution will be on CPU1 to switch _to_ 'interesting_thread'.
    So, 'thread' will be 'interesting_thread' and interesting_thread->cpu now
    will be 1. The previous thread executing on CPU1 is not relevant to this
    so we shall ignore that.

    We get to the thread migration check. Here, we discover that
    interesting_thread->vfpstate.hard.cpu = 0, yet interesting_thread->cpu is
    now 1, indicating thread migration. We set vfp_current_hw_state[1] to
    NULL.

    So, at this point vfp_current_hw_state[] contains the following:

    [0] = &interesting_thread->vfpstate
    [1] = NULL

    Our interesting thread now executes a VFP instruction, takes a fault
    which loads the state into the VFP hardware. Now, through the assembly
    we now have:

    [0] = &interesting_thread->vfpstate
    [1] = &interesting_thread->vfpstate

    CPU1 stops due to ptrace (and so saves its VFP state) using the thread
    switch code above), and CPU0 calls vfp_sync_hwstate().

    if (vfp_current_hw_state[cpu] == &thread->vfpstate) {
    vfp_save_state(&thread->vfpstate, fpexc | FPEXC_EN);

    BANG, we corrupt interesting_thread's VFP state by overwriting the
    more up-to-date state saved by CPU1 with the old VFP state from CPU0.

    Fix this by ensuring that we have sane semantics for the various state
    describing variables:

    1. vfp_current_hw_state[] points to the current owner of the context
    information stored in each CPUs hardware, or NULL if that state
    information is invalid.
    2. thread->vfpstate.hard.cpu always contains the most recent CPU number
    which the state was loaded into or NR_CPUS if no CPU owns the state.

    So, for a particular CPU to be a valid owner of the VFP state for a
    particular thread t, two things must be true:

    vfp_current_hw_state[cpu] == &t->vfpstate && t->vfpstate.hard.cpu == cpu.

    and that is valid from the moment a CPU loads the saved VFP context
    into the hardware. This gives clear and consistent semantics to
    interpreting these variables.

    This patch also fixes thread copying, ensuring that t->vfpstate.hard.cpu
    is invalidated, otherwise CPU0 may believe it was the last owner. The
    hole can happen thus:

    - thread1 runs on CPU2 using VFP, migrates to CPU3, exits and thread_info
    freed.
    - New thread allocated from a previously running thread on CPU2, reusing
    memory for thread1 and copying vfp.hard.cpu.

    At this point, the following are true:

    new_thread1->vfpstate.hard.cpu == 2
    &new_thread1->vfpstate == vfp_current_hw_state[2]

    Lastly, this also addresses thread flushing in a similar way to thread
    copying. Hole is:

    - thread runs on CPU0, using VFP, migrates to CPU1 but does not use VFP.
    - thread calls execve(), so thread flush happens, leaving
    vfp_current_hw_state[0] intact. This vfpstate is memset to 0 causing
    thread->vfpstate.hard.cpu = 0.
    - thread migrates back to CPU0 before using VFP.

    At this point, the following are true:

    thread->vfpstate.hard.cpu == 0
    &thread->vfpstate == vfp_current_hw_state[0]

    Signed-off-by: Russell King

    Russell King
     
  • Rename this branch to more accurately reflect why its taken, rather
    than what the following code does. It is the only caller of this code.
    This helps to clarify following changes, yet this change results in no
    actual code change.

    Document the VFP hardware state at the target of this branch.

    Signed-off-by: Russell King

    Russell King
     
  • Rename the slightly confusing 'last_VFP_context' variable to be more
    descriptive of what it actually is. This variable stores a pointer
    to the current owner's vfpstate structure for the context held in the
    VFP hardware.

    Signed-off-by: Russell King

    Russell King
     

08 Jul, 2011

1 commit

  • The presence of VFPv4 cannot be detected simply by looking at the FPSID
    subarchitecture field, as a value >= 2 signifies the architecture as
    VFPv3 or later.

    This patch reads from MVFR1 to check whether or not the fused multiply
    accumulate instructions are supported. Since these are introduced with
    VFPv4, this tells us what we need to know.

    Signed-off-by: Will Deacon

    Will Deacon
     

25 Apr, 2011

1 commit


11 Apr, 2011

2 commits


21 Mar, 2011

1 commit

  • * 'trivial' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6: (25 commits)
    video: change to new flag variable
    scsi: change to new flag variable
    rtc: change to new flag variable
    rapidio: change to new flag variable
    pps: change to new flag variable
    net: change to new flag variable
    misc: change to new flag variable
    message: change to new flag variable
    memstick: change to new flag variable
    isdn: change to new flag variable
    ieee802154: change to new flag variable
    ide: change to new flag variable
    hwmon: change to new flag variable
    dma: change to new flag variable
    char: change to new flag variable
    fs: change to new flag variable
    xtensa: change to new flag variable
    um: change to new flag variables
    s390: change to new flag variable
    mips: change to new flag variable
    ...

    Fix up trivial conflict in drivers/hwmon/Makefile

    Linus Torvalds
     

17 Mar, 2011

1 commit


24 Feb, 2011

2 commits

  • Improve the documentation for the VFP hotplug notifier handler, so
    that people better understand what's going on there and what has
    been done for them.

    Signed-off-by: Russell King

    Russell King
     
  • arch/arm/kernel/return_address.c:37:6: warning: symbol 'return_address' was not declared. Should it be static?
    arch/arm/kernel/setup.c:76:14: warning: symbol 'processor_id' was not declared. Should it be static?
    arch/arm/kernel/traps.c:259:1: warning: symbol 'die_lock' was not declared. Should it be static?
    arch/arm/vfp/vfpmodule.c:156:6: warning: symbol 'vfp_raise_sigfpe' was not declared. Should it be static?

    Signed-off-by: Russell King

    Russell King
     

07 Jan, 2011

1 commit


20 Dec, 2010

1 commit


30 Nov, 2010

1 commit

  • Directives such as .long and .word do not magically cause the
    assembler location counter to become aligned in gas. As a result,
    using these directives in code sections can result in misaligned
    data words when building a Thumb-2 kernel (CONFIG_THUMB2_KERNEL).

    This is a Bad Thing, since the ABI permits the compiler to assume
    that fundamental types of word size or above are word- aligned when
    accessing them from C. If the data is not really word-aligned,
    this can cause impaired performance and stray alignment faults in
    some circumstances.

    In general, the following rules should be applied when using data
    word declaration directives inside code sections:

    * .quad and .double:
    .align 3

    * .long, .word, .single, .float:
    .align (or .align 2)

    * .short:
    No explicit alignment required, since Thumb-2
    instructions are always 2 or 4 bytes in size.
    immediately after an instruction.

    Reviewed-by: Will Deacon
    Signed-off-by: Dave Martin
    Acked-by: Catalin Marinas
    Signed-off-by: Russell King

    Dave Martin
     

09 Jul, 2010

1 commit

  • MVFR0 and MVFR1 are only available starting with ARM1136 r1p0 release
    according to "B.5 VFP changes" in DDI0211F_arm1136_r1p0_trm.pdf. This is
    also when TLS register got added, so we can use HAS_TLS also to test for
    MVFR0 and MVFR1.

    Otherwise VFPFMRX and VFPFMXR access fails and we get:

    Internal error: Oops - undefined instruction: 0 [#1]
    PC is at no_old_VFP_process+0x8/0x3c
    LR is at __und_svc+0x48/0x80
    ...

    Signed-off-by: Tony Lindgren
    Acked-by: Catalin Marinas
    Signed-off-by: Russell King

    Tony Lindgren
     

27 May, 2010

1 commit


14 Apr, 2010

1 commit


28 Mar, 2010

1 commit


02 Mar, 2010

1 commit

  • * 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm: (100 commits)
    ARM: Eliminate decompressor -Dstatic= PIC hack
    ARM: 5958/1: ARM: U300: fix inverted clk round rate
    ARM: 5956/1: misplaced parentheses
    ARM: 5955/1: ep93xx: move timer defines into core.c and document
    ARM: 5954/1: ep93xx: move gpio interrupt support to gpio.c
    ARM: 5953/1: ep93xx: fix broken build of clock.c
    ARM: 5952/1: ARM: MM: Add ARM_L1_CACHE_SHIFT_6 for handle inside each ARCH Kconfig
    ARM: 5949/1: NUC900 add gpio virtual memory map
    ARM: 5948/1: Enable timer0 to time4 clock support for nuc910
    ARM: 5940/2: ARM: MMCI: remove custom DBG macro and printk
    ARM: make_coherent(): fix problems with highpte, part 2
    MM: Pass a PTE pointer to update_mmu_cache() rather than the PTE itself
    ARM: 5945/1: ep93xx: include correct irq.h in core.c
    ARM: 5933/1: amba-pl011: support hardware flow control
    ARM: 5930/1: Add PKMAP area description to memory.txt.
    ARM: 5929/1: Add checks to detect overlap of memory regions.
    ARM: 5928/1: Change type of VMALLOC_END to unsigned long.
    ARM: 5927/1: Make delimiters of DMA area globally visibly.
    ARM: 5926/1: Add "Virtual kernel memory..." printout.
    ARM: 5920/1: OMAP4: Enable L2 Cache
    ...

    Fix up trivial conflict in arch/arm/mach-mx25/clock.c

    Linus Torvalds
     

16 Feb, 2010

2 commits

  • If we're only reading the VFP context via the ptrace call, there's
    no need to invalidate the hardware context - we only need to do that
    on PTRACE_SETVFPREGS. This allows more efficient monitoring of a
    traced task.

    Signed-off-by: Russell King

    Russell King
     
  • The more I look at vfp_sync_state(), the more I believe it's trying
    to do its job in a really obscure way.

    Essentially, last_VFP_context[] tracks who owns the state in the VFP
    hardware. If last_VFP_context[] is the context for the thread which
    we're interested in, then the VFP hardware has context which is not
    saved in the software state - so we need to bring the software state
    up to date.

    If last_VFP_context[] is for some other thread, we really don't care
    what state the VFP hardware is in; it doesn't contain any information
    pertinent to the thread we're trying to deal with - so don't touch
    the hardware.

    Signed-off-by: Russell King

    Russell King
     

02 Feb, 2010

1 commit


18 Dec, 2009

1 commit

  • This avoids races in the VFP code where the dead thread may have
    state on another CPU. By moving this code to exit_thread(), we
    will be running as the thread, and therefore be running on the
    current CPU.

    This means that we can ensure that the only local state is accessed
    in the thread notifiers.

    Acked-by: Catalin Marinas
    Signed-off-by: Russell King

    Russell King
     

14 Dec, 2009

1 commit

  • When the VFP notifier is called for flush_thread(), we may be
    preemptible, meaning we might migrate to another CPU, which means
    referencing the current CPU number without some form of locking is
    invalid, and can cause data corruption.

    For the most cases, this isn't a problem since atomic notifiers are run
    under rcu lock, which for most configurations results in preemption
    being disabled - except when the preemptable tree-based rcu
    implementation is selected.

    Let's make it safe anyway.

    Signed-off-by: Russell King

    Russell King
     

24 Jul, 2009

2 commits


30 May, 2009

1 commit

  • This CPU generates synchronous VFP exceptions in a non-standard way -
    the FPEXC.EX bit set but without the FPSCR.IXE bit being set like in the
    VFP subarchitecture 1 or just the FPEXC.DEX bit like in VFP
    subarchitecture 2. The main problem is that the faulty instruction
    (which needs to be emulated in software) will be restarted several times
    (normally until a context switch disables the VFP). This patch ensures
    that the VFP exception is treated as synchronous.

    Signed-off-by: Catalin Marinas
    Cc: Nicolas Pitre

    Catalin Marinas