qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>,
	"Bharat.Bhushan@freescale.com" <Bharat.Bhushan@freescale.com>
Cc: "qemu-ppc@nongnu.org" <qemu-ppc@nongnu.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 4/5 v3][RESEND] ppc: Add software breakpoint support
Date: Wed, 25 Jun 2014 00:48:09 +0200	[thread overview]
Message-ID: <53AA0029.4030209@suse.de> (raw)
In-Reply-To: <53A9BC6C.1090705@linux.vnet.ibm.com>


On 24.06.14 19:59, Madhavan Srinivasan wrote:
> On Tuesday 24 June 2014 10:36 PM, Bharat.Bhushan@freescale.com wrote:
>>
>>> -----Original Message-----
>>> From: Madhavan Srinivasan [mailto:maddy@linux.vnet.ibm.com]
>>> Sent: Tuesday, June 24, 2014 8:59 PM
>>> To: Bhushan Bharat-R65777; agraf@suse.de
>>> Cc: qemu-ppc@nongnu.org; qemu-devel@nongnu.org
>>> Subject: Re: [PATCH 4/5 v3][RESEND] ppc: Add software breakpoint support
>>>
>>> On Tuesday 24 June 2014 05:40 PM, Bharat Bhushan wrote:
>>>> This patch allow insert/remove software breakpoint
>>>>
>>>> Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com>
>>>> ---
>>>>   target-ppc/kvm.c | 71
>>>> +++++++++++++++++++++++++++++++++++++++++++++-----------
>>>>   1 file changed, 57 insertions(+), 14 deletions(-)
>>>>
>>>> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index
>>>> 5238de7..8e2dbb3 100644
>>>> --- a/target-ppc/kvm.c
>>>> +++ b/target-ppc/kvm.c
>>>> @@ -1317,6 +1317,53 @@ static int kvmppc_handle_dcr_write(CPUPPCState *env,
>>> uint32_t dcrn, uint32_t dat
>>>>       return 0;
>>>>   }
>>>>
>>>> +int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct
>>>> +kvm_sw_breakpoint *bp) {
>>>> +    /* Mixed endian case is not handled */
>>>> +    uint32_t sc = debug_inst_opcode;
>>>> +
>>>> +    if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 0) ||
>>>> +        cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&sc, 4, 1)) {
>>> Instead of hard coding, can we use sizeof ()?
>> Yes
>>
>>>> +        return -EINVAL;
>>>> +    }
>>>> +
>>>> +    return 0;
>>>> +}
>>>> +
>>>> +int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct
>>>> +kvm_sw_breakpoint *bp) {
>>>> +    uint32_t sc;
>>>> +
>>>> +    if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&sc, 4, 0) ||
>>>> +        sc != debug_inst_opcode ||
>>>> +        cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 1)) {
>>>> +        return -EINVAL;
>>>> +    }
>>>> +
>>> Same. Can we use sizeof?
>> Yes
>>
>>>> +    return 0;
>>>> +}
>>>> +
>>>> +void kvm_arch_update_guest_debug(CPUState *cs, struct kvm_guest_debug
>>>> +*dbg) {
>>>> +    /* Software Breakpoint updates */
>>>> +    if (kvm_sw_breakpoints_active(cs)) {
>>>> +        dbg->control |= KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP;
>>>> +    }
>>>> +}
>>>> +
>>>> +static int kvm_handle_debug(PowerPCCPU *cpu, struct kvm_run *run) {
>>>> +    CPUState *cs = CPU(cpu);
>>>> +    struct kvm_debug_exit_arch *arch_info = &run->debug.arch;
>>>> +    int handle = 0;
>>>> +
>>>> +    if (kvm_find_sw_breakpoint(cs, arch_info->address)) {
>>>> +        handle = 1;
>>>> +    }
>>>> +
>>>> +    return handle;
>>>> +}
>>>> +
>>>>   int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)  {
>>>>       PowerPCCPU *cpu = POWERPC_CPU(cs); @@ -1357,6 +1404,16 @@ int
>>>> kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
>>>>           ret = 0;
>>>>           break;
>>>>
>>>> +    case KVM_EXIT_DEBUG:
>>>> +        DPRINTF("handle debug exception\n");
>>>> +        if (kvm_handle_debug(cpu, run)) {
>>>> +            ret = EXCP_DEBUG;
>>>> +            break;
>>>> +        }
>>>> +        /* re-enter, this exception was guest-internal */
>>> Kindly can you explain when this will happen?
>> If the debug interrupt condition (breakpoint/watchpoint etc) is not set by qemu, i.e that is set by guest.
>>
> OK. This is my understanding. Kindly correct if it is wrong.
> If we are here without any breakpoint from qemu, are we not suppose to
> pass it on to guest with an interrupt inject?

Yes. If the guest issued that instruction itself we need to pass in the 
interrupt that the guest would have received. I think in the book3s case 
this would be a PROGRAM interrupt rather than a DEBUG interrupt.


Alex

  reply	other threads:[~2014-06-24 22:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-24 12:10 [Qemu-devel] [PATCH 0/5 v3][RESEND] ppc: Add debug stub support Bharat Bhushan
2014-06-24 12:10 ` [Qemu-devel] [PATCH 1/5 v3][RESEND] ppc: debug stub: Get trap instruction opcode from KVM Bharat Bhushan
2014-06-24 12:10 ` [Qemu-devel] [PATCH 2/5 v3][RESEND] ppc: Add interface to inject interrupt to guest Bharat Bhushan
2014-06-24 12:10 ` [Qemu-devel] [PATCH 3/5 v3][RESEND] ppc: Add debug interrupt injection handler Bharat Bhushan
2014-06-24 12:10 ` [Qemu-devel] [PATCH 4/5 v3][RESEND] ppc: Add software breakpoint support Bharat Bhushan
2014-06-24 13:04   ` Alexander Graf
2014-06-24 13:11     ` Bharat.Bhushan
2014-06-24 13:20       ` Alexander Graf
2014-06-24 15:28   ` Madhavan Srinivasan
2014-06-24 17:06     ` Bharat.Bhushan
2014-06-24 17:59       ` Madhavan Srinivasan
2014-06-24 22:48         ` Alexander Graf [this message]
2014-06-24 12:10 ` [Qemu-devel] [PATCH 5/5 v3][RESEND] ppc: Add hw breakpoint watchpoint support Bharat Bhushan
2014-06-24 13:19   ` Alexander Graf
2014-06-24 14:37     ` Bharat.Bhushan
2014-06-24 14:50       ` Alexander Graf
2014-06-24 16:57         ` Bharat.Bhushan
2014-06-24 22:46           ` Alexander Graf

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=53AA0029.4030209@suse.de \
    --to=agraf@suse.de \
    --cc=Bharat.Bhushan@freescale.com \
    --cc=maddy@linux.vnet.ibm.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).