From bcd92bd3f13216455287b6f5e50719a48a5aeb0adbef05e1d253aa57349e84ed Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Wed, 28 Mar 2018 07:02:31 +0000 Subject: [PATCH] Accepting request 591058 from home:michals - Fix incorrect netmask on ppc64 (bsc#1085419) * grub2-Fix-incorrect-netmask-on-ppc64.patch OBS-URL: https://build.opensuse.org/request/show/591058 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=295 --- grub2-Fix-incorrect-netmask-on-ppc64.patch | 40 ++++++++++++++++++++++ grub2.changes | 6 ++++ grub2.spec | 8 +++-- 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 grub2-Fix-incorrect-netmask-on-ppc64.patch diff --git a/grub2-Fix-incorrect-netmask-on-ppc64.patch b/grub2-Fix-incorrect-netmask-on-ppc64.patch new file mode 100644 index 0000000..3cf4ba6 --- /dev/null +++ b/grub2-Fix-incorrect-netmask-on-ppc64.patch @@ -0,0 +1,40 @@ +From: Masahiro Matsuya + +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/l-lan@30000002: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 | 2 +- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff -ur grub-2.02~/grub-core/net/drivers/ieee1275/ofnet.c grub-2.02/grub-core/net/drivers/ieee1275/ofnet.c +--- grub-2.02~/grub-core/net/drivers/ieee1275/ofnet.c 2018-03-26 13:49:55.399558334 +0200 ++++ grub-2.02/grub-core/net/drivers/ieee1275/ofnet.c 2018-03-26 13:51:03.092656921 +0200 +@@ -232,7 +232,7 @@ + } + + grub_net_add_ipv4_local (inter, +- __builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4))); ++ __builtin_clz (~ (subnet_mask.ipv4))); + } + + if (gateway_addr.ipv4 != 0) diff --git a/grub2.changes b/grub2.changes index 5e38227..73f3fde 100644 --- a/grub2.changes +++ b/grub2.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon Mar 26 11:37:13 UTC 2018 - msuchanek@suse.com + +- Fix incorrect netmask on ppc64 (bsc#1085419) + * grub2-Fix-incorrect-netmask-on-ppc64.patch + ------------------------------------------------------------------- Mon Mar 12 07:31:10 UTC 2018 - mchang@suse.com diff --git a/grub2.spec b/grub2.spec index 8cff954..23d9817 100644 --- a/grub2.spec +++ b/grub2.spec @@ -213,8 +213,7 @@ Patch81: grub2-lvm-allocate-metadata-buffer-from-raw-contents.patch Patch82: grub2-diskfilter-support-pv-without-metadatacopies.patch Patch83: grub2-efi-uga-64bit-fb.patch Patch84: grub2-s390x-09-improve-zipl-setup.patch -Patch85: grub2-install-remove-useless-check-PReP-partition-is-empty.patch -Patch86: grub2-getroot-scan-disk-pv.patch +Patch85: grub2-getroot-scan-disk-pv.patch # Btrfs snapshot booting related patches Patch101: grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch Patch102: grub2-btrfs-02-export-subvolume-envvars.patch @@ -247,6 +246,8 @@ Patch234: fix-grub2-use-stat-instead-of-udevadm-for-partition-lookup-with- Patch235: 0002-Add-Virtual-LAN-support.patch Patch236: grub2-efi_gop-avoid-low-resolution.patch Patch277: grub2-ppc64-cas-reboot-support.patch +Patch278: grub2-install-remove-useless-check-PReP-partition-is-empty.patch +Patch279: grub2-Fix-incorrect-netmask-on-ppc64.patch # Support HTTP Boot IPv4 and IPv6 (fate#320129) Patch280: 0001-misc-fix-invalid-character-recongition-in-strto-l.patch Patch281: 0002-net-read-bracketed-ipv6-addrs-and-port-numbers.patch @@ -492,7 +493,6 @@ swap partition while in resuming %patch83 -p1 %patch84 -p1 %patch85 -p1 -%patch86 -p1 %patch101 -p1 %patch102 -p1 %patch103 -p1 @@ -519,6 +519,8 @@ swap partition while in resuming %patch235 -p1 %patch236 -p1 %patch277 -p1 +%patch278 -p1 +%patch279 -p1 %patch280 -p1 %patch281 -p1 %patch282 -p1