Related
This question already has answers here:
Error "RangeError: minimumFractionDigits value is out of range" with ChartJS in Next.js app
(3 answers)
Closed 4 months ago.
everthing is working fine in development on my local machine,
but when I deploy my site to netlify, I get this wierd error in console.
the page data is gotten using getStaticProps function and then passed to the page as props.
here is how the data looks like
[
[ 17671, 19856, 37527 ], [ 4887, 5418, 10305 ],
[ 2803, 2303, 5106 ], [ 8617, 9403, 18020 ],
[ 12664, 15722, 28386 ], [ 4227, 3359, 7586 ],
[ 1371, 1545, 2916 ], [ 17526, 14297, 31823 ],
[ 6883, 4781, 11664 ], [ 9805, 10000, 19805 ],
[ 11068, 12888, 23956 ], [ 4570, 4722, 9292 ],
[ 15428, 17309, 32737 ], [ 3565, 3656, 7221 ],
[ 8750, 10443, 19193 ], [ 1771, 1432, 3203 ],
[ 8495, 9979, 18474 ], [ 288, 265, 553 ],
[ 21130, 19321, 40451 ], [ 6867, 6556, 13423 ],
[ 2656, 2092, 4748 ], [ 967, 656, 1623 ],
[ 4540, 4505, 9045 ], [ 7025, 7108, 14133 ],
[ 53134, 59829, 112963 ], [ 8640, 9028, 17668 ],
[ 6759, 7119, 13878 ], [ 28803, 31362, 60165 ],
[ 7346, 7630, 14976 ], [ 9771, 10963, 20734 ],
[ 15783, 17397, 33180 ], [ 9847, 9706, 19553 ],
[ 15154, 17577, 32731 ], [ 1056, 874, 1930 ],
[ 3260, 2476, 5736 ], [ 1488, 1424, 2912 ],
[ 1656, 1154, 2810 ]
]
it is an array of arrays of 3 numbers.
please how do I solve this?
You need to set swcMinify: false false in your next.confug.js. This is currently a bug in the swcMinifier and you will need to wait until they have fixed it before you can enable it again.
I am using a petalinux / yocto on a evaluation board with a MpSoc and a FPGA. I am new to this whole Embedded Linux and gereeted with this error message when I try to run a precompiled example. Any pointers on what's going wrong is appreciated.
[ 91.171070] rcu: INFO: rcu_sched self-detected stall on CPU
[ 91.176642] rcu: 0-....: (5249 ticks this GP) idle=66a/1/0x4000000000000002 softirq=1286/1286 fqs=2625
[ 91.186107] (t=5252 jiffies g=1737 q=5)
[ 91.190013] Task dump for CPU 0:
[ 91.193225] resnet50 R running task 0 740 608 0x00000002
[ 91.200265] Call trace:
[ 91.202701] dump_backtrace+0x0/0x140
[ 91.206352] show_stack+0x14/0x20
[ 91.209652] sched_show_task+0xf4/0x120
[ 91.213479] dump_cpu_task+0x40/0x50
[ 91.217038] rcu_dump_cpu_stacks+0xa0/0xe0
[ 91.221118] rcu_sched_clock_irq+0x52c/0x780
[ 91.225372] update_process_times+0x2c/0x68
[ 91.229539] tick_sched_handle.isra.0+0x30/0x50
[ 91.234052] tick_sched_timer+0x48/0x98
[ 91.237872] __hrtimer_run_queues+0xec/0x1e8
[ 91.242125] hrtimer_interrupt+0x110/0x2c0
[ 91.246207] arch_timer_handler_phys+0x30/0x40
[ 91.250633] handle_percpu_devid_irq+0x80/0x140
[ 91.255147] generic_handle_irq+0x24/0x38
[ 91.259140] __handle_domain_irq+0x60/0xb8
[ 91.263220] gic_handle_irq+0x5c/0xb8
[ 91.266866] el1_irq+0xb8/0x140
[ 91.269992] misc_open+0x50/0x1a0
[ 91.273291] chrdev_open+0xc4/0x200
[ 91.276763] do_dentry_open+0x104/0x398
[ 91.280581] vfs_open+0x28/0x30
[ 91.283708] path_openat+0x4a0/0x1248
[ 91.287353] do_filp_open+0x74/0xf8
[ 91.290825] do_sys_open+0x168/0x218
[ 91.294384] __arm64_sys_openat+0x20/0x28
[ 91.298381] el0_svc_common.constprop.0+0x68/0x160
[ 91.303161] el0_svc_handler+0x6c/0x88
[ 91.306893] el0_svc+0x8/0xc
I'm having an issue implementing EPT in a hypervisor I'm developing.
I'm receiving error no. 48 (EPT violation. An attempt to access memory with a guest-physical address was disallowed by the configuration of the EPT paging structures) with an EXIT_QUALIFICATION of 0x81 upon doing a VMLAUNCH.
I've checked the page allocation logic and made sure GUEST_CR3 = HOST_CR3. I'm not sure why is this happening. I'm running on VMWare on a Linux host.
This is the allocation logic:
EPTP alloc_ept(int initial_pages_count){
int i;
EPTP eptp;
EPT_PML4E *ept_pml4;
EPT_PDPTE *ept_pdpt;
EPT_PDE *ept_pd;
EPT_PTE *ept_pt;
eptp.value = 0;
ept_pml4 = kzalloc(4096, GFP_KERNEL | GFP_NOWAIT);
if(!ept_pml4)
goto pml4err;
ept_pdpt = kzalloc(4096, GFP_KERNEL | GFP_NOWAIT);
if(!ept_pdpt)
goto pdpterr;
ept_pd = kzalloc(4096, GFP_KERNEL | GFP_NOWAIT);
if(!ept_pd)
goto pderr;
ept_pt = kzalloc(4096, GFP_KERNEL | GFP_NOWAIT);
if(!ept_pt)
goto pterr;
for(i = 0; i < initial_pages_count; i++){
ept_pt[i].fields.phys_addr = virt_to_phys(kzalloc(4096, GFP_KERNEL | GFP_NOWAIT)) >> 12;
ept_pt[i].fields.read_access = 1;
ept_pt[i].fields.write_access = 1;
ept_pt[i].fields.execute_access = 1;
// Read CR0.bit30(CD) to determine cache disable and check if memtype=6 is supported:
ept_pt[i].fields.ept_memtype = 0;
}
ept_pd[0].fields.phys_addr = virt_to_phys(ept_pt) >> 12;
ept_pd[0].fields.read_access = 1;
ept_pd[0].fields.write_access = 1;
ept_pd[0].fields.execute_access = 1;
ept_pdpt[0].fields.phys_addr = virt_to_phys(ept_pd) >> 12;
ept_pdpt[0].fields.read_access = 1;
ept_pdpt[0].fields.write_access = 1;
ept_pdpt[0].fields.execute_access = 1;
ept_pml4[0].fields.phys_addr = virt_to_phys(ept_pdpt) >> 12;
ept_pml4[0].fields.read_access = 1;
ept_pml4[0].fields.write_access = 1;
ept_pml4[0].fields.execute_access = 1;
eptp.fields.pml4_phys_addr = virt_to_phys(ept_pml4) >> 12;
// Read CR0.bit30(CD) to determine cache disable and check if memtype=6 is supported:
eptp.fields.memtype = 0;
eptp.fields.page_walk = 3;
// TODO: Read IA32_VMX_EPT_VPID_CAP - bit 21 if this is supported:
eptp.fields.accessed_and_dirty_flags_enabled = 0;
printk("EPTP PML4 PHYS ADDR: %08llx", eptp.fields.pml4_phys_addr);
return eptp;
pterr:
kfree(ept_pd);
pderr:
kfree(ept_pdpt);
pdpterr:
kfree(ept_pml4);
pml4err:
panic("EPT ALLOC ERROR!");
}
static inline void VMLAUNCH(void){
uint8_t err;
__asm__ __volatile__(
"vmlaunch; setna %[err]"
: [err]"=rm"(err)
: : "cc", "memory"
);
dump_vmcs();
printk(KERN_ERR "VMLAUNCH failure (err %lx)", vmcs_read(VM_INSTRUCTION_ERROR));
BUG_ON(err);
}
static void setup_vm_code(vmstate *vms){
int i;
EPT_PML4E *pml = phys_to_virt(vms->eptp.fields.pml4_phys_addr << 12);
EPT_PDPTE *pdpt = phys_to_virt(pml->fields.phys_addr << 12);
EPT_PDE *pd = phys_to_virt(pdpt->fields.phys_addr << 12);
EPT_PTE *pt = phys_to_virt(pd->fields.phys_addr << 12);
vms->initial_rip = (unsigned long)phys_to_virt(pt[0].fields.phys_addr << 12);
for(i = 0; i < 4096; i++){
// hlt
*(char*)(vms->initial_rip+i) = 0xf4;
}
printk(KERN_INFO "INITIAL_RIP: %016lx", vms->initial_rip);
printk(KERN_INFO "INITIAL_RIP_PHYS: %016llx", virt_to_phys((unsigned long*)vms->initial_rip));
// Stack grows down
vms->initial_rsp = (unsigned long)phys_to_virt(pt[9].fields.phys_addr << 12) + 4095;
}
static void prepare_vmx_cpu(void){
uint32_t vmcs_revid = 0;
uint32_t hi = 0;
vmstate *vms = per_cpu(cpu_vms, smp_processor_id());
// Populate VMCS revision id in vmxon region
rdmsr_safe(MSR_IA32_VMX_BASIC, &vmcs_revid, &hi);
memcpy(vms->vmxon_region, &vmcs_revid, 4);
memcpy(vms->vmcs_region, &vmcs_revid, 4);
vms->eptp = alloc_ept(10);
setup_vm_code(vms);
vmx_enable();
}
static void handle_vmexit(void){
int exit_reason = vmcs_read32(VM_EXIT_REASON);
int basic_exit_code = exit_reason & 0xffff;
int exit_qualification = vmcs_read32(EXIT_QUALIFICATION);
int vm_entry_failure = exit_reason & 0x80000000;
dump_vmcs();
panic("VMEXIT WITH CODE %d, VM ENTRY FAILURE: %s, QUAL: %d", basic_exit_code, vm_entry_failure ? "true" : "false", exit_qualification);
VMRESUME();
//TODO: switch error reasons
}
static void vmx_setup_vm_controls(void){
// VM Execution Controls
vmcs_write(PIN_BASED_VM_EXEC_CONTROL, adjust_msr_control(MSR_IA32_VMX_PINBASED_CTLS, 0));
vmcs_write(CPU_BASED_VM_EXEC_CONTROL, adjust_msr_control(
MSR_IA32_VMX_PROCBASED_CTLS, CPU_BASED_HLT_EXITING | CPU_BASED_ACTIVATE_SECONDARY_CONTROLS));
vmcs_write(SECONDARY_VM_EXEC_CONTROL, adjust_msr_control(
MSR_IA32_VMX_PROCBASED_CTLS2, CPU_BASED_CTL2_RDTSCP | CPU_BASED_CTL2_ENABLE_INVPCID | CPU_BASED_CTL2_ENABLE_VPID | CPU_BASED_CTL2_ENABLE_XSAVE_XRSTORS | CPU_BASED_CTL2_ENABLE_EPT
));
//vmcs_write64(TSC_OFFSET, 0);
vmcs_write(CR0_READ_SHADOW, read_cr0());
vmcs_write(CR4_READ_SHADOW, __read_cr4());
vmcs_write(CR0_GUEST_HOST_MASK, ~0ul);
vmcs_write(CR4_GUEST_HOST_MASK, ~0ul);
// How many CR3_TARGET_VALUEs are considered without VM exit when MOV CR3, VAL
vmcs_write(CR3_TARGET_COUNT, 0);
// VM Entry & Exit Controls
vmcs_write(VM_EXIT_CONTROLS, adjust_msr_control(MSR_IA32_VMX_EXIT_CTLS, VM_EXIT_IA32E_MODE | VM_EXIT_LOAD_IA32_EFER | VM_EXIT_HOST_ADDR_SPACE_SIZE));
vmcs_write(VM_ENTRY_CONTROLS, adjust_msr_control(MSR_IA32_VMX_ENTRY_CTLS, VM_ENTRY_IA32E_MODE | VM_ENTRY_LOAD_IA32_EFER));
}
static void vmx_setup_initial_host_state(vmstate *vms){
struct desc_ptr gdtptr, idt;
vmcs_write(HOST_CR0, read_cr0());
vmcs_write(HOST_CR3, __read_cr3());
vmcs_write(HOST_CR4, __read_cr4());
vmcs_write(HOST_RSP, (unsigned long)vms->vmm_handle_stack + vms->vmm_handle_stack_size - 1);
vmcs_write(HOST_RIP, (unsigned long)handle_vmexit);
/* An explanation of segment selectors: https://medium.com/hungys-blog/linux-kernel-memory-addressing-a0d304283af3 */
// Segment Selectors
vmcs_write(HOST_CS_SELECTOR, __KERNEL_CS);
vmcs_write(HOST_DS_SELECTOR, __KERNEL_DS);
vmcs_write(HOST_ES_SELECTOR, __KERNEL_DS);
vmcs_write(HOST_SS_SELECTOR, __KERNEL_DS);
vmcs_write(HOST_FS_SELECTOR, 0);
vmcs_write(HOST_GS_SELECTOR, 0);
vmcs_write(HOST_TR_SELECTOR, GDT_ENTRY_TSS*8);
// Segment Base Adresses
vmcs_write(HOST_FS_BASE, native_read_msr(MSR_FS_BASE));
vmcs_write(HOST_GS_BASE, native_read_msr(MSR_GS_BASE));
vmcs_write(HOST_TR_BASE, read_tr_base());
native_store_gdt(&gdtptr);
vmcs_write(HOST_GDTR_BASE, gdtptr.address);
store_idt(&idt);
vmcs_write(HOST_IDTR_BASE, idt.address);
// MSRs
vmcs_write(HOST_IA32_SYSENTER_CS, native_read_msr(MSR_IA32_SYSENTER_CS));
vmcs_write(HOST_IA32_SYSENTER_ESP, native_read_msr(MSR_IA32_SYSENTER_ESP));
vmcs_write(HOST_IA32_SYSENTER_EIP, native_read_msr(MSR_IA32_SYSENTER_EIP));
vmcs_write64(HOST_IA32_EFER, native_read_msr(MSR_EFER));
}
static void RIPTEST(void) __attribute__((used));
static void RIPTEST(void){
__asm__ __volatile__("hlt; hlt; hlt; hlt; hlt; hlt");
}
static void vmx_setup_initial_guest_state(vmstate *vms){
vmcs_write(GUEST_CR0, read_cr0());
vmcs_write(GUEST_CR3, __read_cr3());
vmcs_write(GUEST_CR4, __read_cr4());
vmcs_write(GUEST_DR7, 0);
vmcs_write(GUEST_RIP, vms->initial_rip);
//vmcs_write(GUEST_RIP, (unsigned long)RIPTEST);
vmcs_write(GUEST_RSP, vms->initial_rsp);
vmcs_write(GUEST_RFLAGS, 0x2); // Reserved flag
// Setup selectors
vmcs_write(GUEST_CS_SELECTOR, 0);
vmcs_write(GUEST_SS_SELECTOR, 0);
vmcs_write(GUEST_DS_SELECTOR, 0);
vmcs_write(GUEST_ES_SELECTOR, 0);
vmcs_write(GUEST_FS_SELECTOR, 0);
vmcs_write(GUEST_GS_SELECTOR, 0);
vmcs_write(GUEST_LDTR_SELECTOR, 0);
vmcs_write(GUEST_TR_SELECTOR, 0);
// Setup base addresses
vmcs_write(GUEST_CS_BASE, 0);
vmcs_write(GUEST_SS_BASE, 0);
vmcs_write(GUEST_DS_BASE, 0);
vmcs_write(GUEST_ES_BASE, 0);
vmcs_write(GUEST_FS_BASE, native_read_msr(MSR_FS_BASE));
vmcs_write(GUEST_GS_BASE, native_read_msr(MSR_GS_BASE));
vmcs_write(GUEST_LDTR_BASE, 0);
vmcs_write(GUEST_TR_BASE, 0);
// Setup guest segment limits
vmcs_write(GUEST_CS_LIMIT, 0xFFFFFFFF);
vmcs_write(GUEST_SS_LIMIT, 0xFFFFFFFF);
vmcs_write(GUEST_DS_LIMIT, 0xFFFFFFFF);
vmcs_write(GUEST_ES_LIMIT, 0xFFFFFFFF);
vmcs_write(GUEST_FS_LIMIT, 0xFFFFFFFF);
vmcs_write(GUEST_GS_LIMIT, 0xFFFFFFFF);
vmcs_write(GUEST_LDTR_LIMIT, 0);
vmcs_write(GUEST_TR_LIMIT, 0xFF);
// Setup guest segment access rights
// https://www.amd.com/system/files/TechDocs/24593.pdf#G10.910849
vmcs_write(GUEST_CS_AR_BYTES, 0xA09B);
vmcs_write(GUEST_SS_AR_BYTES, 0xA093);
vmcs_write(GUEST_DS_AR_BYTES, 0xA093);
vmcs_write(GUEST_ES_AR_BYTES, 0xA093);
vmcs_write(GUEST_FS_AR_BYTES, 0xA093);
vmcs_write(GUEST_GS_AR_BYTES, 0xA093);
vmcs_write(GUEST_LDTR_AR_BYTES, 0x0082);
vmcs_write(GUEST_TR_AR_BYTES, 0x008B);
// Setup GDTR & IDTR
vmcs_write(GUEST_GDTR_BASE, 0);
vmcs_write(GUEST_IDTR_BASE, 0);
vmcs_write(GUEST_GDTR_LIMIT, 0);
vmcs_write(GUEST_IDTR_LIMIT, 0);
vmcs_write(GUEST_IA32_EFER, native_read_msr(MSR_EFER));
vmcs_write64(GUEST_IA32_DEBUGCTL, 0);
// Setup sysenter primitives
vmcs_write(GUEST_SYSENTER_CS, 0);
vmcs_write(GUEST_SYSENTER_ESP, 0);
vmcs_write(GUEST_SYSENTER_EIP, 0);
}
static void init_vmcs(vmstate *vms){
VMPTRLD(vms->vmcs_physical);
vmx_setup_vm_controls();
vmx_setup_initial_guest_state(vms);
vmx_setup_initial_host_state(vms);
vmcs_write64(VMCS_LINK_POINTER, -1ull);
//vmcs_write(EXCEPTION_BITMAP, 8192);
vmcs_write64(EPT_POINTER, vms->eptp.value);
//vmcs_write(VIRTUAL_PROCESSOR_ID, vms->vpid);
}
int vmx_launch(void){
int cpu = smp_processor_id();
vmstate *vms = per_cpu(cpu_vms, smp_processor_id());
printk(KERN_INFO "Launching VM on CPU %d\n", cpu);
init_vmcs(vms);
VMLAUNCH();
put_cpu();
return 0;
}
int vmx_setup(void){
int i = smp_processor_id();
vmstate* vms;
printk(KERN_INFO "NUM CPUS: %d\n", num_online_cpus());
vms = create_vmstate();
vms->vmxon_region = kmalloc(4096, GFP_KERNEL);
vms->vmxon_physical = virt_to_phys(vms->vmxon_region);
vms->vmcs_region = kzalloc(4096, GFP_KERNEL);
vms->vmcs_physical = virt_to_phys(vms->vmcs_region);
vms->vmm_handle_stack_size = 4096;
vms->vmm_handle_stack = kmalloc(vms->vmm_handle_stack_size, GFP_KERNEL);
vms->vpid = get_free_vpid();
per_cpu(cpu_vms, i) = vms;
prepare_vmx_cpu();
printk(KERN_INFO "CPUS prepared!");
vms = per_cpu(cpu_vms, i);
if(vms->vmx_enabled == false) {
printk(KERN_ALERT "Tearing down after VMXON failed!");
vmx_teardown();
return -1;
}
return 0;
}
static int __init hyper_init(void) {
int err;
get_cpu();
printk(KERN_INFO "Hyper1 Init!\n");
if(check_vmx_support()){
device_cleanup();
return -1;
}
if((err = setup_chrdev())){
device_cleanup();
return err;
}
if((err = vmx_setup())){
device_cleanup();
return err;
}
printk(KERN_INFO "Assigned major number %d\n", MAJOR(devt));
vmx_launch();
put_cpu();
return 0;
}
VM log:
[ 323.188232] Hyper1 Init!
[ 323.189311] NUM CPUS: 2
[ 323.192490] EPTP PML4 PHYS ADDR: 0007261e
[ 323.192500] INITIAL_RIP: 18446615530478686208
[ 323.194087] CPUS prepared!
[ 323.195778] Assigned major number 240
[ 323.198310] Launching VM on CPU 1
[ 323.199330] vmwrite log: reg 4000 value 16
[ 323.200639] vmwrite log: reg 4002 value ffffffff8401e1f2
[ 323.202297] vmwrite log: reg 401e value a
[ 323.203499] vmwrite log: reg 6004 value 80050033
[ 323.204836] vmwrite log: reg 6006 value 626e0
[ 323.206041] vmwrite log: reg 6000 value ffffffffffffffff
[ 323.207529] vmwrite log: reg 6002 value ffffffffffffffff
[ 323.209033] vmwrite log: reg 400a value 0
[ 323.210121] vmwrite log: reg 400c value 236fff
[ 323.211322] vmwrite log: reg 4012 value 93ff
[ 323.212541] vmwrite log: reg 6800 value 80050033
[ 323.213900] vmwrite log: reg 6802 value 7776e004
[ 323.215150] vmwrite log: reg 6804 value 626e0
[ 323.216457] vmwrite log: reg 681a value 0
[ 323.217565] vmwrite log: reg 681e value ffff8b173262d000
[ 323.219124] vmwrite log: reg 681c value ffff8b173260cfff
[ 323.220656] vmwrite log: reg 6820 value 2
[ 323.221746] vmwrite log: reg 802 value 0
[ 323.222811] vmwrite log: reg 804 value 0
[ 323.223938] vmwrite log: reg 806 value 0
[ 323.225008] vmwrite log: reg 800 value 0
[ 323.226082] vmwrite log: reg 808 value 0
[ 323.227246] vmwrite log: reg 80a value 0
[ 323.228437] vmwrite log: reg 80c value 0
[ 323.229551] vmwrite log: reg 80e value 0
[ 323.230626] vmwrite log: reg 6808 value 0
[ 323.231753] vmwrite log: reg 680a value 0
[ 323.232841] vmwrite log: reg 680c value 0
[ 323.233925] vmwrite log: reg 6806 value 0
[ 323.235037] vmwrite log: reg 680e value 7f624c519540
[ 323.236473] vmwrite log: reg 6810 value ffff8b173bc40000
[ 323.237903] vmwrite log: reg 6812 value 0
[ 323.238988] vmwrite log: reg 6814 value 0
[ 323.240129] vmwrite log: reg 4802 value ffffffff
[ 323.241375] vmwrite log: reg 4804 value ffffffff
[ 323.242619] vmwrite log: reg 4806 value ffffffff
[ 323.243905] vmwrite log: reg 4800 value ffffffff
[ 323.245150] vmwrite log: reg 4808 value ffffffff
[ 323.246417] vmwrite log: reg 480a value ffffffff
[ 323.247697] vmwrite log: reg 480c value 0
[ 323.248784] vmwrite log: reg 480e value ff
[ 323.249901] vmwrite log: reg 4816 value a09b
[ 323.251053] vmwrite log: reg 4818 value a093
[ 323.252243] vmwrite log: reg 481a value a093
[ 323.253439] vmwrite log: reg 4814 value a093
[ 323.254594] vmwrite log: reg 481c value a093
[ 323.255822] vmwrite log: reg 481e value a093
[ 323.256978] vmwrite log: reg 4820 value 82
[ 323.258142] vmwrite log: reg 4822 value 8b
[ 323.259238] vmwrite log: reg 6816 value 0
[ 323.260350] vmwrite log: reg 6818 value 0
[ 323.261421] vmwrite log: reg 4810 value 0
[ 323.262489] vmwrite log: reg 4812 value 0
[ 323.263762] vmwrite log: reg 2806 value d01
[ 323.264960] vmwrite log: reg 2802 value 0
[ 323.266068] vmwrite log: reg 482a value 0
[ 323.267136] vmwrite log: reg 6824 value 0
[ 323.268257] vmwrite log: reg 6826 value 0
[ 323.269379] vmwrite log: reg 6c00 value 80050033
[ 323.270601] vmwrite log: reg 6c02 value 7776e004
[ 323.271879] vmwrite log: reg 6c04 value 626e0
[ 323.273037] vmwrite log: reg 6c14 value ffff8b1732619fff
[ 323.274435] vmwrite log: reg 6c16 value ffffffffc07154f0
[ 323.275870] vmwrite log: reg c02 value 10
[ 323.277134] vmwrite log: reg c06 value 18
[ 323.278262] vmwrite log: reg c00 value 18
[ 323.279443] vmwrite log: reg c04 value 18
[ 323.280625] vmwrite log: reg c08 value 0
[ 323.282006] vmwrite log: reg c0a value 0
[ 323.283281] vmwrite log: reg c0c value 40
[ 323.284409] vmwrite log: reg 6c06 value 7f624c519540
[ 323.285794] vmwrite log: reg 6c08 value ffff8b173bc40000
[ 323.287244] vmwrite log: reg 6c0a value 0
[ 323.288367] vmwrite log: reg 6c0c value fffffe000002c000
[ 323.289770] vmwrite log: reg 6c0e value fffffe0000000000
[ 323.291169] vmwrite log: reg 4c00 value 10
[ 323.292295] vmwrite log: reg 6c10 value fffffe000002d200
[ 323.293696] vmwrite log: reg 6c12 value ffffffff860015f0
[ 323.295124] vmwrite log: reg 2c02 value d01
[ 323.296309] vmwrite log: reg 2800 value ffffffffffffffff
[ 323.297711] vmwrite log: reg 201a value 7261e018
[ 323.299105] *** Guest State ***
[ 323.300022] CR0: actual=0x0000000080050033, shadow=0x0000000080050033, gh_mask=ffffffffffffffff
[ 323.302373] CR4: actual=0x00000000000626e0, shadow=0x00000000000626e0, gh_mask=ffffffffffffffff
[ 323.304697] CR3 = 0x000000007776e004
[ 323.305687] PDPTR0 = 0x0000000000000000 PDPTR1 = 0x0000000000000000
[ 323.307411] PDPTR2 = 0x0000000000000000 PDPTR3 = 0x0000000000000000
[ 323.309117] RSP = 0xffff8b173260cfff RIP = 0xffff8b173262d000
[ 323.310683] RFLAGS=0x00010002 DR7 = 0x0000000000000400
[ 323.312270] Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000
[ 323.314044] CS: sel=0x0000, attr=0x0a09b, limit=0xffffffff, base=0x0000000000000000
[ 323.316257] DS: sel=0x0000, attr=0x0a093, limit=0xffffffff, base=0x0000000000000000
[ 323.318371] SS: sel=0x0000, attr=0x0a093, limit=0xffffffff, base=0x0000000000000000
[ 323.320506] ES: sel=0x0000, attr=0x0a093, limit=0xffffffff, base=0x0000000000000000
[ 323.322580] FS: sel=0x0000, attr=0x0a093, limit=0xffffffff, base=0x00007f624c519540
[ 323.324678] GS: sel=0x0000, attr=0x0a093, limit=0xffffffff, base=0xffff8b173bc40000
[ 323.326774] GDTR: limit=0x00000000, base=0x0000000000000000
[ 323.328880] LDTR: sel=0x0000, attr=0x00082, limit=0x00000000, base=0x0000000000000000
[ 323.330982] IDTR: limit=0x00000000, base=0x0000000000000000
[ 323.333073] TR: sel=0x0000, attr=0x0008b, limit=0x000000ff, base=0x0000000000000000
[ 323.335153] EFER = 0x0000000000000d01 PAT = 0x0000000000000000
[ 323.337001] DebugCtl = 0x0000000000000000 DebugExceptions = 0x0000000000000000
[ 323.338947] PerfGlobCtl = 0x0000000000000000
[ 323.340114] vmread err: reg 2812 value 0
[ 323.341171] BndCfgS = 0x0000000000000000
[ 323.342235] Interruptibility = 00000000 ActivityState = 00000000
[ 323.343874] vmread err: reg 810 value 0
[ 323.344910] InterruptStatus = 0000
[ 323.345840] *** Host State ***
[ 323.346699] RIP = 0xffffffffc07154f0 RSP = 0xffff8b1732619fff
[ 323.348287] CS=0010 SS=0018 DS=0018 ES=0018 FS=0000 GS=0000 TR=0040
[ 323.349965] FSBase=00007f624c519540 GSBase=ffff8b173bc40000 TRBase=0000000000000000
[ 323.352014] GDTBase=fffffe000002c000 IDTBase=fffffe0000000000
[ 323.353586] CR0=0000000080050033 CR3=000000007776e004 CR4=00000000000626e0
[ 323.355468] Sysenter RSP=fffffe000002d200 CS:RIP=0010:ffffffff860015f0
[ 323.357231] EFER = 0x0000000000000d01 PAT = 0x0000000000000000
[ 323.358815] PerfGlobCtl = 0x0000000000000000
[ 323.359976] *** Control State ***
[ 323.360877] PinBased=00000016 CPUBased=8401e1f2 SecondaryExec=0000000a
[ 323.362632] EntryControls=000093ff ExitControls=00236fff
[ 323.364073] ExceptionBitmap=00000000 PFECmask=00000000 PFECmatch=00000000
[ 323.366003] VMEntry: intr_info=00000000 errcode=00000000 ilen=00000000
[ 323.367768] VMExit: intr_info=00000000 errcode=00000000 ilen=00000003
[ 323.369521] reason=00000030 qualification=0000000000000081
[ 323.371177] IDTVectoring: info=00000000 errcode=00000000
[ 323.372614] TSC Offset = 0x0000000000000000
[ 323.373742] vmread err: reg 810 value 810
[ 323.374822] SVI|RVI = 08|10 TPR Threshold = 0x00
[ 323.376079] vmread err: reg 2014 value 0
[ 323.377276] APIC-access addr = 0x0000000000000000 virt-APIC addr = 0x0000000000000000
[ 323.379498] vmread err: reg 2 value 0
[ 323.380501] PostedIntrVec = 0x00
[ 323.381383] EPT pointer = 0x000000007261e018
[ 323.382534] Virtual processor ID = 0x0000
[ 323.383629] Kernel panic - not syncing: VMEXIT WITH CODE 48, VM ENTRY FAILURE: false, QUAL: 129
Any help would be appreciated, thanks!
It looks like it is only mapping 10 pages (40 KB) in the EPT, but GUEST CR3 is 7776e0000, which is not mapped.
If you want to only map a small amount of memory into the guest, then all the guest structures need to be located within that guest physical address range.
I am working on a project in which we have hooked the system open call. When a user attempts to open a file we want sys_open to check the given path against a file which contains file paths. If the given file path is contained in that file we want to stop them from opening the file. This is our module:
#include <linux/module.h> /* Needed by all kernel modules */
#include <linux/kernel.h> /* Needed for loglevels (KERN_WARNING, KERN_EMERG, KERN_INFO, etc.) */
#include <linux/init.h> /* Needed for __init and __exit macros. */
#include <linux/unistd.h> /* sys_call_table __NR_* system call function indices */
#include <linux/fs.h> /* filp_open */
#include <linux/slab.h> /* kmalloc */
#include <asm/paravirt.h> /* write_cr0 */
#include <asm/uaccess.h> /* get_fs, set_fs */
#include <linux/xattr.h>
#include <linux/dcache.h> /*dentry*/
#include <linux/namei.h>
#define PROC_V "/proc/version"
#define BOOT_PATH "/boot/System.map-"
#define CHECK_FILE "root/home/ben/Documents/project/module/test.txt"
#define MAX_VERSION_LEN 256
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Lots o ppl");
MODULE_DESCRIPTION("File Bunker");
//https://tnichols.org/2015/10/19/Hooking-the-Linux-System-Call-Table/
unsigned long *syscall_table = NULL;
//unsigned long *syscall_table = (unsigned long *)0xffffffff81801400;
asmlinkage int (*original_open)(const char*, int flags, mode_t);
static int find_sys_call_table (char *kern_ver) {
char system_map_entry[MAX_VERSION_LEN];
int i = 0;
/*
* Holds the /boot/System.map-<version> file name as we build it
*/
char *filename;
/*
* Length of the System.map filename, terminating NULL included
*/
size_t filename_length = strlen(kern_ver) + strlen(BOOT_PATH) + 1;
/*
* This will point to our /boot/System.map-<version> file
*/
struct file *f = NULL;
mm_segment_t oldfs;
oldfs = get_fs();
set_fs (KERNEL_DS);
printk(KERN_EMERG "Kernel version: %s\n", kern_ver);
filename = kmalloc(filename_length, GFP_KERNEL);
if (filename == NULL) {
printk(KERN_EMERG "kmalloc failed on System.map-<version> filename allocation");
return -1;
}
/*
* Zero out memory to be safe
*/
memset(filename, 0, filename_length);
/*
* Construct our /boot/System.map-<version> file name
*/
strncpy(filename, BOOT_PATH, strlen(BOOT_PATH));
strncat(filename, kern_ver, strlen(kern_ver));
/*
* Open the System.map file for reading
*/
f = filp_open(filename, O_RDONLY, 0);
if (IS_ERR(f) || (f == NULL)) {
printk(KERN_EMERG "Error opening System.map-<version> file: %s\n", filename);
return -1;
}
memset(system_map_entry, 0, MAX_VERSION_LEN);
/*
* Read one byte at a time from the file until we either max out
* out our buffer or read an entire line.
*/
while (vfs_read(f, system_map_entry + i, 1, &f->f_pos) == 1) {
/*
* If we've read an entire line or maxed out our buffer,
* check to see if we've just read the sys_call_table entry.
*/
if ( system_map_entry[i] == '\n' || i == MAX_VERSION_LEN ) {
// Reset the "column"/"character" counter for the row
i = 0;
if (strstr(system_map_entry, "sys_call_table") != NULL) {
char *sys_string;
char *system_map_entry_ptr = system_map_entry;
sys_string = kmalloc(MAX_VERSION_LEN, GFP_KERNEL);
if (sys_string == NULL) {
filp_close(f, 0);
set_fs(oldfs);
kfree(filename);
return -1;
}
memset(sys_string, 0, MAX_VERSION_LEN);
strncpy(sys_string, strsep(&system_map_entry_ptr, " "), MAX_VERSION_LEN);
//syscall_table = (unsigned long long *) kstrtoll(sys_string, NULL, 16);
//syscall_table = kmalloc(sizeof(unsigned long *), GFP_KERNEL);
//syscall_table = kmalloc(sizeof(syscall_table), GFP_KERNEL);
kstrtoul(sys_string, 16, &syscall_table);
printk(KERN_EMERG "syscall_table retrieved\n");
kfree(sys_string);
break;
}
memset(system_map_entry, 0, MAX_VERSION_LEN);
continue;
}
i++;
}
filp_close(f, 0);
set_fs(oldfs);
kfree(filename);
return 0;
}
/*
* We have to pass in a pointer to a buffer to store the parsed
* version information in. If we declare a pointer to the
* parsed version info on the stack of this function, the
* pointer will disappear when the function ends and the
* stack frame is removed.
*/
char *acquire_kernel_version (char *buf) {
struct file *proc_version;
char *kernel_version;
/*
* We use this to store the userspace perspective of the filesystem
* so we can switch back to it after we are done reading the file
* into kernel memory
*/
mm_segment_t oldfs;
/*
* Standard trick for reading a file into kernel space
* This is very bad practice. We're only doing it here because
* we're malicious and don't give a damn about best practices.
*/
oldfs = get_fs();
set_fs (KERNEL_DS);
/*
* Open the version file in the /proc virtual filesystem
*/
proc_version = filp_open(PROC_V, O_RDONLY, 0);
if (IS_ERR(proc_version) || (proc_version == NULL)) {
return NULL;
}
/*
* Zero out memory just to be safe
*/
memset(buf, 0, MAX_VERSION_LEN);
/*
* Read version info from /proc virtual filesystem
*/
vfs_read(proc_version, buf, MAX_VERSION_LEN, &(proc_version->f_pos));
/*
* Extract the third field from the full version string
*/
kernel_version = strsep(&buf, " ");
kernel_version = strsep(&buf, " ");
kernel_version = strsep(&buf, " ");
filp_close(proc_version, 0);
/*
* Switch filesystem context back to user space mode
*/
set_fs(oldfs);
return kernel_version;
}
asmlinkage int new_open (const char* path, int flags, mode_t mode) {
//printk(KERN_EMERG "[+] open() hooked.");
printk(KERN_EMERG "%s\n",path);
//allow this file to be opened, produces a security hole if they can find the
//file, but since this is just a surface level locking it doesnt violate the
//main idea of this module
if(strcmp(path,CHECK_FILE)) return original_open(path, flags, mode);
//need to check the masterfile to see if it is a restricted file
mm_segment_t oldfs;
oldfs = get_fs();
struct file *f;
set_fs (KERNEL_DS);
f = filp_open(CHECK_FILE,O_RDONLY,0);
if(f){
int i = 0;
int count = 0;
char *buf = kmalloc(sizeof(char)*256, GFP_KERNEL);
//reading a char at a time, if | appears we know it is the end of the path
while (vfs_read(f, buf + i, 1, &f->f_pos) == 1) {
//if it is a end character then it is the end of the file and we need to
//deal with the last path
//we need to get the length of the path
if(buf[count] == "|" || "\0"){
//if it is null char then we know that was the last path
if(buf[count] == "\0"){
kfree(buf);
return original_open(path, flags, mode);
}
buf[count + 1] = "\0";
char str[count+1];
memcpy(str,buf,sizeof(char)*count+1);
//if the path is in the file then do not open it
if(strcmp(path,str)){
kfree(buf);
return 0;
}
count = 0;
}
i++;
}
kfree(buf);
}
return original_open(path, flags, mode);
}
static int __init onload(void) {
char *kernel_version = kmalloc(MAX_VERSION_LEN, GFP_KERNEL);
printk(KERN_WARNING "Hello world!\n");
// printk(KERN_EMERG "Version: %s\n", acquire_kernel_version(kernel_version));
find_sys_call_table(acquire_kernel_version(kernel_version));
printk(KERN_EMERG "Syscall table address: %p\n", syscall_table);
printk(KERN_EMERG "sizeof(unsigned long *): %zx\n", sizeof(unsigned long*));
printk(KERN_EMERG "sizeof(sys_call_table) : %zx\n", sizeof(syscall_table));
if (syscall_table != NULL) {
write_cr0 (read_cr0 () & (~ 0x10000));
original_open = (void *)syscall_table[__NR_open];
syscall_table[__NR_open] = &new_open;
write_cr0 (read_cr0 () | 0x10000);
printk(KERN_EMERG "[+] onload: sys_call_table hooked\n");
} else {
printk(KERN_EMERG "[-] onload: syscall_table is NULL\n");
}
kfree(kernel_version);
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
static void __exit onunload(void) {
if (syscall_table != NULL) {
write_cr0 (read_cr0 () & (~ 0x10000));
syscall_table[__NR_open] = original_open;
write_cr0 (read_cr0 () | 0x10000);
printk(KERN_EMERG "[+] onunload: sys_call_table unhooked\n");
} else {
printk(KERN_EMERG "[-] onunload: syscall_table is NULL\n");
}
printk(KERN_INFO "Goodbye world!\n");
}
module_init(onload);
module_exit(onunload);
This is the output I am getting when I try to open a file then check with the dmsg shell command:
ben#ubuntu:~/Documents/project/module$ dmsg
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 27, in <module>
from CommandNotFound.util import crash_guard
File "/usr/lib/python3/dist-packages/CommandNotFound/__init__.py", line 3, in <module>
from CommandNotFound.CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 7, in <module>
import dbm.gnu as gdbm
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1467, in exec_module
File "<frozen importlib._bootstrap>", line 1579, in get_code
File "<frozen importlib._bootstrap>", line 1639, in _cache_bytecode
File "<frozen importlib._bootstrap>", line 1663, in set_data
File "<frozen importlib._bootstrap>", line 110, in _write_atomic
ValueError: Negative filedescriptor
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 15, in <module>
import xml.dom, xml.dom.minidom
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1467, in exec_module
File "<frozen importlib._bootstrap>", line 1579, in get_code
File "<frozen importlib._bootstrap>", line 1639, in _cache_bytecode
File "<frozen importlib._bootstrap>", line 1663, in set_data
File "<frozen importlib._bootstrap>", line 110, in _write_atomic
ValueError: Negative filedescriptor
Original exception was:
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 27, in <module>
from CommandNotFound.util import crash_guard
File "/usr/lib/python3/dist-packages/CommandNotFound/__init__.py", line 3, in <module>
from CommandNotFound.CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 7, in <module>
import dbm.gnu as gdbm
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1467, in exec_module
File "<frozen importlib._bootstrap>", line 1579, in get_code
File "<frozen importlib._bootstrap>", line 1639, in _cache_bytecode
File "<frozen importlib._bootstrap>", line 1663, in set_data
File "<frozen importlib._bootstrap>", line 110, in _write_atomic
ValueError: Negative filedescriptor
I am confused as to what exactly is going wrong here and would very much appreciate some input! Thanks.
When I run the dmesg command this is the output:
[ 273.571654] /dev/:0
[ 273.571656] /dev/:1
[ 273.571659] /dev/pts/0
[ 273.571696] /var/run/utmp
[ 273.571709] /dev/:0
[ 273.571712] /dev/:1
[ 273.571715] /dev/pts/0
[ 273.571719] /var/run/utmp
[ 273.571731] /dev/:0
[ 273.571734] /dev/:1
[ 273.571736] /dev/pts/0
[ 273.571740] /var/run/utmp
[ 273.571752] /dev/:0
[ 273.571755] /dev/:1
[ 273.571758] /dev/pts/0
[ 273.571761] /var/run/utmp
[ 273.571773] /dev/:0
[ 273.571776] /dev/:1
[ 273.571779] /dev/pts/0
[ 273.571782] /var/run/utmp
[ 273.571794] /dev/:0
[ 273.571797] /dev/:1
[ 273.571800] /dev/pts/0
[ 273.571803] /var/run/utmp
[ 273.571816] /dev/:0
[ 273.571818] /dev/:1
[ 273.571821] /dev/pts/0
[ 273.571825] /var/run/utmp
[ 273.571837] /dev/:0
[ 273.571840] /dev/:1
[ 273.571843] /dev/pts/0
[ 273.571846] /var/run/utmp
[ 273.571859] /dev/:0
[ 273.571861] /dev/:1
[ 273.571864] /dev/pts/0
[ 273.571868] /var/run/utmp
[ 273.571880] /dev/:0
[ 273.571883] /dev/:1
[ 273.571886] /dev/pts/0
[ 273.571889] /var/run/utmp
[ 273.571913] /dev/:0
[ 273.571917] /dev/:1
[ 273.571920] /dev/pts/0
[ 273.571925] /var/run/utmp
[ 273.571937] /dev/:0
[ 273.571940] /dev/:1
[ 273.571943] /dev/pts/0
[ 273.571946] /var/run/utmp
[ 273.571959] /dev/:0
[ 273.571961] /dev/:1
[ 273.571964] /dev/pts/0
[ 273.571967] /var/run/utmp
[ 273.571980] /dev/:0
[ 273.571982] /dev/:1
[ 273.571985] /dev/pts/0
[ 273.571989] /var/run/utmp
[ 273.572001] /dev/:0
[ 273.572004] /dev/:1
[ 273.572006] /dev/pts/0
[ 273.572010] /var/run/utmp
[ 273.572023] /dev/:0
[ 273.572025] /dev/:1
[ 273.572028] /dev/pts/0
[ 273.572032] /var/run/utmp
[ 273.572044] /dev/:0
[ 273.572047] /dev/:1
[ 273.572049] /dev/pts/0
[ 273.572053] /var/run/utmp
[ 273.572066] /dev/:0
[ 273.572068] /dev/:1
[ 273.572071] /dev/pts/0
[ 273.572074] /var/run/utmp
[ 273.572087] /dev/:0
[ 273.572090] /dev/:1
[ 273.572092] /dev/pts/0
[ 273.572096] /var/run/utmp
[ 273.572108] /dev/:0
[ 273.572111] /dev/:1
[ 273.572113] /dev/pts/0
[ 273.572117] /var/run/utmp
[ 273.572129] /dev/:0
[ 273.572132] /dev/:1
[ 273.572135] /dev/pts/0
[ 273.572139] /var/run/utmp
[ 273.572151] /dev/:0
[ 273.572154] /dev/:1
[ 273.572156] /dev/pts/0
[ 273.572160] /var/run/utmp
[ 273.572172] /dev/:0
[ 273.572175] /dev/:1
[ 273.572178] /dev/pts/0
[ 273.572181] /var/run/utmp
[ 273.572194] /dev/:0
[ 273.572197] /dev/:1
[ 273.572199] /dev/pts/0
[ 273.572203] /var/run/utmp
[ 273.572215] /dev/:0
[ 273.572218] /dev/:1
[ 273.572221] /dev/pts/0
[ 273.572224] /var/run/utmp
[ 273.572237] /dev/:0
[ 273.572239] /dev/:1
[ 273.572242] /dev/pts/0
[ 273.572245] /var/run/utmp
[ 273.572258] /dev/:0
[ 273.572261] /dev/:1
[ 273.572263] /dev/pts/0
[ 273.572267] /var/run/utmp
[ 273.572279] /dev/:0
[ 273.572282] /dev/:1
[ 273.572284] /dev/pts/0
[ 273.572288] /var/run/utmp
[ 273.572300] /dev/:0
[ 273.572303] /dev/:1
[ 273.572306] /dev/pts/0
[ 273.572309] /var/run/utmp
[ 273.572322] /dev/:0
[ 273.572324] /dev/:1
[ 273.572327] /dev/pts/0
[ 273.572330] /var/run/utmp
[ 273.572343] /dev/:0
[ 273.572345] /dev/:1
[ 273.572348] /dev/pts/0
[ 273.572352] /var/run/utmp
[ 273.572364] /dev/:0
[ 273.572367] /dev/:1
[ 273.572369] /dev/pts/0
[ 273.572373] /var/run/utmp
[ 273.572385] /dev/:0
[ 273.572388] /dev/:1
[ 273.572390] /dev/pts/0
[ 273.572436] /var/run/utmp
[ 273.572451] /dev/:0
[ 273.572454] /dev/:1
[ 273.572456] /dev/pts/0
[ 273.572460] /var/run/utmp
[ 273.572473] /dev/:0
[ 273.572475] /dev/:1
[ 273.572478] /dev/pts/0
[ 273.572482] /var/run/utmp
[ 273.572494] /dev/:0
[ 273.572497] /dev/:1
[ 273.572500] /dev/pts/0
[ 273.572504] /var/run/utmp
[ 273.572516] /dev/:0
[ 273.572519] /dev/:1
[ 273.572521] /dev/pts/0
[ 273.572525] /var/run/utmp
[ 273.572538] /dev/:0
[ 273.572540] /dev/:1
[ 273.572543] /dev/pts/0
[ 273.572547] /var/run/utmp
[ 273.572559] /dev/:0
[ 273.572563] /dev/:1
[ 273.572566] /dev/pts/0
[ 273.572570] /var/run/utmp
[ 273.572582] /dev/:0
[ 273.572585] /dev/:1
[ 273.572587] /dev/pts/0
[ 273.572591] /var/run/utmp
[ 273.572603] /dev/:0
[ 273.572606] /dev/:1
[ 273.572609] /dev/pts/0
[ 273.572612] /var/run/utmp
[ 273.572625] /dev/:0
[ 273.572627] /dev/:1
[ 273.572630] /dev/pts/0
[ 273.572634] /var/run/utmp
[ 273.572646] /dev/:0
[ 273.572649] /dev/:1
[ 273.572651] /dev/pts/0
[ 273.572655] /var/run/utmp
[ 273.572667] /dev/:0
[ 273.572670] /dev/:1
[ 273.572672] /dev/pts/0
[ 273.572676] /var/run/utmp
[ 273.572689] /dev/:0
[ 273.572691] /dev/:1
[ 273.572694] /dev/pts/0
[ 273.572697] /var/run/utmp
[ 273.572710] /dev/:0
[ 273.572712] /dev/:1
[ 273.572715] /dev/pts/0
[ 273.572719] /var/run/utmp
[ 273.572731] /dev/:0
[ 273.572734] /dev/:1
[ 273.572736] /dev/pts/0
[ 273.572740] /var/run/utmp
[ 273.572752] /dev/:0
[ 273.572755] /dev/:1
[ 273.572757] /dev/pts/0
[ 273.572761] /var/run/utmp
[ 273.572773] /dev/:0
[ 273.572776] /dev/:1
[ 273.572778] /dev/pts/0
[ 273.572782] /var/run/utmp
[ 273.572794] /dev/:0
[ 273.572797] /dev/:1
[ 273.572799] /dev/pts/0
[ 273.572803] /var/run/utmp
[ 273.572815] /dev/:0
[ 273.572818] /dev/:1
[ 273.572820] /dev/pts/0
[ 273.572824] /var/run/utmp
[ 273.572836] /dev/:0
[ 273.572839] /dev/:1
[ 273.572842] /dev/pts/0
[ 273.572845] /var/run/utmp
[ 273.572857] /dev/:0
[ 273.572860] /dev/:1
[ 273.572863] /dev/pts/0
[ 273.572866] /var/run/utmp
[ 273.572879] /dev/:0
[ 273.572881] /dev/:1
[ 273.572884] /dev/pts/0
[ 273.572887] /var/run/utmp
[ 273.573006] /dev/:0
[ 273.573010] /dev/:1
[ 273.573013] /dev/pts/0
[ 273.573018] /var/run/utmp
[ 273.573031] /dev/:0
[ 273.573034] /dev/:1
[ 273.573037] /dev/pts/0
[ 273.573040] /var/run/utmp
[ 273.573053] /dev/:0
[ 273.573055] /dev/:1
[ 273.573058] /dev/pts/0
[ 273.573061] /var/run/utmp
[ 273.573074] /dev/:0
[ 273.573076] /dev/:1
[ 273.573079] /dev/pts/0
[ 273.573082] /var/run/utmp
[ 273.573095] /dev/:0
[ 273.573097] /dev/:1
[ 273.573100] /dev/pts/0
[ 273.573104] /var/run/utmp
[ 273.573116] /dev/:0
[ 273.573119] /dev/:1
[ 273.573121] /dev/pts/0
[ 273.573125] /var/run/utmp
[ 273.573137] /dev/:0
[ 273.573140] /dev/:1
[ 273.573143] /dev/pts/0
[ 273.573146] /var/run/utmp
[ 273.573159] /dev/:0
[ 273.573161] /dev/:1
[ 273.573164] /dev/pts/0
[ 273.573167] /var/run/utmp
[ 273.573180] /dev/:0
[ 273.573183] /dev/:1
[ 273.573185] /dev/pts/0
[ 273.573189] /var/run/utmp
[ 273.573201] /dev/:0
[ 273.573204] /dev/:1
[ 273.573206] /dev/pts/0
[ 273.573210] /var/run/utmp
[ 273.573222] /dev/:0
[ 273.573225] /dev/:1
[ 273.573228] /dev/pts/0
[ 273.573268] /var/run/utmp
[ 273.573281] /dev/:0
[ 273.573284] /dev/:1
[ 273.573287] /dev/pts/0
[ 273.573291] /var/run/utmp
[ 273.573303] /dev/:0
[ 273.573306] /dev/:1
[ 273.573309] /dev/pts/0
[ 273.573312] /var/run/utmp
[ 273.573325] /dev/:0
[ 273.573327] /dev/:1
[ 273.573330] /dev/pts/0
[ 273.573334] /var/run/utmp
[ 273.573346] /dev/:0
[ 273.573349] /dev/:1
[ 273.573352] /dev/pts/0
[ 273.573355] /var/run/utmp
[ 273.573368] /dev/:0
[ 273.573370] /dev/:1
[ 273.573373] /dev/pts/0
[ 273.573377] /var/run/utmp
[ 273.573389] /dev/:0
[ 273.573392] /dev/:1
[ 273.573407] /dev/pts/0
[ 273.573412] /var/run/utmp
[ 273.573425] /dev/:0
[ 273.573428] /dev/:1
[ 273.573431] /dev/pts/0
[ 273.573434] /var/run/utmp
[ 273.573447] /dev/:0
[ 273.573449] /dev/:1
[ 273.573452] /dev/pts/0
[ 273.573456] /var/run/utmp
[ 273.573468] /dev/:0
[ 273.573471] /dev/:1
[ 273.573474] /dev/pts/0
[ 273.573477] /var/run/utmp
[ 273.573490] /dev/:0
[ 273.573493] /dev/:1
[ 273.573495] /dev/pts/0
[ 273.573499] /var/run/utmp
[ 273.573511] /dev/:0
[ 273.573514] /dev/:1
[ 273.573517] /dev/pts/0
[ 273.573520] /var/run/utmp
[ 273.573533] /dev/:0
[ 273.573535] /dev/:1
[ 273.573538] /dev/pts/0
[ 273.573542] /var/run/utmp
[ 273.573554] /dev/:0
[ 273.573557] /dev/:1
[ 273.573560] /dev/pts/0
[ 273.573563] /var/run/utmp
[ 273.573576] /dev/:0
[ 273.573578] /dev/:1
[ 273.573581] /dev/pts/0
[ 273.573585] /var/run/utmp
[ 273.573597] /dev/:0
[ 273.573600] /dev/:1
[ 273.573602] /dev/pts/0
[ 273.573606] /var/run/utmp
[ 273.573618] /dev/:0
[ 273.573621] /dev/:1
[ 273.573624] /dev/pts/0
[ 273.573627] /var/run/utmp
[ 273.573640] /dev/:0
[ 273.573643] /dev/:1
[ 273.573645] /dev/pts/0
[ 273.573649] /var/run/utmp
[ 273.573661] /dev/:0
[ 273.573664] /dev/:1
[ 273.573667] /dev/pts/0
[ 273.573670] /var/run/utmp
[ 273.573683] /dev/:0
[ 273.573686] /dev/:1
[ 273.573688] /dev/pts/0
[ 273.573692] /var/run/utmp
[ 273.573704] /dev/:0
[ 273.573707] /dev/:1
[ 273.573710] /dev/pts/0
[ 273.573713] /var/run/utmp
[ 273.573726] /dev/:0
[ 273.573728] /dev/:1
[ 273.573731] /dev/pts/0
[ 273.573735] /var/run/utmp
[ 273.573747] /dev/:0
[ 273.573750] /dev/:1
[ 273.573752] /dev/pts/0
[ 273.573756] /var/run/utmp
[ 273.573769] /dev/:0
[ 273.573771] /dev/:1
[ 273.573774] /dev/pts/0
[ 273.573778] /var/run/utmp
[ 273.573790] /dev/:0
[ 273.573793] /dev/:1
[ 273.573795] /dev/pts/0
[ 273.573799] /var/run/utmp
[ 273.573811] /dev/:0
[ 273.573814] /dev/:1
[ 273.573817] /dev/pts/0
[ 273.573820] /var/run/utmp
[ 273.573833] /dev/:0
[ 273.573835] /dev/:1
[ 273.573838] /dev/pts/0
[ 273.573841] /var/run/utmp
[ 273.573862] /dev/:0
[ 273.573865] /dev/:1
[ 273.573867] /dev/pts/0
[ 273.573871] /var/run/utmp
[ 273.573883] /dev/:0
[ 273.573885] /dev/:1
[ 273.573888] /dev/pts/0
[ 273.573891] /var/run/utmp
[ 273.573924] /dev/:0
[ 273.573930] /dev/:1
[ 273.573934] /dev/pts/0
[ 273.573940] /var/run/utmp
[ 273.573953] /dev/:0
[ 273.573956] /dev/:1
[ 273.573968] /dev/pts/0
[ 273.573971] /var/run/utmp
[ 273.574003] /dev/:0
[ 273.574006] /dev/:1
[ 273.574008] /dev/pts/0
[ 273.574022] /var/run/utmp
[ 273.574044] /dev/:0
[ 273.574046] /dev/:1
[ 273.574049] /dev/pts/0
[ 273.574136] /var/run/utmp
[ 273.574159] /dev/:0
[ 273.574172] /dev/:1
[ 273.574175] /dev/pts/0
[ 273.574179] /var/run/utmp
[ 273.574211] /dev/:0
[ 273.574213] /dev/:1
[ 273.574216] /dev/pts/0
[ 273.574229] /var/run/utmp
[ 273.574252] /dev/:0
[ 273.574264] /dev/:1
[ 273.574266] /dev/pts/0
[ 273.574270] /var/run/utmp
[ 273.574304] /dev/:0
[ 273.574306] /dev/:1
[ 273.574309] /dev/pts/0
[ 273.574322] /var/run/utmp
[ 273.574344] /dev/:0
[ 273.574347] /dev/:1
[ 273.574359] /dev/pts/0
[ 273.574363] /var/run/utmp
[ 273.574385] /dev/:0
[ 273.574398] /dev/:1
[ 273.574400] /dev/pts/0
[ 273.574404] /var/run/utmp
[ 273.574427] /dev/:0
[ 273.574432] /dev/:1
[ 273.574434] /dev/pts/0
[ 273.574439] /var/run/utmp
[ 273.574452] /dev/:0
[ 273.574454] /dev/:1
[ 273.574457] /dev/pts/0
[ 273.574460] /var/run/utmp
[ 273.574473] /dev/:0
[ 273.574475] /dev/:1
[ 273.574478] /dev/pts/0
[ 273.574482] /var/run/utmp
[ 273.574494] /dev/:0
[ 273.574497] /dev/:1
[ 273.574499] /dev/pts/0
[ 273.574503] /var/run/utmp
[ 273.574515] /dev/:0
[ 273.574518] /dev/:1
[ 273.574520] /dev/pts/0
[ 273.574524] /var/run/utmp
[ 273.574536] /dev/:0
[ 273.574539] /dev/:1
[ 273.574542] /dev/pts/0
[ 273.574545] /var/run/utmp
[ 273.574558] /dev/:0
[ 273.574560] /dev/:1
[ 273.574563] /dev/pts/0
[ 273.574566] /var/run/utmp
[ 273.574579] /dev/:0
[ 273.574581] /dev/:1
[ 273.574584] /dev/pts/0
[ 273.574587] /var/run/utmp
[ 273.574600] /dev/:0
[ 273.574603] /dev/:1
[ 273.574605] /dev/pts/0
[ 273.574609] /var/run/utmp
[ 273.574621] /dev/:0
//part omitted due to character restriction
[ 273.574733] /dev/pts/0
[ 273.574737] /var/run/utmp
[ 273.574749] /dev/:0
[ 273.574752] /dev/:1
[ 273.574754] /dev/pts/0
[ 273.574758] /var/run/utmp
[ 273.574770] /dev/:0
[ 273.574773] /dev/:1
[ 273.574775] /dev/pts/0
[ 273.574779] /var/run/utmp
[ 273.574791] /dev/:0
[ 273.574794] /dev/:1
[ 273.574797] /dev/pts/0
[ 273.574800] /var/run/utmp
[ 273.574813] /dev/:0
[ 273.574815] /dev/:1
[ 273.574818] /dev/pts/0
[ 273.574821] /var/run/utmp
[ 273.574834] /dev/:0
[ 273.574836] /dev/:1
[ 273.574839] /dev/pts/0
[ 273.574843] /var/run/utmp
[ 273.574855] /dev/:0
[ 273.574858] /dev/:1
[ 273.574860] /dev/pts/0
[ 273.574864] /var/run/utmp
[ 273.574876] /dev/:0
[ 273.574879] /dev/:1
[ 273.574881] /dev/pts/0
[ 273.574894] /var/run/utmp
[ 273.574910] /dev/:0
[ 273.574913] /dev/:1
[ 273.574915] /dev/pts/0
[ 273.574920] /var/run/utmp
[ 273.574932] /dev/:0
[ 273.574935] /dev/:1
[ 273.574937] /dev/pts/0
[ 273.574941] /var/run/utmp
[ 273.577004] /etc/ld.so.cache
[ 273.577018] /lib/x86_64-linux-gnu/libc.so.6
[ 273.577182] /usr/lib/locale/locale-archive
i'm implementing an application on top of KVM in which I need to trap writes to CR3.
When I do this when handling a VM EXIT using: vmcs_set_bits(CPU_BASED_VM_EXEC_CONTROL, CPU_BASED_CR3_LOAD_EXITING), it works correctly and I can see the traps in my log file.
Now when I do the same thing after receiving a command from Qemu (command is handled in kvm_vm_ioctl by calling a function I added to kvm_x86_ops vmx_x86_ops) I get a vmwrite error.
Here after the error log:
[ 290.559474] start_vmi
[ 290.559477] vmi: vmx.c: vmx_vmi_start_cr3_store_trapping: vmcs_read32(CPU_BASED_VM_EXEC_CONTROL) & CPU_BASED_CR3_LOAD_EXITING = 0
[ 290.559480] vmwrite error: reg 4002 value c002 (err 16386)
[ 290.559485] CPU: 0 PID: 3376 Comm: qemu-system-i38 Tainted: GF O 3.13.0-32-generic #57~precise1-Ubuntu
[ 290.559513] Call Trace:
[ 290.559525] [<c1680147>] dump_stack+0x41/0x52
[ 290.559533] [<f89f289a>] vmwrite_error+0x35/0x3b [kvm_intel]
[ 290.559538] [<f89e6b95>] vmcs_writel+0x25/0x30 [kvm_intel]
[ 290.559542] [<f89e6c27>] vmcs_set_bits+0x27/0x40 [kvm_intel]
[ 290.559547] [<f89e6c83>] vmx_vmi_start_cr3_store_trapping+0x43/0x50 [kvm_intel]
[ 290.559564] [<fbf861a5>] kvm_vm_ioctl+0x3b5/0x740 [kvm]
[ 290.559570] [<c1150747>] ? __handle_mm_fault+0x127/0x280
[ 290.559574] [<c115093a>] ? handle_mm_fault+0x9a/0x150
[ 290.559580] [<c168ec77>] ? __do_page_fault+0x287/0x520
[ 290.559593] [<fbf85df0>] ? kvm_vm_release+0x20/0x20 [kvm]
[ 290.559600] [<c1194ae2>] do_vfs_ioctl+0x72/0x2e0
[ 290.559604] [<c1194de7>] SyS_ioctl+0x97/0xa0
[ 290.559609] [<c1692b4d>] sysenter_do_call+0x12/0x28
[ 290.559614] [<c1680000>] ? cfq_arm_slice_timer+0x14e/0x254
Does anyone has an idea why what's the problem ? I would be very grateful if there is any answer