From patchwork Wed Nov 2 09:12:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 620837 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp4157748pvb; Wed, 2 Nov 2022 02:13:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6KEOxgT/+rQPI2iY+7Pzur6v+cmJH2OMrnASm1YvrqjezL2QoRRNEwNCkdJ8ZL314h6p87 X-Received: by 2002:a37:6001:0:b0:6fa:40f3:3933 with SMTP id u1-20020a376001000000b006fa40f33933mr7921929qkb.489.1667380404711; Wed, 02 Nov 2022 02:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667380404; cv=none; d=google.com; s=arc-20160816; b=jsaxtty+/KVxLFdABm+WX6IOUCGqpQJEIUGhJaHZTZhyDe/P0Xh1YyYE3q3gILBfIj uQvHDzyTkh5GkbHmOQhMexPAGyZ2s5s9PiCL5/cJNZEuys9vkW8jlTUzTC+lFQ2BWMm4 JbHC7e7dJeo/VUNE61uG+8GUxqcWg6If2CcVJa4pEdog5WE6aYU6cF6/iOf8E7bCIslr 4+Upb1eeBpnWeJGljmeyvJOYv1JYdUwsAVqAFsn7ac8LdHCWX7AHXgiiU6qkFf02gzvE Y5vMGQPFucrpXo91Xc3KDpqgX2+Y3fHGEYGVNLc2hAHu9JrhIbWKwvid0emVS7zorOAJ +huw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=4yyyElQDSV8BnJ18BbBez/2Y1uNzC2NbopBlpNdfYzw=; b=ZKZ1miZQ3hApb3mMoPn81QOO+m878WP99FU0wL/kglcNhR1YhvLQmpesE+Nxfp2a+4 eeZsM7GiINktPT4qA8aF0wfLf1Vp9FCZVel0TNlSi6qQPE3n2DTZE/gpfeasmwB4anRT pU1aaCEL76BGFzL2QpAdI/Iw6svECplFf8lIDuv+52S+2EOwZYAo7mRqTLFNU0PNMx5N AwziOhnwXrDaBtdI+6/IH/dOhcJ/+3nIYBekHP68qBaA/1RvuUSaMDW13VJvFziYsR6e Iv/glfIwdmN3A+r/ZjuvngEoDuH3WebBuBG5wl/5X52iJpy2CbP1Uw4avFL3StgqUrZo Iddw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jDhAMdDw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id cn15-20020a05622a248f00b00397e0f15b99si8285985qtb.310.2022.11.02.02.13.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 Nov 2022 02:13:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jDhAMdDw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oq9nh-0002Ne-93; Wed, 02 Nov 2022 05:12:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oq9nf-0002MI-1t for qemu-devel@nongnu.org; Wed, 02 Nov 2022 05:12:43 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oq9nd-0000zJ-0e for qemu-devel@nongnu.org; Wed, 02 Nov 2022 05:12:42 -0400 Received: by mail-pl1-x62f.google.com with SMTP id g24so15987715plq.3 for ; Wed, 02 Nov 2022 02:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=4yyyElQDSV8BnJ18BbBez/2Y1uNzC2NbopBlpNdfYzw=; b=jDhAMdDwTi/gc9PsN10r/u+oDqKZ19WDvtZMNR9am/L4T2pDlQPCHxYwTmRkMAKSYL s0+itnt6fUVs4VkRgpYWAIB115IJvz/JX4nXVrcNxzKPm0LLuIu5PNnCgRCLDV1DWzSq MAlI+3tfJpbfiXVutk9fHIvnt8nBK3CG8LBZmvl+FnQIkX/Dz/F4XDCmCg3InJBRdgja Vg8pHzuJRN8hP75IwJQ9sR0a0iRYG/txqhSdiMTFmfN/foTPCA0WUR4qtRjUUYq/Rs8T piACgJ2zWygQtdWGUDMI4Z122G19H9YqQIlANemvTNJRSXM9kktOSiuHZKr3INDL/n4v lYRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4yyyElQDSV8BnJ18BbBez/2Y1uNzC2NbopBlpNdfYzw=; b=ZEXP1Br4mnk/0Cr8oQb+/YUitI7fBPVWSvsVtV8yINogHrHgUNqBI7TikMSauFEzMV PIQ5ZH4sbdTB/bvxcR/pQLjSfLu+lSNBYxxGlypfsqHU0TUKo8jyk0kZFNIR6Ro1Kex3 b2tABH3cVnkipnKQZQ13pFzWXvN/LX7Pg8wqSHajwX2kMpjgovSr9Vql/qinWYOvCsOB 7emdLgthQ3R1grIAShOAavT5DQtQh/uHvFtkytTCVq05zXKcZdM+DflsbFHpSTozt+Xb CRQUTdqsjZsAncnXeuqX4+QFJvU7jqwRpsJII3F7VIgkzIC1Zt3LNrH8jnN+jk1ril0/ qb6Q== X-Gm-Message-State: ACrzQf0sYS9AIl0N7XK1A0YAdkH0IC7mvkrPz3QmD4QrGhNi/RBklb55 SG3aySsoKRhFXJCUW4MCeQ+BqByL3rFgmhDK X-Received: by 2002:a17:90a:e413:b0:213:c581:8634 with SMTP id hv19-20020a17090ae41300b00213c5818634mr19692784pjb.185.1667380359086; Wed, 02 Nov 2022 02:12:39 -0700 (PDT) Received: from stoup.. (mur1374950.lnk.telstra.net. [139.130.176.43]) by smtp.gmail.com with ESMTPSA id w65-20020a628244000000b0053b723a74f7sm519261pfd.90.2022.11.02.02.12.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 02:12:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, eduardo@habkost.net, Andreas Gustafsson Subject: [PATCH] target/i386: Fix test for paging enabled Date: Wed, 2 Nov 2022 20:12:32 +1100 Message-Id: <20221102091232.1092552-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org If CR0.PG is unset, pg_mode will be zero, but that is not the only condition for which pg_mode will be zero. 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 Signed-off-by: Richard Henderson --- 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 d51b5d7431..405a5d414a 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;