Skip to contentSkip to conversation

bug in popcnt emulation with some register operand(s)?

Qemu-devel Andriy Gapon 2 participants 8 messages Oct 7, 2012 – Oct 14, 2012

lore
Share & tools
lore
#0 lore raw

I am running Qemu (plain, no kvm, etc) on an AMD 10h machine that provides popcnt instruction.
Qemu advertises availability of pocnt to a guest as well.
What I see in the guest that popcnt 0x20(%r12),%r8 instruction actually placed its result into %rax. With %rdi and %rax operands the instruction worked fine though.

Signature · 1 line
Andriy Gapon
#1 lore raw
Quoted 8 lines · Andriy Gapon

I am running Qemu (plain, no kvm, etc) on an AMD 10h machine that provides popcnt instruction. Qemu advertises availability of pocnt to a guest as well. What I see in the guest that popcnt 0x20(%r12),%r8 instruction actually placed its result into %rax. With %rdi and %rax operands the instruction worked fine though.

Does following work?

target-i386/translate.c +1 -1
index e896abf..c36cc3e 100644
@@ -7818,7 +7818,7 @@ static target_ulong disas_insn(DisasContext *s, target_ulong pc_start)
             goto illegal_op;
 
         modrm = cpu_ldub_code(cpu_single_env, s->pc++);
-        reg = ((modrm >> 3) & 7);
+        reg = ((modrm >> 3) & 7) | rex_r;
 
         if (s->prefix & PREFIX_DATA)
             ot = OT_WORD;
Signature · 1 line
mailto:[email protected]
#2 lore raw

on 08/10/2012 10:52 malc said the following:

Quoted 11 lines · Andriy Gapon
Quoted 9 lines

I am running Qemu (plain, no kvm, etc) on an AMD 10h machine that provides popcnt instruction. Qemu advertises availability of pocnt to a guest as well. What I see in the guest that popcnt 0x20(%r12),%r8 instruction actually placed its result into %rax. With %rdi and %rax operands the instruction worked fine though.

Quoted 1 line

Does following work?

It does! Thank you very much.

Quoted 14 lines
target-i386/translate.c +1 -1
index e896abf..c36cc3e 100644
@@ -7818,7 +7818,7 @@ static target_ulong disas_insn(DisasContext *s, target_ulong pc_start)
             goto illegal_op;
 
         modrm = cpu_ldub_code(cpu_single_env, s->pc++);
-        reg = ((modrm >> 3) & 7);
+        reg = ((modrm >> 3) & 7) | rex_r;
 
         if (s->prefix & PREFIX_DATA)
             ot = OT_WORD;
Signature · 1 line
Andriy Gapon
#3 lore raw

on 08/10/2012 12:02 Andriy Gapon said the following:

Quoted 12 lines

on 08/10/2012 10:52 malc said the following:

Quoted 11 lines · Andriy Gapon
Quoted 9 lines

I am running Qemu (plain, no kvm, etc) on an AMD 10h machine that provides popcnt instruction. Qemu advertises availability of pocnt to a guest as well. What I see in the guest that popcnt 0x20(%r12),%r8 instruction actually placed its result into %rax. With %rdi and %rax operands the instruction worked fine though.

Quoted 3 lines
Quoted 1 line

Does following work?

It does! Thank you very much.

Do you plan to commit this fix?
Is there anything that I should do to make that happen (sooner)?

Quoted 16 lines
Quoted 14 lines
target-i386/translate.c +1 -1
index e896abf..c36cc3e 100644
@@ -7818,7 +7818,7 @@ static target_ulong disas_insn(DisasContext *s, target_ulong pc_start)
             goto illegal_op;
 
         modrm = cpu_ldub_code(cpu_single_env, s->pc++);
-        reg = ((modrm >> 3) & 7);
+        reg = ((modrm >> 3) & 7) | rex_r;
 
         if (s->prefix & PREFIX_DATA)
             ot = OT_WORD;
Signature · 1 line
Andriy Gapon
#4 lore raw
Quoted 13 lines · Andriy Gapon

on 08/10/2012 12:02 Andriy Gapon said the following:

Quoted 12 lines

on 08/10/2012 10:52 malc said the following:

Quoted 11 lines · Andriy Gapon
Quoted 9 lines

I am running Qemu (plain, no kvm, etc) on an AMD 10h machine that provides popcnt instruction. Qemu advertises availability of pocnt to a guest as well. What I see in the guest that popcnt 0x20(%r12),%r8 instruction actually placed its result into %rax. With %rdi and %rax operands the instruction worked fine though.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Does following work?

It does! Thank you very much.

Do you plan to commit this fix?
Is there anything that I should do to make that happen (sooner)?

Submit a patch with a well thought out comment and it'll be commited.

[..snip..]

Signature · 1 line
mailto:[email protected]
#5 lore raw

on 11/10/2012 00:09 malc said the following:

Quoted 19 lines · Andriy Gapon
Quoted 18 lines

on 08/10/2012 12:02 Andriy Gapon said the following:

Quoted 15 lines

on 08/10/2012 10:52 malc said the following:

Quoted 11 lines · Andriy Gapon
Quoted 9 lines

I am running Qemu (plain, no kvm, etc) on an AMD 10h machine that provides popcnt instruction. Qemu advertises availability of pocnt to a guest as well. What I see in the guest that popcnt 0x20(%r12),%r8 instruction actually placed its result into %rax. With %rdi and %rax operands the instruction worked fine though.

Quoted 1 line

Does following work?

It does! Thank you very much.

Quoted 8 lines
Quoted 3 lines

Do you plan to commit this fix?
Is there anything that I should do to make that happen (sooner)?

Submit a patch with a well thought out comment and it'll be commited.

[..snip..]

Hmm... Since you are the author of the patch, wouldn't be more appropriate for you to submit it? Besides, I can only mostly repeat the bug report as I do not quite understand the code and can not properly describe what the patch does.

Sorry for not taking up the work, but I am really just a qemu user.

Signature · 1 line
Andriy Gapon
#6 lore raw

On Sun, 14 Oct 2012, Andriy Gapon wrote:

[..snip..]

Quoted 5 lines

Hmm... Since you are the author of the patch, wouldn't be more appropriate for you to submit it? Besides, I can only mostly repeat the bug report as I do not quite understand the code and can not properly describe what the patch does.

Sigh, okay, commited.

Quoted 4 lines

Sorry for not taking up the work, but I am really just a qemu user.

Signature · 1 line
mailto:[email protected]
#7 lore raw

on 14/10/2012 13:56 malc said the following:

Quoted 11 lines · Andriy Gapon

[..snip..]

Quoted 5 lines

Hmm... Since you are the author of the patch, wouldn't be more appropriate for you to submit it? Besides, I can only mostly repeat the bug report as I do not quite understand the code and can not properly describe what the patch does.

Sigh, okay, commited.

Thank you again!

Quoted 5 lines
Quoted 4 lines

Sorry for not taking up the work, but I am really just a qemu user.

Signature · 1 line
Andriy Gapon