Issue
I made a small code for debug (see href="https://stackoverflow.com/questions/75925087/how-to-load-a-variables-address-in-a-register-using-assembly-arm64-linux-kern?noredirect=1#comment133917786_75925087">here. I've used similar code previously but this one seems more correct.)
And I wanted to make a macro related to this. It is for writing an arbitrary mark data in a buffer. (Of course I cannot write so many data because this macro doesn't do pointer round down at the boundary).
.macro write_mark, data
mov x27, \data
adr_l x26, myptr
ldr x28, [x26]
str x27, [x28], #8
adr_l x26, myptr
str x28, [x26] // store write pointer at myptr
.endm
When I add above code to the beginning of the assembly file, it works just fine.
.... (skip) ....
#include <asm/sysreg.h>
#include <asm/thread_info.h>
#include <asm/virt.h>
.global mydstart
.global myptr
.global mydebug2
.macro write_mark, data
mov x27, \data
adr_l x26, myptr
ldr x28, [x26]
str x27, [x28], #8
adr_l x26, myptr
str x28, [x26] // store write pointer at myptr
.endm
#include "efi-header.S"
#define __PHYS_OFFSET KERNEL_START
I made arch/arm64/include/asm/ckim.h and replace above code to just "#include <asm/ckim.h>".
The ckim.h file is like this.
#ifndef __ASM_ASSEMBLER_H
#define __ASM_ASSEMBLER_H
.global mydstart
.global myptr
.global mydebug2
.macro write_mark, data
mov x27, \data
adr_l x26, myptr
ldr x28, [x26]
str x27, [x28], #8
adr_l x26, myptr
str x28, [x26] // store write pointer at myptr
.endm
#endif /* __ASM_ASSEMBLER_H */
Then when I do 'make', I get this error.
ckim@ckim-ubuntu:~/prj1/LinuxDevDrv/linux-5.15.68$ make
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
CHK include/generated/compile.h
AS arch/arm64/kernel/head.o
arch/arm64/kernel/head.S: Assembler messages:
arch/arm64/kernel/head.S:118: Error: unknown mnemonic `write_mark' -- `write_mark 0x4444'
make[2]: *** [scripts/Makefile.build:391: arch/arm64/kernel/head.o] Error 1
make[1]: *** [scripts/Makefile.build:552: arch/arm64/kernel] Error 2
make: *** [Makefile:1898: arch/arm64] Error 2
All other asm/*.h include files are under arch/arm64 so I put the asm/ckim.h under there. What am I missing??
Solution
The problem is that you have a wrong identifier in the include guard, please use something different like:
#ifndef __ASM_CKIM_H
#define __ASM_CKIM_H
// ...
#endif
you were using a identifier that was defined in other include file (in particular asm/assembler.h
) and therefore, your header file would not include the guarded code
Answered By - EmilioPeJu Answer Checked By - Mary Flores (WPSolving Volunteer)