bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix incorrect mask for ppc64


From: Masahiro Matsuya
Subject: Re: Fix incorrect mask for ppc64
Date: Wed, 6 Dec 2017 23:33:58 +0900

Hello,

I agree with just removing le_to_cpu32.
I wrote the patch one year ago, and I don't remember the intent.
But maybe, I had some wrong assumption at that time.
For now, I think it looks better to remove le_to_cpu32 without swap_bytes
for both LE and BE environment.

Thanks,
Masahiro Matsuya


On Wed, Dec 6, 2017 at 1:12 AM, diegodo <address@hidden> wrote:
> Sending the thread to the author (sorry, I missed his email).
>
> On 2017-12-05 11:26, Vladimir 'phcoder' Serbinenko wrote:
>>
>> Why is swap_bytes right solution? It feels like if anything we just
>> need to remove le_to_cpu32
>>
>> On Tue, Dec 5, 2017, 13:23 <address@hidden> wrote:
>>
>>> From: Masahiro Matsuya <address@hidden>
>>>
>>> The netmask configured in firmware is not respected on ppc64 (big
>>> endian).
>>> When 255.255.252.0 is set as netmask in firmware, the following is
>>> the value of bootpath string in grub_ieee1275_parse_bootpath().
>>>
>>>
>>>
>>
>> /vdevice/address@hidden:speed=auto,duplex=auto,192.168.88.10,,192.168.89.113,192.168.88.1,5,5,255.255.252.0,512
>>>
>>>
>>> The netmask in this bootpath is no problem, since it's a value
>>> specified in firmware. But,
>>> The value of 'subnet_mask.ipv4' was set with 0xfffffc00, and
>>> __builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4)) returned 16
>>> (not 22).
>>> As a result, 16 was used for netmask wrongly.
>>>
>>> 1111 1111 1111 1111 1111 1100 0000 0000 # subnet_mask.ipv4
>>> (=0xfffffc00)
>>> 0000 0000 1111 1100 1111 1111 1111 1111 # grub_le_to_cpu32
>>> (subnet_mask.ipv4)
>>> 1111 1111 0000 0011 0000 0000 0000 0000 # ~grub_le_to_cpu32
>>> (subnet_mask.ipv4)
>>>
>>> And, the count of zero with __builtin_ctz can be 16.
>>> This patch changes it as below.
>>>
>>> 1111 1111 1111 1111 1111 1100 0000 0000 # subnet_mask.ipv4
>>> (=0xfffffc00)
>>> 0000 0000 1111 1100 1111 1111 1111 1111 # grub_le_to_cpu32
>>> (subnet_mask.ipv4)
>>> 1111 1111 1111 1111 1111 1100 0000 0000 #
>>> grub_swap_bytes32(grub_le_to_cpu32 (subnet_mask.ipv4))
>>> 0000 0000 0000 0000 0000 0011 1111 1111 #
>>> ~grub_swap_bytes32(grub_le_to_cpu32 (subnet_mask.ipv4))
>>>
>>> The count of zero with __builtin_clz can be 22. (clz counts the
>>> number of one bits preceding the most significant zero bit)
>>> ---
>>> grub-core/net/drivers/ieee1275/ofnet.c | 3 +--
>>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/grub-core/net/drivers/ieee1275/ofnet.c
>>> b/grub-core/net/drivers/ieee1275/ofnet.c
>>> index 002446be1..3df75357a 100644
>>> --- a/grub-core/net/drivers/ieee1275/ofnet.c
>>> +++ b/grub-core/net/drivers/ieee1275/ofnet.c
>>> @@ -220,8 +220,7 @@ grub_ieee1275_parse_bootpath (const char
>>> *devpath, char *bootpath,
>>> flags);
>>> inter->vlantag = vlantag;
>>> grub_net_add_ipv4_local (inter,
>>> - __builtin_ctz (~grub_le_to_cpu32
>>> (subnet_mask.ipv4)));
>>> -
>>> + __builtin_clz
>>> (~grub_swap_bytes32(grub_le_to_cpu32 (subnet_mask.ipv4))));
>>> }
>>>
>>> if (gateway_addr.ipv4 != 0)
>>> --
>>> 2.13.5
>>>
>>> _______________________________________________
>>> Bug-grub mailing list
>>> address@hidden
>>> https://lists.gnu.org/mailman/listinfo/bug-grub [1]
>>
>>
>>
>> Links:
>> ------
>> [1] https://lists.gnu.org/mailman/listinfo/bug-grub
>>
>> _______________________________________________
>> Bug-grub mailing list
>> address@hidden
>> https://lists.gnu.org/mailman/listinfo/bug-grub
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]