From patchwork Fri Sep 1 02:23:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719478 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp17086lti; Thu, 31 Aug 2023 19:25:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRYvjbxVDAMcuf6ALywyWVpsUbsXetydSgE3XLeSfmsrNl+Cb8OXYUmsp3NODUjGOTQN1p X-Received: by 2002:a0c:f193:0:b0:649:914:6495 with SMTP id m19-20020a0cf193000000b0064909146495mr1041121qvl.62.1693535135710; Thu, 31 Aug 2023 19:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535135; cv=none; d=google.com; s=arc-20160816; b=w12CDB1yThgPQgQfNOaYHsaFiHFgCdv49Qzgr+OnyPGPWJDvdb1TSjjZC1jJDuO/Wz RfycOk+Im2y7l6/AB9a9VYZi3atlispTR96Ugy4NX0e43MSfhLNivc6GXgWty2E/Nsn/ fD1Yq0T5FPNNjcnImB/y9mrcQ3DEdL1B92B7/hYoYxNGuCicsIqM1bKors28WXT4bNTq zYF9sgSwS9g8SiCwrjmzAGzD9vNNtj2mWUSXM21s0quUijVGEFYhTJ+MtoSPJquin+qE bt1qxGzOL5aG2dKnX6fnV5arLhdFcOEQtT4N7A3RmjP4MjaYiuD2TrzrwfkNcnuLHsHY 5Q4w== 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=3P9EWl1tJVitUp2HhYjFwCQR4+GDFyi+Ud4oCYb+o1w=; fh=r1cPj2GlTGSV4V8jQu3jfCKsZwpJ5ktYEUy+P7GD/+s=; b=RbyMcclRQhvi4AxQxQspw7WxaexYeWZ8D7eNsk0ffu4jROrH4VrtlOM+F+X9S1CwP9 B3P2wIRhT0g8JdNlL8fffbn8ny9vawkIyDFWLLWl3SV6Vu+75VoKfBVU6AYHPE0chN1l x+4MjhoML6L63Zg5FIGjjBHDQsggPrPWVpF/YaYZpxvES/0fbEoyarpyaJGKYdsfHxWA xioHSppUjI19lnS6x89mBcAbWmmAj/YLc0BxOmNC1i7r+0rUbAocbMCfxF/Iw9zBVMYa Gwr2W/brpeaSWXcFXNjdhy/7WHBLeUmqrsZ1UD4G1MsjcqTrDY5nDlGUPfzz943ZC09C XZ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="B/oA+yTs"; 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 t3-20020a0cde03000000b0063d453959fesi1770644qvk.369.2023.08.31.19.25.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:25:35 -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="B/oA+yTs"; 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 1qbtoz-0006Tw-O7; Thu, 31 Aug 2023 22:23:41 -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 1qbtoy-0006T9-6X for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:40 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtov-0001OE-Tv for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:23:39 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-68a41035828so1182246b3a.1 for ; Thu, 31 Aug 2023 19:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535016; x=1694139816; 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=3P9EWl1tJVitUp2HhYjFwCQR4+GDFyi+Ud4oCYb+o1w=; b=B/oA+yTs3oM6YKSyum0INh9zx8bBLMRuuL3+qa40XYle9TdovYY/CsGO6EfNHv8YHD beK4afvtISr2ElNhk+krN20aRjPiEjaWz53N+aM9InqMqTW/Th10II3akXBNWlJMJn2C jDaFHKI7ART9ds/vOrUQ3qBR3QBLfgTXpJhsZmiF1BPozRFkJBF92sKH/GClwvptILOg o1gVaEqw9ENiC4SrOA7yPoUvy63VbUkl/075dA8QHQzOc2aOIT5fMU3DQNqvtBl3AjZL eKKYwzA/3HDKsv6LNJCHyJpfoNakA0EnnlNY34cJQMCmIFeoMH0n0bWytx+cFAOMI5sr x2wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535016; x=1694139816; 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=3P9EWl1tJVitUp2HhYjFwCQR4+GDFyi+Ud4oCYb+o1w=; b=j19lQGHYq6eccR4wAWRP8BF7xfN/69UZgOtz+/opc04UYnmBqUY9gsKgBjZAckaZ9x yqRAYVVNG5X0auY8lQy2eHvz1EFAjm0Op2nAaScSC0Eh3L8ijcRABeavWGj8eQDo/vUa jTQuqXUQ5euk8FUlZxUusnpqC6iIFVV87yVPSKKlu1JJzlsbYqEun9BUxRGWACrL2Mcl sTFLogwaZj5RUT+1/EZeoyggqA4WZ9BSN+StLL4sy+hKEBursHhRD0XJ4tHKsDPyriNg xjmeBVMazNJ2Ysa0dNApbKoqYI31pa65a3R3JzqqhTaDLA1rNPbiIPBLY1NC7vfXpuT4 mlBQ== X-Gm-Message-State: AOJu0Yyd/q8J3K1mFfOX4XU/b961kbgyWWjvWW0tHO9z590yWRmXqGAV 54YOKCxHC+xnSuMnjSfQusjEm71bWZ0kyvhuxD8= X-Received: by 2002:a05:6a00:848:b0:68c:478:de31 with SMTP id q8-20020a056a00084800b0068c0478de31mr1581083pfk.12.1693535016518; Thu, 31 Aug 2023 19:23:36 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v2 05/33] linux-user/hppa: Simplify init_guest_commpage Date: Thu, 31 Aug 2023 19:23:03 -0700 Message-Id: <20230901022331.115247-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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 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 --- linux-user/elfload.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 885566c798..939c9b4df1 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1812,16 +1812,21 @@ 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) { + int host_page_size = qemu_real_host_page_size(); + 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, host_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; + } } /*