Home | History | Annotate | Download | only in x86_64
      1 #ifdef HAVE_STRUCT_KVM_REGS
      2 static void
      3 arch_print_kvm_regs(struct tcb *const tcp,
      4 		    const kernel_ulong_t addr,
      5 		    const struct kvm_regs *const regs)
      6 {
      7 	PRINT_FIELD_X("{", *regs, rax);
      8 	if (abbrev(tcp))
      9 		tprints(", ...");
     10 	else {
     11 		PRINT_FIELD_X(", ",  *regs, rbx);
     12 		PRINT_FIELD_X(", ",  *regs, rcx);
     13 		PRINT_FIELD_X(", ",  *regs, rdx);
     14 		PRINT_FIELD_X(", ",  *regs, rsi);
     15 		PRINT_FIELD_X(", ",  *regs, rdi);
     16 	}
     17 	PRINT_FIELD_X(", ",  *regs, rsp);
     18 	PRINT_FIELD_X(", ",  *regs, rbp);
     19 	if (abbrev(tcp))
     20 		tprints(", ...");
     21 	else {
     22 		PRINT_FIELD_X(", ",  *regs, r8);
     23 		PRINT_FIELD_X(", ",  *regs, r9);
     24 		PRINT_FIELD_X(", ",  *regs, r10);
     25 		PRINT_FIELD_X(", ",  *regs, r11);
     26 		PRINT_FIELD_X(", ",  *regs, r12);
     27 		PRINT_FIELD_X(", ",  *regs, r13);
     28 		PRINT_FIELD_X(", ",  *regs, r14);
     29 		PRINT_FIELD_X(", ",  *regs, r15);
     30 	}
     31 	PRINT_FIELD_X(", ",  *regs, rip);
     32 
     33 	/* TODO: we can decode this more */
     34 	PRINT_FIELD_X(", ",  *regs, rflags);
     35 
     36 	tprints("}");
     37 }
     38 #endif	/* HAVE_STRUCT_KVM_REGS */
     39 
     40 #ifdef HAVE_STRUCT_KVM_SREGS
     41 static void
     42 kvm_ioctl_decode_regs_segment(const char *prefix,
     43 			      const struct kvm_segment *const segment)
     44 {
     45 	tprints(prefix);
     46 	PRINT_FIELD_X("={", *segment, base);
     47 	PRINT_FIELD_U(", ", *segment, limit);
     48 	PRINT_FIELD_U(", ", *segment, selector);
     49 	PRINT_FIELD_U(", ", *segment, type);
     50 	PRINT_FIELD_U(", ", *segment, present);
     51 	PRINT_FIELD_U(", ", *segment, dpl);
     52 	PRINT_FIELD_U(", ", *segment, db);
     53 	PRINT_FIELD_U(", ", *segment, s);
     54 	PRINT_FIELD_U(", ", *segment, l);
     55 	PRINT_FIELD_U(", ", *segment, g);
     56 	PRINT_FIELD_U(", ", *segment, avl);
     57 	tprints("}");
     58 }
     59 
     60 static void
     61 kvm_ioctl_decode_regs_dtable(const char *prefix,
     62 			     const struct kvm_dtable *const dtable)
     63 {
     64 	tprints(prefix);
     65 	PRINT_FIELD_X("={", *dtable, base);
     66 	PRINT_FIELD_U(", ", *dtable, limit);
     67 	tprints("}");
     68 }
     69 
     70 # define PRINT_FIELD_KVM_SREGS_STRUCT(prefix_, where_, type_, field_)	\
     71 	kvm_ioctl_decode_regs_ ## type_(prefix_ #field_, &(where_)->field_)
     72 
     73 static void
     74 arch_print_kvm_sregs(struct tcb *const tcp,
     75 		     const kernel_ulong_t addr,
     76 		     const struct kvm_sregs *const sregs)
     77 {
     78 	PRINT_FIELD_KVM_SREGS_STRUCT("{", sregs, segment, cs);
     79 	if (abbrev(tcp)) {
     80 		tprints(", ...}");
     81 		return;
     82 	}
     83 
     84 	PRINT_FIELD_KVM_SREGS_STRUCT(", ", sregs, segment, ds);
     85 	PRINT_FIELD_KVM_SREGS_STRUCT(", ", sregs, segment, es);
     86 	PRINT_FIELD_KVM_SREGS_STRUCT(", ", sregs, segment, fs);
     87 	PRINT_FIELD_KVM_SREGS_STRUCT(", ", sregs, segment, gs);
     88 	PRINT_FIELD_KVM_SREGS_STRUCT(", ", sregs, segment, ss);
     89 	PRINT_FIELD_KVM_SREGS_STRUCT(", ", sregs, segment, tr);
     90 	PRINT_FIELD_KVM_SREGS_STRUCT(", ", sregs, segment, ldt);
     91 	PRINT_FIELD_KVM_SREGS_STRUCT(", ", sregs, dtable, gdt);
     92 	PRINT_FIELD_KVM_SREGS_STRUCT(", ", sregs, dtable, idt);
     93 	PRINT_FIELD_U(", ", *sregs, cr0);
     94 	PRINT_FIELD_U(", ", *sregs, cr2);
     95 	PRINT_FIELD_U(", ", *sregs, cr3);
     96 	PRINT_FIELD_U(", ", *sregs, cr4);
     97 	PRINT_FIELD_U(", ", *sregs, cr8);
     98 	PRINT_FIELD_U(", ", *sregs, efer);
     99 	PRINT_FIELD_X(", ", *sregs, apic_base);
    100 	tprints(", interrupt_bitmap=[");
    101 
    102 	unsigned int i;
    103 	for (i = 0; i < ARRAY_SIZE(sregs->interrupt_bitmap); i++) {
    104 		if (i != 0)
    105 			tprints(", ");
    106 		tprintf("%#" PRI__x64, sregs->interrupt_bitmap[i]);
    107 	}
    108 	tprints("]}");
    109 }
    110 #endif	/* HAVE_STRUCT_KVM_SREGS */
    111