From patchwork Wed Mar 8 16:57:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 660454 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp435092wrb; Wed, 8 Mar 2023 09:06:11 -0800 (PST) X-Google-Smtp-Source: AK7set8T0EnXZcFqyz6jygJj0F8i3KSXADi7zQWJqT07Dm13DZzJzRil/uSr03hl2K53pKIyNO32 X-Received: by 2002:a05:622a:4b:b0:3bf:d6ad:5236 with SMTP id y11-20020a05622a004b00b003bfd6ad5236mr30813164qtw.32.1678295170956; Wed, 08 Mar 2023 09:06:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678295170; cv=none; d=google.com; s=arc-20160816; b=OdrPAbK7Vl6f5msNK70cNc9LLU4F1euCtk7N2yD6vIStUr6zrIBq724EnoTewmSRWB UTDAQPqnJ35/E5anvQqnELCahsH4QACGmXVyWBjENTfTfGxP52eRpcQvr3LjfowyqMEb KKhULWLaBE1MI6eMR7JjhimfMcx8NoM+x0nfjc/vbIyK7rPFeoN1e7dn1Ni3yJnKlsSP 2Ix+lGzXiPihqdye5r9Pcf9C0I+2eBPDLztf6i59nVRwYjOH7SfGluWxs7Pvoy6OXDr7 jAt/E7f3lWK31moJdkKQ3VGjMTW36y82I5BaJn5IKofSSt7VWtsTCf7cQJMz01gdeKTG v4Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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; bh=28Fq/A1YofbQw7VLKsf6ELkrqDfhOKwEh41ZzDBzaXc=; b=MRcM+t/+tCQtqF0HY/0CqWonNZiyPd68zOcYpa3pxLw5tnp/v+CLdWwiZ9Nqb4G1m1 /ascC7GcTCxFgVJC3m/iiTkrIElXIUWLS6BWtCqQTztCBorgpNR14JiFZR2CvXC3oNty hCCv/+wxcDlk8h/Bk1oclR9hSzVd0txM33/ydqPZNx0NRki8LnuOxr6zzQSbYb6ExQr2 3DwmPuRPNnpUZwme6iweUjq87mbj2hp9En2q6gLV1T2k8EVMKSlMMpTlJL+c0Og2S1YC Wkj1izKs9VMfgESYqpUrTApz2Lz3rbOjzMy4z+wTtwD9Uiw59lxATf5MgHTJ56DRUElQ napA== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 10-20020ac8594a000000b003bfb833eb0csi12916258qtz.750.2023.03.08.09.06.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Mar 2023 09:06:10 -0800 (PST) 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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZx7t-0004Az-BK; Wed, 08 Mar 2023 11:58:53 -0500 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 1pZx7r-00049j-Ay; Wed, 08 Mar 2023 11:58:51 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZx7p-0003y5-P3; Wed, 08 Mar 2023 11:58:51 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 0F946400E9; Wed, 8 Mar 2023 19:58:20 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id BBBB313A; Wed, 8 Mar 2023 19:58:18 +0300 (MSK) Received: (nullmailer pid 2098276 invoked by uid 1000); Wed, 08 Mar 2023 16:58:15 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Michael Tokarev Subject: [PATCH 12/47] target/arm: Fix sve_probe_page Date: Wed, 8 Mar 2023 19:57:15 +0300 Message-Id: <20230308165815.2098148-12-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> References: <20230308165035.2097594-1-mjt@msgid.tls.msk.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Don't dereference CPUTLBEntryFull until we verify that the page is valid. Move the other user-only info field updates after the valid check to match. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1412 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20230104190056.305143-1-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit ce848378b999214777fa984a8a0a3e3deb1cf687) Signed-off-by: Michael Tokarev --- target/arm/sve_helper.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index 1afeadf9c8..521fc9b969 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -5354,15 +5354,10 @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env, #ifdef CONFIG_USER_ONLY flags = probe_access_flags(env, addr, access_type, mmu_idx, nofault, &info->host, retaddr); - memset(&info->attrs, 0, sizeof(info->attrs)); - /* Require both ANON and MTE; see allocation_tag_mem(). */ - info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE); #else CPUTLBEntryFull *full; flags = probe_access_full(env, addr, access_type, mmu_idx, nofault, &info->host, &full, retaddr); - info->attrs = full->attrs; - info->tagged = full->pte_attrs == 0xf0; #endif info->flags = flags; @@ -5371,6 +5366,15 @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env, return false; } +#ifdef CONFIG_USER_ONLY + memset(&info->attrs, 0, sizeof(info->attrs)); + /* Require both ANON and MTE; see allocation_tag_mem(). */ + info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE); +#else + info->attrs = full->attrs; + info->tagged = full->pte_attrs == 0xf0; +#endif + /* Ensure that info->host[] is relative to addr, not addr + mem_off. */ info->host -= mem_off; return true;