Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2436369ioo; Sat, 28 May 2022 13:38:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4nKpRxeyT8ZGhJWIhBUc6e1qENQix/HzYhstt+KQVM2Zr2mhQDMEF2eems0+5dvSq6UQn X-Received: by 2002:a65:5886:0:b0:3fb:a6ea:b741 with SMTP id d6-20020a655886000000b003fba6eab741mr7998635pgu.502.1653770280055; Sat, 28 May 2022 13:38:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653770280; cv=none; d=google.com; s=arc-20160816; b=NrcooErpg7C+UYJz/pyvyOiR/me3rTvB5BaGl+qLJywaK4evJQYPh/NPza56RoB7Ks vxOARa0GIfLhWrtY7GdlgyKvPi8Y9p3ugMQWbnsnAGPtv4STrOIoUqvH8WbA4Nxl25b7 j7nadd21c+pbtINUBv4btA1KJOrTZI3QlyDcpL98q6IsD/v7CafXlxyaoTrN2Cpe4JcY mkiBU/Fz5q9HQ+yOSIQHtpScyQp85j2PODZqoxAdNMYGSVx9k2cILwsNz6D+u9+QkZQd F2a52VWcYHdI73xGk0fgYsMPVze1YOs2Q1HFkIe/BBDjZGYx2/W2s7lfo4FppsG+kdnO Otxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=cJRzOpKgtwU4rrRmVY0G9vrNWq/M/GyTzVQS/4EO73M=; b=iKavnVjEQhAXHVafpAXxwlKnygKUSXJ5rEhUIuIJFrL1zdmB/ZKXoOONaqDKjzvI37 r4N3vleRCXWjV2eJ007wlcjke1ujg35gOhr7tOrEU70rWV46aLlYg2JMysseOqmkEHif DaH7crkYdhCalLoF7kzPMjaHhtvcgHRFfLWQccaBzRqcgJhLecNwQeFRg3NDIXzPW0Sp REDBOATFIGmWmcOVdJhd5q5DjGrxQwcanNWibosKcDxlnM1qyqqLBA+hOYW1QHZOH8GG Q8OWuQdjvtsJyKmnwVDcoELIxt7DyEf7p1t0Isxpp8lZde6998Nl9IwFuFVyjhY5PZYr haNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=kw6tfDLl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u4-20020a17090a1f0400b001dcdccd55c4si6208164pja.100.2022.05.28.13.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 13:38:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=kw6tfDLl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B56AE12579E; Sat, 28 May 2022 12:40:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241575AbiEZKOF (ORCPT + 99 others); Thu, 26 May 2022 06:14:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235567AbiEZKOC (ORCPT ); Thu, 26 May 2022 06:14:02 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 118865F58 for ; Thu, 26 May 2022 03:14:01 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id n8so1083507plh.1 for ; Thu, 26 May 2022 03:14:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=cJRzOpKgtwU4rrRmVY0G9vrNWq/M/GyTzVQS/4EO73M=; b=kw6tfDLlv/2wMtAl9/ySnsycGYMBVDM1PY4gGAFJmWDGBshKOu60vIaSpy3kRN4FMw Gdbw158BJWeB3Y6NIV8/WgaWu33kw5ZNXeeUmOLcpArVjyNXTp05Gz90KEH9XYCmkE/Q WLNuPNhkkVc3GhXhEElA0IrVKUpp8k1p3YMFQiOeN8sxjQnviRu8VjHp5Kq2yq0hhJmN 2cwLt1kXhmgncnkwK4FSTbA0e6qwloIzM/tgmpHntFJIznFE/35Ii1v/h2dkSKIqPSaY VchGopo3XRBEaT4yg2au7r9Fi0hXPJG/63suLBlwPf4KWkHyneyFsZwLw1jqorBGW5MO gVxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=cJRzOpKgtwU4rrRmVY0G9vrNWq/M/GyTzVQS/4EO73M=; b=2ILbOaygT+EnHU7y01FakuKCM6x7Ba8ShHtgZb9NjC2uNe3wgclsRATVGP/Op/00ay FXxdvYip+9g30fVNSbB5r4waHCz4pJwiDiqsVr4aZE4k5ObbSJfWmgqHqC/+dTn+n4b+ p55aC8wWOTKrD6FAsgbanDEiQKaE+ftslLRUoCB2w45DstnWj1JQs/k/Dk9WPu+6R69a P4rzlro2sHwvnhmYnVbb0UOMeQAM+lM5uuCpikT0oV5C3sas9vlqFP/HYHgYQHXLuCCD VKXJczW3sIPn100imNX/S07pOppxlDfolSLh+VGJ9PwbQkzo10KOjVcyczMeCvhkAgBl lBbA== X-Gm-Message-State: AOAM5318yZ32QcCSuPehpS2zj/8Hx5cxMSyDbKMUQuKOYn0TH0tuLS3M WC5Ar0xm4DEEmHj04HPHgqIhrg== X-Received: by 2002:a17:90a:55cc:b0:1e0:c4a7:4a59 with SMTP id o12-20020a17090a55cc00b001e0c4a74a59mr1835936pjm.127.1653560040601; Thu, 26 May 2022 03:14:00 -0700 (PDT) Received: from sunil-laptop ([49.206.9.238]) by smtp.gmail.com with ESMTPSA id ce17-20020a17090aff1100b001e09a4afd69sm1090043pjb.7.2022.05.26.03.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 03:14:00 -0700 (PDT) Date: Thu, 26 May 2022 15:43:54 +0530 From: Sunil V L To: Heinrich Schuchardt Cc: 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 Subject: Re: [PATCH 5/5] riscv/efi_stub: Support for 64bit boot-hartid Message-ID: <20220526101354.GA19431@sunil-laptop> References: <20220525151106.2176147-1-sunilvl@ventanamicro.com> <20220525151106.2176147-6-sunilvl@ventanamicro.com> <1e90b15b-8c73-0de8-2885-1292923b7575@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1e90b15b-8c73-0de8-2885-1292923b7575@canonical.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Wed, May 25, 2022 at 06:09:05PM +0200, Heinrich Schuchardt wrote: > On 5/25/22 17:48, Ard Biesheuvel wrote: > > On Wed, 25 May 2022 at 17:11, Sunil V L wrote: > > > > > > 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. > > > > > > Signed-off-by: Sunil V L > > > --- > > > drivers/firmware/efi/libstub/riscv-stub.c | 12 +++++++++--- > > > 1 file changed, 9 insertions(+), 3 deletions(-) > > > > > > 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; > > > > > > fdt = get_efi_config_table(DEVICE_TREE_GUID); > > > if (!fdt) > > > @@ -40,10 +40,16 @@ static int get_boot_hartid_from_fdt(void) > > > return -EINVAL; > > > > > > prop = fdt_getprop((void *)fdt, chosen_node, "boot-hartid", &len); > > > - if (!prop || len != sizeof(u32)) > > > + if (!prop) > > > + return -EINVAL; > > > + > > > + if (len == sizeof(u32)) > > > + hartid = (unsigned long) fdt32_to_cpu(*(fdt32_t *)prop); > > > + else if (len == sizeof(u64)) > > > + hartid = (unsigned long) fdt64_to_cpu(*(fdt64_t *)prop); > > > > 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. > > When running in S-mode the SBI handles unaligned access but this has a > performance penalty. > > We could use fdt64_to_cpu(__get_unaligned_t(fdt64_t, prop)) here. Thank you very much for the feedback. Have updated as per your suggestion and sent V2. Thanks Sunil > > Best regards > > Heinrich > > > > > > > > + else > > > return -EINVAL; > > > > > > - hartid = fdt32_to_cpu(*prop); > > > return 0; > > > } > > > > > > -- > > > 2.25.1 > > > >