[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.10 28/33] target/i386: Generate an illegal opcode exception
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.10 28/33] target/i386: Generate an illegal opcode exception on cmp instructions with lock prefix |
Date: |
Thu, 22 Feb 2024 00:47:11 +0300 |
From: Ziqiao Kong <ziqiaokong@gmail.com>
target/i386: As specified by Intel Manual Vol2 3-180, cmp instructions
are not allowed to have lock prefix and a `UD` should be raised. Without
this patch, s1->T0 will be uninitialized and used in the case OP_CMPL.
Signed-off-by: Ziqiao Kong <ziqiaokong@gmail.com>
Message-ID: <20240215095015.570748-2-ziqiaokong@gmail.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 99d0dcd7f102c07a510200d768cae65e5db25d23)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index 68c42fd9ff..abacb91ddf 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -1501,12 +1501,13 @@ static bool check_iopl(DisasContext *s)
/* if d == OR_TMP0, it means memory operand (address in A0) */
static void gen_op(DisasContext *s1, int op, MemOp ot, int d)
{
+ /* Invalid lock prefix when destination is not memory or OP_CMPL. */
+ if ((d != OR_TMP0 || op == OP_CMPL) && s1->prefix & PREFIX_LOCK) {
+ gen_illegal_opcode(s1);
+ return;
+ }
+
if (d != OR_TMP0) {
- if (s1->prefix & PREFIX_LOCK) {
- /* Lock prefix when destination is not memory. */
- gen_illegal_opcode(s1);
- return;
- }
gen_op_mov_v_reg(s1, ot, s1->T0, d);
} else if (!(s1->prefix & PREFIX_LOCK)) {
gen_op_ld_v(s1, ot, s1->T0, s1->A0);
--
2.39.2
- [Stable-7.2.10 17/33] hw/i386: Fix _STA return value for ACPI0017, (continued)
- [Stable-7.2.10 17/33] hw/i386: Fix _STA return value for ACPI0017, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 14/33] virtio_iommu: Clear IOMMUPciBus pointer cache when system reset, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 18/33] tests/acpi: Update DSDT.cxl to reflect change _STA return value., Michael Tokarev, 2024/02/21
- [Stable-7.2.10 19/33] linux-user/aarch64: Choose SYNC as the preferred MTE mode, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 20/33] target/arm: Fix nregs computation in do_{ld, st}_zpa, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 22/33] target/arm: Don't get MDCR_EL2 in pmu_counter_enabled() before checking ARM_FEATURE_PMU, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 21/33] target/arm: Fix SVE/SME gross MTE suppression checks, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 23/33] iotests: Make 144 deterministic again, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 24/33] i386/cpu: Clear FEAT_XSAVE_XSS_LO/HI leafs when CPUID_EXT_XSAVE is not available, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 26/33] i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 28/33] target/i386: Generate an illegal opcode exception on cmp instructions with lock prefix,
Michael Tokarev <=
- [Stable-7.2.10 25/33] i386/cpu: Mask with XCR0/XSS mask for FEAT_XSAVE_XCR0_HI and FEAT_XSAVE_XSS_HI leafs, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 27/33] i386/cpuid: Move leaf 7 to correct group, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 29/33] ui: reject extended clipboard message if not activated, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 30/33] ui/clipboard: mark type as not available when there is no data, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 32/33] ui/console: Fix console resize with placeholder surface, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 31/33] ui/clipboard: add asserts for update and request, Michael Tokarev, 2024/02/21
- [Stable-7.2.10 33/33] audio: Depend on dbus_display1_dep, Michael Tokarev, 2024/02/21