Skip to content

Commit 7427e4e

Browse files
committed
address more review comments
1 parent 926d10e commit 7427e4e

File tree

4 files changed

+9
-21
lines changed

4 files changed

+9
-21
lines changed

linker/qemu.ld

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
MEMORY
22
{
33
image : ORIGIN = 0x40080000, LENGTH = 4M
4-
heap (rw) : ORIGIN = 0x40400000, LENGTH = 4M
5-
payload (rwx) : ORIGIN = 0x40800000, LENGTH = 64M
4+
payload (rwx) : ORIGIN = 0x40400000, LENGTH = 64M
65
}
76

87
SECTIONS {
9-
.heap :
10-
{
11-
*(.heap);
12-
. = ALIGN(4);
13-
} > heap
148
.payload :
159
{
1610
*(.payload);

src/hypervisor.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,6 @@ pub unsafe fn entry_point_el1(arg0: u64, arg1: u64, arg2: u64, arg3: u64, entry_
7373
arch::elr_el2::write(entry_point);
7474
}
7575

76-
// Set stack pointer for EL1
77-
// SAFETY: We only affect EL1.
78-
unsafe {
79-
arch::sp_el1::write(arch::sp());
80-
}
81-
8276
// SAFETY: The caller ensures that the provided arguments are valid and that this is called
8377
// from EL2. We've set the `elr_el2` system register right before calling this, and the caller
8478
// ensured that the value we've set is a valid address for EL1 execution that never returns.
@@ -181,10 +175,6 @@ unsafe fn handle_psci(fn_id: u64, arg0: u64, arg1: u64, arg2: u64) -> Result<u64
181175

182176
let psci_fn = arm_psci::Function::try_from(&[fn_id, arg0, arg1, arg2])?;
183177
match psci_fn {
184-
CpuSuspend { state, entry } => {
185-
let result = psci_cpu_suspend(state, entry);
186-
Ok(result)
187-
}
188178
Version
189179
| CpuOff
190180
| AffinityInfo { .. }
@@ -205,6 +195,7 @@ unsafe fn handle_psci(fn_id: u64, arg0: u64, arg1: u64, arg2: u64) -> Result<u64
205195
| SetSuspendMode { .. }
206196
| StatResidency { .. }
207197
| StatCount { .. } => {
198+
// forward the PSCI call
208199
let mut smc_args = [0; 17];
209200
smc_args[0] = arg0;
210201
smc_args[1] = arg1;
@@ -220,6 +211,10 @@ unsafe fn handle_psci(fn_id: u64, arg0: u64, arg1: u64, arg2: u64) -> Result<u64
220211
let result = psci_cpu_on(fn_id, target_cpu, entry);
221212
Ok(u64::from(i32::from(result).cast_unsigned()))
222213
}
214+
CpuSuspend { state, entry } => {
215+
let result = psci_cpu_suspend(state, entry);
216+
Ok(result)
217+
}
223218
}
224219
}
225220

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ use crate::{
3737
const LOG_LEVEL: LevelFilter = LevelFilter::Info;
3838

3939
const HEAP_SIZE: usize = 40 * PAGE_SIZE;
40-
#[unsafe(link_section = ".heap")]
4140
static HEAP: SpinMutex<[u8; HEAP_SIZE]> = SpinMutex::new([0; HEAP_SIZE]);
4241

4342
#[global_allocator]

src/platform/qemu.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ impl Platform for Qemu {
8282
// will not try to use it.
8383
// See `linker/qemu.ld` for the address reference.
8484
let mut res = Vec::<u8>::new();
85-
res.extend_from_slice(&0x4080_0000u64.to_be_bytes());
86-
res.extend_from_slice(&(120u64 * 1024 * 1024).to_be_bytes()); // 128 MB default - 8 MB reserved
85+
res.extend_from_slice(&0x4040_0000u64.to_be_bytes());
86+
res.extend_from_slice(&(124u64 * 1024 * 1024).to_be_bytes()); // 128 MiB default - 4 MiB reserved
8787

8888
dt.root_mut()
8989
.remove_child("memory@40000000")
9090
.expect("memory node not found");
9191
dt.root_mut().add_child(
92-
DeviceTreeNode::builder("memory@40800000")
92+
DeviceTreeNode::builder("memory@40400000")
9393
.property(DeviceTreeProperty::new("reg", res))
9494
.property(DeviceTreeProperty::new("device_type", b"memory\0"))
9595
.build(),

0 commit comments

Comments
 (0)