Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp31218960rwd; Thu, 6 Jul 2023 18:07:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlGgmGfj9Zk1rZHaACFuwb2qu1A5tTS5QMAFsYrzrldtyfO4VRKLbODhBER/W6lq2hmL2xUh X-Received: by 2002:a05:6a00:2304:b0:682:4ef7:9b17 with SMTP id h4-20020a056a00230400b006824ef79b17mr3810425pfh.32.1688692035282; Thu, 06 Jul 2023 18:07:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688692035; cv=none; d=google.com; s=arc-20160816; b=Yt3p6s0GpNDm4Ij6bgJ88MmuYyN8bMEDCzaD/TWkJyFLiL0XxqbKwZcmbgSBEuByfF 0QgGBjEtOfV/e6sWIcgtWYEkAoA1R1zj1JuKO/C+VzQmonKlyoTLOTxN0ihbk9DF8hoe YuzDn4Xt8JL2ql/lhENZBZO6c4Q2NEiGwDBB4mcLSMqtRTKMZorRFQGCBvR/7vdER7m5 rsbmy5esNBzCe89axLY2KPjEf4Vprzr6qF7qnr1W7wCdhptxl2eHd05I8WeY6BEHE7yv iynmZFK788GtdgirLIbt/lYHf7JpfAZL0yMygYH90fp+HBUAVar2iT6Nt4Fh7noWo4HG 3Ifg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=r67n9FyRXMn2NIxHWlUhbk55uKQk9X6Dzb3qD8qYPqE=; fh=fX/5kgox4cOsiwqTLNtM/U/twTkx+WYNjimKArRx7w8=; b=ec2oOz5F5bB3h7tRJPH2Qn1is9vVlKSR9NAYXZNyn/aQaPq9j+H3Vmq/pnOjN36GUf LIWhnVMYu+KKq5nORNl2iWU+BzLqcbWzFYXbHLphuocFiShK7H7IKWqCZiyjVXvNamh4 ZHLP1iZQOMbT5LeefxQzVMX9CzqtdA+CLeAmwPmGrJq5zdV/Jfx92OYqohY/JPugvw9B 57tkjl8/ydOqYv0CBczeztPwQHLLvpf86C8fEHBJG4Kz4FB89YOju6vEx5scJt305Qe7 o6Vz8RY/znwzbMvdrOSaodDRwCQlxwuLN0FYFGs5dhoXSYvtXFEmj/Ysx6sHTKQodssl mLmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jrtc27.com header.s=gmail.jrtc27.user header.b=esjLyRw9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k73-20020a62844c000000b00666b8536d8asi2454251pfd.305.2023.07.06.18.07.00; Thu, 06 Jul 2023 18:07:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@jrtc27.com header.s=gmail.jrtc27.user header.b=esjLyRw9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230362AbjGGAxD (ORCPT + 99 others); Thu, 6 Jul 2023 20:53:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbjGGAxC (ORCPT ); Thu, 6 Jul 2023 20:53:02 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81DF21BDB for ; Thu, 6 Jul 2023 17:53:00 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-313f1085ac2so1277119f8f.1 for ; Thu, 06 Jul 2023 17:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=gmail.jrtc27.user; t=1688691179; x=1691283179; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=r67n9FyRXMn2NIxHWlUhbk55uKQk9X6Dzb3qD8qYPqE=; b=esjLyRw9yG+IBiqgDC3zXqfCcnN/DbqAvEF78hFJzU3GMueXP0gDEe8GTEqkIWVxa3 v5zA190KEwcagvtZcljHSX5zruOtY+4A2hJCW3xQ3kYhJ90qFeRfxiol/gEciWHjfH+V mSyV5wfea0jWsz4PHhQxxB5Beo4CjL8wQp1MdL2w0G7UKtRX2oxrtnD39TtmFgkTupMk WrOKCQbvpbAoBBwRglsxfn/NNxtlufKtOCK89XiZrAuUWobpoJwWEkM6LzWixFkAJGVS MnU63/tx7DAHW6EBB/ZRB4iDp07GMPxP25YJdWEYTFFIVGB2D/It7bRcDQ1rxLN1efdG V0eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688691179; x=1691283179; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r67n9FyRXMn2NIxHWlUhbk55uKQk9X6Dzb3qD8qYPqE=; b=gM1UVYGLrHdI4hX/AZ5W/ib+yX7/EGjyvldCo+26KBfSRYljkWJ1HCcY+vZ8sR4j+G DAIqaxTvZtdpaDKcPe/lCci698wdxbknYt9VqTOjom0wTirn3GDuevqr+MbLKB8u9S0o G2aP9rsNnEo6ACm+A9UShPSfhYklQq+JuYv8jGaHIGcDEf56xoN4GnxRUdBZFMX4t/SW J6Pz4A6hW8VzgnAJs+nkuPWfuYRahyN11MI9pIx/Tx1zABsKBMFC/qHqmZUHr0LaKdXP MjhdxRshxitA+pli7rtaFK7hZRD6zYkSKMR07VBooBrGn4C0ZyYmh1/iqJSROBOKsFXN +ezw== X-Gm-Message-State: ABy/qLaZNOMDb3J+eJrXJexHX/YHM3Jjt7CDmi6dysfys/wgeQymLf+D NDKjaU0OuLIXkH9FQbON3ai60g== X-Received: by 2002:a5d:54d2:0:b0:313:f5f8:a331 with SMTP id x18-20020a5d54d2000000b00313f5f8a331mr2449781wrv.34.1688691178654; Thu, 06 Jul 2023 17:52:58 -0700 (PDT) Received: from smtpclient.apple ([131.111.5.246]) by smtp.gmail.com with ESMTPSA id u15-20020a5d6acf000000b003143b7449ffsm3086566wrw.25.2023.07.06.17.52.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jul 2023 17:52:57 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) Subject: Re: [RESEND PATCH v3 1/2] RISC-V: mm: Restrict address space for sv39,sv48,sv57 From: Jessica Clarke In-Reply-To: Date: Fri, 7 Jul 2023 01:52:47 +0100 Cc: Alexandre Ghiti , linux-riscv , linux-kernel , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , konstantin@linuxfoundation.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Linux-MM , mick@ics.forth.gr Content-Transfer-Encoding: quoted-printable Message-Id: <34483C0C-FA31-41E6-9263-1F9A08CEBE2C@jrtc27.com> References: <20230705190002.384799-1-charlie@rivosinc.com> <20230705190002.384799-2-charlie@rivosinc.com> <2084462d-b11d-7a48-3049-6bafbe81e7b4@ghiti.fr> To: Charlie Jenkins X-Mailer: Apple Mail (2.3731.600.7) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7 Jul 2023, at 00:56, Charlie Jenkins wrote: >=20 > On Thu, Jul 06, 2023 at 11:11:37AM +0200, Alexandre Ghiti wrote: >> Hi Charlie, >>=20 >>=20 >> On 05/07/2023 20:59, Charlie Jenkins wrote: >>> Make sv48 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. >>=20 >>=20 >> What do you mean in the last sentence above? >>=20 > Applications like Java and Go broke when sv57 was implemented because > they shove bits into the upper space of pointers. However riscv = enforces > that all of the upper bits in the virtual address are equal to the = most=20 > significant bit. "Temporary" may not have been the best word, but this = change=20 > would be irrelevant if application developers were following this = rule, if I > am understanding this requirement correctly. What this means to me is > that riscv hardware is not guaranteed to not discard the bits in the = virtual=20 > address that are not used in paging. RISC-V guarantees that it will not discard the bits*. Java and Go = aren=E2=80=99t actually dereferencing the pointers with their own metadata in the top bits (doing so would require a pointer masking extension, like how Arm has TBI), they=E2=80=99re just temporarily storing it there, assuming = they=E2=80=99re not significant bits, then masking out and re-canonicalising the address prior to dereferencing. Which breaks, not because the hardware is looking at the higher bits (otherwise you could never use Sv57 for such applications even if you kept your addresses < 2^47), but because the chosen addresses have those high bits as significant. * A page fault is guaranteed if the address isn=E2=80=99t sign-extended Jess