From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BB25C4829B for ; Mon, 12 Feb 2024 02:43:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ACF716B0074; Sun, 11 Feb 2024 21:43:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A586B6B0075; Sun, 11 Feb 2024 21:43:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D2B36B0078; Sun, 11 Feb 2024 21:43:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 759BC6B0074 for ; Sun, 11 Feb 2024 21:43:52 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 44AB0140876 for ; Mon, 12 Feb 2024 02:43:52 +0000 (UTC) X-FDA: 81781606704.18.A4FCE1F Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf26.hostedemail.com (Postfix) with ESMTP id 5378614000B for ; Mon, 12 Feb 2024 02:43:50 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ez3iT5+A; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of bagasdotme@gmail.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=bagasdotme@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707705830; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=RdlET1RbN9Q5CFRccyLJ2v5AE+ycfABA4EBCvkdvcHU=; b=xnzJGT3h+hpsJqNGCj99FBk35J933vUNRrRZZVtVt/dCIjig3+eo9spgdFVhfCCWtU08D8 2BqHlWY7eRHxX/8RveZ8hJ/HYFQLjijOr9me74z53tqVTtQZz0oip2pvWlBYf/oRYP0LiN tEt7zE4N4LIotP+WLaS55E4B0EJPZT8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ez3iT5+A; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of bagasdotme@gmail.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=bagasdotme@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707705830; a=rsa-sha256; cv=none; b=zkirggBD+Ng4pqPZWEYJ77RhwDe1irIpnJhAiK4aRI+z7zweV6x5W0F9QoC8hgStPmquFp xyPlqnY9FuzvjGrGPBpfhX26JQvdLoc7sZVlGGS0fjfFT55g3ekTP9v5SKM2Hgf+43w0QP 3BSVkcl3NClKuN8MUh4L971ab6IE1jw= Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-290da27f597so1409285a91.2 for ; Sun, 11 Feb 2024 18:43:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707705829; x=1708310629; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=RdlET1RbN9Q5CFRccyLJ2v5AE+ycfABA4EBCvkdvcHU=; b=ez3iT5+A/SIdpWTKYQEA7NK4RSV8sOGyU/1q1hcz9W0pJ5sD+7gsp9EcihoNkU7/kO sRAsXu4X512cjf16t1AGVhzrw3XKNr9mk7mYY2fln6XOBKNAiEVELMyboUisyqnWO5AL 6RSUC3ed4dZRdTHVLnDTsNBrn7tnY4ZGvM+VqSK4HbLPfsLZ4yxaas5+fTCKyiyDdx0A AXZekcoUWP970Obmqoq7vRgGxT6LzSibJ+P0GNYIVGOAI7WCiNcN83RIkKWgXyQUNUIO 1Gxr9Dz8KLvYCbnhm5cUcekSiUYzcWtLAMFWqPDn/B16K8zE7mYr1DH8BI0Wa7i2Wzu6 tOnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707705829; x=1708310629; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=RdlET1RbN9Q5CFRccyLJ2v5AE+ycfABA4EBCvkdvcHU=; b=BFsCNE3c6hzqtyqxa5C/jSXwtFyNEqE8N5vvzvtEdf58hyryN/DW72G4Yk7OvYc9qm lxa7g/YerLCRGJs36LIAKTF16VDV+RexpKpH7pA6PsGK4PK9YTXdG1Kr+LZJLn3xmIKX ybhFyV9uZ58Qd6H3IMCmoDOlmwxCcdE4X8yGAdaQjYa/5XMwJV0cxG3S2Uk324M7S9VJ glWtKGDeQXciUPQTL/k8J6i1VhiAxWiXoRlHbbhtGkRMbO4nBdX4g64/LHLxaiA7rW84 eefAZAX5KGJYE7q+D7Vni0RpP1Fa0ehFIKcN4HVjk2k4Ypv6JBJg0shXhdbkxJpHdHeD gCUg== X-Forwarded-Encrypted: i=1; AJvYcCWpJ4M4TPcd2beJK7l7yZp6zC2/YQZ4rmiG0tEttLjNLb26/Qz313EJAiYO/6iOjVSql2PvX4MleoJ5cltlOTENSI4= X-Gm-Message-State: AOJu0YzOCZx3ztP5wq3kqA9e1oHLpXrYrjg9lvR2BmE7reNE05TvZbtt Gx46s5RW5t+WrrBsEbitsphpdLPdsg5S6aAkObIfEkZIyK1FCb3x X-Google-Smtp-Source: AGHT+IEF/ksMVvmRQXrVf8Nyul7fY+wdWksXuKzAB3BucZ+oiXMqQRELoEzYhm/InaSW9VUonhLveg== X-Received: by 2002:a17:90b:46d0:b0:296:4844:78c6 with SMTP id jx16-20020a17090b46d000b00296484478c6mr2759899pjb.7.1707705828998; Sun, 11 Feb 2024 18:43:48 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX+hfIOkuMqXYcMEWK/44OdMBMYTTDmRhScnzlsgB0xTfZJrM6kSeBdEN7xzp26piksh8udEyd28trV5czFNw8AniP8vq87VzZeraWaKFSHfVc0oBW2CUyg1y/hZ77tAQJ2IIikP50BMd7rdIuQbTGzihS4yAJZu2UbQJfbD7NmMnDIgAgO2ifZeYq55+YLGppRrpmxqKbOsbunAUyUREt6HDGAtvjBitBBbxB2pGss7l2O9VYo+eaur1M3p5TFtiwSZ5DISIcRA/q23WaYbzd5fKapvJod/msxKeD6bXrGPWe2AbotstBa/p5E Received: from archie.me ([103.131.18.64]) by smtp.gmail.com with ESMTPSA id q13-20020a170902c74d00b001d8d04a4fa8sm4899330plq.300.2024.02.11.18.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 18:43:48 -0800 (PST) Received: by archie.me (Postfix, from userid 1000) id 5C6E618468562; Mon, 12 Feb 2024 09:43:42 +0700 (WIB) Date: Mon, 12 Feb 2024 09:43:41 +0700 From: Bagas Sanjaya To: hapter@420blaze.it, mingo@redhat.com Cc: tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, Andi Kleen , Andrew Morton , Linux Kernel Mailing List , Linux Memory Management List Subject: Re: arch/x86/kernel/sys_x86_64.c: rationale for 0x40000000 for MAP_32BIT's start address? Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2c971D/B6+W0Fc9t" Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5378614000B X-Stat-Signature: rhseewy8rjedya9h84pn5acfc5f5mzh1 X-H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GuALrOPhdqUfgMoDAZGE3jaaRtm6iClIf00IBpL9kpsHxG+n83DQ2BznqT5CdQip51NIs2I4v8EYDTiW/ucVeLIuSIDjx1pDDGK9UA2aJ/fPwq+h8JozEdeg4G7rYvKF+NA+0ht0FRrT3rI7D9VvU/u4QEtDvigFgKR1tIlt6aMT6ix9OQ9La3HvN48h28wKE6mbomWEYWyJpTQOYPzwKQdg4tY1cnMTxi1S1bfMwCtL6lV19IJkMwAvgRCLD5Z7FxGHGdbh58VHhpfWIudwLwnwmgIU+sVHHXoinWkeP7Shi68rtojxbb1OyxSRYhuRnN2EKeh7TQJkZY6EndY6AVQRBRrUF0stnYiuSaovAIadcO317dIwc8/uhM39Ew9aAo8qjyvNgW21r8CtJBGa2MwA1IjrvmSLL8+Bv6YjenBVHbTfTxylDbnhAs7w8YG7+Z5sNGvbzMnQOFAt32AOkRoITgQXbNdZvHHiU45DljORl/5lVK+NHobF8AmZ9pgZf+qNXXNT/k7tdXrCRBTy0+PPVwHHrtKGg2g2PS76FtH X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: --2c971D/B6+W0Fc9t Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Feb 11, 2024 at 08:52:45AM +0000, hapter@420blaze.it wrote: > I've found that passing in MAP_32BIT for mmap() will always return an > address above 0x40000000. The problem seems to lie in =46rom one gigabyte up? > arch/x86/kernek/sys_x86_64.c, where the following comment is the only thi= ng > close to a hint(Line 100): >=20 > /* This is usually used needed to map code in small > model, so it needs to be in the first 31bit. Limit > it to that. This means we need to move the > unmapped base down for this case. This can give > conflicts with the heap, but we assume that glibc > malloc knows how to fall back to mmap. Give it 1GB > of playground for now. -AK */ >=20 > Unfortunately this does not supply a rationale for starting from 0x400000= 00, > which seems very arbitrary, and the git commit has been there since the > beginning of time (i.e. as far the the git history goes), so the git blame > has not helped much to clarify it. I was also not able to find who "AK" w= as. That was from commit 717db2f9f36805 ("[PATCH] x86-64 updates for 2.5.54") in tglx/history.git repo [1], authored by Andi Kleen. Cc'ing him. >=20 > I have found another operating system that provides MAP_32BIT, FreeBSD, to > not exhibit the same behavior and not cause any execution problems for RWX > pages allocated below 0x40000000, so it does not seem a technical rationa= le > exists either. >=20 > mmap will happily return 0x10000 (which seems like the lowest address the > kernel will map when you supply it as a hint, so I do not see any reason = not > to start the find from 0x10000, or something that isn't as big as > 0x40000000, which is big enough to impose a significant handicap for > applications using MAP_32BIT (e.g. JITs that want to use CALL rel32 at all > times). >=20 Confused... --=20 An old man doll... just what I always wanted! - Clara --2c971D/B6+W0Fc9t Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSSYQ6Cy7oyFNCHrUH2uYlJVVFOowUCZcmF2QAKCRD2uYlJVVFO o7p7AQDotZUk2+8w94lDD76kOjenqqOj0C1G768ZPVy0xcjdlwD/SwXPgbpE2tgz 1CQF7SxKvFNIC6H0tcmFdmQYHF/9UA4= =eg30 -----END PGP SIGNATURE----- --2c971D/B6+W0Fc9t--