From patchwork Wed Jul 5 18:59:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13302671 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 56A0EEB64DA for ; Wed, 5 Jul 2023 19:00:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE9808D0002; Wed, 5 Jul 2023 15:00:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D9A358D0001; Wed, 5 Jul 2023 15:00:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C61348D0002; Wed, 5 Jul 2023 15:00:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B33578D0001 for ; Wed, 5 Jul 2023 15:00:50 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 70615160555 for ; Wed, 5 Jul 2023 19:00:50 +0000 (UTC) X-FDA: 80978475060.11.3E14D4C Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by imf11.hostedemail.com (Postfix) with ESMTP id AA0BC40031 for ; Wed, 5 Jul 2023 19:00:42 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=bBeWNn4Q; spf=pass (imf11.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.216.54 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=1688583643; 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=2aefKDjie+XpptlnykMS4cjK4bXnjT0kz0bBmi0t14U=; b=vcSt1d3iGYFQTzkYW5qJy8FYYiGZLe3LR5CUnC1dchGsyH8smu2Al9158vBQbl1oEynomb T+IAwLkI95AKbL5Sfg4sXhwzsAf18ppEKJK9A2+1bup5y3aPYToy4S87maU0da9D1G1byW kVb+C14039YiHRGbvPd9FC0Dx8RNr6c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688583643; a=rsa-sha256; cv=none; b=iSpAoprc9CdyQ7fr7sa6lQNzsaobmjn7qvxuITOMeb0UUucwRrxiHx0s1KZuw+IWPDUykz GDFEeLWY0kx41s2gH0VgBnw9A+8J65qNp13kJ01WdbGYrbExkAAVnXVT7V2f988Irmx23Q PxTAioU/oq61bo/AQdWq3hhX62P+VGc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=bBeWNn4Q; spf=pass (imf11.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.216.54 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-262ec7b261bso5967a91.3 for ; Wed, 05 Jul 2023 12:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1688583641; x=1691175641; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2aefKDjie+XpptlnykMS4cjK4bXnjT0kz0bBmi0t14U=; b=bBeWNn4QoiUU5WmJ9K/HMlqyJhTj+wXsBHEvd0uGz2MQnsimK3tohAPlu74IT/69YY U7WseCSzhKFXSkVwIpubzNpMLDTJN4v79Fx5s3gsOq1P7dcO2RrtNAb6T867Gd4UoNny 04u0Wz0miji0CvK5q3GwOmrS0V9Fbpna8xqVWSEWEw+BxRGFqickCZHCgI0ncSPfQfxt BgwAWyARnAYVtjU2Hd4O1PADwr78MAV8z4dcbJ6AMs8u0C9xp7QSy3/zWRLuqoXixr9b sz/jlM52lXgAREg7lI63e4ZMxx2LteDx9lHj9eJtFEiBiD2E/+cX+vM3rOdsOKXsIIrh cb8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688583641; x=1691175641; 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=2aefKDjie+XpptlnykMS4cjK4bXnjT0kz0bBmi0t14U=; b=Vi60C3pX3eyBLyzOf5YItAhdLvFdgSDKKHel2Y4uJdWTWNoshPyx3VGb5AR11epjK5 zN42bLA9NgAkrtR4iGFLBFWGk3bFIlkCcc4wTQXPEGXXuqjvWs9BlH2U6mQd9/X9YE0F 6+i0mAbtjKhij3y0FFr5AoI/mV2R7PWUD7ZkreNihmQwOFaxW9n+YZh1slMQDlySCbLQ ZC+w/ZDmLoi5QUJ8gwdX9Y6wcCHkZJTI0yIIGp5MeAq/bfaqJDQJmyhvtlqe/Uy7kfxQ nn6fkl0Pt4XW07gHB8SLfgDBTY41/r57Sv089MCgIuG9Wt9UOm1fFMJso0jF+VLKPyCc 42qg== X-Gm-Message-State: ABy/qLa3gMKRn1dv05V/IWjSxPwsEN9SRAahmsYWBm1jMIgDU4lzw9NX 2RsmBkP6ErG0jUFUjr+mpp/HwQ== X-Google-Smtp-Source: APBJJlGxMtaefB5OYIH9A9tG4cey2jb2WUJlQHyarT2zV+fGHrgpUf+CVv6hEz+oGku5pKoWhIpl7w== X-Received: by 2002:a17:90a:4985:b0:261:1141:b716 with SMTP id d5-20020a17090a498500b002611141b716mr16407697pjh.33.1688583641465; Wed, 05 Jul 2023 12:00:41 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id d7-20020a170902aa8700b001b0358848b0sm19323359plr.161.2023.07.05.12.00.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 12:00:41 -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 Subject: [RESEND PATCH v3 0/2] RISC-V: mm: Make SV48 the default address space Date: Wed, 5 Jul 2023 11:59:40 -0700 Message-ID: <20230705190002.384799-1-charlie@rivosinc.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: AA0BC40031 X-Rspam-User: X-Stat-Signature: sdibmrgxj4cnxs4nrcnuem4pc7romiea X-Rspamd-Server: rspam03 X-HE-Tag: 1688583642-457427 X-HE-Meta: U2FsdGVkX19Yv7mWIq/WJdc7B+E7EAA5XtRYs2NIMW2sYkDzxEQYoe6B3yzeoG6AIUTEXPYyNixxdJUuaDz6kC7Ff4oyWRpKuNwQ2BQ4Q8DxxxeQUWd6Gl5zDA4tX7pDvyH+fr4/ZF2S7AkWynAipUVPVtA7BmlTgqGrcURRNnc4ivE3YltaXbN6sKxfiP0+4Cf8FqSiM67UE+iKEwsx9O3JfYi43Oe/hS9oF3uBWXfMAfwc7RmnF+qIFgl7Ef2tiTNMRALox89Lemas5PAfnfNE/MJyQbl6x1SJqnVSnSJH5c+HKlb6GuOJz1vAaWT5faIHPzfbJK74yNJaUNtDEcu1otvZEc5Gse1URKQfNw3k9s+KfiAFu18z42tb4dNOQfmAPWNp3JFKRBk86YMkeW/6qAJY/TbiUib+4nJRm9DkLnlAkWhZLe6IA9paWZ359qMWtlSwEBGvuCnMlPmB/3r18/maLprfKWNVoo/iqAmPI5xGKibrV03xlc4WBuQWIsSDqqUdLn0OB9t5gXQ4OWGwpONGoYuHJ6djoiYiV/aFc7HUPGRsbY3Cfqp8SuOxYhJQTIMsIdJ8xmt+4AmSEUMOnT4jU3AZgE8nNi6fNxOjxbszXtf4IqBTRx2j/CRcWE65bIOPFRRNaOPO55Bs77E/INDvAmvp0o/0008jj5ysJeaKsbamv5RdNq2CdMQ8HmQqpZp5Q2/INyGugVSgMxaGFFBxegx5fWYVgsF9f3M5XBeFH4URixpuzIx2Zq2Q6ydfGgna+RFKT1+/OjQlnLVl10DUU57xIg4NMNln1DTt/l39BUrcaIMqtVOtBtiLxgDiV2DMtnB5Ft6jgZnFPFgKCOnw+aEpG+5NSl/r9ORodwkYMLHbJfmiC2OFHNDiCJDuTbUIfU2eG+FYeimvrq84iJ9YmGv7TA2/T23u+3mg3GDXVM0XSah36cqzNNCDdnZDKGUsiKrHTz3Zp9x OytVvRbU SaxfHLOD3Dfg+ifJjttBnJnAvpoTSxl92hLhunP8PWsucGziU6NgkhaIawjTYtUg4PCyeI/LO4smSc5p6v8P2efbHlMSDAAdUUrAyiSZ0ajEfKQvBQz43EgFc3ZAo1WIo+ldWkv0psOO7YT64Hrd+fgjPrE0pzsdKVH+5U00gBwXrOxOm7OE5NocbW6IaFuTuWBjETxOkOaiKxpKPlf9HQY7YBlsrHnI9DCmMVhp4QIAESdShOgwNlnbCA5lVP6a5hQY2RguSreXSRU8scbd1505yfZ+WGZ4EBg5FRZRz6EDz+n9xuDYXjcxe7WFtGXnR66X/mXBwD5wgfqLOx8najhuHdiQO3oDfTXhMtYsF895cYDrX8JCtD0hNXxNZioeXa37w 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 sv48 the default address space for mmap as some applications currently depend on this assumption. Also enable users to select desired address space using a non-zero hint address to mmap. Previous kernel changes caused Java and other applications to be broken on sv57 which this patch fixes. 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 | 22 +++++++++ arch/riscv/include/asm/elf.h | 2 +- arch/riscv/include/asm/pgtable.h | 21 ++++++-- arch/riscv/include/asm/processor.h | 34 ++++++++++--- 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 | 49 +++++++++++++++++++ 8 files changed, 139 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