From patchwork Thu Feb 14 14:49:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158395 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462077jaa; Thu, 14 Feb 2019 06:49:34 -0800 (PST) X-Received: by 2002:a0c:b5c8:: with SMTP id o8mr3262938qvf.213.1550155774737; Thu, 14 Feb 2019 06:49:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155774; cv=none; d=google.com; s=arc-20160816; b=hBTNtAJXT0ij/SPtlhhD02R1kZhk4UoVNkwIMfTQrXWsE6rbJEXxEM3QKbh+6reI4d /1ATxzIvFKji/e5fRknWVJljxOdKTbCWGIJL6CkSNHhfzzKC/FDpHuIwDmiIcdf6pnLj 9FhlfvaczYdmHseft8dK5QySOPSE16GsJxpMm7jmDYPjQ/T5MI4Gfo7Rqq9jg2m3L/0N LIoAZB7wRPCnMRTWeKhQwKqpF+ajcGfTMovko3cxcvwE4BNMPzcVhEBVKqP+pnEcjXU1 PWc7OT9H5m9PlsBX6q4PM4hSe6xfFnvLV+92w0WNJV48XqjPsb2iKtf0BkBVuw/EJGRP tA+w== 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=4WIiFnR286YtXg1/WuUdSZbEmbvXJmwAS0RFyIqCoow=; b=cgtcBsTG5O7AzAuSgv/jDpX47dCtgytIkmR28YzAVD3CA8tJNspOeXO8hRFFNVI1fU pNOTBGhZ4g5aGsFlk3IZwm2sUYXmFr03EeHlvHjqZ3GT0Ixw1ZvEqRHgneSls1EB8nPM sMge9X9oalXYfDq1RpoSrIUqAB8b+LL+rvcBx39IcmSfTOznJSMQ1ebjzWDOKG24frRx Y3+Ug4fqcjTUqp68nJbEdFSV5eGF61u6JB72zXyUnOuKUGoPK0qSn3+yHIBjDVHY8cDb d2Sl8LplbJdbbuLCjqC9FqELPfPGeFkN4Ss0r+W/tCl5sOkRsbjfbt4QFkhSdVxDfE3T 6U8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vjS+347F; 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 u51sor2909145qvh.52.2019.02.14.06.49.34 for (Google Transport Security); Thu, 14 Feb 2019 06:49:34 -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=vjS+347F; 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=4WIiFnR286YtXg1/WuUdSZbEmbvXJmwAS0RFyIqCoow=; b=vjS+347FIqlPezMcSF9P1GiEymL0yVmYKwHcKvIn5Zh1j81NA3K8pt355ZvyM3oFEL o+nBQ1EPz/TvytR6mW8IYuHkylt/2oRDy+Al43fFGBrwOZX8yu4KxL/mWYurEImpc2v3 v1/BD0g1jWrB8FFfItN8RE8aF+3X4P4NViFcEr3XKU6mRUD/PHBBIQ/7GaX+GOjAplgS CNVm/Ka7UAUzVcOHtxp8AVZIgp3NLQQZIg+kQydJ0zQcIUNukx+fEwpNp9y1ttEQesZq 4JQaC6JzwE0F8sU8emfthgJdIuYB4l+RSYOnSlN3YSJCCIovkUmRIQ3o5LCSGCxfu6Tj YpVg== 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=4WIiFnR286YtXg1/WuUdSZbEmbvXJmwAS0RFyIqCoow=; b=OrM9ekMcwb59JepdvllddWZsxxDTjGfti+NUeiVppO7tl+2uMTXeT0+zkjzoj2ufG0 gdB83IpMuqZsJyx4VdgZhrGg2HGXncJMKfnWfNjXcElK13+Z7c3+gKZMUlcjO6tFnrAd v8SoiR31+V7227f3+pi18B1d+ji2iDhzsC8mAQOSIrzYkVc8csDSm0KXMN3S6D5sUTNR 3g4XWmnhp7roF/lmjO1s5kJWmJclXKchv5xn4VX8OVC14IQ81DkNQrikEfBWHnnQnEd/ dc1iTJGJPlPlvjRxvVMPuDS/SCMIDcPGaP/DsvoJvpNOY7DIX21QlEC4NwBfn8JIfjiY 3pEQ== X-Gm-Message-State: AHQUAuZpjbg4MtJxt3+kXX8zILAqlIH5TTKRnbOOZVTAlX404nCFl+Iz TCW+H/HOgnKvdlhuIMuN3UkOp0w3 X-Google-Smtp-Source: AHgI3IbTd7fk7ewlUXB/CpYwJJAWXjLLqU8R609Vcmhiohlg+LEEECOFCGSqLwtZ/hLlk2SpHaUXCA== X-Received: by 2002:a0c:d2a5:: with SMTP id q34mr3277880qvh.102.1550155774386; Thu, 14 Feb 2019 06:49:34 -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 k66sm1498919qkc.25.2019.02.14.06.49.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:33 -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 01/16] ARM: 8789/1: signal: copy registers using __copy_to_user() Date: Thu, 14 Feb 2019 09:49:15 -0500 Message-Id: <20190214144930.27539-2-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> From: Julien Thierry Commit 5ca451cf6ed04443774bbb7ee45332dafa42e99f upstream. When saving the ARM integer registers, use __copy_to_user() to copy them into user signal frame, rather than __put_user_error(). This has the benefit of disabling/enabling PAN once for the whole copy intead of once per write. Signed-off-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/kernel/signal.c | 49 ++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 22 deletions(-) -- 2.17.1 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index 6bee5c9b1133..fbb325ff8acc 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -256,30 +256,35 @@ static int setup_sigframe(struct sigframe __user *sf, struct pt_regs *regs, sigset_t *set) { struct aux_sigframe __user *aux; + struct sigcontext context; int err = 0; - __put_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err); - __put_user_error(regs->ARM_r1, &sf->uc.uc_mcontext.arm_r1, err); - __put_user_error(regs->ARM_r2, &sf->uc.uc_mcontext.arm_r2, err); - __put_user_error(regs->ARM_r3, &sf->uc.uc_mcontext.arm_r3, err); - __put_user_error(regs->ARM_r4, &sf->uc.uc_mcontext.arm_r4, err); - __put_user_error(regs->ARM_r5, &sf->uc.uc_mcontext.arm_r5, err); - __put_user_error(regs->ARM_r6, &sf->uc.uc_mcontext.arm_r6, err); - __put_user_error(regs->ARM_r7, &sf->uc.uc_mcontext.arm_r7, err); - __put_user_error(regs->ARM_r8, &sf->uc.uc_mcontext.arm_r8, err); - __put_user_error(regs->ARM_r9, &sf->uc.uc_mcontext.arm_r9, err); - __put_user_error(regs->ARM_r10, &sf->uc.uc_mcontext.arm_r10, err); - __put_user_error(regs->ARM_fp, &sf->uc.uc_mcontext.arm_fp, err); - __put_user_error(regs->ARM_ip, &sf->uc.uc_mcontext.arm_ip, err); - __put_user_error(regs->ARM_sp, &sf->uc.uc_mcontext.arm_sp, err); - __put_user_error(regs->ARM_lr, &sf->uc.uc_mcontext.arm_lr, err); - __put_user_error(regs->ARM_pc, &sf->uc.uc_mcontext.arm_pc, err); - __put_user_error(regs->ARM_cpsr, &sf->uc.uc_mcontext.arm_cpsr, err); - - __put_user_error(current->thread.trap_no, &sf->uc.uc_mcontext.trap_no, err); - __put_user_error(current->thread.error_code, &sf->uc.uc_mcontext.error_code, err); - __put_user_error(current->thread.address, &sf->uc.uc_mcontext.fault_address, err); - __put_user_error(set->sig[0], &sf->uc.uc_mcontext.oldmask, err); + context = (struct sigcontext) { + .arm_r0 = regs->ARM_r0, + .arm_r1 = regs->ARM_r1, + .arm_r2 = regs->ARM_r2, + .arm_r3 = regs->ARM_r3, + .arm_r4 = regs->ARM_r4, + .arm_r5 = regs->ARM_r5, + .arm_r6 = regs->ARM_r6, + .arm_r7 = regs->ARM_r7, + .arm_r8 = regs->ARM_r8, + .arm_r9 = regs->ARM_r9, + .arm_r10 = regs->ARM_r10, + .arm_fp = regs->ARM_fp, + .arm_ip = regs->ARM_ip, + .arm_sp = regs->ARM_sp, + .arm_lr = regs->ARM_lr, + .arm_pc = regs->ARM_pc, + .arm_cpsr = regs->ARM_cpsr, + + .trap_no = current->thread.trap_no, + .error_code = current->thread.error_code, + .fault_address = current->thread.address, + .oldmask = set->sig[0], + }; + + err |= __copy_to_user(&sf->uc.uc_mcontext, &context, sizeof(context)); err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set)); From patchwork Thu Feb 14 14:49:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158396 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462106jaa; Thu, 14 Feb 2019 06:49:36 -0800 (PST) X-Received: by 2002:ac8:21ce:: with SMTP id 14mr3305793qtz.306.1550155776073; Thu, 14 Feb 2019 06:49:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155776; cv=none; d=google.com; s=arc-20160816; b=Bbby0y/vkNB3HB+vkvq+HH7pdYZiwC0N1CYma1UgsUBTUePU5aXioEmHg+DJ42ghrY vCIdyaVciz1QAyw7+D7O8ZLiZNlz8CnAxvzmw/34e9UyLM3+g+W2SEfA4pYK0Zqsws1z 30rEeMMJANOUBMykQPG0geW85NDO6yqbbo4e0Mv2BWKVSiCglqpnFkNLEAf/YY6yjdDL 45VsA5lq2s2gcpBiM3Tb0Z5jFaNoLUzLdxeGnLvlDRQmQ+360UAgEsF7BdONYlbuv/BJ EO7N/XbZ+6fv39at+wEAxLJ9BYsrtQrVw7ifYuKOKgq7Is7l8R//JsCVypF1iqd5cw41 ESBQ== 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=60g7G9GsgPysXeQeRaphSyl4TAccnCLeHznr84gZrn0=; b=KCYDXKuMFLhyXgJXpGlMuwcrt1a4JzkoPfUpChiYmJ2hvroUGlp99AbCLfPw/JMbvs RIWGrZU+PZxZ9bomtu7Fi8xfoVTCqiPtLiPAMeyUSsFt/aS+ItXm/dTABIkzPPOzK+NI jhl6am07psOiSx7aXQ9rL3Igsa6L54PF2M1u7RRsb4NMJ1tgU2hctTsKQqdpuyy+rCfP WXENRIFyofrP9FCIP0GxDJQlTdiQ317y2wX0arQRdVkEXRODGaf2O5EbxAzipr6KMea9 whHVOmmFmYKgZtsZdr06HQ+g48n3VcRo2apBDVkyS4sTMNh3KT9mlkqYjbaRVNynqLoY yH1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="V/EIJY9B"; 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 c47sor2909797qvh.6.2019.02.14.06.49.36 for (Google Transport Security); Thu, 14 Feb 2019 06:49:36 -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="V/EIJY9B"; 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=60g7G9GsgPysXeQeRaphSyl4TAccnCLeHznr84gZrn0=; b=V/EIJY9BGKspAndcNIdR3th42CLoUkdNivW75Klm61UNfZ5bUDb+8pQ9YgZ+aV9xaW quJp2RA+dWlDK3eGad2f+vpkapMMnVGuqwuBFVIeY57WfSscvObAdyBO/a6LuYnJCadR SgaQcUcVZQ9VbZVyPs8vu7TS/YXhoblTOO9nySwB//QuURMG2g6D+Xt/OnAAbNXrpCg/ ajqXQGM6wLjN5oPZjbGUWzhvuBMl7RKG5nWYW7Xk6NHxSgcMLNBmzTLRXB5T1IQp4JSc 2mgz3bRQMV60JYS8WdZTOmCJSwl2uxAbvYrhcmPI0rZ2LPEtN2DHL0L+SNIlWzfHL+Ru gRdw== 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=60g7G9GsgPysXeQeRaphSyl4TAccnCLeHznr84gZrn0=; b=aHVzcd5H8m/+zrW7RHPPtGb26G6Jy2+GrGBEu4397A1/oYpfh7PdJQS/LV6xz+AOZ3 blEVahZUKx5DVVrgglW0YYaZ4JgAqlJxkRt7kAs0N+GtC21DT3MV0ISywihaVo7pZzOu 7ZcIlsCruCaCxLO0ADcmnOp1XXUZkk24+8mMm0rEO24g99JQpriBuKt6/ySqud3Xrrap S3ZZa6NkY1247/LYoX2fq0kcbHWQnV3igqXWpJwVY9/Z+ldzJ3vymUqd2koJpPdJIkUc C/IlphuVb9/4QjB67WmvXpALvNt1it8Ep74veB8oOvc1D/EeHJnwMPAvjRiqcGtdzumo YmfA== X-Gm-Message-State: AHQUAuad+FrMDF/17rMvAn28/9969h1WlaTD66JsNQdv4PbYEJ8aDo5o ELQ9bfWX60E1Mxg0pfOfetFos9Sd X-Google-Smtp-Source: AHgI3IbUU3fl8LTHjYQsqZGkkIyqoaHWVIlo+/lOgXaFrHX57zihf8dkPnwR1cEkqHGfrtbL0hyKSA== X-Received: by 2002:a0c:b2d9:: with SMTP id d25mr3234605qvf.79.1550155775806; Thu, 14 Feb 2019 06:49:35 -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 k66sm1498919qkc.25.2019.02.14.06.49.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:35 -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 02/16] ARM: 8791/1: vfp: use __copy_to_user() when saving VFP state Date: Thu, 14 Feb 2019 09:49:16 -0500 Message-Id: <20190214144930.27539-3-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> From: Julien Thierry Commit 3aa2df6ec2ca6bc143a65351cca4266d03a8bc41 upstream. Use __copy_to_user() rather than __put_user_error() for individual members when saving VFP state. This has the benefit of disabling/enabling PAN once per copied struct intead of once per write. Signed-off-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/include/asm/thread_info.h | 4 ++-- arch/arm/kernel/signal.c | 13 +++++++------ arch/arm/vfp/vfpmodule.c | 20 ++++++++------------ 3 files changed, 17 insertions(+), 20 deletions(-) -- 2.17.1 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h index 57d2ad9c75ca..df8420672c7e 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h @@ -124,8 +124,8 @@ extern void vfp_flush_hwstate(struct thread_info *); struct user_vfp; struct user_vfp_exc; -extern int vfp_preserve_user_clear_hwstate(struct user_vfp __user *, - struct user_vfp_exc __user *); +extern int vfp_preserve_user_clear_hwstate(struct user_vfp *, + struct user_vfp_exc *); extern int vfp_restore_user_hwstate(struct user_vfp *, struct user_vfp_exc *); #endif diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index fbb325ff8acc..135b1a8e12eb 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -94,17 +94,18 @@ static int restore_iwmmxt_context(struct iwmmxt_sigframe *frame) static int preserve_vfp_context(struct vfp_sigframe __user *frame) { - const unsigned long magic = VFP_MAGIC; - const unsigned long size = VFP_STORAGE_SIZE; + struct vfp_sigframe kframe; int err = 0; - __put_user_error(magic, &frame->magic, err); - __put_user_error(size, &frame->size, err); + memset(&kframe, 0, sizeof(kframe)); + kframe.magic = VFP_MAGIC; + kframe.size = VFP_STORAGE_SIZE; + err = vfp_preserve_user_clear_hwstate(&kframe.ufp, &kframe.ufp_exc); if (err) - return -EFAULT; + return err; - return vfp_preserve_user_clear_hwstate(&frame->ufp, &frame->ufp_exc); + return __copy_to_user(frame, &kframe, sizeof(kframe)); } static int restore_vfp_context(struct vfp_sigframe __user *auxp) diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index 8e5e97989fda..df3fa52c0aa3 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -554,12 +554,11 @@ void vfp_flush_hwstate(struct thread_info *thread) * Save the current VFP state into the provided structures and prepare * for entry into a new function (signal handler). */ -int vfp_preserve_user_clear_hwstate(struct user_vfp __user *ufp, - struct user_vfp_exc __user *ufp_exc) +int vfp_preserve_user_clear_hwstate(struct user_vfp *ufp, + struct user_vfp_exc *ufp_exc) { struct thread_info *thread = current_thread_info(); struct vfp_hard_struct *hwstate = &thread->vfpstate.hard; - int err = 0; /* Ensure that the saved hwstate is up-to-date. */ vfp_sync_hwstate(thread); @@ -568,22 +567,19 @@ int vfp_preserve_user_clear_hwstate(struct user_vfp __user *ufp, * Copy the floating point registers. There can be unused * registers see asm/hwcap.h for details. */ - err |= __copy_to_user(&ufp->fpregs, &hwstate->fpregs, - sizeof(hwstate->fpregs)); + memcpy(&ufp->fpregs, &hwstate->fpregs, sizeof(hwstate->fpregs)); + /* * Copy the status and control register. */ - __put_user_error(hwstate->fpscr, &ufp->fpscr, err); + ufp->fpscr = hwstate->fpscr; /* * Copy the exception registers. */ - __put_user_error(hwstate->fpexc, &ufp_exc->fpexc, err); - __put_user_error(hwstate->fpinst, &ufp_exc->fpinst, err); - __put_user_error(hwstate->fpinst2, &ufp_exc->fpinst2, err); - - if (err) - return -EFAULT; + ufp_exc->fpexc = hwstate->fpexc; + ufp_exc->fpinst = hwstate->fpinst; + ufp_exc->fpinst2 = ufp_exc->fpinst2; /* Ensure that VFP is disabled. */ vfp_flush_hwstate(thread); From patchwork Thu Feb 14 14:49:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158397 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462134jaa; Thu, 14 Feb 2019 06:49:37 -0800 (PST) X-Received: by 2002:a37:9a85:: with SMTP id c127mr3029622qke.273.1550155777301; Thu, 14 Feb 2019 06:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155777; cv=none; d=google.com; s=arc-20160816; b=h0ytx6SV+BQboECL8MuAYmO98CwFtynxE6dVNIwUVPUflp0AypLnr9sOQSiDoTdoiF jNjAu+Goy74K41BtaCZyC93/h3fMMNnOS53aBMThAcq88AhfLnpl0eQSxFD5MzTnCEqE LENR5y8yV6Ec4DzMok3vFI7jiarHtwECyn8/hrV5kbHUEEPMutjmw8O1NQvlGn7ZfUow gYZuCt/8p6n8kLx18CKL1/POEoLIMqA4NodEYkWfw5NxLERueULbzzZjQA8SBu9/wB73 ysvAD5oI+agAmgXWkkx8HFjWs7IMTn8Rj0KUjnLRmlGKM7vFj+nTOTNT1CiTal5dj8j7 vwlQ== 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=MmV7tN/knUgUsr5/TOMZopkZ7lVFuxceU9ssNxtaR8I=; b=lh6CSly7FtFaBhfBiGp/6eCppREtiMritLgmQDroTIJ/gV0LrdVtKHEBIo2Tj6DfJS 41NG/1X8C2k8sH/qs6Z9ZBSMUliUjKAxD3OkVyxfyIvixK41lJ1IS1z+7LpNBZPqCI5c JOcw94NPrVeQwAdm2AhPW029GLXKoCk+glMUi7GK376BCcYuF2bJBv0RFaWlnIE2JHYI oApAX+yRDDC3Y6dcyeCh/pESDbe4RqAHUxsCP1S2dxH6T+FFIz89lGeEdfv1kABg+5YS ENNqnLY0Ro9rdlqH2cZeMR7jdoEoWzZz2FdvOWtfZni7J9OfkbseVxqaxorv0oYtNHbD Y8ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pVsQgHTe; 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 l6sor3215020qte.24.2019.02.14.06.49.37 for (Google Transport Security); Thu, 14 Feb 2019 06:49:37 -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=pVsQgHTe; 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=MmV7tN/knUgUsr5/TOMZopkZ7lVFuxceU9ssNxtaR8I=; b=pVsQgHTensRPPDJjhW9eW0OSmKFdVMsJXvTV9Wc4PvA8CHgSyb7wXjaB8cRdBYremx 9U6G05RYzbgS7R1ZHlXok7xqM/+QFjru+/prg0CxFiVwEDe1HsXgyODuhH7WoIGJcqIL jjw/FU1o4ox5q8fL9ICBTC0TQbO0wF5O4qVEsz8+9dk+GAWrl7lvvrrOdPQEkOmYdREb s8qe4Gg3w9D1jaCDMQo196jzjVlrWXaybqK1kDWmj7WniLHSzByyuRTmkRk5KOcIuZqE Ad94JzkLfd0SUPIVi5ThlGcigDgaXNyTqQpyXth93478x4TJdqnfPokQFBpY2v0zTvGE AX/A== 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=MmV7tN/knUgUsr5/TOMZopkZ7lVFuxceU9ssNxtaR8I=; b=dGK66iAL4q5OG1bpprregH6qCKheYDDw1fDsEqfWHibZpGzgE4G/xrIy+X0oL9GIgl cO8plx7KGDRdJLvOa6rQvAo58SbS51My6/fxK11/YdsBTQQixig5yGZoTcGqeOSWrvBS 4W+AErpG+hUvRa4kdhzcWjNhl6A8eB2+2IcVyihHgo6czsQfO51Yt5xVESbxUUgVNZph /YvdfnHus98VnsGlRBfPH90kTis6YUgyhsner4c6mwI/0/bMpkSPRxqpLL9VcBtzGBU5 bu5iVp8/zVgW87tqrmLIRM93UKw1jgbV30MMBr+KRD5LdGFJ8mKbIYxGJI57gJ4lw/Kw ZAuw== X-Gm-Message-State: AHQUAuZoWCX7B3IfIOjGOZQuFs9jiGlxJQvCg+XmdDGnAZHcFr5tU+XV spC+YQQ3XdzWQfWAN1+tRY1OhRMC X-Google-Smtp-Source: AHgI3IbLsO6VEuV/Z+JIsyBOU+wJEJMgVHjY6xzsf3vyOhlYoTJwa8+CCw0djgURk4585epwQbVivA== X-Received: by 2002:ac8:1413:: with SMTP id k19mr785431qtj.134.1550155777063; Thu, 14 Feb 2019 06:49:37 -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 k66sm1498919qkc.25.2019.02.14.06.49.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:36 -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 03/16] ARM: 8792/1: oabi-compat: copy oabi events using __copy_to_user() Date: Thu, 14 Feb 2019 09:49:17 -0500 Message-Id: <20190214144930.27539-4-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> From: Julien Thierry Commit 319508902600c2688e057750148487996396e9ca upstream. Copy events to user using __copy_to_user() rather than copy members of individually with __put_user_error(). This has the benefit of disabling/enabling PAN once per event intead of once per event member. Signed-off-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/kernel/sys_oabi-compat.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/arch/arm/kernel/sys_oabi-compat.c b/arch/arm/kernel/sys_oabi-compat.c index 640748e27035..d844c5c9364b 100644 --- a/arch/arm/kernel/sys_oabi-compat.c +++ b/arch/arm/kernel/sys_oabi-compat.c @@ -276,6 +276,7 @@ asmlinkage long sys_oabi_epoll_wait(int epfd, int maxevents, int timeout) { struct epoll_event *kbuf; + struct oabi_epoll_event e; mm_segment_t fs; long ret, err, i; @@ -294,8 +295,11 @@ asmlinkage long sys_oabi_epoll_wait(int epfd, set_fs(fs); err = 0; for (i = 0; i < ret; i++) { - __put_user_error(kbuf[i].events, &events->events, err); - __put_user_error(kbuf[i].data, &events->data, err); + e.events = kbuf[i].events; + e.data = kbuf[i].data; + err = __copy_to_user(events, &e, sizeof(e)); + if (err) + break; events++; } kfree(kbuf); From patchwork Thu Feb 14 14:49:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158398 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462171jaa; Thu, 14 Feb 2019 06:49:38 -0800 (PST) X-Received: by 2002:a37:a147:: with SMTP id k68mr3091583qke.190.1550155778774; Thu, 14 Feb 2019 06:49:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155778; cv=none; d=google.com; s=arc-20160816; b=zYmb8LoC0mpGMu8O1Et8LmrnA+yyQcJ95sMP0saK/ZOYlCPmztKjvvzDw0LPkyPnhJ QS5z0NqIi2GBL88BK+qspo5EPj1lJFIK/x8XE41VuZpok/lCPDzzNHxkOV8npIwwfMK3 Ch6pcvRO23qDQGbdXt2wqamsI8L74ngQMWTg64++AYTpqBb+jGg0KyaA/Vc0wmWYCPb4 VHb/Xrml9EAE4Mfe5Ngejomdk5FExMz3SkMNpPtzBcg3wa6TwZ4VeL22Gna+1ROZLc1O QO9gJAZRbUSQ2EBhGNDJObhZl5shDEYWxErfeMLV9SUmBqkU5iZzjIkN89jyDMVC+DaA cKJw== 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=njKhqNVW1q77dfnJouybYtAijgeLOYBipkp1AnzUgE8=; b=jrSoFTnJkn8Evfm5DRHH85VbZaXVI5FOfJfRYBS+6/Fyi1Qmlcx/KoqbBBD6UlSWwC b0IgfK1yJ+2BQ2Y4vtgYXZUNYsd1ZmQ/umT7tGBA1eytrzT0vOLwIh0jPiSjmXtCrJgA JXO0JyO4uD586mXm+5C0VZJohEFclpxR8HgnidNRy+rOQlMS4PonPvTV56tZ2tnPpZF1 HJtRf8OaFP8gRDI7Dx86ibPegIVZobbFd2ULM2FgTXP8NT6K52srOOT9ZXBuO5DwW5Xs 6PDlNPlJ+AWM+KyszL74KcrjrnVok57LTJ/74Lr93yD/9Rp9hrwvuIXIw1QvoIERjxqq mjJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O23hPUmT; 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 o200sor1632602qke.41.2019.02.14.06.49.38 for (Google Transport Security); Thu, 14 Feb 2019 06:49:38 -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=O23hPUmT; 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=njKhqNVW1q77dfnJouybYtAijgeLOYBipkp1AnzUgE8=; b=O23hPUmTPYxoo3uILFDTZz7epP3dts+rXc5g2YO4Xz/tEc2cf8SlFWmqgKsqzOpkCd 8RBuDUOwA0twNEt3dO2wtdVMNPPit1eRPwVmmhQ0oAWqxlyYpbAFbl3Ilovh8O52ZTKK zI2yh91q+EKI5ApQZUUoOzkXeZxnOeKCa+1fOVzL2oSEfnXaFBZndxC0O5/s5QgINz9E Q6yMXfMljTgsLB7Ko0g9vF8A+r9iPjYtzQT+32+Ps6qictWs8/LFiUbXBj21nk8q4hsQ 799ypVQ442qrgjiQFtSdCTUQ6ST4jpdR9zjctiKdZck3dOjGA2kgaPK0WF2JeoxY3eVY 4BHA== 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=njKhqNVW1q77dfnJouybYtAijgeLOYBipkp1AnzUgE8=; b=iYIwboFtARv2/IPQZPSC3GTm41KsteQNUHudsot5Sr8lOsQeZ9q769WzBxEYGprJhq XU/lHqKglHaxzKsJHlpRUaLEwVhf0twRJO7I5AdqfE3ZM6snNM7LLhSICGHstQNr49nQ 8QQfe9b40YgkElorckBuopNqtluxfXyWVrY3iAvTaDx7eTZRGraWDnEUPwsoNdh7mcHB FuGEWDAhb+bX8QPbyzC7ARHugZOSIuxP2TrSeOVdl8otBG3qTa7w8VCZraxTJvZPSLYp cmgZaURw4gfsDdAIyY6mT8QX9JfdMH+3KAh0GuB0omuTAMWHcFnKmh9urHUXI4Icw6t8 G7Iw== X-Gm-Message-State: AHQUAuaHbIOANj4H0G8odhG982nv7MlPXpvJGuBZUknPHM1Fnl5JVLpu 2lPzNEM3v1XLIBNoiIFlyatFX5aZ X-Google-Smtp-Source: AHgI3IZeLOitEMQ7JlaeqazgDG5amrIQ9TI436hGm3PGw0z+wD5nC1StYU/ccIhO7n9txbFYE3MmDQ== X-Received: by 2002:a37:8443:: with SMTP id g64mr3129866qkd.334.1550155778416; Thu, 14 Feb 2019 06:49:38 -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 k66sm1498919qkc.25.2019.02.14.06.49.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:37 -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 04/16] ARM: 8793/1: signal: replace __put_user_error with __put_user Date: Thu, 14 Feb 2019 09:49:18 -0500 Message-Id: <20190214144930.27539-5-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> From: Julien Thierry Commit 18ea66bd6e7a95bdc598223d72757190916af28b upstream. With Spectre-v1.1 mitigations, __put_user_error is pointless. In an attempt to remove it, replace its references in frame setups with __put_user. Signed-off-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/kernel/signal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index 135b1a8e12eb..0a066f03b5ec 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -302,7 +302,7 @@ setup_sigframe(struct sigframe __user *sf, struct pt_regs *regs, sigset_t *set) if (err == 0) err |= preserve_vfp_context(&aux->vfp); #endif - __put_user_error(0, &aux->end_magic, err); + err |= __put_user(0, &aux->end_magic); return err; } @@ -434,7 +434,7 @@ setup_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) /* * Set uc.uc_flags to a value which sc.trap_no would never have. */ - __put_user_error(0x5ac3c35a, &frame->uc.uc_flags, err); + err = __put_user(0x5ac3c35a, &frame->uc.uc_flags); err |= setup_sigframe(frame, regs, set); if (err == 0) @@ -454,8 +454,8 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) err |= copy_siginfo_to_user(&frame->info, &ksig->info); - __put_user_error(0, &frame->sig.uc.uc_flags, err); - __put_user_error(NULL, &frame->sig.uc.uc_link, err); + err |= __put_user(0, &frame->sig.uc.uc_flags); + err |= __put_user(NULL, &frame->sig.uc.uc_link); err |= __save_altstack(&frame->sig.uc.uc_stack, regs->ARM_sp); err |= setup_sigframe(&frame->sig, regs, set); From patchwork Thu Feb 14 14:49:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158399 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462190jaa; Thu, 14 Feb 2019 06:49:40 -0800 (PST) X-Received: by 2002:a37:9d56:: with SMTP id g83mr3053561qke.351.1550155779991; Thu, 14 Feb 2019 06:49:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155779; cv=none; d=google.com; s=arc-20160816; b=uuVMBLNow2iLPwVDLt/sNitKAVprtSrlCQ158lu4ENjCv6nvnEN/tteMs5BNnfnP9y t4x/jOMQAnPXc1jfOWVlICEqOfBUT/Gj9TIWz3II/yTDPkyTYFNXJG/9QWmM/Dz3HQU8 Aghu6seFI5omv4GTdfWgXa0G0SOb5E6z/MkisZ1rnWQjPRMlXcob2Gxg9kOH0SE9AP9p BZSrJaemGZUh4r7s/9N3C8cTofBr7tWbkuIxJJmlIBuD/Kio+fPf4s5B+fT8ekt2PCa9 Vc/lpD8TPrqFczfQMNcbjNneS493mEpXHz+Cb4dPY6ker6fsGoi6upOKXbmjiPmfJeGz S1Eg== 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=zCTqVlx5Etjzo5hueWu7ypOoXoXF8xnytS5XFeEjaGs=; b=P2FKc2kfByNRWoFI/VXjPnI7M8RWvKBN+nDeQ2E86KqRsroEgh+B/3BQ3PwiBTKdym bvUboRsm6pZPhQI/FF/EuxAplTxz5eu1nKXA9x4/KdSVG27Q/QaynFUQnVCALgcZHJw8 V/Bkpb5B4Qqr+UZgMx3JfpkKyuUvPRvLWXGaoN+jsi3zMACNHegKWKsUt2mBdx1zgmwE G+1TPDTLjRE1z18NiqBIMPq5M6wZcHWfpFFEnI/TlxYyhxrdUj6ymeYjsNHzWabC11hz O9K7AKmNOB6kdWHDWcs71qPHGQhBNRjzesXwrWKvsuDvVWYlJlSwQtzcA/jzbe3DsY9I V/8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=miavcMRK; 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 n30sor3229375qte.43.2019.02.14.06.49.39 for (Google Transport Security); Thu, 14 Feb 2019 06:49:39 -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=miavcMRK; 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=zCTqVlx5Etjzo5hueWu7ypOoXoXF8xnytS5XFeEjaGs=; b=miavcMRKjxTTt1NnXSs9S5SIgv6tQi9tuaM3o7X7tprvmlvmHyoXop5aflXJXeIkxx do6zn2NQHvlyFLkcgrVE8GxZj3wMi/CVz+CAeO2sqXb6/JH+94dcqoo6axIotNkQff+y nS0SpEGNhIyWDYBl0wL/nOf4e/jaDpfvwpp1OV/osZTnnbxkBW83unDmtBBHN/lQA1w6 9pC94Au9Z8viUxDsy4X6o/h3vdSZrDOs3mAZ8WYwEDDgb7YDGS3LA1ga3UIJ4UFLuCRp wz7fH4hU0moX1giYjpcsYQlvD6N7pgpZWQN/iAIubXQpPjWD3vN9huAkB0S0ACkixiWv n+Lg== 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=zCTqVlx5Etjzo5hueWu7ypOoXoXF8xnytS5XFeEjaGs=; b=B5mph2l6Y8oC/l53eLtUduVFYRBvF9fceLutLLR8WuKgawqDJk2bkpJWBGUwM0lGCY dYSzx7LjlID4brg0NPPBzNWLQ7wSEK4CC4bUBovzDOI7X3eYLt91+JQ8R4YKxXkYUCZ+ GSl+2ZdUqDDAH8hYMtECb3c3WOATuMfmZkic8ABmiaHTwJjrIQKb81QosGyZGl2BYwLW 1FU07Vb8Wa8NPNVMh/enPJQvXIELRoenFQ5OjSJcDAs1HKUhmyYpbS+svuqPR2FOjFHL CUAR5tupigVhVuP0pdF1mXz3mkOFWv2qHeYjxyVrSA+4BiLk5ZOEfDKXoZ8P0ZwOdRLS GDCQ== X-Gm-Message-State: AHQUAuaXyxa4XpvUK9++g86aG/xBU9oeU8OPRyZ5yMInZmwihHu8cYqL waBDPfsgV0ekH0VpDoxNVO4P22JI X-Google-Smtp-Source: AHgI3IYuyKJfKTx5XoJwsHlZqWG3Jx+9E8LTTDtKIppzoB5eOlCS7mWVYLojIewdtsIltstdjCU/kQ== X-Received: by 2002:ac8:26ea:: with SMTP id 39mr3372612qtp.351.1550155779753; Thu, 14 Feb 2019 06:49:39 -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 k66sm1498919qkc.25.2019.02.14.06.49.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:39 -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 05/16] ARM: 8794/1: uaccess: Prevent speculative use of the current addr_limit Date: Thu, 14 Feb 2019 09:49:19 -0500 Message-Id: <20190214144930.27539-6-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> From: Julien Thierry Commit 621afc677465db231662ed126ae1f355bf8eac47 upstream. A mispredicted conditional call to set_fs could result in the wrong addr_limit being forwarded under speculation to a subsequent access_ok check, potentially forming part of a spectre-v1 attack using uaccess routines. This patch prevents this forwarding from taking place, but putting heavy barriers in set_fs after writing the addr_limit. Porting commit c2f0ad4fc089cff8 ("arm64: uaccess: Prevent speculative use of the current addr_limit"). Signed-off-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/include/asm/uaccess.h | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.17.1 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index 7b17460127fd..9ae888775743 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -99,6 +99,14 @@ extern int __put_user_bad(void); static inline void set_fs(mm_segment_t fs) { current_thread_info()->addr_limit = fs; + + /* + * Prevent a mispredicted conditional call to set_fs from forwarding + * the wrong address limit to access_ok under speculation. + */ + dsb(nsh); + isb(); + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER); } From patchwork Thu Feb 14 14:49: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: 158400 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462212jaa; Thu, 14 Feb 2019 06:49:41 -0800 (PST) X-Received: by 2002:ac8:2f4e:: with SMTP id k14mr3314532qta.76.1550155781321; Thu, 14 Feb 2019 06:49:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155781; cv=none; d=google.com; s=arc-20160816; b=0dBR9Dvb5vFs2XLqPDYDIXLe2YVmAMthyK/E5tS4SuxkFH1vKVlc3wvd52w8sulmVk z1pvwt4USU2xbbSMihxZqurc+/mjLNUKPNDx4y753aGIUREKV5VdQKxBsjMUhEov8jjg ftZWtUifZCqC2XhrX1y2DTBYCqXMawoo1uyms0O1aDU3dBSRQra4TWDMuJCfzenWLIER 2zb7yRUdKrLoZ4HNIpTyXLkGgJQSln83yfjWcV8Oi5D2dMHbMVrC+DgcBFlpM+3sGcEi uABfO+kl8m6puQzAPboeVthbKim54myMG/X438CrupbHYd1MSD9aiLLlB5d1gBR77pWo w+Ew== 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=3EUxbJ4Gs2ebNHsOGp92F1GifsPVltaoVmIWi4xEEBo=; b=DzU30+b6Riay/PXz3rWPMdkoX43OQpeoL7XrZf/Lgwftp+LsLSFpTyfg9iIOi2gEDI vH7DozRYgGG05bJOWh5sUKKkT80YjQGimZ4WN3TN9kO8b94P8Nk+rIdGpXwEgOo7os2f chp9nHJWelR0M6Q/hxEPK3uPvqIqb9R/Og808plwGE10wS7mXv3rs16Lx+bKITrsR96S x7qeyS/BLTEzpwVfKKA9efzkLJZ0KSuoBj/CDUAX6/izABa0i2hXJgmXrL/UHD+jsG4N KVktd2NTreO9ww8IAq6Fh/zEq242oxaHfVfqU0UGi1UaWrzY3j4fFyl6mgOWI73tqk2c /yHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ioo7iJvX; 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 g9sor2954549qvm.22.2019.02.14.06.49.41 for (Google Transport Security); Thu, 14 Feb 2019 06:49:41 -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=Ioo7iJvX; 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=3EUxbJ4Gs2ebNHsOGp92F1GifsPVltaoVmIWi4xEEBo=; b=Ioo7iJvX7d6MQbbygi6AqmTR717u8Nn9q4l6Lz9RRC1h2d3f5BI8HB987KC8ic+sht SQoxNNsUvDcnct0MF5I7HmqlYkNS2SnlTLS6JYqlJzKgIMXBTIjxD/ZV1tuqzpb8uBNH PT+t9K7fRpu0muIzuxJZ8aQn96cPNTdDS6TQkBjJDluavck2nBuD8bXJAUe6O24/tHBv IqnIxPiZ3ZUbgvPrcsMySFm4fRYjuYQ18ImpPHE0oknCl1zf75nzAP2rV/RLyoq3jQsY t32Aj633ROdtEItbocW7xgTqUgYH/Skv+qTXrlsGaJwxZDOZWqyXOnVmgqKtIjJhzjRX PAlA== 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=3EUxbJ4Gs2ebNHsOGp92F1GifsPVltaoVmIWi4xEEBo=; b=o9puDYzU6G1DVUcq9JoeHnNFyupYlBvBuIBJ0ZAs5OfJVpU0yUA3osrFPprI26P/V8 yQPZ36kWoZaGFXSgc6ODqU0k9R+E4OZlKQvRsgtqq09kisRmnYG9tpi+sH49PJSTTQuK OcTeKcSJL7H02tIK5EhDt51tEJDTMjEU3h0CuNBbpWd7PLVDrBJsp6kiQfBM7oU0M5BW 9ebRjFiaJaH8L4KShueP0o8bpSUheNtVAx2aVYtvp1tEPmhuQXR2K/y9ZXiUOZCTvsc1 G6dM9GI8Db8xWQLUBlomQ9BEALlTF8KK/Dqvbk0MS3QBsj+zxakEKYbVQW9Qeo7RphJG hUgA== X-Gm-Message-State: AHQUAuY6yU48RkfkpI1wgs4kR2tKXqPm9K6EmJ4JXZ103PUSjHbPKiLU SH+HtT+7XLgkIbti4HcmrEXG8cSa X-Google-Smtp-Source: AHgI3IZsomSLVmJUtA5Ud1tLgJJgLsgoW/v5KOp+5LVD6Kt1FqCgcuILjIUVEQBX6zyvIgGiuH5Uqg== X-Received: by 2002:a0c:8816:: with SMTP id 22mr3233956qvl.247.1550155781094; Thu, 14 Feb 2019 06:49:41 -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 k66sm1498919qkc.25.2019.02.14.06.49.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:40 -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 06/16] ARM: 8795/1: spectre-v1.1: use put_user() for __put_user() Date: Thu, 14 Feb 2019 09:49:20 -0500 Message-Id: <20190214144930.27539-7-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> From: Julien Thierry Commit e3aa6243434fd9a82e84bb79ab1abd14f2d9a5a7 upstream. When Spectre mitigation is required, __put_user() needs to include check_uaccess. This is already the case for put_user(), so just make __put_user() an alias of put_user(). Signed-off-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/include/asm/uaccess.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index 9ae888775743..b61acd62cffb 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -400,6 +400,14 @@ do { \ __pu_err; \ }) +#ifdef CONFIG_CPU_SPECTRE +/* + * When mitigating Spectre variant 1.1, all accessors need to include + * verification of the address space. + */ +#define __put_user(x, ptr) put_user(x, ptr) + +#else #define __put_user(x, ptr) \ ({ \ long __pu_err = 0; \ @@ -407,12 +415,6 @@ do { \ __pu_err; \ }) -#define __put_user_error(x, ptr, err) \ -({ \ - __put_user_switch((x), (ptr), (err), __put_user_nocheck); \ - (void) 0; \ -}) - #define __put_user_nocheck(x, __pu_ptr, __err, __size) \ do { \ unsigned long __pu_addr = (unsigned long)__pu_ptr; \ @@ -492,6 +494,7 @@ do { \ : "r" (x), "i" (-EFAULT) \ : "cc") +#endif /* !CONFIG_CPU_SPECTRE */ #ifdef CONFIG_MMU extern unsigned long __must_check From patchwork Thu Feb 14 14:49:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158401 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462230jaa; Thu, 14 Feb 2019 06:49:42 -0800 (PST) X-Received: by 2002:ac8:1735:: with SMTP id w50mr3380504qtj.361.1550155782786; Thu, 14 Feb 2019 06:49:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155782; cv=none; d=google.com; s=arc-20160816; b=OW3FU0T8OBwNT0hKyz3Zk0ehw+FXuJ3lIH6O2Oe2M4kHg9Wii6W572MS1s1YG7/9J9 QJvOxpES6ukUOxiqohHtIgjYqZIvwnz5FlSN4Sp7265IE9p25jNBqRv0lz4DJ5k0M+iz 2lA/M24Xi6yGXmgzoww9WoxTT5SorqtDZO8wYmMmxy9+4Pgd3VZGBo8J/jh5ZUUfYSsK m6qcHgmXSLu3LLp6Gn6j3Y7jX42Wdk224jW4fL+F9/a7ChFCkaaQMZwwGBQDG5jKR7kW bLlQG2u4HMsS0P8blSnUx0zoopAYjLPEOVWHWP0WsJK74wBT1e7CF/5Y+3BcruHV8Fvx rHgQ== 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=zgIY4W12AifZiYGKPIJKvhZkVAc9WDHsN0M0ZqcY4Ag=; b=B1AZrtoBbev9RTJHM2ffHNUHZUljfm1Sj2l588zKxxdIAX8Ul/EoPsXnaEPP8NJ4wn iZtYdBZbn9zM5lKzvuz058y61em2BMNcDeqr5UkRDKCUfcfFuUEtJKZtcB5FNwMAoDBw nec7Tl6W3DZ0e8AA3nGvH3LOdzVRD+K8w4chUAsEn1Owwhy38Gufj5PUuHqFMXLhyFH6 T5lSKogBVoUc5OU+yFx1SnQIDoY564V+Y+Ype7oXbdGLqIy6wUc6pCMXQ5OPNBt2QykO 6oQIvcUuDGNQpCllT+SeuTuOp1KBgQdearHOasyY10n8Qb1sXfhtZtqpdFNvHv9yU1xk +u9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JYpPZB9y; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.41 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-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id n45sor3230924qtc.52.2019.02.14.06.49.42 for (Google Transport Security); Thu, 14 Feb 2019 06:49:42 -0800 (PST) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JYpPZB9y; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.41 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=zgIY4W12AifZiYGKPIJKvhZkVAc9WDHsN0M0ZqcY4Ag=; b=JYpPZB9yAsehQJ8kX2b9s5gS/ATc4yN+Z7ukFXwBX827q0jQldoOMgxHkkSofgTJ43 pCxVRZRsMMX5jka9RpzcT00sHG4QvKtkKUYJIIB8WF9AAPHXRdOPMm/BVhbCwj3oxQRl oYiOwZQg4vGq9kNokwivpbmcc7AfCtHy1BHjWz+gjxFDM+qsWTqsu9kyD6EYmJ87Ppq7 F08nsPalvOnqVY5Ncsvqsn33CgHh6e5/oRb+0c00vwESTAmpD9LSB8b0OfAG648lC4pg SEBuDxd+6Zed8aGYyQOLhNXCTlFbARJ3gmZyRGDwz/4/KrgrVtNjv841KkayKTKQSSix ZnBw== 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=zgIY4W12AifZiYGKPIJKvhZkVAc9WDHsN0M0ZqcY4Ag=; b=YD6+5uQylyuhQuAtKdUTrSMS7ddyxLk/XDmpc+XsP7hPtSb/kYVCJ9CS2dzt8ojgOI TT52NVrAtjmhEPpv7QtUz6lmqAzHO7MwBg8/pCC+doVNMy1wuCXHuc459isEoCPNn+hI r9iV6vc8jyTRQ/mD9cxzvmNL2zYzdxDeRnGapJVULrNhkVUNbAwr0/PQOnSaLKmtd/u5 y7VNsCEZWLngntzLgH5wSE30+zx/3Eyn9hUBOucfCvmBYkMjyJy1ZSpVpKq5l4wxALJV ONYYSQGlZrqANEmHl/uezsZABZMK3HK8FTAlfhFgxgukDk3XEaPshLX+jM3Td3kaQdSM Yyrw== X-Gm-Message-State: AHQUAuakcm7Clf4M1fPps2BM2lEEuKOZzPmXerClVNqzizI060jL31Y5 IbIArcIFaIE7FRKinlGQpGHJa76Q X-Google-Smtp-Source: AHgI3IZ0UvZbDTKpgh144q3MZAuV7zh79/AGn+9KJdoBj3hITiStWAv+2M2d+N7jtyEYkvhHLc4teA== X-Received: by 2002:aed:24d8:: with SMTP id u24mr3290346qtc.47.1550155782496; Thu, 14 Feb 2019 06:49:42 -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 k66sm1498919qkc.25.2019.02.14.06.49.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:41 -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 07/16] ARM: 8796/1: spectre-v1, v1.1: provide helpers for address sanitization Date: Thu, 14 Feb 2019 09:49:21 -0500 Message-Id: <20190214144930.27539-8-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> From: Julien Thierry Commit afaf6838f4bc896a711180b702b388b8cfa638fc upstream. Introduce C and asm helpers to sanitize user address, taking the address range they target into account. Use asm helper for existing sanitization in __copy_from_user(). Signed-off-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/include/asm/assembler.h | 11 +++++++++++ arch/arm/include/asm/uaccess.h | 26 ++++++++++++++++++++++++++ arch/arm/lib/copy_from_user.S | 6 +----- 3 files changed, 38 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h index e616f61f859d..7d727506096f 100644 --- a/arch/arm/include/asm/assembler.h +++ b/arch/arm/include/asm/assembler.h @@ -465,6 +465,17 @@ THUMB( orr \reg , \reg , #PSR_T_BIT ) #endif .endm + .macro uaccess_mask_range_ptr, addr:req, size:req, limit:req, tmp:req +#ifdef CONFIG_CPU_SPECTRE + sub \tmp, \limit, #1 + subs \tmp, \tmp, \addr @ tmp = limit - 1 - addr + addhs \tmp, \tmp, #1 @ if (tmp >= 0) { + subhss \tmp, \tmp, \size @ tmp = limit - (addr + size) } + movlo \addr, #0 @ if (tmp < 0) addr = NULL + csdb +#endif + .endm + .macro uaccess_disable, tmp, isb=1 #ifdef CONFIG_CPU_SW_DOMAIN_PAN /* diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index b61acd62cffb..0f6c6b873bc5 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -129,6 +129,32 @@ static inline void set_fs(mm_segment_t fs) #define __inttype(x) \ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL)) +/* + * Sanitise a uaccess pointer such that it becomes NULL if addr+size + * is above the current addr_limit. + */ +#define uaccess_mask_range_ptr(ptr, size) \ + ((__typeof__(ptr))__uaccess_mask_range_ptr(ptr, size)) +static inline void __user *__uaccess_mask_range_ptr(const void __user *ptr, + size_t size) +{ + void __user *safe_ptr = (void __user *)ptr; + unsigned long tmp; + + asm volatile( + " sub %1, %3, #1\n" + " subs %1, %1, %0\n" + " addhs %1, %1, #1\n" + " subhss %1, %1, %2\n" + " movlo %0, #0\n" + : "+r" (safe_ptr), "=&r" (tmp) + : "r" (size), "r" (current_thread_info()->addr_limit) + : "cc"); + + csdb(); + return safe_ptr; +} + /* * Single-value transfer routines. They automatically use the right * size if we just have the right pointer type. Note that the functions diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S index a826df3d3814..6709a8d33963 100644 --- a/arch/arm/lib/copy_from_user.S +++ b/arch/arm/lib/copy_from_user.S @@ -93,11 +93,7 @@ ENTRY(arm_copy_from_user) #ifdef CONFIG_CPU_SPECTRE get_thread_info r3 ldr r3, [r3, #TI_ADDR_LIMIT] - adds ip, r1, r2 @ ip=addr+size - sub r3, r3, #1 @ addr_limit - 1 - cmpcc ip, r3 @ if (addr+size > addr_limit - 1) - movcs r1, #0 @ addr = NULL - csdb + uaccess_mask_range_ptr r1, r2, r3, ip #endif #include "copy_template.S" From patchwork Thu Feb 14 14:49:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158402 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462254jaa; Thu, 14 Feb 2019 06:49:44 -0800 (PST) X-Received: by 2002:a37:4145:: with SMTP id o66mr2956095qka.129.1550155784128; Thu, 14 Feb 2019 06:49:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155784; cv=none; d=google.com; s=arc-20160816; b=Y+m9NIY6w4t2rU9hndjtxmdZktvyiAH0FclzeVGDoj+XysJlXfOeRxkI/G1cLfbyDa SgpWsVME5aMv4Ddf8usy6J4LwQuT6+VtFnlTgeesgrnIRcBhpyO+szQKa9P1oTupWoV+ 4c5d5QUXreQHO1G80nl389XFMruOa9PqBIftN+++eoHaVj0KVcJgyYSHgnntlmtyuVnl +Yr+TTLDULfwge+mpl8Ic4PV2kqX57QUoaHwZSqVuHHAQrzwoVJD1ceJuJhChNiggxiD m8+miIB0rJ6Kw7Nn3bnvn8mheBbgWwYYog3x/lUdlU1Bps/8zYRHIiDQmI6bnk6Zroky FUTQ== 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=jAX1WYClvTF68HOuBDHcjdNU9Y05TUeERF66yDaIHEY=; b=RB1sXQkxQhKFpOfYhY3SSrRXOf1XX5G/OrMlg4DsSZQ11rfHvgD96AuA1tfGrE+E97 MzSooZVXEAvFEqAfJj8Vk7wq+iEsaL4MSLQjpw4rZaRsobAiGdZMNzoGSW59dIUZsQpT Q+azupSRISdhOjDqgF64eXDS1qPlvrZMDdA3e02QUmFRrG4XzGgZo/kgfaF2LNePo8GY O5tTtv+CjLYEzFHLRuGN5xM4m0BBcH+j+g+j+WXWh6ScmG7POiYIRKsk5WRBt78WZrcK gSc7BipZnS5/lY1r6dunI1lmvWb1eQDk2hki1GVPLD7KAZlBdRlmrFOZfBuqozOCiVuW bzVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L9Zyo6Tb; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.41 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-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id m16sor2918310qvi.34.2019.02.14.06.49.44 for (Google Transport Security); Thu, 14 Feb 2019 06:49:44 -0800 (PST) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L9Zyo6Tb; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.41 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=jAX1WYClvTF68HOuBDHcjdNU9Y05TUeERF66yDaIHEY=; b=L9Zyo6Tbln45JAT9duHaa+RG+kna2YWVG18IgdQaCAkBuqKBSBxHfhQYFLpRMM8q1K vUa5hlIrngpOLZW+qnMs4VuoUfnCEsQ8QxTdLgJikfw0oKlPGC2wF7N9/vONBVBkHRI8 PLv/3iQp2q0UUqgl74XpHUyWSiX7XrTCpx2A1g+oIOlkL5BsVShfZejJdh3E113twJaL OhOYZRHHWMvpr9PmmDc21N/5M4qbpSzIoNN7B+SPJDKXtYQdPKa0La9A/QihDG27PZRU /YtPIr/EcA97zw3ydKdalfgLpb3aR+9hGt9vP+ZVRlPS8dz0moSsZaR4qJHjdEPTh7zZ w3CA== 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=jAX1WYClvTF68HOuBDHcjdNU9Y05TUeERF66yDaIHEY=; b=USxkgewNsXyHj7bjJkyrbUrcITIaYTrPil/CUJlUUN9TrDLxvPP7foAYMfh6oQHEFh i/ejuHpOodyw+tBKmXzAk+5clNAOO3MqSNVsE6kQNZL57Q8a9rNLv0p6nEE4sxn8x9Xw qOLtZtHVWA/M+Zda3JXZJOWN+iTY1zlZQRi/UuAGCZHrGf/0BG58HJZh8x4+NloGbkVj 633IrMrUlvU5rv4GhvFrvfONdrI1fMmvvlKKR7RNlBUPiP/g2kh79DUjq2baanXLH5BF +2416tIt3++0/rqWo1hl97jXM3cnUg/8e9vJ3qyamvv+4kmLL9midsUfcb+xZcr2rKem zbaQ== X-Gm-Message-State: AHQUAuagpqUPuEgcLRBmoBFq9SK183ZAs6Olh6kgyI1siaiY4iJScgV9 VVO5XIgNmLYyGCJ3V41tR2VyMoT6 X-Google-Smtp-Source: AHgI3IZBiST25lvmOi9NkLs7JajuZ3z+j1YbEwfnS8qIJALn9pNb8XJFarQiroh+0yPSG0KDVtHeoQ== X-Received: by 2002:a0c:d124:: with SMTP id a33mr3194125qvh.19.1550155783894; Thu, 14 Feb 2019 06:49:43 -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 k66sm1498919qkc.25.2019.02.14.06.49.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:43 -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 08/16] ARM: 8797/1: spectre-v1.1: harden __copy_to_user Date: Thu, 14 Feb 2019 09:49:22 -0500 Message-Id: <20190214144930.27539-9-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> From: Julien Thierry Commit a1d09e074250fad24f1b993f327b18cc6812eb7a upstream. Sanitize user pointer given to __copy_to_user, both for standard version and memcopy version of the user accessor. Signed-off-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/lib/copy_to_user.S | 6 +++++- arch/arm/lib/uaccess_with_memcpy.c | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S index caf5019d8161..970abe521197 100644 --- a/arch/arm/lib/copy_to_user.S +++ b/arch/arm/lib/copy_to_user.S @@ -94,6 +94,11 @@ ENTRY(__copy_to_user_std) WEAK(arm_copy_to_user) +#ifdef CONFIG_CPU_SPECTRE + get_thread_info r3 + ldr r3, [r3, #TI_ADDR_LIMIT] + uaccess_mask_range_ptr r0, r2, r3, ip +#endif #include "copy_template.S" @@ -108,4 +113,3 @@ ENDPROC(__copy_to_user_std) rsb r0, r0, r2 copy_abort_end .popsection - diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c index 6bd1089b07e0..f598d792bace 100644 --- a/arch/arm/lib/uaccess_with_memcpy.c +++ b/arch/arm/lib/uaccess_with_memcpy.c @@ -152,7 +152,8 @@ arm_copy_to_user(void __user *to, const void *from, unsigned long n) n = __copy_to_user_std(to, from, n); uaccess_restore(ua_flags); } else { - n = __copy_to_user_memcpy(to, from, n); + n = __copy_to_user_memcpy(uaccess_mask_range_ptr(to, n), + from, n); } return n; } From patchwork Thu Feb 14 14:49:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158403 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462281jaa; Thu, 14 Feb 2019 06:49:45 -0800 (PST) X-Received: by 2002:a0c:8164:: with SMTP id 91mr3219985qvc.100.1550155785442; Thu, 14 Feb 2019 06:49:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155785; cv=none; d=google.com; s=arc-20160816; b=EFA88e+XPHX8yyQGzAx534pRo/QlpjjMqSBqYhxBM4YIDpitRM9NDT1PQYS0WaarZl XhpjZxc+D6PIDzZ8S95r+OA67rzNIvLAh55stLDYbpGLgwSg1aF/109WwbQGbEKgDUYX 36hm8L7i5AmGblP876HUVuJynZ1EMrVwxWwFtjqxrWTDDqfKjUpOPOOGdC/JdEGZuivn 3050BzAAqJaEEcGEXCCLotnQnVnkAEP6U2gLmX4y5RlqCs6iKXlG9jmABBV3qpF8nrmY BwIFCZzlyS991ilN9anH1rUPXlVTo1uNnRKr/DfS2/nkOgoDvvX80Lbb59R3i9IF+LiU NWTw== 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=Al89NpupvfZvzBikplZ0PcauK1wQlzW/uE8qgbOT/SY=; b=Ez8EgGs3TnhBxrkcGtDU9NHu546Fh/qN+DTujz5eUt5WpKomObXPzAi1prUowtFZSa R8ywm5LmOtItepAx/SQ6VAIyMoPOx3Nn8wYb2D9bZa4/E1ls6CEwejC37U2XDAQ/VZVa 62lohc6LaTO2xjq6YYNV95ZxnUiSXHYZoXD6jq88rD3snFnQCq6PeW5dPqFDsuNPjIcL gjTD10DMN7KZSHJyGgrHWA4ampLW12WCE9exaTgbRD/W5Bhro9COcRMcMOB68TVd9ZF3 nxiCoEql/2RdUV/wvVyttiMsGfxWFng/BaKYc+Z1QZY4SVsvpr2F2gyihAjKYt/5u5Hm 3SIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pJpr5xvt; 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 u41sor2920789qvf.42.2019.02.14.06.49.45 for (Google Transport Security); Thu, 14 Feb 2019 06:49: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=pJpr5xvt; 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=Al89NpupvfZvzBikplZ0PcauK1wQlzW/uE8qgbOT/SY=; b=pJpr5xvtUAjUJWpURhnPcWNTSV61J+pt4ZvWEWqt2dhyoDdRLyOfpnydSu3hiyOE4t byJLhaumPjfJZC/mz+3u+af6gynVCSCLBoeNPkZLsUCQpBl1HmhbBRQ79L0ALWEyw1Mc /kftsyY+4LQCpggccbtPJ/vAC4RW+LLEaZvQe1dEvw4CMiCPF+kcHhBPmQI3U2TiyNgT f7hkeGPUhCKhGWdrMZCkoqi0e7anvPePWhQJp2F16K4MVLOrZZnaIUDpqat8Ja8aflGh 8pa/7zlxlNjE+y/krS/ASmgb9chS0t4t52/6bUvhkMz/nN2zr5WQanfcCeq5myKYCKCa AWTA== 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=Al89NpupvfZvzBikplZ0PcauK1wQlzW/uE8qgbOT/SY=; b=BLNIHLswtlmwLdqbogY1t9796pJHslIIlE2g96u4vk0O56T49BO2+IdkUw9ZcgxlMJ 92ylGGpTSe83txU0TGrqoxIqPYN6zpFlCRy5F/WooNEzh45T6V8PjZkodS4QckuE+Kdt zmHVCLlfXeQ5XI/BduKO5Tb24duqrh5iC/pBSQBev/IdtBzQRe9vITfdy8R9L6sf6ZCF sVszQ4x2CMCy/mDMWKKnTVNqrXi7Kugm/xvFvDXsJTD6VpVFhTzcr1KNk43NUWthxqsK NyYs53j3tFOB5oAFeYn3RukU5U9GZ9HpLHc3VvUc59hx0zMGiVZHgV5pEWhOllUjm4o3 zwJw== X-Gm-Message-State: AHQUAubTpywVFoCJ8HVU3WZc6Vclw+9boDbNmrVdIuW9Zzv2HJaqF2mX +JvJHgxtMWLOR8YsZV3vzB6D35n7 X-Google-Smtp-Source: AHgI3IY6xdj32cNiqp1cqU8Z6po4iX/FAASpw8YLC1v6uJLVWZOQ1fH4NVxIE5gQXqiqY6Tq4n5zGg== X-Received: by 2002:a0c:9e05:: with SMTP id p5mr3172793qve.246.1550155785194; Thu, 14 Feb 2019 06:49:45 -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 k66sm1498919qkc.25.2019.02.14.06.49.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49: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.9 09/16] ARM: 8810/1: vfp: Fix wrong assignement to ufp_exc Date: Thu, 14 Feb 2019 09:49:23 -0500 Message-Id: <20190214144930.27539-10-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> From: Julien Thierry Commit 5df7a99bdd0de4a0480320264c44c04543c29d5a upstream. In vfp_preserve_user_clear_hwstate, ufp_exc->fpinst2 gets assigned to itself. It should actually be hwstate->fpinst2 that gets assigned to the ufp_exc field. Fixes commit 3aa2df6ec2ca6bc143a65351cca4266d03a8bc41 ("ARM: 8791/1: vfp: use __copy_to_user() when saving VFP state"). Reported-by: David Binderman Signed-off-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/vfp/vfpmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index df3fa52c0aa3..00dd8cf36632 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -579,7 +579,7 @@ int vfp_preserve_user_clear_hwstate(struct user_vfp *ufp, */ ufp_exc->fpexc = hwstate->fpexc; ufp_exc->fpinst = hwstate->fpinst; - ufp_exc->fpinst2 = ufp_exc->fpinst2; + ufp_exc->fpinst2 = hwstate->fpinst2; /* Ensure that VFP is disabled. */ vfp_flush_hwstate(thread); From patchwork Thu Feb 14 14:49:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158404 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462300jaa; Thu, 14 Feb 2019 06:49:46 -0800 (PST) X-Received: by 2002:a0c:966d:: with SMTP id 42mr3221541qvy.109.1550155786808; Thu, 14 Feb 2019 06:49:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155786; cv=none; d=google.com; s=arc-20160816; b=G2D81GRrM0evGf2DPDBg3lAgIK1ynWRX9WKb2i23JXzj+Xjah8nmUIHkQcdUbrkzg/ QtSnV2v8vFQrhUZ9SA0G5jYIdrIY5WgO6MLN+IJLf2JRbMhnxB0fuhWiz4/PiEVVlhL5 qDZSvllgx+C3tP8S+K/bX6OVvwCq14mY6zOX3yCak5QDsHaFCQldPQx4QyEClrWRKhzj vAmKhaKhk0H0pgwfCMUxridXNz+dndwoYZbezUkZeG39B6qXezkGTpun+JZrgISA7ymo 6ljhj0SfXXQmMD+ytZQJi4AG7J8Kw64mxOw+TbS7X8UVwQzPiH2qwysntTb1Id0G44Ym BM5Q== 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=A+x6L8QagNW3CuUu/ag15Af/EDUw9eLjI6Wngv/1/8I=; b=G+3Fmr5UfU/k5BFyhlBattSOSFApjQMymXh87bllPFQ+wY0KwAWy77UffCtB4puDHb HLF90zN5zufXKGXQfImd1qm3KMc++GRmSFGi5d5glyGkm8KFdz1q3zEv2NC+ob8d7hov 7l1fcHdLbOjtJ6aoh7CSW8T8KruGf9konsoymMK+YGZgOnLUOdnclkE+lv3y8jO8xJov iJWMqCCViaY4x4Db1GLXepH1/UT8KD9p5oXrTHgbqAZRXLgMEnFcdriun8/+4EF42kTt 56BMX1qYbVqHQW3Zfl4qiNutw5ty23SW1yU9kM+aWPL1P6z2aEY63iROIz/PW22WslwB N54Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dh8U3TBw; 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 y2sor3262035qtb.0.2019.02.14.06.49.46 for (Google Transport Security); Thu, 14 Feb 2019 06:49:46 -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=dh8U3TBw; 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=A+x6L8QagNW3CuUu/ag15Af/EDUw9eLjI6Wngv/1/8I=; b=dh8U3TBwa38qeMRCMFTA1fUE5EDhj2RU58iy0u72q2fpD7O7mLoTkPzIrhtqN37929 6a6Cm+iL5S93vb0oLM38HX6kVjNOvkoUGMqaZtB/Y/HTUcfWPpupzTxEhA/WviL7bk+1 kTjIhuJ3IRheJJpvOnwAno/sTDLlnZHgZ62SAdVl/kgfZWVzchOX1krmLFkNCxSlA8eD oSHZmRg5ObAr0TpeM+fNdhN/DSI1M60JZzptaw+FcfgXbfrNb1kl80guxgNPRk/MRQYo qWRRoTk3stRoFDS1rrrzYrfmdRIj9OEDropr0nRDh6k2oU8Qox+6y9SiWCG8/Ab2OTTw vxWw== 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=A+x6L8QagNW3CuUu/ag15Af/EDUw9eLjI6Wngv/1/8I=; b=LvW1OykrAPqoI4F7F4C74/aL30j/j3HP36D2kKjHzrcRrG55T6hnIPH6osCpErtseY DbKBcqvqJ6LrNpJQXtFKCQUsoGMOj5HRKATEQCg2L9oOhrcGce4Y0WVqJHnvJgBc/oMP ia3uhp4ZzXIAq8ImNj/G8DfqXb2h+SsWiYaz83iahV+WpxWPOM2RdyCk22QWWCqg83z/ JQw8bi5ooAAFCs9Eh4XQ5dxP+gmK80wrcns0eBBQpgbXiz3cXCPsrZaiz6BZlj1OrZg2 15dZTEMwvfyLn/61jWlXCI516RXdVhBTa/kurI5ExxJyo/g7ahsfF74vH+/XZ+PKkBhN lQjQ== X-Gm-Message-State: AHQUAuZB3Y3d6JV1MldgCW+G+kJZrAZZMnhxKzT7/EnMEleSmM9K22Pw UIdnJQQCBq8PNLRuckb46vM6ES2VxFK8Lg== X-Google-Smtp-Source: AHgI3IYcG97BfMxpNuc4KngAngOmKS4qSzW8ZYnZOTNl5EQYIZJraMkm8t+KiQ4aSY8epygCim8lKg== X-Received: by 2002:ac8:162b:: with SMTP id p40mr3259244qtj.326.1550155786555; Thu, 14 Feb 2019 06:49:46 -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 k66sm1498919qkc.25.2019.02.14.06.49.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:45 -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 10/16] ARM: make lookup_processor_type() non-__init Date: Thu, 14 Feb 2019 09:49:24 -0500 Message-Id: <20190214144930.27539-11-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> From: Russell King Commit 899a42f836678a595f7d2bc36a5a0c2b03d08cbc upstream. Move lookup_processor_type() out of the __init section so it is callable from (eg) the secondary startup code during hotplug. Reviewed-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/kernel/head-common.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/arch/arm/kernel/head-common.S b/arch/arm/kernel/head-common.S index 8733012d231f..7e662bdd5cb3 100644 --- a/arch/arm/kernel/head-common.S +++ b/arch/arm/kernel/head-common.S @@ -122,6 +122,9 @@ __mmap_switched_data: .long init_thread_union + THREAD_START_SP @ sp .size __mmap_switched_data, . - __mmap_switched_data + __FINIT + .text + /* * This provides a C-API version of __lookup_processor_type */ @@ -133,9 +136,6 @@ ENTRY(lookup_processor_type) ldmfd sp!, {r4 - r6, r9, pc} ENDPROC(lookup_processor_type) - __FINIT - .text - /* * Read processor ID register (CP#15, CR0), and look up in the linker-built * supported processor list. Note that we can't use the absolute addresses From patchwork Thu Feb 14 14:49:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158405 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462329jaa; Thu, 14 Feb 2019 06:49:48 -0800 (PST) X-Received: by 2002:a37:370c:: with SMTP id e12mr3076173qka.64.1550155788167; Thu, 14 Feb 2019 06:49:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155788; cv=none; d=google.com; s=arc-20160816; b=fCsQwJVysw7CO4j17FMUcW0nwhDNZTHNjS3d/f06ZEvk7m24iMCBNUkTCnmro4GIiz +F4Qt0FzSszHVSlEO+3waDb+fDYKB2W0tRbl5KRHL+whp7oWKBGEgkF9tW/ruASvkVdp xQdnCexRsJQU4l3SJTM/7sA+3IomeRfhuvsdaNIildH0Of27MIpC+U8y3VddnBb/gfOp bbmvzien7KTYZBcuP5pLITjVkDcGLor9Riupxr06cZWwZl3B0nHv10b9LRiTnk9DFzVn tYusITylR1Z8MzVEbJLrwJ6GomHVrLrbBfRpOt/cmhg46kq+YNAOfIpIc7hmpahkOblv jnog== 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=VL5Y6vm9NuZCG1g7W3hxrDkMxlPp0J/npa1K1+DSsiA=; b=y4ToSECB7EqMN65eL1Y10bSO2t9k06+oW2TSewiWCRntllCE4L2ejk0lnW429fpIsS ReZT0vaWYCzaG0vRPpy6k4uo7TK1p+krZEq9yiUQTWGYa06Uf84N9LTN+myaOq55kriS OGb9eNuArRlRkUgz+sMJDwgsUvpVy89emnGSze3dBLgaudMRxfXUx1kCdu0BdTByKnIC tZ6BGVrL6n7FdoiwElGIuGyG3jz8eDdMLwdabL5vsrNdmtArQS+5F79LjTUkYeI9WqcK RtLvuGxsWR2Vm2525+UiZrdfx1i6bgvsndeqtxseVwvo31aqMwxbaFafic4kc4PG8eKv X5tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DjeCDkyV; 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 i31sor2883292qvd.73.2019.02.14.06.49.48 for (Google Transport Security); Thu, 14 Feb 2019 06:49:48 -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=DjeCDkyV; 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=VL5Y6vm9NuZCG1g7W3hxrDkMxlPp0J/npa1K1+DSsiA=; b=DjeCDkyV03p1MH23SfbryccfoXky+ZfeRQgVk59WH61M3aiQFNuoTqEtnSd18iHNvz jNbVyzFcF/kLYL5g1hgCcz/ZFhr1ONI3akJbnPFHJ9JWg7SSqiqjy4xSEGYcMrK33XAH RFtFyVjp6H2T3psO58C5eLTbzsvOi8U3juSoTmm0jdYHZFF8avbc5gTgSPx23/r1Th5O vwS0Htt/7JZgffxa+wg/Ii9eWKpuQmE5HLBqLaeCEDkqvsHBuCZ7iZsdCWXwbAtmTLm1 3dazqrRVXEDpDMY67zjdO1PTI5vm5fylBbd6lP1TtohRWOmJSP/yQkluTwsNz5pbi7TL 0XIg== 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=VL5Y6vm9NuZCG1g7W3hxrDkMxlPp0J/npa1K1+DSsiA=; b=Osc7uWS8KP7D3cnkyTgXXanQ40AqFcckOTsbxiv7WK/Y51cTHCXC99VZOSjV2N2jCl sV0AoEGwzUnFWJ/+CZKME2WNCSZU3ErtXrIJXMAd2c1PhOi7aaIqhz1Xm7gcXUIsTbc8 xMIc0Y7tg/9+kiu73kqvDa4wvaOHRhbhV6fUA6bLiO89R0Wbujth/LlhyzjR+42lVuxv xEWxMOuWw+P0ncAJ5lrOkoDDzrMRNWLg1ZXSGzlG4OVc4/9M19v8tf24uq9nyEFADtSE MMSxDcqO3jfvqEF/yHyTOSnW3q29FtfDO8nE04dbDaXgCLZz/l6AGhpc7Eoq3lumAk5/ acnQ== X-Gm-Message-State: AHQUAub23yyfeaXUOY8ug2cIVXxiQ8D2ksLMXbvS1avf+j4r0uiB5ZKd oRF76Gzy3Ror7buHmlPglpry7JX/ X-Google-Smtp-Source: AHgI3IbB0ZSFfIrhdjj4XKHl5dxzwGQFiY0GI+HzN6q1flYBcTqnMA61qDFeacUeSNmw+iMsy6qDwg== X-Received: by 2002:a0c:d80f:: with SMTP id h15mr3241724qvj.228.1550155787910; Thu, 14 Feb 2019 06:49:47 -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 k66sm1498919qkc.25.2019.02.14.06.49.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:47 -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 11/16] ARM: split out processor lookup Date: Thu, 14 Feb 2019 09:49:25 -0500 Message-Id: <20190214144930.27539-12-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> From: Russell King Commit 65987a8553061515b5851b472081aedb9837a391 upstream. Split out the lookup of the processor type and associated error handling from the rest of setup_processor() - we will need to use this in the secondary CPU bringup path for big.Little Spectre variant 2 mitigation. Reviewed-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/include/asm/cputype.h | 1 + arch/arm/kernel/setup.c | 31 +++++++++++++++++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h index c55db1e22f0c..b9356dbfded0 100644 --- a/arch/arm/include/asm/cputype.h +++ b/arch/arm/include/asm/cputype.h @@ -106,6 +106,7 @@ #define ARM_CPU_PART_SCORPION 0x510002d0 extern unsigned int processor_id; +struct proc_info_list *lookup_processor(u32 midr); #ifdef CONFIG_CPU_CP15 #define read_cpuid(reg) \ diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index f4e54503afa9..8d5c3a118abe 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -667,22 +667,29 @@ static void __init smp_build_mpidr_hash(void) } #endif -static void __init setup_processor(void) +/* + * locate processor in the list of supported processor types. The linker + * builds this table for us from the entries in arch/arm/mm/proc-*.S + */ +struct proc_info_list *lookup_processor(u32 midr) { - struct proc_info_list *list; + struct proc_info_list *list = lookup_processor_type(midr); - /* - * locate processor in the list of supported processor - * types. The linker builds this table for us from the - * entries in arch/arm/mm/proc-*.S - */ - list = lookup_processor_type(read_cpuid_id()); if (!list) { - pr_err("CPU configuration botched (ID %08x), unable to continue.\n", - read_cpuid_id()); - while (1); + pr_err("CPU%u: configuration botched (ID %08x), CPU halted\n", + smp_processor_id(), midr); + while (1) + /* can't use cpu_relax() here as it may require MMU setup */; } + return list; +} + +static void __init setup_processor(void) +{ + unsigned int midr = read_cpuid_id(); + struct proc_info_list *list = lookup_processor(midr); + cpu_name = list->cpu_name; __cpu_architecture = __get_cpu_architecture(); @@ -700,7 +707,7 @@ static void __init setup_processor(void) #endif pr_info("CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n", - cpu_name, read_cpuid_id(), read_cpuid_id() & 15, + list->cpu_name, midr, midr & 15, proc_arch[cpu_architecture()], get_cr()); snprintf(init_utsname()->machine, __NEW_UTS_LEN + 1, "%s%c", From patchwork Thu Feb 14 14:49:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158406 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462350jaa; Thu, 14 Feb 2019 06:49:49 -0800 (PST) X-Received: by 2002:ac8:67c3:: with SMTP id r3mr3255738qtp.309.1550155789500; Thu, 14 Feb 2019 06:49:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155789; cv=none; d=google.com; s=arc-20160816; b=Nk+vkNQgl2FS+f83Oq0lKYLFtDiHEG74mwRtE1JUD7nLH0qtVU3tj3LUt30tP0d7Hf gtw2k3epniBXrRfJUoruMCSaHnhELHNf1H5aU4vJQMEFSvvAszEPzc48cv5nafUkXeyO jcqyMgWUtAsS0AGMeOjVc+TYkmdxuIif966t0g4PnBCemm0XPZok4B4Yo3WavkgOcCJR d1S1g31CQFgbhRsQprhILohERhPWWd+ELyD54xSM9HB8zZtaun3OJke4fnKSh4CIXYD+ r4lPDoHQlJ6QGT41O2jjZDTH8mQc7kZevsNvJ3by+pKHdIByFkuWUWxCOxKxA50NojOF zd+g== 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=pAnOVz2Tf8tfyn6B3aYtP2aMoS37wFyp7WQ4pd7h468=; b=muWlHYcz2REPcwf/JUXxj9VYLfJGFXk9REK59pIIOBX06Y86hEuYYxqjBRhtc0yFdQ CUCHK8tnYbDSO6zDn2JA8WTrnrKrb1fkmljcGRYnWqndotgChf6/1ajgjGJJquJ+C9JI vacX8T5ZxSRaqcgeH/xCBxG1/Rv0ApHMKx6gwM8ki4PxhQEBBTxAj5I7rzUNrpElf2pX XTYaDLTaCeD+rHQjZKzSeb0a2J1rOcIWxdGaYoW54ndQFXq/Wihy6odziEXtJVr0xoIV a9HoaiqcFWgJiVuh/pna1zaw2oyxAUqT94ddZyGsOL37/9jEkpr+3Z8UHpjS+sFRL0/Z 821Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oqqa4c05; 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 r8sor2913258qvp.50.2019.02.14.06.49.49 for (Google Transport Security); Thu, 14 Feb 2019 06:49:49 -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=oqqa4c05; 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=pAnOVz2Tf8tfyn6B3aYtP2aMoS37wFyp7WQ4pd7h468=; b=oqqa4c05/tE/es628OJr0AKarImUFLu26ac/Z2ZYTTtqFs/psM0+eQUYUQoJofhFkW wD9y+ej56HVjNfAxvZ5nboB/WZMEhObRwTJcRdf8BwMVUZMXaJFbmkjLSE/wHf4LaKgh 8GO1ZBrEBfz63r0DJDKGYYhiSd2VQnxKUOq2at73VFQIFbDKwg9XUgM2RHKH5pzhgKAX t9XmWVZbDhv+TSxnyiFbqZBtYm0QT0GHBNI5XTWOs27srmfzsYzVM32z3DMhBbReLFWF +Y2LQNcgMvio+lC+DxKGCK4wXHbU+SY912+rsCTws1OYuHdW5+F2VlIeNcqU2XzmvF1e vtPg== 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=pAnOVz2Tf8tfyn6B3aYtP2aMoS37wFyp7WQ4pd7h468=; b=Bo9XPncwAd4TSXrFjp+I4aTduOQAw5xI44378hjn/45Z1GIBbDWS90TDd/7+yYfUHl ZnkNlyAR2N1teJl2Zj16u6v0H7UEWRj71Ikzz0as8pjmJOknjxZMtuv9zjemxTS5p2UH MZq783rADlddhgUtJNL52PXhhEe+WVYXCP5IyymC+L/rxqRx8JxteVRHrITbc6yj0iKK jdiQcpK90p1WoZM1NNxKVW/gdHNgm+ivR3a1NmvR4G7O1QdPDSWK/ku63qdwvHBZ5oHN M6Q+1IbQIsCMvpSJCAQYKyNURhVj2Z3D10A7w+GocvGCVQPbtZggxOeof7Vd1R/vvcKb 96bw== X-Gm-Message-State: AHQUAuaJTjP5X0+uONh9uXFyOATrX8OIE/DbxYPhQBpcL1YjyQUy2BF8 ntTdyqFwMlsFgzlCRtxbMMcsNoEl X-Google-Smtp-Source: AHgI3Ia2uIekICFgLPjSDp7jsbXUE+qOpPavV0Iei1TrHkndAodE352FX+21VP3xhYCudJAwVLsGXA== X-Received: by 2002:a0c:c3d0:: with SMTP id p16mr3259210qvi.47.1550155789277; Thu, 14 Feb 2019 06:49:49 -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 k66sm1498919qkc.25.2019.02.14.06.49.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:48 -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 12/16] ARM: clean up per-processor check_bugs method call Date: Thu, 14 Feb 2019 09:49:26 -0500 Message-Id: <20190214144930.27539-13-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> From: Russell King Commit 945aceb1db8885d3a35790cf2e810f681db52756 upstream. Call the per-processor type check_bugs() method in the same way as we do other per-processor functions - move the "processor." detail into proc-fns.h. Reviewed-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/include/asm/proc-fns.h | 1 + arch/arm/kernel/bugs.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h index f379f5f849a9..19939e88efca 100644 --- a/arch/arm/include/asm/proc-fns.h +++ b/arch/arm/include/asm/proc-fns.h @@ -99,6 +99,7 @@ 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 diff --git a/arch/arm/kernel/bugs.c b/arch/arm/kernel/bugs.c index 7be511310191..d41d3598e5e5 100644 --- a/arch/arm/kernel/bugs.c +++ b/arch/arm/kernel/bugs.c @@ -6,8 +6,8 @@ void check_other_bugs(void) { #ifdef MULTI_CPU - if (processor.check_bugs) - processor.check_bugs(); + if (cpu_check_bugs) + cpu_check_bugs(); #endif } From patchwork Thu Feb 14 14:49:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158407 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462379jaa; Thu, 14 Feb 2019 06:49:50 -0800 (PST) X-Received: by 2002:ac8:68d:: with SMTP id f13mr3443912qth.166.1550155790882; Thu, 14 Feb 2019 06:49:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155790; cv=none; d=google.com; s=arc-20160816; b=MdAiOT9whWUeaBclm06a7oTvkhtwgCWMWiPwEOQB1vBE31Nuq/ePf2UVNnrpjyPLLI AiiJFsP6NFOUxzfFWMYZKLhvlAav4AHEOr6wkDN7x7yUet3tKAT4qUwRfKciCSyaMQgZ /U5s29vAxgpkCnM4171wj66qTYjTrmZs5/gucBxxZtUmTHnKwKgGtwyUL47rXrGVYJVG eUCveBOIofbYnoF5AvMDPf3EqqVRK0voKVAaTabUiDIGVExDmjOHRCt+CZJPxfavbI9d DmbtiJFxtX9M7tHt16Ma8wQMhiqCcXCpyX+dkTtf7y1gkPU5PM1R60cenfliXX1xPoSM 6ZMg== 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=xJy7kJT4fBiBIJxxTbPYvInu/DuxzxwAzrjcMycc8Po=; b=MekefWz8QPoKvUzQSZO/XPoh3QgQCJ+VN7V7J4mnEBvLpLLaVvKcaUuTRwmz5UQgqU g678Qy22+mJZekwc0IP2H09H8cdNwh0qHsTxLV/Yup0hQR3nyK+bU4vA2Qviq3PipyPf a4IBd/Z6obxDs/4yhVS0xhRn28gyqN5pqpL07oxjkSxZTj9XdGLCPvQrjQkNCJOEsv6O PryrwZaJi6D5YAc8PgBdzV3KR0dKRHPimIM6gXNfiEZ+lMNS5qKnOZf2ddSpAFOU3pF5 Gp1laNEGYJs721p7M85OqBDr7F9YIPvJ4ctEEGsGrO1tsQSfLFFw7ZLUdZabYUagGXLN vAZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sCjhpD7i; 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 u7sor2943603qvm.33.2019.02.14.06.49.50 for (Google Transport Security); Thu, 14 Feb 2019 06:49:50 -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=sCjhpD7i; 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=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=RAoi0bSEBFSjjVOyc6mjwewf99T7TkF9sJz8FewpzdRJE1knbhOoH0y7seLGmlBvkB lnhJOPLKlYhQQFaUHIukOm1OYTc/dcDLc06hQIveA3XJ631Bb3h6RZdJjHz/hnqgBaXw 7ipCJZcEVciCnv08WjUKWZ3m1Lb2QgOWzieNELE+/rrNd6jBW9WaI2pcum6W5TGgqIee EYoykWrVY60/l7T9gN4+foj9Tuc+6tXWfalLbJ2rl4p/oGLofeBUmBm8ohbKO0WXch2q AAgq44uCQ+f8HIVAUlTI49utx9zEluJe09Mp6dFNCqeV4azcUrwIPnEt81ZJml3mkbdJ wVuQ== X-Gm-Message-State: AHQUAuaSCKufbCvPjZ6V4RfLNwvGAZAj1TCFVZnekCY04uBP+ifoOIco 7UlNH2eMvFdGMQh3m0DjiDrpr9x1 X-Google-Smtp-Source: AHgI3IaB/f2G9aoi9DM9btyfXiwdaUDoZTJfiaLyi5RXcGZh0CKVzVl+oS39dYFfdPGnc8DWA06sEw== X-Received: by 2002:a0c:ab8b:: with SMTP id j11mr701397qvb.28.1550155790606; Thu, 14 Feb 2019 06:49:50 -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 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> 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 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 From patchwork Thu Feb 14 14:49:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158408 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462408jaa; Thu, 14 Feb 2019 06:49:52 -0800 (PST) X-Received: by 2002:a0c:9c89:: with SMTP id i9mr3163939qvf.153.1550155792626; Thu, 14 Feb 2019 06:49:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155792; cv=none; d=google.com; s=arc-20160816; b=k3uyL7fbrC65vRSNqt8Zz8XbnP4oXqUSbYR4p+ZKOoSAlPj7bsIsVmKOwU1jPjqYgj QH75jv+oavwGD0W5RyzpjoGgZzMM/2RC0PO6d0YKjzZZrZSIU7IqaNEaPvPrjWqPsMMk z/JQxyg4N0kocLo14jZxVuVrD/nAIEsbnK8IeOExaxO504s5F7i6BaBAGX+6kuyxNrEu 0HXQAd+0cco7AzbN50daEzmDYaef4bG71jU+G3vSgFL7dspJdKzJsQPASOcs+ZlQs7er 9iBEoEjKeXMSUGdDkkeEm+9PdGgd+Avjs8EVXKmUD1hjp3NYLh/XEWOwx04Tu3dh5MUg 2jvw== 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=nqpC+x7OojB5e6AT6Ko7lpgIEeP3+R6qKzQcfmayAMM=; b=JqNNtC66Cb1Mkz4l2FcWqh0Lk4CiykKC6iWenSiKJWPDB7N4LrpZWKWWibBcnImhMD uJJqguK9KAzqgGC855zjUWuvkPNWy3jBo8Zye5WxfBM09PVi8bVSW/GNzZv4+am9Ht5b rCVLAJP9pZS8z8P+PwHiER09WBpdKXO5nNhle6Xr8/fbBAZYLA9uy8zxm5UPTxwrpLSb evM2RraT9ODhoLbCG6NyNarhMN2uhMTekcFmt6U16tKVafClB4fmrbufQwshPw3+a3Ss lbCYZM1o4mjRe3iQuWNQgpFQhfMMcrK9eQ96ghS5ATyU47oIWh9mtXAfbLXKQ/VyFkWz xZsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=meYdUgvQ; 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 u41sor2921178qvf.42.2019.02.14.06.49.52 for (Google Transport Security); Thu, 14 Feb 2019 06:49:52 -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=meYdUgvQ; 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=nqpC+x7OojB5e6AT6Ko7lpgIEeP3+R6qKzQcfmayAMM=; b=meYdUgvQh35QkE7UMg173Kn3m6ZmtUcD+hKsyAXGMHsvzuNMAa7X7SaN/B1RYTg1Og +5Cpz4ayI8VABKaDQa6i5Nw86AYJZkMELL1slCfj3JFws1/R/noHNzEWAgk5qyzuSGzU OvMSrj+mbPIAcjBbst8SxHWqOywr8AlRRpHl7ZANZlR5suo3zxoVbgIZwe96YOHWrbs5 H2KcacmsFeNt7TFOZt1CofU4g0PoCpgEFsFYzUr0JrSNPJMk0mzTHSn/H+bm1Yxj64PW 0PbK6b4YGDs/ywwaI2qZUnZIHGsVxN2/cKIWzPaq4pkOhPLDVrxsvbKqyzQuN3A0PQS2 psJg== 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=nqpC+x7OojB5e6AT6Ko7lpgIEeP3+R6qKzQcfmayAMM=; b=oOpVDv7nEcIn7pNfPq1Pj9EPC5S/UhCazE3nRb6PfgUxtzL3ccT/JEGgIdyHlnTfwa 5pUxJdPV5gns30/d5ZvZ107a3E87nfPuvWSztH5tGAXhDrUB259rwuWH3M5MyyzO3/aL tZQzFpuMjNgT5xP6LxZIpsRpUUrZ95VdcsdmhB0QAb1GnHLarqh2flhalHL7XuSiZEL8 3uNOARU7klOs411EarL5PPQvvAhIy3rVrI3UcuSTF4Ks9V6YqQsOfg+XADtDOkVcUQK0 tn2xVrLAQS6pUCuzgO8PQsb06MYdVWITHZfQ1RAlzVXAIIfs7kzWLazFpEE9PLpuZh0/ oj4A== X-Gm-Message-State: AHQUAub6HFcjW7SKTVgzcVTB1A38LlNIoPrDPxqlzlFcA8npAkBOsICB jUTj4+WIIPJfwDKrJ0Aqn8P53exXGOabiw== X-Google-Smtp-Source: AHgI3IahuzIaHiJUFBVk8WUV+O5N6w8lyQUfNkWVFf8GozAuuaTLSwzi6GBnC6eRxH906LFmswMkdw== X-Received: by 2002:a0c:8542:: with SMTP id n60mr3175888qva.205.1550155792303; Thu, 14 Feb 2019 06:49:52 -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 k66sm1498919qkc.25.2019.02.14.06.49.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:51 -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 14/16] ARM: spectre-v2: per-CPU vtables to work around big.Little systems Date: Thu, 14 Feb 2019 09:49:28 -0500 Message-Id: <20190214144930.27539-15-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> From: Russell King Commit 383fb3ee8024d596f488d2dbaf45e572897acbdb upstream. In big.Little systems, some CPUs require the Spectre workarounds in paths such as the context switch, but other CPUs do not. In order to handle these differences, we need per-CPU vtables. We are unable to use the kernel's per-CPU variables to support this as per-CPU is not initialised at times when we need access to the vtables, so we have to use an array indexed by logical CPU number. We use an array-of-pointers to avoid having function pointers in the kernel's read/write .data section. Note: Added include of linux/slab.h in arch/arm/smp.c. Reviewed-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/include/asm/proc-fns.h | 23 +++++++++++++++++++++++ arch/arm/kernel/setup.c | 5 +++++ arch/arm/kernel/smp.c | 32 ++++++++++++++++++++++++++++++++ arch/arm/mm/proc-v7-bugs.c | 17 ++--------------- 4 files changed, 62 insertions(+), 15 deletions(-) -- 2.17.1 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h index a1a71b068edc..1bfcc3bcfc6d 100644 --- a/arch/arm/include/asm/proc-fns.h +++ b/arch/arm/include/asm/proc-fns.h @@ -104,12 +104,35 @@ extern void cpu_do_resume(void *); #else extern struct processor processor; +#if defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) +#include +/* + * This can't be a per-cpu variable because we need to access it before + * per-cpu has been initialised. We have a couple of functions that are + * called in a pre-emptible context, and so can't use smp_processor_id() + * there, hence PROC_TABLE(). We insist in init_proc_vtable() that the + * function pointers for these are identical across all CPUs. + */ +extern struct processor *cpu_vtable[]; +#define PROC_VTABLE(f) cpu_vtable[smp_processor_id()]->f +#define PROC_TABLE(f) cpu_vtable[0]->f +static inline void init_proc_vtable(const struct processor *p) +{ + unsigned int cpu = smp_processor_id(); + *cpu_vtable[cpu] = *p; + WARN_ON_ONCE(cpu_vtable[cpu]->dcache_clean_area != + cpu_vtable[0]->dcache_clean_area); + WARN_ON_ONCE(cpu_vtable[cpu]->set_pte_ext != + cpu_vtable[0]->set_pte_ext); +} +#else #define PROC_VTABLE(f) processor.f #define PROC_TABLE(f) processor.f static inline void init_proc_vtable(const struct processor *p) { processor = *p; } +#endif #define cpu_proc_init PROC_VTABLE(_proc_init) #define cpu_check_bugs PROC_VTABLE(check_bugs) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 2eebb67fa08b..4764742db7b0 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -115,6 +115,11 @@ EXPORT_SYMBOL(elf_hwcap2); #ifdef MULTI_CPU struct processor processor __ro_after_init; +#if defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) +struct processor *cpu_vtable[NR_CPUS] = { + [0] = &processor, +}; +#endif #endif #ifdef MULTI_TLB struct cpu_tlb_fns cpu_tlb __ro_after_init; diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 4b129aac7233..8faf869e9fb2 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -100,6 +102,30 @@ static unsigned long get_arch_pgd(pgd_t *pgd) #endif } +#if defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) +static int secondary_biglittle_prepare(unsigned int cpu) +{ + if (!cpu_vtable[cpu]) + cpu_vtable[cpu] = kzalloc(sizeof(*cpu_vtable[cpu]), GFP_KERNEL); + + return cpu_vtable[cpu] ? 0 : -ENOMEM; +} + +static void secondary_biglittle_init(void) +{ + init_proc_vtable(lookup_processor(read_cpuid_id())->proc); +} +#else +static int secondary_biglittle_prepare(unsigned int cpu) +{ + return 0; +} + +static void secondary_biglittle_init(void) +{ +} +#endif + int __cpu_up(unsigned int cpu, struct task_struct *idle) { int ret; @@ -107,6 +133,10 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle) if (!smp_ops.smp_boot_secondary) return -ENOSYS; + ret = secondary_biglittle_prepare(cpu); + if (ret) + return ret; + /* * We need to tell the secondary core where to find * its stack and the page tables. @@ -358,6 +388,8 @@ asmlinkage void secondary_start_kernel(void) struct mm_struct *mm = &init_mm; unsigned int cpu; + secondary_biglittle_init(); + /* * The identity mapping is uncached (strongly ordered), so * switch away from it before attempting any exclusive accesses. diff --git a/arch/arm/mm/proc-v7-bugs.c b/arch/arm/mm/proc-v7-bugs.c index 5544b82a2e7a..9a07916af8dd 100644 --- a/arch/arm/mm/proc-v7-bugs.c +++ b/arch/arm/mm/proc-v7-bugs.c @@ -52,8 +52,6 @@ static void cpu_v7_spectre_init(void) case ARM_CPU_PART_CORTEX_A17: case ARM_CPU_PART_CORTEX_A73: case ARM_CPU_PART_CORTEX_A75: - if (processor.switch_mm != cpu_v7_bpiall_switch_mm) - goto bl_error; per_cpu(harden_branch_predictor_fn, cpu) = harden_branch_predictor_bpiall; spectre_v2_method = "BPIALL"; @@ -61,8 +59,6 @@ static void cpu_v7_spectre_init(void) case ARM_CPU_PART_CORTEX_A15: case ARM_CPU_PART_BRAHMA_B15: - if (processor.switch_mm != cpu_v7_iciallu_switch_mm) - goto bl_error; per_cpu(harden_branch_predictor_fn, cpu) = harden_branch_predictor_iciallu; spectre_v2_method = "ICIALLU"; @@ -88,11 +84,9 @@ static void cpu_v7_spectre_init(void) ARM_SMCCC_ARCH_WORKAROUND_1, &res); if ((int)res.a0 != 0) break; - if (processor.switch_mm != cpu_v7_hvc_switch_mm && cpu) - goto bl_error; per_cpu(harden_branch_predictor_fn, cpu) = call_hvc_arch_workaround_1; - processor.switch_mm = cpu_v7_hvc_switch_mm; + cpu_do_switch_mm = cpu_v7_hvc_switch_mm; spectre_v2_method = "hypervisor"; break; @@ -101,11 +95,9 @@ static void cpu_v7_spectre_init(void) ARM_SMCCC_ARCH_WORKAROUND_1, &res); if ((int)res.a0 != 0) break; - if (processor.switch_mm != cpu_v7_smc_switch_mm && cpu) - goto bl_error; per_cpu(harden_branch_predictor_fn, cpu) = call_smc_arch_workaround_1; - processor.switch_mm = cpu_v7_smc_switch_mm; + cpu_do_switch_mm = cpu_v7_smc_switch_mm; spectre_v2_method = "firmware"; break; @@ -119,11 +111,6 @@ static void cpu_v7_spectre_init(void) if (spectre_v2_method) pr_info("CPU%u: Spectre v2: using %s workaround\n", smp_processor_id(), spectre_v2_method); - return; - -bl_error: - pr_err("CPU%u: Spectre v2: incorrect context switching function, system vulnerable\n", - cpu); } #else static void cpu_v7_spectre_init(void) From patchwork Thu Feb 14 14:49:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158409 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462425jaa; Thu, 14 Feb 2019 06:49:53 -0800 (PST) X-Received: by 2002:ac8:26b9:: with SMTP id 54mr3356724qto.301.1550155793822; Thu, 14 Feb 2019 06:49:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155793; cv=none; d=google.com; s=arc-20160816; b=vYQ3txrmEthljumP24vD4WqNlvCcBpllI2+mBrtZwxMWi8hRZvqH/tZbrI0LCTrcg6 N0s6mRJ8Rz3QSPZ0pGNW3y8wLlY9LzMfkzJEEHv1nSW1de116aJ7rHut3qR6oyyUmCau vsnNOg9MOt0Bx0Gq6JcheuUyNYJh8oezY/AodM9zB/fqlTiZX+KN1kr7Q5M+VCASxsWp BR1Jxme5vxKJ4/vvNfLcdF8zaN9xWnc0C1VQRaPPOSbiKup9VddEpK2o/qKtSKoEnVUE gO1elW0jJiz1UIgx+9YIh3I2c9I667k6ZLfd9c69HmJPcpSuknc+mNFZiXQV/7ESro+c NlGA== 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=OZ3w/jmfXs2wPitKzfdSFG0201b2pR2doaOOTk38mKc=; b=UIsSq4nh+OsWO2Ma5FBdwaEon5/gXvLHgPVP9XY0WU+tfspGTZtxx/wpPqyUbhUU9O I8XOZyecLHk5JQz6LHwhhDnmvEjK1dQ1iLmiWgMN1l9sM36JidRKtr720zApU5FtxTIQ qIG74haKskLe8wkPSIFsX2x+PFTtMUaXLiIkJE3gsiNkRt4rbds2K64gOkBylE5/mXv0 sqVYTdKhdgf0f6PJbzfTGIEWJV/5hvOfhXvFjkn41tO7nY/7jipqYwzvT2lWI4q38DRn YWryTculRNo43h9cziu5OBb+G4b+mp478PNQE50g2OBgSxAPkQGjV4ayB5Ztr3w7Yi5d LGFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XpWeH7lS; 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 a9sor3205931qtj.40.2019.02.14.06.49.53 for (Google Transport Security); Thu, 14 Feb 2019 06:49:53 -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=XpWeH7lS; 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=OZ3w/jmfXs2wPitKzfdSFG0201b2pR2doaOOTk38mKc=; b=XpWeH7lS5H+3J1QFhvbSoyLLqklA1vROnnRDJ+ITFcNghqk16goR7jMGIqnWxYUYDq dWz3W6p4SH88in/qqqxTriIULi9n42o5qOcDnM0/MAVT/EXCOdqrYcqBZpsXhrhqoK5R i8HjtnTeuHQL/s4D8tihJJ/oJvH7Hy9o8c7KJIRhFXMhvAcAP5tfgPbWMevhTFoNN5TL 1s+rpeBTOh0uJvabSCOQ3BSUtJliKCOFkip48o10bT0wH7ZeVDxZ1gAG3Llv2ysWPtVB Dd1bfJkaJBuha5Q/GT/vUG+UMxbKebFjaRpWr1nH8dXYO633/6rgeqb+AlFOW1YFKJy3 Cpng== 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=OZ3w/jmfXs2wPitKzfdSFG0201b2pR2doaOOTk38mKc=; b=oVuhH4exhGCZJXryonPtUa7V/UAdtL/n7mMXf5yMcYkQkZgc6Cww0PSwtNYR0qMgsB GbzKS7Zp+1foYxz3lSr0Qhm1gBVSzHRGkYQ2RyVHBlE5bFSTbawmRc5tnVh5DGBvGG+Y 8OJWvJqMFT+24i4tkiLhsKQJggSFfix2I1n+99AqPJN3EbHYV1OSVcqDf7lMJ3akcWUD yOX8Kl05bNSdbwzrltx3nOvq89SSqj2GYyjKAUTHaa1ixMW+GyUqO+MtNZrcyMNtVF0n qZwm9ExcN5seoHbuhSZMdrlL4p2tIfIzjqgVGfQNpvlscHWc6OSEUxTb4XDczM1andFH uLQg== X-Gm-Message-State: AHQUAuakJvI4Tg48PLD9mCdkRGXbV8gKpBd+nLtoGfftxpqpDddQdN6J ZoczTjm1wuRS4bV5OU8iWfDPoccXPSitSQ== X-Google-Smtp-Source: AHgI3IYDvHYEt1JOmFbHDHNBdaYonXbEGuQH4Yfe08E2etAt8PWdzu/HrFH+WXBCCyJrBbjKfP2gyA== X-Received: by 2002:ac8:1413:: with SMTP id k19mr786554qtj.134.1550155793586; Thu, 14 Feb 2019 06:49:53 -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 k66sm1498919qkc.25.2019.02.14.06.49.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:53 -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 15/16] ARM: ensure that processor vtables is not lost after boot Date: Thu, 14 Feb 2019 09:49:29 -0500 Message-Id: <20190214144930.27539-16-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> From: Russell King Commit 3a4d0c2172bcf15b7a3d9d498b2b355f9864286b upstream. Marek Szyprowski reported problems with CPU hotplug in current kernels. This was tracked down to the processor vtables being located in an init section, and therefore discarded after kernel boot, despite being required after boot to properly initialise the non-boot CPUs. Arrange for these tables to end up in .rodata when required. Reported-by: Marek Szyprowski Tested-by: Krzysztof Kozlowski Fixes: 383fb3ee8024 ("ARM: spectre-v2: per-CPU vtables to work around big.Little systems") Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/mm/proc-macros.S | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.17.1 diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S index 7d9176c4a21d..7be1d7921342 100644 --- a/arch/arm/mm/proc-macros.S +++ b/arch/arm/mm/proc-macros.S @@ -275,6 +275,13 @@ .endm .macro define_processor_functions name:req, dabort:req, pabort:req, nommu=0, suspend=0, bugs=0 +/* + * If we are building for big.Little with branch predictor hardening, + * we need the processor function tables to remain available after boot. + */ +#if 1 // defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) + .section ".rodata" +#endif .type \name\()_processor_functions, #object .align 2 ENTRY(\name\()_processor_functions) @@ -310,6 +317,9 @@ ENTRY(\name\()_processor_functions) .endif .size \name\()_processor_functions, . - \name\()_processor_functions +#if 1 // defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) + .previous +#endif .endm .macro define_cache_functions name:req From patchwork Thu Feb 14 14:49:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158410 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1462442jaa; Thu, 14 Feb 2019 06:49:55 -0800 (PST) X-Received: by 2002:a37:ba06:: with SMTP id k6mr3091795qkf.115.1550155795112; Thu, 14 Feb 2019 06:49:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550155795; cv=none; d=google.com; s=arc-20160816; b=I/lsEqjAkfRYWwz8vPmFXBYdb2jU9vReI2vEGJbu6nuW95milA/VAYlp6+IYadL9VP iC6MfMHbQbU4v1dWJV++Mvd4L5A+YmW/gXgnkFQ6H//dzLptAsMQLz8PLduh8OMLgyc5 oH2aiAJu+NZCAM6Dq6K7iwIDMiJF0RXiQ7t8z7j7mfOUP9P91d/pTEzeGUiRPJIPvt/h N2i53b11UZLOdzGb78c4ZkLrt/mxydNydzDGVYb/MC7t36kNKKRlPl4C20lvuDPEQbEl i/XWqiONnfCWlGkovTrCoU97QJfpPE+AfRYM7Y/98zAL/+2u44b6sAgb7I5zPCXY+v1P 7UIg== 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=WbXTq/rv4PTCxNmHyDWfQL5ZTTgJSJ1C6Vt+iGpdItk=; b=Mfcg4+ZH5GCe1DnNZZh7hpmy/x1Zr4Q7h4EuQYFXqu0iF/5ZD+a6LkmL3nN1m+nRhX Fe4eGn4eEE8fwcf3fueLMyOpa3vRna9pwYf5jn2BsG9tjN0D+d6JBRcuvTYXLCj9bbQn wSLYknBrv1TSPmNO7quDfnsrzThaqpGZ/YglN4LzabDtAgr/Puam8pOH6IUGUph/zxf6 WqqZpwqAxpZyDnnFGR4I43WMzhDXn9ghNIdJKFUh4FFW/BubpFKLZ0lmgli9KwroLjRF idooBe2W4zx1dX/+S4Far4HP3H/DJ35SeZ2a7z9KteixsY795xZPZwxXgCMOCGRAPTrX GG4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=utApWRdu; 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 t11sor3207075qti.36.2019.02.14.06.49.55 for (Google Transport Security); Thu, 14 Feb 2019 06:49:55 -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=utApWRdu; 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=WbXTq/rv4PTCxNmHyDWfQL5ZTTgJSJ1C6Vt+iGpdItk=; b=utApWRduTafCEFGv8UAoII0fePrHnB33bW4J/MQptc0lsPlgbmsQ1qtVb9MMnHkiUL jrG56n4yCy1KuQKwHn4C7PKyJQXFEZS5hgjDLQURUyl00zgciW4Q5N1OzrNmK8McMQ2H uINaH6/BILlntPaPi7xE7VW8OK3XLqrFyJ/lgNq97H8EUNjVLBQRLzU5ObT0bNF1+rOy 6aX6UGmbyx9RygbF1jSSymTia1hAYqBrytu/G1gDS/NyR/XF/3TSdVWJ88UERuGSf3Jp +VOBXow+YpZ41THXI4CWgyBRMzm1xG1vbBWtviB8faOYMxJG2JXS85I4nlF/SnF4cy1R Kwng== 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=WbXTq/rv4PTCxNmHyDWfQL5ZTTgJSJ1C6Vt+iGpdItk=; b=EhpWHn/Y+n/Q/WkZBxP7UXgp7ScRpZ9vVk5hnCa3zy2qu0fYBEZL0sr2/yCBxnwwl/ hdzQh9nnNL+2dN/3V+Yt3j7YSHJA0e8TvUcoz7hsJwnYKFsShy1IXW+B2N80PJllr7tO lWTUeYdYuiGq4Eq8ZpxqG1756eexIP4Y/x+6gnaeCWHlnIb29tOMhR8CspNDMzCm3feT dszRTjPWEyGeAotkb9QuP40NQfplauIV66CuHBqcsCYmT4XKim45MaGxTkqDuPC3jAOl lBLnvhTugogSVtMFm9LyOKS/I1bKT/ncRqlzaRn5WRsGvKUAxrARvuEDngQ+dKq7zRwk gJ+A== X-Gm-Message-State: AHQUAubpceia3SMwV0zjATdyQ4QegSbE3T8v3+e6DbVGr0Q9MHGJlQlF YnYPDJJ8aTqCVwO5B8477f6CUSAd X-Google-Smtp-Source: AHgI3IbFz1iUbRoxfRgmOdWkz41vaur9A+BtxGrF6mFztB6uoGLcDn0JYna6uhIqtASfYo0eIOjmPg== X-Received: by 2002:ac8:b0e:: with SMTP id e14mr3403862qti.336.1550155794878; Thu, 14 Feb 2019 06:49:54 -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 k66sm1498919qkc.25.2019.02.14.06.49.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:54 -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 16/16] ARM: fix the cockup in the previous patch Date: Thu, 14 Feb 2019 09:49:30 -0500 Message-Id: <20190214144930.27539-17-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> From: Russell King Commit d6951f582cc50ba0ad22ef46b599740966599b14 upstream. The intention in the previous patch was to only place the processor tables in the .rodata section if big.Little was being built and we wanted the branch target hardening, but instead (due to the way it was tested) it ended up always placing the tables into the .rodata section. Although harmless, let's correct this anyway. Fixes: 3a4d0c2172bc ("ARM: ensure that processor vtables is not lost after boot") Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/mm/proc-macros.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S index 7be1d7921342..f8bb65032b79 100644 --- a/arch/arm/mm/proc-macros.S +++ b/arch/arm/mm/proc-macros.S @@ -279,7 +279,7 @@ * If we are building for big.Little with branch predictor hardening, * we need the processor function tables to remain available after boot. */ -#if 1 // defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) +#if defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) .section ".rodata" #endif .type \name\()_processor_functions, #object @@ -317,7 +317,7 @@ ENTRY(\name\()_processor_functions) .endif .size \name\()_processor_functions, . - \name\()_processor_functions -#if 1 // defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) +#if defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) .previous #endif .endm