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 1230FEB64DD for ; Thu, 27 Jul 2023 21:29:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E5A06B0075; Thu, 27 Jul 2023 17:29:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 996946B0078; Thu, 27 Jul 2023 17:29:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85DCB6B007B; Thu, 27 Jul 2023 17:29:23 -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 74FE86B0075 for ; Thu, 27 Jul 2023 17:29:23 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 44427B19D0 for ; Thu, 27 Jul 2023 21:29:23 +0000 (UTC) X-FDA: 81058683006.02.70C2153 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf05.hostedemail.com (Postfix) with ESMTP id 5D4A310000B for ; Thu, 27 Jul 2023 21:29:21 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=Bwo2x8zf; dmarc=none; spf=pass (imf05.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.210.176 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=1690493361; 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=ypAMONzQ9lM309vcGdh+Fb16cWv7RYOttEkuLSf+C9Q=; b=TvKb9YOa8ZE6iEAEjYSLJe4V2EkWh0/XHhO780VNKH31Ci86p6exHjsEO+fgCroBGzxvpQ s4SHt0PWsR0AHjiWfDYG1nNVDjSDsKps0KDUDX5mPkfaL9YV0219j5BSi3rEA1RNkq+R+z 2ZaLVWzqIpOqmm2ra8Q/luqm2qmVmYE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=Bwo2x8zf; dmarc=none; spf=pass (imf05.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690493361; a=rsa-sha256; cv=none; b=Rx6lN94ZbDM+QVrRaNl/CKxUKgV27OXBRmekVBcmgWy2DxG8DeLRr98o5N/Mpo8N/1Qi+2 FlBkumZaBbhe0L1OYDku/GcNPnBi/J6u6MoIeMGg7T/ysPKeVC/jp0vqCzsj193T1PmhRn 1snULRTJTsAWQFK+7IhivqlEY4rFfo4= Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-686c06b806cso1132875b3a.2 for ; Thu, 27 Jul 2023 14:29:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1690493360; x=1691098160; 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=ypAMONzQ9lM309vcGdh+Fb16cWv7RYOttEkuLSf+C9Q=; b=Bwo2x8zf58r3/17nU/dEA+lgi98417VBN10q9GpXZ2yX5bWgvClfFlRZrYgWh6vxOe r0mqw4aODhaJ2EjfLMEWChHMJo67QiYL7UuI76V0B5V0sBJqx633/8IdKvZ62MQ2+DUl J6GIo9C/bwVjsIs63nkDd9w15op+eE3bPam4/TK3NShywE+8Xx/75LaHkeodFIhEIwPp is5HGGIxHwP3BUX1Gg8ys2pqCCyqagzNp8TAZ2n3ah5xe/s8AuEUZyERBtbzxBBvh8e7 XW1EoV/f/B6VtHMfKKSgdzL/ZzdtxWPLIZShgMFFsPR1z034QbJg23p3Jo+apDeFjXi3 3MAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690493360; x=1691098160; 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=ypAMONzQ9lM309vcGdh+Fb16cWv7RYOttEkuLSf+C9Q=; b=H9QscRKcwBzlz6Vr0jCSD1x3LdQfW3wd/ppcefBSRpsN1KqsUpS/yWlDiUStmq1klr 7jN9i4XDSqlJ2h4sDufeVNZvLvOWoK0Wg6bMze3P8TVwStd4KVLyOMp695o+1fcxujft hqsU/KJPeROOXMRIjQtLqSi4kD+ofTFmiS/6AX3+alxeptx1fuuS4vqNTScRoayQHV1K bOrf40jK9L9ATXgR0OC+7Ev+7pwadLTQ609cMh2PUzKakEdhMTg+zY3xgdMNumFNWCRk Pk2OUmGtYb8+j9fs4U+6tZFGg2uz5rOZp6bXcIYo1w4hfuCAg/ml3PLOd2f+YkHG/5J3 CnxQ== X-Gm-Message-State: ABy/qLa17RvUNDUzq5dTU7SqO0RwxHtRez/j1douHLGKbQgjUP/w4OLd GSpKmN00Mbbw5OPPkAfjehZbOA== X-Google-Smtp-Source: APBJJlGB3S/nfKRJRrxAvCsM8dZOvIKZplWkk6B2QF6oZQ+44PkE/bkn/usw/Q968tVlGDZwNJliog== X-Received: by 2002:a05:6a20:7351:b0:133:656e:fe1e with SMTP id v17-20020a056a20735100b00133656efe1emr268970pzc.47.1690493360245; Thu, 27 Jul 2023 14:29:20 -0700 (PDT) Received: from ghost ([2601:c0:ca7f:e7c0:e300:c3dd:e089:386]) by smtp.gmail.com with ESMTPSA id b14-20020aa7870e000000b00686c77a2905sm1906083pfo.20.2023.07.27.14.29.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 14:29:20 -0700 (PDT) Date: Thu, 27 Jul 2023 17:29:16 -0400 From: Charlie Jenkins To: Conor Dooley Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.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: Re: [PATCH v7 1/4] RISC-V: mm: Restrict address space for sv39,sv48,sv57 Message-ID: References: <20230726164620.717288-1-charlie@rivosinc.com> <20230726164620.717288-2-charlie@rivosinc.com> <20230727-unruffled-joyride-410fc348ce7b@spud> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230727-unruffled-joyride-410fc348ce7b@spud> X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5D4A310000B X-Stat-Signature: wehibgruc44syefbdm6jh7feuppap15z X-HE-Tag: 1690493361-906973 X-HE-Meta: U2FsdGVkX18BIQhedXsfOvFdDXH+1kZqSwaudqKQCn/AkOZBpAswFjN08/Msvp9qd8i4o1zrgVBKJDIxpisPc0TPgjB1vUdO3K78NVkdgUExKlD1QOkY+OdNQ4ow61H0RZHkNeH351OsVHmTAYPxgbeTdrrbwZQDnr81Xr5ROjqPwq//Wl7LLWbTj12vnKhjoHxE9ePB3Uo+34YOULkvPDqlIhKwASO/KZlYbCr2S2/SvpdWVRMyZrpW/T3RpALlbf0Ug4lsAvhGdfZW7oCyPExGMKCRcrrng26jS0TInp9UIbYiqbckR+aGzzw+p/IhNUPkpwuunhCFSjKmBKO/TapuL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RiSD4OvTOkgockxDEqdSt3knGeapLQFfHMGUKdg== 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: On Thu, Jul 27, 2023 at 01:33:41PM +0100, Conor Dooley wrote: > Hey Charlie, > > On Wed, Jul 26, 2023 at 09:45:55AM -0700, Charlie Jenkins wrote: > > Make sv48 the default address space for mmap as some applications > > currently depend on this assumption. 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, an sv39 address will > > be used. An exception is that if the hint address is 0, then a sv48 > > address will be used. After an address space is completely full, the next > > smallest address space will be used. > > > > Signed-off-by: Charlie Jenkins > > --- > > arch/riscv/include/asm/elf.h | 2 +- > > arch/riscv/include/asm/pgtable.h | 13 ++++++++- > > arch/riscv/include/asm/processor.h | 47 +++++++++++++++++++++++++----- > > 3 files changed, 53 insertions(+), 9 deletions(-) > > > > diff --git a/arch/riscv/include/asm/elf.h b/arch/riscv/include/asm/elf.h > > index c24280774caf..5d3368d5585c 100644 > > --- a/arch/riscv/include/asm/elf.h > > +++ b/arch/riscv/include/asm/elf.h > > @@ -49,7 +49,7 @@ extern bool compat_elf_check_arch(Elf32_Ehdr *hdr); > > * the loader. We need to make sure that it is out of the way of the program > > * that it will "exec", and that there is sufficient room for the brk. > > */ > > -#define ELF_ET_DYN_BASE ((TASK_SIZE / 3) * 2) > > +#define ELF_ET_DYN_BASE ((DEFAULT_MAP_WINDOW / 3) * 2) > > > > #ifdef CONFIG_64BIT > > #ifdef CONFIG_COMPAT > > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h > > index 75970ee2bda2..530f6a171a2b 100644 > > --- a/arch/riscv/include/asm/pgtable.h > > +++ b/arch/riscv/include/asm/pgtable.h > > @@ -63,12 +63,23 @@ > > * position vmemmap directly below the VMALLOC region. > > */ > > #ifdef CONFIG_64BIT > > +#define VA_BITS_SV39 39 > > +#define VA_BITS_SV48 48 > > +#define VA_BITS_SV57 57 > > + > > +#define VA_USER_SV39 (UL(1) << (VA_BITS_SV39 - 1)) > > +#define VA_USER_SV48 (UL(1) << (VA_BITS_SV48 - 1)) > > +#define VA_USER_SV57 (UL(1) << (VA_BITS_SV57 - 1)) > > + > > #define VA_BITS (pgtable_l5_enabled ? \ > > - 57 : (pgtable_l4_enabled ? 48 : 39)) > > + VA_BITS_SV57 : (pgtable_l4_enabled ? VA_BITS_SV48 : VA_BITS_SV39)) > > #else > > #define VA_BITS 32 > > #endif > > Please, at the very least, build test things for rv32 if you are going > to change things in mm: > io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_SV39' > io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_SV39' > io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_SV39' > io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_SV39' > io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_SV39' > io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_SV39' > mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39' > mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39' > mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39' > mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39' > mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39' > mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39' > mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39' > mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39' > mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39' > mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39' > mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39' > mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39' > > Thanks, > Conor. Thanks for that catch, I sent out a new patch to fix that up. There were also some problems with 32-bit compat support that I resolved.