From patchwork Wed Feb 13 21:32:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158266 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp561035jaa; Wed, 13 Feb 2019 13:32:45 -0800 (PST) X-Received: by 2002:a0c:d7c8:: with SMTP id g8mr211122qvj.63.1550093565231; Wed, 13 Feb 2019 13:32:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093565; cv=none; d=google.com; s=arc-20160816; b=WlcvTU7YFubhMNR5Nh8TCVM1gd+5YU2ATQwxldq8LGZvqEH9Ypd+PQ2wpf7kmjVPug l7HZpu89hgAmmsKfs/soxvMl8CyWHB1Antbdh7oFQzYEp3oBcSEYrBxY65El3vsBXDwM 6yuDPcA+Ls2uUveE+W1o5b/QY9XTJAr5/lOGBKDEik4Q6t3IoUtytVUDcb1UNX/cnnC/ APMfbI0OucWFq8VDhjbUNK56J6pCU2zCOL6bgEMXdLGORhxjovgcIKug4Cw4X50iDy6Y O69HzEfPSEU1iuBD6KKRMRSQ75C0SAgDX8ps73fhyRtHmxN/KyLU9mCLaYEa6i2LuxB7 DRmQ== 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=lLS6GiZ4CUXJ8rZLEaclNEJmcH/KdjbjQyrYJi4C1Xc=; b=bxJS2IQ4zZkzz03NyNbp8kpWIo0WRW7TqklgfPy8zB080Omq+dGp6LIhdMYVpNDwSl 1etRNqEAFRVuxvI7vLn5kSDosRZlrYcSKNfzB1ORyh9gjBg09Zw4uI/oxEGAtJmJZAY4 QsA0KZ6j2LXrCkeWGD+OoyFe6+iWoSIaAIzreFRerNy/Ye8dfksiM3pl69DHNFHNSh7C 6my2lKOFrWqUHWtRc7kHwdUjWTdCG9lOnkBjprLmtebCij/D8wXCWuUnJxXozeRfcoqT ak6T0NhYSpcGYRRu90Y2lCqODIpl6RJ8rdoGRVPxgwCfAt+VJlAYfZhsdW1Jvir7vPEB TX3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PRfj7dqk; 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 q4sor499623qvq.62.2019.02.13.13.32.45 for (Google Transport Security); Wed, 13 Feb 2019 13:32:45 -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=PRfj7dqk; 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=lLS6GiZ4CUXJ8rZLEaclNEJmcH/KdjbjQyrYJi4C1Xc=; b=PRfj7dqkDYgvl5XUoxlfk1tlHRkWzgxQhq1sMVagMpNVzKlDR52K21Rjn/fawFuCaJ TuCb/U23JS3bvYI1GwVEoQjMYvlf7f0nHa0ddmLeeC7U9rZ4QGwd/lcXiLqxbxlN7phc T52SsYUsITCJ0JnbWKHIP8fYozOMpwtDihFjB01ItbUYZQEOqEK0Y6CS4isldusG5Q2T rgfxA/YbMeHUEZShZtMXHpdQvu3Uqrm0242LlOigdf0bFpFyQSmxm0Ry42RU2nB0o7XI jcdlcbh++VLX565AnURx4tiMzD0hlWdntZNSh/eXi+KhqR0aEktIGzTLu93g5HdPjhqr PXsg== 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=lLS6GiZ4CUXJ8rZLEaclNEJmcH/KdjbjQyrYJi4C1Xc=; b=YIhvNvT2rxQmZQcma6yrAzjoS8ZYYbXU/DCRLmMuZGQ/RYPMVhTCEf5flqlv40+Ki5 hJcdXSPgBUtWS4+wbptfO827tQsLrIzYTsGslBbNjk+1DtKMzryJ2mz9Y+vSlWrNR2hM 5eFq/ALgjfUJXpuhoC5KcrNMEA+hkUmLfixU9OXVwTYn1iq1faEu5+2X30OjuYGmuItX 2TSaX2ChwrgLBQm+5dXBNH85hN6mn0das7e0eDzrG6t4bzd/IM1J+IUylHqQmssLzsq6 Jh4H9SOfHMFFDLq/kGdkPgZf6gClSDS3c8La2H+BJuV3Gv1seYCvsMWLy71PP2UjFqz5 iCYA== X-Gm-Message-State: AHQUAuZYTQv2jEPlOD9JdCBDD81KtqyHgjUhCA5wECbTIo/G8LJixNCv 9mpykedG1ppDnlQJcX0thVdSF0mBg7rlxA== X-Google-Smtp-Source: AHgI3IbPF4fPqbClV2fCpcnwO2Iou7NLJVsbXAsV7htoA+WblfJgTeFYwF4LjOFZtBSHa/m3Z0adGw== X-Received: by 2002:a0c:9587:: with SMTP id s7mr207806qvs.155.1550093564953; Wed, 13 Feb 2019 13:32:44 -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 8sm382675qtr.7.2019.02.13.13.32.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32:44 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Greg KH , Mark Rutland Cc: Will Deacon , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4.19 14/17] ARM: add PROC_VTABLE and PROC_TABLE macros Date: Wed, 13 Feb 2019 16:32:20 -0500 Message-Id: <20190213213223.916-15-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-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 8fd7baa158a4..f269f4440496 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