From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PULL 3/3] m68k: align bootinfo strings and data to 4 bytes
Date: Tue, 27 Sep 2022 08:26:33 +0200 [thread overview]
Message-ID: <20220927062633.618677-4-laurent@vivier.eu> (raw)
In-Reply-To: <20220927062633.618677-1-laurent@vivier.eu>
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Various tools, such as kexec-tools and m68k-bootinfo, expect each
bootinfo entry to be aligned to 4 bytes, not 2 bytes. So adjust the
padding to fill this out as such.
Also, break apart the padding additions from the other field length
additions, so that it's more clear why these magic numbers are being
added, and comment them too.
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20220926113900.1256630-2-Jason@zx2c4.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
hw/m68k/bootinfo.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/hw/m68k/bootinfo.h b/hw/m68k/bootinfo.h
index bd8b212fd35c..897162b8189c 100644
--- a/hw/m68k/bootinfo.h
+++ b/hw/m68k/bootinfo.h
@@ -48,13 +48,14 @@
stw_phys(as, base, id); \
base += 2; \
stw_phys(as, base, \
- (sizeof(struct bi_record) + strlen(string) + 2) & ~1); \
+ (sizeof(struct bi_record) + strlen(string) + \
+ 1 /* null termination */ + 3 /* padding */) & ~3); \
base += 2; \
for (i = 0; string[i]; i++) { \
stb_phys(as, base++, string[i]); \
} \
stb_phys(as, base++, 0); \
- base = (base + 1) & ~1; \
+ base = (base + 3) & ~3; \
} while (0)
#define BOOTINFODATA(as, base, id, data, len) \
@@ -63,13 +64,14 @@
stw_phys(as, base, id); \
base += 2; \
stw_phys(as, base, \
- (sizeof(struct bi_record) + len + 3) & ~1); \
+ (sizeof(struct bi_record) + len + \
+ 2 /* length field */ + 3 /* padding */) & ~3); \
base += 2; \
stw_phys(as, base, len); \
base += 2; \
for (i = 0; i < len; ++i) { \
stb_phys(as, base++, data[i]); \
} \
- base = (base + 1) & ~1; \
+ base = (base + 3) & ~3; \
} while (0)
#endif
--
2.37.3
next prev parent reply other threads:[~2022-09-27 6:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-27 6:26 [PULL 0/3] M68k for 7.2 patches Laurent Vivier
2022-09-27 6:26 ` [PULL 1/3] target/m68k: increase size of m68k CPU features from uint32_t to uint64_t Laurent Vivier
2022-09-27 6:26 ` [PULL 2/3] target/m68k: use M68K_FEATURE_MOVEFROMSR_PRIV feature for move_from_sr privilege check Laurent Vivier
2022-09-27 6:26 ` Laurent Vivier [this message]
2022-09-27 18:40 ` [PULL 0/3] M68k for 7.2 patches Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220927062633.618677-4-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=Jason@zx2c4.com \
--cc=geert@linux-m68k.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).