Inline assembly in kernel module

559 views Asked by At

The inline assembly in my kernel module code is following:

   u64 cade_seg;
   __asm__ __volatile__ ("mov %%cs %0": "=r" (code_seg));

However, when it compiles (as kernel module), error is thrown that "junk rax after register." Is there anything wrong with the inline assembly code above.?

Update: by replacing %%cs with other register, say %%rax, the error persists.

1

There are 1 answers

0
Timothy Baldwin On

In assembly language, the registers should be separated by a comma:

__asm__ __volatile__ ("mov %%cs, %0": "=r" (code_seg));

Also segment selectors are a 16 bit type.