From patchwork Wed Feb 13 21:32:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158253 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp560725jaa; Wed, 13 Feb 2019 13:32:27 -0800 (PST) X-Received: by 2002:a37:7883:: with SMTP id t125mr192135qkc.201.1550093547709; Wed, 13 Feb 2019 13:32:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093547; cv=none; d=google.com; s=arc-20160816; b=MjCk3Q29JIbIFc6a3fCVYdu6qjoSu4N6ZUpmI7/J5n5bOmM4kvcv6bJ7rJWTw7dMyS vn0W+6lhGHcjesurJX5aFqmVYLekro0B2ck9DCVb0B4v4d5/D/iJt5LVoiDFHTsBQbvV zMcaZgWcUl0Bvwlhy4y+C7uSLpGefSFEGJbYxvMumI2+PEWoEbLrAl3fAEaXtEAIHnIF 4rTL3OV/Ni9x6GooVj4Eb1mF4FBDvkpGOfxAV0/fT0sveg5lKKfFjDFANsSnRO7pmh7Z OkWvBH+U05jpUxvaGCt1LXRrvlR3Le5OhTAZl4F+8Cz/Rm2wSB9Jz+O7XM9aFkke6BHp zrMQ== 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=ADQDpeTXG9pWgt+iamM9Cmi26SsIAtmUaJH5Crr7iPE=; b=HHyQCjHRBWaG78U5cmxWTw4VQpCC1v9CDXveiX6vQonZsrOD2j+B6Ghil2zOKiI6Qc ErJtHi9x1sQuIqGoJxgVUdJzgw71qZo4zcroZZOrwVP4oOYwDK21YY1OrnoCObYPmpbO CX+RpTMsesxKe/VJpuTZwmVU2NMgJDzIA/NUpUkM4gaL3gLkuUbj3gqA+MdAOyKZFeon Gk6UNg0ufjRy6iAZsSQU5JskK+FthfRVTRxP7pBwcVfxS7cZb82dy/bJEIB3GgTdDdxu RBwC2MpSnK71Dn6JpR8iamendYNQDw/3vrdiRMfuyU4uPWB/9fXiIXdpwtHWxtM+bk9A zvKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bylE+VkM; 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 m2sor564312qti.39.2019.02.13.13.32.27 for (Google Transport Security); Wed, 13 Feb 2019 13:32:27 -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=bylE+VkM; 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=ADQDpeTXG9pWgt+iamM9Cmi26SsIAtmUaJH5Crr7iPE=; b=bylE+VkMOO4hIOd9uSGuNlN74QoZvhmAPx+T+ZSqCbcgSeR4MuoSRbK0/mCLeCS1kC 8mBPhJddgiezzdnOFI1e0Hk2+g5X81whlLrl7u7bZSWxwGo/whqv40ykWCcXJyUo7HCq mJh+iU1KqgisH3Dh11uPsvJMsa5gEiCKNdyarE8ZSnEx+52DgKGvs9j0s2R90GXA3AFP VpaHYxiWpyMx9Y7bqnXA4GMTj+TXYO0rnF4ciqihML+wuPychBQ4XtgJfELKNaUQuS3i Vvv8nVhxWR0kNHavHg6IduZHrDAOW35HJryjTKT/35eF/xTBXm8JW8ncpZB2tW16QG0H uI3Q== 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=ADQDpeTXG9pWgt+iamM9Cmi26SsIAtmUaJH5Crr7iPE=; b=E9hVGBGu7Nt8gWf6ngDViU+xXb0ECfe64Ty1GVoXmm0iGSy+iiTYPzwSSvs46R2QFO zcDBjbHPKHm2cem/tLDcGws056m7rhKVjx/MCDH24MwOuCSd1SvgIzr+plrA8M9Vp+RS b9D6iO6vKjOHmOYnmL7smrMlXxJE5/9LK/Oe4FZEnok4qkET5VTKONCiJkhfF45cXeAX iTG7Ms6MjUf3qm9PDoBRVwbB4VZKZqpjIDQRqFZNNvICyI5zst/+VcZGTC4dX6Np9nIn Xas9NzJLTuzEfwNr+XcGziQUGQo5IgX1R7MWIgEhyNn0WlPfquiOFA2fPGZifdIQljhL DSng== X-Gm-Message-State: AHQUAuZIhm/cyUt011v5KFwY2dMGRE0Nh0c+rZBhcc7Q94GilznxrQ3c xEyFEuUZPTVUnta9k51oeVcsiqX2 X-Google-Smtp-Source: AHgI3IYz8IBn4iko9QcIs9dbw8dxMfkpbzMPcZt31mXi5B2aXwILnN3550Qp33798L+kSKYcDKMOjw== X-Received: by 2002:ac8:2b51:: with SMTP id 17mr229831qtv.328.1550093547353; Wed, 13 Feb 2019 13:32:27 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id 8sm382675qtr.7.2019.02.13.13.32.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32:26 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Greg KH , Mark Rutland Cc: Will Deacon , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4.19 01/17] ARM: 8789/1: signal: copy registers using __copy_to_user() Date: Wed, 13 Feb 2019 16:32:07 -0500 Message-Id: <20190213213223.916-2-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: 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 b8f766cf3a90..76fe75d36312 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -288,30 +288,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 Wed Feb 13 21:32:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158254 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp560751jaa; Wed, 13 Feb 2019 13:32:29 -0800 (PST) X-Received: by 2002:ac8:38fc:: with SMTP id g57mr229541qtc.39.1550093548996; Wed, 13 Feb 2019 13:32:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093548; cv=none; d=google.com; s=arc-20160816; b=pcz1K/qpBCSlvVWipNLBg3yNQAF26gXffhuQRKcF7gGLomLlX7LuCEchfGCXFbSt7B jo74/0DYWOMjdglpwWARlel6CjSdfglaosF2o9F6Eo+cis9sFCNFmRtoaEhwBCX2Hgkl CQWEuVfSAVio7H18+w1S7FZF0DFYdbXv4Op8/cDVRTd/RfiLfPjIwrMALWVhqxODZXjr 1C6kO1HPXMC6ov52EinF4valz5hWt4REULkVvaqwGGkhgQIREoD9VGLCVh1djO2T7nPT 2re6Q9jYC5JJmrLVUC00Q5Rxt0uW4JHMoMBS8ilhvj4aquQubaFyZ7+EwgDfiT1t4MRP dFyA== 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=5XtoX2htZ0Jn0tkRDWU+S8lIEuB+MnkGDKzlpE3hBEI=; b=sGttiStFd/14Fgoxes0wjkpgB9CyJYXQqVrIjN/Fc6NPICUMTMu9Ss+Yq1rDr+AeCt ZYCS0nnuzZqJuXT0MRC5R+26IgLAP8YMGo19QspkT46O/Fpd0daAApr9HL+4YE8A8qLI DMn5K4/RhiOzaqbhg9/2IMZLINB2ICq2tXmLUWnGzmik6/qBS9hWNs2Zgt+otV8laVzn uIaciLaJj+Wm2I/lf+z5qNaBSCIeLLUGRMLiLWPHB+0tESNLhNNDBY34S1xAKwQtglkl ySLCglKRsiBHOpt2KmFSaoYKvk2YBZO2DI9GcN9wTW02E06deTzPHpvbwpToyjKGRn1Y QJHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="INlw/sfd"; 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 l17sor582114qtj.21.2019.02.13.13.32.28 for (Google Transport Security); Wed, 13 Feb 2019 13:32:28 -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="INlw/sfd"; 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=5XtoX2htZ0Jn0tkRDWU+S8lIEuB+MnkGDKzlpE3hBEI=; b=INlw/sfdBet8zDSCENoUwjfxegtQlubL9UmVGQ07agMByfU1HAD3H6h9a1h2loynnp zBn7NmrS7lFmiBMIz9STmkRLR4t0EGPGbcfCvbTVmPSrCy2PkE7Z0HkU7OwuAuiOjR3M TKMa7VyyFbih1CnDzcjCy6tjIIoJ0owEjYB5s10dv8Di/0rRLxE3y6e9eDMS55JtKNmH yub/0NtCqNx75NQSD4oRmEx8hWU7+SaDO+e5P9hWDV4q76VDLGbxTISVejAenTSkwwYl t5Z8E35rqVaX7ETno347GhxF/MP/k3KiU2j22qhp/IRz8CY7HuxQgbG1BQxSxnFE+Gng kcXA== 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=5XtoX2htZ0Jn0tkRDWU+S8lIEuB+MnkGDKzlpE3hBEI=; b=jT3FbQnoKEG6+yZ2Ssn8a+qC5Y7Q4JqCUu8BuC7N19xuYKs4PHmdmGcCDo36xoKnMf qvDPfJ30S+CVhQ41umxkpIojN1bG/FyGjY0K96DlhlNSq+roMzrlpZ/OrmTS3u12Vbv+ lkJviE/i1TDMI36iLhCEUS9JlZJ8L7HeyMT+/fYmY44Md+aOSPe82KzLE6FmRS6lIFD9 4H7PerNKDQgwpcSbgLjEeG/591bjvLQsb5+WiHq+exl1PAfx/Dk+vqHom2+iRtXthf+Q J5IGGx59c3kJglnyPPGz8RgliedWSv4wTVI1oGboaePcHEYbbzAUI9x6gBedO5s+hD75 /aow== X-Gm-Message-State: AHQUAua6M9c38rbpp4tomCsoZ42BI4PKWgBHOyu3K2lmxliEHjsDf8CZ rIqs5fB4vrXxh5WTAlwCmcaTQvqp X-Google-Smtp-Source: AHgI3IaAByStjv6V8O35bZXVYKzOSf+ybqp0f4fOFSaCjYM8AkzPrVq89diPIrhoukHRBUh3IUknVw== X-Received: by 2002:ac8:17e7:: with SMTP id r36mr249071qtk.104.1550093548757; Wed, 13 Feb 2019 13:32:28 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id 8sm382675qtr.7.2019.02.13.13.32.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32:28 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Greg KH , Mark Rutland Cc: Will Deacon , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4.19 02/17] ARM: 8790/1: signal: always use __copy_to_user to save iwmmxt context Date: Wed, 13 Feb 2019 16:32:08 -0500 Message-Id: <20190213213223.916-3-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: Julien Thierry Commit 73839798af7ebc6c8d0c9271ebbbc148700e521f upstream. When setting a dummy iwmmxt context, create a local instance and use __copy_to_user both cases whether iwmmxt is being used or not. 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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index 76fe75d36312..464393d241e1 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -77,8 +77,6 @@ static int preserve_iwmmxt_context(struct iwmmxt_sigframe __user *frame) kframe->magic = IWMMXT_MAGIC; kframe->size = IWMMXT_STORAGE_SIZE; iwmmxt_task_copy(current_thread_info(), &kframe->storage); - - err = __copy_to_user(frame, kframe, sizeof(*frame)); } else { /* * For bug-compatibility with older kernels, some space @@ -86,10 +84,14 @@ static int preserve_iwmmxt_context(struct iwmmxt_sigframe __user *frame) * Set the magic and size appropriately so that properly * written userspace can skip it reliably: */ - __put_user_error(DUMMY_MAGIC, &frame->magic, err); - __put_user_error(IWMMXT_STORAGE_SIZE, &frame->size, err); + *kframe = (struct iwmmxt_sigframe) { + .magic = DUMMY_MAGIC, + .size = IWMMXT_STORAGE_SIZE, + }; } + err = __copy_to_user(frame, kframe, sizeof(*kframe)); + return err; } From patchwork Wed Feb 13 21:32:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158255 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp560773jaa; Wed, 13 Feb 2019 13:32:30 -0800 (PST) X-Received: by 2002:a37:4892:: with SMTP id v140mr204934qka.71.1550093550347; Wed, 13 Feb 2019 13:32:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093550; cv=none; d=google.com; s=arc-20160816; b=PH8ecXBlsjjr8EqdU3j3zBVPzFuBcublNbaMIzhAoUHIOiqsB/KpZxUea/xSbodRHw UPflFZ+7UnoQut5lcpuMTM0BGrNn/Q6gFrHHM7N9drhhdNV7iyU6YnAo5A9JafSu+j3a DWFioTB+cY6NVtAWrOr8GmoB0XYlTpaOxjV8TPeIrL6ME8T2vPPiL8zhBWoA7QzdpW3f hMg+J7qztHBRsjOT3MDRUhtkzdq3KXeCEnQkibBWYftbxV2TdcDV64NkydV/rXo8eql8 RuF0RG4y4t6aJ7VlnBD0GA/Bc2WEq9ADXpR+uYFdZmu8n66UFbX82ktONxYCM4vO5AjE +Vog== 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=3wa6rXoZSMbFMmWTug8sDAz2t0wRwAm1naoRdniYFLc=; b=S+0a4xGqix4nXpSJQUsbsOSpMMgLQQttj47SEor3usVFyYxoU4YsaXDu2+f/RcwHMj GzkdNXypPWQ2+ZBxKMO7pcA+csNmpcEIEWhQ+OxVhg/N1Sx1T4EiV8xVSkKvXN4YAsCS g+uTpvUkqlMa+wURm5XdKZdjSgjDkXnCtXEgPJHaGMSDhPx95eunF2mdaRlMBqmw6Eid yEJnVYDYyuyodRoeSl7GfQKYL8WLX3ySFFzkZgHY4Dad6An3aiTMH+KGh2aGRAxWL46W E0TDjJ8eocVKJ+Bc2nKTK/rHrwYoJkRb+Xr5Uah0fWJZ6zs5/U1yCvfru/pAEHyWp80/ 2hPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WwmhYKUZ; 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 l6sor570597qte.24.2019.02.13.13.32.30 for (Google Transport Security); Wed, 13 Feb 2019 13:32:30 -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=WwmhYKUZ; 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=3wa6rXoZSMbFMmWTug8sDAz2t0wRwAm1naoRdniYFLc=; b=WwmhYKUZtwqmZBPxddYcC8svjEnrpVRs3C6Z89jsp+3z/4O7ttPaFjqC840opkxTzf FSRR9Qt7lbgk7buXPR1/fWZv0rNJffk5Te7k3osJ621iUIeP7po0k10DVuSE5I6fS9hT zJqIW/o9lS1KJ5YIL/CI6XeOd5ngo+kIOJuoW0KBHRgf33uDshpWob5HTcZqR9I2fxsD hRmMokLfiBC++7mt4GVFx3TXqE2koSnqVh/zSqYl5jsUs/SduAItxUF+bDO24QFRy2AP Ct0ObW8+pGJfCb9h/+UrV84/MddJh06eQcI4Coor67KzH+8KON4WHtTjHk1x2+HfMSNI w9dQ== 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=3wa6rXoZSMbFMmWTug8sDAz2t0wRwAm1naoRdniYFLc=; b=fXyuARN6o6dMvR6K+5iaVhlombAQeeqk/wmDbrm37+zHyrmMNL5OtZ/Kk8SBe5OwYz bGoZzrbE2+9I0G7R7hu1YpdXrdosIehuYLWp56LreltA9C7D73Ifj6spfxincCMzdTO3 vUreblCIklJOPaHdZFQdmYP8vjwlTgNStzsFyk3dS3BON/sIW99r5FX86Q7Rk6zBX3rI cwGoS+tab52ygaBClI7UisfJyN0CGROcK4GE3N4e/XbAxpjiPLrV55xYSmmIFKYJLF5W 3gbzkkfjKVDcBzFoqt/sEukWxikwHBxU4r607u1KB+Y5rsTS5IegIO8yttxsGVFynWVO yZdQ== X-Gm-Message-State: AHQUAuZyMA0E+nO5Gb3M+LCvWSc/ZIuL3qF2ja8NgTnC+lAm40it0Do5 /SBk+T6ob0ozgG7TW4vB240y4pWZ X-Google-Smtp-Source: AHgI3IaRqUchb0ljK7x+5kla1RpF7roRiiW6Th5b/C3qiraVvKmJpiIlYIUbPfB95SObg+mo1zguTA== X-Received: by 2002:ac8:6643:: with SMTP id j3mr251608qtp.108.1550093550087; Wed, 13 Feb 2019 13:32:30 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id 8sm382675qtr.7.2019.02.13.13.32.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32:29 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Greg KH , Mark Rutland Cc: Will Deacon , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4.19 03/17] ARM: 8791/1: vfp: use __copy_to_user() when saving VFP state Date: Wed, 13 Feb 2019 16:32:09 -0500 Message-Id: <20190213213223.916-4-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: 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 9b37b6ab27fe..8f55dc520a3e 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h @@ -121,8 +121,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 464393d241e1..1e2ecfe080bb 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -137,17 +137,18 @@ static int restore_iwmmxt_context(char __user **auxp) 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(char __user **auxp) diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index dc7e6b50ef67..2b287d0d6bc2 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -553,12 +553,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); @@ -567,22 +566,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 Wed Feb 13 21:32:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158256 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp560799jaa; Wed, 13 Feb 2019 13:32:31 -0800 (PST) X-Received: by 2002:a37:cf56:: with SMTP id e83mr210154qkj.101.1550093551701; Wed, 13 Feb 2019 13:32:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093551; cv=none; d=google.com; s=arc-20160816; b=p2G2LoIUiFJnB8hjsg+sNSSTOUHIq4qqVGJwoAMgIeKqaKhQAlXTE5bkoU4tN5/b5c Xx0zVIVde0Oxyh8T5syxrns59VBUp/zQqdOUYot/R9m+b+c5vjYVeDteW6zaGpN6cYYn /CPXqAYDoczQbyzUn3slckMCBukltWU0hMuIXyh9cWNn4OlwMnGvd+eKLJ8Tp4RbcLxo X4aSprGYGy7aYdokuKw/pr/cq9S2pSFkFpcGLRRJG8I145xx6w0FeE9h/9OQUmVac6rC PmqjH5pm0r+o/25eQo2IbVYv7SH7686JkCXBr45izu13JJXLDXMVxZ3BFoJNq7ZllxoZ PMsQ== 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=XKNS61az1WGOd8AWFZ4ZTIsUVQ0LSar+s/KyUDJcDZM=; b=CzlKhSOoMH722ruCcH8pcjaVSQoyI1PNF+141xOFzU3hVL6XMVchAEetGebzkJAplb e4wmVBsKJ62s7XN2bpgjTFProZxZOe1ygy1ZSzL4YdplsYw5h1WrTGyI7GscE9cYY5yl GLW+i7zRcmmZ71GoPqp9ce1AevMq0m8lXnq/WyBmtzLtzAGmm2H8YQYGVEtY4eK6Vdpf zCE8U7Tw3sHaUAfThuQ0J+6UuC+UMPuJHuXzFMQHRZ8aFgOefZiWQPGgiFiUngPzcOTL CmjIoeXeBqRM07LiKRTOEdUQk5a7BxsyJ0X1utun+VPP5+doP25waLVUXaDexd13zDax t9Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KL+czqKk; 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 y2sor583966qtb.0.2019.02.13.13.32.31 for (Google Transport Security); Wed, 13 Feb 2019 13:32:31 -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=KL+czqKk; 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=XKNS61az1WGOd8AWFZ4ZTIsUVQ0LSar+s/KyUDJcDZM=; b=KL+czqKkXMMB508fq669G8sT+oinM88F0RwPUXD47WYPeCn3WLKCVKUEffgwBJq773 Bg1l2Idlw4ewZ01aKj8lj1coFPtuAL3watPBEPI0V1YOSoDdePcdZB8Th3Fd3c0qQWUv 9PHttCq3XE4t+Wgv1+Od9KHuSsuezWVZO4EV+qtM7rzYx61k6AeU+ooiynssjwKJsgSE /dlmUOsLQF+2QCdYMAHoMSSlAEoiaEMG5c7qpJ6d4se4O0aALSlTRnnsKxhoSXQc2K// ilgZIL3sdIklo9RYYGOMyomibbU7A4nJ4qtH3wT1x9FoXpGyuxCFuDjugd7OXe3YmVEl u4ZA== 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=XKNS61az1WGOd8AWFZ4ZTIsUVQ0LSar+s/KyUDJcDZM=; b=iQCCm5D7aYoCGyFD0qjsCB7Gk/Dv+Wtzp3fMEBTJVVzhcDuLzO03rd9iMtGsCmzOHm QbmuZ7RuFVtVLRLclmBIzB+tguUWOyz2uVk3WFKyXKzk70U0bkFHgKk4x8bBgZuGE8gw rh2HoOkkTLqZZfGhqTqz/5/RoyxfUIx/cDjsdlywp4JhDVrrZ+d14LtiD6lWunWlA3au QdbkrO4r8vXpdL/y24ZjcJ08qbnMTL0495vN7AUGw6rpbiV2t5ic9drFThtIekfDrBhH 9PmBUxMk51kKl+KMeVOTs2BSC7wQOdV67lYfO++ylsLWd8ccFHDgqqmGmuOj/jqu49GV DZxA== X-Gm-Message-State: AHQUAuZp9HrDB6AmjBvXq2VbpH+9CQQsLPFFhWg+aQEUYf5odCQvrd1j 2FW7Ywix73abA5UraKQ3fFJL89gZ X-Google-Smtp-Source: AHgI3IafCpIs/y9rPR16co2x66QKSVzJyNLtvmMs6gDQZEW/2cbXdskUKQ+2kKteni/lPrG/s6kmDg== X-Received: by 2002:aed:2044:: with SMTP id 62mr224159qta.11.1550093551451; Wed, 13 Feb 2019 13:32:31 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id 8sm382675qtr.7.2019.02.13.13.32.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32:30 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Greg KH , Mark Rutland Cc: Will Deacon , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4.19 04/17] ARM: 8792/1: oabi-compat: copy oabi events using __copy_to_user() Date: Wed, 13 Feb 2019 16:32:10 -0500 Message-Id: <20190213213223.916-5-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: 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 f0dd4b6ebb63..40da0872170f 100644 --- a/arch/arm/kernel/sys_oabi-compat.c +++ b/arch/arm/kernel/sys_oabi-compat.c @@ -277,6 +277,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; @@ -295,8 +296,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 Wed Feb 13 21:32:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158257 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp560834jaa; Wed, 13 Feb 2019 13:32:33 -0800 (PST) X-Received: by 2002:ae9:d8c2:: with SMTP id u185mr194324qkf.107.1550093553051; Wed, 13 Feb 2019 13:32:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093553; cv=none; d=google.com; s=arc-20160816; b=okrDLMJsj5pNKQ0cGiS9bcTyZFk8xmY2E0brg2kdG8C1Xz/WKMMry+LTyIGHzhm2E+ ErmHMvAXCStwP4Yt0E9MwdaLXMegDxhlHDnTRnaQ1yxcl8sVibvKZcPc2c5VWihdnDov vUtZsKj7Ibz7POi4v3RjGz5ap/C6xhkpF/+QAtWLxIR5gkLs8QvRVMNA86TxW+ysxIXg 490/Od+ff0e/+HsdHTJDYgLwqlqjYkNsEZ8z65wIEM2ZY48sl0pAu4nZBRLmS9fOu6oX SmWhOHQ2kUD4X5As47IFpQQ8K3AbJNDdiDxj2XLubvesBzc7//OEeTrpWNB5uFXYLjex hzuw== 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=DKiPUgce4JTheoGvWXbyBEIdokTDXbYrmiEYcaxz36E=; b=OVxx7Y9cuLDL2lNFYIRQjZtzWCGM3RgAktroXzawQseQX5q741xeZH/u7BUIxSHZcI s3aFqmQdIRQE6Pf+0WLhzXlZCGBa1mWYVMNxMAVYVx9IvYf6NwcpJccMbeVCmeTjE9mi 8QuB0bkjWY0Fl7PtTgQS51axxM9lk6JwV3ij1Ctp+kllNnrkFZwB9kqWBOxTg2nlNF7p fMJ8d7f/UJijo8JpZRAjPXxRAbr+A1AsrTsDOlYlKc4uDHX0BycDy24e5juQybmXTNPN rCK+K0A8XzLCePAQbilSolKvilYksv1LNrz/x0JWxjdcPB2HvTS6gJ2/wfT3LV4kHtiY 6itw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DbAPnFK7; 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 q126sor274078qkf.120.2019.02.13.13.32.32 for (Google Transport Security); Wed, 13 Feb 2019 13:32:33 -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=DbAPnFK7; 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=DKiPUgce4JTheoGvWXbyBEIdokTDXbYrmiEYcaxz36E=; b=DbAPnFK7wOOhgCkSXvr0rLYtTRXuMZoONdFu6iHTzWBB/el8BuICjM2pTFOqGm9uUD MzehSpAKMBox9yPh88f2hG4Knzskm9d/Uq8PuLOjVRmRyw5HfRE6h65JxG1hWs/jgzb7 ep/kP7umpWmHAL7RDckVkr84vFvbcl+65Eci/o6yk9AgDW1Ho6YpNC0KPJG4GyO4KOof qU7020prSwEjhrPdjOhv0nTnfZ7UB3eFEgtPH/+g/B13w+swHlEWHm6+9ejg/Yh4evoc YKL4JtBxJiSaOeonz7KnTt4HCuTAV2YpOxp3PrVTmVy1PE7u0Hl25MccfI52IVcaCcLa sAew== 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=DKiPUgce4JTheoGvWXbyBEIdokTDXbYrmiEYcaxz36E=; b=bbG2uxaIzvCGXfIRXfmWWzcH94C+YA6jiFnSLLjs6UvqvtMfTimeWYY3rUGon4Q2WG m+wXCC2bXEk9aCPzIDE1Gike2fDkIgnUhYrxM9ALDrpNJAERZKLwIoILODh5JxqIP2uj +1RvGi/ziaAXnuHGqEE0LH6i9kdbLBd+kyw45QCFvA+CBhRBN8yAN3+eq+Rpa1liZOqA veYfT9ccDlvbxsjfsmof9OznkScD6aFwYS0OxoEyFCNOsVAmuVX2KdnfMmnUYTA8u6o6 hXpNMk+lPRFVZ5kceM/sqmKx4qAFGPlee0UcQ6y20+GCsyHWkedH9BS64dmB3RrQHOQq XCQg== X-Gm-Message-State: AHQUAuZUV2zn4me6iu2p7Zr6eVOAcRsnqHB0PtxgUYv356fQ3ft+e2WC 1M0i0/6f4XutH+G/ulGYYW+REalh X-Google-Smtp-Source: AHgI3Ibx+sKx3L99liSsDx+HFc+v/ruM6shgCriTB9LCyaZtBZ2LkNnyIIhH56SKc+xo29hyIj24zg== X-Received: by 2002:a37:a14d:: with SMTP id k74mr216780qke.242.1550093552772; Wed, 13 Feb 2019 13:32:32 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id 8sm382675qtr.7.2019.02.13.13.32.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32:32 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Greg KH , Mark Rutland Cc: Will Deacon , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4.19 05/17] ARM: 8793/1: signal: replace __put_user_error with __put_user Date: Wed, 13 Feb 2019 16:32:11 -0500 Message-Id: <20190213213223.916-6-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: 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 1e2ecfe080bb..b908382b69ff 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -336,7 +336,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; } @@ -499,7 +499,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) @@ -519,8 +519,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 Wed Feb 13 21:32:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158258 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp560854jaa; Wed, 13 Feb 2019 13:32:34 -0800 (PST) X-Received: by 2002:a37:884:: with SMTP id 126mr249454qki.56.1550093554397; Wed, 13 Feb 2019 13:32:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093554; cv=none; d=google.com; s=arc-20160816; b=E/ZNILBXitt2nqbDDxjbskq9K0lWyAnWYch7ZwkIkduKpOd8JSvBanzvxa1AtDM4ca EPKcBhuqk309woK+BiqTgcQE+g8rutNwGwT6rSIpeE9WQkMK3V2l5u9sHqfJKHzBKOR3 g+7VKbFkVKZ0+Y4E8EidpjBmIjlWyBgwiRSi+6eqnXrgGUrtH7YwuSqGxuGbCh1o9n2h +kN4SGvHljmbyFIwavpjSFDtTxaJ+wM5Jjtv7pKoiszCBguXv2c6a+UsJIgQSjJyOgky z6HQf8UmFn4DOhssZV0oF5MatScrBz84sqMZRhvjm8zLggWiSKGLj9fNaEhE5ubAeprj Vclw== 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=dQLK2/rrLChjZCacrkpff81URBJeOtphw+yxRdVdzZ4=; b=PufJbICjJARFLnNRWxRZbgby64AbHXGoCtidA+AA2XUJUZ+YQFjEumfLBh66B7qtFg I5OzQMJBteqKMdbcpy3LNx45MqshxgLJ26QGCp6nWShJYCPcUan/Iho3TgOYJV1P8J0A aIVNeOCsD8omD4uIUnkuzonqJUQrH02hFXXqePQG9vSkJ3j66zughCFfKSDmBq8nPlrG KienfWMSiFgLHK9BKxK5W7Qj35N04usW+s7YFDXaa0JgLw3PaxMedcehchvMW4p89JZ8 S1NnXJMjT/2J3y/uANECSYFX91nT++DM+aS7l92/XSsS4CFTJ7cyw6rOyHd6U1HqCJLG Rr/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gQABb81M; 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 c17sor597755qtm.2.2019.02.13.13.32.34 for (Google Transport Security); Wed, 13 Feb 2019 13:32: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=gQABb81M; 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=dQLK2/rrLChjZCacrkpff81URBJeOtphw+yxRdVdzZ4=; b=gQABb81MbKQBlmSXhqJWQfg/1AxyC7N9oosWf++hMdAGIruAgpqJYldwUqM1bmB6Jr dulsq1OpTXHG1i2jGcQeuZyZIpjlKNdKfSMyrS0u+NAnjSlxqj7zZ3qkDJYNjUsmUrJF zigsHfdtmvf3MT0gwEA2vuSBKY4RwNgfY025WHBxSsYe2wuncmOQ88OE0GyPQcL58ysd 4e65OoRDhrMM69gcPZUaLEQEaHinHgZEFhvilAAmkSckKd5/7GedCqUALyP0aiq2Fvxn HNIc7JEQhrKke9sonMbxjJlaZ3nPYoqJqcssm1/sMCPDAFExEk7IVkLGZUSwo359avMR lWKQ== 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=dQLK2/rrLChjZCacrkpff81URBJeOtphw+yxRdVdzZ4=; b=Rm8khYrlyU9bhDCY4SaEycWxZUYEy2CBY+aHNG47H0dp/qWHM9nySJ4wTE16cdBOc6 gKY+rgFFTwEl6GNL9YQ0RlKJGWEEkn+fDqT2yychdDqXqE6OAvScn6Q5rsop+d8P8qgl sJ1IFbPM6qwI29kVBQtgcQPWrDLn9AXj4zT1gcyjJlK/hWghVTLu4iKuwtH5SKT4Gkgr 8u7T4aGSaDCAgfgsbigGshSSfq0Rc/dUjEdUSYqY3/ThqkAg4DyIXjpDdW8icdeyhbHQ pHn1DZoqV0PslGaPiR3ODKNMjwjbMbKsLTDWThVs6xmc8XPetjgwrXxRx6XRlMcsJXv6 w4ng== X-Gm-Message-State: AHQUAubFhPt5EARXUSwf0F8zJQyd5UGAeJBkfDiWEZhIZ2hsYX/fpTbN ROZ9rBTS/4jFwK5OBda6meW1auzx X-Google-Smtp-Source: AHgI3Ia4pComQ8ctgxQDJ1CcQxaos+nBxL2y9DAGiemotoOFbJLoJ3KztZyURL89wAh+dQrfdS0EKQ== X-Received: by 2002:ac8:341a:: with SMTP id u26mr205865qtb.211.1550093554162; Wed, 13 Feb 2019 13:32: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 8sm382675qtr.7.2019.02.13.13.32.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32: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.19 06/17] ARM: 8794/1: uaccess: Prevent speculative use of the current addr_limit Date: Wed, 13 Feb 2019 16:32:12 -0500 Message-Id: <20190213213223.916-7-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: 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 5451e1f05a19..d65ef85fc617 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -69,6 +69,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 Wed Feb 13 21:32:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158259 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp560889jaa; Wed, 13 Feb 2019 13:32:35 -0800 (PST) X-Received: by 2002:ac8:2190:: with SMTP id 16mr203001qty.365.1550093555737; Wed, 13 Feb 2019 13:32:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093555; cv=none; d=google.com; s=arc-20160816; b=GrWdg0zHZNZRiy9C0IHptre9BgDX1ORD/Wa4d2rDjcVqbSVMmJj0fmiM4NZJOJa7+c ZaXLKIUeZ72R6NBe4YmaLhyq/qgKWo8TnYmskb9RRtSfGLaTbnhyZqU8OW7glfgTYU1r Nj4Yuy5nxxHLFvy2u6uC8U9E93GsrLHguLlSqJobaYWzsmtcmtBl6Jz5qDnmEzSHWxVH 4EjKyTYEl8EYaItOwoLrItsWAxdQt3MUex1FF6y+FkhEgOzGSQX4RIKc9nAzqmwfTx8t JCQPP1c645ZMCscIS6xySqesywkbWpIqaNW4MTO1FJFGolbr0kB9fnhx3xTDxy8Dfn1b 2ojQ== 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=Y9bjfpnIjOT82L5WN75hPg2gnG6Z+LcsZzLHUB1TZws=; b=OtjP+QT3TM1XsYJ9Ar9LpyG7FJiSZRlLfq0MA1b24cmtNr2P4Frw5cwnRpyGOI71hG uK8T5omVmCIP//LB8oqJO064fhHIeP9CqibHEzi5HjcJi0fJ9j/tzIGej/x4NrmTCNd0 iP72/G0JVmx5QvVUCc4R2Jw5IqKgCVHoyb3y1Gmj271MwEC596R4bLDyS04NKplBfPjK FAvf/MrzKWCYFyWiOjj63apBGwLFhxNUwnUf6mcSsf02yp7LxT6zSKGHBFtHCIx6g+u7 er28BEcG53W7ryckrzvaCRT4KyoMQikn57cl+DCDd9eC0uoO3LVRNwiWD55o6rMflb+8 V4yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MzOyVW4D; 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 y2sor584094qtb.0.2019.02.13.13.32.35 for (Google Transport Security); Wed, 13 Feb 2019 13:32:35 -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=MzOyVW4D; 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=Y9bjfpnIjOT82L5WN75hPg2gnG6Z+LcsZzLHUB1TZws=; b=MzOyVW4Ds6vkL8Y/zO0X8jD1DAb5GY6O3kQ39qkczIEmemCNKPrJYCWKTEGPZcvhLj oqbNB/eHgyKCShxs0F39T7zRkhQUgZxwb0LwiEMFgU2wfrAD2/wNGhxx2cF6mx66JJVi BGZyh6/XkwdlnKx2Shg/ISzfQDAZB840GPOPkg6ou95OAAVx++PnwWh49qx30F/3sAdQ 9XqmvLIfMyZdmGcvVyM69WC+yo8aW+kskfuIZN7fNu+YzJ8ZmBI/7AsgP6b86ThTx7eu BpQZhNw5bNPUY8CKrwUySJ0duKB4X5YhLLvU9q/+eKJ7r2GqY2ZFIh1YfvKQoVPJ/OAK hkBA== 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=Y9bjfpnIjOT82L5WN75hPg2gnG6Z+LcsZzLHUB1TZws=; b=P9TX1eZQ4V6ZguWsSTF57QAYRNOr9wqvZgtyq0sjEvqYq50LktcuulpNgUK+/rp5Xv etez+pyO+HUOskf8TJKGp7+RAxuzH2r/sz3WMvvkVeHbPgGrbTVBBW08r3eNuIj/giFS 5vfAMIVwMFtVkqZU5uL5uMW4fFgWyMb90YS7SjiJ4gjRmHVVk3rcmddwcShYuj+wgLAA hCsYLXdyZk7DHUR9/Nx8ZTgzvAKthKkUlqEmmfrPibqq8PdHkK8Qrsk9WAFG2TR+8Zzm 1nTNGp8iKJrMiVORSbrai9yay0R3ppFwxLmnendHhYztv4K6JdXexh9ffyEdvUqUFcEg Oj7g== X-Gm-Message-State: AHQUAubppGafLcbSpKEebi8BymS1DtGFs4fLO4pftTc9qP9fr5bhIXqI 7b9Hj37z+zpLqJoZepwOR4NvAx0t X-Google-Smtp-Source: AHgI3IZpLedZO/Zy4OyyvE6dqteNaaVtgsW0nEdTvXN5uBvmTqhDJUVV0Djjr6W1HTQST2PeTfrwBg== X-Received: by 2002:ac8:33d7:: with SMTP id d23mr206276qtb.243.1550093555522; Wed, 13 Feb 2019 13:32: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 8sm382675qtr.7.2019.02.13.13.32.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32:34 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Greg KH , Mark Rutland Cc: Will Deacon , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4.19 07/17] ARM: 8795/1: spectre-v1.1: use put_user() for __put_user() Date: Wed, 13 Feb 2019 16:32:13 -0500 Message-Id: <20190213213223.916-8-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: 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 d65ef85fc617..1191e7da8fab 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -370,6 +370,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; \ @@ -377,12 +385,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; \ @@ -462,6 +464,7 @@ do { \ : "r" (x), "i" (-EFAULT) \ : "cc") +#endif /* !CONFIG_CPU_SPECTRE */ #ifdef CONFIG_MMU extern unsigned long __must_check From patchwork Wed Feb 13 21:32:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158260 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp560919jaa; Wed, 13 Feb 2019 13:32:37 -0800 (PST) X-Received: by 2002:a37:c30d:: with SMTP id a13mr247938qkj.18.1550093557134; Wed, 13 Feb 2019 13:32:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093557; cv=none; d=google.com; s=arc-20160816; b=gBajyWq1527EK5ZyNR28Z9ZsKu83gXAr5RPoHMVoBi8BpjXMlGuI1vecyY+hkIxdM3 j3SqPfVGzcM5v4QFNg7twDJwcs0pHDkXYl0Lg3te6s8pdmviuxbiYWe5GvrvMMytscla oGfNYWQSXIFcPjYUGqnGG7lqILhBFSnPwavPxMUdI0hj3eHQvOly9ik8y7+V0AW/G0J5 GrpfKw+4xMJ1iHWICdKhG8+NjCfBmhvyzip9P+1MUh5BDvmXNn+AvIyFJZBzcmXkjh1C LKNpXd2DRydkEL6ReAqxqjfxjBxJCzFFPTpPNYMHyEDPp8tC2f8hyk6tF6Yl48gxoVli +vvQ== 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=rK+V5Bt5jiMQbW7MEfKBAMfmgwoZSjPrByJHM+oVMeo=; b=A/QQF9sZOtEtRpI1kJI4I0G7DKgeZg8Tcv8CcJIGobV+HbkJbNd2DbFcQJnzdCnQx1 o64YDbzFUfHQV95qxDVX7GIYOQp4A6S+9JJhbdo6AJZJIXPi5HUtZr3JsGUnZtHOKNNo chzbiPCBZMWJBZA2HnmiOQOdlQYgDiPv1lLN8jeQNIfZ0co8qH6VhOQ1mvfqCHYtxG7O QcB6gnZoHjglRFfYJ4R/zD3lobbUb7/k6T/1swxR+8XYFPsGHT0n5a9fH9CWNHleyCb5 rC7bHf/iMsbmJFD22ERRs96RSUSRn+lPKCyns3PGJhnciirjuc0IUByKtooDjy4v6uCV OMKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="GTJ/bm4f"; 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 m89sor589927qte.5.2019.02.13.13.32.37 for (Google Transport Security); Wed, 13 Feb 2019 13:32:37 -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="GTJ/bm4f"; 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=rK+V5Bt5jiMQbW7MEfKBAMfmgwoZSjPrByJHM+oVMeo=; b=GTJ/bm4fEru5IpP4vE+G1cANhMJFH2iFjAYzU/wHNNGNCwI+nz6rQOavzMJnf+tdmz Ap1od0Qvoqs1tG719Cp3mvlcOMz8/tjSGFQmxmFns3VpNswa7Y/etgTGt7uJVxT/rvEy 5n2hMb6jBYK4122o8N1rIHPGv6Y4ID/+IxcCm/swWZxPYAb/zbxXrG4/vCSIjDTPUutc AQEbWgTmEuyoKkWaXWLpZuQVHxGthkZbN0XxqwgmGW7lyZGU9KHse1r5L31bOfkBcWuF 5gFGrsP8/N76vlwfkFAaJtunv5NFkicZIyxvzZ+Xhssaefi+LF4jDyAmzmUE9BI3Bk69 D4Og== 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=rK+V5Bt5jiMQbW7MEfKBAMfmgwoZSjPrByJHM+oVMeo=; b=guTHCzQMIi62MOeTl08HvLNof82+9MVq18T47prLpb2MHT/4hMEkgvn1lv5mD1sdfN m0dSgG1MJmJ/2xnTzpdracfHRG/KdOrseZBi4XmKsHx+6BwcooCzoWGuU0fJ6jBRJWWv aFlFY8kD9iK21ETkUq3hIwDaU/LGGHKuD7vRTgUpeQFKnOd18aGXR5ZAcRSLI4qy93RP aa+uZx7NLfuI+896kybnrh+JQtu0uM3M+wXN/42PjiajL7dAtJnhvFQ9J1n4PH3JAoHB pKjdhH1ifzzM7CyDrHhkeWlRowG64BxnxpUw3WCIxDN2RWNv8R7gYip5JphGrxYVjGc5 lfpA== X-Gm-Message-State: AHQUAuaLCxCG0dW8v+PFMuw6MPlgUZMtBzw1nC/iNV6dJZ5FJjL+2YOm HuthxQZ8w7rukorMtI1NAZn9A/kZ X-Google-Smtp-Source: AHgI3IZkKR2llmVo8RdV9zV7WDCBMsjzMV5rSO5HFmnFH7Xd80JGy4FrAg8iUKvUppos0QoYTbSBGw== X-Received: by 2002:ac8:1e04:: with SMTP id n4mr224614qtl.378.1550093556875; Wed, 13 Feb 2019 13:32:36 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id 8sm382675qtr.7.2019.02.13.13.32.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32: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.19 08/17] ARM: 8796/1: spectre-v1, v1.1: provide helpers for address sanitization Date: Wed, 13 Feb 2019 16:32:14 -0500 Message-Id: <20190213213223.916-9-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: 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 b17ee03d280b..88286dd483ff 100644 --- a/arch/arm/include/asm/assembler.h +++ b/arch/arm/include/asm/assembler.h @@ -467,6 +467,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 1191e7da8fab..c136eef8f690 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -99,6 +99,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 Wed Feb 13 21:32: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: 158261 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp560946jaa; Wed, 13 Feb 2019 13:32:38 -0800 (PST) X-Received: by 2002:ac8:3774:: with SMTP id p49mr231330qtb.388.1550093558542; Wed, 13 Feb 2019 13:32:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093558; cv=none; d=google.com; s=arc-20160816; b=eXyQ5RmA/u/QMcdxEwgJMx//Lepc3tYeg5QzAd9n9Z3qJr8KzMTRQqGA0iSN2sbGjn nt6dfqHL8GklpaT3MFOqKLzUbpseoDxDA3vnJvVTWt71gFoaxZylbZ17EX2F+Oj+p4j7 zzemr0iv/8qxatGBb+HI2yuv/wmTyTQtbZqTbi/9ACEfLNwCrr87gyYcIrjRnsvHhOFh kzcXh6iZp0SrrAlzusXeAhk7TfZKxo9JzZ8uMOBXP1eqfVOAOffoR9qwh0Q51/bnAwUN y0ryOf7BQ3gDl0/1QdfkUqA7pynQsGGlSeFDB7sAghoNaOI/NTIKPNgGQkJJ/Bir9MZb 6UZg== 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=cmHxjX3QWGEzbd3gID8OLJBVtbh3tUIgNET1gXVqzGU=; b=cth19GVBpysbRLNUUIom9yXekruzMIZuTB7NW75yAUvgqF7GsttPF8AB6YEGL1vtRt tUBS+PRromt+PtBt8sIuC2F1TgkCZ9Q8Hi8+rbe/mLkl2fQpQQAfFbFdkpP9AP5v3bxc RKaeCzb5ow5qZhwASPhQUROmPXfcc9LC0hL1rkswIGZ4hp1hMjWJaAJQVTeTZk2a5KRA 2qfNYWk86cuJ287mdTsV/ZC1qP7fTwtf7hvxGNyp7YvKFfJYYQxarCYhz6T3k+Oct1hU AM8EgIc7wUTwFbWuCcgGb58jLwpjvrfINy6PSbQvtCAXQho2M1jkaBbClqWDwtT1/kid 8k5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IvJ3USwh; 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 r17sor569245qve.9.2019.02.13.13.32.38 for (Google Transport Security); Wed, 13 Feb 2019 13:32: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=IvJ3USwh; 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=cmHxjX3QWGEzbd3gID8OLJBVtbh3tUIgNET1gXVqzGU=; b=IvJ3USwho3JZnRpyvMASZ3XvtoUm7qzuHhmNDwX8q6yHGzn9uAMmmIBUHhGLFwgQUU seEUJTS1jYdirWnlwMaWfZ1STNzjOeoWD2lr5w+Iq9kcmhXGiAv5AI0sS8kMGxK6fBhg NRTtPwWJmnhk5bK8Pi+x3iXRRprvqNhlAgtk+kET2zt0xiNUFcTzmJPYTvA61T9WuwvZ JqGXRJMA+6qUJZCFLsTTyrteplKjo0NxVun0F3UTJDo9mHz0Dg3jqHGr5EnXhxkJFMw9 XSHcgxBW+FlSHpqGy4SNfysvdA/eznrYPWnr0jqnKmArPcU77qNUYn0Dbrp4k670vAAI pRgg== 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=cmHxjX3QWGEzbd3gID8OLJBVtbh3tUIgNET1gXVqzGU=; b=ogNRsSIZi2H7SORRY2UD2SvDhl4Qj7Bm50uJHiLSYYTBqVf4QlrcSMldQxY+AAihOs RGAYp1fgyCSLX1xss0vkk1lZ9KKu5DinxZJjktKh1WsbfiOkLxyDaylGcIEiOyLE+Z7F AVgHDY3RNA6cGHPo+Qf8Z/Dt1ypfK7wDBd77srah1Op3f4PHinaYZa/SDGZgDMNkrHra DIZAxBZ8Y+CVxL99D0EYYB810BTikN4SXNnAWYq2D3MCsWnrYJS8ef+w1BACigftcaez 9n6Kvdx1bwWvBzXgbuVLzBMQ/hDLs5L0y7OWo/0AyilGH79pk2eQhPpLd17qq6TNEqvQ LF0w== X-Gm-Message-State: AHQUAua7WSiJ1uDz75zzFB88+MOo+2sT6pMClSiO6hszEcWG1am4matW /hkmSwEmxB2u2RYy+5VG+24Gqf5q X-Google-Smtp-Source: AHgI3IYW8+K14QArKauUWkZ9ZtqpL7O14AvEk/eB69PdquX061fTxlr8ZKWVxytrXleRGtxapCzz/Q== X-Received: by 2002:a0c:941b:: with SMTP id h27mr260105qvh.8.1550093558210; Wed, 13 Feb 2019 13:32: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 8sm382675qtr.7.2019.02.13.13.32.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32: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.19 09/17] ARM: 8797/1: spectre-v1.1: harden __copy_to_user Date: Wed, 13 Feb 2019 16:32:15 -0500 Message-Id: <20190213213223.916-10-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: 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 9b4ed1728616..73dc7360cbdd 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 Wed Feb 13 21:32: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: 158262 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp560954jaa; Wed, 13 Feb 2019 13:32:39 -0800 (PST) X-Received: by 2002:a0c:91bb:: with SMTP id n56mr222789qvn.77.1550093559770; Wed, 13 Feb 2019 13:32:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093559; cv=none; d=google.com; s=arc-20160816; b=mu9XswFBvdlNMwVm8cx6TPvkn4LJcWhTV6SbOT2noNEjJN0KEmS5oQVWo2fHJEI6D7 EtZorTeReNVWnAFHV7zoR/PqJyz2iDClJR24R3Y8xZehFRBVtDQ+L0tvolEffQa8Efw6 hVKXJZVS2WqPxtKQZ63bGH66GtW+vmZ7ppsmrIPM587m3u0s7PJiq4fHFA8zUfNnFj26 NsqJzFeBe9GS6mOefIZpBzZRNjdMVfPVLBK9jbgIayhhrNz1DQQFeShg8+M5SvKmaT4f NKIE3G0xpqx5Y/6sik9fOiN3hsC8gptI1josr3Eg1fEqywh1fDJKnRW00YoXZHXtGJXw hbXA== 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=V4sXTOX89oZ7Fok9OP8IOaBv7K1P43zOxOdwYTTyDzQ=; b=uDi7ktwaLgvt4zXvAj1f7HroloWbBI2sLdrwWx5a4cs3LUgBTpJHt5ET0BrANSiOP/ lDXwmuOhDDpX3Wk/PTtw+LsWBuFXNHKM4sSR4GHOu6RfQf7+tseKSoBLsroOv4f45SPY KiTQnXMaweRa3wFNjX0nDw2PN7yfqmmjih3Pdqsn/W+sbtsNhIv+lmiSH7od6OEvMPMV rZ0eTKkIkoYGSBjFh57rdaYN1UcjSchUuA/xlaebmZAvLMJRdmvK0La2CEdxDmSDAQlh RmyrxM4tRQblYuv8geyhOuz7hGgul3QhSa/+2bS47BCY6/Tdc6kXnRVwyf4rsdAI1RPM B7cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W9Zi0TCq; 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 26sor507338qve.51.2019.02.13.13.32.39 for (Google Transport Security); Wed, 13 Feb 2019 13:32: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=W9Zi0TCq; 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=V4sXTOX89oZ7Fok9OP8IOaBv7K1P43zOxOdwYTTyDzQ=; b=W9Zi0TCqR6GLe4u8bTBpGiG8zPTKlOJFU2ckqpfe2s80+2qTWssivV7jHs/ek8sdWO rgOvAd6BnlEO0c2l2e/WuwYC2mgjeu2vOOjfvrX3XKnr/PQqQpLYIy5bTrkYZQZJjuy5 F8vWjPLmbQcJ4fJMDW054jEFOmnnUCvtkHxGNpBg7Xv5d/3bphiKUfGAuKXDxyH7lzg7 yPHwOdtYmr1CR5lC/R1Jn0Er5t123dslHD1Ve8cuu3zzNxV9+YmHWjjLXmWaLzqWhMne /eixw3XbFLElxMoj1TsKUCIshZ8Pvsa8/FhQngugpw+WiP04ZJY+4HGq7ZsmStNgSP1D jL8g== 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=V4sXTOX89oZ7Fok9OP8IOaBv7K1P43zOxOdwYTTyDzQ=; b=pouS6zs/JpXyPdmLcgoMuctpscqzCrFb/OFaGQXEBYJQ1kgXzJqpvwNbnfKWb1OYnm OGkVBv67yRzliB+HCOtOc4jGwwwAh3RHtL8XssLH15quTm7rz5Wb4z9Vy42luwxnAe5t ikAGihdXP0/4557ahvVTL0T3AXz/h+etGcM/5CC+nqMnoDsUHehPo/wg8lxJraBFSxyR fGwv8RqXb7ACAGl2f+7wJGtEqkTfvcQ7UNzVrDXHT7T7K6xdmXcO8mwvtYlInAsa/5ud AIryq/LtP8nSIphU8x60jy072MeLhTVjfbKKgXUWs974plrBEVDiG0GJlkr1WjJPejbt AIgQ== X-Gm-Message-State: AHQUAuYKKV0Q6+LnMKSshrAWNoS4KummbXmwx7bZNTXOxdIXmjuE/4/3 tJU9if2BfVFIwTlvzVCl+fSyxbLJQU0zNw== X-Google-Smtp-Source: AHgI3IYAYr9H/+6fuvWVvrJy3jCzz+p2QCsgMb5HgCJHrylCwxqNm8L5th6PKwuKYz/9Joo/5gsZJQ== X-Received: by 2002:a0c:e486:: with SMTP id n6mr237775qvl.210.1550093559547; Wed, 13 Feb 2019 13:32: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 8sm382675qtr.7.2019.02.13.13.32.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32:38 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Greg KH , Mark Rutland Cc: Will Deacon , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4.19 10/17] ARM: 8810/1: vfp: Fix wrong assignement to ufp_exc Date: Wed, 13 Feb 2019 16:32:16 -0500 Message-Id: <20190213213223.916-11-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: 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 2b287d0d6bc2..66c5e693428a 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -578,7 +578,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 Wed Feb 13 21:32: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: 158263 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp560970jaa; Wed, 13 Feb 2019 13:32:41 -0800 (PST) X-Received: by 2002:a37:5d42:: with SMTP id r63mr235907qkb.114.1550093561169; Wed, 13 Feb 2019 13:32:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093561; cv=none; d=google.com; s=arc-20160816; b=XwIFjQvsCJcmBo28VQPKb5V/x1Nff61gAaAxApU777PfL02WsuEnsLcVsNxhB5d77I aifWQ4kQB9BeMiHcODIeuY/KowztJifHgFZlWKHJlP8ahkwL2vyweMkKZWAXEOg4NLM5 QWWgxnn/0hXUUuMi91rAZHg5sCxT7xPWAzQJy5LVda1LlwsKwRze0yc0D/3hYKs3pV0v v6t2Zt8IlFzTT2FfSbWoS0NXcgOrs0IPiiYWFx2FlpQPlOWQNNdXVzx5YiDszNZsGiKC oEXIVk3UWxC+KufzH7drX8y7iSs2tK1OtPPzCwm1pryoKl5t+wXe4HMZeZ3T3jKhlG4j cAzA== 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=V7lJaSOHNBHQZSETMFK/nyiszapRsFtwkzZBpnv7tGA=; b=WXxYWIGaZeV2Uzxgn9nGe/19wA4MWAyub1TWfM2BOOqweEVBcjB38hec4fj0Q7vIqu 7/R0b2ZTeY9NMza2LjahQG3K1zBTafwz/hxoRQqc8XXhBGyZYOejJEx2UBLvwqUUrrcj iTKZWZRrYtGIp6h9FID0G7dwa3XfoSXnZS+b4ITSNn96nPT1zrQCHw1dv1yvqa8SdQde xD5xP6VLar+yIeTDmgqHEOoY32qghihfgpsOpv3fSATgYTwnvckAPrUcMAtjeBcexs+J zJoOH/cibM2wX+N+qEAe9diAg/OMjCyfovBSh97rdJOsvAb2bGV8FLZ59a/WsynPv3+H 7n3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s1XmvoAF; 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 t9sor538998qvd.7.2019.02.13.13.32.41 for (Google Transport Security); Wed, 13 Feb 2019 13:32: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=s1XmvoAF; 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=V7lJaSOHNBHQZSETMFK/nyiszapRsFtwkzZBpnv7tGA=; b=s1XmvoAFbRCLC+JYLNPmrgNi+JssmEFKTHIZcbM99ZzHvaXiWEfPcFsaMjA+RPq43B yczPxj7RcP711w57TAUQz4xYaaSoh0jVfFOx6j2h1wb4wNsihK7IHdINuM4acN3EumDB xIj6RHmwbyX+CFsVaTCtf0PC03jDYm/FDu7TgzxZgcUaUr3QU9/UcllBOO+cDWOB7VOP 62n+djXEWgqrMCOz8Grqx0dZmARAqSalkajlxcHnsSHtoZugHfU/WH9gSkJ0qxHixc9l 0T6lAt8LTTdgMcPw+qKCJ6Za9zyampaPTnUb/ld8J4oChpEd9cDInVVeD5I4/8FNAnDm VTJg== 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=V7lJaSOHNBHQZSETMFK/nyiszapRsFtwkzZBpnv7tGA=; b=JaTXAIGkJtb7VFNZT4bhRKwBHYdU8pHr/Zy+cWItkvi2OAl1NYRhQoIwDtCXRzeca6 cXhKIdB6+5PmWQYFRIvj9ddAWnHP1ja49IYHWcVuluvmKqeIh3t9RGptbLtTuIQMc5Dv b60V8A2b4TbL5KDT8jTlmYzuq426mV5m4QAypRlseFDcTVwbzDf+dC904O/Ejml7KYJD ADW+COKAfItCu0e99gVAaw74nJATE7lKJEWVH3RhkNq0jMpzm6kvdtTe1/qNOWBNLxs6 QsqX4P1BGk9nuO6Hfi5JO5e+0eare81jq7vcwzEgUyy4DBOqdBMXbB3ETXY4IoVCYrra jmRA== X-Gm-Message-State: AHQUAuaKXXN1kdl4aMwUFFLis256yQquKsk2vYbgF6Ya4E6uaOpOamrc 8Rf5jiSseK1OV0iLqzJmab7YbNV1 X-Google-Smtp-Source: AHgI3IbTTm0DogF/FptlR1dRTwoq3QbYdqPasZVufAbowtGviiZuiARLC3IPIYbYMT42lDIZy/nX6g== X-Received: by 2002:a0c:d90b:: with SMTP id p11mr245177qvj.140.1550093560912; Wed, 13 Feb 2019 13:32:40 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id 8sm382675qtr.7.2019.02.13.13.32.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32: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.19 11/17] ARM: make lookup_processor_type() non-__init Date: Wed, 13 Feb 2019 16:32:17 -0500 Message-Id: <20190213213223.916-12-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: Russell King Commit 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 6e0375e7db05..997b02302c31 100644 --- a/arch/arm/kernel/head-common.S +++ b/arch/arm/kernel/head-common.S @@ -145,6 +145,9 @@ __mmap_switched_data: #endif .size __mmap_switched_data, . - __mmap_switched_data + __FINIT + .text + /* * This provides a C-API version of __lookup_processor_type */ @@ -156,9 +159,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 Wed Feb 13 21:32: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: 158264 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp560990jaa; Wed, 13 Feb 2019 13:32:42 -0800 (PST) X-Received: by 2002:a0c:8b64:: with SMTP id d36mr189849qvc.233.1550093562548; Wed, 13 Feb 2019 13:32:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093562; cv=none; d=google.com; s=arc-20160816; b=W/cnVaRS9gvjiPCoXHDPcJcKWGMXXfuXZpEki3RGkT9KI9/2YgbNmts8DmnS7jEcyk DSHU5T8b8mibwvEsK+KZGO4hQ+pvEzRj4zYW/bkwJkkHa08dyLPjEdAmfb5u2/nBEkIM kcCdGRfu72E8b5T+w3t0eZtfvFbd29+rmyfg6ashjKKmGDCgFuSuIdetNBlH6cVTYyXI i+TWa5CrVcUyX++WT9VOzN6R2kA9231uo+xRKzy3VJ71d77x6HaBj7JA7IVUJWx8c4ZK luqs/N/RKgZUPSrBM+bhGiCNmqe/TLya/3s2uxqKvxXJ/jEgHrDXqEJX9IC8Miztl3Zg nAoA== 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=yEcpOWz45DlZuRpoVIt2gmwCWgLldnvEJdiWLJe6SsM=; b=Q/7ePIYtkbOzDtUcMBR0BlI6KuB+gatULbba8Fy8le5hDzbOa1j4BzhJ9GH+OA/UBd NNQoBnWygB2tzSk+tjAlkHNmvpAV6WeG2fnHUYwlzXGakJ0F7eX3PaFwhaEYq1+IXzw7 gl+a3R8ugLwF36wNUxJwYGTy2AwGWFVUpx3dKOmO0HHn6AqTGVE6GZ6/dk3pfujUFHlW 6m42FTV3U0qDzG8j6YJEDF0GBEtJiAm3hQxYf5WnVJUvMboEX61hdF87CHWbHJy2jLL8 xPIo2QylYwQT6All0Tcb7sjqoa89len+9HAfcnJHLXXQYBMLKMJVVSXWFWB147k90ocr WzUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xY92Dfor; 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 z3sor525235qvm.31.2019.02.13.13.32.42 for (Google Transport Security); Wed, 13 Feb 2019 13:32:42 -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=xY92Dfor; 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=yEcpOWz45DlZuRpoVIt2gmwCWgLldnvEJdiWLJe6SsM=; b=xY92DforhFbv2cZWVFuA+wAEWISzJgcbN6lHdt7O1OIqMul7FpvwUY4dO3MIKKf/BW ZwKyf5Bd+OiyU2l9g5HX8FtPcTV8U9gx5CUlAVD4tdNesRc7WswCrkahrnXbPkYEmBJC wkcU2K8p5lNL/CjZQS7If8YheKGndJ8eMWrSJ2Vdx5Dlgw7LRcUWjR2AuU0YB5zp+dhZ vVj6l2hxFqC6pfU+8/Odg+708ZzJK1s+AYVFIqaJOItwRe99hBN9rTyoqxljJjvOZshk isJv095UXK19rzhdejQCouHBYXeTpeKpeZkUngSMmvlSEyVLShes3zM61p3n6vOQP3Rq PKTw== 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=yEcpOWz45DlZuRpoVIt2gmwCWgLldnvEJdiWLJe6SsM=; b=kVoOKGfea2t0ZTZmoQbW/jjpbU5WkytdBt2nRwLbRWHzu+eFAEostGbcxB4DpqogSd 1D6w54j3dlLfF+yKPZandxlsVoTpGn2KMIrqnnxmtRR2dNJzEeyhHnFgcrD9kWfJrEj2 qHPyyEIAqUMg7IBWylqtW0z96Q4BweyoKfjf6mX8s087+1tPQvAU5cg6+42kamUv8e+t NaTvMHv1ncq7hopXzrKDX7WoHDKVwcFvfYxFtSN1/ovZkDFE3LZptn/JIWgAFv9MXaOx 2OgWMEetm9objW/7r/1r1MjJRVr3tXTBhoQzvGb2vhd45vx4wz5R97P/BtApD0akgH9Q JB/A== X-Gm-Message-State: AHQUAuY3dZI6Izu8LtDenNVVb+UtpNi5XoiR4q8zwWbRNJ7zDBNx7dd6 j4lBueruODd5Xw6QO6lt4NfDCADs X-Google-Smtp-Source: AHgI3Ib42+Syja8TX47oCJxenG/mcxAIKVkK95CvCXAvrmSpO6ztKtl0b+jWng2Z16b0f6Me+RQrlA== X-Received: by 2002:a0c:b90d:: with SMTP id u13mr247321qvf.66.1550093562264; Wed, 13 Feb 2019 13:32: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 8sm382675qtr.7.2019.02.13.13.32.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32: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.19 12/17] ARM: split out processor lookup Date: Wed, 13 Feb 2019 16:32:18 -0500 Message-Id: <20190213213223.916-13-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: Russell King Commit 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 0d289240b6ca..775cac3c02bb 100644 --- a/arch/arm/include/asm/cputype.h +++ b/arch/arm/include/asm/cputype.h @@ -111,6 +111,7 @@ #include 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 4c249cb261f3..8fd7baa158a4 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 Wed Feb 13 21:32: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: 158265 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp561013jaa; Wed, 13 Feb 2019 13:32:43 -0800 (PST) X-Received: by 2002:ac8:6b8a:: with SMTP id z10mr237095qts.248.1550093563880; Wed, 13 Feb 2019 13:32:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093563; cv=none; d=google.com; s=arc-20160816; b=caMzMC+a9jmdXggjZn4hLbFnZQaMyP/hVBcjXaB5yUe2HgDlqm2wSFRHDDyVgApTBa aLLjNunhWohaAzhI4U9eAQ6KK0GvFC+zj3GnohLSfkgplBbv2yBtNsGdjsQ8dOtB5HzH jp7XODYZ/UYW9/ZsZreZIJFCoG8HuviZnBuMplm/wPV0d45ErSPyuMg/ct2yCpnX4/As JBoPpktTZzR8pWCOq4swsFjFYrH9oJleuybZsgtjArbz3I/aP8RTrRt8DvjvOo95fkM2 N/0rDPwvnIPqWfEVa+ptAbQ5wzLn04og9PlIomuimBaN6QA2TQ0cOOL0oBmu//YjdH88 M2gw== 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=yWztxODyJk70cOjZaLMqULYccaSLR3ZRrSr0GSnJD8Q=; b=oOxULO30O/T1o3sUZsRxaHuclhCWB1a8G6KMPys3KCq5beR6xOG2zwC5Y8ZVXCHujS cn23HVrSMLALEDw4FXd3Ti/a7+nyGSgMDzBa6QTEJaGI6T3Db4iDl/RlHPxft2/QNxi3 xYxa6guxoBjVcKhtPNkUcygkvGbI2aSYtS/ELpEgJeH5TlENOe4aE6DteoBfWWMn/SJu bK0dtHlkM7Z6r+Is5UqocD03KWqr7EcG5NRquPUrgderHEkuUETeFKtrPy+H4RMXFhJt yoYjDBWlELa2jWRyn7e8XAl7iomlW00zYEn/d/J3y7132k25/ncDEdX1N8gI6mbGPV5X oD5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w4LDUYdI; 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 g184sor258714qkb.75.2019.02.13.13.32.43 for (Google Transport Security); Wed, 13 Feb 2019 13:32:43 -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=w4LDUYdI; 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=yWztxODyJk70cOjZaLMqULYccaSLR3ZRrSr0GSnJD8Q=; b=w4LDUYdIBqi9i2H0zziVwl6xNlsb4JOGyxns0NY9Sc4Sp2k3RVUCaQDCson84MAuNS dRrE+nsabr/JWzpawl59qNV0Rj3XRFptqCq7GHaFyFep2yisjAv/8tQyTPg9CURB+5Vy f+CSRuDeeOTu4XfRZsxf8pgRoyd0Y0TtogDnA1QSohGyrujR0FYqxQ1RsRukw/Se6Rcu c6P2wxurSjaA4iTmYvrHrE7mJxjK/kneUktI/h5rl3XsZK5n+QpdYw/aC5gvjhbJCNd2 n/IPbUKeQ8Zg9s4j9q7qpLRPTkX+c9bVuTCuam0GKeyiGo3vBe4BH753ytTMXL5oj0FH TLCg== 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=yWztxODyJk70cOjZaLMqULYccaSLR3ZRrSr0GSnJD8Q=; b=W/0E0b2tQuUBpDB6JnWeJ/JnXgn5UcZDLJtWx4WNGXWBQf09BDdpf8rqv8NqAz+EiH JXowYhbNJmRycnAIZ7A6jXAF/SWZa8tPaUTS8lkIYtu3qGbSc5ylg+hmZQ9IgK2b2WTl mI7W7yHeV8Mc3I7PsRErVriT90PfQxqgUjL0CgtgKUKVC4JRXaAriAqxXZN5wcP/nTls FLEW4/bS6KRv1YVDmet7kdthp9ow9+br9UDSJdZjPUbEjBc5NJNdKtcTPLKWtHst39tl 7rRJWmpmDXLYOeSaht6dUEFckXJnP8ClRQ1ij3oRhFc/GovBn0sZBJTNImKhGKGtvQY6 yZAw== X-Gm-Message-State: AHQUAubfDGtnBt311upaZa885abRm6bDI7khT1WUC/GJ6TYk2msZw6PH xTXiBWZDI5aSpSCJ9q+cNTb4v+Ao X-Google-Smtp-Source: AHgI3Iajkc5bd5I0MEuJUUPhXGht8qFhAq1IUEOOB3PAMLsj1uf6kgzkrqxuyR9KOY1mOkKL47TcJg== X-Received: by 2002:a37:cf9d:: with SMTP id v29mr189595qkl.259.1550093563621; Wed, 13 Feb 2019 13:32: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 8sm382675qtr.7.2019.02.13.13.32.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32: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.19 13/17] ARM: clean up per-processor check_bugs method call Date: Wed, 13 Feb 2019 16:32:19 -0500 Message-Id: <20190213213223.916-14-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: Russell King Commit 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 e25f4392e1b2..30c499146320 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 Wed Feb 13 21:32:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158266 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp561035jaa; Wed, 13 Feb 2019 13:32:45 -0800 (PST) X-Received: by 2002:a0c:d7c8:: with SMTP id g8mr211122qvj.63.1550093565231; Wed, 13 Feb 2019 13:32:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093565; cv=none; d=google.com; s=arc-20160816; b=WlcvTU7YFubhMNR5Nh8TCVM1gd+5YU2ATQwxldq8LGZvqEH9Ypd+PQ2wpf7kmjVPug l7HZpu89hgAmmsKfs/soxvMl8CyWHB1Antbdh7oFQzYEp3oBcSEYrBxY65El3vsBXDwM 6yuDPcA+Ls2uUveE+W1o5b/QY9XTJAr5/lOGBKDEik4Q6t3IoUtytVUDcb1UNX/cnnC/ APMfbI0OucWFq8VDhjbUNK56J6pCU2zCOL6bgEMXdLGORhxjovgcIKug4Cw4X50iDy6Y O69HzEfPSEU1iuBD6KKRMRSQ75C0SAgDX8ps73fhyRtHmxN/KyLU9mCLaYEa6i2LuxB7 DRmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lLS6GiZ4CUXJ8rZLEaclNEJmcH/KdjbjQyrYJi4C1Xc=; b=bxJS2IQ4zZkzz03NyNbp8kpWIo0WRW7TqklgfPy8zB080Omq+dGp6LIhdMYVpNDwSl 1etRNqEAFRVuxvI7vLn5kSDosRZlrYcSKNfzB1ORyh9gjBg09Zw4uI/oxEGAtJmJZAY4 QsA0KZ6j2LXrCkeWGD+OoyFe6+iWoSIaAIzreFRerNy/Ye8dfksiM3pl69DHNFHNSh7C 6my2lKOFrWqUHWtRc7kHwdUjWTdCG9lOnkBjprLmtebCij/D8wXCWuUnJxXozeRfcoqT ak6T0NhYSpcGYRRu90Y2lCqODIpl6RJ8rdoGRVPxgwCfAt+VJlAYfZhsdW1Jvir7vPEB TX3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PRfj7dqk; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q4sor499623qvq.62.2019.02.13.13.32.45 for (Google Transport Security); Wed, 13 Feb 2019 13:32:45 -0800 (PST) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PRfj7dqk; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lLS6GiZ4CUXJ8rZLEaclNEJmcH/KdjbjQyrYJi4C1Xc=; b=PRfj7dqkDYgvl5XUoxlfk1tlHRkWzgxQhq1sMVagMpNVzKlDR52K21Rjn/fawFuCaJ TuCb/U23JS3bvYI1GwVEoQjMYvlf7f0nHa0ddmLeeC7U9rZ4QGwd/lcXiLqxbxlN7phc T52SsYUsITCJ0JnbWKHIP8fYozOMpwtDihFjB01ItbUYZQEOqEK0Y6CS4isldusG5Q2T rgfxA/YbMeHUEZShZtMXHpdQvu3Uqrm0242LlOigdf0bFpFyQSmxm0Ry42RU2nB0o7XI jcdlcbh++VLX565AnURx4tiMzD0hlWdntZNSh/eXi+KhqR0aEktIGzTLu93g5HdPjhqr PXsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lLS6GiZ4CUXJ8rZLEaclNEJmcH/KdjbjQyrYJi4C1Xc=; b=YIhvNvT2rxQmZQcma6yrAzjoS8ZYYbXU/DCRLmMuZGQ/RYPMVhTCEf5flqlv40+Ki5 hJcdXSPgBUtWS4+wbptfO827tQsLrIzYTsGslBbNjk+1DtKMzryJ2mz9Y+vSlWrNR2hM 5eFq/ALgjfUJXpuhoC5KcrNMEA+hkUmLfixU9OXVwTYn1iq1faEu5+2X30OjuYGmuItX 2TSaX2ChwrgLBQm+5dXBNH85hN6mn0das7e0eDzrG6t4bzd/IM1J+IUylHqQmssLzsq6 Jh4H9SOfHMFFDLq/kGdkPgZf6gClSDS3c8La2H+BJuV3Gv1seYCvsMWLy71PP2UjFqz5 iCYA== X-Gm-Message-State: AHQUAuZYTQv2jEPlOD9JdCBDD81KtqyHgjUhCA5wECbTIo/G8LJixNCv 9mpykedG1ppDnlQJcX0thVdSF0mBg7rlxA== X-Google-Smtp-Source: AHgI3IbPF4fPqbClV2fCpcnwO2Iou7NLJVsbXAsV7htoA+WblfJgTeFYwF4LjOFZtBSHa/m3Z0adGw== X-Received: by 2002:a0c:9587:: with SMTP id s7mr207806qvs.155.1550093564953; Wed, 13 Feb 2019 13:32:44 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id 8sm382675qtr.7.2019.02.13.13.32.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32:44 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Greg KH , Mark Rutland Cc: Will Deacon , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4.19 14/17] ARM: add PROC_VTABLE and PROC_TABLE macros Date: Wed, 13 Feb 2019 16:32:20 -0500 Message-Id: <20190213213223.916-15-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: Russell King Commit e209950fdd065d2cc46e6338e47e52841b830cba upstream. Allow the way we access members of the processor vtable to be changed at compile time. We will need to move to per-CPU vtables to fix the Spectre variant 2 issues on big.Little systems. However, we have a couple of calls that do not need the vtable treatment, and indeed cause a kernel warning due to the (later) use of smp_processor_id(), so also introduce the PROC_TABLE macro for these which always use CPU 0's function pointers. Reviewed-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/include/asm/proc-fns.h | 39 ++++++++++++++++++++++----------- arch/arm/kernel/setup.c | 4 +--- 2 files changed, 27 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h index 30c499146320..c259cc49c641 100644 --- a/arch/arm/include/asm/proc-fns.h +++ b/arch/arm/include/asm/proc-fns.h @@ -23,7 +23,7 @@ struct mm_struct; /* * Don't change this structure - ASM code relies on it. */ -extern struct processor { +struct processor { /* MISC * get data abort address/flags */ @@ -79,9 +79,13 @@ extern struct processor { unsigned int suspend_size; void (*do_suspend)(void *); void (*do_resume)(void *); -} processor; +}; #ifndef MULTI_CPU +static inline void init_proc_vtable(const struct processor *p) +{ +} + extern void cpu_proc_init(void); extern void cpu_proc_fin(void); extern int cpu_do_idle(void); @@ -98,18 +102,27 @@ extern void cpu_reset(unsigned long addr, bool hvc) __attribute__((noreturn)); extern void cpu_do_suspend(void *); extern void cpu_do_resume(void *); #else -#define cpu_proc_init processor._proc_init -#define cpu_check_bugs processor.check_bugs -#define cpu_proc_fin processor._proc_fin -#define cpu_reset processor.reset -#define cpu_do_idle processor._do_idle -#define cpu_dcache_clean_area processor.dcache_clean_area -#define cpu_set_pte_ext processor.set_pte_ext -#define cpu_do_switch_mm processor.switch_mm -/* These three are private to arch/arm/kernel/suspend.c */ -#define cpu_do_suspend processor.do_suspend -#define cpu_do_resume processor.do_resume +extern struct processor processor; +#define PROC_VTABLE(f) processor.f +#define PROC_TABLE(f) processor.f +static inline void init_proc_vtable(const struct processor *p) +{ + processor = *p; +} + +#define cpu_proc_init PROC_VTABLE(_proc_init) +#define cpu_check_bugs PROC_VTABLE(check_bugs) +#define cpu_proc_fin PROC_VTABLE(_proc_fin) +#define cpu_reset PROC_VTABLE(reset) +#define cpu_do_idle PROC_VTABLE(_do_idle) +#define cpu_dcache_clean_area PROC_TABLE(dcache_clean_area) +#define cpu_set_pte_ext PROC_TABLE(set_pte_ext) +#define cpu_do_switch_mm PROC_VTABLE(switch_mm) + +/* These two are private to arch/arm/kernel/suspend.c */ +#define cpu_do_suspend PROC_VTABLE(do_suspend) +#define cpu_do_resume PROC_VTABLE(do_resume) #endif extern void cpu_resume(void); diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 8fd7baa158a4..f269f4440496 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -693,9 +693,7 @@ static void __init setup_processor(void) cpu_name = list->cpu_name; __cpu_architecture = __get_cpu_architecture(); -#ifdef MULTI_CPU - processor = *list->proc; -#endif + init_proc_vtable(list->proc); #ifdef MULTI_TLB cpu_tlb = *list->tlb; #endif From patchwork Wed Feb 13 21:32: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: 158269 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp561069jaa; Wed, 13 Feb 2019 13:32:46 -0800 (PST) X-Received: by 2002:ac8:3f98:: with SMTP id d24mr206961qtk.219.1550093566687; Wed, 13 Feb 2019 13:32:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093566; cv=none; d=google.com; s=arc-20160816; b=XeputWnZaBNVhjTQzfprPcDAg4y/Popg0ing2IHh8h3zqm08cCF6Xr2KVYtMmsloJ3 +QdapD8RAwDMmlWwUAA4Gv/MSA/FGwdoWntqln+40o1v2QnYWL/bkq+OrGyHG54sj85J /zbKUvRkfl1sK/Bt7dxeJcOJkxRh5IZqWtJIajUL/pQCSa5XYQyWLR9HOi5FhoPYXOuq E71D+D7PPAED9Eni/lua087UKwHSdLLPEovDxE3bIfj5rLHPadtVtVlHjy9ORJluBP/y JXs97S3cmVftoJmGiYSZvVhnlgjTC9ovPtk8ObpPWmZGqO0YKV3GslWdOJTqbEPpZ1n8 Rk7Q== 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=htX5NCY6rOuOTIoyhKI12TDdwsc2R7Wa3vlE0kAtWZo=; b=UOJ0HMVRTt4mJCkVKd4UpId6+H/dOB21gkSQM6EXaSKbcV/0WFloP0zJsN1D9Et8uE hwyXk2SZLbnUEk2W+1cuvDxB6+lB//tDnOl5IX2QGy/4epoYfJDFA1eOSYaIVdobv8Bj T+SS3jR9Ri+e9lMBqcEK6WoVdaOuxyJ4ORKZ1B+ULdZf1E2fPxDOVB4Od2g3NgaGckCW zXVKXY2RpsoyOSIvf4SO6H0wdTvVhV9vCHrx6LdxiF1Bb7jZVJnWEi2+nNgi0HM4FgT9 +Mvj1d4/026BSQbvGO2TXTjQsuw73eECSDSYb2s996wAeTkZIWU5A1ixYr5/Jt4XtB0D 0ogQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Bd3rc/oc"; 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 u81sor271075qki.141.2019.02.13.13.32.46 for (Google Transport Security); Wed, 13 Feb 2019 13:32: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="Bd3rc/oc"; 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=htX5NCY6rOuOTIoyhKI12TDdwsc2R7Wa3vlE0kAtWZo=; b=Bd3rc/oc98TZa70pugFF+4ZUCyk8cxClQU86pT/koqvumVajD83tjjtey5nmv+Xzeu vak5qd2Ml06tok0It+6AzVyXa8KvcgReAmTl/drALNkWQ2jGEKyWZ09X4vHTkOW2n6c0 RKC0JmAbi97WQVpqxXSkTEDPF7pJ5gjCKnrVp1wjXUobPpHup1guR6AbmwD0K/51II4I Eqe4F6OiYqLjAhIopLv13n+gEA2h1r9ULVTzvl73tU6UUzm/lPurLiHGepviX0XmEdHW lMmdylw0pA7aob7qxQKu/6H0/yiBepd2+oTFnpFrGjcDR5Oo4s0tRrSaslngYBCh/LH4 bvhg== 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=htX5NCY6rOuOTIoyhKI12TDdwsc2R7Wa3vlE0kAtWZo=; b=PfumEurD9uPLGI9GIKhxK4XPHF3RFiR9mvz+mMLp3VTaYueFV05ni+6f4mw97kfJPJ Xgv6GO4cwVFfnNsrnBLmKukpyXoSq4SU2Aiq1XkPoWuJ1nxwepc4gL8CruKREZr7nzuf fPuy/ZNjXUk1vYt/mOgQgpkVR96ixo5WJQPInLyt51Q9CtcsTYbGu/AxKMd5KZU/Dp6D c1Vi1VQ+HeiUdYrG0cOUnQcr7UQb/dMgNiUQYjiuk1cU1Zc+m7cvefpSzXItHyajwPBG Wa07+YT+g6rKmZk2170tgUv0j332GQmvVmepQ6tQ7AhD35V7OLooOungfm6A8Nj1tJnp eA0A== X-Gm-Message-State: AHQUAuYiwKpYrAEgjsjID5q31Z0OS/f2xk5QXFzpZoO0prehgBzblZVH rhuIqtkd9Ql5Oxf3n1WwqeMkppiD X-Google-Smtp-Source: AHgI3IZScYOCy2t3ydPZHF1R1hDVF+QJh+/5VQnYtvZcJHcSfN4VkZcPSm0RrxICXc1ht/aeja48Sw== X-Received: by 2002:a37:5b47:: with SMTP id p68mr180434qkb.299.1550093566329; Wed, 13 Feb 2019 13:32: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 8sm382675qtr.7.2019.02.13.13.32.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32: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.19 15/17] ARM: spectre-v2: per-CPU vtables to work around big.Little systems Date: Wed, 13 Feb 2019 16:32:21 -0500 Message-Id: <20190213213223.916-16-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: Russell King Commit 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. 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 | 31 +++++++++++++++++++++++++++++++ arch/arm/mm/proc-v7-bugs.c | 17 ++--------------- 4 files changed, 61 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 c259cc49c641..e1b6f280ab08 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 f269f4440496..7bbaa293a38c 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 f574a5e0d589..3bf82232b1be 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -102,6 +103,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; @@ -109,6 +134,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. @@ -359,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 Wed Feb 13 21:32: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: 158267 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp561092jaa; Wed, 13 Feb 2019 13:32:48 -0800 (PST) X-Received: by 2002:a0c:d4ab:: with SMTP id u40mr265313qvh.30.1550093567943; Wed, 13 Feb 2019 13:32:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093567; cv=none; d=google.com; s=arc-20160816; b=iV58QI7cqulKIG03VcWzVRT5u72wgif4loosvwrVJSuS3747JdwEZ6XLOOa8NOZ5++ wAXr84BqoSX0qjyx7IVGBSLQLDhis7nOg5XYt8N2CIS+1T/R6c6bo+jaTOiT8UVtsJQw dOWxAN15/nf8yC3BsLJ/b0lOCu7yiNSS5GVUon/Ogms9wh6sSyM9Fx4gTr7jy1cnHdSu qyy+1b5pOMpUQUaeHSuqWd82oIRypmZ7gaUvincEpNTe0agTaBXv6mHBAY66Entdw8CX yr0L3qINRxfxnQwPxXk0xwyFem5OfNGDVuVV1osR/F+UGJZnBmLke0WjT852paE9PI66 oVzQ== 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=JWWM0xAWumO0p3bY/5x9HLgVZOQ3s148CYkAGBmj6Ho=; b=dSDmFaGNhCoJ6xgfOovoG8pTwv3C76OTiTqwG0mEbU1lX2sLVsHtj078vBixSSKL7l T+SOeyORXDFslue4HxvgatdkCQKE4O+udFbJPd1jfbujl7XMbc5n8D9Uh95/mL12qoq6 N9JOlBZaDZDswmR7+O71vrKUPkZzKXtgIpWv/pqgyX4X0gP7fMfkIGwPKQUF5eOKQjp0 rYGYEbvBsY/tzqhZ5+b8I1ZLJfug6h6eyQVoiTxzoRf9qr61pWCLrd/Rifej+PcuK5zP sYR2SygwTWoMHrj/aTROz0FcNxHInDiW3GxLwI5lM2SCIclfur2VGgv/71F0rk0NoP+c 9NFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AA4ASCp2; 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 q8sor506906qve.61.2019.02.13.13.32.47 for (Google Transport Security); Wed, 13 Feb 2019 13:32:47 -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=AA4ASCp2; 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=JWWM0xAWumO0p3bY/5x9HLgVZOQ3s148CYkAGBmj6Ho=; b=AA4ASCp2mELKr3pko0Uf9JXxx6WuXxEkZtSYvfWe5+vswKI88GBJZLXygbMTr5fjVQ EGRU3Wf7YEt2bEOeP1Ec4scUcgv4TRBQtVF/vh6SP04SLUGKLnmpmjvM0JYsgE6vZV4J +RS1qwK0+UoBpvRt1EK53hEu4R+TT3N4DUSmTMhzWl+ql/v98Mc1J/Am/Ef7LYYE4AJ0 91c6Vue80g9PSD6s7zvtX9sqVlrPuIOLqJNFsN6e+WgF0iBOKXQHCGg9Td6Ea3fmWRaT 50q+aR4sM4R6x0ciV6+61Jq+WUNxLiuX3rrpMhjkE/wvSOvzl4FQZj7enqKkUN9Pevjm gzCg== 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=JWWM0xAWumO0p3bY/5x9HLgVZOQ3s148CYkAGBmj6Ho=; b=SmgFKTwyoNWdQ7VS3cLEM1UPl2942DZDqCUUr3EBFyChUTdl67Wh175GoqbCxlVMF2 plOfAdc63B4aFVjEZK4Ogm5+195r67wVQEIMDEE7RhN9UuW2McIuOAubIcHuK/pEAjZm UTfok/8x6f7mdllFMVTow4qVGvYdIYcj0hZNpdhu3o72WF2SJm9Bz9MLCLeSibtSh8uq +13lJrqSgChIRJY8SgXNclFXAPUjYAuTckx/ziL5FBVbqvmGze/WbFsYOihSmXnJPgEA FvdmsEYWDAA44NvFIK0jsiICEvK2JKarpx2J4yvSZWwAzOVv4e6ir8btEOTF1DUgxQZl E6GQ== X-Gm-Message-State: AHQUAuabTwwmXEUe2KteZkArxOAC9gg3ELpiXGN/Cog7d1fu50XnG/xD wJSvVWzH0tcuSCpSEwc+FxbbyZSv X-Google-Smtp-Source: AHgI3IY/femxih2p2G073ZpOVUi64ABe1+DQ/mhgjBNHd5Uoxbg7pDbglRMHPTNGP3fYNDBhVMMfDA== X-Received: by 2002:a0c:86bd:: with SMTP id 58mr237102qvf.162.1550093567665; Wed, 13 Feb 2019 13:32: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 8sm382675qtr.7.2019.02.13.13.32.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32: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.19 16/17] ARM: ensure that processor vtables is not lost after boot Date: Wed, 13 Feb 2019 16:32:22 -0500 Message-Id: <20190213213223.916-17-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: Russell King Commit 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 81d0efb055c6..19516fbc2c55 100644 --- a/arch/arm/mm/proc-macros.S +++ b/arch/arm/mm/proc-macros.S @@ -274,6 +274,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) @@ -309,6 +316,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 Wed Feb 13 21:32: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: 158268 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp561106jaa; Wed, 13 Feb 2019 13:32:49 -0800 (PST) X-Received: by 2002:a0c:8a02:: with SMTP id 2mr238268qvt.172.1550093569270; Wed, 13 Feb 2019 13:32:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093569; cv=none; d=google.com; s=arc-20160816; b=W2pKVGpmnjBM6TpZ4Ajdv8YDbTUDGcQ6P+C8jm2glGG2YPB4PJoqYJmcc67tctD/sO tFHWhgQa01m9cwGFk9wbx0NB2elzquUbH6+jlO3kALTPi8Q/Oax6LWh2/HfSBPxduEj4 rLAMdWnaYcJN/oGwDqhMijEk0EAkX3Xwh0zWiBHy/D0CKeUamztpU+HjYRJJqFrqHl+O bEBTTl9H/QltHhAcGzjJ9Ntd4G28kVfqNFI6zCk8hkTzGTB6stixdRoVLlChYp6JIUPN DpVDB2lBWy8tTgPe2X5wYSu+ybvi6Q3M5h+IsmQLk45JeJtRrlv3BKux73x76Mpk0ruA Cjcg== 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=IbhWU+vwiJ4ZGll0liBnsU+9mDwJbLZRs9UYNa4vW7U=; b=FmBdzCt5OS3qlgu8JS56ZBIGILmjLtsdOci6f5bQSnT1cp9oSSAtA6SH1vbFU9CcQO hdJNkl8yFwICyiyBu7nnj45QP2essihotqnRdOzTmDi5p3561mqEE37cX5MucJz318zo hawvay3ybYVwY/SGRgqOHCv5s83+kp9N4M013pEWP+Rh5TPSMQ9Rb9eGPm70krufjLAM 1tqBUBynmBJwWdMjdsVO0x30mOtkgBhB+pJrRo7GU+1ICFu3WdbZ+8UoGm1myu55A7QO oPpoLQVqVpWP+gD3iUVUHyoTjX8yBEmLceUNrITCq5kJWi/TeKePVUdJ0+AVeMBcfPYr HTjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yiA5zt26; 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 l12sor267430qkk.143.2019.02.13.13.32.49 for (Google Transport Security); Wed, 13 Feb 2019 13:32: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=yiA5zt26; 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=IbhWU+vwiJ4ZGll0liBnsU+9mDwJbLZRs9UYNa4vW7U=; b=yiA5zt26BcNlSC5TY8vcwZCC8Vzn6Bz6CToYTziIY/wmZs2h7ALzfFg6KxIMMdyQeW mXKRScI2MNZrqm1ZVyXeQpzK39pyFV9WPHYHsr4T6o8rot52in5/iEXLwKo0A5m8Gg8v 9eRtWIrFNIBEV+zhGdBRZJIQe27wW4ts8UK0sE10MeDSdI2YLmav3hO5kiPWcz2Eb+Ac h6NqzwKBox2S65KFnSaiwhGDDwib73UMsgOkw5gz4DwEoHdog20jFc4nMFUANhsv1Xow 7r6tmeC5nloBRPIBUP2/otfZYwqwEVT7hsJ/JGkaMlu/VA1gHYxsLwbFc3JEGj7yeKoS UGRg== 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=IbhWU+vwiJ4ZGll0liBnsU+9mDwJbLZRs9UYNa4vW7U=; b=YHhwgHl62p9J3fsrGxmESai1J3iwy/hqN2fubDpYe2q76gcJxjXcR55wxpiCAwpXq9 lB4hNDoCcpA/6TkXCne5AB6lJwYmEbyOblS5+uvlJlVned3BnJq5DS57dY1rukdOBFc1 JDlfDEElorgiFjxFni681uTgfgB9nimeHLZUIZG8EuFaP6NlrPjdETBJPIvlFdHJ2KL8 IjMsovcaX2mLaIn9tEmIrrgo6PgWSfYgQPdnJRWOpkW4hLMzUiXPPGtdSTY1Mol/6tsL N1edfHyaUbn+nIFol7xFVu5VOvx+UFYrZ0olh97FcfbX5RTml6lW+yBqM5p8unhm+G0M 0xHg== X-Gm-Message-State: AHQUAuaQkFUQg+IjgDwfOee36nqpAIlpq6D7yrepHXOlSa/c+AiARpbn A963Q2NM+jUEokrqsWkN2obEPCYF X-Google-Smtp-Source: AHgI3IYXQF9N4dCnG9cpRZUOHeWOYrfyw7Sr6gFT+huWsZ0DCuGdVdHQc2a9H39LsIARTX0dB6pvWg== X-Received: by 2002:ae9:e203:: with SMTP id c3mr220767qkc.270.1550093569019; Wed, 13 Feb 2019 13:32: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 8sm382675qtr.7.2019.02.13.13.32.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32: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.19 17/17] ARM: fix the cockup in the previous patch Date: Wed, 13 Feb 2019 16:32:23 -0500 Message-Id: <20190213213223.916-18-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-1-dave.long@linaro.org> From: Russell King Commit 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 19516fbc2c55..5461d589a1e2 100644 --- a/arch/arm/mm/proc-macros.S +++ b/arch/arm/mm/proc-macros.S @@ -278,7 +278,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 @@ -316,7 +316,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