From: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
To: "Bharat.Bhushan@freescale.com" <Bharat.Bhushan@freescale.com>,
"agraf@suse.de" <agraf@suse.de>,
"paulus@samba.org" <paulus@samba.org>
Cc: "qemu-ppc@nongnu.org" <qemu-ppc@nongnu.org>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH] qemu/target-ppc: software breakpoint support
Date: Tue, 17 Jun 2014 13:38:08 +0530 [thread overview]
Message-ID: <539FF768.3030503@linux.vnet.ibm.com> (raw)
In-Reply-To: <8c88e4f25e4747a4a286e9169ba5e533@DM2PR03MB574.namprd03.prod.outlook.com>
On Monday 16 June 2014 03:22 PM, Bharat.Bhushan@freescale.com wrote:
>
>
>> -----Original Message-----
>> From: qemu-ppc-bounces+bharat.bhushan=freescale.com@nongnu.org [mailto:qemu-ppc-
>> bounces+bharat.bhushan=freescale.com@nongnu.org] On Behalf Of Madhavan
>> Srinivasan
>> Sent: Sunday, June 15, 2014 2:38 AM
>> To: agraf@suse.de; paulus@samba.org
>> Cc: Madhavan Srinivasan; qemu-ppc@nongnu.org; qemu-devel@nongnu.org
>> Subject: [Qemu-ppc] [PATCH] qemu/target-ppc: software breakpoint support
>>
>> This patch adds software breakpoint support for ppc. Patch
>> allows to insert and remove sw breakpoints using Qemu
>> gdbserver on ppc.
>>
>> Patch use "abs" instruction as sw breakpoint instruction.
>> This instruction with primary opcode 31 and extended opcode 360
>> has been dropped from PowerISA (in v2.01) and will generate an
>> Emulation assistance interrupt in hypervisor when executed.
>> KVM also has to be updated with this to make use of sw breakpoint.
>
> There are already a patch "ppc debug: Add debug stub support" in review which implements software breakpoint
My bad. Should have checked for it. Will look at the patchset posted.
> In addition this patch also implements h/w breakpoints/watchpoints for BOOKE. But I actually do not know how h/w breakpoints works on BOOK3S and you can help me figuring out what can be shared between booke and book3s.
>
Sure will update you on this soon.
>>
>> Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
>> ---
>> target-ppc/kvm.c | 38 +++++++++++++++++++++++++++++++++++---
>> 1 file changed, 35 insertions(+), 3 deletions(-)
>>
>> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
>> index 9974b10..fa4b4ec 100644
>> --- a/target-ppc/kvm.c
>> +++ b/target-ppc/kvm.c
>> @@ -1201,6 +1201,17 @@ static int kvmppc_handle_dcr_write(CPUPPCState *env,
>> uint32_t dcrn, uint32_t dat
>> return 0;
>> }
>>
>> +static int kvmppc_handle_debug(CPUState *cs, struct kvm_debug_exit_arch
>> *arch_info)
>> +{
>> + int ret = -1;
>> +
>> + if (kvm_find_sw_breakpoint(cs, arch_info->address)) {
>> + ret = EXCP_DEBUG;
>> + }
>> +
>> + return ret;
>> +}
>> +
>> int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
>> {
>> PowerPCCPU *cpu = POWERPC_CPU(cs);
>> @@ -1240,7 +1251,10 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run
>> *run)
>> watchdog_perform_action();
>> ret = 0;
>> break;
>> -
>> + case KVM_EXIT_DEBUG:
>> + DPRINTF("handle debug exit pc = 0x%lx\n", run->debug.arch.address);
>> + ret = kvmppc_handle_debug(cs, &run->debug.arch);
>> + break;
>> default:
>> fprintf(stderr, "KVM: unknown exit reason %d\n", run->exit_reason);
>> ret = -1;
>> @@ -1901,14 +1915,29 @@ void kvm_arch_init_irq_routing(KVMState *s)
>> {
>> }
>>
>> +static const uint8_t dbg_int[] = { 0x7c, 0x00, 0x02, 0xd0};
>
> This should not be hardcoded but we should get this from KVM. Please refer to patch "ppc debug: Add debug stub support" to know how to get debug instruction.
>
Sure Will do
> Thanks
> -Bharat
>
Thanks for review.
Regards
Maddy
>> int kvm_arch_insert_sw_breakpoint(CPUState *cpu, struct kvm_sw_breakpoint *bp)
>> {
>> - return -EINVAL;
>> + if( cpu_memory_rw_debug(cpu, bp->pc, (uint8_t *)&bp->saved_insn,
>> sizeof(dbg_int), 0) ||
>> + cpu_memory_rw_debug(cpu, bp->pc, (uint8_t *)dbg_int, sizeof(dbg_int),
>> 1) ){
>> + return -EINVAL;
>> + }
>> + return 0;
>> }
>>
>> int kvm_arch_remove_sw_breakpoint(CPUState *cpu, struct kvm_sw_breakpoint *bp)
>> {
>> - return -EINVAL;
>> + uint8_t tmp[4];
>> +
>> + if (cpu_memory_rw_debug(cpu, bp->pc, tmp, sizeof(dbg_int), 0)) {
>> + return -EINVAL;
>> + } else if (memcmp(tmp, dbg_int, sizeof(dbg_int))) {
>> + return -EINVAL;
>> + } else if (cpu_memory_rw_debug(cpu, bp->pc, (uint8_t *)&bp->saved_insn,
>> sizeof(dbg_int), 1)) {
>> + return -EINVAL;
>> + }
>> +
>> + return 0;
>> }
>>
>> int kvm_arch_insert_hw_breakpoint(target_ulong addr, target_ulong len, int
>> type)
>> @@ -1927,6 +1956,9 @@ void kvm_arch_remove_all_hw_breakpoints(void)
>>
>> void kvm_arch_update_guest_debug(CPUState *cpu, struct kvm_guest_debug *dbg)
>> {
>> + if (kvm_sw_breakpoints_active(cpu)) {
>> + dbg->control |= KVM_GUESTDBG_USE_SW_BP;
>> + }
>> }
>>
>> struct kvm_get_htab_buf {
>> --
>> 1.8.3.1
>>
>
prev parent reply other threads:[~2014-06-17 8:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-14 21:08 [Qemu-devel] [PATCH] qemu/target-ppc: software breakpoint support Madhavan Srinivasan
2014-06-16 9:52 ` [Qemu-devel] [Qemu-ppc] " Bharat.Bhushan
2014-06-17 8:08 ` Madhavan Srinivasan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=539FF768.3030503@linux.vnet.ibm.com \
--to=maddy@linux.vnet.ibm.com \
--cc=Bharat.Bhushan@freescale.com \
--cc=agraf@suse.de \
--cc=paulus@samba.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.