From patchwork Fri Jan 13 14:10:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 641963 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp241140pvb; Fri, 13 Jan 2023 06:43:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXudBM10jmCwXq8VGG4EmD4890FJrF8aBk6vqUlkFwmjX23sbhtKzTLjFLi32yu1nwfEcblx X-Received: by 2002:a05:6214:2d13:b0:534:80c0:6b64 with SMTP id mz19-20020a0562142d1300b0053480c06b64mr4063726qvb.1.1673621006936; Fri, 13 Jan 2023 06:43:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673621006; cv=none; d=google.com; s=arc-20160816; b=bwrpPk5fHO5jAdxYmEhhZIGvn3tbYHsO5j9KE5KDQd5DpRmSpJLWBaIFb627nbh0IU BI8q9lV67XWHuzQRH2Wxx848/QIMd3DpQxLggqmnR1NiEU+Bd1HpML4dwwv6d3u0Nn1J vBSzhDwekA/pkFCVEgnvfrQcorxCpFiUm5s3WCHecarnTQ6G61ZdpRlF1noQ6sM90lK8 uxuVtglQDxXGOvEFC+k1VJ+aJvoyD9ECsa3TH2WLYG2lAFK/xkfPOaFYIe39N7nU3p4B bavBmTOkluBRSkhOaUGYohzT4lkCsDQx8klffVQP5bLnpUoomIuhrqrJ9wrRhLI6APg7 Il4A== 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:to:from :dkim-signature; bh=yQOKxbWfNbJ6ZYIkx8c2YswZ3peqlz+Y7JAPsZrSkN8=; b=ETTDdTyjx0ZH2jujWnLmE8N0qbtgjNzJmHjG4sCtfuxqDPIXju8zqACNOSKteGWnBZ Ql8zHxGfzWJMLJzvUtCL7jAXgbN20oxyrGAcv6mzese5x1f/Fqq+ZjqwjeiBusl6oTzp TMx05Zc9cEdq3/DduoiA6Y8gVST7zJIHkvAYjEM9dw/SsfEF9PmBxRFO8cMFJrE66UZA cTQglRB9qdL1zLRFiW+lX3NRzO6q8caiEn62icOvVpTohSo+rpIbuz0vq4JzU6WLnQS8 bWl7UAun2VRobN+9jyFueqKBeEcTfDzrhFrq8+PQClVqnqz05ns/vmsUPfb/ohmFZxpY hADQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tKzEpYk+; 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 ESMTP id if8-20020a0562141c4800b005347db833afsi1826207qvb.504.2023.01.13.06.43.26 for ; Fri, 13 Jan 2023 06:43:26 -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; dkim=pass header.i=@linaro.org header.s=google header.b=tKzEpYk+; 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 1pGKmc-0000um-F8; Fri, 13 Jan 2023 09:11:50 -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 1pGKmS-0000r6-7c for qemu-devel@nongnu.org; Fri, 13 Jan 2023 09:11:42 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pGKmP-0003dg-Fb for qemu-devel@nongnu.org; Fri, 13 Jan 2023 09:11:39 -0500 Received: by mail-wm1-x329.google.com with SMTP id g10so15354457wmo.1 for ; Fri, 13 Jan 2023 06:11:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=yQOKxbWfNbJ6ZYIkx8c2YswZ3peqlz+Y7JAPsZrSkN8=; b=tKzEpYk+p9BEmTWInUrHBV/qTXtw8YrhAhpGAzcth47EPNsj0cJTSgPjLqePTtmRWr ZYdL/UqVZFCMreHQiW4jnexSJHZGHOhFFE13/gswzmbFsnqIurFQ1xdF7fam5P8OfGiC 0BSj/8R8SBIhK0FWrxyTK7dfV8tPJ4YD+nykfjcRp+AzhfDjbu9wDzGg4fLBXPVvuCjn vlv511DlMvt9dL9UkIAxGEKvIpwKxspDGEtokbt0dRg7j73fsAeENWihwwpVN1GRAEXD rf9yZrRyNemmenSPvrAjYFR9jjMJ6rfGs4PwtdRsIA81XXyqaZIseIlce4g1yfKN/jxO 815A== 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:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yQOKxbWfNbJ6ZYIkx8c2YswZ3peqlz+Y7JAPsZrSkN8=; b=QdpI8PfKuAhaDdAEDPG2TTOAjTcxAgnJbh4qd2vGt3BXHy6plGE7PeiEq5ZbXBvtJX urJQi3RIPFJ0vfSV6zxGGe8ND7S9RoB1LBBz9qKUZk+L8NYvWmS/J1U2WyZcYw5NPmLP xTX49wY3hqwjm25D7wc/2dJ2TJGmmzehY263vfF1U7OOb4ydVc+GFXhh1r/Vfe7JZaty GYTK2UrpTTMEHgqhfH/3FQrbpkHc2qKF4Gx3lPcXRbe3Yxaw5zU05XKYphiRsmq5rI7i joMIK0+tI39HXv6q1CsycXfaom4OWonadPdCUUerjkwW70CCuPNqgH8bd33aBqKv5X/C RcHw== X-Gm-Message-State: AFqh2krUWmsUqfvMar2hFyEPJZhhe+ioZ5IeF5q47SxR4dvCpS4W7nEq mmcw+gt9qvi59BMwmR7PDLQLFKH0vkknQTIu X-Received: by 2002:a7b:ce87:0:b0:3d9:f37e:2acb with SMTP id q7-20020a7bce87000000b003d9f37e2acbmr13911484wmj.20.1673619096788; Fri, 13 Jan 2023 06:11:36 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id n36-20020a05600c502400b003da0b75de94sm5334464wmr.8.2023.01.13.06.11.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 06:11:36 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 10/38] target/arm: Fix sve_probe_page Date: Fri, 13 Jan 2023 14:10:58 +0000 Message-Id: <20230113141126.535646-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230113141126.535646-1-peter.maydell@linaro.org> References: <20230113141126.535646-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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: , 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 --- 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 1afeadf9c85..521fc9b9697 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;