From patchwork Fri Feb 12 18:49:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 381873 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3198169jah; Fri, 12 Feb 2021 11:23:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJweLdEUiTgMnet9ZzvEVS/r9gxSTO16HZ2mqyNFCbjYeJKQCSlxmXrpsq+WbHHqEJWYO7Rq X-Received: by 2002:a25:1457:: with SMTP id 84mr6220778ybu.74.1613157801124; Fri, 12 Feb 2021 11:23:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613157801; cv=none; d=google.com; s=arc-20160816; b=LYXUfftTFojFrvCJ+5Biy2L6RnE3nmnQqvMZVp4BC90pMkvhP0kPFoxk/I/rZjMVRu nMRHSgwKUkbrvNfnYFzPz69nVy3gvCEavImUT9Fw126wtWONLWWbMWWO6q1Uly/m3Jtr /2XvU66buRRdb7n2qJpMdPjfg7oErBRv4p3AmevONznwVsXASwp4jtEvymjv4aVi6gx/ iK6L4wYUhMvDiQSMHVrgu7pYaaR43nO3NH9VrJuz5GCmt9X5VAVSJaJ+jqFAXe1JfRMG DEueWAMH/QjIuyFMDK6LbSgdUM+ecf4XcVUiBm+MgIztMRRe0uSvYHv6nFwmQDSC0DQA I0Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=9J8C2yhZQHwcHgCFCp6aWoyOwMetLwuIKJgxUSgtqBU=; b=lSq4LVDo7Vj1/LV/VTyZ6C9iN285nk/VHan1ENe/LPlaxkjF+cBjlca5KjwvFLpDH/ JnwFbBPgx9xqwGAvgsVyT7V26Cnb1cTaK9nAwC3EqBsksBfmGAaplgMZNXRCAjGu4/Ix 5QOQV5Vjd5PuH1LnK2aMcXD38pcRlh/z6fa9tUh7wxMnDwC990wRLW4Dv05S83KeYHDt L6wrisEg5ovpV//XMeh7+eHmhZe45DlG8eowlvTp4a3uoBMdvZTsqawE4SZ2bmpRl3wY RCNvAJq3yZZiukjU3yl1vXAXUpqlFhR9Ih5o5aAy31PugYNGBZKNHTRgVtXDAJPxetxT kn0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qRetuitn; 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 n143si8088211yba.351.2021.02.12.11.23.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Feb 2021 11:23:21 -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=qRetuitn; 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]:54788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAe2C-00020m-JY for patch@linaro.org; Fri, 12 Feb 2021 14:23:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAdVg-000265-IV for qemu-devel@nongnu.org; Fri, 12 Feb 2021 13:49:44 -0500 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:42991) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lAdVd-0007vE-Vo for qemu-devel@nongnu.org; Fri, 12 Feb 2021 13:49:44 -0500 Received: by mail-pf1-x42b.google.com with SMTP id w18so55752pfu.9 for ; Fri, 12 Feb 2021 10:49:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9J8C2yhZQHwcHgCFCp6aWoyOwMetLwuIKJgxUSgtqBU=; b=qRetuitnv1o1D9eDfyzBO+8538xggi2yHLCojhmkqlczUGERVQIJKwlmWTTK60ltTK HOTtw82etwNGtW7p9byUO8ttF5XifWUR3RAx2AAuAgohEKlRyaFr9/EH8fx/9bO44fBS kKXnRIJhhzm0DkbJyaum3BPfgctUcqcIivVO9BKjDl2AAzNPLZ39Tu7VbMY+qMevl+ck nKs22iz1xSSfWoVtOzcSYUk72FvhW9nEgAahSVeg2RJEtxEWIurwM+MCVkId0uLox6a8 5XESAJ5wtnOoitnaQtMpxn2E9ueEl64MAFgPyalw0kPoDmrnaMDq16zU/YZeDFYhJls7 dkAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9J8C2yhZQHwcHgCFCp6aWoyOwMetLwuIKJgxUSgtqBU=; b=XUMpZX77WHIVlssmH1fikw5UHgbMlvTeNd1F0Ygo+6niop12r1DB9CfKwo2KLlYg0V n02FTLnOu0pX66PZCUQ6qtKaLOyslBHysCasaOiKRvdqIjsc51E3fgucdsucdJs9ZNY0 3crDYs5CmpwMivnde25d54abZtPVJ+k6J0Loh2ZhUHskMjylfp07ihzUcTUFczGvHMfe q4Lvw6CufTHeGzigyNCZrrJ610ZsK+54q4EMUVvYd/SO4AjmBI5+LwMTjN9XvJjFTZMZ dB6TUTGI5pFAnr7UkUHexvSOFz2ZofjZXQkpuF1+wrueUNjA6bZKjCR8eKtOpnhZm4vk mjTg== X-Gm-Message-State: AOAM532JeLsM+f8tSLvtTD1+W3FHF0k3u5AEFxQ2UJEcTn6aXIbZoc88 BYVcXLTPSMbya5Kl+b8k5wjLowowV24uEg== X-Received: by 2002:a63:1c08:: with SMTP id c8mr4482061pgc.228.1613155779723; Fri, 12 Feb 2021 10:49:39 -0800 (PST) Received: from localhost.localdomain (174-21-150-71.tukw.qwest.net. [174.21.150.71]) by smtp.gmail.com with ESMTPSA id k5sm9427618pfi.31.2021.02.12.10.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 10:49:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 29/31] target/arm: Add allocation tag storage for user mode Date: Fri, 12 Feb 2021 10:49:00 -0800 Message-Id: <20210212184902.1251044-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210212184902.1251044-1-richard.henderson@linaro.org> References: <20210212184902.1251044-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use the now-saved PAGE_ANON and PAGE_MTE bits, and the per-page saved data. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/mte_helper.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c index d55f8d1e1e..1c569336ea 100644 --- a/target/arm/mte_helper.c +++ b/target/arm/mte_helper.c @@ -78,8 +78,33 @@ static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx, int tag_size, uintptr_t ra) { #ifdef CONFIG_USER_ONLY - /* Tag storage not implemented. */ - return NULL; + uint64_t clean_ptr = useronly_clean_ptr(ptr); + int flags = page_get_flags(clean_ptr); + uint8_t *tags; + uintptr_t index; + + if (!(flags & (ptr_access == MMU_DATA_STORE ? PAGE_WRITE : PAGE_READ))) { + /* SIGSEGV */ + arm_cpu_tlb_fill(env_cpu(env), ptr, ptr_size, ptr_access, + ptr_mmu_idx, false, ra); + g_assert_not_reached(); + } + + /* Require both MAP_ANON and PROT_MTE for the page. */ + if (!(flags & PAGE_ANON) || !(flags & PAGE_MTE)) { + return NULL; + } + + tags = page_get_target_data(clean_ptr); + if (tags == NULL) { + size_t alloc_size = TARGET_PAGE_SIZE >> (LOG2_TAG_GRANULE + 1); + tags = page_alloc_target_data(clean_ptr, alloc_size); + assert(tags != NULL); + } + + index = extract32(ptr, LOG2_TAG_GRANULE + 1, + TARGET_PAGE_BITS - LOG2_TAG_GRANULE - 1); + return tags + index; #else uintptr_t index; CPUIOTLBEntry *iotlbentry;