From patchwork Sat Jul 15 13:52:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 703211 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e4d:0:b0:314:25da:8dc4 with SMTP id r13csp156837wrt; Sat, 15 Jul 2023 06:54:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlGn5gFOEVgAjwQlfjNd06c07jkhjwQJXR7GYeAFLl5c+VUa+eghxaYtx/BiTjNwpe2La/Sf X-Received: by 2002:a05:620a:9c3:b0:764:a7d8:1591 with SMTP id y3-20020a05620a09c300b00764a7d81591mr7088804qky.33.1689429285223; Sat, 15 Jul 2023 06:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689429285; cv=none; d=google.com; s=arc-20160816; b=SrmeHI3W9/Vcf9Zex/zp7UrOOlL1m5NedJSPaeQzhcMMoK62WdDcsRbkPL/3kLi597 RljQvkQ88ftDsFu+HvTxwd4rUJaVceJgEjqn4/Qp9T06LvnSir94G2FlWYBxQ9+dJMsr urbeT2MJQJbpb3TPWpFHLG7K1lTYsB0scZAqmlG8ZZBVeTaLGBLktw9TA21UxFC1DSMo QiN/KRURqq8nyRSb4BQMVZvQJqpQmbw6qjGGwVZXNmalm9aNRZHHof31swmEv4cXitY+ t6KdNdbK8fkWQCa5MbkfLRhIemO9ki6/SKBkljDd0//99BEM4zl97lI75I5y73rwqUlO gRuw== 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=4EchJl5hjgKZgeWYuYg1q+jxNR3MablBrvDvJkqZmCU=; fh=ZuLSLtzpwbOj79Lm6HQkAzCl7AYBeBRT4Q/1zeFcrQg=; b=GQ1GOEzxwkp5dMSEyGBYOcMjL8XN9sR/EpnlGIqbbD+QT17ctihNQWV/cWlV/D9xK4 +aFYe1C1MkZ77qn5Z4AOtZAMjBH0JKllh6GGBXxgj3ecAFMUr65LAmcKPhX9c7UoElt6 U2hxfFpbYQQnMsveBEQJgmCRWtrhBWdjsxl7yiDnfrqyBFdvZrEDIxW3WJQv3l2iUolr uIyJ93mpYI6tMJgk4RTsX/cn+jEcfbDSLzdVR03pRWhYgPUb0Y+MpHYYsbaVHIOP5bKw G0bd9/9hGOVNbPodOmnNxPnwFAzK4b0ADgWgPA8oYfCNz3+xo4hwKHES3cMPmGax5R2j p97A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eNv6KoKl; 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 d125-20020a37b483000000b00767cba57b88si5627946qkf.372.2023.07.15.06.54.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Jul 2023 06:54:45 -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=eNv6KoKl; 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 1qKfiz-0004Wp-Hy; Sat, 15 Jul 2023 09:54:18 -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 1qKfiR-000465-3E for qemu-devel@nongnu.org; Sat, 15 Jul 2023 09:53:47 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qKfiP-0001Ig-H8 for qemu-devel@nongnu.org; Sat, 15 Jul 2023 09:53:42 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-31441bc0092so2962726f8f.1 for ; Sat, 15 Jul 2023 06:53:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689429219; x=1692021219; 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=4EchJl5hjgKZgeWYuYg1q+jxNR3MablBrvDvJkqZmCU=; b=eNv6KoKlNQZZMsoIMzJoL+ZzExXw342ELL1HrpWXaxhSq1wgs3OdvUrAME6urpVk/s NyoP6qRJ0er9XrBvzVrjSGDEb5uVMu5H4nJDKte1H+Abu731gBbDz1p65JuaBgO9ebdO mMkORZSBc8WdkkfgqVBfC2jhz6h2dfxIevdPSY8NJd8hq0zbhjn4/ufHSlKWpHT4Bx8u aRopsMf24KYiLczFIXnfwnhbiRUe6c5vuZd9qYzA3FwF3EVYM0Varasgqnr9+cQHS3Bs U998R2wyexEW9vxtsRIo5iUGZO5DgeRkxh/yh5357H0SAWBPw3nLII8XQLm0KdRSc82e 2e3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689429219; x=1692021219; 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=4EchJl5hjgKZgeWYuYg1q+jxNR3MablBrvDvJkqZmCU=; b=E08KIpcUcmmV8kA+bT3ki8evTMXiOj5H+LwO1XvM2Z/9ABc1k5JAcwW68bJTTkBsMN 6L4DJpWd7CERnQGmWM4RK4lN3khBM1ywpPcWD3mzyE17235ZNP+CayIeb6Fq3K90vuE9 b/kfnBACpEjlComPIK6sXHOFb8OoqT4qgS685H3XVluPP4ZTzRE4aMRV5eqoslDhwsdA Lb1ptysBhq3MTcc++mFW2RoZIM29Gz8KLetUp9bKeaeYwWbXSj7NIHn8rpuaqk85bCDN Z/qBZ8A4RrHFAVG4Xbj6GRWCx9990NTLbIxxW+OIQ/VuS7tjHU3Vl5D/d7l+vYyBWoC+ KwIQ== X-Gm-Message-State: ABy/qLavtrrKrNiwAo0LvwZ+jPWksCVfhFddR1v1C9eBQKT85rbyKnKb KmuhaGKa+q6MPEcbNI1dLM6IBJhAITiD+5NI44PKrA== X-Received: by 2002:a5d:5505:0:b0:313:f98a:1fd3 with SMTP id b5-20020a5d5505000000b00313f98a1fd3mr6977580wrv.27.1689429219290; Sat, 15 Jul 2023 06:53:39 -0700 (PDT) Received: from stoup.lan ([51.219.12.49]) by smtp.gmail.com with ESMTPSA id k10-20020a5d66ca000000b00313f9085119sm13838014wrw.113.2023.07.15.06.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 06:53:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 25/47] linux-user: Populate more bits in mmap_flags_tbl Date: Sat, 15 Jul 2023 14:52:55 +0100 Message-Id: <20230715135317.7219-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230715135317.7219-1-richard.henderson@linaro.org> References: <20230715135317.7219-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x435.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 Message-Id: <20230707204054.8792-9-richard.henderson@linaro.org> --- linux-user/strace.c | 23 ++++++++++------------- linux-user/syscall.c | 21 +++++++++++++++++++-- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 9228b235da..bbd29148d4 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 02d3b6c90a..3a89f6b408 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6012,9 +6012,19 @@ static const StructEntry struct_termios_def = { .print = print_termios, }; +/* If the host does not provide these bits, they may be safely discarded. */ +#ifndef MAP_SYNC +#define MAP_SYNC 0 +#endif +#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 }, @@ -6032,6 +6042,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 } };