Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp460201ioo; Thu, 26 May 2022 07:28:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6fCW1L6KZoL6R5Up+MvrU6Som7qPWgEsTVFgZIM/Uthodjva2g/UZmHtZACRntIonALpG X-Received: by 2002:a17:906:a5b:b0:6f4:55f6:78af with SMTP id x27-20020a1709060a5b00b006f455f678afmr33978667ejf.238.1653575285075; Thu, 26 May 2022 07:28:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653575285; cv=none; d=google.com; s=arc-20160816; b=uG5lSJd3HrsNeYtBlMG0fJluL/rQRCb0z6aRpLEwrdy6Ud1aXzCoy0/r8HYdajEBte byshIS2AV7FlCGpVSEGzHzy7VS4yiyDDezZghBo3GIGUYE4aNMTl7RqPoy3bUE+oc8Tk boEzSrG8GNSn/TP2q1dMB2WL6VsjPDJpAQr6E3KfvZvE+9oZuEsbXC0gt/+oPHHFShwg 59gg/iiKpXKX6NknsyNMpf7FZdLp1Ya9zphMxNFO9uhWFtAvDs3bvjhH3XaY0y5E2uXx 7yEm6laoMCDb0b7UganVy+hMN84a9JbmEsWooFCM0Hb0zkIQHjv4Q5CuWnbD5Cj7zAsd GOeA== 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=8Tx5B89wRH0aFtZRAXM3z4Ug2Ls2VMbHaKwqc1lcgtE=; b=NsdE5Si4BlTNR0znAPyJmk6HlbUm5JOB9t7fYa479Fe2XYlCzLsVcY5Hg+TKc/1ouV BuuLunb5rJrOT0zCpvPqTdvpLf8NRfnfCmHre0wd3kTcp/jJvZbG07gIoljypdfMrf7Q sQIw/vdlLH2oTbUKub3FseVvh0iPDSK9IiGGPzsLLAFmOxEPFcpq6tx56SQ0OGPusr6s RolYok7mazkfU+9mS60cttyohMt4BuS53caI5v9/m+/P+1qgQFwtetOr1ujFVM2QT7u3 ykD4kRtZWJmz2Tpvrl89c+TXUs33fHdSEhKNaTKc3ROmB4sfbxIro/7OscQobWsy476y vUGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jrtc27.com header.s=gmail.jrtc27.user header.b=jX2jVB2P; 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 mp25-20020a1709071b1900b006df76385e6csi195315ejc.780.2022.05.26.07.27.37; Thu, 26 May 2022 07:28:05 -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=jX2jVB2P; 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 S235681AbiEZAGf (ORCPT + 99 others); Wed, 25 May 2022 20:06:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345801AbiEZAGb (ORCPT ); Wed, 25 May 2022 20:06:31 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73E4748E61 for ; Wed, 25 May 2022 17:06:29 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id h129-20020a1c2187000000b003975cedb52bso333938wmh.1 for ; Wed, 25 May 2022 17:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=gmail.jrtc27.user; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=8Tx5B89wRH0aFtZRAXM3z4Ug2Ls2VMbHaKwqc1lcgtE=; b=jX2jVB2PuEO61dP74cOE7eq4vJdkuomI88a4aklp62TGE3bMzTdOq3ZvgrjcGanJ9x pfJzN51Dm3OFhODlZ8nHrvaPYURi1/sVlDr7PgEjKj2+voRVEaV8jtqXNVFido/CndB4 TDCDphpS1W0yIPmkl6Uplc86qK+GsCyD/fpyitHuDEwcEx9PAIvX2AQtdvOT8gAaAh+R wdPolM7KIbK+USwDT2vAlnqDKt+md+4KDSduSjtNMf/9L6TbvEAI+aQ+9hUNU/EIM1aN hI/EfaJ25j//Oo9dP/A8bzDAbtwt/VvrCBnv+B4uLX5TIqhAy30LRc1OE304PsNFAKl1 bkNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=8Tx5B89wRH0aFtZRAXM3z4Ug2Ls2VMbHaKwqc1lcgtE=; b=K3LguvZKDnJ4O/hBebIeWyEN+92yrBi15aFewW1yAQovu1pkszVdQwRSB8h6orvMqx VSdTQPJ7IpEy27Q7cOePwyLzgfrkJs0U2DHm85oBDf0PDG0+q7Y9zUorFaOjKjWxOl1z qNQfuI9Yeofn5b8G91UbV0kzplMgaF6YlnWYF7vR81yFps4Lu26orMngHZWs5rm2U92h zi2rippM6a0089fup6uV0OJRaKJqejvcJARn/L+l8zMOQsQ7oQruWMIuks+qH9ZxHRSm 8nE2G42sj71QeqBK5CKC8U4V76RCrAuK5WSw80ylvLth/Tn1s4G3w9gVYD5OK4Cq53so q6Aw== X-Gm-Message-State: AOAM532DCpMwFHUmzD7h9OFen8f+icH+m/N2kUScqsBBjwAOdGltZcE7 4jX2iwLEkQG1yzkbykhWwZzyyw== X-Received: by 2002:a1c:2184:0:b0:397:7421:7761 with SMTP id h126-20020a1c2184000000b0039774217761mr2902180wmh.14.1653523587899; Wed, 25 May 2022 17:06:27 -0700 (PDT) Received: from smtpclient.apple (global-5-141.nat-2.net.cam.ac.uk. [131.111.5.141]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c4e4900b003942a244f2esm3087161wmq.7.2022.05.25.17.06.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 May 2022 17:06:27 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.80.82.1.1\)) Subject: Re: [PATCH 5/5] riscv/efi_stub: Support for 64bit boot-hartid From: Jessica Clarke In-Reply-To: Date: Thu, 26 May 2022 01:06:26 +0100 Cc: Heinrich Schuchardt , Ard Biesheuvel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Daniel Lezcano , Thomas Gleixner , Marc Zyngier , Atish Patra , Anup Patel , linux-riscv , Linux Kernel Mailing List , linux-efi , Sunil V L , Sunil V L Content-Transfer-Encoding: quoted-printable Message-Id: <898EDFB9-D4AE-45CD-AEEC-FAB4BE7AEBF4@jrtc27.com> References: <20220525151106.2176147-1-sunilvl@ventanamicro.com> <20220525151106.2176147-6-sunilvl@ventanamicro.com> <1e90b15b-8c73-0de8-2885-1292923b7575@canonical.com> <5829932A-6E45-46CA-AADA-14EDD903C4AD@jrtc27.com> To: Atish Patra X-Mailer: Apple Mail (2.3696.80.82.1.1) 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 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 26 May 2022, at 00:49, Atish Patra wrote: >=20 > On Wed, May 25, 2022 at 4:36 PM Jessica Clarke = wrote: >>=20 >> On 26 May 2022, at 00:11, Atish Patra wrote: >>>=20 >>> On Wed, May 25, 2022 at 9:09 AM Heinrich Schuchardt >>> wrote: >>>>=20 >>>> On 5/25/22 17:48, Ard Biesheuvel wrote: >>>>> On Wed, 25 May 2022 at 17:11, Sunil V L = wrote: >>>>>>=20 >>>>>> The boot-hartid can be a 64bit value on RV64 platforms. = Currently, >>>>>> the "boot-hartid" in DT is assumed to be 32bit only. This patch >>>>>> detects the size of the "boot-hartid" and uses 32bit or 64bit >>>>>> FDT reads appropriately. >>>>>>=20 >>>>>> Signed-off-by: Sunil V L >>>>>> --- >>>>>> drivers/firmware/efi/libstub/riscv-stub.c | 12 +++++++++--- >>>>>> 1 file changed, 9 insertions(+), 3 deletions(-) >>>>>>=20 >>>>>> diff --git a/drivers/firmware/efi/libstub/riscv-stub.c = b/drivers/firmware/efi/libstub/riscv-stub.c >>>>>> index 9e85e58d1f27..d748533f1329 100644 >>>>>> --- a/drivers/firmware/efi/libstub/riscv-stub.c >>>>>> +++ b/drivers/firmware/efi/libstub/riscv-stub.c >>>>>> @@ -29,7 +29,7 @@ static int get_boot_hartid_from_fdt(void) >>>>>> { >>>>>> const void *fdt; >>>>>> int chosen_node, len; >>>>>> - const fdt32_t *prop; >>>>>> + const void *prop; >>>>>>=20 >>>>>> fdt =3D get_efi_config_table(DEVICE_TREE_GUID); >>>>>> if (!fdt) >>>>>> @@ -40,10 +40,16 @@ static int get_boot_hartid_from_fdt(void) >>>>>> return -EINVAL; >>>>>>=20 >>>>>> prop =3D fdt_getprop((void *)fdt, chosen_node, "boot-hartid", = &len); >>>>>> - if (!prop || len !=3D sizeof(u32)) >>>>>> + if (!prop) >>>>>> + return -EINVAL; >>>>>> + >>>>>> + if (len =3D=3D sizeof(u32)) >>>>>> + hartid =3D (unsigned long) fdt32_to_cpu(*(fdt32_t *)prop); >>>>>> + else if (len =3D=3D sizeof(u64)) >>>>>> + hartid =3D (unsigned long) fdt64_to_cpu(*(fdt64_t *)prop); >>>>>=20 >>>>> Does RISC-V care about alignment? A 64-bit quantity is not = guaranteed >>>>> to appear 64-bit aligned in the DT, and the cast violates C = alignment >>>>> rules, so this should probably used get_unaligned_be64() or = something >>>>> like that. >>>>=20 >>>> When running in S-mode the SBI handles unaligned access but this = has a >>>> performance penalty. >>>>=20 >>>> We could use fdt64_to_cpu(__get_unaligned_t(fdt64_t, prop)) here. >>>>=20 >>>=20 >>> It is better to avoid unaligned access in the kernel. There are some >>> plans to disable >>> misaligned load/store emulation in the firmware if user space = requests >>> it via prctl. >>=20 >> Why? >>=20 > To support prctl call with PR_SET_UNALIGN Is that needed? It=E2=80=99s almost entirely unused as far as I can = tell, with all but one use turning unaligned fixups *on*, and the other use being IA-64-specific. What is the actual use case other than seeing a thing that exists on some architectures and wanting to have it do something on RISC-V? Jess