From patchwork Fri Jun 5 04:17:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187488 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2027915ilo; Thu, 4 Jun 2020 21:25:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx25ot1aMPv/ubzgJXAUqEkRnL4ip04jJ2QQPyNb1pjEsUPpyG1mM/OAcqbpMudJWBKVsQf X-Received: by 2002:a25:d8cd:: with SMTP id p196mr14017877ybg.55.1591331143363; Thu, 04 Jun 2020 21:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591331143; cv=none; d=google.com; s=arc-20160816; b=DneTrrR4Gz062Zo+rjS6sZg3PCx7jYcGRP3GwT7QeamyYBHlaGmPMOVifK1zdJNF0Y AFVsZJ8LbsgksLl6yRm3uil9nDrdSvKjvoJ8YCRiv5/QWnTcpUh7X3fbhNOVNbGs+G9K Bhf3pAL+kwJ33LFR8DI2IQvdsGQvQFPwsFeh+X6jSqLG65FMixQlUWgk6s+pIG4r/qW7 0YDDk9LfzoGztbkUq/9NIsfiD/YGrkTZIEggH9N0QG2n2jWgHmBn1x08gtVkHgfsRaMk MWpoRyQJk19RZHp7AWeMuT3faVRpgHFMOmrKIWE5ziJzmUDBdBVjOe182IN+VjMj33Yk Peaw== 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=CDahIOixg8N2JHR7Ek8lGA826Cs5BmS4mXRyzAL5jqQ=; b=Y1pcFIGN89TQ2+2A+2y7GfBCjGQrojNbsU+kIVhp6jntNhBQS9LFerPsa42CGNwoms 9lraGmMQLGQsZWJy32rJ2HX1QvOD1+0TSaHZAgn+KHQYXo46fO89uS9TgIhKwTykLZT9 8pvK4qaqm2exLtBQIX2M7QlA2IM5JaKsRW6mUywYSbga3nbGczGhNAYMyRvEakNe9Gdm M7mLnC19o7pm0hYomNyNokjmUKueTFA0hBLo8BmN8m827SdFuRDA87Vf6NrE0GCJOBH0 BckrbJGExX8bK3mgtiOwg5dVYVZVE+V66qrUtPvA+rx9nU0PPerqGLR1HGu+8PUjeqLc fARg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Qzvmb+yr; 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=fail (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 204si5615238ybu.214.2020.06.04.21.25.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jun 2020 21:25:43 -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=fail header.i=@linaro.org header.s=google header.b=Qzvmb+yr; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jh3vK-0002TH-RB for patch@linaro.org; Fri, 05 Jun 2020 00:25:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jh3no-0004m7-JY for qemu-devel@nongnu.org; Fri, 05 Jun 2020 00:17:56 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:40559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jh3nn-0000mc-Ug for qemu-devel@nongnu.org; Fri, 05 Jun 2020 00:17:56 -0400 Received: by mail-pf1-x444.google.com with SMTP id s23so2989729pfh.7 for ; Thu, 04 Jun 2020 21:17:55 -0700 (PDT) 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=CDahIOixg8N2JHR7Ek8lGA826Cs5BmS4mXRyzAL5jqQ=; b=Qzvmb+yr6V0rS9fXM7NM1NdR+u0oIf5AZbDsKcxKqGQtlvVdnkS9tfGiwMCoyvdY99 taQ9wK2VfVc1+0Rk8wy0eTrK/oS6pizdvQbgLvTwL0WVP80PL8OlRNKC0aKpUnhaQIEy l1cTfvDQNbYGDLvEJfZcF1QdS7F0TwfffRpcBgHyAsY0PNLL5BP+pTJ2riG+3ygitnFq 0NdYGj5hMpO+ktUHAu4R+on5nL5fxaqlHHSQuI0CNMEHG3kRuPYldQwhpI6HOPFh8jYM 4fDyq3sD9eLNW/zmHR4pjAbw1ut+j5vVYgDaynY3J12HBNOAM7U2jZGvUq+eQuHgGNkJ IdYw== 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=CDahIOixg8N2JHR7Ek8lGA826Cs5BmS4mXRyzAL5jqQ=; b=ZbiTMrnhJTryCbkIdd6udFJwRD1KPi/hIU34/Y8r5Em0IGYm37eJ9dOUBdZJ22R5Ie 9+smtdjudBQqiJhd5Gu5shgvJ1XnQBcMIjRqjdk6tgtzgbM1bezddauCwXbGf1AuXCPS CN/lXhZ2PrPRC2e2lAeDlL/i0PZB8mzX8OpvYXoOAcCegPmgRRyFkhOVFgIZ6rVK8zKM iofRQyTrc7km2AeQxvuuxgSWMZuy56HZnDKLW9x+vXc1ZQymEd5H4AUX2cClq/Gx0GFu kVx2pxYZSZ82NaW2sKQNxVWzygJQQjAVX2SNYORwrrGuGTUUVYavFOQJi7fjfAhNQvuv 7giA== X-Gm-Message-State: AOAM533CmVbplumLdFXSPVGF8IFfpm7Byr3cSvJkNJiAhy8gDq3u9tN4 Yt6OUXBdo46sjxXy/SmRV4l3m9h3n5E= X-Received: by 2002:aa7:84cc:: with SMTP id x12mr7437645pfn.235.1591330674397; Thu, 04 Jun 2020 21:17:54 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id h15sm5440902pgl.12.2020.06.04.21.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 21:17:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 15/17] target/arm: Add allocation tag storage for user mode Date: Thu, 4 Jun 2020 21:17:31 -0700 Message-Id: <20200605041733.415188-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200605041733.415188-1-richard.henderson@linaro.org> References: <20200605041733.415188-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::444; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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, qemu-arm@nongnu.org, steplong@quicinc.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use the now-saved PAGE_ANON and PAGE_TARGET_2 bits, and the per-page saved data. 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 835b6d1ded..0911cebd36 100644 --- a/target/arm/mte_helper.c +++ b/target/arm/mte_helper.c @@ -76,8 +76,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_TARGET_2)) { + 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;