Commit 64bf3f4eec322cd0d179d4b50f3cfc11901bf235
1 parent
5e2972fd
kvm: Drop kvm_patch_opcode_byte (Jan Kiszka)
As cpu_memory_rw_debug is now capable of modifying ROM, we can drop our own patch function. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6906 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
4 additions
and
23 deletions
target-i386/kvm.c
@@ -686,31 +686,12 @@ int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run) | @@ -686,31 +686,12 @@ int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run) | ||
686 | } | 686 | } |
687 | 687 | ||
688 | #ifdef KVM_CAP_SET_GUEST_DEBUG | 688 | #ifdef KVM_CAP_SET_GUEST_DEBUG |
689 | -static int kvm_patch_opcode_byte(CPUState *env, target_ulong addr, uint8_t val) | ||
690 | -{ | ||
691 | - target_phys_addr_t phys_page_addr; | ||
692 | - unsigned long pd; | ||
693 | - uint8_t *ptr; | ||
694 | - | ||
695 | - phys_page_addr = cpu_get_phys_page_debug(env, addr & TARGET_PAGE_MASK); | ||
696 | - if (phys_page_addr == -1) | ||
697 | - return -EINVAL; | ||
698 | - | ||
699 | - pd = cpu_get_physical_page_desc(phys_page_addr); | ||
700 | - if ((pd & ~TARGET_PAGE_MASK) != IO_MEM_RAM && | ||
701 | - (pd & ~TARGET_PAGE_MASK) != IO_MEM_ROM && !(pd & IO_MEM_ROMD)) | ||
702 | - return -EINVAL; | ||
703 | - | ||
704 | - ptr = phys_ram_base + (pd & TARGET_PAGE_MASK) | ||
705 | - + (addr & ~TARGET_PAGE_MASK); | ||
706 | - *ptr = val; | ||
707 | - return 0; | ||
708 | -} | ||
709 | - | ||
710 | int kvm_arch_insert_sw_breakpoint(CPUState *env, struct kvm_sw_breakpoint *bp) | 689 | int kvm_arch_insert_sw_breakpoint(CPUState *env, struct kvm_sw_breakpoint *bp) |
711 | { | 690 | { |
691 | + const static uint8_t int3 = 0xcc; | ||
692 | + | ||
712 | if (cpu_memory_rw_debug(env, bp->pc, (uint8_t *)&bp->saved_insn, 1, 0) || | 693 | if (cpu_memory_rw_debug(env, bp->pc, (uint8_t *)&bp->saved_insn, 1, 0) || |
713 | - kvm_patch_opcode_byte(env, bp->pc, 0xcc)) | 694 | + cpu_memory_rw_debug(env, bp->pc, (uint8_t *)&int3, 1, 1)) |
714 | return -EINVAL; | 695 | return -EINVAL; |
715 | return 0; | 696 | return 0; |
716 | } | 697 | } |
@@ -720,7 +701,7 @@ int kvm_arch_remove_sw_breakpoint(CPUState *env, struct kvm_sw_breakpoint *bp) | @@ -720,7 +701,7 @@ int kvm_arch_remove_sw_breakpoint(CPUState *env, struct kvm_sw_breakpoint *bp) | ||
720 | uint8_t int3; | 701 | uint8_t int3; |
721 | 702 | ||
722 | if (cpu_memory_rw_debug(env, bp->pc, &int3, 1, 0) || int3 != 0xcc || | 703 | if (cpu_memory_rw_debug(env, bp->pc, &int3, 1, 0) || int3 != 0xcc || |
723 | - kvm_patch_opcode_byte(env, bp->pc, bp->saved_insn)) | 704 | + cpu_memory_rw_debug(env, bp->pc, (uint8_t *)&bp->saved_insn, 1, 1)) |
724 | return -EINVAL; | 705 | return -EINVAL; |
725 | return 0; | 706 | return 0; |
726 | } | 707 | } |