All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: Bharat Bhushan <Bharat.Bhushan@freescale.com>, kvm-ppc@vger.kernel.org
Cc: kvm@vger.kernel.org, scottwood@freescale.com, stuart.yoder@freescale.com
Subject: Re: [PATCH 6/6] KVM: PPC: BOOKE: Emulate debug registers and exception
Date: Mon, 28 Jul 2014 16:04:30 +0200	[thread overview]
Message-ID: <53D6586E.7060601@suse.de> (raw)
In-Reply-To: <1405067941-27134-7-git-send-email-Bharat.Bhushan@freescale.com>


On 11.07.14 10:39, Bharat Bhushan wrote:
> This patch emulates debug registers and debug exception
> to support guest using debug resource. This enables running
> gdb/kgdb etc in guest.
>
> On BOOKE architecture we cannot share debug resources between QEMU and
> guest because:
>      When QEMU is using debug resources then debug exception must
>      be always enabled. To achieve this we set MSR_DE and also set
>      MSRP_DEP so guest cannot change MSR_DE.
>
>      When emulating debug resource for guest we want guest
>      to control MSR_DE (enable/disable debug interrupt on need).
>
>      So above mentioned two configuration cannot be supported
>      at the same time. So the result is that we cannot share
>      debug resources between QEMU and Guest on BOOKE architecture.
>
> In the current design QEMU gets priority over guest, this means that if
> QEMU is using debug resources then guest cannot use them and if guest is
> using debug resource then QEMU can overwrite them.
>
> Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com>
> ---
> Hi Alex,
>
> I thought of having some print in register emulation if QEMU
> is using debug resource, Also when QEMU overwrites guest written
> values but that looks excessive. If I uses some variable which
> get set when guest starts using debug registers and check in
> debug set ioctl then that look ugly. Looking for suggestions

Whatever you do, have QEMU do the print, not the kernel.

>
>   arch/powerpc/include/asm/kvm_ppc.h |   3 +
>   arch/powerpc/kvm/booke.c           |  27 +++++++
>   arch/powerpc/kvm/booke_emulate.c   | 157 +++++++++++++++++++++++++++++++++++++
>   3 files changed, 187 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
> index e2fd5a1..f3f7611 100644
> --- a/arch/powerpc/include/asm/kvm_ppc.h
> +++ b/arch/powerpc/include/asm/kvm_ppc.h
> @@ -173,6 +173,9 @@ extern int kvmppc_xics_get_xive(struct kvm *kvm, u32 irq, u32 *server,
>   extern int kvmppc_xics_int_on(struct kvm *kvm, u32 irq);
>   extern int kvmppc_xics_int_off(struct kvm *kvm, u32 irq);
>   
> +void kvmppc_core_dequeue_debug(struct kvm_vcpu *vcpu);
> +void kvmppc_core_queue_debug(struct kvm_vcpu *vcpu);
> +
>   union kvmppc_one_reg {
>   	u32	wval;
>   	u64	dval;
> diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> index fadfe76..c2471ed 100644
> --- a/arch/powerpc/kvm/booke.c
> +++ b/arch/powerpc/kvm/booke.c
> @@ -264,6 +264,16 @@ static void kvmppc_core_dequeue_watchdog(struct kvm_vcpu *vcpu)
>   	clear_bit(BOOKE_IRQPRIO_WATCHDOG, &vcpu->arch.pending_exceptions);
>   }
>   
> +void kvmppc_core_queue_debug(struct kvm_vcpu *vcpu)
> +{
> +	kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_DEBUG);
> +}
> +
> +void kvmppc_core_dequeue_debug(struct kvm_vcpu *vcpu)
> +{
> +	clear_bit(BOOKE_IRQPRIO_DEBUG, &vcpu->arch.pending_exceptions);
> +}
> +
>   static void set_guest_srr(struct kvm_vcpu *vcpu, unsigned long srr0, u32 srr1)
>   {
>   #ifdef CONFIG_KVM_BOOKE_HV
> @@ -783,6 +793,23 @@ static int kvmppc_handle_debug(struct kvm_run *run, struct kvm_vcpu *vcpu)
>   	struct debug_reg *dbg_reg = &(vcpu->arch.shadow_dbg_reg);
>   	u32 dbsr = vcpu->arch.dbsr;
>   
> +	if (vcpu->guest_debug == 0) {
> +		/* Debug resources belong to Guest */
> +		if (dbsr && (vcpu->arch.shared->msr & MSR_DE))
> +			kvmppc_core_queue_debug(vcpu);
> +
> +		/* Inject a program interrupt if trap debug is not allowed */
> +		if ((dbsr & DBSR_TIE) && !(vcpu->arch.shared->msr & MSR_DE))
> +			kvmppc_core_queue_program(vcpu, ESR_PTR);

In that case we would've received a program interrupt and never entered 
this code path, no?


Alex

WARNING: multiple messages have this Message-ID (diff)
From: Alexander Graf <agraf@suse.de>
To: Bharat Bhushan <Bharat.Bhushan@freescale.com>, kvm-ppc@vger.kernel.org
Cc: kvm@vger.kernel.org, scottwood@freescale.com, stuart.yoder@freescale.com
Subject: Re: [PATCH 6/6] KVM: PPC: BOOKE: Emulate debug registers and exception
Date: Mon, 28 Jul 2014 14:04:30 +0000	[thread overview]
Message-ID: <53D6586E.7060601@suse.de> (raw)
In-Reply-To: <1405067941-27134-7-git-send-email-Bharat.Bhushan@freescale.com>


On 11.07.14 10:39, Bharat Bhushan wrote:
> This patch emulates debug registers and debug exception
> to support guest using debug resource. This enables running
> gdb/kgdb etc in guest.
>
> On BOOKE architecture we cannot share debug resources between QEMU and
> guest because:
>      When QEMU is using debug resources then debug exception must
>      be always enabled. To achieve this we set MSR_DE and also set
>      MSRP_DEP so guest cannot change MSR_DE.
>
>      When emulating debug resource for guest we want guest
>      to control MSR_DE (enable/disable debug interrupt on need).
>
>      So above mentioned two configuration cannot be supported
>      at the same time. So the result is that we cannot share
>      debug resources between QEMU and Guest on BOOKE architecture.
>
> In the current design QEMU gets priority over guest, this means that if
> QEMU is using debug resources then guest cannot use them and if guest is
> using debug resource then QEMU can overwrite them.
>
> Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com>
> ---
> Hi Alex,
>
> I thought of having some print in register emulation if QEMU
> is using debug resource, Also when QEMU overwrites guest written
> values but that looks excessive. If I uses some variable which
> get set when guest starts using debug registers and check in
> debug set ioctl then that look ugly. Looking for suggestions

Whatever you do, have QEMU do the print, not the kernel.

>
>   arch/powerpc/include/asm/kvm_ppc.h |   3 +
>   arch/powerpc/kvm/booke.c           |  27 +++++++
>   arch/powerpc/kvm/booke_emulate.c   | 157 +++++++++++++++++++++++++++++++++++++
>   3 files changed, 187 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
> index e2fd5a1..f3f7611 100644
> --- a/arch/powerpc/include/asm/kvm_ppc.h
> +++ b/arch/powerpc/include/asm/kvm_ppc.h
> @@ -173,6 +173,9 @@ extern int kvmppc_xics_get_xive(struct kvm *kvm, u32 irq, u32 *server,
>   extern int kvmppc_xics_int_on(struct kvm *kvm, u32 irq);
>   extern int kvmppc_xics_int_off(struct kvm *kvm, u32 irq);
>   
> +void kvmppc_core_dequeue_debug(struct kvm_vcpu *vcpu);
> +void kvmppc_core_queue_debug(struct kvm_vcpu *vcpu);
> +
>   union kvmppc_one_reg {
>   	u32	wval;
>   	u64	dval;
> diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> index fadfe76..c2471ed 100644
> --- a/arch/powerpc/kvm/booke.c
> +++ b/arch/powerpc/kvm/booke.c
> @@ -264,6 +264,16 @@ static void kvmppc_core_dequeue_watchdog(struct kvm_vcpu *vcpu)
>   	clear_bit(BOOKE_IRQPRIO_WATCHDOG, &vcpu->arch.pending_exceptions);
>   }
>   
> +void kvmppc_core_queue_debug(struct kvm_vcpu *vcpu)
> +{
> +	kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_DEBUG);
> +}
> +
> +void kvmppc_core_dequeue_debug(struct kvm_vcpu *vcpu)
> +{
> +	clear_bit(BOOKE_IRQPRIO_DEBUG, &vcpu->arch.pending_exceptions);
> +}
> +
>   static void set_guest_srr(struct kvm_vcpu *vcpu, unsigned long srr0, u32 srr1)
>   {
>   #ifdef CONFIG_KVM_BOOKE_HV
> @@ -783,6 +793,23 @@ static int kvmppc_handle_debug(struct kvm_run *run, struct kvm_vcpu *vcpu)
>   	struct debug_reg *dbg_reg = &(vcpu->arch.shadow_dbg_reg);
>   	u32 dbsr = vcpu->arch.dbsr;
>   
> +	if (vcpu->guest_debug = 0) {
> +		/* Debug resources belong to Guest */
> +		if (dbsr && (vcpu->arch.shared->msr & MSR_DE))
> +			kvmppc_core_queue_debug(vcpu);
> +
> +		/* Inject a program interrupt if trap debug is not allowed */
> +		if ((dbsr & DBSR_TIE) && !(vcpu->arch.shared->msr & MSR_DE))
> +			kvmppc_core_queue_program(vcpu, ESR_PTR);

In that case we would've received a program interrupt and never entered 
this code path, no?


Alex


  reply	other threads:[~2014-07-28 14:04 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-11  8:38 [PATCH 0/6] Guest debug emulation Bharat Bhushan
2014-07-11  8:50 ` Bharat Bhushan
2014-07-11  8:38 ` [PATCH 1/6] KVM: PPC: BOOKE: No need to set DBCR0_EDM in guest visible register Bharat Bhushan
2014-07-11  8:50   ` Bharat Bhushan
2014-07-28 21:52   ` Scott Wood
2014-07-28 21:52     ` Scott Wood
2014-07-30  5:21     ` Bharat.Bhushan
2014-07-30  5:21       ` Bharat.Bhushan
2014-07-30 17:47       ` Scott Wood
2014-07-30 17:47         ` Scott Wood
2014-07-30 17:57         ` Bharat.Bhushan
2014-07-30 17:57           ` Bharat.Bhushan
2014-07-30 18:15           ` Scott Wood
2014-07-30 18:15             ` Scott Wood
2014-07-11  8:38 ` [PATCH 2/6] KVM: PPC: BOOKE: Force MSR_DE in rfci if guest is under debug Bharat Bhushan
2014-07-11  8:50   ` Bharat Bhushan
2014-07-28 13:54   ` Alexander Graf
2014-07-28 13:54     ` Alexander Graf
2014-07-28 21:54   ` Scott Wood
2014-07-28 21:54     ` Scott Wood
2014-07-30  5:30     ` Bharat.Bhushan
2014-07-30  5:30       ` Bharat.Bhushan
2014-07-11  8:38 ` [PATCH 3/6] KVM: PPC: BOOKE: allow debug interrupt at "debug level" Bharat Bhushan
2014-07-11  8:50   ` Bharat Bhushan
2014-07-11  8:38 ` [PATCH 4/6] KVM: PPC: BOOKE : Emulate rfdi instruction Bharat Bhushan
2014-07-11  8:50   ` Bharat Bhushan
2014-07-11  8:39 ` [PATCH 5/6] KVM: PPC: BOOKE: Allow guest to change MSR_DE Bharat Bhushan
2014-07-11  8:51   ` Bharat Bhushan
2014-07-28 22:01   ` Scott Wood
2014-07-28 22:01     ` Scott Wood
2014-07-29 14:05     ` Alexander Graf
2014-07-29 14:05       ` Alexander Graf
2014-07-30  5:37       ` Bharat.Bhushan
2014-07-30  5:37         ` Bharat.Bhushan
2014-07-11  8:39 ` [PATCH 6/6] KVM: PPC: BOOKE: Emulate debug registers and exception Bharat Bhushan
2014-07-11  8:51   ` Bharat Bhushan
2014-07-28 14:04   ` Alexander Graf [this message]
2014-07-28 14:04     ` Alexander Graf
2014-07-28 22:33     ` Scott Wood
2014-07-28 22:33       ` Scott Wood
2014-07-29 14:06       ` Alexander Graf
2014-07-29 14:06         ` Alexander Graf
2014-07-29 17:50         ` Scott Wood
2014-07-29 17:50           ` Scott Wood
2014-07-29 18:23           ` Alexander Graf
2014-07-29 18:23             ` Alexander Graf
2014-07-30  5:43           ` Bharat.Bhushan
2014-07-30  5:43             ` Bharat.Bhushan
2014-07-30  6:33             ` Alexander Graf
2014-07-30  6:33               ` Alexander Graf
2014-07-30  6:49     ` Bharat.Bhushan
2014-07-30  6:49       ` Bharat.Bhushan
2014-07-28 22:28   ` Scott Wood
2014-07-28 22:28     ` Scott Wood
2014-07-30  6:43     ` Bharat.Bhushan
2014-07-30  6:43       ` Bharat.Bhushan
2014-07-31  2:47       ` Scott Wood
2014-07-31  2:47         ` Scott Wood
2014-07-31  6:15         ` Bharat.Bhushan
2014-07-31  6:15           ` Bharat.Bhushan
2014-07-31 20:45           ` Scott Wood
2014-07-31 20:45             ` Scott Wood
2014-08-01  9:34             ` Bharat.Bhushan
2014-08-01  9:34               ` Bharat.Bhushan
2014-08-02  3:35               ` Scott Wood
2014-08-02  3:35                 ` Scott Wood

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=53D6586E.7060601@suse.de \
    --to=agraf@suse.de \
    --cc=Bharat.Bhushan@freescale.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=scottwood@freescale.com \
    --cc=stuart.yoder@freescale.com \
    /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.