From patchwork Thu Jan 10 17:51:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155259 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176365jaa; Thu, 10 Jan 2019 09:52:14 -0800 (PST) X-Received: by 2002:a37:c597:: with SMTP id k23mr9940582qkl.87.1547142734197; Thu, 10 Jan 2019 09:52:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142734; cv=none; d=google.com; s=arc-20160816; b=KAi4aOpAk8WmPrqhSJE5LSjUZHDjfu41zIG3ajpycs5uCgfWo6EjAwjucts1VsxzO8 +Z+yJGnx/FYWzaFQQ8M7sNGUkWQiCgi67DMfotiP6bG+yZtLNBhn+m9b/MHFtqW52Q8q waeexzWOMxAkUSfqYBWYdqVkQwwKkMTRXZlCGUvjEuUuWFcLMNfsyDsrOmcLlXG4aRKT kpfcc4njRmR/s1Gs0bpFb1ZAN6YD/WOgItEbeebn1KftTNjI4NSasEzDRXExUDn5V9br vzIzUVrZQBH7ImkTQ3El2/1zS0lr0EPdxRZVci/2tNmRoQ5jS4JiBqSCWicqvqWU42i/ EhPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t952pQdCO8vFdgrbc2uvLXfj7ukUT0YFXZtA0v/0jfM=; b=PrnLQ4aefuSL/cFlEREa9p6aPlGEDOpIRkttZm5WcHEwohvlpKmunCfWvbXFlZvSgU svvMTmMold8KKJPnK5FMHK3SoPsX2mc5aRtNUauBeljbPvPtKcSiCsuCRTb8NZaV8yf0 pBiidHDP01kV+1UL1+WkdEHxbK2dwIxLhBuVPrca+ASM7RcFgr2lc5f4Sdhs+XjikBBE LwVqRju33UydNJiHd3HY+66X24TEZp4pcMFujMM1iJTKmTQSIK+COOUrZ3ccsfyHUasH UA6+A+At7bAbTcvHmq8k0ZaZm93uBjtvWWdhoA3O2+b4/G8GTyBrces8g4nC2Lfmmzvp MVSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JXtdP9T7; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id s28sor72832402qtb.48.2019.01.10.09.52.14 for (Google Transport Security); Thu, 10 Jan 2019 09:52:14 -0800 (PST) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JXtdP9T7; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t952pQdCO8vFdgrbc2uvLXfj7ukUT0YFXZtA0v/0jfM=; b=JXtdP9T7Cs3LhTdzDrY08i6vdUaF3gv43ZUkvzuWe0zFMT0kz9e3s4x6lJxO1UqhsK 6WBg8h5Sg4ItaPt4cvBJdNa8bUZUO4P1pDapBDdu69VHZWj98GxOTM0vJn34FuZR7QUj pDT0dvue7fm9vfi4sgML/WxVj/nUSB13x6SXM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t952pQdCO8vFdgrbc2uvLXfj7ukUT0YFXZtA0v/0jfM=; b=en7ZgiE+rXO/95O1ezynrWh06NXO1C6A9iStqZ7t/qIpIZ7HbqBfQhXQIaW22lt1t6 EJ2ICy2CV9VtZzd6sHVlRiKRwEZHHA+aYr+qZFEn3BgW006l+6yilUn6PSIcZ8GnTrzV BLegAMpt+Ny9MHKEeVyBVngyT4OJqDsWrzCS2wRWM+YFNfx2kz0Q4cXkQyiTcY4uLArZ 0rMa85i7c3/ux/vWsBSrD+mpEb+SkAcFoZq+Ea1VixZLzXNafP0YQlcMPS7B8DIPg6SO mswIHUMWLbeVlwXQ8biP0ih510ZSo1qwxIbxe1uQVhtSmV0950kg1G03gRUgM9lIgUTK oECA== X-Gm-Message-State: AJcUuke7uSD7aY6yHqN5Yt62B8tWdpns841nKWIGAt0XS7CJGr2Hi3r7 NwVb1n4CquX1wGvmOFPAaGo1vgJa X-Google-Smtp-Source: ALg8bN7cx7Us0e8TkRd3oRiSTaSWJbY0kHc+PLrLI8CIl2gA2jJYbp35S7iaN1cdU2rLA0KYwGWVbg== X-Received: by 2002:ac8:1b82:: with SMTP id z2mr10765974qtj.321.1547142733935; Thu, 10 Jan 2019 09:52:13 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id b8sm41815904qka.79.2019.01.10.09.52.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:52:13 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 14/17] ARM: add PROC_VTABLE and PROC_TABLE macros Date: Thu, 10 Jan 2019 12:51:47 -0500 Message-Id: <20190110175150.5239-15-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-1-dave.long@linaro.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 --- arch/arm/include/asm/proc-fns.h | 39 ++++++++++++++++++++++----------- arch/arm/kernel/setup.c | 4 +--- 2 files changed, 27 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h index 30c499146320..c259cc49c641 100644 --- 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, bool hvc) __attribute__((noreturn)); 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); diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 1a041ad4881e..c1588e31aa83 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -693,9 +693,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