From patchwork Thu Feb 15 06:19:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772853 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681284wre; Wed, 14 Feb 2024 22:24:54 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUYyVMgOoE4JELs1C+UdDTj3ClRKrR2D8Pbuef6lj3YLk229CmnlKcZdUCI1GIk3j8zNeQcKsL4SWdu+OX9tQC6 X-Google-Smtp-Source: AGHT+IEFuxsgPqeSpiyI33+d2Y2n0fbQEFv+Wy5qGaVffJRDkViqQmht8wxtgLHH7rzxUDBPui// X-Received: by 2002:a0c:f58b:0:b0:68f:6be:9f94 with SMTP id k11-20020a0cf58b000000b0068f06be9f94mr762062qvm.12.1707978294777; Wed, 14 Feb 2024 22:24:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978294; cv=none; d=google.com; s=arc-20160816; b=OlhHrljZCXqEB4gm6ehpLLFb40dbdtudyXLEf3KL6/jvVeqYYh8Y4/EwXcyoQITY3O TfIES2Cpq+uLHQOWdwwWXFGkVRg8S1g6n2eF7BOPj0xiH0TsgVcJvJHssKp3IqfSbQuE i1BH9B1uRKJeWohzSbPvXq1/323PQnt5Y1sOOelsVt8/JdxrNY5QxLGRN3ToJI6dNgu9 gjc/xXBdkSaEDLuNSXa1ebete0lAaTB6E7hzfK5VBfLGobKYf34wap3O3clGhg0gyWNj UndkZ2aO896kiijWqM61I2JBgonlOwVch1d2NTuUVmOULwdIxfs7dcAuCZorH2Pc+Y+h shRg== 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=sNAOuzYKunseGhjt30zEM/eN7uq1Wl50v8pWc8K9LWs=; fh=v7v6q89OJlq+NxHejbJ/ziw7VE+fSww09twjGPM2dQM=; b=abH5QsZws4gzIyAHDMDw3udRUH6WIqTptOzAOhqlkyO2p/fvyVSlhiG7Z5HjxnKkuq okO4dvAPYyjyznlRYwiDM0+0C+mt7Do0A2sMaHA3CAhaqfdLwPUx+on/5xXN3YpWVQva zKQR5x51FjsJXTYZ888/ujXlpY33ZSVhPQyKA8Xz8HsjrT6Cl+2krzQqFU0wFM8zcbXz N/Jed14WVEW4oB9t6UUOCM/lr8IS6XI0wxRfIQ/sp2VoPat4F2qNFaCk5GPpVEWunsiy Mm+0650bg5qc6QF+7068wKLlw2VjFZSsfV/F8xpAY7PoKLajMm8/ZwhcBvE56za559ZO 2Ydw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=df1jQ9nn; 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 8-20020a056214202800b0068cdb0ede35si829164qvf.399.2024.02.14.22.24.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:24:54 -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=df1jQ9nn; 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 1raV6j-0002FR-CV; Thu, 15 Feb 2024 01:20: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 1raV6h-0002En-0J for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:27 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6f-0005JP-7v for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:26 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1d94323d547so4406915ad.3 for ; Wed, 14 Feb 2024 22:20:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978024; x=1708582824; 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=sNAOuzYKunseGhjt30zEM/eN7uq1Wl50v8pWc8K9LWs=; b=df1jQ9nn0h3aSO6nnsYW1nF1/3ECGV8+AhgrhIomokIQnflH0KW+3wgGMX/1FEaDl0 pBGf3EPTOKMG6MRauKwpmcnU/la1Sj9ULKATrkyJ3/kle/jTbRx5Hrr1Etir5OZLeqSC /rNdiEAda6G9GqDVCh6gPcSbs7OWkYhkQadRCKRcxiuUQMgic1NYhroNiydabPYwlnZX okwkCg6g1HuYeFRSltY17Us9jy99JOLsOtLeO+6QeX3iAJCVqNPKVdac/KxiQGL0KDUk 48P6qnKhLMZ3NceHPmDEg2J7J5dBYLpuIzZKOjwHOYR11GcKEfnxp7u81b/3cjo9Lhok g+NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978024; x=1708582824; 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=sNAOuzYKunseGhjt30zEM/eN7uq1Wl50v8pWc8K9LWs=; b=DB4cq9lgvR61yl7kIsOWkQCJ07z7T2dHJNaEx+e385rnPb4uyayD7lv9hSQorPstGb +IyEjxc8r+YO8Umje4CtFVq3vpgo874IpmcBxADz5TY5TaGY0r4OrCn1P7gpmK4eb0m+ GqbyNEskx0fGszWjfgqsSS3p2xGhrOCu15GD5cQPexspHP9K9k21n1vN7L44LExah8Wu /g7gBI51ZYh6dV3Qm9NGBYpVYoYWSECMNsdg+jbjhMAZbG53brVLwb9SaYER7sdk+o2E onzyhrjxmoLPFWxsTQ8ytP+HmBw3+3gAYiTyLUBtmDFpWVxynLPIeCmtbT0RO5JXTxiO IXwA== X-Gm-Message-State: AOJu0YzRfPfrZ7zuuW1IBLBALPNNtLaNMBgWmSYwbt2eyLWhnRW1Z93T hpDUFjrHlbR/HgYTLj/0Eqo2dZUzqpTSbfOJxhaD+Mxv3oOYC9b/ELZn6UJU6XEzOhVYDrNubXS 4 X-Received: by 2002:a17:903:18e:b0:1d7:88de:cffa with SMTP id z14-20020a170903018e00b001d788decffamr1095734plg.19.1707978023844; Wed, 14 Feb 2024 22:20:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PATCH v4 02/36] linux-user: Adjust SVr4 NULL page mapping Date: Wed, 14 Feb 2024 20:19:44 -1000 Message-Id: <20240215062018.795056-3-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::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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 TARGET_PAGE_SIZE and MAP_FIXED_NOREPLACE. We really should be attending to this earlier during probe_guest_base, as well as better detection and emulation of various Linux personalities. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-3-richard.henderson@linaro.org> Reviewed-by: Alex Bennée --- linux-user/elfload.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index b8eef893d0..e918a13748 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3912,8 +3912,9 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) and some applications "depend" upon this behavior. Since we do not have the power to recompile these, we emulate the SVr4 behavior. Sigh. */ - target_mmap(0, qemu_host_page_size, PROT_READ | PROT_EXEC, - MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + target_mmap(0, TARGET_PAGE_SIZE, PROT_READ | PROT_EXEC, + MAP_FIXED_NOREPLACE | MAP_PRIVATE | MAP_ANONYMOUS, + -1, 0); } #ifdef TARGET_MIPS info->interp_fp_abi = interp_info.fp_abi;