linux-kernel

How does Linux kernel flush_write_buffers() work on x86?

我的梦境 提交于 2020-06-27 10:57:47
问题 The following code is from include/asm-i386/io.h , and it is invoked from dma_map_single() . My understanding is that flush_write_buffers() is supposed to flush CPU memory cache before mapping the memory for DMA. But how does this assembly code flush CPU cache? static inline void flush_write_buffers(void) { __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory"); } 回答1: The Intel Pentium Pro processors had a bug wherein a store to a memory location of type UC may be reordered with

Bypassing 4KB block size limitation on block layer/device

╄→尐↘猪︶ㄣ 提交于 2020-06-12 04:30:12
问题 We are developing an ssd-type storage hardware device that can take read/write request for big block size >4KB at a time (even in MBs size). My understanding is that linux and its filesystem will "chop down" files into 4KB block size that will be passed to block device driver, which will need to physically fill the block with data from the device (ex., for write) I am also aware the kernel page size has a role in this limitation as it is set at 4KB. For experiment, I want to find out if there

Getting error when compiling kernel for page table walk

只愿长相守 提交于 2020-06-09 02:03:12
问题 I am doing a page table walk. When I am getting ready to update the kernel I get an error: kernel/sys.c: In function ‘__do_sys_get_page_info’: kernel/sys.c:2745:23: error: passing argument 1 of ‘pud_offset’ from incompatible pointer type [-Werror=incompatible-pointer-types] pud = pud_offset(pgd, vmpage); ^ In file included from ./include/linux/mm.h:99:0, from kernel/sys.c:19: ./arch/x86/include/asm/pgtable.h:905:22: note: expected ‘p4d_t * {aka struct <anonymous> *}’ but argument is of type

When use write-through cache policy for pages

£可爱£侵袭症+ 提交于 2020-05-30 03:37:05
问题 I was reading the MDS attack paper RIDL: Rogue In-Flight Data Load. The set pages as write-back, write-through, write-combined or uncacheable and with different experiments determines that the Line Fill Buffer is the cause of the micro-architectural leaks. On a tangent: I was aware that memory can be uncacheable, but I assumed that cacheable data was always cached in a write-back cache, i.e. I assumed that the L1, L2 and LLC were always write-back caches. I read up on the differences between

How to build kernel debug info as separate file?

浪子不回头ぞ 提交于 2020-05-28 07:48:50
问题 When we share custom built kernel, It is common to give without debug info. Similar to sudo apt-get install linux-image-$(uname -r)-dbgsym , I would like to create separate debug info file for custom built kernel. Here and here they explained generally. I request to share knowledge on creating separate debug info file for entire linux kernel. For sample program $ gcc -g calc.c $ ls -l total 16 -rwxrwxr-x 1 jeyaram jeyaram 8424 Apr 8 09:44 a.out -rw-rw-r-- 1 jeyaram jeyaram 246 Apr 8 09:32

after using rmmod program freezes

徘徊边缘 提交于 2020-05-17 07:44:05
问题 I have some problem with my code. In my code i solve the reader writers problem using RCU, when i load the module (insmod) everything works ok, and it works as i expected, but when i unload module (rmmod) my program freezes and I have to restart Ubuntu. In this program i have to use call_rcu() to delete previous version of the shared resource and i think that problem is here, because if i have not if I do not use this function and simply delete via kmalloc () then the program works as it

Linux kernel compile error elf_x86_64 missing

本小妞迷上赌 提交于 2020-05-13 19:18:07
问题 I'm using Ubuntu Linux 12.04 with the 3.11 kernel. For my work I have to patch the kernel to make it realtime able. So I downloaded the Linux 2.6.31.6 kernel with the patch and tried to patch, compile and instal it. While I try to compile it there comes this error: CC arch/x86/vdso/vgetcpu.o CC arch/x86/vdso/vvar.o VDSO arch/x86/vdso/vdso.so.dbg gcc: Error: elf_x86_64: File or directory not found make[2]: *** [arch/x86/vdso/vdso.so.dbg] Error 1 make[1]: *** [arch/x86/vdso] Error 2 make: ***

Why does Linux favor 0x7f mappings?

陌路散爱 提交于 2020-05-13 06:30:08
问题 By running a simple less /proc/self/maps I see that most mappings start with 55 and 7F . I also noticed these ranges to be used whenever I debug any binary. In addition this comment here suggests that the kernel has indeed some range preference. Why is that? Is there some deeper technical reason for the above ranges? Will there be a problem if I manually mmap pages outside of these prefixes? 回答1: First and foremost, assuming that you are talking about x86-64, we can see that the virtual

Linux Kernel: manually modify page table entry flags

时光总嘲笑我的痴心妄想 提交于 2020-05-13 05:33:48
问题 I am trying to manually mark a certain memory region of a userspace process as non-cacheable (for educational purposes, not intended to be used in production code) by setting a flag in the respective page table entries. I have an Ubuntu 14.04 (ASLR disabled) with a 4.4 Linux kernel running on an x86_64 Intel Skylake processor. In my kernel module I have the following function: /* * Set memory region [start,end], excluding 'addr', of process with PID 'pid' as uncacheable. */ ssize_t set

What is the need of having both System.map file and /proc/kallsyms?

僤鯓⒐⒋嵵緔 提交于 2020-05-10 10:27:12
问题 I just want to know the difference between System.map file and /proc/kallsyms . I am using Linux 3.16 generic kernel. I know that both are the kernel symbol table.. When I did a compare on this files, both are having the same content. So what is the need of having both? 回答1: /proc/kallsysms have symbols of dynamically loaded modules as well static code and system.map is symbol tables of only static code. You can not be really sure if system.map will be available on your system. When kernel