Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5982333pxb; Mon, 14 Feb 2022 12:18:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJB1hkfZoqy09mXAAI7wRM5vTNqV9PO6+1WllnHaQxgxHm9BZkwQQFwXQY3gz/nqMaMkIm X-Received: by 2002:a17:90a:2e07:b0:1b9:e28d:4f6d with SMTP id q7-20020a17090a2e0700b001b9e28d4f6dmr364886pjd.81.1644869889011; Mon, 14 Feb 2022 12:18:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644869889; cv=none; d=google.com; s=arc-20160816; b=ETKvG5+pYrKm1N6rM464RV1jQBt6K2kTz9G6OSKwaZafuuYxbwg+pYXiU+VK7HjQoA oUHF4ByXIQD8bASjFf0sWzD+9syx6qhhb8TcStVqwwmF4JQ3OkPhsrdFPQY87cvU49te /5LqtFAkfWRokinS9eq1g3ebIh5n/8NUJ4577NQMTf/12oqCx2BxopLKDuoxa8bp+lzA Tu++51eBem3lklpEFoBGenjjqAKA5SohsFInZRAetLD9O/ttBOoKOQJInkTsJc2UnD2u FWqonUuxaudYzfpAA/xWEVjOi5vJP1Z0jeEwOEy1xjPJxRmwVDWQfje34f3+S8ect8m3 xzdA== 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=3PDuWpWatMEsaSvbNwsNqzkAPf6BcghIhJSFC8jSD30=; b=kc2B8tpHfHxB34gU/WKtyY4Mq9RlKAtnQeyKA7i3H3xE8RI8iCo+VRvzLoGjQi6Nta eaw8wcw52p/sJTV2PTDs+01gw5ALbTpQH6biymX6oztn72BbN12tZhpymw/k6wvSXsoB Gk818izACpsLT5YwzCyMJSvf6dbtwNrZYCC95i3hj1Ltleh9Iwo8z3iC0z0BR/6z6Jce 4Tg8Lt/Ka6STD0YKhhJmFIj1jEkSWEX9zFD7nF8Ia5VoYv3BSaOhG6j1cEc1otMpJDgi Gl5na/WTWCEAtbZMt2TXp9nGdaohuI8CBgQQFvg5WT1h0PpyxfeoZIndknBmoMLGd3xz /7xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=gzY3pqJh; 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 l13si595519pgj.292.2022.02.14.12.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 12:18:08 -0800 (PST) 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=gzY3pqJh; 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 E57C3133948; Mon, 14 Feb 2022 11:52:12 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242196AbiBNIln (ORCPT + 99 others); Mon, 14 Feb 2022 03:41:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241889AbiBNIlm (ORCPT ); Mon, 14 Feb 2022 03:41:42 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F3334D9EA for ; Mon, 14 Feb 2022 00:41:34 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id p10so7390367pfo.12 for ; Mon, 14 Feb 2022 00:41:34 -0800 (PST) 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=3PDuWpWatMEsaSvbNwsNqzkAPf6BcghIhJSFC8jSD30=; b=gzY3pqJhek5FzBlOdPIHTO6Zi2K/2OsE1k4GoPy0cxDgZ5eiMZT0IOILUlSj/aEB4B RjD+XDpKRlfGfkd/XwIm9iSe4Y+3nP7SOyYnzFkzxTVfZMbOltHxTQIQwcsjUxgvliuV RbJXxs85zzqTaHQWz1//TsTD6s0IGS66ul3McsyVMsXz87heLAK41x4z7Fg3uQQnq8gs jVm4hmClESlQUful+1F5d92AmYMkmuI1xGetK5qucl6SvgNaSvpmZ39gw9Fb73LQQZT/ RccWidsx/F+CL0uIRPkA+2xst5I/kC1auwLVRK+xr2e8w3MCZvct39/rBc4n3iiEZo/U mw4w== 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=3PDuWpWatMEsaSvbNwsNqzkAPf6BcghIhJSFC8jSD30=; b=T9zVyaNBugLs6fOOtsU2wAWT5b7OFGPwlqsYLmeDAOPF1IDs+xz6Rah9OVgY8rGHPV TGYONGfd5xwFku8cC45amsRZUka3RAmVBZ3aav2QdhBZkYXrbnqzANxhNriQx+22pK38 hAy8rvrX6TSOs2KX7RmZAh6P+WAz9D1bBk1ao0kFRwG8oZ8EAaFzF9anDJnyheiuSiag i/S7TfpMmh8pc7b+a0E+Xwue/qpEbyBJpjHQ7ZY1UsJVUR9d831UdljUVFrNiEpOPgyE t98EtRS/8OLPY+51BVpikLASDIPVzpRdnsXi0iQ9+936fIYmr49XhzwfGMJKD9hYd17t l3iQ== X-Gm-Message-State: AOAM530GR3zzrOmkBqAltnAegLtQ3/1rWXi5zm3nwD+RJbEkt5bHmsWh z0dt5/FnlOzAppGWokuGKzH9ZA== X-Received: by 2002:aa7:900d:: with SMTP id m13mr13355552pfo.14.1644828093877; Mon, 14 Feb 2022 00:41:33 -0800 (PST) Received: from sunil-ThinkPad-T490 ([49.206.7.17]) by smtp.gmail.com with ESMTPSA id 13sm22335469pfx.122.2022.02.14.00.41.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 00:41:33 -0800 (PST) Date: Mon, 14 Feb 2022 14:11:24 +0530 From: Sunil V L To: Ard Biesheuvel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Atish Patra Cc: linux-efi@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Heinrich Schuchardt , Anup Patel , stable@vger.kernel.org Subject: Re: [PATCH] riscv/efi_stub: Fix get_boot_hartid_from_fdt() return value Message-ID: <20220214084124.GA11866@sunil-ThinkPad-T490> References: <20220128045004.4843-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220128045004.4843-1-sunilvl@ventanamicro.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 Hi Ard, Could you please take this patch? Heinrich and Atish have added RB tag. Let me know if I need to do anything. Thanks Sunil On Fri, Jan 28, 2022 at 10:20:04AM +0530, Sunil V L wrote: > The get_boot_hartid_from_fdt() function currently returns U32_MAX > for failure case which is not correct because U32_MAX is a valid > hartid value. This patch fixes the issue by returning error code. > > Fixes: d7071743db31 ("RISC-V: Add EFI stub support.") > Cc: stable@vger.kernel.org > > Signed-off-by: Sunil V L > --- > drivers/firmware/efi/libstub/riscv-stub.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/drivers/firmware/efi/libstub/riscv-stub.c b/drivers/firmware/efi/libstub/riscv-stub.c > index 380e4e251399..9c460843442f 100644 > --- a/drivers/firmware/efi/libstub/riscv-stub.c > +++ b/drivers/firmware/efi/libstub/riscv-stub.c > @@ -25,7 +25,7 @@ typedef void __noreturn (*jump_kernel_func)(unsigned int, unsigned long); > > static u32 hartid; > > -static u32 get_boot_hartid_from_fdt(void) > +static int get_boot_hartid_from_fdt(void) > { > const void *fdt; > int chosen_node, len; > @@ -33,23 +33,26 @@ static u32 get_boot_hartid_from_fdt(void) > > fdt = get_efi_config_table(DEVICE_TREE_GUID); > if (!fdt) > - return U32_MAX; > + return -EINVAL; > > chosen_node = fdt_path_offset(fdt, "/chosen"); > if (chosen_node < 0) > - return U32_MAX; > + return -EINVAL; > > prop = fdt_getprop((void *)fdt, chosen_node, "boot-hartid", &len); > if (!prop || len != sizeof(u32)) > - return U32_MAX; > + return -EINVAL; > > - return fdt32_to_cpu(*prop); > + hartid = fdt32_to_cpu(*prop); > + return 0; > } > > efi_status_t check_platform_features(void) > { > - hartid = get_boot_hartid_from_fdt(); > - if (hartid == U32_MAX) { > + int ret; > + > + ret = get_boot_hartid_from_fdt(); > + if (ret) { > efi_err("/chosen/boot-hartid missing or invalid!\n"); > return EFI_UNSUPPORTED; > } > -- > 2.25.1 >