From patchwork Fri Jul 14 16:54:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13313851 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 BBF62C001DE for ; Fri, 14 Jul 2023 16:55:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3824A900012; Fri, 14 Jul 2023 12:55:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 33255900006; Fri, 14 Jul 2023 12:55:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D3E1900012; Fri, 14 Jul 2023 12:55:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0E0D7900006 for ; Fri, 14 Jul 2023 12:55:59 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CC2EFA02D0 for ; Fri, 14 Jul 2023 16:55:58 +0000 (UTC) X-FDA: 81010819596.29.F3A20D7 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf01.hostedemail.com (Postfix) with ESMTP id 820C040012 for ; Fri, 14 Jul 2023 16:55:56 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=DcSFI3El; spf=pass (imf01.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689353756; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=u86Vccu0MjIpV1lk8gugdD4Hj3xwuyAB97KWj8HD83Y=; b=Xro38EOlK3oA4fTbJeJjjfyKn56kXtaGqZQ8mW98CisR0L7yOeeZ4+cgsYtinuE4UaJi4u 6PHg5b27/UdFDWzqc/IzW9Pp2YXgtXmq3sKcqb5/DmaqYorQMXcFA6LMr3xRzTCuskTjAR Btz8+BGo8u4HKnPyCkuuF8ea1kjPA9Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689353756; a=rsa-sha256; cv=none; b=Q4y3DaYYBRmo2eY6dYggGE5hkDJS8x4zvgPmn4+aRNBQAina2opPg56AedIr3+COjwiA2M +r6EH+rbuGMxFlDUCqPvfVxD4t0Bf42d/JiQUV/g/UK1zpn/ugjS0S6q3ofuOMZNyJtKEu G28hwbVe7EvHjh3UngfxKkrTYzvdUOA= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=DcSFI3El; spf=pass (imf01.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-55b66ca1c80so1266025a12.0 for ; Fri, 14 Jul 2023 09:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1689353755; x=1689958555; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=u86Vccu0MjIpV1lk8gugdD4Hj3xwuyAB97KWj8HD83Y=; b=DcSFI3El+kQ7LUhr7I9CNLzPEPRrFlKiPN0ROzCgA+1cx5EXlSbbSIgcwQR813I1L+ 3uvoKmq2u01aQ1HX/F+kykKZKylNNs2J3TaYWmJfiC83cJEInBDz4UCDaT5YwZ28E5St H4SWKBVBsD2CZuKTjWB7EmNUDRNO0LJL6JSIOLpEXHgP2Y0TUROAagLq2gTnozEMMH92 2lDqhD+T+AR9CiYZ0dScRh/n98YBFJOdLfHH+j2EkhhSk32EX6cf10DVILFLv9++ETt4 wXVVrJ8jvwSLjrVIHuumet2G6Uj24MK9BtcXy0zdk2NFm15eYGcfgjfjwSJyXAwIkWWZ Nr3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689353755; x=1689958555; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=u86Vccu0MjIpV1lk8gugdD4Hj3xwuyAB97KWj8HD83Y=; b=SzqtKuOkO4Rl/kC7Ku8jR87TtGfatsNf8RrAUX7mm0SfA7kmWwTKq/+0x2qVOWZPNm WBqCS0oUFo94pNY7U+WwaSaa8dw9irJ+MHl80LmcSgMFjcNWdz4rrX+V2pOdssOQtZJI vIkplzKUm29G2HIbI8DRIdwp7HQ/bFLcQBPyn/w7zlBoKZGmXlJApy5CYKVJKt/w+qZ9 o9O4JzYifwxAyvMwwPf+qTtueJLwdHuIZ9ze0MxedRmBHQxwPwADhgvWiN53lwU+Jh31 alb/RFoXEEhKSlHh6UG8TlbnWVLq4RQP/XnHEgp+Rt0pq1uvJ5O+1Yr2+AEsxITxZGJa imyw== X-Gm-Message-State: ABy/qLb58uOdTO1vVF7FMncf0wzgHGoUk6rucLIXHCh+vjLxbCtfv+KQ 9M/EGMvVre2mp+r9UYzwEanpYA== X-Google-Smtp-Source: APBJJlGGxbl6qGLIF7f2rYJjwvRaITLsmSOC7pkB9qZSGRIv+YlRfSsJaker/tHyOogKYwVG0JmwNg== X-Received: by 2002:a17:903:2288:b0:1b8:af85:e959 with SMTP id b8-20020a170903228800b001b8af85e959mr4250415plh.53.1689353755192; Fri, 14 Jul 2023 09:55:55 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id s8-20020a170902b18800b001b694140d96sm8008081plr.170.2023.07.14.09.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 09:55:54 -0700 (PDT) From: Charlie Jenkins To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: charlie@rivosinc.com, conor@kernel.org, paul.walmsley@sifive.com, palmer@rivosinc.com, aou@eecs.berkeley.edu, anup@brainfault.org, konstantin@linuxfoundation.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, mick@ics.forth.gr, jrtc27@jrtc27.com, rdunlap@infradead.org, alexghiti@rivosinc.com Subject: [PATCH v6 0/4] RISC-V: mm: Make SV48 the default address space Date: Fri, 14 Jul 2023 09:54:48 -0700 Message-ID: <20230714165508.94561-1-charlie@rivosinc.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Stat-Signature: nhk4191w6b9if63go7nedp13un1ctfur X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 820C040012 X-Rspam-User: X-HE-Tag: 1689353756-599500 X-HE-Meta: U2FsdGVkX1/WXs8rOs54LF66IH/SE2cBQceBc5OjMtZgEADYypZ4vDRVEA9t4WzgAJxsl3dEE/AaUOvWPsuD9qsT62giO28Nvbvsh77v4PsyZFtY6/QKc7fseWqoqm1M4o7ejxU0fWQ5dZLNNPOGG+V0bNw2EH4OOrCQRaaeAQNVISWwTtqKkgD9JxGSi+1yXBWDLE/6fbt4poyOHdAfHcv5Vpsi3tL4kmlb3EkvzEmDfQ+kGBNS3ymgrSTJ+TH6X8H4QIM9Z6h4aWCtH4Izrk/3DRHt40uuW60J+tg5FiX4L0hkIfp+XC1tjzmVFKs+/BpB2/ZD1o56I8847OkyVDXKWYmp7vf9wGE52WTJBqhOVvOdDFkQjXywOsLb0B3ZNUtywqCUNiE42SkhtzqFiMCiaNC2qzZsO7dMsLuu51SRoe18hJZSwXxoKph2Kt+mf0znIsqI00q0RrfbnxmB26sUtx70Dffl//TmLPSrfPZNR7oyN/K3hW/u0kKBRlbD9wh6fbOPrgIE4lyr8ZSdm1GlxKgAA5jpMByd5G7DzLopXDJTUH7jDoL842touqBkqZdL+pHnEwn7tHhUsYEqw9G5S+/7pg+x1OfKkAp3UupUsQyFZY6/ikM96jJe96UtuG2fEWRi3HF+ra61/lsHOv1Hgua0yRE5Mbi1gWv6fmvofEdjmHzFV+td3Nt6qxxrl2e6Vvb5JkNy2JsweEnLjbab7zO46vEVXwzEtrucB6sCJd609vQjGj4oalVXLkMllXq0w5zfgn245whDUcAsgpk31QrT/TXca8xFqfWPXGK5eh6V1X6/weHcOfNr1/laMyt0P8mmfp1f3XETcFgxNP4DbL2yDYtFeyHfcuOes2sigWbPDhU36me565CpQJ3AO/aRcQ4eudQ7biTYXrQ5Z1pX6ZakaMNh4CqeNi1+fnG9BuwM6oJXavK+KnRMSTHb3i/q40lAjVMEN5E6yru zE+w9LiC 3dZtLk0x9as08/7EBRMM/Tg+/7hwjDtBxg2K8mwo9ASQmCH0EcEwwzir5nRDFJevuEBAGpJ8opNx7M6zCiYZ50Pu1yXQCxwNEWRajUGnlz/OovPrC6laBp2lmX94iOodKgnnjgJQ/tS+Me++2DzVI6aK4zLkCJVV5Z4iezojFW52SLaCFBDi0KFGz7GFybBJygzDQdYEfzXlbPr4bWUyjS6IT0q7A/H9HYqmSgpRzft1nz/F584FEsg9CyDDfH+0i0rYTTln9QoAfAr6WbXXk56MVMExI5iJ4DqdAbytlzH3S0gIuXU5OSxTKlz0LzN4r4gIYX4p5+234gtxorZf910O+9CZ6JN6XzDcRQHdjEIbwa2UWubrxl/VBIKV31zVblVJbnd8/yeurFB0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000053, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Make sv48 the default address space for mmap as some applications currently depend on this assumption. Users can now select a desired address space using a non-zero hint address to mmap. Previously, requesting the default address space from mmap by passing zero as the hint address would result in using the largest address space possible. Some applications depend on empty bits in the virtual address space, like Go and Java, so this patch provides more flexibility for application developers. -Charlie --- v6: - Rebase onto the correct base v5: - Minor wording change in documentation - Change some parenthesis in arch_get_mmap_ macros - Added case for addr==0 in arch_get_mmap_ because without this, programs would crash if RLIMIT_STACK was modified before executing the program. This was tested using the libhugetlbfs tests. v4: - Split testcases/document patch into test cases, in-code documentation, and formal documentation patches - Modified the mmap_base macro to be more legible and better represent memory layout - Fixed documentation to better reflect the implmentation - Renamed DEFAULT_VA_BITS to MMAP_VA_BITS - Added additional test case for rlimit changes --- Charlie Jenkins (4): RISC-V: mm: Restrict address space for sv39,sv48,sv57 RISC-V: mm: Add tests for RISC-V mm RISC-V: mm: Update pgtable comment documentation RISC-V: mm: Document mmap changes Documentation/riscv/vm-layout.rst | 22 +++ arch/riscv/include/asm/elf.h | 2 +- arch/riscv/include/asm/pgtable.h | 20 ++- arch/riscv/include/asm/processor.h | 46 +++++- tools/testing/selftests/riscv/Makefile | 2 +- tools/testing/selftests/riscv/mm/.gitignore | 1 + tools/testing/selftests/riscv/mm/Makefile | 21 +++ .../selftests/riscv/mm/testcases/mmap.c | 133 ++++++++++++++++++ 8 files changed, 234 insertions(+), 13 deletions(-) create mode 100644 tools/testing/selftests/riscv/mm/.gitignore create mode 100644 tools/testing/selftests/riscv/mm/Makefile create mode 100644 tools/testing/selftests/riscv/mm/testcases/mmap.c