Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3654482pxb; Mon, 24 Jan 2022 14:32:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyS8urK5q08p/OS2vjm2bJTJtFDkZX5VCrw4nYR3fx9kWLlaZ+CODL441r9SE+wn6wnlsnU X-Received: by 2002:aa7:92c5:0:b0:4bd:9f44:9562 with SMTP id k5-20020aa792c5000000b004bd9f449562mr16012268pfa.80.1643063471730; Mon, 24 Jan 2022 14:31:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063471; cv=none; d=google.com; s=arc-20160816; b=IQJqbu9LqAiuWnSQagtsClHuZVRrLYCXpewDIYfcYZCbT0JmMZPiakHbvToUXIdGBm 4pGof1J2i6Rmm+pmQWfUakXZBkqgiF/Ot7t11MCWUOjbRo9UsjCsIAUxoE/Mj2wYJ02A n6qWVSc/Qet0e3NFFmyXZr2TiXm/9ONTAxqPxZkiOI3BEWNBBdvSYB3qHB1GXKH+ZoYW Kh+WaFijlPX0/TyrSFcHbWiRQH5Jtwf1dqA9YnlprzjI1rxdBBeauuOHAEwxSziOCz7H e4DcEcEK9orlCp/0Ep0+LFr54JkeVCkLAdGONIY0ntawtfbasI66zQuzyu9gd20jO+Ue xg5g== 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=ivqy68XALlLPi+huYSRGqCyGs8H1p0pUEc//8Rz1+EY=; b=UpwYfV2AZGnkP8F614wKNBjAczqAr8FHkPGxHH+vG9Ju64NZjM0hENtfwWa2V81SKk 6vF1iBZpCM9jh5ALeJTXL+PrTQVmpJp8TEAMp3ocGfKG//LjceDolPCrD8vgjFA+NRlA RrqZp9hhI6+bmZi3EusohJZqtmnnw1W4TKu2vzWZtKxwYEe/7cxOeOqgveVJL8d8wSCe OCW4B5UxAbxrXp+KhPBZhf1PgSXgyZ4VdNGiUp3JZuQE0n+/pcgutC3qWbm/MgA5Q9i9 4fUJIApQImsXfv5tc0re1t76WGyQBOJ118dErKR68812zn9SVYirl58yl7zhbJImTjNj DM+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q7faK1AS; 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 z3si13205471plo.583.2022.01.24.14.31.00; Mon, 24 Jan 2022 14:31:11 -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=q7faK1AS; 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 S1586561AbiAXW0y (ORCPT + 99 others); Mon, 24 Jan 2022 17:26:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1390869AbiAXVM6 (ORCPT ); Mon, 24 Jan 2022 16:12:58 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C37A5C06E005; Mon, 24 Jan 2022 12:10:41 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 6BAB6B811FB; Mon, 24 Jan 2022 20:10:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82CA4C340E5; Mon, 24 Jan 2022 20:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055040; bh=+ZEnUcY7+RPgzxA8XBOKMNeE7kGEnqhjp3FKXau1vAk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q7faK1ASwMhyJHrh7yRyK3rtF4+4+MHn5+WO7T8hWo5c4jh6zuV2OJVoMadEFvKJu InANxyHIY8yGgmvNftL7Xh+nKILCF+qrTcqzn3b2PT1qlovzsUknyCnw2zW4ki1sPR ain473K3GiJA0J4YkHAyZ2FaP6UzWI6sIl64wuCM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adam Borowski , Anup Patel , Sean Christopherson , Palmer Dabbelt Subject: [PATCH 5.15 022/846] RISC-V: Use common riscv_cpuid_to_hartid_mask() for both SMP=y and SMP=n Date: Mon, 24 Jan 2022 19:32:19 +0100 Message-Id: <20220124184101.685507705@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: Sean Christopherson commit 869c70609248102f3a2e95a39b6233ff6ea2c932 upstream. Use what is currently the SMP=y version of riscv_cpuid_to_hartid_mask() for both SMP=y and SMP=n to fix a build failure with KVM=m and SMP=n due to boot_cpu_hartid not being exported. This also fixes a second bug where the SMP=n version assumes the sole CPU in the system is in the incoming mask, which may not hold true in kvm_riscv_vcpu_sbi_ecall() if the KVM guest VM has multiple vCPUs (on a SMP=n system). Fixes: 1ef46c231df4 ("RISC-V: Implement new SBI v0.2 extensions") Reported-by: Adam Borowski Reviewed-by: Anup Patel Signed-off-by: Sean Christopherson Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman --- arch/riscv/include/asm/smp.h | 10 ++-------- arch/riscv/kernel/setup.c | 10 ++++++++++ arch/riscv/kernel/smp.c | 10 ---------- 3 files changed, 12 insertions(+), 18 deletions(-) --- a/arch/riscv/include/asm/smp.h +++ b/arch/riscv/include/asm/smp.h @@ -43,7 +43,6 @@ void arch_send_call_function_ipi_mask(st void arch_send_call_function_single_ipi(int cpu); int riscv_hartid_to_cpuid(int hartid); -void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out); /* Set custom IPI operations */ void riscv_set_ipi_ops(const struct riscv_ipi_ops *ops); @@ -85,13 +84,6 @@ static inline unsigned long cpuid_to_har return boot_cpu_hartid; } -static inline void riscv_cpuid_to_hartid_mask(const struct cpumask *in, - struct cpumask *out) -{ - cpumask_clear(out); - cpumask_set_cpu(boot_cpu_hartid, out); -} - static inline void riscv_set_ipi_ops(const struct riscv_ipi_ops *ops) { } @@ -102,6 +94,8 @@ static inline void riscv_clear_ipi(void) #endif /* CONFIG_SMP */ +void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out); + #if defined(CONFIG_HOTPLUG_CPU) && (CONFIG_SMP) bool cpu_has_hotplug(unsigned int cpu); #else --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -59,6 +59,16 @@ atomic_t hart_lottery __section(".sdata" unsigned long boot_cpu_hartid; static DEFINE_PER_CPU(struct cpu, cpu_devices); +void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out) +{ + int cpu; + + cpumask_clear(out); + for_each_cpu(cpu, in) + cpumask_set_cpu(cpuid_to_hartid_map(cpu), out); +} +EXPORT_SYMBOL_GPL(riscv_cpuid_to_hartid_mask); + /* * Place kernel memory regions on the resource tree so that * kexec-tools can retrieve them from /proc/iomem. While there --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -59,16 +59,6 @@ int riscv_hartid_to_cpuid(int hartid) return -ENOENT; } -void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out) -{ - int cpu; - - cpumask_clear(out); - for_each_cpu(cpu, in) - cpumask_set_cpu(cpuid_to_hartid_map(cpu), out); -} -EXPORT_SYMBOL_GPL(riscv_cpuid_to_hartid_mask); - bool arch_match_cpu_phys_id(int cpu, u64 phys_id) { return phys_id == cpuid_to_hartid_map(cpu);