From patchwork Mon May 12 12:58:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Freimann X-Patchwork-Id: 348025 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 19676140271 for ; Mon, 12 May 2014 23:01:50 +1000 (EST) Received: from localhost ([::1]:37605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WjprX-00075h-Uk for incoming@patchwork.ozlabs.org; Mon, 12 May 2014 09:01:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WjppD-0002zx-Ag for qemu-devel@nongnu.org; Mon, 12 May 2014 08:59:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wjpp3-0000we-HG for qemu-devel@nongnu.org; Mon, 12 May 2014 08:59:23 -0400 Received: from e06smtp18.uk.ibm.com ([195.75.94.114]:60737) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wjpp3-0000wO-9Q for qemu-devel@nongnu.org; Mon, 12 May 2014 08:59:13 -0400 Received: from /spool/local by e06smtp18.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 12 May 2014 13:59:12 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp18.uk.ibm.com (192.168.101.148) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 12 May 2014 13:59:10 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 28B692190063 for ; Mon, 12 May 2014 13:59:01 +0100 (BST) Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s4CCx9nc52035642 for ; Mon, 12 May 2014 12:59:09 GMT Received: from d06av12.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s4CCx8vj026165 for ; Mon, 12 May 2014 06:59:09 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s4CCx7ON026095; Mon, 12 May 2014 06:59:07 -0600 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 1122) id 06CDE122444C; Mon, 12 May 2014 14:59:07 +0200 (CEST) From: Jens Freimann To: Christian Borntraeger , Alexander Graf , Cornelia Huck Date: Mon, 12 May 2014 14:58:51 +0200 Message-Id: <1399899532-43052-4-git-send-email-jfrei@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.5.5 In-Reply-To: <1399899532-43052-1-git-send-email-jfrei@linux.vnet.ibm.com> References: <1399899532-43052-1-git-send-email-jfrei@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14051212-6892-0000-0000-000008C11750 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.114 Cc: David Hildenbrand , Jens Freimann , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 3/4] s390x/kvm: software breakpoint support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: David Hildenbrand This patch allows to insert and remove sw breakpoints using the QEMU gdbserver on s390 as well as to interrupt execution on a breakpoint hit when running with KVM enabled. Whenever a software breakpoint is inserted, common code calls kvm ioctl KVM_UPDATE_GUEST_DEBUG. As this method's default on s390 is to return an error if not implement, the insertion will fail. Therefore, KVM also has to be updated in order to make use of software breakpoints. Signed-off-by: David Hildenbrand Signed-off-by: Jens Freimann Reviewed-by: Cornelia Huck --- target-s390x/kvm.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 70cfe74..bf62c95 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -610,6 +610,22 @@ static void kvm_handle_diag_308(S390CPU *cpu, struct kvm_run *run) handle_diag_308(&cpu->env, r1, r3); } +static int handle_sw_breakpoint(S390CPU *cpu, struct kvm_run *run) +{ + CPUS390XState *env = &cpu->env; + unsigned long pc; + + cpu_synchronize_state(CPU(cpu)); + + pc = env->psw.addr - 4; + if (kvm_find_sw_breakpoint(CPU(cpu), pc)) { + env->psw.addr = pc; + return EXCP_DEBUG; + } + + return -ENOENT; +} + #define DIAG_KVM_CODE_MASK 0x000000000000ffff static int handle_diag(S390CPU *cpu, struct kvm_run *run, uint32_t ipb) @@ -630,7 +646,7 @@ static int handle_diag(S390CPU *cpu, struct kvm_run *run, uint32_t ipb) r = handle_hypercall(cpu, run); break; case DIAG_KVM_BREAKPOINT: - sleep(10); + r = handle_sw_breakpoint(cpu, run); break; default: DPRINTF("KVM: unknown DIAG: 0x%x\n", func_code); @@ -732,7 +748,7 @@ out: return 0; } -static void handle_instruction(S390CPU *cpu, struct kvm_run *run) +static int handle_instruction(S390CPU *cpu, struct kvm_run *run) { unsigned int ipa0 = (run->s390_sieic.ipa & 0xff00); uint8_t ipa1 = run->s390_sieic.ipa & 0x00ff; @@ -759,8 +775,11 @@ static void handle_instruction(S390CPU *cpu, struct kvm_run *run) } if (r < 0) { + r = 0; enter_pgmcheck(cpu, 0x0001); } + + return r; } static bool is_special_wait_psw(CPUState *cs) @@ -780,7 +799,7 @@ static int handle_intercept(S390CPU *cpu) (long)cs->kvm_run->psw_addr); switch (icpt_code) { case ICPT_INSTRUCTION: - handle_instruction(cpu, run); + r = handle_instruction(cpu, run); break; case ICPT_WAITPSW: /* disabled wait, since enabled wait is handled in kernel */