Received: by 2002:a19:e8d:0:0:0:0:0 with SMTP id 135csp495314lfo; Wed, 3 Feb 2021 11:22:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPer1Q6nPRI2Zxwit/ChKhbR0pSUp5TSQ8x+Sbg8MIgbjiEaDSe0katNggcZt6DS5ut+qN X-Received: by 2002:a25:3056:: with SMTP id w83mr6253819ybw.504.1612380131846; Wed, 03 Feb 2021 11:22:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612380131; cv=none; d=google.com; s=arc-20160816; b=cxfhKYfxpUYOyndCR8cVZbOrSm6xrUvYQZiGkaKryzbYN3/jtvEXJ/HOwgvo7J2+By Z2Z+eQOYzP8tdYjJEGBaBWFmeDrOLaxW83HR/cn21f69QdnSGkPu+HjX6UZHWX7jQ3np IKhuE0smf9K1bWVcmmnDfyDFkWnbxSeq9NQLTJnQoRnNu9nOkaw+PUFsqd9fAyCyyz8d hBJYt4EJZ1YDii8lSwOa6LrUb/atSbKNMbATgOYKgIw3/O1uk1v2c8o4Rxze0n2KKh0b kh94UXziHL1RQF90jhSFQ69bLcvEMyY/UZAbJJ+A4JW+hInD8SIPT/8G2dyyB0HlH8eo XTIg== 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=fCxV49bfxaBtv2xlDg0+NI6CzMz9AR3avdjaaz44F+U=; b=F3ba+doR5KOtX+7Q71P1UJDUq76M8CEPsm4EJe4R6VkfRnn+1O+zeT6L7xqupkgJDg NrqwL2Bhq0J4a2CR6pvrs6pUxEyO9E1zu4O1LKiKgXGVxSerPEmlCHQBEW0yNXBTrzuk i0G7H1xHS5BnklWmFuipy9SFXuPgyw79/Bp+QmB+qlhdYVxQhGpg+kiQ1/qjCeCcPalw wkMyv3N1GWtUZCnY5EMTJ+BMywRWXU6WQKM0JvY//UVuIEPEieiKGel3cOUTClsNI+7X i+bY2X0PEXADfbbvmjEtA1cPyfSz51Shtk3OpN0lZ7JEYIrsGO1tsmOeOJy1bKu+JZy0 Vmvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=U8fptPED; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=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 y9si3281340ybn.264.2021.02.03.11.22.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Feb 2021 11:22:11 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=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=U8fptPED; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:35172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Nj9-0006IR-7T for alex.bennee@linaro.org; Wed, 03 Feb 2021 14:22:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7NP0-0007cg-1W for qemu-arm@nongnu.org; Wed, 03 Feb 2021 14:01:22 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:37038) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7NOr-0001ov-C0 for qemu-arm@nongnu.org; Wed, 03 Feb 2021 14:01:21 -0500 Received: by mail-pg1-x536.google.com with SMTP id z21so392929pgj.4 for ; Wed, 03 Feb 2021 11:01:03 -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=fCxV49bfxaBtv2xlDg0+NI6CzMz9AR3avdjaaz44F+U=; b=U8fptPED9jlxWohXqurZFrvG5APWE7cs6Y28DUfW+HM8yfX4a12H42IgMxWmwWk7cU IP/QmAIr/rDV1c47ZRdeevvKyqJB428i37QqfMY8hwY37yT/0DUzkcwag0h7tEysqQ6f lDFwHDXl2mFeGBMW7OiEfwpPej1BNqN1uf26XDvpy73TIPLaO0z0MY1EL9RpOEDPerZk TA+rV0GosDALoYUGPPSd/eVNMHbSFTERhzFqg0x7QCaohzjbdPjkFWGpNizyeYpWcZl5 N1XyQG00lWq/VY7ucp0rzPEUPGg6Mv8lvZDfXuRKGR+wV15eSp6YuteVVi3MiFiqJWvW 9KKw== 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=fCxV49bfxaBtv2xlDg0+NI6CzMz9AR3avdjaaz44F+U=; b=KmPi60rSvJwi+cYxdi4WTNWyro26D8mVqTqya4dkGa0oxGzWs7jjLZjFVZcdFphfOD vmYPS4hqEYxpIyOykKCj41j2zvx8eX/4DiA32ElMqJ9RWDBaj+r0TrhUUgCA+xsQax7S FcidK1hXl6ETB0MerVhIDnhXjY7K/fGOCB6nbTPBXJr5AJjPZLlmL+n/3XhSl7ZvPyA1 zTZPXbPkn5NPtVRKn2ygm8eygE8ZLPDKAYXdwAK+fVD/VJDcPA0jnW+ot/ZRiJf8FI36 BFEExHS/F6YSCrJTVEskNBYhKgYa/txzKlTiiehWtH2NtbERvFDmvV3VKwWVIzQD2B0L FPnw== X-Gm-Message-State: AOAM531b3mefP+qpprsHGCQOiPnhdptv7+yTGY8neWgPoAoKiQbhhqoG /j/1a7R22pWCLLdgR0fiHgDYsEmBoMGi9WhR X-Received: by 2002:a63:c941:: with SMTP id y1mr5106047pgg.313.1612378863075; Wed, 03 Feb 2021 11:01:03 -0800 (PST) Received: from localhost.localdomain (cpe-66-27-222-29.hawaii.res.rr.com. [66.27.222.29]) by smtp.gmail.com with ESMTPSA id l2sm2906666pju.25.2021.02.03.11.01.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 11:01:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 24/31] linux-user/aarch64: Implement PROT_MTE Date: Wed, 3 Feb 2021 09:00:03 -1000 Message-Id: <20210203190010.759771-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203190010.759771-1-richard.henderson@linaro.org> References: <20210203190010.759771-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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-arm@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 Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: 8/4lx+VE68kX 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(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index c52180e8e6..b2a72f70ec 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 558ad1466b..e3e61ce7ab 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3606,6 +3606,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 -- 2.25.1