From patchwork Fri Mar 1 23:05:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 777103 Delivered-To: patch@linaro.org Received: by 2002:adf:e94d:0:b0:33d:f458:43ce with SMTP id m13csp1603341wrn; Fri, 1 Mar 2024 15:15:13 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUci+2S7gZK6MTf9lAQNNIWXa8dC2ctJjGrTQNooVuOi6yXfYkk5j8PETyQw2pC8ZuVFji3VBSkQZUR2U+3ztEl X-Google-Smtp-Source: AGHT+IF62a7rpas+jZlGnjJcT64H873pQFzGyDJReZjse70DEbWrgfyj7KNPX2Q/CqYNnu/bgPDh X-Received: by 2002:a81:7b84:0:b0:609:856b:9fde with SMTP id w126-20020a817b84000000b00609856b9fdemr2574969ywc.33.1709334912891; Fri, 01 Mar 2024 15:15:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709334912; cv=none; d=google.com; s=arc-20160816; b=RP6w4adTNqSldE8jaT9AU65kSV23bC2pPOJ6+DyvVQ2v1umP3m/15d2f/9Y0gSnPj5 ZnIhJDXxcI1MpulDQC4orqxGbariWPT738CzBy80m7kvtLgiRb4Wct+mGmbgh+k99qK3 0SxqAw4Ac6Rup+HBoRYSr+gngGX1+Qb2BTda8FxGUT8UVFoC+HZKH9bonuGaryBNsRJx szGJprglkrKCQ26DmeR78YcTVoJIIhpBLWRHG579niTZY64MZHQZY0mZY0kZ8hidgE5V 6GeBjFVHrZd8DjmGNcpvgzsPrPbuLPM9SkDyIqpKwB6IdJRemFsMx5BAPplt8zXqfH6f HcCg== 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=oqsehmdSBpDx4+BqjLPOYj++iC85Ag1++NqdrWinVEc=; fh=TypceWkQqZAd58MbMvFzjbJhJVwYT3Z2Jon575mPbgg=; b=CqpYkW2V5H1NkVozLiDkPnp0JpqkBg3rFDUawsqPOslecUxvbYGBDQnXtTcyn9X2NG Zba4ept1VPnGekvwdqUwb1kMV3FahPs3Fv6IyNZq3FZgwr0s0rMqIGu2G1cCEJvkOBh8 312FjTu57q0hspGKsY8djHtobUmZG743yL0PA2NCxMOSHS3Ta9o91FCm1e/1UE/ViuCW GUvhYinvEK+b1uWmxjZNgXyY0Cn3gGZEN8LcFB12RhBeUkffTuBAIPNbj7lzHYUm8sGK SQh7ZJaFb8K86PLbi1eVYo3tq+S9KtHMoR2OTMl7GP5mhnFXSS/X5D1zsXo+yYv/Ohqh lNSg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kjN7bXhd; 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 n21-20020ac85a15000000b0042e6b9d6b65si4830984qta.230.2024.03.01.15.15.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Mar 2024 15:15:12 -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=kjN7bXhd; 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-0005vo-47; 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 1rgBy1-00055O-9l for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:07:02 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rgBxu-0004Gw-Sb for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:07:01 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1dbd32cff0bso25498775ad.0 for ; Fri, 01 Mar 2024 15:06:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709334412; x=1709939212; 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=oqsehmdSBpDx4+BqjLPOYj++iC85Ag1++NqdrWinVEc=; b=kjN7bXhdBvCQHfZD1myvv61PZ5P3Mms30wp0M3oOLD7oeVrQ+AWo7Pek0FubCM25jN QIwydxdHK87RDDJBqsqmNB0rnNllj/PTdnoiGb35FOOL0nG5lPFGguh1QV2uFbGzxAQp SoHXH9QoQHtr7kL+1PJoZSGKX+do2FFWu/deeZ6CO/599b1elcWDLM1rgxvDRhJe1iPk e+q9mSJY/UnbYhcI2r8l9RzZ6olJ7RKLQovtgtg1H8c9qNlgcH/IkcpGZjGvsDlwuSHD eTSJdy9tLd2X4z1O7U9dec6zEuK+wNdcG/7EfYBhKtuFa7t/aByvtw7Gu+mfOw3PfPuF FYxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709334412; x=1709939212; 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=oqsehmdSBpDx4+BqjLPOYj++iC85Ag1++NqdrWinVEc=; b=rytmZGn5ZiFnjlb7K1YVpJo8jgb0O8h3EfFiNIn2qvMhizyCrpJy3e61/GMfKTdj0i 7OtlinWEtXp7nEElgSRuuqe5PfDf3y54vB+oXA6roUM1RzyRD6dWLTcnkw0g82RLUQpN EilrTKmo4lT87vwIkARDdGKGP1HpMLCL7ENkdsVkMUqUYszJj4oF4oPFBfx5tCv8/Hon yOm8pfePLu+E2RUTKizfXwozO03drF2qxXOqQEip2LY+MlJgkodHUtsWttocTwR3+g7S BH1JHFh2ablxivMOJjiYc5LXL26HVSkq3m8Jx8IIlWVpY5HXypogahTpXqeqaQ/NeGPB gsBA== X-Gm-Message-State: AOJu0YyFY86z86py4wHQb5yBxAGliqWBuhufPXzhIjLkISt9SHmnGP2t ZGYR557X9x6TPN/3pfLYsKJft9NFCv88AzfzTNEfpY5YzhbYEVCqMxRGIiF1rmx7FRE4uTPhvCe 7 X-Received: by 2002:a17:902:6544:b0:1dc:7890:72d6 with SMTP id d4-20020a170902654400b001dc789072d6mr2765881pln.22.1709334412565; Fri, 01 Mar 2024 15:06:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:06:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH 22/60] linux-user/hppa: Simplify init_guest_commpage Date: Fri, 1 Mar 2024 13:05:41 -1000 Message-Id: <20240301230619.661008-23-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::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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 0f135f6b6d..53b61aac77 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; + } } /*