kernel 相关问题

在计算中,内核是管理来自软件的输入/输出请求的计算机程序,并将它们转换成用于中央处理单元和计算机的其他电子组件的数据处理指令。内核是现代计算机操作系统的基础部分。此标记用于有关在操作系统内核上下文中运行的代码的一般问题。

无法在可视化代码上执行任何Python程序

我正在尝试运行一个python程序(这次是Jupyter笔记本文件ipynb) 当我尝试执行文件或任何单元格时,它要求我选择一个内核,我安装了所有相关的扩展(

回答 1 投票 0

为什么构建和使用内核模块需要 depmod?

据我所知,depmod 的目的是跟踪每个内核模块加载时的依赖关系。为什么不能在加载内核模块时简单地自动确定这一点,

回答 2 投票 0

来自task_struct的完整进程名称

我想从struct task_struct中获取完整的进程名称。 comm 字段仅存储 16 个字符,而进程名称可以更长。有没有办法获得完整的进程名称? 这可以通过...

回答 3 投票 0

mcopy 说“无法初始化 '::'”,没有明显的原因

我有这个makefile: ASM = NASM .PHONY:软盘映像内核引导加载程序的一切 戈尔多斯:一切 qemu-system-i386-fda build/goldos.img 诺伦:一切 一切:软盘映像内核

回答 1 投票 0

虚拟文件系统和系统调用有什么区别?

据我了解,内核主要提供两个接口供用户空间在内核中执行某些操作,即系统调用和虚拟文件系统(procfs、sysfs 等)。 我在书上读到的内容...

回答 2 投票 0

内核参数更改信号

我想在内核(3.x)模块内使用参数: 静态字符参数= 0xff; module_param(param, ushort, S_IRUGO | S_IWUGO); MODULE_PARM_DESC(param, "一个参数"); 有没有可能...

回答 2 投票 0

将 Kotlin 内核安装到 Jupyter Notebook

我正在尝试在 Jupyter 笔记本(在 VScode 上)上使用 Kotlin 内核。 我创建了一个虚拟环境。 我已经通过 pip 安装了 jupyter Notebook 和 kotlin-jupyter-kernel。 当我从

回答 1 投票 0

如何替换内核 5.10.x 模块驱动程序版本的 set_fs(KERNEL_DS)

我一直在将自定义模块驱动程序更新到 5.10.x Linux 内核版本。我的驱动程序在 cdc-acm 设备上添加了一层。为了复制该行为,使用了下一个小驱动程序。 #包括 我一直在将自定义模块驱动程序更新到 5.10.x Linux 内核版本。我的驱动程序在 cdc-acm 设备上添加了一层。为了复制该行为,使用下一个小驱动程序。 #include <linux/kernel.h> #include <linux/module.h> #include <linux/fs.h> #include <linux/file.h> #include <linux/tty.h> #include <linux/version.h> #include <linux/uaccess.h> /* Device major umber */ static int major; /* ttyACM file descriptor */ static struct file *fd; /* Private functions ---------------------------------------------------------*/ static int usbox_serial_baudrate_set(struct file *fd) { int ret; mm_segment_t old_fs; struct termios newtio; //struct termios __user newtio; //void __user *unewtio = (void __user *) &newtio; memset(&newtio, 0, sizeof(newtio)); newtio.c_cflag = (B115200 | CS8 | CLOCAL | CREAD); #if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) old_fs = get_fs(); set_fs( get_ds() ); #elif LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) old_fs = get_fs(); set_fs( KERNEL_DS ); #else old_fs = force_uaccess_begin(); #endif if (fd->f_op->unlocked_ioctl) { ret = fd->f_op->unlocked_ioctl(fd, TCSETS, (unsigned long int) &newtio); pr_info("_unlocked_ioctl: %d\n", ret); } else { ret = -ENOTTY; } #if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) set_fs(old_fs); #else force_uaccess_end(old_fs); #endif pr_info("ret: %d\n", ret ); return ret; } /* Driver Methods ------------------------------------------------------------*/ static ssize_t testdrv_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos) { return 0; } static ssize_t testdrv_write(struct file *filp, const char __user *buf, size_t count, loff_t *ppos) { return 0; } static int testdrv_open(struct inode *inode, struct file *filp) { pr_info("testdrv_open\n"); fd = filp_open( "/dev/ttyACM0", O_RDWR|O_NOCTTY, 0); if (IS_ERR(fd)) { pr_info("error from filp_open()\n"); return -ENODEV; } pr_info ("fd : %p\n", fd); pr_info ("fd->f_op: %p\n", fd->f_op); pr_info ("ioctl : %p\n", fd->f_op->unlocked_ioctl); if ((fd->f_op == NULL) || (fd->f_op->unlocked_ioctl == NULL)) { pr_info("errno: ENODEV\n"); return -ENODEV; } // Set baudrate. if (usbox_serial_baudrate_set(fd) != 0 ) { filp_close(fd, NULL); pr_info("errno: EINVAL\n"); return -EINVAL; } return 0; } static int testdrv_release(struct inode *inode, struct file *filp) { pr_info("testdrv_release\n"); if (fd != NULL) { filp_close(fd, NULL); fd = NULL; } return 0; } static struct file_operations testdrv_fops = { .owner = THIS_MODULE, .read = testdrv_read, .write = testdrv_write, .open = testdrv_open, .release = testdrv_release }; /* Module stuff --------------------------------------------------------------*/ static int __init testdrv_init(void) { int ret; ret = register_chrdev(0, "testdrv", &testdrv_fops); if (ret < 0) { pr_err("Error %d\n", ret); return ret; } major = ret; fd = NULL; pr_info("Major %d\n", major); return 0; } static void __exit testdrv_exit(void) { unregister_chrdev(major, "testdrv"); } module_init(testdrv_init); module_exit(testdrv_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Unknonw"); MODULE_DESCRIPTION("testdrv"); 这里,当testdrv打开时,驱动会打开ttyACM相关。然后它调用“usbox_serial_baudrate_set”来设置波特率。该函数从填充描述符中调用“unlocked_ioctl”。为了能够使用这个电话,我必须使用 #if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) old_fs = get_fs(); set_fs( get_ds() ); #elif LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) old_fs = get_fs(); set_fs( KERNEL_DS ); #else old_fs = force_uaccess_begin(); #endif ... ret = fd->f_op->unlocked_ioctl(fd, TCSETS, (unsigned long int) &newtio); ... #if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) set_fs(old_fs); #else force_uaccess_end(old_fs); #endif 在 5.10.x 之前,此代码可以正常工作。我必须使用 KERNEL_DS 对 5.4.x 进行一些小的更改,但现在我总是从“unlocked_ioctl”中得到 EFAULT。我尝试删除“force_uaccess_begin/force_uaccess_end”但没有成功。 'unlocked_ioctl' 最终调用 /drivers/tty/tty_ioctl.c 'set_termios' 函数,但失败: #ifdef TCGETS2 } else if (opt & TERMIOS_OLD) { if (user_termios_to_kernel_termios_1(&tmp_termios, (struct termios __user *)arg)) return -EFAULT; } else { 函数“user_termios_to_kernel_termios_1”是一个宏 #define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios)) 使用 4.15.0 内核,插入模块并查找相关设备后,我会在 dmesg 中收到下一条消息: [370099.242677] testdrv:testdrv_init: Major 237 [370103.032357] testdrv:testdrv_open: testdrv_open [370103.032635] testdrv:testdrv_open: fd : 0000000034db75d4 [370103.032637] testdrv:testdrv_open: fd->f_op: 00000000c761e065 [370103.032638] testdrv:testdrv_open: ioctl : 00000000608ed60c [370103.032643] testdrv:usbox_serial_baudrate_set: _unlocked_ioctl: 0 [370103.032645] testdrv:usbox_serial_baudrate_set: ret: 0 [370103.032685] testdrv:testdrv_release: testdrv_release 并使用 5.10.1 [ 294.418308] testdrv:testdrv_init: got major 244 [ 296.574583] testdrv:testdrv_open: testdrv_open [ 296.575949] testdrv:testdrv_open: fd : 00000000c35e59c0 [ 296.575955] testdrv:testdrv_open: fd->f_op: 0000000041840a0e [ 296.575957] testdrv:testdrv_open: ioctl : 000000005e21689c [ 296.575965] testdrv:usbox_serial_baudrate_set: _unlocked_ioctl: -14 [ 296.575967] testdrv:usbox_serial_baudrate_set: ret: -14 [ 296.575970] testdrv:testdrv_open: errno: EINVAL 任何人都可以帮助我了解发生了什么事吗?混合用户空间/内核空间数据有问题吗?我该如何解决? 您可以使用 CONFIG_SET_FS=y (uaccess.h) 构建内核。至少应该是 5.10 的选项。

回答 1 投票 0

如何解决Docker Desktop - WSL内核版本过低

如何解决 Docker Desktop - WSL 内核版本过低 [内容] Docker Desktop 需要更新的 WSL 内核版本。通过运行“wsl --update”或按照说明更新 WSL 内核...

回答 1 投票 0

物理 KASLR 禁用:没有合适的内存区域

我从源代码(从 Linux 存储库下载)构建并安装了最新的内核(v5.4)。我按照此处解释的步骤进行操作: https://www.cyberciti.biz/tips/compiling-linux-kernel-26.html 我用过...

回答 2 投票 0

services.yaml 在 symfony 6.3 中被忽略?

将 Symfony 项目从 v 4 升级到 v6.3,我的自动装配不再工作,似乎 services.yaml 被忽略,但无法弄清楚原因。 将 Symfony 项目从 v 4 升级到 v6.3,我的自动装配不再工作,似乎 services.yaml 被忽略,但无法弄清楚原因。 <?php namespace Api; use App\DependencyInjection\AppExtension; use Api\EventListener\ExceptionSubscriber; use Api\EventListener\MonitoringSubscriber; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\HttpKernel\Kernel as SymfonyKernel; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; /** * @property ContainerInterface $container */ class Kernel extends SymfonyKernel { use MicroKernelTrait; private const ALLOWED_CONFIG_EXTENSIONS = '.{php,yaml}'; private const CONFIG_DIR = 'config'; private const DEFAULT_CACHE_PATH = '/tmp'; private const DEFAULT_LOG_PATH = '/tmp'; private ?string $rootProjectDir = null; /** * @inheritdoc */ public function registerBundles(): iterable { $path = $this->getRootProjectDir() . DIRECTORY_SEPARATOR . self::CONFIG_DIR . '/bundles.php'; $contents = file_exists($path) ? require $path : []; $contents = array_merge([ FrameworkBundle::class => ['all' => true], ], $contents); foreach ($contents as $class => $envs) { if (isset($envs['all']) || isset($envs[(string)$this->environment])) { yield new $class(); } } } /** * @return string */ public function getLogDir(): string { return $_SERVER['LOG_DIR'] ?? self::DEFAULT_LOG_PATH; } /** * @return string */ public function getCacheDir(): string { return $_SERVER['CACHE_DIR'] ?? self::DEFAULT_CACHE_PATH; } private function configureContainer( ContainerConfigurator $container, LoaderInterface $loader, ContainerBuilder $builder ): void { $configDir = $this->getConfigDir(); $container->services()->defaults()->autowire()->autoconfigure(); $container->import($configDir.'/{packages}/*.{php,yaml}'); $container->import($configDir.'/{packages}/'.$this->environment.'/*.{php,yaml}'); if (is_file($configDir.'/services.yaml')) { $container->import($configDir.'/services.yaml'); $container->import($configDir.'/{services}_'.$this->environment.'.yaml'); } else { $container->import($configDir.'/{services}.php'); } $container->services()->set(ExceptionSubscriber::class)->tag('kernel.event_subscriber'); $container->services()->set(MonitoringSubscriber::class)->tag('kernel.event_subscriber'); } protected function configureRoutes(RoutingConfigurator $routes): void { $dir = $this->getRootProjectDir() . DIRECTORY_SEPARATOR . self::CONFIG_DIR; $routes->import($dir. '/{routes}/*' . self::ALLOWED_CONFIG_EXTENSIONS); $routes->import($dir. '/{routes}' . self::ALLOWED_CONFIG_EXTENSIONS); } /** * This method is similar to `getProjectDir` accept that it allows for being a vendor package * * @return string */ private function getRootProjectDir(): string { if (null === $this->rootProjectDir) { $project = $this->getProjectDir(); return $this->rootProjectDir = 'vendor' === substr(\dirname($project, 2), -6) ? \dirname($project, 3) : $project; } return $this->rootProjectDir; } } 这是我的内核和我的 services.yaml services: # default configuration for services in *this* file _defaults: autowire: true # Automatically injects dependencies in your services. autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. public: false # Allows optimizing the container by removing unused services; this also means # fetching services directly from the container via $container->get() won't work. # The best practice is to be explicit about your dependencies anyway. Hermes\: resource: '../src/*' # Hermes\Controllers\: # resource: '../src/Controllers' # tags: ['controller.service_arguments'] Sparrow\Sparrow: public: true CacheAdapters\CacheAdapterInterface: arguments: $driver: 'memcached' $config: connection: host: '127.0.0.1' port: '11211' factory: ['CacheAdapters\CacheAdapterFactory', get] Hermes\Service\Cache\CacheService: arguments: $cacheConfig: adapter: 'memcached' connection: host: '127.0.0.1' port: '11211' Hermes\Database\Connection: class:Hermes\Database\Connection factory: ['Hermes\Database\ConnectionFactory', 'createConnection'] arguments: $config: type: mysql host: mysql.local dbname: HERMES user: root password: port: 3306 persistent: true Hermes\Database\Manager: class:Hermes\Database\Manager factory: ['Hermes\Database\DatabaseManagerFactory', 'createDatabaseManager'] arguments: $config: type: mysql host: mysql.local dbname: HERMES user: root password: port: 3306 persistent: true Hermes\ObjectMapping\RepositoryManager: class:Hermes\ObjectMapping\RepositoryManager factory: ['Hermes\ObjectMapping\RepositoryManagerFactory', 'createRepositoryManager'] Logger\LoggerInterface: class: Logger\LoggerInterface arguments: ['%service.logger%'] factory: ['Logger\LoggerFactory', get] public: true 我已经尝试了我在网上可以看到的所有可能的组合,但仍然无法看到我缺少的内容,重要的是要注意这是在我升级之前工作的,是否有新的地方我需要注册才能获得自动装配我的服务能再次运行吗? 我还没有解决问题,但放弃从 Stackoverflow 获得帮助,难怪这个网站正在消亡......提出了一个问题,但没有太多帮助,只是因为我的麻烦而被否决......

回答 1 投票 0

timer.h 中的计时器在内核模块中不起作用

我正在制作一个每 100 毫秒写入一个文件的内核模块。使用 arch linux 和内核 6.4。 kernel/timer.h 中的计时器似乎不起作用。它已被弃用吗?我应该用什么? #包括<...

回答 1 投票 0

从内核恐慌中调用用户空间应用程序

我需要一种方法来通知我的系统上的 U-Boot 发生了内核恐慌,我已经配置了所有相关的应用程序,例如 fw_setenv,并且它在手动启动时可以正常工作。现在我需要自动...

回答 1 投票 0

SPL(二级程序加载器)有什么用

我对这三个问题的概念很困惑 为什么我们需要辅助程序加载器? 它被加载并重新定位在哪个内存中? sy... 和有什么区别

回答 3 投票 0

x86-64 架构中的分页

在32位操作系统的实现中,页表具有固定的结构(两个级别 - 页目录和页表)。但在x86_64系统中,一般会有多个级别的页面...

回答 1 投票 0

为什么WinDBG命令“!error”不能按预期工作?

我经常查询 NTSTATUS 值的含义。 但是,我总是通过 WinDBG 命令得不到任何结果!错误如下: kd>!错误0xC0000008 1 错误代码:(NTS...

回答 2 投票 0

恢复意外删除的ko文件

我不小心删除了这些文件: 删除了“/usr/src/linux-headers-5.19.0-41-generic/include/config/HID_REDRAGON” 删除了“/usr/src/linux-headers-6.2.0-26-generic/include/config/HID_REDRAGON” 雷莫...

回答 1 投票 0

Linux 中的中断延迟

我想了解Linux中的中断延迟是否依赖于内核滴答(计时器)。 中断延迟是从产生中断到源(代码...

回答 1 投票 0

系统调用中的 printf 返回格式错误的输出

我正在使用 kext 记录 OS X 中的系统调用,如下所示: int hook_read(struct proc *p, struct read_args *u, user_ssize_t *r) { /* 在这里获取一些参数... */ printf("[IDEN] SYS_read 已调用,...

回答 1 投票 0

HUB USB 断开,检测并重新加载,无需重启

我们的机器使用 WiFi 和 3G 通信。两个设备通过集线器共享相同的 USB 连接。 一段时间后,似乎两个设备都断开了连接,并且固件无法恢复它们......

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.