From patchwork Thu Jan 10 17:51:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155245 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2175981jaa; Thu, 10 Jan 2019 09:51:54 -0800 (PST) X-Received: by 2002:ac8:4258:: with SMTP id r24mr10808498qtm.213.1547142714606; Thu, 10 Jan 2019 09:51:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142714; cv=none; d=google.com; s=arc-20160816; b=hCDihWUshiV7wNx+FuqUrpyK7EibfjcczksBSecz+dWRV31Jb0a1uTMyMqU3msjT24 90aT9hk8LrhWE149QjtbKo6UM118GWIlRMBxRYyYgF2QStXTAK/ka0FYRSjjTnP07E0o hGHWkT5Od43M7IwFhPOWQOIFGmEbNt5kT8Vp6qAWFs2o3BJxQuK4xYbZuQKzv0xy2jZP fbldVSkzSZdIxLxML4Cmr2veKzaOd00wM6fa8X9eOgHYHUHCO0slI1QMI3TbjzB99Ipr sjTojoGj/z/MWKybnbCkh+VMuzaJ1lZYNR87cBKOhx86QsIa+EduW0q9VFTpwGvPq4Zy QlOQ== 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=lm06b5DnPFl6WUPd6gP7nA38VSjPWciHgOrlaMdIKVwqEbiqi5c9ZxSTGgsABvQcCS SDN+me+aS2LLhlvLHkQgUVjzYxCI08Bwc+68RZk3OleUpBX2iUSR2xAO4X2N9qSxPH+A KwHrEBG5H5YOXo8mmnbxrIad2r2ZUVu11xMzktGgQM8N4dT/LEjZWTFzRC0YufzdkSHP 2yzE35LiFGF45luBfIqS4wkCUwrRcOgysSJYAGUdSlyfjcHpo9TNg7PDrbVUQeHwEPPl rJA702reoE+omfByM8fgetz9wJHK3rjvnwK41EmATlANDmLaWdaM4MMU7Ynom+SAiNc5 2yFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UzrGXbEs; 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 v66sor9690667qkh.138.2019.01.10.09.51.54 for (Google Transport Security); Thu, 10 Jan 2019 09:51:54 -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=UzrGXbEs; 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=UzrGXbEsoP6BDF2X1AalBLgV2YrTfRwhfEkZuMvbAwfa8H8w2zxWzlvfCsjPg8jp4L iw06xvImEdYEJk7gHOGqQJhegQdSWfDV9x9sTiBoJaCldpkxJQrrXSx6t81kWeW9xueS ETA0a2T822wtIwhNVAG6SEH1xY1Ybm2Pcwajw= 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=UzSi9koFbgPi5NLG6ZfnsLb6gpdTR5/Pznc+f/o3mSF7hckI/rvwIEG3NwQYL/KQ+Y siJoLFyX2XLnZljL9qC1NHfqslWoaDWoPhylBYKrUIf6iEty6++cOeEs4ArwinuDc2SB zv/7QqpRL4TxAlh2soLcy64vaRO1Tz7BkND5IIIgFdRtZqqRjme+uJtqBis1wBIZnNq7 BNEqQNX5508nbEmIZ+7T75E0q1qeVOtSk2UJ+D41M8yPM2q6iLhUnD3PnhvnoCduELO/ oQOU5xrkDYWNr9YxQbrzoNgTyj8uG/Zaqbx0rEc7XBvh51OqslgvO9Oy68ajsTBaC5QK JXHQ== X-Gm-Message-State: AJcUukdC5wmhjvp3qX2b8wnmOsTjPp/ZFQhmo/zzx0zVOuAVxPSY6pTf ftCM3hoC/mohqSM/tT1opM7YVpQ4 X-Google-Smtp-Source: ALg8bN4Fkl6ODTP/UhBFyFBnXhDxaAfj70cvw18D/M4Sysygrd4/ne1C+7fiL37RqTjK+1r1JPGf4w== X-Received: by 2002:a37:9c57:: with SMTP id f84mr10025110qke.176.1547142714110; Thu, 10 Jan 2019 09:51:54 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id b8sm41815904qka.79.2019.01.10.09.51.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:51:53 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 01/17] ARM: 8789/1: signal: copy registers using __copy_to_user() Date: Thu, 10 Jan 2019 12:51:34 -0500 Message-Id: <20190110175150.5239-2-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155246 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176001jaa; Thu, 10 Jan 2019 09:51:55 -0800 (PST) X-Received: by 2002:ae9:d8c2:: with SMTP id u185mr9720058qkf.107.1547142715662; Thu, 10 Jan 2019 09:51:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142715; cv=none; d=google.com; s=arc-20160816; b=yBbIf1JY2JaZcx29o9A6DpHkTDKgbt+wb27QzwUEh8zbKCKGBQSv3ed5ySfWAFy1hA VdUMrYks3q3WqzR8RleRzkhOZXqw1+77o4HBYu7o2dPfsRL0jMftC3jU7O7j1N6KyeNl sRsXzz2ONdjsIgTS3PCIcS2RKJSY6GbUUXAT1HobX1IyPVyfspuIs9VcfE0XwYzjmLWp pQRiyoX+I7yDdH/Ue+9fUJHK+F6JRSSfWb4CaxyhxrsMqF4Ap7IkMAsLAdRv/rdtOVCR J0fL2lly/uEH2BWidqN/zK4O3ntXfbawg/BPfQlxJaAMgCOLEQzH65YCZg4g7e2hbpA6 SRGw== 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=k2kpogJm+kzsaurb36SPfNWnAFajsG4dEo5FMhFBPl70MQIikSgX5YCx+4rqzfjHAM xzCEgyRjt6L24PjM7XAgq3KRsFIijuGoi8s2TwwJYG38duWARUXlkDNsSqGWtE5zFRv1 JFld08julluYZ1CIM+wrdOqkHJG0/Jt0v16X5g7Jupse8rAuCjiDkUbZPI/nGwWgO0oK zVWHtGpuPVbalrPNbrQf0f026Z+gfSB/v6ErNkSCa8ErwcBSxeFUQnJdQ5ZqEYlqsQmE nV9Koss64H/kYotWZJX/otDRUwY3ETRQnEFIo23pk73G1qkxUBtYo4RR1UZwDPtlVbB/ bHIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XoxxG6nI; 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 d10sor67387488qvn.64.2019.01.10.09.51.55 for (Google Transport Security); Thu, 10 Jan 2019 09:51:55 -0800 (PST) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XoxxG6nI; 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=XoxxG6nIkXzy5QuWXVubom4W8yRZ7hlnyFU2dEJ92pcz6crO26BV8Qil9G6EPL9U4e 7Y/ZCCM8TaGb+Y3TtIL6+IyVcm2asy6mn/NuerX3p51yj9nq9ZDYDe5/5C394iRuUTsp 7yj6AaX96rcawCb3VL17v340YPLTVWRWLfocY= 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=b2hkdh74AjjSnnN5e71770nJwr3sF+mE7sIvh7GO33DoyhAvChOXYwkWNK3tBmXDj5 gTBLxZ8RydnC8fNQlYLjfsVUPpNH+eIjVF4VRAhSrBOFt3K7DyyzabrFY8MDL5x3OETh YoGrle7n70+hNYY+xkZGtFCHNPN/m0rmXh09X2Tj684RsXuGxOhSF6TNlgSuVMHY0LCf n+KWIYr8JU8EMM/+ClUX/Y49B6LQ9d4nTNyQNbkFZFtaLqrCC7L+v3pwJHlsiHlQ4vUg AKieZtlhXThshKN0Ti+g167Zh1hZzEZCGOW/eaPjWCaxTaaoQHvCK8hfrp546BjGmLCW Nw0g== X-Gm-Message-State: AJcUukdfOsKdSAnGQxlTfN8qD5u697X+iWieB59qKAswYzH3SkYpWDRD xlURiCu47l2npca+hRcVjv/K8K6l X-Google-Smtp-Source: ALg8bN5fm7v1MtKixcl+8vLZVkwxRNJ2XAMHpZiZzP9iGYAS9AYiBk3+DprARd+bOFR8AllabA0Yvg== X-Received: by 2002:a0c:bb82:: with SMTP id i2mr10600208qvg.159.1547142715346; Thu, 10 Jan 2019 09:51:55 -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 b8sm41815904qka.79.2019.01.10.09.51.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:51:54 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 02/17] ARM: 8790/1: signal: always use __copy_to_user to save iwmmxt context Date: Thu, 10 Jan 2019 12:51:35 -0500 Message-Id: <20190110175150.5239-3-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155247 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176020jaa; Thu, 10 Jan 2019 09:51:57 -0800 (PST) X-Received: by 2002:aed:2cc4:: with SMTP id g62mr10483137qtd.192.1547142717010; Thu, 10 Jan 2019 09:51:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142717; cv=none; d=google.com; s=arc-20160816; b=OXSV8QmjFOsTiQ9TAHbbp0Qlm1/YfNQSnmKqqAbSLaY4caShkndv7+nkpfWgUbf2qZ seVKN9W8AIuQk8PE04qBPFUlMI8hcBSlcaGT2dD9HX4cbxAbgLJR4qgnow7B0vkWfKAX 1D4CJpUKXOH9YGjheBH7Eh/PVZkOsDEju8KGVGrGX/7p6a+i3D2QNnYM0DL59l1RO4kQ FK5JcwJ05SZlHqRff3H9dJQ41cev91MdOlxDvugr2lkCy3X7SnhYQCKz6UlYYNY7bo05 s/v48ZDcI3eQdf3GvgSPfVl2nWxbMAcICzrECaNjOw40xZOkrua/GzaroQ1WKbdgYsbD iSgQ== 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=WgOHYK3l+0OE/b/Dv+SoLY6DHeBQZP46T21l4pUj3ISbJaNToOsKeIGTLHOTyftAL0 adKEZKbsPVIni0wKyrr0JUDZZU9ILykxvMKlL2/lTSawJkNGxWwq82uZWjWWAR0PXaul Shig5nwWII1tC2lRjAcvqjeewdG0wo0141aN1g40Wsg/xXQiU0V5k5QDBuuugEu+Dw/6 dMjEdFN9B6kN+fuFFE6lZ94D0phaTQpxWIZ5hzVPa0VJWT84R4HGCmQ6KG+E38LtPxbh YyX97U77NXs/mjWqM9AoSuGfwtprsZRj6VqmkHT5Mq5L0cLHlHSYx7gHqHic+dB5EQZ8 Pt7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iO5B4qK5; 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 f64sor75193204qtb.41.2019.01.10.09.51.56 for (Google Transport Security); Thu, 10 Jan 2019 09:51:56 -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=iO5B4qK5; 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=iO5B4qK5c4cEgpkYlHlzEeknhl6K2Ct9hrjHX84IN9+T6q8RyO12BUDqBLjAE2eG3v T44Haw/ATYzHFPwj3jf/pIizueHLkRkjxoNzFLnw3l0PB3htySXWVtwypMv4YNg600Dj CkEgHhUDwWEtCfmYXAlTJgY6fb+FmTEHz3sRQ= 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=PRjoTk18q5F3kiRu1GY8aUmTnXEtw+OW87TzG8aJgWdjViVQH8fQPTk7gRn9CFt3a5 i5NJffvtYUkSp1WPeqR8V6yVzQ3JOdISjR1lO1YtoWgVEQwJqFeaZrRGopqprSOwyb9i mawlPSDP7mpLubit8VpS7NJQnF4yLdHpgej92Nm9Kac9s0a7IhZ/UO+t0UgU9SR49hQ5 2hTC0mUnjamsu99AoEaGcRdG4jLN+6TPIW5RkEJrLVzDhVj1ZMmhmTWzZoScckpsEb74 t5ge6xY4t81t2OWCOcVCD2xGyD5M/CZvK+W0zSIJrk5WooshyBDAphSnQvsZ26WBDcey Bc6w== X-Gm-Message-State: AJcUukeZQ8WtR441bUCJS3j81RIRiLd58U6DMkKVGpkMOi2DvTTcwRls ximgzzXFoyzcXfOcVnPsm5cpyq7G X-Google-Smtp-Source: ALg8bN4iCIly1RjudhxZ/Dsiplww/iEhpXxzUZNP0MsfxVtxR6wufdnUThIPC0w0yCIfiotzR89zqA== X-Received: by 2002:ac8:30ac:: with SMTP id v41mr10501410qta.51.1547142716725; Thu, 10 Jan 2019 09:51:56 -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 b8sm41815904qka.79.2019.01.10.09.51.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:51:56 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 03/17] ARM: 8791/1: vfp: use __copy_to_user() when saving VFP state Date: Thu, 10 Jan 2019 12:51:36 -0500 Message-Id: <20190110175150.5239-4-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155248 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176054jaa; Thu, 10 Jan 2019 09:51:58 -0800 (PST) X-Received: by 2002:ac8:2e6a:: with SMTP id s39mr10757693qta.355.1547142718447; Thu, 10 Jan 2019 09:51:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142718; cv=none; d=google.com; s=arc-20160816; b=ew8cEXK0oapXKjAeO2EFg4bSjnHaDuJcdsEOmlLxK8xmNZrzs6R9kjchfGTjl9kOw+ X+nhBxOMGr2kWtEXBkab6QWkZaKuorzfePOQp2F7oq38E8ip3BEaO3Hy8rraBsPzlZQv rzEvqs87cQLtFlRtJHDLm3osJfsNqYD5cXLUhrRcNYWo3wl1n8HgVjUwPkDcfojskXuz 3Rqcv/cApQQOoWsV327PkNQ6nIR9ZeCxmaymO/PnqbAtKgHAciEAVR9TDjJYtM1ijJiP apEreY75g/chR1XrZJIGYtLuHEtdx/qm6q7Zyf/os+iA5q1KwvOKOn1Xs3xPwfIlYFad LGvg== 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=AZDw2pmI7JioxZU/pGMpAYGhshBu+j/6NPsRoa+q5+uKE0FI0es7xPRld9Epy/lJsU 5+xAGVhU9Kv673brebgis5+vMUqgUcGNrLaUicg9Tpn+UFqC7stYDx1tbf/GZS2i2wK1 Br3Y4trSvkuaqTR7jiMCoEZSkKbE4fxi2JyJIB3BLSiva+DhDz1E7qVIJ/fnlvijkRDC dmw5jiCyS/Rsl/wBkL9hqOSDhdZUwUP/eViRc8G3dqvXzzk2P8Yhg+iIge1pNSQgoxds O9wwqwynFHzPgR7vyURAf1RLN2kQzxyyvfTHw9hD3kz96nxVkd3NfXfIg+URYcvosnZr 3i5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Ie1a5r/O"; 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 q17sor72426665qtc.32.2019.01.10.09.51.58 for (Google Transport Security); Thu, 10 Jan 2019 09:51:58 -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="Ie1a5r/O"; 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=Ie1a5r/O0ICRueF8TfCawjsPDMX2IlNYdg8hq5n3FB38u1hmc3s/00N6umkySrF1jF GuFoTESfgJumiymAkU5WqXQRJ5ZlfXIMcYkb2W+KNr+kixWaMsLMcjcZjDinjAnVfTYF CI4EBt5nfCTpzwE67luXQuJmOESssk839uop0= 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=VT+cM56hifhivkJLUHSf0csPlBMxqPYaYQHQ15LPcZN6bGJs8ZTo992mY2G5cBNdJt qYqAoUvD3Il1XkkXfZF5kxAbUz2t6jZf4KFDfE4IdpMDsIsUKq0e79DbfAOJvLplD0hg kT3tBKQrzpfUZnJpfBMS1ixWjO1gxW/JQYNOzaimZ6gFwxM3faQkyeoKUms+z94qMSit 0KPVbnTG0TTsKIVPI13oecb/VGg4XIOt0uhC5pMxMbQWT19tJC6qzEFi0yOouhpUAGx/ JSR+9KsFLt8xdLdLQBB8BeaC7SP0ZSFXGH5GORp6AqmHEfeD2K0+oATEqNuYiW3llg6m pItQ== X-Gm-Message-State: AJcUukfMvsmzGJl/fyKzWiOo3J+Ph7Z14+Xj3Uqo2+1S2bAzHjOuH68a Ff6mDEnhgcewvGT4qp0ADV73f6gc X-Google-Smtp-Source: ALg8bN4Vk8foP957aG89chLyi3lmG4EYGCpBn5F4aH2fNirX+txN+w0PXN/zchdWyEdwDRBbbG/ecg== X-Received: by 2002:aed:2151:: with SMTP id 75mr10935832qtc.24.1547142718219; Thu, 10 Jan 2019 09:51:58 -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 b8sm41815904qka.79.2019.01.10.09.51.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:51:57 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 04/17] ARM: 8792/1: oabi-compat: copy oabi events using __copy_to_user() Date: Thu, 10 Jan 2019 12:51:37 -0500 Message-Id: <20190110175150.5239-5-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155249 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176079jaa; Thu, 10 Jan 2019 09:51:59 -0800 (PST) X-Received: by 2002:ac8:3181:: with SMTP id h1mr10864757qte.14.1547142719857; Thu, 10 Jan 2019 09:51:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142719; cv=none; d=google.com; s=arc-20160816; b=sjP18ZJwiP8MEAtUM6VpKRJcs1M8q0BMHS7NINcB18R8/cd3jRqvk5ztDrVKWjnM36 eascuZ/c0eDuZrZcgMjBwJETB0ES+coWEgPIzWFgsgyvPl+jtFDIWPzgrQsdpon913rn GEJnYk0Srg4uZryMX0zNDNC5itqUmYaa5nSAf7gm+jqZKwwirBy8aapqm7w0ujkp2Gi/ YtE+OmXTlGO3dTUJI2wBRDo2rIKc1GTij+jbVzmkKw5ElJ8WNoZz1QGnNX8mCoT7a0nd nLq95Kvce8VLZRKmNnjydFKpzaA+666/s5a9+AdCKt4O5fBokUOl3PDWn1yFSHEPcrCC ApmQ== 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=iqoUd3BBVgCCCPNDsO3ruGIEt1zyphecuUW2uxCBAmZlJRp5HqDP2GIyC91jYazyaq +2Pg80FNsaOmtGyjBplo4Y9fmt3NHSpPuDiF9Qq4ICvcWsUJOCLeVqsCMSpjbd5xUQbv vDAGl7RjzQ2UfZTUnLkJ3XTJpqdnuuE3m7ppHN4OAywLQjTWGHBczCNsRNv/UWUY3TZJ BgmmnPTH/e8DHx3jlPgFLtpPjjwyms/ykEAX7HQKwTGCM494jNWuhkYGas+ZSIKPwk+T V6+tqaAj5OMQjEW7Mxx4Uy6pAlsUzbqLToFpZWAbNgKb+2q3G6vewDjJwsI/hZioV1IN n0xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PUvu36DD; 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 n15sor36453174qki.24.2019.01.10.09.51.59 for (Google Transport Security); Thu, 10 Jan 2019 09:51:59 -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=PUvu36DD; 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=PUvu36DDKBuL+/xwzoBPyg+6kly8Cr9YAaqC8cBU18AxTlfO3Be66HIAl3xmziMwKU 0f44MXEUq7YmmbYghlifzFaqDpYJDHLsJEfTNJGpFlA1AmHPQYtKT7zk0FJkh+bojPv0 gV5y1QuMJyR+25G3oHNxbhj7y6TDI063rcdOU= 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=clYehhujpGvLucqHJr6An99BYt4CkDg1FQVmqQ6tF4v9Q0E0m8/6h3hkcDurmVc4vu t+1SlXcotlzFol36WlFRtYix5KIyRhYXryZI0d5FO0G8I/33kDMwcxpeNzswjcvsfet8 cxynl5GAyDM4IEmjFtC+lQ2RNPT+t4/pQ5zfJ6P0GmNKUPiqRz782rYgBxUQK8B3r97A PPBFw9sDSb1MWCDL6NdgTgeWe7a4uk09bsaJVo5h/vuTo2IiLl3bXTCH+LfyF9pr6zXV o3coFH93ZE1b7gd+bGbhxexhM2d4oFG9JsfrnGq7/Qmgkqc8Z618RGuuegWkjOBd7vSx vWAQ== X-Gm-Message-State: AJcUukeEVCEJQMqxiNcS+RONppNaEtNNwjLKk8fqDZ4X4n2UnF3BNQuz piC8u9QBFRe5Nl3aoctethHz7V+22Z+b8w== X-Google-Smtp-Source: ALg8bN4HECsOcvGxqD/klkc+uE7HEmyR/u07jY+2uUrF5/Fgiq6h9tTpTRLCXloGF6W8gXzBQ3c+SA== X-Received: by 2002:a37:7d05:: with SMTP id y5mr9641634qkc.310.1547142719619; Thu, 10 Jan 2019 09:51:59 -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 b8sm41815904qka.79.2019.01.10.09.51.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:51:58 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 05/17] ARM: 8793/1: signal: replace __put_user_error with __put_user Date: Thu, 10 Jan 2019 12:51:38 -0500 Message-Id: <20190110175150.5239-6-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155250 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176099jaa; Thu, 10 Jan 2019 09:52:01 -0800 (PST) X-Received: by 2002:ae9:dfc7:: with SMTP id t190mr9739407qkf.43.1547142721528; Thu, 10 Jan 2019 09:52:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142721; cv=none; d=google.com; s=arc-20160816; b=L3yahRTNaeJJa7IB4IPlR2YPOS1qKyOSkoTDqxnZ1w51nD1Rc1SU+ctISGQLjd1qFP jdYJm8vjm/LooWnREZtf9+uCEZP+oU/2kYrJMTN6AkIryu4dF88BaQ/cClINYTP2Y5nC LVdPTxLGUP/53Cv+WO9pZV5UipU7Nz/nLnI4vGg0ghLXoehWPSNUtk4sXDNboDqLuG1c sZLeYzAVaSqGRV8eN5j3K0mWyHeWtUolJGcpXCHRN215CL5ERHn7sEbLl4/SJEd27/YG whsSGEQEO5O+ocMiQsU8G6++sYO8ZFImcbftQzFeM9PtIMoa9Q80jU0Brd959qFZ5wpY oGJg== 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=qrHZkVWoKChiFIdlqRUiNAn9cILSX+ErbPl5MZefwUvIaR5WUaKMEzdtki2Q9BGTtV erwbaePOfFXFubrP1slv1mcnfrPsv+KG2ji3khl+reLBgMvAUnC/LTtgidlF63go3n0N jPmHRi+XMQ1h7KwBRDaBwTWfRSndiLbiJUv20czTl1BVPwHtU469onWvtYktKfgIBElm Eap45dcW/pvXvEb5ee95gchuJgN9URraouuY42W+OyG1hKOtl4hdGN4O28718BmS+nj5 KBqGbXxgFM1pKzN3pdUb0Y4SHIOlkvG1qMyrfXttWKPx/coJBJmDvnPTK95k2+H5QDqv B4cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MdjX6xpI; 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 k18sor67701928qvm.14.2019.01.10.09.52.01 for (Google Transport Security); Thu, 10 Jan 2019 09:52:01 -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=MdjX6xpI; 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=MdjX6xpIGP1iEyzIL4h+6OjyUFUzScmNRQb1WbwVJ6aOg6Xye+66YrBdM8u5tnT4VQ SrzCJMU6eH/jEhIfQEXrQ78TSlDp/CYp6FfEU6DDXrmFzUZYjeJWhECd+hbrjy5X7o0W p+WZq++ciOEGXMBCar7ZAjljSLc1b0ru6Fb40= 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=epOIrF7G0S97PrJWiCErmD6l2eiDiKuhhb7enr3gwJDOx8KH1vvi7c6BdX2wm2syhB zRPR3CpMTQk9T7Hf+Ygs5nhtp1m6Ckufr8Jl0xKi3pi0sp/GNRCzvJkstMJ+JQ4lngR/ /0Q6GreTlBCDzf5nNNz92Z9UgWJnwPaojNiP9BK9r6GpBbqG1c9ggyIemV3452pXck58 NEugTxIQGAl5BKJ5IxNFPJNYGaVjKHaSkkRIWk5tlxW9iOVeLAYnmqMEi7gZ3BOB9kPi WK6yITKZyGz6IbM8QMhUZrrWU9jqczMTqUtBpd/j0vMlAP9a4H5YfjIEUUjAlcYJ1gT6 Qhbw== X-Gm-Message-State: AJcUukfiIpfPJvQF+oG5obz3WDoCvbA09B0sF79rRazBqwPYAjlCm9h0 5IYa67SS49nZ2+eCuwrSqUWdobOe X-Google-Smtp-Source: ALg8bN7TjTLGNkajmfmOrVprL0m/k+WGLGwyM4ZTwT3sKkxg+w2oyZiwZtOxJ/HACjXjFCHQg1lkXQ== X-Received: by 2002:ad4:510f:: with SMTP id g15mr10969603qvp.46.1547142721287; Thu, 10 Jan 2019 09:52:01 -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 b8sm41815904qka.79.2019.01.10.09.51.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:52:00 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 06/17] ARM: 8794/1: uaccess: Prevent speculative use of the current addr_limit Date: Thu, 10 Jan 2019 12:51:39 -0500 Message-Id: <20190110175150.5239-7-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155251 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176131jaa; Thu, 10 Jan 2019 09:52:03 -0800 (PST) X-Received: by 2002:ac8:3ae5:: with SMTP id x92mr10937298qte.370.1547142723070; Thu, 10 Jan 2019 09:52:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142723; cv=none; d=google.com; s=arc-20160816; b=m05rAgbhViV1hnjmTg5N+273MvoQVLMKjENnIM8ohg+LIj94q5I3UW0580vkYBBugy WnJhoYHrDxVt6MasCWPHz6sZTYsmnRZCsYxFTVnBvTKlj4gUlzOIsFvTQC/JXQYpOIEw bJwyUU5iu88+VjJ+zlP1dnO5E5njBTxvjmDGjUK6gm5FVqULRiFkD4zmPWsLwFVKqUSZ eOPyzVe0NRzaTsyQcU23mUz4RUrhRHTBaQNWq6v55KmN3+Q2u7/RG7qC/20zIf8w7R7P 6IoKAdz05zSkshqfcBC2twaSRkfiKGKYSoLMfzChS9MbZSnkoVxjyRZw+MO6WDaudBp6 Lf/A== 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=Wm3kmpHCnVNqQwFNXbmGk2/DSHdmShvRtkl+8DC2407h31JbpAbdDzBuDmPEBZoktD pzavkmPezaBYEzX5lvpkoAPPNXOY9Znxm7qJ3f+gU3xxYQaZJgNxbNvUaQ1qoBv32gJX 2Gk9NxU3qYUBnt7ngg3+0Mj+RIu72PNB2jciSSSp4Vk5o+C5o2RPJgGr/NDqF8VGjyiQ Qb/QZXTqtZCk1IdelXOsPPEWdYGGxcSy5QboVCjiQWQhfWWnbfKoJ2kL+86V+PsS4hb+ keYs8RECTyX5zf86tCNxzGZtsXkfzMdRM/Vgz+q79TBDjDfhFZZqo4cIW2HUeVAVycwP 4y5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V7CT7YZV; 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 m34sor71819247qtc.65.2019.01.10.09.52.03 for (Google Transport Security); Thu, 10 Jan 2019 09:52:03 -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=V7CT7YZV; 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=V7CT7YZVqJwT7KawAlSte1rU4wkBeTBI45PKWaYqng+i+5CJnWwFUqTCq6Re/emZoA Hq3thIUPjwiW+cyQT+XIJ6PLVPfBJAOyWntt0ANyEkS+jm72EuGjCGySpyH5iDVsYPyJ A1kClvbOhApBH485aAhAcGJDxZeaiFIYoRHJY= 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=MSK/W8CTtxT+fpb+H7hjQwCWlTmMi5Qv3drzHcLoxZ0nvvcpMUPHrMo8PQyHFLXSEo j4zCTf2eEvGFYVN+HByF+oCh6PekXbb0nxMbSdMH5ro2bnu98Mu1tSlW5CI2avBaFCwa j13ksP3rif0zasaGFQGHTAjuCmHL+6gACX7mQG4qIQFxB6wugDzXtcajiF/L3TCvIDSL vnqDLpFbsZ7UnC6D5tIyaK/ZjwdDMlW25kXbTPrWRIBUwrJRjZ7HTVTc+DWoqcBPoX+F 9c3uLUTu+T1ZBNRhL/d8rungZH2dG1JCMei7DWZH5ghGTZ9O+cjIBAlHT2whTjxwds91 iSzA== X-Gm-Message-State: AJcUukf3hvqtpzzfkgcsbi70svzFCfXamDp4LGdODyihIv4f85u9QnAc 9znSxNle2g/BdmV8j6z3OAMZZ4oo X-Google-Smtp-Source: ALg8bN6+iw0fnRKxN9HLxu4TQyua5G2QNN647vrgOU7B6RWgK2LXomJOGSMRJczeD4Szvhy2O6vbIA== X-Received: by 2002:ac8:2281:: with SMTP id f1mr10541942qta.197.1547142722843; Thu, 10 Jan 2019 09:52:02 -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 b8sm41815904qka.79.2019.01.10.09.52.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:52:01 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 07/17] ARM: 8795/1: spectre-v1.1: use put_user() for __put_user() Date: Thu, 10 Jan 2019 12:51:40 -0500 Message-Id: <20190110175150.5239-8-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155252 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176165jaa; Thu, 10 Jan 2019 09:52:04 -0800 (PST) X-Received: by 2002:a0c:9384:: with SMTP id f4mr10943982qvf.239.1547142724760; Thu, 10 Jan 2019 09:52:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142724; cv=none; d=google.com; s=arc-20160816; b=DAJg1S37dGTdAEFgDv7jTvpQgDXbSUuW7pLorbGxhsgQsna36ESkuUySrZmsRyXE5Y oTch/EVRWqpjgkqGhfclUz0Qqi1Cw8AU3VEKeRbpliZsf5cWLldZSbGf3M2uxv6+0h3F E2v1xw2t+moKnLhNb272fb935Gv7kSFIkYixT1awWq0/VKFdRm9R8MQI6tLaB4z3SU0j 7nzwyzy1fyH5uEuHYV7O481sH2ZRfxWOfub9IihPpLUvvn1p8L5uSODpl5a/qi4oIg1l KXNy/PavqqV+j+jba55t8dpdSvP1tyBFtUR7uOX/xBjHSGdGATmIehzAG9/RZVX48XKx AYJQ== 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=ecAZkUNX28N1x5+obl+y6dBzEfxYA98XwsNKQOK+Ykir8gA1+TWbfl9Amwp0E8CH7G UVnycJxv2jWUaPg/H0hvJfmJXjOYP2mVmW2KUzJYGHNktUzmQQSMpEt8wdEhEMVskini jJ05SKal9t9Rw+fOvP22Et6b94ZJMdd8OJGo9r2hW/3YRDzI2epvOTL9ZILWsZabuHCk SqIHBvAu5jOp2j194Nq6XMBRPSmlQvM9DtZodtXAItQ3js85NUAQEgUMkFCNDtMS9kp/ ARCaYmc/Qt/ixBj4mWHbsmWArW0VuI4GvIzU0pQLHOzjzJbo/SDlAIlkhhClfdNI7yE3 EwUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ccXudGro; 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 y29sor67619829qvc.49.2019.01.10.09.52.04 for (Google Transport Security); Thu, 10 Jan 2019 09:52:04 -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=ccXudGro; 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=ccXudGroi2GQcoI9rK03mo+Q9Ktafwd6ciQ3lohK2nFSQUXMgEwxtxiM5lk4owrlRq AnpTk4wuefjZPeL+9iE/wuB1yRBjWMQNghxB8Fjg8xDvKP55nTyLGaFSIGJvjSUqpdqG KnTAaEhTRVfoiRNl41QuYThpLlho6E9pKrILs= 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=AaJ9Cbg6u4r/ZGp2K4uTSYA9pYAUgRY77o+j+LEfKOyIz8q3npYh/yvmfbbzr/WUG+ PiHFOzzdhsTnJKw2JuC1U2vnqUBiWtfqwSCpBp0GnrdPQOYXXy9//DU25epJ+oCj2diF vJLKOmOWPh0wUno0gvD3ljPgTLBfJecacaRavZxxGDWGaQx40CJ9HgLqmvi/2UVytK4S cJVx1zHNMknFvrO3SXB7pMcHRnul4GkLhKMv5OHyIf2yW+tp8qjh7nS+eW24gI/rtPo2 OnrcSX6fAr+SshQzm5kN//MQj7Nz9z1qD2Lw1lRSUJeB1tIporAFIpXHvbijBfEYrGaW ujtQ== X-Gm-Message-State: AJcUukfL6gZHtOtUMhVh8zCG2KFZ2iOgkifcobyfpz8p6PW1E6MEZpi2 g6XLDrgyiAz91u4AbdpU5XrANxTP X-Google-Smtp-Source: ALg8bN63ztSATNuB271lxdGZmmZ5SCqyS2k3AqKJyr/9ig2yjoK8xiGGuwQtI2meqg7DkjEJtrw8WQ== X-Received: by 2002:a0c:bb82:: with SMTP id i2mr10600704qvg.159.1547142724500; Thu, 10 Jan 2019 09:52:04 -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 b8sm41815904qka.79.2019.01.10.09.52.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:52:03 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 08/17] ARM: 8796/1: spectre-v1, v1.1: provide helpers for address sanitization Date: Thu, 10 Jan 2019 12:51:41 -0500 Message-Id: <20190110175150.5239-9-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155253 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176206jaa; Thu, 10 Jan 2019 09:52:06 -0800 (PST) X-Received: by 2002:a37:b201:: with SMTP id b1mr9791554qkf.306.1547142726113; Thu, 10 Jan 2019 09:52:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142726; cv=none; d=google.com; s=arc-20160816; b=rmbZ+B8iv8t0NL9hy+pv4X6Dfq3SLpIxpaC9Irllokj+xeqlJDo2CpUK/HNDuOxqpk NgspIr5GKjnnSP8BHhWtpTniZti0P+sx0jh/Y2H/icih2ea+KCbKaAPz9Uwkxly+1F1d oJ0QpQgTPOHCIPfFkhZrc8aPVdPyeSil62LeabVT2SwpGP5I1pbvuZH+20gX60kxYG47 e2gVSZQ7fOW7/fby4r5uFgmosod57YlvVFJZOPX5tAouxA6Hn6dVo0Mc5pvNnJI9mfNn 30ix8oF502w5Y8kdBn3bf1tz8Sw7gKNnSZPATdo9OI3V+swa4cqcNsGpglDhWOm0j45W J98A== 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=NVFd7ayxu2DZHx3GP62gvmybY9/EXCo2HUipgUo+RzIN2cD20BY3m0VfefpAsN4nrG EhUYwAzENEmT4GOQ7yGNpylCHIa/nHHVYiMQ3Un0X9uXNK6V6xLZEmfO3QHZOE4GBeHz IKailYw/EW2ezmYjgPV+WFZlV6g1784hGBQ/9zFqFsJpPR4BTiLTUv7/vHNt32GQqzx4 PqDEvMnb1VR5WQemcPV5OXqd1JfR9gmPwPvgqTIjNoVm4jvJaWxCbj2enQduDm3yPtb/ ac1p/7sM47WvLB9Q++YdY0RgNd8tugAyvoF+q/A/z0MLYenSzqzfQJPEBXItFNhW+BQL VJcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WUCZy8f1; 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 b127sor36321137qkc.48.2019.01.10.09.52.06 for (Google Transport Security); Thu, 10 Jan 2019 09:52:06 -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=WUCZy8f1; 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=WUCZy8f1BSH+sPmVcr2/btSvnRLljKRpk9Tb3KBEV2FJPHpI5PUSJUuwxe7ry6pmH1 NAfK8E8BmGT661BZuVyoExpieMepiivnOr9BaBgv5oJfKLzlPijLrPEIDZ5T6oC+Dbl1 wPt901JSvYAc8VwJ3Tpd1ha+4f994qEljFrXA= 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=LTqSEp+It57mZMtGql3iK9iVSmadpgT+0u/3vwF48U1U9+PBWqQ6wci9nIM4vJZIGM 2ryLr/kGTtj3ZEku04rsvZX0EEqEa5a1y9J92HUu0ZU5Fm3JV/BKrZpQnWMt0I9pGplQ x0q53n5R65caXIhP5zZvL5cHaL5FHCG3KKjXZx/knPZzlBeCcdZP/3p0je1vAz8Xay9v 8Ly+aBk7xA8rewA1XYoUQWf4jbqF7l2wMAJOjo4ahSgc6S4e1RKnv22ayloij+gs2K9p MS8aREOdk1Hj9VHU/gaquVGOOUVmG3JExm7uo0866fEXBGaQXi035iI0zVHzX9LQmZKM qvjA== X-Gm-Message-State: AJcUukce+SFZ9iArx4NYCbmFoqJc1R7I6VALIrrmubhfodTBVwgWe3Lj KA4UW1NGR48l87X2AW5Suk0RIufk X-Google-Smtp-Source: ALg8bN7bBCLkIpWTKRwRun7BQUsTE1uldGzdL8es1VHOPni3i42f/pzpZV6++odKjsklWxjcKe/slw== X-Received: by 2002:a37:4145:: with SMTP id o66mr9823783qka.129.1547142725868; Thu, 10 Jan 2019 09:52:05 -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 b8sm41815904qka.79.2019.01.10.09.52.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:52:05 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 09/17] ARM: 8797/1: spectre-v1.1: harden __copy_to_user Date: Thu, 10 Jan 2019 12:51:42 -0500 Message-Id: <20190110175150.5239-10-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155254 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176255jaa; Thu, 10 Jan 2019 09:52:08 -0800 (PST) X-Received: by 2002:a37:80c2:: with SMTP id b185mr10034250qkd.8.1547142728098; Thu, 10 Jan 2019 09:52:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142728; cv=none; d=google.com; s=arc-20160816; b=DFOr6U6OZim38RHICmFlOopZT0k1AIGpFnUVJkeBdJbn+X6zKuvsR8XgZzIZnKVPh1 72aGwUpDTirdL3FrdCQAnq8xWqD5FBVnwoy9RWgSnWh6V1JzXNw58FxhvC93Ay5t6/3Y zXDfDmDYHy+NUY9mFp8snLhrSgh4KZearUE61MUrtv3xER4aEQnqAlsjcsdms0IxfX4e d8t+dMcgw5EK/Ez4QOjnkB+Txr12N5kW32D8AygPgOxKb8mRkbXzkH6CZiN2Q2MfNIRo VIDS5jTKIhtKJNJzal8KBqrxHN/7sj4zRRMDlGS4d+DRGs+61ZFk+j2LqFRv86+dwOeP cMvg== 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=ldck7bYlsBpl8glE+HLscowqMryihp0qJP4SUooQj+nBMbcJaBpBl+ieD/Mup6yx7v l2OjLCBLeKQT4YL9YzJMbXYIUcm42OUySlu6RwoszhHLv35WFh7ldztKkifNdAJJXW2P fRDStXQCtIOQY3e3lZIemQvY6r60CzSnO4rCw/QcJnk3dJn1UWr/rIm0a8J89Web7t6X yYo01b+RmZbhJsaY7oL9PWwZ84Bhwy9nhTIKdzouthIexKjY12/1YBGiAdb8eGmtKrgx 45UW+flh+GOjFB3aAWjbCPKfRK4avdIgusUzi8vmjJu15UqO4MiWX4PVnMul5Jc27czJ gWcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q6w+70Qn; 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 8sor71710514qto.36.2019.01.10.09.52.08 for (Google Transport Security); Thu, 10 Jan 2019 09:52:08 -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=Q6w+70Qn; 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=Q6w+70Qnw+iwVXLPK0BUq2DNA5qVOdJeRLFa6hOZ70GT7vX5+CP41y9/EnC93QwF84 Bn8aaVEJooN+bmoleSFrb9cdsn0aG53YkwyBL7H5j8u6fNZPYddvQgoLGUJDZHXTAz45 eSVoSbvYTrLPFFJ/HyVaaPYGusrcsyGLdVPtI= 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=qNPibVkbUYzFEuUbOXTA5bnEOvy3f5mRK1EY1B3E2CCpLnQZzzbmusLlorTe9InjEu lMPGBgyydlffUheu4QdaecMd63fPrYU4Jg2iPbP2OcoZgVDlcPTiJ0ApYQS1W8QvncP9 N3Iee9WJM6knfcLd8+pGEIBK1RInbYWR/wh3iLulJJaBOL4DPnLDcMMnGUe2bLGpf7IF yc2nzsiNrnOl1Ai+lnYAkhoPPfAKu+T15iCdVdad1+qeiau5w4NS0aDgUFqWSi7i5J4r uiBhtTaYOS5KPoWV67MUanm6cM/DnSbtx50r6dF+tYKmggmkQ9iJblsOP/QJbdU/mtbd TBGQ== X-Gm-Message-State: AJcUukeOp3LEcJkBIdFcNdKO5W7yFsvwU6eXZ4b3OzKH8HuCCzWucV53 dSeh2tEPFyo4xEi6Gt0idfuN2KWN X-Google-Smtp-Source: ALg8bN6Ia2YWB8vTdBtnURUwxhv53c7saZdrz9kpftobSMKmpGJMt5iLwzeGEJVGRf6eh1qO9Y8jAQ== X-Received: by 2002:ac8:6a06:: with SMTP id t6mr10579112qtr.330.1547142727836; Thu, 10 Jan 2019 09:52:07 -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 b8sm41815904qka.79.2019.01.10.09.52.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:52:06 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 10/17] ARM: 8810/1: vfp: Fix wrong assignement to ufp_exc Date: Thu, 10 Jan 2019 12:51:43 -0500 Message-Id: <20190110175150.5239-11-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155255 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176284jaa; Thu, 10 Jan 2019 09:52:09 -0800 (PST) X-Received: by 2002:a0c:f648:: with SMTP id s8mr10807672qvm.122.1547142729514; Thu, 10 Jan 2019 09:52:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142729; cv=none; d=google.com; s=arc-20160816; b=lRIvR+RCKfjiWZvR42urwuvwIKRE0tjrA4Fvrc41M1UVWY+1me7wCKOQWLhHyw7FoF Zs2NJmDWFC0S8SU58aGDTZVM6Je0YvhW3X07wG+Vd/T5WHl+iRGiDe7pHf+oUWRX1zcF 0RcKLirxxt8TWcvW6UYlY7R5feP2WDWUsbFltmhsnxM89vOstq8pL8W6pWjsHR1n13RT vlbNQP/B0/Xm4KVPeSsm0kXdoRR7zUu/xkiN4Xd609WezFjaEc6VlFy5kUUQ0A1LdoNq RfihnspEELtgQDT85Le6SUWpfQRM3yvJX94mUWWtQqncWLCMbAv9B94tsBgAiXaeDgZ1 jI5A== 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=YBUwbEgJjlIz/Goppi79VPs+BF9sBtx0MSdXzg1tRwNAAYzEnjsx4lrm0qXxmpz6Pe avP1N/vKkt/AxDVO/HZY/vXxiXQeK3PdKTtNO5me/2nt5eV1xpkY3pskslYZ9QZTZPb4 aDaIF50tNCVyrhjB8awjrUirzjBsDTI0pF2Efyhd9QLI4vpG0V9zbltuXgxWoCyKzK9e OPqVMjkE015WluoXySfXwWJMAOOHBuGuS3/7+QSsGl63x0D9kEJc4vBuCJgm1Dhu7F53 hwK+AFEYFajlRbX88bkBX8GXL0I9xADg/K3QWXbQS6M8ii0gyaURAa7VFiBhaizSJNvx l5cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iOec7LlV; 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 41sor72302252qtw.64.2019.01.10.09.52.09 for (Google Transport Security); Thu, 10 Jan 2019 09:52:09 -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=iOec7LlV; 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=iOec7LlVtZKClR2PsZIWbsHBoAjm6XT6FYQ1cOM2SMVltWl6SfRoSUOayDdheerqXv e2OV2MYuLLDWk5Vu6R/W2TRM4XEnCgSIAO6BvOavE+P8fVZYCN6BqEL7u+aovaaE+gAH qIICSe1kOzB3zha3gfR7JK1bBH7TcgX4Bll/Y= 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=Oi+wzXQq9D1FI4cT5At17FUAg1dBWXLr0uvikoSgWzZ4SYro37PhNfQl90v9qByMPc pdv53FSZSBoZij5hE+kp0xVFrTqUlnoooqQeJe//hjZdntU7u9OcOLhTsOmdSOrcYYg1 o6GmBlae5IZpvP9PYzRGe1UBzvmbAkU7kPLK1BsZyH5W5cHKXgViJJj92Ov87TexmMZ7 kpoeiMgnVHnsjf+TTum2FY38Cdv0GN2Hu/SEvmZg5eBkww3AvcORh789z0kz5i4YBFjP t9GettSg+NTRf9+VVORjTmx78ElVR30uERTj2o4nupN116RC4UAsCaNu5EXS5PyRrRLm a1bA== X-Gm-Message-State: AJcUukemKyRgZKfrX0FMhs8lJo0fPLtMAL3R7Is3b2Pfm1mkHhtCTQi1 Ud8Vm3JrAB4ee5mVlHSkEo2eBjjK X-Google-Smtp-Source: ALg8bN79BC/bpyBzj6JwZtu80nsQKXs/nAeHwBMZuf+3KJpY+XmnPEPkkSc07TtqIlJGwE3wIv7ODg== X-Received: by 2002:aed:3907:: with SMTP id l7mr10776681qte.65.1547142729279; Thu, 10 Jan 2019 09:52:09 -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 b8sm41815904qka.79.2019.01.10.09.52.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:52:08 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 11/17] ARM: make lookup_processor_type() non-__init Date: Thu, 10 Jan 2019 12:51:44 -0500 Message-Id: <20190110175150.5239-12-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155257 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176309jaa; Thu, 10 Jan 2019 09:52:11 -0800 (PST) X-Received: by 2002:a0c:878d:: with SMTP id 13mr10730936qvj.8.1547142731134; Thu, 10 Jan 2019 09:52:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142731; cv=none; d=google.com; s=arc-20160816; b=g15Q9XKco32Y9nBVbWxqkq1Gm7A9Cxv6pe0HfscdIy3iCadoMdfFWHnjFsJ7Xfgt3e E4aNN/IzWBwyuqFKQ2EiRKEVU5983cBU4PLln9fT+UxdvJpe0TSvS964rx49iP31LMBj snzOzSURQRBJNcpjPNfWa+e74NnOxFgEMj5YLVbyNmKvK14NAUbVZugtv0dVi32hx93d /exaDgCuMLemViJZ3xgIbnFQPRvcddMBWpDZaziH8mib1hUwdX979jwHxRc1j8zEegrq SOlU7Ez9seYLWgrilnY3M64QZminpYG/yyWwTpVBYr7D6tonMua5Cv2nmnqd0Kyga3xX MaxA== 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=aqyWD7ScimSqPqYH3nzKxN00oesdODHOv51N7sh6j1TkKfpStVQhxFuf0gO++YzHNW lRNeGWQEL7ZzJ/WhF16JrPfbW7Qx4cvJOiA2d+FCrHHUFi9f2d/56yTDFgS9CN9LBcKh 8MFfSkMDaWuE83WzZ4vcLHus5aT257unOJXbrh8nFloo136rW8/aQQ76M5icGgQRBFAG DRWwYOrOeLk1e4H9/JkSnY9JnGQbONVybdDxPzVnUzJC7AfVwrLtQ5xX9PvU0O3ErU9o OWDlA9SEgzI8wiffh4NSr7o2hl/orD6sU5INUGmymbdATO7ysryw74GlCMwWBXtN1b5U uUfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BRuExwPb; 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 4sor72574690qtn.67.2019.01.10.09.52.11 for (Google Transport Security); Thu, 10 Jan 2019 09:52:11 -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=BRuExwPb; 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=BRuExwPb0a34jVDT0hKrNMf6pr+Qy62GGt2DcOyB/mU5RXUzZSjXItw/F09c/a+ooL X/BYlcmWGltbv62a+YfC0OJLHrH8sFNuMn9vTjorhAPvOcnl1b97qgKrTEHcNbf3Jya9 TxcpyXQwU0mCqQktlvIL1x70SxwgRq9ersgKs= 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=HtHFdssbrpPQ2uDfnZ/LkYnG7Zg5kNwVfDVNHPBZdxh81YovYe/9JnSWpfgvIoZVQl EDIEvJVmIl47sSoH0BI/qnlysHC8fLjKfGq6wC/RMSuaEr9N4BIQ9FdzD2VBMEQTlooY PHfc+vvOdEAPmqsTZ2TUrtD2AcuEct1uLI8Eu8svI/hYYzWpb4vLbRsudwB69O3uAwEN Z+YdPb6WvTP8n0CAVXAtq9t1HuBHa7s7W2eif9dlIVLzmiCXhu+AQnsh7D8RVrKfk1eM MqMWpy2hRFW7gFH7g15rBev31THDQvDPgBXM75YlVBZU6nmXOP3DxShtELenpjd9UxZN DWMA== X-Gm-Message-State: AJcUukfNbzZoumPzG4PPq00pICtibIDRr27+tyZUX6DU6m3adXXFREV8 9nOl/3f7VOzezxfSU4U4NcVsN19y X-Google-Smtp-Source: ALg8bN5WcYzSGWfy4mD2GrkPZtCkd+mT9zG7Bc3B1rp0KugbuBTV7VjOQyOtWWB+WlMOKnxpn97Ecg== X-Received: by 2002:ac8:72c1:: with SMTP id o1mr10578018qtp.220.1547142730878; Thu, 10 Jan 2019 09:52:10 -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 b8sm41815904qka.79.2019.01.10.09.52.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:52:09 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 12/17] ARM: split out processor lookup Date: Thu, 10 Jan 2019 12:51:45 -0500 Message-Id: <20190110175150.5239-13-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155256 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176332jaa; Thu, 10 Jan 2019 09:52:12 -0800 (PST) X-Received: by 2002:aed:24b7:: with SMTP id t52mr10779123qtc.131.1547142732611; Thu, 10 Jan 2019 09:52:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142732; cv=none; d=google.com; s=arc-20160816; b=RjyWmA6pwe3b59ddNZ7jERXQ8QtUV/lm6tJd8VLcFOJWuvizmqvnvaBkVUNAGEDo3F HME0I/Cs1XZFjdnuDH8b+vnB0uGIGx1FrCawE7WtcIx6AmMF+yMlXIWM6/batjBlyVP/ R0sJLarqoACUq4E0mNPzXF74ESKAzG06xPJiIy/Si36C3KyP+IVSVJIq4vKQI/QgOrWu Q/KNUKof4HHrACis3YOrw3BHnGOWLoapOoYUY4FK3wbvC0/xUePeUEXtj6u0yQsn0PVY BJs8eA+fUPzpxPiLGgSAPrzmVy+iCX3w4RRBkmpwMAfB1BND91tYXM+Ex9kHJDct+0fg p/fw== 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=IE5z7WkIGzOnWKYvNn6YYPWBYxxifh9dUK5GYsTxtTPwy5hTnoNrI38tHsPlqBkRvB nZEL9Rpxc4lIeQqUzQ+Rp+Uhi3IkZdu687V20cnHnF+RNtYq38sV/7cEVRRaaHMqtO5s ozS8Ps6Kgo+GNBykW/Lqxq5uNZ7qpJq6k07qWvWZNxirKjko29O1eg43hRuroyeqMMyv rL6fh5/NkkuffFzfVWI4oTASzVRfWosXRrDBxbmLizMmvOr8c9d1v0ZOEyKbgoJIMjkn 5naP9uPB4aONokxwNPhYaiJ81S4cNOBAhteHfgdkTZlJhu0WOXlPHvvSZUWsmAphqf5b UafA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PfpKYWGJ; 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 p126sor36657249qkd.106.2019.01.10.09.52.12 for (Google Transport Security); Thu, 10 Jan 2019 09:52:12 -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=PfpKYWGJ; 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=PfpKYWGJ4eIZstKw6WStQx39q+x5lfvvjnhDlJf1RtDdVNlVlsZJdz+Oo0CxZKLM8D Y1qxnPoczCvJ+BpwXOuExtG4dVFM4D8il1iP9AXOcnCvSM1WulxW+cpMqBjphQDiFQIO NwMfqWYEdIld2nDLyOahXBO0elYu2C5zdLl84= 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=PQrzj9X36IdeRCamdOMpJrSHnv4UNX12J/UfSPyJ3c5OIcUkt02CoKJgTmfRZFAApr 9GmF8Qa9CsimP/9R83GycQaMUSe6hLqIlCfDgGN3sJKEAuJ0n4DVK6d52S/owFkCrxU1 VlIutI7hK15e9yzsiMVUumH+SNyUfiiIpUCfYvS0KJzeyqt+A6JdC5xdlZHnAgiEBG3U SdwrpTpoC6KGMuGan6ENZIuuXKreUzhCO8GDzDDT0myAjAcKpuHV4A+c5q+0G1xajT9K PhN/SfTTTKR1oIKD4/dKaOmyTxYWqd06Uf6B3La3uBptC3MylzCpFcDzqFHVY3485SOq 0kew== X-Gm-Message-State: AJcUukdN5oK+zv5xNd44xniZcZcuMtAHXYywJ1+Bh6+MtZ5mBSdlT9K2 bh4j/jCTBjV7DKyRW06jo1oSuyuK X-Google-Smtp-Source: ALg8bN7xvQYniPdbpKztoOl2htQBof9f3rBnevIbzq7Ez5cUZmcV/6QlvpJgxwQARDp40SftShZttQ== X-Received: by 2002:a37:b942:: with SMTP id j63mr10289148qkf.67.1547142732369; Thu, 10 Jan 2019 09:52:12 -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 b8sm41815904qka.79.2019.01.10.09.52.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:52:11 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 13/17] ARM: clean up per-processor check_bugs method call Date: Thu, 10 Jan 2019 12:51:46 -0500 Message-Id: <20190110175150.5239-14-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155259 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176365jaa; Thu, 10 Jan 2019 09:52:14 -0800 (PST) X-Received: by 2002:a37:c597:: with SMTP id k23mr9940582qkl.87.1547142734197; Thu, 10 Jan 2019 09:52:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142734; cv=none; d=google.com; s=arc-20160816; b=KAi4aOpAk8WmPrqhSJE5LSjUZHDjfu41zIG3ajpycs5uCgfWo6EjAwjucts1VsxzO8 +Z+yJGnx/FYWzaFQQ8M7sNGUkWQiCgi67DMfotiP6bG+yZtLNBhn+m9b/MHFtqW52Q8q waeexzWOMxAkUSfqYBWYdqVkQwwKkMTRXZlCGUvjEuUuWFcLMNfsyDsrOmcLlXG4aRKT kpfcc4njRmR/s1Gs0bpFb1ZAN6YD/WOgItEbeebn1KftTNjI4NSasEzDRXExUDn5V9br vzIzUVrZQBH7ImkTQ3El2/1zS0lr0EPdxRZVci/2tNmRoQ5jS4JiBqSCWicqvqWU42i/ EhPQ== 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=PrnLQ4aefuSL/cFlEREa9p6aPlGEDOpIRkttZm5WcHEwohvlpKmunCfWvbXFlZvSgU svvMTmMold8KKJPnK5FMHK3SoPsX2mc5aRtNUauBeljbPvPtKcSiCsuCRTb8NZaV8yf0 pBiidHDP01kV+1UL1+WkdEHxbK2dwIxLhBuVPrca+ASM7RcFgr2lc5f4Sdhs+XjikBBE LwVqRju33UydNJiHd3HY+66X24TEZp4pcMFujMM1iJTKmTQSIK+COOUrZ3ccsfyHUasH UA6+A+At7bAbTcvHmq8k0ZaZm93uBjtvWWdhoA3O2+b4/G8GTyBrces8g4nC2Lfmmzvp MVSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JXtdP9T7; 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 s28sor72832402qtb.48.2019.01.10.09.52.14 for (Google Transport Security); Thu, 10 Jan 2019 09:52:14 -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=JXtdP9T7; 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=JXtdP9T7Cs3LhTdzDrY08i6vdUaF3gv43ZUkvzuWe0zFMT0kz9e3s4x6lJxO1UqhsK 6WBg8h5Sg4ItaPt4cvBJdNa8bUZUO4P1pDapBDdu69VHZWj98GxOTM0vJn34FuZR7QUj pDT0dvue7fm9vfi4sgML/WxVj/nUSB13x6SXM= 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=en7ZgiE+rXO/95O1ezynrWh06NXO1C6A9iStqZ7t/qIpIZ7HbqBfQhXQIaW22lt1t6 EJ2ICy2CV9VtZzd6sHVlRiKRwEZHHA+aYr+qZFEn3BgW006l+6yilUn6PSIcZ8GnTrzV BLegAMpt+Ny9MHKEeVyBVngyT4OJqDsWrzCS2wRWM+YFNfx2kz0Q4cXkQyiTcY4uLArZ 0rMa85i7c3/ux/vWsBSrD+mpEb+SkAcFoZq+Ea1VixZLzXNafP0YQlcMPS7B8DIPg6SO mswIHUMWLbeVlwXQ8biP0ih510ZSo1qwxIbxe1uQVhtSmV0950kg1G03gRUgM9lIgUTK oECA== X-Gm-Message-State: AJcUuke7uSD7aY6yHqN5Yt62B8tWdpns841nKWIGAt0XS7CJGr2Hi3r7 NwVb1n4CquX1wGvmOFPAaGo1vgJa X-Google-Smtp-Source: ALg8bN7cx7Us0e8TkRd3oRiSTaSWJbY0kHc+PLrLI8CIl2gA2jJYbp35S7iaN1cdU2rLA0KYwGWVbg== X-Received: by 2002:ac8:1b82:: with SMTP id z2mr10765974qtj.321.1547142733935; Thu, 10 Jan 2019 09:52:13 -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 b8sm41815904qka.79.2019.01.10.09.52.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:52:13 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 14/17] ARM: add PROC_VTABLE and PROC_TABLE macros Date: Thu, 10 Jan 2019 12:51:47 -0500 Message-Id: <20190110175150.5239-15-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155260 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176385jaa; Thu, 10 Jan 2019 09:52:15 -0800 (PST) X-Received: by 2002:ad4:42d1:: with SMTP id f17mr10772251qvr.59.1547142735576; Thu, 10 Jan 2019 09:52:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142735; cv=none; d=google.com; s=arc-20160816; b=X3b2edDFfGOTXNxzm+MGq2xhP5p85PNamzui97+YggptSo9HXPJk8P3KNbTgucOYyK XSFJ8/3/XFCi7uThQL3/z+kugHX83QBb/5Hh/2FX5jeTGRbd+bxiuyI/Z/QJnmKsUL9T cK2JMdlBoei/U0CwgxcQVD/63wIqox4VbGi28o3tLlxwp7BkZQniuAa7oyddWoHbmxDY ws3Ns6i/vd6ACrlrRCLLXrxM7SMBkHy9zqJofHHLHVBwxHPJ9eZqNHGKRwEImRTg9ati ixyUftJC3UxbOg57DEG4NFz9zuNlq+Pr/MAiSA4CpQb7t3G7RFTaryuea7JrfXnsAPCM 1q9g== 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=1hhaJXoC3+V1XgOExRQF6uRGWM6Y1bUSSamsFfUInZk=; b=VwxYamV+WQFpj6jM9UkMsTOdd2Zmr9pY/3yW2WdIr5dfCMw6QyQs7bU69FFaPq9ThU CWMPCQJ7ZzedunSdm2UFu5mYCGUT9ipGYL8+ztpu/WXMolPGbuNrSpmYf6/Y2jzCA7vV UWcdQOEghNSbrTbtrW3OHe+i9SHzViON0fg40lOpP0N4A2/nSXEaJsbtvpd1QTP2rAbS p+uTmqAD3rhOXP7rWVhFx0OS2/BHoZQ+m29TSePfpxWb3NO7iY5byVvBv1U6qHCqGMPu XiRkdEu92f8bOa4W5FWfaYr584NKxTvKBSLm5wi+o4H8sJ62CZYe2P8A4rxpRizGY0vY dcjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KTiuPXr4; 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 r12sor72057237qtc.26.2019.01.10.09.52.15 for (Google Transport Security); Thu, 10 Jan 2019 09:52:15 -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=KTiuPXr4; 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=1hhaJXoC3+V1XgOExRQF6uRGWM6Y1bUSSamsFfUInZk=; b=KTiuPXr4rGss9E3k887ZZSC/YbQBWvPyD9iVEyveD4U6du30y67CK1ssIfi/fjUya7 oopEDUAIo4fEe+BT8wwzb41hCN6iFQUb9V8KW3stGKusHoCXdaJk8g9GAInIAQjXUl8v EXjDryv3EezetdF+0hE8PtVNkK2ePm/JsF2FA= 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=1hhaJXoC3+V1XgOExRQF6uRGWM6Y1bUSSamsFfUInZk=; b=nkJfEx2uCPucXtOSlBeJADEwrjZJpTFSCoj05eY8zSGUSmB+xGqfwZFipnwnxGAX7k 4bluWvrlccWn8KVxvOet7cL7dfEUalaqE9xO1PnJ5gVrSKTXnhloZJC7VD29eL0GvH+2 u/yiW7ZSB7nsD0x97qtrDlB/ZRfHS5f8LcI7HEn9JEREr6wWOOK+luCPcf9hdITgTIE0 E8xX6XUUojnisLA1fbTLbDEn5JIug73j4Sz+bPTdDGASlYS7mj/5+iAKU7dDpmnqG0zZ 8huAHDMIXW5nmp2eiBl4bNsapXMmYcGHF+31ZWqzsfmJh+ZNfUy9phBSfhRktZlpLHt1 apTA== X-Gm-Message-State: AJcUukcKP9GheQwblfFP1LCSdNUxdfXTHsGoA8nONi5EiqQungtVQahe GMLw0Trg1wN7tyDKInY9GIr1TNgF X-Google-Smtp-Source: ALg8bN5E0p9ljd5BQiPaFxRlb9/mP9sWx1Y48+oD5LnBETzlvCeWzCN5cuZn35Aap1mJT1g4lJ1BYQ== X-Received: by 2002:ac8:75cc:: with SMTP id z12mr10420271qtq.249.1547142735265; Thu, 10 Jan 2019 09:52:15 -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 b8sm41815904qka.79.2019.01.10.09.52.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:52:14 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 15/17] ARM: spectre-v2: per-CPU vtables to work around big.Little systems Date: Thu, 10 Jan 2019 12:51:48 -0500 Message-Id: <20190110175150.5239-16-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 e61af0600133..f6b1c9d2e178 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 Jan 10 17:51:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155261 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176410jaa; Thu, 10 Jan 2019 09:52:16 -0800 (PST) X-Received: by 2002:ac8:3f5c:: with SMTP id w28mr10589912qtk.151.1547142736879; Thu, 10 Jan 2019 09:52:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142736; cv=none; d=google.com; s=arc-20160816; b=Ke0zUH757DwTw8dPbxNFw6K8Qcy647QJDQ3/q8kQ2foHSApxvmBlWXPRv+XazH9t1M 7u5giUjdmXim77U/nnp03Wy8pMusYzl12MUxLMkQ+XE5DqjS1znQd2U6M7PykJf1OQ+h hI45bLMjmgJRr/iF+cuDCM6ckaxxftSSyIRHwhvW7VoBBikEYtieznqrhqq9GklLCYqc M4COP1za06etC0iGzmonsCnyG6jZfJWCYVVIlzXBOgpqzkgxmHsffR6j4L3dyJ+1DMVl VZaqg8VVnjjyaGkFlYfGvOW+rKFkakuaLdf4ezVUurcAFr9WOzAPXsrhWUkb5bU1kPu1 BYmg== 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=DSlpPwdymaPcVoIYjYD+RfzGt6TFZ1O7+hNpXWq6ZzCL85nYMMrk5JYxLI7YAQYVTL fcFUOpnm895n/i5Ho4jiAsVWmWaaKvTSNPf7t2PZ6Gh9dCSJa+/eaHDPoa3bNMwvlg2i Tifh9LWZ82vaSQ0PuKUUlXegEA1YKLoRkcWEqaC1Bo17un8XAXX/ICmxJRKMBh8wdD2e y2nLQhUjVxmgorGWvh6yoXCSIBPisS4XVUhCrSVDyU0YqPTXelfjX0NyLeRN5qi3KTwt ldXqLadHZlZQH6Ouxab5VeuDDdeDULo+E4U8wrd+CK8ak/La48uD9CNYZqyIcrr+qJkt OcTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e5zAqn8F; 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 x20sor67083262qvj.36.2019.01.10.09.52.16 for (Google Transport Security); Thu, 10 Jan 2019 09:52:16 -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=e5zAqn8F; 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=e5zAqn8FwHcZKg1LC1tVPV7fhNt8tU9+cfuLDFrOAMll/bqWLEQPC+EuqBm8MbKYAh brJNsri0/RUkvWVnD9XM7y7dbAcUZaWX0ra2H7spljiB9wfhK3ZtcuN+npFaSGPpnFm/ 39hgPcUCnsaE6I3Re5kLsGWyhAaV8oxHO3cUY= 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=iJqlruzv9CycjncwgHDJxOemJ3VRQpF5eHBci6gxB9nu0AckQCnQZKcZ6gsjHtMMTQ 4hllfD+dv/tzqYnHkp/Th5gP7aEO/6LWWdEsprN4LaTEj4Vh9rSCT6zAJCh6bjSzPTYo cmD8mSTt57/kmQx9lMh9MwCLK0KvgNHOCFjvXDcFrTtNe1Ago13npQ9P5UynMeR8Izqv GFB35K1LetpkyvEr2LBRjd+4niU6GsFYrrktSxeAMp/oXWHfSNPPBNMqZ5C2CCfs13JA NCyDz6Ls78QE67ASbZSOtygDDk51+Ul+JtUXecAZUBfwUgZOl3SylLOYJIKXdrg13q83 ioBw== X-Gm-Message-State: AJcUukeYVLusJyvUV2mDgySo0QUwj6dvgW84ED6n6oMC9TD9DoXJob+1 IpS6pGaBPOeFiC5Cr/ip9ADThf8d X-Google-Smtp-Source: ALg8bN4hh5B70vBsTCbjL+oql5kQs5nTITZCmCYMvH6f8f/CBktsDKHEyLPKE0j/KdhZn3rAelGr3g== X-Received: by 2002:ad4:4391:: with SMTP id s17mr10830663qvr.32.1547142736635; Thu, 10 Jan 2019 09:52:16 -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 b8sm41815904qka.79.2019.01.10.09.52.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:52:15 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 16/17] ARM: ensure that processor vtables is not lost after boot Date: Thu, 10 Jan 2019 12:51:49 -0500 Message-Id: <20190110175150.5239-17-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 Jan 10 17:51:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155262 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176449jaa; Thu, 10 Jan 2019 09:52:18 -0800 (PST) X-Received: by 2002:ac8:73c4:: with SMTP id v4mr10367917qtp.157.1547142738347; Thu, 10 Jan 2019 09:52:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142738; cv=none; d=google.com; s=arc-20160816; b=O5hGKGigZhSTOgCEFfVIIu9IrIkRLJ/fRaT0MS6XROESwyJV8soEyclmjzzQrXaQAI OP1sfEyFUZkSOMWmw1XdZhm6eCVUz686wiN0RzszV4Ncoxox7PHj1fJ/ZlHcuPn8Aztj G8kQN3tBe/kclUsr/A2oQ3bOF8RBw07zboi1qV1XgYH4VLTb6DLEMC14RWGFj07Hq/nJ QIUF7ccMsKrQpfR7UGZcE4rBsALdvqoVuugR72tw7va48AO4hjcowgzPfqrnf1JUJk3g 4sNkzsK8UGgKLabNuLHY97t17OayiMgaKvwsSijZX7yqhI77lC0hckqhOZbhHdROj+Lb Ehlw== 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=PsKiniBbjO2AKuejxHoDrnr30F619Gk3dKo8AyPM/tk7SnKU4w8uiHTUT3zSok9Va/ nr/IhbqlfOGgYkNNW9lMzqEY7FZkP0d1XvAel2PXSok4k7eSAIlC6423dqmWZ10ICt6N f4X4C4Z2GiajJA2uugh/Ygvu1TKkwM9pQeu9Zye6fPEGaOsfft0RrF3MvX6ZtXTPRfEQ DNyG5Ge83b/e7V4d/aqoujslcnQdc72xSnW4WUD3DOXgaU5MUPBy/Muo8XwvMvDfNFQk 4kFHKio+RXza34C/v1Z5gH7rgF6vRGaeoZOTDLtpQ2Y0IobNjF4eLeNCotkrQnGL+j81 vmig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FccdvlDO; 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 l6sor9724404qkl.8.2019.01.10.09.52.18 for (Google Transport Security); Thu, 10 Jan 2019 09:52:18 -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=FccdvlDO; 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=FccdvlDOTVg9RB1rLSPiXfbypsLqvegncWloQntpCNFGDHQ2nx4bj2YDhjz8qS0KoI XDBlwoD8Y5M57Bx0mW5DKK7ci3K9r8otkyskZMlQoyu7haIqS3YCaXtmCcWX5MPRzvBh kUJaXJo7ohTrYWoj4LOu7puN7+S5ex010Nrz4= 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=pm9N2c0ARG0/hL7e4qX1I2pDANhrZA2/PlIjSmVWQesBGpEzcxblNwoJ1uDQqNX6hU zpNBYgpROyjsSCd3kPrrG36mcRpGo4glJFIuv2Bi+kO/jeSc+1LKTwAZdVjZ1rvk1ysf qitUbKIJI8i+HZUm+ivOQSpnbIOqoj4adMj05gNDTgXlwnJm7a5a3hAdk2sBynsplFXz d8d4arrVkGPYxcftAqZXJ85ZKt9+h9L0eqSbAHeMiUvaOJ4vP+xO9jQLP0tmAL+VosEH BRlZMEOkhaiZ4+4OsiuwXm/BQ80ThnkKZYnnlPlEHiqRAXfsrP9BxHTD9E13yMtuXgxe lP8g== X-Gm-Message-State: AJcUukdFeat0Q19jgVjUM9lYHdVXVRZXh8iBjJWHFb+gRgiAP6MDBjiy 3wRgaPAMrtdTUzzIAn6YKP4zBSy1 X-Google-Smtp-Source: ALg8bN5jhBCPrXkZlyjggkc2TYMHEpdBG+8MXNpmxkX7mlgHsGTIxBNwdZC4f8EJK1DgoNfOYDO95g== X-Received: by 2002:ae9:ee02:: with SMTP id i2mr9979811qkg.179.1547142738085; Thu, 10 Jan 2019 09:52:18 -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 b8sm41815904qka.79.2019.01.10.09.52.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:52:17 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 17/17] ARM: fix the cockup in the previous patch Date: Thu, 10 Jan 2019 12:51:50 -0500 Message-Id: <20190110175150.5239-18-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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