From patchwork Wed Nov 2 11:41:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 620838 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp4234981pvb; Wed, 2 Nov 2022 04:45:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5UoYlaASH+HUYDjvRU4g8Jz/yi1FDva+iuBuOS0wnRbLjQdahzW6gWs78/4QXG6S1WnkKR X-Received: by 2002:a05:6214:21ed:b0:4bc:2090:8694 with SMTP id p13-20020a05621421ed00b004bc20908694mr1955046qvj.75.1667389512436; Wed, 02 Nov 2022 04:45:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667389512; cv=none; d=google.com; s=arc-20160816; b=nwcGIrEl6vffUd4opdygQ33+F+dm9M9KfBWCHvubC9FMXljONSdmfyIQnFSn+x4jQe l9fAOY59bpe4o0kDO3mcijElf70GhnySsRY4emI6O+IH72OFIWEjti9VsIZB+0Nfw1Wq qMTlKvP39yjCr8wTJT5rDtFET+OKgpMfxGvEGNfS5pCkhazIoFpzBAbCraIJlm34rBWS aabXz6kDqzMT9i7NGltqplx+2sD6PSxHUyNigwdcpQC8H3qdAf5S50TfGzfeuBXZWOPh TBGa2dyaCq88WLIpi6fqz8CeOM6LO93dVJYI5uSZE6xqJ12Ej9s878QS/ntroT6eYTXA WiZA== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7Au5lB1o4PdSr952SmEZ4IrudR5JlexcK/wWief35hc=; b=eXUm9LoJiNmnC9dNljHFOO7SK4PLqE0ySd8i/Nrt5U4Q6IQibXwq3Ubz+N+AtmCaAb tMuVdNnEabk7rdemy7XLgsggayGVejsRtJIU/rJL/NU+8CSQe9bryanWwaomzgmVp+zg AJEOV6eaosGhS4aBiClzrTAPuzw+BS6scA8G0LbTExuj/92DbbzOd65k1lNwitJhLpf2 2w/L5x8J5wIbu85UmMrW4o9KxTQP0num9cY58EpmrfRpzSBhRJGJ1cSbRi0hbk7lKvhI aOjaJpHRmlRMGLBmQ41uWKX9mWpnDpr0JbNkW52XYJ/zfI1ObMjN32hP7w/YZ+Hustxn lLiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RCTt4Pth; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d6-20020a37b406000000b006f9fdcb4899si7238885qkf.177.2022.11.02.04.45.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 Nov 2022 04:45:12 -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=@redhat.com header.s=mimecast20190719 header.b=RCTt4Pth; 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=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oqC8T-0005Hv-1P; Wed, 02 Nov 2022 07:42:21 -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 1oqC7v-00059V-Ek for qemu-devel@nongnu.org; Wed, 02 Nov 2022 07:41:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oqC7t-0005Nw-My for qemu-devel@nongnu.org; Wed, 02 Nov 2022 07:41:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667389305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7Au5lB1o4PdSr952SmEZ4IrudR5JlexcK/wWief35hc=; b=RCTt4PthLM926DujS36e7eTUMYeTVInjnho0G5k7yNrXxbCx2zTl/u0VfX2vQJfyWNrLS8 03k/oKAX5lZIFm6Tgl3FI3fLA9NtNc9cXgOViqlZhFhMSRAaKlwZ6M33mVFN0evUBjGFrN 5cK/y9mtY+BP6xxlUwSxLnq6aQLLCrM= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-643-qZJJmnHNNHaMWehVzH8Kzg-1; Wed, 02 Nov 2022 07:41:43 -0400 X-MC-Unique: qZJJmnHNNHaMWehVzH8Kzg-1 Received: by mail-ed1-f72.google.com with SMTP id w4-20020a05640234c400b004631f8923baso6817570edc.5 for ; Wed, 02 Nov 2022 04:41:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7Au5lB1o4PdSr952SmEZ4IrudR5JlexcK/wWief35hc=; b=zZogmpgEN4txnQpMDLzs5RyCtyeyHwCmV8CTJrYfZiVyMaBHSRZCIijMYhIHMNnecC tvKa9htysur7GKm7CJuDmSqF7aT69FZMvncow09MENyvOE99623BW44r3VR06tzHWrZl bJ8KmHtvuOcYuv201Gxw/FWJpmwPP+EAlN4SqkjLg7MHk/SqzKjXCyLMMVw2TyEU7QSo fOJIwTuIIv4xL1iNfuy6PGaTI/LZHCdtm69ROSoWQyElJwalpp50KxEICfLAlKywQnjD ery1YAa/yLAFUy6W38law+ohp6UUpxfZj2zDzBixvOdI38j5HL0ZzOqcYJ9+q/icPPox KlvA== X-Gm-Message-State: ACrzQf1+Vt8l64gDvtjJYEIVrIFdXLXMLQjEg+ma5vlDqbxJ+k3E6Xhb bouYTIhYej6gK3yFQGrPSB6YY7JUrfNqy8h0LdzoMGzNFpnuy4hdNBGM25+MRt+zT4GKYkAyPCK lzsW61IUF4G0n7Xm0j6Vno92adVLV3/q3Amn3kgeXE+m695V8RXj1qG3qErSQzgQeoxE= X-Received: by 2002:a50:cc07:0:b0:453:4427:a918 with SMTP id m7-20020a50cc07000000b004534427a918mr24222228edi.121.1667389302080; Wed, 02 Nov 2022 04:41:42 -0700 (PDT) X-Received: by 2002:a50:cc07:0:b0:453:4427:a918 with SMTP id m7-20020a50cc07000000b004534427a918mr24222207edi.121.1667389301807; Wed, 02 Nov 2022 04:41:41 -0700 (PDT) Received: from avogadro.local ([2001:b07:add:ec09:c399:bc87:7b6c:fb2a]) by smtp.gmail.com with ESMTPSA id n11-20020a170906118b00b0078116c361d9sm5384039eja.10.2022.11.02.04.41.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 04:41:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Andreas Gustafsson Subject: [PULL 5/5] target/i386: Fix test for paging enabled Date: Wed, 2 Nov 2022 12:41:25 +0100 Message-Id: <20221102114125.58902-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102114125.58902-1-pbonzini@redhat.com> References: <20221102114125.58902-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.048, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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 From: Richard Henderson 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 Signed-off-by: Richard Henderson Message-Id: <20221102091232.1092552-1-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- 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;