linux-kernel

in linux kernel, asm or asm-generic?

 ̄綄美尐妖づ 提交于 2021-01-26 22:46:12
问题 in mm/memory.c, it includes one file: #include <asm/tlb.h> the tlb.h is include/asm-generic/tlb.h or arch/arm/include/asm/tlb.h ? 回答1: If necessary, header files in arch/arm/include/asm , will include the corresponding header file in include/asm-generic . So in this instance, tlb.h is arch/arm/include/asm/tlb.h . And if necessary, it will include include/asm-generic/tlb.h . You can verify this by running the following command: # The memory.s target creates the assembly file for memory.c make

Why doesn't the function printk() use a comma to separate parameters?

让人想犯罪 __ 提交于 2021-01-26 19:23:11
问题 An example printk call: printk(KERN_INFO "Log message.\n"); Perhaps this question is more about C in general, because I've never seen a function in C before that separated parameters without a comma. How does this work? What does the compiler do with this information? Since the log level is an integer and the message is a pointer to a char array, it must pass them separately. 回答1: The printk() function only takes one const char* argument. The KERN_INFO macro expands to "\001" "6" , yielding:

Why doesn't the function printk() use a comma to separate parameters?

纵饮孤独 提交于 2021-01-26 19:20:51
问题 An example printk call: printk(KERN_INFO "Log message.\n"); Perhaps this question is more about C in general, because I've never seen a function in C before that separated parameters without a comma. How does this work? What does the compiler do with this information? Since the log level is an integer and the message is a pointer to a char array, it must pass them separately. 回答1: The printk() function only takes one const char* argument. The KERN_INFO macro expands to "\001" "6" , yielding:

Linux Kernel code in memory check with sha256 sum

房东的猫 提交于 2021-01-21 11:45:28
问题 Is there a way of finding the loaded kernel code inside the memory? I mean the bootloader loads the kernel and executes it. The kernel extracts itself and start to initialize the hardware and runs init. As I understand the kernel is saved and loaded from the (b)zImage from disk. This unchanged code I want to find inside the memory of the system and check it. I have the following enhancement: Create a sha256 hash of the loaded kernel code and compare it to a defined value to audit the security

__builtin_return_address returns null for index >0?

牧云@^-^@ 提交于 2021-01-20 07:27:42
问题 I want to get the return address of the caller function. I'm using __builtin_return_address() funtion, but if I give index value greater than 0 it is returning NULL . Please help me with this or tell me any other function to get the same. 回答1: See this answer to a related question. __builtin_return_address is GCC and processor specific (also available in some versions of Clang on some processors with some -lack of- optimizations), and documented as On some machines it may be impossible to

Linux compilation | Invalid entrypoint

被刻印的时光 ゝ 提交于 2021-01-20 07:10:22
问题 I am compiling a linux kernel using mipsel toolchain. Everything works fine except at the very last point which states invalid entry point: sh: 0: Can't open /arch/mips/boot/tools/entry rm -f arch/mips/boot/vmlinux.bin.gz gzip -9 arch/mips/boot/vmlinux.bin mkimage -A mips -O linux -T kernel -C gzip \ -a 0x80010000 -e \ -n 'Linux-2.6.31.3-g29b45174-dirty' \ -d arch/mips/boot/vmlinux.bin.gz arch/mips/boot/uImage mkimage: invalid entry point -n Now it mentioned sh: 0: Can't open /arch/mips/boot

Can mutex replace memory barriers

℡╲_俬逩灬. 提交于 2021-01-08 15:27:57
问题 I was trying to understand memory barrier and came across the below wikipedia link http://en.wikipedia.org/wiki/Memory_barrier This explain the concept well but had thoughts if this is really helpful in system where we have mutex() locking the memory section. Taking the same code as mentioned in wikipedia, will the below approach solve the problem using mutex? [Note: Function names are not specific to any programming language, just used for simplicity sake] Processor #1 mutex_lock(a) while (f

Can mutex replace memory barriers

好久不见. 提交于 2021-01-08 15:25:51
问题 I was trying to understand memory barrier and came across the below wikipedia link http://en.wikipedia.org/wiki/Memory_barrier This explain the concept well but had thoughts if this is really helpful in system where we have mutex() locking the memory section. Taking the same code as mentioned in wikipedia, will the below approach solve the problem using mutex? [Note: Function names are not specific to any programming language, just used for simplicity sake] Processor #1 mutex_lock(a) while (f

Map sharing between different ebpf program types

China☆狼群 提交于 2021-01-04 08:58:38
问题 Is it possible to share ebpf maps between different program types. I need to share a map between a tc-bpf program and a cgroup bpf program. This should be possible if the map is pinned to file system that act as global namespace. But, I haven't got this working. The map is created by tc-bpf program and pinned to global namespace. Since it is tc-bpf program, the map is of type struct bpf_elf_map. This bpf program is loaded via iproute2. Now, I have a cgroup bpf program that should be accessing

Does userfaultfd now support file backed map?

 ̄綄美尐妖づ 提交于 2021-01-01 03:56:36
问题 I saw from the documentation of userfaultfd https://manpages.debian.org/testing/manpages-dev/userfaultfd.2.en.html http://man7.org/linux/man-pages/man2/ioctl_userfaultfd.2.html that userfaultfd will start supporting shared map since kernel 4.11. However, the documentation still looks very ambiguous in the sense that I'm still wondering will these include supporting file-backed mmap (which can also be MAP_SHARED)? 回答1: To answer definitively, since the information is not in the manual page(s),