Skip to content

Commit be0f09c

Browse files
authored
Merge pull request #1101 from DragonOS-Community/revert-1097-merge-network-refactor
Revert "Merge Master"
2 parents a02f4c0 + a22408b commit be0f09c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+159
-13904
lines changed

.vscode/settings.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
"rust-analyzer.checkOnSave.allTargets": false,
145145
"rust-analyzer.linkedProjects": [
146146
"./kernel/Cargo.toml",
147-
//"./tools/Cargo.toml",
147+
"./tools/Cargo.toml",
148148

149149
],
150150
// "rust-analyzer.cargo.target": "riscv64gc-unknown-none-elf",
@@ -154,5 +154,4 @@
154154
"check",
155155

156156
],
157-
"makefile.configureOnOpen": false,
158157
}

build-scripts/kernel_build/src/cfiles/arch/x86_64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ impl CFilesArch for X86_64CFilesArch {
3131
files.insert(PathBuf::from("src/arch/x86_64/asm/head.S"));
3232
files.insert(PathBuf::from("src/arch/x86_64/asm/entry.S"));
3333
files.insert(PathBuf::from("src/arch/x86_64/asm/apu_boot.S"));
34-
files.insert(PathBuf::from("src/arch/x86_64/vm/vmx/vmenter.S"));
3534
}
3635

3736
fn setup_global_flags(&self, c: &mut Build) {

kernel/crates/bitmap/src/alloc_bitmap.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use alloc::vec::Vec;
44

55
use crate::{bitmap_core::BitMapCore, traits::BitMapOps};
66

7-
#[derive(Debug, Clone)]
7+
#[derive(Clone)]
88
pub struct AllocBitmap {
99
elements: usize,
1010
data: Vec<usize>,
@@ -26,10 +26,6 @@ impl AllocBitmap {
2626
self.data[i] &= rhs.data[i];
2727
}
2828
}
29-
30-
pub fn data(&self) -> &[usize] {
31-
&self.data
32-
}
3329
}
3430

3531
impl BitMapOps<usize> for AllocBitmap {

kernel/crates/bitmap/src/bitmap_core.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::{intrinsics::unlikely, marker::PhantomData};
33
use crate::traits::BitOps;
44

55
#[derive(Debug, Clone)]
6-
pub struct BitMapCore<T: BitOps> {
6+
pub(crate) struct BitMapCore<T: BitOps> {
77
phantom: PhantomData<T>,
88
}
99

@@ -15,7 +15,7 @@ impl<T: BitOps> BitMapCore<T> {
1515
}
1616

1717
/// 获取位图中的某一位
18-
pub fn get(&self, n: usize, data: &[T], index: usize) -> Option<bool> {
18+
pub(crate) fn get(&self, n: usize, data: &[T], index: usize) -> Option<bool> {
1919
if unlikely(index >= n) {
2020
return None;
2121
}
@@ -30,7 +30,7 @@ impl<T: BitOps> BitMapCore<T> {
3030
}
3131

3232
/// 设置位图中的某一位
33-
pub fn set(&self, n: usize, data: &mut [T], index: usize, value: bool) -> Option<bool> {
33+
pub(crate) fn set(&self, n: usize, data: &mut [T], index: usize, value: bool) -> Option<bool> {
3434
if unlikely(index >= n) {
3535
return None;
3636
}
@@ -43,7 +43,7 @@ impl<T: BitOps> BitMapCore<T> {
4343
Some(bit)
4444
}
4545

46-
pub fn set_all(&self, n: usize, data: &mut [T], value: bool) {
46+
pub(crate) fn set_all(&self, n: usize, data: &mut [T], value: bool) {
4747
let val = if value { T::max() } else { T::zero() };
4848
for element in data.iter_mut() {
4949
*element = val;
@@ -58,7 +58,7 @@ impl<T: BitOps> BitMapCore<T> {
5858
}
5959

6060
/// 获取位图中第一个为1的位
61-
pub fn first_index(&self, data: &[T]) -> Option<usize> {
61+
pub(crate) fn first_index(&self, data: &[T]) -> Option<usize> {
6262
for (i, element) in data.iter().enumerate() {
6363
let bit = <T as BitOps>::first_index(element);
6464
if let Some(b) = bit {
@@ -70,7 +70,7 @@ impl<T: BitOps> BitMapCore<T> {
7070
}
7171

7272
/// 获取位图中第一个为0的位
73-
pub fn first_false_index(&self, n: usize, data: &[T]) -> Option<usize> {
73+
pub(crate) fn first_false_index(&self, n: usize, data: &[T]) -> Option<usize> {
7474
for (i, element) in data.iter().enumerate() {
7575
if let Some(bit) = <T as BitOps>::first_false_index(element) {
7676
return self.make_index(n, i * T::bit_size() + bit);
@@ -81,7 +81,7 @@ impl<T: BitOps> BitMapCore<T> {
8181
}
8282

8383
/// 获取位图中最后一个为1的位
84-
pub fn last_index(&self, n: usize, data: &[T]) -> Option<usize> {
84+
pub(crate) fn last_index(&self, n: usize, data: &[T]) -> Option<usize> {
8585
for (i, element) in data.iter().enumerate().rev() {
8686
if let Some(bit) = <T as BitOps>::last_index(element) {
8787
return self.make_index(n, i * T::bit_size() + bit);
@@ -97,7 +97,7 @@ impl<T: BitOps> BitMapCore<T> {
9797
///
9898
/// - `data`:位图数据
9999
/// - `n`:位图有效位数
100-
pub fn last_false_index(&self, n: usize, data: &[T]) -> Option<usize> {
100+
pub(crate) fn last_false_index(&self, n: usize, data: &[T]) -> Option<usize> {
101101
let mut iter = data.iter().rev();
102102
let mut last_element = *iter.next()?;
103103

@@ -123,7 +123,7 @@ impl<T: BitOps> BitMapCore<T> {
123123
}
124124

125125
/// 获取位图中下一个为1的位
126-
pub fn next_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
126+
pub(crate) fn next_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
127127
if unlikely(index >= n) {
128128
return None;
129129
}
@@ -146,7 +146,7 @@ impl<T: BitOps> BitMapCore<T> {
146146
}
147147

148148
/// 获取位图中下一个为0的位
149-
pub fn next_false_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
149+
pub(crate) fn next_false_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
150150
if unlikely(index >= n) {
151151
return None;
152152
}
@@ -169,7 +169,7 @@ impl<T: BitOps> BitMapCore<T> {
169169
}
170170

171171
/// 获取位图中上一个为1的位
172-
pub fn prev_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
172+
pub(crate) fn prev_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
173173
if unlikely(index >= n) {
174174
return None;
175175
}
@@ -190,7 +190,7 @@ impl<T: BitOps> BitMapCore<T> {
190190
None
191191
}
192192

193-
pub fn prev_false_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
193+
pub(crate) fn prev_false_index(&self, n: usize, data: &[T], index: usize) -> Option<usize> {
194194
let element_index = index / T::bit_size();
195195
let bit_index = index % T::bit_size();
196196

@@ -208,7 +208,7 @@ impl<T: BitOps> BitMapCore<T> {
208208
None
209209
}
210210

211-
pub fn invert(&self, n: usize, data: &mut [T]) {
211+
pub(crate) fn invert(&self, n: usize, data: &mut [T]) {
212212
for element in data.iter_mut() {
213213
<T as BitOps>::invert(element);
214214
}
@@ -222,7 +222,7 @@ impl<T: BitOps> BitMapCore<T> {
222222
}
223223
}
224224

225-
pub fn is_full(&self, n: usize, data: &[T]) -> bool {
225+
pub(crate) fn is_full(&self, n: usize, data: &[T]) -> bool {
226226
let mut iter = data.iter().peekable();
227227
while let Some(element) = iter.next() {
228228
if iter.peek().is_none() {
@@ -245,7 +245,7 @@ impl<T: BitOps> BitMapCore<T> {
245245
return false;
246246
}
247247

248-
pub fn is_empty(&self, data: &[T]) -> bool {
248+
pub(crate) fn is_empty(&self, data: &[T]) -> bool {
249249
for element in data.iter() {
250250
if element != &T::zero() {
251251
return false;

kernel/crates/bitmap/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ mod bitmap_core;
1313
mod static_bitmap;
1414
pub mod traits;
1515
pub use alloc_bitmap::AllocBitmap;
16-
pub use bitmap_core::BitMapCore;
1716
pub use static_bitmap::StaticBitmap;

kernel/src/arch/x86_64/kvm/vmx/mmu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn tdp_get_cr3(_vcpu: &VmxVcpu) -> u64 {
8888
return guest_cr3;
8989
}
9090

91-
pub fn tdp_set_eptp(root_hpa: u64) -> Result<(), SystemError> {
91+
fn tdp_set_eptp(root_hpa: u64) -> Result<(), SystemError> {
9292
// 设置权限位,目前是写死的,可读可写可执行
9393
// EPT paging-structure memory type: Uncacheable
9494
let mut eptp = 0x0_u64;

kernel/src/arch/x86_64/kvm/vmx/vcpu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ pub fn get_segment_base(gdt_base: *const u64, gdt_size: u16, segment_selector: u
501501
// }
502502
pub fn adjust_vmx_controls(ctl_min: u32, ctl_opt: u32, msr: u32, result: &mut u32) {
503503
let vmx_msr_low: u32 = unsafe { (msr::rdmsr(msr) & 0x0000_0000_FFFF_FFFF) as u32 };
504-
let vmx_msr_high: u32 = unsafe { (msr::rdmsr(msr) >> 32) as u32 };
504+
let vmx_msr_high: u32 = unsafe { (msr::rdmsr(msr) << 32) as u32 };
505505
let mut ctl: u32 = ctl_min | ctl_opt;
506506
ctl &= vmx_msr_high; /* bit == 0 in high word ==> must be zero */
507507
ctl |= vmx_msr_low; /* bit == 1 in low word ==> must be one */

kernel/src/arch/x86_64/kvm/vmx/vmexit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ extern "C" fn vmexit_handler() {
264264
}
265265

266266
#[no_mangle]
267-
pub fn adjust_rip(rip: u64) -> Result<(), SystemError> {
267+
fn adjust_rip(rip: u64) -> Result<(), SystemError> {
268268
let instruction_length = vmx_vmread(VmcsFields::VMEXIT_INSTR_LEN as u32)?;
269269
vmx_vmwrite(VmcsFields::GUEST_RIP as u32, rip + instruction_length)?;
270270
Ok(())

kernel/src/arch/x86_64/mm/mod.rs

-9
Original file line numberDiff line numberDiff line change
@@ -439,15 +439,6 @@ impl X86_64MMArch {
439439
// 不支持的原因是,目前好像没有能正确的设置page-level的xd位,会触发page fault
440440
return true;
441441
}
442-
443-
pub unsafe fn read_array<T>(addr: VirtAddr, count: usize) -> Vec<T> {
444-
// 实现读取数组逻辑
445-
let mut vec = Vec::with_capacity(count);
446-
for i in 0..count {
447-
vec.push(Self::read(addr + i * core::mem::size_of::<T>()));
448-
}
449-
vec
450-
}
451442
}
452443

453444
impl VirtAddr {

kernel/src/arch/x86_64/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub mod sched;
2020
pub mod smp;
2121
pub mod syscall;
2222
pub mod time;
23-
pub mod vm;
2423

2524
pub use self::pci::pci::X86_64PciArch as PciArch;
2625

@@ -41,12 +40,3 @@ pub use crate::arch::elf::X86_64ElfArch as CurrentElfArch;
4140
pub use crate::arch::smp::X86_64SMPArch as CurrentSMPArch;
4241

4342
pub use crate::arch::sched::X86_64SchedArch as CurrentSchedArch;
44-
45-
pub use crate::arch::vm::KvmArchManager as CurrentKvmManager;
46-
47-
pub use crate::arch::vm::kvm_host::X86KvmArch as KvmArch;
48-
49-
pub use crate::arch::vm::x86_kvm_ops as kvm_arch_ops;
50-
51-
pub use crate::arch::vm::kvm_host::vcpu::X86VcpuArch as VirtCpuArch;
52-
pub use crate::arch::vm::kvm_host::KvmVcpuStat as VirtCpuStat;

0 commit comments

Comments
 (0)