Received: by 10.213.65.68 with SMTP id h4csp711703imn; Fri, 6 Apr 2018 07:40:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx48FFWnyYsrqlww/8SYiW0Yn8OreQRXL/F0rWjXbQU7NQJxWSkBLIwsUbZv8BcWfH6jTwNvT X-Received: by 10.98.178.29 with SMTP id x29mr20958326pfe.44.1523025647721; Fri, 06 Apr 2018 07:40:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523025647; cv=none; d=google.com; s=arc-20160816; b=nwOQRkdlmdLPMtPEnaQKOyGYiOI5tFnOe4gX3FrkvE+S2oAX3r+ORrV5L1DTLUGIFa ci2AVVU5RKEgUwd/xIqaWrEcOg4RaR6wxWQZ679BoZUmUt8N8gZkjdFiIq0fiTnjINz8 7WpI1O2Y8PeuQrvfTiN/orktEqO/NKVtc0LbyJBlZU7+p/4alWM1mwK8LB3AzMX3Lo48 4ziamyeGnJrV+UMnHnzHm87VIptyFL0PBl7XU8wZHzpq8AECuzwoDnbyO8mBekRkYlKZ w04llgKp8uMeMo6P26lZ5RJm61TBXp3hnGelcTbu4btWSz3u0qP8416qfVrHZ4QuE+y4 2hiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=h4x0jl+KW5fV+pSvcD3AZ0eFghVJL4f52rKjljU3q/w=; b=MGhzR0dW206l/ploUKHDejzMVJkNhel862ydSfnvid+8CJMrFDGGiKLFPIW+lufck1 kBPlXgYGo/GG/OccLLI4Oz82g2bgkXetv0dv5qlQqg/H0Xe1yUxnaOJOMxb30CuhLZSl IkB6jZslLYo5OKg+oWU4UekiF+iuxESLJobyKLNFRjQDcRJ7qfjwHwI2vjCto4rhCPGe 0ZPzrzj3LFS4fIoqUBJr5zlG5oGhnBfzhIek0GFl5ob12Whd5fp8u2yDNRsW793IwPi3 Ojm28SEFl8b6uxgTjO3B8V8DYcbccEs+EN/sU28NdPgJbscJbD9uR+pZQ6UtIrqJ4wMn Mmmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d25-v6si10933252plj.13.2018.04.06.07.40.33; Fri, 06 Apr 2018 07:40:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755935AbeDFNe4 (ORCPT + 99 others); Fri, 6 Apr 2018 09:34:56 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58510 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753046AbeDFNeu (ORCPT ); Fri, 6 Apr 2018 09:34:50 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 90BB5D85; Fri, 6 Apr 2018 13:34:49 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Ard Biesheuvel , Mark Rutland , Will Deacon , Laura Abbott , Catalin Marinas , James Morse , Greg Hackmann , Alex Shi Subject: [PATCH 4.9 055/102] arm64: factor out entry stack manipulation Date: Fri, 6 Apr 2018 15:23:36 +0200 Message-Id: <20180406084339.366053303@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084331.507038179@linuxfoundation.org> References: <20180406084331.507038179@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Rutland commit b11e5759bfac upstream. In subsequent patches, we will detect stack overflow in our exception entry code, by verifying the SP after it has been decremented to make space for the exception regs. This verification code is small, and we can minimize its impact by placing it directly in the vectors. To avoid redundant modification of the SP, we also need to move the initial decrement of the SP into the vectors. As a preparatory step, this patch introduces kernel_ventry, which performs this decrement, and updates the entry code accordingly. Subsequent patches will fold SP verification into kernel_ventry. There should be no functional change as a result of this patch. Signed-off-by: Ard Biesheuvel [Mark: turn into prep patch, expand commit msg] Signed-off-by: Mark Rutland Reviewed-by: Will Deacon Tested-by: Laura Abbott Cc: Catalin Marinas Cc: James Morse Signed-off-by: Alex Shi [v4.9 backport] Signed-off-by: Mark Rutland [v4.9 backport] Tested-by: Will Deacon Tested-by: Greg Hackmann Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/entry.S | 51 +++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 23 deletions(-) --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -68,8 +68,13 @@ #define BAD_FIQ 2 #define BAD_ERROR 3 - .macro kernel_entry, el, regsize = 64 + .macro kernel_ventry label + .align 7 sub sp, sp, #S_FRAME_SIZE + b \label + .endm + + .macro kernel_entry, el, regsize = 64 .if \regsize == 32 mov w0, w0 // zero upper 32 bits of x0 .endif @@ -257,31 +262,31 @@ tsk .req x28 // current thread_info .align 11 ENTRY(vectors) - ventry el1_sync_invalid // Synchronous EL1t - ventry el1_irq_invalid // IRQ EL1t - ventry el1_fiq_invalid // FIQ EL1t - ventry el1_error_invalid // Error EL1t - - ventry el1_sync // Synchronous EL1h - ventry el1_irq // IRQ EL1h - ventry el1_fiq_invalid // FIQ EL1h - ventry el1_error_invalid // Error EL1h - - ventry el0_sync // Synchronous 64-bit EL0 - ventry el0_irq // IRQ 64-bit EL0 - ventry el0_fiq_invalid // FIQ 64-bit EL0 - ventry el0_error_invalid // Error 64-bit EL0 + kernel_ventry el1_sync_invalid // Synchronous EL1t + kernel_ventry el1_irq_invalid // IRQ EL1t + kernel_ventry el1_fiq_invalid // FIQ EL1t + kernel_ventry el1_error_invalid // Error EL1t + + kernel_ventry el1_sync // Synchronous EL1h + kernel_ventry el1_irq // IRQ EL1h + kernel_ventry el1_fiq_invalid // FIQ EL1h + kernel_ventry el1_error_invalid // Error EL1h + + kernel_ventry el0_sync // Synchronous 64-bit EL0 + kernel_ventry el0_irq // IRQ 64-bit EL0 + kernel_ventry el0_fiq_invalid // FIQ 64-bit EL0 + kernel_ventry el0_error_invalid // Error 64-bit EL0 #ifdef CONFIG_COMPAT - ventry el0_sync_compat // Synchronous 32-bit EL0 - ventry el0_irq_compat // IRQ 32-bit EL0 - ventry el0_fiq_invalid_compat // FIQ 32-bit EL0 - ventry el0_error_invalid_compat // Error 32-bit EL0 + kernel_ventry el0_sync_compat // Synchronous 32-bit EL0 + kernel_ventry el0_irq_compat // IRQ 32-bit EL0 + kernel_ventry el0_fiq_invalid_compat // FIQ 32-bit EL0 + kernel_ventry el0_error_invalid_compat // Error 32-bit EL0 #else - ventry el0_sync_invalid // Synchronous 32-bit EL0 - ventry el0_irq_invalid // IRQ 32-bit EL0 - ventry el0_fiq_invalid // FIQ 32-bit EL0 - ventry el0_error_invalid // Error 32-bit EL0 + kernel_ventry el0_sync_invalid // Synchronous 32-bit EL0 + kernel_ventry el0_irq_invalid // IRQ 32-bit EL0 + kernel_ventry el0_fiq_invalid // FIQ 32-bit EL0 + kernel_ventry el0_error_invalid // Error 32-bit EL0 #endif END(vectors)