* [PATCH 0/8] ppc64 little endian bug fixes
@ 2013-12-12 4:59 Anton Blanchard
2013-12-12 4:59 ` [PATCH 1/8] powerpc: PTRACE_PEEKUSR always returns FPR0 Anton Blanchard
` (7 more replies)
0 siblings, 8 replies; 11+ messages in thread
From: Anton Blanchard @ 2013-12-12 4:59 UTC (permalink / raw)
To: benh, paulus, Ulrich.Weigand; +Cc: linuxppc-dev
Here are a number of little endian fixes found during testing of
2.6.13-*. Some of the interesting things:
A patch from Uli that fixes a nasty bug in PTRACE_PEEKUSR, basically
we always get FPR0 no matter which one we ask for.
Also included is a fix for the pseries NVRAM code, without it we
corrupt NVRAM and end up with particular hard to fix issues, since
we don't have easy ways to edit the contents of NVRAM.
Fixed other endian issues in crash dump, lparcfg and MSI code.
Anton Blanchard (7):
powerpc: Fix endian issue in setup-common.c
powerpc: Fix topology core_id endian issue on LE builds
powerpc/pseries: Fix endian issues in /proc/ppc64/lparcfg
powerpc/pseries: Fix endian issues in nvram code
powerpc/pseries: Fix PCIE link speed endian issue
powerpc/pseries: Fix endian issues in MSI code
powerpc: Fix endian issues in crash dump code
Ulrich Weigand (1):
powerpc: PTRACE_PEEKUSR always returns FPR0
arch/powerpc/kernel/crash_dump.c | 6 ++---
arch/powerpc/kernel/ptrace.c | 4 +--
arch/powerpc/kernel/setup-common.c | 4 +--
arch/powerpc/kernel/smp.c | 4 +--
arch/powerpc/platforms/pseries/lparcfg.c | 12 ++++-----
arch/powerpc/platforms/pseries/msi.c | 28 ++++++++++---------
arch/powerpc/platforms/pseries/nvram.c | 46 ++++++++++++++++----------------
arch/powerpc/platforms/pseries/pci.c | 8 +++---
8 files changed, 57 insertions(+), 55 deletions(-)
--
1.8.3.2
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/8] powerpc: PTRACE_PEEKUSR always returns FPR0
2013-12-12 4:59 [PATCH 0/8] ppc64 little endian bug fixes Anton Blanchard
@ 2013-12-12 4:59 ` Anton Blanchard
2013-12-12 4:59 ` [PATCH 2/8] powerpc: Fix endian issue in setup-common.c Anton Blanchard
` (6 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Anton Blanchard @ 2013-12-12 4:59 UTC (permalink / raw)
To: benh, paulus, Ulrich.Weigand; +Cc: linuxppc-dev
From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
There is a bug in using ptrace to access FPRs via PTRACE_PEEKUSR /
PTRACE_POKEUSR. In effect, trying to access any of the FPRs always
really accesses FPR0, which does seriously break debugging :-)
The problem seems to have been introduced by commit 3ad26e5c4459d
(Merge branch 'for-kvm' into next).
[ It is indeed a merge conflict between Paul's FPU/VSX state rework
and my LE patches - Anton ]
Signed-off-by: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Signed-off-by: Anton Blanchard <anton@samba.org>
---
arch/powerpc/kernel/ptrace.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 75fb404..2e3d2bf 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -1555,7 +1555,7 @@ long arch_ptrace(struct task_struct *child, long request,
flush_fp_to_thread(child);
if (fpidx < (PT_FPSCR - PT_FPR0))
- memcpy(&tmp, &child->thread.fp_state.fpr,
+ memcpy(&tmp, &child->thread.TS_FPR(fpidx),
sizeof(long));
else
tmp = child->thread.fp_state.fpscr;
@@ -1588,7 +1588,7 @@ long arch_ptrace(struct task_struct *child, long request,
flush_fp_to_thread(child);
if (fpidx < (PT_FPSCR - PT_FPR0))
- memcpy(&child->thread.fp_state.fpr, &data,
+ memcpy(&child->thread.TS_FPR(fpidx), &data,
sizeof(long));
else
child->thread.fp_state.fpscr = data;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/8] powerpc: Fix endian issue in setup-common.c
2013-12-12 4:59 [PATCH 0/8] ppc64 little endian bug fixes Anton Blanchard
2013-12-12 4:59 ` [PATCH 1/8] powerpc: PTRACE_PEEKUSR always returns FPR0 Anton Blanchard
@ 2013-12-12 4:59 ` Anton Blanchard
2013-12-12 4:59 ` [PATCH 3/8] powerpc: Fix topology core_id endian issue on LE builds Anton Blanchard
` (5 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Anton Blanchard @ 2013-12-12 4:59 UTC (permalink / raw)
To: benh, paulus, Ulrich.Weigand; +Cc: linuxppc-dev
During on LE boot we see:
Partition configured for 1073741824 cpus, operating system maximum is 2048.
Clearly missing a byteswap here.
Signed-off-by: Anton Blanchard <anton@samba.org>
---
arch/powerpc/kernel/setup-common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index febc804..bc76cc6 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -479,7 +479,7 @@ void __init smp_setup_cpu_maps(void)
if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR) &&
(dn = of_find_node_by_path("/rtas"))) {
int num_addr_cell, num_size_cell, maxcpus;
- const unsigned int *ireg;
+ const __be32 *ireg;
num_addr_cell = of_n_addr_cells(dn);
num_size_cell = of_n_size_cells(dn);
@@ -489,7 +489,7 @@ void __init smp_setup_cpu_maps(void)
if (!ireg)
goto out;
- maxcpus = ireg[num_addr_cell + num_size_cell];
+ maxcpus = be32_to_cpup(ireg + num_addr_cell + num_size_cell);
/* Double maxcpus for processors which have SMT capability */
if (cpu_has_feature(CPU_FTR_SMT))
--
1.8.3.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/8] powerpc: Fix topology core_id endian issue on LE builds
2013-12-12 4:59 [PATCH 0/8] ppc64 little endian bug fixes Anton Blanchard
2013-12-12 4:59 ` [PATCH 1/8] powerpc: PTRACE_PEEKUSR always returns FPR0 Anton Blanchard
2013-12-12 4:59 ` [PATCH 2/8] powerpc: Fix endian issue in setup-common.c Anton Blanchard
@ 2013-12-12 4:59 ` Anton Blanchard
2013-12-12 4:59 ` [PATCH 4/8] powerpc/pseries: Fix endian issues in /proc/ppc64/lparcfg Anton Blanchard
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Anton Blanchard @ 2013-12-12 4:59 UTC (permalink / raw)
To: benh, paulus, Ulrich.Weigand; +Cc: linuxppc-dev
cpu_to_core_id() is missing a byteswap:
cat /sys/devices/system/cpu/cpu63/topology/core_id
201326592
Signed-off-by: Anton Blanchard <anton@samba.org>
---
arch/powerpc/kernel/smp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 19d654b..ac2621a 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -575,7 +575,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
int cpu_to_core_id(int cpu)
{
struct device_node *np;
- const int *reg;
+ const __be32 *reg;
int id = -1;
np = of_get_cpu_node(cpu, NULL);
@@ -586,7 +586,7 @@ int cpu_to_core_id(int cpu)
if (!reg)
goto out;
- id = *reg;
+ id = be32_to_cpup(reg);
out:
of_node_put(np);
return id;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/8] powerpc/pseries: Fix endian issues in /proc/ppc64/lparcfg
2013-12-12 4:59 [PATCH 0/8] ppc64 little endian bug fixes Anton Blanchard
` (2 preceding siblings ...)
2013-12-12 4:59 ` [PATCH 3/8] powerpc: Fix topology core_id endian issue on LE builds Anton Blanchard
@ 2013-12-12 4:59 ` Anton Blanchard
2013-12-12 4:59 ` [PATCH 5/8] powerpc/pseries: Fix endian issues in nvram code Anton Blanchard
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Anton Blanchard @ 2013-12-12 4:59 UTC (permalink / raw)
To: benh, paulus, Ulrich.Weigand; +Cc: linuxppc-dev
Some obvious issues:
cat /proc/ppc64/lparcfg
...
partition_id=16777216
...
partition_potential_processors=268435456
Signed-off-by: Anton Blanchard <anton@samba.org>
---
arch/powerpc/platforms/pseries/lparcfg.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/lparcfg.c b/arch/powerpc/platforms/pseries/lparcfg.c
index e738007..c9fecf0 100644
--- a/arch/powerpc/platforms/pseries/lparcfg.c
+++ b/arch/powerpc/platforms/pseries/lparcfg.c
@@ -157,7 +157,7 @@ static void parse_ppp_data(struct seq_file *m)
{
struct hvcall_ppp_data ppp_data;
struct device_node *root;
- const int *perf_level;
+ const __be32 *perf_level;
int rc;
rc = h_get_ppp(&ppp_data);
@@ -201,7 +201,7 @@ static void parse_ppp_data(struct seq_file *m)
perf_level = of_get_property(root,
"ibm,partition-performance-parameters-level",
NULL);
- if (perf_level && (*perf_level >= 1)) {
+ if (perf_level && (be32_to_cpup(perf_level) >= 1)) {
seq_printf(m,
"physical_procs_allocated_to_virtualization=%d\n",
ppp_data.phys_platform_procs);
@@ -435,7 +435,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
int partition_potential_processors;
int partition_active_processors;
struct device_node *rtas_node;
- const int *lrdrp = NULL;
+ const __be32 *lrdrp = NULL;
rtas_node = of_find_node_by_path("/rtas");
if (rtas_node)
@@ -444,7 +444,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
if (lrdrp == NULL) {
partition_potential_processors = vdso_data->processorCount;
} else {
- partition_potential_processors = *(lrdrp + 4);
+ partition_potential_processors = be32_to_cpup(lrdrp + 4);
}
of_node_put(rtas_node);
@@ -654,7 +654,7 @@ static int lparcfg_data(struct seq_file *m, void *v)
const char *model = "";
const char *system_id = "";
const char *tmp;
- const unsigned int *lp_index_ptr;
+ const __be32 *lp_index_ptr;
unsigned int lp_index = 0;
seq_printf(m, "%s %s\n", MODULE_NAME, MODULE_VERS);
@@ -670,7 +670,7 @@ static int lparcfg_data(struct seq_file *m, void *v)
lp_index_ptr = of_get_property(rootdn, "ibm,partition-no",
NULL);
if (lp_index_ptr)
- lp_index = *lp_index_ptr;
+ lp_index = be32_to_cpup(lp_index_ptr);
of_node_put(rootdn);
}
seq_printf(m, "serial_number=%s\n", system_id);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/8] powerpc/pseries: Fix endian issues in nvram code
2013-12-12 4:59 [PATCH 0/8] ppc64 little endian bug fixes Anton Blanchard
` (3 preceding siblings ...)
2013-12-12 4:59 ` [PATCH 4/8] powerpc/pseries: Fix endian issues in /proc/ppc64/lparcfg Anton Blanchard
@ 2013-12-12 4:59 ` Anton Blanchard
2013-12-12 4:59 ` [PATCH 6/8] powerpc/pseries: Fix PCIE link speed endian issue Anton Blanchard
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Anton Blanchard @ 2013-12-12 4:59 UTC (permalink / raw)
To: benh, paulus, Ulrich.Weigand; +Cc: linuxppc-dev
The NVRAM code has a number of endian issues. I noticed a very
confused error log count:
RTAS: 100663330 -------- RTAS event begin --------
100663330 == 0x06000022. 0x6 LE error logs and 0x22 BE error logs.
The pstore code has similar issues - if we write an oops in one
endian and attempt to read it in another we get junk.
Make both of these formats big endian, and byteswap as required.
Signed-off-by: Anton Blanchard <anton@samba.org>
---
arch/powerpc/platforms/pseries/nvram.c | 46 +++++++++++++++++-----------------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c
index 7bfaf58..d7096f2 100644
--- a/arch/powerpc/platforms/pseries/nvram.c
+++ b/arch/powerpc/platforms/pseries/nvram.c
@@ -43,8 +43,8 @@ static char nvram_buf[NVRW_CNT]; /* assume this is in the first 4GB */
static DEFINE_SPINLOCK(nvram_lock);
struct err_log_info {
- int error_type;
- unsigned int seq_num;
+ __be32 error_type;
+ __be32 seq_num;
};
struct nvram_os_partition {
@@ -79,9 +79,9 @@ static const char *pseries_nvram_os_partitions[] = {
};
struct oops_log_info {
- u16 version;
- u16 report_length;
- u64 timestamp;
+ __be16 version;
+ __be16 report_length;
+ __be64 timestamp;
} __attribute__((packed));
static void oops_to_nvram(struct kmsg_dumper *dumper,
@@ -291,8 +291,8 @@ int nvram_write_os_partition(struct nvram_os_partition *part, char * buff,
length = part->size;
}
- info.error_type = err_type;
- info.seq_num = error_log_cnt;
+ info.error_type = cpu_to_be32(err_type);
+ info.seq_num = cpu_to_be32(error_log_cnt);
tmp_index = part->index;
@@ -364,8 +364,8 @@ int nvram_read_partition(struct nvram_os_partition *part, char *buff,
}
if (part->os_partition) {
- *error_log_cnt = info.seq_num;
- *err_type = info.error_type;
+ *error_log_cnt = be32_to_cpu(info.seq_num);
+ *err_type = be32_to_cpu(info.error_type);
}
return 0;
@@ -529,9 +529,9 @@ static int zip_oops(size_t text_len)
pr_err("nvram: logging uncompressed oops/panic report\n");
return -1;
}
- oops_hdr->version = OOPS_HDR_VERSION;
- oops_hdr->report_length = (u16) zipped_len;
- oops_hdr->timestamp = get_seconds();
+ oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION);
+ oops_hdr->report_length = cpu_to_be16(zipped_len);
+ oops_hdr->timestamp = cpu_to_be64(get_seconds());
return 0;
}
@@ -574,9 +574,9 @@ static int nvram_pstore_write(enum pstore_type_id type,
clobbering_unread_rtas_event())
return -1;
- oops_hdr->version = OOPS_HDR_VERSION;
- oops_hdr->report_length = (u16) size;
- oops_hdr->timestamp = get_seconds();
+ oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION);
+ oops_hdr->report_length = cpu_to_be16(size);
+ oops_hdr->timestamp = cpu_to_be64(get_seconds());
if (compressed)
err_type = ERR_TYPE_KERNEL_PANIC_GZ;
@@ -670,16 +670,16 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type,
size_t length, hdr_size;
oops_hdr = (struct oops_log_info *)buff;
- if (oops_hdr->version < OOPS_HDR_VERSION) {
+ if (be16_to_cpu(oops_hdr->version) < OOPS_HDR_VERSION) {
/* Old format oops header had 2-byte record size */
hdr_size = sizeof(u16);
- length = oops_hdr->version;
+ length = be16_to_cpu(oops_hdr->version);
time->tv_sec = 0;
time->tv_nsec = 0;
} else {
hdr_size = sizeof(*oops_hdr);
- length = oops_hdr->report_length;
- time->tv_sec = oops_hdr->timestamp;
+ length = be16_to_cpu(oops_hdr->report_length);
+ time->tv_sec = be64_to_cpu(oops_hdr->timestamp);
time->tv_nsec = 0;
}
*buf = kmalloc(length, GFP_KERNEL);
@@ -889,13 +889,13 @@ static void oops_to_nvram(struct kmsg_dumper *dumper,
kmsg_dump_get_buffer(dumper, false,
oops_data, oops_data_sz, &text_len);
err_type = ERR_TYPE_KERNEL_PANIC;
- oops_hdr->version = OOPS_HDR_VERSION;
- oops_hdr->report_length = (u16) text_len;
- oops_hdr->timestamp = get_seconds();
+ oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION);
+ oops_hdr->report_length = cpu_to_be16(text_len);
+ oops_hdr->timestamp = cpu_to_be64(get_seconds());
}
(void) nvram_write_os_partition(&oops_log_partition, oops_buf,
- (int) (sizeof(*oops_hdr) + oops_hdr->report_length), err_type,
+ (int) (sizeof(*oops_hdr) + text_len), err_type,
++oops_count);
spin_unlock_irqrestore(&lock, flags);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 6/8] powerpc/pseries: Fix PCIE link speed endian issue
2013-12-12 4:59 [PATCH 0/8] ppc64 little endian bug fixes Anton Blanchard
` (4 preceding siblings ...)
2013-12-12 4:59 ` [PATCH 5/8] powerpc/pseries: Fix endian issues in nvram code Anton Blanchard
@ 2013-12-12 4:59 ` Anton Blanchard
2013-12-12 4:59 ` [PATCH 7/8] powerpc/pseries: Fix endian issues in MSI code Anton Blanchard
2013-12-12 4:59 ` [PATCH 8/8] powerpc: Fix endian issues in crash dump code Anton Blanchard
7 siblings, 0 replies; 11+ messages in thread
From: Anton Blanchard @ 2013-12-12 4:59 UTC (permalink / raw)
To: benh, paulus, Ulrich.Weigand; +Cc: linuxppc-dev
We need to byteswap ibm,pcie-link-speed-stats.
Signed-off-by: Anton Blanchard <anton@samba.org>
---
arch/powerpc/platforms/pseries/pci.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index 5f93856..70670a2 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -113,7 +113,7 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
{
struct device_node *dn, *pdn;
struct pci_bus *bus;
- const uint32_t *pcie_link_speed_stats;
+ const __be32 *pcie_link_speed_stats;
bus = bridge->bus;
@@ -122,7 +122,7 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
return 0;
for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) {
- pcie_link_speed_stats = (const uint32_t *) of_get_property(pdn,
+ pcie_link_speed_stats = of_get_property(pdn,
"ibm,pcie-link-speed-stats", NULL);
if (pcie_link_speed_stats)
break;
@@ -135,7 +135,7 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
return 0;
}
- switch (pcie_link_speed_stats[0]) {
+ switch (be32_to_cpup(pcie_link_speed_stats)) {
case 0x01:
bus->max_bus_speed = PCIE_SPEED_2_5GT;
break;
@@ -147,7 +147,7 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
break;
}
- switch (pcie_link_speed_stats[1]) {
+ switch (be32_to_cpup(pcie_link_speed_stats)) {
case 0x01:
bus->cur_bus_speed = PCIE_SPEED_2_5GT;
break;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 7/8] powerpc/pseries: Fix endian issues in MSI code
2013-12-12 4:59 [PATCH 0/8] ppc64 little endian bug fixes Anton Blanchard
` (5 preceding siblings ...)
2013-12-12 4:59 ` [PATCH 6/8] powerpc/pseries: Fix PCIE link speed endian issue Anton Blanchard
@ 2013-12-12 4:59 ` Anton Blanchard
2013-12-12 4:59 ` [PATCH 8/8] powerpc: Fix endian issues in crash dump code Anton Blanchard
7 siblings, 0 replies; 11+ messages in thread
From: Anton Blanchard @ 2013-12-12 4:59 UTC (permalink / raw)
To: benh, paulus, Ulrich.Weigand; +Cc: linuxppc-dev
The MSI code is miscalculating quotas in little endian mode.
Add required byteswaps to fix this.
Before we claimed a quota of 65536, after the patch we
see the correct value of 256.
Signed-off-by: Anton Blanchard <anton@samba.org>
---
arch/powerpc/platforms/pseries/msi.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/msi.c b/arch/powerpc/platforms/pseries/msi.c
index 6d2f0ab..0c882e8 100644
--- a/arch/powerpc/platforms/pseries/msi.c
+++ b/arch/powerpc/platforms/pseries/msi.c
@@ -130,7 +130,8 @@ static int check_req(struct pci_dev *pdev, int nvec, char *prop_name)
{
struct device_node *dn;
struct pci_dn *pdn;
- const u32 *req_msi;
+ const __be32 *p;
+ u32 req_msi;
pdn = pci_get_pdn(pdev);
if (!pdn)
@@ -138,19 +139,20 @@ static int check_req(struct pci_dev *pdev, int nvec, char *prop_name)
dn = pdn->node;
- req_msi = of_get_property(dn, prop_name, NULL);
- if (!req_msi) {
+ p = of_get_property(dn, prop_name, NULL);
+ if (!p) {
pr_debug("rtas_msi: No %s on %s\n", prop_name, dn->full_name);
return -ENOENT;
}
- if (*req_msi < nvec) {
+ req_msi = be32_to_cpup(p);
+ if (req_msi < nvec) {
pr_debug("rtas_msi: %s requests < %d MSIs\n", prop_name, nvec);
- if (*req_msi == 0) /* Be paranoid */
+ if (req_msi == 0) /* Be paranoid */
return -ENOSPC;
- return *req_msi;
+ return req_msi;
}
return 0;
@@ -171,7 +173,7 @@ static int check_req_msix(struct pci_dev *pdev, int nvec)
static struct device_node *find_pe_total_msi(struct pci_dev *dev, int *total)
{
struct device_node *dn;
- const u32 *p;
+ const __be32 *p;
dn = of_node_get(pci_device_to_OF_node(dev));
while (dn) {
@@ -179,7 +181,7 @@ static struct device_node *find_pe_total_msi(struct pci_dev *dev, int *total)
if (p) {
pr_debug("rtas_msi: found prop on dn %s\n",
dn->full_name);
- *total = *p;
+ *total = be32_to_cpup(p);
return dn;
}
@@ -232,13 +234,13 @@ struct msi_counts {
static void *count_non_bridge_devices(struct device_node *dn, void *data)
{
struct msi_counts *counts = data;
- const u32 *p;
+ const __be32 *p;
u32 class;
pr_debug("rtas_msi: counting %s\n", dn->full_name);
p = of_get_property(dn, "class-code", NULL);
- class = p ? *p : 0;
+ class = p ? be32_to_cpup(p) : 0;
if ((class >> 8) != PCI_CLASS_BRIDGE_PCI)
counts->num_devices++;
@@ -249,7 +251,7 @@ static void *count_non_bridge_devices(struct device_node *dn, void *data)
static void *count_spare_msis(struct device_node *dn, void *data)
{
struct msi_counts *counts = data;
- const u32 *p;
+ const __be32 *p;
int req;
if (dn == counts->requestor)
@@ -260,11 +262,11 @@ static void *count_spare_msis(struct device_node *dn, void *data)
req = 0;
p = of_get_property(dn, "ibm,req#msi", NULL);
if (p)
- req = *p;
+ req = be32_to_cpup(p);
p = of_get_property(dn, "ibm,req#msi-x", NULL);
if (p)
- req = max(req, (int)*p);
+ req = max(req, (int)be32_to_cpup(p));
}
if (req < counts->quota)
--
1.8.3.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 8/8] powerpc: Fix endian issues in crash dump code
2013-12-12 4:59 [PATCH 0/8] ppc64 little endian bug fixes Anton Blanchard
` (6 preceding siblings ...)
2013-12-12 4:59 ` [PATCH 7/8] powerpc/pseries: Fix endian issues in MSI code Anton Blanchard
@ 2013-12-12 4:59 ` Anton Blanchard
2013-12-18 4:45 ` Michael Ellerman
7 siblings, 1 reply; 11+ messages in thread
From: Anton Blanchard @ 2013-12-12 4:59 UTC (permalink / raw)
To: benh, paulus, Ulrich.Weigand; +Cc: linuxppc-dev
A couple more device tree properties that need byte swapping.
Signed-off-by: Anton Blanchard <anton@samba.org>
---
arch/powerpc/kernel/crash_dump.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
index 779a78c..11c1d06 100644
--- a/arch/powerpc/kernel/crash_dump.c
+++ b/arch/powerpc/kernel/crash_dump.c
@@ -124,15 +124,15 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
void crash_free_reserved_phys_range(unsigned long begin, unsigned long end)
{
unsigned long addr;
- const u32 *basep, *sizep;
+ const __be32 *basep, *sizep;
unsigned int rtas_start = 0, rtas_end = 0;
basep = of_get_property(rtas.dev, "linux,rtas-base", NULL);
sizep = of_get_property(rtas.dev, "rtas-size", NULL);
if (basep && sizep) {
- rtas_start = *basep;
- rtas_end = *basep + *sizep;
+ rtas_start = be32_to_cpup(basep);
+ rtas_end = rtas_start + be32_to_cpup(sizep);
}
for (addr = begin; addr < end; addr += PAGE_SIZE) {
--
1.8.3.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 8/8] powerpc: Fix endian issues in crash dump code
2013-12-12 4:59 ` [PATCH 8/8] powerpc: Fix endian issues in crash dump code Anton Blanchard
@ 2013-12-18 4:45 ` Michael Ellerman
2014-01-22 10:42 ` Anton Blanchard
0 siblings, 1 reply; 11+ messages in thread
From: Michael Ellerman @ 2013-12-18 4:45 UTC (permalink / raw)
To: Anton Blanchard; +Cc: paulus, linuxppc-dev, Ulrich.Weigand
On Thu, 2013-12-12 at 15:59 +1100, Anton Blanchard wrote:
> A couple more device tree properties that need byte swapping.
>
> Signed-off-by: Anton Blanchard <anton@samba.org>
> ---
> arch/powerpc/kernel/crash_dump.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
> index 779a78c..11c1d06 100644
> --- a/arch/powerpc/kernel/crash_dump.c
> +++ b/arch/powerpc/kernel/crash_dump.c
> @@ -124,15 +124,15 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
> void crash_free_reserved_phys_range(unsigned long begin, unsigned long end)
> {
> unsigned long addr;
> - const u32 *basep, *sizep;
> + const __be32 *basep, *sizep;
> unsigned int rtas_start = 0, rtas_end = 0;
>
> basep = of_get_property(rtas.dev, "linux,rtas-base", NULL);
> sizep = of_get_property(rtas.dev, "rtas-size", NULL);
>
> if (basep && sizep) {
> - rtas_start = *basep;
> - rtas_end = *basep + *sizep;
> + rtas_start = be32_to_cpup(basep);
> + rtas_end = rtas_start + be32_to_cpup(sizep);
> }
>
> for (addr = begin; addr < end; addr += PAGE_SIZE) {
Not my favourite colour :D What about this instead?
We could also add of_property_read_u32(), with an implied index of zero?
I don't like the rc handling, but couldn't come up with anything I liked
better.
cheers
diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
index 11c1d06..60fd0aa 100644
--- a/arch/powerpc/kernel/crash_dump.c
+++ b/arch/powerpc/kernel/crash_dump.c
@@ -124,15 +124,16 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
void crash_free_reserved_phys_range(unsigned long begin, unsigned long end)
{
unsigned long addr;
- const __be32 *basep, *sizep;
+ u32 base, size;
unsigned int rtas_start = 0, rtas_end = 0;
+ int rc;
- basep = of_get_property(rtas.dev, "linux,rtas-base", NULL);
- sizep = of_get_property(rtas.dev, "rtas-size", NULL);
+ rc = of_property_read_u32_index(rtas.dev, "linux,rtas-base", 0, &base);
+ rc |= of_property_read_u32_index(rtas.dev, "rtas-size", 0, &size);
- if (basep && sizep) {
- rtas_start = be32_to_cpup(basep);
- rtas_end = rtas_start + be32_to_cpup(sizep);
+ if (rc == 0) {
+ rtas_start = base;
+ rtas_end = rtas_start + size;
}
for (addr = begin; addr < end; addr += PAGE_SIZE) {
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 8/8] powerpc: Fix endian issues in crash dump code
2013-12-18 4:45 ` Michael Ellerman
@ 2014-01-22 10:42 ` Anton Blanchard
0 siblings, 0 replies; 11+ messages in thread
From: Anton Blanchard @ 2014-01-22 10:42 UTC (permalink / raw)
To: Michael Ellerman; +Cc: paulus, linuxppc-dev, Ulrich.Weigand
Hi Michael,
> Not my favourite colour :D What about this instead?
>
> We could also add of_property_read_u32(), with an implied index of
> zero?
>
> I don't like the rc handling, but couldn't come up with anything I
> liked better.
Thanks for pointing that out, I didn't realise we had so many
of_property_read_* helpers. I'll be sure to use them from here on :)
Anton
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-01-22 10:42 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-12 4:59 [PATCH 0/8] ppc64 little endian bug fixes Anton Blanchard
2013-12-12 4:59 ` [PATCH 1/8] powerpc: PTRACE_PEEKUSR always returns FPR0 Anton Blanchard
2013-12-12 4:59 ` [PATCH 2/8] powerpc: Fix endian issue in setup-common.c Anton Blanchard
2013-12-12 4:59 ` [PATCH 3/8] powerpc: Fix topology core_id endian issue on LE builds Anton Blanchard
2013-12-12 4:59 ` [PATCH 4/8] powerpc/pseries: Fix endian issues in /proc/ppc64/lparcfg Anton Blanchard
2013-12-12 4:59 ` [PATCH 5/8] powerpc/pseries: Fix endian issues in nvram code Anton Blanchard
2013-12-12 4:59 ` [PATCH 6/8] powerpc/pseries: Fix PCIE link speed endian issue Anton Blanchard
2013-12-12 4:59 ` [PATCH 7/8] powerpc/pseries: Fix endian issues in MSI code Anton Blanchard
2013-12-12 4:59 ` [PATCH 8/8] powerpc: Fix endian issues in crash dump code Anton Blanchard
2013-12-18 4:45 ` Michael Ellerman
2014-01-22 10:42 ` Anton Blanchard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).