Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2929078ybx; Fri, 8 Nov 2019 11:24:03 -0800 (PST) X-Google-Smtp-Source: APXvYqx7Jtk0evnpFA1sZzJH25PZmGwjLc+HBdQFlmFgvnz51x5jlQMza1jUvjL901++yGWM/Cji X-Received: by 2002:a05:6402:1250:: with SMTP id l16mr12146003edw.219.1573241043638; Fri, 08 Nov 2019 11:24:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573241043; cv=none; d=google.com; s=arc-20160816; b=b3JNjO6StxU1bmhr3zzWeNWgNYdTOytguywuOyrm3kTrFNV/xCMxf5gPbNnFoxbFrf enwFnhNabcTfxO5HdrYRcGr7NsovHUyGbO70j41GKzML0fKCqF32FixNCqBQOWusDtDx q4Cjd+6y9Z+2qHV/6td0jiaDkvAfIfTBMBIrgFavoshaJOkbzMh/9Ghi0JqLBv7WM1+3 ywWGYufZNkEnqg4cfePbdt4/evS2zWAv0mVobsXbHG6cuL3LFKV76aVGeUS5zp3S3kYi tVJfpV7Zqv/wv6wclaEUeuBlW/jtjkwDYdJuRQI0lEbfC64dpuYdT5A1P3EyuY19lBra 5wpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=janCzX5uMO+3XoPUpE12/BZAm8/gBu+y9hTZfvjHNf4=; b=yVPi+jAiR36XcScQHerEzX2eTz8Dt+rwJ6jJAO9EMAjbq73BAYG+XWMJkx+E/KjRi8 hEWSlN2KBTebmqU0jNWCJDUzKFdc7YvI7tpDi5OvUZCiAwmALxCWsqznkWqS/GcNdnTj Gklf2q3Im993Vpn8mWN2EoslZeey6DSGkgvqgPTHqj3uWkfeSU9WviGzmqJCmWPPfESF tgNmBIn4X8pF5wSdtwwqSobsbLe5cT0Cl142IHqPJJu6t2lnIxGUUAKRYwpYJkQyYM94 XiEfNbsMAglWrAV/fb4+Y2fkuMdg/k7sYbjvqkx0ac3ph2d/Cr2AQ+ifryExhBz7kG9s qmMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="wF0x/lWW"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y12si4517173ejp.299.2019.11.08.11.23.40; Fri, 08 Nov 2019 11:24:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="wF0x/lWW"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390933AbfKHTXB (ORCPT + 99 others); Fri, 8 Nov 2019 14:23:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:52394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731463AbfKHSzR (ORCPT ); Fri, 8 Nov 2019 13:55:17 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7E651214DB; Fri, 8 Nov 2019 18:55:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573239310; bh=1Etv9ePy6Sr1Bpx68YN+nF41DlpzSoObXTIf2hx/zfo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wF0x/lWWDtr4xqInCrYfGH8gXYVwkLKxWyFwF5YQzE8PnSilzav75v8IXyEFw9KdW EQx9ahFAGkQy5lW+cOqEUHwS+Mhn1UbQ06hsI7Sg9ZX/nmkfadJAeplhCT9GmoHuhd uiNDEfA9xSLNUV5YILUbtZFTtP9MWgK7bf9sZy2s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , "linus.walleij@linaro.org, rmk+kernel@armlinux.org.uk, Ard Biesheuvel" , Julien Thierry , Russell King , "David A. Long" , Sasha Levin , Ard Biesheuvel Subject: [PATCH 4.4 70/75] ARM: add PROC_VTABLE and PROC_TABLE macros Date: Fri, 8 Nov 2019 19:50:27 +0100 Message-Id: <20191108174811.038442025@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191108174708.135680837@linuxfoundation.org> References: <20191108174708.135680837@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Russell King Commit e209950fdd065d2cc46e6338e47e52841b830cba upstream. Allow the way we access members of the processor vtable to be changed at compile time. We will need to move to per-CPU vtables to fix the Spectre variant 2 issues on big.Little systems. However, we have a couple of calls that do not need the vtable treatment, and indeed cause a kernel warning due to the (later) use of smp_processor_id(), so also introduce the PROC_TABLE macro for these which always use CPU 0's function pointers. Reviewed-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long Reviewed-by: Julien Thierry Signed-off-by: Sasha Levin Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- arch/arm/include/asm/proc-fns.h | 39 ++++++++++++++++++++++++++------------- arch/arm/kernel/setup.c | 4 +--- 2 files changed, 27 insertions(+), 16 deletions(-) --- a/arch/arm/include/asm/proc-fns.h +++ b/arch/arm/include/asm/proc-fns.h @@ -23,7 +23,7 @@ struct mm_struct; /* * Don't change this structure - ASM code relies on it. */ -extern struct processor { +struct processor { /* MISC * get data abort address/flags */ @@ -79,9 +79,13 @@ extern struct processor { unsigned int suspend_size; void (*do_suspend)(void *); void (*do_resume)(void *); -} processor; +}; #ifndef MULTI_CPU +static inline void init_proc_vtable(const struct processor *p) +{ +} + extern void cpu_proc_init(void); extern void cpu_proc_fin(void); extern int cpu_do_idle(void); @@ -98,18 +102,27 @@ extern void cpu_reset(unsigned long addr extern void cpu_do_suspend(void *); extern void cpu_do_resume(void *); #else -#define cpu_proc_init processor._proc_init -#define cpu_check_bugs processor.check_bugs -#define cpu_proc_fin processor._proc_fin -#define cpu_reset processor.reset -#define cpu_do_idle processor._do_idle -#define cpu_dcache_clean_area processor.dcache_clean_area -#define cpu_set_pte_ext processor.set_pte_ext -#define cpu_do_switch_mm processor.switch_mm -/* These three are private to arch/arm/kernel/suspend.c */ -#define cpu_do_suspend processor.do_suspend -#define cpu_do_resume processor.do_resume +extern struct processor processor; +#define PROC_VTABLE(f) processor.f +#define PROC_TABLE(f) processor.f +static inline void init_proc_vtable(const struct processor *p) +{ + processor = *p; +} + +#define cpu_proc_init PROC_VTABLE(_proc_init) +#define cpu_check_bugs PROC_VTABLE(check_bugs) +#define cpu_proc_fin PROC_VTABLE(_proc_fin) +#define cpu_reset PROC_VTABLE(reset) +#define cpu_do_idle PROC_VTABLE(_do_idle) +#define cpu_dcache_clean_area PROC_TABLE(dcache_clean_area) +#define cpu_set_pte_ext PROC_TABLE(set_pte_ext) +#define cpu_do_switch_mm PROC_VTABLE(switch_mm) + +/* These two are private to arch/arm/kernel/suspend.c */ +#define cpu_do_suspend PROC_VTABLE(do_suspend) +#define cpu_do_resume PROC_VTABLE(do_resume) #endif extern void cpu_resume(void); --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -625,9 +625,7 @@ static void __init setup_processor(void) cpu_name = list->cpu_name; __cpu_architecture = __get_cpu_architecture(); -#ifdef MULTI_CPU - processor = *list->proc; -#endif + init_proc_vtable(list->proc); #ifdef MULTI_TLB cpu_tlb = *list->tlb; #endif