From patchwork Thu Feb 15 06:19:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772841 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp680329wre; Wed, 14 Feb 2024 22:21:32 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVsHq8Ct2y7k/08WCjnrVBUilJcRmDLGnMmg/2ZrhWE3tuZDZNG+NSnVz2GDxub6ngbe3HI671rsDMjVBf5MW/t X-Google-Smtp-Source: AGHT+IEaNyCaAYkFmRFpNci3gTva5vw4qS80AtGoxrLCTWkUQOUdw5GZxmYKdpmpyIRpvcxHw5A3 X-Received: by 2002:a0c:ca92:0:b0:68e:facf:fe4 with SMTP id a18-20020a0cca92000000b0068efacf0fe4mr912071qvk.22.1707978091880; Wed, 14 Feb 2024 22:21:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978091; cv=none; d=google.com; s=arc-20160816; b=wXY41qRG1H/8Qba+uOSCko+HrkP+qefW6fAyr6ZFp1l+M+iQMK5L5fkAI4ZxnHRxdo 6MkSmr4Ct5agAnqpAdDH869L9cy5VKQvno7Sq/d7BfVNR9c/wjS+iDyHMNc0QxZF/wNB /oZDpXGfJV8szGsIqREPgs5kprnQN80mApW2arc0jXHfBnMKJ/AJ9+Nmytrcg0+GStbN tkvwfs9sgZnqx4LXna6tcIad2+dFXyh7l6aE8dentbi1nXyUlW9acTTmtFG8toMAsQ/v 9wFnsMzZk13TGcFzTBZCLVTWQsMShpyoyc/6I0ejC6aa6BYINa++dSL6TXglJK+km/5N lxHg== 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=emMi1h1Qw5IeyN9nGFR+tElZTiLuS0cNV7Vg5JxneO0=; fh=TypceWkQqZAd58MbMvFzjbJhJVwYT3Z2Jon575mPbgg=; b=uxx5dK/27YXkgPeD+x1RoZk9/eUOzf0aYE7Jtcz7VEtmHCiCXh0hEXs/iLPuPZSgFl UmvXa3t5IRwCVxTNmyINCbyp1tqHoza6EONKtSMxd9dDm/byV8PZhVf5WOc6K/DNyfDT lw1s/oPHVa/lKLnDTiUb6Sk07urNp1GXMt0zLM09OQf/0dkXzl1X1Z8/Oi8nAmOak7ad yrgjMRKf9FnBHdW+EPQSoXwCLrTpqu+OPQCTadG7JeDLM3QxB07eidziHkrucZf8pgsw d64XKdICDb+jf6dF6TKa2HafiuVwadGnFriMPmVWxC2v+JFxmD9nsx6fjkOFGqXoSzYs 6uMg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="zJFJ/SjX"; 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 pt3-20020a056214048300b0068cb07848a0si756288qvb.477.2024.02.14.22.21.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:21:31 -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="zJFJ/SjX"; 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 1raV6o-0002Id-MS; Thu, 15 Feb 2024 01:20:34 -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 1raV6l-0002G7-4F for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:31 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6j-0005M4-GC for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:30 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1d8ef977f1eso4469275ad.0 for ; Wed, 14 Feb 2024 22:20:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978028; x=1708582828; 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=emMi1h1Qw5IeyN9nGFR+tElZTiLuS0cNV7Vg5JxneO0=; b=zJFJ/SjXHE7Sqn4HUoCS/MuJRdx0bQFgr0XiEu6NKwX9V1tOOdkiIxYMukF1MJ3x1T xDl0bbVyhVwiwmeGwePBg8sJSMUodD6prl/HOM8ymn7Dkb/X0qZ3LsbZuTqosbgYsVMQ E4LQTqOtLYYtTBE4g5kE8MYQbDk6o/ieEJP5Eu1M1428qfnLBpam1IqQN2nsUM30ikoO shPccr5YcRFe5wve94Db2OWqNlBfZqCQDSfpsW41Dvvq2QNqEBawqcKxLoXUgReYWrlc Fq1EvqhbdqDbrniThsFqi0IRp4R5UwZhys7sdsHKr8aXoQ1bCJ97LW10EkA2o6elJX3o vTIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978028; x=1708582828; 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=emMi1h1Qw5IeyN9nGFR+tElZTiLuS0cNV7Vg5JxneO0=; b=Vdf80zVwVCgJ9qclKmSSQkKtGyU6nj/m0n0HEV3aKBEiW7Xhs2Rn9TKcotbkBzP1TF vR3WMVX/X1f9o4y2P2BT2GVfaEIo3aw+r2YErluJ5vF/EmpDg4mtxIYsx3qxT02dJYzK Q5negPj3Z4wotkQTuGQQXNGM4gluOgv6hdiw5IPwU5dDDCbUc1VZlaTNCxEySj6s0PwB SSUKLhINAQP1jdcItlbnfwr0PzaCq92UtVbMYlqxT7iNsBYwUMhMBppF47pEasEUSOK5 eE9uV4jUGf129i5vZzn7QeKCHrXwsj6AODfu2YutIrkCQHfccN9aayvj1tWd8NHbyjGa rwnQ== X-Gm-Message-State: AOJu0YwfkccT+6yl2kf6R6SS2U4GGIlkOuW2vmpVPZoQlpN6ScMdkYgk TcEuYh8/i7aEjm2za2NXSCth+nvh8goCQ5S6sadMRmf0Hhn0Eu7tis8Mzea8lKM3ipuocFrJ4/D k X-Received: by 2002:a17:902:654d:b0:1d9:6dc6:6616 with SMTP id d13-20020a170902654d00b001d96dc66616mr769027pln.68.1707978028155; Wed, 14 Feb 2024 22:20:28 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 05/36] linux-user/hppa: Simplify init_guest_commpage Date: Wed, 14 Feb 2024 20:19:47 -1000 Message-Id: <20240215062018.795056-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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 If reserved_va, then we have already reserved the entire guest virtual address space; no need to remap page. If !reserved_va, then use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-6-richard.henderson@linaro.org> --- linux-user/elfload.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index dfb152bfcb..1893b3c192 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1970,16 +1970,20 @@ static inline void init_thread(struct target_pt_regs *regs, static bool init_guest_commpage(void) { - void *want = g2h_untagged(LO_COMMPAGE); - void *addr = mmap(want, qemu_host_page_size, PROT_NONE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + /* If reserved_va, then we have already mapped 0 page on the host. */ + if (!reserved_va) { + void *want, *addr; - if (addr == MAP_FAILED) { - perror("Allocating guest commpage"); - exit(EXIT_FAILURE); - } - if (addr != want) { - return false; + want = g2h_untagged(LO_COMMPAGE); + addr = mmap(want, TARGET_PAGE_SIZE, PROT_NONE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1, 0); + if (addr == MAP_FAILED) { + perror("Allocating guest commpage"); + exit(EXIT_FAILURE); + } + if (addr != want) { + return false; + } } /*