RE: [PATCH 4/4 v2] KVM: PPC: Add userspace debug stub support

2013-03-29 Thread Bhushan Bharat-R65777


 -Original Message-
 From: Alexander Graf [mailto:ag...@suse.de]
 Sent: Thursday, March 28, 2013 10:06 PM
 To: Bhushan Bharat-R65777
 Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Wood Scott-B07421; Bhushan
 Bharat-R65777
 Subject: Re: [PATCH 4/4 v2] KVM: PPC: Add userspace debug stub support
 
 
 On 21.03.2013, at 07:25, Bharat Bhushan wrote:
 
  From: Bharat Bhushan bharat.bhus...@freescale.com
 
  This patch adds the debug stub support on booke/bookehv.
  Now QEMU debug stub can use hw breakpoint, watchpoint and software
  breakpoint to debug guest.
 
  Debug registers are saved/restored on vcpu_put()/vcpu_get().
  Also the debug registers are saved restored only if guest is using
  debug resources.
 
  Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com
  ---
  v2:
  - save/restore in vcpu_get()/vcpu_put()
  - some more minor cleanup based on review comments.
 
  arch/powerpc/include/asm/kvm_host.h |   10 ++
  arch/powerpc/include/uapi/asm/kvm.h |   22 +++-
  arch/powerpc/kvm/booke.c|  252 
  ---
  arch/powerpc/kvm/e500_emulate.c |   10 ++
  4 files changed, 272 insertions(+), 22 deletions(-)
 
  diff --git a/arch/powerpc/include/asm/kvm_host.h
  b/arch/powerpc/include/asm/kvm_host.h
  index f4ba881..8571952 100644
  --- a/arch/powerpc/include/asm/kvm_host.h
  +++ b/arch/powerpc/include/asm/kvm_host.h
  @@ -504,7 +504,17 @@ struct kvm_vcpu_arch {
  u32 mmucfg;
  u32 epr;
  u32 crit_save;
  +   /* guest debug registers*/
  struct kvmppc_booke_debug_reg dbg_reg;
  +   /* shadow debug registers */
  +   struct kvmppc_booke_debug_reg shadow_dbg_reg;
  +   /* host debug registers*/
  +   struct kvmppc_booke_debug_reg host_dbg_reg;
  +   /*
  +* Flag indicating that debug registers are used by guest
  +* and requires save restore.
  +   */
  +   bool debug_save_restore;
  #endif
  gpa_t paddr_accessed;
  gva_t vaddr_accessed;
  diff --git a/arch/powerpc/include/uapi/asm/kvm.h
  b/arch/powerpc/include/uapi/asm/kvm.h
  index 15f9a00..d7ce449 100644
  --- a/arch/powerpc/include/uapi/asm/kvm.h
  +++ b/arch/powerpc/include/uapi/asm/kvm.h
  @@ -25,6 +25,7 @@
  /* Select powerpc specific features in linux/kvm.h */ #define
  __KVM_HAVE_SPAPR_TCE #define __KVM_HAVE_PPC_SMT
  +#define __KVM_HAVE_GUEST_DEBUG
 
  struct kvm_regs {
  __u64 pc;
  @@ -267,7 +268,24 @@ struct kvm_fpu {
  __u64 fpr[32];
  };
 
  +/*
  + * Defines for h/w breakpoint, watchpoint (read, write or both) and
  + * software breakpoint.
  + * These are used as type in KVM_SET_GUEST_DEBUG ioctl and status
  + * for KVM_DEBUG_EXIT.
  + */
  +#define KVMPPC_DEBUG_NONE  0x0
  +#define KVMPPC_DEBUG_BREAKPOINT(1UL  1)
  +#define KVMPPC_DEBUG_WATCH_WRITE   (1UL  2)
  +#define KVMPPC_DEBUG_WATCH_READ(1UL  3)
  struct kvm_debug_exit_arch {
  +   __u64 address;
  +   /*
  +* exiting to userspace because of h/w breakpoint, watchpoint
  +* (read, write or both) and software breakpoint.
  +*/
  +   __u32 status;
  +   __u32 reserved;
  };
 
  /* for KVM_SET_GUEST_DEBUG */
  @@ -279,10 +297,6 @@ struct kvm_guest_debug_arch {
   * Type denotes h/w breakpoint, read watchpoint, write
   * watchpoint or watchpoint (both read and write).
   */
  -#define KVMPPC_DEBUG_NOTYPE0x0
  -#define KVMPPC_DEBUG_BREAKPOINT(1UL  1)
  -#define KVMPPC_DEBUG_WATCH_WRITE   (1UL  2)
  -#define KVMPPC_DEBUG_WATCH_READ(1UL  3)
  __u32 type;
  __u32 reserved;
  } bp[16];
  diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index
  1de93a8..bf20056 100644
  --- a/arch/powerpc/kvm/booke.c
  +++ b/arch/powerpc/kvm/booke.c
  @@ -133,6 +133,30 @@ static void kvmppc_vcpu_sync_fpu(struct kvm_vcpu
  *vcpu) #endif }
 
  +static void kvmppc_vcpu_sync_debug(struct kvm_vcpu *vcpu) {
  +   /* Synchronize guest's desire to get debug interrupts into shadow
  +MSR */ #ifndef CONFIG_KVM_BOOKE_HV
  +   vcpu-arch.shadow_msr = ~MSR_DE;
  +   vcpu-arch.shadow_msr |= vcpu-arch.shared-msr  MSR_DE; #endif
  +
  +   /* Force enable debug interrupts when user space wants to debug */
  +   if (vcpu-guest_debug) {
  +#ifdef CONFIG_KVM_BOOKE_HV
  +   /*
  +* Since there is no shadow MSR, sync MSR_DE into the guest
  +* visible MSR. Do not allow guest to change MSR[DE].
  +*/
  +   vcpu-arch.shared-msr |= MSR_DE;
  +   mtspr(SPRN_MSRP, mfspr(SPRN_MSRP) | MSRP_DEP);
 
 This mtspr should really just be a bit or in shadow_mspr when guest_debug gets
 enabled. It should automatically get synchronized as soon as the next
 vpcu_load() happens.

I think this is not required here as shadow_dbsr already have MSRP_DEP set.

Will setup shadow_msrp when setting guest_debug and clear shadow_msrp when 
guest_debug is cleared.
But that will also not be sufficient as it not sure when vcpu_load() will be 

kvm error message when trying to run Mac-On-Linux

2013-03-29 Thread Jochen Rollwagen
Hallo there,

i'm trying to run the latest Mac-On-Linux on a mac mini G4 running Ubuntu 
Precise 12.04 with a 3.4.36-kernel (for nostalgic reasons mainly :-). Building 
it succeeded, but when MOL starts up, it hangs after the following message:

KVM mapped 0x8100 - 0x8104b000 to 0x5807c000 flags 38

 =
 Mac-on-Linux OpenFirmware 0.9.70
 Boot Disk: /pci/pci-bridge/mol-blk@0/disk@1:0 [HFS]
 Loading 'System Folder:Mac OS ROM' from 'MacOS9.1'
 Timer calibration fix: 41.60 MHz [19744]
 Starting ELF boot loader
 =


Running dmesg | tail in another Terminal yields:

[  263.883473] Couldn't emulate instruction 0x0700 (op 0 xop 896)
[  263.883477] kvmppc_handle_exit: emulation at 700 failed (0700)
[  263.883489] Couldn't emulate instruction 0x0700 (op 0 xop 896)
[  263.883493] kvmppc_handle_exit: emulation at 700 failed (0700)
[  263.883505] Couldn't emulate instruction 0x0700 (op 0 xop 896)
[  263.883509] kvmppc_handle_exit: emulation at 700 failed (0700)
[  263.883521] Couldn't emulate instruction 0x0700 (op 0 xop 896)
[  263.883525] kvmppc_handle_exit: emulation at 700 failed (0700)
[  263.883537] Couldn't emulate instruction 0x0700 (op 0 xop 896)
[  263.883541] kvmppc_handle_exit: emulation at 700 failed (0700)


Any suggestions ?

Cheers

Jochen
--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: kvm error message when trying to run Mac-On-Linux

2013-03-29 Thread Alexander Graf
Hi Jochen,

Am 29.03.2013 um 11:40 schrieb Jochen Rollwagen jochenrollwa...@yahoo.com:

 Hallo there,
 
 i'm trying to run the latest Mac-On-Linux on a mac mini G4 running Ubuntu 
 Precise 12.04 with a 3.4.36-kernel (for nostalgic reasons mainly :-). 
 Building it succeeded, but when MOL starts up, it hangs after the following 
 message:
 
 KVM mapped 0x8100 - 0x8104b000 to 0x5807c000 flags 38
 
 =
 Mac-on-Linux OpenFirmware 0.9.70
 Boot Disk: /pci/pci-bridge/mol-blk@0/disk@1:0 [HFS]
 Loading 'System Folder:Mac OS ROM' from 'MacOS9.1'

Unfortunately I never managed to get Mac OS 9 happy enough to run successfully 
inside of KVM. So far only Mac OS X works :).

However, I'd be more than happy to receive patches that fix this situation ;).


Alex

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html