From patchwork Thu Jan 28 22:41:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 372626 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp1663703jam; Thu, 28 Jan 2021 14:45:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMZ1a5EyllIaFe5IG9sSCnaSc1CcebUyymn9/MhFvYtCrFWRAFH0pvcAjqmkYS15+DPYXJ X-Received: by 2002:a25:2e4e:: with SMTP id b14mr161689ybn.135.1611873913869; Thu, 28 Jan 2021 14:45:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611873913; cv=none; d=google.com; s=arc-20160816; b=g6kz3NDUBOxroxr/Za7KqiYi0qgI5xoCPoMTcoucyE4e0LFSevgy0Wd37hk9T6kDhf VeQDvIUs1XzhMyzNqnwu+0xR0Icub0Ki0Qen6oTkmfydPdml8u/t3yDHnRzoOZjSocPZ 5UW+It+nYXlOGG5K9rtwpFUZMfZ8vDsTeB/rIJc4UhpphYee/Ghc7F+Vpu+rThZo5/dw B/VzL8KE+/2kN0g3+/dP2FMj2oALpopsH6BVZ2r8I8AX6iMhY76qD6nlxtRhlh5z5HrH hVnlojq8fVQR66uyHMaZKKEQgJjGIuIQI0jSCBreJxYk1QdnX7o2o1yWZe8SjlgQoUSp Ab4g== 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=Kyzjq96nH0KWrOiii6echH6ofV70lplGMBMMhcVo2Uo=; b=HaENVD5t21cKvmbmrtRabIHuhXKPf9mIQ9lixOzmSDjNplf2F5MxtPI0RYB64ph4QE cGBuw1AXJpnztDbMdvHjTrYC5La4Go1D11ThQMBNZvY/ihTDk/Q0V1kDONq0vm0vsnFv wGSfLeZgsN6DppsXrTxlhR00G+hesajTtqF6kF/jzkdYRDNOclDKvMhCkqzmjDDBrpZf EtvSBjHkSg/X8f/0LSmGOIzN6ZF9N8r5xcHNyxLMQSGF2DH+qOkPQiKqKowvVpqybJEJ ETtOzp43gjni0vvkhaSN/Lul1PECPtXE7omFYrzeTLs7hUHIxP7feXG8A3lz8aGMFcHt 3Mhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KvS9dgiq; 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 d14si6608685ybq.89.2021.01.28.14.45.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jan 2021 14:45:13 -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=fail header.i=@linaro.org header.s=google header.b=KvS9dgiq; 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]:52174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5G2L-0000fv-DE for patch@linaro.org; Thu, 28 Jan 2021 17:45:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:32878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5FzD-0005Pv-4M for qemu-devel@nongnu.org; Thu, 28 Jan 2021 17:41:59 -0500 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]:36643) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l5Fz5-00084t-22 for qemu-devel@nongnu.org; Thu, 28 Jan 2021 17:41:58 -0500 Received: by mail-pf1-x432.google.com with SMTP id u67so4977696pfb.3 for ; Thu, 28 Jan 2021 14:41:49 -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=Kyzjq96nH0KWrOiii6echH6ofV70lplGMBMMhcVo2Uo=; b=KvS9dgiqbKO3ebcoIxR4Yrw78r+JAItDFG6rSKiz6tsiOXoFZYxWLyKCmfsRMnw2h9 Vv9VCBKa7d1ylMd/YcZ2I1pKzbZd6mjRSwdLKpikbSyO1xMEdLyksV8l2/EflSOjjI2v ZeMrhLfcpOrl0hDb7H1rhyHAkwUK2zIZ3tSwlrx2O23qtXUGmkWgOWK73Ck9iHg7rag6 cgJiqdJUewKFfhQlwYWlB93TdKhQdMPmg4tqCtGUTPMk/MZYXnssgitNGMRV+Me7Yn4O COm3fZkRWuH5eBkuezZzsfn1ncBY2K+ZE2Nn0MRhsR9Gq2sKabCdp3imG/EhlcPfkHyn o7cw== 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=Kyzjq96nH0KWrOiii6echH6ofV70lplGMBMMhcVo2Uo=; b=EwW4LZ/aq2mDRwdFQ+EPykBNLBV+dIn4Nc61m5JZMc1D+uVRR4r0s5LG5AZX3QKn8K k2dmkf6KJf7j3mnOKWMdPNiDUoWEEqzcdF91dACFLWPbW4HynfDfiJB2kyUrWATQ368R jZDi5SyS3R/fc+qpVW/7cJomTobojz3UEljiX5J1Y8JXxfE7Oo5DqrgG8hGfjpce/MNs 4716aB5Hs+hcTdqnnAjAvYYW7phnw1/pR0TevIoBymvAIHd/FfWjKIFBn9ORZjTG1pPY WCUIcZAXaRUI4pQM7QNqFpWd3iwcG5EEP7/SQqYYtPb+Vu2hPAG1GjF2GeygyavK6x2V J/Jw== X-Gm-Message-State: AOAM533/X45aOj1pP3YbNTim8tq9y+S+flk4sti7lUO9By6Qrx0gCju8 S/bu9BlNW6+l/dcfuE207uhZf/i3ivbB6jkO X-Received: by 2002:a63:bd4a:: with SMTP id d10mr1589649pgp.18.1611873708278; Thu, 28 Jan 2021 14:41:48 -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 m10sm6042358pjs.25.2021.01.28.14.41.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 14:41:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 02/23] linux-user: Introduce PAGE_ANON Date: Thu, 28 Jan 2021 12:41:20 -1000 Message-Id: <20210128224141.638790-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210128224141.638790-1-richard.henderson@linaro.org> References: <20210128224141.638790-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.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, qemu-arm@nongnu.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 99a09ee137..c23c77589b 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: