Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3595335pxb; Mon, 24 Jan 2022 13:06:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJxScGGYsCLNrXx5MYBrumgq/WM5eAEOSrr4onT0rFsUesAucjNiLwnMzGaIA+LkKq5IBBdI X-Received: by 2002:a05:6a00:21c2:b0:4bc:fb2d:4b6f with SMTP id t2-20020a056a0021c200b004bcfb2d4b6fmr15344478pfj.62.1643058384952; Mon, 24 Jan 2022 13:06:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643058384; cv=none; d=google.com; s=arc-20160816; b=p25nv8fJGRp8vK19WiP29ln2mBq6O2o55DZ1Ik/do5u+NMV1MKFKWJ9no/mME0jcAB c9B7JbT5eYb12iAfa1jf5bTH0o7y7nU621x1HRqsrCi0zIFPq4tW3yc0QkrLAlyu7c0b g38XeQMb7rHav3Im1NHtaEaiIB1LPdTASwq/lOApICHQ+hbEInjC4QLIbamrZNz0na5J dsES711vKpHGz4aDltMuH/RsgaE+0AWgKogW7gzPgsMynDoyCca+lb9y8QxYfeRsfBsL Uzd0jXeYw/Xnxbokd2GiDtUJP8ETIU+d18K+5jCUksDT3+4I5DeR50mq9UXhFPGre/z0 529w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tA/uNjzErrQWnrdiYYhePnmXI4JSD2S6Ke1J/mEluME=; b=cXTRHtygQZYA35cW3O9dxTbAnU9uhXntxVnCB+aIwYdVmDM3S0CNtchG5BxLbu2ovF 5E+or9oqmRfeyQmuKuxiwiA5QpFn2l2MS6JPmOKrM4yHj12zFguBoJ5GJmyUdsuy7yYn 7UxMjK1Zfqi6TAKrKwPgKmBtu7HaQcJm4ULX2gnf02igQ9jSN14hBIGqkFLClAAF+vw2 Vy8Xie6Mmlk52jyxXCh/frDNuBsoMwx4XKFE9JII6YE8PLlBn4ozgw2yzgKIK04+R3AG 2Ig7u8mWKCF3uE1t+hkPCZqKGN4lW2t/vDH+/yJobn3sk3X1O/h2sSQTSyflp69Y9KJh Rj3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BsswdLZc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 11si14157584pfl.113.2022.01.24.13.06.09; Mon, 24 Jan 2022 13:06:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BsswdLZc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384868AbiAXUaq (ORCPT + 99 others); Mon, 24 Jan 2022 15:30:46 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:37262 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355070AbiAXUKy (ORCPT ); Mon, 24 Jan 2022 15:10:54 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 482C261375; Mon, 24 Jan 2022 20:10:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31C09C340E5; Mon, 24 Jan 2022 20:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055052; bh=E+29dWAS2bNGWEVBTIKKRP7OxbGQOJmSmmqhxe69i2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BsswdLZc4JBtxXE6dctJ8PVJ8M22zmLmajBQjHAYk+qm99DxJqYp5Pl32x1W9VfzN amFvibxzu7UJ1Hj5nD9cOn8IZCecQ8s0IHz8Z1N2LPbmv2tD25QsgkCPBaUy37DDlI b4E4dIfIsLzZKqVofX0IHJJ47k1+us75tpICLMRw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nick Kossifidis , Palmer Dabbelt Subject: [PATCH 5.15 025/846] riscv: use hart id instead of cpu id on machine_kexec Date: Mon, 24 Jan 2022 19:32:22 +0100 Message-Id: <20220124184101.791758733@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nick Kossifidis commit 0e105f1d0037d677dff3c697d22f9551e6c39af8 upstream. raw_smp_processor_id() doesn't return the hart id as stated in arch/riscv/include/asm/smp.h, use smp_processor_id() instead to get the cpu id, and cpuid_to_hartid_map() to pass the hart id to the next kernel. This fixes kexec on HiFive Unleashed/Unmatched where cpu ids and hart ids don't match (on qemu-virt they match). Fixes: fba8a8674f68 ("RISC-V: Add kexec support") Signed-off-by: Nick Kossifidis Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman --- arch/riscv/kernel/machine_kexec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/riscv/kernel/machine_kexec.c +++ b/arch/riscv/kernel/machine_kexec.c @@ -169,7 +169,8 @@ machine_kexec(struct kimage *image) struct kimage_arch *internal = &image->arch; unsigned long jump_addr = (unsigned long) image->start; unsigned long first_ind_entry = (unsigned long) &image->head; - unsigned long this_hart_id = raw_smp_processor_id(); + unsigned long this_cpu_id = smp_processor_id(); + unsigned long this_hart_id = cpuid_to_hartid_map(this_cpu_id); unsigned long fdt_addr = internal->fdt_addr; void *control_code_buffer = page_address(image->control_code_page); riscv_kexec_method kexec_method = NULL;