Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile
Browse files Browse the repository at this point in the history
Pull arch/tile updates from Chris Metcalf:
 "This is a grab bag of changes that includes some NOHZ and
  context-tracking related changes, some debugging improvements,
  JUMP_LABEL support, and some fixes for tilepro allmodconfig support.

  We also remove the now-unused node_has_online_mem() definitions both
  for tile's asm/topology.h as well as in linux/topology.h itself"

* git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile:
  numa: remove stale node_has_online_mem() define
  arch/tile: move user_exit() to early kernel entry sequence
  tile: fix bug in setting PT_FLAGS_DISABLE_IRQ on kernel entry
  tile: fix tilepro casts for readl, writel, etc
  tile: fix a -Wframe-larger-than warning
  tile: include the syscall number in the backtrace
  MAINTAINERS: add git URL for tile
  arch/tile: adopt prepare_exit_to_usermode() model from x86
  tile/jump_label: add jump label support for TILE-Gx
  tile: define a macro ktext_writable_addr to get writable kernel text address
  • Loading branch information
Linus Torvalds committed Jan 18, 2016
2 parents d90f351 + 00d27c6 commit d05d82f
Show file tree
Hide file tree
Showing 25 changed files with 310 additions and 188 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -10811,6 +10811,7 @@ F: net/tipc/
TILE ARCHITECTURE
M: Chris Metcalf <cmetcalf@ezchip.com>
W: http://www.ezchip.com/scm/
T: git git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile.git
S: Supported
F: arch/tile/
F: drivers/char/tile-srom.c
Expand Down
1 change: 1 addition & 0 deletions arch/tile/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ config TILEGX
select HAVE_KRETPROBES
select HAVE_ARCH_KGDB
select ARCH_SUPPORTS_ATOMIC_RMW
select HAVE_ARCH_JUMP_LABEL

config TILEPRO
def_bool !TILEGX
Expand Down
59 changes: 59 additions & 0 deletions arch/tile/include/asm/insn.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2015 Tilera Corporation. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
* NON INFRINGEMENT. See the GNU General Public License for
* more details.
*/
#ifndef __ASM_TILE_INSN_H
#define __ASM_TILE_INSN_H

#include <arch/opcode.h>

static inline tilegx_bundle_bits NOP(void)
{
return create_UnaryOpcodeExtension_X0(FNOP_UNARY_OPCODE_X0) |
create_RRROpcodeExtension_X0(UNARY_RRR_0_OPCODE_X0) |
create_Opcode_X0(RRR_0_OPCODE_X0) |
create_UnaryOpcodeExtension_X1(NOP_UNARY_OPCODE_X1) |
create_RRROpcodeExtension_X1(UNARY_RRR_0_OPCODE_X1) |
create_Opcode_X1(RRR_0_OPCODE_X1);
}

static inline tilegx_bundle_bits tilegx_gen_branch(unsigned long pc,
unsigned long addr,
bool link)
{
tilegx_bundle_bits opcode_x0, opcode_x1;
long pcrel_by_instr = (addr - pc) >> TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES;

if (link) {
/* opcode: jal addr */
opcode_x1 =
create_Opcode_X1(JUMP_OPCODE_X1) |
create_JumpOpcodeExtension_X1(JAL_JUMP_OPCODE_X1) |
create_JumpOff_X1(pcrel_by_instr);
} else {
/* opcode: j addr */
opcode_x1 =
create_Opcode_X1(JUMP_OPCODE_X1) |
create_JumpOpcodeExtension_X1(J_JUMP_OPCODE_X1) |
create_JumpOff_X1(pcrel_by_instr);
}

/* opcode: fnop */
opcode_x0 =
create_UnaryOpcodeExtension_X0(FNOP_UNARY_OPCODE_X0) |
create_RRROpcodeExtension_X0(UNARY_RRR_0_OPCODE_X0) |
create_Opcode_X0(RRR_0_OPCODE_X0);

return opcode_x1 | opcode_x0;
}

#endif /* __ASM_TILE_INSN_H */
16 changes: 8 additions & 8 deletions arch/tile/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ extern void _tile_writew(u16 val, unsigned long addr);
extern void _tile_writel(u32 val, unsigned long addr);
extern void _tile_writeq(u64 val, unsigned long addr);

#define __raw_readb(addr) _tile_readb((unsigned long)addr)
#define __raw_readw(addr) _tile_readw((unsigned long)addr)
#define __raw_readl(addr) _tile_readl((unsigned long)addr)
#define __raw_readq(addr) _tile_readq((unsigned long)addr)
#define __raw_writeb(val, addr) _tile_writeb(val, (unsigned long)addr)
#define __raw_writew(val, addr) _tile_writew(val, (unsigned long)addr)
#define __raw_writel(val, addr) _tile_writel(val, (unsigned long)addr)
#define __raw_writeq(val, addr) _tile_writeq(val, (unsigned long)addr)
#define __raw_readb(addr) _tile_readb((unsigned long)(addr))
#define __raw_readw(addr) _tile_readw((unsigned long)(addr))
#define __raw_readl(addr) _tile_readl((unsigned long)(addr))
#define __raw_readq(addr) _tile_readq((unsigned long)(addr))
#define __raw_writeb(val, addr) _tile_writeb(val, (unsigned long)(addr))
#define __raw_writew(val, addr) _tile_writew(val, (unsigned long)(addr))
#define __raw_writel(val, addr) _tile_writel(val, (unsigned long)(addr))
#define __raw_writeq(val, addr) _tile_writeq(val, (unsigned long)(addr))

#else /* CONFIG_PCI */

Expand Down
58 changes: 58 additions & 0 deletions arch/tile/include/asm/jump_label.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2015 Tilera Corporation. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
* NON INFRINGEMENT. See the GNU General Public License for
* more details.
*/

#ifndef _ASM_TILE_JUMP_LABEL_H
#define _ASM_TILE_JUMP_LABEL_H

#include <arch/opcode.h>

#define JUMP_LABEL_NOP_SIZE TILE_BUNDLE_SIZE_IN_BYTES

static __always_inline bool arch_static_branch(struct static_key *key,
bool branch)
{
asm_volatile_goto("1:\n\t"
"nop" "\n\t"
".pushsection __jump_table, \"aw\"\n\t"
".quad 1b, %l[l_yes], %0 + %1 \n\t"
".popsection\n\t"
: : "i" (key), "i" (branch) : : l_yes);
return false;
l_yes:
return true;
}

static __always_inline bool arch_static_branch_jump(struct static_key *key,
bool branch)
{
asm_volatile_goto("1:\n\t"
"j %l[l_yes]" "\n\t"
".pushsection __jump_table, \"aw\"\n\t"
".quad 1b, %l[l_yes], %0 + %1 \n\t"
".popsection\n\t"
: : "i" (key), "i" (branch) : : l_yes);
return false;
l_yes:
return true;
}

typedef u64 jump_label_t;

struct jump_entry {
jump_label_t code;
jump_label_t target;
jump_label_t key;
};

#endif /* _ASM_TILE_JUMP_LABEL_H */
10 changes: 10 additions & 0 deletions arch/tile/include/asm/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@ static inline int pfn_valid(unsigned long pfn)
#define virt_to_page(kaddr) pfn_to_page(kaddr_to_pfn((void *)(kaddr)))
#define page_to_virt(page) pfn_to_kaddr(page_to_pfn(page))

/*
* The kernel text is mapped at MEM_SV_START as read-only. To allow
* modifying kernel text, it is also mapped at PAGE_OFFSET as read-write.
* This macro converts a kernel address to its writable kernel text mapping,
* which is used to modify the text code on a running kernel by kgdb,
* ftrace, kprobe, jump label, etc.
*/
#define ktext_writable_addr(kaddr) \
((unsigned long)(kaddr) - MEM_SV_START + PAGE_OFFSET)

struct mm_struct;
extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr);
extern pte_t *virt_to_kpte(unsigned long kaddr);
Expand Down
2 changes: 1 addition & 1 deletion arch/tile/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static inline void release_thread(struct task_struct *dead_task)
/* Nothing for now */
}

extern int do_work_pending(struct pt_regs *regs, u32 flags);
extern void prepare_exit_to_usermode(struct pt_regs *regs, u32 flags);


/*
Expand Down
8 changes: 6 additions & 2 deletions arch/tile/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,14 @@ extern void _cpu_idle(void);
#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
#define _TIF_NOHZ (1<<TIF_NOHZ)

/* Work to do as we loop to exit to user space. */
#define _TIF_WORK_MASK \
(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
_TIF_ASYNC_TLB | _TIF_NOTIFY_RESUME)

/* Work to do on any return to user space. */
#define _TIF_ALLWORK_MASK \
(_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_SINGLESTEP | \
_TIF_ASYNC_TLB | _TIF_NOTIFY_RESUME | _TIF_NOHZ)
(_TIF_WORK_MASK | _TIF_SINGLESTEP | _TIF_NOHZ)

/* Work to do at syscall entry. */
#define _TIF_SYSCALL_ENTRY_WORK \
Expand Down
3 changes: 0 additions & 3 deletions arch/tile/include/asm/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ static inline const struct cpumask *cpumask_of_node(int node)
/* For now, use numa node -1 for global allocation. */
#define pcibus_to_node(bus) ((void)(bus), -1)

/* By definition, we create nodes based on online memory. */
#define node_has_online_mem(nid) 1

#endif /* CONFIG_NUMA */

#include <asm-generic/topology.h>
Expand Down
1 change: 1 addition & 0 deletions arch/tile/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ obj-$(CONFIG_TILE_HVGLUE_TRACE) += hvglue_trace.o
obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o mcount_64.o
obj-$(CONFIG_KPROBES) += kprobes.o
obj-$(CONFIG_KGDB) += kgdb.o
obj-$(CONFIG_JUMP_LABEL) += jump_label.o

obj-y += vdso/
13 changes: 2 additions & 11 deletions arch/tile/kernel/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,12 @@
#include <asm/cacheflush.h>
#include <asm/ftrace.h>
#include <asm/sections.h>
#include <asm/insn.h>

#include <arch/opcode.h>

#ifdef CONFIG_DYNAMIC_FTRACE

static inline tilegx_bundle_bits NOP(void)
{
return create_UnaryOpcodeExtension_X0(FNOP_UNARY_OPCODE_X0) |
create_RRROpcodeExtension_X0(UNARY_RRR_0_OPCODE_X0) |
create_Opcode_X0(RRR_0_OPCODE_X0) |
create_UnaryOpcodeExtension_X1(NOP_UNARY_OPCODE_X1) |
create_RRROpcodeExtension_X1(UNARY_RRR_0_OPCODE_X1) |
create_Opcode_X1(RRR_0_OPCODE_X1);
}

static int machine_stopped __read_mostly;

int ftrace_arch_code_modify_prepare(void)
Expand Down Expand Up @@ -117,7 +108,7 @@ static int ftrace_modify_code(unsigned long pc, unsigned long old,
return -EINVAL;

/* Operate on writable kernel text mapping. */
pc_wr = pc - MEM_SV_START + PAGE_OFFSET;
pc_wr = ktext_writable_addr(pc);

if (probe_kernel_write((void *)pc_wr, &new, MCOUNT_INSN_SIZE))
return -EPERM;
Expand Down
51 changes: 18 additions & 33 deletions arch/tile/kernel/intvec_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ intvec_\vecname:
}
wh64 r52

#ifdef CONFIG_TRACE_IRQFLAGS
#if defined(CONFIG_TRACE_IRQFLAGS) || defined(CONFIG_CONTEXT_TRACKING)
.ifnc \function,handle_nmi
/*
* We finally have enough state set up to notify the irq
Expand All @@ -588,6 +588,9 @@ intvec_\vecname:
{ move r32, r2; move r33, r3 }
.endif
TRACE_IRQS_OFF
#ifdef CONFIG_CONTEXT_TRACKING
jal context_tracking_user_exit
#endif
.ifnc \function,handle_syscall
{ move r0, r30; move r1, r31 }
{ move r2, r32; move r3, r33 }
Expand Down Expand Up @@ -845,18 +848,6 @@ STD_ENTRY(interrupt_return)
.Lresume_userspace:
FEEDBACK_REENTER(interrupt_return)

/*
* Use r33 to hold whether we have already loaded the callee-saves
* into ptregs. We don't want to do it twice in this loop, since
* then we'd clobber whatever changes are made by ptrace, etc.
* Get base of stack in r32.
*/
{
GET_THREAD_INFO(r32)
movei r33, 0
}

.Lretry_work_pending:
/*
* Disable interrupts so as to make sure we don't
* miss an interrupt that sets any of the thread flags (like
Expand All @@ -867,33 +858,27 @@ STD_ENTRY(interrupt_return)
IRQ_DISABLE(r20, r21)
TRACE_IRQS_OFF /* Note: clobbers registers r0-r29 */


/* Check to see if there is any work to do before returning to user. */
/*
* See if there are any work items (including single-shot items)
* to do. If so, save the callee-save registers to pt_regs
* and then dispatch to C code.
*/
GET_THREAD_INFO(r21)
{
addi r29, r32, THREAD_INFO_FLAGS_OFFSET
moveli r1, lo16(_TIF_ALLWORK_MASK)
addi r22, r21, THREAD_INFO_FLAGS_OFFSET
moveli r20, lo16(_TIF_ALLWORK_MASK)
}
{
lw r29, r29
auli r1, r1, ha16(_TIF_ALLWORK_MASK)
lw r22, r22
auli r20, r20, ha16(_TIF_ALLWORK_MASK)
}
and r1, r29, r1
bzt r1, .Lrestore_all

/*
* Make sure we have all the registers saved for signal
* handling, notify-resume, or single-step. Call out to C
* code to figure out exactly what we need to do for each flag bit,
* then if necessary, reload the flags and recheck.
*/
and r1, r22, r20
{
PTREGS_PTR(r0, PTREGS_OFFSET_BASE)
bnz r33, 1f
bzt r1, .Lrestore_all
}
push_extra_callee_saves r0
movei r33, 1
1: jal do_work_pending
bnz r0, .Lretry_work_pending
jal prepare_exit_to_usermode

/*
* In the NMI case we
Expand Down Expand Up @@ -1327,7 +1312,7 @@ STD_ENTRY(ret_from_kernel_thread)
FEEDBACK_REENTER(ret_from_kernel_thread)
{
movei r30, 0 /* not an NMI */
j .Lresume_userspace /* jump into middle of interrupt_return */
j interrupt_return
}
STD_ENDPROC(ret_from_kernel_thread)

Expand Down
Loading

0 comments on commit d05d82f

Please sign in to comment.