From patchwork Fri Aug 18 17:11:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714663 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629652wrs; Fri, 18 Aug 2023 10:16:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0Na0BnXiPFp0pHoK3tOl9m5Z2RKr9gmp7UdaLn4GlVPCHnQWt+wrF55+P3E8zHNJP+frF X-Received: by 2002:a05:6358:93a3:b0:135:85ec:a080 with SMTP id h35-20020a05635893a300b0013585eca080mr3727943rwb.32.1692378965471; Fri, 18 Aug 2023 10:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378965; cv=none; d=google.com; s=arc-20160816; b=siAOwFVWMXebwnmMSFFa4ovnjDxtnr6AMFvGg7r5mdZpxs8SUfuIdB4JriJVDsi8m2 NtIAgiUHCz5gDUmPGTtQSN/ZhHqqolHIYZ2WwX+x+J33StVQTG2Ogaxr/ztCdVsBBch5 pDUsqn5ugVQL8bIJXUdj60C2aNAi9SKbvBuQXb7eCOrQe/m3Em454iB0DovDrsc/qg6v pVuHYpekj3izTQW4NZZedQRE5sI89Xwv7cyX5F+keuozFasDWBToA9WahbqZOGvI1BG4 sKi5yknRqYzwz9LZomzaedweoo8p0YHsQEtERTMn6673uahUUKN/sZCE9l4ywbks/5CM ZGig== 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:to:from :dkim-signature; bh=foxS0Fq91WmmfcDM8Wf9D08Fa/T038sYWUjuA+SoAyU=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=MtvNV6j8MTPZYWnvooGuQDmFyqdeRLg7WUKQ+sbS94nKY/p9fvuYWm/Z3En9TpZFFe P91nTuysI34ljdCzqbLk6/up2syjueIE/AieryCejpz09tTh0mq0yHp6QD4heThLf+/5 V+iCu/aNKDwW5beE5cIjmJfmUSE11ut6RGWO8naGO3kZJmjUHHJWnK3FNeqtWmhUmIQx PVMusneOc8O7vL1eP0G7iuMzcJ7c4euGJnub3WhW+nqG0SCOdL14bOYEmN2TBtk+PCBm KlO5KtegUxExdW8i0o6jOuUqz04Ux43rxNIvJkOrnSWPwQtyHY9SCpcAciIqPOw++0Vl wLSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J8ufQCj3; 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 s12-20020a05620a254c00b0076d8821ad1csi1400789qko.587.2023.08.18.10.16.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:16:05 -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=J8ufQCj3; 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 1qX31c-0008Bz-Ps; Fri, 18 Aug 2023 13:12:40 -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 1qX31b-0008BS-Oq for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:39 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31Z-00080Y-Mx for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:12:39 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bb84194bf3so8859755ad.3 for ; Fri, 18 Aug 2023 10:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378756; x=1692983556; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=foxS0Fq91WmmfcDM8Wf9D08Fa/T038sYWUjuA+SoAyU=; b=J8ufQCj3bDBvRWuA6trLxcsZRKMyceecEnvjHX7M9colkmTNmxorIIcuoItIknNd2b HHlOjxf0ZzGCbMCom09fMncmsOtsb9THDryk5Pe1k0tD5lFl8i+DSbULcmqh2t9CtXva Fe4PzQSdNZluTtIu/RAmwcoWvy66U8Js0EVg2v8DOiYyrNpuGJ5UIBJ1u71vXHcScz2K 5OJdpZOBZV/20ER6SDz7+crt2Ks1zDQ+nnOVsoSwnl6iDVWbUk77T8FZxT7DN2fLQxTB cwZCwMjKMibjgszE+Dfvk8mxVkmVmdJKF2bvY7wrIW7n2nrq4jmfW5QEmrrElbbdOD/E 2dXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378756; x=1692983556; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=foxS0Fq91WmmfcDM8Wf9D08Fa/T038sYWUjuA+SoAyU=; b=BJmFd9ZxEwSk2sSJ0yEG5PY5HT3LeZ1F+FSyRAZK09QrV8nJknKKgMdTIMKtSQxRhS U+sPoDwNuTmpLI0KLezixzC2Vx19WbMEWUQs8NlhdX7fpKMfYv1TOj6/Y1Cib8nsR412 YfuC6nXOgoy40TBZMwds80Hu9U5tsAS7718WppDyzIAECCUu3hbu8GB6ONJ1087J8+co e5iWK10/BpXL0p6ynuAgdYK3NA+4Dj3EwtyPSb8U5peuOsitZN4bcQHhkvhgIoSQg7OX SutL9Gm9whYhgvZp53Imr99BVOgOK82ORPQngILBpLseNpWFIAI3glTOsN15NpxvqLsZ luhQ== X-Gm-Message-State: AOJu0YzoP51sC2gsLYfn7kAY366WP9BpiZyy8n0QMfEJY+rXEjLu8dfB dx/Bf3RiDOXNaax9Rb3cFmNHEFkepgk53SZnssc= X-Received: by 2002:a17:902:8341:b0:1bd:bfc0:4627 with SMTP id z1-20020a170902834100b001bdbfc04627mr3090319pln.40.1692378756303; Fri, 18 Aug 2023 10:12:36 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.12.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:12:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 05/33] linux-user/hppa: Simplify init_guest_commpage Date: Fri, 18 Aug 2023 10:11:59 -0700 Message-Id: <20230818171227.141728-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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 b6af8f88aa..1da77f4f71 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1831,16 +1831,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; + } } /*