From nobody Fri May 17 04:49:46 2024 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=1650464037; cv=none; d=zohomail.com; s=zohoarc; b=iXlT8ScI1/fUUWLKsOBgERBm+tKh1OcndK0uZ1UeCVpYAfB5hrKxraNmKfVLbaWRGhPP+sKtcT9XZeGeNDfJ+baiflfgb2+M4VVzDjRqkLvSZBFrTNFxBuNZhWWoJ8NH0OSUzdLNHccVRISZ5dF8LXm0sr/aCOmuc7KT22+2tOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650464037; 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=Mg16OiWxjQYDLtaw9PMZR11ErbfYZHJHB99TjNMC3tY=; b=bnsHwxwtdR5DsFkOz5Es07sfLxKgP7Yx+1N+mttyG62s4tdZvP8hm07AlxB+ShoG69L9ub9J4gEPY6eay4EmhJFE/1/ji4r/umxXlnEmiMo+SDLUhgnYM0gSZC1RZo87NyEYvE1BWeV35fwUIOe+5CecSKSGV9Qy7zGch3PyYfs= 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 1650464037508995.6654152810362; Wed, 20 Apr 2022 07:13:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309287.525417 (Exim 4.92) (envelope-from ) id 1nhB5L-0002Ab-Ce; Wed, 20 Apr 2022 14:13:35 +0000 Received: by outflank-mailman (output) from mailman id 309287.525417; Wed, 20 Apr 2022 14:13:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhB5L-000295-0p; Wed, 20 Apr 2022 14:13:35 +0000 Received: by outflank-mailman (input) for mailman id 309287; Wed, 20 Apr 2022 14:13:33 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhB5J-0001HR-7J for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 14:13:33 +0000 Received: from esa3.hc3370-68.iphmx.com (esa3.hc3370-68.iphmx.com [216.71.145.155]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0e00f121-c0b4-11ec-8fbf-03012f2f19d4; 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: 0e00f121-c0b4-11ec-8fbf-03012f2f19d4 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=ppo83czs3ZgYyCOMzHGediGbdWtmuqhueJbG2O/yc+o=; b=MFSzwkfMhTTu6qlVZq8Q6u+GRglnVaCNO1eZnAk+6K+NiNC6754bx5rm OZj8G0x2rP0tmzM/HbWfhu6TlGXPwgefBbHsdz/3VGj1lx3705SjoN5WB GG5FCLRxHACx0RdeH/mdJ0u8RGVvM9VfwYsvMFRZi8iOz3cWiffCa6GUK 8=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 69517263 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:njTUzKBu+KwjUBVW/yPjw5YqxClBgxIJ4kV8jS/XYbTApGtw0D0Ex msWXm6BM63bZDakLo8ibIuwp0kFsZXTzddjQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMZiaA4E/raNANlFEkvU2ybuOU5NXsZ2YgHWeIdA970Ug5w7Jj2tYx6TSEK1jlV e3a8pW31GCNg1aYAkpMg05UgEoy1BhakGpwUm0WPZinjneH/5UmJMt3yZWKB2n5WuFp8tuSH I4v+l0bElTxpH/BAvv9+lryn9ZjrrT6ZWBigVIOM0Sub4QrSoXfHc/XOdJFAXq7hQllkPhI8 4lQp6eWcjtyN6LJh9wsUB5GMj5HaPguFL/veRBTsOSWxkzCNXDt3+9vHAc9OohwFuRfWD8Us 6ZCcXZUM07F17neLLGTE4GAguwKKsXxMZxZkXZn1TzDVt4tQIzZQrWM7thdtNs1rp4fQK+BP ZRCAdZpRDjqWTJSAlgcM68FgsaV32D5aQ94hmvA8MLb5ECMlVcsgdABKuH9WPaHWMFUlUawv X/d8iLyBRRyHMOb4SqI9DSrnOCntTP2XsceGaO18tZugUaP3SoDBRsOT1y5rPKlzEmkVLp3I Use8DtooLMy8EGuR9/VUBixoXrCtRkZM+e8CMVjtlvLkPCNpV/EWC5UFVatdeDKqucPfmA3x GSvpO+yDDNqr4WkSnWD16it+Gba1TcuEUcOYioNTA0g6tbloZ0ugh+ncuuPAJJZnfWuR2iun mniQDwWwuxK0JVVj/nTEUXv2WrEm3TfcuIiCuw7tEqB5xgxWoOqbpfABbPzvacZd9bxorVsU RE5dymiAAImUMnleM+lGrxl8FSVCxGtamO0vLKXN8N9nwlBAlb6FWyq3BlwJV1yLuEPciLzb UnYtGt5vcEOZCfyN/MoPNjhV6zGKJQM8/y8B5g4ifIUPPBMmPKvpnkyNSZ8IUix+KTTrU3PE cjCKpv9ZZrrIa9m0CC3V48gPUwDnUgDKZfobcmjlXyPiOPGDFbMEOttGAbfNYgRsfLbyDg5B v4CbqNmPT0ECL2gCsQWmKZORW03wY8TXMmo8J0GKrTeemKL2ggJUpfs/F/oQKQ994w9qwsC1 irVtpNwoLYnuUD6FA== IronPort-HdrOrdr: A9a23:4o56TKxqiMif+cPvhn2VKrPwFr1zdoMgy1knxilNoRw8SK2lfq eV7YwmPH7P+U8ssR4b6LO90cW7Lk80sKQFhbX5Xo3SOjUO2lHYTr2KhLGKq1aLdkHDH6xmpM BdmsBFeabN5DNB7foSjjPXLz9Z+qjjzJyV X-IronPort-AV: E=Sophos;i="5.90,275,1643691600"; d="scan'208";a="69517263" 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 1/6] x86/debugger: Remove debugger_trap_entry() Date: Wed, 20 Apr 2022 15:13:02 +0100 Message-ID: <20220420141307.24153-2-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: 1650464039488100010 From: Bobby Eshleman debugger_trap_entry() is unrelated to the other contents of debugger.h. It= is a no-op for everything other than #DB/#BP, and for those it invokes guest debugging (CONFIG_GDBSX) not host debugging (CONFIG_CRASH_DEBUG). Furthermore, the description of how to use debugger_trap_entry() is at best, stale. It is not called from all exception paths, and because the developer is forced to modify Xen to perform debugging, editing debugger_trap_entry()= is not the way one would efficiently go about diagnosing the problem. Simplify everything by expanding debugger_trap_entry() into its two non-emp= ty locations, fixing bugs with their positioning (vs early exceptions and curr not being safe to deference) and for #DB, deferring the pause until the changes in %dr6 are saved to v->arch.dr6 so the debugger can actually see which condition triggered. Signed-off-by: Bobby Eshleman Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu v5: * Remove dead logic. Move GDBSX changes into a later patch. * Rewrite commmit message. --- xen/arch/x86/include/asm/debugger.h | 42 ++-------------------------------= ---- xen/arch/x86/traps.c | 34 +++++++++++++----------------- 2 files changed, 16 insertions(+), 60 deletions(-) diff --git a/xen/arch/x86/include/asm/debugger.h b/xen/arch/x86/include/asm= /debugger.h index 221bcde13796..e83b346a21d1 100644 --- a/xen/arch/x86/include/asm/debugger.h +++ b/xen/arch/x86/include/asm/debugger.h @@ -5,19 +5,12 @@ *=20 * Each debugger should define two functions here: *=20 - * 1. debugger_trap_entry():=20 - * Called at start of any synchronous fault or trap, before any other work - * is done. The idea is that if your debugger deliberately caused the trap - * (e.g. to implement breakpoints or data watchpoints) then you can take - * appropriate action and return a non-zero value to cause early exit from - * the trap function. - *=20 - * 2. debugger_trap_fatal(): + * debugger_trap_fatal(): * Called when Xen is about to give up and crash. Typically you will use = this * hook to drop into a debug session. It can also be used to hook off * deliberately caused traps (which you then handle and return non-zero). * - * 3. debugger_trap_immediate(): + * debugger_trap_immediate(): * Called if we want to drop into a debugger now. This is essentially the * same as debugger_trap_fatal, except that we use the current register s= tate * rather than the state which was in effect when we took the trap. @@ -49,31 +42,6 @@ static inline bool debugger_trap_fatal( /* Int3 is a trivial way to gather cpu_user_regs context. */ #define debugger_trap_immediate() __asm__ __volatile__ ( "int3" ); =20 -static inline bool debugger_trap_entry( - unsigned int vector, struct cpu_user_regs *regs) -{ - /* - * This function is called before any checks are made. Amongst other - * things, be aware that during early boot, current is not a safe poin= ter - * to follow. - */ - struct vcpu *v =3D current; - - if ( vector !=3D TRAP_int3 && vector !=3D TRAP_debug ) - return false; - - if ( guest_mode(regs) && guest_kernel_mode(v, regs) && - v->domain->debugger_attached ) - { - if ( vector !=3D TRAP_debug ) /* domain pause is good enough */ - current->arch.gdbsx_vcpu_event =3D vector; - domain_pause_for_debugger(); - return true; - } - - return false; -} - #else =20 static inline bool debugger_trap_fatal( @@ -84,12 +52,6 @@ static inline bool debugger_trap_fatal( =20 #define debugger_trap_immediate() ((void)0) =20 -static inline bool debugger_trap_entry( - unsigned int vector, struct cpu_user_regs *regs) -{ - return false; -} - #endif =20 #ifdef CONFIG_GDBSX diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 4c38f6c01539..84cd038dc38b 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -946,9 +946,6 @@ void do_trap(struct cpu_user_regs *regs) if ( regs->error_code & X86_XEC_EXT ) goto hardware_trap; =20 - if ( debugger_trap_entry(trapnr, regs) ) - return; - ASSERT(trapnr < 32); =20 if ( guest_mode(regs) ) @@ -1177,9 +1174,6 @@ void do_invalid_op(struct cpu_user_regs *regs) int id =3D -1, lineno; const struct virtual_region *region; =20 - if ( debugger_trap_entry(TRAP_invalid_op, regs) ) - return; - if ( likely(guest_mode(regs)) ) { if ( pv_emulate_invalid_op(regs) ) @@ -1284,8 +1278,7 @@ void do_invalid_op(struct cpu_user_regs *regs) =20 void do_int3(struct cpu_user_regs *regs) { - if ( debugger_trap_entry(TRAP_int3, regs) ) - return; + struct vcpu *curr =3D current; =20 if ( !guest_mode(regs) ) { @@ -1299,6 +1292,13 @@ void do_int3(struct cpu_user_regs *regs) return; } =20 + if ( guest_kernel_mode(curr, regs) && curr->domain->debugger_attached ) + { + curr->arch.gdbsx_vcpu_event =3D TRAP_int3; + domain_pause_for_debugger(); + return; + } + pv_inject_hw_exception(TRAP_int3, X86_EVENT_NO_EC); } =20 @@ -1575,9 +1575,6 @@ void do_page_fault(struct cpu_user_regs *regs) /* fixup_page_fault() might change regs->error_code, so cache it here.= */ error_code =3D regs->error_code; =20 - if ( debugger_trap_entry(TRAP_page_fault, regs) ) - return; - perfc_incr(page_faults); =20 /* Any shadow stack access fault is a bug in Xen. */ @@ -1676,9 +1673,6 @@ void do_general_protection(struct cpu_user_regs *regs) struct vcpu *v =3D current; #endif =20 - if ( debugger_trap_entry(TRAP_gp_fault, regs) ) - return; - if ( regs->error_code & X86_XEC_EXT ) goto hardware_gp; =20 @@ -1971,9 +1965,6 @@ void do_debug(struct cpu_user_regs *regs) /* Stash dr6 as early as possible. */ dr6 =3D read_debugreg(6); =20 - if ( debugger_trap_entry(TRAP_debug, regs) ) - return; - /* * At the time of writing (March 2018), on the subject of %dr6: * @@ -2082,6 +2073,12 @@ void do_debug(struct cpu_user_regs *regs) v->arch.dr6 |=3D (dr6 & ~X86_DR6_DEFAULT); v->arch.dr6 &=3D (dr6 | ~X86_DR6_DEFAULT); =20 + if ( guest_kernel_mode(v, regs) && v->domain->debugger_attached ) + { + domain_pause_for_debugger(); + return; + } + pv_inject_hw_exception(TRAP_debug, X86_EVENT_NO_EC); } =20 @@ -2097,9 +2094,6 @@ void do_entry_CP(struct cpu_user_regs *regs) const char *err =3D "??"; unsigned int ec =3D regs->error_code; =20 - if ( debugger_trap_entry(X86_EXC_CP, regs) ) - return; - /* Decode ec if possible */ if ( ec < ARRAY_SIZE(errors) && errors[ec][0] ) err =3D errors[ec]; --=20 2.11.0 From nobody Fri May 17 04:49:46 2024 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 From nobody Fri May 17 04:49:46 2024 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=1650464043; cv=none; d=zohomail.com; s=zohoarc; b=IpyukAR+mbGXO6+62VcwnE6Qpj6VV5gOchCYZUhrRZyRpSS/cZevRZzgagwFDd6uo5rcuUAsf1jcdfVzFZ20f7ClIb16Z6Wd6Hk7SDSpV0lyGGBqWgc0fqF1oAVlMy6x/V643rGsqJ8+3Y9B3sXE7oj/Y/Y3Oj0UWVD4x2is2y4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650464043; 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=HUQKqu7PPph+vue4GPbPwdzc1oWjPYPNfheiRCzOWx4=; b=kJVIgzLizMtjqzWt+isGyWucpFoT/DoPr0+TsNuOZ676E5eQ1JXcTC1zEP09PBc1CRPk4s0Dp7WOgv5KyiPYOJdItA3oSVDqf9jej/9ct9gbW0OB54mQknx3UVXeUtPB6ZsQaBox/kH56xOSF1rNa/yWvjaKwIDWm8Y8V8GvXLg= 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 1650464043702204.7661605197943; Wed, 20 Apr 2022 07:14:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309285.525393 (Exim 4.92) (envelope-from ) id 1nhB5I-0001aX-Cr; Wed, 20 Apr 2022 14:13:32 +0000 Received: by outflank-mailman (output) from mailman id 309285.525393; Wed, 20 Apr 2022 14:13:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhB5I-0001Zd-4w; Wed, 20 Apr 2022 14:13:32 +0000 Received: by outflank-mailman (input) for mailman id 309285; Wed, 20 Apr 2022 14:13:31 +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 1nhB5H-0001HT-EW for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 14:13:31 +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 0c15dbb2-c0b4-11ec-a405-831a346695d4; Wed, 20 Apr 2022 16:13:29 +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: 0c15dbb2-c0b4-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1650464008; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3bpTvdBqxpC9w/lc1aSyt+uk0x3/FV7Yyt5iB0rwB6Y=; b=Ye6j4eWlS1RvHlAmMTEQHanJDoYHJUjQh+fIR4IQsCo+3oYgj6UgXOo7 jRYuNxjaQJ5Umnq8BmMtrk9e+R7grWae8TpWjtbibKGF8WkemLhzQflmp ML9bRRPQFyhwbkJWWYsVn2h1BQSy06MWNAlkf77xZcL22cJ7DWtTg5HBM I=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 69517259 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:RL9cHaBDpYr7yxVW/1njw5YqxClBgxIJ4kV8jS/XYbTApGgl0mAGz 2BJUDuFMq2PZTCjKtkjPI2xpkIF6sPRmtZnQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMZiaA4E/raNANlFEkvU2ybuOU5NXsZ2YgHWeIdA970Ug5w7Jj2tYx6TSEK1jlV e3a8pW31GCNg1aYAkpMg05UgEoy1BhakGpwUm0WPZinjneH/5UmJMt3yZWKB2n5WuFp8tuSH I4v+l0bElTxpH/BAvv9+lryn9ZjrrT6ZWBigVIOM0Sub4QrSoXfHc/XOdJFAXq7hQllkPhI8 4lQp6eWcjtyN6LJh9wsUB5GMj5HaPguFL/veRBTsOSWxkzCNXDt3+9vHAc9OohwFuRfWD8Us 6ZCcXZUM07F17neLLGTE4GAguwKKsXxMZxZkXZn1TzDVt4tQIzZQrWM7thdtNs1rp4fQK+BP ZdIAdZpRFPKJE1DA0oSNLQvteSmlHfkIxoGqHvA8MLb5ECMlVcsgdABKuH9ZdiiVchT2EGCq Qru3U70HxUbP9y30iee/zSngeqntTP2XsceGaO18tZugUaP3SoDBRsOT1y5rPKlzEmkVLpix 1c8o3R06/JorQryE4e7D0bQTGO4UgA0YuEMDv8BzjqxkaPb5hmhN2sDUB9eUYlz3CMpfgAC2 liMltLvIDVgtryJVH6QnoupQSOO1Ts9djFbO3JdJecRy5y6+dxo0EqTJjp2OPTt5uAZDw0c1 NxjQMIWo7wIxfAG2Kyglbwsq2L9/8OZJuLZC+i+Y45E0u+bTNP9D2BLwQKChRqlEGp+ZgPf1 EXoY+DEsIgz4WilzURhutklErCz/OqiOzbBm1NpFJRJ323zpib/JdoMv24kdBsB3iM4ldnBO R67VeR5vsE7AZdXRfUvP9LZ5zoCkcAM6ugJptiLN4ETM/CdhSeM/T10ZF744oweuBNErE3LA r/CKZzEJS9DUcxPlWPqL89AgORD7n1vmgvuqWXTkk3PPUy2PybFF9/o8TKmM4gE0U9ziFyMr Y0OZpfQlk03vS+XSnC/zLP/5GsidRATba0aYeQNHgJfCmKKwF0cNsI= IronPort-HdrOrdr: A9a23:1vSlO6tXvfEeQotpB9Wl266T7skDTtV00zEX/kB9WHVpmszxra 6TdZMgpGbJYVcqKRcdcL+7WJVoLUmxyXcx2/h1AV7AZniAhILLFvAA0WKK+VSJcEeSygce79 YFT0EXMqyJMbEQt6fHCWeDfOrIuOP3kpyVuQ== X-IronPort-AV: E=Sophos;i="5.90,275,1643691600"; d="scan'208";a="69517259" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v5 3/6] x86/gdbsx: Move domain_pause_for_debugger() into gdbsx Date: Wed, 20 Apr 2022 15:13:04 +0100 Message-ID: <20220420141307.24153-4-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: 1650464045494100001 domain_pause_for_debugger() is guest debugging (CONFIG_GDBSX) not host debugging (CONFIG_CRASH_DEBUG). Move it into the new gdbsx.c to drop the (incorrect) ifdefary, and provide a static inline in the !CONFIG_GDBSX case so callers can optimise away everything rather than having to emit a call to an empty function. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu v5: * Basically new. Reworked entirely after re-considering other cleanup. --- xen/arch/x86/domain.c | 14 -------------- xen/arch/x86/gdbsx.c | 14 ++++++++++++++ xen/arch/x86/hvm/svm/svm.c | 2 +- xen/arch/x86/hvm/vmx/realmode.c | 3 ++- xen/arch/x86/hvm/vmx/vmx.c | 2 +- xen/arch/x86/include/asm/debugger.h | 2 -- xen/arch/x86/include/asm/gdbsx.h | 6 ++++++ xen/arch/x86/nmi.c | 1 - xen/arch/x86/traps.c | 1 + 9 files changed, 25 insertions(+), 20 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index a5048ed6546a..a72cc9552ad6 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -2540,20 +2540,6 @@ static int __init cf_check init_vcpu_kick_softirq(vo= id) } __initcall(init_vcpu_kick_softirq); =20 -void domain_pause_for_debugger(void) -{ -#ifdef CONFIG_CRASH_DEBUG - struct vcpu *curr =3D current; - struct domain *d =3D curr->domain; - - domain_pause_by_systemcontroller_nosync(d); - - /* if gdbsx active, we just need to pause the domain */ - if ( curr->arch.gdbsx_vcpu_event =3D=3D 0 ) - send_global_virq(VIRQ_DEBUGGER); -#endif -} - /* * Local variables: * mode: C diff --git a/xen/arch/x86/gdbsx.c b/xen/arch/x86/gdbsx.c index 59eb31fc9a6a..6ef46e8ea77d 100644 --- a/xen/arch/x86/gdbsx.c +++ b/xen/arch/x86/gdbsx.c @@ -18,6 +18,8 @@ #include #include #include +#include + #include #include =20 @@ -164,6 +166,18 @@ int gdbsx_guest_mem_io(struct domain *d, struct xen_do= mctl_gdbsx_memio *iop) return iop->remain ? -EFAULT : 0; } =20 +void domain_pause_for_debugger(void) +{ + struct vcpu *curr =3D current; + struct domain *d =3D curr->domain; + + domain_pause_by_systemcontroller_nosync(d); + + /* if gdbsx active, we just need to pause the domain */ + if ( curr->arch.gdbsx_vcpu_event =3D=3D 0 ) + send_global_virq(VIRQ_DEBUGGER); +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 2455835eda62..0849a9dc5f41 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/xen/arch/x86/hvm/vmx/realmode.c b/xen/arch/x86/hvm/vmx/realmod= e.c index cc23afa788c2..4ac93e081015 100644 --- a/xen/arch/x86/hvm/vmx/realmode.c +++ b/xen/arch/x86/hvm/vmx/realmode.c @@ -14,7 +14,8 @@ #include #include #include -#include + +#include #include #include #include diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index af9ee7cebbe0..cc8c4e9f044a 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/xen/arch/x86/include/asm/debugger.h b/xen/arch/x86/include/asm= /debugger.h index c5585752cae7..9a3132356fd6 100644 --- a/xen/arch/x86/include/asm/debugger.h +++ b/xen/arch/x86/include/asm/debugger.h @@ -26,8 +26,6 @@ #include #include =20 -void domain_pause_for_debugger(void); - #ifdef CONFIG_CRASH_DEBUG =20 #include diff --git a/xen/arch/x86/include/asm/gdbsx.h b/xen/arch/x86/include/asm/gd= bsx.h index eee746fc01d0..938eb74e2e25 100644 --- a/xen/arch/x86/include/asm/gdbsx.h +++ b/xen/arch/x86/include/asm/gdbsx.h @@ -9,5 +9,11 @@ struct xen_domctl_gdbsx_memio; =20 int gdbsx_guest_mem_io(struct domain *d, struct xen_domctl_gdbsx_memio *io= p); =20 +void domain_pause_for_debugger(void); + +#else + +static inline void domain_pause_for_debugger(void) {} + #endif /* CONFIG_GDBSX */ #endif /* __X86_GDBX_H__ */ diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c index 302eaf2ff39a..765602374802 100644 --- a/xen/arch/x86/nmi.c +++ b/xen/arch/x86/nmi.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include =20 diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 84cd038dc38b..d91532461189 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include --=20 2.11.0 From nobody Fri May 17 04:49:46 2024 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=1650464036; cv=none; d=zohomail.com; s=zohoarc; b=U8tAkywxqxkaPpjmNNJktLhxeFqb97zHQQ5zQoalQDah3nvvoJxq1EfCjn6SeNXHKVbFVxR4VXvRnr1pK+7Yt9E/58zt4vRiomFohsJhJTmlb4lG7bSKjDaxb/kBd639W4D82Leo6O9pNSouJMocnNRe0BxXVTtDk6Up4Xv8rtc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650464036; 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=nfVC74MjtSSSbbldhz4yQveURuTwMFIAiu5SkiyqYIM=; b=OQAGE6TbvHIAMMFsFmCOG8AJ0bMoZRNqpqgPMlinNQPQWvpWQ9wpHp4Fkr7nlHjsPwYuckbV9Eg57X8il/fAcFo/bPcYOiJgmW+TGlBQ7EzVSfvZxGcwnsJBQpvfYLFvYmZmFUYTMr558tOmPFne2B49T1rq2sAjK2SKRk4+zsQ= 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 1650464036802901.954838123152; Wed, 20 Apr 2022 07:13:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309284.525388 (Exim 4.92) (envelope-from ) id 1nhB5I-0001XJ-0C; Wed, 20 Apr 2022 14:13:32 +0000 Received: by outflank-mailman (output) from mailman id 309284.525388; Wed, 20 Apr 2022 14:13:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhB5H-0001XC-Sq; Wed, 20 Apr 2022 14:13:31 +0000 Received: by outflank-mailman (input) for mailman id 309284; Wed, 20 Apr 2022 14:13:31 +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 1nhB5G-0001HT-Sl for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 14:13:31 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0be2b538-c0b4-11ec-a405-831a346695d4; Wed, 20 Apr 2022 16:13:28 +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: 0be2b538-c0b4-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1650464008; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6rpyxvnpX51Fwc4NnxSavHiI4jI1PWIWDeeEhjuyTPM=; b=J4X0MrkgbbeuhmOy9eFyME3MgFYMBH6RZUzAX5r5HuSkl5TuavXAKUUn thBmwuIRC0P3455pxSY5Q7dqt59ZQb2LlsM4TNiQA5vy+DvDYq1izDs+/ lBWi9ovLyy7LPLA7RH/CuJbcgfumghGlItAUrCQEKgr0cKRa+kUHcoSwr 0=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 69534205 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:dHYvx6x9cewgMImUpfR6t+dHxirEfRIJ4+MujC+fZmUNrF6WrkUDy moYDzrTbquMajbwKIwlO9618BgDuJHVy4dqSQI4qyAxQypGp/SeCIXCJC8cHc8zwu4v7q5Dx 59DAjUVBJlsFhcwnj/0bv656yMUOZigHtIQMsadUsxKbVIiGX9JZS5LwbZj2NY024DhWmthh PupyyHhEA79s9JLGjp8B5Kr8HuDa9yr5Vv0FnRnDRx6lAe2e0s9VfrzFonoR5fMeaFGH/bSe gr25OrRElU1XfsaIojNfr7TKiXmS1NJVOSEoiI+t6OK2nCuqsGuu0qS2TV1hUp/0l20c95NJ NplmZWUQlwDJbX1qO0zVgl0Kg5zG4BhweqSSZS/mZT7I0zudnLtx7NlDV0sPJ1e8eFyaY1M3 aVGcnZXNEnF3r/ohuLgIgVvrp1LwM3DFYUToHx/ixreCu4rW8vrSKTW/95Imjw3g6iiGN6AN pdCNWA3MXwsZTVJYUYlS8pit93zoVzlThICimm1tJUetj27IAtZj+G2bYu9lsaxbdpRtlaVo CTB5WuRKjMwOcGbyDGF2mmxneKJliT+MKoCGbv9+vN0jVm7wm0IFAZQRVa9ueO+iEO1R5RYM UN8x8Y1hfFsrgrxFIC7BkDm5i7f1vIBZzZOO8EzzArW4LHM2jaQKG0UYgduZfoLk/ZjEFTGy WS1t9/uADVutpicRnSc6qqYoFuOBMQFEYMRTXRaFFVYurEPtKl210uSFYg7TMZZm/WvQVnNL ya2QD/Sbln5peoCzO2F8F/OmFpATbCZH1dutm07so9Ihz6VhbJJhaT1sTA3Dt4ade51q2VtW 1BexaCjABgmV83lqcB0aLxl8EuVz/iEKibAplVkAoMs8T+gk1b6I90IvGkkeBg2aJZYEdMMX KM1kVoAjHO0FCH0BZKbnqrrU5h6pUQePYiNug/ogipmPcEqKV7vENBGbk+MxWH9+HXAYolkU ap3hf2EVC5AYYw+lWLeb75EjdcDm3FlrUuOFM+T8vhS+efHDJJjYexdYAXmgyFQxP7snTg5B P4GbpXRmkQDCrCmCsQVmKZKRW03wbEALcieg6RqmiSrfmKKxElJ5yft/I4c IronPort-HdrOrdr: A9a23:jOnAC6DMw5WSRT/lHemU55DYdb4zR+YMi2TC1yhKJyC9Ffbo7v xG/c5rsyMc5wxwZJhNo7y90ey7MBbhHP1OkO4s1NWZLWrbUQKTRekIh+bfKn/baknDH4ZmpN 9dmsNFaeEYY2IUsS+D2njbL+od X-IronPort-AV: E=Sophos;i="5.90,275,1643691600"; d="scan'208";a="69534205" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v5 4/6] x86/gdbstub: Clean up includes Date: Wed, 20 Apr 2022 15:13:05 +0100 Message-ID: <20220420141307.24153-5-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: 1650464939238100001 common/gdbstub.c wants struct gdb_context but only gets it transitively through asm/debugger.h. None of */gdbstub.c should include asm/debugger.h = so include xen/gdbstub.h instead. Forward declare struct cpu_user_regs in xen/gdbstub.h so it doesn't depend = on the include order to compile. x86/setup.c doesn't need xen/gdbstub.h at all, so drop it. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu v5: * New --- xen/arch/x86/gdbstub.c | 5 ++++- xen/arch/x86/setup.c | 1 - xen/arch/x86/x86_64/gdbstub.c | 2 +- xen/common/gdbstub.c | 3 ++- xen/include/xen/gdbstub.h | 2 ++ 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/gdbstub.c b/xen/arch/x86/gdbstub.c index 8f4f49fd3b54..961cae0be74f 100644 --- a/xen/arch/x86/gdbstub.c +++ b/xen/arch/x86/gdbstub.c @@ -18,7 +18,10 @@ * You should have received a copy of the GNU General Public License * along with this program; If not, see . */ -#include +#include +#include + +#include =20 u16 gdb_arch_signal_num(struct cpu_user_regs *regs, unsigned long cookie) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 6f20e178929f..53a73010e029 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/xen/arch/x86/x86_64/gdbstub.c b/xen/arch/x86/x86_64/gdbstub.c index 2626519c89c7..8287124dfb1d 100644 --- a/xen/arch/x86/x86_64/gdbstub.c +++ b/xen/arch/x86/x86_64/gdbstub.c @@ -17,7 +17,7 @@ * along with this program; If not, see . */ =20 -#include +#include =20 #define GDB_REG64(r) gdb_write_to_packet_hex(r, sizeof(u64), ctx) #define GDB_REG32(r) gdb_write_to_packet_hex(r, sizeof(u32), ctx) diff --git a/xen/common/gdbstub.c b/xen/common/gdbstub.c index d6872721dc0d..df8d122bce8d 100644 --- a/xen/common/gdbstub.c +++ b/xen/common/gdbstub.c @@ -38,13 +38,14 @@ #include #include #include -#include #include #include #include #include #include #include +#include + #include =20 /* Printk isn't particularly safe just after we've trapped to the diff --git a/xen/include/xen/gdbstub.h b/xen/include/xen/gdbstub.h index 0b2041095d88..18c960969b76 100644 --- a/xen/include/xen/gdbstub.h +++ b/xen/include/xen/gdbstub.h @@ -25,6 +25,8 @@ =20 #ifdef CONFIG_CRASH_DEBUG =20 +struct cpu_user_regs; + struct gdb_context { int serhnd; /* handle on our serial line */ int console_steal_id; /* handle on stolen console */ --=20 2.11.0 From nobody Fri May 17 04:49:46 2024 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=1650464035; cv=none; d=zohomail.com; s=zohoarc; b=k8pCHFO1QsJpq2oQemHC82WaOzwTFMrwg+rLjDQX0F9BjXAjGCsiULt+rc0nHQW6Z4wHt7J2zhNBFMmLeaY5qrT2uTqbcEYpjPiR96uOkO5gFunQC8OggmEMSx25YNpQCN5UhM/zPo8+G9omwbZOGCmS0pDRcWUDC9/unnpU1jI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650464035; 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=AQ3Vx9iNzsjaTilbDD4GewVqWVGFm05whm69NXU+F6Y=; b=XddF5WS1GJwWjRVWzUR5lxK6cDWLHp/DGvLjMF4n3miKUzHzRif629xBXTIzkYfSXTDSStMrDWcyDpaYCppeD4wnMeFbVET4vUU4Q/sQaCJ/S0oPHgPoFaz38GLTlO7aHtyWHamy8cCpoH2EadhYdjrzSxDnBNV2TrfqU2BrsNM= 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 1650464035449253.62267910593414; Wed, 20 Apr 2022 07:13:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309286.525410 (Exim 4.92) (envelope-from ) id 1nhB5K-000268-Q1; Wed, 20 Apr 2022 14:13:34 +0000 Received: by outflank-mailman (output) from mailman id 309286.525410; Wed, 20 Apr 2022 14:13:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhB5K-00025u-Lk; Wed, 20 Apr 2022 14:13:34 +0000 Received: by outflank-mailman (input) for mailman id 309286; Wed, 20 Apr 2022 14:13:32 +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 1nhB5I-0001HT-A0 for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 14:13:32 +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 0df5faec-c0b4-11ec-a405-831a346695d4; Wed, 20 Apr 2022 16:13:30 +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: 0df5faec-c0b4-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1650464010; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qmoska+aIxotu+Z9bq9lWSYhYAKM0rZmYd2eehh+pdw=; b=ZtaAE8PvL6sqmWb5OxPYlVy72qOwxQoSED31YAhOuMOU4a5MsRRn/OFd 5X5liRGvz3sG9qNIBfYkBfx7D15qRFx2RNtxtCgDLIpF4X3I8hAA/FT7w jezmkrCs6eAYrQU3An6N1QRSI64hBObjzyPu/1V7KOL3CRtMKydm+oDy8 8=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 69517260 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:0kYFbKJnwVqI8b+rFE+RoZUlxSXFcZb7ZxGr2PjKsXjdYENS0zJRn zBKXmrTbv2KZmD8fNlzbY618UsPscTUxtE1HQBlqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokf0/0vrav67xZVF/fngqoDUUYYoAQgsA148IMsdoUg7wbRh3tQw2YHR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 Ox26YGiciESAvbFl+ECayhbFD9fIpQTrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBODtMJkSpTdLyjbBAOx9aZvCX7/L9ZlT2zJYasVmQ6eDP pVDN2IHgBLoOTBzYnQLV7YFn/qmmVnSajkAj12MjP9ii4TU5FMoi+W8WDbPQfSVQe1Fk0Deo XjJl0zbKBwHMN2UyRKe72mhwOTImEvTSI8UUbG16PNuqFmS3XAITg0bU0Ohpvu0gVL4XMhQQ 3H44QJ38/J0rhbyCICgAVvo+xZooyLwRfJpKLEn+jqr8ZaP6gmcGVA1TTlfScMf4ZpeqSMR6 neFmNbgBDpKubKTSG6A+rr8kQ5eKRT5PkdZO3ZaEFJtD83L5dhq00mRFooL/Lud1IWdJN3m/ 9ydQMHSbZ03hNVD6ai09Euvb9mE9smQFV5dCuk6swuYAuJFiGyNOtTABbvzt68owGOlor6p5 iZspiRmxLpSZaxhbQTUKAn3IJmn5uyeLBrXikN1Ep8q+lyFoiD+JdwIum0hex05bq7onAMFh meK6Gu9A7cJYhOXgVJfOdrtW6zGM4C8fTgaahwkRoUXOcUgHON21CpveVSRzwjQfLsEyskC1 WOgWZ/0Vx4yUP0/pBLvHrt1+eJ6nUgWmDKMLa0XOjz6iNJyklbOEedbWLZPB8hkhJ65TPL9q o8BbJrbl08CCIUToED/qOYuELzDFlBjbbieliCdXrXrztZOcI35N8Ls/A== IronPort-HdrOrdr: A9a23:yVRE/65m3dlgKvVMtAPXwPLXdLJyesId70hD6qhwISY1TiX+rb HXoB17726MtN9/YgBCpTntAsa9qDbnhPpICOoqTNGftWvdyQmVxehZhOOIqVCNJ8S9zJ876U 4JSdkENDSaNzhHZKjBjjVQa+xQpeW6zA== X-IronPort-AV: E=Sophos;i="5.90,275,1643691600"; d="scan'208";a="69517260" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v5 5/6] x86/debugger: Misc cleanup prior to splitting Date: Wed, 20 Apr 2022 15:13:06 +0100 Message-ID: <20220420141307.24153-6-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: 1650464037896100007 * Remove inappropriate semicolon from debugger_trap_immediate() * Try to explain what debugger_trap_fatal() is doing, and write it in a mo= re legible way. * Drop unecessary includes. This includes common/domain.c which doesn't u= se any debugger functionality, even prior to this cleaup. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu v5: * New --- xen/arch/x86/include/asm/debugger.h | 17 +++++++++++------ xen/common/domain.c | 1 - 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/include/asm/debugger.h b/xen/arch/x86/include/asm= /debugger.h index 9a3132356fd6..5bac2ee4c2a4 100644 --- a/xen/arch/x86/include/asm/debugger.h +++ b/xen/arch/x86/include/asm/debugger.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /*************************************************************************= ***** * asm/debugger.h *=20 @@ -22,23 +23,27 @@ #ifndef __X86_DEBUGGER_H__ #define __X86_DEBUGGER_H__ =20 -#include -#include -#include - #ifdef CONFIG_CRASH_DEBUG =20 #include +#include + +#include =20 +/* Returns true if GDB handled the trap, or it is surviveable. */ static inline bool debugger_trap_fatal( unsigned int vector, struct cpu_user_regs *regs) { int rc =3D __trap_to_gdb(regs, vector); - return ((rc =3D=3D 0) || (vector =3D=3D TRAP_int3)); + + if ( rc =3D=3D 0 ) + return true; + + return vector =3D=3D X86_EXC_BP; } =20 /* Int3 is a trivial way to gather cpu_user_regs context. */ -#define debugger_trap_immediate() __asm__ __volatile__ ( "int3" ); +#define debugger_trap_immediate() __asm__ __volatile__ ( "int3" ) =20 #else =20 diff --git a/xen/common/domain.c b/xen/common/domain.c index 351029f8b239..8d2c2a989708 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include --=20 2.11.0 From nobody Fri May 17 04:49:46 2024 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=1650464035; cv=none; d=zohomail.com; s=zohoarc; b=Rp4OK68lJrocj4budQDGc4RsE4gagk2l8jYafwTd7t3Na4iuzAQHzp74jti1kkCRbEf7m9bsGK3X1eQ/VQPrJvUayf3rCFALDR3j7353yA7KvSYgtUMO0ThYLzlQNmEejBfJpOcx/iA46qAsqExi6lRC8k+2Yi2exjdmL+nYYAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650464035; 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=oY/YInZIuiPMZ4VleeaSEWXR5lSqWx0mXH+PHboNE5A=; b=b9Of6IxypClze3FWRE8J4LpThEQjRliQqg6D8tlCaRZbupNdYYlGvxokKoLQKiO79fFuD9HCw4EqTVAfjAEMvuoP3ICwe4C8iC0Q31kpdee0coM/cK9rll4Gyfrd7YNK0Xc5cHEtc4SkMcMaLS54UNKuxIiDIk04gBJwNKq1ljk= 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 1650464035668874.7971943736969; Wed, 20 Apr 2022 07:13:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309288.525423 (Exim 4.92) (envelope-from ) id 1nhB5L-0002Jh-R0; Wed, 20 Apr 2022 14:13:35 +0000 Received: by outflank-mailman (output) from mailman id 309288.525423; Wed, 20 Apr 2022 14:13:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhB5L-0002Gm-HI; Wed, 20 Apr 2022 14:13:35 +0000 Received: by outflank-mailman (input) for mailman id 309288; Wed, 20 Apr 2022 14:13:33 +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 1nhB5J-0001HT-AI for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 14:13:33 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0de30529-c0b4-11ec-a405-831a346695d4; Wed, 20 Apr 2022 16:13:30 +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: 0de30529-c0b4-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1650464010; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gXnxEoUiWo8s2nXZt3K2P0Lqj86T6+uf6sicbBh7yZU=; b=J3knBZaezJhIuzzcdTBpkP7meSkUhWyAX3Mdu2a07ASW/Shr9T+UAO70 XScZz+mSFegg09ZEhyoJNPO+9UI44Uozgw68ohqRQXxL0mzBOlJoc7C6q 2Y8ZPkA8J84NL9a5KM/YENkyM3JgBKYlktD4ksgdJdflWSW/VSamAZ9OL k=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 69534207 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:ZpbATarVUlS7DXBnP68teaupsJBeBmLwZRIvgKrLsJaIsI4StFCzt garIBmCP6uNZGv1LY10Ydni8kgBvJPSz9BqTwNrq39gFC4Q9JuZCYyVIHmrMnLJJKUvbq7GA +byyDXkBJppJpMJjk71atANlVEliefQAOCU5NfsYkidfyc9IMsaoU8lyrZRbrJA24DjWVvR4 4uq+qUzBXf+s9JKGjNMg068gEsHUMTa4Fv0aXRnOJinFHeH/5UkJMp3yZOZdhMUcaENdgKOf M7RzanRw4/s10xF5uVJMFrMWhZirrb6ZWBig5fNMkSoqkAqSicais7XOBeAAKv+Zvrgc91Zk b1wWZKMpQgBEqTok783SAFhIyhQOL1qwZDKB1WYiJnGp6HGWyOEL/RGCUg3OcsT+/ptAHEI/ vsdQNwPRknd3aTsmuv9E7QywJR4RCXoFNp3VnVI5DfVF/s5B7vERL3H/4Rw1zYsnMFeW/3ZY qL1bBIxPUmbP0cXZT/7Droz3+r02lXgIgRhj2O0+7sq8y+CzQF+he2F3N39JYXRGJQ9clyjj mDb+2X0BDkKOdrZziCKmlqzgsffkCW9X5gdfJWy++R2mlSVyioWAQcPSFqgifCjjwi1XNc3A 3IT/i0ivK0j7nuBR9P2XwC7iHOctxtaUN1Ve8Uw7wuH2+zZ+AadC20NSBZObdUnsIk9QjlC/ k+EmZblCCJitJWRSGmB7fGEoDWqIy8XIGQeIygeQmMt+ML/qYs+ihbOSNdLE6OviNDxXzbqz FiijgIzmrEShs4jzLig8BbMhDfEm3TSZldrvEONBDvjt14nIt7+D2C11bTFxdpJCI3CZEKZh UgNtc2OwNkhALegsxXYFY3hA4qVz/qCNTTdh3tmEJ8g6ymh9hafQGxA3N1tDBw3a5hZIFcFd GeW4FoMv8ELYBNGeIctO+qM59IWIb8M/DgPftTddZJwb5d4b2drFwk+NBfLjwgBfKXB+JzT2 Kt3k+7xVR726ow9lVJaotvxNpdxmEgDKZv7H8yT8vhe+eP2iISpYbkEKkCSSesy8bmJpg7Ym /4GaZbSl00FDLKhOHmLmWL2EbzsBSFqbXwRg5YJHtNv3yI8QD1xYxMv6e9Jl3NZc1R9yb6To yDVtr5ww1vjn3zXQThmmVg4AI4Dqa1X9CphVQR1ZA7A8yF6Pe6HsfZEH7NqLOZPyQCW5aMtJ xXzU57YUqonp/Wu02l1UKQRW6Q7LUrw1FPSZXf9CNX9FrY5LzH0FhbfVlOH3EEz4uCf6aPSf 5XIOtvnfKc+ IronPort-HdrOrdr: A9a23:m3VoOamXvnPmrWDt/Obggpc5ltHpDfIU3DAbv31ZSRFFG/Fxl6 iV8sjzsiWE8Qr5OUtQ/+xoV5PhfZqxz/JICMwqTNKftWrdyQyVxeNZnOjfKlTbckWUnINgPO VbAsxD4bXLfCBHZK3BgTVQfexO/DD+ytHLudvj X-IronPort-AV: E=Sophos;i="5.90,275,1643691600"; d="scan'208";a="69534207" From: Andrew Cooper To: Xen-devel CC: Bobby Eshleman , Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , "Bertrand Marquis" Subject: [PATCH v5 6/6] xen: Split x86/debugger.h into common and arch specific parts Date: Wed, 20 Apr 2022 15:13:07 +0100 Message-ID: <20220420141307.24153-7-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: 1650464037613100004 From: Bobby Eshleman With all the non-CONFIG_CRASH_DEBUG functionality moved elsewhere, split x86/debugger.h in two, with the stubs and explanation moved to xen/debugger= .h. In particular, this means that arches only need to provide an $arch/debugge= r.h if they implement CONFIG_CRASH_DEBUG, and ARM's stub can be deleted. Signed-off-by: Bobby Eshleman Signed-off-by: Andrew Cooper Acked-by: Julien Grall Acked-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis v5: * Clean up includes * Drop rendundant comments --- xen/arch/arm/include/asm/debugger.h | 15 -------- xen/arch/x86/include/asm/debugger.h | 34 +---------------- xen/arch/x86/traps.c | 2 +- xen/common/keyhandler.c | 2 +- xen/common/shutdown.c | 2 +- xen/drivers/char/console.c | 2 +- .../x86/include/asm =3D> include/xen}/debugger.h | 44 +++++++---------= ------ 7 files changed, 20 insertions(+), 81 deletions(-) delete mode 100644 xen/arch/arm/include/asm/debugger.h copy xen/{arch/x86/include/asm =3D> include/xen}/debugger.h (54%) diff --git a/xen/arch/arm/include/asm/debugger.h b/xen/arch/arm/include/asm= /debugger.h deleted file mode 100644 index ac776efa7899..000000000000 --- a/xen/arch/arm/include/asm/debugger.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef __ARM_DEBUGGER_H__ -#define __ARM_DEBUGGER_H__ - -#define debugger_trap_fatal(v, r) (0) -#define debugger_trap_immediate() ((void) 0) - -#endif /* __ARM_DEBUGGER_H__ */ -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/xen/arch/x86/include/asm/debugger.h b/xen/arch/x86/include/asm= /debugger.h index 5bac2ee4c2a4..a5c299c6c34d 100644 --- a/xen/arch/x86/include/asm/debugger.h +++ b/xen/arch/x86/include/asm/debugger.h @@ -1,30 +1,12 @@ /* SPDX-License-Identifier: GPL-2.0 */ /*************************************************************************= ***** - * asm/debugger.h - *=20 - * Generic hooks into arch-dependent Xen. - *=20 - * Each debugger should define two functions here: - *=20 - * debugger_trap_fatal(): - * Called when Xen is about to give up and crash. Typically you will use = this - * hook to drop into a debug session. It can also be used to hook off - * deliberately caused traps (which you then handle and return non-zero). + * xen/arch/x86/include/asm/debugger.h * - * debugger_trap_immediate(): - * Called if we want to drop into a debugger now. This is essentially the - * same as debugger_trap_fatal, except that we use the current register s= tate - * rather than the state which was in effect when we took the trap. - * For example: if we're dying because of an unhandled exception, we call - * debugger_trap_fatal; if we're dying because of a panic() we call - * debugger_trap_immediate(). + * x86-specific debugger hooks. */ - #ifndef __X86_DEBUGGER_H__ #define __X86_DEBUGGER_H__ =20 -#ifdef CONFIG_CRASH_DEBUG - #include #include =20 @@ -45,16 +27,4 @@ static inline bool debugger_trap_fatal( /* Int3 is a trivial way to gather cpu_user_regs context. */ #define debugger_trap_immediate() __asm__ __volatile__ ( "int3" ) =20 -#else - -static inline bool debugger_trap_fatal( - unsigned int vector, struct cpu_user_regs *regs) -{ - return false; -} - -#define debugger_trap_immediate() ((void)0) - -#endif - #endif /* __X86_DEBUGGER_H__ */ diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index d91532461189..25bffe47d7ae 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -64,7 +65,6 @@ #include #include #include -#include #include #include #include diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c index ca9ee0790149..0a551033c443 100644 --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -3,6 +3,7 @@ */ =20 #include +#include #include #include #include @@ -20,7 +21,6 @@ #include #include #include -#include #include =20 static unsigned char keypress_key; diff --git a/xen/common/shutdown.c b/xen/common/shutdown.c index abde48aa4ca0..a933ee001ea4 100644 --- a/xen/common/shutdown.c +++ b/xen/common/shutdown.c @@ -2,13 +2,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include =20 /* opt_noreboot: If true, machine will need manual reset on error. */ diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index d9d6556c2293..f9937c5134c0 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -26,7 +27,6 @@ #include #include #include -#include #include #include /* for do_console_io */ #include diff --git a/xen/arch/x86/include/asm/debugger.h b/xen/include/xen/debugger= .h similarity index 54% copy from xen/arch/x86/include/asm/debugger.h copy to xen/include/xen/debugger.h index 5bac2ee4c2a4..72684268aff7 100644 --- a/xen/arch/x86/include/asm/debugger.h +++ b/xen/include/xen/debugger.h @@ -1,11 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ /*************************************************************************= ***** - * asm/debugger.h - *=20 - * Generic hooks into arch-dependent Xen. - *=20 - * Each debugger should define two functions here: - *=20 + * Arch specific debuggers should implement: + * * debugger_trap_fatal(): * Called when Xen is about to give up and crash. Typically you will use = this * hook to drop into a debug session. It can also be used to hook off @@ -20,41 +16,29 @@ * debugger_trap_immediate(). */ =20 -#ifndef __X86_DEBUGGER_H__ -#define __X86_DEBUGGER_H__ +#ifndef __XEN_DEBUGGER_H__ +#define __XEN_DEBUGGER_H__ =20 #ifdef CONFIG_CRASH_DEBUG =20 -#include -#include - -#include - -/* Returns true if GDB handled the trap, or it is surviveable. */ -static inline bool debugger_trap_fatal( - unsigned int vector, struct cpu_user_regs *regs) -{ - int rc =3D __trap_to_gdb(regs, vector); - - if ( rc =3D=3D 0 ) - return true; +#include =20 - return vector =3D=3D X86_EXC_BP; -} +#else =20 -/* Int3 is a trivial way to gather cpu_user_regs context. */ -#define debugger_trap_immediate() __asm__ __volatile__ ( "int3" ) +#include =20 -#else +struct cpu_user_regs; =20 static inline bool debugger_trap_fatal( - unsigned int vector, struct cpu_user_regs *regs) + unsigned int vector, const struct cpu_user_regs *regs) { return false; } =20 -#define debugger_trap_immediate() ((void)0) +static inline void debugger_trap_immediate(void) +{ +} =20 -#endif +#endif /* CONFIG_CRASH_DEBUG */ =20 -#endif /* __X86_DEBUGGER_H__ */ +#endif /* __XEN_DEBUGGER_H__ */ --=20 2.11.0