From nobody Mon Feb 9 12:25:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1650464038; cv=none; d=zohomail.com; s=zohoarc; b=R7eKNctXkyktgd7cS3b4troRtrYishgP4W/umrN7OtI3mdA0EsbWWc54n6jq8xDXe5agaSa/RUFFtBUiNUjIIrBhYXK4pCFz32Rgawbz4d1bogUW3ywhey6H9SNoeEIlwGj7h2efcRP5jQKUI4qlyrkPc1qSdfBBCvWGq99NOXw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650464038; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dB67ArLCIEpPNyxONfaccD1YfXbNitP4H1KihjHIsuA=; b=UuRsuS+pwXWF1vOWFHFy7hJbLjq3rwARFL/eqgU/Zy1K8gEXa5Zbmg73PFtm8rBSROkMPOz1uvINGCOD+M0hBmBF7j8h6WksTXyPWO03CPXSJVFt7GagX1yP+/lQwL/nD7DWccCo4rL9RpfUxwaXQ/EO9ezIpo5vWgfSUqS1Haw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1650464038254926.8041653638401; Wed, 20 Apr 2022 07:13:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309289.525429 (Exim 4.92) (envelope-from ) id 1nhB5M-0002Xj-FN; Wed, 20 Apr 2022 14:13:36 +0000 Received: by outflank-mailman (output) from mailman id 309289.525429; Wed, 20 Apr 2022 14:13:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhB5M-0002UH-9J; Wed, 20 Apr 2022 14:13:36 +0000 Received: by outflank-mailman (input) for mailman id 309289; Wed, 20 Apr 2022 14:13:34 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhB5K-0001HT-AK for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 14:13:34 +0000 Received: from esa3.hc3370-68.iphmx.com (esa3.hc3370-68.iphmx.com [216.71.145.155]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0e9d7115-c0b4-11ec-a405-831a346695d4; Wed, 20 Apr 2022 16:13:31 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0e9d7115-c0b4-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1650464011; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZZ4LFIyXhFA4quq56SEIYd7bIBzBk+g+i6q0EnuhZrs=; b=OUigjGYv7JPs0u8TPgMHaQIFwxBINxWk/03gyY7LNJLGpXNqsCbVVwbN cyb1QzdMyZfi73UGX9Hjq0l3F6SiTH0VSDnpFcW8g8LYBXYtSI2TlIMb5 Wn59qCpb3PdwUPzvAPMVu4CkVm9/cX6syKU/ul88W2K3AJgu66y20nwMu k=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 69517262 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:vjG0caOr2XIUO7/vrR2vl8FynXyQoLVcMsEvi/4bfWQNrUp2hGECz mQdDT2AP/eOZTGnKY9yaI3g8UNQvJ/UzoNgTwto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdleF+lH1dOKJQUBUjclkfJKlYAL/En03FFcMpBsJ00o5wbZl2NYw2LBVPivW0 T/Mi5yHULOa82Yc3lI8s8pvfzs24ZweEBtB1rAPTagjUG32zhH5P7pGTU2FFFPqQ5E8IwKPb 72rIIdVXI/u10xF5tuNyt4Xe6CRK1LYFVDmZnF+A8BOjvXez8CbP2lS2Pc0MC9qZzu1c99Z8 e4RqI6LbzwVZaTDnfslYhpfDQBhBPgTkFPHCSDXXc27ykTHdz3nwul0DVFwNoodkgp1KTgQr 7pCcmlLN03dwbLtqF64YrAEasALBc/nJo4A/FpnyinUF60OSpHfWaTao9Rf2V/cg+gQTKuHO JBHM1KDajycPCIQFHQoJKkuhb3rvkPALT5Vgnas8P9fD2/7k1UqjemF3MDuUv6gSNhRn02Yj nnb5Gm/CRYfXPSAzRKV/3TqgfXA9QvrVYRXGLCm+/pChFyI2ndVGBAQTUG8o/Sylgi5Qd03A 0YT8CA/66Up9EimS9D7dxK9qX+A+BUbXrJt//YSsV/XjPCOukDAWzZCHmUphMEaWNEefAd2y 02yuejVXjVgtaKteHGa6JaLlGbnUcQKFlMqaSgBRAoDxtDspoAvkx7CJupe/L6JYs7dQm+pn W3TxMQqr/BK1JNQif3nlbzSq2j0zqUlWDLZ8ek+soiNygpiLLCoaIWzgbQwxaYRdd3JJrVtU ZVtpiR/0AzsJczV/MBuaL9UdF1M2xpiGGeC6WOD57F7q1yQF4eLJOi8Gg1WKkZzKdojcjT0e kLVsg45zMYNYSP2NfUrPN3rW5hCIU3c+TLND6G8gj1mOMYZSeN61Hs2OR74M57FzCDAbp3Ty b/EKJ3xXB72+IxszSasRvd17FPY7ntW+I8nfriil07P+ePHPBa9EO5ZWHPTP7tRxP7V/23oH yN3apLiJ+N3C7WuPEE6MOc7cDg3EJTMLcmv9ZcGJ7LZf1IO9aNII6a5/I7NsrdNx8x9/tokN FnmMqOE4DITXUH6FDg= IronPort-HdrOrdr: A9a23:SYfyb6HUtKQryQkdpLqE0seALOsnbusQ8zAXP0AYc31om6uj5r iTdZUgpGbJYVkqKRIdcLy7V5VoBEmskaKdgrNhW4tKPjOW2ldARbsKheCJrlHd8m/Fh4lgPM 9bAtND4bbLbWSS4/yV3ODBKadE/OW6 X-IronPort-AV: E=Sophos;i="5.90,275,1643691600"; d="scan'208";a="69517262" From: Andrew Cooper To: Xen-devel CC: Bobby Eshleman , Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v5 2/6] x86/gdbsx: Rename debug.c to gdbsx.c Date: Wed, 20 Apr 2022 15:13:03 +0100 Message-ID: <20220420141307.24153-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220420141307.24153-1-andrew.cooper3@citrix.com> References: <20220420141307.24153-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1650464039488100009 From: Bobby Eshleman debug.c contains only dbg_rw_mem(). Rename it to gdbsx.c. Move gdbsx_guest_mem_io(), and the prior setup of iop->remain, from domctl.c to gdbsx.c, merging it with dbg_rw_mem(). Signed-off-by: Bobby Eshleman Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu v5: * Consolidate hunks from multiple v4 patches * Rewrite commit message The semantics are rather broken. XEN_DOMCTL_gdbsx_guestmemio only sets copyback when there's nothing to copy back, and skips copying back in the -EFAULT case when the iop->remain field is relevant. Furthermore, it can be asked to move up to 4GB in one go, with no continuability whatsoever. --- xen/arch/x86/Makefile | 2 +- xen/arch/x86/domctl.c | 14 ++------------ xen/arch/x86/{debug.c =3D> gdbsx.c} | 23 ++++++++++------------- xen/arch/x86/include/asm/debugger.h | 6 ------ xen/arch/x86/include/asm/gdbsx.h | 13 +++++++++++++ 5 files changed, 26 insertions(+), 32 deletions(-) rename xen/arch/x86/{debug.c =3D> gdbsx.c} (89%) create mode 100644 xen/arch/x86/include/asm/gdbsx.h diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 717bcbcac7a0..177a2ff74272 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -22,7 +22,6 @@ obj-y +=3D cpuid.o obj-$(CONFIG_PV) +=3D compat.o obj-$(CONFIG_PV32) +=3D x86_64/compat.o obj-$(CONFIG_KEXEC) +=3D crash.o -obj-$(CONFIG_GDBSX) +=3D debug.o obj-y +=3D delay.o obj-y +=3D desc.o obj-bin-y +=3D dmi_scan.init.o @@ -34,6 +33,7 @@ obj-y +=3D emul-i8254.o obj-y +=3D extable.o obj-y +=3D flushtlb.o obj-$(CONFIG_CRASH_DEBUG) +=3D gdbstub.o +obj-$(CONFIG_GDBSX) +=3D gdbsx.o obj-y +=3D hypercall.o obj-y +=3D i387.o obj-y +=3D i8259.o diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index a6aae500a30b..c20ab4352715 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -20,6 +20,8 @@ #include #include #include + +#include #include #include #include @@ -33,20 +35,9 @@ #include #include #include -#include #include #include =20 -#ifdef CONFIG_GDBSX -static int gdbsx_guest_mem_io(struct domain *d, struct xen_domctl_gdbsx_me= mio *iop) -{ - iop->remain =3D dbg_rw_mem(iop->gva, guest_handle_from_ptr(iop->uva, v= oid), - iop->len, d, iop->gwr, iop->pgd3val); - - return iop->remain ? -EFAULT : 0; -} -#endif - static int update_domain_cpu_policy(struct domain *d, xen_domctl_cpu_policy_t *xdpc) { @@ -827,7 +818,6 @@ long arch_do_domctl( =20 #ifdef CONFIG_GDBSX case XEN_DOMCTL_gdbsx_guestmemio: - domctl->u.gdbsx_guest_memio.remain =3D domctl->u.gdbsx_guest_memio= .len; ret =3D gdbsx_guest_mem_io(d, &domctl->u.gdbsx_guest_memio); if ( !ret ) copyback =3D true; diff --git a/xen/arch/x86/debug.c b/xen/arch/x86/gdbsx.c similarity index 89% rename from xen/arch/x86/debug.c rename to xen/arch/x86/gdbsx.c index 91034a852e5f..59eb31fc9a6a 100644 --- a/xen/arch/x86/debug.c +++ b/xen/arch/x86/gdbsx.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include =20 typedef unsigned long dbgva_t; @@ -150,21 +150,18 @@ static unsigned int dbg_rw_guest_mem(struct domain *d= p, unsigned long addr, return len; } =20 -/* - * addr is guest addr - * buf is debugger buffer. - * if toaddr, then addr =3D buf (write to addr), else buf =3D addr (rd fro= m guest) - * pgd3: value of init_mm.pgd[3] in guest. see above. - * Returns: number of bytes remaining to be copied. - */ -unsigned int dbg_rw_mem(unsigned long gva, XEN_GUEST_HANDLE_PARAM(void) bu= f, - unsigned int len, struct domain *d, bool toaddr, - uint64_t pgd3) +int gdbsx_guest_mem_io(struct domain *d, struct xen_domctl_gdbsx_memio *io= p) { if ( d && !d->is_dying ) - len =3D dbg_rw_guest_mem(d, gva, buf, len, toaddr, pgd3); + { + iop->remain =3D dbg_rw_guest_mem( + d, iop->gva, guest_handle_from_ptr(iop->uva, void), + iop->len, iop->gwr, iop->pgd3val); + } + else + iop->remain =3D iop->len; =20 - return len; + return iop->remain ? -EFAULT : 0; } =20 /* diff --git a/xen/arch/x86/include/asm/debugger.h b/xen/arch/x86/include/asm= /debugger.h index e83b346a21d1..c5585752cae7 100644 --- a/xen/arch/x86/include/asm/debugger.h +++ b/xen/arch/x86/include/asm/debugger.h @@ -54,10 +54,4 @@ static inline bool debugger_trap_fatal( =20 #endif =20 -#ifdef CONFIG_GDBSX -unsigned int dbg_rw_mem(unsigned long gva, XEN_GUEST_HANDLE_PARAM(void) bu= f, - unsigned int len, struct domain *d, bool toaddr, - uint64_t pgd3); -#endif - #endif /* __X86_DEBUGGER_H__ */ diff --git a/xen/arch/x86/include/asm/gdbsx.h b/xen/arch/x86/include/asm/gd= bsx.h new file mode 100644 index 000000000000..eee746fc01d0 --- /dev/null +++ b/xen/arch/x86/include/asm/gdbsx.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __X86_GDBX_H__ +#define __X86_GDBX_H__ + +#ifdef CONFIG_GDBSX + +struct domain; +struct xen_domctl_gdbsx_memio; + +int gdbsx_guest_mem_io(struct domain *d, struct xen_domctl_gdbsx_memio *io= p); + +#endif /* CONFIG_GDBSX */ +#endif /* __X86_GDBX_H__ */ --=20 2.11.0