get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2075159/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2075159,
    "url": "http://patchwork.ozlabs.org/api/patches/2075159/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/d20971cd7d9736aa3777721765606c244253cdb0.1745295397.git.ktokunaga.mail@gmail.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<d20971cd7d9736aa3777721765606c244253cdb0.1745295397.git.ktokunaga.mail@gmail.com>",
    "list_archive_url": null,
    "date": "2025-04-22T05:27:20",
    "name": "[v2,16/20] util: exclude mmap-alloc.c from compilation target on Emscripten",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "8dfe824bad8bd9e87446b43292fff5310a099cdc",
    "submitter": {
        "id": 90637,
        "url": "http://patchwork.ozlabs.org/api/people/90637/?format=api",
        "name": "Kohei Tokunaga",
        "email": "ktokunaga.mail@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/d20971cd7d9736aa3777721765606c244253cdb0.1745295397.git.ktokunaga.mail@gmail.com/mbox/",
    "series": [
        {
            "id": 453631,
            "url": "http://patchwork.ozlabs.org/api/series/453631/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=453631",
            "date": "2025-04-22T05:27:04",
            "name": "Enable QEMU TCI to run 32bit guests on browsers",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/453631/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2075159/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2075159/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20230601 header.b=ErTJnUOh;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4ZhWCW3FL9z1yJW\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 22 Apr 2025 15:35:03 +1000 (AEST)",
            "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1u76GT-0000Ti-EV; Tue, 22 Apr 2025 01:33:49 -0400",
            "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <ktokunaga.mail@gmail.com>)\n id 1u76Cz-0002qR-Kt; Tue, 22 Apr 2025 01:30:14 -0400",
            "from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <ktokunaga.mail@gmail.com>)\n id 1u76Cv-00089l-GJ; Tue, 22 Apr 2025 01:30:12 -0400",
            "by mail-pl1-x62e.google.com with SMTP id\n d9443c01a7336-22d95f0dda4so9447145ad.2;\n Mon, 21 Apr 2025 22:30:06 -0700 (PDT)",
            "from localhost.localdomain ([240d:1a:3b6:8b00:e142:4a4f:1ebb:3ca4])\n by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-22c50eb4483sm75692085ad.118.2025.04.21.22.29.58\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 21 Apr 2025 22:30:05 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20230601; t=1745299806; x=1745904606; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=2FkVN9PsSNE2Egb+LipsDkf/RHaq4OxguwsmDIo9jqs=;\n b=ErTJnUOhry5sw20L4i2bwkB3aZGj1SJBeiFM6ABpNn6VpcGT5CKCfBeXgV57DUl52i\n MxASKBV6irnef120skj+gP8kT//h+aiV/5oVdHg9pzTa5BxKmuMN75r98iCliPAJCLGL\n xX8nfaYqEqxZQeQdtrNoOQLzk+DovGJOG0lCIRmXC/TkO58bDLs9Q7aAhTtaibk18CCp\n F+OWHmGilLkIUnj8h3GrAHeam7Ohg50KQ4Hpb7Aimdj54PfDw1WhAvIZPsUbrp1/SiMy\n EpQgOfFRWFdmzdNXqlUJIQpFizHOoF+DMMUYlj9v7aZZcUFTyKa81RrffFNJOgzq941h\n 2J8A==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1745299806; x=1745904606;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=2FkVN9PsSNE2Egb+LipsDkf/RHaq4OxguwsmDIo9jqs=;\n b=AeEMB25rAC0dUsLS20ZW3HXwarRS/uZVg8t8EC4stHuR14cGtiqYP7U1DuwL93tYX3\n KvVqW0D2d0fFA+lUtsXY0lTnPXvSY1EGGr2nfkGEVaNgsZQyel2XQyRUlQj5Gqn31G2t\n JvGPnC0oslx5YHSnliCa6MK3erPS7YzJMbD/QZWGIa3e5fDFLRGJbIW9P2mp6Qm6V1cQ\n HduTi8DwFVFKe6ISVsGZyiCZb3SZBp+f1MxFWsB7/jT73jo4lO6aCtKgFX/nOncIMWSj\n BI65sQ3viDHZT6Jyh+DOuu3/fbJ9DdJ9paq2ankZKTkVPyKuOgu/NRJtZS7DkgFo7DYI\n 5GCg==",
        "X-Forwarded-Encrypted": "i=1;\n AJvYcCUf2d5GI0QGdN3ZonYxxhJYx/5YADAzxx5yhxBj49aIgLy9e6nyMsguImoRFScTM4hwW6cTzjDXgVJhIg==@nongnu.org,\n AJvYcCWit7vh3MAHa02+cMJpYU1xZUI4TVXH3jqyig5Wa5aWL8QOjf/2HswMQs/XgttwKFPlfZm+vw3ecpGdzw==@nongnu.org,\n AJvYcCWpeR8jO2ro6i/DQybnUPDDoW9Ynp+bLfQlbRUDLjXeTsZU72kDEZCBwcSO0rr64Ejge6KOkkSVfw==@nongnu.org,\n AJvYcCXkebFYe2UEb52oRmQhd2ZxD+ElaXmOSC+vimrgfISuEwg+clBV/1a+6kBS8N6yXzN2AGcjm/JqU5s=@nongnu.org",
        "X-Gm-Message-State": "AOJu0Yz2xrw9iXgW55ZjxvJbxTMrXdp8jwGdcg+q68K3yQSFTTI+zxY3\n vkd7KdrIXQp06Gm6Nb6gI36GZhFqRxizx89rl8siYhX38wM8gfOhGRk1NHZ2",
        "X-Gm-Gg": "ASbGncvokVctYFP7lmhpm+c735qVB9jvIsjUPWZit1QMcxUxW7qKleHNdfOcjYS3fbA\n FEm3cIDUY55j9PCKn4UT4Gper40SAX28M9ZbuAWyITxFxN+kSEg34kzTBTiHWk4KKIRP50FH0xL\n gh4rxCKe9icmzyOwOQmQVvGv/MRsYOs7g5keRHYdbdlyr9HLvdhPlreUQJjBOySu7oNmpiAnILt\n xnCLYuAVs/bIlFtranz66KWIgRk1LjJz1Sxup7yL7h2u8hJ6wnbChtF9jAk7olKOGz2p3a5UyhP\n iV3mKmvmA5F7zOTWkxXEEumcc6Z6GqvVioAknc7onMZGzGbACufzwtpyqPY=",
        "X-Google-Smtp-Source": "\n AGHT+IF7xwbiS5Pbd8i6m0BJ3l2AbPC1Rmn0ASj1QQA1F9dYuT3aDzSVpRYV+spAOV/dyXoUuJ6ZZw==",
        "X-Received": "by 2002:a17:903:41c7:b0:220:faa2:c911 with SMTP id\n d9443c01a7336-22c535a4b39mr194143805ad.14.1745299805766;\n Mon, 21 Apr 2025 22:30:05 -0700 (PDT)",
        "From": "Kohei Tokunaga <ktokunaga.mail@gmail.com>",
        "To": "qemu-devel@nongnu.org",
        "Cc": "=?utf-8?q?Alex_Benn=C3=A9e?= <alex.bennee@linaro.org>, =?utf-8?q?Philipp?=\n\t=?utf-8?q?e_Mathieu-Daud=C3=A9?= <philmd@linaro.org>,\n Thomas Huth <thuth@redhat.com>, Kevin Wolf <kwolf@redhat.com>,\n Hanna Reitz <hreitz@redhat.com>, Kohei Tokunaga <ktokunaga.mail@gmail.com>,\n Paolo Bonzini <pbonzini@redhat.com>, Alexandre Iooss <erdnaxe@crans.org>,\n Mahmoud Mandour <ma.mandourr@gmail.com>,\n Pierrick Bouvier <pierrick.bouvier@linaro.org>,\n Pavel Pisa <pisa@cmp.felk.cvut.cz>,\n Francisco Iglesias <francisco.iglesias@amd.com>,\n Vikram Garhwal <vikram.garhwal@bytedance.com>,\n Jason Wang <jasowang@redhat.com>,\n =?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>,\n\t=?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= <berrange@redhat.com>,\n Eduardo Habkost <eduardo@habkost.net>, Peter Xu <peterx@redhat.com>,\n David Hildenbrand <david@redhat.com>,\n Peter Maydell <peter.maydell@linaro.org>, Zhao Liu <zhao1.liu@intel.com>,\n Nicholas Piggin <npiggin@gmail.com>,\n Daniel Henrique Barboza <danielhb413@gmail.com>,\n Richard Henderson <richard.henderson@linaro.org>,\n Ilya Leoshkevich <iii@linux.ibm.com>, Stefan Hajnoczi <stefanha@redhat.com>,\n qemu-block@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org,\n qemu-s390x@nongnu.org",
        "Subject": "[PATCH v2 16/20] util: exclude mmap-alloc.c from compilation target\n on Emscripten",
        "Date": "Tue, 22 Apr 2025 14:27:20 +0900",
        "Message-Id": "\n <d20971cd7d9736aa3777721765606c244253cdb0.1745295397.git.ktokunaga.mail@gmail.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<cover.1745295397.git.ktokunaga.mail@gmail.com>",
        "References": "<cover.1745295397.git.ktokunaga.mail@gmail.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Received-SPF": "pass client-ip=2607:f8b0:4864:20::62e;\n envelope-from=ktokunaga.mail@gmail.com; helo=mail-pl1-x62e.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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n 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": "<qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"
    },
    "content": "Emscripten does not support partial unmapping of mmapped memory\nregions[1]. This limitation prevents correct implementation of qemu_ram_mmap\nand qemu_ram_munmap, which rely on partial unmap behavior.\n\nAs a workaround, this commit excludes mmap-alloc.c from the Emscripten\nbuild. Instead, for Emscripten build, this modifies qemu_anon_ram_alloc to\nuse qemu_memalign in place of qemu_ram_mmap, and disable memory backends\nthat rely on mmap, such as memory-backend-file and memory-backend-shm.\n\n[1] https://github.com/emscripten-core/emscripten/blob/d4a74336f23214bf3304d9eb0d03966786b30a36/system/lib/libc/emscripten_mmap.c#L61\n\nSigned-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>\n---\n backends/meson.build |  6 ++++--\n system/memory.c      |  2 +-\n system/physmem.c     |  9 +++++----\n util/meson.build     |  4 +++-\n util/oslib-posix.c   | 28 ++++++++++++++++++++++++++++\n 5 files changed, 41 insertions(+), 8 deletions(-)\n\nV2:\n- Instead of porting mmap-alloc.c to Emscripten, this version excludes the\n  file entirely. The rationale is described in the commit message.",
    "diff": "diff --git a/backends/meson.build b/backends/meson.build\nindex da714b93d1..9b88d22685 100644\n--- a/backends/meson.build\n+++ b/backends/meson.build\n@@ -12,8 +12,10 @@ system_ss.add([files(\n \n if host_os != 'windows'\n   system_ss.add(files('rng-random.c'))\n-  system_ss.add(files('hostmem-file.c'))\n-  system_ss.add([files('hostmem-shm.c'), rt])\n+  if host_os != 'emscripten'\n+    system_ss.add(files('hostmem-file.c'))\n+    system_ss.add([files('hostmem-shm.c'), rt])\n+  endif\n endif\n if host_os == 'linux'\n   system_ss.add(files('hostmem-memfd.c'))\ndiff --git a/system/memory.c b/system/memory.c\nindex 4c829793a0..f5fcbfa799 100644\n--- a/system/memory.c\n+++ b/system/memory.c\n@@ -1636,7 +1636,7 @@ bool memory_region_init_resizeable_ram(MemoryRegion *mr,\n     return true;\n }\n \n-#ifdef CONFIG_POSIX\n+#if defined(CONFIG_POSIX) && !defined(EMSCRIPTEN)\n bool memory_region_init_ram_from_file(MemoryRegion *mr,\n                                       Object *owner,\n                                       const char *name,\ndiff --git a/system/physmem.c b/system/physmem.c\nindex 333a5eb94d..76c65edb62 100644\n--- a/system/physmem.c\n+++ b/system/physmem.c\n@@ -1242,7 +1242,7 @@ long qemu_maxrampagesize(void)\n     return pagesize;\n }\n \n-#ifdef CONFIG_POSIX\n+#if defined(CONFIG_POSIX) && !defined(EMSCRIPTEN)\n static int64_t get_file_size(int fd)\n {\n     int64_t size;\n@@ -1977,7 +1977,7 @@ out_free:\n     }\n }\n \n-#ifdef CONFIG_POSIX\n+#if defined(CONFIG_POSIX) && !defined(EMSCRIPTEN)\n RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, ram_addr_t max_size,\n                                  qemu_ram_resize_cb resized, MemoryRegion *mr,\n                                  uint32_t ram_flags, int fd, off_t offset,\n@@ -2157,7 +2157,8 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,\n     assert(!host ^ (ram_flags & RAM_PREALLOC));\n     assert(max_size >= size);\n \n-#ifdef CONFIG_POSIX         /* ignore RAM_SHARED for Windows */\n+    /* ignore RAM_SHARED for Windows and emscripten*/\n+#if defined(CONFIG_POSIX) && !defined(EMSCRIPTEN)\n     if (!host) {\n         if (!share_flags && current_machine->aux_ram_share) {\n             ram_flags |= RAM_SHARED;\n@@ -2254,7 +2255,7 @@ static void reclaim_ramblock(RAMBlock *block)\n         ;\n     } else if (xen_enabled()) {\n         xen_invalidate_map_cache_entry(block->host);\n-#ifndef _WIN32\n+#if !defined(_WIN32) && !defined(EMSCRIPTEN)\n     } else if (block->fd >= 0) {\n         qemu_ram_munmap(block->fd, block->host, block->max_length);\n         close(block->fd);\ndiff --git a/util/meson.build b/util/meson.build\nindex 780b5977a8..e5cd327e27 100644\n--- a/util/meson.build\n+++ b/util/meson.build\n@@ -11,7 +11,9 @@ if host_os != 'windows'\n   endif\n   util_ss.add(files('compatfd.c'))\n   util_ss.add(files('event_notifier-posix.c'))\n-  util_ss.add(files('mmap-alloc.c'))\n+  if host_os != 'emscripten'\n+    util_ss.add(files('mmap-alloc.c'))\n+  endif\n   freebsd_dep = []\n   if host_os == 'freebsd'\n     freebsd_dep = util\ndiff --git a/util/oslib-posix.c b/util/oslib-posix.c\nindex a697c602c6..4ff577e5de 100644\n--- a/util/oslib-posix.c\n+++ b/util/oslib-posix.c\n@@ -58,6 +58,7 @@\n #include <lwp.h>\n #endif\n \n+#include \"qemu/memalign.h\"\n #include \"qemu/mmap-alloc.h\"\n \n #define MAX_MEM_PREALLOC_THREAD_COUNT 16\n@@ -210,11 +211,21 @@ void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared,\n     const uint32_t qemu_map_flags = (shared ? QEMU_MAP_SHARED : 0) |\n                                     (noreserve ? QEMU_MAP_NORESERVE : 0);\n     size_t align = QEMU_VMALLOC_ALIGN;\n+#ifndef EMSCRIPTEN\n     void *ptr = qemu_ram_mmap(-1, size, align, qemu_map_flags, 0);\n \n     if (ptr == MAP_FAILED) {\n         return NULL;\n     }\n+#else\n+    /*\n+     * qemu_ram_mmap is not implemented for Emscripten. Use qemu_memalign\n+     * for the anonymous allocation. noreserve is ignored as there is no swap\n+     * space on Emscripten, and shared is ignored as there is no other\n+     * processes on Emscripten.\n+     */\n+    void *ptr = qemu_memalign(align, size);\n+#endif\n \n     if (alignment) {\n         *alignment = align;\n@@ -227,7 +238,16 @@ void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared,\n void qemu_anon_ram_free(void *ptr, size_t size)\n {\n     trace_qemu_anon_ram_free(ptr, size);\n+#ifndef EMSCRIPTEN\n     qemu_ram_munmap(-1, ptr, size);\n+#else\n+    /*\n+     * qemu_ram_munmap is not implemented for Emscripten and qemu_memalign\n+     * was used for the allocation. Use the corresponding freeing function\n+     * here.\n+     */\n+    qemu_vfree(ptr);\n+#endif\n }\n \n void qemu_socket_set_block(int fd)\n@@ -588,7 +608,15 @@ bool qemu_prealloc_mem(int fd, char *area, size_t sz, int max_threads,\n {\n     static gsize initialized;\n     int ret;\n+#ifndef EMSCRIPTEN\n     size_t hpagesize = qemu_fd_getpagesize(fd);\n+#else\n+    /*\n+     * mmap-alloc.c is excluded from Emscripten build, so qemu_fd_getpagesize\n+     * is unavailable. Fallback to the lower level implementation.\n+     */\n+    size_t hpagesize = qemu_real_host_page_size();\n+#endif\n     size_t numpages = DIV_ROUND_UP(sz, hpagesize);\n     bool use_madv_populate_write;\n     struct sigaction act;\n",
    "prefixes": [
        "v2",
        "16/20"
    ]
}