From patchwork Tue Jul 25 13:45:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 706140 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp194482wrs; Tue, 25 Jul 2023 06:49:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlHR/cN3xYnH12B2Xcdzg+z2bIGvDXcT/ClWPepMBxAeVcLEr8vUf7j4+O3tJlpD3w1+R7Vb X-Received: by 2002:a05:6214:e48:b0:63d:3b2:482f with SMTP id o8-20020a0562140e4800b0063d03b2482fmr2387044qvc.5.1690292996331; Tue, 25 Jul 2023 06:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690292996; cv=none; d=google.com; s=arc-20160816; b=atqL2WGcfHDISciJLmM6+132Mwr/7yygoGw0fvlkLXGvYi/xrtEuaImKE8LrSyEpt8 YGZERzCtO96rttCshE9p8Mzn8osGTXboiUcimdIN1z6VQf/DucKGpHzD8nFcSWDRczwS 7Mpltn5pjRL6bV9TN78wVmGVRTn/B6uCxqLdnRrfeYBJWain0jkooji5niPupnoi+nMo GzXihLxmRPGNkkINYW07ok74ww9Iv2BDhgK5O48cLPhCmqPNEg2iYtKtgky/i/WgJ4TB 9VeALghjy0HUjLd+MYxAMgMIK50TKfT6HNUGVtI4kUfxfLxHv8cnbUpluM3zJwlGkoCw 1rrw== 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; bh=+bPnbTyYrBxPQsqdbKAUP7s8dak6Cz+8p1IJIQfU9nM=; fh=UV4TdQm0rfmebv6eoDMuLGgChsbF/Gadsx8n5DdbuK4=; b=Mtes+5q6Ax69jdbV5wdIkCG5KcU6PXwU66gNk9GYPk/BQygXIfRDNK48PvCrh0cnpJ ZXU9fDgNtiajQFBxiu8E+Z05TQo1OMkqYA7ugnXCpX/j337WwiFiVo/H091lubibezMD moybzfxGzr/YQhlfyrNyzB291WAah3Bp5PoPopqYLg+L7zS8adNnfMZwnOmNHuJ+SK0b Y+fuH42GOo5sp0AqiCKB1MTIJ6QrylHkJwjcYq1rfu8EEs64nlJMB+OqoaP25l0ImO2H C94PGogatLg4vqXniwK9ueoz1chURI8l60P1qNRJobi/qWaXpvpJvtCQKVutdJPZ2UcT XlPA== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j20-20020a0ce014000000b0062ded861543si6275633qvk.616.2023.07.25.06.49.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jul 2023 06:49:56 -0700 (PDT) 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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qOINc-0007Rs-DX; Tue, 25 Jul 2023 09:47:12 -0400 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 1qOIMr-0005mz-Tr; Tue, 25 Jul 2023 09:46:34 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qOIMp-0001Wx-Oi; Tue, 25 Jul 2023 09:46:25 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 3E482160F7; Tue, 25 Jul 2023 16:45:35 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id E19A0194BA; Tue, 25 Jul 2023 16:45:32 +0300 (MSK) Received: (nullmailer pid 3370828 invoked by uid 1000); Tue, 25 Jul 2023 13:45:29 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Christophe Lyon , Richard Henderson , Anton Johansson , Michael Tokarev Subject: [Stable-8.0.4 15/31] linux-user/arm: Do not allocate a commpage at all for M-profile CPUs Date: Tue, 25 Jul 2023 16:45:00 +0300 Message-Id: <20230725134517.3370706-15-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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 From: Philippe Mathieu-Daudé Since commit fbd3c4cff6 ("linux-user/arm: Mark the commpage executable") executing bare-metal (linked with rdimon.specs) cortex-M code fails as: $ qemu-arm -cpu cortex-m3 ~/hello.exe.m3 qemu-arm: ../../accel/tcg/user-exec.c:492: page_set_flags: Assertion `last <= GUEST_ADDR_MAX' failed. Aborted (core dumped) Commit 4f5c67f8df ("linux-user/arm: Take more care allocating commpage") already took care of not allocating a commpage for M-profile CPUs, however it had to be reverted as commit 6cda41daa2. Re-introduce the M-profile fix from commit 4f5c67f8df. Fixes: fbd3c4cff6 ("linux-user/arm: Mark the commpage executable") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1755 Reported-by: Christophe Lyon Suggested-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Anton Johansson Reviewed-by: Richard Henderson Message-Id: <20230711153408.68389-1-philmd@linaro.org> Signed-off-by: Richard Henderson (cherry picked from commit d713cf4d6c71076513a10528303b3e337b4d5998) Signed-off-by: Michael Tokarev diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f1370a7a8b..88ef26dc03 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -423,10 +423,23 @@ enum { static bool init_guest_commpage(void) { - abi_ptr commpage = HI_COMMPAGE & -qemu_host_page_size; - void *want = g2h_untagged(commpage); - void *addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + ARMCPU *cpu = ARM_CPU(thread_cpu); + abi_ptr commpage; + void *want; + void *addr; + + /* + * M-profile allocates maximum of 2GB address space, so can never + * allocate the commpage. Skip it. + */ + if (arm_feature(&cpu->env, ARM_FEATURE_M)) { + return true; + } + + commpage = HI_COMMPAGE & -qemu_host_page_size; + want = g2h_untagged(commpage); + addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); if (addr == MAP_FAILED) { perror("Allocating guest commpage");