From patchwork Mon Apr 18 15:09:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 66041 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1340675qge; Mon, 18 Apr 2016 08:11:37 -0700 (PDT) X-Received: by 10.98.16.210 with SMTP id 79mr50318488pfq.69.1460992297401; Mon, 18 Apr 2016 08:11:37 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id v185si5750071pfv.205.2016.04.18.08.11.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Apr 2016 08:11:37 -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 1asAoy-0005vo-Ga; Mon, 18 Apr 2016 15:10:40 +0000 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1asAoi-0004Uz-LR for linux-arm-kernel@lists.infradead.org; Mon, 18 Apr 2016 15:10:25 +0000 Received: by mail-wm0-x22c.google.com with SMTP id n3so129514211wmn.0 for ; Mon, 18 Apr 2016 08:10:04 -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=HjmraMrO5Ph3rsjuSpO8ViaaCyXajDaWEEWs3m8LCYQ=; b=NW3cpjILOQh/bV8kE6djnItkftGpsIP1sBX5mQ0IUaes9Gre0IwWubI31/DnDxVaPl U5OkxBMEQkg3Bya+zKwIFfa+1cTnx4IOzJLp8VNmBpOY6mR3rdjP8pptjG78rpl3XN31 uNMK6DNcIyBWZHvPA/8+FLOBNzWfYNCeYcQ6I= 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=HjmraMrO5Ph3rsjuSpO8ViaaCyXajDaWEEWs3m8LCYQ=; b=RJ0RjM28ymfT3hHk/1v7zc5rO7jvbvbAPoXD9/Bp10zbrDw9i8x6pv0yN+hiVZNVsB vGRS0UAalVw59VSWG5g4EsxgMis3SwSneGkdNnc36nuqAVcdNhaN6Yzz98AbP3corGuw ISmC9cluLCYZEY9ryy/O/jWj6P7FxiK8FB9qsP2RpXFhi6I9GcVE+SrkIsWGgJHmmUTx rSQZNUg+7JkLuBfss2AOh7GOsFynsuPDLFCt+3+Phwh1tYTcuI93DC8Gc6OLVtiDAEgH YyMpDy50tEhUW+X0GruNjuEymsXm/AdwrhYTQXsA255IWUa85n7+0rugUeJnGHgO6wTN +KkQ== X-Gm-Message-State: AOPr4FXfWX02eqZwKVlpgu9qMiILlzfi9oYhmoF8l+fJiDtKrR/WIQJkW5t4pxEO7ko9SSgn X-Received: by 10.194.88.201 with SMTP id bi9mr33006004wjb.147.1460992202920; Mon, 18 Apr 2016 08:10:02 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id b135sm54232075wmb.10.2016.04.18.08.10.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Apr 2016 08:10:02 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, mark.rutland@arm.com, james.morse@arm.com Subject: [PATCH 2/8] arm64: kernel: use literal for relocated address of __secondary_switched Date: Mon, 18 Apr 2016 17:09:42 +0200 Message-Id: <1460992188-23295-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1460992188-23295-1-git-send-email-ard.biesheuvel@linaro.org> References: <1460992188-23295-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160418_081024_924191_9BE9B74D X-CRM114-Status: GOOD ( 12.23 ) 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:22c 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: catalin.marinas@arm.com, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org We can simply use a relocated 64-bit literal to store the address of __secondary_switched(), and the relocation code will ensure that it holds the correct value at secondary entry time, as long as we make sure that the literal is not dereferenced until after we have enabled the MMU. So jump via a small __secondary_switch() function covered by the ID map that performs the literal load and branch-to-register. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/head.S | 14 +++++++------- 1 file changed, 7 insertions(+), 7 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 ac27d8d937b2..f13276d4ca91 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -468,9 +468,7 @@ __mmap_switched: str x15, [x11, x23] b 0b -2: adr_l x8, kimage_vaddr // make relocated kimage_vaddr - dc cvac, x8 // value visible to secondaries - dsb sy // with MMU off +2: #endif adr_l sp, initial_sp, x4 @@ -699,12 +697,9 @@ secondary_startup: adrp x26, swapper_pg_dir bl __cpu_setup // initialise processor - ldr x8, kimage_vaddr - ldr w9, 0f - sub x27, x8, w9, sxtw // address to jump to after enabling the MMU + adr_l x27, __secondary_switch // address to jump to after enabling the MMU b __enable_mmu ENDPROC(secondary_startup) -0: .long (_text - TEXT_OFFSET) - __secondary_switched __secondary_switched: adr_l x5, vectors @@ -806,3 +801,8 @@ __no_granule_support: wfi b 1b ENDPROC(__no_granule_support) + +__secondary_switch: + ldr x8, =__secondary_switched + br x8 +ENDPROC(__secondary_switch)