From patchwork Wed Jan 16 08:24:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharat Bhushan X-Patchwork-Id: 1986941 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id E851BDF2A2 for ; Wed, 16 Jan 2013 08:32:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758722Ab3APIcr (ORCPT ); Wed, 16 Jan 2013 03:32:47 -0500 Received: from am1ehsobe006.messaging.microsoft.com ([213.199.154.209]:26415 "EHLO am1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758088Ab3APIcp (ORCPT ); Wed, 16 Jan 2013 03:32:45 -0500 Received: from mail73-am1-R.bigfish.com (10.3.201.248) by AM1EHSOBE014.bigfish.com (10.3.207.136) with Microsoft SMTP Server id 14.1.225.23; Wed, 16 Jan 2013 08:32:44 +0000 Received: from mail73-am1 (localhost [127.0.0.1]) by mail73-am1-R.bigfish.com (Postfix) with ESMTP id 5042A10008E; Wed, 16 Jan 2013 08:32:44 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 3 X-BigFish: VS3(zzzz1ee6h1de0h1202h1e76h1d1ah1d2ah1082kzz8275bhz2dh2a8h668h839hd24he5bhf0ah107ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h1155h) Received: from mail73-am1 (localhost.localdomain [127.0.0.1]) by mail73-am1 (MessageSwitch) id 1358325162962055_22476; Wed, 16 Jan 2013 08:32:42 +0000 (UTC) Received: from AM1EHSMHS001.bigfish.com (unknown [10.3.201.234]) by mail73-am1.bigfish.com (Postfix) with ESMTP id DE112240078; Wed, 16 Jan 2013 08:32:42 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by AM1EHSMHS001.bigfish.com (10.3.207.101) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 16 Jan 2013 08:32:41 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.2.318.3; Wed, 16 Jan 2013 08:32:24 +0000 Received: from freescale.com ([10.232.15.72]) by az84smr01.freescale.net (8.14.3/8.14.0) with SMTP id r0G8WL3P023699; Wed, 16 Jan 2013 01:32:21 -0700 Received: by freescale.com (sSMTP sendmail emulation); Wed, 16 Jan 2013 13:54:55 +0530 From: Bharat Bhushan To: , , CC: Bharat Bhushan Subject: [PATCH 4/8] Added ONE_REG interface for debug instruction Date: Wed, 16 Jan 2013 13:54:41 +0530 Message-ID: <1358324685-30225-3-git-send-email-bharat.bhushan@freescale.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1358324685-30225-1-git-send-email-bharat.bhushan@freescale.com> References: <1358324685-30225-1-git-send-email-bharat.bhushan@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patch adds the one_reg interface to get the special instruction to be used for setting software breakpoint from userspace. Signed-off-by: Bharat Bhushan --- Documentation/virtual/kvm/api.txt | 1 + arch/powerpc/include/asm/kvm_ppc.h | 1 + arch/powerpc/include/uapi/asm/kvm.h | 3 +++ arch/powerpc/kvm/44x.c | 5 +++++ arch/powerpc/kvm/booke.c | 10 ++++++++++ arch/powerpc/kvm/e500.c | 5 +++++ arch/powerpc/kvm/e500.h | 9 +++++++++ arch/powerpc/kvm/e500mc.c | 5 +++++ 8 files changed, 39 insertions(+), 0 deletions(-) diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt index 09905cb..7e8be9e 100644 --- a/Documentation/virtual/kvm/api.txt +++ b/Documentation/virtual/kvm/api.txt @@ -1775,6 +1775,7 @@ registers, find a list below: PPC | KVM_REG_PPC_VPA_DTL | 128 PPC | KVM_REG_PPC_EPCR | 32 PPC | KVM_REG_PPC_EPR | 32 + PPC | KVM_REG_PPC_DEBUG_INST| 32 4.69 KVM_GET_ONE_REG diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 44a657a..b3c481e 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -235,6 +235,7 @@ union kvmppc_one_reg { void kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); int kvmppc_core_set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); +u32 kvmppc_core_debug_inst_op(void); void kvmppc_get_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); int kvmppc_set_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); diff --git a/arch/powerpc/include/uapi/asm/kvm.h b/arch/powerpc/include/uapi/asm/kvm.h index 16064d0..e81ae5b 100644 --- a/arch/powerpc/include/uapi/asm/kvm.h +++ b/arch/powerpc/include/uapi/asm/kvm.h @@ -417,4 +417,7 @@ struct kvm_get_htab_header { #define KVM_REG_PPC_EPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x85) #define KVM_REG_PPC_EPR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x86) +/* Debugging: Special instruction for software breakpoint */ +#define KVM_REG_PPC_DEBUG_INST (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x87) + #endif /* __LINUX_KVM_POWERPC_H */ diff --git a/arch/powerpc/kvm/44x.c b/arch/powerpc/kvm/44x.c index 3d7fd21..41501be 100644 --- a/arch/powerpc/kvm/44x.c +++ b/arch/powerpc/kvm/44x.c @@ -114,6 +114,11 @@ int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu, return 0; } +u32 kvmppc_core_debug_inst_op(void) +{ + return -1; +} + void kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) { kvmppc_get_sregs_ivor(vcpu, sregs); diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index d2f502d..453a10f 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1424,6 +1424,12 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) r = put_user(vcpu->arch.epcr, (u32 __user *)(long)reg->addr); break; #endif + case KVM_REG_PPC_DEBUG_INST: { + u32 opcode = kvmppc_core_debug_inst_op(); + r = copy_to_user((u32 __user *)(long)reg->addr, + &opcode, sizeof(u32)); + break; + } default: break; } @@ -1467,6 +1473,10 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) break; } #endif + case KVM_REG_PPC_DEBUG_INST: + /* This is read only, so write to this is nop*/ + r = 0; + break; default: break; } diff --git a/arch/powerpc/kvm/e500.c b/arch/powerpc/kvm/e500.c index 6dd4de7..d8a5e8e 100644 --- a/arch/powerpc/kvm/e500.c +++ b/arch/powerpc/kvm/e500.c @@ -367,6 +367,11 @@ int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu) return 0; } +u32 kvmppc_core_debug_inst_op(void) +{ + return KVMPPC_INST_GUEST_GDB; +} + void kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) { struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu); diff --git a/arch/powerpc/kvm/e500.h b/arch/powerpc/kvm/e500.h index c70d37e..17942d2 100644 --- a/arch/powerpc/kvm/e500.h +++ b/arch/powerpc/kvm/e500.h @@ -302,4 +302,13 @@ static inline unsigned int get_tlbmiss_tid(struct kvm_vcpu *vcpu) #define get_tlb_sts(gtlbe) (MAS1_TS) #endif /* !BOOKE_HV */ +/* When setting software breakpoint, Change the software breakpoint + * instruction to special trap/invalid instruction and set + * KVM_GUESTDBG_USE_SW_BP flag in kvm_guest_debug->control. KVM does + * keep track of software breakpoints. So when KVM_GUESTDBG_USE_SW_BP + * flag is set and special trap instruction is executed by guest then + * exit to userspace. + */ +#define KVMPPC_INST_GUEST_GDB 0x7C00021C /* ehpriv OC=0 */ + #endif /* KVM_E500_H */ diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c index 1f89d26..dead142 100644 --- a/arch/powerpc/kvm/e500mc.c +++ b/arch/powerpc/kvm/e500mc.c @@ -199,6 +199,11 @@ int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu) return 0; } +u32 kvmppc_core_debug_inst_op(void) +{ + return KVMPPC_INST_GUEST_GDB; +} + void kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) { struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);