From patchwork Thu Feb 15 06:19:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772861 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681441wre; Wed, 14 Feb 2024 22:25:34 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWLi4gZ8u4PBVGfmGh4AmqbKf6BkMdy/cqlvYKhMXma924oweXx2yaaPIxcgBZiLzh/eg4K7Ja+nHir7kz4GxV9 X-Google-Smtp-Source: AGHT+IHVIPMZ6GtKfL9WjeOkcTL8JhcodXfVLy2SknYeOr3glotAInYEyIAl4v43e0W2X0xDUKLR X-Received: by 2002:a05:620a:669:b0:785:d3e4:c91a with SMTP id a9-20020a05620a066900b00785d3e4c91amr1098442qkh.20.1707978334635; Wed, 14 Feb 2024 22:25:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978334; cv=none; d=google.com; s=arc-20160816; b=nzC2cQgK3CuqWF8wZLHkE2JRdF8CSKZVCtfPvmewXSdCxNEAk8B9iRsI8YeiV1XCeH 8JS7bWD1mALSOoGTD0sD1zlLlzyH7HwnBPjCqOMJsTiX45JH4qGjuxCxWl3kkB8rF2SF m1NcCf76CC8b4RFk0Zme2/7Foia4bUNW+89DsOUmVDSHygUHjNbU9YmLu0jqj4//IAqS vzHC27VgaODm++DHezXlw+oQhpxtWgls9J9ddJoISNwj6sjoaNifjgtMt6UFU8XOqaKI 15HCcBKXHK+qAUbnxYLi5vLBNjIOTJPXBBrEAvYQTFxJ/zbI1UBRAbXTsvs3fsNJNtEf R0Jg== 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=on46I2b8riCprdxQ1GrqNDsO17YyckywkPgL9RszReM=; fh=akUSvRccVt8SjEp97fUPeSLjFmLWLgFk16EYqCeIvf8=; b=OKdk0BbdGK0hofFW0ag2mR0RhbLRYWZz2UWHA1c+u82Gjk4JCJUmtK5V8//6g70sfW udnwzDOOlKR/Nemo9z6rokO2pHSDx2UjiLeoG/KcAMCgXaKf0tQ8RCdH0ciZXOnAxX22 z5S5a0JbgZX10q20tvvwkN/QZSsaOw47PCRHdq0BFvw+H/5olwRnvQz5l+FDG/jWYK4j Se8Ev1Jj39rHpcEPJAT4Q4682Z9UhxxNVvZoJbX3+XVZnztZhUokjKXHgrbw/8RJX76A 6JdEq4Vz/LrM1O8NZx5rky6KObfjuWYCZ243hkb+qyeLDEIlj6vVZODdQYIxicJDg4lr wf+A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="oks/L9Gr"; 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 t13-20020a05620a450d00b00785c0c8579fsi899398qkp.632.2024.02.14.22.25.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:25:34 -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="oks/L9Gr"; 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 1raV6q-0002J6-Q6; Thu, 15 Feb 2024 01:20:36 -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 1raV6m-0002Ht-Pe for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:32 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6l-0005Mt-2x for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:32 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1d9b2400910so4240335ad.0 for ; Wed, 14 Feb 2024 22:20:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978030; x=1708582830; 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=on46I2b8riCprdxQ1GrqNDsO17YyckywkPgL9RszReM=; b=oks/L9GrJ2CpPAMuCaYTWC7zE9nJVed3jyX4EV7asGzUGTOmU6vIjY+VVGrc40FrQU Rt59eRdkrXZt7Iu53MXeiJkN31JB2qnCXGNEy9lCrw70F0A7FYsDK/dUZTbAdTii73GL 1VnM3wD7pn+pfJ7W5ZOUBNwAfeOYJFU5uLgUXyb3RAC6TPHOOEdWjeYQbVVG0g7HKO1n Gme5gL+dIVzGihRYfAzH584qO21Nsu7+NXFDNv3iYtpSsoyU9ZOJu7ADPap3Y5dX8YAr VtC1YhNckpUBl/P4mNYOGNMO/fn83V1juoiX5QT+ib/sB7ZrmxEhFih7rTX7HOHOfIEY aT1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978030; x=1708582830; 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=on46I2b8riCprdxQ1GrqNDsO17YyckywkPgL9RszReM=; b=I2XdY6qaKERi232JiahYlbJI1930JIKeQRu54lUpOjqKFUdbDy2GVIBJ8GKSQv3aH1 2fiAfKnMXzAZ02ZyQM4ltCAwUDGaFziMn5VUWHTBaS9CmcvhY7aNN+3eoeaEZyla5+Mv 22k3JMbnYMutjoFIz2TwukS5wppJdq8JFSAevZZlasTLNgZY9h9EKGxoMGjPZ7DJZhL+ ES8JRV9g30TH5Xsb5LAjyAuphfxibxyPpgfIINFOjQXphKGSYvc/5NmbQ99k3yuQQSyw x9A8rQcrJlF2xEnz31hi2wshh98fHe23SO50f3AqYHsRzOOA97Ol9+0qQyXQSRaHhZiR EVDA== X-Gm-Message-State: AOJu0YxmpFiIPGkj9A54YBkVsTrkIkO7hXr/8vfIcdN63gsZ73tkr0r/ V5wyH0M7/CUU18z/J5k4i/V+yDu52oEGvXYnru93apU4TDX9t1kdTwRtXfWGs/sCbD3frbr5ykC d X-Received: by 2002:a17:902:ce8e:b0:1da:1fe7:cacf with SMTP id f14-20020a170902ce8e00b001da1fe7cacfmr1519807plg.25.1707978029794; Wed, 14 Feb 2024 22:20:29 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH v4 06/36] linux-user/nios2: Remove qemu_host_page_size from init_guest_commpage Date: Wed, 14 Feb 2024 20:19:48 -1000 Message-Id: <20240215062018.795056-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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 Use qemu_real_host_page_size. If !reserved_va, use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-7-richard.henderson@linaro.org> --- 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 1893b3c192..a9f1077861 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1532,10 +1532,14 @@ static bool init_guest_commpage(void) 0x3a, 0x68, 0x3b, 0x00, /* trap 0 */ }; - void *want = g2h_untagged(LO_COMMPAGE & -qemu_host_page_size); - void *addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + int host_page_size = qemu_real_host_page_size(); + void *want, *addr; + want = g2h_untagged(LO_COMMPAGE & -host_page_size); + addr = mmap(want, host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + (reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE), + -1, 0); if (addr == MAP_FAILED) { perror("Allocating guest commpage"); exit(EXIT_FAILURE); @@ -1544,9 +1548,9 @@ static bool init_guest_commpage(void) return false; } - memcpy(addr, kuser_page, sizeof(kuser_page)); + memcpy(g2h_untagged(LO_COMMPAGE), kuser_page, sizeof(kuser_page)); - if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, host_page_size, PROT_READ)) { perror("Protecting guest commpage"); exit(EXIT_FAILURE); }