qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL for-7.2 0/2] TCG/i386 fixes for QEMU 7.2-rc4
@ 2022-12-01  8:54 Paolo Bonzini
  2022-12-01  8:54 ` [PULL 1/2] target/i386: allow MMX instructions with CR4.OSFXSR=0 Paolo Bonzini
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Paolo Bonzini @ 2022-12-01  8:54 UTC (permalink / raw)
  To: qemu-devel

The following changes since commit 7c09a7f6ae1770d15535980d15dffdb23f4d9786:

  Update VERSION for v7.2.0-rc2 (2022-11-22 18:59:56 -0500)

are available in the Git repository at:

  https://gitlab.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 8218c048be1567db9dfd3cf1e19fbff76bce8cfd:

  target/i386: Always completely initialize TranslateFault (2022-12-01 09:53:24 +0100)

----------------------------------------------------------------
* Fix MMX instructions for system emulators
* Fix uninitialized TranslateFault after canonical address checks

----------------------------------------------------------------
Paolo Bonzini (1):
      target/i386: allow MMX instructions with CR4.OSFXSR=0

Richard Henderson (1):
      target/i386: Always completely initialize TranslateFault

 target/i386/tcg/decode-new.c.inc     |  3 ++-
 target/i386/tcg/sysemu/excp_helper.c | 34 +++++++++++++++++++---------------
 2 files changed, 21 insertions(+), 16 deletions(-)
-- 
2.38.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PULL 1/2] target/i386: allow MMX instructions with CR4.OSFXSR=0
  2022-12-01  8:54 [PULL for-7.2 0/2] TCG/i386 fixes for QEMU 7.2-rc4 Paolo Bonzini
@ 2022-12-01  8:54 ` Paolo Bonzini
  2022-12-01  8:54 ` [PULL 2/2] target/i386: Always completely initialize TranslateFault Paolo Bonzini
  2022-12-04 23:46 ` [PULL for-7.2 0/2] TCG/i386 fixes for QEMU 7.2-rc4 Stefan Hajnoczi
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2022-12-01  8:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson

MMX state is saved/restored by FSAVE/FRSTOR so the instructions are
not illegal opcodes even if CR4.OSFXSR=0.  Make sure that validate_vex
takes into account the prefix and only checks HF_OSFXSR_MASK in the
presence of an SSE instruction.

Fixes: 20581aadec5e ("target/i386: validate VEX prefixes via the instructions' exception classes", 2022-10-18)
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1350
Reported-by: Helge Konetzka (@hejko on gitlab.com)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/tcg/decode-new.c.inc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index e4878b967f0e..80c579164ff2 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -1488,7 +1488,8 @@ static bool validate_vex(DisasContext *s, X86DecodedInsn *decode)
             if (!(s->flags & HF_AVX_EN_MASK)) {
                 goto illegal;
             }
-        } else {
+        } else if (e->special != X86_SPECIAL_MMX ||
+                   (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ | PREFIX_DATA))) {
             if (!(s->flags & HF_OSFXSR_MASK)) {
                 goto illegal;
             }
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PULL 2/2] target/i386: Always completely initialize TranslateFault
  2022-12-01  8:54 [PULL for-7.2 0/2] TCG/i386 fixes for QEMU 7.2-rc4 Paolo Bonzini
  2022-12-01  8:54 ` [PULL 1/2] target/i386: allow MMX instructions with CR4.OSFXSR=0 Paolo Bonzini
@ 2022-12-01  8:54 ` Paolo Bonzini
  2022-12-04 23:46 ` [PULL for-7.2 0/2] TCG/i386 fixes for QEMU 7.2-rc4 Stefan Hajnoczi
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2022-12-01  8:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Daniel Hoffman

From: Richard Henderson <richard.henderson@linaro.org>

In get_physical_address, the canonical address check failed to
set TranslateFault.stage2, which resulted in an uninitialized
read from the struct when reporting the fault in x86_cpu_tlb_fill.

Adjust all error paths to use structure assignment so that the
entire struct is always initialized.

Reported-by: Daniel Hoffman <dhoff749@gmail.com>
Fixes: 9bbcf372193a ("target/i386: Reorg GET_HPHYS")
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20221201074522.178498-1-richard.henderson@linaro.org>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1324
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/tcg/sysemu/excp_helper.c | 34 ++++++++++++++++------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/target/i386/tcg/sysemu/excp_helper.c b/target/i386/tcg/sysemu/excp_helper.c
index 405a5d414a14..55bd1194d31b 100644
--- a/target/i386/tcg/sysemu/excp_helper.c
+++ b/target/i386/tcg/sysemu/excp_helper.c
@@ -71,10 +71,11 @@ static bool ptw_translate(PTETranslate *inout, hwaddr addr)
         TranslateFault *err = inout->err;
 
         assert(inout->ptw_idx == MMU_NESTED_IDX);
-        err->exception_index = 0; /* unused */
-        err->error_code = inout->env->error_code;
-        err->cr2 = addr;
-        err->stage2 = S2_GPT;
+        *err = (TranslateFault){
+            .error_code = inout->env->error_code,
+            .cr2 = addr,
+            .stage2 = S2_GPT,
+        };
         return false;
     }
     return true;
@@ -431,10 +432,11 @@ do_check_protect_pse36:
                                   MMU_NESTED_IDX, true,
                                   &pte_trans.haddr, &full, 0);
         if (unlikely(flags & TLB_INVALID_MASK)) {
-            err->exception_index = 0; /* unused */
-            err->error_code = env->error_code;
-            err->cr2 = paddr;
-            err->stage2 = S2_GPA;
+            *err = (TranslateFault){
+                .error_code = env->error_code,
+                .cr2 = paddr,
+                .stage2 = S2_GPA,
+            };
             return false;
         }
 
@@ -494,10 +496,11 @@ do_check_protect_pse36:
         }
         break;
     }
-    err->exception_index = EXCP0E_PAGE;
-    err->error_code = error_code;
-    err->cr2 = addr;
-    err->stage2 = S2_NONE;
+    *err = (TranslateFault){
+        .exception_index = EXCP0E_PAGE,
+        .error_code = error_code,
+        .cr2 = addr,
+    };
     return false;
 }
 
@@ -564,9 +567,10 @@ static bool get_physical_address(CPUX86State *env, vaddr addr,
                 int shift = in.pg_mode & PG_MODE_LA57 ? 56 : 47;
                 int64_t sext = (int64_t)addr >> shift;
                 if (sext != 0 && sext != -1) {
-                    err->exception_index = EXCP0D_GPF;
-                    err->error_code = 0;
-                    err->cr2 = addr;
+                    *err = (TranslateFault){
+                        .exception_index = EXCP0D_GPF,
+                        .cr2 = addr,
+                    };
                     return false;
                 }
             }
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PULL for-7.2 0/2] TCG/i386 fixes for QEMU 7.2-rc4
  2022-12-01  8:54 [PULL for-7.2 0/2] TCG/i386 fixes for QEMU 7.2-rc4 Paolo Bonzini
  2022-12-01  8:54 ` [PULL 1/2] target/i386: allow MMX instructions with CR4.OSFXSR=0 Paolo Bonzini
  2022-12-01  8:54 ` [PULL 2/2] target/i386: Always completely initialize TranslateFault Paolo Bonzini
@ 2022-12-04 23:46 ` Stefan Hajnoczi
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2022-12-04 23:46 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 115 bytes --]

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/7.2 for any user-visible changes.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-04 23:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-01  8:54 [PULL for-7.2 0/2] TCG/i386 fixes for QEMU 7.2-rc4 Paolo Bonzini
2022-12-01  8:54 ` [PULL 1/2] target/i386: allow MMX instructions with CR4.OSFXSR=0 Paolo Bonzini
2022-12-01  8:54 ` [PULL 2/2] target/i386: Always completely initialize TranslateFault Paolo Bonzini
2022-12-04 23:46 ` [PULL for-7.2 0/2] TCG/i386 fixes for QEMU 7.2-rc4 Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).