* [PATCH v2 2/2] powerpc/mm/radix: Use the right page size for vmemmap mapping
From: Aneesh Kumar K.V @ 2019-07-01 14:34 UTC (permalink / raw)
To: npiggin, paulus, mpe; +Cc: Aneesh Kumar K.V, linuxppc-dev
In-Reply-To: <20190701143442.17174-1-aneesh.kumar@linux.ibm.com>
We use mmu_vmemmap_psize to find the page size for mapping the vmmemap area.
With radix translation, we are suboptimally setting this value to PAGE_SIZE.
We do check for 2M page size support and update mmu_vmemap_psize to use
hugepage size but we suboptimally reset the value to PAGE_SIZE in
radix__early_init_mmu(). This resulted in always mapping vmemmap area with
64K page size.
Fixes: 2bfd65e45e87 ("powerpc/mm/radix: Add radix callbacks for early init routines")
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/mm/book3s64/radix_pgtable.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index 273ae66a9a45..8deb432c2975 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -515,14 +515,6 @@ void __init radix__early_init_devtree(void)
mmu_psize_defs[MMU_PAGE_64K].shift = 16;
mmu_psize_defs[MMU_PAGE_64K].ap = 0x5;
found:
-#ifdef CONFIG_SPARSEMEM_VMEMMAP
- if (mmu_psize_defs[MMU_PAGE_2M].shift) {
- /*
- * map vmemmap using 2M if available
- */
- mmu_vmemmap_psize = MMU_PAGE_2M;
- }
-#endif /* CONFIG_SPARSEMEM_VMEMMAP */
return;
}
@@ -587,7 +579,13 @@ void __init radix__early_init_mmu(void)
#ifdef CONFIG_SPARSEMEM_VMEMMAP
/* vmemmap mapping */
- mmu_vmemmap_psize = mmu_virtual_psize;
+ if (mmu_psize_defs[MMU_PAGE_2M].shift) {
+ /*
+ * map vmemmap using 2M if available
+ */
+ mmu_vmemmap_psize = MMU_PAGE_2M;
+ } else
+ mmu_vmemmap_psize = mmu_virtual_psize;
#endif
/*
* initialize page table size
--
2.21.0
^ permalink raw reply related
* [PATCH v2 1/3] powerpc/mm/drconf: Use NUMA_NO_NODE on failures instead of node 0
From: Aneesh Kumar K.V @ 2019-07-01 14:36 UTC (permalink / raw)
To: npiggin, paulus, mpe; +Cc: Vaibhav Jain, linuxppc-dev, Aneesh Kumar K.V
If we fail to parse the associativity array we should default to
NUMA_NO_NODE instead of NODE 0. Rest of the code fallback to the
right default if we find the numa node value NUMA_NO_NODE.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/mm/numa.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 917904d2fe97..aee718509085 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -416,17 +416,19 @@ static int of_get_assoc_arrays(struct assoc_arrays *aa)
static int of_drconf_to_nid_single(struct drmem_lmb *lmb)
{
struct assoc_arrays aa = { .arrays = NULL };
- int default_nid = 0;
+ int default_nid = NUMA_NO_NODE;
int nid = default_nid;
int rc, index;
+ if (min_common_depth < 0)
+ return default_nid;
+
rc = of_get_assoc_arrays(&aa);
if (rc)
return default_nid;
- if (min_common_depth > 0 && min_common_depth <= aa.array_sz &&
- !(lmb->flags & DRCONF_MEM_AI_INVALID) &&
- lmb->aa_index < aa.n_arrays) {
+ if (min_common_depth <= aa.array_sz &&
+ !(lmb->flags & DRCONF_MEM_AI_INVALID) && lmb->aa_index < aa.n_arrays) {
index = lmb->aa_index * aa.array_sz + min_common_depth - 1;
nid = of_read_number(&aa.arrays[index], 1);
--
2.21.0
^ permalink raw reply related
* [PATCH v2 2/3] powerpc/mm: Fix node look up with numa=off boot
From: Aneesh Kumar K.V @ 2019-07-01 14:36 UTC (permalink / raw)
To: npiggin, paulus, mpe; +Cc: Vaibhav Jain, linuxppc-dev, Aneesh Kumar K.V
In-Reply-To: <20190701143626.17628-1-aneesh.kumar@linux.ibm.com>
If we boot with numa=off, we need to make sure we return NUMA_NO_NODE when
looking up associativity details of resources. Without this, we hit crash
like below
BUG: Unable to handle kernel data access at 0x40000000008
Faulting instruction address: 0xc000000008f31704
cpu 0x1b: Vector: 380 (Data SLB Access) at [c00000000b9bb320]
pc: c000000008f31704: _raw_spin_lock+0x14/0x100
lr: c0000000083f41fc: ____cache_alloc_node+0x5c/0x290
sp: c00000000b9bb5b0
msr: 800000010280b033
dar: 40000000008
current = 0xc00000000b9a2700
paca = 0xc00000000a740c00 irqmask: 0x03 irq_happened: 0x01
pid = 1, comm = swapper/27
Linux version 5.2.0-rc4-00925-g74e188c620b1 (root@linux-d8ip) (gcc version 7.4.1 20190424 [gcc-7-branch revision 270538] (SUSE Linux)) #34 SMP Sat Jun 29 00:41:02 EDT 2019
enter ? for help
[link register ] c0000000083f41fc ____cache_alloc_node+0x5c/0x290
[c00000000b9bb5b0] 0000000000000dc0 (unreliable)
[c00000000b9bb5f0] c0000000083f48c8 kmem_cache_alloc_node_trace+0x138/0x360
[c00000000b9bb670] c000000008aa789c devres_alloc_node+0x4c/0xa0
[c00000000b9bb6a0] c000000008337218 devm_memremap+0x58/0x130
[c00000000b9bb6f0] c000000008aed00c devm_nsio_enable+0xdc/0x170
[c00000000b9bb780] c000000008af3b6c nd_pmem_probe+0x4c/0x180
[c00000000b9bb7b0] c000000008ad84cc nvdimm_bus_probe+0xac/0x260
[c00000000b9bb840] c000000008aa0628 really_probe+0x148/0x500
[c00000000b9bb8d0] c000000008aa0d7c driver_probe_device+0x19c/0x1d0
[c00000000b9bb950] c000000008aa11bc device_driver_attach+0xcc/0x100
[c00000000b9bb990] c000000008aa12ec __driver_attach+0xfc/0x1e0
[c00000000b9bba10] c000000008a9d0a4 bus_for_each_dev+0xb4/0x130
[c00000000b9bba70] c000000008a9fc04 driver_attach+0x34/0x50
[c00000000b9bba90] c000000008a9f118 bus_add_driver+0x1d8/0x300
[c00000000b9bbb20] c000000008aa2358 driver_register+0x98/0x1a0
[c00000000b9bbb90] c000000008ad7e6c __nd_driver_register+0x5c/0x100
[c00000000b9bbbf0] c0000000093efbac nd_pmem_driver_init+0x34/0x48
[c00000000b9bbc10] c0000000080106c0 do_one_initcall+0x60/0x2d0
[c00000000b9bbce0] c00000000938463c kernel_init_freeable+0x384/0x48c
[c00000000b9bbdb0] c000000008010a5c kernel_init+0x2c/0x160
[c00000000b9bbe20] c00000000800ba54 ret_from_kernel_thread+0x5c/0x68
Reported-and-debugged-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/mm/numa.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index aee718509085..27f792c0df68 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -212,7 +212,7 @@ static int associativity_to_nid(const __be32 *associativity)
{
int nid = NUMA_NO_NODE;
- if (min_common_depth == -1)
+ if (min_common_depth == -1 || !numa_enabled)
goto out;
if (of_read_number(associativity, 1) >= min_common_depth)
@@ -420,7 +420,7 @@ static int of_drconf_to_nid_single(struct drmem_lmb *lmb)
int nid = default_nid;
int rc, index;
- if (min_common_depth < 0)
+ if ((min_common_depth < 0) || !numa_enabled)
return default_nid;
rc = of_get_assoc_arrays(&aa);
@@ -810,7 +810,7 @@ static void __init find_possible_nodes(void)
struct device_node *rtas;
u32 numnodes, i;
- if (min_common_depth <= 0)
+ if (min_common_depth <= 0 || !numa_enabled)
return;
rtas = of_find_node_by_path("/rtas");
--
2.21.0
^ permalink raw reply related
* [PATCH v2 3/3] powerpc/mm: Consolidate numa_enable check and min_common_depth check
From: Aneesh Kumar K.V @ 2019-07-01 14:36 UTC (permalink / raw)
To: npiggin, paulus, mpe; +Cc: Vaibhav Jain, linuxppc-dev, Aneesh Kumar K.V
In-Reply-To: <20190701143626.17628-1-aneesh.kumar@linux.ibm.com>
If we fail to parse min_common_depth from device tree we boot with
numa disabled. Reflect the same by updating numa_enabled variable
to false. Also, switch all min_common_depth failure check to
if (!numa_enabled) check.
This helps us to avoid checking for both in different code paths.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/mm/numa.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 27f792c0df68..848b4663c7ad 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -212,7 +212,7 @@ static int associativity_to_nid(const __be32 *associativity)
{
int nid = NUMA_NO_NODE;
- if (min_common_depth == -1 || !numa_enabled)
+ if (!numa_enabled)
goto out;
if (of_read_number(associativity, 1) >= min_common_depth)
@@ -628,8 +628,14 @@ static int __init parse_numa_properties(void)
min_common_depth = find_min_common_depth();
- if (min_common_depth < 0)
+ if (min_common_depth < 0) {
+ /*
+ * if we fail to parse min_common_depth from device tree
+ * mark the numa disabled, boot with numa disabled.
+ */
+ numa_enabled = false;
return min_common_depth;
+ }
dbg("NUMA associativity depth for CPU/Memory: %d\n", min_common_depth);
@@ -745,7 +751,7 @@ void __init dump_numa_cpu_topology(void)
unsigned int node;
unsigned int cpu, count;
- if (min_common_depth == -1 || !numa_enabled)
+ if (!numa_enabled)
return;
for_each_online_node(node) {
@@ -810,7 +816,7 @@ static void __init find_possible_nodes(void)
struct device_node *rtas;
u32 numnodes, i;
- if (min_common_depth <= 0 || !numa_enabled)
+ if (!numa_enabled)
return;
rtas = of_find_node_by_path("/rtas");
@@ -1012,7 +1018,7 @@ int hot_add_scn_to_nid(unsigned long scn_addr)
struct device_node *memory = NULL;
int nid;
- if (!numa_enabled || (min_common_depth < 0))
+ if (!numa_enabled)
return first_online_node;
memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
--
2.21.0
^ permalink raw reply related
* [PATCH] powerpc: Remove unused variable declaration
From: Aneesh Kumar K.V @ 2019-07-01 14:37 UTC (permalink / raw)
To: npiggin, paulus, mpe; +Cc: Aneesh Kumar K.V, linuxppc-dev
__kernel_virt_size is not used anymore.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/include/asm/book3s/64/pgtable.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 7dede2e34b70..a3eab10f5a27 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -275,7 +275,6 @@ extern unsigned long __vmalloc_end;
#define VMALLOC_END __vmalloc_end
extern unsigned long __kernel_virt_start;
-extern unsigned long __kernel_virt_size;
extern unsigned long __kernel_io_start;
extern unsigned long __kernel_io_end;
#define KERN_VIRT_START __kernel_virt_start
--
2.21.0
^ permalink raw reply related
* Re: [PATCH v12 00/11] Appended signatures support for IMA appraisal
From: Mimi Zohar @ 2019-07-01 14:38 UTC (permalink / raw)
To: Thiago Jung Bauermann, linux-integrity
Cc: Herbert Xu, linux-doc, Dmitry Kasatkin, David S. Miller,
Jonathan Corbet, linux-kernel, James Morris, David Howells,
AKASHI, Takahiro, linux-security-module, keyrings, linux-crypto,
Jessica Yu, linuxppc-dev, David Woodhouse, Serge E. Hallyn
In-Reply-To: <20190628021934.4260-1-bauerman@linux.ibm.com>
On Thu, 2019-06-27 at 23:19 -0300, Thiago Jung Bauermann wrote:
> Hello,
>
> This version is essentially identical to the last one.
>
> It is only a rebase on top of today's linux-integrity/next-queued-testing,
> prompted by conflicts with Prakhar Srivastava's patches to measure the
> kernel command line. It also drops two patches that are already present in
> that branch.
Thanks, Thiago. These patches are now in next-queued-testing waiting
for some additional reviews/acks.
Mimi
^ permalink raw reply
* Re: [PATCH v12 01/11] MODSIGN: Export module signature definitions
From: Jessica Yu @ 2019-07-01 14:47 UTC (permalink / raw)
To: Thiago Jung Bauermann
Cc: Herbert Xu, linux-doc, Dmitry Kasatkin, David S. Miller,
Jonathan Corbet, linux-kernel, Mimi Zohar, James Morris,
David Howells, AKASHI, Takahiro, linux-security-module, keyrings,
linux-crypto, linux-integrity, linuxppc-dev, David Woodhouse,
Serge E. Hallyn
In-Reply-To: <20190628021934.4260-2-bauerman@linux.ibm.com>
+++ Thiago Jung Bauermann [27/06/19 23:19 -0300]:
>IMA will use the module_signature format for append signatures, so export
>the relevant definitions and factor out the code which verifies that the
>appended signature trailer is valid.
>
>Also, create a CONFIG_MODULE_SIG_FORMAT option so that IMA can select it
>and be able to use mod_check_sig() without having to depend on either
>CONFIG_MODULE_SIG or CONFIG_MODULES.
>
>Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
>Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
>Cc: Jessica Yu <jeyu@kernel.org>
>---
> include/linux/module.h | 3 --
> include/linux/module_signature.h | 44 +++++++++++++++++++++++++
> init/Kconfig | 6 +++-
> kernel/Makefile | 1 +
> kernel/module.c | 1 +
> kernel/module_signature.c | 46 ++++++++++++++++++++++++++
> kernel/module_signing.c | 56 +++++---------------------------
> scripts/Makefile | 2 +-
> 8 files changed, 106 insertions(+), 53 deletions(-)
>
>diff --git a/include/linux/module.h b/include/linux/module.h
>index 188998d3dca9..aa56f531cf1e 100644
>--- a/include/linux/module.h
>+++ b/include/linux/module.h
>@@ -25,9 +25,6 @@
> #include <linux/percpu.h>
> #include <asm/module.h>
>
>-/* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
>-#define MODULE_SIG_STRING "~Module signature appended~\n"
>-
Hi Thiago, apologies for the delay.
It looks like arch/s390/kernel/machine_kexec_file.c also relies on
MODULE_SIG_STRING being defined, so module_signature.h will need to be
included there too, otherwise we'll run into a compilation error.
Other than that, the module-related changes look good to me:
Acked-by: Jessica Yu <jeyu@kernel.org>
Thanks!
Jessica
> /* Not Yet Implemented */
> #define MODULE_SUPPORTED_DEVICE(name)
>
>diff --git a/include/linux/module_signature.h b/include/linux/module_signature.h
>new file mode 100644
>index 000000000000..523617fc5b6a
>--- /dev/null
>+++ b/include/linux/module_signature.h
>@@ -0,0 +1,44 @@
>+/* SPDX-License-Identifier: GPL-2.0+ */
>+/*
>+ * Module signature handling.
>+ *
>+ * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
>+ * Written by David Howells (dhowells@redhat.com)
>+ */
>+
>+#ifndef _LINUX_MODULE_SIGNATURE_H
>+#define _LINUX_MODULE_SIGNATURE_H
>+
>+/* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
>+#define MODULE_SIG_STRING "~Module signature appended~\n"
>+
>+enum pkey_id_type {
>+ PKEY_ID_PGP, /* OpenPGP generated key ID */
>+ PKEY_ID_X509, /* X.509 arbitrary subjectKeyIdentifier */
>+ PKEY_ID_PKCS7, /* Signature in PKCS#7 message */
>+};
>+
>+/*
>+ * Module signature information block.
>+ *
>+ * The constituents of the signature section are, in order:
>+ *
>+ * - Signer's name
>+ * - Key identifier
>+ * - Signature data
>+ * - Information block
>+ */
>+struct module_signature {
>+ u8 algo; /* Public-key crypto algorithm [0] */
>+ u8 hash; /* Digest algorithm [0] */
>+ u8 id_type; /* Key identifier type [PKEY_ID_PKCS7] */
>+ u8 signer_len; /* Length of signer's name [0] */
>+ u8 key_id_len; /* Length of key identifier [0] */
>+ u8 __pad[3];
>+ __be32 sig_len; /* Length of signature data */
>+};
>+
>+int mod_check_sig(const struct module_signature *ms, size_t file_len,
>+ const char *name);
>+
>+#endif /* _LINUX_MODULE_SIGNATURE_H */
>diff --git a/init/Kconfig b/init/Kconfig
>index 8b9ffe236e4f..c2286a3c74c5 100644
>--- a/init/Kconfig
>+++ b/init/Kconfig
>@@ -1852,6 +1852,10 @@ config BASE_SMALL
> default 0 if BASE_FULL
> default 1 if !BASE_FULL
>
>+config MODULE_SIG_FORMAT
>+ def_bool n
>+ select SYSTEM_DATA_VERIFICATION
>+
> menuconfig MODULES
> bool "Enable loadable module support"
> option modules
>@@ -1929,7 +1933,7 @@ config MODULE_SRCVERSION_ALL
> config MODULE_SIG
> bool "Module signature verification"
> depends on MODULES
>- select SYSTEM_DATA_VERIFICATION
>+ select MODULE_SIG_FORMAT
> help
> Check modules for valid signatures upon load: the signature
> is simply appended to the module. For more information see
>diff --git a/kernel/Makefile b/kernel/Makefile
>index 33824f0385b3..f29ae2997a43 100644
>--- a/kernel/Makefile
>+++ b/kernel/Makefile
>@@ -58,6 +58,7 @@ endif
> obj-$(CONFIG_UID16) += uid16.o
> obj-$(CONFIG_MODULES) += module.o
> obj-$(CONFIG_MODULE_SIG) += module_signing.o
>+obj-$(CONFIG_MODULE_SIG_FORMAT) += module_signature.o
> obj-$(CONFIG_KALLSYMS) += kallsyms.o
> obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
> obj-$(CONFIG_CRASH_CORE) += crash_core.o
>diff --git a/kernel/module.c b/kernel/module.c
>index 6e6712b3aaf5..2712f4d217f5 100644
>--- a/kernel/module.c
>+++ b/kernel/module.c
>@@ -19,6 +19,7 @@
> #include <linux/export.h>
> #include <linux/extable.h>
> #include <linux/moduleloader.h>
>+#include <linux/module_signature.h>
> #include <linux/trace_events.h>
> #include <linux/init.h>
> #include <linux/kallsyms.h>
>diff --git a/kernel/module_signature.c b/kernel/module_signature.c
>new file mode 100644
>index 000000000000..4224a1086b7d
>--- /dev/null
>+++ b/kernel/module_signature.c
>@@ -0,0 +1,46 @@
>+// SPDX-License-Identifier: GPL-2.0+
>+/*
>+ * Module signature checker
>+ *
>+ * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
>+ * Written by David Howells (dhowells@redhat.com)
>+ */
>+
>+#include <linux/errno.h>
>+#include <linux/printk.h>
>+#include <linux/module_signature.h>
>+#include <asm/byteorder.h>
>+
>+/**
>+ * mod_check_sig - check that the given signature is sane
>+ *
>+ * @ms: Signature to check.
>+ * @file_len: Size of the file to which @ms is appended.
>+ * @name: What is being checked. Used for error messages.
>+ */
>+int mod_check_sig(const struct module_signature *ms, size_t file_len,
>+ const char *name)
>+{
>+ if (be32_to_cpu(ms->sig_len) >= file_len - sizeof(*ms))
>+ return -EBADMSG;
>+
>+ if (ms->id_type != PKEY_ID_PKCS7) {
>+ pr_err("%s: Module is not signed with expected PKCS#7 message\n",
>+ name);
>+ return -ENOPKG;
>+ }
>+
>+ if (ms->algo != 0 ||
>+ ms->hash != 0 ||
>+ ms->signer_len != 0 ||
>+ ms->key_id_len != 0 ||
>+ ms->__pad[0] != 0 ||
>+ ms->__pad[1] != 0 ||
>+ ms->__pad[2] != 0) {
>+ pr_err("%s: PKCS#7 signature info has unexpected non-zero params\n",
>+ name);
>+ return -EBADMSG;
>+ }
>+
>+ return 0;
>+}
>diff --git a/kernel/module_signing.c b/kernel/module_signing.c
>index 6b9a926fd86b..cdd04a6b8074 100644
>--- a/kernel/module_signing.c
>+++ b/kernel/module_signing.c
>@@ -11,37 +11,13 @@
>
> #include <linux/kernel.h>
> #include <linux/errno.h>
>+#include <linux/module.h>
>+#include <linux/module_signature.h>
> #include <linux/string.h>
> #include <linux/verification.h>
> #include <crypto/public_key.h>
> #include "module-internal.h"
>
>-enum pkey_id_type {
>- PKEY_ID_PGP, /* OpenPGP generated key ID */
>- PKEY_ID_X509, /* X.509 arbitrary subjectKeyIdentifier */
>- PKEY_ID_PKCS7, /* Signature in PKCS#7 message */
>-};
>-
>-/*
>- * Module signature information block.
>- *
>- * The constituents of the signature section are, in order:
>- *
>- * - Signer's name
>- * - Key identifier
>- * - Signature data
>- * - Information block
>- */
>-struct module_signature {
>- u8 algo; /* Public-key crypto algorithm [0] */
>- u8 hash; /* Digest algorithm [0] */
>- u8 id_type; /* Key identifier type [PKEY_ID_PKCS7] */
>- u8 signer_len; /* Length of signer's name [0] */
>- u8 key_id_len; /* Length of key identifier [0] */
>- u8 __pad[3];
>- __be32 sig_len; /* Length of signature data */
>-};
>-
> /*
> * Verify the signature on a module.
> */
>@@ -49,6 +25,7 @@ int mod_verify_sig(const void *mod, struct load_info *info)
> {
> struct module_signature ms;
> size_t sig_len, modlen = info->len;
>+ int ret;
>
> pr_devel("==>%s(,%zu)\n", __func__, modlen);
>
>@@ -56,32 +33,15 @@ int mod_verify_sig(const void *mod, struct load_info *info)
> return -EBADMSG;
>
> memcpy(&ms, mod + (modlen - sizeof(ms)), sizeof(ms));
>- modlen -= sizeof(ms);
>+
>+ ret = mod_check_sig(&ms, modlen, info->name);
>+ if (ret)
>+ return ret;
>
> sig_len = be32_to_cpu(ms.sig_len);
>- if (sig_len >= modlen)
>- return -EBADMSG;
>- modlen -= sig_len;
>+ modlen -= sig_len + sizeof(ms);
> info->len = modlen;
>
>- if (ms.id_type != PKEY_ID_PKCS7) {
>- pr_err("%s: Module is not signed with expected PKCS#7 message\n",
>- info->name);
>- return -ENOPKG;
>- }
>-
>- if (ms.algo != 0 ||
>- ms.hash != 0 ||
>- ms.signer_len != 0 ||
>- ms.key_id_len != 0 ||
>- ms.__pad[0] != 0 ||
>- ms.__pad[1] != 0 ||
>- ms.__pad[2] != 0) {
>- pr_err("%s: PKCS#7 signature info has unexpected non-zero params\n",
>- info->name);
>- return -EBADMSG;
>- }
>-
> return verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len,
> VERIFY_USE_SECONDARY_KEYRING,
> VERIFYING_MODULE_SIGNATURE,
>diff --git a/scripts/Makefile b/scripts/Makefile
>index 9d442ee050bd..52098b080ab7 100644
>--- a/scripts/Makefile
>+++ b/scripts/Makefile
>@@ -17,7 +17,7 @@ hostprogs-$(CONFIG_VT) += conmakehash
> hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount
> hostprogs-$(CONFIG_BUILDTIME_EXTABLE_SORT) += sortextable
> hostprogs-$(CONFIG_ASN1) += asn1_compiler
>-hostprogs-$(CONFIG_MODULE_SIG) += sign-file
>+hostprogs-$(CONFIG_MODULE_SIG_FORMAT) += sign-file
> hostprogs-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += extract-cert
> hostprogs-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
>
^ permalink raw reply
* Re: remove asm-generic/ptrace.h v3
From: Arnd Bergmann @ 2019-07-01 15:40 UTC (permalink / raw)
To: Thomas Gleixner
Cc: linux-arch, Linux-sh list, Linux Kernel Mailing List,
the arch/x86 maintainers, linux-mips, Oleg Nesterov, linuxppc-dev,
Christoph Hellwig, Linux ARM
In-Reply-To: <alpine.DEB.2.21.1906240922420.32342@nanos.tec.linutronix.de>
On Mon, Jun 24, 2019 at 9:23 AM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> On Mon, 24 Jun 2019, Christoph Hellwig wrote:
> >
> > asm-generic/ptrace.h is a little weird in that it doesn't actually
> > implement any functionality, but it provided multiple layers of macros
> > that just implement trivial inline functions. We implement those
> > directly in the few architectures and be off with a much simpler
> > design.
> >
> > I'm not sure which tree is the right place, but may this can go through
> > the asm-generic tree since it removes an asm-generic header?
>
> Makes sense.
Applied and pushed to asm-generic.git/master now, sorry for the delay.
Arnd
^ permalink raw reply
* Re: Can I compile Linux Kernel 5.2-rc7 for PowerPC on Intel/AMD x86 hardware?
From: Christophe Leroy @ 2019-07-01 16:17 UTC (permalink / raw)
To: Turritopsis Dohrnii Teo En Ming, linuxppc-dev@lists.ozlabs.org
In-Reply-To: <SG2PR01MB2141EE2AEA0C727527DAC4B087F90@SG2PR01MB2141.apcprd01.prod.exchangelabs.com>
Le 01/07/2019 à 15:39, Turritopsis Dohrnii Teo En Ming a écrit :
> Good evening from Singapore,
Good evening afternoon from Paris,
>
> Can I compile Linux Kernel 5.2-rc7 for PowerPC on Intel/AMD x86 hardware, for example, AMD Ryzen 9 3950X, with 16 CPU cores and 32 threads?
Yes you can
>
> Is it called cross-compiling?
Yes it is, you can get cross compilers at
https://mirrors.edge.kernel.org/pub/tools/crosstool/
Thanks
Christophe
>
> Thank you.
>
> -----BEGIN EMAIL SIGNATURE-----
>
> The Gospel for all Targeted Individuals (TIs):
>
> [The New York Times] Microwave Weapons Are Prime Suspect in Ills of
> U.S. Embassy Workers
>
> Link: https://www.nytimes.com/2018/09/01/science/sonic-attack-cuba-microwave.html
>
> ********************************************************************************************
>
> Singaporean Mr. Turritopsis Dohrnii Teo En Ming's Academic
> Qualifications as at 14 Feb 2019
>
> [1] https://tdtemcerts.wordpress.com/
>
> [2] https://tdtemcerts.blogspot.sg/
>
> [3] https://www.scribd.com/user/270125049/Teo-En-Ming
>
> -----END EMAIL SIGNATURE-----
>
^ permalink raw reply
* Re: ["RFC PATCH" 1/2] powerpc/mm: Fix node look up with numa=off boot
From: Nathan Lynch @ 2019-07-01 16:42 UTC (permalink / raw)
To: Aneesh Kumar K.V; +Cc: Vaibhav Jain, paulus, linuxppc-dev, npiggin
In-Reply-To: <1329fd62-c2ad-f2c9-d3df-731f543dd3ea@linux.ibm.com>
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> writes:
> I guess we should have here.
>
> modified arch/powerpc/mm/numa.c
> @@ -416,12 +416,11 @@ static int of_get_assoc_arrays(struct assoc_arrays
> *aa)
> static int of_drconf_to_nid_single(struct drmem_lmb *lmb)
> {
> struct assoc_arrays aa = { .arrays = NULL };
> - /* is that correct? */
> int default_nid = 0;
> int nid = default_nid;
> int rc, index;
>
> - if (!numa_enabled)
> + if ((min_common_depth < 0) || !numa_enabled)
> return NUMA_NO_NODE;
>
> rc = of_get_assoc_arrays(&aa);
>
>
> Nathan,
>
> Can you check this?
Looks like it would do the right thing.
Just checking: do people still need numa=off? Seems like it's a
maintenance burden :-)
^ permalink raw reply
* Re: [PATCH RFC] generic ELF support for kexec
From: Sven Schnelle @ 2019-07-01 17:08 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linux-s390, deller, kexec, linuxppc-dev
In-Reply-To: <87o92isbxg.fsf@concordia.ellerman.id.au>
Hi Michael,
On Fri, Jun 28, 2019 at 12:04:11PM +1000, Michael Ellerman wrote:
> Sven Schnelle <svens@stackframe.org> writes:
> https://github.com/linuxppc/wiki/wiki/Booting-with-Qemu
>
> But I'm not sure where you get a version of kexec that uses kexec_file().
kexec-tools HEAD supports it, so that's not a problem.
> > If that change is acceptable i would finish the patch and submit it. I think
> > best would be to push this change through Helge's parisc tree, so we don't
> > have any dependencies to sort out.
>
> That will work for you but could cause us problems if we have any
> changes that touch that code.
>
> It's easy enough to create a topic branch with just that patch that both
> of us merge.
What should be the base branch for that patch? Christophe suggested the
powerpc/merge branch?
> > #include <linux/elf.h>
> > #include <linux/kexec.h>
> > #include <linux/libfdt.h>
> > @@ -31,540 +29,6 @@
> > #include <linux/slab.h>
> > #include <linux/types.h>
> >
> > -#define PURGATORY_STACK_SIZE (16 * 1024)
>
> This is unused AFAICS. We should probably remove it explicitly rather
> than as part of this patch.
I have one patch right now. If wanted i can split up all the changes
suggested during the review into smaller pieces, whatever you prefer.
> Or that.
>
> > +#include <linux/slab.h>
> > +#include <linux/types.h>
> > +
> > +#define elf_addr_to_cpu elf64_to_cpu
>
> Why are we doing that rather than just using elf64_to_cpu directly?
>
> > +#ifndef Elf_Rel
> > +#define Elf_Rel Elf64_Rel
> > +#endif /* Elf_Rel */
>
> And that?
Don't know - ask the PPC people :-)
Regards
Sven
^ permalink raw reply
* Re: [PATCH RFC] generic ELF support for kexec
From: Sven Schnelle @ 2019-07-01 18:11 UTC (permalink / raw)
To: Philipp Rudo; +Cc: linux-s390, deller, kexec, linuxppc-dev
In-Reply-To: <20190701143120.20c71b30@laptop-ibm>
Hi Philipp,
On Mon, Jul 01, 2019 at 02:31:20PM +0200, Philipp Rudo wrote:
> Sven Schnelle <svens@stackframe.org> wrote:
>
> > I'm attaching the patch to this Mail. What do you think about that change?
> > s390 also uses ELF files, and (maybe?) could also switch to this implementation.
> > But i don't know anything about S/390 and don't have one in my basement. So
> > i'll leave s390 to the IBM folks.
>
> I'm afraid there isn't much code here s390 can reuse. I see multiple problems
> in kexec_elf_load:
>
> * while loading the phdrs we also need to setup some data structures to pass
> to the next kernel
> * the s390 kernel needs to be loaded to a fixed address
> * there is no support to load a crash kernel
>
> Of course that could all be fixed/worked around by introducing some arch hooks.
> But when you take into account that the whole elf loader on s390 is ~100 lines
> of code, I don't think it is worth it.
That's fine. I didn't really look into the S/390 Loader, and just wanted to let
the IBM people know.
> More comments below.
>
> [...]
>
> > diff --git a/include/linux/kexec.h b/include/linux/kexec.h
> > index b9b1bc5f9669..49b23b425f84 100644
> > --- a/include/linux/kexec.h
> > +++ b/include/linux/kexec.h
> > @@ -216,6 +216,41 @@ extern int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map,
> > void **addr, unsigned long *sz);
> > #endif /* CONFIG_KEXEC_FILE */
> >
> > +#ifdef CONFIG_KEXEC_FILE_ELF
> > +
> > +struct kexec_elf_info {
> > + /*
> > + * Where the ELF binary contents are kept.
> > + * Memory managed by the user of the struct.
> > + */
> > + const char *buffer;
> > +
> > + const struct elfhdr *ehdr;
> > + const struct elf_phdr *proghdrs;
> > + struct elf_shdr *sechdrs;
> > +};
>
> Do i understand this right? elf_info->buffer contains the full elf file and
> elf_info->ehdr is a (endianness translated) copy of the files ehdr?
>
> If so ...
>
> > +void kexec_free_elf_info(struct kexec_elf_info *elf_info);
> > +
> > +int kexec_build_elf_info(const char *buf, size_t len, struct elfhdr *ehdr,
> > + struct kexec_elf_info *elf_info);
> > +
> > +int kexec_elf_kernel_load(struct kimage *image, struct kexec_buf *kbuf,
> > + char *kernel_buf, unsigned long kernel_len,
> > + unsigned long *kernel_load_addr);
> > +
> > +int kexec_elf_probe(const char *buf, unsigned long len);
> > +
> > +int kexec_elf_load(struct kimage *image, struct elfhdr *ehdr,
> > + struct kexec_elf_info *elf_info,
> > + struct kexec_buf *kbuf,
> > + unsigned long *lowest_load_addr);
> > +
> > +int kexec_elf_load(struct kimage *image, struct elfhdr *ehdr,
> > + struct kexec_elf_info *elf_info,
> > + struct kexec_buf *kbuf,
> > + unsigned long *lowest_load_addr);
>
> ... you could simplify the arguments by dropping the ehdr argument. The
> elf_info should contain all the information needed. Furthermore the kexec_buf
> also contains a pointer to its kimage. So you can drop that argument as well.
>
> An other thing is that you kzalloc the memory needed for proghdrs and sechdrs
> but expect the user of those functions to provide the memory needed for ehdr.
> Wouldn't it be more consistent to also kzalloc the ehdr?
>
Good point. I'll think about it. I would like to do that in an extra patch,
as it is not a small style change.
>
> > diff --git a/kernel/kexec_file_elf.c b/kernel/kexec_file_elf.c
> > new file mode 100644
> > index 000000000000..bb966c93492c
> > --- /dev/null
> > +++ b/kernel/kexec_file_elf.c
> > @@ -0,0 +1,574 @@
>
> [...]
>
> > +static uint64_t elf64_to_cpu(const struct elfhdr *ehdr, uint64_t value)
> > +{
> > + if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB)
> > + value = le64_to_cpu(value);
> > + else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB)
> > + value = be64_to_cpu(value);
> > +
> > + return value;
> > +}
> > +
> > +static uint16_t elf16_to_cpu(const struct elfhdr *ehdr, uint16_t value)
> > +{
> > + if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB)
> > + value = le16_to_cpu(value);
> > + else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB)
> > + value = be16_to_cpu(value);
> > +
> > + return value;
> > +}
> > +
> > +static uint32_t elf32_to_cpu(const struct elfhdr *ehdr, uint32_t value)
> > +{
> > + if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB)
> > + value = le32_to_cpu(value);
> > + else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB)
> > + value = be32_to_cpu(value);
> > +
> > + return value;
> > +}
>
> What are the elf*_to_cpu good for? In general I'd assume that kexec loads a
> kernel for the same architecture it is running on. So the new kernel should
> also have the same endianness like the one which loads it. Is this a
> ppcle/ppcbe issue?
Don't know. I would agree, but i'm not an powerpc expert.
> Furthermore the current order is 64->16->32, which my OCPD absolutely hates :)
Fixed.
> [...]
>
> > +/**
> > + * elf_is_shdr_sane - check that it is safe to use the section header
> > + * @buf_len: size of the buffer in which the ELF file is loaded.
> > + */
> > +static bool elf_is_shdr_sane(const struct elf_shdr *shdr, size_t buf_len)
> > +{
> > + bool size_ok;
> > +
> > + /* SHT_NULL headers have undefined values, so we can't check them. */
> > + if (shdr->sh_type == SHT_NULL)
> > + return true;
> > +
> > + /* Now verify sh_entsize */
> > + switch (shdr->sh_type) {
> > + case SHT_SYMTAB:
> > + size_ok = shdr->sh_entsize == sizeof(Elf_Sym);
> > + break;
> > + case SHT_RELA:
> > + size_ok = shdr->sh_entsize == sizeof(Elf_Rela);
> > + break;
> > + case SHT_DYNAMIC:
> > + size_ok = shdr->sh_entsize == sizeof(Elf_Dyn);
> > + break;
> > + case SHT_REL:
> > + size_ok = shdr->sh_entsize == sizeof(Elf_Rel);
> > + break;
> > + case SHT_NOTE:
> > + case SHT_PROGBITS:
> > + case SHT_HASH:
> > + case SHT_NOBITS:
> > + default:
> > + /*
> > + * This is a section whose entsize requirements
> > + * I don't care about. If I don't know about
> > + * the section I can't care about it's entsize
> > + * requirements.
> > + */
> > + size_ok = true;
> > + break;
> > + }
> > +
> > + if (!size_ok) {
> > + pr_debug("ELF section with wrong entry size.\n");
> > + return false;
> > + } else if (shdr->sh_addr + shdr->sh_size < shdr->sh_addr) {
> > + pr_debug("ELF section address wraps around.\n");
> > + return false;
> > + }
> > +
> > + if (shdr->sh_type != SHT_NOBITS) {
> > + if (shdr->sh_offset + shdr->sh_size < shdr->sh_offset) {
> > + pr_debug("ELF section location wraps around.\n");
> > + return false;
> > + } else if (shdr->sh_offset + shdr->sh_size > buf_len) {
> > + pr_debug("ELF section not in file.\n");
> > + return false;
> > + }
> > + }
> > +
> > + return true;
> > +}
> > +
> > +static int elf_read_shdr(const char *buf, size_t len, struct kexec_elf_info *elf_info,
> > + int idx)
> > +{
> > + struct elf_shdr *shdr = &elf_info->sechdrs[idx];
> > + const struct elfhdr *ehdr = elf_info->ehdr;
> > + const char *sbuf;
> > + struct elf_shdr *buf_shdr;
> > +
> > + sbuf = buf + ehdr->e_shoff + idx * sizeof(*buf_shdr);
> > + buf_shdr = (struct elf_shdr *) sbuf;
> > +
> > + shdr->sh_name = elf32_to_cpu(ehdr, buf_shdr->sh_name);
> > + shdr->sh_type = elf32_to_cpu(ehdr, buf_shdr->sh_type);
> > + shdr->sh_addr = elf_addr_to_cpu(ehdr, buf_shdr->sh_addr);
> > + shdr->sh_offset = elf_addr_to_cpu(ehdr, buf_shdr->sh_offset);
> > + shdr->sh_link = elf32_to_cpu(ehdr, buf_shdr->sh_link);
> > + shdr->sh_info = elf32_to_cpu(ehdr, buf_shdr->sh_info);
> > +
> > + /*
> > + * The following fields have a type equivalent to Elf_Addr
> > + * both in 32 bit and 64 bit ELF.
> > + */
> > + shdr->sh_flags = elf_addr_to_cpu(ehdr, buf_shdr->sh_flags);
> > + shdr->sh_size = elf_addr_to_cpu(ehdr, buf_shdr->sh_size);
> > + shdr->sh_addralign = elf_addr_to_cpu(ehdr, buf_shdr->sh_addralign);
> > + shdr->sh_entsize = elf_addr_to_cpu(ehdr, buf_shdr->sh_entsize);
> > +
> > + return elf_is_shdr_sane(shdr, len) ? 0 : -ENOEXEC;
> > +}
> > +
> > +/**
> > + * elf_read_shdrs - read the section headers from the buffer
> > + *
> > + * This function assumes that the section header table was checked for sanity.
> > + * Use elf_is_ehdr_sane() if it wasn't.
> > + */
> > +static int elf_read_shdrs(const char *buf, size_t len,
> > + struct kexec_elf_info *elf_info)
> > +{
> > + size_t shdr_size, i;
> > +
> > + /*
> > + * e_shnum is at most 65536 so calculating
> > + * the size of the section header cannot overflow.
> > + */
> > + shdr_size = sizeof(struct elf_shdr) * elf_info->ehdr->e_shnum;
> > +
> > + elf_info->sechdrs = kzalloc(shdr_size, GFP_KERNEL);
> > + if (!elf_info->sechdrs)
> > + return -ENOMEM;
> > +
> > + for (i = 0; i < elf_info->ehdr->e_shnum; i++) {
> > + int ret;
> > +
> > + ret = elf_read_shdr(buf, len, elf_info, i);
> > + if (ret) {
> > + kfree(elf_info->sechdrs);
> > + elf_info->sechdrs = NULL;
> > + return ret;
> > + }
> > + }
> > +
> > + return 0;
> > +}
>
> In the end you only use the phdrs. So in theory you can drop everything shdr
> related. Although keeping it would be 'formally more correct'.
Correct, done.
> [...]
>
> > +/**
> > + * kexec_free_elf_info - free memory allocated by elf_read_from_buffer
> > + */
> > +void kexec_free_elf_info(struct kexec_elf_info *elf_info)
> > +{
> > + kfree(elf_info->proghdrs);
> > + kfree(elf_info->sechdrs);
> > + memset(elf_info, 0, sizeof(*elf_info));
> > +}
> > +EXPORT_SYMBOL(kexec_free_elf_info);
>
> Why are you exporting these functions? Is there any kexec implementation out
> there which is put into a module? Do you even want that to be possible?
My fault. Fixed.
> > +/**
> > + * kexec_build_elf_info - read ELF executable and check that we can use it
> > + */
> > +int kexec_build_elf_info(const char *buf, size_t len, struct elfhdr *ehdr,
> > + struct kexec_elf_info *elf_info)
> > +{
> > + int i;
> > + int ret;
> > +
> > + ret = elf_read_from_buffer(buf, len, ehdr, elf_info);
> > + if (ret)
> > + return ret;
> > +
> > + /* Big endian vmlinux has type ET_DYN. */
> > + if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN) {
>
> s390 is big endian and it's vmlinux has type ET_EXEC. So I assume that this is
> a ppc issue?
Again, don't know. :)
> > + pr_err("Not an ELF executable.\n");
> > + goto error;
> > + } else if (!elf_info->proghdrs) {
> > + pr_err("No ELF program header.\n");
> > + goto error;
> > + }
> > +
> > + for (i = 0; i < ehdr->e_phnum; i++) {
> > + /*
> > + * Kexec does not support loading interpreters.
> > + * In addition this check keeps us from attempting
> > + * to kexec ordinay executables.
> > + */
> > + if (elf_info->proghdrs[i].p_type == PT_INTERP) {
> > + pr_err("Requires an ELF interpreter.\n");
> > + goto error;
> > + }
> > + }
> > +
> > + return 0;
> > +error:
> > + kexec_free_elf_info(elf_info);
> > + return -ENOEXEC;
> > +}
> > +EXPORT_SYMBOL(kexec_build_elf_info);
>
> [...]
>
> > +int kexec_elf_probe(const char *buf, unsigned long len)
> > +{
> > + struct elfhdr ehdr;
> > + struct kexec_elf_info elf_info;
> > + int ret;
> > +
> > + ret = kexec_build_elf_info(buf, len, &ehdr, &elf_info);
>
> On s390 I only check the elf magic when probing. That's because the image
> loader cannot reliably check the image and thus accepts everything that is
> given to it. That also means that any elf file the elf probe rejects (e.g.
> because it has a phdr with type PT_INTERP) is passed on to the image loader,
> which happily takes it.
>
> If you plan to also add an image loader you should keep that in mind.
>
> Thanks
> Philipp
>
^ permalink raw reply
* Re: [PATCH] powerpc/rtas: retry when cpu offline races with suspend/migration
From: Nathan Lynch @ 2019-07-01 22:12 UTC (permalink / raw)
To: Michael Ellerman; +Cc: ego, mmc, linuxppc-dev, julietk
In-Reply-To: <20190621060518.29616-1-nathanl@linux.ibm.com>
Hi Michael,
Nathan Lynch <nathanl@linux.ibm.com> writes:
> The protocol for suspending or migrating an LPAR requires all present
> processor threads to enter H_JOIN. So if we have threads offline, we
> have to temporarily bring them up. This can race with administrator
> actions such as SMT state changes. As of dfd718a2ed1f ("powerpc/rtas:
> Fix a potential race between CPU-Offline & Migration"),
snowpatch/checkpatch flagged an error in my commit message here:
ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit
<12+ chars of sha1> ("<title line>")' - ie: 'commit dfd718a2ed1f
("powerpc/rtas: Fix a potential race between CPU-Offline &
Migration")'
I see this is in your next-test branch though. Should I fix the commit
message and resend?
^ permalink raw reply
* Re: [PATCH] mm/nvdimm: Add is_ioremap_addr and use that to check ioremap address
From: Andrew Morton @ 2019-07-01 23:51 UTC (permalink / raw)
To: Aneesh Kumar K.V; +Cc: linux-mm, dan.j.williams, linuxppc-dev, linux-nvdimm
In-Reply-To: <20190701134038.14165-1-aneesh.kumar@linux.ibm.com>
On Mon, 1 Jul 2019 19:10:38 +0530 "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> wrote:
> Architectures like powerpc use different address range to map ioremap
> and vmalloc range. The memunmap() check used by the nvdimm layer was
> wrongly using is_vmalloc_addr() to check for ioremap range which fails for
> ppc64. This result in ppc64 not freeing the ioremap mapping. The side effect
> of this is an unbind failure during module unload with papr_scm nvdimm driver
The patch applies to 5.1. Does it need a Fixes: and a Cc:stable?
^ permalink raw reply
* Re: [PATCH] powerpc/rtas: retry when cpu offline races with suspend/migration
From: Michael Ellerman @ 2019-07-02 2:16 UTC (permalink / raw)
To: Nathan Lynch; +Cc: ego, mmc, linuxppc-dev, julietk
In-Reply-To: <87blyds8tu.fsf@linux.ibm.com>
Nathan Lynch <nathanl@linux.ibm.com> writes:
> Hi Michael,
>
> Nathan Lynch <nathanl@linux.ibm.com> writes:
>> The protocol for suspending or migrating an LPAR requires all present
>> processor threads to enter H_JOIN. So if we have threads offline, we
>> have to temporarily bring them up. This can race with administrator
>> actions such as SMT state changes. As of dfd718a2ed1f ("powerpc/rtas:
>> Fix a potential race between CPU-Offline & Migration"),
>
> snowpatch/checkpatch flagged an error in my commit message here:
>
> ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit
> <12+ chars of sha1> ("<title line>")' - ie: 'commit dfd718a2ed1f
> ("powerpc/rtas: Fix a potential race between CPU-Offline &
> Migration")'
>
> I see this is in your next-test branch though. Should I fix the commit
> message and resend?
No that's fine.
You have a Fixes tag which is formatted correctly and that's what
matters IMO.
Ideally we could control that check to not complain about it being split
across lines when there's a fixes tag as well.
cheers
^ permalink raw reply
* Re: Can I compile Linux Kernel 5.2-rc7 for PowerPC on Intel/AMD x86 hardware?
From: Michael Ellerman @ 2019-07-02 2:20 UTC (permalink / raw)
To: Christophe Leroy, Turritopsis Dohrnii Teo En Ming,
linuxppc-dev@lists.ozlabs.org
In-Reply-To: <da969d6f-d5cb-88d7-77b5-54d804a067d7@c-s.fr>
Christophe Leroy <christophe.leroy@c-s.fr> writes:
> Le 01/07/2019 à 15:39, Turritopsis Dohrnii Teo En Ming a écrit :
>> Good evening from Singapore,
>
> Good evening afternoon from Paris,
>
>>
>> Can I compile Linux Kernel 5.2-rc7 for PowerPC on Intel/AMD x86 hardware, for example, AMD Ryzen 9 3950X, with 16 CPU cores and 32 threads?
>
> Yes you can
>
>>
>> Is it called cross-compiling?
>
> Yes it is, you can get cross compilers at
> https://mirrors.edge.kernel.org/pub/tools/crosstool/
There's also some info here:
https://github.com/linuxppc/wiki/wiki/Building-powerpc-kernels
cheers
^ permalink raw reply
* Re: ["RFC PATCH" 1/2] powerpc/mm: Fix node look up with numa=off boot
From: Aneesh Kumar K.V @ 2019-07-02 2:45 UTC (permalink / raw)
To: Nathan Lynch; +Cc: Vaibhav Jain, paulus, linuxppc-dev, npiggin
In-Reply-To: <87imslso3u.fsf@linux.ibm.com>
On 7/1/19 10:12 PM, Nathan Lynch wrote:
> "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> writes:
>> I guess we should have here.
>>
>> modified arch/powerpc/mm/numa.c
>> @@ -416,12 +416,11 @@ static int of_get_assoc_arrays(struct assoc_arrays
>> *aa)
>> static int of_drconf_to_nid_single(struct drmem_lmb *lmb)
>> {
>> struct assoc_arrays aa = { .arrays = NULL };
>> - /* is that correct? */
>> int default_nid = 0;
>> int nid = default_nid;
>> int rc, index;
>>
>> - if (!numa_enabled)
>> + if ((min_common_depth < 0) || !numa_enabled)
>> return NUMA_NO_NODE;
>>
>> rc = of_get_assoc_arrays(&aa);
>>
>>
>> Nathan,
>>
>> Can you check this?
>
> Looks like it would do the right thing.
>
> Just checking: do people still need numa=off? Seems like it's a
> maintenance burden :-)
>
That is used in kdump kernel.
-aneesh
^ permalink raw reply
* Re: [PATCH v2 1/3] arm64: mm: Add p?d_large() definitions
From: Nicholas Piggin @ 2019-07-02 2:55 UTC (permalink / raw)
To: linux-mm @ kvack . org, Steven Price
Cc: Mark Rutland, Ard Biesheuvel, Catalin Marinas, Anshuman Khandual,
Will Deacon, Andrew Morton, linuxppc-dev @ lists . ozlabs . org,
linux-arm-kernel @ lists . infradead . org
In-Reply-To: <0a3e0833-908d-b7eb-e6e7-6413b2e37094@arm.com>
Steven Price's on July 1, 2019 7:57 pm:
> On 01/07/2019 07:40, Nicholas Piggin wrote:
>> walk_page_range() is going to be allowed to walk page tables other than
>> those of user space. For this it needs to know when it has reached a
>> 'leaf' entry in the page tables. This information will be provided by the
>> p?d_large() functions/macros.
>>
>> For arm64, we already have p?d_sect() macros which we can reuse for
>> p?d_large().
>>
>> pud_sect() is defined as a dummy function when CONFIG_PGTABLE_LEVELS < 3
>> or CONFIG_ARM64_64K_PAGES is defined. However when the kernel is
>> configured this way then architecturally it isn't allowed to have a
>> large page that this level, and any code using these page walking macros
>> is implicitly relying on the page size/number of levels being the same as
>> the kernel. So it is safe to reuse this for p?d_large() as it is an
>> architectural restriction.
>>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will.deacon@arm.com>
>> Signed-off-by: Steven Price <steven.price@arm.com>
>
> Hi Nicolas,
>
> This appears to my patch which I originally posted as part of converting
> x86/arm64 to use a generic page walk code[1].
Hey, yeah it is, I'd intended to mark you as the author but must have
forgot to change it in git.
> I'm not sure that this
> patch makes much sense on its own, in particular it was working up to
> having a generic macro[2] which means the _large() macros could be used
> across all architectures.
It goes with this series which makes _large macros usable for archs
that define HUGE_VMAP. I posted the same thing earlier and Anshuman
noted you'd done it too so I deferred to yours (I thought it would
go via arm64 tree and that this would just allow Andrew to easily
reconcile the merge).
If your series is not going upstream this time then the changelog
probably doesn't make so much sense, so I could just send my version
to the arm64 tree.
Thanks,
Nick
^ permalink raw reply
* Re: Re: [PATCH 1/3] arm64: mm: Add p?d_large() definitions
From: Nicholas Piggin @ 2019-07-02 3:07 UTC (permalink / raw)
To: Steven Price, Will Deacon
Cc: Mark Rutland, Ard Biesheuvel, Catalin Marinas, Anshuman Khandual,
Will Deacon, linux-mm, Andrew Morton, linuxppc-dev,
linux-arm-kernel
In-Reply-To: <20190701101510.qup3nd6vm6cbdgjv@willie-the-truck>
Will Deacon's on July 1, 2019 8:15 pm:
> On Mon, Jul 01, 2019 at 11:03:51AM +0100, Steven Price wrote:
>> On 01/07/2019 10:27, Will Deacon wrote:
>> > On Sun, Jun 23, 2019 at 07:44:44PM +1000, Nicholas Piggin wrote:
>> >> walk_page_range() is going to be allowed to walk page tables other than
>> >> those of user space. For this it needs to know when it has reached a
>> >> 'leaf' entry in the page tables. This information will be provided by the
>> >> p?d_large() functions/macros.
>> >
>> > I can't remember whether or not I asked this before, but why not call
>> > this macro p?d_leaf() if that's what it's identifying? "Large" and "huge"
>> > are usually synonymous, so I find this naming needlessly confusing based
>> > on this patch in isolation.
Those page table macro names are horrible. Large, huge, leaf, wtf?
They could do with a sensible renaming. But this series just follows
naming that's alreay there on x86.
Thanks,
Nick
^ permalink raw reply
* Re: [PATCH] mm/nvdimm: Add is_ioremap_addr and use that to check ioremap address
From: Aneesh Kumar K.V @ 2019-07-02 3:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-mm, dan.j.williams, linuxppc-dev, linux-nvdimm
In-Reply-To: <20190701165152.7a55299eb670b0ca326f24dd@linux-foundation.org>
Andrew Morton <akpm@linux-foundation.org> writes:
> On Mon, 1 Jul 2019 19:10:38 +0530 "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> wrote:
>
>> Architectures like powerpc use different address range to map ioremap
>> and vmalloc range. The memunmap() check used by the nvdimm layer was
>> wrongly using is_vmalloc_addr() to check for ioremap range which fails for
>> ppc64. This result in ppc64 not freeing the ioremap mapping. The side effect
>> of this is an unbind failure during module unload with papr_scm nvdimm driver
>
> The patch applies to 5.1. Does it need a Fixes: and a Cc:stable?
Actually, we want it to be backported to an older kernel possibly one
that added papr-scm driver, b5beae5e224f ("powerpc/pseries: Add driver
for PAPR SCM regions"). But that doesn't apply easily. It does apply
without conflicts to 5.0
-aneesh
^ permalink raw reply
* [v2 05/12] powerpc/mce: Allow notifier callback to handle MCE
From: Santosh Sivaraj @ 2019-07-02 5:19 UTC (permalink / raw)
To: linuxppc-dev
Cc: Aneesh Kumar K.V, Mahesh Salgaonkar, Nicholas Piggin,
Chandan Rajendra, Reza Arbab
In-Reply-To: <20190702051932.511-1-santosh@fossix.org>
From: Reza Arbab <arbab@linux.ibm.com>
If a notifier returns NOTIFY_STOP, consider the MCE handled, just as we
do when machine_check_early() returns 1.
Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
---
arch/powerpc/include/asm/asm-prototypes.h | 2 +-
arch/powerpc/include/asm/mce.h | 3 +-
arch/powerpc/kernel/exceptions-64s.S | 3 ++
arch/powerpc/kernel/mce.c | 37 ++++++++++++++++++-----
4 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/arch/powerpc/include/asm/asm-prototypes.h b/arch/powerpc/include/asm/asm-prototypes.h
index f66f26ef3ce0..49ee8f08de2a 100644
--- a/arch/powerpc/include/asm/asm-prototypes.h
+++ b/arch/powerpc/include/asm/asm-prototypes.h
@@ -72,7 +72,7 @@ void machine_check_exception(struct pt_regs *regs);
void emulation_assist_interrupt(struct pt_regs *regs);
long do_slb_fault(struct pt_regs *regs, unsigned long ea);
void do_bad_slb_fault(struct pt_regs *regs, unsigned long ea, long err);
-void machine_check_notify(struct pt_regs *regs);
+long machine_check_notify(struct pt_regs *regs);
/* signals, syscalls and interrupts */
long sys_swapcontext(struct ucontext __user *old_ctx,
diff --git a/arch/powerpc/include/asm/mce.h b/arch/powerpc/include/asm/mce.h
index 948bef579086..240dd1fdfe35 100644
--- a/arch/powerpc/include/asm/mce.h
+++ b/arch/powerpc/include/asm/mce.h
@@ -122,7 +122,8 @@ struct machine_check_event {
enum MCE_UeErrorType ue_error_type:8;
u8 effective_address_provided;
u8 physical_address_provided;
- u8 reserved_1[5];
+ u8 process_event;
+ u8 reserved_1[4];
u64 effective_address;
u64 physical_address;
u8 reserved_2[8];
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 2e56014fca21..c83e38a403fd 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -460,6 +460,9 @@ EXC_COMMON_BEGIN(machine_check_handle_early)
addi r3,r1,STACK_FRAME_OVERHEAD
bl machine_check_notify
+ ld r11,RESULT(r1)
+ or r3,r3,r11
+ std r3,RESULT(r1)
ld r12,_MSR(r1)
BEGIN_FTR_SECTION
diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c
index 0ab171b41ede..4a37928ab30e 100644
--- a/arch/powerpc/kernel/mce.c
+++ b/arch/powerpc/kernel/mce.c
@@ -157,6 +157,8 @@ void save_mce_event(struct pt_regs *regs, long handled,
mce->u.ue_error.physical_address_provided = true;
mce->u.ue_error.physical_address = phys_addr;
}
+
+ mce->u.ue_error.process_event = true;
}
return;
}
@@ -241,6 +243,10 @@ void machine_check_queue_event(void)
if (!get_mce_event(&evt, MCE_EVENT_RELEASE))
return;
+ if (evt.error_type == MCE_ERROR_TYPE_UE &&
+ !evt.u.ue_error.process_event)
+ return;
+
index = __this_cpu_inc_return(mce_queue_count) - 1;
/* If queue is full, just return for now. */
if (index >= MAX_MC_EVT) {
@@ -647,16 +653,31 @@ long hmi_exception_realmode(struct pt_regs *regs)
return 1;
}
-void machine_check_notify(struct pt_regs *regs)
+long machine_check_notify(struct pt_regs *regs)
{
- struct machine_check_event evt;
+ int index = __this_cpu_read(mce_nest_count) - 1;
+ struct machine_check_event *evt;
+ int rc;
- if (!get_mce_event(&evt, MCE_EVENT_DONTRELEASE))
- return;
+ if (index < 0 || index >= MAX_MC_EVT)
+ return 0;
- blocking_notifier_call_chain(&mce_notifier_list, 0, &evt);
+ evt = this_cpu_ptr(&mce_event[index]);
- if (evt.error_type == MCE_ERROR_TYPE_UE &&
- evt.u.ue_error.physical_address_provided)
- machine_check_ue_event(&evt);
+ rc = blocking_notifier_call_chain(&mce_notifier_list, 0, evt);
+ if (rc & NOTIFY_STOP_MASK) {
+ if (evt->error_type == MCE_ERROR_TYPE_UE)
+ evt->u.ue_error.process_event = false;
+
+ if ((rc & NOTIFY_STOP_MASK) && (regs->msr & MSR_RI))
+ evt->disposition = MCE_DISPOSITION_RECOVERED;
+
+ return 1;
+ }
+
+ if (evt->error_type == MCE_ERROR_TYPE_UE &&
+ evt->u.ue_error.physical_address_provided)
+ machine_check_ue_event(evt);
+
+ return 0;
}
--
2.20.1
^ permalink raw reply related
* [v2 06/12] powerpc/mce: Add fixup address to UE events
From: Santosh Sivaraj @ 2019-07-02 5:19 UTC (permalink / raw)
To: linuxppc-dev
Cc: Aneesh Kumar K.V, Mahesh Salgaonkar, Nicholas Piggin,
Chandan Rajendra, Reza Arbab
In-Reply-To: <20190702051932.511-1-santosh@fossix.org>
From: Reza Arbab <arbab@linux.ibm.com>
If the instruction causing a UE has an exception table entry with fixup
address, save it in the machine_check_event struct.
If a machine check notifier callback returns NOTIFY_STOP to indicate it
has handled the error, set nip to continue execution from the fixup
address.
Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
---
arch/powerpc/include/asm/mce.h | 5 +++--
arch/powerpc/kernel/mce.c | 16 +++++++++++++++-
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/include/asm/mce.h b/arch/powerpc/include/asm/mce.h
index 240dd1fdfe35..9d9661747adf 100644
--- a/arch/powerpc/include/asm/mce.h
+++ b/arch/powerpc/include/asm/mce.h
@@ -122,11 +122,12 @@ struct machine_check_event {
enum MCE_UeErrorType ue_error_type:8;
u8 effective_address_provided;
u8 physical_address_provided;
+ u8 fixup_address_provided;
u8 process_event;
- u8 reserved_1[4];
+ u8 reserved_1[3];
u64 effective_address;
u64 physical_address;
- u8 reserved_2[8];
+ u64 fixup_address;
} ue_error;
struct {
diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c
index 4a37928ab30e..0233c0ee45ab 100644
--- a/arch/powerpc/kernel/mce.c
+++ b/arch/powerpc/kernel/mce.c
@@ -15,10 +15,12 @@
#include <linux/percpu.h>
#include <linux/export.h>
#include <linux/irq_work.h>
+#include <linux/extable.h>
#include <asm/machdep.h>
#include <asm/mce.h>
#include <asm/nmi.h>
+#include <asm/extable.h>
static DEFINE_PER_CPU(int, mce_nest_count);
static DEFINE_PER_CPU(struct machine_check_event[MAX_MC_EVT], mce_event);
@@ -151,6 +153,8 @@ void save_mce_event(struct pt_regs *regs, long handled,
mce->u.link_error.effective_address_provided = true;
mce->u.link_error.effective_address = addr;
} else if (mce->error_type == MCE_ERROR_TYPE_UE) {
+ const struct exception_table_entry *entry;
+
mce->u.ue_error.effective_address_provided = true;
mce->u.ue_error.effective_address = addr;
if (phys_addr != ULONG_MAX) {
@@ -158,6 +162,12 @@ void save_mce_event(struct pt_regs *regs, long handled,
mce->u.ue_error.physical_address = phys_addr;
}
+ entry = search_exception_tables(regs->nip);
+ if (entry) {
+ mce->u.ue_error.fixup_address_provided = true;
+ mce->u.ue_error.fixup_address = extable_fixup(entry);
+ }
+
mce->u.ue_error.process_event = true;
}
return;
@@ -666,8 +676,12 @@ long machine_check_notify(struct pt_regs *regs)
rc = blocking_notifier_call_chain(&mce_notifier_list, 0, evt);
if (rc & NOTIFY_STOP_MASK) {
- if (evt->error_type == MCE_ERROR_TYPE_UE)
+ if (evt->error_type == MCE_ERROR_TYPE_UE) {
+ if (evt->u.ue_error.fixup_address_provided)
+ regs->nip = evt->u.ue_error.fixup_address;
+
evt->u.ue_error.process_event = false;
+ }
if ((rc & NOTIFY_STOP_MASK) && (regs->msr & MSR_RI))
evt->disposition = MCE_DISPOSITION_RECOVERED;
--
2.20.1
^ permalink raw reply related
* [v2 07/12] powerpc/memcpy: Add memcpy_mcsafe for pmem
From: Santosh Sivaraj @ 2019-07-02 5:19 UTC (permalink / raw)
To: linuxppc-dev
Cc: Aneesh Kumar K.V, Mahesh Salgaonkar, Nicholas Piggin,
Chandan Rajendra, Reza Arbab
In-Reply-To: <20190702051932.511-1-santosh@fossix.org>
From: Balbir Singh <bsingharora@gmail.com>
The pmem infrastructure uses memcpy_mcsafe in the pmem
layer so as to convert machine check exceptions into
a return value on failure in case a machine check
exception is encountered during the memcpy.
This patch largely borrows from the copyuser_power7
logic and does not add the VMX optimizations, largely
to keep the patch simple. If needed those optimizations
can be folded in.
Signed-off-by: Balbir Singh <bsingharora@gmail.com>
Acked-by: Nicholas Piggin <npiggin@gmail.com>
[arbab@linux.ibm.com: Added symbol export]
---
arch/powerpc/include/asm/string.h | 2 +
arch/powerpc/lib/Makefile | 2 +-
arch/powerpc/lib/memcpy_mcsafe_64.S | 215 ++++++++++++++++++++++++++++
3 files changed, 218 insertions(+), 1 deletion(-)
create mode 100644 arch/powerpc/lib/memcpy_mcsafe_64.S
diff --git a/arch/powerpc/include/asm/string.h b/arch/powerpc/include/asm/string.h
index 9bf6dffb4090..b72692702f35 100644
--- a/arch/powerpc/include/asm/string.h
+++ b/arch/powerpc/include/asm/string.h
@@ -53,7 +53,9 @@ void *__memmove(void *to, const void *from, __kernel_size_t n);
#ifndef CONFIG_KASAN
#define __HAVE_ARCH_MEMSET32
#define __HAVE_ARCH_MEMSET64
+#define __HAVE_ARCH_MEMCPY_MCSAFE
+extern int memcpy_mcsafe(void *dst, const void *src, __kernel_size_t sz);
extern void *__memset16(uint16_t *, uint16_t v, __kernel_size_t);
extern void *__memset32(uint32_t *, uint32_t v, __kernel_size_t);
extern void *__memset64(uint64_t *, uint64_t v, __kernel_size_t);
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index c55f9c27bf79..529d6536eb4a 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -39,7 +39,7 @@ obj-$(CONFIG_PPC_BOOK3S_64) += copyuser_power7.o copypage_power7.o \
memcpy_power7.o
obj64-y += copypage_64.o copyuser_64.o mem_64.o hweight_64.o \
- memcpy_64.o pmem.o
+ memcpy_64.o pmem.o memcpy_mcsafe_64.o
obj64-$(CONFIG_SMP) += locks.o
obj64-$(CONFIG_ALTIVEC) += vmx-helper.o
diff --git a/arch/powerpc/lib/memcpy_mcsafe_64.S b/arch/powerpc/lib/memcpy_mcsafe_64.S
new file mode 100644
index 000000000000..50f865db0338
--- /dev/null
+++ b/arch/powerpc/lib/memcpy_mcsafe_64.S
@@ -0,0 +1,215 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) IBM Corporation, 2011
+ * Derived from copyuser_power7.s by Anton Blanchard <anton@au.ibm.com>
+ * Author - Balbir Singh <bsingharora@gmail.com>
+ */
+#include <asm/ppc_asm.h>
+#include <asm/errno.h>
+#include <asm/export.h>
+
+ .macro err1
+100:
+ EX_TABLE(100b,.Ldo_err1)
+ .endm
+
+ .macro err2
+200:
+ EX_TABLE(200b,.Ldo_err2)
+ .endm
+
+.Ldo_err2:
+ ld r22,STK_REG(R22)(r1)
+ ld r21,STK_REG(R21)(r1)
+ ld r20,STK_REG(R20)(r1)
+ ld r19,STK_REG(R19)(r1)
+ ld r18,STK_REG(R18)(r1)
+ ld r17,STK_REG(R17)(r1)
+ ld r16,STK_REG(R16)(r1)
+ ld r15,STK_REG(R15)(r1)
+ ld r14,STK_REG(R14)(r1)
+ addi r1,r1,STACKFRAMESIZE
+.Ldo_err1:
+ li r3,-EFAULT
+ blr
+
+
+_GLOBAL(memcpy_mcsafe)
+ cmpldi r5,16
+ blt .Lshort_copy
+
+.Lcopy:
+ /* Get the source 8B aligned */
+ neg r6,r4
+ mtocrf 0x01,r6
+ clrldi r6,r6,(64-3)
+
+ bf cr7*4+3,1f
+err1; lbz r0,0(r4)
+ addi r4,r4,1
+err1; stb r0,0(r3)
+ addi r3,r3,1
+
+1: bf cr7*4+2,2f
+err1; lhz r0,0(r4)
+ addi r4,r4,2
+err1; sth r0,0(r3)
+ addi r3,r3,2
+
+2: bf cr7*4+1,3f
+err1; lwz r0,0(r4)
+ addi r4,r4,4
+err1; stw r0,0(r3)
+ addi r3,r3,4
+
+3: sub r5,r5,r6
+ cmpldi r5,128
+ blt 5f
+
+ mflr r0
+ stdu r1,-STACKFRAMESIZE(r1)
+ std r14,STK_REG(R14)(r1)
+ std r15,STK_REG(R15)(r1)
+ std r16,STK_REG(R16)(r1)
+ std r17,STK_REG(R17)(r1)
+ std r18,STK_REG(R18)(r1)
+ std r19,STK_REG(R19)(r1)
+ std r20,STK_REG(R20)(r1)
+ std r21,STK_REG(R21)(r1)
+ std r22,STK_REG(R22)(r1)
+ std r0,STACKFRAMESIZE+16(r1)
+
+ srdi r6,r5,7
+ mtctr r6
+
+ /* Now do cacheline (128B) sized loads and stores. */
+ .align 5
+4:
+err2; ld r0,0(r4)
+err2; ld r6,8(r4)
+err2; ld r7,16(r4)
+err2; ld r8,24(r4)
+err2; ld r9,32(r4)
+err2; ld r10,40(r4)
+err2; ld r11,48(r4)
+err2; ld r12,56(r4)
+err2; ld r14,64(r4)
+err2; ld r15,72(r4)
+err2; ld r16,80(r4)
+err2; ld r17,88(r4)
+err2; ld r18,96(r4)
+err2; ld r19,104(r4)
+err2; ld r20,112(r4)
+err2; ld r21,120(r4)
+ addi r4,r4,128
+err2; std r0,0(r3)
+err2; std r6,8(r3)
+err2; std r7,16(r3)
+err2; std r8,24(r3)
+err2; std r9,32(r3)
+err2; std r10,40(r3)
+err2; std r11,48(r3)
+err2; std r12,56(r3)
+err2; std r14,64(r3)
+err2; std r15,72(r3)
+err2; std r16,80(r3)
+err2; std r17,88(r3)
+err2; std r18,96(r3)
+err2; std r19,104(r3)
+err2; std r20,112(r3)
+err2; std r21,120(r3)
+ addi r3,r3,128
+ bdnz 4b
+
+ clrldi r5,r5,(64-7)
+
+ ld r14,STK_REG(R14)(r1)
+ ld r15,STK_REG(R15)(r1)
+ ld r16,STK_REG(R16)(r1)
+ ld r17,STK_REG(R17)(r1)
+ ld r18,STK_REG(R18)(r1)
+ ld r19,STK_REG(R19)(r1)
+ ld r20,STK_REG(R20)(r1)
+ ld r21,STK_REG(R21)(r1)
+ ld r22,STK_REG(R22)(r1)
+ addi r1,r1,STACKFRAMESIZE
+
+ /* Up to 127B to go */
+5: srdi r6,r5,4
+ mtocrf 0x01,r6
+
+6: bf cr7*4+1,7f
+err1; ld r0,0(r4)
+err1; ld r6,8(r4)
+err1; ld r7,16(r4)
+err1; ld r8,24(r4)
+err1; ld r9,32(r4)
+err1; ld r10,40(r4)
+err1; ld r11,48(r4)
+err1; ld r12,56(r4)
+ addi r4,r4,64
+err1; std r0,0(r3)
+err1; std r6,8(r3)
+err1; std r7,16(r3)
+err1; std r8,24(r3)
+err1; std r9,32(r3)
+err1; std r10,40(r3)
+err1; std r11,48(r3)
+err1; std r12,56(r3)
+ addi r3,r3,64
+
+ /* Up to 63B to go */
+7: bf cr7*4+2,8f
+err1; ld r0,0(r4)
+err1; ld r6,8(r4)
+err1; ld r7,16(r4)
+err1; ld r8,24(r4)
+ addi r4,r4,32
+err1; std r0,0(r3)
+err1; std r6,8(r3)
+err1; std r7,16(r3)
+err1; std r8,24(r3)
+ addi r3,r3,32
+
+ /* Up to 31B to go */
+8: bf cr7*4+3,9f
+err1; ld r0,0(r4)
+err1; ld r6,8(r4)
+ addi r4,r4,16
+err1; std r0,0(r3)
+err1; std r6,8(r3)
+ addi r3,r3,16
+
+9: clrldi r5,r5,(64-4)
+
+ /* Up to 15B to go */
+.Lshort_copy:
+ mtocrf 0x01,r5
+ bf cr7*4+0,12f
+err1; lwz r0,0(r4) /* Less chance of a reject with word ops */
+err1; lwz r6,4(r4)
+ addi r4,r4,8
+err1; stw r0,0(r3)
+err1; stw r6,4(r3)
+ addi r3,r3,8
+
+12: bf cr7*4+1,13f
+err1; lwz r0,0(r4)
+ addi r4,r4,4
+err1; stw r0,0(r3)
+ addi r3,r3,4
+
+13: bf cr7*4+2,14f
+err1; lhz r0,0(r4)
+ addi r4,r4,2
+err1; sth r0,0(r3)
+ addi r3,r3,2
+
+14: bf cr7*4+3,15f
+err1; lbz r0,0(r4)
+err1; stb r0,0(r3)
+
+15: li r3,0
+ blr
+
+EXPORT_SYMBOL_GPL(memcpy_mcsafe);
--
2.20.1
^ permalink raw reply related
* [v2 08/12] powerpc/mce: Handle memcpy_mcsafe()
From: Santosh Sivaraj @ 2019-07-02 5:19 UTC (permalink / raw)
To: linuxppc-dev
Cc: Aneesh Kumar K.V, Mahesh Salgaonkar, Nicholas Piggin,
Chandan Rajendra, Reza Arbab
In-Reply-To: <20190702051932.511-1-santosh@fossix.org>
From: Reza Arbab <arbab@linux.ibm.com>
Add an mce notifier intended to service memcpy_mcsafe().
The notifier uses this heuristic; if a UE occurs when accessing device
memory, and the faulting instruction had a fixup entry, the callback
will return NOTIFY_STOP.
This causes the notification mechanism to consider the MCE handled and
continue execution at the fixup address, which returns -EFAULT from the
memcpy_mcsafe() call.
Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
---
arch/powerpc/kernel/mce.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c
index 0233c0ee45ab..a8348a9bea5b 100644
--- a/arch/powerpc/kernel/mce.c
+++ b/arch/powerpc/kernel/mce.c
@@ -56,6 +56,40 @@ int mce_unregister_notifier(struct notifier_block *nb)
return blocking_notifier_chain_unregister(&mce_notifier_list, nb);
}
+static int check_memcpy_mcsafe(struct notifier_block *nb, unsigned long val,
+ void *data)
+{
+ struct machine_check_event *evt = data;
+ unsigned long pfn;
+ struct page *page;
+
+ if (evt->error_type != MCE_ERROR_TYPE_UE ||
+ !evt->u.ue_error.physical_address_provided)
+ return NOTIFY_DONE;
+
+ pfn = evt->u.ue_error.physical_address >> PAGE_SHIFT;
+ page = pfn_to_page(pfn);
+ if (!page)
+ return NOTIFY_DONE;
+
+ /* HMM and PMEM */
+ if (is_zone_device_page(page) && evt->u.ue_error.fixup_address_provided)
+ return NOTIFY_STOP;
+
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block memcpy_mcsafe_nb = {
+ .notifier_call = check_memcpy_mcsafe
+};
+
+static int __init mce_mcsafe_register(void)
+{
+ mce_register_notifier(&memcpy_mcsafe_nb);
+ return 0;
+}
+arch_initcall(mce_mcsafe_register);
+
static void mce_set_error_info(struct machine_check_event *mce,
struct mce_error_info *mce_err)
{
--
2.20.1
^ permalink raw reply related
* [v2 09/12] powerpc/mce: Enable MCE notifiers in external modules
From: Santosh Sivaraj @ 2019-07-02 5:19 UTC (permalink / raw)
To: linuxppc-dev
Cc: Aneesh Kumar K.V, Mahesh Salgaonkar, Nicholas Piggin,
Chandan Rajendra, Reza Arbab
In-Reply-To: <20190702051932.511-1-santosh@fossix.org>
From: Reza Arbab <arbab@linux.ibm.com>
Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
---
arch/powerpc/kernel/exceptions-64s.S | 6 ++++++
arch/powerpc/kernel/mce.c | 2 ++
2 files changed, 8 insertions(+)
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index c83e38a403fd..311f1392a2ec 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -458,6 +458,12 @@ EXC_COMMON_BEGIN(machine_check_handle_early)
bl machine_check_early
std r3,RESULT(r1) /* Save result */
+ /* Notifiers may be in a module, so enable virtual addressing. */
+ mfmsr r11
+ ori r11,r11,MSR_IR
+ ori r11,r11,MSR_DR
+ mtmsr r11
+
addi r3,r1,STACK_FRAME_OVERHEAD
bl machine_check_notify
ld r11,RESULT(r1)
diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c
index a8348a9bea5b..9e4d497837d8 100644
--- a/arch/powerpc/kernel/mce.c
+++ b/arch/powerpc/kernel/mce.c
@@ -50,11 +50,13 @@ int mce_register_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_register(&mce_notifier_list, nb);
}
+EXPORT_SYMBOL_GPL(mce_register_notifier);
int mce_unregister_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_unregister(&mce_notifier_list, nb);
}
+EXPORT_SYMBOL_GPL(mce_unregister_notifier);
static int check_memcpy_mcsafe(struct notifier_block *nb, unsigned long val,
void *data)
--
2.20.1
^ 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