From patchwork Thu Feb 15 06:19:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772849 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681125wre; Wed, 14 Feb 2024 22:24:22 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVeskMq2W6wdagayF9/WrOOzAxqS9P0Zo889swPVd/LHiujv1Qw4tNehMYTtmSGhF74eBjC+hAYxAPa/wEDIjV9 X-Google-Smtp-Source: AGHT+IFtU2XWL1MsVREbhqArmAIJFcUoz8qbrxrCd02KdwJfynI0udE9jq7JVFLgBfL6r2XIGXGO X-Received: by 2002:a67:cd93:0:b0:46d:30af:ed32 with SMTP id r19-20020a67cd93000000b0046d30afed32mr937666vsl.10.1707978262681; Wed, 14 Feb 2024 22:24:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978262; cv=none; d=google.com; s=arc-20160816; b=WVOGGftxhJEFcMGorgokMq2BAuQ7WjcMYvPH/h5Ud44cxCi8ZzArOOuEYTYupiGBBa d9ZABDD0KisRThSX8yIfY9HkKqyJp9TNwfvtlg0+6xDZvsR62QTijOSdCLxTQC5Mg4MH Ry+2i5g4s9ZHTIKZ7OSzmQPW0DVUDivj0bPVnuKZ/MIjYlwtPpuUS8C+UIhrhrb6yB86 VGZfTwpyrZhv2cSUXbCpSM6ulORLOJSdP4KEsvWrVi1lQPvMRWJoaG4zo2fAtePAopyu pOsVBTSmxRxR+qWLRLYXuvKINbpylGNekiwIYPN2kmjox7SF7dnAb4eYzKt/wycr2/gC zwQg== 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=aaAlM/N1pdfPJQ0AFuX+476ixWIzFXGcl3gsIXYKRec=; fh=akUSvRccVt8SjEp97fUPeSLjFmLWLgFk16EYqCeIvf8=; b=BZCd0gVgBvCfVWEu7FirPopdh5NjzUm7ETlYoCEa8aJfbxOAdUHmmh95hKnPjDmwHi tC0xyys28JqPaxObGDBovxNDtZvmPOxReXttS6/vC0XZMAADdnfQDhsFhQY0rAM8/vgj 6/qVUPit3yCvXQi63Dqn1cUTaPPYlIea3ZIGmGSLAPEicHbQrznRAeSgWNM78o+vzvhF NE5KZ7Fk6KasQqmMoanvdIGnvNMI6msD4szkc606NSa4qR94SlvcORpP+D9Suzzdby9N zgp20ZA9dkRQCs9QD1bZP+C9GvI4pojUVlLwkWWYz7rjW6TX2+MX6Rdo1NNKeA0IvTFD +8lg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=brLrEsIZ; 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 q16-20020ac84510000000b0042db24b2660si684386qtn.307.2024.02.14.22.24.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:24:22 -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=brLrEsIZ; 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 1raV6s-0002JL-GB; Thu, 15 Feb 2024 01:20:38 -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 1raV6o-0002If-4L for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:34 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6m-0005OA-Ca for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:33 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1d934c8f8f7so4643605ad.2 for ; Wed, 14 Feb 2024 22:20:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978031; x=1708582831; 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=aaAlM/N1pdfPJQ0AFuX+476ixWIzFXGcl3gsIXYKRec=; b=brLrEsIZtnVmD+npeC2nKkYX1gQbDbr//W+t1wYWPhextsakKtpAapyxbEZZX5khM2 MXa1l/kjVOBYFk5Gwz3HiGPzLZT9i3qATzbIm/KHSf6LGbJXWkXtdl95OzXwPVF+nxKU yHOGC8koBnJUWhOjfK8fiGixINQU0YcM7w3DAdort9T4rPM23lzV0yMVEFgBMDok1zLc FqO1Eq5+vEZ59isSatGIqcmSRjNUQwtw/cSSQ1oY/xHRTHtZY/Ifgc8RvqTHFiP432uT zyUDbWF1cXwEp/yNFYQ6mrw0MNqHNz9/VsFFTP9bnUEeTzjbwbUXQLqQPNXA/Fwa4Q4O Hdvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978031; x=1708582831; 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=aaAlM/N1pdfPJQ0AFuX+476ixWIzFXGcl3gsIXYKRec=; b=cm+6vxFIKR19ZVkamPSThA9cpGrEU2rfX7W46hiDCNw/PDQ4C0JT7FbFKRwxjAXyht sW2xNu8GVzVXeYuDmq/u7HJ0oscjD6/IxnmbcXVTntF+gycBwjoqpGqRhUxqokUpGXkj pBe3ibVDO7SeN5hqzrRR1Aa1O4onANySrHiXGEUbr980Ppq5o2siun34J2Xz7JvYXs0Q xFTNmKhglJWhV/hVFWjKfW6WMzcJry05uUj8ECBCsSyCS0Uy//wJX9gbmJdeRvuBDV8w LDT7JrxxHbjgmXuaFOS57fTDEXKINUHVjIGhhXx6mxSOWMfxRGP7PCg335Zs4CaXnkb3 tzTw== X-Gm-Message-State: AOJu0YyilzGZZ2N087cVZMo3SaP6zVP1BRNzYuSK60sn26XCxIf9KQAP GONUm80ziF5IYA1uiCPQ6RVzhxQBcEJbDQ69qrgEKDO7H851EaacsMJJ+Qq3Vc7Y6H0tZ1uhs31 J X-Received: by 2002:a17:902:e5c8:b0:1db:3592:a6a2 with SMTP id u8-20020a170902e5c800b001db3592a6a2mr844246plf.12.1707978031127; Wed, 14 Feb 2024 22:20:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH v4 07/36] linux-user/arm: Remove qemu_host_page_size from init_guest_commpage Date: Wed, 14 Feb 2024 20:19:49 -1000 Message-Id: <20240215062018.795056-8-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::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 the commpage is not within reserved_va, use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-8-richard.henderson@linaro.org> --- linux-user/elfload.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index a9f1077861..f3f1ab4f69 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -460,6 +460,7 @@ enum { static bool init_guest_commpage(void) { ARMCPU *cpu = ARM_CPU(thread_cpu); + int host_page_size = qemu_real_host_page_size(); abi_ptr commpage; void *want; void *addr; @@ -472,10 +473,12 @@ static bool init_guest_commpage(void) return true; } - commpage = HI_COMMPAGE & -qemu_host_page_size; + commpage = HI_COMMPAGE & -host_page_size; want = g2h_untagged(commpage); - addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + addr = mmap(want, host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + (commpage < reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE), + -1, 0); if (addr == MAP_FAILED) { perror("Allocating guest commpage"); @@ -488,12 +491,12 @@ static bool init_guest_commpage(void) /* Set kernel helper versions; rest of page is 0. */ __put_user(5, (uint32_t *)g2h_untagged(0xffff0ffcu)); - if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, host_page_size, PROT_READ)) { perror("Protecting guest commpage"); exit(EXIT_FAILURE); } - page_set_flags(commpage, commpage | ~qemu_host_page_mask, + page_set_flags(commpage, commpage | (host_page_size - 1), PAGE_READ | PAGE_EXEC | PAGE_VALID); return true; }