Skip to content
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

Add native arm64 support and cross-compilation for kernels #170

Merged
merged 11 commits into from
Mar 13, 2024

Conversation

mtardy
Copy link
Member

@mtardy mtardy commented Feb 26, 2024

Fixes #56.

With this update, you can:

  • Build kernel natively on both amd64 and arm64.
  • Build kernel with cross-compilation on amd64 and arm64 to respectively arm64 and amd64.
  • Build image natively on amd64 and arm64.
  • Run the kernel with the image natively on amd64 and arm64.

You cannot build an arm64 image on amd64 because of libguestfs tools limitations, unfortunately, mmdebstrap works perfectly fine with emulation but libguestfs tools rely on Qemu to start the VMs to modify the images and it's not set up for emulation.

Also, this introduces a new bootable field in the image conf since with this patch. For now, we can only build non-bootable images for arm64 as I haven't taken the time to investigate the bootloader part that we could use (since extlinux used here is x86_64 only). So the default is that images are bootable by default on x86_64 and non-bootable by default on arm64. You can use the new field to be precise.

This might not be the ideal setup as I haven't taken the time to look into the kernel config specific for arm64 to we should change. It seems to work ok at least, maybe we are not very optimized but...

@mtardy mtardy added the enhancement New feature or request label Feb 26, 2024
@mtardy mtardy force-pushed the pr/mtardy/arm64-support branch from df82d20 to b7c852d Compare March 1, 2024 17:00
@mtardy mtardy marked this pull request as ready for review March 1, 2024 17:05
@mtardy mtardy requested a review from kkourt March 1, 2024 17:05
@mtardy
Copy link
Member Author

mtardy commented Mar 1, 2024

I added some PRs in cilium/little-vm-helper-images:

I just need a last PR for the copy of the kernel modules in the image and then we should be able to run some tests on arm64 using the kind image.

@mtardy mtardy force-pushed the pr/mtardy/arm64-support branch from b7c852d to 9703c0a Compare March 5, 2024 10:03
mtardy added 8 commits March 5, 2024 10:41
To make kvm work on arm64, the default x86_64 kvm64 cpu type needed to
be changed.

Signed-off-by: Mahe Tardy <[email protected]>
Previously, all images were by default bootable. This adds an option in
the image conf to specify if the output image should be bootable or not.
It keeps retro-compatibility with previous configurations by treating
omited option as true using a boolean pointer.

Signed-off-by: Mahe Tardy <[email protected]>
@mtardy mtardy force-pushed the pr/mtardy/arm64-support branch 3 times, most recently from 3f80da9 to 9590475 Compare March 6, 2024 10:53
@mtardy mtardy force-pushed the pr/mtardy/arm64-support branch from 9590475 to a564dda Compare March 12, 2024 16:59
@mtardy mtardy changed the title Add native arm64 support Add native arm64 support and cross-compilation for kernels Mar 12, 2024
For example, on amd64, if the 'gcc-aarch64-linux-gnu' package is
installed, LVH can cross compile an arm64 kernel on amd64. On arm64, if
the 'gcc-x86-64-linux-gnu' package is install, LVH can cross compile an
amd64 kernel on arm64.

Signed-off-by: Mahe Tardy <[email protected]>
@mtardy mtardy force-pushed the pr/mtardy/arm64-support branch from a564dda to 7e43e94 Compare March 12, 2024 18:06
mtardy added 2 commits March 12, 2024 19:34
Commit 9e7539f modified our use of the
dir-pkg target because it wasn't supported in 4.19. This updates the
README along the arch specific target changes.

Signed-off-by: Mahe Tardy <[email protected]>
Copy link
Collaborator

@kkourt kkourt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

minor nit: I would prefered to have the an arch variable (initialized to runtime.GOARCH) passed to the various helper functions rather than using GOARCH everywhere. I think this would made it easier to run an ARM vm in an x86 machine or vice-versa. We can do it in a later PR if needed.

@kkourt kkourt merged commit 770359d into main Mar 13, 2024
1 check passed
@kkourt kkourt deleted the pr/mtardy/arm64-support branch March 13, 2024 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

arm64 support
2 participants