From patchwork Wed Aug 24 14:36:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 74620 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp352057qga; Wed, 24 Aug 2016 07:40:16 -0700 (PDT) X-Received: by 10.98.129.130 with SMTP id t124mr6343871pfd.162.1472049616777; Wed, 24 Aug 2016 07:40:16 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ml5si9930789pab.150.2016.08.24.07.40.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Aug 2016 07:40:16 -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.85_2 #1 (Red Hat Linux)) id 1bcZKd-0006tp-0T; Wed, 24 Aug 2016 14:39:07 +0000 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bcZIO-0005L8-UE for linux-arm-kernel@lists.infradead.org; Wed, 24 Aug 2016 14:36:52 +0000 Received: by mail-wm0-x232.google.com with SMTP id q128so204576677wma.1 for ; Wed, 24 Aug 2016 07:36:29 -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=zwqkV7y4ICxjN7qQPRHTDC5DGy/rQbeaPqO+40k4sQ8=; b=XNIOYeVfsykwoPB+2glEJUCbMPw37J8uTulf2zITps0x7eklEn04gwrCU+ORnNsni5 ZYV0TK6gvIXcMRngWj1b4TWSbLt1rRXUkmMJ6selvElRKVIV2NHCTxV4s7LYZDeeD6Ks 80y1Ej3HfJnH+Bw8+YSOps60ryEob1pGb3FfQ= 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=zwqkV7y4ICxjN7qQPRHTDC5DGy/rQbeaPqO+40k4sQ8=; b=b6yG/wiB5qF3JldUN9K0SE8BZfbSs56WAidXZe7yBZo1t1Y2t0y9wqOnOJkwZIpjcB 3nnky+TDkCiXbV4isND3iywab+D45ReqNYWJZMo08X3iRtgUHLhSeE9jXAA2gC/1ct8G 4pbCkqnKw74BW5zi+emQdydTlij2jXlCCY1AUYM7Gzpa9ZTYoygYtXgFVsi1b1f+2Iqi YV4RoroMernmIjA5AoB6CzsNJBVV3fyMmDoBuQXUUkcGR1ujf9vYdbBVQsqa71GajrKL IUC3707bYRzwIip6Wc/tR0N1cGh66ETJrVlwfgDeMF0bKnLOInippt/Gr3cOq73hfmMX QqOw== X-Gm-Message-State: AEkoouswQlF8T1KGcQD9DZA9tAvsJxlaKLZriGQGyDXBxes7ORdPHAY/XQXD3QhapHbybQbx X-Received: by 10.194.66.3 with SMTP id b3mr3153196wjt.119.1472049388417; Wed, 24 Aug 2016 07:36:28 -0700 (PDT) Received: from localhost.localdomain ([213.143.60.123]) by smtp.gmail.com with ESMTPSA id n2sm10365569wjd.1.2016.08.24.07.36.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Aug 2016 07:36:27 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, james.morse@arm.com Subject: [PATCH v2 8/9] arm64: head.S: use ordinary stack frame for __primary_switched() Date: Wed, 24 Aug 2016 16:36:05 +0200 Message-Id: <1472049366-10922-9-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472049366-10922-1-git-send-email-ard.biesheuvel@linaro.org> References: <1472049366-10922-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160824_073649_444394_4D73D254 X-CRM114-Status: GOOD ( 12.03 ) 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:400c:c09:0:0:0:232 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_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 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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 Instead of stashing the value of the link register in x28 before setting up the stack and calling into C code, create an ordinary PCS compatible stack frame so that we can push the return address onto the stack. Since exception handlers require a stack as well, assign the stach pointer register before installing the vector table. Note that this accounts for the difference between THREAD_START_SP and THREAD_SIZE, given that the stack pointer is always decremented before calling into any C code. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/head.S | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel Reviewed-by: Mark Rutland diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 27f51272de68..ad1dc61d67ac 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -415,13 +415,18 @@ ENDPROC(__create_page_tables) * * x0 = __PHYS_OFFSET */ - .set initial_sp, init_thread_union + THREAD_START_SP __primary_switched: - mov x28, lr // preserve LR + adrp x4, init_thread_union + add sp, x4, #THREAD_SIZE + msr sp_el0, x4 // Save thread_info + adr_l x8, vectors // load VBAR_EL1 with virtual msr vbar_el1, x8 // vector table address isb + stp xzr, x30, [sp, #-16]! + mov x29, sp + str_l x21, __fdt_pointer, x5 // Save FDT pointer ldr_l x4, kimage_vaddr // Save the offset between @@ -436,11 +441,6 @@ __primary_switched: bl __pi_memset dsb ishst // Make zero page visible to PTW - adr_l sp, initial_sp, x4 - mov x4, sp - and x4, x4, #~(THREAD_SIZE - 1) - msr sp_el0, x4 // Save thread_info - mov x29, #0 #ifdef CONFIG_KASAN bl kasan_early_init #endif @@ -452,8 +452,8 @@ __primary_switched: bl kaslr_early_init // parse FDT for KASLR options cbz x0, 0f // KASLR disabled? just proceed orr x23, x23, x0 // record KASLR offset - ret x28 // we must enable KASLR, return - // to __primary_switch() + ldp x29, x30, [sp], #16 // we must enable KASLR, return + ret // to __primary_switch() 0: #endif b start_kernel