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: 65005 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1232467lbc; Mon, 4 Apr 2016 07:54:42 -0700 (PDT) X-Received: by 10.98.86.157 with SMTP id h29mr21374736pfj.105.1459781682056; Mon, 04 Apr 2016 07:54:42 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id g29si3153936pfj.135.2016.04.04.07.54.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Apr 2016 07:54:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org 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-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:4010:c04:0:0:0:22b listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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+patch=linaro.org@lists.infradead.org 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(-) -- 2.5.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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