mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 08:06:32 +00:00
feat(virtualization): 内核虚拟化支持 (#1073)
* 几个结构体 * 通过vmx_init以及create_vm,create_vcpu部分TODO * kvm_run完成一半 * 能够成功vmlaunch,但是在vmexit时候还有些问题未排查出来 * 解决了vmlaunch导致的cpu_reset的问题 * 整理代码 * 暂时性push到hyc仓库 * 修改内存虚拟化部分参数传入,解决死锁问题 * 初步完成ept映射.但不停EPT_VIOLATION * 初步完成了EPT映射,但是读写内存还是有点问题 * fixme * 更新了一些truncate到from_bits_unchecked的实现 * 完成内存虚拟化EPT_VIOLATION的映射 * fmt * Remove /fixme from .gitignore * Remove /fixme file * Update kernel/src/init/init.rs Co-authored-by: Samuel Dai <samuka007@dragonos.org> * Update kernel/src/init/init.rs Co-authored-by: Samuel Dai <samuka007@dragonos.org> * 修改了注释格式,删除了附带的一些文件操作 * feat(syscall): 实现syscall restart (#1075) 能够在系统调用返回ERESTARTSYS时,信号处理结束后,自动重启系统调用. TODO: 实现wait等需要restart_block的系统调用的重启 Signed-off-by: longjin <longjin@DragonOS.org> * chore: update docker image version in script && update doc (#1076) * chore: update docker image version in script * chore: replace lots of spaces with newline in doc * fix: 修复wait4系统调用部分语义与Linux不一致的问题 (#1080) * fix: 修复wait4系统调用部分语义与Linux不一致的问题 解决wait不住/wait之后卡死的bug --------- Signed-off-by: longjin <longjin@DragonOS.org> * feat(fs/syscall): 实现fchdir系统调用 (#1081) Signed-off-by: longjin <longjin@DragonOS.org> * fix(mm): 修复fat文件系统的PageCache同步问题 (#1005) --------- Co-authored-by: longjin <longjin@DragonOS.org> * fix: 修正nographic启动时,控制台日志未能输出到文件的问题 (#1082) Signed-off-by: longjin <longjin@DragonOS.org> * fix(process): 修复copy_process的一些bug & 支持默认init进程传参 (#1083) - 修复`copy_process`函数对标志位处理不正确的bug - init进程搜索列表中,支持为默认init程序传入参数 Signed-off-by: longjin <longjin@DragonOS.org> * feat: 完善sys_reboot (#1084) * fix(process): 修复copy_process的一些bug & 支持默认init进程传参 - 修复`copy_process`函数对标志位处理不正确的bug - init进程搜索列表中,支持为默认init程序传入参数 Signed-off-by: longjin <longjin@DragonOS.org> * feat: 完善sys_reboot - 校验magic number - 支持多个cmd (具体内容未实现) Signed-off-by: longjin <longjin@DragonOS.org> --------- Signed-off-by: longjin <longjin@DragonOS.org> * fix: 修复do_wait函数在wait所有子进程时,忘了释放锁就sleep的bug (#1089) Signed-off-by: longjin <longjin@DragonOS.org> * pull主线并且fmt --------- Signed-off-by: longjin <longjin@DragonOS.org> Co-authored-by: GnoCiYeH <heyicong@dragonos.org> Co-authored-by: Samuel Dai <samuka007@dragonos.org> Co-authored-by: LoGin <longjin@DragonOS.org> Co-authored-by: LIU Yuwei <22045841+Marsman1996@users.noreply.github.com> Co-authored-by: MemoryShore <1353318529@qq.com>
This commit is contained in:
@ -4,7 +4,7 @@ use alloc::vec::Vec;
|
||||
|
||||
use crate::{bitmap_core::BitMapCore, traits::BitMapOps};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AllocBitmap {
|
||||
elements: usize,
|
||||
data: Vec<usize>,
|
||||
@ -26,6 +26,10 @@ impl AllocBitmap {
|
||||
self.data[i] &= rhs.data[i];
|
||||
}
|
||||
}
|
||||
|
||||
pub fn data(&self) -> &[usize] {
|
||||
&self.data
|
||||
}
|
||||
}
|
||||
|
||||
impl BitMapOps<usize> for AllocBitmap {
|
||||
|
@ -3,7 +3,7 @@ use core::{intrinsics::unlikely, marker::PhantomData};
|
||||
use crate::traits::BitOps;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct BitMapCore<T: BitOps> {
|
||||
pub struct BitMapCore<T: BitOps> {
|
||||
phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ impl<T: BitOps> BitMapCore<T> {
|
||||
}
|
||||
|
||||
/// 获取位图中的某一位
|
||||
pub(crate) fn get(&self, n: usize, data: &[T], index: usize) -> Option<bool> {
|
||||
pub fn get(&self, n: usize, data: &[T], index: usize) -> Option<bool> {
|
||||
if unlikely(index >= n) {
|
||||
return None;
|
||||
}
|
||||
@ -30,7 +30,7 @@ impl<T: BitOps> BitMapCore<T> {
|
||||
}
|
||||
|
||||
/// 设置位图中的某一位
|
||||
pub(crate) fn set(&self, n: usize, data: &mut [T], index: usize, value: bool) -> Option<bool> {
|
||||
pub fn set(&self, n: usize, data: &mut [T], index: usize, value: bool) -> Option<bool> {
|
||||
if unlikely(index >= n) {
|
||||
return None;
|
||||
}
|
||||
@ -43,7 +43,7 @@ impl<T: BitOps> BitMapCore<T> {
|
||||
Some(bit)
|
||||
}
|
||||
|
||||
pub(crate) fn set_all(&self, n: usize, data: &mut [T], value: bool) {
|
||||
pub fn set_all(&self, n: usize, data: &mut [T], value: bool) {
|
||||
let val = if value { T::max() } else { T::zero() };
|
||||
for element in data.iter_mut() {
|
||||
*element = val;
|
||||
@ -58,7 +58,7 @@ impl<T: BitOps> BitMapCore<T> {
|
||||
}
|
||||
|
||||
/// 获取位图中第一个为1的位
|
||||
pub(crate) fn first_index(&self, data: &[T]) -> Option<usize> {
|
||||
pub fn first_index(&self, data: &[T]) -> Option<usize> {
|
||||
for (i, element) in data.iter().enumerate() {
|
||||
let bit = <T as BitOps>::first_index(element);
|
||||
if let Some(b) = bit {
|
||||
@ -70,7 +70,7 @@ impl<T: BitOps> BitMapCore<T> {
|
||||
}
|
||||
|
||||
/// 获取位图中第一个为0的位
|
||||
pub(crate) fn first_false_index(&self, n: usize, data: &[T]) -> Option<usize> {
|
||||
pub fn first_false_index(&self, n: usize, data: &[T]) -> Option<usize> {
|
||||
for (i, element) in data.iter().enumerate() {
|
||||
if let Some(bit) = <T as BitOps>::first_false_index(element) {
|
||||
return self.make_index(n, i * T::bit_size() + bit);
|
||||
@ -81,7 +81,7 @@ impl<T: BitOps> BitMapCore<T> {
|
||||
}
|
||||
|
||||
/// 获取位图中最后一个为1的位
|
||||
pub(crate) fn last_index(&self, n: usize, data: &[T]) -> Option<usize> {
|
||||
pub fn last_index(&self, n: usize, data: &[T]) -> Option<usize> {
|
||||
for (i, element) in data.iter().enumerate().rev() {
|
||||
if let Some(bit) = <T as BitOps>::last_index(element) {
|
||||
return self.make_index(n, i * T::bit_size() + bit);
|
||||
@ -97,7 +97,7 @@ impl<T: BitOps> BitMapCore<T> {
|
||||
///
|
||||
/// - `data`:位图数据
|
||||
/// - `n`:位图有效位数
|
||||
pub(crate) fn last_false_index(&self, n: usize, data: &[T]) -> Option<usize> {
|
||||
pub fn last_false_index(&self, n: usize, data: &[T]) -> Option<usize> {
|
||||
let mut iter = data.iter().rev();
|
||||
let mut last_element = *iter.next()?;
|
||||
|
||||
@ -123,7 +123,7 @@ impl<T: BitOps> BitMapCore<T> {
|
||||
}
|
||||
|
||||
/// 获取位图中下一个为1的位
|
||||
pub(crate) fn next_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
|
||||
pub fn next_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
|
||||
if unlikely(index >= n) {
|
||||
return None;
|
||||
}
|
||||
@ -146,7 +146,7 @@ impl<T: BitOps> BitMapCore<T> {
|
||||
}
|
||||
|
||||
/// 获取位图中下一个为0的位
|
||||
pub(crate) fn next_false_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
|
||||
pub fn next_false_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
|
||||
if unlikely(index >= n) {
|
||||
return None;
|
||||
}
|
||||
@ -169,7 +169,7 @@ impl<T: BitOps> BitMapCore<T> {
|
||||
}
|
||||
|
||||
/// 获取位图中上一个为1的位
|
||||
pub(crate) fn prev_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
|
||||
pub fn prev_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
|
||||
if unlikely(index >= n) {
|
||||
return None;
|
||||
}
|
||||
@ -190,7 +190,7 @@ impl<T: BitOps> BitMapCore<T> {
|
||||
None
|
||||
}
|
||||
|
||||
pub(crate) fn prev_false_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
|
||||
pub fn prev_false_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
|
||||
let element_index = index / T::bit_size();
|
||||
let bit_index = index % T::bit_size();
|
||||
|
||||
@ -208,7 +208,7 @@ impl<T: BitOps> BitMapCore<T> {
|
||||
None
|
||||
}
|
||||
|
||||
pub(crate) fn invert(&self, n: usize, data: &mut [T]) {
|
||||
pub fn invert(&self, n: usize, data: &mut [T]) {
|
||||
for element in data.iter_mut() {
|
||||
<T as BitOps>::invert(element);
|
||||
}
|
||||
@ -222,7 +222,7 @@ impl<T: BitOps> BitMapCore<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn is_full(&self, n: usize, data: &[T]) -> bool {
|
||||
pub fn is_full(&self, n: usize, data: &[T]) -> bool {
|
||||
let mut iter = data.iter().peekable();
|
||||
while let Some(element) = iter.next() {
|
||||
if iter.peek().is_none() {
|
||||
@ -245,7 +245,7 @@ impl<T: BitOps> BitMapCore<T> {
|
||||
return false;
|
||||
}
|
||||
|
||||
pub(crate) fn is_empty(&self, data: &[T]) -> bool {
|
||||
pub fn is_empty(&self, data: &[T]) -> bool {
|
||||
for element in data.iter() {
|
||||
if element != &T::zero() {
|
||||
return false;
|
||||
|
@ -13,4 +13,5 @@ mod bitmap_core;
|
||||
mod static_bitmap;
|
||||
pub mod traits;
|
||||
pub use alloc_bitmap::AllocBitmap;
|
||||
pub use bitmap_core::BitMapCore;
|
||||
pub use static_bitmap::StaticBitmap;
|
||||
|
Reference in New Issue
Block a user