From patchwork Tue Jul 11 15:34:08 2023 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: 701526 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5786562wrs; Tue, 11 Jul 2023 08:34:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlG9FYBfaAUWldgekYMf+kdm2zyc5GEQldcUC9Sa2q2mRpFM/I8CD7hRmpQWJu/RmD2go9Om X-Received: by 2002:ac8:5715:0:b0:3f4:df56:1c90 with SMTP id 21-20020ac85715000000b003f4df561c90mr17935142qtw.63.1689089676778; Tue, 11 Jul 2023 08:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689089676; cv=none; d=google.com; s=arc-20160816; b=c9fu664CWdEDYIXT40jkPDZdeB+jQdZPprbMdXpRIyFEKi7K4q9MbyD/cu+xjN8Uix sA1sJuhRPK36UUvvM7fqyTWb/ykoLxPbFts52GYnmj//zWrvgelKiwlAR7FLVDdj45sj kVj6fuk+HV+7N6mwafLZhnuOMDnNlJjZ6+J3hMNEEeACSaJ9xEL96Vvow1kmWJxxqYNN ulXnaqh3bWN94nXse1W0oOofcMSKPxlP0uTxyYlDvGVX6a5jsQMLE0ISlrtAEpMtJlMA rrjG1vQjtNp8kUaKykEfvHbJY9ofgKkoh7De2A9/siBfdJ384kUZF8mJNYLZ11JJQOtG +mYQ== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=86/jbKk9mpH7o5Ei8JC92SPbLl0aqPRLgXFSEbJBkeg=; fh=QxkBeOB0Bj822bGND/SlBzurGTJnfTXUm8XyT4Nng30=; b=dHqppx/j+HvjUROkyP22sb68C6E8aCEinz3CWV/tXDNMALlFK1VHhPMYe9tPt/eYTv oQ9WVg169ySd3d7s8nbGfkIZpzDck3EDHu/bNCC9CDGXkNuHLaZvZ/AU4WhcmfPJsgpv lsKl4/Oci70T4GHbfB269Vstf4zn1ZsbPb/9UR5XTEBnpC1fsE0r2wsor6L8WkWEUaaP ADCFWWvTAJSrRcTHDxzcrv3ipoD+qdtmPB2fOtu87iDKNQ5mrf+9x2IX3N1yXQCiDwZe gJIw0SlWjcAhW8Mozoj9N3VChtM+7RpUhIWZu9ZnWhgMWNzDcoia9H3NL7DcQYHqpq0c KlZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m0nuIP7C; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m12-20020a05622a054c00b00403b254cf43si940813qtx.229.2023.07.11.08.34.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Jul 2023 08:34:36 -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; dkim=pass header.i=@linaro.org header.s=google header.b=m0nuIP7C; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJFNa-00077C-HH; Tue, 11 Jul 2023 11:34:18 -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 1qJFNY-00076e-9A for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:34:16 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qJFNV-0005Xr-LN for qemu-devel@nongnu.org; Tue, 11 Jul 2023 11:34:16 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-9922d6f003cso765381666b.0 for ; Tue, 11 Jul 2023 08:34:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689089651; x=1691681651; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=86/jbKk9mpH7o5Ei8JC92SPbLl0aqPRLgXFSEbJBkeg=; b=m0nuIP7C2ZVEmvXXiK3X2uytRCQMoqsQEeDTxqwItxDBdepGjvlhfd7AD7Svb7v5sm Wi7v+7TOq2mth3PN1JUBqmfGXIRa2E3PshoAzQQX6flFTaO3nghAzBSxbCqRKIOEj5Jq LOvNJPiCktdynyk5CbthOVXMzNK4l5DawPsMxcQuudzrGF1vyauMpn5EBYmKcACc91BN EoeZSVrqnr1PwNlOL0KBR6ylwSnKymYyEc4yetkPoO9sWbXeyTuUUzfpEe2lYyp6av/9 FRWtZ447LId8tu4N9rlsjajpPulLyIHAZf0CWp72vWJKXXUT6tfFxe2D044goRH9OT6Z YvJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689089651; x=1691681651; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=86/jbKk9mpH7o5Ei8JC92SPbLl0aqPRLgXFSEbJBkeg=; b=CfXvstE8m89w1/nyHtMrNO1L445OYxwpE5SGIzTTlxHzQqqdaEz04tPg2tn1oqBGoD W11cogWFVubgX4c4qulFsKpt1xKlaEgpEZAK1r3Q83MeLj/vla/GV9Iz5c0eQ5DZWNtf My9sotJm0fixp6QJMtclOB9s9ftFkk7zeej3HSR2f9nVVzkvXElsPpgzVkYjqiLkMLME ZqktO3JDB/hShjmUZGZ64ulsWIXMktsFI+3PVs0hv4CDDBA/1Pmk5x+AyHoxWoLHQPJf 0vGm3p6AlTKUKsQ2iDLvcBkUfADEKmeNYVuh51+eCKY4fQmw8BVjXn7Cfuv7+AOPTlKE cuhA== X-Gm-Message-State: ABy/qLawL2f37Gx0YnyzY6qPVhlw0mP+UXjae65gV7DZ/d8ZagP/GKod 2wX08xgvRez5QkdQhV/Ms/P8LnhKaFQPU+zY+pg= X-Received: by 2002:a17:907:2a4f:b0:992:5cda:69ee with SMTP id fe15-20020a1709072a4f00b009925cda69eemr14292596ejc.55.1689089651070; Tue, 11 Jul 2023 08:34:11 -0700 (PDT) Received: from m1x-phil.lan ([176.187.194.156]) by smtp.gmail.com with ESMTPSA id s8-20020a170906a18800b0098e0a937a6asm1313532ejy.69.2023.07.11.08.34.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 11 Jul 2023 08:34:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Christophe Lyon , Richard Henderson Subject: [PATCH-for-8.1] linux-user/arm: Do not allocate a commpage at all for M-profile CPUs Date: Tue, 11 Jul 2023 17:34:08 +0200 Message-Id: <20230711153408.68389-1-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=philmd@linaro.org; helo=mail-ej1-x633.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, 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 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: Richard Henderson Reviewed-by: Anton Johansson --- linux-user/elfload.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index d3d1352c4e..a26200d9f3 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -424,10 +424,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");