All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Richard Henderson <richard.henderson@linaro.org>,
	Andreas Gustafsson <gson@gson.org>
Subject: [PULL 5/5] target/i386: Fix test for paging enabled
Date: Wed,  2 Nov 2022 12:41:25 +0100	[thread overview]
Message-ID: <20221102114125.58902-6-pbonzini@redhat.com> (raw)
In-Reply-To: <20221102114125.58902-1-pbonzini@redhat.com>

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

If CR0.PG is unset, pg_mode will be zero, but it will also be zero
for non-PAE/non-PSE page tables with CR0.WP=0.  Restore the
correct test for paging enabled.

Fixes: 98281984a37 ("target/i386: Add MMU_PHYS_IDX and MMU_NESTED_IDX")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1269
Reported-by: Andreas Gustafsson <gson@gson.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20221102091232.1092552-1-richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/tcg/sysemu/excp_helper.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/target/i386/tcg/sysemu/excp_helper.c b/target/i386/tcg/sysemu/excp_helper.c
index d51b5d7431a0..405a5d414a14 100644
--- a/target/i386/tcg/sysemu/excp_helper.c
+++ b/target/i386/tcg/sysemu/excp_helper.c
@@ -553,12 +553,12 @@ static bool get_physical_address(CPUX86State *env, vaddr addr,
         break;
 
     default:
-        in.cr3 = env->cr[3];
-        in.mmu_idx = mmu_idx;
-        in.ptw_idx = use_stage2 ? MMU_NESTED_IDX : MMU_PHYS_IDX;
-        in.pg_mode = get_pg_mode(env);
+        if (likely(env->cr[0] & CR0_PG_MASK)) {
+            in.cr3 = env->cr[3];
+            in.mmu_idx = mmu_idx;
+            in.ptw_idx = use_stage2 ? MMU_NESTED_IDX : MMU_PHYS_IDX;
+            in.pg_mode = get_pg_mode(env);
 
-        if (likely(in.pg_mode)) {
             if (in.pg_mode & PG_MODE_LMA) {
                 /* test virtual address sign extension */
                 int shift = in.pg_mode & PG_MODE_LA57 ? 56 : 47;
-- 
2.38.1



  parent reply	other threads:[~2022-11-02 11:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-02 11:41 [PULL 0/5] Misc patches for QEMU 7.2 soft freeze Paolo Bonzini
2022-11-02 11:41 ` [PULL 1/5] target/i386: Fix calculation of LOCK NEG eflags Paolo Bonzini
2022-11-02 11:41 ` [PULL 2/5] os-posix: asynchronous teardown for shutdown on Linux Paolo Bonzini
2022-11-02 11:41 ` [PULL 3/5] target/i386: Set maximum APIC ID to KVM prior to vCPU creation Paolo Bonzini
2022-11-02 11:41 ` [PULL 4/5] util/log: Close per-thread log file on thread termination Paolo Bonzini
2022-11-02 11:41 ` Paolo Bonzini [this message]
2022-11-02 12:13 ` [PULL 0/5] Misc patches for QEMU 7.2 soft freeze Bin Meng
2022-11-02 13:04   ` Paolo Bonzini
2022-11-03 21:27 ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221102114125.58902-6-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=gson@gson.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.