From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A34AFC433F5 for ; Sat, 23 Oct 2021 23:27:14 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF6C060527 for ; Sat, 23 Oct 2021 23:27:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CF6C060527 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 573AD83535; Sun, 24 Oct 2021 01:27:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ZHJ9lOly"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0486582E7A; Sun, 24 Oct 2021 01:26:54 +0200 (CEST) Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9025C82E7A for ; Sun, 24 Oct 2021 01:26:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oi1-x22d.google.com with SMTP id bk18so9997561oib.8 for ; Sat, 23 Oct 2021 16:26:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4Rhn1a3qX10+vqZfBM3KaZF//3S5JJWo3LIzwGUOM+0=; b=ZHJ9lOlyYYoAW8c+YZLj2KEwOJL+gtgyMnKXlp8NTFWsu0E+9X/LBRUaDABMa6W6MO hxjy6mckFGnkqQfk9x0Jt2+Oqawtk+baL9PywJKUf1IZFiPXkXI5a275UvWm0sSA7caY EdxwVSs0esKVmxwBAXz7p3udZmGXNo9dsgsbw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4Rhn1a3qX10+vqZfBM3KaZF//3S5JJWo3LIzwGUOM+0=; b=YUJwbWT/icuqM0tctZ5Y0gVlitK3J3RyWKU41nuumLlO6iT6YzAMmHZHtzD5Mcu1rq 17x4UUEYeItSSY+m3mKu68tZeOsrqM/Q7XFq3RR1GkSNdXqrg24JNnlvb62UlEdIaiM7 D0FgH1Q3Jbf0wnu22rGwNc1c1yFdHg7X16ET6sSKo+hVw9Os+42Faa66ZNITIqiXAGnE QfWvRkxthMYr2dK6d45a2Q2YmAKeK0eE2CmB7kEsgAQjXSPAZ4SCqgcrCV0PldAr6vmq n4mVD2n3L7+i1eHmcCjvmOx/A8B7WKiTjrrEob+IJ0ZWPiSbCABc7HhtHyCIkdfBMWpO VMug== X-Gm-Message-State: AOAM530DH7nvdWsDzkbZ7fl8/GkcriWUCAENFuP89Z3MyLvI5YjKUHa0 e5oMqvD37HO7n5A/XwkkY7qYMDFdX7v6JQ== X-Google-Smtp-Source: ABdhPJzVlYuVssVoBSjpLsALn5wtPHHU8vlr4usT+vT+j+cEK2vhFkM8fCE+zdeRHOI9g6DIRgr0+Q== X-Received: by 2002:aca:b982:: with SMTP id j124mr12791893oif.56.1635031608135; Sat, 23 Oct 2021 16:26:48 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id l24sm2253885oop.4.2021.10.23.16.26.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Oct 2021 16:26:47 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Michal Simek , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Daniel Schwierzeck , Steffen Jaeckel , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Lukas Auer , Dennis Gilmore , Simon Glass Subject: [PATCH v2 04/41] sandbox: Support unmapping a file Date: Sat, 23 Oct 2021 17:25:58 -0600 Message-Id: <20211023232635.9195-5-sjg@chromium.org> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211023232635.9195-1-sjg@chromium.org> References: <20211023232635.9195-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Add the opposite of mapping, so that we can unmap and avoid running out of address space. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/os.c | 10 ++++++++++ include/os.h | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index b72dafca2ba..873f85ac3be 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -211,6 +211,16 @@ int os_map_file(const char *pathname, int os_flags, void **bufp, int *sizep) return 0; } +int os_unmap(void *buf, int size) +{ + if (munmap(buf, size)) { + printf("Can't unmap %p %x\n", buf, size); + return -EIO; + } + + return 0; +} + /* Restore tty state when we exit */ static struct termios orig_term; static bool term_setup; diff --git a/include/os.h b/include/os.h index 770d76e02f7..4cbcbd93a71 100644 --- a/include/os.h +++ b/include/os.h @@ -419,6 +419,15 @@ int os_read_file(const char *name, void **bufp, int *sizep); */ int os_map_file(const char *pathname, int os_flags, void **bufp, int *sizep); +/** + * os_unmap() - Unmap a file previously mapped + * + * @buf: Mapped address + * @size: Size in bytes + * Return: 0 if OK, -ve on error + */ +int os_unmap(void *buf, int size); + /* * os_find_text_base() - Find the text section in this running process * -- 2.33.0.1079.g6e70778dc9-goog