From nobody Tue Feb 10 20:14:26 2026 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1508246419730909.1787541777796; Tue, 17 Oct 2017 06:20:19 -0700 (PDT) Received: from localhost ([::1]:39196 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Rme-0002yX-Sx for importer@patchew.org; Tue, 17 Oct 2017 09:19:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Rct-00032j-2q for qemu-devel@nongnu.org; Tue, 17 Oct 2017 09:09:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4Rcp-0004uQ-Ej for qemu-devel@nongnu.org; Tue, 17 Oct 2017 09:09:43 -0400 Received: from mail.ispras.ru ([83.149.199.45]:56596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Rcp-0004uA-2A for qemu-devel@nongnu.org; Tue, 17 Oct 2017 09:09:39 -0400 Received: from Misha-PC.lan02.inno (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 5428D54006C; Tue, 17 Oct 2017 16:09:38 +0300 (MSK) From: Mihail Abakumov To: qemu-devel@nongnu.org Date: Tue, 17 Oct 2017 16:09:35 +0300 Message-ID: <150824577575.6816.902878105747508734.stgit@Misha-PC.lan02.inno> In-Reply-To: <150824572545.6816.5099701189660002212.stgit@Misha-PC.lan02.inno> References: <150824572545.6816.5099701189660002212.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 v2 08/43] 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_6 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 | 5 +++++ windbgstub.c | 13 +++++++++++++ 6 files changed, 27 insertions(+) diff --git a/include/exec/windbgstub-utils.h b/include/exec/windbgstub-util= s.h index 1c27ee4ce8..825d58b76b 100755 --- a/include/exec/windbgstub-utils.h +++ b/include/exec/windbgstub-utils.h @@ -50,4 +50,6 @@ _t; \ }) =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 f54f5178fb..f2f83423a0 100755 --- a/target/i386/windbgstub.c +++ b/target/i386/windbgstub.c @@ -11,3 +11,8 @@ =20 #include "qemu/osdep.h" #include "exec/windbgstub-utils.h" + +bool windbg_on_load(void) +{ + return false; +} 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);