Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp96805imj; Thu, 14 Feb 2019 16:08:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IYPfK5anZ317uF/Qx13/xw6vpxSv7txc9RqCWTXWGoTJevI0+wAeYSvno9CnR7z5JZ32p17 X-Received: by 2002:a65:46cf:: with SMTP id n15mr2597537pgr.187.1550189331178; Thu, 14 Feb 2019 16:08:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550189331; cv=none; d=google.com; s=arc-20160816; b=x9PDst3Fcoh9R6tiNjZYCZVoTyxSwes+MhqBacgce1iIXcNnGq8jYqysrU98EptNlK romGF5xBvrwZrK9fjMZLONnPOGcP257uisuXT6wZHAWar6gegCeFYfZEiNYDK4nfK/UE qZ9fAeR0yWuXhSZpx6O9j7IOoMDsQcq3aQafSOH5hJMBt2H1psjjq7jnEwcdL2cY2Gq8 B/f9BDgpTSQ3nKCI/rx1IKPdkx+gXF9lnjJXBSczs68+T/6bw4+CeB2BJCdfXuVPtgQU En10Xj6EH9ohy8NgALGLHorNk/6SPwevJtGYU5vdN5u0/4VavoXCQiknylvZf0jToDrd TkLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=xJy7kJT4fBiBIJxxTbPYvInu/DuxzxwAzrjcMycc8Po=; b=qzhHPOMuSQrErH1fa8hN8r2yA1GE/Q/yNj6cGsFFF+uNYXXvl8efLph3wgYfSWiro4 xLeSYA7tud9eDxhGi1YldrD7CUi5i64PBaKd7QiFcqWBd9vOGQpMdtxPIGRCFZrTQhVX Li0ZKSmCFLkOb7xzTbf+V9pp/tG3TzSvQIgxuJu5XnJpiRznvbDYGLIk8q0D8Pix9/Vp w+9UZ5ioqh1GuNMvom8y52oyzYlH9T9dzFAqZMxv5jJRajYQ7v5fsp8Q6L4lkxpqesFx qO6UG+dVQhDYhiJR8Jk5F8BFbd4hYL63+gFCuZUgtKD+wPZOqEcix1jjUrq95hv1x+0h uxPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sCjhpD7i; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n23si3740655pff.10.2019.02.14.16.08.27; Thu, 14 Feb 2019 16:08:51 -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=@linaro.org header.s=google header.b=sCjhpD7i; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439399AbfBNOuR (ORCPT + 99 others); Thu, 14 Feb 2019 09:50:17 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:35696 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439347AbfBNOtv (ORCPT ); Thu, 14 Feb 2019 09:49:51 -0500 Received: by mail-qt1-f193.google.com with SMTP id p48so7119988qtk.2 for ; Thu, 14 Feb 2019 06:49:51 -0800 (PST) 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=xJy7kJT4fBiBIJxxTbPYvInu/DuxzxwAzrjcMycc8Po=; b=sCjhpD7ifrZCFfat2bEgCm0Dk7L04XJM88o1B6DttO4sqPHuKeb9tv5I+fClnAlngZ 2O7LPYRayzEvvnutfmoCuJ902oO2zjBTLplVlvpPbVwDSLJLqvtchrC8L2TD18B/6kVW +klmS2egDFmhHjRCjTkoWN9pxVKyGg0k9850JPJk9sULAZOtZDjARK4XetRKyZeroZ3Z SBi2PSVBEORPCR7U0pgvgqlhOrAgt2gihl+8w3BOnpyfXlsRgz7K+97iutkicJrdwPcH BQdO0WEAcdxd72x9vCQl52G2EHMQHpalgM1pdzEEMzZGExjWo8CJnA+b70xYsCfNiZj6 MXJg== 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=xJy7kJT4fBiBIJxxTbPYvInu/DuxzxwAzrjcMycc8Po=; b=Rv4w9mEoA2vvE+C9PCEovoJMg/fnoUtbipKRm/p7ha2QHyP3M/zOqRpVk3Np7ITf0h yb1HmiIwuR/rObWC7bMW6bVxpg1xRE0ncps80/FlsxsIBgvD2XxAjXPuff2Uxw8XCOq6 6GoXaOpIhrF2gSahfcVjmefphO8Tk0NwmdMomagJPWk/ZfbFLjxx+Z0N2VlVL+XTAEgS PrLD69ygfS34F2uQEKUyrfZ0jTZLu6sPobyWz2B9hVQE1uaV8R9u+HdWHQa0Uwh8mAaO KcqWju1PGK8rvRNojqSXd6W5bF2PgRFvH6Sfz9JUpU4YnZBJzWJQIdFRYT6pzH+sYSDL CJWg== X-Gm-Message-State: AHQUAuZDvRVuOfFbRX2AbtPib2sJEefm4zRR57qny0jCtmZ8661a82JS /62gCcqRr7Li/LzUAuxuqL5P2AT4gdA= X-Received: by 2002:a0c:ab8b:: with SMTP id j11mr701397qvb.28.1550155790606; Thu, 14 Feb 2019 06:49:50 -0800 (PST) Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id k66sm1498919qkc.25.2019.02.14.06.49.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:50 -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.9 13/16] ARM: add PROC_VTABLE and PROC_TABLE macros Date: Thu, 14 Feb 2019 09:49:27 -0500 Message-Id: <20190214144930.27539-14-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214144930.27539-1-dave.long@linaro.org> References: <20190214144930.27539-1-dave.long@linaro.org> 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 --- arch/arm/include/asm/proc-fns.h | 39 ++++++++++++++++++++++----------- arch/arm/kernel/setup.c | 4 +--- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h index 19939e88efca..a1a71b068edc 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) __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 8d5c3a118abe..2eebb67fa08b 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 -- 2.17.1