From patchwork Sun Apr 23 17:09:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9695055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C828A60245 for ; Sun, 23 Apr 2017 17:13:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B36B926530 for ; Sun, 23 Apr 2017 17:13:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8362265B9; Sun, 23 Apr 2017 17:13:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 276C126530 for ; Sun, 23 Apr 2017 17:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162690AbdDWRNp (ORCPT ); Sun, 23 Apr 2017 13:13:45 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:36779 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162416AbdDWRKl (ORCPT ); Sun, 23 Apr 2017 13:10:41 -0400 Received: by mail-wm0-f44.google.com with SMTP id u65so7508520wmu.1 for ; Sun, 23 Apr 2017 10:10: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=oekz3yE/65nftmrMGt7n4KzkD2yYugvKTdyj21fN+7Y=; b=AIqBbxOuGyFYFXdLRvq0yA5oY7UaeW4LhLSI4Shyz5yrjWzAfXnIgmakupNXkmcw1c bQpyluNo22jLH7B5zQxWaoSX21o2+H7+iEx1WQQkToUAznzcsJJ1iplL1Fgmroq+NMrs iPRviGO5Rf8ADGC65uHADftMiz71EXQisFyvI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oekz3yE/65nftmrMGt7n4KzkD2yYugvKTdyj21fN+7Y=; b=G4O1ODi+hGom/tniiw5K3fHcqo2Dm9vFyh1s0CjGhxpgywcH9BriGfP2nsK6yZsFsH UKPoZQzddKiiFxl5QAUYBwvE2V0PY/3231j71apdkOfvekCwGJ77bAbhXu/MEsSfbgLJ wXHu0pOq7knorZTMDmJdbRHM07cX62+UNHUJ9nX9OPpVjxTh+l0Zrh3hvPm+nNXiMrvY 3u06Vm1/0PRiAHYnudIVxT7ozPBWkuSWOxzk0D2Q+oWGWnwXx0tQvqnr5z4M92lQshHn 2uZcmvAv+Pk3JdrK7RlrXEeM7bDbXqllLM5/OlDycFGFPVdghZNP66MG6oBS+M32l4qI /R8Q== X-Gm-Message-State: AN3rC/4xEnY7uR/RwzgKDNp/uqwOZkObPbI0op8JJV/ONszd8vStIIOO y1NwO2tO3e1ClvYa X-Received: by 10.80.166.197 with SMTP id f5mr123077edc.144.1492967439681; Sun, 23 Apr 2017 10:10:39 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id 58sm2803521edz.2.2017.04.23.10.10.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Apr 2017 10:10:39 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Christoffer Dall Subject: [PULL 64/79] ARM: decompressor: Remove __hyp_get_vectors usage Date: Sun, 23 Apr 2017 19:09:14 +0200 Message-Id: <20170423170929.27334-65-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170423170929.27334-1-cdall@linaro.org> References: <20170423170929.27334-1-cdall@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier When the compressed image needs to be relocated to avoid being overwritten by the decompression process, we need to relocate the hyp vectors as well so that we can find them once the decompression has taken effect. For that, we perform the following calculation: u32 v = __hyp_get_vectors(); v += offset; __hyp_set_vectors(v); But we're guaranteed that the initial value of v as returned by __hyp_get_vectors is always __hyp_stub_vectors, because we have just set it by calling __hyp_stub_install. So let's remove the use of __hyp_get_vectors, and directly use __hyp_stub_vectors instead. Acked-by: Russell King Acked-by: Catalin Marinas Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm/boot/compressed/head.S | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 9150f97..7c711ba 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -422,7 +422,17 @@ dtb_check_done: cmp r0, #HYP_MODE bne 1f - bl __hyp_get_vectors + /* + * Compute the address of the hyp vectors after relocation. + * This requires some arithmetic since we cannot directly + * reference __hyp_stub_vectors in a PC-relative way. + * Call __hyp_set_vectors with the new address so that we + * can HVC again after the copy. + */ +0: adr r0, 0b + movw r1, #:lower16:__hyp_stub_vectors - 0b + movt r1, #:upper16:__hyp_stub_vectors - 0b + add r0, r0, r1 sub r0, r0, r5 add r0, r0, r10 bl __hyp_set_vectors