格式如下:
- sudo find /usr/include/ -name *.h | xargs grep ‘you_wanted’
ub16:~/c_study/kvm_study/hitcon2018_abyss$ sudo find /usr/include/ -name *.h | xargs grep 'KVM_CREATE_VM'
/usr/include/linux/kvm.h:/* machine type bits, to be used as argument to KVM_CREATE_VM */
/usr/include/linux/kvm.h:#define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */
vim xx.h
677 /* machine type bits, to be used as argument to KVM_CREATE_VM */
678 #define KVM_VM_S390_UCONTROL 1
679
680 /* on ppc, 0 indicate default, 1 should force HV and 2 PR */
681 #define KVM_VM_PPC_HV 1
682 #define KVM_VM_PPC_PR 2
683
684 #define KVM_S390_SIE_PAGE_OFFSET 1
685
686 /*
687 * ioctls for /dev/kvm fds:
688 */
689 #define KVM_GET_API_VERSION _IO(KVMIO, 0x00)
690 #define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */ //!!!
691 #define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list)
查找结构体定义
- sudo find /usr/include/ -name *.h | xargs grep ‘struct kvm_regs’
ub16:~/c_study/kvm_study/hitcon2018_abyss$ sudo find /usr/include/ -name *.h | xargs grep 'struct kvm_regs'
/usr/include/linux/kvm.h:#define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs)
/usr/include/linux/kvm.h:#define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs)
/usr/include/x86_64-linux-gnu/asm/kvm.h:struct kvm_regs {
111 /* for KVM_GET_REGS and KVM_SET_REGS */
112 struct kvm_regs {
113 /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
114 __u64 rax, rbx, rcx, rdx;
115 __u64 rsi, rdi, rsp, rbp;
116 __u64 r8, r9, r10, r11;
117 __u64 r12, r13, r14, r15;
118 __u64 rip, rflags;
119 };
** 在所有文件里面检索相应的内容**
zj@zj-virtual-machine:~/bochs_prj/64os/4-5/kernel$ find ./ -name "*" | xargs grep sys_vector
grep: ./: Is a directory
./main.c: sys_vector_init();
./trap.c:void sys_vector_init()
./trap.h:void sys_vector_init();