From patchwork Thu Feb 14 02:10:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158274 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793640jaa; Wed, 13 Feb 2019 18:10:26 -0800 (PST) X-Received: by 2002:a0c:b00b:: with SMTP id k11mr992400qvc.237.1550110226526; Wed, 13 Feb 2019 18:10:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110226; cv=none; d=google.com; s=arc-20160816; b=wAPg0GJK7oC+gMap+JXdjhIQegFyJkitex0Oa81GOAdaXdJRJc8dipcvoCadl+5rOx 48Jw7a92kO/dOr3e4tVdUqAQ5PvYYxq3q3JOrV3bGVPBfDkW9vVZKi4kcutqIRqG3yON 4hKhOmzGp5E2GsFZOC6TlXOhrvkleoNLAEE+8tee/+IRK25pYJaFsJ67gImF/vbS1ATz q71OsjyEfzOcTbZBam76QaTQFNAv00BeeuYrgrEF1uZimuRBcq0b0hBAiIDySZ4+hyvz Zajff8JZItvKH5Y6ix6HF1vzhIuntLUSkhFkhFL9cOFC3BokVkh806IRUaSVg/Tj7Nqj 2kkg== 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=JdLRrZPibA2dIcwMA1KY3ab0IY+IQcbm99bqdyt8hkw=; b=XpSZ+YC8AtcHjqRRyo05pif+yhn+1KhksNMFA9tVgSM1h4h9W3bIS3vQsj1PoJufDi +2J6etwW8qZIwXcFihT18xM5A4gbtaMwZo4bBXbGqj42yDQde9zF5HR03kDxVYjlYuAH VvzoPHvqo0tRc90IrBN+jxXFGILFu6dxiExXXrXJIlYNAFfM0uDN+ZiwVh5Hn+b5tlJQ 96noC/riFnva198foCvpbWiBMfn8rH0D2ehT+myeR2VaK8TQ8HfAVvk5uc6Vd+ynRreO BbZjlQ5GV07ljOctDhrwLb94dD2ECsU5nrVZTQL3kjLbySGKwZbnrbl1G0FnDIrDOYTh PI/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vy1LxriG; 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 68sor1272793qte.29.2019.02.13.18.10.26 for (Google Transport Security); Wed, 13 Feb 2019 18:10:26 -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=vy1LxriG; 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=JdLRrZPibA2dIcwMA1KY3ab0IY+IQcbm99bqdyt8hkw=; b=vy1LxriGrYRghnYRsC715zl3NC+jrgX/rz9dTo92LqbVzYHrQ+XA9/4h4nOHn230Y9 lrcKF44hCZO/oPbJf3n7sFe0tAy3yxFpwkOc2NJYUimwXy1DW3G+yakdkd8bgP7APe4f QPTTO6mVBga629i5cVvTlcFFpp/7l5eqjpZDW/WAHbcCZhQ25lcdKfK/ALiaHczq8SIS eSF/lZFRyGFuH1AKIrxww3uqElkF8JFjtqgqcgmAGcw0d0md9QT9mHEIxlgQ2WtCcGVs g7iYeINagArzCl5DEZdCkJc/hc70MWS1l5DLzdz3KP/0INSK/nrjy86thsaZZxytESAz Rncg== 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=JdLRrZPibA2dIcwMA1KY3ab0IY+IQcbm99bqdyt8hkw=; b=msQmmJ9WjZRiXvBO8MhCkCeXkmeyg1tOrw7uSZTYdWQ1qKv/4/koIdgHciW06E4zPL hJtSZLhxcFuUt4g7aVEt7XcD1H/F9MZyUKnzwwgsttrMgUMmI5IwuY4bza0QiQUWdPqT +6jnGEFk+Dkoj2ZvMo0Dh4oOGsaY0JXDPTyWGJ6+3JD03+NkVj+esrTaSoBCinyk8n7B xG9Yy/2c100y2/mJUPx/bpvg7akTwDNz1MOzQph6ZiiCXiZeYpHDF7xppFzlkr7czkWM hvhmSy5sA8YoZvaDsfEh2kfm8DJtREgC2Ex+tVR8QZlbIMHOuesVr6tY9mdytN3dLyl6 27lg== X-Gm-Message-State: AHQUAuaFbA1pJe7plRzycSLu8X4+Sbnqryzl4O/1c1H4O/LBDnRijm/Y cabB4xKOgNAxxionEvOonfKVV2TZ X-Google-Smtp-Source: AHgI3Ia+8KHBDqKJ+YiKJMA1T19oD1YZ4wEPTzG0Eq995VT34n7Uy/EudvIYqUwLCW5J3kN/4q+ykw== X-Received: by 2002:aed:3ae4:: with SMTP id o91mr1041056qte.251.1550110226151; Wed, 13 Feb 2019 18:10:26 -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 d63sm1091575qka.22.2019.02.13.18.10.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10:25 -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.14 V2 01/17] ARM: 8789/1: signal: copy registers using __copy_to_user() Date: Wed, 13 Feb 2019 21:10:06 -0500 Message-Id: <20190214021022.5313-2-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-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 cdfe52b15a0a..1dc1f39825b6 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -296,30 +296,35 @@ static int setup_sigframe(struct sigframe __user *sf, struct pt_regs *regs, sigset_t *set) { struct aux_sigframe __user *aux; + struct sigcontext context; int err = 0; - __put_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err); - __put_user_error(regs->ARM_r1, &sf->uc.uc_mcontext.arm_r1, err); - __put_user_error(regs->ARM_r2, &sf->uc.uc_mcontext.arm_r2, err); - __put_user_error(regs->ARM_r3, &sf->uc.uc_mcontext.arm_r3, err); - __put_user_error(regs->ARM_r4, &sf->uc.uc_mcontext.arm_r4, err); - __put_user_error(regs->ARM_r5, &sf->uc.uc_mcontext.arm_r5, err); - __put_user_error(regs->ARM_r6, &sf->uc.uc_mcontext.arm_r6, err); - __put_user_error(regs->ARM_r7, &sf->uc.uc_mcontext.arm_r7, err); - __put_user_error(regs->ARM_r8, &sf->uc.uc_mcontext.arm_r8, err); - __put_user_error(regs->ARM_r9, &sf->uc.uc_mcontext.arm_r9, err); - __put_user_error(regs->ARM_r10, &sf->uc.uc_mcontext.arm_r10, err); - __put_user_error(regs->ARM_fp, &sf->uc.uc_mcontext.arm_fp, err); - __put_user_error(regs->ARM_ip, &sf->uc.uc_mcontext.arm_ip, err); - __put_user_error(regs->ARM_sp, &sf->uc.uc_mcontext.arm_sp, err); - __put_user_error(regs->ARM_lr, &sf->uc.uc_mcontext.arm_lr, err); - __put_user_error(regs->ARM_pc, &sf->uc.uc_mcontext.arm_pc, err); - __put_user_error(regs->ARM_cpsr, &sf->uc.uc_mcontext.arm_cpsr, err); - - __put_user_error(current->thread.trap_no, &sf->uc.uc_mcontext.trap_no, err); - __put_user_error(current->thread.error_code, &sf->uc.uc_mcontext.error_code, err); - __put_user_error(current->thread.address, &sf->uc.uc_mcontext.fault_address, err); - __put_user_error(set->sig[0], &sf->uc.uc_mcontext.oldmask, err); + context = (struct sigcontext) { + .arm_r0 = regs->ARM_r0, + .arm_r1 = regs->ARM_r1, + .arm_r2 = regs->ARM_r2, + .arm_r3 = regs->ARM_r3, + .arm_r4 = regs->ARM_r4, + .arm_r5 = regs->ARM_r5, + .arm_r6 = regs->ARM_r6, + .arm_r7 = regs->ARM_r7, + .arm_r8 = regs->ARM_r8, + .arm_r9 = regs->ARM_r9, + .arm_r10 = regs->ARM_r10, + .arm_fp = regs->ARM_fp, + .arm_ip = regs->ARM_ip, + .arm_sp = regs->ARM_sp, + .arm_lr = regs->ARM_lr, + .arm_pc = regs->ARM_pc, + .arm_cpsr = regs->ARM_cpsr, + + .trap_no = current->thread.trap_no, + .error_code = current->thread.error_code, + .fault_address = current->thread.address, + .oldmask = set->sig[0], + }; + + err |= __copy_to_user(&sf->uc.uc_mcontext, &context, sizeof(context)); err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set)); From patchwork Thu Feb 14 02:10: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: 158275 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793659jaa; Wed, 13 Feb 2019 18:10:27 -0800 (PST) X-Received: by 2002:a37:4d03:: with SMTP id a3mr946504qkb.181.1550110227759; Wed, 13 Feb 2019 18:10:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110227; cv=none; d=google.com; s=arc-20160816; b=PZfKMBtxbSCLA+2ahEi8S/iIrIxCA03upIzSbzsThVs/m1AL6DjimJOaSHznASrx3a 2JO68O2E7AabPyWKLFXCTvS9kA2bWiFOpPT+LNot9wFU0T4bXmZ6zWfwnZcLmFYHGfob GiiSLSucybHge1OV+fhTDjX/jyyVuSxWPTa8FeMz/iW2ZhlkP9d0t8nnGenQ5pVZoaZS E8yelyWKVhHVu96p0VU8MaTRyPNQqpdtYTqnr9F1eQHbt4PfRBZyNOpU0cDcDb9MzvIY 7eE0dU5llvtjs0yKj2WxIH28+59xwEwNvIG6oNZCXGNGLvt8wPVli9yANYiKsy/FALZV oaBA== 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=AZaysvDZX4O/Bu8vrQvGUNcMZ0ecXD4hClmIQ5jet3M=; b=rj9Ki56U35vn6q366jYQSfzlnmMtjjMnEBhndSYfqqvsgXOi980C2uz0u3n6gdukrn lFiaPmF/YbjpzweFRsh6fXZwKVO3zyrASynL3y+Q+PYtRh+JK5KhUP8gcqDdZBsd/y+J c+96WyiXgWmGeCyCMUQ67xrvfZSTldUXKarq75ft1Wfi/vg4eZIHy0vIAaijA9/BIZSH 20/BMg9xGDsovn6xKwL+WrvqLRUyob7CNOQF8wqP/DmRSE5fdohtymaS/KkgQVtKwH3i /I+5AP1f1GOka6o7fmymL2lZV1euRKq5ahR/Snfkq46e8MTQeON6ApWSm5Iq9LD7ACnX nfJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zqofi2n+; 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 r35sor1269648qtr.48.2019.02.13.18.10.27 for (Google Transport Security); Wed, 13 Feb 2019 18:10: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=Zqofi2n+; 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=AZaysvDZX4O/Bu8vrQvGUNcMZ0ecXD4hClmIQ5jet3M=; b=Zqofi2n+I6J25lcFxoU+utTxRN1+3tt6/q5AcD0yTqerFBelxOHNXClBDeDPFWesXN z1ejzTUM6KvhBdEgQBM/Y3HXY1BUgvNsqVlKmBYZaOS1N+ZbgNRFMatZ0Ah3lbQsQOul Mjo3+wBFgSwGNAzieoKIBXFrTDhNLwQ8Qd0v5L5mWi8mciy4JSUx1i0QDn5FGnJCc2nk vNv4Rr6Wf2InTUsczrWWDYcsBGTfyv2ZqxNm17xA4oJkeDx+8MQI4fkDafmDpQFCJU36 acaaGvZWly6x4cTB+4+Ro7DusNFpyg1CTEU/MIfvOUcLlMEoUOM3QXn5GCTlQlGfvQkb egVQ== 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=AZaysvDZX4O/Bu8vrQvGUNcMZ0ecXD4hClmIQ5jet3M=; b=LlNvsEciN4BnYUoHCGoWhdr/T39Fhf46YF7FKvtejvowKShFw4FBaecieGBWsemeSk vzN9tab/apjKraqbzda33D+hJRjOLPCd8AVv4EQxguQBma5EhscB3iZaeoaeYFIwPQ1x 66tM6rl9wan1Kb0k9WHGH3PC5GZQDDzAVBX2JaLznZQ8PcvW2VJ2gHGth9LxMyUoNVhq ajj+xVQIvrVOQaJsBSD8jVdOeq8Gcd1tyRElX4CMb5g7NYsjWXBy1O9TbK8YsoU4g+AA mgUGUHKcDTmzdqFQiFDx4VjAaRJqIzmukKyaYr3tH0wc/PAFbrQyjhj7G1FhclI1ID1w Xy5Q== X-Gm-Message-State: AHQUAuapRY6oLk42Cwhgo/9mkDpmRQKg7APkfxh4MrHxHirD9Rn/ZXyg efy2poqu43BAP20mWlVqCfyuJ6be X-Google-Smtp-Source: AHgI3IZiSsetuliD1FYf/uzQZwhkfFxbABKBD2LRuA0i/09q02mdj1Hkf3uWB6pr8CJikGqsfr6JJg== X-Received: by 2002:aed:3ef7:: with SMTP id o52mr1079347qtf.276.1550110227507; Wed, 13 Feb 2019 18:10: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 d63sm1091575qka.22.2019.02.13.18.10.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10: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.14 V2 02/17] ARM: 8790/1: signal: always use __copy_to_user to save iwmmxt context Date: Wed, 13 Feb 2019 21:10:07 -0500 Message-Id: <20190214021022.5313-3-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-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 1dc1f39825b6..b12499cc3582 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -76,8 +76,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 @@ -85,10 +83,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 Thu Feb 14 02:10: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: 158276 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793688jaa; Wed, 13 Feb 2019 18:10:29 -0800 (PST) X-Received: by 2002:ae9:de44:: with SMTP id s65mr980032qkf.55.1550110229324; Wed, 13 Feb 2019 18:10:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110229; cv=none; d=google.com; s=arc-20160816; b=w7djx0z2MwxEuNzAwQMkn/GCxQby7LVZdm2NFkh6oB/sAGy1/iQJw2j0IuH6NBrVpO MzRBqf3gmPVacFuq+oH21HE8spvWNy8nzt3TWAoAajYwzKXh04+IS9GGKapPZoQ+v9Xx kikwa4ZffCQVDIPDWZZrMhrJcI2i+x3ROk5B0bcMdA76q3KScMlA+1B+0tUc1+44f+C7 Z90VXKLVWtehvYzXL5011dnaKZGKEtv3oyErMO/9/mVc1zV38e/wyKv5K4Xe639rqvHM ug9nDnXL2KYCGPnBUpoJcpoT2pXV6JPH4/QTxfaqafBa8/YF+4aynVJGG5JTTXtsbsyj yhCg== 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=2KcANZZu3B+b5HtApH0abXmIyTLE/qQis8j8nSO9A+k=; b=DVd/oxkuyTkkuxZsuep9vDIxMh6SSggWa4R/D7vdDU1cqR71UOC75XrNmct87Z3pgz Gy3Gn7WOAgeHV9tTqgtL+ZETWy0mdGIaR6mBUA4+QZzV/D0bC/BkQIslsNcUapXvyugL j78RxAaoDcxBApf8Lrv2Wk+1I5o6bc6/C7XW5s++sb/50cWnN7b9tWITUsyeB/P3/SQF 5H4RtBszRRIqqfnk8iPvI2w2BOL4XAXXRWP5gkKadeRxhK6fxecf/0I0VMtNvDkboOoO pSVa58ojcHj6XfPag5w+D1BNOznPX5Xi08MVi2z1bPOuSCxOZtoKRll5j5LSBlUR0yA1 ygLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YRtf+fna; 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 y2sor1283339qtb.0.2019.02.13.18.10.29 for (Google Transport Security); Wed, 13 Feb 2019 18:10:29 -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=YRtf+fna; 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=2KcANZZu3B+b5HtApH0abXmIyTLE/qQis8j8nSO9A+k=; b=YRtf+fnalzvYzEFEGgnWPy00GIpL/bexiZ1RxPdCli1K4lq/hmRrRKkB/JpxTgl0Qt d0fPkLe4R5CbjnFVdt2yunkAymTbtKdaDsgIUo2TJvR+YGLgPR5dgZaZzBckYUryeWgr MO7JUgxfzxDtMYCT6aRA4OidQMRdsC71oyvW7CL38JZDgC8fdWTNdM6PRW9YYg6gTIF7 efeYLICL6sc9ZMr0qvfAc/bnCkfqrjAgLvsa0snW/Bs2uwUwdbK7nDb/4TB4Heedu9x6 2jDIPD8N/wkZyxP8/ddhHZgut917OgixKkyUsa5BMs3zqC5hnABSVvA9gQ3WtwHBX+Iq YUSA== 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=2KcANZZu3B+b5HtApH0abXmIyTLE/qQis8j8nSO9A+k=; b=HEer/BDXoSRYrV18ARGRVsdiIr8juJZcJSHUZVkwNWZ6Wzw0guBh/uHG68t7RNufvH hdvKPwcdd4ExfllKuF9Rqkp+aMQ673bWAXEjYV9/mO8XrR/lGkoArclPMhTKjz8aErOE 2xawsl9a7aH4r92ya+B4FsoLSrxn3z4wBeAVEdhHQpDZt8KpcXUzqJ4laToHtUmUshdl f9eyMXodoDefRK11Up09epD9NugCZAjrDO14USJmN6XURRrIN3PBFXmaBvz1m3iXOTTR Lo85CFYxoYKFqmtpBpzDUTDkZalfYAIaPmviewe4AgqQwwehtqdMqH6hL0XwOeejowrL Pdrg== X-Gm-Message-State: AHQUAubud7eBwbRaHImvI6CsztBop+/KXF5AYavaJPgq/t6B5hnSqcel O0+YJKVcyZi9tcJNpw7eNR2Hisy76zJczg== X-Google-Smtp-Source: AHgI3IbLjBtRwJjiW7vuPmPsBHq125WQ7V4HpYt9WNmX4X5Hqd7ZI8UpNuukPUDlOV8ULYYwaSnqxg== X-Received: by 2002:ac8:3501:: with SMTP id y1mr1017461qtb.209.1550110229015; Wed, 13 Feb 2019 18:10:29 -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 d63sm1091575qka.22.2019.02.13.18.10.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10: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.14 V2 03/17] ARM: 8791/1: vfp: use __copy_to_user() when saving VFP state Date: Wed, 13 Feb 2019 21:10:08 -0500 Message-Id: <20190214021022.5313-4-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-1-dave.long@linaro.org> From: Julien Thierry Commit 3aa2df6ec2ca6bc143a65351cca4266d03a8bc41 upstream. Use __copy_to_user() rather than __put_user_error() for individual members when saving VFP state. This has the benefit of disabling/enabling PAN once per copied struct intead of once per write. Signed-off-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/include/asm/thread_info.h | 4 ++-- arch/arm/kernel/signal.c | 13 +++++++------ arch/arm/vfp/vfpmodule.c | 20 ++++++++------------ 3 files changed, 17 insertions(+), 20 deletions(-) -- 2.17.1 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h index 57d2ad9c75ca..df8420672c7e 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h @@ -124,8 +124,8 @@ extern void vfp_flush_hwstate(struct thread_info *); struct user_vfp; struct user_vfp_exc; -extern int vfp_preserve_user_clear_hwstate(struct user_vfp __user *, - struct user_vfp_exc __user *); +extern int vfp_preserve_user_clear_hwstate(struct user_vfp *, + struct user_vfp_exc *); extern int vfp_restore_user_hwstate(struct user_vfp *, struct user_vfp_exc *); #endif diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index b12499cc3582..1eb83ee7e1cc 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -136,17 +136,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 6abcd4af8274..6bacd69c9e81 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -554,12 +554,11 @@ void vfp_flush_hwstate(struct thread_info *thread) * Save the current VFP state into the provided structures and prepare * for entry into a new function (signal handler). */ -int vfp_preserve_user_clear_hwstate(struct user_vfp __user *ufp, - struct user_vfp_exc __user *ufp_exc) +int vfp_preserve_user_clear_hwstate(struct user_vfp *ufp, + struct user_vfp_exc *ufp_exc) { struct thread_info *thread = current_thread_info(); struct vfp_hard_struct *hwstate = &thread->vfpstate.hard; - int err = 0; /* Ensure that the saved hwstate is up-to-date. */ vfp_sync_hwstate(thread); @@ -568,22 +567,19 @@ int vfp_preserve_user_clear_hwstate(struct user_vfp __user *ufp, * Copy the floating point registers. There can be unused * registers see asm/hwcap.h for details. */ - err |= __copy_to_user(&ufp->fpregs, &hwstate->fpregs, - sizeof(hwstate->fpregs)); + memcpy(&ufp->fpregs, &hwstate->fpregs, sizeof(hwstate->fpregs)); + /* * Copy the status and control register. */ - __put_user_error(hwstate->fpscr, &ufp->fpscr, err); + ufp->fpscr = hwstate->fpscr; /* * Copy the exception registers. */ - __put_user_error(hwstate->fpexc, &ufp_exc->fpexc, err); - __put_user_error(hwstate->fpinst, &ufp_exc->fpinst, err); - __put_user_error(hwstate->fpinst2, &ufp_exc->fpinst2, err); - - if (err) - return -EFAULT; + ufp_exc->fpexc = hwstate->fpexc; + ufp_exc->fpinst = hwstate->fpinst; + ufp_exc->fpinst2 = ufp_exc->fpinst2; /* Ensure that VFP is disabled. */ vfp_flush_hwstate(thread); From patchwork Thu Feb 14 02:10: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: 158277 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793703jaa; Wed, 13 Feb 2019 18:10:30 -0800 (PST) X-Received: by 2002:ac8:2e19:: with SMTP id r25mr1084512qta.0.1550110230546; Wed, 13 Feb 2019 18:10:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110230; cv=none; d=google.com; s=arc-20160816; b=nry+E/O3KmbLXvtzoDpC8hSgW8+gO6HJ/veaKjjR0B8vEZdSLtCC4ma0Gf6hdKJaQk YHEUSynErkCYpPP+SmjdSpA45da+W60Rvc0jLezl3RQohy0zPZ9/42xQzd/1TmvWmV2A RoI9HteoHQtpwYjqsSpEEpXkg3UX7Ee/SzD3ecfAZKFdWiO7cNf+1SsuMJPZ6du9Ggv7 VhmI98naIobmdNhFSdVCygcEmozT3lLOF4FEnSMes+OtWimfZoQlhR9ljoLLnYg1dEhN 4Hm2MpLSgMKjJF4QfwXzl9iem9+r6bTZQFRW9M3WEp9sQRZkQXw6rdOEhrH9w5UwFMsc SoHA== 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=ao2zNPPAVKm6DVngcSIODmeIuZt8Da7c4FKcqwlcUWs=; b=BIytx0eG+FzKAFSYJxYyhp5xd2qDzKLRbdw2W9htB3qk0/p9jMQnYWSBLy41mxU8Gr /DSYmX5F2ojj0CbaS50ZwA4qotQJeSfXIDwTDH0BppQrFSJIpT4iFMW7y/ekstA9ahnD hI14LDcabaG8JqBQHg7wmvCYvwMrfhtk8qoQnJ9mPfNLclKUAccWyuSj8YBqD8Gn8+Jj ECUamc6nD30I5j/bvR2MUZI1KSQHChwF/l2i9uzpLTqsZd1uEfKFGn5XiTICuFYsBfwU H2895i7U7zjvdfQ6dAXVKvIS62Tw18cE+3WlNyJuKk1UUStMpnBloK54s5Ad2J7z5o89 p8dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UgLNxFkX; 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 a9sor1250634qtj.40.2019.02.13.18.10.30 for (Google Transport Security); Wed, 13 Feb 2019 18:10: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=UgLNxFkX; 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=ao2zNPPAVKm6DVngcSIODmeIuZt8Da7c4FKcqwlcUWs=; b=UgLNxFkXN5F63atBRrO/+dam22AD9xcXt581af1qQdlsAytsMpzMy2XlygaxbDcy9/ IdR0Gl78bheX/LuIAHEvlKI4oUOuU+pKQ5vBGreBFVzSfcJK+pexDAHvgXYuJW6qEPBl MIfREGA1UDearL0vzEYwwS5sS6+qjjF/6wb3Gcbym8V1KeqLvP4ipKSLe9McwMp3CSNH UpqVvpyjWo1zfaHelNPDMWd0FCLwZQe6PSRRiNJ9ddj4VafKY8itk0YlzY/dUVil6rO6 VMMOZPJ9urwPQ3QFJCgCy+asEJADrs9qRwaTlQN7U0ZCrG5bwTg2m/ixn299DpCyB0bU wGjA== 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=ao2zNPPAVKm6DVngcSIODmeIuZt8Da7c4FKcqwlcUWs=; b=iG894X6Jt23lkzfhOCYCDnuNyYAcziovbS15PRjfERej+d0pIY/cJT0v7hoYrfs9PL VinqXL2Rl9u9AQoH7kMnsya+DYyvIhmxKGKyUk6AjIhsxbPSAPKNNqB8ogqGfiThdiat RKroiLRJagZ4VnejvuW2x+XX1eFs/je9awcNCGmAj1hVLDG+SrBq8AUKDwfwXvjhh4nq CSDFnF738jJQIN56LTTxwQy7eovTPPDoVNgWI8duNgIpdC1GN0Lufb4pLFJyPF9x5zqG AGvo0lfoNFcbCnJEnrfaouC2O17Hau2hFk6Q5Yg+yNOe7plbkn7biK6Q7wDxQ2RZTJea Sxyw== X-Gm-Message-State: AHQUAuZT2cPxPiCr0PXryydSgcxms+bDvn06DqcR+8rwcjJi6TaRobgR lG9LcFOwE3i72zgeVr1FJKj3cQcI X-Google-Smtp-Source: AHgI3Ib063IR4oXphlNEnw5EUM6dccVs/KVPVRN+fklLvH0axGg1PfPynsFO4dxwzyS+e/OVR7NFCw== X-Received: by 2002:ac8:2c51:: with SMTP id e17mr1032432qta.254.1550110230310; Wed, 13 Feb 2019 18:10: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 d63sm1091575qka.22.2019.02.13.18.10.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10: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.14 V2 04/17] ARM: 8792/1: oabi-compat: copy oabi events using __copy_to_user() Date: Wed, 13 Feb 2019 21:10:09 -0500 Message-Id: <20190214021022.5313-5-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-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 4abe4909417f..a87684532327 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 Thu Feb 14 02:10: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: 158278 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793724jaa; Wed, 13 Feb 2019 18:10:32 -0800 (PST) X-Received: by 2002:a37:a147:: with SMTP id k68mr979256qke.190.1550110232152; Wed, 13 Feb 2019 18:10:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110232; cv=none; d=google.com; s=arc-20160816; b=ZKdPRTi62idWFe6FFPdM7/LZytR8WRQSrgj45aIEXNhFT59LfLNxY6NDBp0ZbNDPAx lVKkB0pBNgS56DICc3sT2lMj7CU66Qtupx+FT8ljNG98ow0YJ6RmkVIha54feMJYwCRn BFpZQ7lAPvAhPnj8MVbWvXYAY+IgAw6FnX7+Vw0TkpyxipQIbfN0VvmlhAzzxnKi8RFI PlHtK0NozH5HaQDvM0M2MpyR9lBmCvaWdEqLxzPCA2usiYk9EnoKf7ZYYfAWF7OjcBfo VjmUOULh42W4zn5FinSIuRAyM/GCZWWeqzhvrkxNv+mBTLRX8dgelu8Mh0bkMRl7JoqX 9yEg== 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=xIzVBfVsJyFafmUW72TZLqDDrY1szfaf1MexYWgTKBk=; b=tm98I3yOcDnVtyCieCNYW/cfOfaDrJ3AafiFg0hhWrlzWjWsBvwCy7EVeXSSuOpGGr sgJ24qjNfwbx8yneIOdDo+SMznzPYb3QKadhsoUp1fbgpgmyej1kHNxGwh4AmQqrCbL8 TXl4acRggaO3mHSK6FB1TdNKGczKS3VcMvojFWWFABIuRvtJ4AGHYMPVlvcdZB5easYH xvoyNobnDn39YJPRgqOqm8BbA+jH7mvHlmE87c9kWjckbe53fb5QSeZlAJM5On6apm+y FCtatlreA7exTh37/E5vhnWUhUzubI4rXADe6X77wENEQJr/Db6X3n6F83y5o01r0iVB VLqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bSJWiF25; 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 c186sor625307qkd.142.2019.02.13.18.10.31 for (Google Transport Security); Wed, 13 Feb 2019 18:10: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=bSJWiF25; 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=xIzVBfVsJyFafmUW72TZLqDDrY1szfaf1MexYWgTKBk=; b=bSJWiF25S/UclV7gkfOpR2SXzbsw/A4AR4+zqb6qpO1veqy64HDC/XScLrdw2icpDo 8MeRynHIaSNrIqFB0vfA6ZGHYZNkbKWzCbhK9J6kq6BZ8+glVioFlrXk2DDOFNNacJQm K2go/hcpMhSEu9jvcd6bGuaBqIYV8qC28c8ZuJUdy0TnBq08qIO8x4EWMT+3xP57x3oN egAFkNBRPOprcjoZo+wOGoqVT9JJ7kQUpHquKsi1QRij0QRawyMbLRLzNCAyrOkzF5iI W5GYCuAYRxuPYgAyg9OBraDCEXAkMPV3Ya1oVVwTU+g1WovCI5VzvAHvoqz5pZXHWMw+ 6BuA== 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=xIzVBfVsJyFafmUW72TZLqDDrY1szfaf1MexYWgTKBk=; b=QQn029PuuUCnSTr1jFqy2ICnXKcVvBiaC8HOPerq7NnXBMBPy5SJB8/ymdZnqVGu3y 4OAJ7wFFlFVmghLKAQhPkXiUDhaaR/bXdx0YRyUzeDl7OLS8nol3suQvCcKXpoYMB8Dy 4V9ziomfpos+FWcdPONDKigfFxIRnIzX4oMN6Tbsa9Ck8PzJBeKMW5BN2DMtEtk/Rwvb V9ihsmfBMGPpoYQT+CoKoYGz0fntkfNlaTbjhRHgGEthkpGQKj1yHKSonTYytN2qEZ1E PxYiB8lFXFrwgPzO/dpqbK/J2CiLhLsMVHMLHYC/FzMtA00Jb2+ozwJIc9iEnF48ByfY UP+A== X-Gm-Message-State: AHQUAuZNHkaAUGFzuDJXsq7+j4ZteJSB7QOHifvr6kGi/jPb3PmmhCnY E5t229bGfz2E5dbbwWsWINpx6YJe X-Google-Smtp-Source: AHgI3IYfUk2A8qd0ubf+k0DgmFRWZzwMACnQjGBVT7rPfaVEaK5tRcEzUmZly/sGJCvQiVwaInr56A== X-Received: by 2002:a37:3641:: with SMTP id d62mr982296qka.14.1550110231737; Wed, 13 Feb 2019 18:10: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 d63sm1091575qka.22.2019.02.13.18.10.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10:31 -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.14 V2 05/17] ARM: 8793/1: signal: replace __put_user_error with __put_user Date: Wed, 13 Feb 2019 21:10:10 -0500 Message-Id: <20190214021022.5313-6-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-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 1eb83ee7e1cc..02e6b6dfffa7 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -344,7 +344,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; } @@ -476,7 +476,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) @@ -496,8 +496,8 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) err |= copy_siginfo_to_user(&frame->info, &ksig->info); - __put_user_error(0, &frame->sig.uc.uc_flags, err); - __put_user_error(NULL, &frame->sig.uc.uc_link, err); + err |= __put_user(0, &frame->sig.uc.uc_flags); + err |= __put_user(NULL, &frame->sig.uc.uc_link); err |= __save_altstack(&frame->sig.uc.uc_stack, regs->ARM_sp); err |= setup_sigframe(&frame->sig, regs, set); From patchwork Thu Feb 14 02:10: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: 158279 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793741jaa; Wed, 13 Feb 2019 18:10:33 -0800 (PST) X-Received: by 2002:a0c:afb6:: with SMTP id s51mr1058511qvc.34.1550110233335; Wed, 13 Feb 2019 18:10:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110233; cv=none; d=google.com; s=arc-20160816; b=td8IjEF40dyzGPg8b7xgQtBu0nQvv9SuW22Hf0uE086sPRMgQ0oblXOXMgZfrhfYTP 8QqN4svDieimUqdqk/VW9bKI5/djRRE0Rg1l1Mz/x76vnuzSw8KmTo2pfmbp+NNQuPRX LpflVQt4PanOOhvdnpEfjAs6M0YD6z1iTvd/04DkIKV1Q0hgx9NDTEIM74KuAcHHI0jH MORBkESIjr/kGlmdXYwxXNp6ppvO4zPDXoAsIqrO5gkDMnOdU9Z4/Qil348Xzd77mycc KQYoflLgEJ9ohQOW/J89H8L9/btdOj1n2lcuzEbKdf3y8Kwlfs0S9P+Es/djq581LBsy Iy/Q== 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=hBL7Wb0KdnmLsxeoxyLW0Tbkce8RSkol6PC9Ygx296g=; b=Wqcb1if962tzGXnCePt8yIkA4x8h+UaToySloYGd7VhsDh8vVZIy+TIpBGpeDsb7x+ NctPR4rDft9oOLMHK+sMoELSQu76181z4NQOLxyikvQWyXq5X18pVTE+SvuCEgQZXMXt 84X1M+Hc/n+3v49PbXGkqSVRW0ZOXhNwWMjM5rU8bgcYrr9BVZUhojbAsgzvJEEDwj9r MRx6rSAZPVsHE1Pekm0YBJkQl31ZNG9YP+C/0DOi1qlX3qoeH2S3R8oufBdim75ggJOc xllnBeuxWzjcxGpuTfRmLKyYj4IVxglzYZTSq6BkFFImfpNxKaJ1CXIeU5+meHfZpu1P rs4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jG9k1VfQ; 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 n7sor630918qkb.138.2019.02.13.18.10.33 for (Google Transport Security); Wed, 13 Feb 2019 18:10: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=jG9k1VfQ; 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=hBL7Wb0KdnmLsxeoxyLW0Tbkce8RSkol6PC9Ygx296g=; b=jG9k1VfQvhqa9stEBXoUgTnHpRsxJKHOyYG1WWAXTdx1CMzgOPJoBBGUK3dDuJh7Jt InBZGJo4lOLCvI5fafIqykZup//rOWKm1rhQbXJI6Cgp0A6/3aWXP39Wln9mMvJ9Rmj5 CzZIFCn1jm0BLYVKl0ftmtfkThwrB67I7iaifVBZG9noOu3KrdPiKNUIqQGHodhc3emd BzthAd+xwHF/wbv+FojoZDOaJHpKD+uLtVrcZFAJkNxjV4KdU5P4H040Mt0tR7UMl4wI 3wCjfWy0XONYeVhoqKFxSKt5W8XA69GqUoUNvM00LDjQZPvUvKQcNPVV+g+E8CU8Pp6y lGKg== 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=hBL7Wb0KdnmLsxeoxyLW0Tbkce8RSkol6PC9Ygx296g=; b=R+nW4NGwvJk49RO7d488du/630ajfNLnR9ZAwDwBRsvooFnqkLt8T0Tt0aNXd+BHrt 15H65cicX0+hgVW6ty7UzRlMYqDIgVPaOX3WZOE2fsrAS1KEWzL6xZBRsAsZueOXUNlA 3xmLhXKsIEglVU86/Hx9G72BDHok6fTxbz15hD/adiaDX9NvESWshaJ37zdcTV/TYxxT a1QQSqcr6hjjNX8dfb2fC5pG0MZIB9RoLI5hb42cMdHCQB5tPSwxp7v7kluqFBfPNM4w BAGlyC1HHod56y395g686skK8Qhvj8h04Tchv0jhnfkdhD/+Drz6OrVzIbD1/QjBcf+l 1DSQ== X-Gm-Message-State: AHQUAuZahZl9vIre17eb1v+LTt4qw/ybgnkLZ2E0zLErxb34kv0Nkc0Y ismJWEiONbXfVi0E97WJn3EeBy3P9e55ag== X-Google-Smtp-Source: AHgI3IZcpwfSnjhLIPi5nDo695ajgpwp3u6zeBChihrC0pKX9ABdZSdAuhmul8NHt/UhyoAjdzHMqQ== X-Received: by 2002:a37:4145:: with SMTP id o66mr920551qka.129.1550110233070; Wed, 13 Feb 2019 18:10:33 -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 d63sm1091575qka.22.2019.02.13.18.10.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10: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.14 V2 06/17] ARM: 8794/1: uaccess: Prevent speculative use of the current addr_limit Date: Wed, 13 Feb 2019 21:10:11 -0500 Message-Id: <20190214021022.5313-7-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-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 4140be431087..7d19584f5c39 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 Thu Feb 14 02:10: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: 158280 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793764jaa; Wed, 13 Feb 2019 18:10:34 -0800 (PST) X-Received: by 2002:a0c:8876:: with SMTP id 51mr1035919qvm.38.1550110234640; Wed, 13 Feb 2019 18:10:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110234; cv=none; d=google.com; s=arc-20160816; b=G2TDDWqkwR5dee/O/6aAEfA5x3aMPs09vg4W/9N+kL98pMv31KUlOVWwWUMbQ/VmVL I3imCIVK4D+eiYVmTSe8w2xyvHAL7XOjZHvhkyeFePWvpPuWnehYA3vIT9qL4RqFuRbr rcoFWx88f6KUtWXew7MALaH/K0D29eQq4ZBXFIYQDiHwBT0ECy3vbg/Dorfe7JcZU4Z/ 4pFLAcS0ldsX8T0bsfdgFH2ThJX5RmOjPpsinIwKU5HwNPHE8qbcZNjGT/1nd/AOPmhs tf3BWtT3LR0iUYwURet+voSZebElRYgPhJTSiaiGYYVBiEEud5xiisPzkp7Zms38noDF vbXw== 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=GrDWcqvz4w1IZM4bLnbt43ZL+fuuyvY4dihBlBpjGL0=; b=PzzX6JXa8O4+14fyeWIVZlJwBe97yhr8jDMhzUiZI4JS7jf4xnLO61sUByxyooxQoA AYAoS+AKwiEfKWjd5cQ7jb/kh9E9ses0dRHHIsnKLDGZJOyFmVBlYIR4D2zlw49y4B5E IlhhkkmoJmpY1peRq+EqwxVuw11MDc/XIiW+uDBUJ1S4mdMIHg/mASAf4ysMDfZEHrb5 ptAYEf+eUSg28PVe/o7ZB2ByDapx5eCO5FmaZKZ851/ru91u/KaSMQvU9ccLGdjlnwjQ Qy/N2tXv6FJnqTl/G6QjRHHD+riUFqiy6liHrtZloT24dHh8RsQXZ7C5YxImmXRyW8pS FNpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VzVvpheq; 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 j190sor662351qke.8.2019.02.13.18.10.34 for (Google Transport Security); Wed, 13 Feb 2019 18:10: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=VzVvpheq; 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=GrDWcqvz4w1IZM4bLnbt43ZL+fuuyvY4dihBlBpjGL0=; b=VzVvpheqp9hL5aBvqV+UN/IEz2gVnF1Cd2GNJPqgtpJxcEv0o4pOTs70+aKuKSm1tU 4yuf6fy5j/ngR5niiCDuPZ1urSER5nY8Vu2VyLILOUjXsgbY6uP1q5Sfl2VmFELP1ZhP Ivu61ESd9zhK+pwXou8EBzthzF3fUsbcyyrv9obV29tsQhmk9N4xXNCnunAWNLutaHWA xlR6KTYV/46+gyXMLMErG2nHz841J5HP6jfeLuncyZ4cIWRlkjEpnPP4U7hMjnLqbSeE S3tmG2ohyBEE3oLDehlIhmtR0UcIVft2PQohanK3NDZkTuIcrVUuTn0eD+B/fwtJ8Jp/ WjqQ== 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=GrDWcqvz4w1IZM4bLnbt43ZL+fuuyvY4dihBlBpjGL0=; b=U/ZEk1hu5bV3DTWjgZkuoghOSv6NrqCeFWZ6X5NzLcqVRVwuPeGhUeMXFtTDA8cgA5 UOGzyhysEpuSNY+MEa+rMIydsYa0CvwxXg7MrEA8c/eC64BB+CgAHMwOxEzz8op03ILe STHqksagLZzkirngpT1BhFar/Vh809B7IGADvggqnwTiYlHHGDSSp7QTdr9hONhfXjL8 s9It1yOgfjZQYgJDpSWRxnyx1gAIRU3FwNdSFgMzllHDATBxG65LuYGPRt9wsLeYRW+q qKxwWG0Dung0y7RMaygDxWEstDivZiD0qJrT5/UXDdIxtprOPWCMtgQz8fk6/IEvs8JC RWkw== X-Gm-Message-State: AHQUAuZLaHA0x4fnwl/Q2jDwVAo7/KuJno1OqE0XX+nIYZaBeyoLqufX UKfUByjE+YXQeFk+uTfdgHwWYEmj X-Google-Smtp-Source: AHgI3IaYYyWqe9n1hfxRFdlH3JFi+4Eec1KQI0gP7QHpfay6mpCKQirj30l/dFG8TeXKP9DcSIgg5g== X-Received: by 2002:a37:628a:: with SMTP id w132mr1008754qkb.60.1550110234410; Wed, 13 Feb 2019 18:10: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 d63sm1091575qka.22.2019.02.13.18.10.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10: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.14 V2 07/17] ARM: 8795/1: spectre-v1.1: use put_user() for __put_user() Date: Wed, 13 Feb 2019 21:10:12 -0500 Message-Id: <20190214021022.5313-8-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-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 7d19584f5c39..cf50b030c62c 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 Thu Feb 14 02:10: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: 158281 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793778jaa; Wed, 13 Feb 2019 18:10:36 -0800 (PST) X-Received: by 2002:ac8:18fa:: with SMTP id o55mr1059232qtk.272.1550110236123; Wed, 13 Feb 2019 18:10:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110236; cv=none; d=google.com; s=arc-20160816; b=pzqjGeiWOoltafcwZq8yvuQza6wy0dBflNxjCwHRmY9a3dNI3MorSkEAxFIkG05LaC HGR+wThtyt05MudxisivE2LOIcYEtp4xUMjLY0EEE+itU6OaWigYN1wTfJw5dkljtXij Gtw4Ysn47DWB4tVY1M5Zo1/+cyUEDG5QaojqUdSm8QP7sOXzn1GcHXy0PWKr7CmJXA2L FM9RDn7wK4pLl4kGEMHDtawRebMKprHe+KIHnxvQiDBVs2Dx2+EVihWMFQ3vjUgU6GV7 b3QgLY1/y/tdSqWBRDkQFTcQl5PSMywHTdcadCDn62GZEkvVI1pDndDR0Kxo8LhAlEOP lBjw== 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=39y7AjK7peQfKaqAWC/HsqOhv07u/eu+YO/gawsGjOo=; b=rr1jdMRJzhYnArzim8yJMIsthjnnT4Y/22QJQ63pRk6LHc9JjZsMSsERjDKgvsw7op naJyZTfhBmiuNwm3Pd7/JO3tml3QXohQ8bmFy6AHaD5VInxHE/0PLN1Kb3roXWCco5US /Jdm8c1JeJbWmZ04FFinn7oCnw1laaSsVtuf5aZVSW1qdUDUOx2nqa4alQWxJO4JK97y C41A4hMSD0ae1tBiOmvrt9HknqwkXMizlDFWo977/Za2VkeNSDcQNxwRb1inYnafL8pK 13ztKgXvQN0wbDngtL0O9f0QtifrU6mweA3eS/HpAWBk3wRQ9Su43L9RtIwk5Tr400hF QfGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B79bS5Lo; 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 m15sor1276557qtb.16.2019.02.13.18.10.36 for (Google Transport Security); Wed, 13 Feb 2019 18:10:36 -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=B79bS5Lo; 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=39y7AjK7peQfKaqAWC/HsqOhv07u/eu+YO/gawsGjOo=; b=B79bS5LozvnKZmS+ofA7EZyc742ycPZZafnn9JfHNU+XuK5Rv0DlIjq2zftNuZnnX2 CTr4hRn3N9Sg18fiGg6J0Pm87PGMSISqWE6MkZrqx1v/Rv9Sz8r9jvSmYy/p8L0As2s3 evqUAWxGT6TxyToF2g00dcT6tXOUItrIIKdw4SNr3k7YKJLlCXkoid+Kg7f88d5I13xp rHKDfpcpzRc2iOOcuCALNKo6YRdz9StBV2UMYfZY2U09UrvcSLujDm63E6TKQMFu6xwY REUpMavQweMFk3OpX6EAivxfyZd5iBbkfO5Dfrmn8hiftilW3X6ILHXWitHB8Vrmu9jX aDDQ== 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=39y7AjK7peQfKaqAWC/HsqOhv07u/eu+YO/gawsGjOo=; b=IcWf1iBkH2DfaS4tNoi9XsZPd57MZlLO20hIscl4c+SVGu0VKAZ7lN0vpNzMX7LIY0 1SGmA8VFtym55H5j1Q4u7KyyDjcOb1s4pE8OIhIFMS4HZudTsTx/F0w5Gn0qiQarG/EB OqMnledlg/sOSgdhik/xXvUs1iq5Kcc1UZLQRqitrKljoLNTGIbxjT3ktQRnHbRmw7Dz ErdG5WJgAbOwS38UysXwznyr/HrnJN6vPn+bv4Uo7k+KXzldLdEEuEbtaN+k6kJnqJtK Gc4jW4HLWisup704our0zL/il/a9u6+u06bceCZh7dC8Cf/JYu5MUfl+xcphfE9FPQlW qwag== X-Gm-Message-State: AHQUAuaZr4bubPqc9l0MKomMnod6hEddfq5N1qHR/cLPwjth+0gsVbpM Bp7bRzvnOO7yUylZwoa0jUCmVulD X-Google-Smtp-Source: AHgI3IbdXsLcPMDuF6L/GoHAtZoUOyjB+XvX4Zz2DXjnAzYOS2cKN9R5pxInjik1pfVy+8+3xeXsCQ== X-Received: by 2002:ac8:2a39:: with SMTP id k54mr1098700qtk.26.1550110235825; Wed, 13 Feb 2019 18:10: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 d63sm1091575qka.22.2019.02.13.18.10.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10:35 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Greg KH , Mark Rutland Cc: Will Deacon , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4.14 V2 08/17] ARM: 8796/1: spectre-v1, v1.1: provide helpers for address sanitization Date: Wed, 13 Feb 2019 21:10:13 -0500 Message-Id: <20190214021022.5313-9-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-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 cf50b030c62c..a5807b67ca8a 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 Thu Feb 14 02:10: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: 158282 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793804jaa; Wed, 13 Feb 2019 18:10:37 -0800 (PST) X-Received: by 2002:a37:9dd0:: with SMTP id g199mr931032qke.344.1550110237480; Wed, 13 Feb 2019 18:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110237; cv=none; d=google.com; s=arc-20160816; b=E9BnAIjd3Xx+iKjtydjmfylfw11nLBV9ci1d9wuJQZK1PpnFYLukSBjVDc3KbOO0rL PjTtkQFHS0bYH0NKuAVei66Fx12LJ2tzYKBpfPQrpMOoe8n7rct56qk77MdBSyUz1o3Y 5yrFVllcS+hTq+doUNlpKU0v7kVNhAwMuk01CCDuLS7s6LZAsoVsFSMaQi6JPIClZ1fu I6s1TiNIACskHQICa6tFllkPOStZ+VOPbxigWZlQV80hKYwYwlK5mpcx5A9pTA1/7Ri6 7IWbjP2ooAM0vWku6Q4PSrYnNWzvshAg2c38m6T9vWjVE50lS35bYmTXKNAlYwUP/l8S Lf3Q== 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=UDfhDnpKVnmaeI2MOrtdpi1WP35k25fyZ+OFvqzwhfiYjKvgZc1Hg0Sjekqiu2nMCl Pfe9AfiYJpbzWS7S34UY4pZ6xSrfxuFPXx1IlDm2RtBB9cK1pXIDcfxqLPAEB/Ipi6te G8q3ViTabDhxT/RTpuLQ/hMsFBb6NlSsIgguFyzunA7Oq+5AhPYKE28mIMWWO8EGOMCn JlZxJRDg1SW1DZGXdykem92irj09KpmUnOABQVUGR1qdQQFFxEXkLggw0odJUFP103bn ZFxPJYkF1EY5UmtAfmc56PXDdE1z45nKfXBCc6ASpfCerbJ3PGIiDPoxI8v+Z7ZsyWxB 09Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dwwaIIhG; 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 p45sor1253420qtp.35.2019.02.13.18.10.37 for (Google Transport Security); Wed, 13 Feb 2019 18:10: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=dwwaIIhG; 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=cmHxjX3QWGEzbd3gID8OLJBVtbh3tUIgNET1gXVqzGU=; b=dwwaIIhGhe/W4fv0WLGZipxrqaTJg/oyBGMzOQ5IfacD3zPcmv4vwj2uiHmFq9QWNy 5JPvOiad9GUL8bC6P7oGHiMR4AOxVlE+P6E39igFBrB3pv2Pczr92iGqyI4PjKPJUPpA x65m/MqQN62IhgWMpwGrc9yaparmdeII9TdnaREM2oxlvLC2b9otDSgIFbda/Ss1RQWi ebi9XIa3aNFeKyYxRH2zfPQxZUpgGd+Pz1OXmex5llrU44lvLBCSqofmN5iNmaEYIg6L iBtT7a28KDuwKj9c1a/8a6UXU1IWpGSth6KdlcLG72/qpZhy5u6q2WiPowFbqTfihKYe qMFQ== 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=d/K+cmmKf7+7ZnZn4kbA8rrsm2qZUGe4IiDtp9EGFwsl2LqsNw52QqZdaNqdKyh9zf MX7VwI1HISTcZHp7o9LGj5EfVCJpptY2vnThEu1U7E+5r9PGyqEMGURv49S3ERF4jpRD AWrEQbRFeW/IYOW3VRWr+B/clC0BbOFhkWxgoR/w9lr4Yq2mD2Yr8icZrquEJyxHEnQ3 PdkaUSCOp7uCfTIcx0krBlfg2LkMEgEdNQHwZHHDCviQvWnTZPc1s4kw2pRlKhdcz4g3 cn92jtoyVzXmi29ECr5JjifuWPyUAy78GInaOa2ZJcd3owmQKnAxGZOzv/lanDNN/Afr nJ+A== X-Gm-Message-State: AHQUAuZcrD7QUjOtp8u7JnV4Oh0r3QLlTT9EpzL1HZBe93xM/q8iP64E SltDxIJ0akIgtdpCgnaBtbGNBGog X-Google-Smtp-Source: AHgI3IbOJ0G/C9jKSa9gSfu5KY19PNsZDByWcebqN0yAJbWGCFZfEZvLsjhYnORACPzBc8i4S0rGeA== X-Received: by 2002:ac8:34ed:: with SMTP id x42mr1062788qtb.173.1550110237197; Wed, 13 Feb 2019 18:10:37 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id d63sm1091575qka.22.2019.02.13.18.10.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10: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.14 V2 09/17] ARM: 8797/1: spectre-v1.1: harden __copy_to_user Date: Wed, 13 Feb 2019 21:10:14 -0500 Message-Id: <20190214021022.5313-10-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-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 Thu Feb 14 02:10: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: 158283 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793817jaa; Wed, 13 Feb 2019 18:10:38 -0800 (PST) X-Received: by 2002:a0c:d804:: with SMTP id h4mr1059996qvj.15.1550110238750; Wed, 13 Feb 2019 18:10:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110238; cv=none; d=google.com; s=arc-20160816; b=mlfOChj/3ta1bE9aFuYXUkt/DtPzADyTsNH4jxmAKyTVtQdG77cxWU5NhnSOm1Daf/ dKi8U7QyM5IMs7xYjTeT2ms857B3j20gFfRSNyVzI2cm16Ihcb0uQInrItOwgxRm1CAs 3RV3G4yl+03zUGCaSIJEwnhvBa82lozeAGxRbHTPaYn1vsPLcsDkoyICajjHW4hug+jG pCCZf6zTygDALLmM62kpvCKQMfLG1G1I8Y6l8jtctTLZRND1QWYDJWdHSGWvrC97k+hH 9qyaI4bxXhqR8l/3qKrhq0ZzfqE5bmoUp0HdiN1+p754+V0iiTUqrHJullR6wGID4FRM DHXg== 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=WeFsULKehq8jGUkRqP49XwEy/ibmR7uFLb5YfBUBkPg=; b=Jr6ZL5gd2iIgWdxrWedx6leMq4XsNmUl+PS9u8oMzVTHch7XMXKa1FqwNTcL6ZzDRg 9PJhltJnldL644GKqUwKiICA61lTYXdBzy7dvBy7NKayvgF0Mu4syf5YfxQpeFHkm6Sg Aa3jqv+dLgOIn68LEOG2iN2fhs4WzRKbfOb+IoviTCxjylNMV4tNZJ6vxKytSdVYJ34K //dXMQlq+xYhQs63pP/JRQro9YzmaaZVALhGKu6ZdZVjbNcc4ffQN6OI+F/4TdvQAc71 6j+OE4jrHX10iW3xDpzrNuQnYLhfbxJ9fp6s5d7rWA4tD68zT5tAyuVnECRM/y6+OfFj 0V2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R3lYUvOz; 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 n28sor1287018qtn.18.2019.02.13.18.10.38 for (Google Transport Security); Wed, 13 Feb 2019 18:10: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=R3lYUvOz; 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=WeFsULKehq8jGUkRqP49XwEy/ibmR7uFLb5YfBUBkPg=; b=R3lYUvOzi0+V8DbmxPIDUt1Dx4wG26aUxaGi4hDa/1pCCNVDrIONxfIgRzxE9Fpe3g DWgiPypw8lWYvB/vI7+5a1+CpsDxeOGtZInC8/JXrtr3sWx5Z6PThtz1jsIptgrnlfXg XqSo6pLz582sgBt85uVU/bmxPCLCU5682nsFQ182bIGROLIl+00I6pxEU2w2kpFOEcY/ t5dc3c98u93YJbs2c9PQkAYPxVGx9/atVR6lt5sxJk11Yg12vsY+ndWehKQ7ndsRa4US /4/angB3m+fL2vTcIBlbfH2a9nMggpk2lIfSXo81L7KwIpJV9d4mkeQYFk1pWuBaD6yg S4RQ== 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=WeFsULKehq8jGUkRqP49XwEy/ibmR7uFLb5YfBUBkPg=; b=lnURHW/o5tvKU5pls7T+XMHoqtR7L6VRZeAc7ExLpPXX0FPiOtgU453Aa9ojPp9GQI zgvRsjAacOE3rgSua+1asvOL2VJhDMGpPl1L0EgniDE1XTerfwi5jvEJsPEtxzzYCX/b PbHFRvxky7ZCtR6EJrDJOsq5AG1qTMq6C2MCPMCj9LY3wIRJAglY1/9h0H7ClbJiDI54 aOloOjyuG5mqGGp1H/85CyaTIE/YFPuPHHBy8umf2sequGVW+QrP5Ox9ODpSX33SOrjr 0T/lFdM7BELrNJozuuVD+ZMg/vyd4HRm+vq2WdD4855LqgTjViF5qiQOdw7+tKpa4QbU SuqQ== X-Gm-Message-State: AHQUAuZmYe9oD5TNW+U2NnjFdt8oasuh60OwgJTAHRg2dCJXYFUVbokV jIcPo0NLCuw/H5i+6iR1i9gZxKwB X-Google-Smtp-Source: AHgI3IY0+/3ScFqLVlOcwskHRQBCj3PjT9tL4yL6mLIQg/nPNZAA90sQvyyiFsfhmamPojLVrpuF4Q== X-Received: by 2002:ac8:2de4:: with SMTP id q33mr1050917qta.358.1550110238505; Wed, 13 Feb 2019 18:10: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 d63sm1091575qka.22.2019.02.13.18.10.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10: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.14 V2 10/17] ARM: 8810/1: vfp: Fix wrong assignement to ufp_exc Date: Wed, 13 Feb 2019 21:10:15 -0500 Message-Id: <20190214021022.5313-11-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-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 6bacd69c9e81..8e11223d32a1 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -579,7 +579,7 @@ int vfp_preserve_user_clear_hwstate(struct user_vfp *ufp, */ ufp_exc->fpexc = hwstate->fpexc; ufp_exc->fpinst = hwstate->fpinst; - ufp_exc->fpinst2 = ufp_exc->fpinst2; + ufp_exc->fpinst2 = hwstate->fpinst2; /* Ensure that VFP is disabled. */ vfp_flush_hwstate(thread); From patchwork Thu Feb 14 02:10: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: 158284 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793838jaa; Wed, 13 Feb 2019 18:10:40 -0800 (PST) X-Received: by 2002:aed:3b25:: with SMTP id p34mr1044294qte.310.1550110240268; Wed, 13 Feb 2019 18:10:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110240; cv=none; d=google.com; s=arc-20160816; b=n/YLL6KQ+AY/8vxzYZn2c7WxGtfwqGfH9VrwckaHpHFuUpcHdQ5NpNlegvxKzuONrd yXOIa/65j2IebTGJq03vqvp53UwHkiEpLSLuHGsQjQoLfhsWgxSrnj8mZpDYyENKX2HK 0jO3vGQH3QBlrpkKF2ZYbPFHAVEEeywvSSrjWPJrbrcdOOLbEHwgXrQw50qm1qHemdNW jAYYHjlf3+EYq+Ny+g5HdJD2V7FSWJjvogGmCt5XlcytP4Iuda9wrIBiCmfk6EGGbAK5 ibLF1RdUPXb0BTCq9y2tCOSaXcc8aW9Bobos9Rc2zvYr/2QVObwvusmJHGZZmwSK21Ys TChQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=A+x6L8QagNW3CuUu/ag15Af/EDUw9eLjI6Wngv/1/8I=; b=z4vfwCjxAx33h+B/9DwdpDhJ4wUXd6zV6bRBkWGnNLm+h6KUtMJQlKKfmM9hZWGW1s 6y1Lp5NQcUAJuZV9L+PDqE8h9GCZy0ZCT/r94mu0MbFY6wkPQflouokp2V3kGMRvZOG1 hel9vX319FNO0Kh10B3EK2g/BIJ+1BhMrFCJ0Mz0+NkbqetBrxoUezgZY4twp+7rb3z4 WfU+IqDvAhvrA6rlNjY2PJbPzMzAn/gzPJC/fdgWdmsD87dHXNhLDTtQnxgyQmTKitKV SOHuvHXVQomwy3SCmjeoLpWeTrBdKfgb/G4EJJZ/e4V0K/RdlkoWaw4RGM/oXAXimkgR kBWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="F/DYWxkh"; 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 f34sor1247396qtk.57.2019.02.13.18.10.39 for (Google Transport Security); Wed, 13 Feb 2019 18:10:40 -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="F/DYWxkh"; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A+x6L8QagNW3CuUu/ag15Af/EDUw9eLjI6Wngv/1/8I=; b=F/DYWxkh5h75uyvkL5ybYW1+nVHGm/FdHj6VpSwOWKUsc7xtH3gRIP+9XNtAFHwdV9 tlF12ZIf1DoC8vUTfNIJ3t+DywksctRt2LuXqWoJTaOMfd1n4HKhKCvCh4acdEmgWnXX zjSyQiEt98ejoZUgSqBi8LqyjTjS0ZNcpDHmE8DsQCKn2ypMAfZI3OmUyfO5yqWWHlgO hIcScjt3Op+I4Jt83tDACO/ttjOzu7wRAu6ejH6xkC0HwHfrh+q+GwCIbJjNXEAPyBgm L+FlU2tUC2ycqkP21vMKLw1ffaA3TDPwsdDV5rkXhRtM8x+E6g2+oSE0RFvCgdC3Ig9b PMQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=A+x6L8QagNW3CuUu/ag15Af/EDUw9eLjI6Wngv/1/8I=; b=T3hh/M5VbNIv6+845jjfho3BT9VsvmEbUqvqyRad3LkBZS63e6ucg5QP9V8+MQUsEW O/DTQZpw4orznFPtOPEO6xTMWIs9cBOkzCF2BBVNjOD4MoV1YGtr+lbOvVN+UFtTvdGV PBrCY374qIqzA3TrRaYjmst6F7kCpNRJhrAqfMNDJRkPsC3xP0Zmu7AwcIvaA80LHHc4 gT2hrpWmrp+VFHMiGp+U8ivZMy0n9aIli54RmTVCMDRIGzaOEc6MCngAcDcKoLkaDrnA du5qRjW2p17xtkoLwPOl4nMPhMu0z2YX8m6KS1Zi5xPVeDBD0dbkCFze0x7kMayBkgu6 wl/Q== X-Gm-Message-State: AHQUAubTPxQFaG9WONX2BOV12Sfb0J/JyeERPcg53PWJ/grOIvMjjdLS dD5BVZloFmsnz2QazeF/6PIS6iUB X-Google-Smtp-Source: AHgI3IaVL7hODMtb5WWTu/BbEVFFTfMJCNw9tclqL21xf+smHU/pGBosslZK402W3aslAbHVALQryA== X-Received: by 2002:ac8:35a7:: with SMTP id k36mr1053958qtb.213.1550110239809; Wed, 13 Feb 2019 18:10: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 d63sm1091575qka.22.2019.02.13.18.10.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10:39 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Greg KH , Mark Rutland Cc: Will Deacon , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4.14 V2 11/17] ARM: make lookup_processor_type() non-__init Date: Wed, 13 Feb 2019 21:10:16 -0500 Message-Id: <20190214021022.5313-12-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-1-dave.long@linaro.org> From: Russell King Commit 899a42f836678a595f7d2bc36a5a0c2b03d08cbc upstream. Move lookup_processor_type() out of the __init section so it is callable from (eg) the secondary startup code during hotplug. Reviewed-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/kernel/head-common.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/arch/arm/kernel/head-common.S b/arch/arm/kernel/head-common.S index 8733012d231f..7e662bdd5cb3 100644 --- a/arch/arm/kernel/head-common.S +++ b/arch/arm/kernel/head-common.S @@ -122,6 +122,9 @@ __mmap_switched_data: .long init_thread_union + THREAD_START_SP @ sp .size __mmap_switched_data, . - __mmap_switched_data + __FINIT + .text + /* * This provides a C-API version of __lookup_processor_type */ @@ -133,9 +136,6 @@ ENTRY(lookup_processor_type) ldmfd sp!, {r4 - r6, r9, pc} ENDPROC(lookup_processor_type) - __FINIT - .text - /* * Read processor ID register (CP#15, CR0), and look up in the linker-built * supported processor list. Note that we can't use the absolute addresses From patchwork Thu Feb 14 02:10: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: 158285 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793858jaa; Wed, 13 Feb 2019 18:10:41 -0800 (PST) X-Received: by 2002:ac8:2b4b:: with SMTP id 11mr1029213qtv.252.1550110241507; Wed, 13 Feb 2019 18:10:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110241; cv=none; d=google.com; s=arc-20160816; b=QzQiMiD/wpJbwslicg4DaLmzIsFHYD0q7hbgcOp/i1LMBI9OrgG7HgQWI7XitTGbfK 1nIdUAZ+0sw+LIIoGH505jOd9OrH7mVWVGwXQUkGjTiVGRu58uwrh79nR8Dd+yQa/Lrl bxee9H7aZUvTq9sTfEfrlYTK3zvuBl8mBRA5oxd10LFQOySpz58zjHqooJE/P7xZdA7r NXuMYsb3KHnQIYvbwo07G20komhdC92WrOxl4FH5dDn+haKHMOeLfBnoQPzmmT6JmGjL NLj01jQINsCZGjjCmx7eppMwQMgss0/gDaXk8RgLwkAtNMf1KF4LClzrUKpWQigBrFeC Cz3Q== 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=yvoFdkch7Gd4/MbRPm6+HJonlCHu2OWfPFxCbumCzMk=; b=U0BPMMlpwoms0lvzzpV7Y6p3jjNdv8o6nC01Bv5r/SbFxY2Lkk97am8vbKXEpyTh+R zEN+vGEmbkrzl4DS6pZ7V28GNDysULEdEw/vJ9o1FWjUH/dcZp2hUL1kkMmmIkIvGjMR arKPSFhbQs0UZkim3AaYZRG2nrDu0MmHdqO9ya+piLUyi6Y94mYn9/rBEwvQQ6zWnAgI H2+Io9/zphBVdk10dEZEuW2fMctPf080rmDpHsm4Dg4QfDum9suqrR+0rE0lf1LEYFrB fp13YFQT09at+KOD5xJC+523cdsZAY4YbbSOZb0DwJX7LTDESAWX1rtxPReX5ZuHdyXV OQmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ysqTniWx; 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 b67sor659257qke.9.2019.02.13.18.10.41 for (Google Transport Security); Wed, 13 Feb 2019 18:10: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=ysqTniWx; 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=yvoFdkch7Gd4/MbRPm6+HJonlCHu2OWfPFxCbumCzMk=; b=ysqTniWxOkEN223i3ZqWK3+2Xx1kjnpb4gHRW2xyYDchldG5zL+5a7Q45TMllbqhik UMkxm3LHpdFxxbq6PxHFEf0+SBDVl2Xu8qSZDx3G3Mz3fWBKF+WyDb1kkr3+VxCWv4Pd k1j0NvkzzmIvTB63xRZU9nTgReJRTN40s0dNxlf1e2t20U6XEqi+Y47J6xrizZKowm53 z13xmgLXYXfKsA8zfiN8Wyu3LUa3daVdekpZ6dgt6RGt/4Ioxo99mQ+vAfIrLwmvtNbN j3cOHDiedKf01Bf28npHWE8pKictERK9jStB1KOLoTqgPk/y1sL3E7fNMqtdHlb05Ugj bO2g== 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=yvoFdkch7Gd4/MbRPm6+HJonlCHu2OWfPFxCbumCzMk=; b=bYJmoQYumUjVU18zIR5vynM5PYSw9BZzAkMXrnAz2DLmxBu6QTq69VlUnSv2jPs3Tj t/4TT5/9G5UwXyZJ8oh2eyrC98++AsKced00d5oRCcHm37nwxunw4YBexFcNf4BlIKTJ RG1knhGSxS2Sq/sJ7/iocxiMyEDEgy74cDZSR7Wvv4HVb1aXp4BMmoa9u/ND4b1JXlWY wOqX6ZC3btxLE6Vx5NIrTzaYGnFRDSXISAuy4He4y89/+cEO3gFIK8QMVon7wT7OmKGT FbVi8aq7QNUCWbOH45ogaddRdJrURWgeNGUu9tMvE8kjK6l3jjhiZtlROn8SIkX7lGqv JJNg== X-Gm-Message-State: AHQUAuYS/68XSAvD9QKVYI4krVMzjpLwczZUo4D5+JSHJy22jAhrsuTc B3mh5Mtt9dqU8RTI9cg8OyKyggIB X-Google-Smtp-Source: AHgI3IabMFdTfhlPPpeJQQWD5R+ltUy+nb2QKWqd38UJDeiPhzGdYN9mZwzizCIwSQRfAGIynBGIRw== X-Received: by 2002:a37:8e81:: with SMTP id q123mr998935qkd.34.1550110241233; Wed, 13 Feb 2019 18:10:41 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id d63sm1091575qka.22.2019.02.13.18.10.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10: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.14 V2 12/17] ARM: split out processor lookup Date: Wed, 13 Feb 2019 21:10:17 -0500 Message-Id: <20190214021022.5313-13-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-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 3379c2c684c2..25d523185c6a 100644 --- a/arch/arm/include/asm/cputype.h +++ b/arch/arm/include/asm/cputype.h @@ -107,6 +107,7 @@ #define ARM_CPU_PART_SCORPION 0x510002d0 extern unsigned int processor_id; +struct proc_info_list *lookup_processor(u32 midr); #ifdef CONFIG_CPU_CP15 #define read_cpuid(reg) \ diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 8e9a3e40d949..1a041ad4881e 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -667,22 +667,29 @@ static void __init smp_build_mpidr_hash(void) } #endif -static void __init setup_processor(void) +/* + * locate processor in the list of supported processor types. The linker + * builds this table for us from the entries in arch/arm/mm/proc-*.S + */ +struct proc_info_list *lookup_processor(u32 midr) { - struct proc_info_list *list; + struct proc_info_list *list = lookup_processor_type(midr); - /* - * locate processor in the list of supported processor - * types. The linker builds this table for us from the - * entries in arch/arm/mm/proc-*.S - */ - list = lookup_processor_type(read_cpuid_id()); if (!list) { - pr_err("CPU configuration botched (ID %08x), unable to continue.\n", - read_cpuid_id()); - while (1); + pr_err("CPU%u: configuration botched (ID %08x), CPU halted\n", + smp_processor_id(), midr); + while (1) + /* can't use cpu_relax() here as it may require MMU setup */; } + return list; +} + +static void __init setup_processor(void) +{ + unsigned int midr = read_cpuid_id(); + struct proc_info_list *list = lookup_processor(midr); + cpu_name = list->cpu_name; __cpu_architecture = __get_cpu_architecture(); @@ -700,7 +707,7 @@ static void __init setup_processor(void) #endif pr_info("CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n", - cpu_name, read_cpuid_id(), read_cpuid_id() & 15, + list->cpu_name, midr, midr & 15, proc_arch[cpu_architecture()], get_cr()); snprintf(init_utsname()->machine, __NEW_UTS_LEN + 1, "%s%c", From patchwork Thu Feb 14 02:10: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: 158286 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793870jaa; Wed, 13 Feb 2019 18:10:42 -0800 (PST) X-Received: by 2002:ac8:1415:: with SMTP id k21mr1033014qtj.321.1550110242913; Wed, 13 Feb 2019 18:10:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110242; cv=none; d=google.com; s=arc-20160816; b=qOKWu671qfyUU0P5wxmtQVUTdDLT5/tNfYx5gTU2j/+t6zsc9F825TEdh2/EpOlCNp /nlBDimuq6giQHlje6Wxorq0x/bOQcAr+c4fZ+IJRi52IMgb3230rgYRm32wL7ASy73W f5+EEZ0gx1MJ79xRUYP3yExRNA0+9BL58EC+OJkNIApIYdEat4po0rF/cZmEgBWD4XJH k/PbbPdVx4uQ0ERxQqU0o4sx+6xdao1vSUxynwNS/9GaUgXpSfYQtBggHfa4i/gjjbhu 60PTeJrlSiukdrxMSoZVpLk9dDfp1ibLYunXebqusKDfsGtu6nGWg1tiutBScqgq16jx NduA== 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=CCW1/8GEO/oH/6Nb5HMFV1cYiPmQJfAGIh0eC+ZBrrHZOyt9JD6tYQrNCMLHkE7MLD foX4wmlntl6liwmjE0jir2uJhZyQ8xx6DRMJlu+VQvXArmE1NvoIOqfYmCL1YKd9l3jh CZuBxfeLPVsfg4d2yIc1h8m8nDgo5DXOkM2v54sPTZtH4ynlK+nm3qSBOw9AIkZd+41Y W8iGjOH8GAAEiQY6MN3PzwoaPYYIu5Zlea9UP21b9c3z5jSF1OcHp/TYlFvHYTUnwefZ DiAqKzgmSWtjNpT8tXvV5MNpBHHVaXWHSbnvs2iylooUT2xcf3HVNAmgt5nzdjrkDPgQ zCFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RLOAOGsE; 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 e72sor630841qka.107.2019.02.13.18.10.42 for (Google Transport Security); Wed, 13 Feb 2019 18:10: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=RLOAOGsE; 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=RLOAOGsE5nSbSM6/Fdwv4fbbCUUDxoH87XcZiZPt8XPUpEg2LeQDlKEdX9eejNMth4 D5sjkt3JIQB0/O4sBhzjI4Xv7TxMEI42fBR97qAQ9cEEOuR65FFVZMWXkwlG4nqVNzAA EfPJTUnOXNxNhhGH/5tgmpP6UVQJQzNHJNQG11QqTJiwiawxa4GLUSjj/KP/VFlVej/W VH/WPb8HzrrPBx/qXezHkdtF475W0RFdZVJpXxwJlA2vwLfNvMv2HhvzF+lq3iAEzPht kZ6B1lO/XSu80dqNSmIygnLp8yzaVcaN/IW8WA1AkCzfWWk8IfZjAPiFnb07WJNIi7Cs hoKw== 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=uoIsoyZ1sGlz6Ea+j5xJsuZe/ASJSqspkQ9DbVM7/WpRNxdZ0vhkiGl3x+DSRo8joP 1oa9udnwJeAUD4ThbxzT7NKE6Az+PvxccgHnHpJ9CMppM3l7/bouPnT1EqHW861KnllP Da3FTFZNqol4olhlKpPsoBy6MmWetEo8VF1iswXExShw2M/U1X4YJqQsV8BbvG9udHxH PyYAOxS0K13jk6M5npPzUZf+VqMLp3Ln6yXPqyG4woDBnIlyIlEWRxJ/7xDEba6/YyON V7BltnxSWs0B5Y8qiwL14MY5QPKnJitL9LvIfOkWdf5SCloMiuZfUPBKvnf7RmHpBkpr 501g== X-Gm-Message-State: AHQUAuZJRAqZbgkEibXcf3MuJlK5GfDG/IxHIDcKMHs12ixqWJ4iT3nH TY2NFReb14HdzP++Mf7Pi7yO1XiQ X-Google-Smtp-Source: AHgI3IaOdEJlYGfGZFJ03LySCXK9Oa2itBY1PUrqSCZa559Bzvv8O1a10Md03zQeqa4HrWam4yA2fQ== X-Received: by 2002:a37:b405:: with SMTP id d5mr980783qkf.162.1550110242675; Wed, 13 Feb 2019 18:10: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 d63sm1091575qka.22.2019.02.13.18.10.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10:42 -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.14 V2 13/17] ARM: clean up per-processor check_bugs method call Date: Wed, 13 Feb 2019 21:10:18 -0500 Message-Id: <20190214021022.5313-14-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-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 Thu Feb 14 02:10: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: 158287 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793895jaa; Wed, 13 Feb 2019 18:10:44 -0800 (PST) X-Received: by 2002:ac8:31ab:: with SMTP id h40mr1094668qte.122.1550110244337; Wed, 13 Feb 2019 18:10:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110244; cv=none; d=google.com; s=arc-20160816; b=czIaJv8BIBAXEic/3EJAPcgIBKQt23BAfMYCyAmqSZnTtEsf0pCKqv26FBQ7appKBv iddOelp2RFa/wzUhy+fZuq4LFkvyBGSUNV+IWUUVES9kdJc/qgp/IK8i1aEm7EI4L79Y DNKDas0fvpm7+EiJt4+zArID0C3z4sjlNPK0HdbiPCGmdh9621SDpcUW2zJgEetnsoFF ilD05z3dt2IOkA5j7KagwvwgD51lSikiGwNv0dBBislbl28PcPHK98WmEdpqkGlhg45V IUckmMMOAd/qlB0QS7v+L9o8IS/L/19cY+ZBjW7rs/goEnnHSyyq7zFsiQ5kApua16+0 TPCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t952pQdCO8vFdgrbc2uvLXfj7ukUT0YFXZtA0v/0jfM=; b=dXjmgcQJSVjzFCANq3IoYABxSd0LFlndhL8cWoq3GXFcyBo9ZttLNVWePJ29wIUrRX gTOdnJ+JMapyfQsp2tpxB9ymTs/zED/mo88hD81W2RUuY+Q8Vx7zUQtEZ8HR8ecoKnuP Sva0VspULwVs7axdQEfsUbwvpdtkwpaWWQJhk2zj3qmSO1jAeXbkw2q1flW51fuSVkXp kxyY8TogZ881Afp3TFgCZVDCPz6xqCL8uGVe7yjakO3pXIXkqco30zX+gwtjUgFU7LHd PN9Pdlf1bPmMhjwmIv75idlHTKSHwOVUJDUimEjZ98GPB5200H+t0toiFBvrLJ5xaEEh smqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uTNUl8vM; 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 e185sor645088qkd.87.2019.02.13.18.10.44 for (Google Transport Security); Wed, 13 Feb 2019 18:10:44 -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=uTNUl8vM; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t952pQdCO8vFdgrbc2uvLXfj7ukUT0YFXZtA0v/0jfM=; b=uTNUl8vMExmK2zTMmjR5pyJVKk/vJ96uti0dKLmR4uAnsllgao7RXVm750HfOIA1mT fkCGGWowkflUyM7cuzEkpSZnKJJtNKOtygnz6KdsxDSgOROKzQFTjpjHgqr23pKtmTxv mLcbtWhM/L+alcePlNwJZL+v0PgGcrX78u2xx2h2QXZCp4fu5ggQbxsImyAbBIL6IUsx GWGbWdhrnFG3LFAFhr4AaUS3GQEoNCSUOXbN9cH5Dbb9UzEk9MINU7EFv+bxpsSXzduU bnnCV02aZjZ2DUKoXbJURmeKdvbmEmpT/+S5tsm7izBNIATBVn8eAvN7nUbhgToKwOvJ /Qkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t952pQdCO8vFdgrbc2uvLXfj7ukUT0YFXZtA0v/0jfM=; b=aio7z63nU+XfNgtvmjWjH8zaQ/QGDi+UYCjdOe8aGLKaFvpExNRjnhyqs3+1Xa9D7G Ui2JpbUWVYHWIkpfYWu/HsSghJiovWrUvs3sTThVRuct0kxbDN/a+VrrKCHxiVit9uDj oTX7qDXkuBJmnbkprM0zLkbS7oso7GyenGZC/1H0LQSQWCYbFngLkTRl5St6+4vEM+s0 CeDE5GeMMdYO7vUYUegMf/yMjvkCRrjSqbWUowh2yUFim5Z9tHjwFLi4SruPyRgsGLJ9 QljdfkcPmb0c231Ceh1iJksujo9jTthintwRgQ5H7Xx6465aQrYD81SiSzz/nf6xs08T Vmsw== X-Gm-Message-State: AHQUAuZrjb99QyxWRglu9Kq4w4G18eZazqbnLgN1DWe/NEiHI0YXYIZT rIVXR8uoPyQnFH+5zsUBQUcFu7MB X-Google-Smtp-Source: AHgI3IbKk2PzwlnIZZvylG7tKCx9qyB6fAFytvU+qfIiwprqSesCnhZ6jknn6IY+mfL+l5wJJ9ivRw== X-Received: by 2002:a37:9286:: with SMTP id u128mr1030206qkd.0.1550110244064; Wed, 13 Feb 2019 18:10: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 d63sm1091575qka.22.2019.02.13.18.10.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10: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.14 V2 14/17] ARM: add PROC_VTABLE and PROC_TABLE macros Date: Wed, 13 Feb 2019 21:10:19 -0500 Message-Id: <20190214021022.5313-15-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-1-dave.long@linaro.org> From: Russell King Commit e209950fdd065d2cc46e6338e47e52841b830cba upstream. Allow the way we access members of the processor vtable to be changed at compile time. We will need to move to per-CPU vtables to fix the Spectre variant 2 issues on big.Little systems. However, we have a couple of calls that do not need the vtable treatment, and indeed cause a kernel warning due to the (later) use of smp_processor_id(), so also introduce the PROC_TABLE macro for these which always use CPU 0's function pointers. Reviewed-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/include/asm/proc-fns.h | 39 ++++++++++++++++++++++----------- arch/arm/kernel/setup.c | 4 +--- 2 files changed, 27 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h index 30c499146320..c259cc49c641 100644 --- a/arch/arm/include/asm/proc-fns.h +++ b/arch/arm/include/asm/proc-fns.h @@ -23,7 +23,7 @@ struct mm_struct; /* * Don't change this structure - ASM code relies on it. */ -extern struct processor { +struct processor { /* MISC * get data abort address/flags */ @@ -79,9 +79,13 @@ extern struct processor { unsigned int suspend_size; void (*do_suspend)(void *); void (*do_resume)(void *); -} processor; +}; #ifndef MULTI_CPU +static inline void init_proc_vtable(const struct processor *p) +{ +} + extern void cpu_proc_init(void); extern void cpu_proc_fin(void); extern int cpu_do_idle(void); @@ -98,18 +102,27 @@ extern void cpu_reset(unsigned long addr, bool hvc) __attribute__((noreturn)); extern void cpu_do_suspend(void *); extern void cpu_do_resume(void *); #else -#define cpu_proc_init processor._proc_init -#define cpu_check_bugs processor.check_bugs -#define cpu_proc_fin processor._proc_fin -#define cpu_reset processor.reset -#define cpu_do_idle processor._do_idle -#define cpu_dcache_clean_area processor.dcache_clean_area -#define cpu_set_pte_ext processor.set_pte_ext -#define cpu_do_switch_mm processor.switch_mm -/* These three are private to arch/arm/kernel/suspend.c */ -#define cpu_do_suspend processor.do_suspend -#define cpu_do_resume processor.do_resume +extern struct processor processor; +#define PROC_VTABLE(f) processor.f +#define PROC_TABLE(f) processor.f +static inline void init_proc_vtable(const struct processor *p) +{ + processor = *p; +} + +#define cpu_proc_init PROC_VTABLE(_proc_init) +#define cpu_check_bugs PROC_VTABLE(check_bugs) +#define cpu_proc_fin PROC_VTABLE(_proc_fin) +#define cpu_reset PROC_VTABLE(reset) +#define cpu_do_idle PROC_VTABLE(_do_idle) +#define cpu_dcache_clean_area PROC_TABLE(dcache_clean_area) +#define cpu_set_pte_ext PROC_TABLE(set_pte_ext) +#define cpu_do_switch_mm PROC_VTABLE(switch_mm) + +/* These two are private to arch/arm/kernel/suspend.c */ +#define cpu_do_suspend PROC_VTABLE(do_suspend) +#define cpu_do_resume PROC_VTABLE(do_resume) #endif extern void cpu_resume(void); diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 1a041ad4881e..c1588e31aa83 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -693,9 +693,7 @@ static void __init setup_processor(void) cpu_name = list->cpu_name; __cpu_architecture = __get_cpu_architecture(); -#ifdef MULTI_CPU - processor = *list->proc; -#endif + init_proc_vtable(list->proc); #ifdef MULTI_TLB cpu_tlb = *list->tlb; #endif From patchwork Thu Feb 14 02:10: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: 158288 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793915jaa; Wed, 13 Feb 2019 18:10:45 -0800 (PST) X-Received: by 2002:a0c:8204:: with SMTP id h4mr1028567qva.85.1550110245710; Wed, 13 Feb 2019 18:10:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110245; cv=none; d=google.com; s=arc-20160816; b=WYko5/77sduQLBrFXJAG/iMg8FIkyULi511BdwSGJ/nRFyBvCw+xq7AyKO1uW/5qZj Ia8bH/P/v9hJch/cu5bRIYmXeS91QPpqnbXhjl2zb6Cw3TjDIkbYcYhrN7UI40faIBQp fNm9mDLK1CR2EVDhwVYvXfXEkh+9AwNIzO1pcLLnAOhzgSkbddUKr/49MalwaF5aDdun 4gDuV8+JYIEjJTscyWp3FZF1LAAGJlPV77U4TzmpEJbKRyd0elSqgOUcXuRk39RTuJKX OQDfUvyKpSpLibt/gRSGllvQjuNu2GLCKJADkyN5hv0hs7pDWzPy2uB+u/7rzhmHi+5w 498w== 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=2Lgm0wW67bNBbj1r22lApgse7tqbhFKA3zBeaNlbhCI=; b=TtIJuHoU9keYgaYUCoNWidff/yCM3rQkxgOWIXz6kJBnEJ7YNTnmjv2yCZ7KQyr9n/ ESOihAheF0z+38QdOhSMm75iqlpDhqBSGcP8+SWItDXPtjdPwVIu/EKQYo83nMIkMji5 q38O8LJFl3qin5TDKDAAznSyIrr5rfjJd6itYsBKsezwhpiGFpwzDID3W1ESQFU1bIFw ru777fqBdnHYP11D0tBnHd5X8AEXkJY4DphiIkDkkGIlVza7OAhFKOVQJEzJDIevs2Co CcMN4E2IUL7baJyn2a97rzi1336uRFYTCtHbCwEqxJHZLHY5HWpjE0cVcg2ir6ooujRI keAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZqtC6ztQ; 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 j137sor634476qke.70.2019.02.13.18.10.45 for (Google Transport Security); Wed, 13 Feb 2019 18:10: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=ZqtC6ztQ; 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=2Lgm0wW67bNBbj1r22lApgse7tqbhFKA3zBeaNlbhCI=; b=ZqtC6ztQKzKjRT17/NHjp51BgwHp2P8zTR/KjjBZOi/aBmnf9GCVYZNFqDu+ZQbYyE AVOZlG91yPwbr581JY3vXpnEr2bs+63WcoJCsBmXD5jhAIttu6X6WCRZR0hlXOQ6PbKW xy+CNGXQkVV48z2q6THpiVdP8NmIgdHD+UdCmfvvhf24CGp/9FTXxCVJjaN/rnYqQw1b 1ZzNba3O20YsITg9X+IEBK41YViocpVXqjqustQdMSP1VMjea8lxgB/Uqmb3u+JL5Kjo LpXtM/FKU9lofgbNq/gMQrxW5Ny81IR8WZDf2MtgiBS0EGYYM+qKCu2etzp0Lt1+ux1o MPzQ== 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=2Lgm0wW67bNBbj1r22lApgse7tqbhFKA3zBeaNlbhCI=; b=eOCpNFtsgLxtEbu2MK7hrhrc6MKJkc2Xx7GlsqsjR7BccQxbqasF/FP22rQYXZ4Xh/ Ngbhhm9e3FUsBIQ1aT2ildfRyR3zRK+XuKwL8u9hQpXKF14ejlWensZJOXezC8binj0d Wn92o6ItqDpfUYto/8qOWZdgBZv28HNs62WWk377Re/UzT1DSgcvXmjniB3jPKtAVefG BdfNC+bMx2qJo7j4hlWbfNTQ5B2KwdLPXO1cyolaGC7Z9cL8r0IRR98f9hqeHQGSsybz gM5Py0ZNONkRzofIkYlHXPZqhPXLSvp0FTIu0dKP6uBb9mapmvyWv5eRNOxLPOddGCru iEkQ== X-Gm-Message-State: AHQUAuYaYdDgPc5+aDvciEQb4m+BHRU8Nftl/rKl9JUEousip/A+2lSq D4W0FRvSZ9syg2mgRkD5zMBwR1sY2ALrPA== X-Google-Smtp-Source: AHgI3IbkIMKirzSeRlp6sjp1u6jkDWXic77jGrmcuLXEQ6FKZZRn66QwCFwx2jC1GA/ASOvB8ZhGbQ== X-Received: by 2002:a37:4145:: with SMTP id o66mr921103qka.129.1550110245375; Wed, 13 Feb 2019 18:10:45 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id d63sm1091575qka.22.2019.02.13.18.10.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10: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.14 V2 15/17] ARM: spectre-v2: per-CPU vtables to work around big.Little systems Date: Wed, 13 Feb 2019 21:10:20 -0500 Message-Id: <20190214021022.5313-16-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-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 c1588e31aa83..a6d27284105a 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 5e31c62127a0..f57333f46242 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. @@ -360,6 +389,8 @@ asmlinkage void secondary_start_kernel(void) struct mm_struct *mm = &init_mm; unsigned int cpu; + secondary_biglittle_init(); + /* * The identity mapping is uncached (strongly ordered), so * switch away from it before attempting any exclusive accesses. diff --git a/arch/arm/mm/proc-v7-bugs.c b/arch/arm/mm/proc-v7-bugs.c index 5544b82a2e7a..9a07916af8dd 100644 --- a/arch/arm/mm/proc-v7-bugs.c +++ b/arch/arm/mm/proc-v7-bugs.c @@ -52,8 +52,6 @@ static void cpu_v7_spectre_init(void) case ARM_CPU_PART_CORTEX_A17: case ARM_CPU_PART_CORTEX_A73: case ARM_CPU_PART_CORTEX_A75: - if (processor.switch_mm != cpu_v7_bpiall_switch_mm) - goto bl_error; per_cpu(harden_branch_predictor_fn, cpu) = harden_branch_predictor_bpiall; spectre_v2_method = "BPIALL"; @@ -61,8 +59,6 @@ static void cpu_v7_spectre_init(void) case ARM_CPU_PART_CORTEX_A15: case ARM_CPU_PART_BRAHMA_B15: - if (processor.switch_mm != cpu_v7_iciallu_switch_mm) - goto bl_error; per_cpu(harden_branch_predictor_fn, cpu) = harden_branch_predictor_iciallu; spectre_v2_method = "ICIALLU"; @@ -88,11 +84,9 @@ static void cpu_v7_spectre_init(void) ARM_SMCCC_ARCH_WORKAROUND_1, &res); if ((int)res.a0 != 0) break; - if (processor.switch_mm != cpu_v7_hvc_switch_mm && cpu) - goto bl_error; per_cpu(harden_branch_predictor_fn, cpu) = call_hvc_arch_workaround_1; - processor.switch_mm = cpu_v7_hvc_switch_mm; + cpu_do_switch_mm = cpu_v7_hvc_switch_mm; spectre_v2_method = "hypervisor"; break; @@ -101,11 +95,9 @@ static void cpu_v7_spectre_init(void) ARM_SMCCC_ARCH_WORKAROUND_1, &res); if ((int)res.a0 != 0) break; - if (processor.switch_mm != cpu_v7_smc_switch_mm && cpu) - goto bl_error; per_cpu(harden_branch_predictor_fn, cpu) = call_smc_arch_workaround_1; - processor.switch_mm = cpu_v7_smc_switch_mm; + cpu_do_switch_mm = cpu_v7_smc_switch_mm; spectre_v2_method = "firmware"; break; @@ -119,11 +111,6 @@ static void cpu_v7_spectre_init(void) if (spectre_v2_method) pr_info("CPU%u: Spectre v2: using %s workaround\n", smp_processor_id(), spectre_v2_method); - return; - -bl_error: - pr_err("CPU%u: Spectre v2: incorrect context switching function, system vulnerable\n", - cpu); } #else static void cpu_v7_spectre_init(void) From patchwork Thu Feb 14 02:10: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: 158289 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793932jaa; Wed, 13 Feb 2019 18:10:47 -0800 (PST) X-Received: by 2002:a0c:d947:: with SMTP id t7mr1036972qvj.49.1550110246953; Wed, 13 Feb 2019 18:10:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110246; cv=none; d=google.com; s=arc-20160816; b=g9eXfG2RJWBAxtJP0yhMiR7tsxK8Mlb+637yhrXPk8MrSnpSzowWtktBWMWd2Pu1WO 8n+RhJpoGclow+PSi7uE5hNbH+2hCyN7rk9mnx07th6erXj5+7igBTI0RbXN1iVGyivX a2yNnQN3KoBour4mcEl+ANnU3V3X2wpJ3sLXlqcabf7IajDF25GqnHddpNMFf0G/dRPQ /5RwJiCmvCI2iMBXViotNdxxBsCLO9KrVw2dF5GIPOqzQJDfSzc2U+83J6h1VbRpwtBu 6mS4PCv5H/mIjZanhymGvFpf0tDjpXeXPz1L/8Tj+JXCDLeJqpc8QraxhffhewShCMDN dRXg== 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=jLDDMh8mbtyjFJlS9fZ6SY8AbHHHwpMNEiboomCNhu8miQjTDRHHH4stsAcZjJjErp 3ps69+saFvRYfmkJ9Zc2+GqeC6gNsiDjmjECkToyoFTL3sZED+QqZ4Usz9rdx1JJNqIu kJ0YlSFRCoLOvv7W5vHG5jFcMiNkIDbZu+rszOVLa3t0elHWmXbU5Ko3G8oVBLwKmBEd UPQc0zeu05NL0OnPvY1TQIfPBcmJdnjiEXlSlPkZeFZrfkxUDSqOaK7ojeBDYS3SLbiv 2fXoeIaiYkrI9WHxNcjI5rZTS7fYz3qLddVDFYnoBHimWxeTnsKKMZEeMk3z/0uNuq10 i25Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bT3kHfdd; 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 t17sor1282076qtn.22.2019.02.13.18.10.46 for (Google Transport Security); Wed, 13 Feb 2019 18:10: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=bT3kHfdd; 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=bT3kHfddWoHjrWDizCUVqCfJci9GhpLD5WdiKcPx9Y6Xh6xad5lgywK8s1mOg27y02 QotBuVnRS4fym+imfJ/3aIv9jA1z+WiYfT0k6Kw3FM0N16aQ1WlpQt0oIGr8fuo5ULh4 K2/4vkB77v7jLnFQj4sxAanlpa5QVZ5Ih2NCq5hOXpODH61LocWaDRHRurs00Kf3RR8S aZxMGLJgD8OjczBDYplKPCfkAe0fsCSFNLV3MFfiY9+hjg+AxUNeDM0jZuj3QZD2vPm6 Gh/P0w6VNVUH8s4ppUgnkZuKFSvLX66fiSdol/3PFrwvTeCyXB5aTTrjMmuwM/WOd8lu 5elQ== 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=JB2gk2CedPJadQMqskOmLrFYGYPGa2mcX5ruUm8qlZdmCK7YfEzIHJDhB6azStIxsr 6MuYWnrqGjeBRiXCrbvS1/FMkyLDGJZx8K6NCLZEDgGTnbkSgqUO5Wxoi+6tayZYYaeW ucT+8cPMOKvVwf/ynaZ1Vx5JEitVIw5qxLLIMi0cM42QZrfMWQHnJajEqMtSrQfTC/8t Kps3qisWno3D+iF6yilbVfR1gG/sAAM64f+ZuQTo9OsMbSTbPW3KGWABYiPAhSANGIlR o/q7kcxvaBj43/n0870XzWLp2M/+8O4WCtLHsDlAk7Mk/hyRgngtzOEjQINEArayRZt0 RmjQ== X-Gm-Message-State: AHQUAuYngIyYPuc/LbGcpv3F/3e8y7Q90yP9p7A0QFhTB0FY9BSImb9w ObO9YKCdeHAszBBGWLqAI5Wt07Gf X-Google-Smtp-Source: AHgI3IazptIldckFE+JpS4X8VLBIbLvw497vjBxkeyWoq09DUgmSPtkMKbQh84Uxc//yagtB+DHsxA== X-Received: by 2002:ac8:814:: with SMTP id u20mr1011078qth.313.1550110246693; Wed, 13 Feb 2019 18:10: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 d63sm1091575qka.22.2019.02.13.18.10.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10:46 -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.14 V2 16/17] ARM: ensure that processor vtables is not lost after boot Date: Wed, 13 Feb 2019 21:10:21 -0500 Message-Id: <20190214021022.5313-17-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-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 Thu Feb 14 02:10: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: 158290 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793949jaa; Wed, 13 Feb 2019 18:10:48 -0800 (PST) X-Received: by 2002:a0c:e751:: with SMTP id g17mr1044256qvn.160.1550110248312; Wed, 13 Feb 2019 18:10:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110248; cv=none; d=google.com; s=arc-20160816; b=J83KPFQm5UOGyUfwpyAH8+fhbSZbpYt3/jjraZ07bRP9tIohWuzl7w+cHYT2iLifsO /+si1oB2ce6wmYsAkRycnOemLElxS/ivZvL5IDBROuywGA0DNbQcHzNknhkZVQclkOSW cmugUGdmX4ND18Z220cHc4xBz++g3tSeym1ukhV4Y+9b++Nmi8RUW1A153ywrxD2g4fY 3o+JZClr/gcUA0e4N68Hvqzs4Ex3H5mOriEGxtpCHigXF1ITarvnQtaRZWoWEfJG3VcU yyxycYikE3M9Fi0ozFvmCYLHMXw7tEc53bfXVFZ/+ZdC6XrruaFu+fzKf3v1wEJvmDk7 mgOQ== 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=Yay8Ei4z+GaV9hI9l2UOpDtb8gsGsqc80XDPQCMUPLk9mbWgg6QcfczuVISNSunefG Ljfz78EGmDD/7frgI/iPnq6h5DTO5SHdMDcNyhsiZeho3wy5Q04Oes/vV9Tt+h4HTeqB wejqck2BkOimZRzZzNXLwfxSac9eyYPFGWjYcmE9NZLhU6+VLRTI72XmsNE1AfkgCrxM tFcEWPyz34rZcbNvx0xgS9MyJRoRuXsO3Ej1l11pSsyjN+1JE1D7G3SoCX/6P+KzXQls nz+LKgZzxsU8sM2C+197APfr+dzybq9GILwjZ28Om6jLLtceSviaROBMfl0z3i1Al0IW tkOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TUmqxXJ3; 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 z19sor1279535qti.20.2019.02.13.18.10.48 for (Google Transport Security); Wed, 13 Feb 2019 18:10:48 -0800 (PST) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TUmqxXJ3; 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=TUmqxXJ3ic22OfhEe89ZDRixUCnlvjj9uB5CneITxJzkkMRs4WQJb72VlX96SnADhP VTB2pHS0k0VrzNbJ7NecCcw5rLmo7jkFZRwzJimwbIRLJl2JzmXmG8mHtxbI3Hs3lKVj x0Kr2EK1MrrrxyR4tumbtse4V110OGsowoYFJSivydgnmPQLPQHAHuXcM9nDmtTmeJCE V9hOmEexPi2D2xMW5MBKQvah2oQRMMgRYFkjWpILEKE8wRbimcDYjzJSxWMZvLIoqcrL BYhm701/zHf+FaO2fUGdcFVKYR3zbgk2FPE98KatEzZ5cbJkeNOnp1N2z9IFznpLXwQq y5Lg== 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=P2Xp4ZruttiEYmupcYWxq7scp76cHs7eE1SixZKS3GGS8LliK5pUP6WSLofLk7Iot7 DXtZF+CDij6PUscdrY0+erY7vmYV78M335mKrnE1QpI5HACL3EKwYEcSzIPjPJzdcbrr 4BXAGXCyrcJU/ruPjgHwLZrykbL2GohQBs7d3HPxUpWV3BY5wHQ1kr86fCCVFei5Jk/Z tr/ocTHJrARrYDuVdnrtW4tg2ecJlD2xPzZX0xOiXVAvJgfMJ8ELkjzSOPpqgK6Ewr4/ 4Gk8HLZY1ztWd9MI0NHlMLPn2KU5RWXp09W2Xv6Od/1UwOxo1krTbvYUjCdz/StNLule mzOw== X-Gm-Message-State: AHQUAuYLO0k5/ElIh/j6Mcztt9/MmL8XYuCvXEUxJgNQKRYArWL3Pa4p Shl3KtTlzLIhlY6bC0HBac8HTY6d X-Google-Smtp-Source: AHgI3IZCqQEjW8+70aks9hLHT5DqKugLFWu2fQpvtcz0+1TLoEgwjoykFxfZCRsuGgFtLTftI4KRhg== X-Received: by 2002:ac8:27ba:: with SMTP id w55mr1061465qtw.228.1550110248059; Wed, 13 Feb 2019 18:10:48 -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 d63sm1091575qka.22.2019.02.13.18.10.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10: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.14 V2 17/17] ARM: fix the cockup in the previous patch Date: Wed, 13 Feb 2019 21:10:22 -0500 Message-Id: <20190214021022.5313-18-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-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