darwin: expand cross-builds to also support x86 and testing
cover darwin: expand cross-builds to also support x86 and testing
Hello,
This series expands the recently introduced Darwin hypervisor build support to also allow cross-building an x86 hypervisor, that's done in patches 1 to 3. Patches 4 and 5 introduce some Cirrus-CI testing to do cross-builds from macOS, plus it also introduces some basic smoke testing of the x86 builds using the XTF selftest, just like it's currently done for the FreeBSD builds.
A result of the updated Cirrus-CI pipeline can be seen at:
https://cirrus-ci.com/build/6723050642604032
Thanks, Roger.
Roger Pau Monne (5):
xen/x86: always consider '/' as a division in assembly xen/tools: remove usages of stat -s in check-endbr.sh xen/tools: fix grep reporting 'illegal byte sequence' in
check-endbr.sh
cirrus-ci: add x86 and arm64 macOS hypervisor builds
cirrus-ci: add x86 XTF self-tests for macOS build
.cirrus.yml | 51 ++++++++++++++++++++++++++++++++++------ xen/Makefile | 7 ++++++ xen/tools/check-endbr.sh | 18 +++++++------- 3 files changed, 61 insertions(+), 15 deletions(-)
Signature · 1 line
2.51.0
PATCH 1/5 xen/x86: always consider '/' as a division in assembly
On x86 GNU assembler will consider '/' as the start of comment marker for some ELF targets. This is incorrect with Xen's usage, which does use '/' in assembly files as a mathematical operator.
The behavior of the assembler can be altered by passing the --divide option; unconditionally pass this option when available to force the expected behavior.
---
Changes since v1:
- Guard option setting to x86 only.
- Adjust comment.
--- xen/Makefile | 7 +++++++ 1 file changed, 7 insertions(+)
xen/Makefile +7 -0
@@ -413,6 +413,13 @@ ifneq ($(CONFIG_CC_IS_CLANG),y) CFLAGS += -Wa,--strip-local-absolute endif +ifeq ($(CONFIG_X86),y) +# The GNU assembler will interpret '/' as a comment start marker instead of a +# divide for some ELF targets. Pass --divide when when available to signal '/' +# is always used as an operator in assembly. +$(call cc-option-add,CFLAGS,CC,-Wa$$(comma)--divide) +endif + $(call cc-option-add,AFLAGS,CC,-Wa$$(comma)--noexecstack) LDFLAGS-$(call ld-option,--warn-rwx-segments) += --no-warn-rwx-segments
Signature · 1 line
2.51.0
Re: [PATCH 1/5] xen/x86: always consider '/' as a division in assembly
Hi Roger,
Quoted 9 lines · Roger Pau Monne
On x86 GNU assembler will consider '/' as the start of comment marker for some ELF targets. This is incorrect with Xen's usage, which does use '/' in assembly files as a mathematical operator.
The behavior of the assembler can be altered by passing the --divide option; unconditionally pass this option when available to force the expected behavior.
Works to build x86 and arm still working on Mac OS.
Quoted 3 lines
Reported-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>
Cheers
Bertrand
Quoted 30 lines
---
Changes since v1:
- Guard option setting to x86 only.
- Adjust comment.
---
xen/Makefile | 7 +++++++1 file changed, 7 insertions(+)xen/Makefile +0
-0@@ -413,6 +413,13 @@ ifneq ($(CONFIG_CC_IS_CLANG),y)CFLAGS += -Wa,--strip-local-absolute
endifxen/Makefile +7
-0+ifeq ($(CONFIG_X86),y) +# The GNU assembler will interpret '/' as a comment start marker instead of a +# divide for some ELF targets. Pass --divide when when available to signal '/' +# is always used as an operator in assembly. +$(call cc-option-add,CFLAGS,CC,-Wa$$(comma)--divide) +endif +$(call cc-option-add,AFLAGS,CC,-Wa$$(comma)--noexecstack)
LDFLAGS-$(call ld-option,--warn-rwx-segments) += --no-warn-rwx-segments
Signature · 1 line
2.51.0
Re: [PATCH 1/5] xen/x86: always consider '/' as a division in assembly
In reply to Roger Pau Monnexen/Makefile ifneq ($(CONFIG_CC_IS_CLANG),y) · line 421
Quoted 12 lines · Roger Pau Monne
xen/Makefile +6
-0@@ -413,6 +413,13 @@ ifneq ($(CONFIG_CC_IS_CLANG),y) CFLAGS += -Wa,--strip-local-absolute endif +ifeq ($(CONFIG_X86),y) +# The GNU assembler will interpret '/' as a comment start marker instead of a +# divide for some ELF targets. Pass --divide when when available to signal '/' +# is always used as an operator in assembly. +$(call cc-option-add,CFLAGS,CC,-Wa$$(comma)--divide) +endif
As said before, I don't think this should be put here. Not even with the new ifeq(,) around it. It should go in x86/arch.mk, or a reason should be given why it can't.
Jan
Re: [PATCH 1/5] xen/x86: always consider '/' as a division in assembly
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Roger Pau Monne
xen/Makefile +0
-0@@ -413,6 +413,13 @@ ifneq ($(CONFIG_CC_IS_CLANG),y) CFLAGS += -Wa,--strip-local-absolute endif
Quoted 10 lines
xen/Makefile ifneq ($(CONFIG_CC_IS_CLANG),y) · line 421
Quoted 6 lines
xen/Makefile +6
-0+ifeq ($(CONFIG_X86),y) +# The GNU assembler will interpret '/' as a comment start marker instead of a +# divide for some ELF targets. Pass --divide when when available to signal '/' +# is always used as an operator in assembly. +$(call cc-option-add,CFLAGS,CC,-Wa$$(comma)--divide) +endifAs said before, I don't think this should be put here. Not even with the new
ifeq(,)around it. It should go inx86/arch.mk, or a reason should be given why it can't.
My bad. I've attempted to put it there but got complains from the build in x86/boot/. I think that was because I had leftover stale objects in there, and nothing do to with the patch itself. I can confirm it works when the chunk is placed in x86/arch.mk.
Thanks, Roger.
PATCH 2/5 xen/tools: remove usages of `stat -s` in check-endbr.sh
In reply to Roger Pau MonneThe -s option to stat is not POSIX compatible, and hence prevents the check-endbr.sh script from running reliably.
The first instance of stat -s can be removed by fetching the section size from the output of objdump itself, which the script already parses to get the VMA values.
The other two instances can be replaced by counting the lines in the respective files. Those files contain list of addresses, so the size in bytes is not strictly needed, we can count the number of lines instead.
--- xen/tools/check-endbr.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
xen/tools/check-endbr.sh +7 -6
@@ -92,14 +92,15 @@ ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & # check nevertheless. # eval $(${OBJDUMP} -j .text $1 -h | - $AWK '$2 == ".text" {printf "vma_hi=%s\nvma_lo=%s\n", substr($4, 1, 9), substr($4, 10, 16)}') + $AWK '$2 == ".text" {printf "bin_sz=%s\nvma_hi=%s\nvma_lo=%s\n", "0x" $3, substr($4, 1, 9), substr($4, 10, 16)}') -${OBJCOPY} -j .text $1 -O binary $TEXT_BIN - -bin_sz=$(stat -c '%s' $TEXT_BIN) +# Convert objdump hex reported .text size to decimal +bin_sz=$(printf %u $bin_sz) [ "$bin_sz" -ge $(((1 << 28) - $vma_lo)) ] && { echo "$MSG_PFX Error: .text offsets must not exceed 256M" >&2; exit 1; } +${OBJCOPY} -j .text $1 -O binary $TEXT_BIN + # instruction: hex: oct: # endbr64 f3 0f 1e fa 363 017 036 372 # endbr32 f3 0f 1e fb 363 017 036 373
@@ -116,8 +117,8 @@ fi | $AWK -F':' '{printf "%s%07x\n", "'$vma_hi'", int('$((0x$vma_lo))') + $1}' > wait # Sanity check $VALID and $ALL, in case the string parsing bitrots -val_sz=$(stat -c '%s' $VALID) -all_sz=$(stat -c '%s' $ALL) +val_sz=$(wc -l < $VALID) +all_sz=$(wc -l < $ALL) [ "$val_sz" -eq 0 ] && { echo "$MSG_PFX Error: Empty valid-addrs" >&2; exit 1; } [ "$all_sz" -eq 0 ] && { echo "$MSG_PFX Error: Empty all-addrs" >&2; exit 1; } [ "$all_sz" -lt "$val_sz" ] && { echo "$MSG_PFX Error: More valid-addrs than all-addrs" >&2; exit 1; }
Signature · 1 line
2.51.0
Re: [PATCH 2/5] xen/tools: remove usages of `stat -s` in check-endbr.sh
Hi Roger,
Quoted 5 lines · Roger Pau Monne
The
-soption to stat is not POSIX compatible, and hence prevents thecheck-endbr.shscript from running reliably.
Quoted 7 lines
The first instance of
stat -scan be removed by fetching the section size from the output of objdump itself, which the script already parses to get the VMA values.The other two instances can be replaced by counting the lines in the respective files. Those files contain list of addresses, so the size in bytes is not strictly needed, we can count the number of lines instead.
I can confirm compilation works on my side and changes seem coherent but i would like an x86 maintainer to review/ack this one to confirm that functionally it is ok.
Quoted 3 lines
Suggested-by Bertrand Marquis <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>
Cheers
Bertrand
Quoted 42 lines
---
xen/tools/check-endbr.sh| 13 +++++++------1 file changed, 7 insertions(+), 6 deletions(-)xen/tools/check-endbr.sh +0
-0@@ -92,14 +92,15 @@ ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & # check nevertheless. #eval $(${OBJDUMP} -j .text $1 -h |
xen/tools/check-endbr.sh +3
-4- $AWK '$2 == ".text" {printf "vma_hi=%s\nvma_lo=%s\n", substr($4, 1, 9), substr($4, 10, 16)}') + $AWK '$2 == ".text" {printf "bin_sz=%s\nvma_hi=%s\nvma_lo=%s\n", "0x" $3, substr($4, 1, 9), substr($4, 10, 16)}') -${OBJCOPY} -j .text $1 -O binary $TEXT_BIN - -bin_sz=$(stat -c '%s' $TEXT_BIN) +# Convert objdump hex reported .text size to decimal +bin_sz=$(printf %u $bin_sz)[ "$bin_sz" -ge $(((1 << 28) - $vma_lo)) ] &&
{ echo "$MSG_PFX Error: .text offsets must not exceed 256M" >&2; exit 1; }+${OBJCOPY} -j .text $1 -O binary $TEXT_BIN
+# instruction: hex: oct: # endbr64 f3 0f 1e fa 363 017 036 372 # endbr32 f3 0f 1e fb 363 017 036 373xen/tools/check-endbr.sh +0
-0@@ -116,8 +117,8 @@ fi | $AWK -F':' '{printf "%s%07x\n", "'$vma_hi'", int('$((0x$vma_lo))') + $1}' >wait
# Sanity check $VALID and $ALL, in case the string parsing bitrots
xen/tools/check-endbr.sh +2
-2-val_sz=$(stat -c '%s' $VALID) -all_sz=$(stat -c '%s' $ALL) +val_sz=$(wc -l < $VALID) +all_sz=$(wc -l < $ALL)[ "$val_sz" -eq 0 ] && { echo "$MSG_PFX Error: Empty valid-addrs" >&2; exit 1; }
[ "$all_sz" -eq 0 ] && { echo "$MSG_PFX Error: Empty all-addrs" >&2; exit 1; }
[ "$all_sz" -lt "$val_sz" ] && { echo "$MSG_PFX Error: More valid-addrs than all-addrs" >&2; exit 1; }Signature · 1 line
2.51.0
Re: [PATCH 2/5] xen/tools: remove usages of `stat -s` in check-endbr.sh
In reply to Roger Pau MonneQuoted 6 lines · Roger Pau Monne
The
-soption to stat is not POSIX compatible, and hence prevents thecheck-endbr.shscript from running reliably.The first instance of
stat -scan be removed by fetching the section size from the output of objdump itself, which the script already parses to get the VMA values.
In both paragraphs, s/-s/-c/ ?
Quoted 3 lines
The other two instances can be replaced by counting the lines in the respective files. Those files contain list of addresses, so the size in bytes is not strictly needed, we can count the number of lines instead.
Hmm, indeed, just that ...
Quoted 4 lines
xen/tools/check-endbr.sh +0
-0@@ -92,14 +92,15 @@ ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & # check nevertheless.
xen/tools/check-endbr.sh ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & · line 98
Quoted 10 lines
xen/tools/check-endbr.sh +3
-4# eval $(${OBJDUMP} -j .text $1 -h | - $AWK '$2 == ".text" {printf "vma_hi=%s\nvma_lo=%s\n", substr($4, 1, 9), substr($4, 10, 16)}') + $AWK '$2 == ".text" {printf "bin_sz=%s\nvma_hi=%s\nvma_lo=%s\n", "0x" $3, substr($4, 1, 9), substr($4, 10, 16)}') -${OBJCOPY} -j .text $1 -O binary $TEXT_BIN - -bin_sz=$(stat -c '%s' $TEXT_BIN) +# Convert objdump hex reported .text size to decimal +bin_sz=$(printf %u $bin_sz)
(Alternatively without this line, but ...
xen/tools/check-endbr.sh ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & · line 99
Quoted 1 line
xen/tools/check-endbr.sh +0
-0[ "$bin_sz" -ge $(((1 << 28) - $vma_lo)) ] &&
[ "$(($bin_sz))" -ge $(((1 << 28) - $vma_lo)) ] &&
?)
Quoted 8 lines
xen/tools/check-endbr.sh +2
-0{ echo "$MSG_PFX Error: .text offsets must not exceed 256M" >&2; exit 1; } +${OBJCOPY} -j .text $1 -O binary $TEXT_BIN + # instruction: hex: oct: # endbr64 f3 0f 1e fa 363 017 036 372 # endbr32 f3 0f 1e fb 363 017 036 373
xen/tools/check-endbr.sh fi | $AWK -F':' '{printf "%s%07x\n", "'$vma_hi'", int('$((0x$vma_lo))') + $1}' > · line 124
Quoted 10 lines
xen/tools/check-endbr.sh +2
-2@@ -116,8 +117,8 @@ fi | $AWK -F':' '{printf "%s%07x\n", "'$vma_hi'", int('$((0x$vma_lo))') + $1}' > wait # Sanity check $VALID and $ALL, in case the string parsing bitrots -val_sz=$(stat -c '%s' $VALID) -all_sz=$(stat -c '%s' $ALL) +val_sz=$(wc -l < $VALID) +all_sz=$(wc -l < $ALL) [ "$val_sz" -eq 0 ] && { echo "$MSG_PFX Error: Empty valid-addrs" >&2; exit 1; } [ "$all_sz" -eq 0 ] && { echo "$MSG_PFX Error: Empty all-addrs" >&2; exit 1; } [ "$all_sz" -lt "$val_sz" ] && { echo "$MSG_PFX Error: More valid-addrs than all-addrs" >&2; exit 1; }
... the variables' _sz suffixes then end up a little misleading. Not sure in how far we care. Perhaps not enough to warrant the bigger churn:
(with the description adjustment).
Jan
Re: [PATCH 2/5] xen/tools: remove usages of `stat -s` in check-endbr.sh
Quoted 9 lines · Jan Beulich
Quoted 6 lines · Roger Pau Monne
The
-soption to stat is not POSIX compatible, and hence prevents thecheck-endbr.shscript from running reliably.The first instance of
stat -scan be removed by fetching the section size from the output of objdump itself, which the script already parses to get the VMA values.In both paragraphs, s/-s/-c/ ?
Bah, yes.
Quoted 23 lines
Quoted 3 lines
The other two instances can be replaced by counting the lines in the respective files. Those files contain list of addresses, so the size in bytes is not strictly needed, we can count the number of lines instead.
Hmm, indeed, just that ...
Quoted 4 lines
xen/tools/check-endbr.sh +0
-0@@ -92,14 +92,15 @@ ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & # check nevertheless.xen/tools/check-endbr.sh ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & · line 98
Quoted 10 lines
xen/tools/check-endbr.sh +3
-4# eval $(${OBJDUMP} -j .text $1 -h | - $AWK '$2 == ".text" {printf "vma_hi=%s\nvma_lo=%s\n", substr($4, 1, 9), substr($4, 10, 16)}') + $AWK '$2 == ".text" {printf "bin_sz=%s\nvma_hi=%s\nvma_lo=%s\n", "0x" $3, substr($4, 1, 9), substr($4, 10, 16)}') -${OBJCOPY} -j .text $1 -O binary $TEXT_BIN - -bin_sz=$(stat -c '%s' $TEXT_BIN) +# Convert objdump hex reported .text size to decimal +bin_sz=$(printf %u $bin_sz)(Alternatively without this line, but ...
Quoted 5 lines
xen/tools/check-endbr.sh ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & · line 99
Quoted 1 line
xen/tools/check-endbr.sh +0
-0[ "$bin_sz" -ge $(((1 << 28) - $vma_lo)) ] &&[ "$(($bin_sz))" -ge $(((1 << 28) - $vma_lo)) ] &&
?)
Isn't that bash-specific functionality? The script interpreter is set as /bin/sh.
Quoted 21 lines
Quoted 8 lines
xen/tools/check-endbr.sh +2
-0{ echo "$MSG_PFX Error: .text offsets must not exceed 256M" >&2; exit 1; } +${OBJCOPY} -j .text $1 -O binary $TEXT_BIN + # instruction: hex: oct: # endbr64 f3 0f 1e fa 363 017 036 372 # endbr32 f3 0f 1e fb 363 017 036 373xen/tools/check-endbr.sh fi | $AWK -F':' '{printf "%s%07x\n", "'$vma_hi'", int('$((0x$vma_lo))') + $1}' > · line 124
Quoted 10 lines
xen/tools/check-endbr.sh +2
-2@@ -116,8 +117,8 @@ fi | $AWK -F':' '{printf "%s%07x\n", "'$vma_hi'", int('$((0x$vma_lo))') + $1}' > wait # Sanity check $VALID and $ALL, in case the string parsing bitrots -val_sz=$(stat -c '%s' $VALID) -all_sz=$(stat -c '%s' $ALL) +val_sz=$(wc -l < $VALID) +all_sz=$(wc -l < $ALL) [ "$val_sz" -eq 0 ] && { echo "$MSG_PFX Error: Empty valid-addrs" >&2; exit 1; } [ "$all_sz" -eq 0 ] && { echo "$MSG_PFX Error: Empty all-addrs" >&2; exit 1; } [ "$all_sz" -lt "$val_sz" ] && { echo "$MSG_PFX Error: More valid-addrs than all-addrs" >&2; exit 1; }... the variables'
_szsuffixes then end up a little misleading. Not sure in how far we care. Perhaps not enough to warrant the bigger churn:
Quoted 2 lines
Reviewed-by Jan Beulich <[email protected]>(with the description adjustment).
I could rename to _lines or some such, but I didn't see much benefit. If you don't have a strong opinion towards renaming I will leave as-is.
Thanks, Roger.
Re: [PATCH 2/5] xen/tools: remove usages of `stat -s` in check-endbr.sh
Quoted 19 lines · Roger Pau Monné
Quoted 18 lines · Jan Beulich
Quoted 4 lines · Roger Pau Monne
xen/tools/check-endbr.sh +0
-0@@ -92,14 +92,15 @@ ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & # check nevertheless.xen/tools/check-endbr.sh ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & · line 98
Quoted 10 lines
xen/tools/check-endbr.sh +3
-4# eval $(${OBJDUMP} -j .text $1 -h | - $AWK '$2 == ".text" {printf "vma_hi=%s\nvma_lo=%s\n", substr($4, 1, 9), substr($4, 10, 16)}') + $AWK '$2 == ".text" {printf "bin_sz=%s\nvma_hi=%s\nvma_lo=%s\n", "0x" $3, substr($4, 1, 9), substr($4, 10, 16)}') -${OBJCOPY} -j .text $1 -O binary $TEXT_BIN - -bin_sz=$(stat -c '%s' $TEXT_BIN) +# Convert objdump hex reported .text size to decimal +bin_sz=$(printf %u $bin_sz)(Alternatively without this line, but ...
Quoted 8 lines
Quoted 5 lines
xen/tools/check-endbr.sh ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & · line 99
Quoted 1 line
xen/tools/check-endbr.sh +0
-0[ "$bin_sz" -ge $(((1 << 28) - $vma_lo)) ] &&[ "$(($bin_sz))" -ge $(((1 << 28) - $vma_lo)) ] &&
?)
Isn't that bash-specific functionality? The script interpreter is set as
/bin/sh.
I, too, would have thought so, but then the rhs of the -ge already used $((...)).
Jan
Re: [PATCH 2/5] xen/tools: remove usages of `stat -s` in check-endbr.sh
Quoted 22 lines · Jan Beulich
Quoted 21 lines · Roger Pau Monné
Quoted 20 lines · Jan Beulich
Quoted 4 lines · Roger Pau Monne
xen/tools/check-endbr.sh +0
-0@@ -92,14 +92,15 @@ ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & # check nevertheless.xen/tools/check-endbr.sh ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & · line 98
Quoted 10 lines
xen/tools/check-endbr.sh +3
-4# eval $(${OBJDUMP} -j .text $1 -h | - $AWK '$2 == ".text" {printf "vma_hi=%s\nvma_lo=%s\n", substr($4, 1, 9), substr($4, 10, 16)}') + $AWK '$2 == ".text" {printf "bin_sz=%s\nvma_hi=%s\nvma_lo=%s\n", "0x" $3, substr($4, 1, 9), substr($4, 10, 16)}') -${OBJCOPY} -j .text $1 -O binary $TEXT_BIN - -bin_sz=$(stat -c '%s' $TEXT_BIN) +# Convert objdump hex reported .text size to decimal +bin_sz=$(printf %u $bin_sz)(Alternatively without this line, but ...
Quoted 1 line
xen/tools/check-endbr.sh +0
-0[ "$bin_sz" -ge $(((1 << 28) - $vma_lo)) ] &&
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
[ "$(($bin_sz))" -ge $(((1 << 28) - $vma_lo)) ] &&
?)
Isn't that bash-specific functionality? The script interpreter is set as
/bin/sh.I, too, would have thought so, but then the rhs of the -ge already used $((...)).
OK, yes, I didn't realize those existing usages. Now that I look at it it does seem to have a bunch of other bashisms, for example parameter expansion.
I will adjust that plus the commit message and take your RB.
Thanks, Roger.
Re: [PATCH 2/5] xen/tools: remove usages of `stat -s` in check-endbr.sh
Quoted 27 lines · Roger Pau Monné
Quoted 26 lines · Jan Beulich
Quoted 25 lines · Roger Pau Monné
Quoted 23 lines · Jan Beulich
Quoted 4 lines · Roger Pau Monne
xen/tools/check-endbr.sh +0
-0@@ -92,14 +92,15 @@ ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & # check nevertheless.xen/tools/check-endbr.sh ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & · line 98
Quoted 10 lines
xen/tools/check-endbr.sh +3
-4# eval $(${OBJDUMP} -j .text $1 -h | - $AWK '$2 == ".text" {printf "vma_hi=%s\nvma_lo=%s\n", substr($4, 1, 9), substr($4, 10, 16)}') + $AWK '$2 == ".text" {printf "bin_sz=%s\nvma_hi=%s\nvma_lo=%s\n", "0x" $3, substr($4, 1, 9), substr($4, 10, 16)}') -${OBJCOPY} -j .text $1 -O binary $TEXT_BIN - -bin_sz=$(stat -c '%s' $TEXT_BIN) +# Convert objdump hex reported .text size to decimal +bin_sz=$(printf %u $bin_sz)(Alternatively without this line, but ...
xen/tools/check-endbr.sh ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut -f 1 -d ':' > $VALID & · line 99
Quoted 1 line
xen/tools/check-endbr.sh +0
-0[ "$bin_sz" -ge $(((1 << 28) - $vma_lo)) ] &&[ "$(($bin_sz))" -ge $(((1 << 28) - $vma_lo)) ] &&
?)
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Isn't that bash-specific functionality? The script interpreter is set as
/bin/sh.I, too, would have thought so, but then the rhs of the -ge already used $((...)).
OK, yes, I didn't realize those existing usages. Now that I look at it it does seem to have a bunch of other bashisms, for example parameter expansion.
Then perhaps in another patch we want to properly mark it as a bash script.
Jan
PATCH 3/5 xen/tools: fix grep reporting 'illegal byte sequence' in check-endbr.sh
In reply to Roger Pau MonneOn macOS the default encoding is UTF-8. The binary encoding used by the grep matching pattern is not valid when processed as UTF-8. Switch the local to C just for the grep invocation to use the binary match pattern correctly.
--- xen/tools/check-endbr.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
xen/tools/check-endbr.sh +3 -2
@@ -109,8 +109,9 @@ if $perl_re then LC_ALL=C grep -aobP '\xf3\x0f\x1e(\xfa|\xfb)|\x66\x0f\x1f\x01' $TEXT_BIN else - grep -aob -e "$(printf '\363\17\36\372')" -e "$(printf '\363\17\36\373')" \ - -e "$(printf '\146\17\37\1')" $TEXT_BIN + LC_ALL=C grep -aob -e "$(printf '\363\17\36\372')" \ + -e "$(printf '\363\17\36\373')" \ + -e "$(printf '\146\17\37\1')" $TEXT_BIN fi | $AWK -F':' '{printf "%s%07x\n", "'$vma_hi'", int('$((0x$vma_lo))') + $1}' > $ALL # Wait for $VALID to become complete
Signature · 1 line
2.51.0
Re: [PATCH 3/5] xen/tools: fix grep reporting 'illegal byte sequence' in check-endbr.sh
Hi Roger,
Quoted 9 lines · Roger Pau Monne
On macOS the default encoding is UTF-8. The binary encoding used by the grep matching pattern is not valid when processed as UTF-8. Switch the local to C just for the grep invocation to use the binary match pattern correctly.
Suggested-by Bertrand Marquis <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>
Works and makes sense.
Cheers
Bertrand
Quoted 23 lines
---
xen/tools/check-endbr.sh| 5 +++--1 file changed, 3 insertions(+), 2 deletions(-)xen/tools/check-endbr.sh +0
-0@@ -109,8 +109,9 @@ if $perl_rethen
LC_ALL=C grep -aobP '\xf3\x0f\x1e(\xfa|\xfb)|\x66\x0f\x1f\x01' $TEXT_BINelse
xen/tools/check-endbr.sh +3
-2- grep -aob -e "$(printf '\363\17\36\372')" -e "$(printf '\363\17\36\373')" \ - -e "$(printf '\146\17\37\1')" $TEXT_BIN + LC_ALL=C grep -aob -e "$(printf '\363\17\36\372')" \ + -e "$(printf '\363\17\36\373')" \ + -e "$(printf '\146\17\37\1')" $TEXT_BINfi | $AWK -F':' '{printf "%s%07x\n", "'$vma_hi'", int('$((0x$vma_lo))') + $1}' > $ALL
# Wait for $VALID to become complete
Signature · 1 line
2.51.0
PATCH 4/5 cirrus-ci: add x86 and arm64 macOS hypervisor builds
In reply to Roger Pau MonneIntroduce two new build that run on macOS Cirrus-CI instances. Those build the hypervisor using the elf cross-toolchain from Homebrew for both x86 and arm64.
---
I haven't added any randconfig jobs, we can consider adding those later on if the builds are stable.
--- .cirrus.yml | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-)
.cirrus.yml +37 -1
@@ -1,3 +1,5 @@ +## FreeBSD Build Jobs + # https://cirrus-ci.org/guide/tips-and-tricks/#sharing-configuration-between-tasks freebsd_versions: &FREEBSD_VERSIONS env:
@@ -122,7 +124,41 @@ task: path: xtf/tests/selftest/test-*-selftest type: application/octet-stream -# Test jobs +## macOS Build Jobs + +task: + name: 'macOS: hypervisor build' + + env: + matrix: + ARCH: x86_64 + ARCH: aarch64 + + alias: macos-$ARCH + macos_instance: + image: ghcr.io/cirruslabs/macos-runner:sonoma + + environment: + CIRRUS_CLONE_DEPTH: 1 + CIRRUS_LOG_TIMESTAMP: true + + install_script: + - brew install $ARCH-elf-gcc $ARCH-elf-binutils + + build_script: + - make -j`sysctl -n hw.ncpu` + XEN_TARGET_ARCH=`echo $ARCH | sed -e s/aarch64/arm64/` + CROSS_COMPILE=$ARCH-elf- HOSTCC=clang -C xen + + xen_artifacts: + path: xen/xen + type: application/octet-stream + + debug_artifacts: + path: xen/xen-syms + type: application/octet-stream + +## Test Jobs task: name: 'FreeBSD: XTF selftest'
Signature · 1 line
2.51.0
PATCH 5/5 cirrus-ci: add x86 XTF self-tests for macOS build
In reply to Roger Pau MonneLike we do for the FreeBSD builds, introduce some basic smoke testing of the built binary using the XTF selftest image.
Note this is only done for the x86 build, there's no ARM support in XTF yet.
--- .cirrus.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
.cirrus.yml +7 -6
@@ -161,18 +161,19 @@ task: ## Test Jobs task: - name: 'FreeBSD: XTF selftest' + name: 'XTF selftest' << : *FREEBSD_ENV_PRODUCTION env: matrix: - FREEBSD_BUILD: $FREEBSD_LEGACY - FREEBSD_BUILD: $FREEBSD_PRODUCTION - FREEBSD_BUILD: $FREEBSD_CURRENT + BUILD: freebsd_full_$FREEBSD_LEGACY + BUILD: freebsd_full_$FREEBSD_PRODUCTION + BUILD: freebsd_full_$FREEBSD_CURRENT + BUILD: macos-x86_64 depends_on: - - freebsd_full_$FREEBSD_BUILD + - $BUILD - xtf install_script: pkg install -y qemu-nox11 expect
@@ -187,7 +188,7 @@ task: fetch_script: - fetch https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/xtf/xtf.zip - - fetch https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/freebsd_full_$FREEBSD_BUILD/xen.zip + - fetch https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/$BUILD/xen.zip - unzip xtf.zip - unzip xen.zip
Signature · 1 line
2.51.0