From patchwork Fri Mar 1 23:05:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 777101 Delivered-To: patch@linaro.org Received: by 2002:adf:e94d:0:b0:33d:f458:43ce with SMTP id m13csp1603297wrn; Fri, 1 Mar 2024 15:15:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWRjKsxowtFW+xideNZBKmG0J9hQZwRULlGKYCbyBh5V0MU0BNqfdFo/7VPFfQd0JhNr4eRSZU5n4+fTibluYav X-Google-Smtp-Source: AGHT+IFxPbFyqVj15EkX9utZHs0L2UmXsMVnOrnZNcr6RQG+RJ3o9XcxE+iSi0rM3lmidjSL2D/D X-Received: by 2002:a05:6808:1524:b0:3c1:ab06:7c5b with SMTP id u36-20020a056808152400b003c1ab067c5bmr3861768oiw.47.1709334909503; Fri, 01 Mar 2024 15:15:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709334909; cv=none; d=google.com; s=arc-20160816; b=SoLRbbqWRplRyF08TSJ9/jDTa+naxm8KEB+dw8oh0xOzdZmiY4TRHCtxcnp+tAJB+v W/uMpYXe5Ueqjmj/5+Rwf3ZopEajHj8NjoGHnRzzho6aZ87pCqX+whr3TF8G62/zgASQ sYdB9sHZwJbSjW1uRHnO7+O22jENspdpv5hn22mVbfzKdI/WU+9g8jvtBPi+Is49z8jf xzRU5OAkmzpAdFHp0Ojq9wYkZ/Z7mW5lKGLDp7kTje3TN61hlzWBwEeAe28VaEz7yKd5 TlgQXoabcWBSiaFXgfvvmHy6yFB3GTJf1bcIk2OAXUfOjMngys6Pa3IdKoqgZbUECfvc vJpQ== 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=nQmGR5cKuPmbKwlAdgNxFbsG53EvNXJRjqMWG5g8T5M=; fh=akUSvRccVt8SjEp97fUPeSLjFmLWLgFk16EYqCeIvf8=; b=lx4IiImFETwLvhG+XL5KxWc75F5POmZpiETf9/wIsd3kuyPmnHes0qhmPqSJZnGYXP 5aDaWmo8FHBkyzYt5i/7H8DuJ4nO42rhzfOsPB5jDSwvmMROPDr5VroqpPniPR2jZmBX ajzMUHbPJ/EImge4ykhEheRoOp/A4f63g8VsJWmqNwaZL23frqrV3bY5okpJCQ1XJHql JUyRxOOUSyQ5hXJNzKfNBOfF6z/QMI8OXosNuGqAF96nYB/aN25ftn6DgnUvH4p9EXu6 A0p3aHvJMZnSnaN81tIaMdC0PJOZ4x3ZF84zKWvW0qZPspzQ9d5Y12TxNTKowyNOYZMD bYAg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jhZfhj8V; 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 fo9-20020ad45f09000000b0068f2dbe3675si4485605qvb.347.2024.03.01.15.15.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Mar 2024 15:15:09 -0800 (PST) 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=jhZfhj8V; 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 1rgByS-0005ww-8Q; Fri, 01 Mar 2024 18:07:28 -0500 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 1rgBy2-00056U-Ks for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:07:03 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rgBxw-0004H3-JZ for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:07:02 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1dcafff3c50so23001815ad.0 for ; Fri, 01 Mar 2024 15:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709334414; x=1709939214; darn=nongnu.org; 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=nQmGR5cKuPmbKwlAdgNxFbsG53EvNXJRjqMWG5g8T5M=; b=jhZfhj8Vl7XpCYWRyQN+Vyj8HNJBO+FmjWM2rVYUXLFmVreSjxgGCe4J9Pg2l2BD0a 1JibQPHgl2BR64s4OcnwHXsu+A5AgiW6Us6e9ijibDXHYjGieq3jjnLtQ7bMJ8g96lNl 9w5zGdrt1XBRMjoj9qy0e2Ab7kQrlQ5yzl1XFYqsD3EgRBQv0lGokFM+Ao47JN1l0zya Wq66Xe3KPIR3a5CcIBjebtp7JeI7N/RNH+ET19MZb5UFErEIdnvxWipWOwDACOK6v3hq 1u5ovDrED7XRvu0IG9F3gf0cWpaa6QwWuMbK5A6rfaC88Xd5rs/h31Vh6XNt2zX7R8+d lZcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709334414; x=1709939214; 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=nQmGR5cKuPmbKwlAdgNxFbsG53EvNXJRjqMWG5g8T5M=; b=Bw/qTezrTn9YiauzE3/nEV5jTlui1xV+O8FavgMBrC1mdyLBi6KSevjSS/i/c2bPKv u5pLoYIYH5iLolChQoCgMfvklOPC01muBiVuDBPB8IedYUCGo5SCf88buGCxP4UHswzn vwgg1iNvkNiEPanH12IYHG7gQ5w0f+WIWAoNErwJ8oSX5xj7sX0xa+SeIWvRF00Abozf 4GoJpMI8664vYMa5VqGJRMihQvyhueAeIkUqSdi1JTBB3YCIk5VjdIuvxs5JQHZR4qOz JIRP9lLBnX63IYzsOJtU8FCpFSEHvpWHm02/NEBQnd4hSTKNDqGl3eOkXqO4LSwS3VjH kQCA== X-Gm-Message-State: AOJu0Yywqa1eqUfVNPZbNLDUySexzZcTq2TsBTa8z35pC7gbOvKy46Uf h3GIENc36EYyp9LRO7iS7Lvixn6tTX4GPhyTF+eQED9+LydZdrvyy0eQuhocHf6W97zjMk7Stw1 a X-Received: by 2002:a17:903:98b:b0:1db:fa84:9be3 with SMTP id mb11-20020a170903098b00b001dbfa849be3mr3697635plb.8.1709334413896; Fri, 01 Mar 2024 15:06:53 -0800 (PST) Received: from stoup.. (098-147-055-211.res.spectrum.com. [98.147.55.211]) by smtp.gmail.com with ESMTPSA id lc11-20020a170902fa8b00b001dc668e145asm3988580plb.200.2024.03.01.15.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:06:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH 23/60] linux-user/nios2: Remove qemu_host_page_size from init_guest_commpage Date: Fri, 1 Mar 2024 13:05:42 -1000 Message-Id: <20240301230619.661008-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301230619.661008-1-richard.henderson@linaro.org> References: <20240301230619.661008-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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 Use qemu_real_host_page_size. If !reserved_va, use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-7-richard.henderson@linaro.org> --- linux-user/elfload.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 53b61aac77..479acb4e7b 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1532,10 +1532,14 @@ static bool init_guest_commpage(void) 0x3a, 0x68, 0x3b, 0x00, /* trap 0 */ }; - void *want = g2h_untagged(LO_COMMPAGE & -qemu_host_page_size); - void *addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + int host_page_size = qemu_real_host_page_size(); + void *want, *addr; + want = g2h_untagged(LO_COMMPAGE & -host_page_size); + addr = mmap(want, host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + (reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE), + -1, 0); if (addr == MAP_FAILED) { perror("Allocating guest commpage"); exit(EXIT_FAILURE); @@ -1544,9 +1548,9 @@ static bool init_guest_commpage(void) return false; } - memcpy(addr, kuser_page, sizeof(kuser_page)); + memcpy(g2h_untagged(LO_COMMPAGE), kuser_page, sizeof(kuser_page)); - if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, host_page_size, PROT_READ)) { perror("Protecting guest commpage"); exit(EXIT_FAILURE); }