qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 08/43] windbg: hook to wrmsr operation


From: Ladi Prosek
Subject: Re: [Qemu-devel] [PATCH 08/43] windbg: hook to wrmsr operation
Date: Tue, 3 Oct 2017 13:57:31 +0200

On Tue, Sep 26, 2017 at 1:04 PM, Mihail Abakumov
<address@hidden> wrote:
> 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 server 
> handle packets.
>
> Signed-off-by: Mihail Abakumov <address@hidden>
> Signed-off-by: Pavel Dovgalyuk <address@hidden>
> Signed-off-by: Dmitriy Koltunov <address@hidden>
> ---
>  include/exec/windbgstub-utils.h |    3 +++
>  include/exec/windbgstub.h       |    1 +
>  target/i386/misc_helper.c       |    3 +++
>  windbgstub-utils.c              |    8 ++++++++
>  windbgstub.c                    |    8 ++++++++
>  5 files changed, 23 insertions(+)
>
> diff --git a/include/exec/windbgstub-utils.h b/include/exec/windbgstub-utils.h
> index 65f336e4bf..90fb766839 100755
> --- a/include/exec/windbgstub-utils.h
> +++ b/include/exec/windbgstub-utils.h
> @@ -62,4 +62,7 @@
>      _t;                                                       \
>  })
>
> +bool windbg_on_load(void);
> +void windbg_on_exit(void);
> +
>  #endif
> diff --git a/include/exec/windbgstub.h b/include/exec/windbgstub.h
> index 703fc26b8f..2dbf1b1f13 100755
> --- a/include/exec/windbgstub.h
> +++ b/include/exec/windbgstub.h
> @@ -15,6 +15,7 @@
>  #define WINDBG "windbg"
>  #define WINDBG_DEBUG_ON false
>
> +void windbg_try_load(void);
>  int windbg_server_start(const char *device);
>
>  #endif
> 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"
>
>  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();

Most people use QEMU with KVM and won't ever hit this code. Does your
work rely on TCG only for FS/GS write interception?

If KVM is out of scope for you, you should at least make sure that
users won't expect -windbg to work with it. So either fall back to TCG
if -windbg is passed or issue a warning.

>  }
>
>  void helper_rdmsr(CPUX86State *env)
> diff --git a/windbgstub-utils.c b/windbgstub-utils.c
> index dc5e505c63..b5fb6db3f2 100755
> --- a/windbgstub-utils.c
> +++ b/windbgstub-utils.c
> @@ -10,3 +10,11 @@
>   */
>
>  #include "exec/windbgstub-utils.h"
> +
> +bool windbg_on_load(void)
> +{
> +    return false;
> +}
> +
> +void windbg_on_exit(void)
> +{}
> diff --git a/windbgstub.c b/windbgstub.c
> index 378d1b911f..99c3ef9b14 100755
> --- a/windbgstub.c
> +++ b/windbgstub.c
> @@ -39,8 +39,16 @@ static void windbg_chr_receive(void *opaque, const uint8_t 
> *buf, int size)
>      }
>  }
>
> +void windbg_try_load(void)
> +{
> +    if (windbg_state && !windbg_state->is_loaded) {
> +        windbg_state->is_loaded = windbg_on_load();
> +    }
> +}
> +
>  static void windbg_exit(void)
>  {
> +    windbg_on_exit();
>      g_free(windbg_state);
>  }
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]