From patchwork Fri Feb 12 18:48:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 381874 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3199012jah; Fri, 12 Feb 2021 11:24:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzykAxFi01MRMWBqR+W14B9S/6zWNFyzaKiUU+myybtgc6Htrd8lJimdF5J4YRcx08bsVV6 X-Received: by 2002:a5b:887:: with SMTP id e7mr5769641ybq.15.1613157888385; Fri, 12 Feb 2021 11:24:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613157888; cv=none; d=google.com; s=arc-20160816; b=Me74XqFGP/3Ds1XQ5jxcjTsntp5l9NHRA9+q7xo6AtIvjPx0JybUh88VtIecOCbbhP kis3nb34ffr4dPDkDK0zIr4qlYdL8eFZjq/X//3ypB5kird9+OGWutBEIvXaIqahhqQx VbOBWQU03gMGVRVEDCfz/sc9NAXR4BWfR0rE86cjhvRf/1I5Mx5KQWky0ko5eZoZHE3G uCho851zVf0y3Z27mQvJOq8mHrz7+YpUdDmOfRbgOKm8FAN03EQOejVjioyj6p5mtDWD Ymcqdy59mFRJReRCBumutzjq5JyvOCuPXUlvXR/p6ARko64ntQit812b/bUCY+etQv/U 2pKw== 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=gurvZ66hLTix7YQy4oY0/x7F0ARKo0Vv8g7JqIdz5nU=; b=qycmJ22rUrPrCajXlslN6yHEY0XhlcWzZOZkTz/QBBGJEqSaZbTCAHUPfpam3R9y+k T9GFw/D/0U/MvWV8sErCpAaRxJqQIlNeNprdljD7J7maqlEAjFmg87yZvS20q9TKcvk4 FJJjwxL5Q1cGsDMud2zSfiuEkp3qaTIjKNRJ1fOCSckDj7tYmDihHrV+SWr0fYffZ67m HNpQxpfigIIct2l6vefJmxovNt2RRiGgUb2HTSjQEIlHztqUoYHai/2oArv+BWafwvJd aRT3TBOEJaswso/FwI+SluvNcSDSqlL5d5Y3lSwI0gUN36NVZSXkGG9v4lWZbuLbwWmW BpXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pxyno6aj; 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 d193si8436004ybf.298.2021.02.12.11.24.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Feb 2021 11:24:48 -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=Pxyno6aj; 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]:58630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAe3b-0005LH-Tn for patch@linaro.org; Fri, 12 Feb 2021 14:24:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAdVb-0001ue-D7 for qemu-devel@nongnu.org; Fri, 12 Feb 2021 13:49:39 -0500 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]:36563) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lAdVX-0007sR-RE for qemu-devel@nongnu.org; Fri, 12 Feb 2021 13:49:39 -0500 Received: by mail-pg1-x530.google.com with SMTP id t26so257635pgv.3 for ; Fri, 12 Feb 2021 10:49:35 -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=gurvZ66hLTix7YQy4oY0/x7F0ARKo0Vv8g7JqIdz5nU=; b=Pxyno6aj1ldDTxbkH87G9Z9rmXndd7+1CpyIZa7kGIP5RsfiYWUPQ4FpIoSnmsRM4G 6s2WBsdvasbgvkfDqLMjIQICPNn5VpOcAORv2FMSc5AI1oln7+Y88BtCA7S7L5wT+d7N 6wvHm0VT0NMNwy4peFW4gC6oVlscDpNXstGEUMmSbvs+tTaayluElUvyets2/aEAr819 e+pPDxnHvE5Y/nG696JzllBQmx6m7Ag5T0+C7iVCQ7VzEZTeihbK7O3xImhhIXIAPnHD 6fZhTKTIdaJxZO0+QBrQfXuIxRS/bm3znWGE6igdVctzRAJtD87zUEJGgHrmN7oyKayU uEDw== 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=gurvZ66hLTix7YQy4oY0/x7F0ARKo0Vv8g7JqIdz5nU=; b=VHtq8FNNWLwY4l7mEZolVlx8qi65fJoCIyHc8dW5xIMwGBsEOqKCzxPN/nGc/Yq0ZJ KmKZCzY13bbfg6sk1ZXp2kNLQZbGZK1wY6rLx1DUAkYg4ugmMF6QqCalRwlCuzlQ0kgD wGlG5CLqTioMLazbGJk3FkwrLYrcuTKlz0tajV+4GC8QUFnkadtdMXDlon2kWRNKl8EC MPomZOHSEw3g66VRrhXXA3QOhqvgC4qxJW+rSIGso2/R+/dR1iBJrAyly5tjxhyrRlvn d3OyzQ4gGfoR51SAFJ7SA5mZOTJzD045jeytb6pUVyBrwOj0yhmfICfQ0gED2VEwC0ro Qrzg== X-Gm-Message-State: AOAM531PeEr0i8pWGzzTfxNpT0NPsdIASsl8lfeTHsyVhEIbq51M6QXi 7nP94821RqksAJwyIqKqwxQfzUiuhJfPKg== X-Received: by 2002:a62:4d43:0:b029:1c6:e790:5f8f with SMTP id a64-20020a624d430000b02901c6e7905f8fmr4175335pfb.65.1613155774495; Fri, 12 Feb 2021 10:49:34 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 10:49:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 24/31] linux-user/aarch64: Implement PROT_MTE Date: Fri, 12 Feb 2021 10:48:55 -0800 Message-Id: <20210212184902.1251044-25-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::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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" Remember the PROT_MTE bit as PAGE_MTE/PAGE_TARGET_2. Otherwise this does not yet have effect. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 1 + linux-user/syscall_defs.h | 1 + target/arm/cpu.h | 1 + linux-user/mmap.c | 22 ++++++++++++++-------- 4 files changed, 17 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index d6ad774c01..09b9be845d 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -284,6 +284,7 @@ extern intptr_t qemu_host_page_mask; #endif /* Target-specific bits that will be used via page_get_flags(). */ #define PAGE_TARGET_1 0x0080 +#define PAGE_TARGET_2 0x0200 #if defined(CONFIG_USER_ONLY) void page_dump(FILE *f); diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index f98c1c1c8d..46a960fccb 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1311,6 +1311,7 @@ struct target_winsize { #ifdef TARGET_AARCH64 #define TARGET_PROT_BTI 0x10 +#define TARGET_PROT_MTE 0x20 #endif /* Common */ diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 72a0819eb8..efa1618c4d 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3608,6 +3608,7 @@ static inline MemTxAttrs *typecheck_memtxattrs(MemTxAttrs *x) * AArch64 usage of the PAGE_TARGET_* bits for linux-user. */ #define PAGE_BTI PAGE_TARGET_1 +#define PAGE_MTE PAGE_TARGET_2 #ifdef TARGET_TAGGED_ADDRESSES /** diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 6690384752..85e218ab1d 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -84,18 +84,24 @@ static int validate_prot_to_pageflags(int *host_prot, int prot) | (prot & PROT_EXEC ? PROT_READ : 0); #ifdef TARGET_AARCH64 - /* - * The PROT_BTI bit is only accepted if the cpu supports the feature. - * Since this is the unusual case, don't bother checking unless - * the bit has been requested. If set and valid, record the bit - * within QEMU's page_flags. - */ - if (prot & TARGET_PROT_BTI) { + { ARMCPU *cpu = ARM_CPU(thread_cpu); - if (cpu_isar_feature(aa64_bti, cpu)) { + + /* + * The PROT_BTI bit is only accepted if the cpu supports the feature. + * Since this is the unusual case, don't bother checking unless + * the bit has been requested. If set and valid, record the bit + * within QEMU's page_flags. + */ + if ((prot & TARGET_PROT_BTI) && cpu_isar_feature(aa64_bti, cpu)) { valid |= TARGET_PROT_BTI; page_flags |= PAGE_BTI; } + /* Similarly for the PROT_MTE bit. */ + if ((prot & TARGET_PROT_MTE) && cpu_isar_feature(aa64_mte, cpu)) { + valid |= TARGET_PROT_MTE; + page_flags |= PAGE_MTE; + } } #endif