From nobody Tue Nov 26 22:19:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704160973; cv=none; d=zohomail.com; s=zohoarc; b=VwiZzU+i5TB+zMEYTiyOFm5U2pdOwdiYdYV8jLQ0UFdPgJUr8jFG2drJlLmicOep92OtKPobA2R0d8jxGFHJjkjAZ559zd1nrFTeKFkJKbiMfu0a9WrH3RsBnZdij6F/HOkl/JJ77casYM44ala+Ter8Jec+lihK6tDNBJ92pfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160973; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=doJtWyMStqOAlo7bZL0mf6PIzbVYMD2KRSmUqFYZbbM=; b=aQ71OCjaGKi/oBrBj240y1XspWYi4Rhd3QjMB3mmmfSXYDj9A9Dl99iLh8tCwFTjyTjd2gslq5wB+yWvD25ZhEE5yB1wJjCNmSTN4ORrTGh1RlXtpNWndgqi+2ppOJ3C/zBTPbwSXIhdjfn6zDKTJi4fsT2u54huJV5LIL5pyP8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170416097397327.46473455272053; Mon, 1 Jan 2024 18:02:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU33-0003GO-MR; Mon, 01 Jan 2024 20:58:29 -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 1rKU32-0003Fj-N4 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:28 -0500 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU31-0006zz-9g for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:28 -0500 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-203fed05a31so7078298fac.0 for ; Mon, 01 Jan 2024 17:58:26 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160705; x=1704765505; darn=nongnu.org; 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=doJtWyMStqOAlo7bZL0mf6PIzbVYMD2KRSmUqFYZbbM=; b=iliY3WQORQojL66bodB69O5hvrV+cAO2r9GuP4k77jVbyDV+zU+LBkfaFtzHo8Eb6o nTJb3t8kx3+UzJmCXDYv9nElccOaaKojTFvfgvgicZGLP5GftFB7SWmspzZZFR3G8sbP EzOgYRdBCxRPvTRe63Mh324Me3SDiBSfIwbtNqCFuFtHCfH1Hceh0ISOoPPyon31y0+C wI6S5C0oGMNIIiZbV5wjH2s2KrjYzm4sWIlSLNM+ny/9XssmquWp9d0BQJDb0/rEpaKb PlZbrsLHYQ1nAr+bD5eFfjcnDlOQcIbjhrQ92EFOg7K8m6wDULdnkkL2yOduZYAWj66U W+XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160705; x=1704765505; 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=doJtWyMStqOAlo7bZL0mf6PIzbVYMD2KRSmUqFYZbbM=; b=N6zzk2d9laBlkO7CnuyV4gDpCmcIDJSTlNBIK0piLyUEez0rOz8RlsIMANXcbx8NHo 0YYW6Wsh0Jwro5E7rf0M0fCAMEVghsoKplSFsrzR8FX29rSfo38vheYSInI13p0nsNNy uk+28eKacVOl703LShIRNACWqNYgGdoNh4gPQSN0h+XrYPj0q5+lJnyN3ZPV3YDp5MJ1 6kuEThe1IqnnaSPD0O6Yzi30ysM3j0X3fzyWt1CIbgIpnwNDOKb7KEMuIfBSe1RNvxyD Be7Xl3sU96IB2YOy0rpOXVdShv5xYVVtf5jhHm8fkV78Wsx0GY0BTExt8lFkldFmbcZN DJiA== X-Gm-Message-State: AOJu0YzTsCwSbHsHBuX9w+Tt9e5mzYktEbYo2L6St6ePdQzcUKpx424T CtOSLFdziMwn0gn+rvc6ZRosw1J0pPL25ABcTWiImzgEmA0= X-Google-Smtp-Source: AGHT+IHCCh9Re7FIx9x17Wv2DnDG6ExxZLinFRQKjPxkht/v3c4eFg1Yr015/3PaAW3FuXFBHe1eZw== X-Received: by 2002:a05:6870:e38d:b0:204:2bc4:87c9 with SMTP id x13-20020a056870e38d00b002042bc487c9mr18563179oad.86.1704160705491; Mon, 01 Jan 2024 17:58:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 06/33] linux-user/nios2: Remove qemu_host_page_size from init_guest_commpage Date: Tue, 2 Jan 2024 12:57:41 +1100 Message-Id: <20240102015808.132373-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::2d; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704160975747100003 Content-Type: text/plain; charset="utf-8" Use qemu_real_host_page_size. If !reserved_va, use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- linux-user/elfload.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 96d8d4f84c..4fcc490ce6 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1531,10 +1531,14 @@ static bool init_guest_commpage(void) 0x3a, 0x68, 0x3b, 0x00, /* trap 0 */ }; =20 - void *want =3D g2h_untagged(LO_COMMPAGE & -qemu_host_page_size); - void *addr =3D mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + int host_page_size =3D qemu_real_host_page_size(); + void *want, *addr; =20 + want =3D g2h_untagged(LO_COMMPAGE & -host_page_size); + addr =3D mmap(want, host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + (reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE), + -1, 0); if (addr =3D=3D MAP_FAILED) { perror("Allocating guest commpage"); exit(EXIT_FAILURE); @@ -1543,9 +1547,9 @@ static bool init_guest_commpage(void) return false; } =20 - memcpy(addr, kuser_page, sizeof(kuser_page)); + memcpy(g2h_untagged(LO_COMMPAGE), kuser_page, sizeof(kuser_page)); =20 - if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, host_page_size, PROT_READ)) { perror("Protecting guest commpage"); exit(EXIT_FAILURE); } --=20 2.34.1