This source file includes following definitions.
- set_dawr
- set_dawr_cb
- dawr_write_file_bool
- dawr_force_setup
1
2
3
4
5
6
7
8 #include <linux/types.h>
9 #include <linux/export.h>
10 #include <linux/fs.h>
11 #include <linux/debugfs.h>
12 #include <asm/debugfs.h>
13 #include <asm/machdep.h>
14 #include <asm/hvcall.h>
15
16 bool dawr_force_enable;
17 EXPORT_SYMBOL_GPL(dawr_force_enable);
18
19 int set_dawr(struct arch_hw_breakpoint *brk)
20 {
21 unsigned long dawr, dawrx, mrd;
22
23 dawr = brk->address;
24
25 dawrx = (brk->type & (HW_BRK_TYPE_READ | HW_BRK_TYPE_WRITE))
26 << (63 - 58);
27 dawrx |= ((brk->type & (HW_BRK_TYPE_TRANSLATE)) >> 2) << (63 - 59);
28 dawrx |= (brk->type & (HW_BRK_TYPE_PRIV_ALL)) >> 3;
29
30
31
32
33
34
35
36 mrd = ((brk->len + 7) >> 3) - 1;
37 dawrx |= (mrd & 0x3f) << (63 - 53);
38
39 if (ppc_md.set_dawr)
40 return ppc_md.set_dawr(dawr, dawrx);
41
42 mtspr(SPRN_DAWR, dawr);
43 mtspr(SPRN_DAWRX, dawrx);
44
45 return 0;
46 }
47
48 static void set_dawr_cb(void *info)
49 {
50 set_dawr(info);
51 }
52
53 static ssize_t dawr_write_file_bool(struct file *file,
54 const char __user *user_buf,
55 size_t count, loff_t *ppos)
56 {
57 struct arch_hw_breakpoint null_brk = {0, 0, 0};
58 size_t rc;
59
60
61 if (!dawr_force_enable &&
62 firmware_has_feature(FW_FEATURE_LPAR) &&
63 set_dawr(&null_brk) != H_SUCCESS)
64 return -ENODEV;
65
66 rc = debugfs_write_file_bool(file, user_buf, count, ppos);
67 if (rc)
68 return rc;
69
70
71 if (!dawr_force_enable)
72 smp_call_function(set_dawr_cb, &null_brk, 0);
73
74 return rc;
75 }
76
77 static const struct file_operations dawr_enable_fops = {
78 .read = debugfs_read_file_bool,
79 .write = dawr_write_file_bool,
80 .open = simple_open,
81 .llseek = default_llseek,
82 };
83
84 static int __init dawr_force_setup(void)
85 {
86 if (cpu_has_feature(CPU_FTR_DAWR)) {
87
88 dawr_force_enable = true;
89 return 0;
90 }
91
92 if (PVR_VER(mfspr(SPRN_PVR)) == PVR_POWER9) {
93
94 debugfs_create_file_unsafe("dawr_enable_dangerous", 0600,
95 powerpc_debugfs_root,
96 &dawr_force_enable,
97 &dawr_enable_fops);
98 }
99 return 0;
100 }
101 arch_initcall(dawr_force_setup);