printk from x86-64 assembly code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I want to call printk from arch/x86/lib/copy_user_64.S.  The only
example in assembly that I can find for calling something like
printk is from: arch/x86/kernel/head_64.S (code follows)

here is what I tried:

ENTRY(jj_print)
        CFI_STARTPROC
        ASM_STAC
        leaq jj_buf(%rip),%rdi
        mov $0, %rsi
        call printk
        xorl %eax,%eax
        ASM_CLAC
        ret
        CFI_ENDPROC
ENDPROC(jj_print)
        jj_buf:
                .ascii "hello asm\n\0"

Then I added this to where I wanted to run the code:
        ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
                jj_print, jj_print, jj_print

I wasn't sure how to make the call to jj_print so I just used the
ALTERNATIVE_JUMP without trying to understand it, but from what I can
tell, it seems like it should work (I know it is not ideal and lame)

sample workig code which I based my jj_print func on:
#ifdef CONFIG_EARLY_PRINTK
        GET_CR2_INTO(%r9)       # can clobber any volatile register if pv
        movl 80(%rsp),%r8d      # error code
        movl 72(%rsp),%esi      # vector number
        movl 96(%rsp),%edx      # %cs
        movq 88(%rsp),%rcx      # %rip
        xorl %eax,%eax
        leaq early_idt_msg(%rip),%rdi
        call early_printk
        cmpl $2,early_recursion_flag(%rip)
        jz  1f
        call dump_stack
#ifdef CONFIG_KALLSYMS
        leaq early_idt_ripmsg(%rip),%rdi
        movq 40(%rsp),%rsi      # %rip again
        call __print_symbol
#endif
#endif /* EARLY_PRINTK */

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux