Преглед изворни кода

fix: 修复glibc判断内核版本过老的bug

Signed-off-by: longjin <longjin@DragonOS.org>
longjin пре 3 недеља
родитељ
комит
6a6beddd14

+ 1 - 0
kernel/src/arch/x86_64/mm/fault.rs

@@ -272,6 +272,7 @@ impl X86_64MMArch {
                         address.data(),
                         address.data(),
                         flags
                         flags
                     );
                     );
+                    log::error!("fault rip: {:#x}", regs.rip);
                     let pid = ProcessManager::current_pid();
                     let pid = ProcessManager::current_pid();
                     let mut info =
                     let mut info =
                         SigInfo::new(Signal::SIGSEGV, 0, SigCode::User, SigType::Kill(pid));
                         SigInfo::new(Signal::SIGSEGV, 0, SigCode::User, SigType::Kill(pid));

+ 8 - 2
kernel/src/arch/x86_64/process/syscall.rs

@@ -53,6 +53,7 @@ impl Syscall {
     }
     }
 
 
     /// ## 用于控制和查询与体系结构相关的进程特定选项
     /// ## 用于控制和查询与体系结构相关的进程特定选项
+    /// https://code.dragonos.org.cn/xref/linux-6.6.21/arch/x86/kernel/process_64.c#913
     pub fn arch_prctl(option: usize, arg2: usize) -> Result<usize, SystemError> {
     pub fn arch_prctl(option: usize, arg2: usize) -> Result<usize, SystemError> {
         let pcb = ProcessManager::current_pcb();
         let pcb = ProcessManager::current_pcb();
         if let Err(SystemError::EINVAL) = Self::do_arch_prctl_64(&pcb, option, arg2, true) {
         if let Err(SystemError::EINVAL) = Self::do_arch_prctl_64(&pcb, option, arg2, true) {
@@ -109,8 +110,13 @@ impl Syscall {
     }
     }
 
 
     #[allow(dead_code)]
     #[allow(dead_code)]
-    pub fn do_arch_prctl_common(_option: usize, _arg2: usize) -> Result<usize, SystemError> {
-        todo!("do_arch_prctl_common not unimplemented");
+    pub fn do_arch_prctl_common(option: usize, arg2: usize) -> Result<usize, SystemError> {
+        // Don't use 0x3001-0x3004 because of old glibcs
+        if (0x3001..=0x3004).contains(&option) {
+            return Err(SystemError::EINVAL);
+        }
+
+        todo!("do_arch_prctl_common not unimplemented, option: {}, arg2: {}", option, arg2);
     }
     }
 }
 }
 
 

+ 1 - 1
kernel/src/arch/x86_64/syscall/mod.rs

@@ -90,7 +90,7 @@ pub extern "sysv64" fn syscall_handler(frame: &mut TrapFrame) {
     mfence();
     mfence();
     let pid = ProcessManager::current_pcb().pid();
     let pid = ProcessManager::current_pcb().pid();
     let show = false;
     let show = false;
-    // let show = if syscall_num != SYS_SCHED && pid.data() >= 7 {
+    // let show = if syscall_num != SYS_SCHED && pid.data() >= 9{
     //     true
     //     true
     // } else {
     // } else {
     //     false
     //     false

+ 0 - 11
kernel/src/filesystem/page_cache.rs

@@ -25,7 +25,6 @@ use crate::{libs::align::page_align_up, mm::page::PageType};
 #[derive(Debug)]
 #[derive(Debug)]
 pub struct PageCache {
 pub struct PageCache {
     inner: SpinLock<InnerPageCache>,
     inner: SpinLock<InnerPageCache>,
-    inode_id: usize,
     inode: Lazy<Weak<dyn IndexNode>>,
     inode: Lazy<Weak<dyn IndexNode>>,
 }
 }
 
 
@@ -319,15 +318,6 @@ impl Drop for InnerPageCache {
 
 
 impl PageCache {
 impl PageCache {
     pub fn new(inode: Option<Weak<dyn IndexNode>>) -> Arc<PageCache> {
     pub fn new(inode: Option<Weak<dyn IndexNode>>) -> Arc<PageCache> {
-        let inode_id = inode
-            .as_ref()
-            .and_then(|inode| inode.upgrade())
-            .map_or(0, |inode| {
-                inode
-                    .metadata()
-                    .map(|metadata| metadata.inode_id.data())
-                    .unwrap_or(0)
-            });
         Arc::new_cyclic(|weak| Self {
         Arc::new_cyclic(|weak| Self {
             inner: SpinLock::new(InnerPageCache::new(weak.clone())),
             inner: SpinLock::new(InnerPageCache::new(weak.clone())),
             inode: {
             inode: {
@@ -337,7 +327,6 @@ impl PageCache {
                 }
                 }
                 v
                 v
             },
             },
-            inode_id,
         })
         })
     }
     }
 
 

+ 0 - 5
kernel/src/mm/ucontext.rs

@@ -355,11 +355,6 @@ impl InnerAddressSpace {
 
 
         let len = page_align_up(len);
         let len = page_align_up(len);
 
 
-        let vm_flags = VmFlags::from(prot_flags)
-            | VmFlags::from(map_flags)
-            | VmFlags::VM_MAYREAD
-            | VmFlags::VM_MAYWRITE
-            | VmFlags::VM_MAYEXEC;
         // debug!("map_anonymous: len = {}", len);
         // debug!("map_anonymous: len = {}", len);
 
 
         let binding = ProcessManager::current_pcb().fd_table();
         let binding = ProcessManager::current_pcb().fd_table();

+ 3 - 3
kernel/src/process/syscall.rs

@@ -51,10 +51,10 @@ pub struct PosixOldUtsName {
 
 
 impl PosixOldUtsName {
 impl PosixOldUtsName {
     pub fn new() -> Self {
     pub fn new() -> Self {
-        const SYS_NAME: &[u8] = b"DragonOS";
+        const SYS_NAME: &[u8] = b"Linux";
         const NODENAME: &[u8] = b"DragonOS";
         const NODENAME: &[u8] = b"DragonOS";
-        const RELEASE: &[u8] = env!("CARGO_PKG_VERSION").as_bytes();
-        const VERSION: &[u8] = env!("CARGO_PKG_VERSION").as_bytes();
+        const RELEASE: &[u8] = b"5.19.0";
+        const VERSION: &[u8] = b"5.19.0";
 
 
         #[cfg(target_arch = "x86_64")]
         #[cfg(target_arch = "x86_64")]
         const MACHINE: &[u8] = b"x86_64";
         const MACHINE: &[u8] = b"x86_64";

+ 1 - 1
kernel/src/syscall/mod.rs

@@ -1065,7 +1065,7 @@ impl Syscall {
 
 
             SYS_RSEQ => {
             SYS_RSEQ => {
                 warn!("SYS_RSEQ has not yet been implemented");
                 warn!("SYS_RSEQ has not yet been implemented");
-                Ok(0)
+                Err(SystemError::ENOSYS)
             }
             }
 
 
             #[cfg(target_arch = "x86_64")]
             #[cfg(target_arch = "x86_64")]