From patchwork Thu Feb 22 20:42:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 774898 Delivered-To: patch@linaro.org Received: by 2002:adf:a356:0:b0:33b:4db1:f5b3 with SMTP id d22csp43594wrb; Thu, 22 Feb 2024 12:46:54 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXbcdPvWcNrCacLUlxz8fDNoTVc2BVBwyLTCuLL9lKXMF/F8JyQDdXUKbYefHsKJhdHQuvJTqVf6PT242CFkt+x X-Google-Smtp-Source: AGHT+IGH5ShzyMS019Ayqe+QBgIvyjVDeWE1rM66fiIsetO1L2z0OOjiy1cJdVHK7Hpusx8Pv3Kb X-Received: by 2002:a9d:6844:0:b0:6e4:76c9:f82c with SMTP id c4-20020a9d6844000000b006e476c9f82cmr117770oto.24.1708634813784; Thu, 22 Feb 2024 12:46:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708634813; cv=none; d=google.com; s=arc-20160816; b=y7VIPiMP+WGend2Aou/RLbSRyGnPznTCTFX10P2fPRCK1YUoRVFwilGpyg3Z1zXt6F xVKfsUTOhgGAvKvtCLtyLH7ujo2sYNuMUXmJRaLqfWyrXIyLN6XA83NykBN7sWAkgtPk hSNSkCu33sqoUUUIGQ+D/fXB5FV3Jf/+gDcU8qA6yUmY6/p268WYehcvvAG/bJqNn58h h8GRKfP+tyXcaQ2hmIzrFxJdBWETBg3hQ1jvnuTPPumyOzRnYYidlLLbuwpZogNj9F2f Wh7EmQbuYtPeNYRFPCv1qxohiR9ZJWq2Q9e8uh+v9qXJ0U978vJtXKHf8ncPJllow9QI qxTQ== 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=fAiWVqMT4njlMtScoMBCu3PCxYXTD3aw1TB2EdXKL8Roc37Nloaoo6K4A3bZ7uWVGu yuJp8ob3+BYKhsVtNre3izfjO5Q1kuwfd4l4wxNGZfGVDe0h3BJnr1zUOzBYfEhP0hrX 6sqvF9Ks60KvqgGQuVQlVpZ67PaN2ZR++v0mkbPXKfBYRaTvW4C//y3nTtWw6iXraRlf TNz+Gj1ALhIdDRun8j8vZdYhO8lWUvg3mKg2n189OIJBWK95GNku9xK3SuGpip4WBtYN lWYtt47odOo38/7VB77W7Gs41YsmACtif3KvNm1yWIANQlhEgXtLEwH8z7S2cr8KsDmW luYw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IXY3FNMl; 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 i23-20020ac84897000000b0042bf3ea8991si13212713qtq.320.2024.02.22.12.46.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Feb 2024 12:46:53 -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=IXY3FNMl; 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 1rdFuy-00070n-96; Thu, 22 Feb 2024 15:43:44 -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 1rdFuv-0006zp-9Q for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:41 -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 1rdFut-0002cS-Mc for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:41 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1d934c8f8f7so521735ad.2 for ; Thu, 22 Feb 2024 12:43:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634618; x=1709239418; 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=IXY3FNMlf5tD4tkHfrXxIkdWE84Lo257kMH4kL6eu1Xzbg93yqpbHxEv+x2pZYniSG iQY72bxqvGHmHh0j7i7kssPboxK47hZvHPYzAFutWAND8rrayWvLw26pUittbhFTG4cj Av7eKNujTyijnIeLBO63/oUWgtdOzyy1QGGemrXiidss+HYwFWOkTldu5mthHYusczVf 5axnJ1MF68461ZTTtg6f2+RjqwP4QxeiQJYonU95rHMYu5I94CvBfp9GA9D/Z5OmL0TJ hbMetGxTF/9B+aY0wDctjA2Pm6YnP5kkrFNNuJNA1qbNxZSaonerJC4eT54fCnKtLN9Z G8xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634618; x=1709239418; 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=fkdC63Zv6dxMqatm/tX6AI21Kxo3bFaYDIu/d82jX2j0K5iL3iceNMAdWNja2av8cY 0fPM7IsOEIOxRNs04ChoE1p44wX8io9CrZx5stKhmjCQNkKwpXff8kYrJM0/vLuPyEga IF8k/IGZEP3KhDnnGzQ3bWbD7Dif6/Ug0tEj2/RmNtZHagzcJX0L4D2oLWJa3m8Bnd0Z RNjTCASMz4Ikzob8SL/18PeBbVLYKbJX1gTw7BqVfPSEgC7g4UreNuELc0VpqWER0NI6 3Z3tL6khgbHpXif0IOOY6EPhUxxYV8yMpDqxX1+leU1AqveqBVdBvTqgjkz0sHbEhm1S 3VoQ== X-Gm-Message-State: AOJu0YxDPTbB62X4AVBarLPEN2HT03uZq3vA6PetobeVBn27n6xvx2lh udaJNI83guTSR4RM42EP3S3gXR1z2WqQ22vhP2H5W/AMdH4JrLMsV3AW8tG4kPZ2lJqBBXJA8xL S X-Received: by 2002:a17:903:1c6:b0:1db:d7a8:850b with SMTP id e6-20020a17090301c600b001dbd7a8850bmr16589191plh.25.1708634618559; Thu, 22 Feb 2024 12:43:38 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id l12-20020a170902d34c00b001d8f81ecebesm10275500plk.192.2024.02.22.12.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PULL 08/39] linux-user/hppa: Simplify init_guest_commpage Date: Thu, 22 Feb 2024 10:42:52 -1000 Message-Id: <20240222204323.268539-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240222204323.268539-1-richard.henderson@linaro.org> References: <20240222204323.268539-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; + } } /*