From patchwork Tue Mar 29 10:36:02 2022 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: 12794657 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4289AC433F5 for ; Tue, 29 Mar 2022 10:44:44 +0000 (UTC) Received: from localhost ([::1]:49838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZ9L9-00036i-BZ for qemu-devel@archiver.kernel.org; Tue, 29 Mar 2022 06:44:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZ9Cx-0003iq-3N for qemu-devel@nongnu.org; Tue, 29 Mar 2022 06:36:15 -0400 Received: from [2a00:1450:4864:20::432] (port=35728 helo=mail-wr1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nZ9Cv-00017i-Ik for qemu-devel@nongnu.org; Tue, 29 Mar 2022 06:36:14 -0400 Received: by mail-wr1-x432.google.com with SMTP id w21so19572842wra.2 for ; Tue, 29 Mar 2022 03:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wY7O/mESzSiqaHBUJ4K2Tv3anipr4OYB2btHaa8SA7o=; b=lzzT7PS+SHTP4dmFjHlXgzwkmurTnNUlIqzs/44Lx6TK07u09OKLtm2Kstt/1w/p3m 6qoChV64iqLWHeT0OfMBgHCy6/zyCdwIiiR2xEifxotgqfTf3XkXLOJocqGTjWUVwAC0 D7atGA/SqV6vKYyer7yAReI32FSaj2T98tvfQcp90aWjUr5Jml82TST/YiF4iJHDsaw5 xIP+NYio24nqADrGXd5JplMwO6jaL7wuqbTGwgk7sPdMnTMU38gpFaQUjOzvAT49In0+ b0VmA9N4t5fZh2F1/zHWZa0W5O6I4pgczuR4U+gqssYeoJXEZjNKXRrsE6U15IW6j8MI KbAg== 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=wY7O/mESzSiqaHBUJ4K2Tv3anipr4OYB2btHaa8SA7o=; b=ABYAdtelvkh0/QvNrOPj9wUqg/eNF/dFIO2oKQ/mYrligUKRR3yo2urx/2XfA+CUKh 56C4Gpg/cNThMOUlS8QUgTAlrcgk3+NssimJpB0dXAzuU4D43MaiMuDKNxYKE3Q5PR4G BrmBxsU2EMLjvChV/h7R2sEfJztGYfufmBSMEZFhfhfVdLtuw4rwKgXdmLEHQS62zXZ2 zCCzcMKIPKTZ6A9I265+no37KWO+XYyPUW5sFTzRCNThSG7+8hNjYm1d3u8tMUDbYimF jfqsiYS5rSrcgN+MjYQsPB9N1ixDP+ifTEjuCCzFaAcMqMK+M2dR/qM1s2o2U3CCtVhJ GubA== X-Gm-Message-State: AOAM533q/AmjT5zQDyW3NqGDa0fUD/5LqiYrnmnVyYT+HGUz+dLI9GYT LcrJGdb2LODO7D+bPng7dWXPn3GbLN8aVg== X-Google-Smtp-Source: ABdhPJxJCQJM+PqxADMT3uouKFfyO0TWBArr6R2tq6C5Tq4lyrxLp6/ubqI+luCZWz5GiBSUGWhd6w== X-Received: by 2002:a05:6000:1566:b0:204:20d9:a5b0 with SMTP id 6-20020a056000156600b0020420d9a5b0mr31050906wrz.207.1648550172090; Tue, 29 Mar 2022 03:36:12 -0700 (PDT) Received: from localhost.localdomain ([2600:70ff:f07f:0:d557:f3bb:5d8b:b5f3]) by smtp.gmail.com with ESMTPSA id z3-20020a1cf403000000b0037d1f4a2201sm1868323wma.21.2022.03.29.03.36.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 29 Mar 2022 03:36:11 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 1/3] memory: Make memory_region_readd_subregion() properly handle mapped aliases Date: Tue, 29 Mar 2022 12:36:02 +0200 Message-Id: <20220329103604.41208-2-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220329103604.41208-1-philippe.mathieu.daude@gmail.com> References: <20220329103604.41208-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::432 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x432.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Cc: Aleksandar Rikalo , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Niek Linnenbank , Peter Xu , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand memory_region_readd_subregion() wants to readd a region by first removing it and then readding it. For readding, it doesn't use one of the memory_region_add_*() variants, which is why fail to re-increment the mr->mapped_via_alias counters, resulting in the assert(alias->mapped_via_alias >= 0) in memory_region_del_subregion() triggering the next time we call memory_region_readd_subregion(). Fix it by using memory_region_add_subregion_common() for readding the region. Reported-by: Niek Linnenbank Fixes: 5ead62185d23 ("memory: Make memory_region_is_mapped() succeed when mapped via an alias") Tested-by: Niek Linnenbank Cc: Paolo Bonzini Cc: Peter Xu Cc: "Philippe Mathieu-Daudé" Signed-off-by: David Hildenbrand Message-Id: <20220201100940.47788-1-david@redhat.com> Signed-off-by: Philippe Mathieu-Daudé --- softmmu/memory.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/softmmu/memory.c b/softmmu/memory.c index 8060c6de78..bfa5d5178c 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2626,8 +2626,7 @@ static void memory_region_readd_subregion(MemoryRegion *mr) memory_region_transaction_begin(); memory_region_ref(mr); memory_region_del_subregion(container, mr); - mr->container = container; - memory_region_update_container_subregions(mr); + memory_region_add_subregion_common(container, mr->addr, mr); memory_region_unref(mr); memory_region_transaction_commit(); } From patchwork Tue Mar 29 10:36:03 2022 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: 12794660 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EAD68C433EF for ; Tue, 29 Mar 2022 10:48:05 +0000 (UTC) Received: from localhost ([::1]:54192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZ9OO-0006AD-Qe for qemu-devel@archiver.kernel.org; Tue, 29 Mar 2022 06:48:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZ9D3-0003lV-Mg for qemu-devel@nongnu.org; Tue, 29 Mar 2022 06:36:22 -0400 Received: from [2a00:1450:4864:20::42d] (port=35725 helo=mail-wr1-x42d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nZ9D1-00019M-9h for qemu-devel@nongnu.org; Tue, 29 Mar 2022 06:36:21 -0400 Received: by mail-wr1-x42d.google.com with SMTP id w21so19573158wra.2 for ; Tue, 29 Mar 2022 03:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pzkR8/kAabmvhc+t7Xvkr9admFp65gGBNYh313N0BrM=; b=iCLwhL5k6ToVvHGQh5j43Eq/3p/FqZiaeO/nXBoL6A+5UyEyZ+3443yuCfCKyV0y2e o0ojdJyuJnI+knCBJ56xACbvbDvHkkbmZSMvYx7a1Akhf/3GqBYUSk+A/k9bGTAZ/c1c DopOiUpkKP7OmjYiQrF0dY2lN83Akmjz9vDywRfvSoD3sL42kHXH97aHqHt4k6ByJPiL hI0j0mYZ95zjPVRkA1umOek9zNPRHDxSEq8ffqbuZ/t9hMjcKfyYKOubt2SHriS0UCPR myunKf+2tK+SqR0lQ8nNvDrN8wAGRiRS+V405Bl45WDl59jDpZbqeEWugWZINZ2iW93g y1dg== 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=pzkR8/kAabmvhc+t7Xvkr9admFp65gGBNYh313N0BrM=; b=fcKdhxUHYTmIRJAZWhnQ6UpD7LLRIY6XMDzrJsHMfIGSdz4A83eSb7CbY4HfDZlJWi C3po6YpvygF6GWzuKFqIVd5mg7V9UwaKjSLJnMBNdeeBGw7sDItI7yDPAuTyw4Lnin9p HiUt04EZxuy9vvM2N1i7BWhAEsgQcc1K9FDWd1QWXri4hTRWoQbPTDY+cq1UCLOoFZmW +6z+VD30IogQWhJwj1asSzb9DiSS1qbDRUfEz7gDBtRBJCky3HsgL/rL8BZeZ2x+Euh0 p8EWfp7e33g6SBeBPZPXXDgY0qaqTCGlnakKd/fpepab76IjLsaf19TGx/Nn1p41BfqX N+0A== X-Gm-Message-State: AOAM532YROm+xakNzOi8Vi/j8+7OXFjKrlBO2Cj4/L63YlYcdVDaGgTY Q8csuS6CKKNPNR8BBmrEIqWIowplUDnbYg== X-Google-Smtp-Source: ABdhPJwFyzyLmef00KytD/4OHSTIzNEsLcvDPT4vNbXLBQ3xW6a/zUrnsYXSSDLi7TBYyu0msDElGg== X-Received: by 2002:a05:6000:10ce:b0:204:203:9c87 with SMTP id b14-20020a05600010ce00b0020402039c87mr29606810wrx.181.1648550177737; Tue, 29 Mar 2022 03:36:17 -0700 (PDT) Received: from localhost.localdomain ([2600:70ff:f07f:0:d557:f3bb:5d8b:b5f3]) by smtp.gmail.com with ESMTPSA id m8-20020a05600c3b0800b0038cc8f116d3sm1769565wms.44.2022.03.29.03.36.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 29 Mar 2022 03:36:17 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 2/3] target/mips: Fix address space range declaration on n32 Date: Tue, 29 Mar 2022 12:36:03 +0200 Message-Id: <20220329103604.41208-3-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220329103604.41208-1-philippe.mathieu.daude@gmail.com> References: <20220329103604.41208-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42d (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42d.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Cc: Aleksandar Rikalo , Richard Henderson , "Andreas K . Huettel" , =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= , WANG Xuerui , Aurelien Jarno Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui This bug is probably lurking there for so long, I cannot even git-blame my way to the commit first introducing it. Anyway, because n32 is also TARGET_MIPS64, the address space range cannot be determined by looking at TARGET_MIPS64 alone. Fix this by only declaring 48-bit address spaces for n64, or the n32 user emulation will happily hand out memory ranges beyond the 31-bit limit and crash. Confirmed to make the minimal reproducing example in the linked issue behave. Closes: https://gitlab.com/qemu-project/qemu/-/issues/939 Cc: Philippe Mathieu-Daudé Cc: Aurelien Jarno Cc: Jiaxun Yang Cc: Aleksandar Rikalo Signed-off-by: WANG Xuerui Tested-by: Andreas K. Huettel Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20220328035942.3299661-1-xen0n@gentoo.org> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/cpu-param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/mips/cpu-param.h b/target/mips/cpu-param.h index 9c4a6ea45e..1aebd01df9 100644 --- a/target/mips/cpu-param.h +++ b/target/mips/cpu-param.h @@ -12,7 +12,7 @@ #else # define TARGET_LONG_BITS 32 #endif -#ifdef TARGET_MIPS64 +#ifdef TARGET_ABI_MIPSN64 #define TARGET_PHYS_ADDR_SPACE_BITS 48 #define TARGET_VIRT_ADDR_SPACE_BITS 48 #else From patchwork Tue Mar 29 10:36:04 2022 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: 12794656 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D12A5C433FE for ; Tue, 29 Mar 2022 10:43:39 +0000 (UTC) Received: from localhost ([::1]:48204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZ9K6-0001vy-Md for qemu-devel@archiver.kernel.org; Tue, 29 Mar 2022 06:43:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZ9DA-0003q0-K0 for qemu-devel@nongnu.org; Tue, 29 Mar 2022 06:36:28 -0400 Received: from [2a00:1450:4864:20::42f] (port=36423 helo=mail-wr1-x42f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nZ9D8-0001A6-EO for qemu-devel@nongnu.org; Tue, 29 Mar 2022 06:36:27 -0400 Received: by mail-wr1-x42f.google.com with SMTP id u3so24171110wrg.3 for ; Tue, 29 Mar 2022 03:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jn+w0GAcUlDgRGTG2s/c6dZzbEISAktahvM0Y42FQ7M=; b=Jnx2wDP+1ss0lptO7LCtAeUrUf0TAcT13xyeN4na/4eQMQILUJ+nvuOP6dp+2gHcaA K7S005zzcd8S4vyVlfLdpBNXnhAyTaYDPM9K8P7/2jRpqTGSZRU7/eE88nHY1Cp3+TZk 3lSXIZKBdB2Cb0pvWXhsTKMo39QxUHmQBiNNKSDRukxrSPdorVsCLOCbqyMfpPirmzWP VPs7VPPHk8l6mKiEOzcY1HpKCdJii77wIE656agF9RvkshgZ5bAabYJ0UXMd/NBego7/ npta8NQ0BHuuayveuXNdV9IOvs2ZHNiP0PcMOIr7fudUNZ6ykovmJC5i86vJA/qOeyYy z6BQ== 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=jn+w0GAcUlDgRGTG2s/c6dZzbEISAktahvM0Y42FQ7M=; b=4EQ2cI6AhAikp0Ja9XBd/h6iecdpAJqIybfLYeYiP56hqygMq4pv/V9ahbBNfhm1Qx I8xzbvJpCHiwgsl1K4CMob9Wt/iFWgJaZX8qiQmJxMFKKeCeodI+3XdpppykgQ3UcRzI Q71F7kb6gH21RlMVKZs/MrYa/t6gQ4d2+QA6CBXjYrhI0bo+h6cLGUJ+HI/LWVvP7Yfq m8pvM5ecULXTuaiZ4yzgNxB6D00nviyUMr/S6fFADWi6mZO8CLBii5AXZtCr9BiXHvFl dAbd5i0z+BwRWiiCsaaUsbfU6P/2tdkFriKGiinShF3SQXjogy7QXK6zSch8MYnXIVh3 HU7Q== X-Gm-Message-State: AOAM532Fp4eLh2pmmFxa4OZTzijRU+xVz+xkxyIk0B6/M3kpFbRaGGJ/ 1TrDtdoNoUKaHD8bdXu6RoQtF8cXGxAS4A== X-Google-Smtp-Source: ABdhPJy+Q1Nv+70lRUWFAZlf2RSF2SVRjhD3cuivjLgOcn3SJu+XRkbJ664KUqgzER3s+NM1qQjkPA== X-Received: by 2002:a5d:6a45:0:b0:204:597:2708 with SMTP id t5-20020a5d6a45000000b0020405972708mr31794837wrw.2.1648550183523; Tue, 29 Mar 2022 03:36:23 -0700 (PDT) Received: from localhost.localdomain ([2600:70ff:f07f:0:d557:f3bb:5d8b:b5f3]) by smtp.gmail.com with ESMTPSA id y13-20020adffa4d000000b00203e3ca2701sm19959244wrr.45.2022.03.29.03.36.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 29 Mar 2022 03:36:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 3/3] qemu-binfmt-conf.sh: mips: allow nonzero EI_ABIVERSION, distinguish o32 and n32 Date: Tue, 29 Mar 2022 12:36:04 +0200 Message-Id: <20220329103604.41208-4-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220329103604.41208-1-philippe.mathieu.daude@gmail.com> References: <20220329103604.41208-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42f (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42f.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Cc: Aleksandar Rikalo , Richard Henderson , =?utf-8?q?Andreas_K=2E_H?= =?utf-8?q?=C3=BCttel?= , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Laurent Vivier , WANG Xuerui , Alex Bennee , Aurelien Jarno Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Andreas K. Hüttel With the command line flag -mplt and a recent toolchain, ELF binaries generated by gcc can obtain EI_ABIVERSION=1, which makes, e.g., gcc three-stage bootstrap in a mips-unknown-linux-gnu qemu-user chroot fail since the binfmt-misc magic does not match anymore. Also other values are technically possible. qemu executes these binaries just fine, so relax the mask for the EI_ABIVERSION byte at offset 0x08. In addition, extend magic string to distinguish mips o32 and n32 ABI. This information is given by the EF_MIPS_ABI2 (0x20) bit in the e_flags field of the ELF header (a 4-byte value at offset 0x24 for the here applicable ELFCLASS32). See-also: ace3d65459 Signed-off-by: Andreas K. Hüttel Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: WANG Xuerui Cc: Laurent Vivier Cc: WANG Xuerui Cc: Richard Henderson Cc: Alex Bennee Cc: Philippe Mathieu-Daudé Closes: https://gitlab.com/qemu-project/qemu/-/issues/843 Message-Id: <20220328204900.3914990-1-dilfridge@gentoo.org> Signed-off-by: Philippe Mathieu-Daudé --- scripts/qemu-binfmt-conf.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index e9bfeb94d3..9cb723f443 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -60,28 +60,28 @@ m68k_family=m68k # FIXME: We could use the other endianness on a MIPS host. -mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08' -mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' +mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20' mips_family=mips -mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00' -mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' +mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00' mipsel_family=mips -mipsn32_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08' -mipsn32_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' +mipsn32_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20' +mipsn32_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20' mipsn32_family=mips -mipsn32el_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00' -mipsn32el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' +mipsn32el_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00' +mipsn32el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00' mipsn32el_family=mips mips64_magic='\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08' -mips64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' +mips64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' mips64_family=mips mips64el_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00' -mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' +mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' mips64el_family=mips sh4_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00'