No FIQ.h on Raspberry PI3B+ - c

I was exploring the FQI routine for ARM processors. I noticed that most Linux kernels provide a fiq.h header file yet my RPi does not seem to have it. Using find does not return anything. My Linux kernel version is 5.15.61-v8+. How would one use FIQ without the header file on RPI? Thanks.
robin#raspberrypi:/ $ locate interrupt.h
/usr/lib/python3/dist-packages/numpy/core/include/numpy/npy_interrupt.h
/usr/src/linux-headers-5.15.61-v8+/include/linux/interrupt.h
robin#raspberrypi:/ $ locate fiq.h
/usr/src/linux-headers-5.15.61-v8+/include/linux/platform_data/ams-delta-fiq.h
/usr/src/linux-headers-5.15.61-v8+/include/linux/spi/s3c24xx-fiq.h

Related

No source file mapping nvvp with nvfortran

Good morning to everyone!
I am accelerating a fortran code with some OpenACC directives.
I am trying to do some profiling with nvvp. However, when I get to the compute analysis, I get the following error:
The source-assembly viewer could not be shown because source-file mappings are missing from the kernel. You can enable source-file mappings by using the -lineinfo flag when compiling the kernels.
When I try to compile the code with the -lineinfo flag, though, I get the error:
cannot find -lineinfo
I found some topics in the forums that suggest to use the -arch=sm_52 flag. Needless, to say, I get:
nvfortran-Error-Unknown switch: -arch=sm_52
Acutally, I have a Quadro P1000 graphic card, cuda 11.7 installed, and a compute capabily 6.1.
Can you please help me to generate these source-file mappings for my code?
Thank you

Trying to include header for vsnprintf throws error in compiling

What is the header file for vsnprintf in the kernel? Can anyone please tell me this, I have kernel 5.14 and I am not sure what headers are default on my system. I have a number of different kernel headers installed, these are:
linux-headers-5.11.0-25
linux-headers-5.11.0-40
linux-headers-5.11.0-25-generic
linux-headers-5.11.0-40-generic
linux-headers-5.11.0-38
linux-headers-5.11.0-38-generic
Which one should be the default? But i like to ask what is the header file for function vsnprintf?
Taking a look at the source code for Linux v5.11, the correct header seems to be linux/kernel.h. It's the same file for Linux v5.14.
To check which headers you should use for your currently running kernel use the command uname -r which should tell you the correct version. You can then compile using those and an appropriate Makefile: see the documentation for more info.

Why couldn't I get the source code line from addr2line?

I'm trying to get the line of source code from addr2line for the rasbian 5.4.y kernel.
My host environment is ubuntu18.04.2 on virtualbox, and I'm compiling the kernel with arm-linux-gnueabihf- cross-compiler.
I compiled the kernel with bcm2711_defconfig configuration since the target machine is Raspberry Pi 4, following the official guide, https://www.raspberrypi.org/documentation/linux/kernel/building.md, with 32-bit arm arch configuration. I didn't modify any kernel configuration at all.
I obtained the address of a function (_local_bh_enable here, for an instance) from vmlinux by using objdump as below,
$ arm-linux-gnueabihf-objdump -x linux/vmlinux | grep _local_bh_enable
...
c0227a28 g F .text 00000098 _local_bh_enable
As you can see above, I got the address for _local_bh_enable as 0xc0227a28.
Then I ran addr2line to get the line of the address but some strange result I've got as below.
$ arm-linux-gnueabihf-addr2line -fe linux/vmlinux -a 0xc0227a28
0xc0227a28
_local_bh_enable
.tmp_vmlinux.kallsyms2.o:?
I don't get what that means. Isn't it supposed to give the source file name with the line number on it?
I've also tried with many other functions but ended up all the same with the ".tmp_vmlinux.kallsyms2.o:?", not the code line I'm expecting to get.
Am I missing something here? Please give me any help for this.
Thanks in advance.
I checked the kernel configuration, and I've found out that the CONFIG_DEBUG_INFO was not set. It seems the cause.
I'm compiling the kernel with CONFIG_DEBUG_INFO set, let me see whether it's working.

C- displaying CPU info using kernel module

I've recently learned about kernel modules and I was thinking on how to create one that does what cat /proc/cpuinfo does.
Is it possible to do this without opening/reading the file directly (fread)?
Thanks in advance!
/proc/cpuinfo output is generated by kernel code; you can check that code and do the same in your kernel module.
Code is located in fs/proc/cpuinfo.c
It references 'cpuinfo_op' object that is provided by architecture-dependent code, try 'grep cpuinfo_op arch' from toplevel directory of kernel source to locate it.

How to read, understand, analyze, and debug a Linux kernel panic?

Consider the following Linux kernel dump stack trace; e.g., you can trigger a panic from the kernel source code by calling panic("debugging a Linux kernel panic");:
[<001360ac>] (unwind_backtrace+0x0/0xf8) from [<00147b7c>] (warn_slowpath_common+0x50/0x60)
[<00147b7c>] (warn_slowpath_common+0x50/0x60) from [<00147c40>] (warn_slowpath_null+0x1c/0x24)
[<00147c40>] (warn_slowpath_null+0x1c/0x24) from [<0014de44>] (local_bh_enable_ip+0xa0/0xac)
[<0014de44>] (local_bh_enable_ip+0xa0/0xac) from [<0019594c>] (bdi_register+0xec/0x150)
In unwind_backtrace+0x0/0xf8 what does +0x0/0xf8 stand for?
How can I see the C code of unwind_backtrace+0x0/0xf8?
How to interpret the panic's content?
It's just an ordinary backtrace, those functions are called in reverse order (first one called was called by the previous one and so on):
unwind_backtrace+0x0/0xf8
warn_slowpath_common+0x50/0x60
warn_slowpath_null+0x1c/0x24
ocal_bh_enable_ip+0xa0/0xac
bdi_register+0xec/0x150
The bdi_register+0xec/0x150 is the symbol + the offset/length there's more information about that in Understanding a Kernel Oops and how you can debug a kernel oops. Also there's this excellent tutorial on Debugging the Kernel
Note: as suggested below by Eugene, you may want to try addr2line first, it still needs an image with debugging symbols though, for example
addr2line -e vmlinux_with_debug_info 0019594c(+offset)
Here are two alternatives for addr2line. Assuming you have the proper target's toolchain, you can do one of the following:
Use objdump:
locate your vmlinux or the .ko file under the kernel root directory, then disassemble the object file :
objdump -dS vmlinux > /tmp/kernel.s
Open the generated assembly file, /tmp/kernel.s. with a text editor such as vim. Go to
unwind_backtrace+0x0/0xf8, i.e. search for the address of unwind_backtrace + the offset. Finally, you have located the problematic part in your source code.
Use gdb:
IMO, an even more elegant option is to use the one and only gdb. Assuming you have the suitable toolchain on your host machine:
Run gdb <path-to-vmlinux>.
Execute in gdb's prompt: list *(unwind_backtrace+0x10).
For additional information, you may checkout the following resources:
Kernel Debugging Tricks.
Debugging The Linux Kernel Using Gdb
In unwind_backtrace+0x0/0xf8 what the +0x0/0xf8 stands for?
The first number (+0x0) is the offset from the beginning of the function (unwind_backtrace in this case). The second number (0xf8) is the total length of the function. Given these two pieces of information, if you already have a hunch about where the fault occurred this might be enough to confirm your suspicion (you can tell (roughly) how far along in the function you were).
To get the exact source line of the corresponding instruction (generally better than hunches), use addr2line or the other methods in other answers.

Resources