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

Introduce umode binary and map it in salus user space address. #178

Merged
merged 4 commits into from
Dec 13, 2022
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
19 changes: 19 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ s_mode_utils = { path = "./s-mode-utils" }
sbi = { path = "./sbi" }
spin = { version = "*", default-features = false }
sha2 = {version = "0.10", default-features = false }
riscv_elf = { path = "./riscv-elf" }

[workspace]

members = [
"libuser",
"umode",
"test-workloads",
]
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,23 @@ check:
--target $(HOST_TRIPLET) \
--workspace \
--exclude test_workloads \
--exclude libuser \
--lib
cargo test \
--target $(HOST_TRIPLET) \
--workspace \
--exclude test_workloads \
--exclude libuser \
--doc

CARGO_FLAGS :=

.PHONY: salus
salus:
salus: umode
cargo build $(CARGO_FLAGS) --release --bin salus

.PHONY: salus_debug
salus_debug:
salus_debug: umode
cargo build $(CARGO_FLAGS) --bin salus

tellus_bin: tellus
Expand All @@ -94,6 +96,10 @@ guestvm:
tellus: guestvm
cargo build $(CARGO_FLAGS) --package test_workloads --bin tellus --release

.PHONY: umode
umode:
RUSTFLAGS='-Clink-arg=-Tlds/umode.lds' cargo build --release --package umode

# Runnable targets:
#
# run_tellus_gdb: Run Tellus as the host VM with GDB debugging enabled.
Expand Down
47 changes: 47 additions & 0 deletions lds/umode.lds
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
OUTPUT_ARCH( "riscv" )

ENTRY( _start )

PHDRS
{
text PT_LOAD;
rodata PT_LOAD;
data PT_LOAD;
stack PT_LOAD;
}

SECTIONS
{
. = 0xffffffff00000000;

.text ALIGN(4096) : {
*(.text.start)
*(.text.init) *(.text .text.*)
} :text

.rodata ALIGN(4096) : {
*(.rodata .rodata.*)
} :rodata

.data ALIGN(4096) : {
*(.data .data.*)

. = ALIGN(8);
PROVIDE(__global_pointer$ = .);
*(.sdata .sdata.*)

*(.sbss .sbss.*) *(.bss .bss.*)
} :data

. += 4096;

.stack ALIGN(4096) (NOLOAD) : {
PROVIDE(_stack_start = .);
. += 4096;
PROVIDE(_stack_end = .);
} :stack

/DISCARD/ : {
*(.eh_frame)
}
}
8 changes: 8 additions & 0 deletions libuser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "libuser"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
21 changes: 21 additions & 0 deletions libuser/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2022 by Rivos Inc.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

#![no_std]

use core::arch::{asm, global_asm};

global_asm!(include_str!("task_start.S"));

// Loop making ecalls as the kernel will kill the task on an ecall (the only syscall supported is
// `exit`).
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
// Safe to make an ecall that won't return.
unsafe {
loop {
asm!("ecall");
}
}
}
23 changes: 23 additions & 0 deletions libuser/src/task_start.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2021 by Rivos Inc.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

.option norvc

.section .text.start

// The entry point for a task.
.global _start
_start:

.option push
.option norelax
la gp, __global_pointer$
.option pop
la sp, _stack_end

call task_main

// ecall to exit
ecall

8 changes: 8 additions & 0 deletions riscv-elf/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "riscv_elf"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
arrayvec = { version = "0.7.2", default-features = false }
Loading