-
Notifications
You must be signed in to change notification settings - Fork 127
Return riscv_sbi to VMM for further process #352
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
Open
BillXiang
wants to merge
3
commits into
rust-vmm:main
Choose a base branch
from
BillXiang:riscv64_sbi
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,6 +184,8 @@ pub enum VcpuExit<'a> { | |
/// size | ||
size: u64, | ||
}, | ||
/// Corresponds to KVM_EXIT_RISCV_SBI | ||
RiscvSbi(&'a mut kvm_run__bindgen_ty_1__bindgen_ty_24), | ||
/// Corresponds to an exit reason that is unknown from the current version | ||
/// of the kvm-ioctls crate. Let the consumer decide about what to do with | ||
/// it. | ||
|
@@ -1641,6 +1643,13 @@ impl VcpuFd { | |
Ok(VcpuExit::IoapicEoi(eoi.vector)) | ||
} | ||
KVM_EXIT_HYPERV => Ok(VcpuExit::Hyperv), | ||
#[cfg(target_arch = "riscv64")] | ||
KVM_EXIT_RISCV_SBI => { | ||
// SAFETY: Safe because the exit_reason (which comes from the kernel) told us | ||
// which union field to use. | ||
let riscv_sbi = unsafe { &mut run.__bindgen_anon_1.riscv_sbi }; | ||
Ok(VcpuExit::RiscvSbi(riscv_sbi)) | ||
} | ||
r => Ok(VcpuExit::Unsupported(r)), | ||
} | ||
} else { | ||
|
@@ -2574,6 +2583,25 @@ mod tests { | |
0x03, 0xa5, 0x0c, 0x00, // lw a0, 0(s9); test MMIO read | ||
0x93, 0x05, 0x70, 0x60, // li a1, 0x0607; | ||
0x23, 0xa0, 0xbc, 0x00, // sw a1, 0(s9); test MMIO write | ||
//sbi_console_getchar | ||
0x01, 0x45, // li a0, 0 | ||
0x81, 0x45, // li a1, 0 | ||
0x01, 0x46, // li a2, 0 | ||
0x81, 0x46, // li a3, 0 | ||
0x01, 0x47, // li a4, 0 | ||
0x81, 0x47, // li a5, 0 | ||
0x01, 0x48, // li a6, 0 | ||
0x89, 0x48, // li a7, 2 | ||
0x73, 0x00, 0x00, 0x00, //ecall | ||
//sbi_console_putchar | ||
0x81, 0x45, // li a1, 0 | ||
0x01, 0x46, // li a2, 0 | ||
0x81, 0x46, // li a3, 0 | ||
0x01, 0x47, // li a4, 0 | ||
0x81, 0x47, // li a5, 0 | ||
0x01, 0x48, // li a6, 0 | ||
0x85, 0x48, // li a7, 1 | ||
0x73, 0x00, 0x00, 0x00, //ecall | ||
0x6f, 0x00, 0x00, 0x00, // j .; shouldn't get here, but if so loop forever | ||
]; | ||
|
||
|
@@ -2645,7 +2673,20 @@ mod tests { | |
.map(|page| page.count_ones()) | ||
.sum(); | ||
assert_eq!(dirty_pages, 1); | ||
break; | ||
} | ||
VcpuExit::RiscvSbi(riscv_sbi) => { | ||
match riscv_sbi.extension_id as usize { | ||
2 /* SBI_EXT_0_1_CONSOLE_GETCHAR */ => { | ||
let ch = &mut riscv_sbi.ret[..1]; | ||
ch[0] = 0x2a; | ||
} | ||
1 /* SBI_EXT_0_1_CONSOLE_PUTCHAR */ => { | ||
let ch = riscv_sbi.args[0]; | ||
assert_eq!(ch, 0x2a); | ||
break; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why indent here, make sure you ran cargo fmt before proceeding to next commit 🙂 |
||
} | ||
_ => panic!("unexpected extension_id: {:?}", riscv_sbi.extension_id), | ||
} | ||
} | ||
r => panic!("unexpected exit reason: {:?}", r), | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
test_run_code
is failing in our CI