From nobody Fri Nov 7 13:01:39 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547820639748768.0299786993797; Fri, 18 Jan 2019 06:10:39 -0800 (PST) Received: from localhost ([127.0.0.1]:40099 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkUqv-0000BO-Jv for importer@patchew.org; Fri, 18 Jan 2019 09:10:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkUou-0007Ec-Ql for qemu-devel@nongnu.org; Fri, 18 Jan 2019 09:08:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkUor-0002kq-0Q for qemu-devel@nongnu.org; Fri, 18 Jan 2019 09:08:26 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60746) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gkUoq-0002gW-Fh for qemu-devel@nongnu.org; Fri, 18 Jan 2019 09:08:24 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0IDwk5R102942 for ; Fri, 18 Jan 2019 09:08:22 -0500 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2q3e4t5gan-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 18 Jan 2019 09:08:21 -0500 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 18 Jan 2019 14:08:19 -0000 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 18 Jan 2019 14:08:16 -0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0IE8FLX6750374 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 18 Jan 2019 14:08:15 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C696112069; Fri, 18 Jan 2019 14:08:15 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2CBFC112067; Fri, 18 Jan 2019 14:08:13 +0000 (GMT) Received: from farosas.linux.ibm.com.br.ibm.com (unknown [9.86.26.66]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 18 Jan 2019 14:08:12 +0000 (GMT) From: Fabiano Rosas To: qemu-devel@nongnu.org Date: Fri, 18 Jan 2019 12:07:55 -0200 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190118140758.829-1-farosas@linux.ibm.com> References: <20190118140758.829-1-farosas@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19011814-0052-0000-0000-0000037A99F1 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010430; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000275; SDB=6.01148269; UDB=6.00598209; IPR=6.00928572; MB=3.00025187; MTD=3.00000008; XFM=3.00000015; UTC=2019-01-18 14:08:19 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011814-0053-0000-0000-00005F837BDA Message-Id: <20190118140758.829-5-farosas@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-18_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901180101 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [RFC PATCH v3 4/7] kvm-all: Introduce kvm_set_singlestep X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: crosthwaite.peter@gmail.com, aik@ozlabs.ru, cohuck@redhat.com, qemu-ppc@nongnu.org, pbonzini@redhat.com, david@gibson.dropbear.id.au, philmd@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This will allow architecture-specifc implementations of a fallback mechanism for single stepping in cases where KVM does not support it via the KVM_SET_GUEST_DEBUG ioctl. Signed-off-by: Fabiano Rosas --- accel/kvm/kvm-all.c | 9 +++++++++ accel/stubs/kvm-stub.c | 4 ++++ exec.c | 2 +- include/sysemu/kvm.h | 2 ++ stubs/Makefile.objs | 1 + stubs/kvm-arch-set-singlestep.c | 8 ++++++++ 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 stubs/kvm-arch-set-singlestep.c diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 0dc7a32883..8dc5d32f08 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2320,6 +2320,15 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned l= ong reinject_trap) return data.err; } =20 +void kvm_set_singlestep(CPUState *cs, int enabled) +{ + if (kvm_has_guestdbg_singlestep()) { + kvm_update_guest_debug(cs, 0); + } else { + kvm_arch_set_singlestep(cs, enabled); + } +} + int kvm_insert_breakpoint(CPUState *cpu, target_ulong addr, target_ulong len, int type) { diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index 02d5170031..69bd07f50e 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -79,6 +79,10 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned long = reinject_trap) return -ENOSYS; } =20 +void kvm_set_singlestep(CPUState *cs, int enabled) +{ +} + int kvm_insert_breakpoint(CPUState *cpu, target_ulong addr, target_ulong len, int type) { diff --git a/exec.c b/exec.c index 895449f926..6612f90b3a 100644 --- a/exec.c +++ b/exec.c @@ -1234,7 +1234,7 @@ void cpu_single_step(CPUState *cpu, int enabled) if (cpu->singlestep_enabled !=3D enabled) { cpu->singlestep_enabled =3D enabled; if (kvm_enabled()) { - kvm_update_guest_debug(cpu, 0); + kvm_set_singlestep(cpu, enabled); } else { /* must flush all the translated code to avoid inconsistencies= */ /* XXX: only flush what is necessary */ diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index ca2bbff053..e1ef2f5b99 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -247,6 +247,7 @@ bool kvm_memcrypt_enabled(void); */ int kvm_memcrypt_encrypt_data(uint8_t *ptr, uint64_t len); =20 +void kvm_arch_set_singlestep(CPUState *cpu, int enabled); =20 #ifdef NEED_CPU_H #include "cpu.h" @@ -259,6 +260,7 @@ int kvm_remove_breakpoint(CPUState *cpu, target_ulong a= ddr, target_ulong len, int type); void kvm_remove_all_breakpoints(CPUState *cpu); int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap); +void kvm_set_singlestep(CPUState *cs, int enabled); =20 int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr); int kvm_on_sigbus(int code, void *addr); diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index 5dd0aeeec6..145ca9620b 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -16,6 +16,7 @@ stub-obj-y +=3D get-vm-name.o stub-obj-y +=3D iothread.o stub-obj-y +=3D iothread-lock.o stub-obj-y +=3D is-daemonized.o +stub-obj-y +=3D kvm-arch-set-singlestep.o stub-obj-$(CONFIG_LINUX_AIO) +=3D linux-aio.o stub-obj-y +=3D machine-init-done.o stub-obj-y +=3D migr-blocker.o diff --git a/stubs/kvm-arch-set-singlestep.c b/stubs/kvm-arch-set-singleste= p.c new file mode 100644 index 0000000000..ba6e0323d6 --- /dev/null +++ b/stubs/kvm-arch-set-singlestep.c @@ -0,0 +1,8 @@ +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "sysemu/kvm.h" + +void kvm_arch_set_singlestep(CPUState *cpu, int enabled) +{ + warn_report("KVM does not support single stepping"); +} --=20 2.17.1