From patchwork Mon Apr 4 14:52:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 8741561 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CD125C0553 for ; Mon, 4 Apr 2016 14:55:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0298820114 for ; Mon, 4 Apr 2016 14:55:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0158020270 for ; Mon, 4 Apr 2016 14:55:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1an5sr-0005Si-HX; Mon, 04 Apr 2016 14:53:41 +0000 Received: from mail-lb0-x22b.google.com ([2a00:1450:4010:c04::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1an5sC-00056t-IS for linux-arm-kernel@lists.infradead.org; Mon, 04 Apr 2016 14:53:02 +0000 Received: by mail-lb0-x22b.google.com with SMTP id bc4so163625469lbc.2 for ; Mon, 04 Apr 2016 07:52:40 -0700 (PDT) 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=VzbhOTkFLxrEQ7quzYKevL3nymQNtF1BPCS/rQW6fm4=; b=XgH8pvORhCIkMa2jConJR0K6+8CtBn5bsFvhAfeZSoiKaa4O75oiuZHn0yR/EivMF4 k7qJr0sX/s/hYpv89o/0eX4I1qML8l0+ZetVSlNn67fLJUF36aLrInk3VHK6c74z8M2T LvqMXyjlcrOmME6+oat2qZRrW9UDIFszN99XU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VzbhOTkFLxrEQ7quzYKevL3nymQNtF1BPCS/rQW6fm4=; b=gGVsPJ9a8ulcB3Xt07e1d1cpEFKb49OVuidonG8eDfBJY8AF5d/5liMg0j2n+h2YYS wn8FD0OVJmr2lYmd/+tRaLVJag06rftKT0GmA8jJx2fhoYnOYzNs7hyQEqopECH1kqi+ jzFtCB1L3X/6E4qxGryfqCcB6hSmf9TUIXfVkM6DzivoxF2quG30DFLJcbyR9qugTxII zUxXbyNCEmEycov0q33TRebOmV5w2hEJnvn17J7lWgggTBJY/knDPQREnjZI6kv808MH HyVk81QQgpaSdif6flvpfPSMCCtevowdbm4NaUbwhZZDEHo8/NH4b4bz8h/h2YAueyZh jcGQ== X-Gm-Message-State: AD7BkJI/nERnk1VQ67JFXOtBT/RzB5hCHunDWyH+FpFmaSDFVisvgj1VMbehp8umojpmFs4q X-Received: by 10.28.90.68 with SMTP id o65mr12635454wmb.70.1459781556130; Mon, 04 Apr 2016 07:52:36 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id cf6sm7922528wjc.12.2016.04.04.07.52.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Apr 2016 07:52:35 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, catalin.marinas@arm.com, mark.rutland@arm.com Subject: [PATCH 3/8] arm64/kernel: use a proper stack frame in __mmap_switched() Date: Mon, 4 Apr 2016 16:52:19 +0200 Message-Id: <1459781544-14310-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459781544-14310-1-git-send-email-ard.biesheuvel@linaro.org> References: <1459781544-14310-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160404_075300_912016_8ACC6C9A X-CRM114-Status: GOOD ( 12.15 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Considering that we can expect stack accesses from the moment we assign VBAR_EL1, let's initialize the stack pointer first in __mmap_switched(), and set up a proper stack frame while we're at it. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/head.S | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 9d8f928c355c..f441fc73a7a2 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -421,9 +421,14 @@ kernel_img_size: /* * The following fragment of code is executed with the MMU enabled. */ - .set initial_sp, init_thread_union + THREAD_START_SP __mmap_switched: - mov x28, lr // preserve LR + adrp x4, init_thread_union + add sp, x4, #THREAD_SIZE + msr sp_el0, x4 // Save thread_info + + stp xzr, x30, [sp, #-16]! + mov x29, sp + adr_l x8, vectors // load VBAR_EL1 with virtual msr vbar_el1, x8 // vector table address isb @@ -475,16 +480,9 @@ __mmap_switched: dsb sy // with MMU off #endif - adr_l sp, initial_sp, x4 - mov x4, sp - and x4, x4, #~(THREAD_SIZE - 1) - msr sp_el0, x4 // Save thread_info - ldr_l x4, kimage_vaddr // Save the offset between sub x4, x4, x24 // the kernel virtual and str_l x4, kimage_voffset, x5 // physical mappings - - mov x29, #0 #ifdef CONFIG_KASAN bl kasan_early_init #endif @@ -494,8 +492,8 @@ __mmap_switched: bl kaslr_early_init // parse FDT for KASLR options cbz x0, 0f // KASLR disabled? just proceed mov x23, x0 // record KASLR offset - ret x28 // we must enable KASLR, return - // to __enable_mmu() + ldp x29, x30, [sp], #16 // we must enable KASLR, return + ret // to __enable_mmu() 0: #endif b start_kernel