From nobody Tue Feb 10 13:34:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512999151353495.68432378854186; Mon, 11 Dec 2017 05:32:31 -0800 (PST) Received: from localhost ([::1]:53042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOOBw-0002hd-JT for importer@patchew.org; Mon, 11 Dec 2017 08:32:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOO2G-0000P6-GY for qemu-devel@nongnu.org; Mon, 11 Dec 2017 08:22:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eOO2F-0001xd-HV for qemu-devel@nongnu.org; Mon, 11 Dec 2017 08:22:20 -0500 Received: from mail.ispras.ru ([83.149.199.45]:43398) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOO2F-0001xE-5B for qemu-devel@nongnu.org; Mon, 11 Dec 2017 08:22:19 -0500 Received: from Misha-PC.lan02.inno (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 6984654006A; Mon, 11 Dec 2017 16:22:18 +0300 (MSK) From: Mihail Abakumov To: qemu-devel@nongnu.org Date: Mon, 11 Dec 2017 16:22:03 +0300 Message-ID: <151299852373.4808.1451782080986133047.stgit@Misha-PC.lan02.inno> In-Reply-To: <151299847127.4808.14646046517426494416.stgit@Misha-PC.lan02.inno> References: <151299847127.4808.14646046517426494416.stgit@Misha-PC.lan02.inno> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [PATCH v4 08/46] windbg: hook to wrmsr operation 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: sw@weilnetz.de, lprosek@redhat.com, dovgaluk@ispras.ru, rkagan@virtuozzo.com, pbonzini@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Inserted hook to wrmsr operation. Windows Kernel put address on KPCR struct= to fs/gs (x32/x64) register. Needs catch this moment and allow windbg serv= er handle packets. Signed-off-by: Mihail Abakumov Signed-off-by: Pavel Dovgalyuk Signed-off-by: Dmitriy Koltunov --- include/exec/windbgstub-utils.h | 2 ++ include/exec/windbgstub.h | 1 + stubs/windbgstub.c | 3 +++ target/i386/misc_helper.c | 3 +++ target/i386/windbgstub.c | 10 ++++++++++ windbgstub.c | 13 +++++++++++++ 6 files changed, 32 insertions(+) diff --git a/include/exec/windbgstub-utils.h b/include/exec/windbgstub-util= s.h index 4c747fa23e..a181e172e9 100755 --- a/include/exec/windbgstub-utils.h +++ b/include/exec/windbgstub-utils.h @@ -47,4 +47,6 @@ typedef struct SizedBuf { size_t size; } SizedBuf; =20 +bool windbg_on_load(void); + #endif diff --git a/include/exec/windbgstub.h b/include/exec/windbgstub.h index 21bc552e58..309f692383 100755 --- a/include/exec/windbgstub.h +++ b/include/exec/windbgstub.h @@ -18,6 +18,7 @@ #define WINDBG_DEBUG_ON false #endif =20 +void windbg_try_load(void); int windbg_server_start(const char *device); =20 #endif diff --git a/stubs/windbgstub.c b/stubs/windbgstub.c index 4951f59203..bd7e2dccd1 100755 --- a/stubs/windbgstub.c +++ b/stubs/windbgstub.c @@ -12,6 +12,9 @@ #include "qemu/osdep.h" #include "exec/windbgstub.h" =20 +void windbg_try_load(void) +{} + int windbg_server_start(const char *device) { return 0; diff --git a/target/i386/misc_helper.c b/target/i386/misc_helper.c index 628f64aad5..ec1fcd2899 100644 --- a/target/i386/misc_helper.c +++ b/target/i386/misc_helper.c @@ -24,6 +24,7 @@ #include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "exec/address-spaces.h" +#include "exec/windbgstub.h" =20 void helper_outb(CPUX86State *env, uint32_t port, uint32_t data) { @@ -385,6 +386,8 @@ void helper_wrmsr(CPUX86State *env) /* XXX: exception? */ break; } + + windbg_try_load(); } =20 void helper_rdmsr(CPUX86State *env) diff --git a/target/i386/windbgstub.c b/target/i386/windbgstub.c index df89e1edd8..0938f738e6 100755 --- a/target/i386/windbgstub.c +++ b/target/i386/windbgstub.c @@ -10,3 +10,13 @@ */ =20 #include "qemu/osdep.h" + +#ifndef TARGET_X86_64 +#include "exec/windbgstub-utils.h" + +bool windbg_on_load(void) +{ + return false; +} + +#endif diff --git a/windbgstub.c b/windbgstub.c index e30b8500e0..a2a6eb81b4 100755 --- a/windbgstub.c +++ b/windbgstub.c @@ -16,6 +16,7 @@ #include "qemu/cutils.h" #include "exec/windbgstub.h" #include "exec/windbgstub-utils.h" +#include "sysemu/kvm.h" =20 typedef struct WindbgState { bool is_loaded; @@ -45,6 +46,13 @@ static void windbg_exit(void) g_free(windbg_state); } =20 +void windbg_try_load(void) +{ + if (windbg_state && !windbg_state->is_loaded) { + windbg_state->is_loaded =3D windbg_on_load(); + } +} + int windbg_server_start(const char *device) { Chardev *chr =3D NULL; @@ -54,6 +62,11 @@ int windbg_server_start(const char *device) exit(1); } =20 + if (kvm_enabled()) { + WINDBG_ERROR("KVM is not supported."); + exit(1); + } + if (!strstart(device, "pipe:", NULL)) { WINDBG_ERROR("Unsupported device. Supported only pipe."); exit(1);