From patchwork Mon Jun 26 18:36:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13293340 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 53A99EB64D7 for ; Mon, 26 Jun 2023 18:41:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1A738D0003; Mon, 26 Jun 2023 14:41:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AA31B8D0001; Mon, 26 Jun 2023 14:41:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91D618D0003; Mon, 26 Jun 2023 14:41:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7D5AA8D0001 for ; Mon, 26 Jun 2023 14:41:55 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4B20AAFF87 for ; Mon, 26 Jun 2023 18:41:55 +0000 (UTC) X-FDA: 80945768190.20.2FF629C Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf11.hostedemail.com (Postfix) with ESMTP id 6FD484000F for ; Mon, 26 Jun 2023 18:41:53 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=iOnzyINl; dmarc=none; spf=pass (imf11.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687804913; a=rsa-sha256; cv=none; b=gsXNAbcxrw2b5lB6CVPcZymjYbEQxWlPzXReX/ljD+nJxFtLevhi/jHP2gZPpvLo4Y5Y0a FC16dhm8LPsy25ujEambpztSEW+ltP0+UQtB3usVq5SYewPyNq0hk3nbcnrL1Z5Fq/mSly 7QB4ZF8T6KKbi5yJevMVqZjDEjWjMNs= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=iOnzyINl; dmarc=none; spf=pass (imf11.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687804913; 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=Mc8gTI3W4RW6dHKji0wpJv9Z8xook1q3V9GncqmxBNs=; b=vVyO744tdvitKm4XIJ8Buo5r4gShwuxS23XvlUASKHiYr1+CEbzcCusVQAaM4nn6XPPxy2 ONBm9eSaGcPOb06R8ncDnxYOj3sFYjfD/LFg2vDVQEva5rQL8Tv/7qof5Kc+g+gCJOTFJG 3WFhgjt13nnJv+Q/abS85nmEU+iJfwE= Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1b7fdc66e30so7604605ad.2 for ; Mon, 26 Jun 2023 11:41:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1687804912; x=1690396912; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Mc8gTI3W4RW6dHKji0wpJv9Z8xook1q3V9GncqmxBNs=; b=iOnzyINlILniQP2HRPivDFLMjVUVk2QQghS1NdKbwT8rRo+aVuMr+sfhItnycltrNm +n6dJOvm68rZFp2EiiEnVADw/GZuH7oKvqN5Sq39xJfzgSMC4/5mT/TAx3BStqepAQXQ Sg4Dn+fhfxgYQwc18AdfeP92dYRiA++NH4Fi85nAY0RVNSlIGXaoGVPilka2ylzoQiOL QFv51RKurWg4uRW70Xv1lzgmSMw2Ip/+GK4UUgD+U9SZlbfDzwzEPmEvWFZ81IT+N/0w PNWNpwtVOFrYPj4+2nZkY4bDzIDrdYhdHQSuBH1u4hj92twmPTY8PNZWxTnXDJ34Xi9t MkkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687804912; x=1690396912; 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=Mc8gTI3W4RW6dHKji0wpJv9Z8xook1q3V9GncqmxBNs=; b=bQxd7Cik5TQBh4PgoBwyJ+WxcLMLkEvvUb/7Wmr56amnmIhtD+4AhYRZ5Iyi/ObRTT 9kCFpti5iRNK/kbK+gioUD5cTuazdC4vy9WZnwZlAcKlNK8Am08sHeH7VwNjl4jMVm1Q th4CCo//GFNgheDN5OfLWgyARJlkI+p1DGgqN7ryaT95uczOfXY0ZFFF52AsTPcgAr4k HlEJ7xsP/81pbDyiGBwLWVYbYewhuw3oLLZekZiQtUpgBnkO1cchHWWVebZ0nHcx3oRf vIUtrwghxCEIPWgvhTdm7eBZh7jsSj4OEjdVSvyRnRJkPKtyBNIj9xvbKlfhmZevCaDr 9owQ== X-Gm-Message-State: AC+VfDyrxA5tjt/XX1sisKN+gPZWCuj2P2rSYZQ4n6do/yr9oir/CVVG S+x4NXRZnm9b1iyfOXuchCMsoQ== X-Google-Smtp-Source: ACHHUZ6kF7UCHGB/S7z47aVb3jHXMmBM7Gkc9O6kvyrBL6waC3X7eaZQjrosczNmx+jqkRnxb00mxg== X-Received: by 2002:a17:902:be09:b0:1b3:d6c8:7008 with SMTP id r9-20020a170902be0900b001b3d6c87008mr3314468pls.57.1687804912000; Mon, 26 Jun 2023 11:41:52 -0700 (PDT) Received: from ghost.hq.rivosinc.com ([50.221.140.188]) by smtp.gmail.com with ESMTPSA id y6-20020a1709029b8600b001b682336f66sm4499842plp.55.2023.06.26.11.41.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 11:41:51 -0700 (PDT) From: Charlie Jenkins To: charlie@rivosinc.com Cc: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Eric Biederman , Kees Cook , Shuah Khan , Alexandre Ghiti , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Conor Dooley , Greentime Hu , Zong Li , Andrew Morton , Guo Ren , Andrew Jones , Sergey Matyukevich , David Hildenbrand , Mayuresh Chitale , Qinglin Pan , Anshuman Khandual , Huacai Chen , Brian Cain , "Russell King (Oracle)" , Geert Uytterhoeven , Stafford Horne , Kefeng Wang , Anup Patel , Sunil V L , Evan Green , Guillaume Tucker , Mark Brown , Nick Desaulniers , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-riscv@lists.infradead.org (open list:RISC-V ARCHITECTURE), linux-kernel@vger.kernel.org (open list), linux-mm@kvack.org (open list:EXEC & BINFMT API), linux-kselftest@vger.kernel.org (open list:KERNEL SELFTEST FRAMEWORK) Subject: [PATCH 0/2] Restrict address space for sv39,sv48,sv57 Date: Mon, 26 Jun 2023 11:36:02 -0700 Message-Id: <20230626183611.40479-1-charlie@rivosinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 6FD484000F X-Stat-Signature: qztyjyk3o9o6r5yf3h5kneddpnp4j54f X-HE-Tag: 1687804913-661589 X-HE-Meta: U2FsdGVkX194qJj0Oe7D2x4WHoza4YY7ZWohnsvaCzNdBYihnt4rhY/bLcoeMM9umxDpmFTUZc4W4dktv1nb8KXbweAXvi9WGfW2zbQrQkxGj/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ZHOQuAwGGSDWFjeV1mGLVyDn9AQ1Ec/1HL4xFRoAWg1aow/29REw3MgHJfh2D2ZTbn+BAlGS3+rYJ6Z9jtBfDle0yCI+jjnw5X2aDp82cwCKR5JppNXep0wSrng6aunojlKIH8y8iczu1exyj/sf0MjkxqtRin2zNBUOom11UFjcJJZM4KOTNjHj0JVMuZ6hAAdR223kWbSQM3Jwmxoyzgz+ADQ/kcD3JN9hC6mXtln1yTbV/9Ls93rMogXlffKE5eIVUp2Lw== 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: Make sv39 the default address space for mmap as some applications currently depend on this assumption. The RISC-V specification enforces that bits outside of the virtual address range are not used, so restricting the size of the default address space as such should be temporary. A hint address passed to mmap will cause the largest address space that fits entirely into the hint to be used. If the hint is less than or equal to 1<<38, a 39-bit address will be used. After an address space is completely full, the next smallest address space will be used. Documentation is also added to the RISC-V virtual memory section to explain these changes. Charlie Jenkins (2): RISC-V: mm: Restrict address space for sv39,sv48,sv57 RISC-V: mm: Update documentation and include test Documentation/riscv/vm-layout.rst | 20 ++++++++ arch/riscv/include/asm/elf.h | 2 +- arch/riscv/include/asm/pgtable.h | 21 ++++++-- arch/riscv/include/asm/processor.h | 41 +++++++++++++--- tools/testing/selftests/riscv/Makefile | 2 +- tools/testing/selftests/riscv/mm/Makefile | 22 +++++++++ .../selftests/riscv/mm/testcases/mmap.c | 49 +++++++++++++++++++ 7 files changed, 144 insertions(+), 13 deletions(-) create mode 100644 tools/testing/selftests/riscv/mm/Makefile create mode 100644 tools/testing/selftests/riscv/mm/testcases/mmap.c base-commit: eef509789cecdce895020682192d32e8bac790e8