Received: by 10.223.185.116 with SMTP id b49csp67673wrg; Thu, 15 Feb 2018 16:43:38 -0800 (PST) X-Google-Smtp-Source: AH8x2273VxSfM7frzGWfPsxD9lsSG9/IEfLYQcYRTo3SLOvse8ZP8nWbtNxslsHVeSAoSyRevv6l X-Received: by 2002:a17:902:7297:: with SMTP id d23-v6mr4139774pll.417.1518741818156; Thu, 15 Feb 2018 16:43:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518741818; cv=none; d=google.com; s=arc-20160816; b=PUfZRq0oGf1LYZ7iRAH4tJLgOGDmrZlkrLN+UizYhefkh4nT05AkqUwZ1K8QN+fkea W+0+DsnnymbVcrd+2sE5GPwaP411ly+SdlNYIFQymg4FH6WytwzvbPyUI57N9hxXbmrZ yn87d11X4YnnoAGNHZ18xkADSs0DxvMMypbT+cFvmIaWgHYL4+xTznNqaWGkNPvWQ6Vv TGfPnyyJ9p6zKZ1I2YHhtFAFbKaXMve+jwRPckjuo3rFhUTAXUImn1hlGt77/+SsXl0P wvCWlVNUt/t7fu09g0181VEKrl2jeeQtVjyvOdiz+zDO+qPqmuDPYdwBUEG9NCWw8Dej 92Gw== 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=n/OtUdmAywOZ574eIQq3Aehza9bbgtLtI2gnGa7714k=; b=rXps02VoV5EF+U/y4dlRcce9qzyIQZj93Uz/et0hiMoOClnKIk7oq+uZ42Ux0/+1VO Ddv3e1lP5emgZikaDcJ01LTc8IpTSp0ndX77SwY0FoptAO9snd2AFW/ZeMRUJeHFKWza xVpRRSmOozSexyRfDYXVpSwB7zvZJWbDynnTUTg/NM1L5max88ud50Ho8mrC8ztNy+iq YL34jTeCRIYuyeQ5FPrhU1/Zzrb9+coJDjt+UiDLaolaLgkwZXOFJoaPVj7mEhcidXYd AL8oHH8NcuGT/pzS2kNoxi+M/pnAXCcYhrLWwt3ifRI6ZYQkY5+IQ9z+ygVLBgwP+UZ2 MJbw== 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 u18si1975568pge.232.2018.02.15.16.43.23; Thu, 15 Feb 2018 16:43:38 -0800 (PST) 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 S1423602AbeBOPjs (ORCPT + 99 others); Thu, 15 Feb 2018 10:39:48 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:59862 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423370AbeBOPjp (ORCPT ); Thu, 15 Feb 2018 10:39:45 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E69471133; Thu, 15 Feb 2018 15:39:44 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Laura Abbott , Shanker Donthineni , Will Deacon Subject: [PATCH 4.15 027/202] [Variant 3/Meltdown] arm64: entry: Hook up entry trampoline to exception vectors Date: Thu, 15 Feb 2018 16:15:27 +0100 Message-Id: <20180215151714.347148508@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@linuxfoundation.org> User-Agent: quilt/0.65 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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Will Deacon Commit 4bf3286d29f3 upstream. Hook up the entry trampoline to our exception vectors so that all exceptions from and returns to EL0 go via the trampoline, which swizzles the vector base register accordingly. Transitioning to and from the kernel clobbers x30, so we use tpidrro_el0 and far_el1 as scratch registers for native tasks. Reviewed-by: Mark Rutland Tested-by: Laura Abbott Tested-by: Shanker Donthineni Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/entry.S | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -73,6 +73,17 @@ .macro kernel_ventry, el, label, regsize = 64 .align 7 +#ifdef CONFIG_UNMAP_KERNEL_AT_EL0 + .if \el == 0 + .if \regsize == 64 + mrs x30, tpidrro_el0 + msr tpidrro_el0, xzr + .else + mov x30, xzr + .endif + .endif +#endif + sub sp, sp, #S_FRAME_SIZE #ifdef CONFIG_VMAP_STACK /* @@ -119,6 +130,11 @@ b el\()\el\()_\label .endm + .macro tramp_alias, dst, sym + mov_q \dst, TRAMP_VALIAS + add \dst, \dst, #(\sym - .entry.tramp.text) + .endm + .macro kernel_entry, el, regsize = 64 .if \regsize == 32 mov w0, w0 // zero upper 32 bits of x0 @@ -271,18 +287,20 @@ alternative_else_nop_endif .if \el == 0 ldr x23, [sp, #S_SP] // load return stack pointer msr sp_el0, x23 + tst x22, #PSR_MODE32_BIT // native task? + b.eq 3f + #ifdef CONFIG_ARM64_ERRATUM_845719 alternative_if ARM64_WORKAROUND_845719 - tbz x22, #4, 1f #ifdef CONFIG_PID_IN_CONTEXTIDR mrs x29, contextidr_el1 msr contextidr_el1, x29 #else msr contextidr_el1, xzr #endif -1: alternative_else_nop_endif #endif +3: .endif msr elr_el1, x21 // set up the return data @@ -304,7 +322,22 @@ alternative_else_nop_endif ldp x28, x29, [sp, #16 * 14] ldr lr, [sp, #S_LR] add sp, sp, #S_FRAME_SIZE // restore sp - eret // return to kernel + +#ifndef CONFIG_UNMAP_KERNEL_AT_EL0 + eret +#else + .if \el == 0 + bne 4f + msr far_el1, x30 + tramp_alias x30, tramp_exit_native + br x30 +4: + tramp_alias x30, tramp_exit_compat + br x30 + .else + eret + .endif +#endif .endm .macro irq_stack_entry