dawr.c (0898782247ae533d1f4e47a06bc5d4870931b284) dawr.c (b57aeab811db07295f646808b1b17c312d17f57d)
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * DAWR infrastructure
4 *
5 * Copyright 2019, Michael Neuling, IBM Corporation.
6 */
7
8#include <linux/types.h>

--- 16 unchanged lines hidden (view full) ---

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 * DAWR length is stored in field MDR bits 48:53. Matches range in
31 * doublewords (64 bits) baised by -1 eg. 0b000000=1DW and
32 * 0b111111=64DW.
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * DAWR infrastructure
4 *
5 * Copyright 2019, Michael Neuling, IBM Corporation.
6 */
7
8#include <linux/types.h>

--- 16 unchanged lines hidden (view full) ---

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 * DAWR length is stored in field MDR bits 48:53. Matches range in
31 * doublewords (64 bits) baised by -1 eg. 0b000000=1DW and
32 * 0b111111=64DW.
33 * brk->len is in bytes.
33 * brk->hw_len is in bytes.
34 * This aligns up to double word size, shifts and does the bias.
35 */
34 * This aligns up to double word size, shifts and does the bias.
35 */
36 mrd = ((brk->len + 7) >> 3) - 1;
36 mrd = ((brk->hw_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

--- 4 unchanged lines hidden (view full) ---

49{
50 set_dawr(info);
51}
52
53static ssize_t dawr_write_file_bool(struct file *file,
54 const char __user *user_buf,
55 size_t count, loff_t *ppos)
56{
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

--- 4 unchanged lines hidden (view full) ---

49{
50 set_dawr(info);
51}
52
53static 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};
57 struct arch_hw_breakpoint null_brk = {0};
58 size_t rc;
59
60 /* Send error to user if they hypervisor won't allow us to write DAWR */
61 if (!dawr_force_enable &&
62 firmware_has_feature(FW_FEATURE_LPAR) &&
63 set_dawr(&null_brk) != H_SUCCESS)
64 return -ENODEV;
65

--- 36 unchanged lines hidden ---
58 size_t rc;
59
60 /* Send error to user if they hypervisor won't allow us to write DAWR */
61 if (!dawr_force_enable &&
62 firmware_has_feature(FW_FEATURE_LPAR) &&
63 set_dawr(&null_brk) != H_SUCCESS)
64 return -ENODEV;
65

--- 36 unchanged lines hidden ---