mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 18:21:39 +01:00
This changeset contains all differences between xen-unstable.hg and xen-unstable-hvm.hg. All information and comments for changesets unique to xen-unstable-hvm.hg are included below. Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> Signed-off-by: Keir Fraser <keir@xensource.com> > user: leendert@eserver2.watson.ibm.com > date: Tue Jan 31 04:29:51 2006 -0400 > files: xen/include/asm-ia64/mm.h > description: > Fix ia64 compile. > > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Tue Jan 31 02:21:49 2006 -0400 > files: xen/include/xen/domain_page.h > description: > Eliminate unused fields (pfn,va) warnings. > > Signed-Off-By: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Fri Jan 27 04:31:44 2006 -0400 > files: tools/python/xen/xend/image.py > description: > Name cleanup. vmx refers to VT-x specific code, HVM is used for all others. > > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: root@xen-trw1.amd.com > date: Sun Jan 22 18:39:58 2006 -0500 > files: xen/arch/x86/hvm/platform.c > description: > support prefix 0x67 in hvm decode logic, gfxboot patch causes 0x67 prefix. > > > user: twoller@xen-trw1.amd.com > date: Sun Jan 22 18:35:59 2006 -0500 > files: xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/svm/vmcb.c xen/include/asm-x86/hvm/svm/svm.h > description: > check for valid shared_page_va/vmcb before deallocating in SVM. > > > user: leendert@eserver2.watson.ibm.com > date: Sun Jan 22 02:56:20 2006 -0400 > files: xen/include/asm-x86/hvm/svm/svm.h xen/include/asm-x86/hvm/svm/vmmcall.h > description: > Some SVM header file cleanups. > > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Fri Jan 20 11:50:23 2006 -0400 > files: xen/arch/x86/domain.c > description: > Need to be more diligent about when to call into the HVM abstraction layer > and when not. > > Signed-Off-By: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Wed Jan 18 15:14:56 2006 -0400 > files: xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/svm/x86_32/exits.S xen/arch/x86/hvm/svm/x86_64/exits.S xen/arch/x86/hvm/vmx/x86_32/exits.S xen/arch/x86/hvm/vmx/x86_64/exits.S > description: > Added missing copyright statements and updated svm.c's copyright to properly > reflect that it was derived from vmx.c. > > Signed-Off-By: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Tue Jan 17 09:42:11 2006 -0400 > files: xen/arch/ia64/Makefile xen/arch/ia64/vmx/vlsapic.c xen/arch/ia64/vmx/vmx_init.c xen/include/asm-ia64/vmx_platform.h > description: > Make sure ia64 builds again with the new directory structure. > > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@localhost.localdomain > date: Tue Jan 17 08:28:51 2006 -0400 > files: xen/arch/x86/Makefile xen/arch/x86/hvm/i8259.c xen/arch/x86/hvm/vioapic.c > description: > The device models now belong in hvm. > > Signed-ff-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Sun Jan 15 16:40:58 2006 -0400 > files: xen/arch/x86/Makefile xen/arch/x86/cpu/amd.c xen/arch/x86/cpu/intel.c xen/arch/x86/dm/hvm_vioapic.c xen/arch/x86/dm/i8259.c xen/arch/x86/dom0_ops.c xen/arch/x86/domain.c xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/intercept.c xen/arch/x86/hvm/io.c xen/arch/x86/hvm/platform.c xen/arch/x86/hvm/svm/emulate.c xen/arch/x86/hvm/svm/instrlen.c xen/arch/x86/hvm/svm/intr.c xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/svm/vmcb.c xen/arch/x86/hvm/svm/x86_32/exits.S xen/arch/x86/hvm/svm/x86_64/exits.S xen/arch/x86/hvm/vlapic.c xen/arch/x86/hvm/vmx/io.c xen/arch/x86/hvm/vmx/vmcs.c xen/arch/x86/hvm/vmx/vmx.c xen/arch/x86/hvm/vmx/x86_32/exits.S xen/arch/x86/hvm/vmx/x86_64/exits.S xen/arch/x86/i387.c xen/arch/x86/x86_32/entry.S xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/entry.S xen/arch/x86/x86_64/traps.c xen/include/asm-x86/domain.h xen/include/asm-x86/hvm/domain.h xen/include/asm-x86/hvm/hvm.h xen/include/asm-x86/hvm/io.h xen/include/asm-x86/hvm/support.h xen/include/asm-x86/hvm/svm/emulate.h xen/include/asm-x86/hvm/svm/intr.h xen/include/asm-x86/hvm/svm/svm.h xen/include/asm-x86/hvm/svm/vmcb.h xen/include/asm-x86/hvm/svm/vmmcall.h xen/include/asm-x86/hvm/vcpu.h xen/include/asm-x86/hvm/vioapic.h xen/include/asm-x86/hvm/vlapic.h xen/include/asm-x86/hvm/vmx/cpu.h xen/include/asm-x86/hvm/vmx/vmcs.h xen/include/asm-x86/hvm/vmx/vmx.h xen/include/asm-x86/hvm/vpic.h xen/include/asm-x86/hvm/vpit.h xen/include/asm-x86/shadow.h > description: > As suggested by Keir, I restructured the hvm/vmx/svm tree. The new > directory structure looks like: > > xen/arch/hvm/ > xen/arch/hvm/vmx > xen/arch/hvm/vmx/x86_32 > xen/arch/hvm/vmx/x86_64 > xen/arch/hvm/svm > xen/arch/hvm/svm/x86_32 > xen/arch/hvm/svm/x86_64 > > xen/include/hvm/ > xen/include/hvm/vmx > xen/include/hvm/svm > > Many files have been renamed and had their hvm_/vmx_/svm_ suffix removed > because this is now clear from the directory where the file resides. > > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Sat Jan 14 17:03:28 2006 -0400 > files: xen/arch/ia64/vmx/vlsapic.c xen/include/asm-ia64/vmx_platform.h > description: > Name change fix for ia64. > > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Sat Jan 14 15:12:59 2006 -0400 > files: xen/arch/x86/dm/hvm_vioapic.c xen/arch/x86/dm/i8259.c xen/arch/x86/hvm.c xen/arch/x86/hvm_intercept.c xen/arch/x86/svm.c xen/arch/x86/svm_intr.c xen/arch/x86/svm_vmcb.c xen/arch/x86/vmx.c xen/arch/x86/vmx_io.c xen/arch/x86/vmx_vmcs.c xen/include/asm-x86/hvm_domain.h xen/include/asm-x86/hvm_vcpu.h > description: > Move VMX/SVM print buffer to hvm_domain. > > Cleanup variable names. The suffix hvm_ is redundant in hvm_domain. > > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: twoller@xen-trw1.site > date: Fri Jan 13 17:03:18 2006 -0500 > files: xen/arch/x86/svm.c > description: > remove unnecessary spin_unlock in asid_fetch code for svm. > > > user: twoller@xen-trw1.site > date: Wed Jan 11 20:00:36 2006 -0500 > files: xen/arch/x86/svm.c > description: > remove unneeded update_pagetables() during svm PF handling (resolved with ASID code rework). > > > user: leendert@eserver2.watson.ibm.com > date: Tue Jan 10 02:45:32 2006 -0400 > files: xen/arch/x86/hvm.c xen/arch/x86/vmx_io.c > description: > Factor out cpu_get_interrupt(). It is used by VMX and SVM. > > Signed-Off-By: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Mon Jan 9 00:03:30 2006 -0400 > files: xen/arch/x86/hvm.c xen/arch/x86/svm.c xen/arch/x86/vmx.c xen/include/asm-x86/hvm_support.h xen/include/asm-x86/hvm_vcpu.h > description: > Introduce small print buffer per domain rather than a single global one. > > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Sun Jan 8 23:07:12 2006 -0400 > files: xen/arch/x86/dom0_ops.c xen/include/asm-x86/hvm_support.h xen/include/public/arch-x86_32.h xen/include/public/arch-x86_64.h > description: > More cleanup. There is no point in distinguishing between SVM and VMX, > a single HVM flag bit suffices. > > Signed-Off-By: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Sun Jan 8 12:05:59 2006 -0400 > files: xen/arch/x86/svm.c xen/arch/x86/vmx.c > description: > Both VMX & SVM now print writes to the debug port (0xE9) on the console. > > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Sat Jan 7 13:55:27 2006 -0400 > files: xen/arch/x86/svm.c xen/arch/x86/svm_intr.c xen/arch/x86/svm_vmcb.c xen/arch/x86/vmx.c xen/arch/x86/vmx_io.c xen/arch/x86/vmx_vmcs.c xen/arch/x86/x86_32/asm-offsets.c xen/arch/x86/x86_64/asm-offsets.c xen/include/asm-x86/domain.h xen/include/asm-x86/vmx.h > description: > Introduce shorthands to improve code legibility. > > Signed-Off-By: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Wed Jan 4 06:12:10 2006 -0400 > files: tools/examples/xmexample.hvm > description: > Minor spelling mistakes. > > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Wed Jan 4 03:37:55 2006 -0400 > files: xen/include/public/hvm/hvm_info_table.h xen/include/public/hvm/ioreq.h xen/include/public/hvm/vmx_assist.h > description: > Missed adding new files. > > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Mon Jan 2 01:23:54 2006 -0400 > files: tools/debugger/libxendebug/xendebug.c tools/libxc/xc_hvm_build.c > description: > Finalize Xin Li's patch: vmx/svm_identify is no longer necessary. > Xen debug should test for HVM instead of VMX. > > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: twoller@xen-trw1.site > date: Sun Jan 1 03:22:39 2006 -0500 > files: tools/ioemu/vl.c > description: > change hardcoded VTXEN to HVMXEN. > > > user: leendert@eserver2.watson.ibm.com > date: Sun Jan 1 02:22:47 2006 -0400 > files: tools/libxc/xc_hvm_build.c tools/python/xen/xend/image.py xen/arch/x86/domain.c > description: > Avoid xen crash if there is no VMX support. If a platform > doesn't support VMX, creating VMX domain will crash xen > HV. > > Signed-off-by: Xin Li <xin.b.li@intel.com> > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > [ vmx/svm_identify are still needed in hvm builder, but this may not > really be necessary. I need to check this. - lvd ] > > > user: twoller@xen-trw1.site > date: Fri Dec 30 21:38:56 2005 -0500 > files: xen/arch/x86/svm.c xen/arch/x86/svm_vmcb.c xen/arch/x86/x86_32/entry.S xen/include/asm-x86/svm.h xen/include/asm-x86/svm_vmcb.h > description: > add multi-core support for guest ASIDs for SVM partitions. > > > user: leendert@eserver2.watson.ibm.com > date: Sun Dec 25 20:44:43 2005 -0400 > files: tools/firmware/vmxassist/head.S > description: > Make sure vmxassist still works in its debug environment. > > Signed-Off-By: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Fri Dec 23 18:27:57 2005 -0400 > files: tools/libxc/xc_ia64_stubs.c > description: > Fixed libxc ia64, xend uses xc_hvm_build instead of xc_vmx_build. > > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: twoller@xen-trw1.site > date: Wed Dec 21 21:39:17 2005 -0500 > files: xen/arch/x86/svm_intr.c xen/arch/x86/svm_vmcb.c > description: > cleanup of svm specific code. > > > user: leendert@eserver2.watson.ibm.com > date: Wed Dec 21 17:18:25 2005 -0400 > files: tools/python/xen/xm/tests/test_create.py tools/xm-test/README > description: > Minor name cleanups. xm-test isn't VMX specific. Instead use HVM. > > > user: twoller@xen-trw1.site > date: Tue Dec 20 20:01:38 2005 -0500 > files: xen/arch/x86/svm_vmcb.c > description: > reword comments. > > > user: twoller@xen-trw1.site > date: Tue Dec 20 20:01:07 2005 -0500 > files: xen/arch/x86/svm_intr.c > description: > add additional VLAPIC delivery modes. > > > user: twoller@xen-trw1.site > date: Tue Dec 20 20:00:22 2005 -0500 > files: xen/arch/x86/svm.c > description: > reformat misaligned code. > > > user: twoller@xen-trw1.site > date: Tue Dec 20 19:59:37 2005 -0500 > files: xen/arch/x86/svm.c > description: > Add additional AMD SVM specific CPUID logic. > > > user: leendert@eserver2.watson.ibm.com > date: Thu Dec 15 03:06:15 2005 -0400 > files: tools/xm-test/tests/block-create/01_block_attach_device_pos.py tools/xm-test/tests/block-create/02_block_attach_file_device_pos.py tools/xm-test/tests/block-create/04_block_attach_device_repeatedly_pos.py tools/xm-test/tests/block-create/05_block_attach_and_dettach_device_repeatedly_pos.py tools/xm-test/tests/block-create/06_block_attach_baddomain_neg.py tools/xm-test/tests/block-create/07_block_attach_baddevice_neg.py tools/xm-test/tests/block-create/08_block_attach_bad_filedevice_neg.py tools/xm-test/tests/block-create/09_block_attach_and_dettach_device_check_data_pos.py tools/xm-test/tests/block-create/10_block_attach_dettach_multiple_devices.py tools/xm-test/tests/block-create/11_block_attach_shared_dom0.py tools/xm-test/tests/block-create/12_block_attach_shared_domU.py tools/xm-test/tests/block-destroy/01_block-destroy_btblock_pos.py tools/xm-test/tests/block-destroy/02_block-destroy_rtblock_pos.py tools/xm-test/tests/block-destroy/04_block-destroy_nonattached_neg.py tools/xm-test/tests/block-destroy/05_block-destroy_byname_pos.py tools/xm-test/tests/block-destroy/06_block-destroy_check_list_pos.py tools/xm-test/tests/block-list/01_block-list_pos.py tools/xm-test/tests/block-list/02_block-list_attachbd_pos.py tools/xm-test/tests/block-list/03_block-list_anotherbd_pos.py tools/xm-test/tests/block-list/04_block-list_nodb_pos.py tools/xm-test/tests/block-list/06_block-list_checkremove_pos.py tools/xm-test/tests/memmax/01_memmax_badparm_neg.py tools/xm-test/tests/memset/01_memset_basic_pos.py tools/xm-test/tests/memset/02_memset_badparm_neg.py tools/xm-test/tests/memset/03_memset_random_pos.py tools/xm-test/tests/memset/04_memset_smallmem_pos.py tools/xm-test/tests/migrate/01_migrate_localhost_pos.py tools/xm-test/tests/network-attach/01_network_attach_pos.py tools/xm-test/tests/network-attach/02_network_attach_detach_pos.py tools/xm-test/tests/network-attach/03_network_attach_detach_multiple_pos.py tools/xm-test/tests/restore/01_restore_basic_pos.py tools/xm-test/tests/restore/02_restore_badparm_neg.py tools/xm-test/tests/restore/03_restore_badfilename_neg.py tools/xm-test/tests/restore/04_restore_withdevices_pos.py tools/xm-test/tests/save/01_save_basic_pos.py tools/xm-test/tests/save/02_save_badparm_neg.py tools/xm-test/tests/save/03_save_bogusfile_neg.py tools/xm-test/tests/sysrq/01_sysrq_basic_neg.py tools/xm-test/tests/sysrq/02_sysrq_sync_pos.py tools/xm-test/tests/sysrq/03_sysrq_withreboot_pos.py > description: > Adding SKIP() to tests that aren't supported for VMX domains. > > Signed-off-by: Dan Stekloff <dsteklof@us.ibm.com> > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Tue Dec 13 22:43:47 2005 -0400 > files: xen/arch/x86/svm.c xen/arch/x86/vmx.c xen/arch/x86/vmx_io.c xen/include/asm-x86/hvm_vpit.h xen/include/asm-x86/msr.h > description: > Support VMX guest accesses to IA32_TIME_STAMP_COUNTER MSR. > > Signed-off-by: Haifeng Xue <haifeng.xue@intel.com> > Signed-off-by: Leendert van Doorn <leendert@us.ibm.com> > > > user: twoller@xen-trw1.site > date: Tue Dec 13 19:49:53 2005 -0500 > files: xen/arch/x86/svm.c xen/arch/x86/svm_emulate.c xen/arch/x86/svm_instrlen.c xen/arch/x86/svm_intr.c xen/arch/x86/svm_vmcb.c xen/include/asm-x86/svm.h xen/include/asm-x86/svm_emulate.h xen/include/asm-x86/svm_intr.h xen/include/asm-x86/svm_vmcb.h xen/include/asm-x86/svm_vmmcall.h > description: > Add SVM base files to repository. > > > user: twoller@xen-trw1.site > date: Tue Dec 13 19:49:02 2005 -0500 > files: xen/arch/x86/x86_32/entry.S xen/arch/x86/x86_64/entry.S > description: > Add SVM entry points for launch/resume. > > > user: twoller@xen-trw1.site > date: Tue Dec 13 19:47:38 2005 -0500 > files: .hgignore > description: > Add hvmloader files to ignore list. > > > user: leendert@eserver2.watson.ibm.com > date: Mon Dec 12 22:58:54 2005 -0400 > files: docs/src/user.tex tools/firmware/README xen/include/asm-x86/hvm.h > description: > Removed dirty words (by request). > > > user: leendert@eserver2.watson.ibm.com > date: Mon Dec 12 05:48:22 2005 -0400 > files: tools/firmware/hvmloader/mkhex > description: > Fix file mode. > > Signed-off-by: Leendert van Doorn <leendert@watson.ibm.com> > > > user: leendert@eserver2.watson.ibm.com > date: Mon Dec 12 04:50:42 2005 -0400 > files: xen/Rules.mk xen/arch/x86/cpu/amd.c xen/arch/x86/cpu/intel.c xen/arch/x86/dm/hvm_vioapic.c xen/arch/x86/dm/i8259.c xen/arch/x86/dom0_ops.c xen/arch/x86/domain.c xen/arch/x86/hvm.c xen/arch/x86/hvm_intercept.c xen/arch/x86/hvm_io.c xen/arch/x86/hvm_platform.c xen/arch/x86/hvm_vlapic.c xen/arch/x86/mpparse.c xen/arch/x86/shadow.c xen/arch/x86/vmx.c xen/arch/x86/vmx_io.c xen/arch/x86/vmx_vmcs.c xen/arch/x86/x86_32/asm-offsets.c xen/arch/x86/x86_32/entry.S xen/arch/x86/x86_64/asm-offsets.c xen/arch/x86/x86_64/entry.S xen/arch/x86/x86_64/mm.c xen/include/asm-x86/config.h xen/include/asm-x86/cpufeature.h xen/include/asm-x86/domain.h xen/include/asm-x86/hvm_domain.h xen/include/asm-x86/hvm_io.h xen/include/asm-x86/hvm_support.h xen/include/asm-x86/hvm_vcpu.h xen/include/asm-x86/hvm_vioapic.h xen/include/asm-x86/hvm_vlapic.h xen/include/asm-x86/hvm_vpic.h xen/include/asm-x86/hvm_vpit.h xen/include/asm-x86/mpspec.h xen/include/asm-x86/msr.h xen/include/asm-x86/processor.h xen/include/asm-x86/vmx.h xen/include/asm-x86/vmx_cpu.h xen/include/asm-x86/vmx_vmcs.h > description: > Phase 3 of HVM integration: This patchset introduces the refactoring of > virtualization architecture independent functions from specific ones. > > > user: leendert@eserver2.watson.ibm.com > date: Sun Dec 11 07:02:51 2005 -0400 > files: xen/arch/x86/dom0_ops.c xen/arch/x86/domain.c xen/arch/x86/i387.c xen/arch/x86/shadow.c xen/arch/x86/vmx.c xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/traps.c xen/include/asm-x86/hvm.h xen/include/asm-x86/hvm_support.h xen/include/asm-x86/regs.h xen/include/asm-x86/shadow.h xen/include/asm-x86/vmx_vmcs.h > description: > Phase 2 of HVM integration: This patchset introduces the hvm interface > to the hypervisor and modifies all the non-vmx specific files to use it. > > > user: leendert@eserver2.watson.ibm.com > date: Sun Dec 11 01:10:00 2005 -0400 > files: tools/examples/Makefile tools/examples/README tools/examples/xmexample.hvm tools/ioemu/exec-all.h tools/ioemu/hw/i8254.c tools/ioemu/hw/i8259.c tools/ioemu/monitor.c tools/ioemu/target-i386-dm/helper2.c tools/ioemu/vl.c tools/libxc/Makefile tools/libxc/xc_hvm_build.c tools/libxc/xc_ptrace.c tools/libxc/xc_ptrace_core.c tools/libxc/xenguest.h tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/image.py tools/python/xen/xm/create.py tools/xm-test/configure.ac tools/xm-test/lib/XmTestLib/XenDomain.py tools/xm-test/lib/XmTestLib/config.py.in tools/xm-test/ramdisk/Makefile.am tools/xm-test/ramdisk/bin/create_disk_image tools/xm-test/tests/block-list/04_block-list_nodb_pos.py xen/include/public/arch-x86_32.h xen/include/public/arch-x86_64.h > description: > Phase 1 of HVM integration: This patchset updates the tools. Most of the > tools are machine independent except for some detection code in the hvm > domain builder.
599 lines
15 KiB
C
599 lines
15 KiB
C
/*
|
|
* xendebug.c
|
|
*
|
|
* alex ho
|
|
* http://www.cl.cam.ac.uk/netos/pdb
|
|
*
|
|
* xendebug_memory_page adapted from xc_ptrace.c
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include <sys/mman.h>
|
|
#include <xenctrl.h>
|
|
#include "list.h"
|
|
|
|
#if defined(__i386__)
|
|
#define L1_PAGETABLE_SHIFT 12
|
|
#define L2_PAGETABLE_SHIFT 22
|
|
#elif defined(__x86_64__)
|
|
#define L1_PAGETABLE_SHIFT 12
|
|
#define L2_PAGETABLE_SHIFT 21
|
|
#define L3_PAGETABLE_SHIFT 30
|
|
#define L4_PAGETABLE_SHIFT 39
|
|
#endif
|
|
|
|
#define PAGE_SHIFT L1_PAGETABLE_SHIFT
|
|
#define PAGE_SIZE (1UL<<PAGE_SHIFT)
|
|
#define PAGE_MASK (~(PAGE_SIZE - 1))
|
|
|
|
/* from xen/include/asm-x86/processor.h */
|
|
#define X86_EFLAGS_TF 0x00000100 /* Trap Flag */
|
|
|
|
typedef int boolean;
|
|
#define true 1
|
|
#define false 0
|
|
|
|
|
|
typedef struct bwcpoint /* break/watch/catch point */
|
|
{
|
|
struct list_head list;
|
|
unsigned long address;
|
|
uint32_t domain;
|
|
uint8_t old_value; /* old value for software bkpt */
|
|
} bwcpoint_t, *bwcpoint_p;
|
|
|
|
static bwcpoint_t bwcpoint_list;
|
|
|
|
|
|
|
|
typedef struct domain_context /* local cache of domain state */
|
|
{
|
|
struct list_head list;
|
|
uint32_t domid;
|
|
boolean valid[MAX_VIRT_CPUS];
|
|
vcpu_guest_context_t context[MAX_VIRT_CPUS];
|
|
|
|
long total_pages;
|
|
unsigned long *page_array;
|
|
|
|
unsigned long cr3_phys[MAX_VIRT_CPUS];
|
|
unsigned long *cr3_virt[MAX_VIRT_CPUS];
|
|
unsigned long pde_phys[MAX_VIRT_CPUS];
|
|
unsigned long *pde_virt[MAX_VIRT_CPUS];
|
|
unsigned long page_phys[MAX_VIRT_CPUS];
|
|
unsigned long *page_virt[MAX_VIRT_CPUS];
|
|
int page_perm[MAX_VIRT_CPUS];
|
|
} domain_context_t, *domain_context_p;
|
|
|
|
static domain_context_t domain_context_list;
|
|
|
|
/* initialization */
|
|
|
|
static boolean xendebug_initialized = false;
|
|
|
|
static __inline__ void
|
|
xendebug_initialize()
|
|
{
|
|
if ( !xendebug_initialized )
|
|
{
|
|
memset((void *) &domain_context_list, 0, sizeof(domain_context_t));
|
|
INIT_LIST_HEAD(&domain_context_list.list);
|
|
|
|
memset((void *) &bwcpoint_list, 0, sizeof(bwcpoint_t));
|
|
INIT_LIST_HEAD(&bwcpoint_list.list);
|
|
|
|
xendebug_initialized = true;
|
|
}
|
|
}
|
|
|
|
/**************/
|
|
|
|
static domain_context_p
|
|
xendebug_domain_context_search (uint32_t domid)
|
|
{
|
|
struct list_head *entry;
|
|
domain_context_p ctxt;
|
|
|
|
list_for_each(entry, &domain_context_list.list)
|
|
{
|
|
ctxt = list_entry(entry, domain_context_t, list);
|
|
if ( domid == ctxt->domid )
|
|
return ctxt;
|
|
}
|
|
return (domain_context_p)NULL;
|
|
}
|
|
|
|
static __inline__ domain_context_p
|
|
xendebug_get_context (int xc_handle, uint32_t domid, uint32_t vcpu)
|
|
{
|
|
int rc;
|
|
domain_context_p ctxt;
|
|
|
|
xendebug_initialize();
|
|
|
|
if ( (ctxt = xendebug_domain_context_search(domid)) == NULL)
|
|
return NULL;
|
|
|
|
if ( !ctxt->valid[vcpu] )
|
|
{
|
|
if ( (rc = xc_vcpu_getcontext(xc_handle, domid, vcpu,
|
|
&ctxt->context[vcpu])) )
|
|
return NULL;
|
|
|
|
ctxt->valid[vcpu] = true;
|
|
}
|
|
|
|
return ctxt;
|
|
}
|
|
|
|
static __inline__ int
|
|
xendebug_set_context (int xc_handle, domain_context_p ctxt, uint32_t vcpu)
|
|
{
|
|
dom0_op_t op;
|
|
int rc;
|
|
|
|
if ( !ctxt->valid[vcpu] )
|
|
return -EINVAL;
|
|
|
|
op.interface_version = DOM0_INTERFACE_VERSION;
|
|
op.cmd = DOM0_SETVCPUCONTEXT;
|
|
op.u.setvcpucontext.domain = ctxt->domid;
|
|
op.u.setvcpucontext.vcpu = vcpu;
|
|
op.u.setvcpucontext.ctxt = &ctxt->context[vcpu];
|
|
|
|
if ( (rc = mlock(&ctxt->context[vcpu], sizeof(vcpu_guest_context_t))) )
|
|
return rc;
|
|
|
|
rc = xc_dom0_op(xc_handle, &op);
|
|
(void) munlock(&ctxt->context[vcpu], sizeof(vcpu_guest_context_t));
|
|
|
|
return rc;
|
|
}
|
|
|
|
/**************/
|
|
|
|
int
|
|
xendebug_attach(int xc_handle,
|
|
uint32_t domid,
|
|
uint32_t vcpu)
|
|
{
|
|
domain_context_p ctxt;
|
|
|
|
xendebug_initialize();
|
|
|
|
if ( (ctxt = malloc(sizeof(domain_context_t))) == NULL )
|
|
return -1;
|
|
memset(ctxt, 0, sizeof(domain_context_t));
|
|
|
|
ctxt->domid = domid;
|
|
list_add(&ctxt->list, &domain_context_list.list);
|
|
|
|
return xc_domain_pause(xc_handle, domid);
|
|
}
|
|
|
|
int
|
|
xendebug_detach(int xc_handle,
|
|
uint32_t domid,
|
|
uint32_t vcpu)
|
|
{
|
|
domain_context_p ctxt;
|
|
|
|
xendebug_initialize();
|
|
|
|
if ( (ctxt = xendebug_domain_context_search (domid)) == NULL)
|
|
return -EINVAL;
|
|
|
|
list_del(&ctxt->list);
|
|
|
|
if ( ctxt->page_array ) free(ctxt->page_array);
|
|
|
|
free(ctxt);
|
|
|
|
return xc_domain_unpause(xc_handle, domid);
|
|
}
|
|
|
|
int
|
|
xendebug_read_registers(int xc_handle,
|
|
uint32_t domid,
|
|
uint32_t vcpu,
|
|
cpu_user_regs_t **regs)
|
|
{
|
|
domain_context_p ctxt;
|
|
int rc = -1;
|
|
|
|
xendebug_initialize();
|
|
|
|
ctxt = xendebug_get_context(xc_handle, domid, vcpu);
|
|
if (ctxt)
|
|
{
|
|
*regs = &ctxt->context[vcpu].user_regs;
|
|
rc = 0;
|
|
}
|
|
|
|
return rc;
|
|
}
|
|
|
|
int
|
|
xendebug_read_fpregisters (int xc_handle,
|
|
uint32_t domid,
|
|
uint32_t vcpu,
|
|
char **regs)
|
|
{
|
|
domain_context_p ctxt;
|
|
int rc = -1;
|
|
|
|
xendebug_initialize();
|
|
|
|
ctxt = xendebug_get_context(xc_handle, domid, vcpu);
|
|
if (ctxt)
|
|
{
|
|
*regs = ctxt->context[vcpu].fpu_ctxt.x;
|
|
rc = 0;
|
|
}
|
|
|
|
return rc;
|
|
}
|
|
|
|
int
|
|
xendebug_write_registers(int xc_handle,
|
|
uint32_t domid,
|
|
uint32_t vcpu,
|
|
cpu_user_regs_t *regs)
|
|
{
|
|
domain_context_p ctxt;
|
|
int rc = -1;
|
|
|
|
xendebug_initialize();
|
|
|
|
ctxt = xendebug_get_context(xc_handle, domid, vcpu);
|
|
if (ctxt)
|
|
{
|
|
memcpy(&ctxt->context[vcpu].user_regs, regs, sizeof(cpu_user_regs_t));
|
|
rc = xendebug_set_context(xc_handle, ctxt, vcpu);
|
|
}
|
|
|
|
return rc;
|
|
}
|
|
|
|
int
|
|
xendebug_step(int xc_handle,
|
|
uint32_t domid,
|
|
uint32_t vcpu)
|
|
{
|
|
domain_context_p ctxt;
|
|
int rc;
|
|
|
|
xendebug_initialize();
|
|
|
|
ctxt = xendebug_get_context(xc_handle, domid, vcpu);
|
|
if (!ctxt) return -EINVAL;
|
|
|
|
ctxt->context[vcpu].user_regs.eflags |= X86_EFLAGS_TF;
|
|
|
|
if ( (rc = xendebug_set_context(xc_handle, ctxt, vcpu)) )
|
|
return rc;
|
|
|
|
ctxt->valid[vcpu] = false;
|
|
return xc_domain_unpause(xc_handle, domid);
|
|
}
|
|
|
|
int
|
|
xendebug_continue(int xc_handle,
|
|
uint32_t domid,
|
|
uint32_t vcpu)
|
|
{
|
|
domain_context_p ctxt;
|
|
int rc;
|
|
|
|
xendebug_initialize();
|
|
|
|
ctxt = xendebug_get_context(xc_handle, domid, vcpu);
|
|
if (!ctxt) return -EINVAL;
|
|
|
|
if ( ctxt->context[vcpu].user_regs.eflags & X86_EFLAGS_TF )
|
|
{
|
|
ctxt->context[vcpu].user_regs.eflags &= ~X86_EFLAGS_TF;
|
|
if ( (rc = xendebug_set_context(xc_handle, ctxt, vcpu)) )
|
|
return rc;
|
|
}
|
|
ctxt->valid[vcpu] = false;
|
|
return xc_domain_unpause(xc_handle, domid);
|
|
}
|
|
|
|
/*************************************************/
|
|
|
|
#define vtopdi(va) ((va) >> L2_PAGETABLE_SHIFT)
|
|
#define vtopti(va) (((va) >> PAGE_SHIFT) & 0x3ff)
|
|
|
|
/* access to one page */
|
|
static int
|
|
xendebug_memory_page (domain_context_p ctxt, int xc_handle, uint32_t vcpu,
|
|
int protection, unsigned long address, int length, uint8_t *buffer)
|
|
{
|
|
vcpu_guest_context_t *vcpu_ctxt = &ctxt->context[vcpu];
|
|
unsigned long pde, page;
|
|
unsigned long va = (unsigned long)address;
|
|
void *ptr;
|
|
long pages;
|
|
|
|
pages = xc_get_tot_pages(xc_handle, ctxt->domid);
|
|
|
|
if ( ctxt->total_pages != pages )
|
|
{
|
|
if ( ctxt->total_pages > 0 ) free( ctxt->page_array );
|
|
ctxt->total_pages = pages;
|
|
|
|
ctxt->page_array = malloc(pages * sizeof(unsigned long));
|
|
if ( ctxt->page_array == NULL )
|
|
{
|
|
printf("Could not allocate memory\n");
|
|
return 0;
|
|
}
|
|
|
|
if ( xc_get_pfn_list(xc_handle, ctxt->domid, ctxt->page_array,pages) !=
|
|
pages )
|
|
{
|
|
printf("Could not get the page frame list\n");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
if ( vcpu_ctxt->ctrlreg[3] != ctxt->cr3_phys[vcpu])
|
|
{
|
|
ctxt->cr3_phys[vcpu] = vcpu_ctxt->ctrlreg[3];
|
|
if ( ctxt->cr3_virt[vcpu] )
|
|
munmap(ctxt->cr3_virt[vcpu], PAGE_SIZE);
|
|
ctxt->cr3_virt[vcpu] = xc_map_foreign_range(xc_handle, ctxt->domid,
|
|
PAGE_SIZE, PROT_READ, ctxt->cr3_phys[vcpu] >> PAGE_SHIFT);
|
|
if ( ctxt->cr3_virt[vcpu] == NULL )
|
|
return 0;
|
|
}
|
|
|
|
|
|
if ( (pde = ctxt->cr3_virt[vcpu][vtopdi(va)]) == 0) /* logical address */
|
|
return 0;
|
|
if (ctxt->context[vcpu].flags & VGCF_HVM_GUEST)
|
|
pde = ctxt->page_array[pde >> PAGE_SHIFT] << PAGE_SHIFT;
|
|
if (pde != ctxt->pde_phys[vcpu])
|
|
{
|
|
ctxt->pde_phys[vcpu] = pde;
|
|
if ( ctxt->pde_virt[vcpu])
|
|
munmap(ctxt->pde_virt[vcpu], PAGE_SIZE);
|
|
ctxt->pde_virt[vcpu] = xc_map_foreign_range(xc_handle, ctxt->domid,
|
|
PAGE_SIZE, PROT_READ, ctxt->pde_phys[vcpu] >> PAGE_SHIFT);
|
|
if ( ctxt->pde_virt[vcpu] == NULL )
|
|
return 0;
|
|
}
|
|
|
|
if ((page = ctxt->pde_virt[vcpu][vtopti(va)]) == 0) /* logical address */
|
|
return 0;
|
|
if (ctxt->context[vcpu].flags & VGCF_HVM_GUEST)
|
|
page = ctxt->page_array[page >> PAGE_SHIFT] << PAGE_SHIFT;
|
|
if (page != ctxt->page_phys[vcpu] || protection != ctxt->page_perm[vcpu])
|
|
{
|
|
ctxt->page_phys[vcpu] = page;
|
|
if (ctxt->page_virt[vcpu])
|
|
munmap(ctxt->page_virt[vcpu], PAGE_SIZE);
|
|
ctxt->page_virt[vcpu] = xc_map_foreign_range(xc_handle, ctxt->domid,
|
|
PAGE_SIZE, protection, ctxt->page_phys[vcpu] >> PAGE_SHIFT);
|
|
if ( ctxt->page_virt[vcpu] == NULL )
|
|
{
|
|
printf("cr3 %lx pde %lx page %lx pti %lx\n",
|
|
vcpu_ctxt->ctrlreg[3], pde, page, vtopti(va));
|
|
ctxt->page_phys[vcpu] = 0;
|
|
return 0;
|
|
}
|
|
ctxt->page_perm[vcpu] = protection;
|
|
}
|
|
|
|
ptr = (void *)( (unsigned long)ctxt->page_virt[vcpu] |
|
|
(va & ~PAGE_MASK) );
|
|
|
|
if ( protection & PROT_WRITE )
|
|
{
|
|
memcpy(ptr, buffer, length);
|
|
}
|
|
else
|
|
{
|
|
memcpy(buffer, ptr, length);
|
|
}
|
|
|
|
return length;
|
|
}
|
|
|
|
/* divide a memory operation into accesses to individual pages */
|
|
static int
|
|
xendebug_memory_op (domain_context_p ctxt, int xc_handle, uint32_t vcpu,
|
|
int protection, unsigned long address, int length, uint8_t *buffer)
|
|
{
|
|
int remain; /* number of bytes to touch past this page */
|
|
int bytes = 0;
|
|
|
|
while ( (remain = (address + length - 1) - (address | (PAGE_SIZE-1))) > 0)
|
|
{
|
|
bytes += xendebug_memory_page(ctxt, xc_handle, vcpu, protection,
|
|
address, length - remain, buffer);
|
|
buffer += (length - remain);
|
|
length = remain;
|
|
address = (address | (PAGE_SIZE - 1)) + 1;
|
|
}
|
|
|
|
bytes += xendebug_memory_page(ctxt, xc_handle, vcpu, protection,
|
|
address, length, buffer);
|
|
|
|
return bytes;
|
|
}
|
|
|
|
int
|
|
xendebug_read_memory(int xc_handle,
|
|
uint32_t domid,
|
|
uint32_t vcpu,
|
|
unsigned long address,
|
|
uint32_t length,
|
|
uint8_t *data)
|
|
{
|
|
domain_context_p ctxt;
|
|
|
|
xendebug_initialize();
|
|
|
|
ctxt = xendebug_get_context(xc_handle, domid, vcpu);
|
|
|
|
xendebug_memory_op(ctxt, xc_handle, vcpu, PROT_READ,
|
|
address, length, data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
xendebug_write_memory(int xc_handle,
|
|
uint32_t domid,
|
|
uint32_t vcpu,
|
|
unsigned long address,
|
|
uint32_t length,
|
|
uint8_t *data)
|
|
{
|
|
domain_context_p ctxt;
|
|
|
|
xendebug_initialize();
|
|
|
|
ctxt = xendebug_get_context(xc_handle, domid, vcpu);
|
|
xendebug_memory_op(ctxt, xc_handle, vcpu, PROT_READ | PROT_WRITE,
|
|
|
|
address, length, data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
xendebug_insert_memory_breakpoint(int xc_handle,
|
|
uint32_t domid,
|
|
uint32_t vcpu,
|
|
unsigned long address,
|
|
uint32_t length)
|
|
{
|
|
bwcpoint_p bkpt;
|
|
uint8_t breakpoint_opcode = 0xcc;
|
|
|
|
printf("insert breakpoint %d:%lx %d\n",
|
|
domid, address, length);
|
|
|
|
xendebug_initialize();
|
|
|
|
bkpt = malloc(sizeof(bwcpoint_t));
|
|
if ( bkpt == NULL )
|
|
{
|
|
printf("error: breakpoint length should be 1\n");
|
|
return -1;
|
|
}
|
|
|
|
if ( length != 1 )
|
|
{
|
|
printf("error: breakpoint length should be 1\n");
|
|
free(bkpt);
|
|
return -1;
|
|
}
|
|
|
|
bkpt->address = address;
|
|
bkpt->domain = domid;
|
|
|
|
xendebug_read_memory(xc_handle, domid, vcpu, address, 1,
|
|
&bkpt->old_value);
|
|
|
|
xendebug_write_memory(xc_handle, domid, vcpu, address, 1,
|
|
&breakpoint_opcode);
|
|
|
|
list_add(&bkpt->list, &bwcpoint_list.list);
|
|
|
|
printf("breakpoint_set %d:%lx 0x%x\n",
|
|
domid, address, bkpt->old_value);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
xendebug_remove_memory_breakpoint(int xc_handle,
|
|
uint32_t domid,
|
|
uint32_t vcpu,
|
|
unsigned long address,
|
|
uint32_t length)
|
|
{
|
|
bwcpoint_p bkpt = NULL;
|
|
|
|
printf ("remove breakpoint %d:%lx\n",
|
|
domid, address);
|
|
|
|
struct list_head *entry;
|
|
list_for_each(entry, &bwcpoint_list.list)
|
|
{
|
|
bkpt = list_entry(entry, bwcpoint_t, list);
|
|
if ( domid == bkpt->domain && address == bkpt->address )
|
|
break;
|
|
}
|
|
|
|
if (bkpt == &bwcpoint_list || bkpt == NULL)
|
|
{
|
|
printf ("error: no breakpoint found\n");
|
|
return -1;
|
|
}
|
|
|
|
list_del(&bkpt->list);
|
|
|
|
xendebug_write_memory(xc_handle, domid, vcpu, address, 1,
|
|
&bkpt->old_value);
|
|
|
|
free(bkpt);
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
xendebug_query_domain_stop(int xc_handle, int *dom_list, int dom_list_size)
|
|
{
|
|
xc_dominfo_t *info;
|
|
uint32_t first_dom = 0;
|
|
int max_doms = 1024;
|
|
int nr_doms, loop;
|
|
int count = 0;
|
|
|
|
if ( (info = malloc(max_doms * sizeof(xc_dominfo_t))) == NULL )
|
|
return -ENOMEM;
|
|
|
|
nr_doms = xc_domain_getinfo(xc_handle, first_dom, max_doms, info);
|
|
|
|
for (loop = 0; loop < nr_doms; loop++)
|
|
{
|
|
printf ("domid: %d", info[loop].domid);
|
|
printf (" %c%c%c%c%c%c",
|
|
info[loop].dying ? 'D' : '-',
|
|
info[loop].crashed ? 'C' : '-',
|
|
info[loop].shutdown ? 'S' : '-',
|
|
info[loop].paused ? 'P' : '-',
|
|
info[loop].blocked ? 'B' : '-',
|
|
info[loop].running ? 'R' : '-');
|
|
printf (" pages: %ld, vcpus %d",
|
|
info[loop].nr_pages, info[loop].vcpus);
|
|
printf ("\n");
|
|
|
|
if ( info[loop].paused && count < dom_list_size)
|
|
{
|
|
dom_list[count++] = info[loop].domid;
|
|
}
|
|
}
|
|
|
|
free(info);
|
|
|
|
return count;
|
|
}
|
|
|
|
/*
|
|
* Local variables:
|
|
* mode: C
|
|
* c-set-style: "BSD"
|
|
* c-basic-offset: 4
|
|
* tab-width: 4
|
|
* indent-tabs-mode: nil
|
|
* End:
|
|
*/
|