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

Fix aarch64 build by adapting to changes in kvm-ioctl #155

Merged
merged 2 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
LIBRARY_HEADER = include/libkrun.h

ABI_VERSION=1
FULL_VERSION=1.7.1
FULL_VERSION=1.7.2

INIT_SRC = init/init.c
KBS_INIT_SRC = init/tee/kbs/kbs.h \
Expand Down
12 changes: 7 additions & 5 deletions src/arch/src/aarch64/linux/regs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,22 @@ arm64_sys_reg!(MPIDR_EL1, 3, 0, 0, 0, 5);
pub fn setup_regs(vcpu: &VcpuFd, cpu_id: u8, boot_ip: u64, mem: &GuestMemoryMmap) -> Result<()> {
// Get the register index of the PSTATE (Processor State) register.
#[allow(deref_nullptr)]
vcpu.set_one_reg(arm64_core_reg!(pstate), PSTATE_FAULT_BITS_64.into())
vcpu.set_one_reg(arm64_core_reg!(pstate), &PSTATE_FAULT_BITS_64.to_le_bytes())
.map_err(Error::SetCoreRegister)?;

// Other vCPUs are powered off initially awaiting PSCI wakeup.
if cpu_id == 0 {
// Setting the PC (Processor Counter) to the current program address (kernel address).
#[allow(deref_nullptr)]
vcpu.set_one_reg(arm64_core_reg!(pc), boot_ip.into())
vcpu.set_one_reg(arm64_core_reg!(pc), &boot_ip.to_le_bytes())
.map_err(Error::SetCoreRegister)?;

// Last mandatory thing to set -> the address pointing to the FDT (also called DTB).
// "The device tree blob (dtb) must be placed on an 8-byte boundary and must
// not exceed 2 megabytes in size." -> https://www.kernel.org/doc/Documentation/arm64/booting.txt.
// We are choosing to place it the end of DRAM. See `get_fdt_addr`.
#[allow(deref_nullptr)]
vcpu.set_one_reg(arm64_core_reg!(regs), get_fdt_addr(mem).into())
vcpu.set_one_reg(arm64_core_reg!(regs), &get_fdt_addr(mem).to_le_bytes())
.map_err(Error::SetCoreRegister)?;
}
Ok(())
Expand All @@ -154,8 +154,10 @@ pub fn setup_regs(vcpu: &VcpuFd, cpu_id: u8, boot_ip: u64, mem: &GuestMemoryMmap
///
/// * `vcpu` - Structure for the VCPU that holds the VCPU's fd.
pub fn read_mpidr(vcpu: &VcpuFd) -> Result<u64> {
u64::try_from(vcpu.get_one_reg(MPIDR_EL1).map_err(Error::GetSysRegister)?)
.map_err(Error::MpidrTooBig)
let mut data = [0u8; 8];
vcpu.get_one_reg(MPIDR_EL1, &mut data)
.map_err(Error::GetSysRegister)?;
Ok(u64::from_le_bytes(data))
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion src/libkrun/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libkrun"
version = "1.7.1"
version = "1.7.2"
authors = ["Sergio Lopez <[email protected]>"]
edition = "2021"
build = "build.rs"
Expand Down
Loading