Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2439522ioo; Sat, 28 May 2022 13:45:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUspth5GFtc/hsATQ77LDSUYOMLX2sUr+pSUev1cqOoba/QK4MTNpcn5SkLML9Cqntbeth X-Received: by 2002:a63:f057:0:b0:3fb:94e5:8a90 with SMTP id s23-20020a63f057000000b003fb94e58a90mr9943787pgj.141.1653770721350; Sat, 28 May 2022 13:45:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653770721; cv=none; d=google.com; s=arc-20160816; b=RC4wpSu28negpby6TE76r+aFxlTTsfiFI8fHHt1Zm6TbrC/uz5fPX+pZhM7YtNX0ON Bi9AUyNyqTC5n9Xo2fnTYlNNSkKeQ8cd/rUCA4UN8qxRnsOIeYS/FXOcsyqtBb4ZtiV4 E+aYmFsuM8U4YgkHaPnD969BBzMsm3wy41TbOXSjdFggcrdJELIE3DiAFpBd0eFCcm4I GL9HHJ4xXiDMLpgR6UEL1esnTYIhHs6quPDF53/dnUmL+cuto3leJ+/I2km9BxLpJmWy S+bNo6WIXef2JRLVr9J3WR+iLHlmR0Zq3po8dKcWgliKwAUnnho2oZVTZIndAOdNIP9f 7LWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P7OLahpm+kkKBEARj4VmqHAWwKE6JWuCb2y1kO4JlMo=; b=q5c1Xa8L8a/ts1d7ehQyKA4LeQqANBYxDuAKxP+ku7T06n6HuNG8ewtuVGMuaqQSyA L8IflMMrqjsUrxTkmpq4C9zgcxavMe7iFl+azxqOGIr2o9RtRF/XjmGc/Mu0lPTCjmbC iv8mNR9XdTug5JS1C/gN5iO4MiXc8Cqu+4lGdlhwjJ05dusjsnjbuX84WOluSSNhPOV0 hr9EOEXwphI+YMtYXjKG04NjZMsjiTR7Czx+2iysN3GZWdNxig1m5gZDA6P5YOEKXB3H WsMauQbSZmwTVOx44LOFBioBdp3rc2w8zVrsN4TE3WFdavT/flgXMTU1KNYKm93EEV1Y /O0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=jbbgWDbw; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id lk18-20020a17090b33d200b001e09092c060si7795343pjb.169.2022.05.28.13.45.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 13:45:21 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=jbbgWDbw; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 91D9D110464; Sat, 28 May 2022 12:44:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233703AbiE0FSf (ORCPT + 99 others); Fri, 27 May 2022 01:18:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243286AbiE0FSM (ORCPT ); Fri, 27 May 2022 01:18:12 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E977A3204C for ; Thu, 26 May 2022 22:18:11 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id h186so3050291pgc.3 for ; Thu, 26 May 2022 22:18:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P7OLahpm+kkKBEARj4VmqHAWwKE6JWuCb2y1kO4JlMo=; b=jbbgWDbwDxjGdcveN5opTsfLAmWPWwGxc3+eVGbfsHWg/8rWmYs56+UOro+RogMEZM N62nMVWsUj4S1x1EO9/sOj+RyfnNolADop36vf0W9gI0grwBEj+LHvnS7NObdOChj1fr pdp0MAqHt69N2PVB+On0qE0fzZJgaFk0jSAklcoSCwUR6pMoJ4N8ch2kmRJgzYicZ9g8 nlLrckWV6F2Xf89IfGJjZxykmYvwWKkF7yBDRhpy2/xXY+McSVN22CDwjx0K6bd6/K27 2TheHSPfI3Q1v5eelfmdXtqX1eqTBKySsvAWD35PX8QXMUzn0ASyQRVsfnxQdZU0In0w pjLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P7OLahpm+kkKBEARj4VmqHAWwKE6JWuCb2y1kO4JlMo=; b=E97sGWjghZF0o2Jxa7PY/7cCvRGdMwsLau+nvxat0Mp2SD+8XoiYIyIv30AMC/wxFS 8Kh9UyYSP/2hFhVpas3nsKdFgN0F/W7jPiF3y1GzxXIAzE2qxO1Yx5zDaD7riKlXaU8c G+9kuSI0vW7b5Uk/RmbSISa6wIgL34qeG0TAtxhAMYGGsGvOcy0CnhBUWBJN9qAjwmZf 42ie85Ou27tDvOzFzs9YFqbAuIWIEx+IFLqwAzwdotnLymv0RE5tm1VS4SJ0/Tqz6XFv TaMddaIFLpBa7LcXRLk+ZmaQTBp8SCdm8yopRWwMWv8Hgx6Pftnw8bYRWxBEIIock2S/ PL2w== X-Gm-Message-State: AOAM530HgyY1qyNTxYENK+ifVc7tdXKfbufwOE6u2HDSWwg3ANpz7uIT EvebLwlBFcfqDaIjRBwvcodBkA== X-Received: by 2002:a05:6a00:88f:b0:510:7a49:b72f with SMTP id q15-20020a056a00088f00b005107a49b72fmr41896359pfj.21.1653628691482; Thu, 26 May 2022 22:18:11 -0700 (PDT) Received: from kerodipc.Dlink ([49.206.9.238]) by smtp.gmail.com with ESMTPSA id j34-20020a634a62000000b003c14af5063fsm2459003pgl.87.2022.05.26.22.18.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 22:18:11 -0700 (PDT) From: Sunil V L To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Daniel Lezcano , Thomas Gleixner , Ard Biesheuvel , Marc Zyngier , Atish Patra , Heinrich Schuchardt , Anup Patel Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, Sunil V L , Sunil V L Subject: [PATCH V3 5/5] riscv/efi_stub: Add 64bit boot-hartid support on RV64 Date: Fri, 27 May 2022 10:47:43 +0530 Message-Id: <20220527051743.2829940-6-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220527051743.2829940-1-sunilvl@ventanamicro.com> References: <20220527051743.2829940-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 The boot-hartid can be a 64bit value on RV64 platforms but the "boot-hartid" in DT is assumed to be 32bit only. Detect the size of the "boot-hartid" in DT and use 32bit or 64bit read appropriately. Signed-off-by: Sunil V L --- drivers/firmware/efi/libstub/riscv-stub.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/efi/libstub/riscv-stub.c b/drivers/firmware/efi/libstub/riscv-stub.c index 9e85e58d1f27..b450ebf95977 100644 --- a/drivers/firmware/efi/libstub/riscv-stub.c +++ b/drivers/firmware/efi/libstub/riscv-stub.c @@ -8,6 +8,7 @@ #include #include +#include #include "efistub.h" @@ -29,7 +30,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 +41,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(__get_unaligned_t(fdt64_t, prop)); + else return -EINVAL; - hartid = fdt32_to_cpu(*prop); return 0; } -- 2.25.1