-
Notifications
You must be signed in to change notification settings - Fork 564
Enable AArch64 #1126
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
Enable AArch64 #1126
Conversation
|
@michael2012z Thanks for your contribution. This is a huge and significant contribution for your first one! I can see that you have composed the PR of many well structured commits but we may ask you to revisit the way aspects of this PR are structured (possibly even splitting it if necessary.)
In your PR you have the lines that change the change the dependencies commented out? For kvm-bindings our ch branch has everything that upstream master has (plus extras) are you saying that you have to use the older 0.2.0 tag because master does not work For kvm-ioctls I can see we have diverged slightly and we should be able to rebase the changes on top. |
|
Hi, @rbradford When I tried to build on an ARM machine, some errors were seen:
And I kept my local modification as comments to remind, if someones want to try on ARM. |
Do you suggest to split this single PR into several smaller ones? |
We'll let you know how we'd like to see it split up but don't do any work on this at the moment. |
|
Thanks. I will wait for your advice and do the restructuring then. I am wondering why the CI jobs hang unfinished. I saw it also happened sometimes in other PR's. |
|
@michael2012z Again thank you for submitting this PR. Please could you extract the following changes into separate PRs so that we can start making progress on merging this. Firstly can you separate the abstraction and refactoring you did for the IOAPIC (the Secondly can you create the most minimal PR that makes the code build (I don't expect it to be functional) with the rust stable Longer term we will need to establish a CI to be able to try and run the integration test suite. With those two PRs reviewed and merged I think the PR will be a lot less intrusive and more easily reviewable. It's also possible that some of the other "portability" fixes would also benefit from being in their own PR. Thanks, I look forward to seeing your submissions. |
|
Hi, @rbradford Nice to see your feedback. Besides the splitting of
|
Using the cross toolchain the compilation succeeds (when started by a GitHub action.) |
|
Is it feasible to augment existing device support documentation in order to clarify the 'support level' per architecture, as we expand the architecture support? Nice work @michael2012z |
|
@egernst Thanks. Yes, that document should be updated to reflect the difference between architectures. |
fd0ae6a to
24f6686
Compare
51bd18d to
f1f5825
Compare
|
Hi, @rbradford, @sboeuf Having much code separated, this PR came back with ARM-enabling code only. Could you help review it? @egernst Regarding the documents, now I wrote a very small guide for testing on Arm64. More documenting work is not included in this PR. My personal opinion is it's better update device supporting document when we have CI (in progress now) and have more things stably tested. |
f1f5825 to
344f976
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 very good. Could you do a quick pass through the commit messages and:
- Standardise on aarch64 or arm64 (or whichever :))
- Try and make the commit messages describe WHY rather than WHAT (the code should ideally show the what).
- I think some of the commit messages have some strange wrapping issues.
As always look for ways to minimise the amount of compile-time differences even if that means refactoring the existing code.
vm-allocator/src/gsi.rs
Outdated
| pub fn allocate_irq(&mut self) -> Result<u32> { | ||
| self.next_irq = self.next_irq.checked_add(1).ok_or(Error::Overflow)?; | ||
| Ok(self.next_irq - 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.
Purely as a matter of taste I prefer:
let irq = self.next_irq;
self.next_irq = self.next_irq.checked_add(1).ok_or(Error::Overflow)?;
Ok(irq)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 better than using an additional subtracting.
|
|
||
| #[cfg(target_arch = "x86_64")] | ||
| /// Allocate an IRQ | ||
| pub fn allocate_irq(&mut self) -> Result<u32> { |
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.
Not for you to fix but if we only support one IOAPIC (@sboeuf - would we need more?) then maybe we could heavily simplify this function and make it look like the ARM version.
vmm/src/device_manager.rs
Outdated
| ConsoleOutputMode::Off | ConsoleOutputMode::Null => None, | ||
| }; | ||
| let serial = if serial_config.mode != ConsoleOutputMode::Off { | ||
| #[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.
Please refactor this into two functions; one for each architecture. I think it will be much easier to read (e.g. add_serial_device(...)
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. Thanks.
vmm/src/device_manager.rs
Outdated
| }; | ||
|
|
||
| #[cfg(target_arch = "aarch64")] | ||
| let device_type = virtio_device.lock().unwrap().device_type(); |
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.
Could you move this line lower and then use block syntax for the architecture control
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.
virtio_device is consumed among next lines, I can't move it down.
I chose to move self.id_to_dev_info.insert() up, and then have to move irq_num in front of them.
| io_base: GuestAddress, | ||
| io_size: GuestUsize, | ||
| #[cfg(target_arch = "x86_64")] io_base: GuestAddress, | ||
| #[cfg(target_arch = "x86_64")] io_size: GuestUsize, |
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.
Rather than all this complexity. What about making it an Option<T> type. You could also do the same for everywhere the io_bus is used. That would remove a bunch of conditionals and make the code easier to read.
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.
My original consideration to screen IO things with conditions is:
- IO is not for ARM, having it in binary looks weird.
- Hiding IO bus may avoid potential mistakes in code. It should be wrong if some ARM code is using IO operating/bus, but this will be impossible if IO things are not present. I also planed to make PciBarRegionType::IORegion x86_64 only when coming to support PCI.
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.
Okay!
Implemented GSI allocator and system allocator for AArch64. Renamed some layout definitions to align more code between architectures. Signed-off-by: Michael Zhao <[email protected]>
Screened IO bus because it is not for AArch64. Enabled Serial, RTC and Virtio devices with MMIO transport option. Signed-off-by: Michael Zhao <[email protected]>
Screened IO space as it is not available on AArch64. Signed-off-by: Michael Zhao <[email protected]>
Added MPIDR which is needed in system configuration. Signed-off-by: Michael Zhao <[email protected]>
Signed-off-by: Michael Zhao <[email protected]>
X86 and AArch64 work in different ways to shutdown a VM. X86 exit VMM event loop through ACPI device; AArch64 need to exit from CPU loop of a SystemEvent. Signed-off-by: Michael Zhao <[email protected]>
The support of AArch64 is in very early stage. The steps in building and runing on X86 and AArch64 can not align well yet. Adding AArch64 content to README.md would produce much divergence. Adding a guide in docs/ folder could be a better way to start now. Signed-off-by: Michael Zhao <[email protected]>
344f976 to
1bebeca
Compare
| .clone(); | ||
|
|
||
| arch::configure_system( | ||
| &self.memory_manager.lock().as_ref().unwrap().fd, |
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.
Echoing comment #1126 (comment)
The fd was added for this. Now I set fd field public in memory manager and BORROW it back from there.
|
Thanks for reviewing. |
|
@sboeuf Please review |
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.
I think this looks pretty good to me!
|
|
||
| ## Prerequisites | ||
|
|
||
| On Arm64 machines, Cloud-hypervisor depends on an external library `libfdt-dev` for generating Flatted Device Tree (FDT). |
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.
Typo: Flatted should be Flattened
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.
@michael2012z Can you please fix this in a subsequent PR.
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.
Thanks, @sboeuf , @rbradford . I will fix it in my next PR.
This pull request contains the code to enable the basic functionalities of Cloud-hypervisor on AArch64.
Summary of the major changes:
What was tested: