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
7676 # CONFIG_HW_RANDOM is not set
7777 # CONFIG_HWMON is not set
7878 CONFIG_FB=y
79−CONFIG_FIRMWARE_EDID=y
8079 CONFIG_FB_TILEBLITTING=y
8180 CONFIG_FB_RADEON=y
8281 CONFIG_FB_3DFX=y
arch/powerpc/configs/chrp32_defconfig+0−1
@@ -76,7 +76,6 @@ CONFIG_SERIAL_8250_CONSOLE=y · 75 unmodified lines
7676 CONFIG_NVRAM=y
7777 # CONFIG_HWMON is not set
7878 CONFIG_FB=y
79−CONFIG_FIRMWARE_EDID=y
8079 CONFIG_FB_OF=y
8180 CONFIG_FB_MATROX=y
8281 CONFIG_FB_MATROX_MILLENIUM=y
arch/powerpc/configs/g5_defconfig+0−1
@@ -121,7 +121,6 @@ CONFIG_I2C_CHARDEV=y · 120 unmodified lines
121121 CONFIG_AGP=m
122122 CONFIG_AGP_UNINORTH=m
123123 CONFIG_FB=y
124−CONFIG_FIRMWARE_EDID=y
125124 CONFIG_FB_TILEBLITTING=y
126125 CONFIG_FB_OF=y
127126 CONFIG_FB_NVIDIA=y
arch/powerpc/configs/pasemi_defconfig+0−1
@@ -98,7 +98,6 @@ CONFIG_SENSORS_LM85=y · 97 unmodified lines
9898 CONFIG_SENSORS_LM90=y
9999 CONFIG_DRM=y
100100 CONFIG_DRM_RADEON=y
101−CONFIG_FIRMWARE_EDID=y
102101 CONFIG_FB_TILEBLITTING=y
103102 CONFIG_FB_VGA16=y
104103 CONFIG_FB_NVIDIA=y
arch/powerpc/configs/powernv_defconfig+0−1
@@ -196,7 +196,6 @@ CONFIG_I2C_CHARDEV=y · 195 unmodified lines
196196 # CONFIG_PTP_1588_CLOCK is not set
197197 CONFIG_DRM=y
198198 CONFIG_DRM_AST=y
199−CONFIG_FIRMWARE_EDID=y
200199 CONFIG_FB_OF=y
201200 CONFIG_FB_MATROX=m
202201 CONFIG_FB_MATROX_MILLENIUM=y
arch/powerpc/configs/ppc64_defconfig+0−1
@@ -249,7 +249,6 @@ CONFIG_I2C_CHARDEV=y · 248 unmodified lines
249249 CONFIG_I2C_AMD8111=y
250250 CONFIG_I2C_PASEMI=y
251251 CONFIG_FB=y
252−CONFIG_FIRMWARE_EDID=y
253252 CONFIG_FB_OF=y
254253 CONFIG_FB_MATROX=y
255254 CONFIG_FB_MATROX_MILLENIUM=y
arch/powerpc/configs/ppc64e_defconfig+0−1
@@ -118,7 +118,6 @@ CONFIG_SERIAL_8250_CONSOLE=y · 117 unmodified lines
118118 CONFIG_I2C_CHARDEV=y
119119 CONFIG_I2C_AMD8111=y
120120 CONFIG_FB=y
121−CONFIG_FIRMWARE_EDID=y
122121 CONFIG_FB_OF=y
123122 CONFIG_FB_MATROX=y
124123 CONFIG_FB_MATROX_MILLENIUM=y
arch/powerpc/configs/skiroot_defconfig+0−1
@@ -214,7 +214,6 @@ CONFIG_SENSORS_IBMPOWERNV=m · 213 unmodified lines
214214 CONFIG_DRM=m
215215 CONFIG_DRM_AST=m
216216 CONFIG_FB=y
217−CONFIG_FIRMWARE_EDID=y
218217 # CONFIG_VGA_CONSOLE is not set
219218 CONFIG_FRAMEBUFFER_CONSOLE=y
220219 CONFIG_LOGO=y
arch/powerpc/kernel/vdso/Makefile+6−0
@@ -62,6 +62,12 @@ CC32FLAGSREMOVE += -fno-stack-clash-protection · 61 unmodified lines
6262 # 32-bit one. clang validates the values passed to these arguments during
6363 # parsing, even when -fno-stack-protector is passed afterwards.
6464 CC32FLAGSREMOVE += -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.
70+CC32FLAGSREMOVE += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
6571 endif
6672 LD32FLAGS := -Wl,-soname=linux-vdso32.so.1
6773 AS32FLAGS := -D__VDSO32__
arch/powerpc/kexec/Makefile+1−1
@@ -16,4 +16,4 @@ GCOV_PROFILE_core_$(BITS).o := n · 15 unmodified lines
1616 KCOV_INSTRUMENT_core_$(BITS).o := n
1717 UBSAN_SANITIZE_core_$(BITS).o := n
1818 KASAN_SANITIZE_core.o := n
19−KASAN_SANITIZE_core_$(BITS) := n
19+KASAN_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
5252 }
5353 EXPORT_SYMBOL(exit_vmx_usercopy);
5454
55−int 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+ */
62+int __no_sanitize_address enter_vmx_ops(void)
5663 {
5764 if (in_interrupt())
5865 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
22422242 const u64 last_period = event->hw.last_period;
22432243 s64 prev, delta, left;
22442244 int record = 0;
2245+ int mark_event = regs->dsisr & MMCRA_SAMPLE_ENABLE;
22452246
22462247 if (event->hw.state & PERF_HES_STOPPED) {
22472248 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
23042305 * In ISA v3.0 and before values "0" and "7" are considered reserved.
23052306 * In ISA v3.1, value "7" has been used to indicate "larx/stcx".
23062307 * Drop the sample if "type" has reserved values for this field with a
2307− * ISA version check.
2308+ * ISA version check for marked events.
23082309 */
2309− if (event->attr.sample_type & PERF_SAMPLE_DATA_SRC &&
2310+ if (mark_event && event->attr.sample_type & PERF_SAMPLE_DATA_SRC &&
23102311 ppmu->get_mem_data_src) {
23112312 val = (regs->dar & SIER_TYPE_MASK) >> SIER_TYPE_SHIFT;
23122313 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
477477 struct device_node *np = dev->of_node;
478478 struct cpm1_gpio16_chip *cpm1_gc;
479479 struct gpio_chip *gc;
480− u16 mask;
480+ u32 mask;
481481
482482 cpm1_gc = devm_kzalloc(dev, sizeof(*cpm1_gc), GFP_KERNEL);
483483 if (!cpm1_gc)
@@ -485,7 +485,7 @@ int cpm1_gpiochip_add16(struct device *dev) · 1 unmodified line
485485
486486 spin_lock_init(&cpm1_gc->lock);
487487
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)) {
489489 int i, j;
490490
491491 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
272272 {
273273 struct device_node *root = of_find_node_by_path("/");
274274 struct device_node *np;
275− int res;
276275
277276 pci_set_flags(PCI_SCAN_ALL_PCIE_DEVS);
278277
279278 np = of_find_compatible_node(root, NULL, "pasemi,rootbus");
280279 if (np) {
281− res = pas_add_bridge(np);
280+ pas_add_bridge(np);
282281 of_node_put(np);
283282 }
284283 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
950950
951951 static int __init ps3_register_devices(void)
952952 {
953− int result;
954−
955953 if (!firmware_has_feature(FW_FEATURE_PS3_LV1))
956954 return -ENODEV;
957955
@@ -959,7 +957,7 @@ static int __init ps3_register_devices(void) · 1 unmodified line
959957
960958 /* ps3_repository_dump_bus_info(); */
961959
962− result = ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE);
960+ ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE);
963961
964962 ps3_register_vuart_devices();
965963
arch/powerpc/platforms/pseries/htmdump.c+116−17
@@ -16,6 +16,7 @@ static void *htm_buf; · 15 unmodified lines
1616 static void *htm_status_buf;
1717 static void *htm_info_buf;
1818 static void *htm_caps_buf;
19+static void *htm_mem_buf;
1920 static u32 nodeindex;
2021 static u32 nodalchipindex;
2122 static u32 coreindexonchip;
@@ -86,7 +87,7 @@ static ssize_t htm_return_check(long rc) · 64 unmodified lines
8687 static ssize_t htmdump_read(struct file *filp, char __user *ubuf,
8788 size_t count, loff_t *ppos)
8889 {
89− void *htm_buf = filp->private_data;
90+ void *htm_buf_data = filp->private_data;
9091 unsigned long page, read_size, available;
9192 loff_t offset;
9293 long rc, ret;
@@ -100,7 +101,7 @@ static ssize_t htmdump_read(struct file *filp, char __user *ubuf, · 7 unmodified lines
100101 * - last three values are address, size and offset
101102 */
102103 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),
104105 PAGE_SIZE, page);
105106
106107 ret = htm_return_check(rc);
@@ -112,7 +113,61 @@ static ssize_t htmdump_read(struct file *filp, char __user *ubuf, · 5 unmodified lines
112113 available = PAGE_SIZE;
113114 read_size = min(count, available);
114115 *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+
119+static 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);
116171 }
117172
118173 static const struct file_operations htmdump_fops = {
@@ -121,6 +176,12 @@ static const struct file_operations htmdump_fops = { · 2 unmodified lines
121176 .open = simple_open,
122177 };
123178
179+static const struct file_operations htmsystem_mem_fops = {
180+ .llseek = NULL,
181+ .read = htmsystem_mem_read,
182+ .open = simple_open,
183+};
184+
124185 static int htmconfigure_set(void *data, u64 val)
125186 {
126187 long rc, ret;
@@ -226,20 +287,31 @@ static int htmstart_get(void *data, u64 *val) · 99 unmodified lines
226287 static ssize_t htmstatus_read(struct file *filp, char __user *ubuf,
227288 size_t count, loff_t *ppos)
228289 {
229− void *htm_status_buf = filp->private_data;
290+ void *htm_status_data = filp->private_data;
230291 long rc, ret;
231292 u64 *num_entries;
232293 u64 to_copy;
233294 int htmstatus_flag;
295+ loff_t offset = 0;
296+ u64 status_offset = 0;
234297
235298 /*
236299 * Invoke H_HTM call with:
237300 * - operation as htm status (H_HTM_OP_STATUS)
238− * - last three values as addr, size and offset
301+ * - 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.
239306 */
307+ if (*ppos) {
308+ status_offset = *(u64 *)(htm_status_data + 0x8);
309+ if (status_offset == -1)
310+ return 0;
311+ }
240312 rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
241− htmtype, H_HTM_OP_STATUS, virt_to_phys(htm_status_buf),
242− PAGE_SIZE, 0);
313+ htmtype, H_HTM_OP_STATUS, virt_to_phys(htm_status_data),
314+ PAGE_SIZE, be64_to_cpu(status_offset));
243315
244316 ret = htm_return_check(rc);
245317 if (ret <= 0) {
@@ -255,13 +327,15 @@ static ssize_t htmstatus_read(struct file *filp, char __user *ubuf, · 9 unmodified lines
255327 * So total count to copy is:
256328 * 32 bytes (for first 7 fields) + (number of HTM entries * entry size)
257329 */
258− num_entries = htm_status_buf + 0x10;
330+ num_entries = htm_status_data + 0x10;
259331 if (htmtype == 0x2)
260332 htmstatus_flag = 0x8;
261333 else
262334 htmstatus_flag = 0x6;
263335 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);
265339 }
266340
267341 static const struct file_operations htmstatus_fops = {
@@ -273,19 +347,30 @@ static const struct file_operations htmstatus_fops = { · 5 unmodified lines
273347 static ssize_t htminfo_read(struct file *filp, char __user *ubuf,
274348 size_t count, loff_t *ppos)
275349 {
276− void *htm_info_buf = filp->private_data;
350+ void *htm_info_data = filp->private_data;
277351 long rc, ret;
278352 u64 *num_entries;
279353 u64 to_copy;
354+ loff_t offset = 0;
355+ u64 info_offset = 0;
280356
281357 /*
282358 * Invoke H_HTM call with:
283359 * - operation as htm status (H_HTM_OP_STATUS)
284360 * - 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.
285365 */
366+ if (*ppos) {
367+ info_offset = *(u64 *)(htm_info_data + 0x8);
368+ if (info_offset == -1)
369+ return 0;
370+ }
286371 rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
287− htmtype, H_HTM_OP_DUMP_SYSPROC_CONF, virt_to_phys(htm_info_buf),
288− PAGE_SIZE, 0);
372+ htmtype, H_HTM_OP_DUMP_SYSPROC_CONF, virt_to_phys(htm_info_data),
373+ PAGE_SIZE, be64_to_cpu(info_offset));
289374
290375 ret = htm_return_check(rc);
291376 if (ret <= 0) {
@@ -301,15 +386,17 @@ static ssize_t htminfo_read(struct file *filp, char __user *ubuf, · 9 unmodified lines
301386 * So total count to copy is:
302387 * 32 bytes (for first 5 fields) + (number of HTM entries * entry size)
303388 */
304− num_entries = htm_info_buf + 0x10;
389+ num_entries = htm_info_data + 0x10;
305390 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);
307394 }
308395
309396 static ssize_t htmcaps_read(struct file *filp, char __user *ubuf,
310397 size_t count, loff_t *ppos)
311398 {
312− void *htm_caps_buf = filp->private_data;
399+ void *htm_caps_data = filp->private_data;
313400 long rc, ret;
314401
315402 /*
@@ -319,7 +406,7 @@ static ssize_t htmcaps_read(struct file *filp, char __user *ubuf, · 3 unmodified lines
319406 * and zero
320407 */
321408 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),
323410 0x80, 0);
324411
325412 ret = htm_return_check(rc);
@@ -328,7 +415,7 @@ static ssize_t htmcaps_read(struct file *filp, char __user *ubuf, · 2 unmodified lines
328415 return ret;
329416 }
330417
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);
332419 }
333420
334421 static const struct file_operations htminfo_fops = {
@@ -457,9 +544,17 @@ static int htmdump_init_debugfs(void) · 122 unmodified lines
457544 return -ENOMEM;
458545 }
459546
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+
460554 debugfs_create_file("htmstatus", 0400, htmdump_debugfs_dir, htm_status_buf, &htmstatus_fops);
461555 debugfs_create_file("htminfo", 0400, htmdump_debugfs_dir, htm_info_buf, &htminfo_fops);
462556 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);
463558
464559 return 0;
465560 }
@@ -482,6 +577,10 @@ static void __exit htmdump_exit(void) · 16 unmodified lines
482577 {
483578 debugfs_remove_recursive(htmdump_debugfs_dir);
484579 kfree(htm_buf);
580+ kfree(htm_status_buf);
581+ kfree(htm_info_buf);
582+ kfree(htm_caps_buf);
583+ kfree(htm_mem_buf);
485584 }
486585
487586 module_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
190190 return -ENOMEM;
191191 }
192192
193− ret = rtas_ibm_receive_hvpipe_msg(work_area, &srcID,
194− &bytes_written);
195− if (!ret) {
196− /*
197− * Recv HVPIPE RTAS is successful.
198− * When releasing FD or no one is waiting on the
199− * specific source, issue recv HVPIPE RTAS call
200− * so that pipe is not blocked - this func is called
201− * with NULL buf.
202− */
203− if (buf) {
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);
193+ /*
194+ * Recv HVPIPE RTAS is successful.
195+ * When releasing FD or no one is waiting on the
196+ * specific source, issue recv HVPIPE RTAS call
197+ * so that pipe is not blocked - this func is called
198+ * with NULL buf.
199+ */
200+ ret = rtas_ibm_receive_hvpipe_msg(work_area, &srcID, &bytes_written);
201+ if (ret) {
202+ pr_err("ibm,receive-hvpipe-msg failed with %d\n", ret);
203+ goto out;
218204 }
219205
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+
220+out:
220221 rtas_work_area_free(work_area);
221222 return ret;
222223 }
@@ -327,8 +328,8 @@ static ssize_t papr_hvpipe_handle_read(struct file *file, · 104 unmodified lines
327328 {
328329
329330 struct hvpipe_source_info *src_info = file->private_data;
330− struct papr_hvpipe_hdr hdr;
331− long ret;
331+ struct papr_hvpipe_hdr hdr = {};
332+ ssize_t ret = 0;
332333
333334 /*
334335 * Return -ENXIO during migration
@@ -376,7 +377,7 @@ static ssize_t papr_hvpipe_handle_read(struct file *file, · 41 unmodified lines
376377
377378 ret = copy_to_user(buf, &hdr, HVPIPE_HDR_LEN);
378379 if (ret)
379− return ret;
380+ return -EFAULT;
380381
381382 /*
382383 * 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
385386 if (hdr.flags & HVPIPE_MSG_AVAILABLE) {
386387 ret = hvpipe_rtas_recv_msg(buf + HVPIPE_HDR_LEN,
387388 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)
389394 src_info->hvpipe_status &= ~HVPIPE_MSG_AVAILABLE;
390− ret += HVPIPE_HDR_LEN;
391− }
392395 } else if (hdr.flags & HVPIPE_LOST_CONNECTION) {
393396 /*
394397 * Hypervisor is closing the pipe for the specific
395398 * source. So notify user space.
396399 */
397400 src_info->hvpipe_status &= ~HVPIPE_LOST_CONNECTION;
398− ret = HVPIPE_HDR_LEN;
399401 }
400402
403+ if (ret >= 0)
404+ ret += HVPIPE_HDR_LEN;
405+
401406 return ret;
402407 }
403408
@@ -444,16 +449,18 @@ static int papr_hvpipe_handle_release(struct inode *inode, · 40 unmodified lines
444449 struct file *file)
445450 {
446451 struct hvpipe_source_info *src_info;
452+ unsigned long flags;
447453
448454 /*
449455 * Hold the lock, remove source from src_list, reset the
450456 * hvpipe status and release the lock to prevent any race
451457 * with message event IRQ.
452458 */
453− spin_lock(&hvpipe_src_list_lock);
459+ spin_lock_irqsave(&hvpipe_src_list_lock, flags);
454460 src_info = file->private_data;
455461 list_del(&src_info->list);
456462 file->private_data = NULL;
463+ spin_unlock_irqrestore(&hvpipe_src_list_lock, flags);
457464 /*
458465 * If the pipe for this specific source has any pending
459466 * 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
461468 */
462469 if (src_info->hvpipe_status & HVPIPE_MSG_AVAILABLE) {
463470 src_info->hvpipe_status = 0;
464− spin_unlock(&hvpipe_src_list_lock);
465471 hvpipe_rtas_recv_msg(NULL, 0);
466− } else
467− spin_unlock(&hvpipe_src_list_lock);
472+ }
468473
469474 kfree(src_info);
470475 return 0;
@@ -479,50 +484,53 @@ static const struct file_operations papr_hvpipe_handle_ops = { · 8 unmodified lines
479484
480485 static int papr_hvpipe_dev_create_handle(u32 srcID)
481486 {
482− struct hvpipe_source_info *src_info __free(kfree) = NULL;
483−
484− spin_lock(&hvpipe_src_list_lock);
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);
487+ struct hvpipe_source_info *src_info;
488+ int fd;
489+ unsigned long flags;
497490
498491 src_info = kzalloc_obj(*src_info, GFP_KERNEL_ACCOUNT);
499492 if (!src_info)
500493 return -ENOMEM;
501494
502495 src_info->srcID = srcID;
503− src_info->tsk = current;
504496 init_waitqueue_head(&src_info->recv_wqh);
505497
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);
514498 /*
515− * If two processes are executing ioctl() for the same
516− * source ID concurrently, prevent the second process to
517− * acquire FD.
499+ * Do not allow more than one process communicates with
500+ * each source.
518501 */
502+ spin_lock_irqsave(&hvpipe_src_list_lock, flags);
519503 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);
521508 return -EALREADY;
522509 }
523510 list_add(&src_info->list, &hvpipe_src_list);
524− spin_unlock(&hvpipe_src_list_lock);
525− return fd_publish(fdf);
511+ spin_unlock_irqrestore(&hvpipe_src_list_lock, flags);
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;
526534 }
527535
528536 /*
@@ -685,20 +693,19 @@ static int __init enable_hvpipe_IRQ(void) · 156 unmodified lines
685693 struct device_node *np;
686694
687695 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)
689697 return -ENODEV;
690698
691699 /* hvpipe events */
692700 np = of_find_node_by_path("/event-sources/ibm,hvpipe-msg-events");
693− if (np != NULL) {
694− request_event_sources_irqs(np, hvpipe_event_interrupt,
695− "HPIPE_EVENT");
696− of_node_put(np);
697− } else {
698− pr_err("Can not enable hvpipe event IRQ\n");
701+ if (!np) {
702+ pr_err("No device node found, could not enable hvpipe event IRQ\n");
699703 return -ENODEV;
700704 }
701705
706+ request_event_sources_irqs(np, hvpipe_event_interrupt, "HPIPE_EVENT");
707+ of_node_put(np);
708+
702709 return 0;
703710 }
704711
@@ -775,23 +782,29 @@ static int __init papr_hvpipe_init(void) · 70 unmodified lines
775782 }
776783
777784 ret = enable_hvpipe_IRQ();
778− if (!ret) {
779− ret = set_hvpipe_sys_param(1);
780− if (!ret)
781− ret = misc_register(&papr_hvpipe_dev);
782− }
785+ if (ret)
786+ goto out_wq;
783787
784− if (!ret) {
785− pr_info("hvpipe feature is enabled\n");
786− hvpipe_feature = true;
787− return 0;
788− }
788+ ret = misc_register(&papr_hvpipe_dev);
789+ if (ret)
790+ goto out_wq;
789791
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+
800+out_misc:
801+ misc_deregister(&papr_hvpipe_dev);
802+out_wq:
791803 destroy_workqueue(papr_hvpipe_wq);
792804 out:
793805 kfree(papr_hvpipe_work);
794806 papr_hvpipe_work = NULL;
807+ pr_err("hvpipe feature is not enabled %d\n", ret);
795808 return ret;
796809 }
797810 machine_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
2121 u32 srcID;
2222 u32 hvpipe_status;
2323 wait_queue_head_t recv_wqh; /* wake up poll() waitq */
24− struct task_struct *tsk;
2524 };
2625
2726 /*

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