Lines Matching refs:sregs
176 static void setup_32bit_idt(struct kvm_sregs* sregs, char* host_mem, uintptr_t guest_mem) in setup_32bit_idt() argument
178 sregs->idt.base = guest_mem + ADDR_VAR_IDT; in setup_32bit_idt()
179 sregs->idt.limit = 0x1ff; in setup_32bit_idt()
180 uint64* idt = (uint64*)(host_mem + sregs->idt.base); in setup_32bit_idt()
229 static void setup_64bit_idt(struct kvm_sregs* sregs, char* host_mem, uintptr_t guest_mem) in setup_64bit_idt() argument
231 sregs->idt.base = guest_mem + ADDR_VAR_IDT; in setup_64bit_idt()
232 sregs->idt.limit = 0x1ff; in setup_64bit_idt()
233 uint64* idt = (uint64*)(host_mem + sregs->idt.base); in setup_64bit_idt()
317 struct kvm_sregs sregs; in syz_kvm_setup_cpu() local
318 if (ioctl(cpufd, KVM_GET_SREGS, &sregs)) in syz_kvm_setup_cpu()
326 sregs.gdt.base = guest_mem + ADDR_GDT; in syz_kvm_setup_cpu()
327 sregs.gdt.limit = 256 * sizeof(uint64) - 1; in syz_kvm_setup_cpu()
328 uint64* gdt = (uint64*)(host_mem + sregs.gdt.base); in syz_kvm_setup_cpu()
341 sregs.ldt = seg_ldt; in syz_kvm_setup_cpu()
342 uint64* ldt = (uint64*)(host_mem + sregs.ldt.base); in syz_kvm_setup_cpu()
500 sregs.cs = seg_cs16; in syz_kvm_setup_cpu()
501 sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds16; in syz_kvm_setup_cpu()
502 sregs.cr0 |= CR0_PE; in syz_kvm_setup_cpu()
504 sregs.cs.selector = 0; in syz_kvm_setup_cpu()
505 sregs.cs.base = 0; in syz_kvm_setup_cpu()
513 sregs.cs = seg_cs32; in syz_kvm_setup_cpu()
514 sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds32; in syz_kvm_setup_cpu()
515 sregs.cr0 |= CR0_PE; in syz_kvm_setup_cpu()
516 sregs.efer |= EFER_SCE; in syz_kvm_setup_cpu()
519 setup_32bit_idt(&sregs, host_mem, guest_mem); in syz_kvm_setup_cpu()
526 sregs.cr3 = pd_addr; in syz_kvm_setup_cpu()
527 sregs.cr4 |= CR4_PSE; in syz_kvm_setup_cpu()
536 sregs.cs.selector = 0; in syz_kvm_setup_cpu()
537 sregs.cs.base = 0; in syz_kvm_setup_cpu()
541 sregs.cs = seg_cs16; in syz_kvm_setup_cpu()
542 sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds16; in syz_kvm_setup_cpu()
547 sregs.cr0 |= CR0_PE; in syz_kvm_setup_cpu()
548 sregs.cs = seg_cs16; in syz_kvm_setup_cpu()
549 sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds16; in syz_kvm_setup_cpu()
552 sregs.cr0 |= CR0_PE; in syz_kvm_setup_cpu()
553 sregs.efer |= EFER_SCE; in syz_kvm_setup_cpu()
556 setup_32bit_idt(&sregs, host_mem, guest_mem); in syz_kvm_setup_cpu()
559 sregs.cs = seg_cs32; in syz_kvm_setup_cpu()
560 sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds32; in syz_kvm_setup_cpu()
567 sregs.cs = seg_cs32; in syz_kvm_setup_cpu()
568 sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds32; in syz_kvm_setup_cpu()
574 sregs.cr3 = pd_addr; in syz_kvm_setup_cpu()
575 sregs.cr4 |= CR4_PSE; in syz_kvm_setup_cpu()
580 sregs.cs = seg_cs32_cpl3; in syz_kvm_setup_cpu()
581 sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds32_cpl3; in syz_kvm_setup_cpu()
583 sregs.cs = seg_cs32; in syz_kvm_setup_cpu()
584 sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds32; in syz_kvm_setup_cpu()
587 sregs.efer |= EFER_LME | EFER_SCE; in syz_kvm_setup_cpu()
588 sregs.cr0 |= CR0_PE; in syz_kvm_setup_cpu()
591 setup_64bit_idt(&sregs, host_mem, guest_mem); in syz_kvm_setup_cpu()
593 sregs.cs = seg_cs32; in syz_kvm_setup_cpu()
594 sregs.ds = sregs.es = sregs.fs = sregs.gs = sregs.ss = seg_ds32; in syz_kvm_setup_cpu()
605 sregs.cr3 = pml4_addr; in syz_kvm_setup_cpu()
606 sregs.cr4 |= CR4_PAE; in syz_kvm_setup_cpu()
609 sregs.cr0 |= CR0_NE; in syz_kvm_setup_cpu()
657 tss32.cr3 = sregs.cr3; in syz_kvm_setup_cpu()
667 tss32.cr3 = sregs.cr3; in syz_kvm_setup_cpu()
671 tss32.cr3 = sregs.cr3; in syz_kvm_setup_cpu()
730 sregs.cr0 ^= val & (CR0_MP | CR0_EM | CR0_ET | CR0_NE | CR0_WP | CR0_AM | CR0_NW | CR0_CD); in syz_kvm_setup_cpu()
733 sregs.cr4 ^= val & (CR4_VME | CR4_PVI | CR4_TSD | CR4_DE | CR4_MCE | CR4_PGE | CR4_PCE | in syz_kvm_setup_cpu()
738 sregs.efer ^= val & (EFER_SCE | EFER_NXE | EFER_SVME | EFER_LMSLE | EFER_FFXSR | EFER_TCE); in syz_kvm_setup_cpu()
807 if (ioctl(cpufd, KVM_SET_SREGS, &sregs)) in syz_kvm_setup_cpu()