Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'powerpc-6.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux

Pull powerpc updates from Madhavan Srinivasan:

- CONFIG_HZ changes to move the base_slice from 10ms to 1ms

- Patchset to move some of the mutex handling to lock guard

- Expose secvars relevant to the key management mode

- Misc cleanups and fixes

Thanks to Ankit Chauhan, Christophe Leroy, Donet Tom, Gautam Menghani,
Haren Myneni, Johan Korsnes, Madadi Vineeth Reddy, Paul Mackerras,
Shrikanth Hegde, Srish Srinivasan, Thomas Fourier, Thomas Huth, Thomas
Weißschuh, Souradeep, Amit Machhiwal, R Nageswara Sastry, Venkat Rao
Bagalkote, Andrew Donnellan, Greg Kroah-Hartman, Mimi Zohar, Mukesh
Kumar Chaurasiya, Nayna Jain, Ritesh Harjani (IBM), Sourabh Jain, Srikar
Dronamraju, Stefan Berger, Tyrel Datwyler, and Kowshik Jois.

* tag 'powerpc-6.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (23 commits)
arch/powerpc: Remove .interp section in vmlinux
powerpc: Drop GPL boilerplate text with obsolete FSF address
powerpc: Don't use %pK through printk
arch: powerpc: defconfig: Drop obsolete CONFIG_NET_CLS_TCINDEX
misc: ocxl: Replace scnprintf() with sysfs_emit() in sysfs show functions
integrity/platform_certs: Allow loading of keys in the static key management mode
powerpc/secvar: Expose secvars relevant to the key management mode
powerpc/pseries: Correct secvar format representation for static key management
(powerpc/512) Fix possible `dma_unmap_single()` on uninitialized pointer
powerpc: floppy: Add missing checks after DMA map
book3s64/radix : Optimize vmemmap start alignment
book3s64/radix : Handle error conditions properly in radix_vmemmap_populate
powerpc/pseries/dlpar: Search DRC index from ibm,drc-indexes for IO add
KVM: PPC: Book3S HV: Add H_VIRT mapping for tracing exits
powerpc: sysdev: use lock guard for mutex
powerpc: powernv: ocxl: use lock guard for mutex
powerpc: book3s: vas: use lock guard for mutex
powerpc: fadump: use lock guard for mutex
powerpc: rtas: use lock guard for mutex
powerpc: eeh: use lock guard for mutex
...

+225 -224
+14 -3
Documentation/ABI/testing/sysfs-secvar
··· 22 22 and is expected to be "ibm,edk2-compat-v1". 23 23 24 24 On pseries/PLPKS, this is generated by the kernel based on the 25 - version number in the SB_VERSION variable in the keystore, and 26 - has the form "ibm,plpks-sb-v<version>", or 27 - "ibm,plpks-sb-unknown" if there is no SB_VERSION variable. 25 + version number in the SB_VERSION variable in the keystore. The 26 + version numbering in the SB_VERSION variable starts from 1. The 27 + format string takes the form "ibm,plpks-sb-v<version>" in the 28 + case of dynamic key management mode. If the SB_VERSION variable 29 + does not exist (or there is an error while reading it), it takes 30 + the form "ibm,plpks-sb-v0", indicating that the key management 31 + mode is static. 28 32 29 33 What: /sys/firmware/secvar/vars/<variable name> 30 34 Date: August 2019 ··· 37 33 <variable_name>. The variable name is unique and is in ASCII 38 34 representation. The data and size can be determined by reading 39 35 their respective attribute files. 36 + 37 + Only secvars relevant to the key management mode are exposed. 38 + Only in the dynamic key management mode should the user have 39 + access (read and write) to the secure boot secvars db, dbx, 40 + grubdb, grubdbx, and sbat. These secvars are not consumed in the 41 + static key management mode. PK, trustedcadb and moduledb are the 42 + secvars common to both static and dynamic key management modes. 40 43 41 44 What: /sys/firmware/secvar/vars/<variable_name>/size 42 45 Date: August 2019
+1 -1
arch/powerpc/Makefile
··· 101 101 endif 102 102 103 103 LDFLAGS_vmlinux-y := -Bstatic 104 - LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie 104 + LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie --no-dynamic-linker 105 105 LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) += -z notext 106 106 LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y) 107 107
+1 -1
arch/powerpc/boot/dts/microwatt.dts
··· 37 37 38 38 ibm,powerpc-cpu-features { 39 39 display-name = "Microwatt"; 40 - isa = <3010>; 40 + isa = <3100>; 41 41 device_type = "cpu-features"; 42 42 compatible = "ibm,powerpc-cpu-features"; 43 43
+2 -1
arch/powerpc/configs/powernv_defconfig
··· 46 46 CONFIG_CPU_FREQ_GOV_USERSPACE=y 47 47 CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y 48 48 CONFIG_CPU_IDLE=y 49 - CONFIG_HZ_100=y 49 + CONFIG_HZ_1000=y 50 50 CONFIG_BINFMT_MISC=m 51 51 CONFIG_PPC_TRANSACTIONAL_MEM=y 52 52 CONFIG_PPC_UV=y ··· 340 340 CONFIG_VHOST_NET=m 341 341 CONFIG_PRINTK_TIME=y 342 342 CONFIG_PRINTK_CALLER=y 343 + CONFIG_KALLSYMS_ALL=y
+2 -1
arch/powerpc/configs/ppc64_defconfig
··· 57 57 CONFIG_CPU_FREQ_GOV_USERSPACE=y 58 58 CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y 59 59 CONFIG_CPU_FREQ_PMAC64=y 60 - CONFIG_HZ_100=y 60 + CONFIG_HZ_1000=y 61 61 CONFIG_PPC_TRANSACTIONAL_MEM=y 62 62 CONFIG_KEXEC=y 63 63 CONFIG_KEXEC_FILE=y ··· 465 465 CONFIG_TEST_MEMINIT=m 466 466 CONFIG_TEST_FREE_PAGES=m 467 467 CONFIG_MEMTEST=y 468 + CONFIG_KALLSYMS_ALL=y
-1
arch/powerpc/configs/ppc6xx_defconfig
··· 252 252 CONFIG_NET_SCH_NETEM=m 253 253 CONFIG_NET_SCH_INGRESS=m 254 254 CONFIG_NET_CLS_BASIC=m 255 - CONFIG_NET_CLS_TCINDEX=m 256 255 CONFIG_NET_CLS_ROUTE4=m 257 256 CONFIG_NET_CLS_FW=m 258 257 CONFIG_NET_CLS_U32=m
+4 -1
arch/powerpc/include/asm/floppy.h
··· 144 144 bus_addr = 0; 145 145 } 146 146 147 - if (!bus_addr) /* need to map it */ 147 + if (!bus_addr) { /* need to map it */ 148 148 bus_addr = dma_map_single(&isa_bridge_pcidev->dev, addr, size, 149 149 dir); 150 + if (dma_mapping_error(&isa_bridge_pcidev->dev, bus_addr)) 151 + return -ENOMEM; 152 + } 150 153 151 154 /* remember this one as prev */ 152 155 prev_addr = addr;
-13
arch/powerpc/include/uapi/asm/eeh.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 2 /* 3 - * This program is free software; you can redistribute it and/or modify 4 - * it under the terms of the GNU General Public License, version 2, as 5 - * published by the Free Software Foundation. 6 - * 7 - * This program is distributed in the hope that it will be useful, 8 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 - * GNU General Public License for more details. 11 - * 12 - * You should have received a copy of the GNU General Public License 13 - * along with this program; if not, write to the Free Software 14 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 - * 16 3 * Copyright IBM Corp. 2015 17 4 * 18 5 * Authors: Gavin Shan <gwshan@linux.vnet.ibm.com>
-13
arch/powerpc/include/uapi/asm/kvm.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 2 /* 3 - * This program is free software; you can redistribute it and/or modify 4 - * it under the terms of the GNU General Public License, version 2, as 5 - * published by the Free Software Foundation. 6 - * 7 - * This program is distributed in the hope that it will be useful, 8 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 - * GNU General Public License for more details. 11 - * 12 - * You should have received a copy of the GNU General Public License 13 - * along with this program; if not, write to the Free Software 14 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 - * 16 3 * Copyright IBM Corp. 2007 17 4 * 18 5 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
-13
arch/powerpc/include/uapi/asm/kvm_para.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 2 /* 3 - * This program is free software; you can redistribute it and/or modify 4 - * it under the terms of the GNU General Public License, version 2, as 5 - * published by the Free Software Foundation. 6 - * 7 - * This program is distributed in the hope that it will be useful, 8 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 - * GNU General Public License for more details. 11 - * 12 - * You should have received a copy of the GNU General Public License 13 - * along with this program; if not, write to the Free Software 14 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 - * 16 3 * Copyright IBM Corp. 2008 17 4 * 18 5 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
-13
arch/powerpc/include/uapi/asm/ps3fb.h
··· 2 2 /* 3 3 * Copyright (C) 2006 Sony Computer Entertainment Inc. 4 4 * Copyright 2006, 2007 Sony Corporation 5 - * 6 - * This program is free software; you can redistribute it and/or modify it 7 - * under the terms of the GNU General Public License as published 8 - * by the Free Software Foundation; version 2 of the License. 9 - * 10 - * This program is distributed in the hope that it will be useful, but 11 - * WITHOUT ANY WARRANTY; without even the implied warranty of 12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 - * General Public License for more details. 14 - * 15 - * You should have received a copy of the GNU General Public License along 16 - * with this program; if not, write to the Free Software Foundation, Inc., 17 - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 5 */ 19 6 20 7 #ifndef _ASM_POWERPC_PS3FB_H_
+7 -13
arch/powerpc/kernel/eeh.c
··· 1208 1208 struct eeh_dev *edev; 1209 1209 int ret = -ENODEV; 1210 1210 1211 - mutex_lock(&eeh_dev_mutex); 1211 + guard(mutex)(&eeh_dev_mutex); 1212 1212 1213 1213 /* No PCI device ? */ 1214 1214 if (!pdev) 1215 - goto out; 1215 + return ret; 1216 1216 1217 1217 /* No EEH device or PE ? */ 1218 1218 edev = pci_dev_to_eeh_dev(pdev); 1219 1219 if (!edev || !edev->pe) 1220 - goto out; 1220 + return ret; 1221 1221 1222 1222 /* 1223 1223 * The PE might have been put into frozen state, but we ··· 1227 1227 */ 1228 1228 ret = eeh_pe_change_owner(edev->pe); 1229 1229 if (ret) 1230 - goto out; 1230 + return ret; 1231 1231 1232 1232 /* Increase PE's pass through count */ 1233 1233 atomic_inc(&edev->pe->pass_dev_cnt); 1234 - mutex_unlock(&eeh_dev_mutex); 1235 1234 1236 1235 return 0; 1237 - out: 1238 - mutex_unlock(&eeh_dev_mutex); 1239 - return ret; 1240 1236 } 1241 1237 EXPORT_SYMBOL_GPL(eeh_dev_open); 1242 1238 ··· 1248 1252 { 1249 1253 struct eeh_dev *edev; 1250 1254 1251 - mutex_lock(&eeh_dev_mutex); 1255 + guard(mutex)(&eeh_dev_mutex); 1252 1256 1253 1257 /* No PCI device ? */ 1254 1258 if (!pdev) 1255 - goto out; 1259 + return; 1256 1260 1257 1261 /* No EEH device ? */ 1258 1262 edev = pci_dev_to_eeh_dev(pdev); 1259 1263 if (!edev || !edev->pe || !eeh_pe_passed(edev->pe)) 1260 - goto out; 1264 + return; 1261 1265 1262 1266 /* Decrease PE's pass through count */ 1263 1267 WARN_ON(atomic_dec_if_positive(&edev->pe->pass_dev_cnt) < 0); 1264 1268 eeh_pe_change_owner(edev->pe); 1265 - out: 1266 - mutex_unlock(&eeh_dev_mutex); 1267 1269 } 1268 1270 EXPORT_SYMBOL(eeh_dev_release); 1269 1271
+1 -1
arch/powerpc/kernel/eeh_driver.c
··· 907 907 /* FIXME: Use the same format as dump_stack() */ 908 908 pr_err("EEH: Call Trace:\n"); 909 909 for (i = 0; i < pe->trace_entries; i++) 910 - pr_err("EEH: [%pK] %pS\n", ptrs[i], ptrs[i]); 910 + pr_err("EEH: [%p] %pS\n", ptrs[i], ptrs[i]); 911 911 912 912 pe->trace_entries = 0; 913 913 }
+4 -7
arch/powerpc/kernel/fadump.c
··· 1373 1373 1374 1374 static void fadump_invalidate_release_mem(void) 1375 1375 { 1376 - mutex_lock(&fadump_mutex); 1377 - if (!fw_dump.dump_active) { 1378 - mutex_unlock(&fadump_mutex); 1379 - return; 1376 + scoped_guard(mutex, &fadump_mutex) { 1377 + if (!fw_dump.dump_active) 1378 + return; 1379 + fadump_cleanup(); 1380 1380 } 1381 - 1382 - fadump_cleanup(); 1383 - mutex_unlock(&fadump_mutex); 1384 1381 1385 1382 fadump_free_elfcorehdr_buf(); 1386 1383 fadump_release_memory(fw_dump.boot_mem_top, memblock_end_of_DRAM());
+20 -44
arch/powerpc/kernel/rtas_flash.c
··· 312 312 { 313 313 struct rtas_update_flash_t *const uf = &rtas_update_flash_data; 314 314 char *p; 315 - int next_free, rc; 315 + int next_free; 316 316 struct flash_block_list *fl; 317 317 318 - mutex_lock(&rtas_update_flash_mutex); 318 + guard(mutex)(&rtas_update_flash_mutex); 319 319 320 320 if (uf->status == FLASH_AUTH || count == 0) 321 - goto out; /* discard data */ 321 + return count; /* discard data */ 322 322 323 323 /* In the case that the image is not ready for flashing, the memory 324 324 * allocated for the block list will be freed upon the release of the ··· 327 327 if (uf->flist == NULL) { 328 328 uf->flist = kmem_cache_zalloc(flash_block_cache, GFP_KERNEL); 329 329 if (!uf->flist) 330 - goto nomem; 330 + return -ENOMEM; 331 331 } 332 332 333 333 fl = uf->flist; ··· 338 338 /* Need to allocate another block_list */ 339 339 fl->next = kmem_cache_zalloc(flash_block_cache, GFP_KERNEL); 340 340 if (!fl->next) 341 - goto nomem; 341 + return -ENOMEM; 342 342 fl = fl->next; 343 343 next_free = 0; 344 344 } ··· 347 347 count = RTAS_BLK_SIZE; 348 348 p = kmem_cache_zalloc(flash_block_cache, GFP_KERNEL); 349 349 if (!p) 350 - goto nomem; 350 + return -ENOMEM; 351 351 352 352 if(copy_from_user(p, buffer, count)) { 353 353 kmem_cache_free(flash_block_cache, p); 354 - rc = -EFAULT; 355 - goto error; 354 + return -EFAULT; 356 355 } 357 356 fl->blocks[next_free].data = p; 358 357 fl->blocks[next_free].length = count; 359 358 fl->num_blocks++; 360 - out: 361 - mutex_unlock(&rtas_update_flash_mutex); 362 - return count; 363 359 364 - nomem: 365 - rc = -ENOMEM; 366 - error: 367 - mutex_unlock(&rtas_update_flash_mutex); 368 - return rc; 360 + return count; 369 361 } 370 362 371 363 /* ··· 397 405 static const char reject_str[] = "0"; 398 406 static const char commit_str[] = "1"; 399 407 char stkbuf[10]; 400 - int op, rc; 408 + int op; 401 409 402 - mutex_lock(&rtas_manage_flash_mutex); 410 + guard(mutex)(&rtas_manage_flash_mutex); 403 411 404 412 if ((args_buf->status == MANAGE_AUTH) || (count == 0)) 405 - goto out; 413 + return count; 406 414 407 415 op = -1; 408 416 if (buf) { 409 417 if (count > 9) count = 9; 410 - rc = -EFAULT; 411 418 if (copy_from_user (stkbuf, buf, count)) 412 - goto error; 419 + return -EFAULT; 413 420 if (strncmp(stkbuf, reject_str, strlen(reject_str)) == 0) 414 421 op = RTAS_REJECT_TMP_IMG; 415 422 else if (strncmp(stkbuf, commit_str, strlen(commit_str)) == 0) ··· 416 425 } 417 426 418 427 if (op == -1) { /* buf is empty, or contains invalid string */ 419 - rc = -EINVAL; 420 - goto error; 428 + return -EINVAL; 421 429 } 422 430 423 431 manage_flash(args_buf, op); 424 - out: 425 - mutex_unlock(&rtas_manage_flash_mutex); 426 432 return count; 427 - 428 - error: 429 - mutex_unlock(&rtas_manage_flash_mutex); 430 - return rc; 431 433 } 432 434 433 435 /* ··· 483 499 { 484 500 struct rtas_validate_flash_t *const args_buf = 485 501 &rtas_validate_flash_data; 486 - int rc; 487 502 488 - mutex_lock(&rtas_validate_flash_mutex); 503 + guard(mutex)(&rtas_validate_flash_mutex); 489 504 490 505 /* We are only interested in the first 4K of the 491 506 * candidate image */ 492 507 if ((*off >= VALIDATE_BUF_SIZE) || 493 508 (args_buf->status == VALIDATE_AUTH)) { 494 509 *off += count; 495 - mutex_unlock(&rtas_validate_flash_mutex); 496 510 return count; 497 511 } 498 512 ··· 501 519 args_buf->status = VALIDATE_INCOMPLETE; 502 520 } 503 521 504 - if (!access_ok(buf, count)) { 505 - rc = -EFAULT; 506 - goto done; 507 - } 508 - if (copy_from_user(args_buf->buf + *off, buf, count)) { 509 - rc = -EFAULT; 510 - goto done; 511 - } 522 + if (!access_ok(buf, count)) 523 + return -EFAULT; 524 + 525 + if (copy_from_user(args_buf->buf + *off, buf, count)) 526 + return -EFAULT; 512 527 513 528 *off += count; 514 - rc = count; 515 - done: 516 - mutex_unlock(&rtas_validate_flash_mutex); 517 - return rc; 529 + return count; 518 530 } 519 531 520 532 static int validate_flash_release(struct inode *inode, struct file *file)
+1
arch/powerpc/kvm/trace_book3s.h
··· 25 25 {0xe00, "H_DATA_STORAGE"}, \ 26 26 {0xe20, "H_INST_STORAGE"}, \ 27 27 {0xe40, "H_EMUL_ASSIST"}, \ 28 + {0xea0, "H_VIRT"}, \ 28 29 {0xf00, "PERFMON"}, \ 29 30 {0xf20, "ALTIVEC"}, \ 30 31 {0xf40, "VSX"}
+19 -12
arch/powerpc/mm/book3s64/radix_pgtable.c
··· 1122 1122 pte_t *pte; 1123 1123 1124 1124 /* 1125 - * Make sure we align the start vmemmap addr so that we calculate 1126 - * the correct start_pfn in altmap boundary check to decided whether 1127 - * we should use altmap or RAM based backing memory allocation. Also 1128 - * the address need to be aligned for set_pte operation. 1129 - 1130 - * If the start addr is already PMD_SIZE aligned we will try to use 1131 - * a pmd mapping. We don't want to be too aggressive here beacause 1132 - * that will cause more allocations in RAM. So only if the namespace 1133 - * vmemmap start addr is PMD_SIZE aligned we will use PMD mapping. 1125 + * If altmap is present, Make sure we align the start vmemmap addr 1126 + * to PAGE_SIZE so that we calculate the correct start_pfn in 1127 + * altmap boundary check to decide whether we should use altmap or 1128 + * RAM based backing memory allocation. Also the address need to be 1129 + * aligned for set_pte operation. If the start addr is already 1130 + * PMD_SIZE aligned and with in the altmap boundary then we will 1131 + * try to use a pmd size altmap mapping else we go for page size 1132 + * mapping. 1133 + * 1134 + * If altmap is not present, align the vmemmap addr to PMD_SIZE and 1135 + * always allocate a PMD size page for vmemmap backing. 1136 + * 1134 1137 */ 1135 1138 1136 - start = ALIGN_DOWN(start, PAGE_SIZE); 1139 + if (altmap) 1140 + start = ALIGN_DOWN(start, PAGE_SIZE); 1141 + else 1142 + start = ALIGN_DOWN(start, PMD_SIZE); 1143 + 1137 1144 for (addr = start; addr < end; addr = next) { 1138 1145 next = pmd_addr_end(addr, end); 1139 1146 ··· 1166 1159 * in altmap block allocation failures, in which case 1167 1160 * we fallback to RAM for vmemmap allocation. 1168 1161 */ 1169 - if (!IS_ALIGNED(addr, PMD_SIZE) || (altmap && 1162 + if (altmap && (!IS_ALIGNED(addr, PMD_SIZE) || 1170 1163 altmap_cross_boundary(altmap, addr, PMD_SIZE))) { 1171 1164 /* 1172 1165 * make sure we don't create altmap mappings ··· 1180 1173 vmemmap_set_pmd(pmd, p, node, addr, next); 1181 1174 pr_debug("PMD_SIZE vmemmap mapping\n"); 1182 1175 continue; 1183 - } else if (altmap) { 1176 + } else { 1184 1177 /* 1185 1178 * A vmemmap block allocation can fail due to 1186 1179 * alignment requirements and we trying to align
+4 -4
arch/powerpc/perf/hv-24x7.c
··· 713 713 ev_len = be16_to_cpu(event->length); 714 714 715 715 if (ev_len % 16) 716 - pr_info("event %zu has length %zu not divisible by 16: event=%pK\n", 716 + pr_info("event %zu has length %zu not divisible by 16: event=%p\n", 717 717 event_idx, ev_len, event); 718 718 719 719 ev_end = (__u8 *)event + ev_len; 720 720 if (ev_end > end) { 721 - pr_warn("event %zu has .length=%zu, ends after buffer end: ev_end=%pK > end=%pK, offset=%zu\n", 721 + pr_warn("event %zu has .length=%zu, ends after buffer end: ev_end=%p > end=%p, offset=%zu\n", 722 722 event_idx, ev_len, ev_end, end, 723 723 offset); 724 724 return -1; ··· 726 726 727 727 calc_ev_end = event_end(event, end); 728 728 if (!calc_ev_end) { 729 - pr_warn("event %zu has a calculated length which exceeds buffer length %zu: event=%pK end=%pK, offset=%zu\n", 729 + pr_warn("event %zu has a calculated length which exceeds buffer length %zu: event=%p end=%p, offset=%zu\n", 730 730 event_idx, event_data_bytes, event, end, 731 731 offset); 732 732 return -1; 733 733 } 734 734 735 735 if (calc_ev_end > ev_end) { 736 - pr_warn("event %zu exceeds its own length: event=%pK, end=%pK, offset=%zu, calc_ev_end=%pK\n", 736 + pr_warn("event %zu exceeds its own length: event=%p, end=%p, offset=%zu, calc_ev_end=%p\n", 737 737 event_idx, event, ev_end, offset, calc_ev_end); 738 738 return -1; 739 739 }
+2 -4
arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
··· 240 240 dma_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 241 241 242 242 /* Make DMA channel work with LPB FIFO data register */ 243 - if (dma_dev->device_config(lpbfifo.chan, &dma_conf)) { 244 - ret = -EINVAL; 245 - goto err_dma_prep; 246 - } 243 + if (dma_dev->device_config(lpbfifo.chan, &dma_conf)) 244 + return -EINVAL; 247 245 248 246 sg_init_table(&sg, 1); 249 247
+13 -19
arch/powerpc/platforms/book3s/vas-api.c
··· 425 425 return VM_FAULT_SIGBUS; 426 426 } 427 427 428 - mutex_lock(&txwin->task_ref.mmap_mutex); 429 428 /* 430 429 * The window may be inactive due to lost credit (Ex: core 431 430 * removal with DLPAR). If the window is active again when 432 431 * the credit is available, map the new paste address at the 433 432 * window virtual address. 434 433 */ 435 - if (txwin->status == VAS_WIN_ACTIVE) { 436 - paste_addr = cp_inst->coproc->vops->paste_addr(txwin); 437 - if (paste_addr) { 438 - fault = vmf_insert_pfn(vma, vma->vm_start, 439 - (paste_addr >> PAGE_SHIFT)); 440 - mutex_unlock(&txwin->task_ref.mmap_mutex); 441 - return fault; 434 + scoped_guard(mutex, &txwin->task_ref.mmap_mutex) { 435 + if (txwin->status == VAS_WIN_ACTIVE) { 436 + paste_addr = cp_inst->coproc->vops->paste_addr(txwin); 437 + if (paste_addr) { 438 + fault = vmf_insert_pfn(vma, vma->vm_start, 439 + (paste_addr >> PAGE_SHIFT)); 440 + return fault; 441 + } 442 442 } 443 443 } 444 - mutex_unlock(&txwin->task_ref.mmap_mutex); 445 444 446 445 /* 447 446 * Received this fault due to closing the actual window. ··· 493 494 return; 494 495 } 495 496 496 - mutex_lock(&txwin->task_ref.mmap_mutex); 497 - txwin->task_ref.vma = NULL; 498 - mutex_unlock(&txwin->task_ref.mmap_mutex); 497 + scoped_guard(mutex, &txwin->task_ref.mmap_mutex) 498 + txwin->task_ref.vma = NULL; 499 499 } 500 500 501 501 static const struct vm_operations_struct vas_vm_ops = { ··· 550 552 * close/open event and allows mmap() only when the window is 551 553 * active. 552 554 */ 553 - mutex_lock(&txwin->task_ref.mmap_mutex); 555 + guard(mutex)(&txwin->task_ref.mmap_mutex); 554 556 if (txwin->status != VAS_WIN_ACTIVE) { 555 557 pr_err("Window is not active\n"); 556 - rc = -EACCES; 557 - goto out; 558 + return -EACCES; 558 559 } 559 560 560 561 paste_addr = cp_inst->coproc->vops->paste_addr(txwin); 561 562 if (!paste_addr) { 562 563 pr_err("Window paste address failed\n"); 563 - rc = -EINVAL; 564 - goto out; 564 + return -EINVAL; 565 565 } 566 566 567 567 pfn = paste_addr >> PAGE_SHIFT; ··· 579 583 txwin->task_ref.vma = vma; 580 584 vma->vm_ops = &vas_vm_ops; 581 585 582 - out: 583 - mutex_unlock(&txwin->task_ref.mmap_mutex); 584 586 return rc; 585 587 } 586 588
+3 -9
arch/powerpc/platforms/powernv/ocxl.c
··· 172 172 if (phb->type != PNV_PHB_NPU_OCAPI) 173 173 return; 174 174 175 - mutex_lock(&links_list_lock); 175 + guard(mutex)(&links_list_lock); 176 176 177 177 link = find_link(dev); 178 178 if (!link) { 179 179 dev_warn(&dev->dev, "couldn't update actag information\n"); 180 - mutex_unlock(&links_list_lock); 181 180 return; 182 181 } 183 182 ··· 205 206 dev_dbg(&dev->dev, "total actags for function: %d\n", 206 207 link->fn_desired_actags[PCI_FUNC(dev->devfn)]); 207 208 208 - mutex_unlock(&links_list_lock); 209 209 } 210 210 DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pnv_ocxl_fixup_actag); 211 211 ··· 251 253 { 252 254 struct npu_link *link; 253 255 254 - mutex_lock(&links_list_lock); 256 + guard(mutex)(&links_list_lock); 255 257 256 258 link = find_link(dev); 257 259 if (!link) { 258 260 dev_err(&dev->dev, "actag information not found\n"); 259 - mutex_unlock(&links_list_lock); 260 261 return -ENODEV; 261 262 } 262 263 /* ··· 271 274 *enabled = link->fn_actags[PCI_FUNC(dev->devfn)].count; 272 275 *supported = link->fn_desired_actags[PCI_FUNC(dev->devfn)]; 273 276 274 - mutex_unlock(&links_list_lock); 275 277 return 0; 276 278 } 277 279 EXPORT_SYMBOL_GPL(pnv_ocxl_get_actag); ··· 289 293 * 290 294 * We only support one AFU-carrying function for now. 291 295 */ 292 - mutex_lock(&links_list_lock); 296 + guard(mutex)(&links_list_lock); 293 297 294 298 link = find_link(dev); 295 299 if (!link) { 296 300 dev_err(&dev->dev, "actag information not found\n"); 297 - mutex_unlock(&links_list_lock); 298 301 return -ENODEV; 299 302 } 300 303 ··· 304 309 break; 305 310 } 306 311 307 - mutex_unlock(&links_list_lock); 308 312 dev_dbg(&dev->dev, "%d PASIDs available for function\n", 309 313 rc ? 0 : *count); 310 314 return rc;
+50 -2
arch/powerpc/platforms/pseries/dlpar.c
··· 404 404 return NULL; 405 405 } 406 406 407 + static struct device_node * 408 + get_device_node_with_drc_indexes(u32 drc_index) 409 + { 410 + struct device_node *np = NULL; 411 + u32 nr_indexes, index; 412 + int i, rc; 413 + 414 + for_each_node_with_property(np, "ibm,drc-indexes") { 415 + /* 416 + * First element in the array is the total number of 417 + * DRC indexes returned. 418 + */ 419 + rc = of_property_read_u32_index(np, "ibm,drc-indexes", 420 + 0, &nr_indexes); 421 + if (rc) 422 + goto out_put_np; 423 + 424 + /* 425 + * Retrieve DRC index from the list and return the 426 + * device node if matched with the specified index. 427 + */ 428 + for (i = 0; i < nr_indexes; i++) { 429 + rc = of_property_read_u32_index(np, "ibm,drc-indexes", 430 + i+1, &index); 431 + if (rc) 432 + goto out_put_np; 433 + 434 + if (drc_index == index) 435 + return np; 436 + } 437 + } 438 + 439 + return NULL; 440 + 441 + out_put_np: 442 + of_node_put(np); 443 + return NULL; 444 + } 445 + 407 446 static int dlpar_hp_dt_add(u32 index) 408 447 { 409 448 struct device_node *np, *nodes; ··· 462 423 goto out; 463 424 } 464 425 426 + /* 427 + * Recent FW provides ibm,drc-info property. So search 428 + * for the user specified DRC index from ibm,drc-info 429 + * property. If this property is not available, search 430 + * in the indexes array from ibm,drc-indexes property. 431 + */ 465 432 np = get_device_node_with_drc_info(index); 466 433 467 - if (!np) 468 - return -EIO; 434 + if (!np) { 435 + np = get_device_node_with_drc_indexes(index); 436 + if (!np) 437 + return -EIO; 438 + } 469 439 470 440 /* Next, configure the connector. */ 471 441 nodes = dlpar_configure_connector(cpu_to_be32(index), np);
+71 -35
arch/powerpc/platforms/pseries/plpks-secvar.c
··· 59 59 return PLPKS_SIGNEDUPDATE; 60 60 } 61 61 62 - static const char * const plpks_var_names[] = { 62 + static const char * const plpks_var_names_static[] = { 63 + "PK", 64 + "moduledb", 65 + "trustedcadb", 66 + NULL, 67 + }; 68 + 69 + static const char * const plpks_var_names_dynamic[] = { 63 70 "PK", 64 71 "KEK", 65 72 "db", ··· 159 152 return rc; 160 153 } 161 154 162 - // PLPKS dynamic secure boot doesn't give us a format string in the same way OPAL does. 163 - // Instead, report the format using the SB_VERSION variable in the keystore. 164 - // The string is made up by us, and takes the form "ibm,plpks-sb-v<n>" (or "ibm,plpks-sb-unknown" 165 - // if the SB_VERSION variable doesn't exist). Hypervisor defines the SB_VERSION variable as a 166 - // "1 byte unsigned integer value". 155 + /* 156 + * Return the key management mode. 157 + * 158 + * SB_VERSION is defined as a "1 byte unsigned integer value", taking values 159 + * starting from 1. It is owned by the Partition Firmware and its presence 160 + * indicates that the key management mode is dynamic. Any failure in 161 + * reading SB_VERSION defaults the key management mode to static. The error 162 + * codes -ENOENT or -EPERM are expected in static key management mode. An 163 + * unexpected error code will have to be investigated. Only signed variables 164 + * have null bytes in their names, SB_VERSION does not. 165 + * 166 + * Return 0 to indicate that the key management mode is static. Otherwise 167 + * return the SB_VERSION value to indicate that the key management mode is 168 + * dynamic. 169 + */ 170 + static u8 plpks_get_sb_keymgmt_mode(void) 171 + { 172 + u8 mode; 173 + ssize_t rc; 174 + struct plpks_var var = { 175 + .component = NULL, 176 + .name = "SB_VERSION", 177 + .namelen = 10, 178 + .datalen = 1, 179 + .data = &mode, 180 + }; 181 + 182 + rc = plpks_read_fw_var(&var); 183 + if (rc) { 184 + if (rc != -ENOENT && rc != -EPERM) 185 + pr_info("Error %ld reading SB_VERSION from firmware\n", rc); 186 + mode = 0; 187 + } 188 + return mode; 189 + } 190 + 191 + /* 192 + * PLPKS dynamic secure boot doesn't give us a format string in the same way 193 + * OPAL does. Instead, report the format using the SB_VERSION variable in the 194 + * keystore. The string, made up by us, takes the form of either 195 + * "ibm,plpks-sb-v<n>" or "ibm,plpks-sb-v0", based on the key management mode, 196 + * and return the length of the secvar format property. 197 + */ 167 198 static ssize_t plpks_secvar_format(char *buf, size_t bufsize) 168 199 { 169 - struct plpks_var var = {0}; 170 - ssize_t ret; 171 - u8 version; 200 + u8 mode; 172 201 173 - var.component = NULL; 174 - // Only the signed variables have null bytes in their names, this one doesn't 175 - var.name = "SB_VERSION"; 176 - var.namelen = strlen(var.name); 177 - var.datalen = 1; 178 - var.data = &version; 179 - 180 - // Unlike the other vars, SB_VERSION is owned by firmware instead of the OS 181 - ret = plpks_read_fw_var(&var); 182 - if (ret) { 183 - if (ret == -ENOENT) { 184 - ret = snprintf(buf, bufsize, "ibm,plpks-sb-unknown"); 185 - } else { 186 - pr_err("Error %ld reading SB_VERSION from firmware\n", ret); 187 - ret = -EIO; 188 - } 189 - goto err; 190 - } 191 - 192 - ret = snprintf(buf, bufsize, "ibm,plpks-sb-v%hhu", version); 193 - err: 194 - return ret; 202 + mode = plpks_get_sb_keymgmt_mode(); 203 + return snprintf(buf, bufsize, "ibm,plpks-sb-v%hhu", mode); 195 204 } 196 205 197 206 static int plpks_max_size(u64 *max_size) ··· 220 197 return 0; 221 198 } 222 199 223 - 224 - static const struct secvar_operations plpks_secvar_ops = { 200 + static const struct secvar_operations plpks_secvar_ops_static = { 225 201 .get = plpks_get_variable, 226 202 .set = plpks_set_variable, 227 203 .format = plpks_secvar_format, 228 204 .max_size = plpks_max_size, 229 205 .config_attrs = config_attrs, 230 - .var_names = plpks_var_names, 206 + .var_names = plpks_var_names_static, 207 + }; 208 + 209 + static const struct secvar_operations plpks_secvar_ops_dynamic = { 210 + .get = plpks_get_variable, 211 + .set = plpks_set_variable, 212 + .format = plpks_secvar_format, 213 + .max_size = plpks_max_size, 214 + .config_attrs = config_attrs, 215 + .var_names = plpks_var_names_dynamic, 231 216 }; 232 217 233 218 static int plpks_secvar_init(void) 234 219 { 220 + u8 mode; 221 + 235 222 if (!plpks_is_available()) 236 223 return -ENODEV; 237 224 238 - return set_secvar_ops(&plpks_secvar_ops); 225 + mode = plpks_get_sb_keymgmt_mode(); 226 + if (mode) 227 + return set_secvar_ops(&plpks_secvar_ops_dynamic); 228 + return set_secvar_ops(&plpks_secvar_ops_static); 239 229 } 240 230 machine_device_initcall(pseries, plpks_secvar_init);
+3 -11
arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c
··· 75 75 if (kstrtoll(buf, 0, &interval)) 76 76 return -EINVAL; 77 77 78 - mutex_lock(&sysfs_lock); 78 + guard(mutex)(&sysfs_lock); 79 79 80 80 if (fsl_wakeup->timer) { 81 81 disable_irq_wake(fsl_wakeup->timer->irq); ··· 83 83 fsl_wakeup->timer = NULL; 84 84 } 85 85 86 - if (!interval) { 87 - mutex_unlock(&sysfs_lock); 86 + if (!interval) 88 87 return count; 89 - } 90 88 91 89 fsl_wakeup->timer = mpic_request_timer(fsl_mpic_timer_irq, 92 90 fsl_wakeup, interval); 93 - if (!fsl_wakeup->timer) { 94 - mutex_unlock(&sysfs_lock); 91 + if (!fsl_wakeup->timer) 95 92 return -EINVAL; 96 - } 97 93 98 94 ret = enable_irq_wake(fsl_wakeup->timer->irq); 99 95 if (ret) { 100 96 mpic_free_timer(fsl_wakeup->timer); 101 97 fsl_wakeup->timer = NULL; 102 - mutex_unlock(&sysfs_lock); 103 - 104 98 return ret; 105 99 } 106 100 107 101 mpic_start_timer(fsl_wakeup->timer); 108 - 109 - mutex_unlock(&sysfs_lock); 110 102 111 103 return count; 112 104 }
+3 -2
security/integrity/platform_certs/load_powerpc.c
··· 75 75 return -ENODEV; 76 76 77 77 // Check for known secure boot implementations from OPAL or PLPKS 78 - if (strcmp("ibm,edk2-compat-v1", buf) && strcmp("ibm,plpks-sb-v1", buf)) { 78 + if (strcmp("ibm,edk2-compat-v1", buf) && strcmp("ibm,plpks-sb-v1", buf) && 79 + strcmp("ibm,plpks-sb-v0", buf)) { 79 80 pr_err("Unsupported secvar implementation \"%s\", not loading certs\n", buf); 80 81 return -ENODEV; 81 82 } 82 83 83 - if (strcmp("ibm,plpks-sb-v1", buf) == 0) 84 + if (strcmp("ibm,plpks-sb-v1", buf) == 0 || strcmp("ibm,plpks-sb-v0", buf) == 0) 84 85 /* PLPKS authenticated variables ESL data is prefixed with 8 bytes of timestamp */ 85 86 offset = 8; 86 87