Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp837611lqj; Mon, 3 Jun 2024 02:15:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWInknAv4NhbLYuWXGJZoPkZ/JerwGnKCRDpHp1wnHuB0v34pdHi9T3OH86gmzo4CHrFvCQGCNH3Q+lRXM0IoZHJ+siFHwQyqCkiiGryw== X-Google-Smtp-Source: AGHT+IHr1qk7JSSgRIu6ugEwc7TQ+cQ+q65T2LwMcUEoYoK0P/f32FzHT1DC9eWATGY53f1dQ3RF X-Received: by 2002:a17:902:dac1:b0:1f6:8be6:428d with SMTP id d9443c01a7336-1f68be64516mr1364495ad.56.1717406104473; Mon, 03 Jun 2024 02:15:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717406104; cv=pass; d=google.com; s=arc-20160816; b=QTPXtgj5rbFzd0RYtk0bPK0Xr5cYG9aeeVhyDhXridY1FxyrQKEiL3OmD5+H9n48Gt 8Qh5lKfKRS8p4JUiBvf49NDl3kmpYP3ssKDqwham/81+S6AugApOdUhXu7/x9QMX1ItC 3X5gJXu/vNmdkPznnsXig7NhxocFxryPmxingZvFjV2BcOdzgwIPzyxp7p708EqS/uMG Obw+6jzvcFU0LdJM27ox1KhrzzeXYOKLVKuX6C/gGb1Y6IeFqW/dVmzPewL+NETwuZSW SWmr9GVlF4f/JBLaq0S9yndnv9eCh1I7OPMDrzYqEir/xREx7CcpUrqo3EeLYx7sAmJB ETHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=1zQqouULt2WLR7LNhsK86+6nRM2YfkHcxYr4hxOMSbc=; fh=KGfrgJqUH/h90YLfZ6YKHW+zbZGW/Oi2h1ZuoyDLy/0=; b=el9/5uxza4vaXbMyqTttyBM+M6iz1+lwoIsY4/tRWQRnwpSURZGRxCOhYlUBa2oTTR CFrSizvlZxtBC+z6+gCbzjqG7OqvbcF+dbVLMqBZeJpvDv49JiN9d7b1Q0ajqoOLL519 hbqbaBw/zvSX7H6L+sI8BVSv/1NWVB/PVCjl7Eduoi6974e0WbHiEEaoebJw33aIpxvC lW6SpKd60h2GEhbGtIU+7XiOGk/mnEbEbINHnktkIvu34f0VutZGklUerWNPZXZGpp6a 8Hjw/+xoewiA7A0JItPflj7Wmq0W9A+aoSZ/pd8APVT/Ez4LsZLj31oslMXB5rg329t0 zUzA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=ghiti.fr); spf=pass (google.com: domain of linux-kernel+bounces-198845-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198845-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f6323dd13csi60729855ad.245.2024.06.03.02.15.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 02:15:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198845-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=ghiti.fr); spf=pass (google.com: domain of linux-kernel+bounces-198845-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198845-linux.lists.archive=gmail.com@vger.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D0334280FE1 for ; Mon, 3 Jun 2024 09:15:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D32A57E578; Mon, 3 Jun 2024 09:14:57 +0000 (UTC) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 65C8B770F1 for ; Mon, 3 Jun 2024 09:14:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406097; cv=none; b=ZfecDtj9zm1C26y2q2G2PjJbZ+SDCU2IIKKoomF8CkR6h1RLLlxCpLsa2IV1ZLXOZvU5bx1XxESplwXLWTdnwZWrBHcklppEiQ7YEhAK6BTLP0uOCBrhuvSMZ03FqSkJYFc6ZlJixQbq8eMdqjL3OS63Yh7EwWNL4B1G5nZwAto= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406097; c=relaxed/simple; bh=RBHxbEbPrdDXGVgs9JAV6IdcubHw5Ps3pU1smttww4I=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ke/U+H8MY3ylSvy3U/yytkLonGV9B6Ew9QU2WxJQ5rx/Px1lLj6clM2uFeirgxQM9RNWJLoF4Qi3aXcPnAbBoCtj/FctF+ordXKqxU0pvxrqVOx6ZKwVXtltg02IL2ezNUjfwtOIeUOlT/Yel/Z/Dtv4QpVC6Gz6SPqTPGRLn9Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr; spf=pass smtp.mailfrom=ghiti.fr; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id 8477CC0005; Mon, 3 Jun 2024 09:14:50 +0000 (UTC) Message-ID: Date: Mon, 3 Jun 2024 11:14:49 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v0] RISC-V: Use Zkr to seed KASLR base address Content-Language: en-US To: Conor Dooley , Jesse Taube Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Alexandre Ghiti , Palmer Dabbelt , Albert Ou , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Nathan Chancellor , Nick Desaulniers , Masahiro Yamada References: <20240531162327.2436962-1-jesse@rivosinc.com> <20240531-uselessly-spied-262ecf44e694@spud> From: Alexandre Ghiti In-Reply-To: <20240531-uselessly-spied-262ecf44e694@spud> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr Hi Conor, On 31/05/2024 19:31, Conor Dooley wrote: > 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. >> >> 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. FYI, this patch is my idea, so I'm the one to blame here :) > > 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. I took a look at how to access ACPI tables this early when implementing the Zabha/Zacas patches, but it seems not possible. But I'll look into this more, this is not the first time we need the extensions list very early and since we have no way to detect the presence of an extension at runtime, something needs to be done. Thanks, Alex > > Thanks, > Conor. > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv