From patchwork Sat Jul 15 13:53:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 703241 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e4d:0:b0:314:25da:8dc4 with SMTP id r13csp158329wrt; Sat, 15 Jul 2023 06:58:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlEN5t4zEjzlSUgsoShD2XBguLHAMxNlIR3Aw57Ps9izu99XzJKyohG0x3Llj0PjJK8KY69+ X-Received: by 2002:a0c:ea50:0:b0:62f:fe67:7372 with SMTP id u16-20020a0cea50000000b0062ffe677372mr7191428qvp.14.1689429519514; Sat, 15 Jul 2023 06:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689429519; cv=none; d=google.com; s=arc-20160816; b=M7YN8MXDe9iomRS2F5CktFUrNmlqoBq/fsU8MOiAqpKZ36c07KT32GXaI6h81YRnsE qaa1Q6PEIutpptmX5eXaLUCuxzB5d1CpWQlUftjEZgAjpodhOvo+u/NithWj0pTtlae3 Za5oXKZnNeKwZ2kD3Y/xr4MQa2fkg64UNhMGN//85wgGnU/1KJsoA5uEeOpu7zE1DC22 3MlEV7AXH1wcN1YZsOKN38XK42E0CFEWitxylIoySlt/NhvweDNN/TkafEgViR26pMxc J7l6Ve0FxrN0vAK3UZojhqeQdIYtgz7EztNT8tDBNIYFv3DxGkm1uZFdDlqIEYdeWKQT qfeQ== 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:dkim-signature; bh=vpPPTc1J6EP9QJbzcPqiBEK5MSOQgGdVVPldReJi1XE=; fh=B5F1zNWozCRIKzcS+ZgfrKlXPkLIO2qXFqx+dMecEQE=; b=mAIKbR9uT3YsRePn7ky+hKg9cKBcLYwiYPD0VbkrFC8CZrF+cLh8nSLaY6G/4n0NoO 2lx1GB2aDyTXyj60CbUZGlv5DloGWvYeEuSVoU1zSV0VNd87+XuhSU24aC5o/IY5pZ7n Xt8MZSl4oS3Hxupj+hMHe4/PIVT+W2vSYcU1TgY3LOSwRCY4GJBK7XPVSIRCB+fLwWlD 9GbIzx6nGEDX4fpRPnh01oWdh/pdAzDZ9qX3FzYd+gTujFgxTQKiEz/m37KOvTkcF1Ts brYh5d2npXyEcE7cy8WZ7+mSmSydAuxsDPgdKrNzmzc14NTcVGxQugRmBAl3Mdk1vgQb LrLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rajLt5A5; 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 a13-20020a0cb34d000000b006261e6b4780si5812384qvf.197.2023.07.15.06.58.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Jul 2023 06:58:39 -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=rajLt5A5; 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 1qKflf-0001Fb-Mv; Sat, 15 Jul 2023 09:57:03 -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 1qKfla-000188-0U for qemu-devel@nongnu.org; Sat, 15 Jul 2023 09:56:59 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qKflX-0003Tk-S1 for qemu-devel@nongnu.org; Sat, 15 Jul 2023 09:56:57 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3159da54e95so2757167f8f.3 for ; Sat, 15 Jul 2023 06:56:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689429414; x=1692021414; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vpPPTc1J6EP9QJbzcPqiBEK5MSOQgGdVVPldReJi1XE=; b=rajLt5A5MmhNh/+wdqsWpQwhP5NTf9/u5UUI/uim6z5O4eJUd2bfqb3tffHQT5F96u sB65n24brOrqcm3y5xRd1ud4rqLcZ0piF4bKtNnxX9JJF0bPd791D4lHtwKObrkbVdJw qoZgBwHu7rThPa7lhhyVjbt9y7cAtKpLWCPA4nAlu14RA7iEis4qHm5dSmmFHrk8fvTa qbk2uPgI/y2HELfXMOwO0xmb1ko8kP+e08IB15jvKJqWcTeJVKkYhRV0s8FpN8e/2E95 44+F5e6ofOxqS5FLZlZ2gJtngcCCGrNzaQxRyiKTjIF0GRtug/iZLAxT0A9IAd38cuGS 2UHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689429414; x=1692021414; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vpPPTc1J6EP9QJbzcPqiBEK5MSOQgGdVVPldReJi1XE=; b=T3OheNS7Il8EtSJK47GvGKZlAERyKEGu7e9s5+kfyYxaS3gURRiongv9YejER/XwMu pEKi9ogY1nfBzFJqiKkeE7eJB7sygvD1ZM842tKy+E8MLtrqCXsdopbwg9RE4FakAQDg w/yMyWQ7GbRQtZ0t0xlIp08ebb14ZftZPRGdiNfTqV2BvGK2fWhFsu6GHq9+OGceABRd vBZyiTCpcD5oSHH3MAkFw128dHehpWYwxGSA/UQNvyY3xSs9siIrq3t2rbN+pcJsBP8u yLqw/kLaZ9gPEcZVLbMbdgPAgrtedkmOFSiJWd+wvwoh8vH+TU0nCeZJsb4rwdj3cD9A ODTA== X-Gm-Message-State: ABy/qLZwBzHGZOKRnlhddjGmK0eY4yhM47U77rAguxlyB69cB5OuCC5H DnqQEaSpvPpKmcnF+b2CtrAX6HsHIdx8PpkoJkOlbg== X-Received: by 2002:adf:d852:0:b0:314:13e2:2f78 with SMTP id k18-20020adfd852000000b0031413e22f78mr6444223wrl.44.1689429414638; Sat, 15 Jul 2023 06:56:54 -0700 (PDT) Received: from stoup.lan ([51.219.12.49]) by smtp.gmail.com with ESMTPSA id r8-20020a056000014800b0030fa3567541sm13866651wrx.48.2023.07.15.06.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 06:56:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Christophe Lyon , Anton Johansson Subject: [PULL 45/47] linux-user/arm: Do not allocate a commpage at all for M-profile CPUs Date: Sat, 15 Jul 2023 14:53:15 +0100 Message-Id: <20230715135317.7219-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230715135317.7219-1-richard.henderson@linaro.org> References: <20230715135317.7219-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x431.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 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 --- 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");