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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4e6de98c-833b-a80b-acef-6e88391e80f2@arm.com>
Date:   Wed, 7 Aug 2019 15:07:39 +0100
From:   Robin Murphy <robin.murphy@....com>
To:     Sudeep Holla <sudeep.holla@....com>,
        Philipp Zabel <p.zabel@...gutronix.de>
Cc:     linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH] firmware: arm_scmi: Use {get,put}_unaligned_le32
 accessors

On 07/08/2019 14:57, Sudeep Holla wrote:
> On Wed, Aug 07, 2019 at 03:36:11PM +0200, Philipp Zabel wrote:
>> Hi Sudeep,
>>
>> On Wed, 2019-08-07 at 14:00 +0100, Sudeep Holla wrote:
>>> Instead of type-casting the {tx,rx}.buf all over the place while
>>> accessing them to read/write __le32 from/to the firmware, let's use
>>> the nice existing {get,put}_unaligned_le32 accessors to hide all the
>>> type cast ugliness.
>>>
>>> Suggested-by: Philipp Zabel <p.zabel@...gutronix.de>
>>> Signed-off-by: Sudeep Holla <sudeep.holla@....com>
>>> ---
>>>   drivers/firmware/arm_scmi/base.c    |  2 +-
>>>   drivers/firmware/arm_scmi/clock.c   | 10 ++++------
>>>   drivers/firmware/arm_scmi/common.h  |  2 ++
>>>   drivers/firmware/arm_scmi/perf.c    |  8 ++++----
>>>   drivers/firmware/arm_scmi/power.c   |  6 +++---
>>>   drivers/firmware/arm_scmi/reset.c   |  2 +-
>>>   drivers/firmware/arm_scmi/sensors.c | 12 +++++-------
>>>   7 files changed, 20 insertions(+), 22 deletions(-)
>>>
>>> diff --git a/drivers/firmware/arm_scmi/base.c b/drivers/firmware/arm_scmi/base.c
>>> index 204390297f4b..f804e8af6521 100644
>>> --- a/drivers/firmware/arm_scmi/base.c
>>> +++ b/drivers/firmware/arm_scmi/base.c
>> [...]
>>> @@ -204,14 +204,12 @@ scmi_clock_rate_get(const struct scmi_handle *handle, u32 clk_id, u64 *value)
>>>   	if (ret)
>>>   		return ret;
>>>
>>> -	*(__le32 *)t->tx.buf = cpu_to_le32(clk_id);
>>> +	put_unaligned_le32(clk_id, t->tx.buf);
>>>
>>>   	ret = scmi_do_xfer(handle, t);
>>>   	if (!ret) {
>>> -		__le32 *pval = t->rx.buf;
>>> -
>>> -		*value = le32_to_cpu(*pval);
>>> -		*value |= (u64)le32_to_cpu(*(pval + 1)) << 32;
>>> +		*value = get_unaligned_le32(t->rx.buf);
>>> +		*value |= (u64)get_unaligned_le32(t->rx.buf + 1) << 32;
>>
>> Isn't t->rx.buf a void pointer? If I am not mistaken, you'd either have
>> to keep the pval local variables, or cast to (__le32 *) before doing
>> pointer arithmetic.
>>
> 
> Ah right, that's the reason I added it at the first place. I will fix that.

Couldn't you just use get_unaligned_le64() here anyway?

Robin.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ