Skip to content

Conversation

zhuangel
Copy link
Contributor

@zhuangel zhuangel commented Jan 25, 2023

Fix incorrect alignment for ELF notes, starting address of name field and descriptor field have a 4-byte alignment.

See refer from:

Fixes: #71

Reported-by: Iulian Barbu iul@amazon.com
Signed-off-by: Yong He alexyonghe@tencent.com
Co-authored-by: Rob Bradford robert.bradford@intel.com
Signed-off-by: Yong He alexyonghe@tencent.com

Summary of the PR

Please summarize here why the changes in this PR are needed.

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR are signed (with git commit -s), and the commit
    message has max 60 characters for the summary and max 75 characters for each
    description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

Fix incorrect alignment for ELF notes, starting address of
name field and descriptor field have a 4-byte alignment.

See refer from:
 - 'Note Section' of 'Executable and Linking Format (ELF)
   Specification' v1.2.
 - Linux implementations,
   https://elixir.bootlin.com/linux/v6.1/source/include/linux/elfnote.h#L56

Fixes: rust-vmm#71

Reported-by: Iulian Barbu <iul@amazon.com>
Signed-off-by: Yong He <alexyonghe@tencent.com>
Co-authored-by: Rob Bradford <robert.bradford@intel.com>
Signed-off-by: Yong He <alexyonghe@tencent.com>
Copy link
Collaborator

@rbradford rbradford left a comment

Choose a reason for hiding this comment

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

Looks good, did you test with with a VMM and an kernel you were having issues with?

@zhuangel
Copy link
Contributor Author

Looks good, did you test with with a VMM and an kernel you were having issues with?

Thanks for reviewing, I was tested the issue with the revise code in local it solve the issue.

Then I re-run the test with formal way, cloud-hypervisor v29.0, revise linux-loader in Cargo.toml into linux-loader = { git = "https://github.com/zhuangel/linux-loader", branch = "alexyonghe/dev", features = ["elf", "bzimage", "pe"] }, I cloud load kernel v6.1 successfully (as compare, directly run the test with cloud-hypervisor v29.0, load failed with ApiError(VmBoot(KernelMissingPvhHeader))).

@andreeaflorescu andreeaflorescu merged commit 09c6f35 into rust-vmm:main Jan 26, 2023
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.

[Bug] Parsing elf notes does not use the System V ABI spec recommended alignment

3 participants