History

Merge tag 'powerpc-7.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux

Pull powerpc fixes from Madhavan Srinivasan: - Fix KASAN sanitization flag for core_$(BITS).o - Fixes for handling offset values in pseries htmdump - Fix interrupt mask in cpm1_gpiochip_add16() - ps3/pasemi fixes to drop redundant result assignment - Fixes in papr-hvpipe code path - powerpc/perf: Update check for PERF_SAMPLE_DATA_SRC marked events Thanks to Aboorva Devarajan, Athira Rajeev, Christophe Leroy (CS GROUP), Geert Uytterhoeven, Haren Myneni, Krzysztof Kozlowski, Mukesh Kumar Chaurasiya (IBM), Nathan Chancellor, Ritesh Harjani (IBM), Shivani Nittor, Sourabh Jain, Thomas Zimmermann, and Venkat Rao Bagalkote. * tag 'powerpc-7.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (21 commits) powerpc/pasemi: Drop redundant res assignment powerpc/ps3: Drop redundant result assignment powerpc/vdso: Drop -DCC_USING_PATCHABLE_FUNCTION_ENTRY from 32-bit flags with clang arch/powerpc: Drop CONFIG_FIRMWARE_EDID from defconfig files powerpc/perf: Update check for PERF_SAMPLE_DATA_SRC marked events powerpc/8xx: Fix interrupt mask in cpm1_gpiochip_add16() powerpc/vmx: avoid KASAN instrumentation in enter_vmx_ops() for kexec powerpc/kdump: fix KASAN sanitization flag for core_$(BITS).o pseries/papr-hvpipe: Fix style and checkpatch issues in enable_hvpipe_IRQ() pseries/papr-hvpipe: Refactor and simplify hvpipe_rtas_recv_msg() pseries/papr-hvpipe: Kill task_struct pointer from struct hvpipe_source_info pseries/papr-hvpipe: Simplify spin unlock usage in papr_hvpipe_handle_release() pseries/papr-hvpipe: Fix the usage of copy_to_user() pseries/papr-hvpipe: Fix & simplify error handling in papr_hvpipe_init() pseries/papr-hvpipe: Fix null ptr deref in papr_hvpipe_dev_create_handle() pseries/papr-hvpipe: Prevent kernel stack memory leak to userspace pseries/papr-hvpipe: Fix race with interrupt handler powerpc/pseries/htmdump: Add memory configuration dump support to htmdump module powerpc/pseries/htmdump: Fix the offset value used in htm status dump powerpc/pseries/htmdump: Fix the offset value used in processor configuration dump ...

Linus Torvalds committed 6 months ago

Commit bf0e0222 parents 7039050 f583bd518 files · +235 −121Browse files

Unified · Split

18 files
  1. arch/powerpc/configs/amigaone_defconfig +0 −1
  2. arch/powerpc/configs/chrp32_defconfig +0 −1
  3. arch/powerpc/configs/g5_defconfig +0 −1
  4. arch/powerpc/configs/pasemi_defconfig +0 −1
  5. arch/powerpc/configs/powernv_defconfig +0 −1
  6. arch/powerpc/configs/ppc64_defconfig +0 −1
  7. arch/powerpc/configs/ppc64e_defconfig +0 −1
  8. arch/powerpc/configs/skiroot_defconfig +0 −1
  9. arch/powerpc/kernel/vdso/Makefile +6 −0
  10. arch/powerpc/kexec/Makefile +1 −1
  11. arch/powerpc/lib/vmx-helper.c +8 −1
  12. arch/powerpc/perf/core-book3s.c +3 −2
  13. arch/powerpc/platforms/8xx/cpm1.c +2 −2
  14. arch/powerpc/platforms/pasemi/pci.c +1 −2
  15. arch/powerpc/platforms/ps3/device-init.c +1 −3
  16. arch/powerpc/platforms/pseries/htmdump.c +116 −17
  17. arch/powerpc/platforms/pseries/papr-hvpipe.c +97 −84
  18. arch/powerpc/platforms/pseries/papr-hvpipe.h +0 −1
arch/powerpc/configs/amigaone_defconfig+0−1
@@ -76,7 +76,6 @@ CONFIG_SERIAL_8250_CONSOLE=y · 75 unmodified lines
76# CONFIG_HW_RANDOM is not set76# CONFIG_HW_RANDOM is not set
77# CONFIG_HWMON is not set77# CONFIG_HWMON is not set
78CONFIG_FB=y78CONFIG_FB=y
79CONFIG_FIRMWARE_EDID=y
80CONFIG_FB_TILEBLITTING=y79CONFIG_FB_TILEBLITTING=y
81CONFIG_FB_RADEON=y80CONFIG_FB_RADEON=y
82CONFIG_FB_3DFX=y81CONFIG_FB_3DFX=y
arch/powerpc/configs/chrp32_defconfig+0−1
@@ -76,7 +76,6 @@ CONFIG_SERIAL_8250_CONSOLE=y · 75 unmodified lines
76CONFIG_NVRAM=y76CONFIG_NVRAM=y
77# CONFIG_HWMON is not set77# CONFIG_HWMON is not set
78CONFIG_FB=y78CONFIG_FB=y
79CONFIG_FIRMWARE_EDID=y
80CONFIG_FB_OF=y79CONFIG_FB_OF=y
81CONFIG_FB_MATROX=y80CONFIG_FB_MATROX=y
82CONFIG_FB_MATROX_MILLENIUM=y81CONFIG_FB_MATROX_MILLENIUM=y
arch/powerpc/configs/g5_defconfig+0−1
@@ -121,7 +121,6 @@ CONFIG_I2C_CHARDEV=y · 120 unmodified lines
121CONFIG_AGP=m121CONFIG_AGP=m
122CONFIG_AGP_UNINORTH=m122CONFIG_AGP_UNINORTH=m
123CONFIG_FB=y123CONFIG_FB=y
124CONFIG_FIRMWARE_EDID=y
125CONFIG_FB_TILEBLITTING=y124CONFIG_FB_TILEBLITTING=y
126CONFIG_FB_OF=y125CONFIG_FB_OF=y
127CONFIG_FB_NVIDIA=y126CONFIG_FB_NVIDIA=y
arch/powerpc/configs/pasemi_defconfig+0−1
@@ -98,7 +98,6 @@ CONFIG_SENSORS_LM85=y · 97 unmodified lines
98CONFIG_SENSORS_LM90=y98CONFIG_SENSORS_LM90=y
99CONFIG_DRM=y99CONFIG_DRM=y
100CONFIG_DRM_RADEON=y100CONFIG_DRM_RADEON=y
101CONFIG_FIRMWARE_EDID=y
102CONFIG_FB_TILEBLITTING=y101CONFIG_FB_TILEBLITTING=y
103CONFIG_FB_VGA16=y102CONFIG_FB_VGA16=y
104CONFIG_FB_NVIDIA=y103CONFIG_FB_NVIDIA=y
arch/powerpc/configs/powernv_defconfig+0−1
@@ -196,7 +196,6 @@ CONFIG_I2C_CHARDEV=y · 195 unmodified lines
196# CONFIG_PTP_1588_CLOCK is not set196# CONFIG_PTP_1588_CLOCK is not set
197CONFIG_DRM=y197CONFIG_DRM=y
198CONFIG_DRM_AST=y198CONFIG_DRM_AST=y
199CONFIG_FIRMWARE_EDID=y
200CONFIG_FB_OF=y199CONFIG_FB_OF=y
201CONFIG_FB_MATROX=m200CONFIG_FB_MATROX=m
202CONFIG_FB_MATROX_MILLENIUM=y201CONFIG_FB_MATROX_MILLENIUM=y
arch/powerpc/configs/ppc64_defconfig+0−1
@@ -249,7 +249,6 @@ CONFIG_I2C_CHARDEV=y · 248 unmodified lines
249CONFIG_I2C_AMD8111=y249CONFIG_I2C_AMD8111=y
250CONFIG_I2C_PASEMI=y250CONFIG_I2C_PASEMI=y
251CONFIG_FB=y251CONFIG_FB=y
252CONFIG_FIRMWARE_EDID=y
253CONFIG_FB_OF=y252CONFIG_FB_OF=y
254CONFIG_FB_MATROX=y253CONFIG_FB_MATROX=y
255CONFIG_FB_MATROX_MILLENIUM=y254CONFIG_FB_MATROX_MILLENIUM=y
arch/powerpc/configs/ppc64e_defconfig+0−1
@@ -118,7 +118,6 @@ CONFIG_SERIAL_8250_CONSOLE=y · 117 unmodified lines
118CONFIG_I2C_CHARDEV=y118CONFIG_I2C_CHARDEV=y
119CONFIG_I2C_AMD8111=y119CONFIG_I2C_AMD8111=y
120CONFIG_FB=y120CONFIG_FB=y
121CONFIG_FIRMWARE_EDID=y
122CONFIG_FB_OF=y121CONFIG_FB_OF=y
123CONFIG_FB_MATROX=y122CONFIG_FB_MATROX=y
124CONFIG_FB_MATROX_MILLENIUM=y123CONFIG_FB_MATROX_MILLENIUM=y
arch/powerpc/configs/skiroot_defconfig+0−1
@@ -214,7 +214,6 @@ CONFIG_SENSORS_IBMPOWERNV=m · 213 unmodified lines
214CONFIG_DRM=m214CONFIG_DRM=m
215CONFIG_DRM_AST=m215CONFIG_DRM_AST=m
216CONFIG_FB=y216CONFIG_FB=y
217CONFIG_FIRMWARE_EDID=y
218# CONFIG_VGA_CONSOLE is not set217# CONFIG_VGA_CONSOLE is not set
219CONFIG_FRAMEBUFFER_CONSOLE=y218CONFIG_FRAMEBUFFER_CONSOLE=y
220CONFIG_LOGO=y219CONFIG_LOGO=y
arch/powerpc/kernel/vdso/Makefile+6−0
@@ -62,6 +62,12 @@ CC32FLAGSREMOVE += -fno-stack-clash-protection · 61 unmodified lines
62# 32-bit one. clang validates the values passed to these arguments during62# 32-bit one. clang validates the values passed to these arguments during
63# parsing, even when -fno-stack-protector is passed afterwards.63# parsing, even when -fno-stack-protector is passed afterwards.
64CC32FLAGSREMOVE += -mstack-protector-guard%64CC32FLAGSREMOVE += -mstack-protector-guard%
65# ftrace is disabled for the vdso but arch/powerpc/Makefile adds this define to
66# KBUILD_CPPFLAGS, which enables use of the 'patchable_function_entry'
67# attribute in the 'inline' define via 'notrace'. This attribute is not
68# supported for the powerpcle target, resulting in many instances of
69# -Wunknown-attributes.
70CC32FLAGSREMOVE += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
65endif71endif
66LD32FLAGS := -Wl,-soname=linux-vdso32.so.172LD32FLAGS := -Wl,-soname=linux-vdso32.so.1
67AS32FLAGS := -D__VDSO32__73AS32FLAGS := -D__VDSO32__
arch/powerpc/kexec/Makefile+1−1
@@ -16,4 +16,4 @@ GCOV_PROFILE_core_$(BITS).o := n · 15 unmodified lines
16KCOV_INSTRUMENT_core_$(BITS).o := n16KCOV_INSTRUMENT_core_$(BITS).o := n
17UBSAN_SANITIZE_core_$(BITS).o := n17UBSAN_SANITIZE_core_$(BITS).o := n
18KASAN_SANITIZE_core.o := n18KASAN_SANITIZE_core.o := n
19KASAN_SANITIZE_core_$(BITS) := n19KASAN_SANITIZE_core_$(BITS).o := n
arch/powerpc/lib/vmx-helper.c+8−1
@@ -52,7 +52,14 @@ int exit_vmx_usercopy(void) · 51 unmodified lines
52}52}
53EXPORT_SYMBOL(exit_vmx_usercopy);53EXPORT_SYMBOL(exit_vmx_usercopy);
54 54
55int enter_vmx_ops(void)55/*
56 * Can be called from kexec copy_page() path with MMU off. The kexec
57 * code sets preempt_count to HARDIRQ_OFFSET so we return early here.
58 * Since in_interrupt() is always inline, __no_sanitize_address on this
59 * function is sufficient to avoid KASAN shadow memory accesses in real
60 * mode.
61 */
62int __no_sanitize_address enter_vmx_ops(void)
56{63{
57 if (in_interrupt())64 if (in_interrupt())
58 return 0;65 return 0;
arch/powerpc/perf/core-book3s.c+3−2
@@ -2242,6 +2242,7 @@ static void record_and_restart(struct perf_event *event, unsigned long val, · 2241 unmodified lines
2242 const u64 last_period = event->hw.last_period;2242 const u64 last_period = event->hw.last_period;
2243 s64 prev, delta, left;2243 s64 prev, delta, left;
2244 int record = 0;2244 int record = 0;
2245 int mark_event = regs->dsisr & MMCRA_SAMPLE_ENABLE;
2245 2246
2246 if (event->hw.state & PERF_HES_STOPPED) {2247 if (event->hw.state & PERF_HES_STOPPED) {
2247 write_pmc(event->hw.idx, 0);2248 write_pmc(event->hw.idx, 0);
@@ -2304,9 +2305,9 @@ static void record_and_restart(struct perf_event *event, unsigned long val, · 56 unmodified lines
2304 * In ISA v3.0 and before values "0" and "7" are considered reserved.2305 * In ISA v3.0 and before values "0" and "7" are considered reserved.
2305 * In ISA v3.1, value "7" has been used to indicate "larx/stcx".2306 * In ISA v3.1, value "7" has been used to indicate "larx/stcx".
2306 * Drop the sample if "type" has reserved values for this field with a2307 * Drop the sample if "type" has reserved values for this field with a
2307 * ISA version check.2308 * ISA version check for marked events.
2308 */2309 */
2309 if (event->attr.sample_type & PERF_SAMPLE_DATA_SRC &&2310 if (mark_event && event->attr.sample_type & PERF_SAMPLE_DATA_SRC &&
2310 ppmu->get_mem_data_src) {2311 ppmu->get_mem_data_src) {
2311 val = (regs->dar & SIER_TYPE_MASK) >> SIER_TYPE_SHIFT;2312 val = (regs->dar & SIER_TYPE_MASK) >> SIER_TYPE_SHIFT;
2312 if (val == 0 || (val == 7 && !cpu_has_feature(CPU_FTR_ARCH_31))) {2313 if (val == 0 || (val == 7 && !cpu_has_feature(CPU_FTR_ARCH_31))) {
arch/powerpc/platforms/8xx/cpm1.c+2−2
@@ -477,7 +477,7 @@ int cpm1_gpiochip_add16(struct device *dev) · 476 unmodified lines
477 struct device_node *np = dev->of_node;477 struct device_node *np = dev->of_node;
478 struct cpm1_gpio16_chip *cpm1_gc;478 struct cpm1_gpio16_chip *cpm1_gc;
479 struct gpio_chip *gc;479 struct gpio_chip *gc;
480 u16 mask;480 u32 mask;
481 481
482 cpm1_gc = devm_kzalloc(dev, sizeof(*cpm1_gc), GFP_KERNEL);482 cpm1_gc = devm_kzalloc(dev, sizeof(*cpm1_gc), GFP_KERNEL);
483 if (!cpm1_gc)483 if (!cpm1_gc)
@@ -485,7 +485,7 @@ int cpm1_gpiochip_add16(struct device *dev) · 1 unmodified line
485 485
486 spin_lock_init(&cpm1_gc->lock);486 spin_lock_init(&cpm1_gc->lock);
487 487
488 if (!of_property_read_u16(np, "fsl,cpm1-gpio-irq-mask", &mask)) {488 if (!of_property_read_u32(np, "fsl,cpm1-gpio-irq-mask", &mask)) {
489 int i, j;489 int i, j;
490 490
491 for (i = 0, j = 0; i < 16; i++)491 for (i = 0, j = 0; i < 16; i++)
arch/powerpc/platforms/pasemi/pci.c+1−2
@@ -272,13 +272,12 @@ void __init pas_pci_init(void) · 271 unmodified lines
272{272{
273 struct device_node *root = of_find_node_by_path("/");273 struct device_node *root = of_find_node_by_path("/");
274 struct device_node *np;274 struct device_node *np;
275 int res;
276 275
277 pci_set_flags(PCI_SCAN_ALL_PCIE_DEVS);276 pci_set_flags(PCI_SCAN_ALL_PCIE_DEVS);
278 277
279 np = of_find_compatible_node(root, NULL, "pasemi,rootbus");278 np = of_find_compatible_node(root, NULL, "pasemi,rootbus");
280 if (np) {279 if (np) {
281 res = pas_add_bridge(np);280 pas_add_bridge(np);
282 of_node_put(np);281 of_node_put(np);
283 }282 }
284 of_node_put(root);283 of_node_put(root);
arch/powerpc/platforms/ps3/device-init.c+1−3
@@ -950,8 +950,6 @@ static int __init ps3_start_probe_thread(enum ps3_bus_type bus_type) · 949 unmodified lines
950 950
951static int __init ps3_register_devices(void)951static int __init ps3_register_devices(void)
952{952{
953 int result;
954
955 if (!firmware_has_feature(FW_FEATURE_PS3_LV1))953 if (!firmware_has_feature(FW_FEATURE_PS3_LV1))
956 return -ENODEV;954 return -ENODEV;
957 955
@@ -959,7 +957,7 @@ static int __init ps3_register_devices(void) · 1 unmodified line
959 957
960 /* ps3_repository_dump_bus_info(); */958 /* ps3_repository_dump_bus_info(); */
961 959
962 result = ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE);960 ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE);
963 961
964 ps3_register_vuart_devices();962 ps3_register_vuart_devices();
965 963
arch/powerpc/platforms/pseries/htmdump.c+116−17
@@ -16,6 +16,7 @@ static void *htm_buf; · 15 unmodified lines
16static void *htm_status_buf;16static void *htm_status_buf;
17static void *htm_info_buf;17static void *htm_info_buf;
18static void *htm_caps_buf;18static void *htm_caps_buf;
19static void *htm_mem_buf;
19static u32 nodeindex;20static u32 nodeindex;
20static u32 nodalchipindex;21static u32 nodalchipindex;
21static u32 coreindexonchip;22static u32 coreindexonchip;
@@ -86,7 +87,7 @@ static ssize_t htm_return_check(long rc) · 64 unmodified lines
86static ssize_t htmdump_read(struct file *filp, char __user *ubuf,87static ssize_t htmdump_read(struct file *filp, char __user *ubuf,
87 size_t count, loff_t *ppos)88 size_t count, loff_t *ppos)
88{89{
89 void *htm_buf = filp->private_data;90 void *htm_buf_data = filp->private_data;
90 unsigned long page, read_size, available;91 unsigned long page, read_size, available;
91 loff_t offset;92 loff_t offset;
92 long rc, ret;93 long rc, ret;
@@ -100,7 +101,7 @@ static ssize_t htmdump_read(struct file *filp, char __user *ubuf, · 7 unmodified lines
100 * - last three values are address, size and offset101 * - last three values are address, size and offset
101 */102 */
102 rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,103 rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
103 htmtype, H_HTM_OP_DUMP_DATA, virt_to_phys(htm_buf),104 htmtype, H_HTM_OP_DUMP_DATA, virt_to_phys(htm_buf_data),
104 PAGE_SIZE, page);105 PAGE_SIZE, page);
105 106
106 ret = htm_return_check(rc);107 ret = htm_return_check(rc);
@@ -112,7 +113,61 @@ static ssize_t htmdump_read(struct file *filp, char __user *ubuf, · 5 unmodified lines
112 available = PAGE_SIZE;113 available = PAGE_SIZE;
113 read_size = min(count, available);114 read_size = min(count, available);
114 *ppos += read_size;115 *ppos += read_size;
115 return simple_read_from_buffer(ubuf, count, &offset, htm_buf, available);116 return simple_read_from_buffer(ubuf, count, &offset, htm_buf_data, available);
117}
118
119static ssize_t htmsystem_mem_read(struct file *filp, char __user *ubuf,
120 size_t count, loff_t *ppos)
121{
122 void *htm_mem_data = filp->private_data;
123 long rc, ret;
124 u64 *num_entries;
125 u64 to_copy = 0;
126 loff_t offset = 0;
127 u64 mem_offset = 0;
128
129 /*
130 * Invoke H_HTM call with:
131 * - operation as htm status (H_HTM_OP_STATUS)
132 * - last three values as addr, size and offset. "offset"
133 * is value from output buffer header that points to next
134 * entry to dump. 0 is the first entry to dump. next entry
135 * is read from the output bufferbyte offset 0x8.
136 *
137 * When first time hcall is invoked, mem_offset should be
138 * zero because zero is the first entry.
139 * In the next hcall, offset of next entry to read from is
140 * picked from output buffer header itself. So don't fill
141 * mem_offset for first read.
142 *
143 * If there is no further data to read in next iteration,
144 * offset value from output buffer header will point to -1.
145 */
146 if (*ppos) {
147 mem_offset = *(u64 *)(htm_mem_data + 0x8);
148 if (mem_offset == -1)
149 return 0;
150 }
151 rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
152 htmtype, H_HTM_OP_DUMP_SYSMEM_CONF, virt_to_phys(htm_mem_data),
153 PAGE_SIZE, be64_to_cpu(mem_offset));
154 ret = htm_return_check(rc);
155 if (ret <= 0) {
156 pr_debug("H_HTM hcall returned for op: H_HTM_OP_DUMP_SYSMEM_CONF with hcall returning %ld\n", ret);
157 return ret;
158 }
159
160 /*
161 * HTM system mem buffer, start of buffer + 0x10 gives the
162 * number of HTM entries in the buffer.
163 * So total count to copy is:
164 * 32 bytes (for first 5 fields) + (number of HTM entries * entry size)
165 */
166 num_entries = htm_mem_data + 0x10;
167 to_copy = 32 + (be64_to_cpu(*num_entries) * 32);
168
169 *ppos += to_copy;
170 return simple_read_from_buffer(ubuf, count, &offset, htm_mem_data, to_copy);
116}171}
117 172
118static const struct file_operations htmdump_fops = {173static const struct file_operations htmdump_fops = {
@@ -121,6 +176,12 @@ static const struct file_operations htmdump_fops = { · 2 unmodified lines
121 .open = simple_open,176 .open = simple_open,
122};177};
123 178
179static const struct file_operations htmsystem_mem_fops = {
180 .llseek = NULL,
181 .read = htmsystem_mem_read,
182 .open = simple_open,
183};
184
124static int htmconfigure_set(void *data, u64 val)185static int htmconfigure_set(void *data, u64 val)
125{186{
126 long rc, ret;187 long rc, ret;
@@ -226,20 +287,31 @@ static int htmstart_get(void *data, u64 *val) · 99 unmodified lines
226static ssize_t htmstatus_read(struct file *filp, char __user *ubuf,287static ssize_t htmstatus_read(struct file *filp, char __user *ubuf,
227 size_t count, loff_t *ppos)288 size_t count, loff_t *ppos)
228{289{
229 void *htm_status_buf = filp->private_data;290 void *htm_status_data = filp->private_data;
230 long rc, ret;291 long rc, ret;
231 u64 *num_entries;292 u64 *num_entries;
232 u64 to_copy;293 u64 to_copy;
233 int htmstatus_flag;294 int htmstatus_flag;
295 loff_t offset = 0;
296 u64 status_offset = 0;
234 297
235 /*298 /*
236 * Invoke H_HTM call with:299 * Invoke H_HTM call with:
237 * - operation as htm status (H_HTM_OP_STATUS)300 * - operation as htm status (H_HTM_OP_STATUS)
238 * - last three values as addr, size and offset301 * - last three values as addr, size and offset.
302 * "offset" is value from output buffer header
303 * that points to next entry to dump. 0 is the first
304 * entry to dump. next entry is read from the output
305 * bufferbyte offset 0x8.
239 */306 */
307 if (*ppos) {
308 status_offset = *(u64 *)(htm_status_data + 0x8);
309 if (status_offset == -1)
310 return 0;
311 }
240 rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,312 rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
241 htmtype, H_HTM_OP_STATUS, virt_to_phys(htm_status_buf),313 htmtype, H_HTM_OP_STATUS, virt_to_phys(htm_status_data),
242 PAGE_SIZE, 0);314 PAGE_SIZE, be64_to_cpu(status_offset));
243 315
244 ret = htm_return_check(rc);316 ret = htm_return_check(rc);
245 if (ret <= 0) {317 if (ret <= 0) {
@@ -255,13 +327,15 @@ static ssize_t htmstatus_read(struct file *filp, char __user *ubuf, · 9 unmodified lines
255 * So total count to copy is:327 * So total count to copy is:
256 * 32 bytes (for first 7 fields) + (number of HTM entries * entry size)328 * 32 bytes (for first 7 fields) + (number of HTM entries * entry size)
257 */329 */
258 num_entries = htm_status_buf + 0x10;330 num_entries = htm_status_data + 0x10;
259 if (htmtype == 0x2)331 if (htmtype == 0x2)
260 htmstatus_flag = 0x8;332 htmstatus_flag = 0x8;
261 else333 else
262 htmstatus_flag = 0x6;334 htmstatus_flag = 0x6;
263 to_copy = 32 + (be64_to_cpu(*num_entries) * htmstatus_flag);335 to_copy = 32 + (be64_to_cpu(*num_entries) * htmstatus_flag);
264 return simple_read_from_buffer(ubuf, count, ppos, htm_status_buf, to_copy);336 *ppos += to_copy;
337
338 return simple_read_from_buffer(ubuf, count, &offset, htm_status_data, to_copy);
265}339}
266 340
267static const struct file_operations htmstatus_fops = {341static const struct file_operations htmstatus_fops = {
@@ -273,19 +347,30 @@ static const struct file_operations htmstatus_fops = { · 5 unmodified lines
273static ssize_t htminfo_read(struct file *filp, char __user *ubuf,347static ssize_t htminfo_read(struct file *filp, char __user *ubuf,
274 size_t count, loff_t *ppos)348 size_t count, loff_t *ppos)
275{349{
276 void *htm_info_buf = filp->private_data;350 void *htm_info_data = filp->private_data;
277 long rc, ret;351 long rc, ret;
278 u64 *num_entries;352 u64 *num_entries;
279 u64 to_copy;353 u64 to_copy;
354 loff_t offset = 0;
355 u64 info_offset = 0;
280 356
281 /*357 /*
282 * Invoke H_HTM call with:358 * Invoke H_HTM call with:
283 * - operation as htm status (H_HTM_OP_STATUS)359 * - operation as htm status (H_HTM_OP_STATUS)
284 * - last three values as addr, size and offset360 * - last three values as addr, size and offset
361 * "offset" is value from output buffer header
362 * that points to next entry to dump. 0 is the first
363 * entry to dump. next entry is read from the output
364 * bufferbyte offset 0x8.
285 */365 */
366 if (*ppos) {
367 info_offset = *(u64 *)(htm_info_data + 0x8);
368 if (info_offset == -1)
369 return 0;
370 }
286 rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,371 rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
287 htmtype, H_HTM_OP_DUMP_SYSPROC_CONF, virt_to_phys(htm_info_buf),372 htmtype, H_HTM_OP_DUMP_SYSPROC_CONF, virt_to_phys(htm_info_data),
288 PAGE_SIZE, 0);373 PAGE_SIZE, be64_to_cpu(info_offset));
289 374
290 ret = htm_return_check(rc);375 ret = htm_return_check(rc);
291 if (ret <= 0) {376 if (ret <= 0) {
@@ -301,15 +386,17 @@ static ssize_t htminfo_read(struct file *filp, char __user *ubuf, · 9 unmodified lines
301 * So total count to copy is:386 * So total count to copy is:
302 * 32 bytes (for first 5 fields) + (number of HTM entries * entry size)387 * 32 bytes (for first 5 fields) + (number of HTM entries * entry size)
303 */388 */
304 num_entries = htm_info_buf + 0x10;389 num_entries = htm_info_data + 0x10;
305 to_copy = 32 + (be64_to_cpu(*num_entries) * 16);390 to_copy = 32 + (be64_to_cpu(*num_entries) * 16);
306 return simple_read_from_buffer(ubuf, count, ppos, htm_info_buf, to_copy);391
392 *ppos += to_copy;
393 return simple_read_from_buffer(ubuf, count, &offset, htm_info_data, to_copy);
307}394}
308 395
309static ssize_t htmcaps_read(struct file *filp, char __user *ubuf,396static ssize_t htmcaps_read(struct file *filp, char __user *ubuf,
310 size_t count, loff_t *ppos)397 size_t count, loff_t *ppos)
311{398{
312 void *htm_caps_buf = filp->private_data;399 void *htm_caps_data = filp->private_data;
313 long rc, ret;400 long rc, ret;
314 401
315 /*402 /*
@@ -319,7 +406,7 @@ static ssize_t htmcaps_read(struct file *filp, char __user *ubuf, · 3 unmodified lines
319 * and zero406 * and zero
320 */407 */
321 rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,408 rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
322 htmtype, H_HTM_OP_CAPABILITIES, virt_to_phys(htm_caps_buf),409 htmtype, H_HTM_OP_CAPABILITIES, virt_to_phys(htm_caps_data),
323 0x80, 0);410 0x80, 0);
324 411
325 ret = htm_return_check(rc);412 ret = htm_return_check(rc);
@@ -328,7 +415,7 @@ static ssize_t htmcaps_read(struct file *filp, char __user *ubuf, · 2 unmodified lines
328 return ret;415 return ret;
329 }416 }
330 417
331 return simple_read_from_buffer(ubuf, count, ppos, htm_caps_buf, 0x80);418 return simple_read_from_buffer(ubuf, count, ppos, htm_caps_data, 0x80);
332}419}
333 420
334static const struct file_operations htminfo_fops = {421static const struct file_operations htminfo_fops = {
@@ -457,9 +544,17 @@ static int htmdump_init_debugfs(void) · 122 unmodified lines
457 return -ENOMEM;544 return -ENOMEM;
458 }545 }
459 546
547 /* Memory to present HTM system memory configuration */
548 htm_mem_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
549 if (!htm_mem_buf) {
550 pr_err("Failed to allocate htm mem buf\n");
551 return -ENOMEM;
552 }
553
460 debugfs_create_file("htmstatus", 0400, htmdump_debugfs_dir, htm_status_buf, &htmstatus_fops);554 debugfs_create_file("htmstatus", 0400, htmdump_debugfs_dir, htm_status_buf, &htmstatus_fops);
461 debugfs_create_file("htminfo", 0400, htmdump_debugfs_dir, htm_info_buf, &htminfo_fops);555 debugfs_create_file("htminfo", 0400, htmdump_debugfs_dir, htm_info_buf, &htminfo_fops);
462 debugfs_create_file("htmcaps", 0400, htmdump_debugfs_dir, htm_caps_buf, &htmcaps_fops);556 debugfs_create_file("htmcaps", 0400, htmdump_debugfs_dir, htm_caps_buf, &htmcaps_fops);
557 debugfs_create_file("htmsystem_mem", 0400, htmdump_debugfs_dir, htm_mem_buf, &htmsystem_mem_fops);
463 558
464 return 0;559 return 0;
465}560}
@@ -482,6 +577,10 @@ static void __exit htmdump_exit(void) · 16 unmodified lines
482{577{
483 debugfs_remove_recursive(htmdump_debugfs_dir);578 debugfs_remove_recursive(htmdump_debugfs_dir);
484 kfree(htm_buf);579 kfree(htm_buf);
580 kfree(htm_status_buf);
581 kfree(htm_info_buf);
582 kfree(htm_caps_buf);
583 kfree(htm_mem_buf);
485}584}
486 585
487module_init(htmdump_init);586module_init(htmdump_init);
arch/powerpc/platforms/pseries/papr-hvpipe.c+97−84
@@ -190,33 +190,34 @@ static int hvpipe_rtas_recv_msg(char __user *buf, int size) · 189 unmodified lines
190 return -ENOMEM;190 return -ENOMEM;
191 }191 }
192 192
193 ret = rtas_ibm_receive_hvpipe_msg(work_area, &srcID,193 /*
194 &bytes_written);194 * Recv HVPIPE RTAS is successful.
195 if (!ret) {195 * When releasing FD or no one is waiting on the
196 /*196 * specific source, issue recv HVPIPE RTAS call
197 * Recv HVPIPE RTAS is successful.197 * so that pipe is not blocked - this func is called
198 * When releasing FD or no one is waiting on the198 * with NULL buf.
199 * specific source, issue recv HVPIPE RTAS call199 */
200 * so that pipe is not blocked - this func is called200 ret = rtas_ibm_receive_hvpipe_msg(work_area, &srcID, &bytes_written);
201 * with NULL buf.201 if (ret) {
202 */202 pr_err("ibm,receive-hvpipe-msg failed with %d\n", ret);
203 if (buf) {203 goto out;
204 if (size < bytes_written) {
205 pr_err("Received the payload size = %d, but the buffer size = %d\n",
206 bytes_written, size);
207 bytes_written = size;
208 }
209 ret = copy_to_user(buf,
210 rtas_work_area_raw_buf(work_area),
211 bytes_written);
212 if (!ret)
213 ret = bytes_written;
214 }
215 } else {
216 pr_err("ibm,receive-hvpipe-msg failed with %d\n",
217 ret);
218 }204 }
219 205
206 if (!buf)
207 goto out;
208
209 if (size < bytes_written) {
210 pr_err("Received the payload size = %d, but the buffer size = %d\n",
211 bytes_written, size);
212 bytes_written = size;
213 }
214
215 if (copy_to_user(buf, rtas_work_area_raw_buf(work_area), bytes_written))
216 ret = -EFAULT;
217 else
218 ret = bytes_written;
219
220out:
220 rtas_work_area_free(work_area);221 rtas_work_area_free(work_area);
221 return ret;222 return ret;
222}223}
@@ -327,8 +328,8 @@ static ssize_t papr_hvpipe_handle_read(struct file *file, · 104 unmodified lines
327{328{
328 329
329 struct hvpipe_source_info *src_info = file->private_data;330 struct hvpipe_source_info *src_info = file->private_data;
330 struct papr_hvpipe_hdr hdr;331 struct papr_hvpipe_hdr hdr = {};
331 long ret;332 ssize_t ret = 0;
332 333
333 /*334 /*
334 * Return -ENXIO during migration335 * Return -ENXIO during migration
@@ -376,7 +377,7 @@ static ssize_t papr_hvpipe_handle_read(struct file *file, · 41 unmodified lines
376 377
377 ret = copy_to_user(buf, &hdr, HVPIPE_HDR_LEN);378 ret = copy_to_user(buf, &hdr, HVPIPE_HDR_LEN);
378 if (ret)379 if (ret)
379 return ret;380 return -EFAULT;
380 381
381 /*382 /*
382 * Message event has payload, so get the payload with383 * Message event has payload, so get the payload with
@@ -385,19 +386,23 @@ static ssize_t papr_hvpipe_handle_read(struct file *file, · 2 unmodified lines
385 if (hdr.flags & HVPIPE_MSG_AVAILABLE) {386 if (hdr.flags & HVPIPE_MSG_AVAILABLE) {
386 ret = hvpipe_rtas_recv_msg(buf + HVPIPE_HDR_LEN,387 ret = hvpipe_rtas_recv_msg(buf + HVPIPE_HDR_LEN,
387 size - HVPIPE_HDR_LEN);388 size - HVPIPE_HDR_LEN);
388 if (ret > 0) {389 /*
390 * Always clear MSG_AVAILABLE once the RTAS call has drained
391 * the message, regardless of whether copy_to_user succeeded.
392 */
393 if (ret >= 0 || ret == -EFAULT)
389 src_info->hvpipe_status &= ~HVPIPE_MSG_AVAILABLE;394 src_info->hvpipe_status &= ~HVPIPE_MSG_AVAILABLE;
390 ret += HVPIPE_HDR_LEN;
391 }
392 } else if (hdr.flags & HVPIPE_LOST_CONNECTION) {395 } else if (hdr.flags & HVPIPE_LOST_CONNECTION) {
393 /*396 /*
394 * Hypervisor is closing the pipe for the specific397 * Hypervisor is closing the pipe for the specific
395 * source. So notify user space.398 * source. So notify user space.
396 */399 */
397 src_info->hvpipe_status &= ~HVPIPE_LOST_CONNECTION;400 src_info->hvpipe_status &= ~HVPIPE_LOST_CONNECTION;
398 ret = HVPIPE_HDR_LEN;
399 }401 }
400 402
403 if (ret >= 0)
404 ret += HVPIPE_HDR_LEN;
405
401 return ret;406 return ret;
402}407}
403 408
@@ -444,16 +449,18 @@ static int papr_hvpipe_handle_release(struct inode *inode, · 40 unmodified lines
444 struct file *file)449 struct file *file)
445{450{
446 struct hvpipe_source_info *src_info;451 struct hvpipe_source_info *src_info;
452 unsigned long flags;
447 453
448 /*454 /*
449 * Hold the lock, remove source from src_list, reset the455 * Hold the lock, remove source from src_list, reset the
450 * hvpipe status and release the lock to prevent any race456 * hvpipe status and release the lock to prevent any race
451 * with message event IRQ.457 * with message event IRQ.
452 */458 */
453 spin_lock(&hvpipe_src_list_lock);459 spin_lock_irqsave(&hvpipe_src_list_lock, flags);
454 src_info = file->private_data;460 src_info = file->private_data;
455 list_del(&src_info->list);461 list_del(&src_info->list);
456 file->private_data = NULL;462 file->private_data = NULL;
463 spin_unlock_irqrestore(&hvpipe_src_list_lock, flags);
457 /*464 /*
458 * If the pipe for this specific source has any pending465 * If the pipe for this specific source has any pending
459 * payload, issue recv HVPIPE RTAS so that pipe will not466 * payload, issue recv HVPIPE RTAS so that pipe will not
@@ -461,10 +468,8 @@ static int papr_hvpipe_handle_release(struct inode *inode, · 1 unmodified line
461 */468 */
462 if (src_info->hvpipe_status & HVPIPE_MSG_AVAILABLE) {469 if (src_info->hvpipe_status & HVPIPE_MSG_AVAILABLE) {
463 src_info->hvpipe_status = 0;470 src_info->hvpipe_status = 0;
464 spin_unlock(&hvpipe_src_list_lock);
465 hvpipe_rtas_recv_msg(NULL, 0);471 hvpipe_rtas_recv_msg(NULL, 0);
466 } else472 }
467 spin_unlock(&hvpipe_src_list_lock);
468 473
469 kfree(src_info);474 kfree(src_info);
470 return 0;475 return 0;
@@ -479,50 +484,53 @@ static const struct file_operations papr_hvpipe_handle_ops = { · 8 unmodified lines
479 484
480static int papr_hvpipe_dev_create_handle(u32 srcID)485static int papr_hvpipe_dev_create_handle(u32 srcID)
481{486{
482 struct hvpipe_source_info *src_info __free(kfree) = NULL;487 struct hvpipe_source_info *src_info;
483 488 int fd;
484 spin_lock(&hvpipe_src_list_lock);489 unsigned long flags;
485 /*
486 * Do not allow more than one process communicates with
487 * each source.
488 */
489 src_info = hvpipe_find_source(srcID);
490 if (src_info) {
491 spin_unlock(&hvpipe_src_list_lock);
492 pr_err("pid(%d) is already using the source(%d)\n",
493 src_info->tsk->pid, srcID);
494 return -EALREADY;
495 }
496 spin_unlock(&hvpipe_src_list_lock);
497 490
498 src_info = kzalloc_obj(*src_info, GFP_KERNEL_ACCOUNT);491 src_info = kzalloc_obj(*src_info, GFP_KERNEL_ACCOUNT);
499 if (!src_info)492 if (!src_info)
500 return -ENOMEM;493 return -ENOMEM;
501 494
502 src_info->srcID = srcID;495 src_info->srcID = srcID;
503 src_info->tsk = current;
504 init_waitqueue_head(&src_info->recv_wqh);496 init_waitqueue_head(&src_info->recv_wqh);
505 497
506 FD_PREPARE(fdf, O_RDONLY | O_CLOEXEC,
507 anon_inode_getfile("[papr-hvpipe]", &papr_hvpipe_handle_ops,
508 (void *)src_info, O_RDWR));
509 if (fdf.err)
510 return fdf.err;
511
512 retain_and_null_ptr(src_info);
513 spin_lock(&hvpipe_src_list_lock);
514 /*498 /*
515 * If two processes are executing ioctl() for the same499 * Do not allow more than one process communicates with
516 * source ID concurrently, prevent the second process to500 * each source.
517 * acquire FD.
518 */501 */
502 spin_lock_irqsave(&hvpipe_src_list_lock, flags);
519 if (hvpipe_find_source(srcID)) {503 if (hvpipe_find_source(srcID)) {
520 spin_unlock(&hvpipe_src_list_lock);504 spin_unlock_irqrestore(&hvpipe_src_list_lock, flags);
505 pr_err("pid(%s:%d) could not get the source(%d)\n",
506 current->comm, task_pid_nr(current), srcID);
507 kfree(src_info);
521 return -EALREADY;508 return -EALREADY;
522 }509 }
523 list_add(&src_info->list, &hvpipe_src_list);510 list_add(&src_info->list, &hvpipe_src_list);
524 spin_unlock(&hvpipe_src_list_lock);511 spin_unlock_irqrestore(&hvpipe_src_list_lock, flags);
525 return fd_publish(fdf);512
513 fd = FD_ADD(O_RDONLY | O_CLOEXEC,
514 anon_inode_getfile("[papr-hvpipe]", &papr_hvpipe_handle_ops,
515 (void *)src_info, O_RDWR));
516 if (fd < 0) {
517 spin_lock_irqsave(&hvpipe_src_list_lock, flags);
518 list_del(&src_info->list);
519 spin_unlock_irqrestore(&hvpipe_src_list_lock, flags);
520 /*
521 * if we fail to add FD, that means no userspace program is
522 * polling. In that case if there is a msg pending because the
523 * interrupt was fired after the src_info was added to the
524 * global list, then let's consume it here, to unblock the
525 * hvpipe
526 */
527 if (src_info->hvpipe_status & HVPIPE_MSG_AVAILABLE)
528 hvpipe_rtas_recv_msg(NULL, 0);
529 kfree(src_info);
530 return fd;
531 }
532
533 return fd;
526}534}
527 535
528/*536/*
@@ -685,20 +693,19 @@ static int __init enable_hvpipe_IRQ(void) · 156 unmodified lines
685 struct device_node *np;693 struct device_node *np;
686 694
687 hvpipe_check_exception_token = rtas_function_token(RTAS_FN_CHECK_EXCEPTION);695 hvpipe_check_exception_token = rtas_function_token(RTAS_FN_CHECK_EXCEPTION);
688 if (hvpipe_check_exception_token == RTAS_UNKNOWN_SERVICE)696 if (hvpipe_check_exception_token == RTAS_UNKNOWN_SERVICE)
689 return -ENODEV;697 return -ENODEV;
690 698
691 /* hvpipe events */699 /* hvpipe events */
692 np = of_find_node_by_path("/event-sources/ibm,hvpipe-msg-events");700 np = of_find_node_by_path("/event-sources/ibm,hvpipe-msg-events");
693 if (np != NULL) {701 if (!np) {
694 request_event_sources_irqs(np, hvpipe_event_interrupt,702 pr_err("No device node found, could not enable hvpipe event IRQ\n");
695 "HPIPE_EVENT");
696 of_node_put(np);
697 } else {
698 pr_err("Can not enable hvpipe event IRQ\n");
699 return -ENODEV;703 return -ENODEV;
700 }704 }
701 705
706 request_event_sources_irqs(np, hvpipe_event_interrupt, "HPIPE_EVENT");
707 of_node_put(np);
708
702 return 0;709 return 0;
703}710}
704 711
@@ -775,23 +782,29 @@ static int __init papr_hvpipe_init(void) · 70 unmodified lines
775 }782 }
776 783
777 ret = enable_hvpipe_IRQ();784 ret = enable_hvpipe_IRQ();
778 if (!ret) {785 if (ret)
779 ret = set_hvpipe_sys_param(1);786 goto out_wq;
780 if (!ret)
781 ret = misc_register(&papr_hvpipe_dev);
782 }
783 787
784 if (!ret) {788 ret = misc_register(&papr_hvpipe_dev);
785 pr_info("hvpipe feature is enabled\n");789 if (ret)
786 hvpipe_feature = true;790 goto out_wq;
787 return 0;
788 }
789 791
790 pr_err("hvpipe feature is not enabled %d\n", ret);792 ret = set_hvpipe_sys_param(1);
793 if (ret)
794 goto out_misc;
795
796 pr_info("hvpipe feature is enabled\n");
797 hvpipe_feature = true;
798 return 0;
799
800out_misc:
801 misc_deregister(&papr_hvpipe_dev);
802out_wq:
791 destroy_workqueue(papr_hvpipe_wq);803 destroy_workqueue(papr_hvpipe_wq);
792out:804out:
793 kfree(papr_hvpipe_work);805 kfree(papr_hvpipe_work);
794 papr_hvpipe_work = NULL;806 papr_hvpipe_work = NULL;
807 pr_err("hvpipe feature is not enabled %d\n", ret);
795 return ret;808 return ret;
796}809}
797machine_device_initcall(pseries, papr_hvpipe_init);810machine_device_initcall(pseries, papr_hvpipe_init);
arch/powerpc/platforms/pseries/papr-hvpipe.h+0−1
@@ -21,7 +21,6 @@ struct hvpipe_source_info { · 20 unmodified lines
21 u32 srcID;21 u32 srcID;
22 u32 hvpipe_status;22 u32 hvpipe_status;
23 wait_queue_head_t recv_wqh; /* wake up poll() waitq */23 wait_queue_head_t recv_wqh; /* wake up poll() waitq */
24 struct task_struct *tsk;
25};24};
26 25
27/*26/*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t