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

Aarch64 Image format and device tree loading support for linux-loader #16

Merged
merged 5 commits into from
Apr 1, 2020

Conversation

crab2313
Copy link
Contributor

@crab2313 crab2313 commented Mar 9, 2020

I am working on porting cloud-hypervisor to ARM64 platform and this is part of my effort.

@alxiord
Copy link
Member

alxiord commented Mar 9, 2020

Hi @crab2313, there's already an open PR that adds PE support: #9.

@crab2313
Copy link
Contributor Author

crab2313 commented Mar 9, 2020

@aghecenco I'm aware of that. It is lacking device tree support and somehow complicated. I am just trying to upstream my work after launching a kernel with cloud-hypervisor on ARM64.

src/loader/mod.rs Outdated Show resolved Hide resolved
src/loader/mod.rs Outdated Show resolved Hide resolved
src/loader/mod.rs Outdated Show resolved Hide resolved
src/loader/mod.rs Outdated Show resolved Hide resolved
@alxiord alxiord mentioned this pull request Mar 9, 2020
@alxiord
Copy link
Member

alxiord commented Mar 9, 2020

It is lacking device tree support

There's also a proposal for a vmm-fdt crate: rust-vmm/community#87. @crab2313 would you be interested in this direction?

/// * `guest_addr` - The address in `guest_mem` at which to load the device tree blob.
/// * `dtb_image` - The device tree blob.
#[cfg(target_arch = "aarch64")]
pub fn load_dtb<F, M: GuestMemory>(
Copy link

Choose a reason for hiding this comment

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

I think that this function should be residing somewhere higher in the design. The way I see it is: the vmm obtains the entry address for where the kernel should be loaded, it also knows about the dtb and it is the one who writes things to memory, to the dtb etc. I see this as a more decoupled and flexible design.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is just a helper loading a dtb blob into memory. How to generate and modify a dtb should be implemented in vmm-fdt.

@andreeaflorescu
Copy link
Member

It is lacking device tree support

There's also a proposal for a vmm-fdt crate: rust-vmm/community#87. @crab2313 would you be interested in this direction?

@aghecenco I had a chat with Marc Zyngier about adding fdt support in rust-vmm. It is a hard problem to tackle right now because we do not really have a resource allocator based on which the fdt can be created. We might want to postpone that work until we have a clear path forward for creating the fdt in a VMM agnostic way.

@crab2313
Copy link
Contributor Author

crab2313 commented Mar 10, 2020

@aghecenco Architecture specific features is not ready today. A possible work around is making image a default feature. It is fine since everything guarded by feature(image) is also guarded by target_arch(aarch64). We can remove this work around when arch-specific feature is ready on cargo stable.

@alxiord
Copy link
Member

alxiord commented Mar 12, 2020

@aghecenco Architecture specific features is not ready today. A possible work around is making image a default feature. It is fine since everything guarded by feature(image) is also guarded by target_arch(aarch64). We can remove this work around when arch-specific feature is ready on cargo stable.

Agreed. I logged #27 to track this as I can't think of a better solution either. There's of course the option of having no default features, @andreeaflorescu and I had a quick chat about it but didn't explore it; I for one prefer having them as I think it would simplify the vmm's Cargo.toml and therefore improve UX. @andreeaflorescu WDYT?

@andreeaflorescu
Copy link
Member

I don't have a strong preference. I am not super sure though that elf is necessarily used by everyone to make it a default feature.

alxiord
alxiord previously approved these changes Mar 12, 2020
@crab2313 crab2313 force-pushed the aarch64-image branch 2 times, most recently from 8fa2521 to dab9208 Compare March 14, 2020 14:50
Copy link
Member

@andreeaflorescu andreeaflorescu left a comment

Choose a reason for hiding this comment

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

The readme and crate root (/src/lib.rs) should also be updated to specify that we support aarch64 as well.

Cargo.toml Outdated Show resolved Hide resolved
src/loader/mod.rs Outdated Show resolved Hide resolved
src/loader/mod.rs Outdated Show resolved Hide resolved
/// # Arguments
///
/// * `guest_mem` - The guest memory where the kernel image is loaded.
/// * `kernel_start` - The offset into 'guest_mem' at which to load the kernel.
Copy link
Member

Choose a reason for hiding this comment

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

nit: We typically add code-related things in backticks. This is the case for guest_mem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it should be addressed in #23 since these comments are copied from other loaders.

Copy link
Member

Choose a reason for hiding this comment

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

The comment is for: "The offset into 'guest_mem'" where guest_mem is wrapped in single quotes. But you can ignore it, it is just a nit.

src/loader/mod.rs Outdated Show resolved Hide resolved
src/loader/mod.rs Outdated Show resolved Hide resolved
@crab2313 crab2313 requested a review from alxiord March 18, 2020 00:42
@crab2313 crab2313 force-pushed the aarch64-image branch 2 times, most recently from 962c843 to 4c2915c Compare March 23, 2020 15:53
@crab2313
Copy link
Contributor Author

rebased to the master branch.

src/loader/aarch64/pe/mod.rs Outdated Show resolved Hide resolved
src/loader/aarch64/pe/mod.rs Outdated Show resolved Hide resolved
src/loader/aarch64/pe/mod.rs Outdated Show resolved Hide resolved
src/loader/aarch64/pe/mod.rs Outdated Show resolved Hide resolved
src/loader/aarch64/pe/mod.rs Outdated Show resolved Hide resolved
src/loader/aarch64/pe/mod.rs Outdated Show resolved Hide resolved
src/loader/aarch64/pe/mod.rs Outdated Show resolved Hide resolved
crab2313 added 5 commits April 1, 2020 01:25
The test_image.bin is a cut of the first 4096 bytes of a pre-compiled
linux kernel ARM64 Image. You can generate by:

        make Image
        head -c 4096 arch/arm64/boot/Image > test_image.bin

Signed-off-by: Qiu Wenbo <[email protected]>
@andreeaflorescu andreeaflorescu merged commit 61d95eb into rust-vmm:master Apr 1, 2020
@crab2313 crab2313 deleted the aarch64-image branch April 1, 2020 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants