ieee1275/ofdisk: vscsi lun handling on lun len
PATCH v2 1/1 ieee1275/ofdisk: vscsi lun handling on lun len
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 | buf-len | --------> -------------
| ------------------------ | lun |
| | buf-addr | buf-len | ----| -------------
"len" ------------------------ | | ... |
| | ... | | -------------
| ------------------------ | | lun |
| | buf-addr | buf-len | | -------------
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.
--- grub-core/disk/ieee1275/ofdisk.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
grub-core/disk/ieee1275/ofdisk.c +8 -3
@@ -222,8 +222,12 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)grub_ieee1275_cell_t table; } args; +struct lun_buf { +grub_uint64_t *buf_addr; +grub_uint64_t buf_len; + } *tbl;char *buf, *bufptr; -unsigned i; +unsigned int i, j;if (grub_ieee1275_open (alias->path, &ihandle))return ;
@@ -248,12 +252,13 @@ 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) + ptr = (grub_uint64_t *)(grub_addr_t ) tbl[i].buf_addr; +for (j =0 ; j < tbl[i].buf_len; j++) {grub_snprintf (bufptr,32 ,"/disk@%" PRIxGRUB_UINT64_T, *ptr++);dev_iterate_real (buf, buf);
Signature · 7 lines
2.43.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 2 lines · Mukesh Kumar Chaurasiya
The information about "vscsi-report-luns" data is a list of disk details with pairs of memory addresses and lengths.
Not lengths but counts of entries.
Quoted 17 lines
8 bytes 8 bytes
lun-addr ---> ------------------------ 8 bytes ^ | buf-addr | buf-len | --------> ------------- | ------------------------ | lun | | | buf-addr | buf-len | ----| ------------- "len" ------------------------ | | ... | | | ... | | ------------- | ------------------------ | | lun | | | buf-addr | buf-len | | ------------- V ------------------------ | |---> ------------- | lun | ------------- | ... | ------------- | lun | -------------
Quoted 1 line
The way the expression "(args.table + 4 + 8 * i)" is used is incorrect and
I would drop quotation marks from here.
Quoted 3 lines
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
... ditto...
Quoted 12 lines
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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)grub-core/disk/ieee1275/ofdisk.c +0
-0
grub-core/disk/ieee1275/ofdisk.c dev_iterate (const struct grub_ieee1275_devalias *alias) · line 226
Quoted 5 lines
grub-core/disk/ieee1275/ofdisk.c +2
-0@@ -222,8 +222,12 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)grub_ieee1275_cell_t table; } args; +struct lun_buf { +grub_uint64_t *buf_addr;
This will not work on 32-bit architectures.
grub-core/disk/ieee1275/ofdisk.c dev_iterate (const struct grub_ieee1275_devalias *alias) · line 227
Quoted 1 line
grub-core/disk/ieee1275/ofdisk.c +1
-0+grub_uint64_t buf_len;
Again, this is not length. It is number of entries.
grub-core/disk/ieee1275/ofdisk.c dev_iterate (const struct grub_ieee1275_devalias *alias) · line 228
Quoted 1 line
grub-core/disk/ieee1275/ofdisk.c +1
-0+ } *tbl;
Why do you define this struct here? Do not you have its proper definition in currently existing code? Even if not I would define it properly outside of this function because somebody may need it later.
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 6 lines · Daniel Kiper
Quoted 5 lines · Mukesh Kumar Chaurasiya
Signed-off-by Mukesh Kumar Chaurasiya <[email protected]>--- grub-core/disk/ieee1275/ofdisk.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
Quoted 11 lines
grub-core/disk/ieee1275/ofdisk.c dev_iterate (const struct grub_ieee1275_devalias *alias) · line 226
Quoted 10 lines
grub-core/disk/ieee1275/ofdisk.c +2
-0@@ -222,8 +222,12 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)grub_ieee1275_cell_t table; } args; +struct lun_buf { +grub_uint64_t *buf_addr;This will not work on 32-bit architectures.
Umm...
well i checked this and the definition for 32bit and 64bit are same. So the structure part should be fine.
+ ptr =(grub_uint64_t*)(grub_addr_t) tbl[i].buf_addr; and this should handle the 32bit arch in terms of address. for rest i'll send out a new version of patch Regards,
Mukesh
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 19 lines · Mukesh Kumar Chaurasiya
Quoted 6 lines · Daniel Kiper
Quoted 5 lines · Mukesh Kumar Chaurasiya
Signed-off-by Mukesh Kumar Chaurasiya <[email protected]>--- grub-core/disk/ieee1275/ofdisk.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)Quoted 11 lines
grub-core/disk/ieee1275/ofdisk.c dev_iterate (const struct grub_ieee1275_devalias *alias) · line 226
Quoted 10 lines
grub-core/disk/ieee1275/ofdisk.c +2
-0@@ -222,8 +222,12 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)grub_ieee1275_cell_t table; } args; +struct lun_buf { +grub_uint64_t *buf_addr;This will not work on 32-bit architectures.
Quoted 3 lines
Umm...
well i checked this and the definition for 32bit and 64bit are same. So the
I am not entirely sure what you mean by "the same" here.
Quoted 5 lines
structure part should be fine.
+ ptr =(grub_uint64_t*)(grub_addr_t) tbl[i].buf_addr; and this should handle the 32bit arch in terms of address. for rest i'll send out a new version of patch
The problem is with the *buf_addr pointer. Its size on 32-bit platform is 32-bit. So, on 32-bit platform you will have struct with 32-bit member and 64-bit member following it. This is not what you expect. The buf_addr/buf_size table has each entry with two 64-bit members. Am I missing something?
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 29 lines · Daniel Kiper
Quoted 18 lines · Mukesh Kumar Chaurasiya
Quoted 6 lines · Daniel Kiper
Quoted 5 lines · Mukesh Kumar Chaurasiya
Signed-off-by Mukesh Kumar Chaurasiya <[email protected]>--- grub-core/disk/ieee1275/ofdisk.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)Quoted 11 lines
grub-core/disk/ieee1275/ofdisk.c dev_iterate (const struct grub_ieee1275_devalias *alias) · line 226
Quoted 10 lines
grub-core/disk/ieee1275/ofdisk.c +2
-0@@ -222,8 +222,12 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)grub_ieee1275_cell_t table; } args; +struct lun_buf { +grub_uint64_t *buf_addr;This will not work on 32-bit architectures.
Quoted 3 lines
Umm...
well i checked this and the definition for 32bit and 64bit are same. So the
I am not entirely sure what you mean by "the same" here.
Quoted 5 lines
structure part should be fine.
+ ptr =(grub_uint64_t*)(grub_addr_t) tbl[i].buf_addr; and this should handle the 32bit arch in terms of address. for rest i'll send out a new version of patch
Quoted 6 lines
The problem is with the
*buf_addrpointer. Its size on 32-bit platform is 32-bit. So, on 32-bit platform you will have struct with 32-bit member and 64-bit member following it. This is not what you expect. The buf_addr/buf_size table has each entry with two 64-bit members. Am I missing something?Daniel
In case of 32 bit the upper 4 bytes are padded with 00. I am not sure why, this was weird for me too.
Regards
Mukesh
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel