From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org,
Tyrel Datwyler <tyreld@linux.vnet.ibm.com>,
Nathan Fontenot <nfont@linux.vnet.ibm.com>,
Cyril Bur <cyrilbur@gmail.com>,
Michael Ellerman <mpe@ellerman.id.au>
Subject: [PATCH 3.14 35/38] powerpc/pseries: Little endian fixes for post mobility device tree update
Date: Fri, 10 Apr 2015 15:19:23 +0200 [thread overview]
Message-ID: <20150410131704.255079955@linuxfoundation.org> (raw)
In-Reply-To: <20150410131701.236830106@linuxfoundation.org>
3.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
commit f6ff04149637723261aa4738958b0098b929ee9e upstream.
We currently use the device tree update code in the kernel after resuming
from a suspend operation to re-sync the kernels view of the device tree with
that of the hypervisor. The code as it stands is not endian safe as it relies
on parsing buffers returned by RTAS calls that thusly contains data in big
endian format.
This patch annotates variables and structure members with __be types as well
as performing necessary byte swaps to cpu endian for data that needs to be
parsed.
Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Cc: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/powerpc/platforms/pseries/mobility.c | 44 +++++++++++++++---------------
1 file changed, 23 insertions(+), 21 deletions(-)
--- a/arch/powerpc/platforms/pseries/mobility.c
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -24,10 +24,10 @@
static struct kobject *mobility_kobj;
struct update_props_workarea {
- u32 phandle;
- u32 state;
- u64 reserved;
- u32 nprops;
+ __be32 phandle;
+ __be32 state;
+ __be64 reserved;
+ __be32 nprops;
} __packed;
#define NODE_ACTION_MASK 0xff000000
@@ -53,11 +53,11 @@ static int mobility_rtas_call(int token,
return rc;
}
-static int delete_dt_node(u32 phandle)
+static int delete_dt_node(__be32 phandle)
{
struct device_node *dn;
- dn = of_find_node_by_phandle(phandle);
+ dn = of_find_node_by_phandle(be32_to_cpu(phandle));
if (!dn)
return -ENOENT;
@@ -126,7 +126,7 @@ static int update_dt_property(struct dev
return 0;
}
-static int update_dt_node(u32 phandle, s32 scope)
+static int update_dt_node(__be32 phandle, s32 scope)
{
struct update_props_workarea *upwa;
struct device_node *dn;
@@ -135,6 +135,7 @@ static int update_dt_node(u32 phandle, s
char *prop_data;
char *rtas_buf;
int update_properties_token;
+ u32 nprops;
u32 vd;
update_properties_token = rtas_token("ibm,update-properties");
@@ -145,7 +146,7 @@ static int update_dt_node(u32 phandle, s
if (!rtas_buf)
return -ENOMEM;
- dn = of_find_node_by_phandle(phandle);
+ dn = of_find_node_by_phandle(be32_to_cpu(phandle));
if (!dn) {
kfree(rtas_buf);
return -ENOENT;
@@ -161,6 +162,7 @@ static int update_dt_node(u32 phandle, s
break;
prop_data = rtas_buf + sizeof(*upwa);
+ nprops = be32_to_cpu(upwa->nprops);
/* On the first call to ibm,update-properties for a node the
* the first property value descriptor contains an empty
@@ -169,17 +171,17 @@ static int update_dt_node(u32 phandle, s
*/
if (*prop_data == 0) {
prop_data++;
- vd = *(u32 *)prop_data;
+ vd = be32_to_cpu(*(__be32 *)prop_data);
prop_data += vd + sizeof(vd);
- upwa->nprops--;
+ nprops--;
}
- for (i = 0; i < upwa->nprops; i++) {
+ for (i = 0; i < nprops; i++) {
char *prop_name;
prop_name = prop_data;
prop_data += strlen(prop_name) + 1;
- vd = *(u32 *)prop_data;
+ vd = be32_to_cpu(*(__be32 *)prop_data);
prop_data += sizeof(vd);
switch (vd) {
@@ -211,13 +213,13 @@ static int update_dt_node(u32 phandle, s
return 0;
}
-static int add_dt_node(u32 parent_phandle, u32 drc_index)
+static int add_dt_node(__be32 parent_phandle, __be32 drc_index)
{
struct device_node *dn;
struct device_node *parent_dn;
int rc;
- parent_dn = of_find_node_by_phandle(parent_phandle);
+ parent_dn = of_find_node_by_phandle(be32_to_cpu(parent_phandle));
if (!parent_dn)
return -ENOENT;
@@ -236,7 +238,7 @@ static int add_dt_node(u32 parent_phandl
int pseries_devicetree_update(s32 scope)
{
char *rtas_buf;
- u32 *data;
+ __be32 *data;
int update_nodes_token;
int rc;
@@ -253,17 +255,17 @@ int pseries_devicetree_update(s32 scope)
if (rc && rc != 1)
break;
- data = (u32 *)rtas_buf + 4;
- while (*data & NODE_ACTION_MASK) {
+ data = (__be32 *)rtas_buf + 4;
+ while (be32_to_cpu(*data) & NODE_ACTION_MASK) {
int i;
- u32 action = *data & NODE_ACTION_MASK;
- int node_count = *data & NODE_COUNT_MASK;
+ u32 action = be32_to_cpu(*data) & NODE_ACTION_MASK;
+ u32 node_count = be32_to_cpu(*data) & NODE_COUNT_MASK;
data++;
for (i = 0; i < node_count; i++) {
- u32 phandle = *data++;
- u32 drc_index;
+ __be32 phandle = *data++;
+ __be32 drc_index;
switch (action) {
case DELETE_DT_NODE:
next prev parent reply other threads:[~2015-04-10 13:19 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-10 13:18 [PATCH 3.14 00/38] 3.14.38-stable review Greg Kroah-Hartman
2015-04-10 13:18 ` [PATCH 3.14 01/38] ASoC: sgtl5000: remove useless register write clearing CHRGPUMP_POWERUP Greg Kroah-Hartman
2015-04-10 13:18 ` [PATCH 3.14 02/38] ASoC: pcm1681: Fix wrong value references for boolean kctl Greg Kroah-Hartman
2015-04-10 13:18 ` [PATCH 3.14 03/38] ASoC: cs4271: " Greg Kroah-Hartman
2015-04-10 13:18 ` [PATCH 3.14 04/38] ASoC: wm8960: " Greg Kroah-Hartman
2015-04-10 13:18 ` [PATCH 3.14 05/38] ASoC: tas5086: " Greg Kroah-Hartman
2015-04-10 13:18 ` [PATCH 3.14 06/38] ASoC: wm8731: " Greg Kroah-Hartman
2015-04-10 13:18 ` [PATCH 3.14 07/38] ASoC: wm2000: " Greg Kroah-Hartman
2015-04-10 13:18 ` [PATCH 3.14 08/38] ASoC: wm8903: " Greg Kroah-Hartman
2015-04-10 13:18 ` [PATCH 3.14 09/38] ASoC: wm8904: " Greg Kroah-Hartman
2015-04-10 13:18 ` [PATCH 3.14 10/38] ASoC: ak4641: " Greg Kroah-Hartman
2015-04-10 13:18 ` [PATCH 3.14 11/38] ASoC: adav80x: " Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 12/38] ASoC: wm8955: " Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 13/38] ASoC: jz4740: Remove Makefile entry for removed file Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 14/38] clockevents: sun5i: Fix setup_irq init sequence Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 15/38] regmap: regcache-rbtree: Fix present bitmap resize Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 17/38] tcm_fc: missing curly braces in ft_invl_hw_context() Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 18/38] tcm_qla2xxx: Fix incorrect use of __transport_register_session Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 19/38] nl80211: ignore HT/VHT capabilities without QoS/WMM Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 20/38] mac80211: disable u-APSD queues by default Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 21/38] mac80211: drop unencrypted frames in mesh fwding Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 22/38] Revert "iwlwifi: mvm: fix failure path when power_update fails in add_interface" Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 23/38] phy: Find the right match in devm_phy_destroy() Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 24/38] of/irq: Fix of_irq_parse_one() returned error codes Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 25/38] perf: Fix irq_work tail recursion Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 26/38] staging: vt6656: vnt_rf_setpower: fix missing rate RATE_12M Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 27/38] vt6655: RFbSetPower " Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 28/38] dmaengine: dw: append MODULE_ALIAS for platform driver Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 29/38] dm: hold suspend_lock while suspending device during device deletion Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 30/38] dm io: deal with wandering queue limits when handling REQ_DISCARD and REQ_WRITE_SAME Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 32/38] hfsplus: fix B-tree corruption after insertion at position 0 Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 33/38] powerpc/book3s: Fix the MCE code to use CONFIG_KVM_BOOK3S_64_HANDLER Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 34/38] arm64: Use the reserved TTBR0 if context switching to the init_mm Greg Kroah-Hartman
2015-04-10 13:19 ` Greg Kroah-Hartman [this message]
2015-04-10 13:19 ` [PATCH 3.14 36/38] powerpc/mpc85xx: Add ranges to etsec2 nodes Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 37/38] net: ethernet: pcnet32: Setup the SRAM and NOUFLO on Am79C97{3, 5} Greg Kroah-Hartman
2015-04-10 13:19 ` [PATCH 3.14 38/38] mfd: kempld-core: Fix callback return value check Greg Kroah-Hartman
2015-04-10 18:04 ` [PATCH 3.14 00/38] 3.14.38-stable review Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150410131704.255079955@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=cyrilbur@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpe@ellerman.id.au \
--cc=nfont@linux.vnet.ibm.com \
--cc=stable@vger.kernel.org \
--cc=tyreld@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).