Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4110238rwo; Tue, 25 Jul 2023 00:17:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlGhldDFTQ7e4F/Knfp0hJZXbCgJgXpkm21uuUI8TdHIH7V00FGKNxJPxlxaJzeGIa5o9uMQ X-Received: by 2002:a17:906:1c5:b0:988:fb2f:274e with SMTP id 5-20020a17090601c500b00988fb2f274emr11220642ejj.27.1690269466204; Tue, 25 Jul 2023 00:17:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690269466; cv=none; d=google.com; s=arc-20160816; b=pKIYFCjw7qBd+QHGTOtKppvIeeNi36bG23Yn/Z/3ba6zGj1p3ARxnC0VlkvTjapNrg X24KX/CHkQZx2IudmmLamF3HDtCPmv8ru2dxc/t5FrRI83WJymOYTKeXZhKO6pkulTYO ztTiKRZFkhZ3r978DTTWmT8mfqjgIvB8e4O8SSnIo0BQug70OONy0tJG33ypEqo/6u1v Q06qKR+rJb/E5t1pvN6N1Q6z+hKCsbJbRWEvICPBv36G1o7DV2b9sxTHrlpN8tQ8H08M +P8vID5/KdbQgWpx8N7V/ffwlf164uMwMV/2j8uteO/RPzFocMDSxRbqRppWm2a1xuLw 5lkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Nemwt6odA/W6LAzXazKdN7X8FI/tGQtoSYxpSs1lg8c=; fh=KO4MSXtUzCeT3i1C3GsodiBtjPkLqMipVv87gFSZoEc=; b=WbWxug2u8wQBEEWtCdjq8z6fMeQohF3vtjk/JHVNgC+Kl13ELMGJxLfYGNmEyvoHu8 kMPpqlnRPZ5UuCgP/cmdcoUqxDyYVFQGuCrOEH4ZJoyrc0waxblFgEJgPFrzQKZ+n//j /VcxdbBomChYSgbvlGcrzbZq/6/0Paldqy+i8hVBgtvTRxiUhvMTFFFSyq8U7HWctwT2 N+fza3GcgxAvpS9xXMTm/Yb23XigTwsS49iB3wTmR1YVPg2GsZu9sGuKWKGSHC8DTuAQ Y2Q/CZpQwoJucPiCCZ1GqymBZ/tl6YjqFrOOZqwYehu27e6p1z1IvZKnY4GQt3VRXJq8 Utig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=zWJ7gNOe; 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 h3-20020a1709063c0300b0098dfb10f3a6si6916711ejg.107.2023.07.25.00.17.21; Tue, 25 Jul 2023 00:17:46 -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=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=zWJ7gNOe; 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 S231526AbjGYHIS (ORCPT + 99 others); Tue, 25 Jul 2023 03:08:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230405AbjGYHIP (ORCPT ); Tue, 25 Jul 2023 03:08:15 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B83FBF for ; Tue, 25 Jul 2023 00:08:14 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-316feb137a7so4703563f8f.1 for ; Tue, 25 Jul 2023 00:08:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1690268893; x=1690873693; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Nemwt6odA/W6LAzXazKdN7X8FI/tGQtoSYxpSs1lg8c=; b=zWJ7gNOev2UK2JbtjZgRfPfqW0WArnCMDMvfXl8Yonl2R6MPL5/7DFkC3BGCcw82W2 mGd/ShG6plEokjzXzt0/QOJoQIFzFH1z0dKLOgoWmY7IhSZTFc17xbJlvxGT0JbgFFTW r3wE232x+WJwcKlBZQ0GCrV1aj18OwIdCqeqOAnmEScGNlaU6viHri7P+FFW/cF0JE8Y l0N8flrR7Ko4pQzV1VwUlD4Ba2S5wBckSGhOTyrZ69xiBIUcMQPnBt3A2ATtNV+IMoa0 SBveIjNOrybY5vtXxx9R3+VLB0d8GC4UdmjVuQfL0/4mO+KnApIPbMDDgBozjHcBX5uE wrxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690268893; x=1690873693; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nemwt6odA/W6LAzXazKdN7X8FI/tGQtoSYxpSs1lg8c=; b=jXb2wEXjfXeCipFULPkXjAeP1r0QSGMKwxb4x4bi0MmtEiu7wFEhiinNoYp1eCGE4g H5CkyX+S5p2zjbMid02HWJbTkFP6035SkLDrq4cotoRB/E6Bq+ft6yt8g2NVePvDlgwa Xo5xB98mBDc+Dz0WWXDhAYzKXOARxzYaFn9Ly50tB9Kv/9Mkh9PrCd5q40q/ot9LXpiw NUKRDIchUCajvX5/br9ijV8c5Y3HAo2AtBRvqOXTjNfBLqbuA4uwV+TzsmdDOM4AfNZz 2OtppvT7DkAhQoSDu06jVKWbPGjsIB59131w2SYFESPw7J0h6ORDNxlK5VxvbLm/19ju 5mbQ== X-Gm-Message-State: ABy/qLYz0KFEWf1LGWT9BBn9g4rmX7EwwMx51D42ynkanD+xSnhrOTFp hanG4wFn+FEHmNSuBlU8iXTsrLqn3e5k+HDre6yW/w== X-Received: by 2002:adf:ce8a:0:b0:317:5c18:f31d with SMTP id r10-20020adfce8a000000b003175c18f31dmr5125722wrn.35.1690268893182; Tue, 25 Jul 2023 00:08:13 -0700 (PDT) MIME-Version: 1.0 References: <20230722123850.634544-1-alexghiti@rivosinc.com> <20230724-sanded-dental-c9125c76ad74@wendy> In-Reply-To: <20230724-sanded-dental-c9125c76ad74@wendy> From: Alexandre Ghiti Date: Tue, 25 Jul 2023 09:08:01 +0200 Message-ID: Subject: Re: [PATCH v6 0/5] riscv: Introduce KASLR To: Conor Dooley Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Ard Biesheuvel , Kees Cook , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Mon, Jul 24, 2023 at 4:32=E2=80=AFPM Conor Dooley wrote: > > Hey Alex, > > On Sat, Jul 22, 2023 at 02:38:45PM +0200, Alexandre Ghiti wrote: > > The following KASLR implementation allows to randomize the kernel mappi= ng: > > > > - virtually: we expect the bootloader to provide a seed in the device-t= ree > > - physically: only implemented in the EFI stub, it relies on the firmwa= re to > > provide a seed using EFI_RNG_PROTOCOL. arm64 has a similar implementa= tion > > hence the patch 3 factorizes KASLR related functions for riscv to tak= e > > advantage. > > > > The new virtual kernel location is limited by the early page table that= only > > has one PUD and with the PMD alignment constraint, the kernel can only = take > > < 512 positions. > > I gave this all a go today, it seems to do what it it says on the tin, > and crashing my kernel does dump out an offset etc. > > Tested-by: Conor Dooley Great, thanks for testing! > > I'll hopefully get some time later in the week to go through the code. I will be on holiday in 3 weeks, you have some time, no worries :) Thanks again, Alex > > Cheers, > Conor. >