diff mbox series

[V3] target/i386: Fix handling of k_gs_base register in 32-bit mode in gdbstub

Message ID 2cf601fe9f2d4447ba4eec653df634ee@us.ibm.com
State New
Headers show
Series [V3] target/i386: Fix handling of k_gs_base register in 32-bit mode in gdbstub | expand

Commit Message

Marek Dolata - mkdolata@us.ibm.com Dec. 27, 2019, 11:37 p.m. UTC
Fixes: corrects clobbering of registers appearing after k_gs_base
Buglink: https://bugs.launchpad.net/qemu/+bug/1857640

Signed-off-by: Marek Dolata <mkdolata@us.ibm.com<mailto:mkdolata@us.ibm.com>>
---
target/i386/gdbstub.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--
2.24.1

Comments

Philippe Mathieu-Daudé Dec. 28, 2019, 4:57 p.m. UTC | #1
On 12/28/19 12:37 AM, Marek Dolata - mkdolata@us.ibm.com wrote:
> Fixes: corrects clobbering of registers appearing after k_gs_base
> 
> Buglink: https://bugs.launchpad.net/qemu/+bug/1857640
> 
> Signed-off-by: Marek Dolata <mkdolata@us.ibm.com 
> <mailto:mkdolata@us.ibm.com>>
> 
> ---
> 
> target/i386/gdbstub.c | 4 ++--
> 
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c
> 
> index aef25b70f1..572ead641c 100644
> 
> --- a/target/i386/gdbstub.c
> 
> +++ b/target/i386/gdbstub.c
> 
> @@ -350,15 +350,15 @@ int x86_cpu_gdb_write_register(CPUState *cs, 
> uint8_t *mem_buf, int n)
> 
>               env->segs[R_GS].base = ldl_p(mem_buf);
> 
>               return 4;
> 
> -#ifdef TARGET_X86_64
> 
>           case IDX_SEG_REGS + 8:
> 
> +#ifdef TARGET_X86_64
> 
>               if (env->hflags & HF_CS64_MASK) {
> 
>                   env->kernelgsbase = ldq_p(mem_buf);
> 
>                   return 8;
> 
>               }
> 
>               env->kernelgsbase = ldl_p(mem_buf);
> 
> -            return 4;
> 
> #endif
> 
> +            return 4;
> 
>           case IDX_FP_REGS + 8:
> 
>               cpu_set_fpuc(env, ldl_p(mem_buf));
> 
> -- 
> 
> 2.24.1
> 

Still:

$ pwclient git-am 11311411
Applying patch #11311411 using "git am"
Description: [V3] target/i386: Fix handling of k_gs_base register in 
32-bit mode in gdbstub
Applying: target/i386: Fix handling of k_gs_base register in 32-bit mode 
in gdbstub
error: corrupt patch at line 25
Patch failed at 0001 target/i386: Fix handling of k_gs_base register in 
32-bit mode in gdbstub
hint: Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
'git am' failed with exit status 128

I thought this could be due to this recent git change:
https://github.com/git/git/commit/5983ddc1652
and would suggest to try with:

$ git config sendemail.transferEncoding 8bit

but you use git 2.24 and this got introduced in 2.25, so I'm not sure 
what's wrong. You could still try, in case this helps...
diff mbox series

Patch

diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c
index aef25b70f1..572ead641c 100644
--- a/target/i386/gdbstub.c
+++ b/target/i386/gdbstub.c
@@ -350,15 +350,15 @@  int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
             env->segs[R_GS].base = ldl_p(mem_buf);
             return 4;

-#ifdef TARGET_X86_64
         case IDX_SEG_REGS + 8:
+#ifdef TARGET_X86_64
             if (env->hflags & HF_CS64_MASK) {
                 env->kernelgsbase = ldq_p(mem_buf);
                 return 8;
             }
             env->kernelgsbase = ldl_p(mem_buf);
-            return 4;
#endif
+            return 4;

         case IDX_FP_REGS + 8:
             cpu_set_fpuc(env, ldl_p(mem_buf));