From patchwork Fri Mar 1 23:05:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 777110 Delivered-To: patch@linaro.org Received: by 2002:adf:e94d:0:b0:33d:f458:43ce with SMTP id m13csp1603745wrn; Fri, 1 Mar 2024 15:16:32 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVEAeg1CSW6orlgEKISQow0yBQ0NjlyGTybrfXWVeOiS+yz+MwN8gUTk1xa3STzYZuVB/1D0T/FZ/HBPCOVsAJh X-Google-Smtp-Source: AGHT+IF7t4BWylHZZ/MTKLz7kxPBhzmhWVZaZiuqDofKMR1HvR6NeNqpMYG/PltkBouta/rmTlsH X-Received: by 2002:ac8:59cc:0:b0:42e:bd4b:7099 with SMTP id f12-20020ac859cc000000b0042ebd4b7099mr2427303qtf.4.1709334992696; Fri, 01 Mar 2024 15:16:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709334992; cv=none; d=google.com; s=arc-20160816; b=I2dh6BOAA5wXT90UGMxOvK/rKmQh5xsj29QZsYhSZFuUsz2QtLco3uoyHOGPQbOixi XZ9jwBR1C8oTMuVIGDyy/DQ8WvEnmlvcyVJQ6cTLIUdIQg4buXXT0R+XQn3ei9KGK6tJ Km93hAtRBLRjoaamB+v/aq+ui1GRWPCb5FuviYg5hpl+gxzff//vOMmgypd5uajhw55i 7MtDqvHvor9blB6u2+OA5WrxsuAQ0Fl3ZC8Kds03+PVpUB66yXT45e8SoJmQmucEZfd3 4zyD9gYjmIamR9wwTEl4gIuAO86pGJcizDbLyDJhzguADEyWx0ynNfyCIcZd8WhTYIva z6iw== 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=ZykOOhGWRLaDSZ6ojBtzy1ZtPjktUdeyK8bHHdP5Cx0=; fh=TypceWkQqZAd58MbMvFzjbJhJVwYT3Z2Jon575mPbgg=; b=tvhhAtZemZP67Ot9A0vYqGDgKA2GpzkTEGhMrxK3c/ofPA6WiyAWIkYrN1uDi2oBvI jgdL6s5Mhn0NDpExXM8qcaecbphTs1idDO3XbBI1U7hF3ZFkECwwIH+OzFpKgQCWZzyh dBvTkaxeVI7o4HXPKvDI7Pq+a1e7J755lIFKDa/gU/Y9lwZ6c3FKVMuXS7RD5uLv5yt3 Q+Kel5OPeDVeoUCrQZFvGbqQukt+FXyhpwPBoG47cvvFMUSpYMlyj/EXY4iB/IexUswT 6iCSQ7m6aGQjVw53bTZD5CajdaY7zdQxG9Nr5mGleCNVS/Jh2+tYxoXOePHBMJxWpB/0 1kRQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DWkDLAOe; 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 6-20020ac85946000000b0042e04621f7bsi4994515qtz.3.2024.03.01.15.16.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Mar 2024 15:16:32 -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=DWkDLAOe; 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 1rgByV-0006BL-H2; Fri, 01 Mar 2024 18:07:31 -0500 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 1rgByK-0005kj-QH for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:07:22 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rgByI-0004PQ-Nf for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:07:19 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1dc75972f25so24448785ad.1 for ; Fri, 01 Mar 2024 15:07:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709334437; x=1709939237; darn=nongnu.org; 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=ZykOOhGWRLaDSZ6ojBtzy1ZtPjktUdeyK8bHHdP5Cx0=; b=DWkDLAOe9yvqiTfCM4cnIu5qF8tD80IlrKfbJSo8tY8BQAYQjojg+2w9g7YQJ8vzW/ 4NTVEnaC6r2ypZbVHppgYr+OWZS5nGePxl9j6WHExQFg0u2SX+jlCpy0WUZTGggt0C8S M8VjBcJj3pYdlZDmJkua2Q45uoD24UmkkpkfpeRFlBiT2PmWLGuykxnlIZSOgLSDV2ZX z+1KctoGqBpdvvbUjnkaXH4OfsoSiQYGSIeQ2vPAg99laYs7DNG1FI3NPGAvpm5AWrWA wAAQiOTURA9gqmc0OF4lCOa1Amkl1CByUiOklbWmCi0Wp05wktA+Ejhxuhk9FSYbH/pb cBTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709334437; x=1709939237; 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=ZykOOhGWRLaDSZ6ojBtzy1ZtPjktUdeyK8bHHdP5Cx0=; b=r7QFK4r5lDC0u1lfK8PzSMiXXNcxrbKhlALNAyb5+N+XflzdivhT4adAubfPjGlqvZ 027QTFbmt+i6BqWcvt5OvHGb2K7Y17rkU1UTSTo7RZCV+dU6q2JeqLTEkS0g7ousOVAz JPA7sPj88ZF7/H1fq5RyIpM1srcxlZxpcL9ah0FBtoZ9gDLgAcW0FGohviwA9J8euvBi 9VwwyYQK2XvO9Z/Gm4n35lAnt/7VAvqElEfHnhCChll+MgQ7EWi+Qih0aPtP23LkUTeD f6TRTp3qanIFZtTzkvHuQdyDYUvhI/RCSF5gkd2pqF+PjhpmrSr5ZPs2/lc//VQlrZ8O xNnQ== X-Gm-Message-State: AOJu0YyPm/D8zytqy90iEZ9tojogDSyaWUEX2LDETqOReMd95JJ0x2kA reCMPO9xDoHHYGjrc8GKQbXfsph6qM6456c1bJHyyrZjtNaL+EndHBXE8E3G0QzTBUU3xGfrnQt i X-Received: by 2002:a17:902:ea8d:b0:1d9:7ebe:431f with SMTP id x13-20020a170902ea8d00b001d97ebe431fmr2723459plb.25.1709334437481; Fri, 01 Mar 2024 15:07:17 -0800 (PST) Received: from stoup.. (098-147-055-211.res.spectrum.com. [98.147.55.211]) by smtp.gmail.com with ESMTPSA id lc11-20020a170902fa8b00b001dc668e145asm3988580plb.200.2024.03.01.15.07.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:07:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH 38/60] linux-user: Do early mmap placement only for reserved_va Date: Fri, 1 Mar 2024 13:05:57 -1000 Message-Id: <20240301230619.661008-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301230619.661008-1-richard.henderson@linaro.org> References: <20240301230619.661008-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 autolearn=ham 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 For reserved_va, place all non-fixed maps then proceed as for MAP_FIXED. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-21-richard.henderson@linaro.org> --- linux-user/mmap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index cc983bedbd..1bbfeb25b1 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -540,17 +540,19 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, host_offset = offset & -host_page_size; /* - * If the user is asking for the kernel to find a location, do that - * before we truncate the length for mapping files below. + * For reserved_va, we are in full control of the allocation. + * Find a suitable hole and convert to MAP_FIXED. */ - if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { + if (reserved_va && !(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { host_len = len + offset - host_offset; - host_len = ROUND_UP(host_len, host_page_size); - start = mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); + start = mmap_find_vma(real_start, host_len, + MAX(host_page_size, TARGET_PAGE_SIZE)); if (start == (abi_ulong)-1) { errno = ENOMEM; return -1; } + start += offset - host_offset; + flags |= MAP_FIXED; } /*