ieee1275/ofdisk: vscsi lun handling on lun len
A message that is not in the archive (sent off-list or not yet received): [email protected]
Avnish Chouhan
Reviewed-byQuoted 104 lines
Message: 3
Date: Mon, 11 Nov 2024 14:42:55 +0530
From: Mukesh Kumar Chaurasiya <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
[email protected], [email protected], [email protected], Mukesh Kumar Chaurasiya <[email protected]>
Subject: [PATCH V4] ieee1275/ofdisk: vscsi lun handling on lun len
Message-ID: <[email protected]>The information about "vscsi-report-luns" data is a list of disk details with pairs of memory addresses and lengths.
8 bytes 8 bytes
lun-addr ---> ------------------------ 8 bytes ^ | buf-addr | lun-count| --------> ------------- | ------------------------ | lun | | | buf-addr | lun-count| ----| ------------- "len" ------------------------ | | ... | | | ... | | ------------- | ------------------------ | | lun | | | buf-addr | lun-count| | ------------- V ------------------------ | |---> ------------- | lun | ------------- | ... | ------------- | lun | -------------The way the expression (args.table + 4 + 8 * i) is used is incorrect and can be confusing. The list of LUNs doesn't end with NULL, indicated by while (*ptr). Usually, this loop doesn't process any LUNs because it ends before checking any as first reported LUN is likely to be 0. The list of LUNs ends based on its length, not by a NULL value.
Signed-off-by Mukesh Kumar Chaurasiya <[email protected]>--- grub-core/disk/ieee1275/ofdisk.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)grub-core/disk/ieee1275/ofdisk.c +6
-0@@ -43,6 +43,12 @@ struct ofdisk_hash_entstruct ofdisk_hash_ent *next; }; +struct lun_buf +{ +grub_uint64_t buf_addr; +grub_uint64_t lun_count; +}; + static grub_err_t grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size,grub-core/disk/ieee1275/ofdisk.c +2
-1struct ofdisk_hash_ent *op);@@ -222,8 +228,9 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)grub_ieee1275_cell_t table; } args; +struct lun_buf *tbl;char *buf, *bufptr; -unsigned i; +unsigned int i, j;if (grub_ieee1275_open (alias->path, &ihandle))grub-core/disk/ieee1275/ofdisk.c +11
-10return ;@@ -248,17 +255,18 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)return ; bufptr =grub_stpcpy (buf, alias->path); + tbl = (struct lun_len *) args.table;for (i =0 ; i < args.nentries; i++) - { -grub_uint64_t *ptr; - - ptr = *(grub_uint64_t **) (args.table +4 +8 * i); -while (*ptr) - { -grub_snprintf (bufptr,32 ,"/disk@%" PRIxGRUB_UINT64_T, *ptr++); -dev_iterate_real (buf, buf); - } - } + { +grub_uint64_t *ptr; + + ptr = (grub_uint64_t *)(grub_addr_t ) tbl[i].buf_addr; +for (j =0 ; j < tbl[i].lun_count; j++) + { +grub_snprintf (bufptr,32 ,"/disk@%" PRIxGRUB_UINT64_T, *ptr++); +dev_iterate_real (buf, buf); + } + }grub_ieee1275_close (ihandle); grub_free (buf); return;
Quoted 7 lines
--
2.47.0------------------------------
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: Grub-devel Digest, Vol 249, Issue 46
In reply to a message not in the archiveHi Vladimir,
Hope you're doing wonderful!
Did you get a change to review my response to your query?
A similar handling of install device has been done for "SPARC64_IEEE1275 Platform". The issue we had in my v1 is to identify whether the machine PowerPC or PowerMac. With v2, we have achieved this and the change is limited to PowerPC now. Thank you!
Regards,
Avnish Chouhan
Quoted 170 lines
------------------------------
Message: 4
Date: Mon, 11 Nov 2024 10:13:57 +0100
From: Michal Suchánek <[email protected]>
To: avnish <[email protected]>
Cc: [email protected], [email protected], [email protected],
[email protected]
Subject: Re: [PATCH] Mandatory install device check for PowerPC
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-1Hello,
thanks for the patch!
Quoted 15 lines · avnish
Hi Vladimir,
Thank you so much for your response!I have fine tuned the patch as per the last discussion (sorry, I missed the v2 tag). This latest patch will add install device check only to PowerPC machines. PowerMacs aren't affected by this change. The check is added when platform is detected as "
GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275" along with machine detected as non PowerMac. As per my Power platform analysis, currently in "grub_install.c", it detects PowerMacs based on the file system detected (HFS or HFS+) and set the "is_prep" as 0 based on this finding. This new check will only be applicable to PowerPC. And in case of PowerMacs, it will allowgrub_installeven without mentioning the install device. Thank you!Quoted 15 lines
Regards,
Avnish ChouhanQuoted 13 lines
------------------------------
Message: 5
Date: Fri, 8 Nov 2024 15:07:29 +0300
From: "Vladimir 'phcoder' Serbinenko" <[email protected]>
To: The development of GNU GRUB <[email protected]>
Subject: Re: [PATCH] Mandatory install device check for PowerPC Message-ID:
<CAEaD8JMqP4_uP5cZutSMGWvGMxbHAvNh10VCMO4ZcbqvLAQ9zw@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"As discussed in another thread, this breaks installing from x86 onto removable disk for PPC Mac which is a supported workflow
Please be more specific. I cannot find how this version of the patch still breaks other platforms. Given that you are talking about cross-installation form x86 this should be eeasy to test given detailed description.
Quoted 19 lines
Quoted 19 lines
Le ven. 8 nov. 2024, 14:13, Avnish Chouhan <[email protected]> a écrit :
Quoted 15 lines
This patch adds a check on
install_devicewhile installing grub for PowerPC.
Ifinstall_deviceis not mentioned in grub2-install and machine is detected
as PowerPC, the error will be thrown and it will terminates the grub2-install
operation. Running grub2-install on PowerPC without theinstall_devicemay
result in bootlist corruption. When no install device is specified, it attempts
to load images from the filesystem, which leads to nvram bootlist corruption.
The idea is to fail the operation and avoid creating the invalid boot entry.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Avnish Chouhan <[email protected]>--- grub-install.c | 11 +++++++++++ 1 file changed, 11 insertions(+)Before here there is this code:
if (
install_device)
is_prep= 1;This is the root of the problem. The code sets
is_prepbased on user input, and when the input is wrongis_prepremains wrongly unset, leading to bogus entry written to bootlist, and the system becoming unbootable.Instead this code shuld be removed, and
is_prepinitialized to 1.Quoted 7 lines
Quoted 7 lines
util/grub-install.c main (int argc, char *argv[]) · line 1289
Quoted 7 lines
util/grub-install.c +0
-0@@ -1289,6 +1289,17 @@ main (int argc, char *argv[]) is_prep =0 ;Here
is_prepis unset when a Mac boot partition is found. With that initializingis_prepto 1 gives sound logic for determining if the system looks like a PowerMac or not.There is the possibility that grub-install would run on a PowerMac, and the Mac boot partition is not given by the user nor autodetected but there is not much that can be done about that given cross-installation is supported. This case can't work currently either.
Quoted 3 lines
Quoted 3 lines
util/grub-install.c main (int argc, char *argv[]) · line 1292
Quoted 3 lines
util/grub-install.c +1
-0} } +else This logic is still not sound. Though unlikely grub-install can find something that looks like a Mac boot partition (
is_guessis 1) but is not one (does not unsetis_prep).Instead of
else if (!install_device)
if (
is_prep&& !install_device)can be used when
is_prepis initialized to true unconditionally. Then the code above setsis_prepto false when a Mac partition is found, and if none is found and install device is not set it's an error.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
util/grub-install.c +3
-0+ { +/* +* As the machine has been detected as PowerPC and not the PowerMac. We need to check
+ * whether theinstall_devicehas been mentioned while
installing. If no device has beenQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
+ * mentioned, we need to exit and mark it as an error as the
install_deviceis required for
+ * PowerPC installation. An installation with no device
mentioned may lead to corruptions.util/grub-install.c +3
-0+*/ +if (!install_device) + grub_util_error ("%s", _("install device isn't specifiedrequired for PowerPC"));
This message is rather awkward and misleading.
I think something like "install device required on PReP platform" is as good as it gets.
The platform naming is quite unfortunate. The port to Power family of CPUs is called powerpc or ppc but PowerPC refers to the desktop family of CPUs found mainly in PowerMac hardware.
PReP is a standard originally meant for use with PowerPC based hardware, and that's where the partition name comes from but was superseded by CHRP and PAPR. PAPR specifically is used for server and embedded CPUs, not desktop, and that's what is supported besides PowerMac. I doubt current version of GRUB would work on the original PReP hardware.
Thanks
Michal
------------------------------
Subject: Digest Footer
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 4 lines
------------------------------
End of Grub-devel Digest, Vol 249, Issue 46
*******************************************
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Mandatory install device check for PowerPC
In reply to a message not in the archive(Resending the email due to missing proper subject line caused by some glitches in my application)
Hi Vladimir,
Hope you're doing wonderful!
Did you get a change to review my response to your query?
A similar handling of install device has been done for "SPARC64_IEEE1275 Platform". The issue we had in my v1 is to identify whether the machine PowerPC or PowerMac. With v2, we have achieved this and the change is limited to PowerPC now. Thank you!
Regards,
Avnish Chouhan
Quoted 170 lines
------------------------------
Message: 4
Date: Mon, 11 Nov 2024 10:13:57 +0100
From: Michal Suchánek <[email protected]>
To: avnish <[email protected]>
Cc: [email protected], [email protected], [email protected],
[email protected]
Subject: Re: [PATCH] Mandatory install device check for PowerPC
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-1Hello,
thanks for the patch!
Quoted 15 lines · avnish
Hi Vladimir,
Thank you so much for your response!I have fine tuned the patch as per the last discussion (sorry, I missed the v2 tag). This latest patch will add install device check only to PowerPC machines. PowerMacs aren't affected by this change. The check is added when platform is detected as "
GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275" along with machine detected as non PowerMac. As per my Power platform analysis, currently in "grub_install.c", it detects PowerMacs based on the file system detected (HFS or HFS+) and set the "is_prep" as 0 based on this finding. This new check will only be applicable to PowerPC. And in case of PowerMacs, it will allowgrub_installeven without mentioning the install device. Thank you!Quoted 15 lines
Regards,
Avnish ChouhanQuoted 13 lines
------------------------------
Message: 5
Date: Fri, 8 Nov 2024 15:07:29 +0300
From: "Vladimir 'phcoder' Serbinenko" <[email protected]>
To: The development of GNU GRUB <[email protected]>
Subject: Re: [PATCH] Mandatory install device check for PowerPC Message-ID:
<CAEaD8JMqP4_uP5cZutSMGWvGMxbHAvNh10VCMO4ZcbqvLAQ9zw@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"As discussed in another thread, this breaks installing from x86 onto removable disk for PPC Mac which is a supported workflow
Please be more specific. I cannot find how this version of the patch still breaks other platforms. Given that you are talking about cross-installation form x86 this should be eeasy to test given detailed description.
Quoted 19 lines
Quoted 19 lines
Le ven. 8 nov. 2024, 14:13, Avnish Chouhan <[email protected]> a écrit :
Quoted 15 lines
This patch adds a check on
install_devicewhile installing grub for PowerPC.
Ifinstall_deviceis not mentioned in grub2-install and machine is detected
as PowerPC, the error will be thrown and it will terminates the grub2-install
operation. Running grub2-install on PowerPC without theinstall_devicemay
result in bootlist corruption. When no install device is specified, it attempts
to load images from the filesystem, which leads to nvram bootlist corruption.
The idea is to fail the operation and avoid creating the invalid boot entry.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Avnish Chouhan <[email protected]>--- grub-install.c | 11 +++++++++++ 1 file changed, 11 insertions(+)Before here there is this code:
if (
install_device)
is_prep= 1;This is the root of the problem. The code sets
is_prepbased on user input, and when the input is wrongis_prepremains wrongly unset, leading to bogus entry written to bootlist, and the system becoming unbootable.Instead this code shuld be removed, and
is_prepinitialized to 1.Quoted 7 lines
Quoted 7 lines
util/grub-install.c main (int argc, char *argv[]) · line 1289
Quoted 7 lines
util/grub-install.c +0
-0@@ -1289,6 +1289,17 @@ main (int argc, char *argv[]) is_prep =0 ;Here
is_prepis unset when a Mac boot partition is found. With that initializingis_prepto 1 gives sound logic for determining if the system looks like a PowerMac or not.There is the possibility that grub-install would run on a PowerMac, and the Mac boot partition is not given by the user nor autodetected but there is not much that can be done about that given cross-installation is supported. This case can't work currently either.
Quoted 3 lines
Quoted 3 lines
util/grub-install.c main (int argc, char *argv[]) · line 1292
Quoted 3 lines
util/grub-install.c +1
-0} } +else This logic is still not sound. Though unlikely grub-install can find something that looks like a Mac boot partition (
is_guessis 1) but is not one (does not unsetis_prep).Instead of
else if (!install_device)
if (
is_prep&& !install_device)can be used when
is_prepis initialized to true unconditionally. Then the code above setsis_prepto false when a Mac partition is found, and if none is found and install device is not set it's an error.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
util/grub-install.c +3
-0+ { +/* +* As the machine has been detected as PowerPC and not the PowerMac. We need to check
+ * whether theinstall_devicehas been mentioned while
installing. If no device has beenQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
+ * mentioned, we need to exit and mark it as an error as the
install_deviceis required for
+ * PowerPC installation. An installation with no device
mentioned may lead to corruptions.util/grub-install.c +3
-0+*/ +if (!install_device) + grub_util_error ("%s", _("install device isn't specifiedrequired for PowerPC"));
This message is rather awkward and misleading.
I think something like "install device required on PReP platform" is as good as it gets.
The platform naming is quite unfortunate. The port to Power family of CPUs is called powerpc or ppc but PowerPC refers to the desktop family of CPUs found mainly in PowerMac hardware.
PReP is a standard originally meant for use with PowerPC based hardware, and that's where the partition name comes from but was superseded by CHRP and PAPR. PAPR specifically is used for server and embedded CPUs, not desktop, and that's what is supported besides PowerMac. I doubt current version of GRUB would work on the original PReP hardware.
Thanks
Michal
------------------------------
Subject: Digest Footer
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 4 lines
------------------------------
End of Grub-devel Digest, Vol 249, Issue 46
*******************************************
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Mandatory install device check for PowerPC
Hi Vladimir,
Did you get a chance to review my response to your query? Thank you!
Regards,
Avnish Chouhan
Quoted 8 lines · Avnish Chouhan
(Resending the email due to missing proper subject line caused by some glitches in my application)
Hi Vladimir,
Hope you're doing wonderful!Did you get a change to review my response to your query?
Quoted 183 lines
A similar handling of install device has been done for "
SPARC64_IEEE1275Platform". The issue we had in my v1 is to identify whether the machine PowerPC or PowerMac. With v2, we have achieved this and the change is limited to PowerPC now.
Thank you!Regards,
Avnish ChouhanQuoted 174 lines
------------------------------
Message: 4
Date: Mon, 11 Nov 2024 10:13:57 +0100
From: Michal Suchánek <[email protected]>
To: avnish <[email protected]>
Cc: [email protected], [email protected], [email protected],
[email protected]
Subject: Re: [PATCH] Mandatory install device check for PowerPC
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-1Hello,
thanks for the patch!
Quoted 15 lines · avnish
Hi Vladimir,
Thank you so much for your response!I have fine tuned the patch as per the last discussion (sorry, I missed the v2 tag). This latest patch will add install device check only to PowerPC machines. PowerMacs aren't affected by this change. The check is added when platform is detected as "
GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275" along with machine detected as non PowerMac. As per my Power platform analysis, currently in "grub_install.c", it detects PowerMacs based on the file system detected (HFS or HFS+) and set the "is_prep" as 0 based on this finding. This new check will only be applicable to PowerPC. And in case of PowerMacs, it will allowgrub_installeven without mentioning the install device. Thank you!Quoted 15 lines
Regards,
Avnish ChouhanQuoted 13 lines
------------------------------
Message: 5
Date: Fri, 8 Nov 2024 15:07:29 +0300
From: "Vladimir 'phcoder' Serbinenko" <[email protected]>
To: The development of GNU GRUB <[email protected]>
Subject: Re: [PATCH] Mandatory install device check for PowerPC Message-ID:
<CAEaD8JMqP4_uP5cZutSMGWvGMxbHAvNh10VCMO4ZcbqvLAQ9zw@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"As discussed in another thread, this breaks installing from x86 onto removable disk for PPC Mac which is a supported workflow
Please be more specific. I cannot find how this version of the patch still breaks other platforms. Given that you are talking about cross-installation form x86 this should be eeasy to test given detailed description.
Quoted 19 lines
Quoted 19 lines
Le ven. 8 nov. 2024, 14:13, Avnish Chouhan <[email protected]> a écrit :
Quoted 15 lines
This patch adds a check on
install_devicewhile installing grub for PowerPC.
Ifinstall_deviceis not mentioned in grub2-install and machine is detected
as PowerPC, the error will be thrown and it will terminates the grub2-install
operation. Running grub2-install on PowerPC without theinstall_devicemay
result in bootlist corruption. When no install device is specified, it attempts
to load images from the filesystem, which leads to nvram bootlist corruption.
The idea is to fail the operation and avoid creating the invalid boot entry.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Avnish Chouhan <[email protected]>--- grub-install.c | 11 +++++++++++ 1 file changed, 11 insertions(+)Before here there is this code:
if (
install_device)
is_prep= 1;This is the root of the problem. The code sets
is_prepbased on user input, and when the input is wrongis_prepremains wrongly unset, leading to bogus entry written to bootlist, and the system becoming unbootable.Instead this code shuld be removed, and
is_prepinitialized to 1.Quoted 7 lines
Quoted 7 lines
util/grub-install.c main (int argc, char *argv[]) · line 1289
Quoted 7 lines
util/grub-install.c +0
-0@@ -1289,6 +1289,17 @@ main (int argc, char *argv[]) is_prep =0 ;Here
is_prepis unset when a Mac boot partition is found. With that initializingis_prepto 1 gives sound logic for determining if the system looks like a PowerMac or not.There is the possibility that grub-install would run on a PowerMac, and the Mac boot partition is not given by the user nor autodetected but there is not much that can be done about that given cross-installation is supported. This case can't work currently either.
Quoted 3 lines
Quoted 3 lines
util/grub-install.c main (int argc, char *argv[]) · line 1292
Quoted 3 lines
util/grub-install.c +1
-0} } +else This logic is still not sound. Though unlikely grub-install can find something that looks like a Mac boot partition (
is_guessis 1) but is not one (does not unsetis_prep).Instead of
else if (!install_device)
if (
is_prep&& !install_device)can be used when
is_prepis initialized to true unconditionally. Then the code above setsis_prepto false when a Mac partition is found, and if none is found and install device is not set it's an error.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
util/grub-install.c +3
-0+ { +/* +* As the machine has been detected as PowerPC and not the PowerMac. We need to check
+ * whether theinstall_devicehas been mentioned while
installing. If no device has beenQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
+ * mentioned, we need to exit and mark it as an error as the
install_deviceis required for
+ * PowerPC installation. An installation with no device
mentioned may lead to corruptions.util/grub-install.c +3
-0+*/ +if (!install_device) + grub_util_error ("%s", _("install device isn't specifiedrequired for PowerPC"));
This message is rather awkward and misleading.
I think something like "install device required on PReP platform" is as good as it gets.
The platform naming is quite unfortunate. The port to Power family of CPUs is called powerpc or ppc but PowerPC refers to the desktop family of CPUs found mainly in PowerMac hardware.
PReP is a standard originally meant for use with PowerPC based hardware, and that's where the partition name comes from but was superseded by CHRP and PAPR. PAPR specifically is used for server and embedded CPUs, not desktop, and that's what is supported besides PowerMac. I doubt current version of GRUB would work on the original PReP hardware.
Thanks
Michal
------------------------------
Subject: Digest Footer
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel------------------------------
End of Grub-devel Digest, Vol 249, Issue 46
*******************************************
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel