Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp605727lqh; Fri, 31 May 2024 10:31:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWnX+vFPolYHc9rGrrQ1qJyT8B8sRe1f5pdqfKquYCyE/7fUO4xE8yeogwx710D/9FV4oIdAhfMl7sSOworWwsnDftWJweQqXkovn2p8Q== X-Google-Smtp-Source: AGHT+IGsyqaOx6HuhuWg+tPGTyPf/miaRUhyRCFZHEPu/PuVbYHJXdgIWVGTvhCdoEOhS2Lm13Bs X-Received: by 2002:a17:906:25d0:b0:a5a:8b17:d851 with SMTP id a640c23a62f3a-a68204229dbmr201470266b.20.1717176682394; Fri, 31 May 2024 10:31:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717176682; cv=pass; d=google.com; s=arc-20160816; b=Pkw/8CqQdTboWI7hVMwD1JHKf7wJS22Ye+EVNT8zyptHiBxjAXzt7oabKWLIZbKV5+ Wt7NDMpbOF3oPJmMzn9ighfgcbj4KoRgCJBrU902QLLjtBCib03bw5htqMybBCHAnjVm kLQ2Nd5JB+WXX828zYuAQkZXhAQ+EwUuQVzq6WeIHWZ96u6phTpADMz8TMFRtS/mun3/ 5Ay3ERYl6O8+AE7ubOn+TJJzno9yc2KILTcAFm9H18mjJwQOUHkESYyZxJ9HX80u8uVh LoPLNtrXjfjm2MJEGc/j+2E/HgNyMT3IqkRB+KhVezGppm1k06HcWzlNLBBt+4cZCynj Sa/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ugKsI1n0ps5BfECIOYx/A6IymgUIGBxwn3EHv/Id8mE=; fh=DkGmdEaVjmYYcb0gWGY7MpydvnXoFYiv6BtrglRreoI=; b=igPqsP0+JQGHEQ6VJyH9qXq2mOq5Vm2qYXxrcufR5szvIPWK5BOh2qHfVSUef83Bku 4nUT8Dm79C6glnrtSu9geZGkTw8prpaFkFizJleFGcqcEJdy/McD7flyrZSNMTJaANOj 8RUkViYemDPcLDs0xRP/Pq97ce/v8WS0u9ICdSmdHGvaWP8ru1keO06D7a0dZmkpn8au Y59oIKN0lYl2V5L/q8sM5Qw1bLo+bqSApe1yuQ3ZhqL2TAQv2AogIx/Jv2so/t7426aU 4ghtBqdYdmd9gqNIjlVXIiEqZ1HdIHaKWINCBiJFFDRivClP+eJrZIPQFeYv12I6QF8X bmXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rGf8CKyH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-197251-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197251-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a68a059bfaasi12090266b.758.2024.05.31.10.31.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 10:31:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197251-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rGf8CKyH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-197251-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197251-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1F9641F277A4 for ; Fri, 31 May 2024 17:31:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4352217B4F2; Fri, 31 May 2024 17:31:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rGf8CKyH" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B1DA80C1F; Fri, 31 May 2024 17:31:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717176674; cv=none; b=thZ6iRy07nOUFNTzGaktEOia7DXAXHTjqQboSjU2kLsbQfzp2pmVLA30JWrRfWs7dQiuuXY1DPt00x01mRz9gtdshtReSdbcVX492xYJJ4l3WyzCrcO/lH+x8foirs0wSA/bMmOBey9v45NhALBJe7vSZgFIuR242Lj55020CSg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717176674; c=relaxed/simple; bh=ugKsI1n0ps5BfECIOYx/A6IymgUIGBxwn3EHv/Id8mE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Wd810kmF6q5Zg6VWoqIPyl8gwHH41PMPY+Ay0+pgOqfpUYY0Gz5rlDsofUqI+jO/tCBCmKmugoDf/BZbrOFOOt5iHmujs6gplCPgKPBJh0tSenX+/fGhC9H/0lEPYBqGBLLSZpsihsN+HEEYOswbEwXAS5VmTotZ1ViYEwOVkZY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rGf8CKyH; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8966DC2BD10; Fri, 31 May 2024 17:31:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717176674; bh=ugKsI1n0ps5BfECIOYx/A6IymgUIGBxwn3EHv/Id8mE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rGf8CKyHFijgLDSqYePnQ5BCTYnBTXCTIR7yFEJknvnNOQ/hdxJ2qZAs0M7kcsxLm pk76gkHxefmIVBYIrtYbxwMb5x2CbUZ7sqalM1gvrqc4uMBNY+Z7fH1UBhsXarwcxp FTLaEWHCxtKiJzjjNd0CIsJJe+3tiWuqjfkoRefwjTFy3PCs6UTm7hi4YqP1XzHG1g eaJ/meSnXuj1Li4yDdzDFHZ0XctqhnbxhWTcPCLffmGOaXdTeCkPH2pEnFnBHvLe51 10OondmOCzovC/AY9gpGpxUzdQJSI2OuorxHNORYMDnuHTBbAoNMtyYN5NLjetfX7A OEaogdLCfTaBg== Date: Fri, 31 May 2024 18:31:09 +0100 From: Conor Dooley To: Jesse Taube Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Alexandre Ghiti , Palmer Dabbelt , Albert Ou , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Paul Walmsley , Nathan Chancellor , Nick Desaulniers , Masahiro Yamada Subject: Re: [PATCH v0] RISC-V: Use Zkr to seed KASLR base address Message-ID: <20240531-uselessly-spied-262ecf44e694@spud> References: <20240531162327.2436962-1-jesse@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xt66x2nsbKVBAiZs" Content-Disposition: inline In-Reply-To: <20240531162327.2436962-1-jesse@rivosinc.com> --xt66x2nsbKVBAiZs Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 31, 2024 at 12:23:27PM -0400, Jesse Taube wrote: > Dectect the Zkr extension and use it to seed the kernel base address. >=20 > Detection of the extension can not be done in the typical fashion, as > this is very early in the boot process. Instead, add a trap handler > and run it to see if the extension is present. You can't rely on the lack of a trap meaning that Zkr is present unless you know that the platform implements Ssstrict. The CSR with that number could do anything if not Ssstrict compliant, so this approach gets a nak from me. Unfortunately, Ssstrict doesn't provide a way to detect it, so you're stuck with getting that information from firmware. For DT systems, you can actually parse the DT in the pi, we do it to get the kaslr seed if present, so you can actually check for Zkr. With ACPI I have no idea how you can get that information, I amn't an ACPI-ist. Thanks, Conor. --xt66x2nsbKVBAiZs Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZloJXQAKCRB4tDGHoIJi 0q+NAQDg7dQm4yIuqIpJJUx6xVHNdm7QHRH1oZhb6KTvKdauPAEAjlDPmXth3suH EyUEa4xRA2F6Bpo7l3BF2i0FndH74gw= =J8qv -----END PGP SIGNATURE----- --xt66x2nsbKVBAiZs--