From patchwork Fri Mar 7 13:09:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 871180 Delivered-To: patch@linaro.org Received: by 2002:a5d:64c8:0:b0:38f:210b:807b with SMTP id f8csp757072wri; Fri, 7 Mar 2025 05:10:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUfE1NzluE5gdL9qms5w13nB1MD/YFUn5QikMOFUNpkZ0yrft/w/r8ESzMA0GP7axx8XleWkA==@linaro.org X-Google-Smtp-Source: AGHT+IH03XpAB7sLT2ChTseeV/WGjVCLGwrIWGCv8A3QtiK9QKLvqR64cPnjp3JBYV0Ng+R+bDtF X-Received: by 2002:a05:6214:20cf:b0:6e4:4484:f357 with SMTP id 6a1803df08f44-6e9006adc5amr33003276d6.30.1741353046202; Fri, 07 Mar 2025 05:10:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1741353046; cv=none; d=google.com; s=arc-20240605; b=UHbHo+N24NcMQ27TjCJUwbH6p0W448fVJpBPB22IxHdJ1j7zlC3v51u6nvKDkpNzum LJPLj+540USroA2rCfKXwlRj1tY9uIdFAhkhBcoFPumb2gzo5E08OI3+p+4iUC2+nWht iWyAFGmHVg9i+viYsH2QI7XoqyEnwOqeCCA2eIPifRgGAbPUnepY/e2Rbb4PVYK9OWH7 MQwoeT0tkPUF14rSd5gWtPeWjVyZdbBLF9vJMCLaMfzz4q7ot5Ua5AXg/+WtrPmqLE2R JpxB/3K4jvJD/KEPaUVBHwfENOJtnXrXzh5THPPvcAnoZJxGU2WpTjbDa2U4cJ9C9zLN zR/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=Yfyfv3HDb0p+J1qRUgpzig7LH5Vl2xWLWoUhxNEl80M=; fh=YwzZLqTkl/aXI2kmXKm3J+muCZNvgKu6t1Htrn0AL98=; b=EXoNWWePBVnpoNAx8jxMa3l8r1dPEFn9raQWkLJ9d1D/PrZy/pZa58wmFVCB0BFcdR fKV1788MesWTkD995uhKYagSbsSeUBxWi/pSQ7dJQaV7P7GP/IPovDMs8F42Ox94uzeg 3uXPuuNTUa7FG7jVgLRyUOfI+ObGDYjodHyx2WewdLJmiCjZWed5YykdbfmY2S61ivMg gxdV6Es0cA7SpFExXjgpDp93iq30/lXpfV2+mqdSxXrDJ5rpVW9tyasLvzeZ4PG5aZrZ kyz/5oPsuZgwR35yWwFpMOe5X+WtYIRk6dZBAFd8n2dz0qoNb+Txwf31qMUnR0dCc6JZ YE2w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iR0ewxhO; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6e8f707cc78si33918626d6.88.2025.03.07.05.10.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Mar 2025 05:10:46 -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=iR0ewxhO; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tqXSp-0002mC-RT; Fri, 07 Mar 2025 08:10:07 -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 1tqXSo-0002lD-3V for qemu-devel@nongnu.org; Fri, 07 Mar 2025 08:10:06 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tqXSm-0001Ly-8q for qemu-devel@nongnu.org; Fri, 07 Mar 2025 08:10:05 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-43bbb440520so20623015e9.2 for ; Fri, 07 Mar 2025 05:10:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741353002; x=1741957802; 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=Yfyfv3HDb0p+J1qRUgpzig7LH5Vl2xWLWoUhxNEl80M=; b=iR0ewxhOfczaTEaRT028Zvu6/7YoiXlNxZn+U1MnuS+oeOVQyoiTUmpPVSEAAZ0M1o 3Vo3ImQcVTJGJXC87EZCZQhKAGj+2Nqbzo0JWSIIVyM1V7tPQ4eZwSe0coGrAliFJEYv in48AidUCbHOsd8WQkPrPcYYNg6bB45rygNRfPWMHnyDSENgErn9KxldLI7F5dwyRksN bBpYUlLK+O5QJ+pjky62ogKPrjets7kBo3xlzBUFIarjCQKMCfhGM4u+QbRtfOJerFD+ MaEW7Tbc6cUBmMGdXYdWYaQstD6ezPe3OQZHnkg2uvrt+7CLq5T5hByZGvAwxnXcMVzl E38w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741353002; x=1741957802; 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=Yfyfv3HDb0p+J1qRUgpzig7LH5Vl2xWLWoUhxNEl80M=; b=QCFALHOidJdG3OtVff+aUlfvKTBQQ/ZAMxoHNUf9WPOJP08VsXf2APRnQMaM8o+iGB W0pek7Mf4spWJwM8shHnBUA0AiEuExrQMq/Rv3hb+sRs14wc5YyXoAoDld/Nco4zPlLz Qod4wtoToTZ/++G60650u1SvEZmVrX3nLvfB/qjWdrTdaUsMIltqH23Ce2Apg/jOfOId grpt44JY9GIhkg2/BEaU0TvxjdL9LxyQ4lRYLBXlaBMQxe3qmhinXLxZ7PaxWd1P0CZf tRbTAhybCTeC6MjiszJ17IwHGXGMyhokdqC2dnTzZtVAs/QLKihs9v9SiKOaVeBOWWAm T0Ig== X-Gm-Message-State: AOJu0YxRmnxczWe8INx4JT+3p9/Xbmg2JhCZvmwSBKxrRgDCk5ef5eSl 3QvEPs5j1cYEV3z128C5K1gxLTl9yoXS7XYIhM4DjyYjBspXDeLAq6QobnaO1IQXA0AOmZWxHDQ uNEA= X-Gm-Gg: ASbGncsJ4Fq4tSlNleiKcsIXPVQEaughT4HYdvalJrS38RGsvnfsll2yMDPh24mK/06 YP/A8s1dGR/eYx9BsDsuI8qdLdcyb8kxD1hHXS+yhMCNMg3uSDeGIOAEmYrLar+T5LLzYPaXl/N K8Ce9QCLHNXy6geVC+jB3uWCgJY2zRdH9YrQPTN50d6CoCQX65dJZ4ibO95dj6jZzhZjN8kaXE0 6xMsIFsuCDZzmrXf9H9JoxEGkK8rU2UhyoQgjFkxbSNWXO/SGwe1w7a/ZHZ/KXyZBWBN1cwZIUH ZxZN62QE57iw5aKGM5cf9CKduRNAV88tRY34aj+tMAjWL2Yt6zm1OEKjp0Jlz+3YfzrewHIyg8g TlXU5OXn8rJeIwdzln2I= X-Received: by 2002:a05:600c:4ed1:b0:439:9b80:ca6f with SMTP id 5b1f17b1804b1-43c5a630248mr37335545e9.5.1741353002264; Fri, 07 Mar 2025 05:10:02 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43bd435c88esm80351355e9.36.2025.03.07.05.10.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 07 Mar 2025 05:10:01 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Riku Voipio , Kyle Evans , Warner Losh , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 2/3] bsd-user: Propagate alignment argument to mmap_find_vma() Date: Fri, 7 Mar 2025 14:09:50 +0100 Message-ID: <20250307130951.4816-3-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250307130951.4816-1-philmd@linaro.org> References: <20250307130951.4816-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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.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 Propagate the alignment to mmap_find_vma(), effectively embedding mmap_find_vma_aligned() within mmap_find_vma(). Since we ignore the alignment in do_bsd_shmat(), leave a FIXME comment. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Warner Losh --- bsd-user/bsd-mem.h | 2 +- bsd-user/qemu.h | 2 +- bsd-user/mmap.c | 10 ++-------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index f5ec0de24ca..87219da2919 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -372,7 +372,7 @@ static inline abi_long do_bsd_shmat(int shmid, abi_ulong shmaddr, int shmflg) } else { abi_ulong mmap_start; - mmap_start = mmap_find_vma(0, shm_info.shm_segsz); + mmap_start = mmap_find_vma(0, shm_info.shm_segsz, 0 /* FIXME??? */); if (mmap_start == -1) { return -TARGET_ENOMEM; diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 4e97c796318..0b3bd65b180 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -242,7 +242,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, abi_ulong new_addr); int target_msync(abi_ulong start, abi_ulong len, int flags); extern abi_ulong mmap_next_start; -abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size); +abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong alignment); void mmap_reserve(abi_ulong start, abi_ulong size); void TSA_NO_TSA mmap_fork_start(void); void TSA_NO_TSA mmap_fork_end(int child); diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 28d7e387a20..da22fcc7c41 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -275,8 +275,7 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size, * It must be called with mmap_lock() held. * Return -1 if error. */ -static abi_ulong mmap_find_vma_aligned(abi_ulong start, abi_ulong size, - abi_ulong alignment) +abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong alignment) { void *ptr, *prev; abi_ulong addr; @@ -395,11 +394,6 @@ static abi_ulong mmap_find_vma_aligned(abi_ulong start, abi_ulong size, } } -abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) -{ - return mmap_find_vma_aligned(start, size, 0); -} - /* NOTE: all the constants are the HOST ones */ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, int flags, int fd, off_t offset) @@ -496,7 +490,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, if ((flags & MAP_ALIGNMENT_MASK) != 0) { alignment = (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT; } - start = mmap_find_vma_aligned(real_start, host_len, alignment); + start = mmap_find_vma(real_start, host_len, alignment); if (start == (abi_ulong)-1) { errno = ENOMEM; goto fail;