-
Notifications
You must be signed in to change notification settings - Fork 564
AArch64 initial build #1168
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
AArch64 initial build #1168
Conversation
|
@michael2012z Yes please feel free to send a PR to the appropriate fork repos targetting the "ch" branch. Make sure to mark it for review by @rbradford and @sboeuf |
852871d to
a2cb466
Compare
|
Hi, @rbradford , @sboeuf Regarding the build error of kvm-bindings with feature Now cross-build jobs have passed. This PR is ready for review. Would you like to take a look? |
a2cb466 to
9a2215f
Compare
rbradford
left a comment
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.
Looking nice so far. Just some comments to help reduce some of the conditionals
vmm/src/memory_manager.rs
Outdated
| } | ||
|
|
||
| #[cfg(target_arch = "aarch64")] | ||
| pub fn get_host_cpu_phys_bits() -> u8 { |
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.
Please move get_host_cpu_phys_bits to the arch/ crate.
vmm/src/cpu.rs
Outdated
| guest_memory: GuestMemoryAtomic<GuestMemoryMmap>, | ||
| kvm: &Kvm, | ||
| #[cfg(target_arch = "x86_64")] kvm: &Kvm, | ||
| #[cfg(target_arch = "aarch64")] _kvm: &Kvm, |
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.
#[cfg_attr(target_arch = "aarch64", allow(dead_code)]
vmm/src/cpu.rs
Outdated
| _inserting: bool, | ||
| _snapshot: Option<Snapshot>, | ||
| ) -> Result<()> { | ||
| // temporary code to mute "unused variable" warnings |
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.
Put this as unimplemented! and then use #[cfg_attr(target_arch = "aarch64", allow(dead_code)] on the fields instead,
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.
Good idea!
vmm/src/device_manager.rs
Outdated
| fn add_ioapic(&mut self) -> DeviceManagerResult<Arc<Mutex<ioapic::Ioapic>>> { | ||
| // temporary code to mute "unused variable" warnings | ||
| let _ = &self.msi_interrupt_manager; | ||
| panic!("impossible for aarch64"); |
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.
unreachable!()
vmm/src/memory_manager.rs
Outdated
| }; | ||
|
|
||
| #[cfg(target_arch = "aarch64")] | ||
| let start_addr = GuestAddress((mem_end.0 + 1 + (256 << 20)) & !((128 << 20) - 1)); |
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.
Refactor out into a start_addr() function.
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.
I refactored more to cover the similar calculation for the start address of device space in new().
vmm/src/vm.rs
Outdated
|
|
||
| if !kvm.check_extension(Cap::TscDeadlineTimer) { | ||
| return Err(Error::CapabilityMissing(Cap::TscDeadlineTimer)); | ||
| #[cfg(target_arch = "x86_64")] |
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.
Refactor out into a function in the arch crate check_required_kvm_extensions() ?
9a2215f to
888028a
Compare
|
Hi, @rbradford Thanks for reviewing. I updated the PR as per the comments, and rebased to latest code. Please take a look again. |
rbradford
left a comment
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.
Almost ready to approve. Just want to see some commit message changes.
| @@ -1,5 +1,6 @@ | |||
| FROM ubuntu:18.04 as dev | |||
|
|
|||
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.
For b40aea0 please prefix first line of commit message with "build:" and drop trailing full-stop.
Please remove the Gerrit Change-Id.
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.
Done for all commits.
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| pub mod layout; | ||
|
|
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.
For 24e62df please prefix with "build:" and drop gerrit Change-Id.
| @@ -0,0 +1,32 @@ | |||
| name: Cloud Hypervisor Cross Build | |||
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.
For 888028a please prefix first commit message line with "build: " and drop gerrit Change-Id
Updated Dockerfile to work with multiple architectures. Updated dev_cli.sh to: 1. Build container image before AArch64 image is ready in public. 2. Adjust default feature collection on AArch64. 3. Workaround a build problem with musl on AArch64. Signed-off-by: Michael Zhao <[email protected]>
This is a preparing commit to build and test CH on AArch64. All building issues were fixed, but no functionality was introduced. For X86, the logic of code was not changed at all. For ARM, the architecture specific part is still empty. And we applied some tricks to workaround lint warnings. But such code will be replaced later by other commits with real functionality. Signed-off-by: Michael Zhao <[email protected]>
The result of the workflow can be seen in Checks tab of a PR. Two targets have been added: - stable aarch64-unknown-linux-gnu - stable aarch64-unknown-linux-musl Note: a temporary step was added before building. We used "sed" command to remove "with-serde" feature of kvm-bindings in vmm/Cargo.toml. This step should be removed in future when kvm-bindings is ready. Signed-off-by: Michael Zhao <[email protected]>
888028a to
07f3c9d
Compare
| target: ${{ matrix.target }} | ||
| override: true | ||
| - name: Disable "with-serde" in kvm-bindings | ||
| run: sed -i 's/"with-serde",\ //g' vmm/Cargo.toml |
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.
This is a reasonable solution for the time being.
sboeuf
left a comment
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.
Nice PR!
This PR is splitted from #1126.
It prepares for upcoming PR's to enable AArch64. All building issues were fixed, but no functionality was introduced. A lot of
#[cfg(target_arch = "xxx")]were used in source files to separate architecture specific code. Some utility files were updated as well.For X86, the logic of code was not changed at all. Nothing should be broken.
For ARM, the architecture specific part is still empty. Some new added ARM-specific code may looks weird, because they were added temporarily to workaround lint warnings. But they will be replaced later by other commits with real functionality.
A workflow for "Checks" was setup to cross-build for AArch64. But now the cross-build fails, which is related to Serde in kvm-bindings. The reason is that CH forked
kvm-bindingsto add the support of Serde, the modification was mainly for X86 and a little was modified for ARM, but it is not ready for ARM. A workaround is to revert the modification for ARM totally. A PR for this has been issued tocloud-hypervisor/kvm-bindings