-
Notifications
You must be signed in to change notification settings - Fork 853
internal/mkcw/embed: cross-compile using Go #6471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| If we have a toolchain for the target that can handle plain assembly, build with that. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| .section .rodata.1,"aMS",@progbits,1 | ||
| msg: | ||
| .string "This image is designed to be run as a confidential workload using libkrun.\n" | ||
| .section .text._start,"ax",@progbits | ||
| .globl _start | ||
| .type _start,@function | ||
| _start: | ||
| movq $1, %rax # write | ||
| movq $2, %rdi # fd=stderr_fileno | ||
| movq $msg, %rsi # message | ||
| movq $75, %rdx # length | ||
| syscall | ||
| movq $60, %rax # exit | ||
| movq $1, %rdi # status=1 | ||
| syscall | ||
| .section .note.GNU-stack,"",@progbits |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/usr/bin/env bash | ||
| expected="This image is designed to be run as a confidential workload using libkrun." | ||
| cd $(dirname ${BASH_SOURCE[0]}) | ||
| for GOARCH in amd64 arm64 ppc64le s390x ; do | ||
| make -C ../../.. internal/mkcw/embed/entrypoint_$GOARCH | ||
| case $GOARCH in | ||
| amd64) QEMUARCH=x86_64;; | ||
| arm64) QEMUARCH=aarch64;; | ||
| ppc64le|s390x) QEMUARCH=$GOARCH;; | ||
| esac | ||
| actual="$(qemu-$QEMUARCH ./entrypoint_$GOARCH 2>&1)" | ||
| if test "$actual" != "$expected" ; then | ||
| echo unexpected error from entrypoint_$GOARCH: "$actual" | ||
| exit 1 | ||
| fi | ||
| done |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // Supplying our own _start that just writes the message and exits avoids | ||
| // pulling in the proper standard library, which produces a smaller binary, but | ||
| // we still end up pulling in the language runtime. | ||
| package main |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| package main |
Binary file not shown.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,13 @@ | ||
| .section .rodata.1,"aMS",@progbits,1 | ||
| msg: | ||
| .string "This image is designed to be run as a confidential workload using libkrun.\n" | ||
| .section .text._start,"ax",@progbits | ||
| .globl _start | ||
| .type _start,@function | ||
| _start: | ||
| movq $1, %rax # write | ||
| movq $2, %rdi # fd=stderr_fileno | ||
| movq $msg, %rsi # message | ||
| movq $75, %rdx # length | ||
| syscall | ||
| movq $60, %rax # exit | ||
| movq $1, %rdi # status=1 | ||
| syscall | ||
| .section .note.GNU-stack,"",@progbits | ||
| DATA msg+0(SB)/75, $"This image is designed to be run as a confidential workload using libkrun.\n" | ||
|
|
||
| GLOBL msg(SB),8,$75 | ||
|
|
||
| TEXT _start(SB),8-0,$0 | ||
| MOVQ $1, AX // syscall=write | ||
| MOVQ $2, DI // descriptor=2 | ||
| MOVQ $msg(SB), SI // buffer (msg) address | ||
| MOVQ $75, DX // buffer (msg) length | ||
| SYSCALL | ||
| MOVQ $60, AX // syscall=exit | ||
| MOVQ $1, DI // status=1 | ||
| SYSCALL |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| DATA msg+0(SB)/75, $"This image is designed to be run as a confidential workload using libkrun.\n" | ||
|
|
||
| GLOBL msg(SB),8,$75 | ||
|
|
||
| TEXT _start(SB),8-0,$0 | ||
| MOVD $64, R8 // syscall=write | ||
| MOVD $2, R0 // descriptor=2 | ||
| MOVD $msg(SB), R1 // buffer (msg) address | ||
| MOVD $75, R2 // buffer (msg) length | ||
| SVC | ||
| MOVD $93, R8 // syscall=exit | ||
| MOVD $1, R0 // status=1 | ||
| SVC |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| DATA msg+0(SB)/75, $"This image is designed to be run as a confidential workload using libkrun.\n" | ||
|
|
||
| GLOBL msg(SB),8,$75 | ||
|
|
||
| TEXT _start(SB),8-0,$0 | ||
| MOVD $4, R0 // syscall=write | ||
| MOVD $2, R3 // descriptor=2 | ||
| MOVD $msg(SB), R4 // buffer (msg) address | ||
| MOVD $75, R5 // buffer (msg) length | ||
| SYSCALL | ||
| MOVD $1, R0 // syscall=exit | ||
| MOVD $1, R3 // status=1 | ||
| SYSCALL |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| DATA msg+0(SB)/75, $"This image is designed to be run as a confidential workload using libkrun.\n" | ||
|
|
||
| GLOBL msg(SB),8,$75 | ||
|
|
||
| TEXT _start(SB),8-0,$0 | ||
| MOVD $4, R1 // syscall=write | ||
| MOVD $2, R2 // descriptor=2 | ||
| MOVD $msg(SB), R3 // buffer (msg) address | ||
| MOVD $75, R4 // buffer (msg) length | ||
| SYSCALL | ||
| MOVD $1, R1 // syscall=exit | ||
| MOVD $1, R2 // status=1 | ||
| SYSCALL |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we need the other arches for if we only ever embed the amd64 one? Seems like unnecessary churn having to maintain a assembly version for each arch that we don't ever end up using.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't build them, but the confidential workload folks have been making noises about supporting other architectures for a while now.