* [PATCH 0/7] sha1 library cleanup
From: Eric Biggers @ 2020-05-02 18:24 UTC (permalink / raw)
To: linux-crypto
Cc: linux-s390, Jason A . Donenfeld, Theodore Ts'o, linuxppc-dev,
linux-kernel, Paul Mackerras, Paolo Abeni, mptcp
<linux/cryptohash.h> sounds very generic and important, like it's the
header to include if you're doing cryptographic hashing in the kernel.
But actually it only includes the library implementation of the SHA-1
compression function (not even the full SHA-1). This should basically
never be used anymore; SHA-1 is no longer considered secure, and there
are much better ways to do cryptographic hashing in the kernel.
Also the function is named just "sha_transform()", which makes it
unclear which version of SHA is meant.
Therefore, this series cleans things up by moving these SHA-1
declarations into <crypto/sha.h> where they better belong, and changing
the names to say SHA-1 rather than just SHA.
As future work, we should split sha.h into sha1.h and sha2.h and try to
remove the remaining uses of SHA-1. For example, the remaining use in
drivers/char/random.c is probably one that can be gotten rid of.
This patch series applies to cryptodev/master.
Eric Biggers (7):
mptcp: use SHA256_BLOCK_SIZE, not SHA_MESSAGE_BYTES
crypto: powerpc/sha1 - remove unused temporary workspace
crypto: powerpc/sha1 - prefix the "sha1_" functions
crypto: s390/sha1 - prefix the "sha1_" functions
crypto: lib/sha1 - rename "sha" to "sha1"
crypto: lib/sha1 - remove unnecessary includes of linux/cryptohash.h
crypto: lib/sha1 - fold linux/cryptohash.h into crypto/sha.h
Documentation/security/siphash.rst | 2 +-
arch/arm/crypto/sha1_glue.c | 1 -
arch/arm/crypto/sha1_neon_glue.c | 1 -
arch/arm/crypto/sha256_glue.c | 1 -
arch/arm/crypto/sha256_neon_glue.c | 1 -
arch/arm/kernel/armksyms.c | 1 -
arch/arm64/crypto/sha256-glue.c | 1 -
arch/arm64/crypto/sha512-glue.c | 1 -
arch/microblaze/kernel/microblaze_ksyms.c | 1 -
arch/mips/cavium-octeon/crypto/octeon-md5.c | 1 -
arch/powerpc/crypto/md5-glue.c | 1 -
arch/powerpc/crypto/sha1-spe-glue.c | 1 -
arch/powerpc/crypto/sha1.c | 33 ++++++++++-----------
arch/powerpc/crypto/sha256-spe-glue.c | 1 -
arch/s390/crypto/sha1_s390.c | 12 ++++----
arch/sparc/crypto/md5_glue.c | 1 -
arch/sparc/crypto/sha1_glue.c | 1 -
arch/sparc/crypto/sha256_glue.c | 1 -
arch/sparc/crypto/sha512_glue.c | 1 -
arch/unicore32/kernel/ksyms.c | 1 -
arch/x86/crypto/sha1_ssse3_glue.c | 1 -
arch/x86/crypto/sha256_ssse3_glue.c | 1 -
arch/x86/crypto/sha512_ssse3_glue.c | 1 -
crypto/sha1_generic.c | 5 ++--
drivers/char/random.c | 8 ++---
drivers/crypto/atmel-sha.c | 1 -
drivers/crypto/chelsio/chcr_algo.c | 1 -
drivers/crypto/chelsio/chcr_ipsec.c | 1 -
drivers/crypto/omap-sham.c | 1 -
fs/f2fs/hash.c | 1 -
include/crypto/sha.h | 10 +++++++
include/linux/cryptohash.h | 14 ---------
include/linux/filter.h | 4 +--
include/net/tcp.h | 1 -
kernel/bpf/core.c | 18 +++++------
lib/crypto/chacha.c | 1 -
lib/sha1.c | 24 ++++++++-------
net/core/secure_seq.c | 1 -
net/ipv6/addrconf.c | 10 +++----
net/ipv6/seg6_hmac.c | 1 -
net/mptcp/crypto.c | 4 +--
41 files changed, 69 insertions(+), 104 deletions(-)
delete mode 100644 include/linux/cryptohash.h
base-commit: 12b3cf9093542d9f752a4968815ece836159013f
--
2.26.2
^ permalink raw reply
* [PATCH 2/7] crypto: powerpc/sha1 - remove unused temporary workspace
From: Eric Biggers @ 2020-05-02 18:24 UTC (permalink / raw)
To: linux-crypto
Cc: Jason A . Donenfeld, Theodore Ts'o, linux-kernel,
Paul Mackerras, linuxppc-dev
In-Reply-To: <20200502182427.104383-1-ebiggers@kernel.org>
From: Eric Biggers <ebiggers@google.com>
The PowerPC implementation of SHA-1 doesn't actually use the 16-word
temporary array that's passed to the assembly code. This was probably
meant to correspond to the 'W' array that lib/sha1.c uses. However, in
sha1-powerpc-asm.S these values are actually stored in GPRs 16-31.
Referencing SHA_WORKSPACE_WORDS from this code also isn't appropriate,
since it's an implementation detail of lib/sha1.c.
Therefore, just remove this unneeded array.
Tested with:
export ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-
make mpc85xx_defconfig
cat >> .config << EOF
# CONFIG_MODULES is not set
# CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set
CONFIG_DEBUG_KERNEL=y
CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y
CONFIG_CRYPTO_SHA1_PPC=y
EOF
make olddefconfig
make -j32
qemu-system-ppc -M mpc8544ds -cpu e500 -nographic \
-kernel arch/powerpc/boot/zImage \
-append "cryptomgr.fuzz_iterations=1000 cryptomgr.panic_on_fail=1"
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
arch/powerpc/crypto/sha1.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/crypto/sha1.c b/arch/powerpc/crypto/sha1.c
index 7b43fc352089b1..db46b6130a9642 100644
--- a/arch/powerpc/crypto/sha1.c
+++ b/arch/powerpc/crypto/sha1.c
@@ -16,12 +16,11 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mm.h>
-#include <linux/cryptohash.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <asm/byteorder.h>
-extern void powerpc_sha_transform(u32 *state, const u8 *src, u32 *temp);
+void powerpc_sha_transform(u32 *state, const u8 *src);
static int sha1_init(struct shash_desc *desc)
{
@@ -47,7 +46,6 @@ static int sha1_update(struct shash_desc *desc, const u8 *data,
src = data;
if ((partial + len) > 63) {
- u32 temp[SHA_WORKSPACE_WORDS];
if (partial) {
done = -partial;
@@ -56,12 +54,11 @@ static int sha1_update(struct shash_desc *desc, const u8 *data,
}
do {
- powerpc_sha_transform(sctx->state, src, temp);
+ powerpc_sha_transform(sctx->state, src);
done += 64;
src = data + done;
} while (done + 63 < len);
- memzero_explicit(temp, sizeof(temp));
partial = 0;
}
memcpy(sctx->buffer + partial, src, len - done);
--
2.26.2
^ permalink raw reply related
* [PATCH 3/7] crypto: powerpc/sha1 - prefix the "sha1_" functions
From: Eric Biggers @ 2020-05-02 18:24 UTC (permalink / raw)
To: linux-crypto
Cc: Jason A . Donenfeld, Theodore Ts'o, linux-kernel,
Paul Mackerras, linuxppc-dev
In-Reply-To: <20200502182427.104383-1-ebiggers@kernel.org>
From: Eric Biggers <ebiggers@google.com>
Prefix the PowerPC SHA-1 functions with "powerpc_sha1_" rather than
"sha1_". This allows us to rename the library function sha_init() to
sha1_init() without causing a naming collision.
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
arch/powerpc/crypto/sha1.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/arch/powerpc/crypto/sha1.c b/arch/powerpc/crypto/sha1.c
index db46b6130a9642..b40dc50a6908ae 100644
--- a/arch/powerpc/crypto/sha1.c
+++ b/arch/powerpc/crypto/sha1.c
@@ -22,7 +22,7 @@
void powerpc_sha_transform(u32 *state, const u8 *src);
-static int sha1_init(struct shash_desc *desc)
+static int powerpc_sha1_init(struct shash_desc *desc)
{
struct sha1_state *sctx = shash_desc_ctx(desc);
@@ -33,8 +33,8 @@ static int sha1_init(struct shash_desc *desc)
return 0;
}
-static int sha1_update(struct shash_desc *desc, const u8 *data,
- unsigned int len)
+static int powerpc_sha1_update(struct shash_desc *desc, const u8 *data,
+ unsigned int len)
{
struct sha1_state *sctx = shash_desc_ctx(desc);
unsigned int partial, done;
@@ -68,7 +68,7 @@ static int sha1_update(struct shash_desc *desc, const u8 *data,
/* Add padding and return the message digest. */
-static int sha1_final(struct shash_desc *desc, u8 *out)
+static int powerpc_sha1_final(struct shash_desc *desc, u8 *out)
{
struct sha1_state *sctx = shash_desc_ctx(desc);
__be32 *dst = (__be32 *)out;
@@ -81,10 +81,10 @@ static int sha1_final(struct shash_desc *desc, u8 *out)
/* Pad out to 56 mod 64 */
index = sctx->count & 0x3f;
padlen = (index < 56) ? (56 - index) : ((64+56) - index);
- sha1_update(desc, padding, padlen);
+ powerpc_sha1_update(desc, padding, padlen);
/* Append length */
- sha1_update(desc, (const u8 *)&bits, sizeof(bits));
+ powerpc_sha1_update(desc, (const u8 *)&bits, sizeof(bits));
/* Store state in digest */
for (i = 0; i < 5; i++)
@@ -96,7 +96,7 @@ static int sha1_final(struct shash_desc *desc, u8 *out)
return 0;
}
-static int sha1_export(struct shash_desc *desc, void *out)
+static int powerpc_sha1_export(struct shash_desc *desc, void *out)
{
struct sha1_state *sctx = shash_desc_ctx(desc);
@@ -104,7 +104,7 @@ static int sha1_export(struct shash_desc *desc, void *out)
return 0;
}
-static int sha1_import(struct shash_desc *desc, const void *in)
+static int powerpc_sha1_import(struct shash_desc *desc, const void *in)
{
struct sha1_state *sctx = shash_desc_ctx(desc);
@@ -114,11 +114,11 @@ static int sha1_import(struct shash_desc *desc, const void *in)
static struct shash_alg alg = {
.digestsize = SHA1_DIGEST_SIZE,
- .init = sha1_init,
- .update = sha1_update,
- .final = sha1_final,
- .export = sha1_export,
- .import = sha1_import,
+ .init = powerpc_sha1_init,
+ .update = powerpc_sha1_update,
+ .final = powerpc_sha1_final,
+ .export = powerpc_sha1_export,
+ .import = powerpc_sha1_import,
.descsize = sizeof(struct sha1_state),
.statesize = sizeof(struct sha1_state),
.base = {
--
2.26.2
^ permalink raw reply related
* Re: [PATCH v2 2/3] mm/memory_hotplug: Introduce MHP_NO_FIRMWARE_MEMMAP
From: Dan Williams @ 2020-05-02 18:03 UTC (permalink / raw)
To: David Hildenbrand
Cc: virtio-dev, linux-hyperv, Michal Hocko, Baoquan He, Linux ACPI,
Wei Yang, linux-s390, linux-nvdimm, Linux Kernel Mailing List,
Dave Hansen, virtualization, Linux MM, Michael S . Tsirkin,
Eric W. Biederman, Pankaj Gupta, xen-devel, Andrew Morton,
Michal Hocko, linuxppc-dev
In-Reply-To: <467ccba3-80ac-085c-3127-d5618d77d3e0@redhat.com>
On Sat, May 2, 2020 at 2:27 AM David Hildenbrand <david@redhat.com> wrote:
>
> >> Now, let's clarify what I want regarding virtio-mem:
> >>
> >> 1. kexec should not add virtio-mem memory to the initial firmware
> >> memmap. The driver has to be in charge as discussed.
> >> 2. kexec should not place kexec images onto virtio-mem memory. That
> >> would end badly.
> >> 3. kexec should still dump virtio-mem memory via kdump.
> >
> > Ok, but then seems to say to me that dax/kmem is a different type of
> > (driver managed) than virtio-mem and it's confusing to try to apply
> > the same meaning. Why not just call your type for the distinct type it
> > is "System RAM (virtio-mem)" and let any other driver managed memory
> > follow the same "System RAM ($driver)" format if it wants?
>
> I had the same idea but discarded it because it seemed to uglify the
> add_memory() interface (passing yet another parameter only relevant for
> driver managed memory). Maybe we really want a new one, because I like
> that idea:
>
> /*
> * Add special, driver-managed memory to the system as system ram.
> * The resource_name is expected to have the name format "System RAM
> * ($DRIVER)", so user space (esp. kexec-tools)" can special-case it.
> *
> * For this memory, no entries in /sys/firmware/memmap are created,
> * as this memory won't be part of the raw firmware-provided memory map
> * e.g., after a reboot. Also, the created memory resource is flagged
> * with IORESOURCE_MEM_DRIVER_MANAGED, so in-kernel users can special-
> * case this memory (e.g., not place kexec images onto it).
> */
> int add_memory_driver_managed(int nid, u64 start, u64 size,
> const char *resource_name);
>
>
> If we'd ever have to special case it even more in the kernel, we could
> allow to specify further resource flags. While passing the driver name
> instead of the resource_name would be an option, this way we don't have
> to hand craft new resource strings for added memory resources.
>
> Thoughts?
Looks useful to me and simplifies walking /proc/iomem. I personally
like the safety of the string just being the $driver component of the
name, but I won't lose sleep if the interface stays freeform like you
propose.
^ permalink raw reply
* [PATCH] powerpc/64s: Fix unrecoverable SLB crashes due to preemption check
From: Michael Ellerman @ 2020-05-02 14:33 UTC (permalink / raw)
To: linuxppc-dev; +Cc: hughd, npiggin
Hugh reported that his trusty G5 crashed after a few hours under load
with an "Unrecoverable exception 380".
The crash is in interrupt_return() where we check lazy_irq_pending(),
which calls get_paca() and with CONFIG_DEBUG_PREEMPT=y that goes to
check_preemption_disabled() via debug_smp_processor_id().
As Nick explained on the list:
Problem is MSR[RI] is cleared here, ready to do the last few things
for interrupt return where we're not allowed to take any other
interrupts.
SLB interrupts can happen just about anywhere aside from kernel
text, global variables, and stack. When that hits, it appears to be
unrecoverable due to RI=0.
The problematic access is in preempt_count() which is:
return READ_ONCE(current_thread_info()->preempt_count);
Because of THREAD_INFO_IN_TASK, current_thread_info() just points to
current, so the access is to somewhere in kernel memory, but not on
the stack or in .data, which means it can cause an SLB miss. If we
take an SLB miss with RI=0 it is fatal.
The easiest solution is to add a version of lazy_irq_pending() that
doesn't do the preemption check and call it from the interrupt return
path.
Fixes: 68b34588e202 ("powerpc/64/sycall: Implement syscall entry/exit logic in C")
Reported-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/include/asm/hw_irq.h | 20 +++++++++++++++++++-
arch/powerpc/kernel/syscall_64.c | 6 +++---
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
index e0e71777961f..3a0db7b0b46e 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -250,9 +250,27 @@ static inline bool arch_irqs_disabled(void)
} \
} while(0)
+static inline bool __lazy_irq_pending(u8 irq_happened)
+{
+ return !!(irq_happened & ~PACA_IRQ_HARD_DIS);
+}
+
+/*
+ * Check if a lazy IRQ is pending. Should be called with IRQs hard disabled.
+ */
static inline bool lazy_irq_pending(void)
{
- return !!(get_paca()->irq_happened & ~PACA_IRQ_HARD_DIS);
+ return __lazy_irq_pending(get_paca()->irq_happened);
+}
+
+/*
+ * Check if a lazy IRQ is pending, with no debugging checks.
+ * Should be called with IRQs hard disabled.
+ * For use in RI disabled code or other constrained situations.
+ */
+static inline bool lazy_irq_pending_nocheck(void)
+{
+ return __lazy_irq_pending(local_paca->irq_happened);
}
/*
diff --git a/arch/powerpc/kernel/syscall_64.c b/arch/powerpc/kernel/syscall_64.c
index c74295a7765b..1fe94dd9de32 100644
--- a/arch/powerpc/kernel/syscall_64.c
+++ b/arch/powerpc/kernel/syscall_64.c
@@ -189,7 +189,7 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,
/* This pattern matches prep_irq_for_idle */
__hard_EE_RI_disable();
- if (unlikely(lazy_irq_pending())) {
+ if (unlikely(lazy_irq_pending_nocheck())) {
__hard_RI_enable();
trace_hardirqs_off();
local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
@@ -264,7 +264,7 @@ notrace unsigned long interrupt_exit_user_prepare(struct pt_regs *regs, unsigned
trace_hardirqs_on();
__hard_EE_RI_disable();
- if (unlikely(lazy_irq_pending())) {
+ if (unlikely(lazy_irq_pending_nocheck())) {
__hard_RI_enable();
trace_hardirqs_off();
local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
@@ -334,7 +334,7 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs, unsign
trace_hardirqs_on();
__hard_EE_RI_disable();
- if (unlikely(lazy_irq_pending())) {
+ if (unlikely(lazy_irq_pending_nocheck())) {
__hard_RI_enable();
irq_soft_mask_set(IRQS_ALL_DISABLED);
trace_hardirqs_off();
--
2.25.1
^ permalink raw reply related
* Re: [PATCH v7 11/28] powerpc: Use a datatype for instructions
From: kbuild test robot @ 2020-05-02 14:29 UTC (permalink / raw)
To: Jordan Niethe, linuxppc-dev
Cc: kbuild-all, alistair, npiggin, bala24, Jordan Niethe,
naveen.n.rao, dja
In-Reply-To: <20200501034220.8982-12-jniethe5@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 14614 bytes --]
Hi Jordan,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on powerpc/next]
[also build test ERROR on v5.7-rc3 next-20200501]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Jordan-Niethe/Initial-Prefixed-Instruction-support/20200501-124644
base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-randconfig-a001-20200501 (attached as .config)
compiler: powerpc-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=powerpc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>
All error/warnings (new ones prefixed by >>):
arch/powerpc/mm/nohash/8xx.c: In function 'mmu_patch_addis':
>> arch/powerpc/mm/nohash/8xx.c:104:31: error: incompatible type for argument 2 of 'patch_instruction_site'
104 | patch_instruction_site(site, instr);
| ^~~~~
| |
| unsigned int
In file included from arch/powerpc/mm/nohash/8xx.c:13:
arch/powerpc/include/asm/code-patching.h:39:69: note: expected 'struct ppc_inst' but argument is of type 'unsigned int'
39 | static inline int patch_instruction_site(s32 *site, struct ppc_inst instr)
| ~~~~~~~~~~~~~~~~^~~~~
In file included from arch/powerpc/include/asm/asm-compat.h:6,
from arch/powerpc/include/asm/bug.h:6,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:9,
from include/linux/memblock.h:13,
from arch/powerpc/mm/nohash/8xx.c:10:
arch/powerpc/mm/nohash/8xx.c: In function 'mmu_mapin_ram':
>> arch/powerpc/include/asm/ppc-opcode.h:234:24: error: incompatible type for argument 2 of 'patch_instruction_site'
234 | #define PPC_INST_NOP 0x60000000
| ^~~~~~~~~~
| |
| int
>> arch/powerpc/mm/nohash/8xx.c:128:54: note: in expansion of macro 'PPC_INST_NOP'
128 | patch_instruction_site(&patch__dtlbmiss_immr_jmp, PPC_INST_NOP);
| ^~~~~~~~~~~~
In file included from arch/powerpc/mm/nohash/8xx.c:13:
arch/powerpc/include/asm/code-patching.h:39:69: note: expected 'struct ppc_inst' but argument is of type 'int'
39 | static inline int patch_instruction_site(s32 *site, struct ppc_inst instr)
| ~~~~~~~~~~~~~~~~^~~~~
--
In file included from include/linux/printk.h:7,
from include/linux/kernel.h:15,
from include/linux/list.h:9,
from include/linux/preempt.h:11,
from include/linux/spinlock.h:51,
from arch/powerpc/kernel/trace/ftrace.c:16:
arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_nop':
>> include/linux/kern_levels.h:5:18: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'struct ppc_inst' [-Werror=format=]
5 | #define KERN_SOH "\001" /* ASCII Start Of Header */
| ^~~~~~
include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
| ^~~~~~~~
include/linux/printk.h:299:9: note: in expansion of macro 'KERN_ERR'
299 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~
>> arch/powerpc/kernel/trace/ftrace.c:233:3: note: in expansion of macro 'pr_err'
233 | pr_err("Not expected bl: opcode is %x\n", op);
| ^~~~~~
arch/powerpc/kernel/trace/ftrace.c:233:39: note: format string is defined here
233 | pr_err("Not expected bl: opcode is %x\n", op);
| ~^
| |
| unsigned int
In file included from include/linux/printk.h:7,
from include/linux/kernel.h:15,
from include/linux/list.h:9,
from include/linux/preempt.h:11,
from include/linux/spinlock.h:51,
from arch/powerpc/kernel/trace/ftrace.c:16:
arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_call':
>> include/linux/kern_levels.h:5:18: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'struct ppc_inst' [-Werror=format=]
5 | #define KERN_SOH "\001" /* ASCII Start Of Header */
| ^~~~~~
include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
| ^~~~~~~~
include/linux/printk.h:299:9: note: in expansion of macro 'KERN_ERR'
299 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~
arch/powerpc/kernel/trace/ftrace.c:595:3: note: in expansion of macro 'pr_err'
595 | pr_err("Expected NOP but have %x\n", op);
| ^~~~~~
arch/powerpc/kernel/trace/ftrace.c:595:34: note: format string is defined here
595 | pr_err("Expected NOP but have %x\n", op);
| ~^
| |
| unsigned int
>> arch/powerpc/kernel/trace/ftrace.c:615:24: error: passing argument 1 of 'patch_instruction' from incompatible pointer type [-Werror=incompatible-pointer-types]
615 | if (patch_instruction((unsigned int *)ip, op))
| ^~~~~~~~~~~~~~~~~~
| |
| unsigned int *
In file included from arch/powerpc/kernel/trace/ftrace.c:27:
arch/powerpc/include/asm/code-patching.h:31:40: note: expected 'struct ppc_inst *' but argument is of type 'unsigned int *'
31 | int patch_instruction(struct ppc_inst *addr, struct ppc_inst instr);
| ~~~~~~~~~~~~~~~~~^~~~
cc1: all warnings being treated as errors
vim +/patch_instruction_site +104 arch/powerpc/mm/nohash/8xx.c
bb7f380849f8c8 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-05-17 97
d5f17ee9644773 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2019-02-21 98 static void mmu_patch_addis(s32 *site, long simm)
d5f17ee9644773 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2019-02-21 99 {
d5f17ee9644773 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2019-02-21 100 unsigned int instr = *(unsigned int *)patch_site_addr(site);
d5f17ee9644773 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2019-02-21 101
d5f17ee9644773 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2019-02-21 102 instr &= 0xffff0000;
d5f17ee9644773 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2019-02-21 103 instr |= ((unsigned long)simm) >> 16;
d5f17ee9644773 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2019-02-21 @104 patch_instruction_site(site, instr);
d5f17ee9644773 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2019-02-21 105 }
d5f17ee9644773 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2019-02-21 106
0601546f23fb70 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-12-14 107 static void mmu_mapin_ram_chunk(unsigned long offset, unsigned long top, pgprot_t prot)
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 108 {
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 109 unsigned long s = offset;
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 110 unsigned long v = PAGE_OFFSET + s;
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 111 phys_addr_t p = memstart_addr + s;
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 112
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 113 for (; s < top; s += PAGE_SIZE) {
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 114 map_kernel_page(v, p, prot);
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 115 v += PAGE_SIZE;
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 116 p += PAGE_SIZE;
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 117 }
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 118 }
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 119
14e609d693ef67 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2019-02-21 120 unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)
bb7f380849f8c8 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-05-17 121 {
bb7f380849f8c8 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-05-17 122 unsigned long mapped;
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 123
4badd43ae44109 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-05-17 124 if (__map_without_ltlbs) {
bb7f380849f8c8 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-05-17 125 mapped = 0;
4badd43ae44109 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-05-17 126 mmu_mapin_immr();
665bed2386e5dc arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2019-02-13 127 if (!IS_ENABLED(CONFIG_PIN_TLB_IMMR))
1a210878bf21de arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2018-10-19 @128 patch_instruction_site(&patch__dtlbmiss_immr_jmp, PPC_INST_NOP);
665bed2386e5dc arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2019-02-13 129 if (!IS_ENABLED(CONFIG_PIN_TLB_TEXT))
1a210878bf21de arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2018-10-19 130 mmu_patch_cmp_limit(&patch__itlbmiss_linmem_top, 0);
bb7f380849f8c8 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-05-17 131 } else {
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 132 unsigned long einittext8 = ALIGN(__pa(_einittext), SZ_8M);
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 133
bb7f380849f8c8 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-05-17 134 mapped = top & ~(LARGE_PAGE_SIZE_8M - 1);
e4470bd6a41477 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2019-02-13 135 if (!IS_ENABLED(CONFIG_PIN_TLB_TEXT))
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 136 mmu_patch_cmp_limit(&patch__itlbmiss_linmem_top, einittext8);
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 137
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 138 /*
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 139 * Populate page tables to:
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 140 * - have them appear in /sys/kernel/debug/kernel_page_tables
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 141 * - allow the BDI to find the pages when they are not PINNED
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 142 */
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 143 mmu_mapin_ram_chunk(0, einittext8, PAGE_KERNEL_X);
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 144 mmu_mapin_ram_chunk(einittext8, mapped, PAGE_KERNEL);
a2227a27774328 arch/powerpc/mm/nohash/8xx.c Christophe Leroy 2019-08-23 145 mmu_mapin_immr();
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 146 }
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 147
1a210878bf21de arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2018-10-19 148 mmu_patch_cmp_limit(&patch__dtlbmiss_linmem_top, mapped);
1a210878bf21de arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2018-10-19 149 mmu_patch_cmp_limit(&patch__fixupdar_linmem_top, mapped);
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 150
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 151 /* If the size of RAM is not an exact power of two, we may not
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 152 * have covered RAM in its entirety with 8 MiB
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 153 * pages. Consequently, restrict the top end of RAM currently
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 154 * allocable so that calls to the MEMBLOCK to allocate PTEs for "tail"
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 155 * coverage with normal-sized pages (or other reasons) do not
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 156 * attempt to allocate outside the allowed range.
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 157 */
bb7f380849f8c8 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-05-17 158 if (mapped)
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 159 memblock_set_current_limit(mapped);
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 160
eef784bbe775e6 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2017-07-12 161 block_mapped_ram = mapped;
eef784bbe775e6 arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2017-07-12 162
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 163 return mapped;
a372acfac51e0d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 164 }
516d91893b548d arch/powerpc/mm/8xx_mmu.c Christophe Leroy 2016-02-09 165
:::::: The code at line 104 was first introduced by commit
:::::: d5f17ee96447736a84bc44ffc4b0dddb1b519222 powerpc/8xx: don't disable large TLBs with CONFIG_STRICT_KERNEL_RWX
:::::: TO: Christophe Leroy <christophe.leroy@c-s.fr>
:::::: CC: Michael Ellerman <mpe@ellerman.id.au>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 31894 bytes --]
^ permalink raw reply
* [powerpc:next-test] BUILD SUCCESS 64c245a2974a376bb02dd94d1d03719d3a167e86
From: kbuild test robot @ 2020-05-02 12:24 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next-test
branch HEAD: 64c245a2974a376bb02dd94d1d03719d3a167e86 Merge branch 'topic/uaccess-ppc' into next-test
elapsed time: 766m
configs tested: 209
configs skipped: 0
The following configs have been built successfully.
More configs may be tested in the coming days.
arm64 allyesconfig
arm allyesconfig
arm64 allmodconfig
arm allmodconfig
arm64 allnoconfig
arm allnoconfig
arm efm32_defconfig
arm at91_dt_defconfig
arm shmobile_defconfig
arm64 defconfig
arm exynos_defconfig
arm multi_v5_defconfig
arm sunxi_defconfig
arm multi_v7_defconfig
sparc allyesconfig
powerpc defconfig
ia64 defconfig
arc defconfig
mips ar7_defconfig
mips ath79_defconfig
mips allmodconfig
nios2 3c120_defconfig
sparc64 defconfig
csky defconfig
sh rsk7269_defconfig
ia64 allnoconfig
nds32 allnoconfig
m68k sun3_defconfig
i386 allnoconfig
i386 allyesconfig
i386 alldefconfig
i386 defconfig
i386 debian-10.3
ia64 allmodconfig
ia64 generic_defconfig
ia64 tiger_defconfig
ia64 bigsur_defconfig
ia64 allyesconfig
ia64 alldefconfig
m68k m5475evb_defconfig
m68k allmodconfig
m68k bvme6000_defconfig
m68k multi_defconfig
nios2 10m50_defconfig
c6x evmc6678_defconfig
c6x allyesconfig
openrisc simple_smp_defconfig
openrisc or1ksim_defconfig
nds32 defconfig
alpha defconfig
h8300 h8s-sim_defconfig
h8300 edosk2674_defconfig
xtensa iss_defconfig
h8300 h8300h-sim_defconfig
xtensa common_defconfig
arc allyesconfig
microblaze mmu_defconfig
microblaze nommu_defconfig
mips fuloong2e_defconfig
mips malta_kvm_defconfig
mips allyesconfig
mips 64r6el_defconfig
mips allnoconfig
mips 32r2_defconfig
mips malta_kvm_guest_defconfig
mips tb0287_defconfig
mips capcella_defconfig
mips ip32_defconfig
mips decstation_64_defconfig
mips loongson3_defconfig
mips bcm63xx_defconfig
parisc allnoconfig
parisc generic-64bit_defconfig
parisc generic-32bit_defconfig
parisc allyesconfig
parisc allmodconfig
powerpc chrp32_defconfig
powerpc holly_defconfig
powerpc ppc64_defconfig
powerpc rhel-kconfig
powerpc allnoconfig
powerpc mpc866_ads_defconfig
powerpc amigaone_defconfig
powerpc adder875_defconfig
powerpc ep8248e_defconfig
powerpc g5_defconfig
powerpc mpc512x_defconfig
m68k randconfig-a001-20200502
mips randconfig-a001-20200502
nds32 randconfig-a001-20200502
alpha randconfig-a001-20200502
parisc randconfig-a001-20200502
riscv randconfig-a001-20200502
h8300 randconfig-a001-20200502
nios2 randconfig-a001-20200502
microblaze randconfig-a001-20200502
c6x randconfig-a001-20200502
sparc64 randconfig-a001-20200502
s390 randconfig-a001-20200502
xtensa randconfig-a001-20200502
sh randconfig-a001-20200502
openrisc randconfig-a001-20200502
csky randconfig-a001-20200502
x86_64 randconfig-a003-20200502
x86_64 randconfig-a001-20200502
x86_64 randconfig-a002-20200502
i386 randconfig-a002-20200502
i386 randconfig-a003-20200502
i386 randconfig-a001-20200502
i386 randconfig-b003-20200502
i386 randconfig-b001-20200502
x86_64 randconfig-b003-20200502
x86_64 randconfig-b001-20200502
i386 randconfig-b002-20200502
i386 randconfig-b003-20200501
x86_64 randconfig-b002-20200501
i386 randconfig-b001-20200501
x86_64 randconfig-b003-20200501
x86_64 randconfig-b001-20200501
i386 randconfig-b002-20200501
x86_64 randconfig-c002-20200502
i386 randconfig-c002-20200502
i386 randconfig-c001-20200502
i386 randconfig-c003-20200502
i386 randconfig-d003-20200502
i386 randconfig-d001-20200502
x86_64 randconfig-d002-20200502
i386 randconfig-d002-20200502
x86_64 randconfig-e003-20200502
i386 randconfig-e003-20200502
x86_64 randconfig-e001-20200502
i386 randconfig-e002-20200502
i386 randconfig-e001-20200502
x86_64 randconfig-e002-20200430
i386 randconfig-e003-20200430
x86_64 randconfig-e003-20200430
i386 randconfig-e002-20200430
x86_64 randconfig-e001-20200430
i386 randconfig-e001-20200430
i386 randconfig-f003-20200502
x86_64 randconfig-f001-20200502
x86_64 randconfig-f003-20200502
x86_64 randconfig-f002-20200502
i386 randconfig-f001-20200502
i386 randconfig-f002-20200502
x86_64 randconfig-g003-20200502
i386 randconfig-g003-20200502
i386 randconfig-g002-20200502
x86_64 randconfig-g001-20200502
x86_64 randconfig-g002-20200502
i386 randconfig-g001-20200502
i386 randconfig-h001-20200502
i386 randconfig-h002-20200502
i386 randconfig-h003-20200502
x86_64 randconfig-h002-20200502
x86_64 randconfig-h001-20200502
x86_64 randconfig-h003-20200502
i386 randconfig-h001-20200501
i386 randconfig-h002-20200501
i386 randconfig-h003-20200501
x86_64 randconfig-h001-20200501
x86_64 randconfig-h003-20200501
sparc randconfig-a001-20200430
arc randconfig-a001-20200430
ia64 randconfig-a001-20200430
powerpc randconfig-a001-20200430
arm randconfig-a001-20200430
ia64 randconfig-a001-20200502
arm64 randconfig-a001-20200502
arc randconfig-a001-20200502
powerpc randconfig-a001-20200502
arm randconfig-a001-20200502
sparc randconfig-a001-20200502
ia64 randconfig-a001-20200501
arc randconfig-a001-20200501
powerpc randconfig-a001-20200501
arm randconfig-a001-20200501
sparc randconfig-a001-20200501
riscv allyesconfig
riscv nommu_virt_defconfig
riscv allnoconfig
riscv defconfig
riscv rv32_defconfig
riscv allmodconfig
s390 zfcpdump_defconfig
s390 debug_defconfig
s390 allyesconfig
s390 allnoconfig
s390 allmodconfig
s390 alldefconfig
s390 defconfig
sh allmodconfig
sh titan_defconfig
sh sh7785lcr_32bit_defconfig
sh allnoconfig
sparc defconfig
sparc64 allnoconfig
sparc64 allyesconfig
sparc64 allmodconfig
um x86_64_defconfig
um i386_defconfig
um defconfig
x86_64 rhel
x86_64 rhel-7.6
x86_64 rhel-7.6-kselftests
x86_64 rhel-7.2-clear
x86_64 lkp
x86_64 fedora-25
x86_64 kexec
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply
* [PATCH] powerpc/powernv: Fix a warning message
From: Christophe JAILLET @ 2020-05-02 11:59 UTC (permalink / raw)
To: mpe, benh, paulus, npiggin, tglx, maddy, cclaudio, zhangshaokun,
atrajeev, akshay.adiga, ego
Cc: kernel-janitors, Christophe JAILLET, linuxppc-dev, linux-kernel
Fix a cut'n'paste error in a warning message. This should be
'cpu-idle-state-residency-ns' to match the property searched in the
previous 'of_property_read_u32_array()'
Fixes: 9c7b185ab2fe ("powernv/cpuidle: Parse dt idle properties into global structure")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
arch/powerpc/platforms/powernv/idle.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c
index 78599bca66c2..2dd467383a88 100644
--- a/arch/powerpc/platforms/powernv/idle.c
+++ b/arch/powerpc/platforms/powernv/idle.c
@@ -1270,7 +1270,7 @@ static int pnv_parse_cpuidle_dt(void)
/* Read residencies */
if (of_property_read_u32_array(np, "ibm,cpu-idle-state-residency-ns",
temp_u32, nr_idle_states)) {
- pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-latencies-ns in DT\n");
+ pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-residency-ns in DT\n");
rc = -EINVAL;
goto out;
}
--
2.25.1
^ permalink raw reply related
* Re: [RFC 1/3] powernv/cpuidle : Support for pre-entry and post exit of stop state in firmware
From: Nicholas Piggin @ 2020-05-02 11:40 UTC (permalink / raw)
To: Abhishek, linux-kernel, linuxppc-dev; +Cc: ego, mikey, psampat, oohall, skiboot
In-Reply-To: <66ce544a-c1bf-4e84-2a7c-7480bbc0e12c@linux.vnet.ibm.com>
Excerpts from Abhishek's message of April 30, 2020 3:52 pm:
> Hi Nick,
>
> Have you posted out the kernel side of "opal v4" patchset?
> I could only find the opal patchset.
I just posted some new ones. I have some change sfor the cpuidle side
but I haven't really looked to see what needs reconciling with your
version, but I'll try to do that when I get time.
Thanks,
Nick
^ permalink raw reply
* [powerpc:topic/uaccess] BUILD SUCCESS b44f687386875b714dae2afa768e73401e45c21c
From: kbuild test robot @ 2020-05-02 11:38 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git topic/uaccess
branch HEAD: b44f687386875b714dae2afa768e73401e45c21c drm/i915/gem: Replace user_access_begin by user_write_access_begin
elapsed time: 695m
configs tested: 193
configs skipped: 0
The following configs have been built successfully.
More configs may be tested in the coming days.
arm64 allyesconfig
arm allyesconfig
arm64 allmodconfig
arm allmodconfig
arm64 allnoconfig
arm allnoconfig
arm efm32_defconfig
arm at91_dt_defconfig
arm shmobile_defconfig
arm64 defconfig
arm exynos_defconfig
arm multi_v5_defconfig
arm sunxi_defconfig
arm multi_v7_defconfig
sparc allyesconfig
arc allyesconfig
powerpc defconfig
ia64 defconfig
i386 alldefconfig
openrisc simple_smp_defconfig
arc defconfig
mips ar7_defconfig
s390 allnoconfig
mips allnoconfig
mips allmodconfig
sparc64 defconfig
csky defconfig
sh rsk7269_defconfig
ia64 allnoconfig
powerpc mpc512x_defconfig
sh sh7785lcr_32bit_defconfig
xtensa iss_defconfig
um defconfig
nds32 allnoconfig
m68k sun3_defconfig
i386 allnoconfig
i386 allyesconfig
i386 defconfig
i386 debian-10.3
ia64 allmodconfig
ia64 generic_defconfig
ia64 tiger_defconfig
ia64 bigsur_defconfig
ia64 allyesconfig
ia64 alldefconfig
m68k m5475evb_defconfig
m68k allmodconfig
m68k bvme6000_defconfig
m68k multi_defconfig
nios2 3c120_defconfig
nios2 10m50_defconfig
c6x evmc6678_defconfig
c6x allyesconfig
openrisc or1ksim_defconfig
nds32 defconfig
alpha defconfig
h8300 h8s-sim_defconfig
h8300 edosk2674_defconfig
h8300 h8300h-sim_defconfig
xtensa common_defconfig
microblaze mmu_defconfig
microblaze nommu_defconfig
mips fuloong2e_defconfig
mips malta_kvm_defconfig
mips allyesconfig
mips 64r6el_defconfig
mips 32r2_defconfig
mips malta_kvm_guest_defconfig
mips tb0287_defconfig
mips capcella_defconfig
mips ip32_defconfig
mips decstation_64_defconfig
mips loongson3_defconfig
mips ath79_defconfig
mips bcm63xx_defconfig
parisc allnoconfig
parisc generic-64bit_defconfig
parisc generic-32bit_defconfig
parisc allyesconfig
parisc allmodconfig
powerpc chrp32_defconfig
powerpc holly_defconfig
powerpc ppc64_defconfig
powerpc rhel-kconfig
powerpc allnoconfig
powerpc mpc866_ads_defconfig
powerpc amigaone_defconfig
powerpc adder875_defconfig
powerpc ep8248e_defconfig
powerpc g5_defconfig
m68k randconfig-a001-20200502
mips randconfig-a001-20200502
nds32 randconfig-a001-20200502
alpha randconfig-a001-20200502
parisc randconfig-a001-20200502
riscv randconfig-a001-20200502
h8300 randconfig-a001-20200502
nios2 randconfig-a001-20200502
microblaze randconfig-a001-20200502
c6x randconfig-a001-20200502
sparc64 randconfig-a001-20200502
s390 randconfig-a001-20200502
xtensa randconfig-a001-20200502
sh randconfig-a001-20200502
openrisc randconfig-a001-20200502
csky randconfig-a001-20200502
x86_64 randconfig-a003-20200502
x86_64 randconfig-a001-20200502
x86_64 randconfig-a002-20200502
i386 randconfig-a002-20200502
i386 randconfig-a003-20200502
i386 randconfig-a001-20200502
i386 randconfig-b003-20200502
i386 randconfig-b001-20200502
x86_64 randconfig-b003-20200502
x86_64 randconfig-b001-20200502
i386 randconfig-b002-20200502
i386 randconfig-b003-20200501
x86_64 randconfig-b002-20200501
i386 randconfig-b001-20200501
x86_64 randconfig-b003-20200501
x86_64 randconfig-b001-20200501
i386 randconfig-b002-20200501
x86_64 randconfig-c002-20200502
i386 randconfig-c002-20200502
i386 randconfig-c001-20200502
i386 randconfig-c003-20200502
i386 randconfig-d003-20200502
i386 randconfig-d001-20200502
x86_64 randconfig-d002-20200502
i386 randconfig-d002-20200502
x86_64 randconfig-e003-20200502
i386 randconfig-e003-20200502
x86_64 randconfig-e001-20200502
i386 randconfig-e002-20200502
i386 randconfig-e001-20200502
i386 randconfig-f003-20200502
x86_64 randconfig-f001-20200502
x86_64 randconfig-f003-20200502
x86_64 randconfig-f002-20200502
i386 randconfig-f001-20200502
i386 randconfig-f002-20200502
x86_64 randconfig-g003-20200502
i386 randconfig-g003-20200502
i386 randconfig-g002-20200502
x86_64 randconfig-g001-20200502
x86_64 randconfig-g002-20200502
i386 randconfig-g001-20200502
i386 randconfig-h001-20200502
i386 randconfig-h002-20200502
i386 randconfig-h003-20200502
x86_64 randconfig-h002-20200502
x86_64 randconfig-h001-20200502
x86_64 randconfig-h003-20200502
ia64 randconfig-a001-20200502
arm64 randconfig-a001-20200502
arc randconfig-a001-20200502
powerpc randconfig-a001-20200502
arm randconfig-a001-20200502
sparc randconfig-a001-20200502
ia64 randconfig-a001-20200501
arc randconfig-a001-20200501
powerpc randconfig-a001-20200501
arm randconfig-a001-20200501
sparc randconfig-a001-20200501
riscv allyesconfig
riscv nommu_virt_defconfig
riscv allnoconfig
riscv defconfig
riscv rv32_defconfig
riscv allmodconfig
s390 zfcpdump_defconfig
s390 debug_defconfig
s390 allyesconfig
s390 allmodconfig
s390 alldefconfig
s390 defconfig
sh allmodconfig
sh titan_defconfig
sh allnoconfig
sparc defconfig
sparc64 allnoconfig
sparc64 allyesconfig
sparc64 allmodconfig
um x86_64_defconfig
um i386_defconfig
x86_64 rhel
x86_64 rhel-7.6
x86_64 rhel-7.6-kselftests
x86_64 rhel-7.2-clear
x86_64 lkp
x86_64 fedora-25
x86_64 kexec
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply
* [PATCH v2 28/28] powerpc/book3s64/keys/kuap: Reset AMR/IAMR values on kexec
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
We can kexec into a kernel that doesn't use memory keys for kernel
mapping (such as an older kernel which doesn't support kuap/kuep with hash
translation). We need to make sure we reset the AMR/IAMR value on kexec
otherwise, the new kernel will use key 0 for kernel mapping and the old
AMR value prevents access to key 0.
This patch also removes reset if IAMR and AMOR in kexec_sequence. Reset of AMOR
is not needed and the IAMR reset is partial (it doesn't do the reset
on secondary cpus) and is redundant with this patch.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/include/asm/book3s/64/kup.h | 20 ++++++++++++++++++++
arch/powerpc/include/asm/kup.h | 14 ++++++++++++++
arch/powerpc/kernel/misc_64.S | 14 --------------
arch/powerpc/kexec/core_64.c | 3 +++
arch/powerpc/mm/book3s64/pgtable.c | 3 +++
5 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include/asm/book3s/64/kup.h
index 5b00592479d1..1cd0d849bd1b 100644
--- a/arch/powerpc/include/asm/book3s/64/kup.h
+++ b/arch/powerpc/include/asm/book3s/64/kup.h
@@ -341,6 +341,26 @@ static inline bool bad_kuap_fault(struct pt_regs *regs, unsigned long address,
return !!(error_code & DSISR_KEYFAULT);
}
+#define reset_kuap reset_kuap
+static inline void reset_kuap(void)
+{
+ if (mmu_has_feature(MMU_FTR_KUAP)) {
+ mtspr(SPRN_AMR, 0);
+ /* Do we need isync()? We are going via a kexec reset */
+ isync();
+ }
+}
+
+#define reset_kuep reset_kuep
+static inline void reset_kuep(void)
+{
+ if (mmu_has_feature(MMU_FTR_KUEP)) {
+ mtspr(SPRN_IAMR, 0);
+ /* Do we need isync()? We are going via a kexec reset */
+ isync();
+ }
+}
+
#else /* CONFIG_PPC_MEM_KEYS */
static inline void kuap_restore_user_amr(struct pt_regs *regs)
{
diff --git a/arch/powerpc/include/asm/kup.h b/arch/powerpc/include/asm/kup.h
index 249eed77a06b..b22becc1705c 100644
--- a/arch/powerpc/include/asm/kup.h
+++ b/arch/powerpc/include/asm/kup.h
@@ -101,6 +101,20 @@ static inline void prevent_current_access_user(void)
prevent_user_access(NULL, NULL, ~0UL, KUAP_CURRENT);
}
+#ifndef reset_kuap
+#define reset_kuap reset_kuap
+static inline void reset_kuap(void)
+{
+}
+#endif
+
+#ifndef reset_kuep
+#define reset_kuep reset_kuep
+static inline void reset_kuep(void)
+{
+}
+#endif
+
#endif /* !__ASSEMBLY__ */
#endif /* _ASM_POWERPC_KUAP_H_ */
diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
index 1864605eca29..7bb46ad98207 100644
--- a/arch/powerpc/kernel/misc_64.S
+++ b/arch/powerpc/kernel/misc_64.S
@@ -413,20 +413,6 @@ _GLOBAL(kexec_sequence)
li r0,0
std r0,16(r1)
-BEGIN_FTR_SECTION
- /*
- * This is the best time to turn AMR/IAMR off.
- * key 0 is used in radix for supervisor<->user
- * protection, but on hash key 0 is reserved
- * ideally we want to enter with a clean state.
- * NOTE, we rely on r0 being 0 from above.
- */
- mtspr SPRN_IAMR,r0
-BEGIN_FTR_SECTION_NESTED(42)
- mtspr SPRN_AMOR,r0
-END_FTR_SECTION_NESTED_IFSET(CPU_FTR_HVMODE, 42)
-END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
-
/* save regs for local vars on new stack.
* yes, we won't go back, but ...
*/
diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c
index b4184092172a..a124715f33ea 100644
--- a/arch/powerpc/kexec/core_64.c
+++ b/arch/powerpc/kexec/core_64.c
@@ -152,6 +152,9 @@ static void kexec_smp_down(void *arg)
if (ppc_md.kexec_cpu_down)
ppc_md.kexec_cpu_down(0, 1);
+ reset_kuap();
+ reset_kuep();
+
kexec_smp_wait();
/* NOTREACHED */
}
diff --git a/arch/powerpc/mm/book3s64/pgtable.c b/arch/powerpc/mm/book3s64/pgtable.c
index e0bb69c616e4..cf3d65067d48 100644
--- a/arch/powerpc/mm/book3s64/pgtable.c
+++ b/arch/powerpc/mm/book3s64/pgtable.c
@@ -168,6 +168,9 @@ void mmu_cleanup_all(void)
radix__mmu_cleanup_all();
else if (mmu_hash_ops.hpte_clear_all)
mmu_hash_ops.hpte_clear_all();
+
+ reset_kuap();
+ reset_kuep();
}
#ifdef CONFIG_MEMORY_HOTPLUG
--
2.26.2
^ permalink raw reply related
* [PATCH v2 27/28] powerpc/selftest/ptrace-pkey: IAMR and uamor cannot be updated by ptrace
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
Both IAMR and uamor are privileged and cannot be updated by userspace. Hence
we also don't allow ptrace interface to update them. Don't update them in the
test. Also expected_iamr is only changed if we can allocate a DISABLE_EXECUTE
pkey.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c b/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
index bc33d748d95b..5c3c8222de46 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
@@ -101,15 +101,12 @@ static int child(struct shared_info *info)
*/
info->invalid_amr = info->amr2 | (~0x0UL & ~info->expected_uamor);
+ /*
+ * if PKEY_DISABLE_EXECUTE succeeded we should update the expected_iamr
+ */
if (disable_execute)
info->expected_iamr |= 1ul << pkeyshift(pkey1);
- else
- info->expected_iamr &= ~(1ul << pkeyshift(pkey1));
-
- info->expected_iamr &= ~(1ul << pkeyshift(pkey2) | 1ul << pkeyshift(pkey3));
- info->expected_uamor |= 3ul << pkeyshift(pkey1) |
- 3ul << pkeyshift(pkey2);
/*
* Create an IAMR value different from expected value.
* Kernel will reject an IAMR and UAMOR change.
--
2.26.2
^ permalink raw reply related
* [PATCH v2 26/28] powerpc/selftest/ptrace-pkey: Update the test to mark an invalid pkey correctly
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
.../selftests/powerpc/ptrace/ptrace-pkey.c | 30 ++++++++-----------
1 file changed, 12 insertions(+), 18 deletions(-)
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c b/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
index f9216c7a1829..bc33d748d95b 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
@@ -66,11 +66,6 @@ static int sys_pkey_alloc(unsigned long flags, unsigned long init_access_rights)
return syscall(__NR_pkey_alloc, flags, init_access_rights);
}
-static int sys_pkey_free(int pkey)
-{
- return syscall(__NR_pkey_free, pkey);
-}
-
static int child(struct shared_info *info)
{
unsigned long reg;
@@ -100,7 +95,11 @@ static int child(struct shared_info *info)
info->amr1 |= 3ul << pkeyshift(pkey1);
info->amr2 |= 3ul << pkeyshift(pkey2);
- info->invalid_amr |= info->amr2 | 3ul << pkeyshift(pkey3);
+ /*
+ * invalid amr value where we try to force write
+ * things which are deined by a uamor setting.
+ */
+ info->invalid_amr = info->amr2 | (~0x0UL & ~info->expected_uamor);
if (disable_execute)
info->expected_iamr |= 1ul << pkeyshift(pkey1);
@@ -111,17 +110,12 @@ static int child(struct shared_info *info)
info->expected_uamor |= 3ul << pkeyshift(pkey1) |
3ul << pkeyshift(pkey2);
- info->invalid_iamr |= 1ul << pkeyshift(pkey1) | 1ul << pkeyshift(pkey2);
- info->invalid_uamor |= 3ul << pkeyshift(pkey1);
-
/*
- * We won't use pkey3. We just want a plausible but invalid key to test
- * whether ptrace will let us write to AMR bits we are not supposed to.
- *
- * This also tests whether the kernel restores the UAMOR permissions
- * after a key is freed.
+ * Create an IAMR value different from expected value.
+ * Kernel will reject an IAMR and UAMOR change.
*/
- sys_pkey_free(pkey3);
+ info->invalid_iamr = info->expected_iamr | (1ul << pkeyshift(pkey1) | 1ul << pkeyshift(pkey2));
+ info->invalid_uamor = info->expected_uamor & ~(0x3ul << pkeyshift(pkey1));
printf("%-30s AMR: %016lx pkey1: %d pkey2: %d pkey3: %d\n",
user_write, info->amr1, pkey1, pkey2, pkey3);
@@ -196,9 +190,9 @@ static int parent(struct shared_info *info, pid_t pid)
PARENT_SKIP_IF_UNSUPPORTED(ret, &info->child_sync);
PARENT_FAIL_IF(ret, &info->child_sync);
- info->amr1 = info->amr2 = info->invalid_amr = regs[0];
- info->expected_iamr = info->invalid_iamr = regs[1];
- info->expected_uamor = info->invalid_uamor = regs[2];
+ info->amr1 = info->amr2 = regs[0];
+ info->expected_iamr = regs[1];
+ info->expected_uamor = regs[2];
/* Wake up child so that it can set itself up. */
ret = prod_child(&info->child_sync);
--
2.26.2
^ permalink raw reply related
* [PATCH v2 25/28] powerpc/selftest/ptrave-pkey: Rename variables to make it easier to follow code
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
Rename variable to indicate that they are invalid values which we will use to
test ptrace update of pkeys.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
.../selftests/powerpc/ptrace/ptrace-pkey.c | 26 +++++++++----------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c b/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
index bdbbbe8431e0..f9216c7a1829 100644
--- a/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
+++ b/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
@@ -44,7 +44,7 @@ struct shared_info {
unsigned long amr2;
/* AMR value that ptrace should refuse to write to the child. */
- unsigned long amr3;
+ unsigned long invalid_amr;
/* IAMR value the parent expects to read from the child. */
unsigned long expected_iamr;
@@ -57,8 +57,8 @@ struct shared_info {
* (even though they're valid ones) because userspace doesn't have
* access to those registers.
*/
- unsigned long new_iamr;
- unsigned long new_uamor;
+ unsigned long invalid_iamr;
+ unsigned long invalid_uamor;
};
static int sys_pkey_alloc(unsigned long flags, unsigned long init_access_rights)
@@ -100,7 +100,7 @@ static int child(struct shared_info *info)
info->amr1 |= 3ul << pkeyshift(pkey1);
info->amr2 |= 3ul << pkeyshift(pkey2);
- info->amr3 |= info->amr2 | 3ul << pkeyshift(pkey3);
+ info->invalid_amr |= info->amr2 | 3ul << pkeyshift(pkey3);
if (disable_execute)
info->expected_iamr |= 1ul << pkeyshift(pkey1);
@@ -111,8 +111,8 @@ static int child(struct shared_info *info)
info->expected_uamor |= 3ul << pkeyshift(pkey1) |
3ul << pkeyshift(pkey2);
- info->new_iamr |= 1ul << pkeyshift(pkey1) | 1ul << pkeyshift(pkey2);
- info->new_uamor |= 3ul << pkeyshift(pkey1);
+ info->invalid_iamr |= 1ul << pkeyshift(pkey1) | 1ul << pkeyshift(pkey2);
+ info->invalid_uamor |= 3ul << pkeyshift(pkey1);
/*
* We won't use pkey3. We just want a plausible but invalid key to test
@@ -196,9 +196,9 @@ static int parent(struct shared_info *info, pid_t pid)
PARENT_SKIP_IF_UNSUPPORTED(ret, &info->child_sync);
PARENT_FAIL_IF(ret, &info->child_sync);
- info->amr1 = info->amr2 = info->amr3 = regs[0];
- info->expected_iamr = info->new_iamr = regs[1];
- info->expected_uamor = info->new_uamor = regs[2];
+ info->amr1 = info->amr2 = info->invalid_amr = regs[0];
+ info->expected_iamr = info->invalid_iamr = regs[1];
+ info->expected_uamor = info->invalid_uamor = regs[2];
/* Wake up child so that it can set itself up. */
ret = prod_child(&info->child_sync);
@@ -234,10 +234,10 @@ static int parent(struct shared_info *info, pid_t pid)
return ret;
/* Write invalid AMR value in child. */
- ret = ptrace_write_regs(pid, NT_PPC_PKEY, &info->amr3, 1);
+ ret = ptrace_write_regs(pid, NT_PPC_PKEY, &info->invalid_amr, 1);
PARENT_FAIL_IF(ret, &info->child_sync);
- printf("%-30s AMR: %016lx\n", ptrace_write_running, info->amr3);
+ printf("%-30s AMR: %016lx\n", ptrace_write_running, info->invalid_amr);
/* Wake up child so that it can verify it didn't change. */
ret = prod_child(&info->child_sync);
@@ -249,7 +249,7 @@ static int parent(struct shared_info *info, pid_t pid)
/* Try to write to IAMR. */
regs[0] = info->amr1;
- regs[1] = info->new_iamr;
+ regs[1] = info->invalid_iamr;
ret = ptrace_write_regs(pid, NT_PPC_PKEY, regs, 2);
PARENT_FAIL_IF(!ret, &info->child_sync);
@@ -257,7 +257,7 @@ static int parent(struct shared_info *info, pid_t pid)
ptrace_write_running, regs[0], regs[1]);
/* Try to write to IAMR and UAMOR. */
- regs[2] = info->new_uamor;
+ regs[2] = info->invalid_uamor;
ret = ptrace_write_regs(pid, NT_PPC_PKEY, regs, 3);
PARENT_FAIL_IF(!ret, &info->child_sync);
--
2.26.2
^ permalink raw reply related
* [PATCH v2 24/28] powerpc/book3s64/keys: Print information during boot.
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/mm/book3s64/pkeys.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c
index bb127e4e2dd2..5d320ac2ba04 100644
--- a/arch/powerpc/mm/book3s64/pkeys.c
+++ b/arch/powerpc/mm/book3s64/pkeys.c
@@ -207,6 +207,7 @@ void __init pkey_early_init_devtree(void)
*/
initial_allocation_mask |= reserved_allocation_mask;
+ pr_info("Enabling Memory keys with max key count %d", max_pkey);
err_out:
/*
* Setup uamor on boot cpu
--
2.26.2
^ permalink raw reply related
* [PATCH v2 23/28] powerpc/book3s64/hash/kuep: Enable KUEP on hash
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/mm/book3s64/pkeys.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c
index e94585fad5c4..bb127e4e2dd2 100644
--- a/arch/powerpc/mm/book3s64/pkeys.c
+++ b/arch/powerpc/mm/book3s64/pkeys.c
@@ -219,7 +219,12 @@ void __init pkey_early_init_devtree(void)
#ifdef CONFIG_PPC_KUEP
void __init setup_kuep(bool disabled)
{
- if (disabled || !early_radix_enabled())
+ if (disabled)
+ return;
+ /*
+ * On hash if PKEY feature is not enabled, disable KUAP too.
+ */
+ if (!early_radix_enabled() && !early_mmu_has_feature(MMU_FTR_PKEY))
return;
if (smp_processor_id() == boot_cpuid) {
--
2.26.2
^ permalink raw reply related
* [PATCH v2 22/28] powerpc/book3s64/hash/kuap: Enable kuap on hash
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/mm/book3s64/pkeys.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c
index 0f4fc2876fc8..e94585fad5c4 100644
--- a/arch/powerpc/mm/book3s64/pkeys.c
+++ b/arch/powerpc/mm/book3s64/pkeys.c
@@ -240,7 +240,12 @@ void __init setup_kuep(bool disabled)
#ifdef CONFIG_PPC_KUAP
void __init setup_kuap(bool disabled)
{
- if (disabled || !early_radix_enabled())
+ if (disabled)
+ return;
+ /*
+ * On hash if PKEY feature is not enabled, disable KUAP too.
+ */
+ if (!early_radix_enabled() && !early_mmu_has_feature(MMU_FTR_PKEY))
return;
if (smp_processor_id() == boot_cpuid) {
--
2.26.2
^ permalink raw reply related
* [PATCH v2 21/28] powerpc/book3s64/kuep: Use Key 3 to implement KUEP with hash translation.
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
Radix use IAMR Key 0 and hash translation use IAMR key 3.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/include/asm/book3s/64/kup.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include/asm/book3s/64/kup.h
index f704fb615dd5..5b00592479d1 100644
--- a/arch/powerpc/include/asm/book3s/64/kup.h
+++ b/arch/powerpc/include/asm/book3s/64/kup.h
@@ -7,7 +7,7 @@
#define AMR_KUAP_BLOCK_READ UL(0x5455555555555555)
#define AMR_KUAP_BLOCK_WRITE UL(0xa8aaaaaaaaaaaaaa)
-#define AMR_KUEP_BLOCKED (1UL << 62)
+#define AMR_KUEP_BLOCKED UL(0x5455555555555555)
#define AMR_KUAP_BLOCKED (AMR_KUAP_BLOCK_READ | AMR_KUAP_BLOCK_WRITE)
#ifdef __ASSEMBLY__
--
2.26.2
^ permalink raw reply related
* [PATCH v2 20/28] powerpc/book3s64/kuap: Use Key 3 to implement KUAP with hash translation.
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
Radix use AMR Key 0 and hash translation use AMR key 3.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/include/asm/book3s/64/kup.h | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include/asm/book3s/64/kup.h
index 66c97d9d2ed8..f704fb615dd5 100644
--- a/arch/powerpc/include/asm/book3s/64/kup.h
+++ b/arch/powerpc/include/asm/book3s/64/kup.h
@@ -5,11 +5,10 @@
#include <linux/const.h>
#include <asm/reg.h>
-#define AMR_KUAP_BLOCK_READ UL(0x4000000000000000)
-#define AMR_KUAP_BLOCK_WRITE UL(0x8000000000000000)
+#define AMR_KUAP_BLOCK_READ UL(0x5455555555555555)
+#define AMR_KUAP_BLOCK_WRITE UL(0xa8aaaaaaaaaaaaaa)
#define AMR_KUEP_BLOCKED (1UL << 62)
#define AMR_KUAP_BLOCKED (AMR_KUAP_BLOCK_READ | AMR_KUAP_BLOCK_WRITE)
-#define AMR_KUAP_SHIFT 62
#ifdef __ASSEMBLY__
@@ -75,8 +74,8 @@
#ifdef CONFIG_PPC_KUAP_DEBUG
BEGIN_MMU_FTR_SECTION_NESTED(67)
mfspr \gpr1, SPRN_AMR
- li \gpr2, (AMR_KUAP_BLOCKED >> AMR_KUAP_SHIFT)
- sldi \gpr2, \gpr2, AMR_KUAP_SHIFT
+ /* Prevent access to userspace using any key values */
+ LOAD_REG_IMMEDIATE(\gpr2, AMR_KUAP_BLOCKED)
999: tdne \gpr1, \gpr2
EMIT_BUG_ENTRY 999b, __FILE__, __LINE__, (BUGFLAG_WARNING | BUGFLAG_ONCE)
END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_KUAP, 67)
--
2.26.2
^ permalink raw reply related
* [PATCH v2 19/28] powerpc/book3s64/kuap: Improve error reporting with KUAP
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
With hash translation use DSISR_KEYFAULT to identify a wrong access.
With Radix we look at the AMR value and type of fault.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/include/asm/book3s/32/kup.h | 4 +--
arch/powerpc/include/asm/book3s/64/kup.h | 28 ++++++++++++++++----
arch/powerpc/include/asm/kup.h | 4 +--
arch/powerpc/include/asm/nohash/32/kup-8xx.h | 4 +--
arch/powerpc/mm/fault.c | 2 +-
5 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/32/kup.h b/arch/powerpc/include/asm/book3s/32/kup.h
index 3c0ba22dc360..213d3ab40d2d 100644
--- a/arch/powerpc/include/asm/book3s/32/kup.h
+++ b/arch/powerpc/include/asm/book3s/32/kup.h
@@ -176,8 +176,8 @@ static inline void restore_user_access(unsigned long flags)
allow_user_access(to, to, end - addr, KUAP_READ_WRITE);
}
-static inline bool
-bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
+static inline bool bad_kuap_fault(struct pt_regs *regs, unsigned long address,
+ bool is_write, unsigned long error_code)
{
unsigned long begin = regs->kuap & 0xf0000000;
unsigned long end = regs->kuap << 28;
diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include/asm/book3s/64/kup.h
index f097d69ec2c8..66c97d9d2ed8 100644
--- a/arch/powerpc/include/asm/book3s/64/kup.h
+++ b/arch/powerpc/include/asm/book3s/64/kup.h
@@ -317,13 +317,31 @@ static inline void restore_user_access(unsigned long flags)
set_kuap(flags);
}
-static inline bool
-bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
+#define RADIX_KUAP_BLOCK_READ UL(0x4000000000000000)
+#define RADIX_KUAP_BLOCK_WRITE UL(0x8000000000000000)
+
+static inline bool bad_kuap_fault(struct pt_regs *regs, unsigned long address,
+ bool is_write, unsigned long error_code)
{
- return WARN(mmu_has_feature(MMU_FTR_KUAP) &&
- (regs->kuap & (is_write ? AMR_KUAP_BLOCK_WRITE : AMR_KUAP_BLOCK_READ)),
- "Bug: %s fault blocked by AMR!", is_write ? "Write" : "Read");
+ if (!mmu_has_feature(MMU_FTR_KUAP))
+ return false;
+
+ if (radix_enabled()) {
+ /*
+ * Will be a storage protection fault.
+ * Only check the details of AMR[0]
+ */
+ return WARN((regs->kuap & (is_write ? RADIX_KUAP_BLOCK_WRITE : RADIX_KUAP_BLOCK_READ)),
+ "Bug: %s fault blocked by AMR!", is_write ? "Write" : "Read");
+ }
+ /*
+ * We don't want to WARN here because userspace can setup
+ * keys such that a kernel access to user address can cause
+ * fault
+ */
+ return !!(error_code & DSISR_KEYFAULT);
}
+
#else /* CONFIG_PPC_MEM_KEYS */
static inline void kuap_restore_user_amr(struct pt_regs *regs)
{
diff --git a/arch/powerpc/include/asm/kup.h b/arch/powerpc/include/asm/kup.h
index 248438dff74a..249eed77a06b 100644
--- a/arch/powerpc/include/asm/kup.h
+++ b/arch/powerpc/include/asm/kup.h
@@ -57,8 +57,8 @@ static inline void prevent_user_access(void __user *to, const void __user *from,
unsigned long size, unsigned long dir) { }
static inline unsigned long prevent_user_access_return(void) { return 0UL; }
static inline void restore_user_access(unsigned long flags) { }
-static inline bool
-bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
+static inline bool bad_kuap_fault(struct pt_regs *regs, unsigned long address,
+ bool is_write, unsigned long error_code)
{
return false;
}
diff --git a/arch/powerpc/include/asm/nohash/32/kup-8xx.h b/arch/powerpc/include/asm/nohash/32/kup-8xx.h
index 85ed2390fb99..c401e4e404d4 100644
--- a/arch/powerpc/include/asm/nohash/32/kup-8xx.h
+++ b/arch/powerpc/include/asm/nohash/32/kup-8xx.h
@@ -60,8 +60,8 @@ static inline void restore_user_access(unsigned long flags)
mtspr(SPRN_MD_AP, flags);
}
-static inline bool
-bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
+static inline bool bad_kuap_fault(struct pt_regs *regs, unsigned long address,
+ bool is_write, unsigned long error_code)
{
return WARN(!((regs->kuap ^ MD_APG_KUAP) & 0xf0000000),
"Bug: fault blocked by AP register !");
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index 84af6c8eecf7..4e6e7e0fea21 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -233,7 +233,7 @@ static bool bad_kernel_fault(struct pt_regs *regs, unsigned long error_code,
// Read/write fault in a valid region (the exception table search passed
// above), but blocked by KUAP is bad, it can never succeed.
- if (bad_kuap_fault(regs, address, is_write))
+ if (bad_kuap_fault(regs, address, is_write, error_code))
return true;
// What's left? Kernel fault on user in well defined regions (extable
--
2.26.2
^ permalink raw reply related
* [PATCH v2 18/28] powerpc/book3s64/kuap: Restrict access to userspace based on userspace AMR
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
If an application has configured address protection such that read/write is
denied using pkey even the kernel should receive a FAULT on accessing the same.
This patch use user AMR value stored in pt_regs.kuap to achieve the same.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/include/asm/book3s/64/kup.h | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include/asm/book3s/64/kup.h
index 31eb0acddea9..f097d69ec2c8 100644
--- a/arch/powerpc/include/asm/book3s/64/kup.h
+++ b/arch/powerpc/include/asm/book3s/64/kup.h
@@ -279,14 +279,20 @@ static inline void set_kuap(unsigned long value)
static __always_inline void allow_user_access(void __user *to, const void __user *from,
unsigned long size, unsigned long dir)
{
+ unsigned long thread_amr = 0;
+
// This is written so we can resolve to a single case at build time
BUILD_BUG_ON(!__builtin_constant_p(dir));
+
+ if (mmu_has_feature(MMU_FTR_PKEY))
+ thread_amr = current_thread_amr();
+
if (dir == KUAP_READ)
- set_kuap(AMR_KUAP_BLOCK_WRITE);
+ set_kuap(thread_amr | AMR_KUAP_BLOCK_WRITE);
else if (dir == KUAP_WRITE)
- set_kuap(AMR_KUAP_BLOCK_READ);
+ set_kuap(thread_amr | AMR_KUAP_BLOCK_READ);
else if (dir == KUAP_READ_WRITE)
- set_kuap(0);
+ set_kuap(thread_amr);
else
BUILD_BUG();
}
--
2.26.2
^ permalink raw reply related
* [PATCH v2 17/28] powerpc/book3s64/pkeys: Don't update SPRN_AMR when in kernel mode.
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
Now that kernel correctly store/restore userspace AMR/IAMR values, avoid
manipulating AMR and IAMR from the kernel on behalf of userspace.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/include/asm/book3s/64/kup.h | 23 ++++++++
arch/powerpc/include/asm/processor.h | 5 --
arch/powerpc/kernel/process.c | 4 --
arch/powerpc/kernel/traps.c | 6 --
arch/powerpc/mm/book3s64/pkeys.c | 71 ++++--------------------
5 files changed, 34 insertions(+), 75 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include/asm/book3s/64/kup.h
index fe1818954e51..31eb0acddea9 100644
--- a/arch/powerpc/include/asm/book3s/64/kup.h
+++ b/arch/powerpc/include/asm/book3s/64/kup.h
@@ -174,6 +174,29 @@ extern u64 default_uamor;
extern u64 default_amr;
extern u64 default_iamr;
+/*
+ * For kernel thread that doesn't have thread.regs return
+ * default AMR/IAMR values.
+ */
+static inline u64 current_thread_amr(void)
+{
+ if (current->thread.regs)
+ return current->thread.regs->kuap;
+ return AMR_KUAP_BLOCKED;
+}
+
+static inline u64 current_thread_iamr(void)
+{
+ if (current->thread.regs)
+ return current->thread.regs->kuep;
+ return AMR_KUEP_BLOCKED;
+}
+
+static inline u64 read_uamor(void)
+{
+ return default_uamor;
+}
+
static inline void kuap_restore_user_amr(struct pt_regs *regs)
{
if (!mmu_has_feature(MMU_FTR_PKEY))
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index a51964b4ec42..591987da44e2 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -234,11 +234,6 @@ struct thread_struct {
struct thread_vr_state ckvr_state; /* Checkpointed VR state */
unsigned long ckvrsave; /* Checkpointed VRSAVE */
#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
-#ifdef CONFIG_PPC_MEM_KEYS
- unsigned long amr;
- unsigned long iamr;
- unsigned long uamor;
-#endif
#ifdef CONFIG_KVM_BOOK3S_32_HANDLER
void* kvm_shadow_vcpu; /* KVM internal data */
#endif /* CONFIG_KVM_BOOK3S_32_HANDLER */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 0ab9a8cf1bcb..682deeee421f 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -585,7 +585,6 @@ static void save_all(struct task_struct *tsk)
__giveup_spe(tsk);
msr_check_and_clear(msr_all_available);
- thread_pkey_regs_save(&tsk->thread);
}
void flush_all_to_thread(struct task_struct *tsk)
@@ -1097,8 +1096,6 @@ static inline void save_sprs(struct thread_struct *t)
t->tar = mfspr(SPRN_TAR);
}
#endif
-
- thread_pkey_regs_save(t);
}
static inline void restore_sprs(struct thread_struct *old_thread,
@@ -1139,7 +1136,6 @@ static inline void restore_sprs(struct thread_struct *old_thread,
mtspr(SPRN_TIDR, new_thread->tidr);
#endif
- thread_pkey_regs_restore(new_thread, old_thread);
}
struct task_struct *__switch_to(struct task_struct *prev,
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 3fca22276bb1..a47fb49b7af8 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -348,12 +348,6 @@ static bool exception_common(int signr, struct pt_regs *regs, int code,
current->thread.trap_nr = code;
- /*
- * Save all the pkey registers AMR/IAMR/UAMOR. Eg: Core dumps need
- * to capture the content, if the task gets killed.
- */
- thread_pkey_regs_save(¤t->thread);
-
return true;
}
diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c
index 5012b57af808..0f4fc2876fc8 100644
--- a/arch/powerpc/mm/book3s64/pkeys.c
+++ b/arch/powerpc/mm/book3s64/pkeys.c
@@ -264,40 +264,17 @@ void pkey_mm_init(struct mm_struct *mm)
mm->context.execute_only_pkey = execute_only_key;
}
-static inline u64 read_amr(void)
+static inline void update_current_thread_amr(u64 value)
{
- return mfspr(SPRN_AMR);
+ current->thread.regs->kuap = value;
}
-static inline void write_amr(u64 value)
-{
- mtspr(SPRN_AMR, value);
-}
-
-static inline u64 read_iamr(void)
-{
- if (static_branch_unlikely(&execute_pkey_disabled))
- return 0x0UL;
-
- return mfspr(SPRN_IAMR);
-}
-
-static inline void write_iamr(u64 value)
+static inline void update_current_thread_iamr(u64 value)
{
if (static_branch_unlikely(&execute_pkey_disabled))
return;
- mtspr(SPRN_IAMR, value);
-}
-
-static inline u64 read_uamor(void)
-{
- return mfspr(SPRN_UAMOR);
-}
-
-static inline void write_uamor(u64 value)
-{
- mtspr(SPRN_UAMOR, value);
+ current->thread.regs->kuep = value;
}
static bool is_pkey_enabled(int pkey)
@@ -314,20 +291,21 @@ static bool is_pkey_enabled(int pkey)
return !!(uamor_pkey_bits);
}
+/* FIXME!! what happens to other threads AMR value? */
static inline void init_amr(int pkey, u8 init_bits)
{
u64 new_amr_bits = (((u64)init_bits & 0x3UL) << pkeyshift(pkey));
- u64 old_amr = read_amr() & ~((u64)(0x3ul) << pkeyshift(pkey));
+ u64 old_amr = current_thread_amr() & ~((u64)(0x3ul) << pkeyshift(pkey));
- write_amr(old_amr | new_amr_bits);
+ update_current_thread_amr(old_amr | new_amr_bits);
}
static inline void init_iamr(int pkey, u8 init_bits)
{
u64 new_iamr_bits = (((u64)init_bits & 0x1UL) << pkeyshift(pkey));
- u64 old_iamr = read_iamr() & ~((u64)(0x1ul) << pkeyshift(pkey));
+ u64 old_iamr = current_thread_iamr() & ~((u64)(0x1ul) << pkeyshift(pkey));
- write_iamr(old_iamr | new_iamr_bits);
+ update_current_thread_iamr(old_iamr | new_iamr_bits);
}
/*
@@ -360,33 +338,6 @@ int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
return 0;
}
-void thread_pkey_regs_save(struct thread_struct *thread)
-{
- if (!mmu_has_feature(MMU_FTR_PKEY))
- return;
-
- /*
- * TODO: Skip saving registers if @thread hasn't used any keys yet.
- */
- thread->amr = read_amr();
- thread->iamr = read_iamr();
- thread->uamor = read_uamor();
-}
-
-void thread_pkey_regs_restore(struct thread_struct *new_thread,
- struct thread_struct *old_thread)
-{
- if (!mmu_has_feature(MMU_FTR_PKEY))
- return;
-
- if (old_thread->amr != new_thread->amr)
- write_amr(new_thread->amr);
- if (old_thread->iamr != new_thread->iamr)
- write_iamr(new_thread->iamr);
- if (old_thread->uamor != new_thread->uamor)
- write_uamor(new_thread->uamor);
-}
-
int execute_only_pkey(struct mm_struct *mm)
{
if (static_branch_likely(&execute_pkey_disabled))
@@ -440,10 +391,10 @@ static bool pkey_access_permitted(int pkey, bool write, bool execute)
return true;
pkey_shift = pkeyshift(pkey);
- if (execute && !(read_iamr() & (IAMR_EX_BIT << pkey_shift)))
+ if (execute && !(current_thread_iamr() & (IAMR_EX_BIT << pkey_shift)))
return true;
- amr = read_amr(); /* Delay reading amr until absolutely needed */
+ amr = current_thread_amr();
return ((!write && !(amr & (AMR_RD_BIT << pkey_shift))) ||
(write && !(amr & (AMR_WR_BIT << pkey_shift))));
}
--
2.26.2
^ permalink raw reply related
* [PATCH v2 16/28] powerpc/ptrace-view: Use pt_regs values instead of thread_struct based one.
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
We will remove thread.amr/iamr/uamor in a later patch
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/kernel/ptrace/ptrace-view.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/kernel/ptrace/ptrace-view.c b/arch/powerpc/kernel/ptrace/ptrace-view.c
index 15e3b79b6395..5b7bea41c699 100644
--- a/arch/powerpc/kernel/ptrace/ptrace-view.c
+++ b/arch/powerpc/kernel/ptrace/ptrace-view.c
@@ -488,14 +488,25 @@ static int pkey_active(struct task_struct *target, const struct user_regset *reg
static int pkey_get(struct task_struct *target, const struct user_regset *regset,
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
{
- BUILD_BUG_ON(TSO(amr) + sizeof(unsigned long) != TSO(iamr));
- BUILD_BUG_ON(TSO(iamr) + sizeof(unsigned long) != TSO(uamor));
+ int ret;
if (!arch_pkeys_enabled())
return -ENODEV;
- return user_regset_copyout(&pos, &count, &kbuf, &ubuf, &target->thread.amr,
- 0, ELF_NPKEY * sizeof(unsigned long));
+ ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &target->thread.regs->kuap,
+ 0, 1 * sizeof(unsigned long));
+ if (ret)
+ goto err_out;
+
+ ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &target->thread.regs->kuep,
+ 1 * sizeof(unsigned long), 2 * sizeof(unsigned long));
+ if (ret)
+ goto err_out;
+
+ ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &default_uamor,
+ 2 * sizeof(unsigned long), 3 * sizeof(unsigned long));
+err_out:
+ return ret;
}
static int pkey_set(struct task_struct *target, const struct user_regset *regset,
@@ -518,8 +529,8 @@ static int pkey_set(struct task_struct *target, const struct user_regset *regset
return ret;
/* UAMOR determines which bits of the AMR can be set from userspace. */
- target->thread.amr = (new_amr & target->thread.uamor) |
- (target->thread.amr & ~target->thread.uamor);
+ target->thread.regs->kuap = (new_amr & default_uamor) |
+ (target->thread.regs->kuap & ~default_uamor);
return 0;
}
--
2.26.2
^ permalink raw reply related
* [PATCH v2 15/28] powerpc/book3s64/pkeys: Reset userspace AMR correctly on exec
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
On fork, we inherit from the parent and on exec, we should switch to default_amr values.
Also, avoid changing the AMR register value within the kernel. The kernel now runs with
different AMR values.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/include/asm/book3s/64/kup.h | 2 ++
arch/powerpc/kernel/process.c | 19 ++++++++++++++++++-
arch/powerpc/mm/book3s64/pkeys.c | 18 ++----------------
3 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include/asm/book3s/64/kup.h
index 67320a990f3f..fe1818954e51 100644
--- a/arch/powerpc/include/asm/book3s/64/kup.h
+++ b/arch/powerpc/include/asm/book3s/64/kup.h
@@ -171,6 +171,8 @@
#include <asm/ptrace.h>
extern u64 default_uamor;
+extern u64 default_amr;
+extern u64 default_iamr;
static inline void kuap_restore_user_amr(struct pt_regs *regs)
{
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 9ef95a1217ef..0ab9a8cf1bcb 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1474,7 +1474,25 @@ void arch_setup_new_exec(void)
current->thread.regs = regs - 1;
}
+#ifdef CONFIG_PPC_MEM_KEYS
+ current->thread.regs->kuap = default_amr;
+ current->thread.regs->kuep = default_iamr;
+#endif
+
}
+#else
+void arch_setup_new_exec(void)
+{
+ /*
+ * If we exec out of a kernel thread then thread.regs will not be
+ * set. Do it now.
+ */
+ if (!current->thread.regs) {
+ struct pt_regs *regs = task_stack_page(current) + THREAD_SIZE;
+ current->thread.regs = regs - 1;
+ }
+}
+
#endif
#ifdef CONFIG_PPC64
@@ -1809,7 +1827,6 @@ void start_thread(struct pt_regs *regs, unsigned long start, unsigned long sp)
current->thread.load_tm = 0;
#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
- thread_pkey_regs_init(¤t->thread);
}
EXPORT_SYMBOL(start_thread);
diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c
index 976f65f27324..5012b57af808 100644
--- a/arch/powerpc/mm/book3s64/pkeys.c
+++ b/arch/powerpc/mm/book3s64/pkeys.c
@@ -20,8 +20,8 @@ int max_pkey; /* Maximum key value supported */
*/
u32 reserved_allocation_mask;
static u32 initial_allocation_mask; /* Bits set for the initially allocated keys */
-static u64 default_amr;
-static u64 default_iamr;
+u64 default_amr;
+u64 default_iamr;
/* Allow all keys to be modified by default */
u64 default_uamor = ~0x0UL;
/*
@@ -387,20 +387,6 @@ void thread_pkey_regs_restore(struct thread_struct *new_thread,
write_uamor(new_thread->uamor);
}
-void thread_pkey_regs_init(struct thread_struct *thread)
-{
- if (!mmu_has_feature(MMU_FTR_PKEY))
- return;
-
- thread->amr = default_amr;
- thread->iamr = default_iamr;
- thread->uamor = default_uamor;
-
- write_amr(default_amr);
- write_iamr(default_iamr);
- write_uamor(default_uamor);
-}
-
int execute_only_pkey(struct mm_struct *mm)
{
if (static_branch_likely(&execute_pkey_disabled))
--
2.26.2
^ permalink raw reply related
* [PATCH v2 14/28] powerpc/book3s64/pkeys: Inherit correctly on fork.
From: Aneesh Kumar K.V @ 2020-05-02 11:22 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, linuxram, bauerman, npiggin
In-Reply-To: <20200502112229.545331-1-aneesh.kumar@linux.ibm.com>
Child thread.kuap value is inherited from the parent in copy_thread_tls. We still
need to make sure when the child returns from a fork in the kernel we start with the kernel
default AMR value.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/kernel/process.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index abbe545ed88c..9ef95a1217ef 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1677,6 +1677,13 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
childregs->ppr = DEFAULT_PPR;
p->thread.tidr = 0;
+#endif
+ /*
+ * Run with the current AMR value of the kernel
+ */
+#if defined(CONFIG_PPC_MEM_KEYS)
+ kregs->kuap = AMR_KUAP_BLOCKED;
+ kregs->kuep = AMR_KUEP_BLOCKED;
#endif
kregs->nip = ppc_function_entry(f);
return 0;
--
2.26.2
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox