1. 13 7月, 2015 1 次提交
    • A
      ARC: make sure instruction_pointer() returns unsigned value · f51e2f19
      Alexey Brodkin 提交于
      Currently instruction_pointer() returns pt_regs->ret and so return value
      is of type "long", which implicitly stands for "signed long".
      
      While that's perfectly fine when dealing with 32-bit values if return
      value of instruction_pointer() gets assigned to 64-bit variable sign
      extension may happen.
      
      And at least in one real use-case it happens already.
      In perf_prepare_sample() return value of perf_instruction_pointer()
      (which is an alias to instruction_pointer() in case of ARC) is assigned
      to (struct perf_sample_data)->ip (which type is "u64").
      
      And what we see if instuction pointer points to user-space application
      that in case of ARC lays below 0x8000_0000 "ip" gets set properly with
      leading 32 zeros. But if instruction pointer points to kernel address
      space that starts from 0x8000_0000 then "ip" is set with 32 leadig
      "f"-s. I.e. id instruction_pointer() returns 0x8100_0000, "ip" will be
      assigned with 0xffff_ffff__8100_0000. Which is obviously wrong.
      
      In particular that issuse broke output of perf, because perf was unable
      to associate addresses like 0xffff_ffff__8100_0000 with anything from
      /proc/kallsyms.
      
      That's what we used to see:
       ----------->8----------
        6.27%  ls       [unknown]                [k] 0xffffffff8046c5cc
        2.96%  ls       libuClibc-0.9.34-git.so  [.] memcpy
        2.25%  ls       libuClibc-0.9.34-git.so  [.] memset
        1.66%  ls       [unknown]                [k] 0xffffffff80666536
        1.54%  ls       libuClibc-0.9.34-git.so  [.] 0x000224d6
        1.18%  ls       libuClibc-0.9.34-git.so  [.] 0x00022472
       ----------->8----------
      
      With that change perf output looks much better now:
       ----------->8----------
        8.21%  ls       [kernel.kallsyms]        [k] memset
        3.52%  ls       libuClibc-0.9.34-git.so  [.] memcpy
        2.11%  ls       libuClibc-0.9.34-git.so  [.] malloc
        1.88%  ls       libuClibc-0.9.34-git.so  [.] memset
        1.64%  ls       [kernel.kallsyms]        [k] _raw_spin_unlock_irqrestore
        1.41%  ls       [kernel.kallsyms]        [k] __d_lookup_rcu
       ----------->8----------
      Signed-off-by: NAlexey Brodkin <abrodkin@synopsys.com>
      Cc: arc-linux-dev@synopsys.com
      Cc: stable@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      f51e2f19
  2. 22 6月, 2015 1 次提交
    • V
      ARCv2: Support for ARCv2 ISA and HS38x cores · 1f6ccfff
      Vineet Gupta 提交于
      The notable features are:
          - SMP configurations of upto 4 cores with coherency
          - Optional L2 Cache and IO-Coherency
          - Revised Interrupt Architecture (multiple priorites, reg banks,
              auto stack switch, auto regfile save/restore)
          - MMUv4 (PIPT dcache, Huge Pages)
          - Instructions for
      	* 64bit load/store: LDD, STD
      	* Hardware assisted divide/remainder: DIV, REM
      	* Function prologue/epilogue: ENTER_S, LEAVE_S
      	* IRQ enable/disable: CLRI, SETI
      	* pop count: FFS, FLS
      	* SETcc, BMSKN, XBFU...
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      1f6ccfff
  3. 29 8月, 2013 1 次提交
  4. 26 6月, 2013 1 次提交
    • V
      ARC: pt_regs update #5: Use real ECR for pt_regs->event vs. synth values · 502a0c77
      Vineet Gupta 提交于
      pt_regs->event was set with artificial values to identify the low level
      system event (syscall trap / breakpoint trap / exceptions / interrupts)
      
      With r8 saving out of the way, the full word can be used to save real
      ECR (Exception Cause Register) which helps idenify the event naturally,
      including additional info such as cause code, param.
      Only for Interrupts, where ECR is not applicable, do we resort to
      synthetic non ECR values.
      
      SAVE_ALL_TRAP/EXCEPTIONS can now be merged as they both use ECR with
      different runtime values.
      
      The ptrace helpers now use the sub-fields of ECR to distinguish the
      events (e.g. vector 0x25 is trap, param 0 is syscall...)
      
      The following benefits will follow:
      
      (1) This centralizes the location of where ECR is saved and will allow
          the cleanup of task->thread.cause_code ECR placeholder which is set
          in non-uniform way. Then ARC VM code can safely rely on it being
          there for purpose of finer grained VM_EXEC dcache flush (based on
          exec fault: I-TLB Miss)
      
      (2) Further, ECR being passed around from low level handlers as arg can
          be eliminated as it is part of standard reg-file in pt_regs
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      502a0c77
  5. 22 6月, 2013 4 次提交
    • V
      ARC: pt_regs update #4: r25 saved/restored unconditionally · 359105bd
      Vineet Gupta 提交于
      (This is a VERY IMP change for low level interrupt/exception handling)
      
      -----------------------------------------------------------------------
      WHAT
      -----------------------------------------------------------------------
      * User 25 now saved in pt_regs->user_r25 (vs. tsk->thread_info.user_r25)
      
      * This allows Low level interrupt code to unconditionally save r25
        (vs. the prev version which would only do it for U->K transition).
        Ofcourse for nested interrupts, only the pt_regs->user_r25 of
        bottom-most frame is useful.
      
      * simplifies the interrupt prologue/epilogue
      
      * Needed for ARCv2 ISA code and done here to keep design similar with
        ARCompact event handling
      
      -----------------------------------------------------------------------
      WHY
      -------------------------------------------------------------------------
      With CONFIG_ARC_CURR_IN_REG, r25 is used to cache "current" task pointer
      in kernel mode. So when entering kernel mode from User Mode
      - user r25 is specially safe-kept (it being a callee reg is NOT part of
        pt_regs which are saved by default on each interrupt/trap/exception)
      - r25 loaded with current task pointer.
      
      Further, if interrupt was taken in kernel mode, this is skipped since we
      know that r25 already has valid "current" pointer.
      
      With 2 level of interrupts in ARCompact ISA, detecting this is difficult
      but still possible, since we could be in kernel mode but r25 not already saved
      (in fact the stack itself might not have been switched).
      
      A. User mode
      B. L1 IRQ taken
      C. L2 IRQ taken (while on 1st line of L1 ISR)
      
      So in #C, although in kernel mode, r25 not saved (infact SP not
      switched at all)
      
      Given that ARcompact has manual stack switching, we could use a bit of
      trickey - The low level code would make sure that SP is only set to kernel
      mode value at the very end (after saving r25). So a non kernel mode SP,
      even if in kernel mode, meant r25 was NOT saved.
      
      The same paradigm won't work in ARCv2 ISA since SP is auto-switched so
      it's setting can't be delayed/constrained.
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      359105bd
    • V
      ARC: pt_regs update #3: Remove unused gutter at start of callee_regs · 16f9afe6
      Vineet Gupta 提交于
      This is trickier than prev two:
      
      * context switching code saves kernel mode callee regs in the format of
        struct callee_regs thus needs adjustment. This also reduces the height
        of topmost kernel stack frame by 1 word.
      
      * Since kernel stack unwinder is sensitive to height of topmost kernel
        stack frame, that needs a word of adjustment too.
      
      ptrace needs a bit of updating since pt_regs now diverges from
      user_regs_struct.
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      16f9afe6
    • V
    • V
      ARC: pt_regs update #1: Align pt_regs end with end of kernel stack page · 283237a0
      Vineet Gupta 提交于
      Historically, pt_regs would end at offset of 1 word from end of stack
      page.
      
              -----------------  -> START of page (task->stack)
              |               |
              | thread_info   |
              -----------------
              |               |
         ^    ~               ~
         |    ~               ~
         |    |               |
         |    |               | <---- pt_regs used to END here
              -----------------
              | 1 word GUTTER |
              ----------------- -> End of page (START of kernel stack)
      
      This required special "one-off" considerations in low level code.
      
      The root cause is very likely assumption of "empty" SP by the original
      ARC kernel hackers, despite ARC700 always been "full" SP.
      
      So finally RIP one word gutter !
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      283237a0
  6. 20 3月, 2013 1 次提交
    • V
      ARC: Fix the typo in event identifier flags used by ptrace · 367f3fcd
      Vineet Gupta 提交于
      orig_r8_IS_EXCPN and orig_r8_IS_BRKPT were same values due to a
      copy/paste error. Although it looks bad and is wrong, it really doesn't
      affect gdb working.
      
      orig_r8_IS_BRKPT is the one relevant to debugging (breakpoints), since
      it is used to provide EFA vs. ERET to a ptrace "stop_pc" request.
      
      So when gdb has inserted a breakpoint, orig_r8_IS_BRKPT is already set,
      and anything else (i.e. orig_r8_IS_EXCPN) becoming same as it, really
      doesn't hurt gdb. The corollary case, could be nasty but nobody uses the
      ptrace "stop_pc" request in that case
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      367f3fcd
  7. 16 2月, 2013 5 次提交
    • V
      ARC: UAPI Disintegrate arch/arc/include/asm · 8c2f4a8d
      Vineet Gupta 提交于
      1. ./genfilelist.pl arch/arc/include/asm/
      
      2. Create arch/arc/include/uapi/asm/Kbuild as follows
      
      	+# UAPI Header export list
      	+include include/uapi/asm-generic/Kbuild.asm
      
      3. ./disintegrate-one.pl arch/arc/include/{,uapi/}asm/<above-list>
      
      4. Edit arch/arc/include/asm/Kbuild to remove ref to
      	asm-generic/Kbuild.asm
      
      - To work around empty uapi/asm/setup.h added a placholder comment.
      - Also a manual #ifdef __ASSEMBLY__ for a late ptrace change
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      Cc: David Howells <dhowells@redhat.com>
      8c2f4a8d
    • V
      ARC: Unaligned access emulation · 2e651ea1
      Vineet Gupta 提交于
      ARC700 doesn't natively support unaligned access, but can be emulated
      -Unaligned Access Exception
      -Disassembly at the Fault address to find the exact insn (long/short)
      
      Also per Arnd's comment, we runtime control it using 2 sysctl knobs:
      * SYSCTL_ARCH_UNALIGN_ALLOW: Runtime enable/disble
      * SYSCTL_ARCH_UNALIGN_NO_WARN: Warn on each emulation attempt
      
      Originally contributed by Tim Yao <tim.yao@amlogic.com>
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      Cc: Tim Yao <tim.yao@amlogic.com>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      2e651ea1
    • V
      ARC: kprobes support · 4d86dfbb
      Vineet Gupta 提交于
      Origin port done by Rajeshwar Ranga
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      Cc: Rajeshwar Ranga <rajeshwar.ranga@gmail.com>
      4d86dfbb
    • V
      ARC: [Review] Prevent incorrect syscall restarts · 55bb9480
      Vineet Gupta 提交于
      Per Al Viro's "signals for dummies" https://lkml.org/lkml/2012/12/6/366
      there are 3 golden rules for (not) restarting syscalls:
      
      "	What we need to guarantee is
      * restarts do not happen on signals caught in interrupts or exceptions
      * restarts do not happen on signals caught in sigreturn()
      * restart should happen only once, even if we get through do_signal()
        many times."
      
      ARC Port already handled #1, this patch fixes #2 and #3.
      
      We use the additional state in pt_regs->orig_r8 to ckh if restarting
      has already been done once.
      
      Thanks to Al Viro for spotting this.
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      Cc: Al Viro <viro@ZenIV.linux.org.uk>
      55bb9480
    • V
      ARC: [Review] Preparing to fix incorrect syscall restarts due to signals · 5c39c0ab
      Vineet Gupta 提交于
      To avoid multiple syscall restarts (multiple signals) or no restart at
      all (sigreturn), we need just an extra bit of state "literally 1 bit" in
      struct pt_regs. orig_r8 is the best place to do this, however given the
      way it is encoded currently, we can't add anything simplistically.
      
      Current orig_r8:
      * syscalls   -> 1 to NR_SYSCALLS
      * Exceptions -> NR_SYSCALLS + 1
      * Break-point-> NR_SYSCALLS + 2
      
      In new scheme it is a bit-field
      * lower short word contains the  exact event type (and a new bit to represent
         restart semantics : if syscall was already / can't be restarted)
      * upper short word optionally containing the syscall num - needed by
        likes of tracehooks etc
      
      This patch only changes how orig_r8 is organised and nothing should
      change behaviourily.
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      Cc: Al Viro <viro@ZenIV.linux.org.uk>
      5c39c0ab
  8. 11 2月, 2013 3 次提交