]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/mmiotrace.h
x86 mmiotrace: fix page-unaligned ioremaps
[mirror_ubuntu-bionic-kernel.git] / include / linux / mmiotrace.h
CommitLineData
8b7d89d0
PP
1#ifndef MMIOTRACE_H
2#define MMIOTRACE_H
3
970e6fa0 4#include <linux/types.h>
0fd0e3da
PP
5
6#include <linux/list.h>
7
8struct kmmio_probe;
9struct pt_regs;
10
11typedef void (*kmmio_pre_handler_t)(struct kmmio_probe *,
12 struct pt_regs *, unsigned long addr);
13typedef void (*kmmio_post_handler_t)(struct kmmio_probe *,
14 unsigned long condition, struct pt_regs *);
15
16struct kmmio_probe {
d61fc448 17 struct list_head list; /* kmmio internal list */
0fd0e3da
PP
18 unsigned long addr; /* start location of the probe point */
19 unsigned long len; /* length of the probe region */
20 kmmio_pre_handler_t pre_handler; /* Called before addr is executed. */
21 kmmio_post_handler_t post_handler; /* Called after addr is executed */
d61fc448 22 void *user_data;
0fd0e3da
PP
23};
24
25/* kmmio is active by some kmmio_probes? */
26static inline int is_kmmio_active(void)
27{
28 extern unsigned int kmmio_count;
29 return kmmio_count;
30}
31
0fd0e3da
PP
32extern int register_kmmio_probe(struct kmmio_probe *p);
33extern void unregister_kmmio_probe(struct kmmio_probe *p);
34
35/* Called from page fault handler. */
36extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
37
d61fc448
PP
38/* Called from ioremap.c */
39#ifdef CONFIG_MMIOTRACE
40extern void
41mmiotrace_ioremap(unsigned long offset, unsigned long size, void __iomem *addr);
42extern void mmiotrace_iounmap(volatile void __iomem *addr);
43#else
44static inline void
45mmiotrace_ioremap(unsigned long offset, unsigned long size, void __iomem *addr)
46{
47}
48static inline void mmiotrace_iounmap(volatile void __iomem *addr)
49{
50}
51#endif /* CONFIG_MMIOTRACE_HOOKS */
52
bd8ac686
PP
53enum mm_io_opcode {
54 MMIO_READ = 0x1, /* struct mmiotrace_rw */
55 MMIO_WRITE = 0x2, /* struct mmiotrace_rw */
56 MMIO_PROBE = 0x3, /* struct mmiotrace_map */
57 MMIO_UNPROBE = 0x4, /* struct mmiotrace_map */
8b7d89d0 58 MMIO_MARKER = 0x5, /* raw char data */
bd8ac686 59 MMIO_UNKNOWN_OP = 0x6, /* struct mmiotrace_rw */
8b7d89d0
PP
60};
61
bd8ac686
PP
62struct mmiotrace_rw {
63 unsigned long phys; /* PCI address of register */
64 unsigned long value;
65 unsigned long pc; /* optional program counter */
66 int map_id;
67 unsigned char opcode; /* one of MMIO_{READ,WRITE,UNKNOWN_OP} */
68 unsigned char width; /* size of register access in bytes */
8b7d89d0
PP
69};
70
bd8ac686
PP
71struct mmiotrace_map {
72 unsigned long phys; /* base address in PCI space */
73 unsigned long virt; /* base virtual address */
74 unsigned long len; /* mapping size */
75 int map_id;
76 unsigned char opcode; /* MMIO_PROBE or MMIO_UNPROBE */
8b7d89d0
PP
77};
78
bd8ac686
PP
79/* in kernel/trace/trace_mmiotrace.c */
80extern void enable_mmiotrace(void);
81extern void disable_mmiotrace(void);
82extern void mmio_trace_rw(struct mmiotrace_rw *rw);
83extern void mmio_trace_mapping(struct mmiotrace_map *map);
8b7d89d0 84
8b7d89d0 85#endif /* MMIOTRACE_H */