Grub-devel Digest, Vol 234, Issue 14
A message that is not in the archive (sent off-list or not yet received): [email protected]
help
Quoted 268 lines · On Sun, Aug 13, 2023 at 1:17 PM <[email protected]> wrote:
Send Grub-devel mailing list submissions to
[email protected]To subscribe or unsubscribe via the World Wide Web, visit
https://lists.gnu.org/mailman/listinfo/grub-devel
or, via email, send a message with subject or body 'help' to
[email protected]You can reach the person managing the list at
[email protected]When replying, please edit your Subject line so it is more specific than "Re: Contents of Grub-devel digest..."
Today's Topics:
1. Re: [PATCH v9 02/11] Unify GUID types
(Vladimir 'phcoder' Serbinenko)----------------------------------------------------------------------
Message: 1
Date: Sun, 13 Aug 2023 09:46:45 +0200
From: "Vladimir 'phcoder' Serbinenko" <[email protected]>
To: Pedro Miguel Justo <[email protected]>
Cc: John Paul Adrian Glaubitz <[email protected]>, The
development of GNU GRUB <[email protected]>, Oliver Steffen <[email protected]>, Gerd Hoffmann <[email protected]>, Frank Scheiner <[email protected]>
Subject: Re: [PATCH v9 02/11] Unify GUID types
Message-ID:<CAEaD8JOWL9gyWt6qs36pDFioi3uE86YQhp=[email protected]>
Content-Type: text/plain; charset="utf-8"Full analysis:
gpt_partentrycan be marked as aligned8. But following are problem:
*protocols_per_handlemay return unaligned guids
*configuration_tablesarray may be unaligned. On efi32 every entry is 20 bytes, so guids can't be 8-byte aligned
* The worst offender is device path as it's packed, unpredictable and contains uuids.
* Efiemu gets guid as argument and probably should be able to handle unaligned case. So far it's x86 only and we have no mmx and co so it's not a problem right now unless we enable ubsan.
All in all we do need packed guid type unless those are resolved. I attach patches for testing. If they work, I'll rearrange them a bitQuoted 58 lines · Vladimir 'phcoder' Serbinenko
Le dim. 13 août 2023, 00:57, Pedro Miguel Justo <[email protected]> a écrit :
Quoted 53 lines
Quoted 3 lines
On Aug 12, 2023, at 11:04, John Paul Adrian Glaubitz <
Quoted 13 lines · [email protected]> wrote:
Hi Daniel!
Quoted 9 lines · Daniel Kiper
Quoted 8 lines · Oliver Steffen
Quoting John Paul Adrian Glaubitz (2023-08-11 10:32:17)
Quoted 7 lines
Hi Oliver!
Quoted 4 lines · Oliver Steffen
There are 3 implementations of a GUID in Grub. Replace them with a common one, placed in
types.h.It uses the "packed" flavor of the GUID structs, the alignment
attribute
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
is dropped, since it is not required.
Signed-off-by Oliver Steffen <[email protected]>Reviewed-by Daniel Kiper <[email protected]>[...]
Quoted 2 lines
Quoted 2 lines
According to [1], this change broke GRUB on ia64:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Welcome to GRUB!
7 0
0x00006B0x000000000000001Eunexpected trap
7 00x0000660x000000000000001Etrap taken, number in ext PE 7 00x00003C0x0000000000005A00trap taken, offset in ext PEI assume this is because of the strict alignment requirements on
ia64.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Could you have a look?
I am very sorry for this mistake.
My goal was to unify the two GUID types we had in grub but I missedthe
Quoted 1 line
Quoted 1 line
Quoted 1 line
fact that in my "solution" the alignments are not correct in all
cases.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
The quickest way out could be to revert the GUID unification and
printf
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
format specifier commits:
6ad116e5fguid: Make use of GUID printf format specifierf82dbf2bdkern/misc: Add a format specifier GUIDs06edd40dbguid: Unify GUID typesAnd use the explicit, long-winded format string for printing the
GUID
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
in the bli module instead (added in the commits following those).
I am open to suggestions / comments.
Adrian, could you check what will happen when you add alignment to
the
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
grub_guid_tas it was suggested by Frank here [2]?Personally I would avoid adding another GUID type with just alignment requirement as the difference. Making one GUID type with always
enforced
Quoted 1 line
Quoted 1 line
alignment should not cost us a lot. Or we can enforce alignment on
EFI
Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Quoted 1 line
platforms only.
My Itanium hardware is not available for bootloader tests at the
moment, so I would
Quoted 1 line
like to ask Pedro Miguel Justo or Frank Scheiner to test the proposed
fix.
The reason that before this unification there were a packed and aligned types suggest that the packed type was necessary in some cases. Frank
had
Quoted 2 lines
Quoted 2 lines
shared the concern against his own suggestion that changing the unified type to be aligned (as opposite to packed) would likely regress the
cases
Quoted 17 lines
Quoted 17 lines
where the packed might be needed/expected.
Just for kicks, I gave it a try:
```
include/grub/types.h +1
-1@@ -376,7 +376,7 @@ struct grub_guidgrub_uint16_t data2;grub_uint16_t data3;grub_uint8_t data4[8 ]; -}GRUB_PACKED ; +} __attribute__ ((aligned(8)));typedef struct grub_guid grub_guid_t ;Quoted 5 lines
Quoted 5 lines
include/grub/types.h +0
-0#endif /* ! GRUB_TYPES_HEADER */ ```
As hypothesized, there are places where these structs (now unified) are expected to be packed, meaning to have an alignment of 1 (even smaller
than
Quoted 4 lines
Quoted 4 lines
the natural alignment of its larger member).
One of the cases where the dependency is present is in the
grub_gpt_partentrystructure. This structure is packed and includes aGUID
Quoted 5 lines
Quoted 4 lines
field. One struct of an enforced alignment ’n’ cannot host a member with enforced alignment ‘m’ where m > n. Thus, an 8 byte aligned
grub_guidcannot be hosted inside a 1 byte alignedgrub_gpt_partentry:Quoted 21 lines
grub_gpt_partentrydoesn't need
GRUB_PACKED. To be on a safe side we canadd compile time assert on its size
Quoted 13 lines
``` In file included from grub-core/disk/ldm.c:26: ./include/grub/gpt_partition.h:70:1: error: alignment 1 of ‘struct grub_gpt_partentry’ is less than 8 [-Werror=packed-not-aligned] 70 | } GRUB_PACKED; | ^ ./include/grub/gpt_partition.h:70:1: error: alignment 1 of ‘struct grub_gpt_partentry’ is less than 8 [-Werror=packed-not-aligned] ```Now, we could go this rabbit hole on and try to hack
grub_gpt_partentry, or special-case the GUID insidegrub_gpt_partentryto be packed… but at which point will I just end up with the thing we were trying to avoid:more
Quoted 6 lines
Quoted 6 lines
than one definition of GUID?
Quoted 4 lines
Thanks,
AdrianQuoted 7 lines
Quoted 7 lines
Quoted 5 lines
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer.' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913-------------- next part --------------
An HTML attachment was scrubbed...
URL: <
https://lists.gnu.org/archive/html/grub-devel/attachments/20230813/b10a3380/attachment.htmQuoted 1 line
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Mark-grub_gpt_partentry-as-aligned-to-8-bytes.patch
Type: text/x-diff
Size: 723 bytes
Desc: not available
URL: <
https://lists.gnu.org/archive/html/grub-devel/attachments/20230813/b10a3380/attachment.patchQuoted 1 line
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-missing-static-qualifier.patch
Type: text/x-diff
Size: 644 bytes
Desc: not available
URL: <
https://lists.gnu.org/archive/html/grub-devel/attachments/20230813/b10a3380/attachment-0001.patchQuoted 1 line
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Add-compile-time-asserts-for-guid-and-gpt_partentry-.patch
Type: text/x-diff
Size: 821 bytes
Desc: not available
URL: <
https://lists.gnu.org/archive/html/grub-devel/attachments/20230813/b10a3380/attachment-0002.patchQuoted 1 line
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Split-aligned-and-packed-guids.patch
Type: text/x-diff
Size: 9171 bytes
Desc: not available
URL: <
https://lists.gnu.org/archive/html/grub-devel/attachments/20230813/b10a3380/attachment-0003.patchQuoted 1 line
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-Fix-typo.patch
Type: text/x-diff
Size: 1078 bytes
Desc: not available
URL: <
https://lists.gnu.org/archive/html/grub-devel/attachments/20230813/b10a3380/attachment-0004.patchQuoted 1 line
------------------------------
Subject: Digest Footer
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 5 lines
------------------------------
End of Grub-devel Digest, Vol 234, Issue 14
*******************************************
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel