From patchwork Fri Feb 12 18:48:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 381853 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3178424jah; Fri, 12 Feb 2021 10:54:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxggLYAIRqtWlVgNMP8YhhA7S75qvirfIKNmFjRUuYNo4uyLyQe/zvA+uJxe13V7jwOnuB X-Received: by 2002:a25:f601:: with SMTP id t1mr1622196ybd.268.1613156057061; Fri, 12 Feb 2021 10:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613156057; cv=none; d=google.com; s=arc-20160816; b=tSXq1VOACTDP1RqxNkzhfMBNQCluNS1ea6LtS/jOsZgacEXH0OiKhikAFpyPnYd3RR diOfaBTRG39RFoEUxAB4WKq3WH03jiS2JBJI9heIUNkMClfJFzBYoDY3S7DvG79sPKSb T0SDNDcS2u7ZVjLtbLWqbACXsyKrFZN1646mvsEetVRDV4ABeU3w/WXxrALWNQ89up9P AKkSPbs/SryJy2EobO3edo4cDDVk+i969TRvtAYkP2LdUAZu/IX/7Bfh1VSIMO1NPhGF Dj7hRQKs/P7ywsjWASYuz0zBlkq5Nix+Bdm0GOcmokCQ2m41WIgVKeLCLKJrgsrnHUSi czlw== 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=oq1eUfNJ5Tqc2veFWdzskdMZSlKpLHVOgyNg6GN6+/A=; b=ofPDZIACVbbMSsj3zQPGu5QcrfkU0uvGarCBi4jEfl9FhpojxJzrCC+yZ/A1NzuQcy AJsvL8FDs56cuEt+QhQE5XijRmICdpcu/snn7ioDswczhlaS192YSbWNn077W4mrmX/b j8/aEkG/4A5Gkd9Qw+0c7nM9TcTqSh8GczjBO+GqRS2RBvFuPOr/US6KrJfT/flPM8nV DD9yh41fg4mtdHHd3raKoYUyewWS3ohRH7tp8qH7ZoaXVwGHK9b0RHWm8nnF78fzFvgL SyzDdD8dXOfE8bWqH5YiTae94WmliJP7SR5TICFzf6jO8hsoImHTLo94rdLmlMsRRns/ zjuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hMl1JnXx; 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 q12si9130378ybk.95.2021.02.12.10.54.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Feb 2021 10:54:17 -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=hMl1JnXx; 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]:51402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAda3-0005Y3-Hd for patch@linaro.org; Fri, 12 Feb 2021 13:54:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAdVB-0001VI-8z for qemu-devel@nongnu.org; Fri, 12 Feb 2021 13:49:13 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:35003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lAdV6-0007fq-EN for qemu-devel@nongnu.org; Fri, 12 Feb 2021 13:49:12 -0500 Received: by mail-pl1-x630.google.com with SMTP id g20so332478plo.2 for ; Fri, 12 Feb 2021 10:49:07 -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=oq1eUfNJ5Tqc2veFWdzskdMZSlKpLHVOgyNg6GN6+/A=; b=hMl1JnXxUm+aWxE69SXTyDaTzFB7ZU6bT5+zPQYO/ppU8c1bR5WTqwdwk6UUnsIuxN auWyIsSDmCEx8cEq0gzpUj6UItq1ABoUv+ks9CD6n7TYK939KF4Wl4jIlgr2iKXcq58h oLN/ePq3UgA/7wH7tklb0++9vePXstKE6fuLDjvFW5uuWj2cR+AtdwnFUHInOf2oX1vo iIp8c209mt8krXoLtawg0UIcCrLYzEnOboBIBRx0/pnD9DWuueyMoYvMV1s4fDZeN8OE 5BeXAka5wHd+z1w4KNtSESWfwz8L2sLt3o5JZ/PMiyYlzQHYodN4cuOXh7tX6BORk+zV Dp0A== 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=oq1eUfNJ5Tqc2veFWdzskdMZSlKpLHVOgyNg6GN6+/A=; b=sMUyO+lXzwEmG5ioN58AHv4WjmLyM3AwOVkbkGi6lnMpcadaEyq6zbp4cHYwFNgAO8 SHHpKsigvWyqEElhW0XSEGlv0VPumNf2cAE8iNiv4tR3SmNzo53Ql3SxAheMKQq/wcks iClBnCuN7T6CSnYjUAxlT3yZ2zq5IdzHvT1EOYKp7vqal0S90SMJLl/sKjUOI3RYINkM dZndAFKF87bnUYFM6jlTrciTbRUvEEoIfNsfliZZjagOJ1LIIOv7lmJ6/hJb6Le9SR8c oGsBNp7Lgtkzg6dgj6N4vkeT6nZAwPGObpejS3B3rFyp1TvFQC8+FUyJqx9X2KceaN5W ObiQ== X-Gm-Message-State: AOAM532UwyUDKaZYu92YqyUWyXhMaGMKus9l8SUzXlyOQW7aQ3Ko6gPp oH9VGOCZG93uaoSkZegk5I00XFEXuNoL2Q== X-Received: by 2002:a17:90a:66ce:: with SMTP id z14mr3971227pjl.123.1613155746594; Fri, 12 Feb 2021 10:49:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 10:49:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 02/31] linux-user: Introduce PAGE_ANON Date: Fri, 12 Feb 2021 10:48:33 -0800 Message-Id: <20210212184902.1251044-3-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::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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" Record whether the backing page is anonymous, or if it has file backing. This will allow us to get close to the Linux AArch64 ABI for MTE, which allows tag memory only on ram-backed VMAs. The real ABI allows tag memory on files, when those files are on ram-backed filesystems, such as tmpfs. We will not be able to implement that in QEMU linux-user. Thankfully, anonymous memory for malloc arenas is the primary consumer of this feature, so this restricted version should still be of use. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 2 ++ linux-user/mmap.c | 3 +++ 2 files changed, 5 insertions(+) -- 2.25.1 diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index af555f1798..1f47e0fe44 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -275,6 +275,8 @@ extern intptr_t qemu_host_page_mask; #define PAGE_WRITE_INV 0x0020 /* For use with page_set_flags: page is being replaced; target_data cleared. */ #define PAGE_RESET 0x0040 +/* For linux-user, indicates that the page is MAP_ANON. */ +#define PAGE_ANON 0x0080 #if defined(CONFIG_BSD) && defined(CONFIG_USER_ONLY) /* FIXME: Code that sets/uses this is broken and needs to go away. */ diff --git a/linux-user/mmap.c b/linux-user/mmap.c index c693505b60..7fb4c628e1 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -599,6 +599,9 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, } } the_end1: + if (flags & MAP_ANONYMOUS) { + page_flags |= PAGE_ANON; + } page_flags |= PAGE_RESET; page_set_flags(start, start + len, page_flags); the_end: