Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 324072
b: refs/heads/master
c: e4b8b3f
h: refs/heads/master
v: v3
  • Loading branch information
Jan Glauber authored and Martin Schwidefsky committed Sep 26, 2012
1 parent 6d16d43 commit ccd392c
Show file tree
Hide file tree
Showing 15 changed files with 301 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0d804b20735d974534abb422f723d404b779433a
refs/heads/master: e4b8b3f33fcaa0ed6e6b5482a606091d8cd20beb
4 changes: 4 additions & 0 deletions trunk/arch/s390/include/asm/cpu_mf.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@
#define CPU_MF_INT_SF_LSDA (1 << 22) /* loss of sample data alert */
#define CPU_MF_INT_CF_CACA (1 << 7) /* counter auth. change alert */
#define CPU_MF_INT_CF_LCDA (1 << 6) /* loss of counter data alert */
#define CPU_MF_INT_RI_HALTED (1 << 5) /* run-time instr. halted */
#define CPU_MF_INT_RI_BUF_FULL (1 << 4) /* run-time instr. program
buffer full */

#define CPU_MF_INT_CF_MASK (CPU_MF_INT_CF_CACA|CPU_MF_INT_CF_LCDA)
#define CPU_MF_INT_SF_MASK (CPU_MF_INT_SF_IAE|CPU_MF_INT_SF_ISE| \
CPU_MF_INT_SF_PRA|CPU_MF_INT_SF_SACA| \
CPU_MF_INT_SF_LSDA)
#define CPU_MF_INT_RI_MASK (CPU_MF_INT_RI_HALTED|CPU_MF_INT_RI_BUF_FULL)

/* CPU measurement facility support */
static inline int cpum_cf_avail(void)
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/s390/include/asm/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum interruption_class {
EXTINT_IUC,
EXTINT_CMS,
EXTINT_CMC,
EXTINT_CMR,
IOINT_CIO,
IOINT_QAI,
IOINT_DAS,
Expand Down
4 changes: 4 additions & 0 deletions trunk/arch/s390/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <asm/page.h>
#include <asm/ptrace.h>
#include <asm/setup.h>
#include <asm/runtime_instr.h>

/*
* Default implementation of macro that returns current
Expand Down Expand Up @@ -78,6 +79,9 @@ struct thread_struct {
/* pfault_wait is used to block the process on a pfault event */
unsigned long pfault_wait;
struct list_head list;
/* cpu runtime instrumentation */
struct runtime_instr_cb *ri_cb;
int ri_signum;
};

typedef struct thread_struct thread_struct;
Expand Down
4 changes: 3 additions & 1 deletion trunk/arch/s390/include/asm/ptrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ typedef struct
#define PSW_MASK_ASC 0x0000C000UL
#define PSW_MASK_CC 0x00003000UL
#define PSW_MASK_PM 0x00000F00UL
#define PSW_MASK_RI 0x00000000UL
#define PSW_MASK_EA 0x00000000UL
#define PSW_MASK_BA 0x00000000UL

Expand Down Expand Up @@ -264,10 +265,11 @@ typedef struct
#define PSW_MASK_ASC 0x0000C00000000000UL
#define PSW_MASK_CC 0x0000300000000000UL
#define PSW_MASK_PM 0x00000F0000000000UL
#define PSW_MASK_RI 0x0000008000000000UL
#define PSW_MASK_EA 0x0000000100000000UL
#define PSW_MASK_BA 0x0000000080000000UL

#define PSW_MASK_USER 0x00003F0180000000UL
#define PSW_MASK_USER 0x00003F8180000000UL

#define PSW_ADDR_AMODE 0x0000000000000000UL
#define PSW_ADDR_INSN 0xFFFFFFFFFFFFFFFFUL
Expand Down
98 changes: 98 additions & 0 deletions trunk/arch/s390/include/asm/runtime_instr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#ifndef _RUNTIME_INSTR_H
#define _RUNTIME_INSTR_H

#define S390_RUNTIME_INSTR_START 0x1
#define S390_RUNTIME_INSTR_STOP 0x2

struct runtime_instr_cb {
__u64 buf_current;
__u64 buf_origin;
__u64 buf_limit;

__u32 valid : 1;
__u32 pstate : 1;
__u32 pstate_set_buf : 1;
__u32 home_space : 1;
__u32 altered : 1;
__u32 : 3;
__u32 pstate_sample : 1;
__u32 sstate_sample : 1;
__u32 pstate_collect : 1;
__u32 sstate_collect : 1;
__u32 : 1;
__u32 halted_int : 1;
__u32 int_requested : 1;
__u32 buffer_full_int : 1;
__u32 key : 4;
__u32 : 9;
__u32 rgs : 3;

__u32 mode : 4;
__u32 next : 1;
__u32 mae : 1;
__u32 : 2;
__u32 call_type_br : 1;
__u32 return_type_br : 1;
__u32 other_type_br : 1;
__u32 bc_other_type : 1;
__u32 emit : 1;
__u32 tx_abort : 1;
__u32 : 2;
__u32 bp_xn : 1;
__u32 bp_xt : 1;
__u32 bp_ti : 1;
__u32 bp_ni : 1;
__u32 suppr_y : 1;
__u32 suppr_z : 1;

__u32 dc_miss_extra : 1;
__u32 lat_lev_ignore : 1;
__u32 ic_lat_lev : 4;
__u32 dc_lat_lev : 4;

__u64 reserved1;
__u64 scaling_factor;
__u64 rsic;
__u64 reserved2;
} __packed __aligned(8);

extern struct runtime_instr_cb runtime_instr_empty_cb;

static inline void load_runtime_instr_cb(struct runtime_instr_cb *cb)
{
asm volatile(".insn rsy,0xeb0000000060,0,0,%0" /* LRIC */
: : "Q" (*cb));
}

static inline void store_runtime_instr_cb(struct runtime_instr_cb *cb)
{
asm volatile(".insn rsy,0xeb0000000061,0,0,%0" /* STRIC */
: "=Q" (*cb) : : "cc");
}

static inline void save_ri_cb(struct runtime_instr_cb *cb_prev)
{
#ifdef CONFIG_64BIT
if (cb_prev)
store_runtime_instr_cb(cb_prev);
#endif
}

static inline void restore_ri_cb(struct runtime_instr_cb *cb_next,
struct runtime_instr_cb *cb_prev)
{
#ifdef CONFIG_64BIT
if (cb_next)
load_runtime_instr_cb(cb_next);
else if (cb_prev)
load_runtime_instr_cb(&runtime_instr_empty_cb);
#endif
}

#ifdef CONFIG_64BIT
extern void exit_thread_runtime_instr(void);
#else
static inline void exit_thread_runtime_instr(void) { }
#endif

#endif /* _RUNTIME_INSTR_H */
2 changes: 2 additions & 0 deletions trunk/arch/s390/include/asm/switch_to.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ static inline void restore_access_regs(unsigned int *acrs)
if (prev->mm) { \
save_fp_regs(&prev->thread.fp_regs); \
save_access_regs(&prev->thread.acrs[0]); \
save_ri_cb(prev->thread.ri_cb); \
} \
if (next->mm) { \
restore_fp_regs(&next->thread.fp_regs); \
restore_access_regs(&next->thread.acrs[0]); \
restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \
update_per_regs(next); \
} \
prev = __switch_to(prev,next); \
Expand Down
3 changes: 2 additions & 1 deletion trunk/arch/s390/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@
#define __NR_setns 339
#define __NR_process_vm_readv 340
#define __NR_process_vm_writev 341
#define NR_syscalls 342
#define __NR_s390_runtime_instr 342
#define NR_syscalls 343

/*
* There are some system calls that are not present on 64 bit, some
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/s390/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o
obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_cpum_cf.o
obj-$(CONFIG_64BIT) += cache.o
obj-$(CONFIG_64BIT) += runtime_instr.o cache.o

# Kexec part
S390_KEXEC_OBJS := machine_kexec.o
Expand Down
5 changes: 5 additions & 0 deletions trunk/arch/s390/kernel/compat_wrapper.S
Original file line number Diff line number Diff line change
Expand Up @@ -1646,3 +1646,8 @@ ENTRY(compat_sys_process_vm_writev_wrapper)
llgf %r0,164(%r15) # unsigned long
stg %r0,160(%r15)
jg compat_sys_process_vm_writev

ENTRY(sys_s390_runtime_instr_wrapper)
lgfr %r2,%r2 # int
lgfr %r3,%r3 # int
jg sys_s390_runtime_instr
21 changes: 21 additions & 0 deletions trunk/arch/s390/kernel/dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ enum {
LONG_INSN_POPCNT,
LONG_INSN_RISBHG,
LONG_INSN_RISBLG,
LONG_INSN_RINEXT,
LONG_INSN_RIEMIT,
};

static char *long_insn_name[] = {
Expand All @@ -330,6 +332,8 @@ static char *long_insn_name[] = {
[LONG_INSN_POPCNT] = "popcnt",
[LONG_INSN_RISBHG] = "risbhg",
[LONG_INSN_RISBLG] = "risblk",
[LONG_INSN_RINEXT] = "rinext",
[LONG_INSN_RIEMIT] = "riemit",
};

static struct insn opcode[] = {
Expand Down Expand Up @@ -582,6 +586,17 @@ static struct insn opcode_a7[] = {
{ "", 0, INSTR_INVALID }
};

static struct insn opcode_aa[] = {
#ifdef CONFIG_64BIT
{ { 0, LONG_INSN_RINEXT }, 0x00, INSTR_RI_RI },
{ "rion", 0x01, INSTR_RI_RI },
{ "tric", 0x02, INSTR_RI_RI },
{ "rioff", 0x03, INSTR_RI_RI },
{ { 0, LONG_INSN_RIEMIT }, 0x04, INSTR_RI_RI },
#endif
{ "", 0, INSTR_INVALID }
};

static struct insn opcode_b2[] = {
#ifdef CONFIG_64BIT
{ "sske", 0x2b, INSTR_RRF_M0RR },
Expand Down Expand Up @@ -1210,6 +1225,9 @@ static struct insn opcode_eb[] = {
{ "cliy", 0x55, INSTR_SIY_URD },
{ "oiy", 0x56, INSTR_SIY_URD },
{ "xiy", 0x57, INSTR_SIY_URD },
{ "lric", 0x60, INSTR_RSY_RDRM },
{ "stric", 0x61, INSTR_RSY_RDRM },
{ "mric", 0x62, INSTR_RSY_RDRM },
{ "icmh", 0x80, INSTR_RSE_RURD },
{ "icmh", 0x80, INSTR_RSY_RURD },
{ "icmy", 0x81, INSTR_RSY_RURD },
Expand Down Expand Up @@ -1408,6 +1426,9 @@ static struct insn *find_insn(unsigned char *code)
case 0xa7:
table = opcode_a7;
break;
case 0xaa:
table = opcode_aa;
break;
case 0xb2:
table = opcode_b2;
break;
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/s390/kernel/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static const struct irq_class intrclass_names[] = {
{.name = "IUC", .desc = "[EXT] IUCV" },
{.name = "CMS", .desc = "[EXT] CPU-Measurement: Sampling" },
{.name = "CMC", .desc = "[EXT] CPU-Measurement: Counter" },
{.name = "CMR", .desc = "[EXT] CPU-Measurement: RI" },
{.name = "CIO", .desc = "[I/O] Common I/O Layer Interrupt" },
{.name = "QAI", .desc = "[I/O] QDIO Adapter Interrupt" },
{.name = "DAS", .desc = "[I/O] DASD" },
Expand Down
7 changes: 7 additions & 0 deletions trunk/arch/s390/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <asm/nmi.h>
#include <asm/smp.h>
#include <asm/switch_to.h>
#include <asm/runtime_instr.h>
#include "entry.h"

asmlinkage void ret_from_fork(void) asm ("ret_from_fork");
Expand Down Expand Up @@ -132,6 +133,7 @@ EXPORT_SYMBOL(kernel_thread);
*/
void exit_thread(void)
{
exit_thread_runtime_instr();
}

void flush_thread(void)
Expand Down Expand Up @@ -170,6 +172,11 @@ int copy_thread(unsigned long clone_flags, unsigned long new_stackp,
/* Save access registers to new thread structure. */
save_access_regs(&p->thread.acrs[0]);

/* Don't copy runtime instrumentation info */
p->thread.ri_cb = NULL;
p->thread.ri_signum = 0;
frame->childregs.psw.mask &= ~PSW_MASK_RI;

#ifndef CONFIG_64BIT
/*
* save fprs to current->thread.fp_regs to merge them with
Expand Down
Loading

0 comments on commit ccd392c

Please sign in to comment.