target/i386: Fix BEXTR instruction

There were two problems here: not limiting the input to operand bits,
and not correctly handling large extraction length.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1372
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230114230542.3116013-3-richard.henderson@linaro.org>
Cc: qemu-stable@nongnu.org
Fixes: 1d0b926150 ("target/i386: move scalar 0F 38 and 0F 3A instruction to new decoder", 2022-10-18)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Richard Henderson 2023-01-14 13:05:42 -10:00 committed by Paolo Bonzini
parent 5d62d6649c
commit b14c009897
2 changed files with 23 additions and 11 deletions

View file

@ -99,6 +99,9 @@ int main(int argc, char *argv[]) {
result = bextrq(mask, 0x10f8);
assert(result == 0);
result = bextrq(0xfedcba9876543210ull, 0x7f00);
assert(result == 0xfedcba9876543210ull);
result = blsiq(0x30);
assert(result == 0x10);
@ -164,6 +167,15 @@ int main(int argc, char *argv[]) {
result = bextrl(mask, 0x1038);
assert(result == 0);
result = bextrl((reg_t)0x8f635a775ad3b9b4ull, 0x3018);
assert(result == 0x5a);
result = bextrl((reg_t)0xfedcba9876543210ull, 0x7f00);
assert(result == 0x76543210u);
result = bextrl(-1, 0);
assert(result == 0);
result = blsil(0xffff);
assert(result == 1);