Re: [RFC PATCH 0/2] powerpc/pseries: add support for local secure storage called Platform Keystore(PKS)
On Fri, Jan 21, 2022 at 07:56:35PM -0500, Nayna Jain wrote: > PowerVM provides an isolated Platform Keystore(PKS) storage allocation > for each partition with individually managed access controls to store > sensitive information securely. Linux Kernel can access this storage by > interfacing with hypervisor using a new set of hypervisor calls. > > PowerVM guest secure boot intend to use Platform Keystore for the > purpose of storing public keys. Secure boot requires public keys to > be able to verify the grub and boot kernel. To allow authenticated > manipulation of keys, it supports variables to store key authorities > - PK/KEK and code signing keys - db. It also supports denied list to > disallow booting even if signed with valid key. This is done via > denied list database - dbx or sbat. These variables would be stored in > PKS, and are managed and controlled by firmware. > > The purpose of this patchset is to add support for users to > read/write/add/delete variables required for secure boot on PowerVM. Ok, this is like the 3rd or 4th different platform-specific proposal for this type of functionality. I think we need to give up on platform-specific user/kernel apis on this (random sysfs/securityfs files scattered around the tree), and come up with a standard place for all of this. Please work with the other developers of the other drivers for this to make this unified so that userspace has a chance to use this in a sane manner. thanks, greg k-h
Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
(trying this again, as first time, my message bounced) I just saw this and have not followed the entire thread from the beginning, but if you are unsure if a given license text to something on the SPDX License List, I highly recommend using the SPDX License-diff browser extension / add-on (for Chrome or Firefox) - once you have that, you can simply highlight a text in your browser window and it will tell you if it matches or how far off it is if not. If a license is NOT a match to anything on the SPDX License List, please submit it to the SPDX legal team here: https://tools.spdx.org/app/submit_new_license/ (and preferably then tag me in the Github issue, my Github ide is @jlovejoy ) Please make sure to include that it's in the LInux kernel and a link to where you found it. More about requesting a new license be added to the SPDX License List can be found here: https://github.com/spdx/license-list-XML/blob/master/DOCS/request-new-license.md Thanks! Jilayne SPDX legal team co-lead > On Jan 21, 2022, at 10:17 AM, Richard Fontana wrote: > > On Fri, Jan 21, 2022 at 6:03 AM Christophe Leroy > wrote: >> >> Several files are missing SPDX license identifiers. >> >> Following files are given the following SPDX identifier based on the >> comments in the top of the file: >> >>include/asm/ibmebus.h:/* SPDX-License-Identifier: GPL-2.0 OR OpenIB >> BSD */ > [...] >>platforms/pseries/ibmebus.c:// SPDX-License-Identifier: GPL-2.0 OR >> OpenIB BSD > > "OpenIB BSD" is not a defined SPDX identifier. There is an SPDX > identifier "Linux-OpenIB" > https://spdx.org/licenses/Linux-OpenIB.html > but I believe that is not a match to what's in these files > (specifically, the wording of the disclaimer), rather I believe what > you want here is BSD-2-Clause, but you may want to check that. > > Richard >
[PATCH V2] powerpc/perf: Fix power_pmu_disable to call clear_pmi_irq_pending only if PMI is pending
Running selftest with CONFIG_PPC_IRQ_SOFT_MASK_DEBUG enabled in kernel triggered below warning: [ 172.851380] [ cut here ] [ 172.851391] WARNING: CPU: 8 PID: 2901 at arch/powerpc/include/asm/hw_irq.h:246 power_pmu_disable+0x270/0x280 [ 172.851402] Modules linked in: dm_mod bonding nft_ct nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ip_set nf_tables rfkill nfnetlink sunrpc xfs libcrc32c pseries_rng xts vmx_crypto uio_pdrv_genirq uio sch_fq_codel ip_tables ext4 mbcache jbd2 sd_mod t10_pi sg ibmvscsi ibmveth scsi_transport_srp fuse [ 172.851442] CPU: 8 PID: 2901 Comm: lost_exception_ Not tainted 5.16.0-rc5-03218-g798527287598 #2 [ 172.851451] NIP: c013d600 LR: c013d5a4 CTR: c013b180 [ 172.851458] REGS: c00017687860 TRAP: 0700 Not tainted (5.16.0-rc5-03218-g798527287598) [ 172.851465] MSR: 80029033 CR: 48004884 XER: 2004 [ 172.851482] CFAR: c013d5b4 IRQMASK: 1 [ 172.851482] GPR00: c013d5a4 c00017687b00 c2a10600 0004 [ 172.851482] GPR04: 82004000 c008ba08f0a8 0008b7ed [ 172.851482] GPR08: 446194f6 8000 c013b118 c0d58e68 [ 172.851482] GPR12: c013d390 c0001ec54a80 [ 172.851482] GPR16: c00015d5c708 c25396d0 [ 172.851482] GPR20: ca3bbf40 0003 [ 172.851482] GPR24: c008ba097400 c000161e0d00 ca3bb600 [ 172.851482] GPR28: c00015d5c700 0001 82384090 c008ba0020d8 [ 172.851549] NIP [c013d600] power_pmu_disable+0x270/0x280 [ 172.851557] LR [c013d5a4] power_pmu_disable+0x214/0x280 [ 172.851565] Call Trace: [ 172.851568] [c00017687b00] [c013d5a4] power_pmu_disable+0x214/0x280 (unreliable) [ 172.851579] [c00017687b40] [c03403ac] perf_pmu_disable+0x4c/0x60 [ 172.851588] [c00017687b60] [c03445e4] __perf_event_task_sched_out+0x1d4/0x660 [ 172.851596] [c00017687c50] [c0d1175c] __schedule+0xbcc/0x12a0 [ 172.851602] [c00017687d60] [c0d11ea8] schedule+0x78/0x140 [ 172.851608] [c00017687d90] [c01a8080] sys_sched_yield+0x20/0x40 [ 172.851615] [c00017687db0] [c00334dc] system_call_exception+0x18c/0x380 [ 172.851622] [c00017687e10] [c000c74c] system_call_common+0xec/0x268 The warning indicates that MSR_EE being set(interrupt enabled) when there was an overflown PMC detected. This could happen in power_pmu_disable since it runs under interrupt soft disable condition ( local_irq_save ) and not with interrupts hard disabled. commit 2c9ac51b850d ("powerpc/perf: Fix PMU callbacks to clear pending PMI before resetting an overflown PMC") intended to clear PMI pending bit in Paca when disabling the PMU. It could happen that PMC gets overflown while code is in power_pmu_disable callback function. Hence add a check to see if PMI pending bit is set in Paca before clearing it via clear_pmi_pending. Fixes: 2c9ac51b850d ("powerpc/perf: Fix PMU callbacks to clear pending PMI before resetting an overflown PMC") Signed-off-by: Athira Rajeev Reviewed-by: Nicholas Piggin Reported-by: Sachin Sant Tested-by: Sachin Sant --- Changelog: Change from v1 to v2: - Addressed suggestion from Nick to add comment about why this change is needed in the code. - Added Reviewed-by from Nick. Note: Address the warning reported here: https://lists.ozlabs.org/pipermail/linuxppc-dev/2021-December/238190.html Patch is on top of powerpc/merge arch/powerpc/perf/core-book3s.c | 17 ++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c index a684901b6965..c886801fc11d 100644 --- a/arch/powerpc/perf/core-book3s.c +++ b/arch/powerpc/perf/core-book3s.c @@ -1327,9 +1327,20 @@ static void power_pmu_disable(struct pmu *pmu) * Otherwise provide a warning if there is PMI pending, but * no counter is found overflown. */ - if (any_pmc_overflown(cpuhw)) - clear_pmi_irq_pending(); - else + if (any_pmc_overflown(cpuhw)) { + /* +* Since power_pmu_disable runs under local_irq_save, it +* could happen that code hits a PMC overflow without PMI +* pending in paca. Hence only clear PMI pending if it was +* set. +* +* If a PMI is pending, then MSR[EE] must be disabled (because +* the masked PMI handler disabling EE). So it is safe to +* call clear_pmi_irq_pending(). +*/ + if
[RFC PATCH 2/2] pseries: define sysfs interface to expose PKS variables
PowerVM guest secure boot intend to use Platform Keystore(PKS) for the purpose of storing public keys to verify digital signature. Define sysfs interface to expose PKS variables to userspace to allow read/write/add/delete operations. Each variable is shown as a read/write attribute file. The size of the file represents the size of the current content of the variable. create_var and delete_var attribute files are always present which allow users to create/delete variables. These are write only attributes.The design has tried to be compliant with sysfs semantic to represent single value per attribute. Thus, rather than mapping a complete data structure representation to create_var, it only accepts a single formatted string to create an empty variable. The sysfs interface is designed such as to expose PKS configuration properties, operating system variables and firmware variables. Current version exposes configuration and operating system variables. The support for exposing firmware variables will be added in the future version. Example of pksvar sysfs interface: # cd /sys/firmware/pksvar/ # ls config os # cd config # ls -ltrh total 0 -r--r--r-- 1 root root 64K Jan 21 17:55 version -r--r--r-- 1 root root 64K Jan 21 17:55 used_space -r--r--r-- 1 root root 64K Jan 21 17:55 total_size -r--r--r-- 1 root root 64K Jan 21 17:55 supported_policies -r--r--r-- 1 root root 64K Jan 21 17:55 max_object_size -r--r--r-- 1 root root 64K Jan 21 17:55 max_object_label_size -r--r--r-- 1 root root 64K Jan 21 17:55 flags # cd os # ls -ltrh total 0 -rw--- 1 root root 104 Jan 21 17:56 var4 -rw--- 1 root root 104 Jan 21 17:56 var3 -rw--- 1 root root 831 Jan 21 17:56 GLOBAL_PK -rw--- 1 root root 831 Jan 21 17:56 GLOBAL_KEK -rw--- 1 root root 76 Jan 21 17:56 GLOBAL_dbx -rw--- 1 root root 831 Jan 21 17:56 GLOBAL_db --w--- 1 root root 64K Jan 21 17:56 delete_var --w--- 1 root root 64K Jan 21 17:56 create_var 1. Read variable # hexdump -C GLOBAL_db 00 00 00 00 a1 59 c0 a5 e4 94 a7 4a 87 b5 ab 15 |.Y.J| 0010 5c 2b f0 72 3f 03 00 00 00 00 00 00 23 03 00 00 |\+.r?...#...| 0330 02 a8 e8 ed 0f 20 60 3f 40 04 7c a8 91 21 37 eb |. `?@.|..!7.| 0340 f3 f1 4e |..N| 0343 2. Write variable cat /tmp/data.bin > 3. Create variable # echo "var1" > create_var # ls -ltrh total 0 -rw--- 1 root root 104 Jan 21 17:56 var4 -rw--- 1 root root 104 Jan 21 17:56 var3 -rw--- 1 root root 831 Jan 21 17:56 GLOBAL_PK -rw--- 1 root root 831 Jan 21 17:56 GLOBAL_KEK -rw--- 1 root root 76 Jan 21 17:56 GLOBAL_dbx -rw--- 1 root root 831 Jan 21 17:56 GLOBAL_db --w--- 1 root root 64K Jan 21 17:56 delete_var --w--- 1 root root 64K Jan 21 17:57 create_var -rw--- 1 root root 0 Jan 21 17:57 var1.tmp Current design creates a zero size temporary variable. This implies it is not yet persisted to PKS. Only once data is written to newly created temporary variable and if it is successfully stored in the PKS, that the variable is permanent. The temporary variable will get removed on reboot. The code currently doesn't remove .tmp suffix immediately when persisted. The future version will fix this. To avoid the additional .tmp semantic, alternative option is to consider any zero size variable as temporary variable. This option is under evaluation. This would avoid any runtime sysfs magic to replace .tmp variable with real variable. Also, the formatted string to pass to create_var will have following format in the future version: : 4. Delete variable # echo "var3" > delete_var # ls -ltrh total 0 -rw--- 1 root root 104 Jan 21 17:56 var4 -rw--- 1 root root 831 Jan 21 17:56 GLOBAL_PK -rw--- 1 root root 831 Jan 21 17:56 GLOBAL_KEK -rw--- 1 root root 76 Jan 21 17:56 GLOBAL_dbx -rw--- 1 root root 831 Jan 21 17:56 GLOBAL_db --w--- 1 root root 64K Jan 21 17:57 create_var -rw--- 1 root root 0 Jan 21 17:57 var1.tmp --w--- 1 root root 64K Jan 21 17:58 delete_var The var3 file is removed at runtime, if variable is successfully removed from the PKS storage. NOTE: We are evaluating two design for userspace interface: using the sysfs or defining a new filesystem based. Any feedback on this sysfs based approach would be highly appreciated. We have tried to follow one value per attribute semantic. If that or any other semantics aren't followed properly, please let us know. Signed-off-by: Nayna Jain --- Documentation/ABI/testing/sysfs-pksvar| 77 arch/powerpc/platforms/pseries/Kconfig| 7 + arch/powerpc/platforms/pseries/Makefile | 1 + arch/powerpc/platforms/pseries/pksvar-sysfs.c | 356 ++ 4 files changed, 441 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-pksvar create mode 100644 arch/powerpc/platforms/pseries/pksvar-sysfs.c diff --git a/Documentation/ABI/testing/sysfs-pksvar
[RFC PATCH 1/2] pseries: define driver for Platform Keystore
PowerVM provides an isolated Platform Keystore(PKS) storage allocation for each partition with individually managed access controls to store sensitive information securely. It provides a new set of hypervisor calls for Linux kernel to access PKS storage. Define PKS driver using H_CALL interface to access PKS storage. Signed-off-by: Nayna Jain --- arch/powerpc/include/asm/hvcall.h | 13 +- arch/powerpc/include/asm/pks.h | 84 arch/powerpc/platforms/pseries/Kconfig | 10 + arch/powerpc/platforms/pseries/Makefile | 1 + arch/powerpc/platforms/pseries/pks.c| 494 5 files changed, 601 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/include/asm/pks.h create mode 100644 arch/powerpc/platforms/pseries/pks.c diff --git a/arch/powerpc/include/asm/hvcall.h b/arch/powerpc/include/asm/hvcall.h index 9bcf345cb208..08108dcf8677 100644 --- a/arch/powerpc/include/asm/hvcall.h +++ b/arch/powerpc/include/asm/hvcall.h @@ -97,6 +97,7 @@ #define H_OP_MODE -73 #define H_COP_HW -74 #define H_STATE-75 +#define H_IN_USE -77 #define H_UNSUPPORTED_FLAG_START -256 #define H_UNSUPPORTED_FLAG_END -511 #define H_MULTI_THREADS_ACTIVE -9005 @@ -321,9 +322,19 @@ #define H_SCM_UNBIND_ALL0x3FC #define H_SCM_HEALTH0x400 #define H_SCM_PERFORMANCE_STATS 0x418 +#define H_PKS_GET_CONFIG 0x41C +#define H_PKS_SET_PASSWORD 0x420 +#define H_PKS_GEN_PASSWORD 0x424 +#define H_PKS_GET_OBJECT_LABELS 0x428 +#define H_PKS_WRITE_OBJECT 0x42C +#define H_PKS_GEN_KEY 0x430 +#define H_PKS_READ_OBJECT 0x434 +#define H_PKS_REMOVE_OBJECT0x438 +#define H_PKS_CONFIRM_OBJECT_FLUSHED 0x43C #define H_RPT_INVALIDATE 0x448 #define H_SCM_FLUSH0x44C -#define MAX_HCALL_OPCODE H_SCM_FLUSH +#define H_PKS_SB_SIGNED_UPDATE 0x454 +#define MAX_HCALL_OPCODE H_PKS_SB_SIGNED_UPDATE /* Scope args for H_SCM_UNBIND_ALL */ #define H_UNBIND_SCOPE_ALL (0x1) diff --git a/arch/powerpc/include/asm/pks.h b/arch/powerpc/include/asm/pks.h new file mode 100644 index ..ef6f541d75d3 --- /dev/null +++ b/arch/powerpc/include/asm/pks.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 IBM Corporation + * Author: Nayna Jain + * + * Platform keystore for pseries. + */ +#ifndef _PSERIES_PKS_H +#define _PSERIES_PKS_H + + +#include +#include + +struct pks_var { + char *prefix; + u8 *name; + u16 namelen; + u32 policy; + u16 datalen; + u8 *data; +}; + +struct pks_var_name { + u16 namelen; + u8 *name; +}; + +struct pks_var_name_list { + u32 varcount; + struct pks_var_name *varlist; +}; + +struct pks_config { + u8 version; + u8 flags; + u32 rsvd0; + u16 maxpwsize; + u16 maxobjlabelsize; + u16 maxobjsize; + u32 totalsize; + u32 usedspace; + u32 supportedpolicies; + u64 rsvd1; +} __packed; + +/** + * Successful return from this API implies PKS is available. + * This is used to initialize kernel driver and user interfaces. + */ +extern struct pks_config *pks_get_config(void); + +/** + * Returns all the var names for this prefix. + * This only returns name list. If the caller needs data, it has to specifically + * call read for the required var name. + */ +int pks_get_var_ids_for_type(char *prefix, struct pks_var_name_list *list); + +/** + * Writes the specified var and its data to PKS. + * Any caller of PKS driver should present a valid prefix type for their + * variable. This is an exception only for signed variables exposed via + * sysfs which do not have any prefixes. + * The prefix should always start with '/'. For eg. '/sysfs'. + */ +extern int pks_write_var(struct pks_var var); + +/** + * Writes the specified signed var and its data to PKS. + */ +extern int pks_update_signed_var(struct pks_var var); + +/** + * Removes the specified var and its data from PKS. + */ +extern int pks_remove_var(char *prefix, struct pks_var_name vname); + +/** + * Returns the data for the specified variable. + */ +extern int pks_read_var(struct pks_var *var); + +#endif diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig index 2e57391e0778..32d0df84e611 100644 --- a/arch/powerpc/platforms/pseries/Kconfig +++ b/arch/powerpc/platforms/pseries/Kconfig @@ -147,6 +147,16 @@ config IBMEBUS help Bus device driver for GX bus based adapters. +config PSERIES_PKS + depends on PPC_PSERIES + tristate "Support for the Platform Key Storage" + help + PowerVM provides an isolated Platform Keystore(PKS) storage + allocation for each partition with individually managed + access controls to store sensitive information securely. Select + this config to enable operating system interface to hypervisor to + access this space. + config PAPR_SCM
[RFC PATCH 0/2] powerpc/pseries: add support for local secure storage called Platform Keystore(PKS)
PowerVM provides an isolated Platform Keystore(PKS) storage allocation for each partition with individually managed access controls to store sensitive information securely. Linux Kernel can access this storage by interfacing with hypervisor using a new set of hypervisor calls. PowerVM guest secure boot intend to use Platform Keystore for the purpose of storing public keys. Secure boot requires public keys to be able to verify the grub and boot kernel. To allow authenticated manipulation of keys, it supports variables to store key authorities - PK/KEK and code signing keys - db. It also supports denied list to disallow booting even if signed with valid key. This is done via denied list database - dbx or sbat. These variables would be stored in PKS, and are managed and controlled by firmware. The purpose of this patchset is to add support for users to read/write/add/delete variables required for secure boot on PowerVM. Nayna Jain (2): pseries: define driver for Platform Keystore pseries: define sysfs interface to expose PKS variables Documentation/ABI/testing/sysfs-pksvar| 77 +++ arch/powerpc/include/asm/hvcall.h | 13 +- arch/powerpc/include/asm/pks.h| 84 +++ arch/powerpc/platforms/pseries/Kconfig| 17 + arch/powerpc/platforms/pseries/Makefile | 2 + arch/powerpc/platforms/pseries/pks.c | 494 ++ arch/powerpc/platforms/pseries/pksvar-sysfs.c | 356 + 7 files changed, 1042 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-pksvar create mode 100644 arch/powerpc/include/asm/pks.h create mode 100644 arch/powerpc/platforms/pseries/pks.c create mode 100644 arch/powerpc/platforms/pseries/pksvar-sysfs.c -- 2.27.0
[Bug 213837] [bisected] "Kernel panic - not syncing: corrupted stack end detected inside scheduler" at building via distcc on a G5
https://bugzilla.kernel.org/show_bug.cgi?id=213837 Erhard F. (erhar...@mailbox.org) changed: What|Removed |Added Summary|"Kernel panic - not |[bisected] "Kernel panic - |syncing: corrupted stack|not syncing: corrupted |end detected inside |stack end detected inside |scheduler" at building via |scheduler" at building via |distcc on a G5 |distcc on a G5 --- Comment #15 from Erhard F. (erhar...@mailbox.org) --- This may look a bit odd at first to cause memory corruption while building stuff, but as I do the builds via distcc on another host (sources are fetched via nfs from this host too) it seems possible. Problem is the 'bad' commit is a merge and reverting it on v5.16.2 for a test via git revert -m1 c2c11289021dfacec1658b2019faab10e12f383a gets me some merge conflicts which I don't know to resolve properly.. -- You may reply to this email to add a comment. You are receiving this mail because: You are watching the assignee of the bug. You are watching someone on the CC list of the bug.
[Bug 213837] "Kernel panic - not syncing: corrupted stack end detected inside scheduler" at building via distcc on a G5
https://bugzilla.kernel.org/show_bug.cgi?id=213837 --- Comment #14 from Erhard F. (erhar...@mailbox.org) --- Created attachment 300297 --> https://bugzilla.kernel.org/attachment.cgi?id=300297=edit bisect.log Finally did a bisect which revealed the following commit: # git bisect good c2c11289021dfacec1658b2019faab10e12f383a is the first bad commit commit c2c11289021dfacec1658b2019faab10e12f383a Merge: 63bef48fd6c9 ef516e8625dd Author: David S. Miller Date: Tue Apr 7 18:08:06 2020 -0700 Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf Pablo Neira Ayuso says: Netfilter fixes for net The following patchset contains Netfilter fixes for net, they are: 1) Fix spurious overlap condition in the rbtree tree, from Stefano Brivio. 2) Fix possible uninitialized pointer dereference in nft_lookup. 3) IDLETIMER v1 target matches the Android layout, from Maciej Zenczykowski. 4) Dangling pointer in nf_tables_set_alloc_name, from Eric Dumazet. 5) Fix RCU warning splat in ipset find_set_type(), from Amol Grover. 6) Report EOPNOTSUPP on unsupported set flags and object types in sets. 7) Add NFT_SET_CONCAT flag to provide consistent error reporting when users defines set with ranges in concatenations in old kernels. Signed-off-by: David S. Miller include/net/netfilter/nf_tables.h | 2 +- include/uapi/linux/netfilter/nf_tables.h| 2 ++ include/uapi/linux/netfilter/xt_IDLETIMER.h | 1 + net/netfilter/ipset/ip_set_core.c | 3 ++- net/netfilter/nf_tables_api.c | 7 --- net/netfilter/nft_lookup.c | 12 +++- net/netfilter/nft_set_bitmap.c | 1 - net/netfilter/nft_set_rbtree.c | 23 +++ net/netfilter/xt_IDLETIMER.c| 3 +++ 9 files changed, 31 insertions(+), 23 deletions(-) -- You may reply to this email to add a comment. You are receiving this mail because: You are watching the assignee of the bug. You are watching someone on the CC list of the bug.
[PATCH v4 5/5] KVM: PPC: mmio: Deliver DSI after emulation failure
MMIO emulation can fail if the guest uses an instruction that we are not prepared to emulate. Since these instructions can be and most likely are valid ones, this is (slightly) closer to an access fault than to an illegal instruction, so deliver a Data Storage interrupt instead of a Program interrupt. Suggested-by: Nicholas Piggin Signed-off-by: Fabiano Rosas --- arch/powerpc/kvm/emulate_loadstore.c | 10 +++--- arch/powerpc/kvm/powerpc.c | 12 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/kvm/emulate_loadstore.c b/arch/powerpc/kvm/emulate_loadstore.c index 48272a9b9c30..cfc9114b87d0 100644 --- a/arch/powerpc/kvm/emulate_loadstore.c +++ b/arch/powerpc/kvm/emulate_loadstore.c @@ -73,7 +73,6 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu) { u32 inst; enum emulation_result emulated = EMULATE_FAIL; - int advance = 1; struct instruction_op op; /* this default type might be overwritten by subcategories */ @@ -98,6 +97,8 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu) int type = op.type & INSTR_TYPE_MASK; int size = GETSIZE(op.type); + vcpu->mmio_is_write = OP_IS_STORE(type); + switch (type) { case LOAD: { int instr_byte_swap = op.type & BYTEREV; @@ -355,15 +356,10 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu) } } - if (emulated == EMULATE_FAIL) { - advance = 0; - kvmppc_core_queue_program(vcpu, 0); - } - trace_kvm_ppc_instr(inst, kvmppc_get_pc(vcpu), emulated); /* Advance past emulated instruction. */ - if (advance) + if (emulated != EMULATE_FAIL) kvmppc_set_pc(vcpu, kvmppc_get_pc(vcpu) + 4); return emulated; diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 214602c58f13..9befb121dddb 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -305,10 +305,22 @@ int kvmppc_emulate_mmio(struct kvm_vcpu *vcpu) case EMULATE_FAIL: { u32 last_inst; + ulong store_bit = DSISR_ISSTORE; + ulong cause = DSISR_BADACCESS; +#ifdef CONFIG_BOOKE + store_bit = ESR_ST; + cause = 0; +#endif kvmppc_get_last_inst(vcpu, INST_GENERIC, _inst); pr_info_ratelimited("KVM: guest access to device memory using unsupported instruction (PID: %d opcode: %#08x)\n", current->pid, last_inst); + + if (vcpu->mmio_is_write) + cause |= store_bit; + + kvmppc_core_queue_data_storage(vcpu, vcpu->arch.vaddr_accessed, + cause); r = RESUME_GUEST; break; } -- 2.34.1
[PATCH v4 4/5] KVM: PPC: mmio: Return to guest after emulation failure
If MMIO emulation fails we don't want to crash the whole guest by returning to userspace. The original commit bbf45ba57eae ("KVM: ppc: PowerPC 440 KVM implementation") added a todo: /* XXX Deliver Program interrupt to guest. */ and later the commit d69614a295ae ("KVM: PPC: Separate loadstore emulation from priv emulation") added the Program interrupt injection but in another file, so I'm assuming it was missed that this block needed to be altered. Also change the message to a ratelimited one since we're letting the guest run and it could flood the host logs. Signed-off-by: Fabiano Rosas --- arch/powerpc/kvm/powerpc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 27fb2b70f631..214602c58f13 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -307,9 +307,9 @@ int kvmppc_emulate_mmio(struct kvm_vcpu *vcpu) u32 last_inst; kvmppc_get_last_inst(vcpu, INST_GENERIC, _inst); - /* XXX Deliver Program interrupt to guest. */ - pr_emerg("%s: emulation failed (%08x)\n", __func__, last_inst); - r = RESUME_HOST; + pr_info_ratelimited("KVM: guest access to device memory using unsupported instruction (PID: %d opcode: %#08x)\n", + current->pid, last_inst); + r = RESUME_GUEST; break; } default: -- 2.34.1
[PATCH v4 3/5] KVM: PPC: mmio: Reject instructions that access more than mmio.data size
The MMIO interface between the kernel and userspace uses a structure that supports a maximum of 8-bytes of data. Instructions that access more than that need to be emulated in parts. We currently don't have generic support for splitting the emulation in parts and each set of instructions needs to be explicitly included. There's already an error message being printed when a load or store exceeds the mmio.data buffer but we don't fail the emulation until later at kvmppc_complete_mmio_load and even then we allow userspace to make a partial copy of the data, which ends up overwriting some fields of the mmio structure. This patch makes the emulation fail earlier at kvmppc_handle_load|store, which will send a Program interrupt to the guest. This is better than allowing the guest to proceed with partial data. Note that this was caught in a somewhat artificial scenario using quadword instructions (lq/stq), there's no account of an actual guest in the wild running instructions that are not properly emulated. (While here, remove the "bad MMIO" messages. The caller already has an error message.) Signed-off-by: Fabiano Rosas Reviewed-by: Alexey Kardashevskiy --- arch/powerpc/kvm/powerpc.c | 16 +--- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index c2bd29e90314..27fb2b70f631 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -1114,10 +1114,8 @@ static void kvmppc_complete_mmio_load(struct kvm_vcpu *vcpu) struct kvm_run *run = vcpu->run; u64 gpr; - if (run->mmio.len > sizeof(gpr)) { - printk(KERN_ERR "bad MMIO length: %d\n", run->mmio.len); + if (run->mmio.len > sizeof(gpr)) return; - } if (!vcpu->arch.mmio_host_swabbed) { switch (run->mmio.len) { @@ -1236,10 +1234,8 @@ static int __kvmppc_handle_load(struct kvm_vcpu *vcpu, host_swabbed = !is_default_endian; } - if (bytes > sizeof(run->mmio.data)) { - printk(KERN_ERR "%s: bad MMIO length: %d\n", __func__, - run->mmio.len); - } + if (bytes > sizeof(run->mmio.data)) + return EMULATE_FAIL; run->mmio.phys_addr = vcpu->arch.paddr_accessed; run->mmio.len = bytes; @@ -1325,10 +1321,8 @@ int kvmppc_handle_store(struct kvm_vcpu *vcpu, host_swabbed = !is_default_endian; } - if (bytes > sizeof(run->mmio.data)) { - printk(KERN_ERR "%s: bad MMIO length: %d\n", __func__, - run->mmio.len); - } + if (bytes > sizeof(run->mmio.data)) + return EMULATE_FAIL; run->mmio.phys_addr = vcpu->arch.paddr_accessed; run->mmio.len = bytes; -- 2.34.1
[PATCH v4 2/5] KVM: PPC: Fix vmx/vsx mixup in mmio emulation
The MMIO emulation code for vector instructions is duplicated between VSX and VMX. When emulating VMX we should check the VMX copy size instead of the VSX one. Fixes: acc9eb9305fe ("KVM: PPC: Reimplement LOAD_VMX/STORE_VMX instruction ...") Signed-off-by: Fabiano Rosas Reviewed-by: Nicholas Piggin --- arch/powerpc/kvm/powerpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 50414fb2a5ea..c2bd29e90314 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -1499,7 +1499,7 @@ int kvmppc_handle_vmx_load(struct kvm_vcpu *vcpu, { enum emulation_result emulated = EMULATE_DONE; - if (vcpu->arch.mmio_vsx_copy_nums > 2) + if (vcpu->arch.mmio_vmx_copy_nums > 2) return EMULATE_FAIL; while (vcpu->arch.mmio_vmx_copy_nums) { @@ -1596,7 +1596,7 @@ int kvmppc_handle_vmx_store(struct kvm_vcpu *vcpu, unsigned int index = rs & KVM_MMIO_REG_MASK; enum emulation_result emulated = EMULATE_DONE; - if (vcpu->arch.mmio_vsx_copy_nums > 2) + if (vcpu->arch.mmio_vmx_copy_nums > 2) return EMULATE_FAIL; vcpu->arch.io_gpr = rs; -- 2.34.1
[PATCH v4 1/5] KVM: PPC: Book3S HV: Stop returning internal values to userspace
Our kvm_arch_vcpu_ioctl_run currently returns the RESUME_HOST values to userspace, against the API of the KVM_RUN ioctl which returns 0 on success. Signed-off-by: Fabiano Rosas Reviewed-by: Nicholas Piggin --- This was noticed while enabling the kvm selftests for powerpc. There's an assert at the _vcpu_run function when we return a value different from the expected. --- arch/powerpc/kvm/powerpc.c | 8 1 file changed, 8 insertions(+) diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 2ad0ccd202d5..50414fb2a5ea 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -1841,6 +1841,14 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) #ifdef CONFIG_ALTIVEC out: #endif + + /* +* We're already returning to userspace, don't pass the +* RESUME_HOST flags along. +*/ + if (r > 0) + r = 0; + vcpu_put(vcpu); return r; } -- 2.34.1
[PATCH v4 0/5] KVM: PPC: MMIO fixes
Changes from v3: Removed all of the low level messages and altered the pr_emerg in the emulate_mmio to a more descriptive message. Changed the Program interrupt to a Data Storage. There's an ifdef needed because this code is shared by HV, PR and booke. v3: https://lore.kernel.org/r/20220107210012.4091153-1-faro...@linux.ibm.com v2: https://lore.kernel.org/r/20220106200304.4070825-1-faro...@linux.ibm.com v1: https://lore.kernel.org/r/20211223211528.3560711-1-faro...@linux.ibm.com Fabiano Rosas (5): KVM: PPC: Book3S HV: Stop returning internal values to userspace KVM: PPC: Fix vmx/vsx mixup in mmio emulation KVM: PPC: mmio: Reject instructions that access more than mmio.data size KVM: PPC: mmio: Return to guest after emulation failure KVM: PPC: mmio: Deliver DSI after emulation failure arch/powerpc/kvm/emulate_loadstore.c | 10 ++ arch/powerpc/kvm/powerpc.c | 46 ++-- 2 files changed, 33 insertions(+), 23 deletions(-) -- 2.34.1
[RFC PATCH 3/3] powerpc/pseries/vas: Disable window open during migration
The current partition migration implementation does not freeze the user space and the user space can continue open VAS windows. So when migration_in_progress flag is enabled, VAS open window API returns -EBUSY. Signed-off-by: Haren Myneni --- arch/powerpc/platforms/pseries/vas.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c index 7087528e4246..e407767a9cb8 100644 --- a/arch/powerpc/platforms/pseries/vas.c +++ b/arch/powerpc/platforms/pseries/vas.c @@ -30,6 +30,7 @@ static bool copypaste_feat; static struct vas_caps vascaps[VAS_MAX_FEAT_TYPE]; static DEFINE_MUTEX(vas_pseries_mutex); +static bool migration_in_progress; static long hcall_return_busy_check(long rc) { @@ -356,8 +357,11 @@ static struct vas_window *vas_allocate_window(int vas_id, u64 flags, * same fault IRQ is not freed by the OS before. */ mutex_lock(_pseries_mutex); - rc = allocate_setup_window(txwin, (u64 *)[0], - cop_feat_caps->win_type); + if (migration_in_progress) + rc = -EBUSY; + else + rc = allocate_setup_window(txwin, (u64 *)[0], + cop_feat_caps->win_type); mutex_unlock(_pseries_mutex); if (rc) goto out; @@ -796,6 +800,7 @@ int vas_reconfig_capabilties(u8 type) return -ENOMEM; mutex_lock(_pseries_mutex); + rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES, vcaps->feat, (u64)virt_to_phys(hv_caps)); if (rc) @@ -894,6 +899,11 @@ static int vas_migrate_windows(bool suspend) mutex_lock(_pseries_mutex); + if (suspend) + migration_in_progress = true; + else + migration_in_progress = false; + for (i = 0; i < VAS_MAX_FEAT_TYPE; i++) { vcaps = [i]; caps = >caps; -- 2.27.0
[RFC PATCH 2/3] powerpc/pseries/vas: Add VAS suspend/resume notifier
Since the windows belong to the VAS hardware resource, the hypervisor expects the partition to close them on source partition and reopen them after the partition migrated on the destination machine. This suspend/resume notifier invokes suspend operation before and resume operation after migration. All active windows for both default and QoS types will be closed during suspend and reopen them during resume. During migration, the user space should expect paste instruction failure if issues copy/paste on these active windows. Signed-off-by: Haren Myneni --- arch/powerpc/platforms/pseries/vas.c | 97 +++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c index e4797fc73553..7087528e4246 100644 --- a/arch/powerpc/platforms/pseries/vas.c +++ b/arch/powerpc/platforms/pseries/vas.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "vas.h" @@ -873,6 +874,98 @@ static struct notifier_block pseries_vas_nb = { .notifier_call = pseries_vas_notifier, }; +/* + * For LPM, all windows have to be closed on the source partition + * before migration and reopen them on the destination partition + * after migration. So closing windows during suspend and + * reopen them during resume. + */ +static int vas_migrate_windows(bool suspend) +{ + struct hv_vas_cop_feat_caps *hv_caps; + struct vas_cop_feat_caps *caps; + int lpar_creds, new_creds = 0; + struct vas_caps *vcaps; + int i, rc = 0; + + hv_caps = kmalloc(sizeof(*hv_caps), GFP_KERNEL); + if (!hv_caps) + return -ENOMEM; + + mutex_lock(_pseries_mutex); + + for (i = 0; i < VAS_MAX_FEAT_TYPE; i++) { + vcaps = [i]; + caps = >caps; + lpar_creds = atomic_read(>target_creds); + + rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES, vcaps->feat, + (u64)virt_to_phys(hv_caps)); + if (!rc) { + new_creds = be16_to_cpu(hv_caps->target_lpar_creds); + /* +* Should not happen. But incase print messages, close all +* windows in the list during suspend and reopen windows +* based on new lpar_creds on the destination system. +*/ + if (lpar_creds != new_creds) { + pr_err("%s: lpar creds: %d HV lpar creds: %d\n", + suspend ? "Suspend" : "Resume", lpar_creds, + new_creds); + pr_err("Used creds: %d, Active creds: %d\n", + atomic_read(>used_creds), + vcaps->num_wins - vcaps->close_wins); + } + } else { + pr_err("%s: Get VAS capabilities failed with %d\n", + suspend ? "Suspend" : "Resume", rc); + /* +* We can not stop migration with the current lpm +* implementation. So continue closing all windows in the +* list (during suspend) and return without opending windows +* (during resume) if VAS capabilities HCALL failed. +*/ + if (!suspend) + goto out; + } + + if (suspend) + rc = reconfig_close_windows(vcaps, vcaps->num_wins, true); + else { + atomic_set(>target_creds, new_creds); + rc = reconfig_open_windows(vcaps, new_creds, true); + } + + /* +* Ignore errors during suspend and return for resume. +*/ + if (rc && !suspend) + goto out; + } + +out: + mutex_unlock(_pseries_mutex); + kfree(hv_caps); + return rc; +} + +static int vas_migration_handler(struct notifier_block *nb, +unsigned long action, void *data) +{ + if (action == PSERIES_RESUMING) + return vas_migrate_windows(false); + else + return vas_migrate_windows(true); + +} + +static struct pseries_suspend_handler vas_suspend_handler = { + .notifier_block = { + .notifier_call = vas_migration_handler, + }, +}; + + static int __init pseries_vas_init(void) { struct hv_vas_cop_feat_caps *hv_cop_caps; @@ -929,8 +1022,10 @@ static int __init pseries_vas_init(void) } /* Processors can be added/removed only on LPAR */ -
[RFC PATCH 1/3] powerpc/pseries/vas: Modify reconfig open/close functions for migration
VAS is a hardware engine stays on the chip. So when the partition migrates, all VAS windows on the source system have to be closed and reopen them on the destination after migration. This patch make changes to the current reconfig_open/close_windows functions to support migration: - Set VAS_WIN_MIGRATE_CLOSE to the window status when closes and reopen windows with the same status during resume. - Continue to close all windows even if deallocate HCALL failed (should not happen) since no way to stop migration with the current LPM implementation. - If the DLPAR CPU event happens while migration is in progress, set VAS_WIN_NO_CRED_CLOSE to the window status. Close window happens with the first event (migration or DLPAR) and Reopen window happens only with the last event (migration or DLPAR). Signed-off-by: Haren Myneni --- arch/powerpc/include/asm/vas.h | 2 + arch/powerpc/platforms/pseries/vas.c | 88 ++-- 2 files changed, 73 insertions(+), 17 deletions(-) diff --git a/arch/powerpc/include/asm/vas.h b/arch/powerpc/include/asm/vas.h index ddc05a8fc2e3..f21e76f47175 100644 --- a/arch/powerpc/include/asm/vas.h +++ b/arch/powerpc/include/asm/vas.h @@ -42,6 +42,8 @@ /* Linux status bits */ #define VAS_WIN_NO_CRED_CLOSE 0x0004 /* Window is closed due to */ /* lost credit */ +#define VAS_WIN_MIGRATE_CLOSE 0x0008 /* Window is closed due to */ + /* migration */ /* * Get/Set bit fields */ diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c index 3400f4fc6609..e4797fc73553 100644 --- a/arch/powerpc/platforms/pseries/vas.c +++ b/arch/powerpc/platforms/pseries/vas.c @@ -456,11 +456,12 @@ static int vas_deallocate_window(struct vas_window *vwin) mutex_lock(_pseries_mutex); /* * VAS window is already closed in the hypervisor when -* lost the credit. So just remove the entry from -* the list, remove task references and free vas_window +* lost the credit or with migration. So just remove the entry +* from the list, remove task references and free vas_window * struct. */ - if (win->vas_win.status & VAS_WIN_NO_CRED_CLOSE) { + if (!(win->vas_win.status & VAS_WIN_NO_CRED_CLOSE) && + !(win->vas_win.status & VAS_WIN_MIGRATE_CLOSE)) { rc = deallocate_free_window(win); if (rc) { mutex_unlock(_pseries_mutex); @@ -577,12 +578,14 @@ static int __init get_vas_capabilities(u8 feat, enum vas_cop_feat_type type, * by setting the remapping to new paste address if the window is * active. */ -static int reconfig_open_windows(struct vas_caps *vcaps, int creds) +static int reconfig_open_windows(struct vas_caps *vcaps, int creds, +bool migrate) { long domain[PLPAR_HCALL9_BUFSIZE] = {VAS_DEFAULT_DOMAIN_ID}; struct vas_cop_feat_caps *caps = >caps; struct pseries_vas_window *win = NULL, *tmp; int rc, mv_ents = 0; + int flag; /* * Nothing to do if there are no closed windows. @@ -601,8 +604,10 @@ static int reconfig_open_windows(struct vas_caps *vcaps, int creds) * (dedicated). If 1 core is added, this LPAR can have 20 more * credits. It means the kernel can reopen 20 windows. So move * 20 entries in the VAS windows lost and reopen next 20 windows. +* For partition migration, reopen all windows that are closed +* during resume. */ - if (vcaps->close_wins > creds) + if ((vcaps->close_wins > creds) && !migrate) mv_ents = vcaps->close_wins - creds; list_for_each_entry_safe(win, tmp, >list, win_list) { @@ -612,12 +617,35 @@ static int reconfig_open_windows(struct vas_caps *vcaps, int creds) mv_ents--; } + /* +* Open windows if they are closed only with migration or +* DLPAR (lost credit) before. +*/ + if (migrate) + flag = VAS_WIN_MIGRATE_CLOSE; + else + flag = VAS_WIN_NO_CRED_CLOSE; + list_for_each_entry_safe_from(win, tmp, >list, win_list) { + /* +* This window is closed with DLPAR and migration events. +* So reopen the window with the last event. +* The user space is not suspended with the current +* migration notifier. So the user space can issue DLPAR +* CPU hotplug while migration in progress. In this case +* this window will be opened with the last event. +*/ + if ((win->vas_win.status & VAS_WIN_NO_CRED_CLOSE) && + (win->vas_win.status & VAS_WIN_MIGRATE_CLOSE)) { + win->vas_win.status &= ~flag; + continue; +
[RFC PATCH 0/3] powerpc/pseries/vas: VAS/NXGZIP support with LPM
Virtual Accelerator Switchboard (VAS) is an engine stays on the chip. So all windows opened on a specific engine belongs to VAS the chip. The hypervisor expects the partition to close all active windows on the sources system and reopen them after migration on the destination machine. This patch series adds VAS support with the partition migration. When the migration initiates, the VAS code gets suspend notifier which closes all active windows and sets VAS_WIN_MIGRATE_CLOSE as window status. Whereas receives resume notifier after migration to reopen all windows which has VAS_WIN_MIGRATE_CLOSE status. These patches depend on VAS/DLPAR support patch series (https://lists.ozlabs.org/pipermail/linuxppc-dev/2021-December/238331.html) Also the suspend/resume notifier code is added in a separate patch and will be posted later with the actual patches. Haren Myneni (3): powerpc/pseries/vas: Modify reconfig open/close functions for migration powerpc/pseries/vas: Add VAS suspend/resume notifier powerpc/pseries/vas: Disable window open during migration arch/powerpc/include/asm/vas.h | 2 + arch/powerpc/platforms/pseries/vas.c | 199 --- 2 files changed, 181 insertions(+), 20 deletions(-) -- 2.27.0
Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
I just saw this and have not followed the entire thread from the beginning, but if you are unsure if a given license text to something on the SPDX License List, I highly recommend using the SPDX License-diff browser extension / add-on (for Chrome or Firefox) - once you have that, you can simply highlight a text in your browser window and it will tell you if it matches or how far off it is if not. If a license is NOT a match to anything on the SPDX License List, please submit it to the SPDX legal team here: https://tools.spdx.org/app/submit_new_license/ (and preferably then tag me in the Github issue, my Github ide is @jlovejoy ) Please make sure to include that it's in the LInux kernel and a link to where you found it. More about requesting a new license be added to the SPDX License List can be found here: https://github.com/spdx/license-list-XML/blob/master/DOCS/request-new-license.md Thanks! Jilayne SPDX legal team co-lead On 1/21/22 10:17 AM, Richard Fontana wrote: On Fri, Jan 21, 2022 at 6:03 AM Christophe Leroy wrote: Several files are missing SPDX license identifiers. Following files are given the following SPDX identifier based on the comments in the top of the file: include/asm/ibmebus.h:/* SPDX-License-Identifier: GPL-2.0 OR OpenIB BSD */ [...] platforms/pseries/ibmebus.c:// SPDX-License-Identifier: GPL-2.0 OR OpenIB BSD "OpenIB BSD" is not a defined SPDX identifier. There is an SPDX identifier "Linux-OpenIB" https://spdx.org/licenses/Linux-OpenIB.html but I believe that is not a match to what's in these files (specifically, the wording of the disclaimer), rather I believe what you want here is BSD-2-Clause, but you may want to check that. Richard
Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
On Fri, Jan 21, 2022 at 6:03 AM Christophe Leroy wrote: > > Several files are missing SPDX license identifiers. > > Following files are given the following SPDX identifier based on the comments > in the top of the file: > > include/asm/ibmebus.h:/* SPDX-License-Identifier: GPL-2.0 OR OpenIB > BSD */ [...] > platforms/pseries/ibmebus.c:// SPDX-License-Identifier: GPL-2.0 OR > OpenIB BSD "OpenIB BSD" is not a defined SPDX identifier. There is an SPDX identifier "Linux-OpenIB" https://spdx.org/licenses/Linux-OpenIB.html but I believe that is not a match to what's in these files (specifically, the wording of the disclaimer), rather I believe what you want here is BSD-2-Clause, but you may want to check that. Richard
Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
On Fri, Jan 21, 2022 at 6:03 AM Christophe Leroy wrote: > > Several files are missing SPDX license identifiers. > > Following files are given the following SPDX identifier based on the comments > in the top of the file: > > include/asm/epapr_hcalls.h:/* SPDX-License-Identifier: GPL-2.0+ OR > BSD */ > include/asm/fsl_hcalls.h:/* SPDX-License-Identifier: GPL-2.0+ OR BSD > */ "BSD" is not a defined SPDX identifier. I believe what you want here is "BSD-3-Clause" (see: https://spdx.org/licenses/BSD-3-Clause.html) Richard
[PATCH 08/31] leds: changing LED_* from enum led_brightness to actual value
The enum led_brightness, which contains the declaration of LED_OFF, LED_ON, LED_HALF and LED_FULL is obsolete, as the led class now supports max_brightness. --- drivers/leds/blink/leds-lgm-sso.c| 8 +++ drivers/leds/flash/leds-ktd2692.c| 4 ++-- drivers/leds/flash/leds-lm3601x.c| 10 drivers/leds/flash/leds-mt6360.c | 10 drivers/leds/flash/leds-rt4505.c | 8 +++ drivers/leds/flash/leds-rt8515.c | 4 ++-- drivers/leds/flash/leds-sgm3140.c| 4 ++-- drivers/leds/led-class.c | 6 ++--- drivers/leds/led-core.c | 8 +++ drivers/leds/led-triggers.c | 4 ++-- drivers/leds/leds-adp5520.c | 2 +- drivers/leds/leds-an30259a.c | 8 +++ drivers/leds/leds-apu.c | 6 ++--- drivers/leds/leds-ariel.c| 8 +++ drivers/leds/leds-asic3.c| 2 +- drivers/leds/leds-aw2013.c | 6 ++--- drivers/leds/leds-bcm6328.c | 14 +-- drivers/leds/leds-bcm6358.c | 14 +-- drivers/leds/leds-bd2802.c | 14 +-- drivers/leds/leds-clevo-mail.c | 6 ++--- drivers/leds/leds-cobalt-qube.c | 2 +- drivers/leds/leds-cpcap.c| 10 drivers/leds/leds-da903x.c | 4 ++-- drivers/leds/leds-da9052.c | 4 ++-- drivers/leds/leds-dac124s085.c | 2 +- drivers/leds/leds-el15203000.c | 4 ++-- drivers/leds/leds-gpio.c | 4 ++-- drivers/leds/leds-is31fl319x.c | 2 +- drivers/leds/leds-lm3530.c | 4 ++-- drivers/leds/leds-lm3532.c | 8 +++ drivers/leds/leds-lm3533.c | 4 ++-- drivers/leds/leds-lm3692x.c | 2 +- drivers/leds/leds-lm3697.c | 6 ++--- drivers/leds/leds-lp3952.c | 4 ++-- drivers/leds/leds-lt3593.c | 2 +- drivers/leds/leds-max77650.c | 4 ++-- drivers/leds/leds-menf21bmc.c| 2 +- drivers/leds/leds-mlxcpld.c | 22 - drivers/leds/leds-mlxreg.c | 10 drivers/leds/leds-mt6323.c | 2 +- drivers/leds/leds-netxbig.c | 4 ++-- drivers/leds/leds-nic78bx.c | 2 +- drivers/leds/leds-ns2.c | 4 ++-- drivers/leds/leds-ot200.c| 2 +- drivers/leds/leds-pca9532.c | 6 ++--- drivers/leds/leds-pca955x.c | 30 drivers/leds/leds-pca963x.c | 4 ++-- drivers/leds/leds-pm8058.c | 8 +++ drivers/leds/leds-powernv.c | 12 +- drivers/leds/leds-pwm.c | 2 +- drivers/leds/leds-rb532.c| 2 +- drivers/leds/leds-regulator.c| 2 +- drivers/leds/leds-sc27xx-bltc.c | 6 ++--- drivers/leds/leds-spi-byte.c | 2 +- drivers/leds/leds-ss4200.c | 12 +- drivers/leds/leds-sunfire.c | 2 +- drivers/leds/leds-syscon.c | 2 +- drivers/leds/leds-tca6507.c | 8 +++ drivers/leds/leds-wm831x-status.c| 8 +++ drivers/leds/leds-wm8350.c | 8 +++ drivers/leds/simple/simatic-ipc-leds.c | 10 drivers/leds/trigger/ledtrig-activity.c | 2 +- drivers/leds/trigger/ledtrig-backlight.c | 4 ++-- drivers/leds/trigger/ledtrig-camera.c| 4 ++-- drivers/leds/trigger/ledtrig-cpu.c | 4 ++-- drivers/leds/trigger/ledtrig-gpio.c | 4 ++-- drivers/leds/trigger/ledtrig-heartbeat.c | 4 ++-- drivers/leds/trigger/ledtrig-netdev.c| 6 ++--- drivers/leds/trigger/ledtrig-oneshot.c | 6 ++--- drivers/leds/trigger/ledtrig-panic.c | 2 +- drivers/leds/trigger/ledtrig-pattern.c | 2 +- drivers/leds/trigger/ledtrig-timer.c | 2 +- drivers/leds/trigger/ledtrig-transient.c | 6 ++--- drivers/leds/trigger/ledtrig-tty.c | 4 ++-- 74 files changed, 217 insertions(+), 217 deletions(-) diff --git a/drivers/leds/blink/leds-lgm-sso.c b/drivers/leds/blink/leds-lgm-sso.c index 6f270c0272fb..26c17c64bd4f 100644 --- a/drivers/leds/blink/leds-lgm-sso.c +++ b/drivers/leds/blink/leds-lgm-sso.c @@ -51,7 +51,7 @@ #define SSO_LED_MAX_NUMSZ_32 #define MAX_FREQ_RANK 10 #define DEF_GPTC_CLK_RATE 2 -#define SSO_DEF_BRIGHTNESS LED_HALF +#define SSO_DEF_BRIGHTNESS 127 #define DATA_CLK_EDGE 0 /* 0-rising, 1-falling */ static const u32 freq_div_tbl[] = {4000, 2000, 1000, 800}; @@ -244,7 +244,7 @@ static void sso_led_brightness_set(struct led_classdev *led_cdev, desc->brightness = brightness; regmap_write(priv->mmap, DUTY_CYCLE(desc->pin), brightness); - if (brightness == LED_OFF) + if (brightness ==
[PATCH 09/31] macintosh: changing LED_* from enum led_brightness to actual value
The enum led_brightness, which contains the declaration of LED_OFF, LED_ON, LED_HALF and LED_FULL is obsolete, as the led class now supports max_brightness. --- drivers/macintosh/via-pmu-led.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c index ae067ab2373d..b0a727ad0157 100644 --- a/drivers/macintosh/via-pmu-led.c +++ b/drivers/macintosh/via-pmu-led.c @@ -54,7 +54,7 @@ static void pmu_led_set(struct led_classdev *led_cdev, spin_lock_irqsave(_blink_lock, flags); switch (brightness) { - case LED_OFF: + case 0: requested_change = 0; break; case LED_FULL: -- 2.34.1
[PATCH v3 10/10] powerpc/pseries/vas: Write 'target_creds' for QoS credits change
PowerVM support two types of credits - Default (uses normal priority FIFO) and Qality of service (QoS uses high priproty FIFO). The user decides the number of QoS credits and sets this value with HMC interface. With the core add/removal, this value can be changed in HMC which invokes drmgr to communicate to the kernel. This patch adds an interface so that drmgr command can write the new target QoS credits in sysfs. But the kernel gets the new QoS capabilities from the hypervisor whenever target_creds is updated to make sure sync with the values in the hypervisor. Signed-off-by: Haren Myneni --- arch/powerpc/platforms/pseries/vas-sysfs.c | 34 +- arch/powerpc/platforms/pseries/vas.c | 2 +- arch/powerpc/platforms/pseries/vas.h | 1 + 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/vas-sysfs.c b/arch/powerpc/platforms/pseries/vas-sysfs.c index f7609cdef8f8..66f1a0224811 100644 --- a/arch/powerpc/platforms/pseries/vas-sysfs.c +++ b/arch/powerpc/platforms/pseries/vas-sysfs.c @@ -36,6 +36,34 @@ static ssize_t avail_creds_show(struct vas_cop_feat_caps *caps, char *buf) return sprintf(buf, "%d\n", avail_creds); } +/* + * This function is used to get the notification from the drmgr when + * QoS credits are changed as part of DLPAR core add/removal. Though + * receiving the total QoS credits here, get the official QoS + * capabilities from the hypervisor. + */ +static ssize_t target_creds_store(struct vas_cop_feat_caps *caps, + const char *buf, size_t count) +{ + int err; + u16 creds; + + /* +* Nothing to do for default credit type. +*/ + if (caps->win_type == VAS_GZIP_DEF_FEAT_TYPE) + return -EOPNOTSUPP; + + err = kstrtou16(buf, 0, ); + if (!err) + err = vas_reconfig_capabilties(caps->win_type); + + if (err) + return -EINVAL; + + return count; +} + #define sysfs_capbs_entry_read(_name) \ static ssize_t _name##_show(struct vas_cop_feat_caps *caps, char *buf) \ { \ @@ -52,8 +80,12 @@ struct vas_sysfs_entry { sysfs_capbs_entry_read(_name); \ static struct vas_sysfs_entry _name##_attribute = __ATTR(_name, \ 0444, _name##_show, NULL); +#define VAS_ATTR(_name) \ + sysfs_capbs_entry_read(_name); \ + static struct vas_sysfs_entry _name##_attribute = __ATTR(_name, \ + 0644, _name##_show, _name##_store) -VAS_ATTR_RO(target_creds); +VAS_ATTR(target_creds); VAS_ATTR_RO(used_creds); static struct vas_sysfs_entry avail_creds_attribute = diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c index 32098e4a2786..3400f4fc6609 100644 --- a/arch/powerpc/platforms/pseries/vas.c +++ b/arch/powerpc/platforms/pseries/vas.c @@ -722,7 +722,7 @@ static int reconfig_close_windows(struct vas_caps *vcap, int excess_creds) * changes. Reconfig window configurations based on the credits * availability from this new capabilities. */ -static int vas_reconfig_capabilties(u8 type) +int vas_reconfig_capabilties(u8 type) { struct hv_vas_cop_feat_caps *hv_caps; struct vas_cop_feat_caps *caps; diff --git a/arch/powerpc/platforms/pseries/vas.h b/arch/powerpc/platforms/pseries/vas.h index bc393bd74030..4cf1d0ef66a5 100644 --- a/arch/powerpc/platforms/pseries/vas.h +++ b/arch/powerpc/platforms/pseries/vas.h @@ -125,5 +125,6 @@ struct pseries_vas_window { }; int sysfs_add_vas_caps(struct vas_cop_feat_caps *caps); +int vas_reconfig_capabilties(u8 type); int __init sysfs_pseries_vas_init(struct vas_all_caps *vas_caps); #endif /* _VAS_H */ -- 2.27.0
[PATCH v3 09/10] powerpc/pseries/vas: sysfs interface to export capabilities
The hypervisor provides the available VAS GZIP capabilities such as default or QoS window type and the target available credits in each type. This patch creates sysfs entries and exports the target, used and the available credits for each feature. This interface can be used by the user space to determine the credits usage or to set the target credits in the case of QoS type (for DLPAR). /sys/devices/vas/vas0/gzip/def_caps: (default GZIP capabilities) avail_creds /* Available credits to use */ target_creds /* Total credits available. Can be /* changed with DLPAR operation */ used_creds /* Used credits */ /sys/devices/vas/vas0/gzip/qos_caps (QoS GZIP capabilities) avail_creds target_creds used_creds Signed-off-by: Haren Myneni --- arch/powerpc/platforms/pseries/Makefile| 2 +- arch/powerpc/platforms/pseries/vas-sysfs.c | 218 + arch/powerpc/platforms/pseries/vas.c | 6 + arch/powerpc/platforms/pseries/vas.h | 6 + 4 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/platforms/pseries/vas-sysfs.c diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile index ee60b59024b4..29b522d2c755 100644 --- a/arch/powerpc/platforms/pseries/Makefile +++ b/arch/powerpc/platforms/pseries/Makefile @@ -29,6 +29,6 @@ obj-$(CONFIG_PPC_SVM) += svm.o obj-$(CONFIG_FA_DUMP) += rtas-fadump.o obj-$(CONFIG_SUSPEND) += suspend.o -obj-$(CONFIG_PPC_VAS) += vas.o +obj-$(CONFIG_PPC_VAS) += vas.o vas-sysfs.o obj-$(CONFIG_ARCH_HAS_CC_PLATFORM) += cc_platform.o diff --git a/arch/powerpc/platforms/pseries/vas-sysfs.c b/arch/powerpc/platforms/pseries/vas-sysfs.c new file mode 100644 index ..f7609cdef8f8 --- /dev/null +++ b/arch/powerpc/platforms/pseries/vas-sysfs.c @@ -0,0 +1,218 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright 2016-17 IBM Corp. + */ + +#define pr_fmt(fmt) "vas: " fmt + +#include +#include +#include +#include +#include +#include + +#include "vas.h" + +#ifdef CONFIG_SYSFS +static struct kobject *pseries_vas_kobj; +static struct kobject *gzip_caps_kobj; + +struct vas_caps_entry { + struct kobject kobj; + struct vas_cop_feat_caps *caps; +}; + +#define to_caps_entry(entry) container_of(entry, struct vas_caps_entry, kobj) + +static ssize_t avail_creds_show(struct vas_cop_feat_caps *caps, char *buf) +{ + /* +* avail_creds may be -ve if used_creds is oversubscribed, +* can happen if target_creds is reduced with DLPAR core removal. +*/ + int avail_creds = atomic_read(>target_creds) - + atomic_read(>used_creds); + return sprintf(buf, "%d\n", avail_creds); +} + +#define sysfs_capbs_entry_read(_name) \ +static ssize_t _name##_show(struct vas_cop_feat_caps *caps, char *buf) \ +{ \ + return sprintf(buf, "%d\n", atomic_read(>_name)); \ +} + +struct vas_sysfs_entry { + struct attribute attr; + ssize_t (*show)(struct vas_cop_feat_caps *, char *); + ssize_t (*store)(struct vas_cop_feat_caps *, const char *, size_t); +}; + +#define VAS_ATTR_RO(_name) \ + sysfs_capbs_entry_read(_name); \ + static struct vas_sysfs_entry _name##_attribute = __ATTR(_name, \ + 0444, _name##_show, NULL); + +VAS_ATTR_RO(target_creds); +VAS_ATTR_RO(used_creds); + +static struct vas_sysfs_entry avail_creds_attribute = + __ATTR(avail_creds, 0444, avail_creds_show, NULL); + +static struct attribute *vas_capab_attrs[] = { + _creds_attribute.attr, + _creds_attribute.attr, + _creds_attribute.attr, + NULL, +}; + +static ssize_t vas_type_show(struct kobject *kobj, struct attribute *attr, +char *buf) +{ + struct vas_caps_entry *centry; + struct vas_cop_feat_caps *caps; + struct vas_sysfs_entry *entry; + + centry = to_caps_entry(kobj); + caps = centry->caps; + entry = container_of(attr, struct vas_sysfs_entry, attr); + + if (!entry->show) + return -EIO; + + return entry->show(caps, buf); +} + +static ssize_t vas_type_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t count) +{ + struct vas_caps_entry *centry; + struct vas_cop_feat_caps *caps; + struct vas_sysfs_entry *entry; + + centry = to_caps_entry(kobj); + caps = centry->caps; + entry = container_of(attr, struct vas_sysfs_entry, attr); + if (!entry->store) + return -EIO; + + return entry->store(caps, buf, count); +} + +static void vas_type_release(struct kobject *kobj) +{ + struct vas_caps_entry *centry = to_caps_entry(kobj); +
[PATCH v3 08/10] powerpc/vas: Return paste instruction failure if no active window
The VAS window may not be active if the system looses credits and the NX generates page fault when it receives request on unmap paste address. The kernel handles the fault by remap new paste address if the window is active again, Otherwise return the paste instruction failure if the executed instruction that caused the fault was a paste. Signed-off-by: Nicholas Piggin Signed-off-by: Haren Myneni --- arch/powerpc/include/asm/ppc-opcode.h | 2 ++ arch/powerpc/platforms/book3s/vas-api.c | 47 - 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h index efad07081cc0..fe2a69206588 100644 --- a/arch/powerpc/include/asm/ppc-opcode.h +++ b/arch/powerpc/include/asm/ppc-opcode.h @@ -262,6 +262,8 @@ #define PPC_INST_MFSPR_PVR 0x7c1f42a6 #define PPC_INST_MFSPR_PVR_MASK0xfc1e #define PPC_INST_MTMSRD0x7c000164 +#define PPC_INST_PASTE 0x7c20070d +#define PPC_INST_PASTE_MASK0xfc2007ff #define PPC_INST_POPCNTB 0x7cf4 #define PPC_INST_POPCNTB_MASK 0xfc0007fe #define PPC_INST_RFEBB 0x4c000124 diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c index 5ceba75c13eb..2ffd34bc4032 100644 --- a/arch/powerpc/platforms/book3s/vas-api.c +++ b/arch/powerpc/platforms/book3s/vas-api.c @@ -351,6 +351,41 @@ static int coproc_release(struct inode *inode, struct file *fp) return 0; } +/* + * If the executed instruction that caused the fault was a paste, then + * clear regs CR0[EQ], advance NIP, and return 0. Else return error code. + */ +static int do_fail_paste(void) +{ + struct pt_regs *regs = current->thread.regs; + u32 instword; + + if (WARN_ON_ONCE(!regs)) + return -EINVAL; + + if (WARN_ON_ONCE(!user_mode(regs))) + return -EINVAL; + + /* +* If we couldn't translate the instruction, the driver should +* return success without handling the fault, it will be retried +* or the instruction fetch will fault. +*/ + if (get_user(instword, (u32 __user *)(regs->nip))) + return -EAGAIN; + + /* +* Not a paste instruction, driver may fail the fault. +*/ + if ((instword & PPC_INST_PASTE_MASK) != PPC_INST_PASTE) + return -ENOENT; + + regs->ccr &= ~0xe000; /* Clear CR0[0-2] to fail paste */ + regs_add_return_ip(regs, 4);/* Skip the paste */ + + return 0; +} + /* * This fault handler is invoked when the VAS/NX generates page fault on * the paste address. Happens if the kernel closes window in hypervisor @@ -403,9 +438,19 @@ static vm_fault_t vas_mmap_fault(struct vm_fault *vmf) } mutex_unlock(>task_ref.mmap_mutex); - return VM_FAULT_SIGBUS; + /* +* Received this fault due to closing the actual window. +* It can happen during migration or lost credits. +* Since no mapping, return the paste instruction failure +* to the user space. +*/ + ret = do_fail_paste(); + if (!ret) + return VM_FAULT_NOPAGE; + return VM_FAULT_SIGBUS; } + static const struct vm_operations_struct vas_vm_ops = { .fault = vas_mmap_fault, }; -- 2.27.0
[PATCH v3 07/10] powerpc/vas: Add paste address mmap fault handler
The user space opens VAS windows and issues NX requests by pasting CRB on the corresponding paste address mmap. When the system looses credits due to core removal, the kernel has to close the window in the hypervisor and make the window inactive by unmapping this paste address. Also the OS has to handle NX request page faults if the user space issue NX requests. This handler remap the new paste address with the same VMA when the window is active again (due to core add with DLPAR). Otherwise returns paste failure. Signed-off-by: Haren Myneni --- arch/powerpc/platforms/book3s/vas-api.c | 60 + 1 file changed, 60 insertions(+) diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c index 2d06bd1b1935..5ceba75c13eb 100644 --- a/arch/powerpc/platforms/book3s/vas-api.c +++ b/arch/powerpc/platforms/book3s/vas-api.c @@ -351,6 +351,65 @@ static int coproc_release(struct inode *inode, struct file *fp) return 0; } +/* + * This fault handler is invoked when the VAS/NX generates page fault on + * the paste address. Happens if the kernel closes window in hypervisor + * (on PowerVM) due to lost credit or the paste address is not mapped. + */ +static vm_fault_t vas_mmap_fault(struct vm_fault *vmf) +{ + struct vm_area_struct *vma = vmf->vma; + struct file *fp = vma->vm_file; + struct coproc_instance *cp_inst = fp->private_data; + struct vas_window *txwin; + u64 paste_addr; + int ret; + + /* +* window is not opened. Shouldn't expect this error. +*/ + if (!cp_inst || !cp_inst->txwin) { + pr_err("%s(): No send window open?\n", __func__); + return VM_FAULT_SIGBUS; + } + + txwin = cp_inst->txwin; + /* +* Fault is coming due to missing from the original mmap. +* Can happen only when the window is closed due to lost +* credit before mmap() or the user space issued NX request +* without mapping. +*/ + if (txwin->task_ref.vma != vmf->vma) { + pr_err("%s(): No previous mapping with paste address\n", + __func__); + return VM_FAULT_SIGBUS; + } + + mutex_lock(>task_ref.mmap_mutex); + /* +* The window may be inactive due to lost credit (Ex: core +* removal with DLPAR). When the window is active again when +* the credit is available, remap with the new paste address. +*/ + if (txwin->status == VAS_WIN_ACTIVE) { + paste_addr = cp_inst->coproc->vops->paste_addr(txwin); + if (paste_addr) { + ret = vmf_insert_pfn(vma, vma->vm_start, + (paste_addr >> PAGE_SHIFT)); + mutex_unlock(>task_ref.mmap_mutex); + return ret; + } + } + mutex_unlock(>task_ref.mmap_mutex); + + return VM_FAULT_SIGBUS; + +} +static const struct vm_operations_struct vas_vm_ops = { + .fault = vas_mmap_fault, +}; + static int coproc_mmap(struct file *fp, struct vm_area_struct *vma) { struct coproc_instance *cp_inst = fp->private_data; @@ -417,6 +476,7 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma) paste_addr, vma->vm_start, rc); txwin->task_ref.vma = vma; + vma->vm_ops = _vm_ops; out: mutex_unlock(>task_ref.mmap_mutex); -- 2.27.0
[PATCH v3 06/10] powerpc/vas: Map paste address only if window is active
The paste address mapping is done with mmap() after the window is opened with ioctl. But the window can be closed due to lost credit due to core removal before mmap(). So if the window is not active, return mmap() failure with -EACCES and expects the user space reissue mmap() when the window is active or open new window when the credit is available. Signed-off-by: Haren Myneni --- arch/powerpc/platforms/book3s/vas-api.c | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c index a63fd48e34a7..2d06bd1b1935 100644 --- a/arch/powerpc/platforms/book3s/vas-api.c +++ b/arch/powerpc/platforms/book3s/vas-api.c @@ -379,10 +379,27 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma) return -EACCES; } + /* +* The initial mapping is done after the window is opened +* with ioctl. But this window might have been closed +* due to lost credit (core removal on PowerVM) before mmap(). +* So if the window is not active, return mmap() failure +* with -EACCES and expects the user space reconfigure (mmap) +* window when it is active again or open new window when +* the credit is available. +*/ + mutex_lock(>task_ref.mmap_mutex); + if (txwin->status != VAS_WIN_ACTIVE) { + pr_err("%s(): Window is not active\n", __func__); + rc = -EACCES; + goto out; + } + paste_addr = cp_inst->coproc->vops->paste_addr(txwin); if (!paste_addr) { pr_err("%s(): Window paste address failed\n", __func__); - return -EINVAL; + rc = -EINVAL; + goto out; } pfn = paste_addr >> PAGE_SHIFT; @@ -401,6 +418,8 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma) txwin->task_ref.vma = vma; +out: + mutex_unlock(>task_ref.mmap_mutex); return rc; } -- 2.27.0
[PATCH v3 05/10] powerpc/pseries/vas: Close windows with DLPAR core removal
The hypervisor reduces the available credits if the core is removed from the LPAR. So there is possibility of using excessive credits (windows) in the LPAR and the hypervisor expects the system to close the excessive windows. Even though the user space can continue to use these windows to send compression requests to NX, the hypervisor expects the LPAR to reduce these windows usage so that NX load can be equally distributed across all LPARs in the system. When the DLPAR notifier is received, get the new VAS capabilities from the hypervisor and close the excessive windows in the hypervisor. Also the kernel unmaps the paste address so that the user space receives paste failure until these windows are active with the later DLPAR (core add). Signed-off-by: Haren Myneni --- arch/powerpc/include/asm/vas.h | 1 + arch/powerpc/platforms/book3s/vas-api.c | 2 + arch/powerpc/platforms/pseries/vas.c| 117 ++-- arch/powerpc/platforms/pseries/vas.h| 1 + 4 files changed, 112 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/include/asm/vas.h b/arch/powerpc/include/asm/vas.h index f1efe86563cc..ddc05a8fc2e3 100644 --- a/arch/powerpc/include/asm/vas.h +++ b/arch/powerpc/include/asm/vas.h @@ -74,6 +74,7 @@ struct vas_user_win_ref { struct mm_struct *mm; /* Linux process mm_struct */ struct mutex mmap_mutex;/* protects paste address mmap() */ /* with DLPAR close/open windows */ + struct vm_area_struct *vma; /* Save VMA and used in DLPAR ops */ }; /* diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c index 2b0ced611f32..a63fd48e34a7 100644 --- a/arch/powerpc/platforms/book3s/vas-api.c +++ b/arch/powerpc/platforms/book3s/vas-api.c @@ -399,6 +399,8 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma) pr_devel("%s(): paste addr %llx at %lx, rc %d\n", __func__, paste_addr, vma->vm_start, rc); + txwin->task_ref.vma = vma; + return rc; } diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c index d9ff73d7704d..75ccd0a599ec 100644 --- a/arch/powerpc/platforms/pseries/vas.c +++ b/arch/powerpc/platforms/pseries/vas.c @@ -370,13 +370,28 @@ static struct vas_window *vas_allocate_window(int vas_id, u64 flags, if (rc) goto out_free; - vas_user_win_add_mm_context(>vas_win.task_ref); txwin->win_type = cop_feat_caps->win_type; mutex_lock(_pseries_mutex); - list_add(>win_list, >list); + /* +* Possible to loose the acquired credit with DLPAR core +* removal after the window is opened. So if there are any +* closed windows (means with lost credits), do not give new +* window to user space. New windows will be opened only +* after the existing windows are reopened when credits are +* available. +*/ + if (!caps->close_wins) { + list_add(>win_list, >list); + caps->num_wins++; + mutex_unlock(_pseries_mutex); + vas_user_win_add_mm_context(>vas_win.task_ref); + return >vas_win; + } mutex_unlock(_pseries_mutex); - return >vas_win; + put_vas_user_win_ref(>vas_win.task_ref); + rc = -EBUSY; + pr_err("No credit is available to allocate window\n"); out_free: /* @@ -439,14 +454,24 @@ static int vas_deallocate_window(struct vas_window *vwin) caps = [win->win_type].caps; mutex_lock(_pseries_mutex); - rc = deallocate_free_window(win); - if (rc) { - mutex_unlock(_pseries_mutex); - return rc; - } + /* +* VAS window is already closed in the hypervisor when +* lost the credit. So just remove the entry from +* the list, remove task references and free vas_window +* struct. +*/ + if (win->vas_win.status & VAS_WIN_NO_CRED_CLOSE) { + rc = deallocate_free_window(win); + if (rc) { + mutex_unlock(_pseries_mutex); + return rc; + } + } else + vascaps[win->win_type].close_wins--; list_del(>win_list); atomic_dec(>used_creds); + vascaps[win->win_type].num_wins--; mutex_unlock(_pseries_mutex); put_vas_user_win_ref(>task_ref); @@ -622,6 +647,72 @@ static int reconfig_open_windows(struct vas_caps *vcaps, int creds) return rc; } +/* + * The hypervisor reduces the available credits if the LPAR lost core. It + * means the excessive windows should not be active and the user space + * should not be using these windows to send compression requests to NX. + * So the kernel closes the excessive windows and unmap the paste address + * such that the user space receives paste instruction
[PATCH v3 04/10] powerpc/pseries/vas: Reopen windows with DLPAR core add
VAS windows can be closed in the hypervisor due to lost credits when the core is removed. If these credits are available later for core add, reopen these windows and set them active. When the kernel sees page fault on the paste address, it creates new mapping on the new paste address. Then the user space can continue to use these windows and send HW compression requests to NX successfully. Signed-off-by: Haren Myneni --- arch/powerpc/include/asm/vas.h | 16 +++ arch/powerpc/platforms/book3s/vas-api.c | 1 + arch/powerpc/platforms/pseries/vas.c| 144 arch/powerpc/platforms/pseries/vas.h| 8 +- 4 files changed, 163 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/include/asm/vas.h b/arch/powerpc/include/asm/vas.h index 57573d9c1e09..f1efe86563cc 100644 --- a/arch/powerpc/include/asm/vas.h +++ b/arch/powerpc/include/asm/vas.h @@ -29,6 +29,19 @@ #define VAS_THRESH_FIFO_GT_QTR_FULL2 #define VAS_THRESH_FIFO_GT_EIGHTH_FULL 3 +/* + * VAS window status + */ +#define VAS_WIN_ACTIVE 0x0 /* Used in platform independent */ + /* vas mmap() */ +/* The hypervisor returns these values */ +#define VAS_WIN_CLOSED 0x0001 +#define VAS_WIN_INACTIVE 0x0002 /* Inactive due to HW failure */ +#define VAS_WIN_MOD_IN_PROCESS 0x0003 /* Process of being modified, */ + /* deallocated, or quiesced */ +/* Linux status bits */ +#define VAS_WIN_NO_CRED_CLOSE 0x0004 /* Window is closed due to */ + /* lost credit */ /* * Get/Set bit fields */ @@ -59,6 +72,8 @@ struct vas_user_win_ref { struct pid *pid;/* PID of owner */ struct pid *tgid; /* Thread group ID of owner */ struct mm_struct *mm; /* Linux process mm_struct */ + struct mutex mmap_mutex;/* protects paste address mmap() */ + /* with DLPAR close/open windows */ }; /* @@ -67,6 +82,7 @@ struct vas_user_win_ref { struct vas_window { u32 winid; u32 wcreds_max; /* Window credits */ + u32 status; enum vas_cop_type cop; struct vas_user_win_ref task_ref; char *dbgname; diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c index 4d82c92ddd52..2b0ced611f32 100644 --- a/arch/powerpc/platforms/book3s/vas-api.c +++ b/arch/powerpc/platforms/book3s/vas-api.c @@ -316,6 +316,7 @@ static int coproc_ioc_tx_win_open(struct file *fp, unsigned long arg) return PTR_ERR(txwin); } + mutex_init(>task_ref.mmap_mutex); cp_inst->txwin = txwin; return 0; diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c index 2ef56157634f..d9ff73d7704d 100644 --- a/arch/powerpc/platforms/pseries/vas.c +++ b/arch/powerpc/platforms/pseries/vas.c @@ -501,6 +501,7 @@ static int __init get_vas_capabilities(u8 feat, enum vas_cop_feat_type type, memset(vcaps, 0, sizeof(*vcaps)); INIT_LIST_HEAD(>list); + vcaps->feat = feat; caps = >caps; rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES, feat, @@ -539,6 +540,145 @@ static int __init get_vas_capabilities(u8 feat, enum vas_cop_feat_type type, return 0; } +/* + * VAS windows can be closed due to lost credits when the core is + * removed. So reopen them if credits are available due to DLPAR + * core add and set the window active status. When NX sees the page + * fault on the unmapped paste address, the kernel handles the fault + * by setting the remapping to new paste address if the window is + * active. + */ +static int reconfig_open_windows(struct vas_caps *vcaps, int creds) +{ + long domain[PLPAR_HCALL9_BUFSIZE] = {VAS_DEFAULT_DOMAIN_ID}; + struct vas_cop_feat_caps *caps = >caps; + struct pseries_vas_window *win = NULL, *tmp; + int rc, mv_ents = 0; + + /* +* Nothing to do if there are no closed windows. +*/ + if (!vcaps->close_wins) + return 0; + + /* +* For the core removal, the hypervisor reduces the credits +* assigned to the LPAR and the kernel closes VAS windows +* in the hypervisor depends on reduced credits. The kernel +* uses LIFO (the last windows that are opened will be closed +* first) and expects to open in the same order when credits +* are available. +* For example, 40 windows are closed when the LPAR lost 2 cores +* (dedicated). If 1 core is added, this LPAR can have 20 more +* credits. It means the kernel can reopen 20 windows. So move +* 20 entries in the VAS windows lost and reopen next 20 windows. +*/ + if (vcaps->close_wins > creds) + mv_ents = vcaps->close_wins - creds; + + list_for_each_entry_safe(win, tmp, >list, win_list) {
[PATCH v3 03/10] powerpc/pseries/vas: Save LPID in pseries_vas_window struct
The kernel sets the VAS window with partition PID when is opened in the hypervisor. During DLPAR operation, windows can be closed and reopened in the hypervisor when the credit is available. So saves this PID in pseries_vas_window struct when the window is opened initially and reuse it later during DLPAR operation. Signed-off-by: Haren Myneni --- arch/powerpc/platforms/pseries/vas.c | 7 --- arch/powerpc/platforms/pseries/vas.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c index d2c8292bfb33..2ef56157634f 100644 --- a/arch/powerpc/platforms/pseries/vas.c +++ b/arch/powerpc/platforms/pseries/vas.c @@ -107,7 +107,6 @@ static int h_deallocate_vas_window(u64 winid) static int h_modify_vas_window(struct pseries_vas_window *win) { long rc; - u32 lpid = mfspr(SPRN_PID); /* * AMR value is not supported in Linux VAS implementation. @@ -115,7 +114,7 @@ static int h_modify_vas_window(struct pseries_vas_window *win) */ do { rc = plpar_hcall_norets(H_MODIFY_VAS_WINDOW, - win->vas_win.winid, lpid, 0, + win->vas_win.winid, win->lpid, 0, VAS_MOD_WIN_FLAGS, 0); rc = hcall_return_busy_check(rc); @@ -125,7 +124,7 @@ static int h_modify_vas_window(struct pseries_vas_window *win) return 0; pr_err("H_MODIFY_VAS_WINDOW error: %ld, winid %u lpid %u\n", - rc, win->vas_win.winid, lpid); + rc, win->vas_win.winid, win->lpid); return -EIO; } @@ -338,6 +337,8 @@ static struct vas_window *vas_allocate_window(int vas_id, u64 flags, } } + txwin->lpid = mfspr(SPRN_PID); + /* * Allocate / Deallocate window hcalls and setup / free IRQs * have to be protected with mutex. diff --git a/arch/powerpc/platforms/pseries/vas.h b/arch/powerpc/platforms/pseries/vas.h index fa7ce74f1e49..0538760d13be 100644 --- a/arch/powerpc/platforms/pseries/vas.h +++ b/arch/powerpc/platforms/pseries/vas.h @@ -115,6 +115,7 @@ struct pseries_vas_window { u64 domain[6]; /* Associativity domain Ids */ /* this window is allocated */ u64 util; + u32 lpid; /* List of windows opened which is used for LPM */ struct list_head win_list; -- 2.27.0
[PATCH v3 02/10] powerpc/pseries/vas: Add notifier for DLPAR core removal/add
The hypervisor assigns credits for each LPAR based on number of cores configured in that system. So expects to release credits (means windows) when the core is removed. This patch adds notifier for core removal/add so that the OS closes windows if the system looses credits due to core removal and reopen windows when the credits available later. Signed-off-by: Haren Myneni --- arch/powerpc/platforms/pseries/vas.c | 37 1 file changed, 37 insertions(+) diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c index c0737379cc7b..d2c8292bfb33 100644 --- a/arch/powerpc/platforms/pseries/vas.c +++ b/arch/powerpc/platforms/pseries/vas.c @@ -538,6 +538,39 @@ static int __init get_vas_capabilities(u8 feat, enum vas_cop_feat_type type, return 0; } +/* + * Total number of default credits available (target_credits) + * in LPAR depends on number of cores configured. It varies based on + * whether processors are in shared mode or dedicated mode. + * Get the notifier when CPU configuration is changed with DLPAR + * operation so that get the new target_credits (vas default capabilities) + * and then update the existing windows usage if needed. + */ +static int pseries_vas_notifier(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct of_reconfig_data *rd = data; + struct device_node *dn = rd->dn; + const __be32 *intserv = NULL; + int len, rc = 0; + + if ((action == OF_RECONFIG_ATTACH_NODE) || + (action == OF_RECONFIG_DETACH_NODE)) + intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s", + ); + /* +* Processor config is not changed +*/ + if (!intserv) + return NOTIFY_OK; + + return rc; +} + +static struct notifier_block pseries_vas_nb = { + .notifier_call = pseries_vas_notifier, +}; + static int __init pseries_vas_init(void) { struct hv_vas_cop_feat_caps *hv_cop_caps; @@ -591,6 +624,10 @@ static int __init pseries_vas_init(void) goto out_cop; } + /* Processors can be added/removed only on LPAR */ + if (copypaste_feat && firmware_has_feature(FW_FEATURE_LPAR)) + of_reconfig_notifier_register(_vas_nb); + pr_info("GZIP feature is available\n"); out_cop: -- 2.27.0
[PATCH v3 01/10] powerpc/pseries/vas: Use common names in VAS capability structure
target/used/avail_creds provides credits usage to user space via sysfs and the same interface can be used on PowerNV in future. Remove "lpar" from these names so that applicable on both PowerVM and PowerNV. Signed-off-by: Haren Myneni --- arch/powerpc/platforms/pseries/vas.c | 10 +- arch/powerpc/platforms/pseries/vas.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c index d243ddc58827..c0737379cc7b 100644 --- a/arch/powerpc/platforms/pseries/vas.c +++ b/arch/powerpc/platforms/pseries/vas.c @@ -310,8 +310,8 @@ static struct vas_window *vas_allocate_window(int vas_id, u64 flags, cop_feat_caps = >caps; - if (atomic_inc_return(_feat_caps->used_lpar_creds) > - atomic_read(_feat_caps->target_lpar_creds)) { + if (atomic_inc_return(_feat_caps->used_creds) > + atomic_read(_feat_caps->target_creds)) { pr_err("Credits are not available to allocate window\n"); rc = -EINVAL; goto out; @@ -385,7 +385,7 @@ static struct vas_window *vas_allocate_window(int vas_id, u64 flags, free_irq_setup(txwin); h_deallocate_vas_window(txwin->vas_win.winid); out: - atomic_dec(_feat_caps->used_lpar_creds); + atomic_dec(_feat_caps->used_creds); kfree(txwin); return ERR_PTR(rc); } @@ -445,7 +445,7 @@ static int vas_deallocate_window(struct vas_window *vwin) } list_del(>win_list); - atomic_dec(>used_lpar_creds); + atomic_dec(>used_creds); mutex_unlock(_pseries_mutex); put_vas_user_win_ref(>task_ref); @@ -521,7 +521,7 @@ static int __init get_vas_capabilities(u8 feat, enum vas_cop_feat_type type, } caps->max_lpar_creds = be16_to_cpu(hv_caps->max_lpar_creds); caps->max_win_creds = be16_to_cpu(hv_caps->max_win_creds); - atomic_set(>target_lpar_creds, + atomic_set(>target_creds, be16_to_cpu(hv_caps->target_lpar_creds)); if (feat == VAS_GZIP_DEF_FEAT) { caps->def_lpar_creds = be16_to_cpu(hv_caps->def_lpar_creds); diff --git a/arch/powerpc/platforms/pseries/vas.h b/arch/powerpc/platforms/pseries/vas.h index 4ecb3fcabd10..fa7ce74f1e49 100644 --- a/arch/powerpc/platforms/pseries/vas.h +++ b/arch/powerpc/platforms/pseries/vas.h @@ -72,9 +72,9 @@ struct vas_cop_feat_caps { }; /* Total LPAR available credits. Can be different from max LPAR */ /* credits due to DLPAR operation */ - atomic_ttarget_lpar_creds; - atomic_tused_lpar_creds; /* Used credits so far */ - u16 avail_lpar_creds; /* Remaining available credits */ + atomic_ttarget_creds; + atomic_tused_creds; /* Used credits so far */ + u16 avail_creds;/* Remaining available credits */ }; /* -- 2.27.0
[PATCH v3 00/10] powerpc/pseries/vas: NXGZIP support with DLPAR
PowerPC provides HW compression with NX coprocessor. This feature is available on both PowerNV and PowerVM and included in Linux. Since each powerpc chip has one NX coprocessor, the VAS introduces the concept of windows / credits to manage access to this hardware resource. On powerVM, these limited resources should be available across all LPARs. So the hypervisor assigns the specific credits to each LPAR based on processor entitlement so that one LPAR does not overload NX. The hypervisor can reject the window open request to a partition if exceeds its credit limit (1 credit per window). So the total number of target credits in a partition can be changed if the core configuration is modified. The hypervisor expects the partition to modify its window usage depends on new target credits. For example, if the partition uses more credits than the new target credits, it should close the excessive windows so that the NX resource will be available to other partitions. This patch series enables OS to support this dynamic credit management with DLPAR core removal/add. Core removal operation: - Get new VAS capabilities from the hypervisor when the DLPAR notifier is received. This capabilities provides the new target credits based on new processor entitlement. In the case of QoS credit changes, the notification will be issued by updating the target_creds via sysfs. - If the partition is already used more than the new target credits, the kernel selects windows, unmap the current paste address and close them in the hypervisor, It uses LIFO to identify these windows - last windows that are opened are the first ones to be closed. - When the user space issue requests on these windows, NX generates page fault on the unmap paste address. The kernel handles the fault by returning the paste instruction failure if the window is not active (means unmap paste). Then up to the library / user space to fall back to SW compression or manage with the current windows. Core add operation: - The kernel can see increased target credits from the new VAS capabilities. - Scans the window list for the closed windows in the hypervisor due to lost credit before and selects windows based on same LIFO. - Make these corresponding windows active and create remap with the same VMA on the new paste address in the fault handler. - Then the user space should expect paste successful later. Patch 1: Define common names for sysfs target/used/avail_creds so that same sysfs entries can be used even on PowerNV later. Patch 2: Add VAS notifier for DLPAR core add / removal Patch 3: Save LPID in the vas window struct during initial window open and use it when reopen later. Patch 4: When credits are available, reopen windows that are closed before with core removal. Patch 5: Close windows in the hypervisor when the partition exceeds its usage than the new target credits. Patch 6: If the window is closed in the hypervisor before the user space issue the initial mmap(), return -EACCES failure. Patch 7: Add new mmap fault handler which handles the page fault from NX on paste address. Patch 8: Return the paste instruction failure if the window is not active. Patch 9 & 10: The user space determines the credit usage with sysfs target/avail/used_creds interfaces. drmgr uses target_creds to notify OS for QoS credit changes. Thanks to Nicholas Piggin and Aneesh Kumar for the valuable suggestions on the NXGZIP design to support DLPAR operations. Changes in v2: - Rebase 5.16-rc5 - Use list safe functions to iterate windows list - Changes to show the actual value in sysfs used_credits even though some windows are inactive with core removal. Reflects -ve value in sysfs avail_creds to let userspace know that it opened more windows than the current maximum LPAR credits. Changes in v3: - Rebase 5.16 - Reconfigure VAS windows only for CPU hotplug events. Haren Myneni (10): powerpc/pseries/vas: Use common names in VAS capability structure powerpc/pseries/vas: Add notifier for DLPAR core removal/add powerpc/pseries/vas: Save partition PID in pseries_vas_window struct powerpc/pseries/vas: Reopen windows with DLPAR core add powerpc/pseries/vas: Close windows with DLPAR core removal powerpc/vas: Map paste address only if window is active powerpc/vas: Add paste address mmap fault handler powerpc/vas: Return paste instruction failure if window is not active powerpc/pseries/vas: sysfs interface to export capabilities powerpc/pseries/vas: Write 'target_creds' for QoS credits change arch/powerpc/include/asm/ppc-opcode.h | 2 + arch/powerpc/include/asm/vas.h | 17 ++ arch/powerpc/platforms/book3s/vas-api.c| 129 - arch/powerpc/platforms/pseries/Makefile| 2 +- arch/powerpc/platforms/pseries/vas-sysfs.c | 250 arch/powerpc/platforms/pseries/vas.c | 319 +++--
Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
On Fri, Jan 21, 2022 at 04:19:12PM +0100, Greg Kroah-Hartman wrote: > On Fri, Jan 21, 2022 at 03:13:50PM +, Christophe Leroy wrote: > > >> - * This file is free software; you can redistribute it and/or modify it > > >> - * under the terms of the GNU General Public License as published by the > > >> - * Free Software Foundation; either version 2, or (at your option) any > > >> - * later version. [ ... ] > > >>*As a special exception, if you link this library with files > > >>*compiled with GCC to produce an executable, this does not cause > > >>*the resulting executable to be covered by the GNU General Public > > >> License. The "as a special exception" refers to "This file is free software; you can redistribute it and/or modify it". It is meaningless without having anything it is an exception *to* :-) In general, you should never edit licence texts. > > > Look at that "special exception", why are you ignoring it here? You > > > can't do that :( > > > > I'm not ignoring it, that's the reason why I left it. > > You ignore that part of the license in the SPDX line, why? > > > Isn't it the correct way to do ? How should it be done ? > > You need to properly describe this in the SPDX line. You did not do so > here, which means that any tool just looking at the SPDX line would get > this license wrong. A new label needs to be defined and documented. Should be pretty mechanical to do, but that should see a wider audience than the powerpc hackers :-) Segher
[PATCH v4 5/5] powerpc/vdso: Move cvdso_call macro into gettimeofday.S
Now that gettimeofday.S is unique, move cvdso_call macro into that file which is the only user. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/vdso/gettimeofday.h | 52 +--- arch/powerpc/kernel/vdso/gettimeofday.S | 44 - 2 files changed, 45 insertions(+), 51 deletions(-) diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/include/asm/vdso/gettimeofday.h index df00e91c9a90..f0a4cf01e85c 100644 --- a/arch/powerpc/include/asm/vdso/gettimeofday.h +++ b/arch/powerpc/include/asm/vdso/gettimeofday.h @@ -2,57 +2,9 @@ #ifndef _ASM_POWERPC_VDSO_GETTIMEOFDAY_H #define _ASM_POWERPC_VDSO_GETTIMEOFDAY_H -#include - -#ifdef __ASSEMBLY__ - -#include - -/* - * The macro sets two stack frames, one for the caller and one for the callee - * because there are no requirement for the caller to set a stack frame when - * calling VDSO so it may have omitted to set one, especially on PPC64 - */ - -.macro cvdso_call funct call_time=0 - .cfi_startproc - PPC_STLUr1, -PPC_MIN_STKFRM(r1) - mflrr0 - .cfi_register lr, r0 - PPC_STLUr1, -PPC_MIN_STKFRM(r1) - PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) -#ifdef __powerpc64__ - PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1) -#endif - get_datapager5 - .ifeq \call_time - addir5, r5, VDSO_DATA_OFFSET - .else - addir4, r5, VDSO_DATA_OFFSET - .endif - bl DOTSYM(\funct) - PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) -#ifdef __powerpc64__ - PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1) -#endif - .ifeq \call_time - cmpwi r3, 0 - .endif - mtlrr0 - .cfi_restore lr - addir1, r1, 2 * PPC_MIN_STKFRM - crclr so - .ifeq \call_time - beqlr+ - crset so - neg r3, r3 - .endif - blr - .cfi_endproc -.endm - -#else +#ifndef __ASSEMBLY__ +#include #include #include #include diff --git a/arch/powerpc/kernel/vdso/gettimeofday.S b/arch/powerpc/kernel/vdso/gettimeofday.S index 397f290015bc..eb9c81e1c218 100644 --- a/arch/powerpc/kernel/vdso/gettimeofday.S +++ b/arch/powerpc/kernel/vdso/gettimeofday.S @@ -12,7 +12,49 @@ #include #include #include -#include + +/* + * The macro sets two stack frames, one for the caller and one for the callee + * because there are no requirement for the caller to set a stack frame when + * calling VDSO so it may have omitted to set one, especially on PPC64 + */ + +.macro cvdso_call funct call_time=0 + .cfi_startproc + PPC_STLUr1, -PPC_MIN_STKFRM(r1) + mflrr0 + .cfi_register lr, r0 + PPC_STLUr1, -PPC_MIN_STKFRM(r1) + PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) +#ifdef __powerpc64__ + PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1) +#endif + get_datapager5 + .ifeq \call_time + addir5, r5, VDSO_DATA_OFFSET + .else + addir4, r5, VDSO_DATA_OFFSET + .endif + bl DOTSYM(\funct) + PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) +#ifdef __powerpc64__ + PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1) +#endif + .ifeq \call_time + cmpwi r3, 0 + .endif + mtlrr0 + .cfi_restore lr + addir1, r1, 2 * PPC_MIN_STKFRM + crclr so + .ifeq \call_time + beqlr+ + crset so + neg r3, r3 + .endif + blr + .cfi_endproc +.endm .text /* -- 2.33.1
[PATCH v4 3/5] powerpc/vdso: Merge vdso64 and vdso32 into a single directory
merge vdso64 into vdso32 and rename it vdso. Signed-off-by: Christophe Leroy --- arch/powerpc/Makefile | 4 +- arch/powerpc/kernel/Makefile | 6 +- .../kernel/{vdso64 => vdso}/.gitignore| 2 + arch/powerpc/kernel/{vdso32 => vdso}/Makefile | 35 + .../kernel/{vdso32 => vdso}/cacheflush.S | 0 .../kernel/{vdso32 => vdso}/datapage.S| 0 .../{vdso32 => vdso}/gen_vdso32_offsets.sh| 0 .../gen_vdso64_offsets.sh}| 0 arch/powerpc/kernel/{vdso32 => vdso}/getcpu.S | 0 .../kernel/{vdso32 => vdso}/gettimeofday.S| 0 arch/powerpc/kernel/{vdso32 => vdso}/note.S | 0 .../kernel/{vdso32 => vdso}/sigtramp32.S | 0 .../{vdso64/sigtramp.S => vdso/sigtramp64.S} | 0 .../kernel/{vdso32 => vdso}/vdso32.lds.S | 0 .../kernel/{vdso64 => vdso}/vdso64.lds.S | 0 .../kernel/{vdso32 => vdso}/vgettimeofday.c | 0 arch/powerpc/kernel/vdso32/.gitignore | 3 - arch/powerpc/kernel/vdso32_wrapper.S | 2 +- arch/powerpc/kernel/vdso64/Makefile | 56 -- arch/powerpc/kernel/vdso64/cacheflush.S | 75 --- arch/powerpc/kernel/vdso64/datapage.S | 59 --- arch/powerpc/kernel/vdso64/getcpu.S | 33 arch/powerpc/kernel/vdso64/gettimeofday.S | 58 -- arch/powerpc/kernel/vdso64/note.S | 1 - arch/powerpc/kernel/vdso64/vgettimeofday.c| 29 --- arch/powerpc/kernel/vdso64_wrapper.S | 2 +- 26 files changed, 44 insertions(+), 321 deletions(-) rename arch/powerpc/kernel/{vdso64 => vdso}/.gitignore (72%) rename arch/powerpc/kernel/{vdso32 => vdso}/Makefile (56%) rename arch/powerpc/kernel/{vdso32 => vdso}/cacheflush.S (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/datapage.S (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/gen_vdso32_offsets.sh (100%) rename arch/powerpc/kernel/{vdso64/gen_vdso_offsets.sh => vdso/gen_vdso64_offsets.sh} (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/getcpu.S (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/gettimeofday.S (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/note.S (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/sigtramp32.S (100%) rename arch/powerpc/kernel/{vdso64/sigtramp.S => vdso/sigtramp64.S} (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/vdso32.lds.S (100%) rename arch/powerpc/kernel/{vdso64 => vdso}/vdso64.lds.S (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/vgettimeofday.c (100%) delete mode 100644 arch/powerpc/kernel/vdso32/.gitignore delete mode 100644 arch/powerpc/kernel/vdso64/Makefile delete mode 100644 arch/powerpc/kernel/vdso64/cacheflush.S delete mode 100644 arch/powerpc/kernel/vdso64/datapage.S delete mode 100644 arch/powerpc/kernel/vdso64/getcpu.S delete mode 100644 arch/powerpc/kernel/vdso64/gettimeofday.S delete mode 100644 arch/powerpc/kernel/vdso64/note.S delete mode 100644 arch/powerpc/kernel/vdso64/vgettimeofday.c diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 5f16ac1583c5..ddc5a706760a 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -421,9 +421,9 @@ ifeq ($(KBUILD_EXTMOD),) prepare: vdso_prepare vdso_prepare: prepare0 $(if $(CONFIG_VDSO32),$(Q)$(MAKE) \ - $(build)=arch/powerpc/kernel/vdso32 include/generated/vdso32-offsets.h) + $(build)=arch/powerpc/kernel/vdso include/generated/vdso32-offsets.h) $(if $(CONFIG_PPC64),$(Q)$(MAKE) \ - $(build)=arch/powerpc/kernel/vdso64 include/generated/vdso64-offsets.h) + $(build)=arch/powerpc/kernel/vdso include/generated/vdso64-offsets.h) endif archprepare: checkbin diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index 4d7829399570..4ddd161aef32 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -194,8 +194,8 @@ targets += prom_init_check clean-files := vmlinux.lds # Force dependency (incbin is bad) -$(obj)/vdso32_wrapper.o : $(obj)/vdso32/vdso32.so.dbg -$(obj)/vdso64_wrapper.o : $(obj)/vdso64/vdso64.so.dbg +$(obj)/vdso32_wrapper.o : $(obj)/vdso/vdso32.so.dbg +$(obj)/vdso64_wrapper.o : $(obj)/vdso/vdso64.so.dbg # for cleaning -subdir- += vdso32 vdso64 +subdir- += vdso diff --git a/arch/powerpc/kernel/vdso64/.gitignore b/arch/powerpc/kernel/vdso/.gitignore similarity index 72% rename from arch/powerpc/kernel/vdso64/.gitignore rename to arch/powerpc/kernel/vdso/.gitignore index 84151a7ba31d..dd9bdd67758b 100644 --- a/arch/powerpc/kernel/vdso64/.gitignore +++ b/arch/powerpc/kernel/vdso/.gitignore @@ -1,3 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only +vdso32.lds +vdso32.so.dbg vdso64.lds vdso64.so.dbg diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso/Makefile similarity index 56% rename from arch/powerpc/kernel/vdso32/Makefile rename to arch/powerpc/kernel/vdso/Makefile index 7d7b38d90ca5..954974287ee7 100644 ---
[PATCH v4 4/5] powerpc/vdso: Remove cvdso_call_time macro
cvdso_call_time macro is very similar to cvdso_call macro. Add a call_time argument to cvdso_call which is 0 by default and set to 1 when using cvdso_call to call __c_kernel_time(). Return returned value as is with CR[SO] cleared when it is used for time(). Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/vdso/gettimeofday.h | 37 ++-- arch/powerpc/kernel/vdso/gettimeofday.S | 2 +- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/include/asm/vdso/gettimeofday.h index 1faff0be..df00e91c9a90 100644 --- a/arch/powerpc/include/asm/vdso/gettimeofday.h +++ b/arch/powerpc/include/asm/vdso/gettimeofday.h @@ -9,12 +9,12 @@ #include /* - * The macros sets two stack frames, one for the caller and one for the callee + * The macro sets two stack frames, one for the caller and one for the callee * because there are no requirement for the caller to set a stack frame when * calling VDSO so it may have omitted to set one, especially on PPC64 */ -.macro cvdso_call funct +.macro cvdso_call funct call_time=0 .cfi_startproc PPC_STLUr1, -PPC_MIN_STKFRM(r1) mflrr0 @@ -25,45 +25,28 @@ PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1) #endif get_datapager5 + .ifeq \call_time addir5, r5, VDSO_DATA_OFFSET + .else + addir4, r5, VDSO_DATA_OFFSET + .endif bl DOTSYM(\funct) PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) #ifdef __powerpc64__ PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1) #endif + .ifeq \call_time cmpwi r3, 0 + .endif mtlrr0 .cfi_restore lr addir1, r1, 2 * PPC_MIN_STKFRM crclr so + .ifeq \call_time beqlr+ crset so neg r3, r3 - blr - .cfi_endproc -.endm - -.macro cvdso_call_time funct - .cfi_startproc - PPC_STLUr1, -PPC_MIN_STKFRM(r1) - mflrr0 - .cfi_register lr, r0 - PPC_STLUr1, -PPC_MIN_STKFRM(r1) - PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) -#ifdef __powerpc64__ - PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1) -#endif - get_datapager4 - addir4, r4, VDSO_DATA_OFFSET - bl DOTSYM(\funct) - PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) -#ifdef __powerpc64__ - PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1) -#endif - crclr so - mtlrr0 - .cfi_restore lr - addir1, r1, 2 * PPC_MIN_STKFRM + .endif blr .cfi_endproc .endm diff --git a/arch/powerpc/kernel/vdso/gettimeofday.S b/arch/powerpc/kernel/vdso/gettimeofday.S index c875312274aa..397f290015bc 100644 --- a/arch/powerpc/kernel/vdso/gettimeofday.S +++ b/arch/powerpc/kernel/vdso/gettimeofday.S @@ -65,7 +65,7 @@ V_FUNCTION_END(__kernel_clock_getres) * */ V_FUNCTION_BEGIN(__kernel_time) - cvdso_call_time __c_kernel_time + cvdso_call __c_kernel_time call_time=1 V_FUNCTION_END(__kernel_time) /* Routines for restoring integer registers, called by the compiler. */ -- 2.33.1
[PATCH v4 1/5] powerpc/vdso: augment VDSO32 functions to support 64 bits build
VDSO64 cacheflush.S datapage.S gettimeofday.S and vgettimeofday.c are very similar to their VDSO32 counterpart. VDSO32 counterpart is already more complete than the VDSO64 version as it supports both PPC32 vdso and 32 bits VDSO for PPC64. Use compat macros wherever necessary in PPC32 files so that they can also be used to build VDSO64. vdso64/note.S is already a link to vdso32/note.S so no change is required. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/asm-compat.h | 2 ++ arch/powerpc/kernel/vdso32/cacheflush.S| 4 ++-- arch/powerpc/kernel/vdso32/datapage.S | 10 -- arch/powerpc/kernel/vdso32/getcpu.S| 4 ++-- arch/powerpc/kernel/vdso32/gettimeofday.S | 8 ++-- arch/powerpc/kernel/vdso32/vgettimeofday.c | 23 ++ 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/include/asm/asm-compat.h b/arch/powerpc/include/asm/asm-compat.h index 2b736d9fbb1b..2bc53c646ccd 100644 --- a/arch/powerpc/include/asm/asm-compat.h +++ b/arch/powerpc/include/asm/asm-compat.h @@ -21,6 +21,7 @@ #define PPC_STLCX stringify_in_c(stdcx.) #define PPC_CNTLZL stringify_in_c(cntlzd) #define PPC_MTOCRF(FXM, RS) MTOCRF((FXM), RS) +#define PPC_SRLstringify_in_c(srd) #define PPC_LR_STKOFF 16 #define PPC_MIN_STKFRM 112 @@ -54,6 +55,7 @@ #define PPC_STLCX stringify_in_c(stwcx.) #define PPC_CNTLZL stringify_in_c(cntlzw) #define PPC_MTOCRF stringify_in_c(mtcrf) +#define PPC_SRLstringify_in_c(srw) #define PPC_LR_STKOFF 4 #define PPC_MIN_STKFRM 16 diff --git a/arch/powerpc/kernel/vdso32/cacheflush.S b/arch/powerpc/kernel/vdso32/cacheflush.S index f340e82d1981..d4e43ab2d5df 100644 --- a/arch/powerpc/kernel/vdso32/cacheflush.S +++ b/arch/powerpc/kernel/vdso32/cacheflush.S @@ -46,7 +46,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE) add r8,r8,r5/* ensure we get enough */ #ifdef CONFIG_PPC64 lwz r9,CFG_DCACHE_LOGBLOCKSZ(r10) - srw.r8,r8,r9/* compute line count */ + PPC_SRL.r8,r8,r9/* compute line count */ #else srwi. r8, r8, L1_CACHE_SHIFT mr r7, r6 @@ -72,7 +72,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE) subfr8,r6,r4/* compute length */ add r8,r8,r5 lwz r9,CFG_ICACHE_LOGBLOCKSZ(r10) - srw.r8,r8,r9/* compute line count */ + PPC_SRL.r8,r8,r9/* compute line count */ crclr cr0*4+so beqlr /* nothing to do? */ #endif diff --git a/arch/powerpc/kernel/vdso32/datapage.S b/arch/powerpc/kernel/vdso32/datapage.S index 65244416ab94..db8e167f0166 100644 --- a/arch/powerpc/kernel/vdso32/datapage.S +++ b/arch/powerpc/kernel/vdso32/datapage.S @@ -30,11 +30,15 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map) mr. r4,r3 get_datapager3 mtlrr12 +#ifdef __powerpc64__ + addir3,r3,CFG_SYSCALL_MAP64 +#else addir3,r3,CFG_SYSCALL_MAP32 +#endif + crclr cr0*4+so beqlr li r0,NR_syscalls stw r0,0(r4) - crclr cr0*4+so blr .cfi_endproc V_FUNCTION_END(__kernel_get_syscall_map) @@ -49,8 +53,10 @@ V_FUNCTION_BEGIN(__kernel_get_tbfreq) mflrr12 .cfi_register lr,r12 get_datapager3 +#ifndef __powerpc64__ lwz r4,(CFG_TB_TICKS_PER_SEC + 4)(r3) - lwz r3,CFG_TB_TICKS_PER_SEC(r3) +#endif + PPC_LL r3,CFG_TB_TICKS_PER_SEC(r3) mtlrr12 crclr cr0*4+so blr diff --git a/arch/powerpc/kernel/vdso32/getcpu.S b/arch/powerpc/kernel/vdso32/getcpu.S index ff5e214fec41..8e08ccf19062 100644 --- a/arch/powerpc/kernel/vdso32/getcpu.S +++ b/arch/powerpc/kernel/vdso32/getcpu.S @@ -19,8 +19,8 @@ V_FUNCTION_BEGIN(__kernel_getcpu) .cfi_startproc mfspr r5,SPRN_SPRG_VDSO_READ - cmpwi cr0,r3,0 - cmpwi cr1,r4,0 + PPC_LCMPI cr0,r3,0 + PPC_LCMPI cr1,r4,0 clrlwi r6,r5,16 rlwinm r7,r5,16,31-15,31-0 beq cr0,1f diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S index d21d08140a5e..c875312274aa 100644 --- a/arch/powerpc/kernel/vdso32/gettimeofday.S +++ b/arch/powerpc/kernel/vdso32/gettimeofday.S @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ /* - * Userland implementation of gettimeofday() for 32 bits processes in a - * ppc64 kernel for use in the vDSO + * Userland implementation of gettimeofday() for processes + * for use in the vDSO * * Copyright (C) 2004 Benjamin Herrenschmuidt (b...@kernel.crashing.org, *IBM Corp. @@ -41,9 +41,11 @@ V_FUNCTION_END(__kernel_clock_gettime) * int __kernel_clock_gettime64(clockid_t clock_id, struct __timespec64 *ts); * */ +#ifndef __powerpc64__
[PATCH v4 2/5] powerpc/vdso: Rework VDSO32 makefile to add a prefix to object files
In order to merge vdso32 and vdso64 build in following patch, rework Makefile is order to add -32 suffix to VDSO32 object files. Also change sigtramp.S to sigtramp32.S as VDSO64 sigtramp.S is too different to be squashed into VDSO32 sigtramp.S at the first place. gen_vdso_offsets.sh also becomes gen_vdso32_offsets.sh Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/vdso32/Makefile | 47 +-- ..._vdso_offsets.sh => gen_vdso32_offsets.sh} | 0 .../vdso32/{sigtramp.S => sigtramp32.S} | 0 3 files changed, 21 insertions(+), 26 deletions(-) rename arch/powerpc/kernel/vdso32/{gen_vdso_offsets.sh => gen_vdso32_offsets.sh} (100%) rename arch/powerpc/kernel/vdso32/{sigtramp.S => sigtramp32.S} (100%) diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso32/Makefile index 7d9a6fee0e3d..7d7b38d90ca5 100644 --- a/arch/powerpc/kernel/vdso32/Makefile +++ b/arch/powerpc/kernel/vdso32/Makefile @@ -5,15 +5,16 @@ ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN|R_PPC_REL24 include $(srctree)/lib/vdso/Makefile -obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o getcpu.o +obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o note-32.o getcpu-32.o ifneq ($(c-gettimeofday-y),) - CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y) - CFLAGS_vgettimeofday.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) - CFLAGS_vgettimeofday.o += $(call cc-option, -fno-stack-protector) - CFLAGS_vgettimeofday.o += -DDISABLE_BRANCH_PROFILING - CFLAGS_vgettimeofday.o += -ffreestanding -fasynchronous-unwind-tables - CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) + CFLAGS_vgettimeofday-32.o += -include $(c-gettimeofday-y) + CFLAGS_vgettimeofday-32.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) + CFLAGS_vgettimeofday-32.o += $(call cc-option, -fno-stack-protector) + CFLAGS_vgettimeofday-32.o += -DDISABLE_BRANCH_PROFILING + CFLAGS_vgettimeofday-32.o += -ffreestanding -fasynchronous-unwind-tables + CFLAGS_REMOVE_vgettimeofday-32.o = $(CC_FLAGS_FTRACE) + CFLAGS_REMOVE_vgettimeofday-32.o += -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc endif # Build rules @@ -24,13 +25,7 @@ else VDSOCC := $(CC) endif -CC32FLAGS := -ifdef CONFIG_PPC64 -CC32FLAGS += -m32 -KBUILD_CFLAGS := $(filter-out -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc,$(KBUILD_CFLAGS)) -endif - -targets := $(obj-vdso32) vdso32.so.dbg vgettimeofday.o +targets := $(obj-vdso32) vdso32.so.dbg vgettimeofday-32.o obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32)) GCOV_PROFILE := n @@ -38,36 +33,36 @@ KCOV_INSTRUMENT := n UBSAN_SANITIZE := n KASAN_SANITIZE := n -ccflags-y := -shared -fno-common -fno-builtin -nostdlib \ - -Wl,-soname=linux-vdso32.so.1 -Wl,--hash-style=both -asflags-y := -D__VDSO32__ -s +ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both + +CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32 +AS32FLAGS := -D__VDSO32__ -s -obj-y += vdso32_wrapper.o targets += vdso32.lds CPPFLAGS_vdso32.lds += -P -C -Upowerpc # link rule for the .so file, .lds has to be first -$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday.o FORCE +$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday-32.o FORCE $(call if_changed,vdso32ld_and_check) # assembly rules for the .S files -$(obj-vdso32): %.o: %.S FORCE +$(obj-vdso32): %-32.o: %.S FORCE $(call if_changed_dep,vdso32as) -$(obj)/vgettimeofday.o: %.o: %.c FORCE +$(obj)/vgettimeofday-32.o: %-32.o: %.c FORCE $(call if_changed_dep,vdso32cc) # Generate VDSO offsets using helper script -gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh -quiet_cmd_vdsosym = VDSOSYM $@ - cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ +gen-vdso32sym := $(srctree)/$(src)/gen_vdso32_offsets.sh +quiet_cmd_vdso32sym = VDSO32SYM $@ + cmd_vdso32sym = $(NM) $< | $(gen-vdso32sym) | LC_ALL=C sort > $@ include/generated/vdso32-offsets.h: $(obj)/vdso32.so.dbg FORCE - $(call if_changed,vdsosym) + $(call if_changed,vdso32sym) # actual build commands quiet_cmd_vdso32ld_and_check = VDSO32L $@ cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check) quiet_cmd_vdso32as = VDSO32A $@ - cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $< + cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $< quiet_cmd_vdso32cc = VDSO32C $@ cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $< diff --git a/arch/powerpc/kernel/vdso32/gen_vdso_offsets.sh b/arch/powerpc/kernel/vdso32/gen_vdso32_offsets.sh similarity index 100% rename from arch/powerpc/kernel/vdso32/gen_vdso_offsets.sh rename to
Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
On Fri, Jan 21, 2022 at 03:34:24PM +, Christophe Leroy wrote: > > > Le 21/01/2022 à 16:19, Greg Kroah-Hartman a écrit : > > On Fri, Jan 21, 2022 at 03:13:50PM +, Christophe Leroy wrote: > >> > >> > >> Le 21/01/2022 à 15:35, Greg Kroah-Hartman a écrit : > > ... > > @@ -20,16 +16,6 @@ > * respects; for example, they cover modification of the file, and > * distribution when not linked into another program.) > * > - * This file is distributed in the hope that it will be useful, but > - * WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > - * General Public License for more details. > - * > - * You should have received a copy of the GNU General Public License > - * along with this program; see the file COPYING. If not, write to > - * the Free Software Foundation, 51 Franklin Street, Fifth Floor, > - * Boston, MA 02110-1301, USA. > - * > *As a special exception, if you link this library with files > *compiled with GCC to produce an executable, this does not cause > *the resulting executable to be covered by the GNU General > Public License. > >>> > >>> Look at that "special exception", why are you ignoring it here? You > >>> can't do that :( > >> > >> I'm not ignoring it, that's the reason why I left it. > > > > You ignore that part of the license in the SPDX line, why? > > > >> Isn't it the correct way to do ? How should it be done ? > > > > You need to properly describe this in the SPDX line. You did not do so > > here, which means that any tool just looking at the SPDX line would get > > this license wrong. > > How do you describe such an exception on the SPDX line then ? > > You add " WITH GCC-exception-2.0" to the SPDX line ? Am I understanding > correctly ? I do not know, please ask the SPDX people. There's a reason we didn't catch these files in our original sweep, and that is because they take some manual work. Which is great to see you doing, but realize it isn't as simple as your first set of patches were :) thanks, greg k-h
Re: [PATCH v3 4/5] powerpc/vdso: Remove cvdso_call_time macro
Le 21/01/2022 à 16:47, kernel test robot a écrit : > arch/powerpc/kernel/vdso/gettimeofday.S: Assembler messages: >>> arch/powerpc/kernel/vdso/gettimeofday.S:68: Error: unrecognized opcode: >>> `cvdso_call_time' > make[2]: *** [arch/powerpc/kernel/vdso/Makefile:71: > arch/powerpc/kernel/vdso/gettimeofday-32.o] Error 1 > make[2]: Target 'include/generated/vdso32-offsets.h' not remade because > of errors. > make[1]: *** [arch/powerpc/Makefile:423: vdso_prepare] Error 2 > make[1]: Target 'prepare' not remade because of errors. > make: *** [Makefile:219: __sub-make] Error 2 > make: Target 'prepare' not remade because of errors. > > Oops. Last minutes change done too quickly. Sorry for the noise.
Re: [PATCH v3 4/5] powerpc/vdso: Remove cvdso_call_time macro
Hi Christophe, I love your patch! Yet something to improve: [auto build test ERROR on powerpc/next] [also build test ERROR on v5.16 next-20220121] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-vdso-augment-VDSO32-functions-to-support-64-bits-build/20220121-180748 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20220121/202201212332.oy8fmnno-...@intel.com/config) compiler: powerpc-linux-gcc (GCC) 11.2.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/09651dc41aab619a025925ace9f5b81e478e7334 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Christophe-Leroy/powerpc-vdso-augment-VDSO32-functions-to-support-64-bits-build/20220121-180748 git checkout 09651dc41aab619a025925ace9f5b81e478e7334 # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=powerpc prepare If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): arch/powerpc/kernel/vdso/gettimeofday.S: Assembler messages: >> arch/powerpc/kernel/vdso/gettimeofday.S:68: Error: unrecognized opcode: >> `cvdso_call_time' make[2]: *** [arch/powerpc/kernel/vdso/Makefile:71: arch/powerpc/kernel/vdso/gettimeofday-32.o] Error 1 make[2]: Target 'include/generated/vdso32-offsets.h' not remade because of errors. make[1]: *** [arch/powerpc/Makefile:423: vdso_prepare] Error 2 make[1]: Target 'prepare' not remade because of errors. make: *** [Makefile:219: __sub-make] Error 2 make: Target 'prepare' not remade because of errors. vim +68 arch/powerpc/kernel/vdso/gettimeofday.S a7f290dad32ee3 arch/powerpc/kernel/vdso32/gettimeofday.S Benjamin Herrenschmidt 2005-11-11 59 a7f290dad32ee3 arch/powerpc/kernel/vdso32/gettimeofday.S Benjamin Herrenschmidt 2005-11-11 60 fcb41a2030abe0 arch/powerpc/kernel/vdso32/gettimeofday.S Adhemerval Zanella 2013-04-22 61 /* fcb41a2030abe0 arch/powerpc/kernel/vdso32/gettimeofday.S Adhemerval Zanella 2013-04-22 62 * Exact prototype of time() fcb41a2030abe0 arch/powerpc/kernel/vdso32/gettimeofday.S Adhemerval Zanella 2013-04-22 63 * fcb41a2030abe0 arch/powerpc/kernel/vdso32/gettimeofday.S Adhemerval Zanella 2013-04-22 64 * time_t time(time *t); fcb41a2030abe0 arch/powerpc/kernel/vdso32/gettimeofday.S Adhemerval Zanella 2013-04-22 65 * fcb41a2030abe0 arch/powerpc/kernel/vdso32/gettimeofday.S Adhemerval Zanella 2013-04-22 66 */ fcb41a2030abe0 arch/powerpc/kernel/vdso32/gettimeofday.S Adhemerval Zanella 2013-04-22 67 V_FUNCTION_BEGIN(__kernel_time) ab037dd87a2f94 arch/powerpc/kernel/vdso32/gettimeofday.S Christophe Leroy 2020-11-27 @68 cvdso_call_time __c_kernel_time fcb41a2030abe0 arch/powerpc/kernel/vdso32/gettimeofday.S Adhemerval Zanella 2013-04-22 69 V_FUNCTION_END(__kernel_time) 08c18b63d9656e arch/powerpc/kernel/vdso32/gettimeofday.S Christophe Leroy 2021-03-09 70 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org
Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
Le 21/01/2022 à 16:19, Greg Kroah-Hartman a écrit : > On Fri, Jan 21, 2022 at 03:13:50PM +, Christophe Leroy wrote: >> >> >> Le 21/01/2022 à 15:35, Greg Kroah-Hartman a écrit : ... @@ -20,16 +16,6 @@ * respects; for example, they cover modification of the file, and * distribution when not linked into another program.) * - * This file is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * *As a special exception, if you link this library with files *compiled with GCC to produce an executable, this does not cause *the resulting executable to be covered by the GNU General Public License. >>> >>> Look at that "special exception", why are you ignoring it here? You >>> can't do that :( >> >> I'm not ignoring it, that's the reason why I left it. > > You ignore that part of the license in the SPDX line, why? > >> Isn't it the correct way to do ? How should it be done ? > > You need to properly describe this in the SPDX line. You did not do so > here, which means that any tool just looking at the SPDX line would get > this license wrong. How do you describe such an exception on the SPDX line then ? You add " WITH GCC-exception-2.0" to the SPDX line ? Am I understanding correctly ? Thanks Christophe
Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
On Fri, Jan 21, 2022 at 03:13:50PM +, Christophe Leroy wrote: > > > Le 21/01/2022 à 15:35, Greg Kroah-Hartman a écrit : > > On Fri, Jan 21, 2022 at 11:03:20AM +, Christophe Leroy wrote: > >> Several files are missing SPDX license identifiers. > >> > >> Following files are given the following SPDX identifier based on the > >> comments in the top of the file: > >> > >>boot/crtsavres.S:/* SPDX-License-Identifier: GPL-2.0+ */ > > > > Are you sure that this is the correct license for this file? > > it says "... GNU General Public License ... either version 2, or (at > your option) any later version". > > Isn't it what GPL-2.0+ means ? Yes, but look further down, as I point out below... > >>include/asm/epapr_hcalls.h:/* SPDX-License-Identifier: GPL-2.0+ OR BSD > >> */ > >>include/asm/fsl_hcalls.h:/* SPDX-License-Identifier: GPL-2.0+ OR BSD */ > >>include/asm/ibmebus.h:/* SPDX-License-Identifier: GPL-2.0 OR OpenIB BSD > >> */ > >>include/asm/sfp-machine.h:/* SPDX-License-Identifier: LGPL-2.0+ */ > >>kvm/mpic.c:// SPDX-License-Identifier: GPL-2.0 > >>lib/crtsavres.S:/* SPDX-License-Identifier: GPL-2.0+ */ > >>mm/book3s64/hash_4k.c:// SPDX-License-Identifier: LGPL-2.0 > >>mm/book3s64/hash_64k.c:// SPDX-License-Identifier: LGPL-2.0 > >>mm/book3s64/hash_hugepage.c:// SPDX-License-Identifier: LGPL-2.1 > >>platforms/pseries/ibmebus.c:// SPDX-License-Identifier: GPL-2.0 OR > >> OpenIB BSD > >>tools/head_check.sh:# SPDX-License-Identifier: GPL-2.0+ > >>xmon/ppc.h:/* SPDX-License-Identifier: GPL-1.0+ */ > >> > >> Add to other files the default kernel license identifier, in extenso > >> GPL-2.0. > >> > >> DTS files are handled in a separate commit. > >> > >> Signed-off-by: Christophe Leroy > >> Cc: Thomas Gleixner > >> Cc: Greg Kroah-Hartman > >> Cc: linux-s...@vger.kernel.org > >> --- > >> v3: Removed license text and license note in the files that have any. > >> > >> v2: Changed from GPL-2.0 to a licence consistant with the file's comments > >> for the few files listed in the commit message. > >> --- > > ... > > >> 92 files changed, 105 insertions(+), 422 deletions(-) > > > > You might want to change less of these at once, as this is hard to > > review as-is. > > Ok > > > > >> diff --git a/arch/powerpc/boot/crtsavres.S b/arch/powerpc/boot/crtsavres.S > >> index 085fb2b9a8b8..25e924459dcc 100644 > >> --- a/arch/powerpc/boot/crtsavres.S > >> +++ b/arch/powerpc/boot/crtsavres.S > >> @@ -1,3 +1,4 @@ > >> +/* SPDX-License-Identifier: GPL-2.0+ */ > >> /* > >>* Special support for eabi and SVR4 > >>* > >> @@ -7,11 +8,6 @@ > >>* > >>* Based on gcc/config/rs6000/crtsavres.asm from gcc > >>* > >> - * This file is free software; you can redistribute it and/or modify it > >> - * under the terms of the GNU General Public License as published by the > >> - * Free Software Foundation; either version 2, or (at your option) any > >> - * later version. > >> - * > >>* In addition to the permissions in the GNU General Public License, the > >>* Free Software Foundation gives you unlimited permission to link the > >>* compiled version of this file with other programs, and to distribute > >> @@ -20,16 +16,6 @@ > >>* respects; for example, they cover modification of the file, and > >>* distribution when not linked into another program.) > >>* > >> - * This file is distributed in the hope that it will be useful, but > >> - * WITHOUT ANY WARRANTY; without even the implied warranty of > >> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > >> - * General Public License for more details. > >> - * > >> - * You should have received a copy of the GNU General Public License > >> - * along with this program; see the file COPYING. If not, write to > >> - * the Free Software Foundation, 51 Franklin Street, Fifth Floor, > >> - * Boston, MA 02110-1301, USA. > >> - * > >>*As a special exception, if you link this library with files > >>*compiled with GCC to produce an executable, this does not cause > >>*the resulting executable to be covered by the GNU General Public > >> License. > > > > Look at that "special exception", why are you ignoring it here? You > > can't do that :( > > I'm not ignoring it, that's the reason why I left it. You ignore that part of the license in the SPDX line, why? > Isn't it the correct way to do ? How should it be done ? You need to properly describe this in the SPDX line. You did not do so here, which means that any tool just looking at the SPDX line would get this license wrong. thanks, greg k-h
Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
Le 21/01/2022 à 15:35, Greg Kroah-Hartman a écrit : > On Fri, Jan 21, 2022 at 11:03:20AM +, Christophe Leroy wrote: >> Several files are missing SPDX license identifiers. >> >> Following files are given the following SPDX identifier based on the >> comments in the top of the file: >> >> boot/crtsavres.S:/* SPDX-License-Identifier: GPL-2.0+ */ > > Are you sure that this is the correct license for this file? it says "... GNU General Public License ... either version 2, or (at your option) any later version". Isn't it what GPL-2.0+ means ? > > Also you dropped the arch/powerpc/ prefix here... Yes I did, for clarity, to get shorter lines. > > >> include/asm/epapr_hcalls.h:/* SPDX-License-Identifier: GPL-2.0+ OR BSD >> */ >> include/asm/fsl_hcalls.h:/* SPDX-License-Identifier: GPL-2.0+ OR BSD */ >> include/asm/ibmebus.h:/* SPDX-License-Identifier: GPL-2.0 OR OpenIB BSD >> */ >> include/asm/sfp-machine.h:/* SPDX-License-Identifier: LGPL-2.0+ */ >> kvm/mpic.c:// SPDX-License-Identifier: GPL-2.0 >> lib/crtsavres.S:/* SPDX-License-Identifier: GPL-2.0+ */ >> mm/book3s64/hash_4k.c:// SPDX-License-Identifier: LGPL-2.0 >> mm/book3s64/hash_64k.c:// SPDX-License-Identifier: LGPL-2.0 >> mm/book3s64/hash_hugepage.c:// SPDX-License-Identifier: LGPL-2.1 >> platforms/pseries/ibmebus.c:// SPDX-License-Identifier: GPL-2.0 OR >> OpenIB BSD >> tools/head_check.sh:# SPDX-License-Identifier: GPL-2.0+ >> xmon/ppc.h:/* SPDX-License-Identifier: GPL-1.0+ */ >> >> Add to other files the default kernel license identifier, in extenso GPL-2.0. >> >> DTS files are handled in a separate commit. >> >> Signed-off-by: Christophe Leroy >> Cc: Thomas Gleixner >> Cc: Greg Kroah-Hartman >> Cc: linux-s...@vger.kernel.org >> --- >> v3: Removed license text and license note in the files that have any. >> >> v2: Changed from GPL-2.0 to a licence consistant with the file's comments >> for the few files listed in the commit message. >> --- ... >> 92 files changed, 105 insertions(+), 422 deletions(-) > > You might want to change less of these at once, as this is hard to > review as-is. Ok > >> diff --git a/arch/powerpc/boot/crtsavres.S b/arch/powerpc/boot/crtsavres.S >> index 085fb2b9a8b8..25e924459dcc 100644 >> --- a/arch/powerpc/boot/crtsavres.S >> +++ b/arch/powerpc/boot/crtsavres.S >> @@ -1,3 +1,4 @@ >> +/* SPDX-License-Identifier: GPL-2.0+ */ >> /* >>* Special support for eabi and SVR4 >>* >> @@ -7,11 +8,6 @@ >>* >>* Based on gcc/config/rs6000/crtsavres.asm from gcc >>* >> - * This file is free software; you can redistribute it and/or modify it >> - * under the terms of the GNU General Public License as published by the >> - * Free Software Foundation; either version 2, or (at your option) any >> - * later version. >> - * >>* In addition to the permissions in the GNU General Public License, the >>* Free Software Foundation gives you unlimited permission to link the >>* compiled version of this file with other programs, and to distribute >> @@ -20,16 +16,6 @@ >>* respects; for example, they cover modification of the file, and >>* distribution when not linked into another program.) >>* >> - * This file is distributed in the hope that it will be useful, but >> - * WITHOUT ANY WARRANTY; without even the implied warranty of >> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >> - * General Public License for more details. >> - * >> - * You should have received a copy of the GNU General Public License >> - * along with this program; see the file COPYING. If not, write to >> - * the Free Software Foundation, 51 Franklin Street, Fifth Floor, >> - * Boston, MA 02110-1301, USA. >> - * >>*As a special exception, if you link this library with files >>*compiled with GCC to produce an executable, this does not cause >>*the resulting executable to be covered by the GNU General Public >> License. > > Look at that "special exception", why are you ignoring it here? You > can't do that :( I'm not ignoring it, that's the reason why I left it. Isn't it the correct way to do ? How should it be done ? Christophe
Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
On Fri, Jan 21, 2022 at 11:03:20AM +, Christophe Leroy wrote: > Several files are missing SPDX license identifiers. > > Following files are given the following SPDX identifier based on the comments > in the top of the file: Nit, please wrap your changelog text properly. > > boot/crtsavres.S:/* SPDX-License-Identifier: GPL-2.0+ */ > include/asm/epapr_hcalls.h:/* SPDX-License-Identifier: GPL-2.0+ OR BSD > */ > include/asm/fsl_hcalls.h:/* SPDX-License-Identifier: GPL-2.0+ OR BSD */ > include/asm/ibmebus.h:/* SPDX-License-Identifier: GPL-2.0 OR OpenIB BSD > */ > include/asm/sfp-machine.h:/* SPDX-License-Identifier: LGPL-2.0+ */ > kvm/mpic.c:// SPDX-License-Identifier: GPL-2.0 > lib/crtsavres.S:/* SPDX-License-Identifier: GPL-2.0+ */ > mm/book3s64/hash_4k.c:// SPDX-License-Identifier: LGPL-2.0 > mm/book3s64/hash_64k.c:// SPDX-License-Identifier: LGPL-2.0 > mm/book3s64/hash_hugepage.c:// SPDX-License-Identifier: LGPL-2.1 > platforms/pseries/ibmebus.c:// SPDX-License-Identifier: GPL-2.0 OR > OpenIB BSD > tools/head_check.sh:# SPDX-License-Identifier: GPL-2.0+ > xmon/ppc.h:/* SPDX-License-Identifier: GPL-1.0+ */ > > Add to other files the default kernel license identifier, in extenso GPL-2.0. That might be good for a single commit alone, don't mix it up with the other files that you are removing stuff from. thanks, greg k-h
Re: [PATCH v3] powerpc: Add missing SPDX license identifiers
On Fri, Jan 21, 2022 at 11:03:20AM +, Christophe Leroy wrote: > Several files are missing SPDX license identifiers. > > Following files are given the following SPDX identifier based on the comments > in the top of the file: > > boot/crtsavres.S:/* SPDX-License-Identifier: GPL-2.0+ */ Are you sure that this is the correct license for this file? Also you dropped the arch/powerpc/ prefix here... > include/asm/epapr_hcalls.h:/* SPDX-License-Identifier: GPL-2.0+ OR BSD > */ > include/asm/fsl_hcalls.h:/* SPDX-License-Identifier: GPL-2.0+ OR BSD */ > include/asm/ibmebus.h:/* SPDX-License-Identifier: GPL-2.0 OR OpenIB BSD > */ > include/asm/sfp-machine.h:/* SPDX-License-Identifier: LGPL-2.0+ */ > kvm/mpic.c:// SPDX-License-Identifier: GPL-2.0 > lib/crtsavres.S:/* SPDX-License-Identifier: GPL-2.0+ */ > mm/book3s64/hash_4k.c:// SPDX-License-Identifier: LGPL-2.0 > mm/book3s64/hash_64k.c:// SPDX-License-Identifier: LGPL-2.0 > mm/book3s64/hash_hugepage.c:// SPDX-License-Identifier: LGPL-2.1 > platforms/pseries/ibmebus.c:// SPDX-License-Identifier: GPL-2.0 OR > OpenIB BSD > tools/head_check.sh:# SPDX-License-Identifier: GPL-2.0+ > xmon/ppc.h:/* SPDX-License-Identifier: GPL-1.0+ */ > > Add to other files the default kernel license identifier, in extenso GPL-2.0. > > DTS files are handled in a separate commit. > > Signed-off-by: Christophe Leroy > Cc: Thomas Gleixner > Cc: Greg Kroah-Hartman > Cc: linux-s...@vger.kernel.org > --- > v3: Removed license text and license note in the files that have any. > > v2: Changed from GPL-2.0 to a licence consistant with the file's comments for > the few files listed in the commit message. > --- > arch/powerpc/Makefile | 5 +-- > arch/powerpc/boot/44x.h | 5 +-- > arch/powerpc/boot/4xx.h | 5 +-- > arch/powerpc/boot/crtsavres.S | 16 +- > arch/powerpc/boot/dummy.c | 1 + > arch/powerpc/boot/install.sh | 5 +-- > arch/powerpc/boot/ops.h | 6 ++-- > arch/powerpc/boot/serial.c| 6 ++-- > arch/powerpc/boot/simple_alloc.c | 6 ++-- > arch/powerpc/include/asm/8xx_immap.h | 1 + > arch/powerpc/include/asm/asm-compat.h | 1 + > arch/powerpc/include/asm/asm-const.h | 1 + > arch/powerpc/include/asm/asm-offsets.h| 1 + > arch/powerpc/include/asm/cpm.h| 1 + > arch/powerpc/include/asm/dtl.h| 1 + > arch/powerpc/include/asm/edac.h | 6 ++-- > arch/powerpc/include/asm/ehv_pic.h| 5 +-- > arch/powerpc/include/asm/emergency-restart.h | 1 + > arch/powerpc/include/asm/epapr_hcalls.h | 32 +-- > arch/powerpc/include/asm/fixmap.h | 5 +-- > arch/powerpc/include/asm/floppy.h | 5 +-- > arch/powerpc/include/asm/fs_pd.h | 5 +-- > arch/powerpc/include/asm/fsl_hcalls.h | 32 +-- > arch/powerpc/include/asm/hydra.h | 5 +-- > arch/powerpc/include/asm/ibmebus.h| 29 + > arch/powerpc/include/asm/kgdb.h | 6 ++-- > arch/powerpc/include/asm/membarrier.h | 1 + > arch/powerpc/include/asm/module.lds.h | 1 + > arch/powerpc/include/asm/mpc52xx.h| 5 +-- > arch/powerpc/include/asm/mpc52xx_psc.h| 5 +-- > arch/powerpc/include/asm/pmac_feature.h | 5 +-- > arch/powerpc/include/asm/ppc_asm.h| 1 + > arch/powerpc/include/asm/pte-walk.h | 1 + > arch/powerpc/include/asm/rheap.h | 6 ++-- > arch/powerpc/include/asm/sfp-machine.h| 16 +- > arch/powerpc/include/asm/vmalloc.h| 1 + > arch/powerpc/include/asm/word-at-a-time.h | 1 + > arch/powerpc/kernel/interrupt_64.S| 1 + > arch/powerpc/kernel/kgdb.c| 5 +-- > arch/powerpc/kernel/ptrace/ptrace.c | 5 +-- > arch/powerpc/kernel/ptrace/ptrace32.c | 5 +-- > arch/powerpc/kernel/signal.c | 5 +-- > arch/powerpc/kernel/signal.h | 5 +-- > arch/powerpc/kernel/vdso32/note.S | 1 + > arch/powerpc/kernel/vdso64/note.S | 1 + > arch/powerpc/kvm/mpic.c | 19 +-- > arch/powerpc/lib/crtsavres.S | 16 +- > arch/powerpc/lib/restart_table.c | 1 + > arch/powerpc/lib/rheap.c | 6 ++-- > arch/powerpc/mm/book3s64/hash_4k.c| 10 +- > arch/powerpc/mm/book3s64/hash_64k.c | 10 +- > arch/powerpc/mm/book3s64/hash_hugepage.c | 10 +- > arch/powerpc/mm/hugetlbpage.c | 1 + > arch/powerpc/perf/req-gen/_end.h | 1 + > arch/powerpc/platforms/44x/fsp2.h | 1 + >
Re: [PATCH v3 4/5] powerpc/vdso: Remove cvdso_call_time macro
Hi Christophe, I love your patch! Yet something to improve: [auto build test ERROR on powerpc/next] [also build test ERROR on v5.16 next-20220121] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-vdso-augment-VDSO32-functions-to-support-64-bits-build/20220121-180748 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next config: powerpc-randconfig-r021-20220120 (https://download.01.org/0day-ci/archive/20220121/202201212229.ibniex24-...@intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 7b3d30728816403d1fd73cc5082e9fb761262bce) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install powerpc cross compiling tool for clang build # apt-get install binutils-powerpc-linux-gnu # https://github.com/0day-ci/linux/commit/09651dc41aab619a025925ace9f5b81e478e7334 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Christophe-Leroy/powerpc-vdso-augment-VDSO32-functions-to-support-64-bits-build/20220121-180748 git checkout 09651dc41aab619a025925ace9f5b81e478e7334 # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc prepare If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): arch/powerpc/include/asm/io.h:557:56: note: expanded from macro '__do_insw' #define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~^ In file included from arch/powerpc/kernel/asm-offsets.c:21: In file included from include/linux/suspend.h:5: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:26: In file included from include/linux/kernel_stat.h:9: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from arch/powerpc/include/asm/hardirq.h:6: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/powerpc/include/asm/io.h:619: arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c), ^~~ arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~ :198:1: note: expanded from here __do_insl ^ arch/powerpc/include/asm/io.h:558:56: note: expanded from macro '__do_insl' #define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~^ In file included from arch/powerpc/kernel/asm-offsets.c:21: In file included from include/linux/suspend.h:5: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:26: In file included from include/linux/kernel_stat.h:9: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from arch/powerpc/include/asm/hardirq.h:6: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/powerpc/include/asm/io.h:619: arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c), ^~ arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~ :200:1: note: expanded from here __do_outsb ^ arch/powerpc/include/asm/io.h:559:58: note: expanded from macro '__do_outsb' #define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) ~^ In file included from arch/powerpc/kernel/asm-offsets.c:21: In file included from include/linux/suspend.h:5: In file included from i
Re: [PATCH v7 1/7] powerpc/pmem: Restrict papr_scm to P8 and above.
On Fri, Jan 21, 2022 at 02:48:32PM +0530, Aneesh Kumar K.V wrote: > Michal Suchánek writes: > > > Hello, > > > > On Wed, Jul 01, 2020 at 12:52:29PM +0530, Aneesh Kumar K.V wrote: > >> The PAPR based virtualized persistent memory devices are only supported on > >> POWER9 and above. In the followup patch, the kernel will switch the > >> persistent > >> memory cache flush functions to use a new `dcbf` variant instruction. The > >> new > >> instructions even though added in ISA 3.1 works even on P8 and P9 because > >> these > >> are implemented as a variant of existing `dcbf` and `hwsync` and on P8 and > >> P9 behaves as such. > >> > >> Considering these devices are only supported on P8 and above, update the > >> driver > >> to prevent a P7-compat guest from using persistent memory devices. > >> > >> We don't update of_pmem driver with the same condition, because, on > >> bare-metal, > >> the firmware enables pmem support only on P9 and above. There the kernel > >> depends > >> on OPAL firmware to restrict exposing persistent memory related device tree > >> entries on older hardware. of_pmem.ko is written without any arch > >> dependency and > >> we don't want to add ppc64 specific cpu feature check in of_pmem driver. > >> > >> Signed-off-by: Aneesh Kumar K.V > >> --- > >> arch/powerpc/platforms/pseries/pmem.c | 6 ++ > >> 1 file changed, 6 insertions(+) > >> > >> diff --git a/arch/powerpc/platforms/pseries/pmem.c > >> b/arch/powerpc/platforms/pseries/pmem.c > >> index f860a897a9e0..2347e1038f58 100644 > >> --- a/arch/powerpc/platforms/pseries/pmem.c > >> +++ b/arch/powerpc/platforms/pseries/pmem.c > >> @@ -147,6 +147,12 @@ const struct of_device_id drc_pmem_match[] = { > >> > >> static int pseries_pmem_init(void) > >> { > >> + /* > >> + * Only supported on POWER8 and above. > >> + */ > >> + if (!cpu_has_feature(CPU_FTR_ARCH_207S)) > >> + return 0; > >> + > > > > This looks superfluous. > > > > The hypervisor is responsible for publishing the pmem in devicetree when > > present, kernel is responsible for using it when supported by the > > kernel. > > > > Or is there a problem that the flush instruction is not available in P7 > > compat mode? > > We want to avoid the usage of persistent memory on p7 compat mode > because such a guest can LPM migrate to p7 systems. Now ideally I would > expect hypervisor to avoid such migration, that is a p7 compat mode > guest running on p10 using persistence memory migrating to p7 > (considering p7 never really had support for persistent memory). Yes, I would expect the hypervisor to prevent migration to host that does not have all the hardawre that the guest uses. It could still migrate to P8 or whatever in compat mode. > > There was also the complexity w.r.t what instructions the userspace will > use. So it was discussed at that point that we could comfortably state > and prevent the usage of persistent memory on p7 and below. But is that arbitrary or does POWER7 not support the pmem sync instructions? If that is true then how is POWER7 compat mode behaving WRT those instructions? Thanks Michal
[PATCH v3] powerpc: Add missing SPDX license identifiers
Several files are missing SPDX license identifiers. Following files are given the following SPDX identifier based on the comments in the top of the file: boot/crtsavres.S:/* SPDX-License-Identifier: GPL-2.0+ */ include/asm/epapr_hcalls.h:/* SPDX-License-Identifier: GPL-2.0+ OR BSD */ include/asm/fsl_hcalls.h:/* SPDX-License-Identifier: GPL-2.0+ OR BSD */ include/asm/ibmebus.h:/* SPDX-License-Identifier: GPL-2.0 OR OpenIB BSD */ include/asm/sfp-machine.h:/* SPDX-License-Identifier: LGPL-2.0+ */ kvm/mpic.c:// SPDX-License-Identifier: GPL-2.0 lib/crtsavres.S:/* SPDX-License-Identifier: GPL-2.0+ */ mm/book3s64/hash_4k.c:// SPDX-License-Identifier: LGPL-2.0 mm/book3s64/hash_64k.c:// SPDX-License-Identifier: LGPL-2.0 mm/book3s64/hash_hugepage.c:// SPDX-License-Identifier: LGPL-2.1 platforms/pseries/ibmebus.c:// SPDX-License-Identifier: GPL-2.0 OR OpenIB BSD tools/head_check.sh:# SPDX-License-Identifier: GPL-2.0+ xmon/ppc.h:/* SPDX-License-Identifier: GPL-1.0+ */ Add to other files the default kernel license identifier, in extenso GPL-2.0. DTS files are handled in a separate commit. Signed-off-by: Christophe Leroy Cc: Thomas Gleixner Cc: Greg Kroah-Hartman Cc: linux-s...@vger.kernel.org --- v3: Removed license text and license note in the files that have any. v2: Changed from GPL-2.0 to a licence consistant with the file's comments for the few files listed in the commit message. --- arch/powerpc/Makefile | 5 +-- arch/powerpc/boot/44x.h | 5 +-- arch/powerpc/boot/4xx.h | 5 +-- arch/powerpc/boot/crtsavres.S | 16 +- arch/powerpc/boot/dummy.c | 1 + arch/powerpc/boot/install.sh | 5 +-- arch/powerpc/boot/ops.h | 6 ++-- arch/powerpc/boot/serial.c| 6 ++-- arch/powerpc/boot/simple_alloc.c | 6 ++-- arch/powerpc/include/asm/8xx_immap.h | 1 + arch/powerpc/include/asm/asm-compat.h | 1 + arch/powerpc/include/asm/asm-const.h | 1 + arch/powerpc/include/asm/asm-offsets.h| 1 + arch/powerpc/include/asm/cpm.h| 1 + arch/powerpc/include/asm/dtl.h| 1 + arch/powerpc/include/asm/edac.h | 6 ++-- arch/powerpc/include/asm/ehv_pic.h| 5 +-- arch/powerpc/include/asm/emergency-restart.h | 1 + arch/powerpc/include/asm/epapr_hcalls.h | 32 +-- arch/powerpc/include/asm/fixmap.h | 5 +-- arch/powerpc/include/asm/floppy.h | 5 +-- arch/powerpc/include/asm/fs_pd.h | 5 +-- arch/powerpc/include/asm/fsl_hcalls.h | 32 +-- arch/powerpc/include/asm/hydra.h | 5 +-- arch/powerpc/include/asm/ibmebus.h| 29 + arch/powerpc/include/asm/kgdb.h | 6 ++-- arch/powerpc/include/asm/membarrier.h | 1 + arch/powerpc/include/asm/module.lds.h | 1 + arch/powerpc/include/asm/mpc52xx.h| 5 +-- arch/powerpc/include/asm/mpc52xx_psc.h| 5 +-- arch/powerpc/include/asm/pmac_feature.h | 5 +-- arch/powerpc/include/asm/ppc_asm.h| 1 + arch/powerpc/include/asm/pte-walk.h | 1 + arch/powerpc/include/asm/rheap.h | 6 ++-- arch/powerpc/include/asm/sfp-machine.h| 16 +- arch/powerpc/include/asm/vmalloc.h| 1 + arch/powerpc/include/asm/word-at-a-time.h | 1 + arch/powerpc/kernel/interrupt_64.S| 1 + arch/powerpc/kernel/kgdb.c| 5 +-- arch/powerpc/kernel/ptrace/ptrace.c | 5 +-- arch/powerpc/kernel/ptrace/ptrace32.c | 5 +-- arch/powerpc/kernel/signal.c | 5 +-- arch/powerpc/kernel/signal.h | 5 +-- arch/powerpc/kernel/vdso32/note.S | 1 + arch/powerpc/kernel/vdso64/note.S | 1 + arch/powerpc/kvm/mpic.c | 19 +-- arch/powerpc/lib/crtsavres.S | 16 +- arch/powerpc/lib/restart_table.c | 1 + arch/powerpc/lib/rheap.c | 6 ++-- arch/powerpc/mm/book3s64/hash_4k.c| 10 +- arch/powerpc/mm/book3s64/hash_64k.c | 10 +- arch/powerpc/mm/book3s64/hash_hugepage.c | 10 +- arch/powerpc/mm/hugetlbpage.c | 1 + arch/powerpc/perf/req-gen/_end.h | 1 + arch/powerpc/platforms/44x/fsp2.h | 1 + arch/powerpc/platforms/4xx/pci.c | 1 + arch/powerpc/platforms/4xx/pci.h | 1 + arch/powerpc/platforms/52xx/efika.c | 5 +-- arch/powerpc/platforms/52xx/mpc52xx_common.c | 6 +--- arch/powerpc/platforms/52xx/mpc52xx_pci.c | 5 +-- arch/powerpc/platforms/52xx/mpc52xx_pic.c | 6 +---
[PATCH v3 5/5] powerpc/vdso: Move cvdso_call macro into gettimeofday.S
Now that gettimeofday.S is unique, move cvdso_call macro into that file which is the only user. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/vdso/gettimeofday.h | 52 +--- arch/powerpc/kernel/vdso/gettimeofday.S | 44 - 2 files changed, 45 insertions(+), 51 deletions(-) diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/include/asm/vdso/gettimeofday.h index df00e91c9a90..f0a4cf01e85c 100644 --- a/arch/powerpc/include/asm/vdso/gettimeofday.h +++ b/arch/powerpc/include/asm/vdso/gettimeofday.h @@ -2,57 +2,9 @@ #ifndef _ASM_POWERPC_VDSO_GETTIMEOFDAY_H #define _ASM_POWERPC_VDSO_GETTIMEOFDAY_H -#include - -#ifdef __ASSEMBLY__ - -#include - -/* - * The macro sets two stack frames, one for the caller and one for the callee - * because there are no requirement for the caller to set a stack frame when - * calling VDSO so it may have omitted to set one, especially on PPC64 - */ - -.macro cvdso_call funct call_time=0 - .cfi_startproc - PPC_STLUr1, -PPC_MIN_STKFRM(r1) - mflrr0 - .cfi_register lr, r0 - PPC_STLUr1, -PPC_MIN_STKFRM(r1) - PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) -#ifdef __powerpc64__ - PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1) -#endif - get_datapager5 - .ifeq \call_time - addir5, r5, VDSO_DATA_OFFSET - .else - addir4, r5, VDSO_DATA_OFFSET - .endif - bl DOTSYM(\funct) - PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) -#ifdef __powerpc64__ - PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1) -#endif - .ifeq \call_time - cmpwi r3, 0 - .endif - mtlrr0 - .cfi_restore lr - addir1, r1, 2 * PPC_MIN_STKFRM - crclr so - .ifeq \call_time - beqlr+ - crset so - neg r3, r3 - .endif - blr - .cfi_endproc -.endm - -#else +#ifndef __ASSEMBLY__ +#include #include #include #include diff --git a/arch/powerpc/kernel/vdso/gettimeofday.S b/arch/powerpc/kernel/vdso/gettimeofday.S index c875312274aa..11e0b911c923 100644 --- a/arch/powerpc/kernel/vdso/gettimeofday.S +++ b/arch/powerpc/kernel/vdso/gettimeofday.S @@ -12,7 +12,49 @@ #include #include #include -#include + +/* + * The macro sets two stack frames, one for the caller and one for the callee + * because there are no requirement for the caller to set a stack frame when + * calling VDSO so it may have omitted to set one, especially on PPC64 + */ + +.macro cvdso_call funct call_time=0 + .cfi_startproc + PPC_STLUr1, -PPC_MIN_STKFRM(r1) + mflrr0 + .cfi_register lr, r0 + PPC_STLUr1, -PPC_MIN_STKFRM(r1) + PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) +#ifdef __powerpc64__ + PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1) +#endif + get_datapager5 + .ifeq \call_time + addir5, r5, VDSO_DATA_OFFSET + .else + addir4, r5, VDSO_DATA_OFFSET + .endif + bl DOTSYM(\funct) + PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) +#ifdef __powerpc64__ + PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1) +#endif + .ifeq \call_time + cmpwi r3, 0 + .endif + mtlrr0 + .cfi_restore lr + addir1, r1, 2 * PPC_MIN_STKFRM + crclr so + .ifeq \call_time + beqlr+ + crset so + neg r3, r3 + .endif + blr + .cfi_endproc +.endm .text /* -- 2.33.1
[PATCH v3 4/5] powerpc/vdso: Remove cvdso_call_time macro
cvdso_call_time macro is very similar to cvdso_call macro. Add a call_time argument to cvdso_call which is 0 by default and set to 1 when using cvdso_call to call __c_kernel_time(). Return returned value as is with CR[SO] cleared when it is used for time(). Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/vdso/gettimeofday.h | 37 ++-- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/include/asm/vdso/gettimeofday.h index 1faff0be..df00e91c9a90 100644 --- a/arch/powerpc/include/asm/vdso/gettimeofday.h +++ b/arch/powerpc/include/asm/vdso/gettimeofday.h @@ -9,12 +9,12 @@ #include /* - * The macros sets two stack frames, one for the caller and one for the callee + * The macro sets two stack frames, one for the caller and one for the callee * because there are no requirement for the caller to set a stack frame when * calling VDSO so it may have omitted to set one, especially on PPC64 */ -.macro cvdso_call funct +.macro cvdso_call funct call_time=0 .cfi_startproc PPC_STLUr1, -PPC_MIN_STKFRM(r1) mflrr0 @@ -25,45 +25,28 @@ PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1) #endif get_datapager5 + .ifeq \call_time addir5, r5, VDSO_DATA_OFFSET + .else + addir4, r5, VDSO_DATA_OFFSET + .endif bl DOTSYM(\funct) PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) #ifdef __powerpc64__ PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1) #endif + .ifeq \call_time cmpwi r3, 0 + .endif mtlrr0 .cfi_restore lr addir1, r1, 2 * PPC_MIN_STKFRM crclr so + .ifeq \call_time beqlr+ crset so neg r3, r3 - blr - .cfi_endproc -.endm - -.macro cvdso_call_time funct - .cfi_startproc - PPC_STLUr1, -PPC_MIN_STKFRM(r1) - mflrr0 - .cfi_register lr, r0 - PPC_STLUr1, -PPC_MIN_STKFRM(r1) - PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) -#ifdef __powerpc64__ - PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1) -#endif - get_datapager4 - addir4, r4, VDSO_DATA_OFFSET - bl DOTSYM(\funct) - PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) -#ifdef __powerpc64__ - PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1) -#endif - crclr so - mtlrr0 - .cfi_restore lr - addir1, r1, 2 * PPC_MIN_STKFRM + .endif blr .cfi_endproc .endm -- 2.33.1
[PATCH v3 3/5] powerpc/vdso: Merge vdso64 and vdso32 into a single directory
merge vdso64 into vdso32 and rename it vdso. Signed-off-by: Christophe Leroy --- arch/powerpc/Makefile | 4 +- arch/powerpc/kernel/Makefile | 6 +- .../kernel/{vdso64 => vdso}/.gitignore| 2 + arch/powerpc/kernel/{vdso32 => vdso}/Makefile | 35 + .../kernel/{vdso32 => vdso}/cacheflush.S | 0 .../kernel/{vdso32 => vdso}/datapage.S| 0 .../{vdso32 => vdso}/gen_vdso32_offsets.sh| 0 .../gen_vdso64_offsets.sh}| 0 arch/powerpc/kernel/{vdso32 => vdso}/getcpu.S | 0 .../kernel/{vdso32 => vdso}/gettimeofday.S| 0 arch/powerpc/kernel/{vdso32 => vdso}/note.S | 0 .../kernel/{vdso32 => vdso}/sigtramp32.S | 0 .../{vdso64/sigtramp.S => vdso/sigtramp64.S} | 0 .../kernel/{vdso32 => vdso}/vdso32.lds.S | 0 .../kernel/{vdso64 => vdso}/vdso64.lds.S | 0 .../kernel/{vdso32 => vdso}/vgettimeofday.c | 0 arch/powerpc/kernel/vdso32/.gitignore | 3 - arch/powerpc/kernel/vdso32_wrapper.S | 2 +- arch/powerpc/kernel/vdso64/Makefile | 56 -- arch/powerpc/kernel/vdso64/cacheflush.S | 75 --- arch/powerpc/kernel/vdso64/datapage.S | 59 --- arch/powerpc/kernel/vdso64/getcpu.S | 33 arch/powerpc/kernel/vdso64/gettimeofday.S | 58 -- arch/powerpc/kernel/vdso64/note.S | 1 - arch/powerpc/kernel/vdso64/vgettimeofday.c| 29 --- arch/powerpc/kernel/vdso64_wrapper.S | 2 +- 26 files changed, 44 insertions(+), 321 deletions(-) rename arch/powerpc/kernel/{vdso64 => vdso}/.gitignore (72%) rename arch/powerpc/kernel/{vdso32 => vdso}/Makefile (56%) rename arch/powerpc/kernel/{vdso32 => vdso}/cacheflush.S (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/datapage.S (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/gen_vdso32_offsets.sh (100%) rename arch/powerpc/kernel/{vdso64/gen_vdso_offsets.sh => vdso/gen_vdso64_offsets.sh} (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/getcpu.S (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/gettimeofday.S (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/note.S (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/sigtramp32.S (100%) rename arch/powerpc/kernel/{vdso64/sigtramp.S => vdso/sigtramp64.S} (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/vdso32.lds.S (100%) rename arch/powerpc/kernel/{vdso64 => vdso}/vdso64.lds.S (100%) rename arch/powerpc/kernel/{vdso32 => vdso}/vgettimeofday.c (100%) delete mode 100644 arch/powerpc/kernel/vdso32/.gitignore delete mode 100644 arch/powerpc/kernel/vdso64/Makefile delete mode 100644 arch/powerpc/kernel/vdso64/cacheflush.S delete mode 100644 arch/powerpc/kernel/vdso64/datapage.S delete mode 100644 arch/powerpc/kernel/vdso64/getcpu.S delete mode 100644 arch/powerpc/kernel/vdso64/gettimeofday.S delete mode 100644 arch/powerpc/kernel/vdso64/note.S delete mode 100644 arch/powerpc/kernel/vdso64/vgettimeofday.c diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 5f16ac1583c5..ddc5a706760a 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -421,9 +421,9 @@ ifeq ($(KBUILD_EXTMOD),) prepare: vdso_prepare vdso_prepare: prepare0 $(if $(CONFIG_VDSO32),$(Q)$(MAKE) \ - $(build)=arch/powerpc/kernel/vdso32 include/generated/vdso32-offsets.h) + $(build)=arch/powerpc/kernel/vdso include/generated/vdso32-offsets.h) $(if $(CONFIG_PPC64),$(Q)$(MAKE) \ - $(build)=arch/powerpc/kernel/vdso64 include/generated/vdso64-offsets.h) + $(build)=arch/powerpc/kernel/vdso include/generated/vdso64-offsets.h) endif archprepare: checkbin diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index 4d7829399570..4ddd161aef32 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -194,8 +194,8 @@ targets += prom_init_check clean-files := vmlinux.lds # Force dependency (incbin is bad) -$(obj)/vdso32_wrapper.o : $(obj)/vdso32/vdso32.so.dbg -$(obj)/vdso64_wrapper.o : $(obj)/vdso64/vdso64.so.dbg +$(obj)/vdso32_wrapper.o : $(obj)/vdso/vdso32.so.dbg +$(obj)/vdso64_wrapper.o : $(obj)/vdso/vdso64.so.dbg # for cleaning -subdir- += vdso32 vdso64 +subdir- += vdso diff --git a/arch/powerpc/kernel/vdso64/.gitignore b/arch/powerpc/kernel/vdso/.gitignore similarity index 72% rename from arch/powerpc/kernel/vdso64/.gitignore rename to arch/powerpc/kernel/vdso/.gitignore index 84151a7ba31d..dd9bdd67758b 100644 --- a/arch/powerpc/kernel/vdso64/.gitignore +++ b/arch/powerpc/kernel/vdso/.gitignore @@ -1,3 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only +vdso32.lds +vdso32.so.dbg vdso64.lds vdso64.so.dbg diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso/Makefile similarity index 56% rename from arch/powerpc/kernel/vdso32/Makefile rename to arch/powerpc/kernel/vdso/Makefile index 7d7b38d90ca5..954974287ee7 100644 ---
[PATCH v3 2/5] powerpc/vdso: Rework VDSO32 makefile to add a prefix to object files
In order to merge vdso32 and vdso64 build in following patch, rework Makefile is order to add -32 suffix to VDSO32 object files. Also change sigtramp.S to sigtramp32.S as VDSO64 sigtramp.S is too different to be squashed into VDSO32 sigtramp.S at the first place. gen_vdso_offsets.sh also becomes gen_vdso32_offsets.sh Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/vdso32/Makefile | 47 +-- ..._vdso_offsets.sh => gen_vdso32_offsets.sh} | 0 .../vdso32/{sigtramp.S => sigtramp32.S} | 0 3 files changed, 21 insertions(+), 26 deletions(-) rename arch/powerpc/kernel/vdso32/{gen_vdso_offsets.sh => gen_vdso32_offsets.sh} (100%) rename arch/powerpc/kernel/vdso32/{sigtramp.S => sigtramp32.S} (100%) diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso32/Makefile index 7d9a6fee0e3d..7d7b38d90ca5 100644 --- a/arch/powerpc/kernel/vdso32/Makefile +++ b/arch/powerpc/kernel/vdso32/Makefile @@ -5,15 +5,16 @@ ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN|R_PPC_REL24 include $(srctree)/lib/vdso/Makefile -obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o getcpu.o +obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o note-32.o getcpu-32.o ifneq ($(c-gettimeofday-y),) - CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y) - CFLAGS_vgettimeofday.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) - CFLAGS_vgettimeofday.o += $(call cc-option, -fno-stack-protector) - CFLAGS_vgettimeofday.o += -DDISABLE_BRANCH_PROFILING - CFLAGS_vgettimeofday.o += -ffreestanding -fasynchronous-unwind-tables - CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) + CFLAGS_vgettimeofday-32.o += -include $(c-gettimeofday-y) + CFLAGS_vgettimeofday-32.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) + CFLAGS_vgettimeofday-32.o += $(call cc-option, -fno-stack-protector) + CFLAGS_vgettimeofday-32.o += -DDISABLE_BRANCH_PROFILING + CFLAGS_vgettimeofday-32.o += -ffreestanding -fasynchronous-unwind-tables + CFLAGS_REMOVE_vgettimeofday-32.o = $(CC_FLAGS_FTRACE) + CFLAGS_REMOVE_vgettimeofday-32.o += -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc endif # Build rules @@ -24,13 +25,7 @@ else VDSOCC := $(CC) endif -CC32FLAGS := -ifdef CONFIG_PPC64 -CC32FLAGS += -m32 -KBUILD_CFLAGS := $(filter-out -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc,$(KBUILD_CFLAGS)) -endif - -targets := $(obj-vdso32) vdso32.so.dbg vgettimeofday.o +targets := $(obj-vdso32) vdso32.so.dbg vgettimeofday-32.o obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32)) GCOV_PROFILE := n @@ -38,36 +33,36 @@ KCOV_INSTRUMENT := n UBSAN_SANITIZE := n KASAN_SANITIZE := n -ccflags-y := -shared -fno-common -fno-builtin -nostdlib \ - -Wl,-soname=linux-vdso32.so.1 -Wl,--hash-style=both -asflags-y := -D__VDSO32__ -s +ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both + +CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32 +AS32FLAGS := -D__VDSO32__ -s -obj-y += vdso32_wrapper.o targets += vdso32.lds CPPFLAGS_vdso32.lds += -P -C -Upowerpc # link rule for the .so file, .lds has to be first -$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday.o FORCE +$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday-32.o FORCE $(call if_changed,vdso32ld_and_check) # assembly rules for the .S files -$(obj-vdso32): %.o: %.S FORCE +$(obj-vdso32): %-32.o: %.S FORCE $(call if_changed_dep,vdso32as) -$(obj)/vgettimeofday.o: %.o: %.c FORCE +$(obj)/vgettimeofday-32.o: %-32.o: %.c FORCE $(call if_changed_dep,vdso32cc) # Generate VDSO offsets using helper script -gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh -quiet_cmd_vdsosym = VDSOSYM $@ - cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ +gen-vdso32sym := $(srctree)/$(src)/gen_vdso32_offsets.sh +quiet_cmd_vdso32sym = VDSO32SYM $@ + cmd_vdso32sym = $(NM) $< | $(gen-vdso32sym) | LC_ALL=C sort > $@ include/generated/vdso32-offsets.h: $(obj)/vdso32.so.dbg FORCE - $(call if_changed,vdsosym) + $(call if_changed,vdso32sym) # actual build commands quiet_cmd_vdso32ld_and_check = VDSO32L $@ cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check) quiet_cmd_vdso32as = VDSO32A $@ - cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $< + cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $< quiet_cmd_vdso32cc = VDSO32C $@ cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $< diff --git a/arch/powerpc/kernel/vdso32/gen_vdso_offsets.sh b/arch/powerpc/kernel/vdso32/gen_vdso32_offsets.sh similarity index 100% rename from arch/powerpc/kernel/vdso32/gen_vdso_offsets.sh rename to
[PATCH v3 1/5] powerpc/vdso: augment VDSO32 functions to support 64 bits build
VDSO64 cacheflush.S datapage.S gettimeofday.S and vgettimeofday.c are very similar to their VDSO32 counterpart. VDSO32 counterpart is already more complete than the VDSO64 version as it supports both PPC32 vdso and 32 bits VDSO for PPC64. Use compat macros wherever necessary in PPC32 files so that they can also be used to build VDSO64. vdso64/note.S is already a link to vdso32/note.S so no change is required. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/asm-compat.h | 2 ++ arch/powerpc/kernel/vdso32/cacheflush.S| 4 ++-- arch/powerpc/kernel/vdso32/datapage.S | 10 -- arch/powerpc/kernel/vdso32/getcpu.S| 4 ++-- arch/powerpc/kernel/vdso32/gettimeofday.S | 8 ++-- arch/powerpc/kernel/vdso32/vgettimeofday.c | 23 ++ 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/include/asm/asm-compat.h b/arch/powerpc/include/asm/asm-compat.h index 2b736d9fbb1b..2bc53c646ccd 100644 --- a/arch/powerpc/include/asm/asm-compat.h +++ b/arch/powerpc/include/asm/asm-compat.h @@ -21,6 +21,7 @@ #define PPC_STLCX stringify_in_c(stdcx.) #define PPC_CNTLZL stringify_in_c(cntlzd) #define PPC_MTOCRF(FXM, RS) MTOCRF((FXM), RS) +#define PPC_SRLstringify_in_c(srd) #define PPC_LR_STKOFF 16 #define PPC_MIN_STKFRM 112 @@ -54,6 +55,7 @@ #define PPC_STLCX stringify_in_c(stwcx.) #define PPC_CNTLZL stringify_in_c(cntlzw) #define PPC_MTOCRF stringify_in_c(mtcrf) +#define PPC_SRLstringify_in_c(srw) #define PPC_LR_STKOFF 4 #define PPC_MIN_STKFRM 16 diff --git a/arch/powerpc/kernel/vdso32/cacheflush.S b/arch/powerpc/kernel/vdso32/cacheflush.S index f340e82d1981..d4e43ab2d5df 100644 --- a/arch/powerpc/kernel/vdso32/cacheflush.S +++ b/arch/powerpc/kernel/vdso32/cacheflush.S @@ -46,7 +46,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE) add r8,r8,r5/* ensure we get enough */ #ifdef CONFIG_PPC64 lwz r9,CFG_DCACHE_LOGBLOCKSZ(r10) - srw.r8,r8,r9/* compute line count */ + PPC_SRL.r8,r8,r9/* compute line count */ #else srwi. r8, r8, L1_CACHE_SHIFT mr r7, r6 @@ -72,7 +72,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE) subfr8,r6,r4/* compute length */ add r8,r8,r5 lwz r9,CFG_ICACHE_LOGBLOCKSZ(r10) - srw.r8,r8,r9/* compute line count */ + PPC_SRL.r8,r8,r9/* compute line count */ crclr cr0*4+so beqlr /* nothing to do? */ #endif diff --git a/arch/powerpc/kernel/vdso32/datapage.S b/arch/powerpc/kernel/vdso32/datapage.S index 65244416ab94..db8e167f0166 100644 --- a/arch/powerpc/kernel/vdso32/datapage.S +++ b/arch/powerpc/kernel/vdso32/datapage.S @@ -30,11 +30,15 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map) mr. r4,r3 get_datapager3 mtlrr12 +#ifdef __powerpc64__ + addir3,r3,CFG_SYSCALL_MAP64 +#else addir3,r3,CFG_SYSCALL_MAP32 +#endif + crclr cr0*4+so beqlr li r0,NR_syscalls stw r0,0(r4) - crclr cr0*4+so blr .cfi_endproc V_FUNCTION_END(__kernel_get_syscall_map) @@ -49,8 +53,10 @@ V_FUNCTION_BEGIN(__kernel_get_tbfreq) mflrr12 .cfi_register lr,r12 get_datapager3 +#ifndef __powerpc64__ lwz r4,(CFG_TB_TICKS_PER_SEC + 4)(r3) - lwz r3,CFG_TB_TICKS_PER_SEC(r3) +#endif + PPC_LL r3,CFG_TB_TICKS_PER_SEC(r3) mtlrr12 crclr cr0*4+so blr diff --git a/arch/powerpc/kernel/vdso32/getcpu.S b/arch/powerpc/kernel/vdso32/getcpu.S index ff5e214fec41..8e08ccf19062 100644 --- a/arch/powerpc/kernel/vdso32/getcpu.S +++ b/arch/powerpc/kernel/vdso32/getcpu.S @@ -19,8 +19,8 @@ V_FUNCTION_BEGIN(__kernel_getcpu) .cfi_startproc mfspr r5,SPRN_SPRG_VDSO_READ - cmpwi cr0,r3,0 - cmpwi cr1,r4,0 + PPC_LCMPI cr0,r3,0 + PPC_LCMPI cr1,r4,0 clrlwi r6,r5,16 rlwinm r7,r5,16,31-15,31-0 beq cr0,1f diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S index d21d08140a5e..c875312274aa 100644 --- a/arch/powerpc/kernel/vdso32/gettimeofday.S +++ b/arch/powerpc/kernel/vdso32/gettimeofday.S @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ /* - * Userland implementation of gettimeofday() for 32 bits processes in a - * ppc64 kernel for use in the vDSO + * Userland implementation of gettimeofday() for processes + * for use in the vDSO * * Copyright (C) 2004 Benjamin Herrenschmuidt (b...@kernel.crashing.org, *IBM Corp. @@ -41,9 +41,11 @@ V_FUNCTION_END(__kernel_clock_gettime) * int __kernel_clock_gettime64(clockid_t clock_id, struct __timespec64 *ts); * */ +#ifndef __powerpc64__
Re: [PATCH V3 08/17] riscv: compat: syscall: Add compat_sys_call_table implementation
On Fri, Jan 21, 2022 at 4:57 PM Arnd Bergmann wrote: > > On Fri, Jan 21, 2022 at 7:25 AM Guo Ren wrote: > > On Thu, Jan 20, 2022 at 10:43 PM Arnd Bergmann wrote: > > > On Thu, Jan 20, 2022 at 8:39 AM wrote: > > > > Are you sure these are the right calling conventions? According to [1], > > > I think the 64-bit argument should be in an aligned pair of registers, > > > which means you need an extra pad argument as in the arm64 version > > > of these functions. Same for ftruncate64, pread64, pwrite64, and > > > readahead. > > > > [1] has abandoned. > > > > See: > > https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc > > Ok, thanks for the reference, I picked the first one that came up in > a google search and didn't expect this to ever have changed. > > > > I still feel like these should be the common implementations next to the > > > native handlers inside of an #ifdef CONFIG_COMPAT. > > > > > > The names clash with the custom versions defined for powerpc and sparc, > > > but the duplicates look compatible if you can account for the padded > > > argument and the lo/hi order of the pairs, so could just be removed here > > > (all other architectures use custom function names instead). > > I would try it later. > > This becomes easier then, as powerpc and sparc already have the non-padded > calling conventions, so you could just generalize those without looking at > the other architectures or adding the padding. The powerpc version already > has the dual-endian version, so using that will work on big-endian sparc and > on little-endian riscv as well, though we may need to come up with a better > name > for the arg_u32/arg_u64/merge_64 macros in order to put that into a global > header without namespace collisions. Sounds good, thanks! > > Arnd -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/
Re: [PATCH v7 1/7] powerpc/pmem: Restrict papr_scm to P8 and above.
Michal Suchánek writes: > Hello, > > On Wed, Jul 01, 2020 at 12:52:29PM +0530, Aneesh Kumar K.V wrote: >> The PAPR based virtualized persistent memory devices are only supported on >> POWER9 and above. In the followup patch, the kernel will switch the >> persistent >> memory cache flush functions to use a new `dcbf` variant instruction. The new >> instructions even though added in ISA 3.1 works even on P8 and P9 because >> these >> are implemented as a variant of existing `dcbf` and `hwsync` and on P8 and >> P9 behaves as such. >> >> Considering these devices are only supported on P8 and above, update the >> driver >> to prevent a P7-compat guest from using persistent memory devices. >> >> We don't update of_pmem driver with the same condition, because, on >> bare-metal, >> the firmware enables pmem support only on P9 and above. There the kernel >> depends >> on OPAL firmware to restrict exposing persistent memory related device tree >> entries on older hardware. of_pmem.ko is written without any arch dependency >> and >> we don't want to add ppc64 specific cpu feature check in of_pmem driver. >> >> Signed-off-by: Aneesh Kumar K.V >> --- >> arch/powerpc/platforms/pseries/pmem.c | 6 ++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/arch/powerpc/platforms/pseries/pmem.c >> b/arch/powerpc/platforms/pseries/pmem.c >> index f860a897a9e0..2347e1038f58 100644 >> --- a/arch/powerpc/platforms/pseries/pmem.c >> +++ b/arch/powerpc/platforms/pseries/pmem.c >> @@ -147,6 +147,12 @@ const struct of_device_id drc_pmem_match[] = { >> >> static int pseries_pmem_init(void) >> { >> +/* >> + * Only supported on POWER8 and above. >> + */ >> +if (!cpu_has_feature(CPU_FTR_ARCH_207S)) >> +return 0; >> + > > This looks superfluous. > > The hypervisor is responsible for publishing the pmem in devicetree when > present, kernel is responsible for using it when supported by the > kernel. > > Or is there a problem that the flush instruction is not available in P7 > compat mode? We want to avoid the usage of persistent memory on p7 compat mode because such a guest can LPM migrate to p7 systems. Now ideally I would expect hypervisor to avoid such migration, that is a p7 compat mode guest running on p10 using persistence memory migrating to p7 (considering p7 never really had support for persistent memory). There was also the complexity w.r.t what instructions the userspace will use. So it was discussed at that point that we could comfortably state and prevent the usage of persistent memory on p7 and below. > > Even then volatile regions should still work. That is a different problem altogether. We could really kill the usage of cache flush w.r.t volatile regions from the nvdimm driver right? For all these reason, disabling pmem on p7 was found to be the simplest solution. -aneesh
[PATCH v3] powerpc: dts: t1040rdb: fix ports names for Seville Ethernet switch
On board rev A, the network interface labels for the switch ports written on the front panel are different than on rev B and later. This patch fixes network interface names for the switch ports according to labels that are written on the front panel of the board rev B. They start from ETH3 and end at ETH10. This patch also introduces a separate device tree for rev A. The main device tree is supposed to cover rev B and later. Fixes: e69eb0824d8c ("powerpc: dts: t1040rdb: add ports for Seville Ethernet switch") Signed-off-by: Maxim Kiselev Reviewed-by: Maxim Kochetkov Reviewed-by: Vladimir Oltean --- Here is the fix for the error in t1040rdb-rev-a.dts caused by containing '#include' directive inside '/include/' --- arch/powerpc/boot/dts/fsl/t1040rdb-rev-a.dts | 30 arch/powerpc/boot/dts/fsl/t1040rdb.dts | 8 +++--- 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 arch/powerpc/boot/dts/fsl/t1040rdb-rev-a.dts diff --git a/arch/powerpc/boot/dts/fsl/t1040rdb-rev-a.dts b/arch/powerpc/boot/dts/fsl/t1040rdb-rev-a.dts new file mode 100644 index 0..73f8c998c64df --- /dev/null +++ b/arch/powerpc/boot/dts/fsl/t1040rdb-rev-a.dts @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * T1040RDB-REV-A Device Tree Source + * + * Copyright 2014 - 2015 Freescale Semiconductor Inc. + * + */ + +#include "t1040rdb.dts" + +/ { + model = "fsl,T1040RDB-REV-A"; + compatible = "fsl,T1040RDB-REV-A"; +}; + +_port0 { + label = "ETH5"; +}; + +_port2 { + label = "ETH7"; +}; + +_port4 { + label = "ETH9"; +}; + +_port6 { + label = "ETH11"; +}; diff --git a/arch/powerpc/boot/dts/fsl/t1040rdb.dts b/arch/powerpc/boot/dts/fsl/t1040rdb.dts index af0c8a6f56138..b6733e7e65805 100644 --- a/arch/powerpc/boot/dts/fsl/t1040rdb.dts +++ b/arch/powerpc/boot/dts/fsl/t1040rdb.dts @@ -119,7 +119,7 @@ _port0 { managed = "in-band-status"; phy-handle = <_qsgmii_0>; phy-mode = "qsgmii"; - label = "ETH5"; + label = "ETH3"; status = "okay"; }; @@ -135,7 +135,7 @@ _port2 { managed = "in-band-status"; phy-handle = <_qsgmii_2>; phy-mode = "qsgmii"; - label = "ETH7"; + label = "ETH5"; status = "okay"; }; @@ -151,7 +151,7 @@ _port4 { managed = "in-band-status"; phy-handle = <_qsgmii_4>; phy-mode = "qsgmii"; - label = "ETH9"; + label = "ETH7"; status = "okay"; }; @@ -167,7 +167,7 @@ _port6 { managed = "in-band-status"; phy-handle = <_qsgmii_6>; phy-mode = "qsgmii"; - label = "ETH11"; + label = "ETH9"; status = "okay"; }; -- 2.32.0
Re: [PATCH v7 3/7] powerpc/pmem: Add flush routines using new pmem store and sync instruction
Christophe Leroy writes: > Le 01/07/2020 à 09:22, Aneesh Kumar K.V a écrit : >> Start using dcbstps; phwsync; sequence for flushing persistent memory range. >> The new instructions are implemented as a variant of dcbf and hwsync and on >> P8 and P9 they will be executed as those instructions. We avoid using them on >> older hardware. This helps to avoid difficult to debug bugs. >> > > Before this patch, the flush was done for all. > After this patch, IIUC the flush is done only on CPUs having feature > CPU_FTR_ARCH_207S. > > What about other CPUs ? > > I don't know much about PMEM, my concern is about the UACCESS_FLUSHCACHE > API introduced by commit 6c44741d75a2 ("powerpc/lib: Implement > UACCESS_FLUSHCACHE API") > > After your patch, __copy_from_user_flushcache() and memcpy_flushcache() > are not doing cache flush anymore. > > Is that intended ? yes, with the understanding that these functions are used with persistent memory . We restrict the persistent memory usage to p8 and above via commit c83040192f3763b243ece26073d61a895b4a230f > > I'm trying to optimise some ALSA driver that does copy_from_user + > cache_flush for DMA, and I was wondering if using > __copy_from_user_flushcache() was an alternative. > > Or is it __copy_from_user_inatomic_nocache() which has to be done for that ? > > Thanks > Christophe > > >> Signed-off-by: Aneesh Kumar K.V >> --- >> arch/powerpc/include/asm/cacheflush.h | 1 + >> arch/powerpc/lib/pmem.c | 50 --- >> 2 files changed, 47 insertions(+), 4 deletions(-) >> >> diff --git a/arch/powerpc/include/asm/cacheflush.h >> b/arch/powerpc/include/asm/cacheflush.h >> index de600b915a3c..54764c6e922d 100644 >> --- a/arch/powerpc/include/asm/cacheflush.h >> +++ b/arch/powerpc/include/asm/cacheflush.h >> @@ -6,6 +6,7 @@ >> >> #include >> #include >> +#include >> >> #ifdef CONFIG_PPC_BOOK3S_64 >> /* >> diff --git a/arch/powerpc/lib/pmem.c b/arch/powerpc/lib/pmem.c >> index 0666a8d29596..5a61aaeb6930 100644 >> --- a/arch/powerpc/lib/pmem.c >> +++ b/arch/powerpc/lib/pmem.c >> @@ -9,20 +9,62 @@ >> >> #include >> >> +static inline void __clean_pmem_range(unsigned long start, unsigned long >> stop) >> +{ >> +unsigned long shift = l1_dcache_shift(); >> +unsigned long bytes = l1_dcache_bytes(); >> +void *addr = (void *)(start & ~(bytes - 1)); >> +unsigned long size = stop - (unsigned long)addr + (bytes - 1); >> +unsigned long i; >> + >> +for (i = 0; i < size >> shift; i++, addr += bytes) >> +asm volatile(PPC_DCBSTPS(%0, %1): :"i"(0), "r"(addr): "memory"); >> + >> + >> +asm volatile(PPC_PHWSYNC ::: "memory"); >> +} >> + >> +static inline void __flush_pmem_range(unsigned long start, unsigned long >> stop) >> +{ >> +unsigned long shift = l1_dcache_shift(); >> +unsigned long bytes = l1_dcache_bytes(); >> +void *addr = (void *)(start & ~(bytes - 1)); >> +unsigned long size = stop - (unsigned long)addr + (bytes - 1); >> +unsigned long i; >> + >> +for (i = 0; i < size >> shift; i++, addr += bytes) >> +asm volatile(PPC_DCBFPS(%0, %1): :"i"(0), "r"(addr): "memory"); >> + >> + >> +asm volatile(PPC_PHWSYNC ::: "memory"); >> +} >> + >> +static inline void clean_pmem_range(unsigned long start, unsigned long stop) >> +{ >> +if (cpu_has_feature(CPU_FTR_ARCH_207S)) >> +return __clean_pmem_range(start, stop); >> +} >> + >> +static inline void flush_pmem_range(unsigned long start, unsigned long stop) >> +{ >> +if (cpu_has_feature(CPU_FTR_ARCH_207S)) >> +return __flush_pmem_range(start, stop); >> +} >> + >> /* >>* CONFIG_ARCH_HAS_PMEM_API symbols >>*/ >> void arch_wb_cache_pmem(void *addr, size_t size) >> { >> unsigned long start = (unsigned long) addr; >> -flush_dcache_range(start, start + size); >> +clean_pmem_range(start, start + size); >> } >> EXPORT_SYMBOL_GPL(arch_wb_cache_pmem); >> >> void arch_invalidate_pmem(void *addr, size_t size) >> { >> unsigned long start = (unsigned long) addr; >> -flush_dcache_range(start, start + size); >> +flush_pmem_range(start, start + size); >> } >> EXPORT_SYMBOL_GPL(arch_invalidate_pmem); >> >> @@ -35,7 +77,7 @@ long __copy_from_user_flushcache(void *dest, const void >> __user *src, >> unsigned long copied, start = (unsigned long) dest; >> >> copied = __copy_from_user(dest, src, size); >> -flush_dcache_range(start, start + size); >> +clean_pmem_range(start, start + size); >> >> return copied; >> } >> @@ -45,7 +87,7 @@ void *memcpy_flushcache(void *dest, const void *src, >> size_t size) >> unsigned long start = (unsigned long) dest; >> >> memcpy(dest, src, size); >> -flush_dcache_range(start, start + size); >> +clean_pmem_range(start, start + size); >> >> return dest; >> }
Re: [PATCH V3 08/17] riscv: compat: syscall: Add compat_sys_call_table implementation
On Fri, Jan 21, 2022 at 7:25 AM Guo Ren wrote: > On Thu, Jan 20, 2022 at 10:43 PM Arnd Bergmann wrote: > > On Thu, Jan 20, 2022 at 8:39 AM wrote: > > Are you sure these are the right calling conventions? According to [1], > > I think the 64-bit argument should be in an aligned pair of registers, > > which means you need an extra pad argument as in the arm64 version > > of these functions. Same for ftruncate64, pread64, pwrite64, and > > readahead. > > [1] has abandoned. > > See: > https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc Ok, thanks for the reference, I picked the first one that came up in a google search and didn't expect this to ever have changed. > > I still feel like these should be the common implementations next to the > > native handlers inside of an #ifdef CONFIG_COMPAT. > > > > The names clash with the custom versions defined for powerpc and sparc, > > but the duplicates look compatible if you can account for the padded > > argument and the lo/hi order of the pairs, so could just be removed here > > (all other architectures use custom function names instead). > I would try it later. This becomes easier then, as powerpc and sparc already have the non-padded calling conventions, so you could just generalize those without looking at the other architectures or adding the padding. The powerpc version already has the dual-endian version, so using that will work on big-endian sparc and on little-endian riscv as well, though we may need to come up with a better name for the arg_u32/arg_u64/merge_64 macros in order to put that into a global header without namespace collisions. Arnd
[PATCH v7 14/14] powerpc: Simplify and move arch_randomize_brk()
arch_randomize_brk() is only needed for hash on book3s/64, for other platforms the one provided by the default mmap layout is good enough. Move it to hash_utils.c and use randomize_page() like the generic one. And properly opt out the radix case instead of making an assumption on mmu_highuser_ssize. Also change to a 32M range like most other architectures instead of 8M. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/process.c | 41 --- arch/powerpc/mm/book3s64/hash_utils.c | 19 + 2 files changed, 19 insertions(+), 41 deletions(-) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 984813a4d5dc..e7f809bdd433 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -34,10 +34,8 @@ #include #include #include -#include #include #include -#include #include #include @@ -2313,42 +2311,3 @@ unsigned long arch_align_stack(unsigned long sp) sp -= get_random_int() & ~PAGE_MASK; return sp & ~0xf; } - -static inline unsigned long brk_rnd(void) -{ -unsigned long rnd = 0; - - /* 8MB for 32bit, 1GB for 64bit */ - if (is_32bit_task()) - rnd = (get_random_long() % (1UL<<(23-PAGE_SHIFT))); - else - rnd = (get_random_long() % (1UL<<(30-PAGE_SHIFT))); - - return rnd << PAGE_SHIFT; -} - -unsigned long arch_randomize_brk(struct mm_struct *mm) -{ - unsigned long base = mm->brk; - unsigned long ret; - -#ifdef CONFIG_PPC_BOOK3S_64 - /* -* If we are using 1TB segments and we are allowed to randomise -* the heap, we can put it above 1TB so it is backed by a 1TB -* segment. Otherwise the heap will be in the bottom 1TB -* which always uses 256MB segments and this may result in a -* performance penalty. -*/ - if (!radix_enabled() && !is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T)) - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T); -#endif - - ret = PAGE_ALIGN(base + brk_rnd()); - - if (ret < mm->brk) - return mm->brk; - - return ret; -} - diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c index 154a5a860959..d28003132a51 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include @@ -2171,3 +2173,20 @@ void __init print_system_hash_info(void) if (htab_hash_mask) pr_info("htab_hash_mask= 0x%lx\n", htab_hash_mask); } + +unsigned long arch_randomize_brk(struct mm_struct *mm) +{ + /* +* If we are using 1TB segments and we are allowed to randomise +* the heap, we can put it above 1TB so it is backed by a 1TB +* segment. Otherwise the heap will be in the bottom 1TB +* which always uses 256MB segments and this may result in a +* performance penalty. +*/ + if (is_32bit_task()) + return randomize_page(mm->brk, SZ_32M); + else if (!radix_enabled() && mmu_highuser_ssize == MMU_SEGSIZE_1T) + return randomize_page(max_t(unsigned long, mm->brk, SZ_1T), SZ_1G); + else + return randomize_page(mm->brk, SZ_1G); +} -- 2.33.1
[PATCH v7 13/14] powerpc/mm: Convert to default topdown mmap layout
Select CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT and remove arch/powerpc/mm/mmap.c This change reuses the generic framework added by commit 67f3977f805b ("arm64, mm: move generic mmap layout functions to mm") without any functional change. Comparison between powerpc implementation and the generic one: - mmap_is_legacy() is identical. - arch_mmap_rnd() does exactly the same allthough it's written slightly differently. - MIN_GAP and MAX_GAP are identical. - mmap_base() does the same but uses STACK_RND_MASK which provides the same values as stack_maxrandom_size(). - arch_pick_mmap_layout() is identical. Signed-off-by: Christophe Leroy --- arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/processor.h | 2 - arch/powerpc/mm/Makefile | 2 +- arch/powerpc/mm/mmap.c | 105 --- 4 files changed, 2 insertions(+), 109 deletions(-) delete mode 100644 arch/powerpc/mm/mmap.c diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 0631c9241af3..b4ae3d8bde46 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -122,7 +122,6 @@ config PPC select ARCH_HAS_DEBUG_WXif STRICT_KERNEL_RWX select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_DMA_MAP_DIRECT if PPC_PSERIES - select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_HUGEPD if HUGETLB_PAGE @@ -158,6 +157,7 @@ config PPC select ARCH_USE_MEMTEST select ARCH_USE_QUEUED_RWLOCKS if PPC_QUEUED_SPINLOCKS select ARCH_USE_QUEUED_SPINLOCKSif PPC_QUEUED_SPINLOCKS + select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT select ARCH_WANT_IPC_PARSE_VERSION select ARCH_WANT_IRQS_OFF_ACTIVATE_MM select ARCH_WANT_LD_ORPHAN_WARN diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h index 2c8686d9e964..873adaab20c8 100644 --- a/arch/powerpc/include/asm/processor.h +++ b/arch/powerpc/include/asm/processor.h @@ -392,8 +392,6 @@ static inline void prefetchw(const void *x) #define spin_lock_prefetch(x) prefetchw(x) -#define HAVE_ARCH_PICK_MMAP_LAYOUT - /* asm stubs */ extern unsigned long isa300_idle_stop_noloss(unsigned long psscr_val); extern unsigned long isa300_idle_stop_mayloss(unsigned long psscr_val); diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile index d4c20484dad9..503a6e249940 100644 --- a/arch/powerpc/mm/Makefile +++ b/arch/powerpc/mm/Makefile @@ -5,7 +5,7 @@ ccflags-$(CONFIG_PPC64):= $(NO_MINIMAL_TOC) -obj-y := fault.o mem.o pgtable.o mmap.o maccess.o pageattr.o \ +obj-y := fault.o mem.o pgtable.o maccess.o pageattr.o \ init_$(BITS).o pgtable_$(BITS).o \ pgtable-frag.o ioremap.o ioremap_$(BITS).o \ init-common.o mmu_context.o drmem.o \ diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c deleted file mode 100644 index d9eae456558a.. --- a/arch/powerpc/mm/mmap.c +++ /dev/null @@ -1,105 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * flexible mmap layout support - * - * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina. - * All Rights Reserved. - * - * Started by Ingo Molnar - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Top of mmap area (just below the process stack). - * - * Leave at least a ~128 MB hole. - */ -#define MIN_GAP (128*1024*1024) -#define MAX_GAP (TASK_SIZE/6*5) - -static inline int mmap_is_legacy(struct rlimit *rlim_stack) -{ - if (current->personality & ADDR_COMPAT_LAYOUT) - return 1; - - if (rlim_stack->rlim_cur == RLIM_INFINITY) - return 1; - - return sysctl_legacy_va_layout; -} - -unsigned long arch_mmap_rnd(void) -{ - unsigned long shift, rnd; - - shift = mmap_rnd_bits; -#ifdef CONFIG_COMPAT - if (is_32bit_task()) - shift = mmap_rnd_compat_bits; -#endif - rnd = get_random_long() % (1ul << shift); - - return rnd << PAGE_SHIFT; -} - -static inline unsigned long stack_maxrandom_size(void) -{ - if (!(current->flags & PF_RANDOMIZE)) - return 0; - - /* 8MB for 32bit, 1GB for 64bit */ - if (is_32bit_task()) - return (1<<23); - else - return (1<<30); -} - -static inline unsigned long mmap_base(unsigned long rnd, - struct rlimit *rlim_stack) -{ - unsigned long gap = rlim_stack->rlim_cur; - unsigned long pad = stack_maxrandom_size() + stack_guard_gap; - - /* Values close to RLIM_INFINITY can overflow. */ - if (gap + pad > gap) - gap += pad; - - if (gap < MIN_GAP) - gap = MIN_GAP; - else
[PATCH v7 12/14] powerpc/mm: Enable full randomisation of memory mappings
Do like most other architectures and provide randomisation also to "legacy" memory mappings, by adding the random factor to mm->mmap_base in arch_pick_mmap_layout(). See commit 8b8addf891de ("x86/mm/32: Enable full randomization on i386 and X86_32") for all explanations and benefits of that mmap randomisation. At the moment, slice_find_area_bottomup() doesn't use mm->mmap_base but uses the fixed TASK_UNMAPPED_BASE instead. slice_find_area_bottomup() being used as a fallback to slice_find_area_topdown(), it can't use mm->mmap_base directly. Instead of always using TASK_UNMAPPED_BASE as base address, leave it to the caller. When called from slice_find_area_topdown() TASK_UNMAPPED_BASE is used. Otherwise mm->mmap_base is used. Signed-off-by: Christophe Leroy --- arch/powerpc/mm/book3s64/slice.c | 18 +++--- arch/powerpc/mm/mmap.c | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/mm/book3s64/slice.c b/arch/powerpc/mm/book3s64/slice.c index 03681042b807..c0b58afb9a47 100644 --- a/arch/powerpc/mm/book3s64/slice.c +++ b/arch/powerpc/mm/book3s64/slice.c @@ -276,20 +276,18 @@ static bool slice_scan_available(unsigned long addr, } static unsigned long slice_find_area_bottomup(struct mm_struct *mm, - unsigned long len, + unsigned long addr, unsigned long len, const struct slice_mask *available, int psize, unsigned long high_limit) { int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT); - unsigned long addr, found, next_end; + unsigned long found, next_end; struct vm_unmapped_area_info info; info.flags = 0; info.length = len; info.align_mask = PAGE_MASK & ((1ul << pshift) - 1); info.align_offset = 0; - - addr = TASK_UNMAPPED_BASE; /* * Check till the allow max value for this mmap request */ @@ -322,12 +320,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm, } static unsigned long slice_find_area_topdown(struct mm_struct *mm, -unsigned long len, +unsigned long addr, unsigned long len, const struct slice_mask *available, int psize, unsigned long high_limit) { int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT); - unsigned long addr, found, prev; + unsigned long found, prev; struct vm_unmapped_area_info info; unsigned long min_addr = max(PAGE_SIZE, mmap_min_addr); @@ -335,8 +333,6 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm, info.length = len; info.align_mask = PAGE_MASK & ((1ul << pshift) - 1); info.align_offset = 0; - - addr = mm->mmap_base; /* * If we are trying to allocate above DEFAULT_MAP_WINDOW * Add the different to the mmap_base. @@ -377,7 +373,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm, * can happen with large stack limits and large mmap() * allocations. */ - return slice_find_area_bottomup(mm, len, available, psize, high_limit); + return slice_find_area_bottomup(mm, TASK_UNMAPPED_BASE, len, available, psize, high_limit); } @@ -386,9 +382,9 @@ static unsigned long slice_find_area(struct mm_struct *mm, unsigned long len, int topdown, unsigned long high_limit) { if (topdown) - return slice_find_area_topdown(mm, len, mask, psize, high_limit); + return slice_find_area_topdown(mm, mm->mmap_base, len, mask, psize, high_limit); else - return slice_find_area_bottomup(mm, len, mask, psize, high_limit); + return slice_find_area_bottomup(mm, mm->mmap_base, len, mask, psize, high_limit); } static inline void slice_copy_mask(struct slice_mask *dst, diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c index 5972d619d274..d9eae456558a 100644 --- a/arch/powerpc/mm/mmap.c +++ b/arch/powerpc/mm/mmap.c @@ -96,7 +96,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) * bit is set, or if the expected stack growth is unlimited: */ if (mmap_is_legacy(rlim_stack)) { - mm->mmap_base = TASK_UNMAPPED_BASE; + mm->mmap_base = TASK_UNMAPPED_BASE + random_factor; mm->get_unmapped_area = arch_get_unmapped_area; } else { mm->mmap_base = mmap_base(random_factor, rlim_stack); -- 2.33.1
[PATCH v7 11/14] powerpc/mm: Move get_unmapped_area functions to slice.c
hugetlb_get_unmapped_area() is now identical to the generic version if only RADIX is enabled, so move it to slice.c and let it fallback on the generic one when HASH MMU is not compiled in. Do the same with arch_get_unmapped_area() and arch_get_unmapped_area_topdown(). Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/book3s/64/mmu.h | 6 arch/powerpc/include/asm/book3s/64/slice.h | 6 arch/powerpc/mm/book3s64/slice.c | 42 ++ arch/powerpc/mm/hugetlbpage.c | 21 --- arch/powerpc/mm/mmap.c | 36 --- 5 files changed, 48 insertions(+), 63 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h index ba5b1becf518..db47524fa8ea 100644 --- a/arch/powerpc/include/asm/book3s/64/mmu.h +++ b/arch/powerpc/include/asm/book3s/64/mmu.h @@ -4,12 +4,6 @@ #include -#ifdef CONFIG_HUGETLB_PAGE -#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA -#endif -#define HAVE_ARCH_UNMAPPED_AREA -#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN - #ifndef __ASSEMBLY__ /* * Page size definition diff --git a/arch/powerpc/include/asm/book3s/64/slice.h b/arch/powerpc/include/asm/book3s/64/slice.h index 5b0f7105bc8b..b8eb4ad271b9 100644 --- a/arch/powerpc/include/asm/book3s/64/slice.h +++ b/arch/powerpc/include/asm/book3s/64/slice.h @@ -4,6 +4,12 @@ #ifndef __ASSEMBLY__ +#ifdef CONFIG_HUGETLB_PAGE +#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA +#endif +#define HAVE_ARCH_UNMAPPED_AREA +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN + #define SLICE_LOW_SHIFT28 #define SLICE_LOW_TOP (0x1ul) #define SLICE_NUM_LOW (SLICE_LOW_TOP >> SLICE_LOW_SHIFT) diff --git a/arch/powerpc/mm/book3s64/slice.c b/arch/powerpc/mm/book3s64/slice.c index e4382713746d..03681042b807 100644 --- a/arch/powerpc/mm/book3s64/slice.c +++ b/arch/powerpc/mm/book3s64/slice.c @@ -639,6 +639,32 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, } EXPORT_SYMBOL_GPL(slice_get_unmapped_area); +unsigned long arch_get_unmapped_area(struct file *filp, +unsigned long addr, +unsigned long len, +unsigned long pgoff, +unsigned long flags) +{ + if (radix_enabled()) + return generic_get_unmapped_area(filp, addr, len, pgoff, flags); + + return slice_get_unmapped_area(addr, len, flags, + mm_ctx_user_psize(>mm->context), 0); +} + +unsigned long arch_get_unmapped_area_topdown(struct file *filp, +const unsigned long addr0, +const unsigned long len, +const unsigned long pgoff, +const unsigned long flags) +{ + if (radix_enabled()) + return generic_get_unmapped_area_topdown(filp, addr0, len, pgoff, flags); + + return slice_get_unmapped_area(addr0, len, flags, + mm_ctx_user_psize(>mm->context), 1); +} + unsigned int notrace get_slice_psize(struct mm_struct *mm, unsigned long addr) { unsigned char *psizes; @@ -766,4 +792,20 @@ unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) return 1UL << mmu_psize_to_shift(get_slice_psize(vma->vm_mm, vma->vm_start)); } + +static int file_to_psize(struct file *file) +{ + struct hstate *hstate = hstate_file(file); + return shift_to_mmu_psize(huge_page_shift(hstate)); +} + +unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + if (radix_enabled()) + return generic_hugetlb_get_unmapped_area(file, addr, len, pgoff, flags); + + return slice_get_unmapped_area(addr, len, flags, file_to_psize(file), 1); +} #endif diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index bfd7f4af1e58..eb9de09e49a3 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -542,27 +542,6 @@ struct page *follow_huge_pd(struct vm_area_struct *vma, return page; } -#ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA -static inline int file_to_psize(struct file *file) -{ - struct hstate *hstate = hstate_file(file); - return shift_to_mmu_psize(huge_page_shift(hstate)); -} - -unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags) -{ - if (radix_enabled()) - return generic_hugetlb_get_unmapped_area(file, addr, len, -
[PATCH v7 05/14] sizes.h: Add SZ_1T macro
Today drivers/pci/controller/pci-xgene.c defines SZ_1T Move it into linux/sizes.h so that it can be re-used elsewhere. Cc: Toan Le Cc: linux-...@vger.kernel.org Signed-off-by: Christophe Leroy Reviewed-by: Krzysztof Wilczyński Acked-by: Bjorn Helgaas --- drivers/pci/controller/pci-xgene.c | 1 - include/linux/sizes.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c index 56d0d50338c8..716dcab5ca47 100644 --- a/drivers/pci/controller/pci-xgene.c +++ b/drivers/pci/controller/pci-xgene.c @@ -49,7 +49,6 @@ #define EN_REG 0x0001 #define OB_LO_IO 0x0002 #define XGENE_PCIE_DEVICEID0xE004 -#define SZ_1T (SZ_1G*1024ULL) #define PIPE_PHY_RATE_RD(src) ((0xc000 & (u32)(src)) >> 0xe) #define XGENE_V1_PCI_EXP_CAP 0x40 diff --git a/include/linux/sizes.h b/include/linux/sizes.h index 1ac79bcee2bb..84aa448d8bb3 100644 --- a/include/linux/sizes.h +++ b/include/linux/sizes.h @@ -47,6 +47,8 @@ #define SZ_8G _AC(0x2, ULL) #define SZ_16G _AC(0x4, ULL) #define SZ_32G _AC(0x8, ULL) + +#define SZ_1T _AC(0x100, ULL) #define SZ_64T _AC(0x4000, ULL) #endif /* __LINUX_SIZES_H__ */ -- 2.33.1
[PATCH v7 10/14] powerpc/mm: Use generic_hugetlb_get_unmapped_area()
Use the generic version of arch_hugetlb_get_unmapped_area() which is now available at all time. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/book3s/64/hugetlb.h | 4 -- arch/powerpc/mm/book3s64/radix_hugetlbpage.c | 55 arch/powerpc/mm/hugetlbpage.c| 4 +- 3 files changed, 1 insertion(+), 62 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/hugetlb.h b/arch/powerpc/include/asm/book3s/64/hugetlb.h index 12e150e615b7..b37a28f62cf6 100644 --- a/arch/powerpc/include/asm/book3s/64/hugetlb.h +++ b/arch/powerpc/include/asm/book3s/64/hugetlb.h @@ -8,10 +8,6 @@ */ void radix__flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr); void radix__local_flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr); -extern unsigned long -radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags); extern void radix__huge_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, diff --git a/arch/powerpc/mm/book3s64/radix_hugetlbpage.c b/arch/powerpc/mm/book3s64/radix_hugetlbpage.c index 23d3e08911d3..d2fb776febb4 100644 --- a/arch/powerpc/mm/book3s64/radix_hugetlbpage.c +++ b/arch/powerpc/mm/book3s64/radix_hugetlbpage.c @@ -41,61 +41,6 @@ void radix__flush_hugetlb_tlb_range(struct vm_area_struct *vma, unsigned long st radix__flush_tlb_range_psize(vma->vm_mm, start, end, psize); } -/* - * A vairant of hugetlb_get_unmapped_area doing topdown search - * FIXME!! should we do as x86 does or non hugetlb area does ? - * ie, use topdown or not based on mmap_is_legacy check ? - */ -unsigned long -radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags) -{ - struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; - struct hstate *h = hstate_file(file); - int fixed = (flags & MAP_FIXED); - unsigned long high_limit; - struct vm_unmapped_area_info info; - - high_limit = DEFAULT_MAP_WINDOW; - if (addr >= high_limit || (fixed && (addr + len > high_limit))) - high_limit = TASK_SIZE; - - if (len & ~huge_page_mask(h)) - return -EINVAL; - if (len > high_limit) - return -ENOMEM; - - if (fixed) { - if (addr > high_limit - len) - return -ENOMEM; - if (prepare_hugepage_range(file, addr, len)) - return -EINVAL; - return addr; - } - - if (addr) { - addr = ALIGN(addr, huge_page_size(h)); - vma = find_vma(mm, addr); - if (high_limit - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vm_start_gap(vma))) - return addr; - } - /* -* We are always doing an topdown search here. Slice code -* does that too. -*/ - info.flags = VM_UNMAPPED_AREA_TOPDOWN; - info.length = len; - info.low_limit = max(PAGE_SIZE, mmap_min_addr); - info.high_limit = mm->mmap_base + (high_limit - DEFAULT_MAP_WINDOW); - info.align_mask = PAGE_MASK & ~huge_page_mask(h); - info.align_offset = 0; - - return vm_unmapped_area(); -} - void radix__huge_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t old_pte, pte_t pte) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index f18b3a1d18f0..bfd7f4af1e58 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -553,11 +553,9 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { -#ifdef CONFIG_PPC_RADIX_MMU if (radix_enabled()) - return radix__hugetlb_get_unmapped_area(file, addr, len, + return generic_hugetlb_get_unmapped_area(file, addr, len, pgoff, flags); -#endif #ifdef CONFIG_PPC_64S_HASH_MMU return slice_get_unmapped_area(addr, len, flags, file_to_psize(file), 1); #endif -- 2.33.1
[PATCH v7 09/14] powerpc/mm: Use generic_get_unmapped_area() and call it from arch_get_unmapped_area()
Use the generic version of arch_get_unmapped_area() which is now available at all time instead of its copy radix__arch_get_unmapped_area() To allow that for PPC64, add arch_get_mmap_base() and arch_get_mmap_end() macros. Instead of setting mm->get_unmapped_area() to either arch_get_unmapped_area() or generic_get_unmapped_area(), always set it to arch_get_unmapped_area() and call generic_get_unmapped_area() from there when radix is enabled. Do the same with radix__arch_get_unmapped_area_topdown() Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/task_size_64.h | 8 ++ arch/powerpc/mm/mmap.c | 127 ++-- 2 files changed, 14 insertions(+), 121 deletions(-) diff --git a/arch/powerpc/include/asm/task_size_64.h b/arch/powerpc/include/asm/task_size_64.h index 38fdf8041d12..5a709951c901 100644 --- a/arch/powerpc/include/asm/task_size_64.h +++ b/arch/powerpc/include/asm/task_size_64.h @@ -72,4 +72,12 @@ #define STACK_TOP_MAX TASK_SIZE_USER64 #define STACK_TOP (is_32bit_task() ? STACK_TOP_USER32 : STACK_TOP_USER64) +#define arch_get_mmap_base(addr, base) \ + (((addr) > DEFAULT_MAP_WINDOW) ? (base) + TASK_SIZE - DEFAULT_MAP_WINDOW : (base)) + +#define arch_get_mmap_end(addr, len, flags) \ + (((addr) > DEFAULT_MAP_WINDOW) || \ +(((flags) & MAP_FIXED) && ((addr) + (len) > DEFAULT_MAP_WINDOW)) ? TASK_SIZE : \ + DEFAULT_MAP_WINDOW) + #endif /* _ASM_POWERPC_TASK_SIZE_64_H */ diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c index 9b0d6e395bc0..46781d0103d1 100644 --- a/arch/powerpc/mm/mmap.c +++ b/arch/powerpc/mm/mmap.c @@ -81,115 +81,15 @@ static inline unsigned long mmap_base(unsigned long rnd, } #ifdef HAVE_ARCH_UNMAPPED_AREA -#ifdef CONFIG_PPC_RADIX_MMU -/* - * Same function as generic code used only for radix, because we don't need to overload - * the generic one. But we will have to duplicate, because hash select - * HAVE_ARCH_UNMAPPED_AREA - */ -static unsigned long -radix__arch_get_unmapped_area(struct file *filp, unsigned long addr, -unsigned long len, unsigned long pgoff, -unsigned long flags) -{ - struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; - int fixed = (flags & MAP_FIXED); - unsigned long high_limit; - struct vm_unmapped_area_info info; - - high_limit = DEFAULT_MAP_WINDOW; - if (addr >= high_limit || (fixed && (addr + len > high_limit))) - high_limit = TASK_SIZE; - - if (len > high_limit) - return -ENOMEM; - - if (fixed) { - if (addr > high_limit - len) - return -ENOMEM; - return addr; - } - - if (addr) { - addr = PAGE_ALIGN(addr); - vma = find_vma(mm, addr); - if (high_limit - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vm_start_gap(vma))) - return addr; - } - - info.flags = 0; - info.length = len; - info.low_limit = mm->mmap_base; - info.high_limit = high_limit; - info.align_mask = 0; - - return vm_unmapped_area(); -} - -static unsigned long -radix__arch_get_unmapped_area_topdown(struct file *filp, -const unsigned long addr0, -const unsigned long len, -const unsigned long pgoff, -const unsigned long flags) -{ - struct vm_area_struct *vma; - struct mm_struct *mm = current->mm; - unsigned long addr = addr0; - int fixed = (flags & MAP_FIXED); - unsigned long high_limit; - struct vm_unmapped_area_info info; - - high_limit = DEFAULT_MAP_WINDOW; - if (addr >= high_limit || (fixed && (addr + len > high_limit))) - high_limit = TASK_SIZE; - - if (len > high_limit) - return -ENOMEM; - - if (fixed) { - if (addr > high_limit - len) - return -ENOMEM; - return addr; - } - - if (addr) { - addr = PAGE_ALIGN(addr); - vma = find_vma(mm, addr); - if (high_limit - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vm_start_gap(vma))) - return addr; - } - - info.flags = VM_UNMAPPED_AREA_TOPDOWN; - info.length = len; - info.low_limit = max(PAGE_SIZE, mmap_min_addr); - info.high_limit = mm->mmap_base + (high_limit - DEFAULT_MAP_WINDOW); - info.align_mask = 0; - - addr = vm_unmapped_area(); - if (!(addr & ~PAGE_MASK)) - return addr; - VM_BUG_ON(addr != -ENOMEM); - - /* -* A failed mmap() very likely causes application failure, -
[PATCH v7 08/14] powerpc/mm: Remove CONFIG_PPC_MM_SLICES
CONFIG_PPC_MM_SLICES is always selected by hash book3s/64. CONFIG_PPC_MM_SLICES is never selected by other platforms. Remove it. Signed-off-by: Christophe Leroy Reviewed-by: Nicholas Piggin --- arch/powerpc/include/asm/hugetlb.h | 2 +- arch/powerpc/include/asm/paca.h| 7 --- arch/powerpc/kernel/paca.c | 5 - arch/powerpc/mm/book3s64/Makefile | 3 +-- arch/powerpc/mm/book3s64/hash_utils.c | 14 -- arch/powerpc/mm/hugetlbpage.c | 2 +- arch/powerpc/mm/mmap.c | 4 ++-- arch/powerpc/platforms/Kconfig.cputype | 4 8 files changed, 5 insertions(+), 36 deletions(-) diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h index 962708fa1017..46e0b9dc77bf 100644 --- a/arch/powerpc/include/asm/hugetlb.h +++ b/arch/powerpc/include/asm/hugetlb.h @@ -24,7 +24,7 @@ static inline int is_hugepage_only_range(struct mm_struct *mm, unsigned long addr, unsigned long len) { - if (IS_ENABLED(CONFIG_PPC_MM_SLICES) && !radix_enabled()) + if (IS_ENABLED(CONFIG_PPC_64S_HASH_MMU) && !radix_enabled()) return slice_is_hugepage_only_range(mm, addr, len); return 0; } diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h index 295573a82c66..bd4dd02e61c8 100644 --- a/arch/powerpc/include/asm/paca.h +++ b/arch/powerpc/include/asm/paca.h @@ -152,16 +152,9 @@ struct paca_struct { struct tlb_core_data tcd; #endif /* CONFIG_PPC_BOOK3E */ -#ifdef CONFIG_PPC_BOOK3S #ifdef CONFIG_PPC_64S_HASH_MMU -#ifdef CONFIG_PPC_MM_SLICES unsigned char mm_ctx_low_slices_psize[BITS_PER_LONG / BITS_PER_BYTE]; unsigned char mm_ctx_high_slices_psize[SLICE_ARRAY_SIZE]; -#else - u16 mm_ctx_user_psize; - u16 mm_ctx_sllp; -#endif -#endif #endif /* diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c index 39da688a9455..ba593fd60124 100644 --- a/arch/powerpc/kernel/paca.c +++ b/arch/powerpc/kernel/paca.c @@ -344,15 +344,10 @@ void copy_mm_to_paca(struct mm_struct *mm) { mm_context_t *context = >context; -#ifdef CONFIG_PPC_MM_SLICES VM_BUG_ON(!mm_ctx_slb_addr_limit(context)); memcpy(_paca()->mm_ctx_low_slices_psize, mm_ctx_low_slices(context), LOW_SLICE_ARRAY_SZ); memcpy(_paca()->mm_ctx_high_slices_psize, mm_ctx_high_slices(context), TASK_SLICE_ARRAY_SZ(context)); -#else /* CONFIG_PPC_MM_SLICES */ - get_paca()->mm_ctx_user_psize = context->user_psize; - get_paca()->mm_ctx_sllp = context->sllp; -#endif } #endif /* CONFIG_PPC_64S_HASH_MMU */ diff --git a/arch/powerpc/mm/book3s64/Makefile b/arch/powerpc/mm/book3s64/Makefile index af2f3e75d458..d527dc8e30a8 100644 --- a/arch/powerpc/mm/book3s64/Makefile +++ b/arch/powerpc/mm/book3s64/Makefile @@ -5,7 +5,7 @@ ccflags-y := $(NO_MINIMAL_TOC) obj-y += mmu_context.o pgtable.o trace.o ifdef CONFIG_PPC_64S_HASH_MMU CFLAGS_REMOVE_slb.o = $(CC_FLAGS_FTRACE) -obj-y += hash_pgtable.o hash_utils.o hash_tlb.o slb.o +obj-y += hash_pgtable.o hash_utils.o hash_tlb.o slb.o slice.o obj-$(CONFIG_PPC_HASH_MMU_NATIVE) += hash_native.o obj-$(CONFIG_PPC_4K_PAGES) += hash_4k.o obj-$(CONFIG_PPC_64K_PAGES)+= hash_64k.o @@ -21,7 +21,6 @@ obj-$(CONFIG_PPC_RADIX_MMU) += radix_hugetlbpage.o endif obj-$(CONFIG_SPAPR_TCE_IOMMU) += iommu_api.o obj-$(CONFIG_PPC_PKEY) += pkeys.o -obj-$(CONFIG_PPC_MM_SLICES)+= slice.o # Instrumenting the SLB fault path can lead to duplicate SLB entries KCOV_INSTRUMENT_slb.o := n diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c index 7abf82a698d3..154a5a860959 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -1264,7 +1264,6 @@ unsigned int hash_page_do_lazy_icache(unsigned int pp, pte_t pte, int trap) return pp; } -#ifdef CONFIG_PPC_MM_SLICES static unsigned int get_paca_psize(unsigned long addr) { unsigned char *psizes; @@ -1281,12 +1280,6 @@ static unsigned int get_paca_psize(unsigned long addr) return (psizes[index >> 1] >> (mask_index * 4)) & 0xF; } -#else -unsigned int get_paca_psize(unsigned long addr) -{ - return get_paca()->mm_ctx_user_psize; -} -#endif /* * Demote a segment to using 4k pages. @@ -1710,7 +1703,6 @@ DEFINE_INTERRUPT_HANDLER_RAW(do_hash_fault) return 0; } -#ifdef CONFIG_PPC_MM_SLICES static bool should_hash_preload(struct mm_struct *mm, unsigned long ea) { int psize = get_slice_psize(mm, ea); @@ -1727,12 +1719,6 @@ static bool should_hash_preload(struct mm_struct *mm, unsigned long ea) return true; } -#else -static bool should_hash_preload(struct mm_struct *mm, unsigned long ea) -{ - return true; -} -#endif
[PATCH v7 07/14] powerpc/mm: Make slice specific to book3s/64
Since commit 555904d07eef ("powerpc/8xx: MM_SLICE is not needed anymore") only book3s/64 selects CONFIG_PPC_MM_SLICES. Move slice.c into mm/book3s64/ Move necessary stuff in asm/book3s/64/slice.h and remove asm/slice.h Signed-off-by: Christophe Leroy Reviewed-by: Nicholas Piggin --- arch/powerpc/include/asm/book3s/64/mmu-hash.h | 1 + arch/powerpc/include/asm/book3s/64/slice.h| 18 arch/powerpc/include/asm/page.h | 1 - arch/powerpc/include/asm/slice.h | 46 --- arch/powerpc/mm/Makefile | 1 - arch/powerpc/mm/book3s64/Makefile | 1 + arch/powerpc/mm/{ => book3s64}/slice.c| 2 - arch/powerpc/mm/nohash/mmu_context.c | 9 arch/powerpc/mm/nohash/tlb.c | 4 -- 9 files changed, 20 insertions(+), 63 deletions(-) delete mode 100644 arch/powerpc/include/asm/slice.h rename arch/powerpc/mm/{ => book3s64}/slice.c (99%) diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h b/arch/powerpc/include/asm/book3s/64/mmu-hash.h index 21f780942911..1c4eebbc69c9 100644 --- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h +++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h @@ -18,6 +18,7 @@ * complete pgtable.h but only a portion of it. */ #include +#include #include #include diff --git a/arch/powerpc/include/asm/book3s/64/slice.h b/arch/powerpc/include/asm/book3s/64/slice.h index f0d3194ba41b..5b0f7105bc8b 100644 --- a/arch/powerpc/include/asm/book3s/64/slice.h +++ b/arch/powerpc/include/asm/book3s/64/slice.h @@ -2,6 +2,8 @@ #ifndef _ASM_POWERPC_BOOK3S_64_SLICE_H #define _ASM_POWERPC_BOOK3S_64_SLICE_H +#ifndef __ASSEMBLY__ + #define SLICE_LOW_SHIFT28 #define SLICE_LOW_TOP (0x1ul) #define SLICE_NUM_LOW (SLICE_LOW_TOP >> SLICE_LOW_SHIFT) @@ -13,4 +15,20 @@ #define SLB_ADDR_LIMIT_DEFAULT DEFAULT_MAP_WINDOW_USER64 +struct mm_struct; + +unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, + unsigned long flags, unsigned int psize, + int topdown); + +unsigned int get_slice_psize(struct mm_struct *mm, unsigned long addr); + +void slice_set_range_psize(struct mm_struct *mm, unsigned long start, + unsigned long len, unsigned int psize); + +void slice_init_new_context_exec(struct mm_struct *mm); +void slice_setup_new_exec(void); + +#endif /* __ASSEMBLY__ */ + #endif /* _ASM_POWERPC_BOOK3S_64_SLICE_H */ diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h index 254687258f42..62e0c6f12869 100644 --- a/arch/powerpc/include/asm/page.h +++ b/arch/powerpc/include/asm/page.h @@ -329,6 +329,5 @@ static inline unsigned long kaslr_offset(void) #include #endif /* __ASSEMBLY__ */ -#include #endif /* _ASM_POWERPC_PAGE_H */ diff --git a/arch/powerpc/include/asm/slice.h b/arch/powerpc/include/asm/slice.h deleted file mode 100644 index 0bdd9c62eca0.. --- a/arch/powerpc/include/asm/slice.h +++ /dev/null @@ -1,46 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_POWERPC_SLICE_H -#define _ASM_POWERPC_SLICE_H - -#ifdef CONFIG_PPC_BOOK3S_64 -#include -#endif - -#ifndef __ASSEMBLY__ - -struct mm_struct; - -#ifdef CONFIG_PPC_MM_SLICES - -#ifdef CONFIG_HUGETLB_PAGE -#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA -#endif -#define HAVE_ARCH_UNMAPPED_AREA -#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN - -unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, - unsigned long flags, unsigned int psize, - int topdown); - -unsigned int get_slice_psize(struct mm_struct *mm, unsigned long addr); - -void slice_set_range_psize(struct mm_struct *mm, unsigned long start, - unsigned long len, unsigned int psize); - -void slice_init_new_context_exec(struct mm_struct *mm); -void slice_setup_new_exec(void); - -#else /* CONFIG_PPC_MM_SLICES */ - -static inline void slice_init_new_context_exec(struct mm_struct *mm) {} - -static inline unsigned int get_slice_psize(struct mm_struct *mm, unsigned long addr) -{ - return 0; -} - -#endif /* CONFIG_PPC_MM_SLICES */ - -#endif /* __ASSEMBLY__ */ - -#endif /* _ASM_POWERPC_SLICE_H */ diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile index df8172da2301..d4c20484dad9 100644 --- a/arch/powerpc/mm/Makefile +++ b/arch/powerpc/mm/Makefile @@ -14,7 +14,6 @@ obj-$(CONFIG_PPC_MMU_NOHASH) += nohash/ obj-$(CONFIG_PPC_BOOK3S_32)+= book3s32/ obj-$(CONFIG_PPC_BOOK3S_64)+= book3s64/ obj-$(CONFIG_NUMA) += numa.o -obj-$(CONFIG_PPC_MM_SLICES)+= slice.o obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-noncoherent.o obj-$(CONFIG_PPC_COPRO_BASE) += copro_fault.o diff --git a/arch/powerpc/mm/book3s64/Makefile b/arch/powerpc/mm/book3s64/Makefile index 2d50cac499c5..af2f3e75d458 100644
[PATCH v7 06/14] powerpc/mm: Move vma_mmu_pagesize()
vma_mmu_pagesize() is only required for slices, otherwise there is a generic weak version doing the exact same thing. Move it to slice.c Signed-off-by: Christophe Leroy Reviewed-by: Nicholas Piggin --- arch/powerpc/mm/hugetlbpage.c | 11 --- arch/powerpc/mm/slice.c | 9 + 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index ddead41e2194..0eec3b61bd13 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -565,17 +565,6 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, } #endif -unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) -{ - /* With radix we don't use slice, so derive it from vma*/ - if (IS_ENABLED(CONFIG_PPC_MM_SLICES) && !radix_enabled()) { - unsigned int psize = get_slice_psize(vma->vm_mm, vma->vm_start); - - return 1UL << mmu_psize_to_shift(psize); - } - return vma_kernel_pagesize(vma); -} - bool __init arch_hugetlb_valid_size(unsigned long size) { int shift = __ffs(size); diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c index f42711f865f3..8a3ac062b71e 100644 --- a/arch/powerpc/mm/slice.c +++ b/arch/powerpc/mm/slice.c @@ -759,4 +759,13 @@ int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr, return !slice_check_range_fits(mm, maskp, addr, len); } + +unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) +{ + /* With radix we don't use slice, so derive it from vma*/ + if (radix_enabled()) + return vma_kernel_pagesize(vma); + + return 1UL << mmu_psize_to_shift(get_slice_psize(vma->vm_mm, vma->vm_start)); +} #endif -- 2.33.1
[PATCH v7 03/14] mm: Add len and flags parameters to arch_get_mmap_end()
Powerpc needs flags and len to make decision on arch_get_mmap_end(). So add them as parameters to arch_get_mmap_end(). Signed-off-by: Christophe Leroy Cc: Steve Capper Cc: Catalin Marinas Cc: Will Deacon Acked-by: Catalin Marinas --- arch/arm64/include/asm/processor.h | 4 ++-- mm/mmap.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 6f41b65f9962..9ceec2bf4b93 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -91,8 +91,8 @@ #endif /* CONFIG_COMPAT */ #ifndef CONFIG_ARM64_FORCE_52BIT -#define arch_get_mmap_end(addr) ((addr > DEFAULT_MAP_WINDOW) ? TASK_SIZE :\ - DEFAULT_MAP_WINDOW) +#define arch_get_mmap_end(addr, len, flags) \ + (((addr) > DEFAULT_MAP_WINDOW) ? TASK_SIZE : DEFAULT_MAP_WINDOW) #define arch_get_mmap_base(addr, base) ((addr > DEFAULT_MAP_WINDOW) ? \ base + TASK_SIZE - DEFAULT_MAP_WINDOW :\ diff --git a/mm/mmap.c b/mm/mmap.c index 7ac6a07ff382..ad48f7af7511 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2113,7 +2113,7 @@ unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info) } #ifndef arch_get_mmap_end -#define arch_get_mmap_end(addr)(TASK_SIZE) +#define arch_get_mmap_end(addr, len, flags)(TASK_SIZE) #endif #ifndef arch_get_mmap_base @@ -2139,7 +2139,7 @@ generic_get_unmapped_area(struct file *filp, unsigned long addr, struct mm_struct *mm = current->mm; struct vm_area_struct *vma, *prev; struct vm_unmapped_area_info info; - const unsigned long mmap_end = arch_get_mmap_end(addr); + const unsigned long mmap_end = arch_get_mmap_end(addr, len, flags); if (len > mmap_end - mmap_min_addr) return -ENOMEM; @@ -2187,7 +2187,7 @@ generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr, struct vm_area_struct *vma, *prev; struct mm_struct *mm = current->mm; struct vm_unmapped_area_info info; - const unsigned long mmap_end = arch_get_mmap_end(addr); + const unsigned long mmap_end = arch_get_mmap_end(addr, len, flags); /* requested length too big for entire address space */ if (len > mmap_end - mmap_min_addr) -- 2.33.1
[PATCH v7 04/14] mm, hugetlbfs: Allow for "high" userspace addresses
This is a complement of f6795053dac8 ("mm: mmap: Allow for "high" userspace addresses") for hugetlb. This patch adds support for "high" userspace addresses that are optionally supported on the system and have to be requested via a hint mechanism ("high" addr parameter to mmap). Architectures such as powerpc and x86 achieve this by making changes to their architectural versions of hugetlb_get_unmapped_area() function. However, arm64 uses the generic version of that function. So take into account arch_get_mmap_base() and arch_get_mmap_end() in hugetlb_get_unmapped_area(). To allow that, move those two macros out of mm/mmap.c into include/linux/sched/mm.h If these macros are not defined in architectural code then they default to (TASK_SIZE) and (base) so should not introduce any behavioural changes to architectures that do not define them. For the time being, only ARM64 is affected by this change. Signed-off-by: Christophe Leroy Cc: Steve Capper Cc: Will Deacon Cc: Catalin Marinas Fixes: f6795053dac8 ("mm: mmap: Allow for "high" userspace addresses") Cc: # 5.0.x Reviewed-by: Catalin Marinas --- fs/hugetlbfs/inode.c | 9 + include/linux/sched/mm.h | 8 mm/mmap.c| 8 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index c7cde4e5924d..a8d3b0899b60 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -205,7 +205,7 @@ hugetlb_get_unmapped_area_bottomup(struct file *file, unsigned long addr, info.flags = 0; info.length = len; info.low_limit = current->mm->mmap_base; - info.high_limit = TASK_SIZE; + info.high_limit = arch_get_mmap_end(addr, len, flags); info.align_mask = PAGE_MASK & ~huge_page_mask(h); info.align_offset = 0; return vm_unmapped_area(); @@ -221,7 +221,7 @@ hugetlb_get_unmapped_area_topdown(struct file *file, unsigned long addr, info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.length = len; info.low_limit = max(PAGE_SIZE, mmap_min_addr); - info.high_limit = current->mm->mmap_base; + info.high_limit = arch_get_mmap_base(addr, current->mm->mmap_base); info.align_mask = PAGE_MASK & ~huge_page_mask(h); info.align_offset = 0; addr = vm_unmapped_area(); @@ -236,7 +236,7 @@ hugetlb_get_unmapped_area_topdown(struct file *file, unsigned long addr, VM_BUG_ON(addr != -ENOMEM); info.flags = 0; info.low_limit = current->mm->mmap_base; - info.high_limit = TASK_SIZE; + info.high_limit = arch_get_mmap_end(addr, len, flags); addr = vm_unmapped_area(); } @@ -251,6 +251,7 @@ generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr, struct mm_struct *mm = current->mm; struct vm_area_struct *vma; struct hstate *h = hstate_file(file); + const unsigned long mmap_end = arch_get_mmap_end(addr, len, flags); if (len & ~huge_page_mask(h)) return -EINVAL; @@ -266,7 +267,7 @@ generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr, if (addr) { addr = ALIGN(addr, huge_page_size(h)); vma = find_vma(mm, addr); - if (TASK_SIZE - len >= addr && + if (mmap_end - len >= addr && (!vma || addr + len <= vm_start_gap(vma))) return addr; } diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 2584f7c13f69..cc9d80bd36d5 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -135,6 +135,14 @@ static inline void mm_update_next_owner(struct mm_struct *mm) #endif /* CONFIG_MEMCG */ #ifdef CONFIG_MMU +#ifndef arch_get_mmap_end +#define arch_get_mmap_end(addr, len, flags)(TASK_SIZE) +#endif + +#ifndef arch_get_mmap_base +#define arch_get_mmap_base(addr, base) (base) +#endif + extern void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack); extern unsigned long diff --git a/mm/mmap.c b/mm/mmap.c index ad48f7af7511..c773b5ad9a11 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2112,14 +2112,6 @@ unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info) return addr; } -#ifndef arch_get_mmap_end -#define arch_get_mmap_end(addr, len, flags)(TASK_SIZE) -#endif - -#ifndef arch_get_mmap_base -#define arch_get_mmap_base(addr, base) (base) -#endif - /* Get an address range which is currently unmapped. * For shmat() with addr=0. * -- 2.33.1
[PATCH v7 02/14] mm, hugetlbfs: Allow an arch to always use generic versions of get_unmapped_area functions
Unlike most architectures, powerpc can only define at runtime if it is going to use the generic arch_get_unmapped_area() or not. Today, powerpc has a copy of the generic arch_get_unmapped_area() because when selection HAVE_ARCH_UNMAPPED_AREA the generic arch_get_unmapped_area() is not available. Rename it generic_get_unmapped_area() and make it independent of HAVE_ARCH_UNMAPPED_AREA. Do the same for arch_get_unmapped_area_topdown() versus HAVE_ARCH_UNMAPPED_AREA_TOPDOWN. Do the same for hugetlb_get_unmapped_area() versus HAVE_ARCH_HUGETLB_UNMAPPED_AREA. Signed-off-by: Christophe Leroy Reviewed-by: Nicholas Piggin --- fs/hugetlbfs/inode.c | 17 + include/linux/hugetlb.h | 5 + include/linux/sched/mm.h | 9 + mm/mmap.c| 31 --- 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 49d2e686be74..c7cde4e5924d 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -195,7 +195,6 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) * Called under mmap_write_lock(mm). */ -#ifndef HAVE_ARCH_HUGETLB_UNMAPPED_AREA static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) @@ -244,9 +243,10 @@ hugetlb_get_unmapped_area_topdown(struct file *file, unsigned long addr, return addr; } -static unsigned long -hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, unsigned long flags) +unsigned long +generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) { struct mm_struct *mm = current->mm; struct vm_area_struct *vma; @@ -282,6 +282,15 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr, return hugetlb_get_unmapped_area_bottomup(file, addr, len, pgoff, flags); } + +#ifndef HAVE_ARCH_HUGETLB_UNMAPPED_AREA +static unsigned long +hugetlb_get_unmapped_area(struct file *file, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + return generic_hugetlb_get_unmapped_area(file, addr, len, pgoff, flags); +} #endif static size_t diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 00351ccb49a3..df899d1937ff 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -513,6 +513,11 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, unsigned long flags); #endif /* HAVE_ARCH_HUGETLB_UNMAPPED_AREA */ +unsigned long +generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags); + /* * huegtlb page specific state flags. These flags are located in page.private * of the hugetlb head page. Functions created via the below macros should be diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index aca874d33fe6..2584f7c13f69 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -144,6 +144,15 @@ extern unsigned long arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags); + +unsigned long +generic_get_unmapped_area(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags); +unsigned long +generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags); #else static inline void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) {} diff --git a/mm/mmap.c b/mm/mmap.c index bfb0ea164a90..7ac6a07ff382 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2131,10 +2131,10 @@ unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info) * * This function "knows" that -ENOMEM has the bits set. */ -#ifndef HAVE_ARCH_UNMAPPED_AREA unsigned long -arch_get_unmapped_area(struct file *filp, unsigned long addr, - unsigned long len, unsigned long pgoff, unsigned long flags) +generic_get_unmapped_area(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) { struct mm_struct *mm = current->mm; struct vm_area_struct *vma, *prev; @@ -2164,17 +2164,25 @@
[PATCH v7 01/14] mm: Allow arch specific arch_randomize_brk() with CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
Commit e7142bf5d231 ("arm64, mm: make randomization selected by generic topdown mmap layout") introduced a default version of arch_randomize_brk() provided when CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT is selected. powerpc could select CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT but needs to provide its own arch_randomize_brk(). In order to allow that, define generic version of arch_randomize_brk() as a __weak symbol. Cc: Alexandre Ghiti Signed-off-by: Christophe Leroy --- mm/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/util.c b/mm/util.c index 741ba32a43ac..46d1a2dd7a32 100644 --- a/mm/util.c +++ b/mm/util.c @@ -344,7 +344,7 @@ unsigned long randomize_stack_top(unsigned long stack_top) } #ifdef CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT -unsigned long arch_randomize_brk(struct mm_struct *mm) +unsigned long __weak arch_randomize_brk(struct mm_struct *mm) { /* Is the current task 32bit ? */ if (!IS_ENABLED(CONFIG_64BIT) || is_compat_task()) -- 2.33.1
[PATCH v7 00/14] Convert powerpc to default topdown mmap layout
Rebased on top of powerpc/next branch This series converts powerpc to default topdown mmap layout. powerpc requires its own arch_get_unmapped_area() only when slices are needed, which is only for book3s/64. First part of the series moves slices into book3s/64 specific directories and cleans up other subarchitectures. Last part converts to default topdown mmap layout. A small modification is done to core mm to allow powerpc to still provide its own arch_randomize_brk() Another modification is done to core mm to allow powerpc to use generic versions of get_unmapped_area functions for Radix while still providing its own implementation for Hash, the selection between Radix and Hash being doing at runtime. Last modification to core mm is to give len and flags to arch_get_mmap_end(). Signed-off-by: Christophe Leroy Changes in v7: - Taken into account comments from Catalin (patches 3 and 4) Changes in v6: - New patch (patch 4) to take arch_get_mmap_base() and arch_get_mmap_end() into account in generic hugetlb_get_unmapped_area() - Get back arch_randomize_brk() simplification as it relies on default topdown mmap layout. - Fixed precedence between || and && in powerpc's arch_get_mmap_end() (patch 9) Changes in v5: - Added patch 3 - Added arch_get_mmap_base() and arch_get_mmap_end() to patch 7 to better match original powerpc behaviour - Switched patched 10 and 11 and performed full randomisation in patch 10 just before switching to default implementation, as suggested by Nic. Changes in v4: - Move arch_randomize_brk() simplification out of this series - Add a change to core mm to enable using generic implementation while providing arch specific one at the same time. - Reworked radix get_unmapped_area to use generic implementation - Rebase on top of Nic's series v6 Changes in v3: - Fixed missing in last patch - Added a patch to move SZ_1T out of drivers/pci/controller/pci-xgene.c Changes in v2: - Moved patch 4 before patch 2 - Make generic arch_randomize_brk() __weak - Added patch 9 Christophe Leroy (14): mm: Allow arch specific arch_randomize_brk() with CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT mm, hugetlbfs: Allow an arch to always use generic versions of get_unmapped_area functions mm: Add len and flags parameters to arch_get_mmap_end() mm, hugetlbfs: Allow for "high" userspace addresses sizes.h: Add SZ_1T macro powerpc/mm: Move vma_mmu_pagesize() powerpc/mm: Make slice specific to book3s/64 powerpc/mm: Remove CONFIG_PPC_MM_SLICES powerpc/mm: Use generic_get_unmapped_area() and call it from arch_get_unmapped_area() powerpc/mm: Use generic_hugetlb_get_unmapped_area() powerpc/mm: Move get_unmapped_area functions to slice.c powerpc/mm: Enable full randomisation of memory mappings powerpc/mm: Convert to default topdown mmap layout powerpc: Simplify and move arch_randomize_brk() arch/arm64/include/asm/processor.h| 4 +- arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/book3s/64/hugetlb.h | 4 - arch/powerpc/include/asm/book3s/64/mmu-hash.h | 1 + arch/powerpc/include/asm/book3s/64/mmu.h | 6 - arch/powerpc/include/asm/book3s/64/slice.h| 24 ++ arch/powerpc/include/asm/hugetlb.h| 2 +- arch/powerpc/include/asm/paca.h | 7 - arch/powerpc/include/asm/page.h | 1 - arch/powerpc/include/asm/processor.h | 2 - arch/powerpc/include/asm/slice.h | 46 arch/powerpc/include/asm/task_size_64.h | 8 + arch/powerpc/kernel/paca.c| 5 - arch/powerpc/kernel/process.c | 41 --- arch/powerpc/mm/Makefile | 3 +- arch/powerpc/mm/book3s64/Makefile | 2 +- arch/powerpc/mm/book3s64/hash_utils.c | 33 ++- arch/powerpc/mm/book3s64/radix_hugetlbpage.c | 55 arch/powerpc/mm/{ => book3s64}/slice.c| 71 - arch/powerpc/mm/hugetlbpage.c | 34 --- arch/powerpc/mm/mmap.c| 256 -- arch/powerpc/mm/nohash/mmu_context.c | 9 - arch/powerpc/mm/nohash/tlb.c | 4 - arch/powerpc/platforms/Kconfig.cputype| 4 - drivers/pci/controller/pci-xgene.c| 1 - fs/hugetlbfs/inode.c | 26 +- include/linux/hugetlb.h | 5 + include/linux/sched/mm.h | 17 ++ include/linux/sizes.h | 2 + mm/mmap.c | 43 +-- mm/util.c | 2 +- 31 files changed, 185 insertions(+), 535 deletions(-) delete mode 100644 arch/powerpc/include/asm/slice.h rename arch/powerpc/mm/{ => book3s64}/slice.c (91%) delete mode 100644 arch/powerpc/mm/mmap.c -- 2.33.1
Re: [PATCH v7 1/7] powerpc/pmem: Restrict papr_scm to P8 and above.
Hello, On Wed, Jul 01, 2020 at 12:52:29PM +0530, Aneesh Kumar K.V wrote: > The PAPR based virtualized persistent memory devices are only supported on > POWER9 and above. In the followup patch, the kernel will switch the persistent > memory cache flush functions to use a new `dcbf` variant instruction. The new > instructions even though added in ISA 3.1 works even on P8 and P9 because > these > are implemented as a variant of existing `dcbf` and `hwsync` and on P8 and > P9 behaves as such. > > Considering these devices are only supported on P8 and above, update the > driver > to prevent a P7-compat guest from using persistent memory devices. > > We don't update of_pmem driver with the same condition, because, on > bare-metal, > the firmware enables pmem support only on P9 and above. There the kernel > depends > on OPAL firmware to restrict exposing persistent memory related device tree > entries on older hardware. of_pmem.ko is written without any arch dependency > and > we don't want to add ppc64 specific cpu feature check in of_pmem driver. > > Signed-off-by: Aneesh Kumar K.V > --- > arch/powerpc/platforms/pseries/pmem.c | 6 ++ > 1 file changed, 6 insertions(+) > > diff --git a/arch/powerpc/platforms/pseries/pmem.c > b/arch/powerpc/platforms/pseries/pmem.c > index f860a897a9e0..2347e1038f58 100644 > --- a/arch/powerpc/platforms/pseries/pmem.c > +++ b/arch/powerpc/platforms/pseries/pmem.c > @@ -147,6 +147,12 @@ const struct of_device_id drc_pmem_match[] = { > > static int pseries_pmem_init(void) > { > + /* > + * Only supported on POWER8 and above. > + */ > + if (!cpu_has_feature(CPU_FTR_ARCH_207S)) > + return 0; > + This looks superfluous. The hypervisor is responsible for publishing the pmem in devicetree when present, kernel is responsible for using it when supported by the kernel. Or is there a problem that the flush instruction is not available in P7 compat mode? Even then volatile regions should still work. Thanks Michal
[PATCH 3/3] powerpc/lib/sstep: use truncate_if_32bit()
Use truncate_if_32bit() when possible instead of open coding. truncate_if_32bit() returns an unsigned long, so don't use it when a signed value is expected. Signed-off-by: Christophe Leroy --- arch/powerpc/lib/sstep.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c index 4aabe3854484..ca38d026fd88 100644 --- a/arch/powerpc/lib/sstep.c +++ b/arch/powerpc/lib/sstep.c @@ -1065,8 +1065,7 @@ int emulate_dcbz(unsigned long ea, struct pt_regs *regs) int err; unsigned long size = l1_dcache_bytes(); - if (!(regs->msr & MSR_64BIT)) - ea &= 0xUL; + ea = truncate_if_32bit(regs->msr, ea); ea &= ~(size - 1); if (!address_ok(regs, ea, size)) return -EFAULT; @@ -1164,10 +1163,8 @@ static nokprobe_inline void add_with_carry(const struct pt_regs *regs, op->type = COMPUTE + SETREG + SETXER; op->reg = rd; op->val = val; - if (!(regs->msr & MSR_64BIT)) { - val = (unsigned int) val; - val1 = (unsigned int) val1; - } + val = truncate_if_32bit(regs->msr, val); + val1 = truncate_if_32bit(regs->msr, val1); op->xerval = regs->xer; if (val < val1 || (carry_in && val == val1)) op->xerval |= XER_CA; -- 2.33.1
[PATCH 2/3] powerpc/lib/sstep: Remove unneeded #ifdef __powerpc64__
MSR_64BIT is always defined, no need to hide code using MSR_64BIT inside an #ifdef __powerpc64__ Signed-off-by: Christophe Leroy --- arch/powerpc/lib/sstep.c | 8 1 file changed, 8 deletions(-) diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c index b7316d697d80..4aabe3854484 100644 --- a/arch/powerpc/lib/sstep.c +++ b/arch/powerpc/lib/sstep.c @@ -75,10 +75,8 @@ extern int do_stqcx(unsigned long ea, unsigned long val0, unsigned long val1, static nokprobe_inline unsigned long truncate_if_32bit(unsigned long msr, unsigned long val) { -#ifdef __powerpc64__ if ((msr & MSR_64BIT) == 0) val &= 0xUL; -#endif return val; } @@ -1067,10 +1065,8 @@ int emulate_dcbz(unsigned long ea, struct pt_regs *regs) int err; unsigned long size = l1_dcache_bytes(); -#ifdef __powerpc64__ if (!(regs->msr & MSR_64BIT)) ea &= 0xUL; -#endif ea &= ~(size - 1); if (!address_ok(regs, ea, size)) return -EFAULT; @@ -1136,10 +1132,8 @@ static nokprobe_inline void set_cr0(const struct pt_regs *regs, op->type |= SETCC; op->ccval = (regs->ccr & 0x0fff) | ((regs->xer >> 3) & 0x1000); -#ifdef __powerpc64__ if (!(regs->msr & MSR_64BIT)) val = (int) val; -#endif if (val < 0) op->ccval |= 0x8000; else if (val > 0) @@ -1170,12 +1164,10 @@ static nokprobe_inline void add_with_carry(const struct pt_regs *regs, op->type = COMPUTE + SETREG + SETXER; op->reg = rd; op->val = val; -#ifdef __powerpc64__ if (!(regs->msr & MSR_64BIT)) { val = (unsigned int) val; val1 = (unsigned int) val1; } -#endif op->xerval = regs->xer; if (val < val1 || (carry_in && val == val1)) op->xerval |= XER_CA; -- 2.33.1
[PATCH 1/3] powerpc/lib/sstep: Use l1_dcache_bytes() instead of opencoding
Don't opencode dcache size retrieval based on whether that's ppc32 or ppc64. Use l1_dcache_bytes() Signed-off-by: Christophe Leroy --- arch/powerpc/lib/sstep.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c index a94b0cd0bdc5..b7316d697d80 100644 --- a/arch/powerpc/lib/sstep.c +++ b/arch/powerpc/lib/sstep.c @@ -1065,14 +1065,11 @@ static int __emulate_dcbz(unsigned long ea) int emulate_dcbz(unsigned long ea, struct pt_regs *regs) { int err; - unsigned long size; + unsigned long size = l1_dcache_bytes(); #ifdef __powerpc64__ - size = ppc64_caches.l1d.block_size; if (!(regs->msr & MSR_64BIT)) ea &= 0xUL; -#else - size = L1_CACHE_BYTES; #endif ea &= ~(size - 1); if (!address_ok(regs, ea, size)) -- 2.33.1