lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1434364142-763-1-git-send-email-achandran@mvista.com>
Date:	Mon, 15 Jun 2015 15:59:02 +0530
From:	Arun Chandran <achandran@...sta.com>
To:	Mark Brown <broonie@...nel.org>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Michal Simek <michal.simek@...inx.com>,
	linux-kernel@...r.kernel.org, Michal Simek <monstr@...str.eu>,
	Sören Brinkmann <soren.brinkmann@...inx.com>,
	Arun Chandran <achandran@...sta.com>
Subject: [PATCH v1] regmap: Fix regmap_bulk_read in BE mode

In big endian mode regmap_bulk_read gives incorrect data
for byte reads.

This is because memcpy of a single byte from an address
after full word read gives different results when
endianness differs. ie. we get little-end in LE and big-end in BE.

Signed-off-by: Arun Chandran <achandran@...sta.com>
---
---
I tested this on xilinx zynq platform in BE mode. On zynq
drivers/clk/clk-si570.c uses regmap and it fails in BE mode.

Please see the error below.

[    2.634380] Reg val0 =0
[    2.636788] Reg val1 =0
[    2.639168] Reg val2 =0
[    2.641598] Reg val3 =0
[    2.644028] Reg val4 =0
[    2.646513] Reg val5 =0
[    2.648890] Division by zero in kernel.
[    2.652715] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.1.0-rc6+ #116
[    2.659181] Hardware name: Xilinx Zynq Platform
[    2.663676] [<800158a0>] (unwind_backtrace) from [<8001286c>] (show_stack+0x10/0x14)
[    2.671429] [<8001286c>] (show_stack) from [<804f8e00>] (dump_stack+0x88/0xc8)
[    2.678624] [<804f8e00>] (dump_stack) from [<8027a408>] (Ldiv0_64+0x8/0x18)
[    2.685575] [<8027a408>] (Ldiv0_64) from [<80288830>] (div64_u64+0x1c/0xac)
[    2.692477] [<80288830>] (div64_u64) from [<803caf48>] (si570_probe+0x140/0x2dc)
[    2.699896] [<803caf48>] (si570_probe) from [<802d9da0>] (really_probe+0x1b0/0x28c)
[    2.707529] [<802d9da0>] (really_probe) from [<802d9f68>] (__driver_attach+0x98/0x9c)
[    2.715301] [<802d9f68>] (__driver_attach) from [<802d8308>] (bus_for_each_dev+0x68/0x9c)
[    2.723498] [<802d8308>] (bus_for_each_dev) from [<802d954c>] (bus_add_driver+0x148/0x1f0)
[    2.731746] [<802d954c>] (bus_add_driver) from [<802da35c>] (driver_register+0x78/0xf8)
[    2.739731] [<802da35c>] (driver_register) from [<8036b154>] (i2c_register_driver+0x30/0x7c)
[    2.748146] [<8036b154>] (i2c_register_driver) from [<800097d0>] (do_one_initcall+0x8c/0x1e0)
[    2.756652] [<800097d0>] (do_one_initcall) from [<806bde50>] (kernel_init_freeable+0x1cc/0x270)
[    2.765298] [<806bde50>] (kernel_init_freeable) from [<804f5ec0>] (kernel_init+0xc/0xe8)
[    2.773393] [<804f5ec0>] (kernel_init) from [<8000f628>] (ret_from_fork+0x14/0x2c)


drivers/clk/clk-si570.c is modified to print the register values
after using regmap_bulk_read() as shown below

 static int si570_get_divs(struct clk_si570 *data, u64 *rfreq,
                unsigned int *n1, unsigned int *hs_div)
 {
-       int err;
+       int err, i;
        u8 reg[6];
        u64 tmp;
 
        err = regmap_bulk_read(data->regmap, SI570_REG_HS_N1 + data->div_offset,
                        reg, ARRAY_SIZE(reg));
+       for (i = 0; i < 6; i++)
+               printk("Reg val%d =%x\n", i, reg[i]);
+

---
 drivers/base/regmap/regmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 6273ff0..9f7f78e 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -2318,7 +2318,7 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
 					  &ival);
 			if (ret != 0)
 				return ret;
-			memcpy(val + (i * val_bytes), &ival, val_bytes);
+			map->format.format_val(val + (i * val_bytes), ival, 0);
 		}
 	}
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ