본문 바로가기

programming/Linux

우분투 모듈 디버깅 모음(module debugging)

insmod: ERROR: could not insert module vif.ko: Unknown symbol in module

vif: Unknown symbol tg_get_cfs_quota (err -2)

vif: Unknown symbol tg_set_cfs_quota (err -2)

>> 커널이 심볼을 못 찾는 문제, dmesg 와 심볼테이블에서 체크해본결과 

>> cat /proc/kallsyms 결과 위치는 알려져 있지만 코드에서 EXPORT_SYMBOL을 하지않아 링킹이 되지 않아 심볼 주소를 해석할 수가 없음

>> /include/linux/sched.h 수정 & /kernel/sched/core.c 수정

        1. /usr/src/linux-5.1.5/kernel/sched/core.c 에서 해당함수를  EXPORT

          1. EXPORT_SYMBOL_GPL(tg_set_cfs_quota);

          2. EXPORT_SYMBOL_GPL(tg_get_cfs_quota);

        2. /usr/src/linux-5.1.5/kernel/sched/sched.h 에서 extern

          1. extern int tg_set_cfs_quota(struct task_group *tg, long cfs_quota_us); //kwlee

          2. extern long tg_get_cfs_quota(struct task_group *tg); //kwlee

        3. vif.c 에서도 위와같이 extern으로 외부 함수 호출 선언

>>주소를 수동으로 바이너리(.ko)에 넣어줄 수는 있지만 커널컴파일이 더빠르고 안전하다고 판단하여 커널컴파일 진행

 

 

implicit declaration of function ‘setup_timer’; did you mean ‘setup_irq’?

>>setup_timer(&credit_allocator->quota_timer, quota_control, cpu);

>>In newer version of Linux kernel, setup_timer function is known as timer_setup.

https://stackoverflow.com/questions/53839625/adaptation-from-old-init-timer-to-new-timer-setup/53842823

>>data = t->expires;

http://jake.dothome.co.kr/lowrestimer/

 

 

error: ‘__GFP_REPEAT’ undeclared (first use in this function); did you mean ‘NF_REPEAT’?

credit_allocator = kmalloc(sizeof(struct credit_allocator), GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);

Reclaim modifiers - __GFP_NORETRY and __GFP_NOFAIL are not supported. __GFP_REPEAT  is supported only for large (>32kB) allocations, and it should be used only if kmalloc is preferable to the vmalloc fallback, due to visible performance drawbacks

https://woodz.tistory.com/90