* [PATCH] pseries: Make CPU hotplug path endian safe
@ 2014-09-05 9:16 bharata.rao
2014-09-05 14:08 ` Nathan Fontenot
0 siblings, 1 reply; 3+ messages in thread
From: bharata.rao @ 2014-09-05 9:16 UTC (permalink / raw)
To: linux-kernel; +Cc: linuxppc-dev, benh, Bharata B Rao
From: Bharata B Rao <bharata@linux.vnet.ibm.com>
- ibm,rtas-configure-connector should treat the RTAS data as big endian.
- Treat ibm,ppc-interrupt-server#s as big-endian when setting
smp_processor_id during hotplug.
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
arch/powerpc/platforms/pseries/dlpar.c | 10 +++++-----
arch/powerpc/platforms/pseries/hotplug-cpu.c | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index 2d0b4d6..dc55f9c 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -48,11 +48,11 @@ static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa)
if (!prop)
return NULL;
- name = (char *)ccwa + ccwa->name_offset;
+ name = (char *)ccwa + be32_to_cpu(ccwa->name_offset);
prop->name = kstrdup(name, GFP_KERNEL);
- prop->length = ccwa->prop_length;
- value = (char *)ccwa + ccwa->prop_offset;
+ prop->length = be32_to_cpu(ccwa->prop_length);
+ value = (char *)ccwa + be32_to_cpu(ccwa->prop_offset);
prop->value = kmemdup(value, prop->length, GFP_KERNEL);
if (!prop->value) {
dlpar_free_cc_property(prop);
@@ -78,7 +78,7 @@ static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa,
if (!dn)
return NULL;
- name = (char *)ccwa + ccwa->name_offset;
+ name = (char *)ccwa + be32_to_cpu(ccwa->name_offset);
dn->full_name = kasprintf(GFP_KERNEL, "%s/%s", path, name);
if (!dn->full_name) {
kfree(dn);
@@ -148,7 +148,7 @@ struct device_node *dlpar_configure_connector(u32 drc_index,
return NULL;
ccwa = (struct cc_workarea *)&data_buf[0];
- ccwa->drc_index = drc_index;
+ ccwa->drc_index = cpu_to_be32(drc_index);
ccwa->zero = 0;
do {
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index 20d6297..447f8c6 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -247,7 +247,7 @@ static int pseries_add_processor(struct device_node *np)
unsigned int cpu;
cpumask_var_t candidate_mask, tmp;
int err = -ENOSPC, len, nthreads, i;
- const u32 *intserv;
+ const __be32 *intserv;
intserv = of_get_property(np, "ibm,ppc-interrupt-server#s", &len);
if (!intserv)
@@ -293,7 +293,7 @@ static int pseries_add_processor(struct device_node *np)
for_each_cpu(cpu, tmp) {
BUG_ON(cpu_present(cpu));
set_cpu_present(cpu, true);
- set_hard_smp_processor_id(cpu, *intserv++);
+ set_hard_smp_processor_id(cpu, be32_to_cpu(*intserv++));
}
err = 0;
out_unlock:
--
1.7.11.7
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] pseries: Make CPU hotplug path endian safe
2014-09-05 9:16 [PATCH] pseries: Make CPU hotplug path endian safe bharata.rao
@ 2014-09-05 14:08 ` Nathan Fontenot
2014-09-05 15:33 ` Bharata B Rao
0 siblings, 1 reply; 3+ messages in thread
From: Nathan Fontenot @ 2014-09-05 14:08 UTC (permalink / raw)
To: bharata.rao, linux-kernel; +Cc: linuxppc-dev, Bharata B Rao
On 09/05/2014 04:16 AM, bharata.rao@gmail.com wrote:
> From: Bharata B Rao <bharata@linux.vnet.ibm.com>
>
> - ibm,rtas-configure-connector should treat the RTAS data as big endian.
> - Treat ibm,ppc-interrupt-server#s as big-endian when setting
> smp_processor_id during hotplug.
>
> Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> ---
> arch/powerpc/platforms/pseries/dlpar.c | 10 +++++-----
> arch/powerpc/platforms/pseries/hotplug-cpu.c | 4 ++--
> 2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
> index 2d0b4d6..dc55f9c 100644
> --- a/arch/powerpc/platforms/pseries/dlpar.c
> +++ b/arch/powerpc/platforms/pseries/dlpar.c
> @@ -48,11 +48,11 @@ static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa)
> if (!prop)
> return NULL;
>
> - name = (char *)ccwa + ccwa->name_offset;
> + name = (char *)ccwa + be32_to_cpu(ccwa->name_offset);
> prop->name = kstrdup(name, GFP_KERNEL);
>
> - prop->length = ccwa->prop_length;
> - value = (char *)ccwa + ccwa->prop_offset;
> + prop->length = be32_to_cpu(ccwa->prop_length);
> + value = (char *)ccwa + be32_to_cpu(ccwa->prop_offset);
> prop->value = kmemdup(value, prop->length, GFP_KERNEL);
> if (!prop->value) {
> dlpar_free_cc_property(prop);
> @@ -78,7 +78,7 @@ static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa,
> if (!dn)
> return NULL;
>
> - name = (char *)ccwa + ccwa->name_offset;
> + name = (char *)ccwa + be32_to_cpu(ccwa->name_offset);
> dn->full_name = kasprintf(GFP_KERNEL, "%s/%s", path, name);
> if (!dn->full_name) {
> kfree(dn);
> @@ -148,7 +148,7 @@ struct device_node *dlpar_configure_connector(u32 drc_index,
> return NULL;
>
> ccwa = (struct cc_workarea *)&data_buf[0];
> - ccwa->drc_index = drc_index;
> + ccwa->drc_index = cpu_to_be32(drc_index);
I need to look at this some more but I think this may cause an issue for
partition migration. If I am following the code correctly, starting in
pseries_devicetree_update(), the drc_index value passed to
dlpar_configure_connector is pulled directly out of a buffer we get from
firmware. This would mean the drc_index value is already in BE format.
Whereas for cpu hotplug the drc_index value is passed in from userspace
via the cpu probe interface in sysfs. I assume that you are seeing the
drc_index value getting passed in in LE format.
-Nathan
> ccwa->zero = 0;
>
> do {
> diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
> index 20d6297..447f8c6 100644
> --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
> +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
> @@ -247,7 +247,7 @@ static int pseries_add_processor(struct device_node *np)
> unsigned int cpu;
> cpumask_var_t candidate_mask, tmp;
> int err = -ENOSPC, len, nthreads, i;
> - const u32 *intserv;
> + const __be32 *intserv;
>
> intserv = of_get_property(np, "ibm,ppc-interrupt-server#s", &len);
> if (!intserv)
> @@ -293,7 +293,7 @@ static int pseries_add_processor(struct device_node *np)
> for_each_cpu(cpu, tmp) {
> BUG_ON(cpu_present(cpu));
> set_cpu_present(cpu, true);
> - set_hard_smp_processor_id(cpu, *intserv++);
> + set_hard_smp_processor_id(cpu, be32_to_cpu(*intserv++));
> }
> err = 0;
> out_unlock:
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pseries: Make CPU hotplug path endian safe
2014-09-05 14:08 ` Nathan Fontenot
@ 2014-09-05 15:33 ` Bharata B Rao
0 siblings, 0 replies; 3+ messages in thread
From: Bharata B Rao @ 2014-09-05 15:33 UTC (permalink / raw)
To: Nathan Fontenot; +Cc: linux-kernel, linuxppc-dev, Bharata B Rao
On Fri, Sep 5, 2014 at 7:38 PM, Nathan Fontenot
<nfont@linux.vnet.ibm.com> wrote:
> On 09/05/2014 04:16 AM, bharata.rao@gmail.com wrote:
>> From: Bharata B Rao <bharata@linux.vnet.ibm.com>
>>
>> - ibm,rtas-configure-connector should treat the RTAS data as big endian.
>> - Treat ibm,ppc-interrupt-server#s as big-endian when setting
>> smp_processor_id during hotplug.
>>
>> Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
>> ---
>> arch/powerpc/platforms/pseries/dlpar.c | 10 +++++-----
>> arch/powerpc/platforms/pseries/hotplug-cpu.c | 4 ++--
>> 2 files changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
>> index 2d0b4d6..dc55f9c 100644
>> --- a/arch/powerpc/platforms/pseries/dlpar.c
>> +++ b/arch/powerpc/platforms/pseries/dlpar.c
>> @@ -48,11 +48,11 @@ static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa)
>> if (!prop)
>> return NULL;
>>
>> - name = (char *)ccwa + ccwa->name_offset;
>> + name = (char *)ccwa + be32_to_cpu(ccwa->name_offset);
>> prop->name = kstrdup(name, GFP_KERNEL);
>>
>> - prop->length = ccwa->prop_length;
>> - value = (char *)ccwa + ccwa->prop_offset;
>> + prop->length = be32_to_cpu(ccwa->prop_length);
>> + value = (char *)ccwa + be32_to_cpu(ccwa->prop_offset);
>> prop->value = kmemdup(value, prop->length, GFP_KERNEL);
>> if (!prop->value) {
>> dlpar_free_cc_property(prop);
>> @@ -78,7 +78,7 @@ static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa,
>> if (!dn)
>> return NULL;
>>
>> - name = (char *)ccwa + ccwa->name_offset;
>> + name = (char *)ccwa + be32_to_cpu(ccwa->name_offset);
>> dn->full_name = kasprintf(GFP_KERNEL, "%s/%s", path, name);
>> if (!dn->full_name) {
>> kfree(dn);
>> @@ -148,7 +148,7 @@ struct device_node *dlpar_configure_connector(u32 drc_index,
>> return NULL;
>>
>> ccwa = (struct cc_workarea *)&data_buf[0];
>> - ccwa->drc_index = drc_index;
>> + ccwa->drc_index = cpu_to_be32(drc_index);
>
> I need to look at this some more but I think this may cause an issue for
> partition migration. If I am following the code correctly, starting in
> pseries_devicetree_update(), the drc_index value passed to
> dlpar_configure_connector is pulled directly out of a buffer we get from
> firmware. This would mean the drc_index value is already in BE format.
Yes I see that now.
>
> Whereas for cpu hotplug the drc_index value is passed in from userspace
> via the cpu probe interface in sysfs. I assume that you are seeing the
> drc_index value getting passed in in LE format.
Yes I am seeing drc_index in LE format for an LE guest during CPU
hotplug operation.
Regards,
Bharata.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-05 15:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-05 9:16 [PATCH] pseries: Make CPU hotplug path endian safe bharata.rao
2014-09-05 14:08 ` Nathan Fontenot
2014-09-05 15:33 ` Bharata B Rao
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).