From patchwork Fri Jun 5 04:17:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187476 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp2024665ilo; Thu, 4 Jun 2020 21:18:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdoNW6V8NAIR+oPbs9HR3FzyWtFJI2N4KUk7l1813YbzDNxb7gpkUgmYk7WiQB41ttiTGa X-Received: by 2002:a25:c647:: with SMTP id k68mr13043191ybf.345.1591330722558; Thu, 04 Jun 2020 21:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591330722; cv=none; d=google.com; s=arc-20160816; b=X6HblEK6FW1OkUnm1VrKoS1lmSlliAnxMH/CDCNrQT0qS31PgPb1BMArZCb8W2usaJ TAiy3XR2nRjGuKQKb88IBDtJGFnzXq7Cm7RTIHwgEbSZUk5bnRm0UXAKTwOR9/WGwKhv fFXatnalsFi1tPQMfEH0KUz7e49w+CvJvhoqJX5ptFLhSR2im7tCSmwsShQva1ZP8L9K NCAzIU0TpXKO5FqfGy04zwaDJuJcHVoRoz8uQP9xMri/PzP9HJHhy4LYMKAdjDprP+k8 WF3bD/hYfo5asNGWfPZzDHmdhV1XTyYYtuN3IwiBmaKITK9C9LFkkWnEbnRC3XFAwCug JShQ== 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=eLZZtVFaB75BQS+spGGXnwizsOQKSuMWVvyzFk16uJw=; b=kzkNmuDtfYcB03rdp06/KTEun3LKkBJMG+0tp0FIGgNn4ce9+SmSIN5eGmjT6A7Yjj mYso1cfoO7nywl2cq6JQxs439JVS+t+K/58stzD6PwxSOjW0T7dp9lax+beejvShZcl7 ja398Gm6bhhGU8QBXZM7B5TYQwAqMXsIzp2FNDOkl18ocop08owN7qwJx/6S9p32BBEg 01OPC7dufq6P4RFxbTu9VhFpz7WwDlutLFgPidV+srjGn5HVAzZBU7rDwBZFAVcSzE2J cZMN11BpUuZHP2hI6clRol2hL+geefRjrhqtSqU9Z3HuJzfQHvRH+NmJ6YE6ORGB3YOI D4Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="dkGcpEw/"; 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 e15si622701ybr.334.2020.06.04.21.18.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jun 2020 21:18:42 -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="dkGcpEw/"; 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]:37524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jh3oY-00054r-1a for patch@linaro.org; Fri, 05 Jun 2020 00:18:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jh3na-0004Ef-4T for qemu-devel@nongnu.org; Fri, 05 Jun 2020 00:17:42 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:36156) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jh3nX-0000it-Gb for qemu-devel@nongnu.org; Fri, 05 Jun 2020 00:17:41 -0400 Received: by mail-pj1-x1042.google.com with SMTP id q24so2180561pjd.1 for ; Thu, 04 Jun 2020 21:17:39 -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=eLZZtVFaB75BQS+spGGXnwizsOQKSuMWVvyzFk16uJw=; b=dkGcpEw/QA8qwpDaDFqgPmDutz39Gfwybi7llJl84hrNtzI8DD261uTAlCrwspeY25 HDasxtEIgKSuUghhmyPWGmEDECPRG9uOGNweAyTvQG7KY/nY/AIlf/Lg8y7KdjTWnFXu +5Tjorxm6GtCjAlWDPyfcdqDcBlOxGX25Q/38/B1uZypAOf4K0qNv7ltf2b0f009/R18 BoXlgvIDdRIboQY4TkqMxQjRGzPjGEeMTSKooxYqv7KRaUX5brtPitOGdnwSHrVXhsqm Y+ob45FpwXUlAE7GTJN+aTOAPOrgvq4lb+1RFzjz7OLxh1otKOH3PuoVmlC+NqlMf4++ V/bA== 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=eLZZtVFaB75BQS+spGGXnwizsOQKSuMWVvyzFk16uJw=; b=p/91jvpTahBezvTfLaZH/8a71y5o2L6ROqTqvHVjdEm9fIuUTehanmC012LhDB68vl LjBHzgg01CP8+PtTwKAZGjRt5zuTpT3oo8WqPmNBiPZfH0ZSGpHMzQ3ZWktvO95gbXnq mAYD8j/xypNVVoweyrnZtXm8MjanYiwyHK7In0FGq592l4kWKdGhV5jM2rRwSTExEi8e 5P7n9hVkEckycDWNeY7bkTyloBWTu4t4W4fMNevLet3a/VqboQmXozFbSQ4rVkcpnpsl 03GWsyM4mMTlLT6rnfvr5XLd2EUa3YwbRY+TTUFLiJlJFvBkHqSip32eTHRMiWDelB1H QHxA== X-Gm-Message-State: AOAM532Qe1tcfSiEzPo/np6e0MuPmZXKYL3cteICHzdBplK1SXU9KRKL vdniYDd9X0FvTLEo6eVFjwh1rtPBICc= X-Received: by 2002:a17:902:24d:: with SMTP id 71mr5345398plc.12.1591330657785; Thu, 04 Jun 2020 21:17:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 21:17:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 02/17] linux-user: Introduce PAGE_ANON Date: Thu, 4 Jun 2020 21:17:18 -0700 Message-Id: <20200605041733.415188-3-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::1042; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1042.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" 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. Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 2 ++ linux-user/mmap.c | 3 +++ 2 files changed, 5 insertions(+) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index e5f564fa1f..3cac7750e4 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -277,6 +277,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 f9832609b0..fdd55986a1 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: