Platform/RaspberryPi: Fix RPI_FW_MAC_ADDR_TAG value buffer size - #1042
Open
valtzu wants to merge 1 commit into
Open
Platform/RaspberryPi: Fix RPI_FW_MAC_ADDR_TAG value buffer size#1042valtzu wants to merge 1 commit into
valtzu wants to merge 1 commit into
Conversation
The mailbox property interface pads each tag's value buffer to a 32-bit boundary so the following tags and the end tag stay aligned. Commit 6170839 ("RPiFirmwareDxe: Fix and consolidate incorrect pragma pack blocks") moved RPI_FW_MAC_ADDR_TAG under the module-wide #pragma pack(1) block. Its "UINT32 Padding" member then no longer rounds the struct up to a multiple of 4: the packed tag is 10 bytes (6-byte MAC address + 4-byte Padding), which leaves the trailing end tag misaligned. Recent VideoCore firmware rejects such a request with a 0x80000001 partial response, so RpiFirmwareGetMacAddress () fails and callers fall back to an all-zero MAC address. Replace the UINT32 with a 2-byte Padding array so the packed struct is 8 bytes - the smallest multiple of 4 that holds the 6-byte address. Signed-off-by: valtzu <valtzu@gmail.com>
Member
|
Can we just get rid of the --- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
+++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
@@ -31,7 +31,6 @@
//
#define NUM_PAGES 1
-#pragma pack(1)
typedef struct {
UINT32 BufferSize;
UINT32 Response;
@@ -69,7 +68,6 @@ typedef struct {
typedef struct {
UINT8 MacAddress[6];
- UINT32 Padding;
} RPI_FW_MAC_ADDR_TAG;
typedef struct {
@@ -80,7 +78,7 @@ typedef struct {
} RPI_FW_GET_MAC_ADDR_CMD;
typedef struct {
- UINT64 Serial;
+ UINT32 Serial[2];
} RPI_FW_SERIAL_TAG;
typedef struct {
@@ -254,7 +252,6 @@ typedef struct {
RPI_FW_GPIO_SET_CFG_TAG TagBody;
UINT32 EndTag;
} RPI_FW_NOTIFY_GPIO_SET_CFG_CMD;
-#pragma pack()
STATIC VOID *mDmaBuffer;
STATIC VOID *mDmaBufferMapping;
@@ -549,7 +546,7 @@ RpiFirmwareGetSerial (
return EFI_DEVICE_ERROR;
}
- *Serial = Cmd->TagBody.Serial;
+ CopyMem (Serial, Cmd->TagBody.Serial, sizeof (*Serial));
ReleaseSpinLock (&mMailboxLock);
// Some platforms return 0 or 0x0000000010000000 for serial.
// For those, try to use the MAC address. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix reading mac address on RPi4.
Background
2 years ago I submitted a bugfix for populating serial number on RPi4. That fix turned into larger refactoring. That refactoring caused another bug: #908.
I actually received an email from Oleg (sorry don't know his GH handle) reporting this same issue right after the changes were merged, but I didn't manage to look into it back then.
Interesting thing is that with older firmware (e.g.
1.20241125) there were no issues, so it seems that at some point the firmware started returning an error if you provide it with an unaligned block of memory (not 100% sure on this).