From patchwork Fri Jul 7 20:40:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700044 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4065538wrs; Fri, 7 Jul 2023 13:42:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlF4ptaebQL4HpK5WaYxyMWUwHh4zgMjMOJ0jlyD3FVHhxDUMvBniWzAY3qMujF/jCPP8ENb X-Received: by 2002:ac8:5c45:0:b0:3f6:c609:e9da with SMTP id j5-20020ac85c45000000b003f6c609e9damr7237698qtj.44.1688762561647; Fri, 07 Jul 2023 13:42:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688762561; cv=none; d=google.com; s=arc-20160816; b=FoBLCEnQKMve4fJTUOXmBv9hPeGMb76XFTyy++AttM2bEWSHAMFPtTlk3TIqGTFG5l QazJZyazoTa54HTIo5Pl1bFbWIwH/ANbWkIrgRVmW0bAj3OfCD4WR+tR7u6lHm/y5jw5 kmwmcpy44P1VLGwVaDTbScUtulONf9aUIVi0axIfqptXDZam9G53umLMZA6NNvoacCke VcE8xgXpHUTy5U3H5N8ljy84B3CMVeTYxejUIvBRJOPSXKEtX953UODKb77jw+PpksoJ olaycjdVirU6wgRWMJhODK3LrggQF59Ek0fx4La21azv748rHTDsb5aRQdsPq2xRVZJk KBtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=b2kxpoTo/D6lAeqPJxWGsbdox8UTpGN/fykOYkONe80=; fh=Snw/yWAI/7AA6tppTg8XdyKlL779shjlYiHUTcQyZPQ=; b=C+SA1jFHZTOeKA80EKaTmzSuerDzZ5KlF/fUF95WwOFCDqqTFsSeMpck6ykVeEOP8W 9yV3FbfSHRJG3mfgBBf6STdi62wBFGZyIPRU+Sfbh679GWy1Rs4vXt9kr/YKOfoZ1qXL pNNV+jw6sFjO97iRINYKKFCtfc7i7bJIsNouE4RplPMvbvemx/Vuyw7TxQPoWRoV2E3n r4Ex4HNEsZxUZjJE8jqquuAmF9ZT3SVnmKJEvCXoS7yT0BArtCD17UQgo9JOowLA8FJn Ib5yLR+Pv7Q7C0jqHie7oGOv0cjbZXrmiL/F03pEpu0OXpm6QaGKTQEpn8kKxLHjNn2i VIpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eSf0ydDe; 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 e19-20020a05622a111300b004021c5962f6si3154533qty.422.2023.07.07.13.42.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jul 2023 13:42:41 -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=pass header.i=@linaro.org header.s=google header.b=eSf0ydDe; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qHsGJ-0004mg-Tv; Fri, 07 Jul 2023 16:41:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qHsGG-0004j7-KZ for qemu-devel@nongnu.org; Fri, 07 Jul 2023 16:41:04 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qHsGE-0004e2-Rm for qemu-devel@nongnu.org; Fri, 07 Jul 2023 16:41:04 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fbc6ab5ff5so25328905e9.1 for ; Fri, 07 Jul 2023 13:41:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688762461; x=1691354461; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b2kxpoTo/D6lAeqPJxWGsbdox8UTpGN/fykOYkONe80=; b=eSf0ydDeKFGinF4i7T4iQAz0VkndFzqqlUdrTnjvGdATg2a01+ecgaVy4ZM61YCOW6 GFGJSczA382gPKWJeYUmH+6CkbSnbM4ZDOpM7vZ23+wiX/Kplp16XUZUV7ku55uBL3BZ uxa4GEBGM9vicrJiJEcDcbG3NbrCXUgazYr3vgf9t+ss21iG37SdK1ZCTyMBi7BulyfB 7aPj3xaSHwKdM4fDWcmqRwlhHulNRkN2d9NQLRo3RdSNoUrfSMGZeTg1dFbzCWmzgWwU ppa8bUZRvsJkZy0JyFuFbFBjmrdUxzKX/pufbxzm6BhuuLNn37nHOEnc6EfX2UzLgNRR FuDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688762461; x=1691354461; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b2kxpoTo/D6lAeqPJxWGsbdox8UTpGN/fykOYkONe80=; b=UE8Oi9P8R2Fey+ZYEog56qPYTsLVBmAMVwltGOxT51iYgE8umWFHPEdPfKTmQnrldU GhlLM2DLi7UQ2B8IKx/P6sT+gAkwpQc7K+pvOjY8mcrdtllMWzaHoPIWl/rr3L3Eeyar mop5f07QwkRcg8akMlRYluk0/IyxP5xTtoP1ZbzyNhskVsQDRoie76sK4TSM6hNN/CWn /TZp4OCxCciz9CTGuIeygCtKdV2WyEQek0ne0kAPAloAEkfVVLeH+wx5TOdJGG82N9Q9 3NSbmY2XPZveDTd9DcHfNMuWhxhJfCs90lx3l+dmAms/RmntzOco3+Hf+mRDOMz9idBy UQZQ== X-Gm-Message-State: ABy/qLZrovdObEgLvS+9gkvlRo+V1PYyviImlGPik/QzOZG8hWSNfRGh 783edkjffizAxIOuDiNuvoG1p4M5pDtXpn15frbGjA== X-Received: by 2002:a05:600c:210a:b0:3f6:58ad:ed85 with SMTP id u10-20020a05600c210a00b003f658aded85mr4664061wml.10.1688762461345; Fri, 07 Jul 2023 13:41:01 -0700 (PDT) Received: from localhost.localdomain (host-92-23-208-66.as13285.net. [92.23.208.66]) by smtp.gmail.com with ESMTPSA id q10-20020a1ce90a000000b003fbb25da65bsm3337736wmc.30.2023.07.07.13.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 13:41:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, mjt@tls.msk.ru, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 06/24] linux-user: Populate more bits in mmap_flags_tbl Date: Fri, 7 Jul 2023 21:40:36 +0100 Message-Id: <20230707204054.8792-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230707204054.8792-1-richard.henderson@linaro.org> References: <20230707204054.8792-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x331.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, T_SCC_BODY_TEXT_LINE=-0.01, UPPERCASE_50_75=0.008 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Fix translation of TARGET_MAP_SHARED and TARGET_MAP_PRIVATE, which are types not single bits. Add TARGET_MAP_SHARED_VALIDATE, TARGET_MAP_SYNC, TARGET_MAP_NONBLOCK, TARGET_MAP_POPULATE, TARGET_MAP_FIXED_NOREPLACE, and TARGET_MAP_UNINITIALIZED. Update strace to match. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- linux-user/strace.c | 23 ++++++++++------------- linux-user/syscall.c | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 566396d051..af5c5f135b 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1094,28 +1094,25 @@ UNUSED static const struct flags mmap_prot_flags[] = { }; UNUSED static const struct flags mmap_flags[] = { - FLAG_TARGET(MAP_SHARED), - FLAG_TARGET(MAP_PRIVATE), + FLAG_TARGET_MASK(MAP_SHARED, MAP_TYPE), + FLAG_TARGET_MASK(MAP_PRIVATE, MAP_TYPE), + FLAG_TARGET_MASK(MAP_SHARED_VALIDATE, MAP_TYPE), FLAG_TARGET(MAP_ANONYMOUS), FLAG_TARGET(MAP_DENYWRITE), - FLAG_TARGET(MAP_FIXED), - FLAG_TARGET(MAP_GROWSDOWN), FLAG_TARGET(MAP_EXECUTABLE), -#ifdef MAP_LOCKED + FLAG_TARGET(MAP_FIXED), + FLAG_TARGET(MAP_FIXED_NOREPLACE), + FLAG_TARGET(MAP_GROWSDOWN), + FLAG_TARGET(MAP_HUGETLB), FLAG_TARGET(MAP_LOCKED), -#endif -#ifdef MAP_NONBLOCK FLAG_TARGET(MAP_NONBLOCK), -#endif FLAG_TARGET(MAP_NORESERVE), -#ifdef MAP_POPULATE FLAG_TARGET(MAP_POPULATE), -#endif -#if defined(TARGET_MAP_UNINITIALIZED) && TARGET_MAP_UNINITIALIZED != 0 + FLAG_TARGET(MAP_STACK), + FLAG_TARGET(MAP_SYNC), +#if TARGET_MAP_UNINITIALIZED != 0 FLAG_TARGET(MAP_UNINITIALIZED), #endif - FLAG_TARGET(MAP_HUGETLB), - FLAG_TARGET(MAP_STACK), FLAG_END, }; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 08162cc966..2c0c6e745e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6002,9 +6002,16 @@ static const StructEntry struct_termios_def = { .print = print_termios, }; +/* If the host does not provide these bits, they may be safely discarded. */ +#ifndef MAP_UNINITIALIZED +#define MAP_UNINITIALIZED 0 +#endif + static const bitmask_transtbl mmap_flags_tbl[] = { - { TARGET_MAP_SHARED, TARGET_MAP_SHARED, MAP_SHARED, MAP_SHARED }, - { TARGET_MAP_PRIVATE, TARGET_MAP_PRIVATE, MAP_PRIVATE, MAP_PRIVATE }, + { TARGET_MAP_TYPE, TARGET_MAP_SHARED, MAP_TYPE, MAP_SHARED }, + { TARGET_MAP_TYPE, TARGET_MAP_PRIVATE, MAP_TYPE, MAP_PRIVATE }, + { TARGET_MAP_TYPE, TARGET_MAP_SHARED_VALIDATE, + MAP_TYPE, MAP_SHARED_VALIDATE }, { TARGET_MAP_FIXED, TARGET_MAP_FIXED, MAP_FIXED, MAP_FIXED }, { TARGET_MAP_ANONYMOUS, TARGET_MAP_ANONYMOUS, MAP_ANONYMOUS, MAP_ANONYMOUS }, @@ -6022,6 +6029,13 @@ static const bitmask_transtbl mmap_flags_tbl[] = { Recognize it for the target insofar as we do not want to pass it through to the host. */ { TARGET_MAP_STACK, TARGET_MAP_STACK, 0, 0 }, + { TARGET_MAP_SYNC, TARGET_MAP_SYNC, MAP_SYNC, MAP_SYNC }, + { TARGET_MAP_NONBLOCK, TARGET_MAP_NONBLOCK, MAP_NONBLOCK, MAP_NONBLOCK }, + { TARGET_MAP_POPULATE, TARGET_MAP_POPULATE, MAP_POPULATE, MAP_POPULATE }, + { TARGET_MAP_FIXED_NOREPLACE, TARGET_MAP_FIXED_NOREPLACE, + MAP_FIXED_NOREPLACE, MAP_FIXED_NOREPLACE }, + { TARGET_MAP_UNINITIALIZED, TARGET_MAP_UNINITIALIZED, + MAP_UNINITIALIZED, MAP_UNINITIALIZED }, { 0, 0, 0, 0 } };