From patchwork Thu May 27 15:05:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12284527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9975CC4708A for ; Thu, 27 May 2021 15:05:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 48B1D613AC for ; Thu, 27 May 2021 15:05:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48B1D613AC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AA6386B0071; Thu, 27 May 2021 11:05:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A32346B0072; Thu, 27 May 2021 11:05:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A8DD8D0001; Thu, 27 May 2021 11:05:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0083.hostedemail.com [216.40.44.83]) by kanga.kvack.org (Postfix) with ESMTP id 50B4E6B0071 for ; Thu, 27 May 2021 11:05:32 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E31B6824999B for ; Thu, 27 May 2021 15:05:31 +0000 (UTC) X-FDA: 78187334862.05.CF054DE Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by imf13.hostedemail.com (Postfix) with ESMTP id 91A07E000816 for ; Thu, 27 May 2021 15:05:23 +0000 (UTC) Received: by mail-qk1-f172.google.com with SMTP id i67so931433qkc.4 for ; Thu, 27 May 2021 08:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ghqRky3xeZiHl8S3DiRVTP9pM6BiSKFavllixIkkvd0=; b=caUhVx3J/tqp+Gal3Xi+7VBVenbj1bAKADWn8txk9KZ20D6QNDbgDjYASPogchOfyj MnR9GvDeTVlU/w7h0MDxRGxJcSxJKoV0mjkK+QdLIg1QR5LED8krF6MVh4Dw7m3PScI9 DH5d0pWUvzXOFaty1vK3wY3s2CaSoIxaYfFpwPApeJBhcfwIAViezHl4cLnrFbUJWTEz CxttZKvFn/yQ47HYBvaRhH+Top3dM3Aos+zj8m2STtvk8DprhmBAFJxZS0AcEiFO3Kb7 DrdN7vRSm71g5/nEb3VcE95apeL0RMCTNaPwasAdOu10HhJ2vq1M/c/C1Yn8L1NpF7Rq MkWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ghqRky3xeZiHl8S3DiRVTP9pM6BiSKFavllixIkkvd0=; b=ouWETiO5moEEmuc+VywX2BcXpj5laLQq5zZ2MOk1SZIJFQ/47Vq0+2UdgLJo2+SEuq Qbf5arO7YesfjoUd4FUcFElt7XVFi5plw8PQwpRwxZmg78a8/rPX6//sQDNFtfnZFVaN fTOmmLMCgK0xLETrTIyxgKK7KdvmZoMl35/NzXNQ3K+vi+o4CxuaJOLezEJ90OF38eX8 nwXauPWCktOnbyieX8bUCqt6FeNSnJsONMSHxXA0cicZrGSk5ki+PQ7rW9F8y9fENXHY TZQSajZaJN4IxQmtWvwoekRApRKLUi30MAVGUnvqQGG519OaEa94thfEdiplo3RQr6i/ /2IQ== X-Gm-Message-State: AOAM533b/mq7a46bcFhV9T9SomfOpfvzwpAi6sJh1mIuaU0sWEF61gjF eBDUpwpvUcyA9YJ4keAprVGS0g== X-Google-Smtp-Source: ABdhPJzkqRktvQM1YvTQKwrzQq+gZ576cPkKRhONnmbg0z/uIwTpNvyWkip4RNp35WexktltcbHpqw== X-Received: by 2002:a37:c15:: with SMTP id 21mr3945299qkm.180.1622127930853; Thu, 27 May 2021 08:05:30 -0700 (PDT) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id x10sm1447468qkh.124.2021.05.27.08.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 08:05:30 -0700 (PDT) From: Pavel Tatashin To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, maz@kernel.org, james.morse@arm.com, vladimir.murzin@arm.com, matthias.bgg@gmail.com, linux-mm@kvack.org, mark.rutland@arm.com, steve.capper@arm.com, rfontana@redhat.com, tglx@linutronix.de, selindag@gmail.com, tyhicks@linux.microsoft.com, kernelfans@gmail.com, akpm@linux-foundation.org, madvenka@linux.microsoft.com Subject: [PATCH 01/18] arm64: hyp-stub: Check the size of the HYP stub's vectors Date: Thu, 27 May 2021 11:05:09 -0400 Message-Id: <20210527150526.271941-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210527150526.271941-1-pasha.tatashin@soleen.com> References: <20210527150526.271941-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 91A07E000816 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=caUhVx3J; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.172 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none X-Rspamd-Server: rspam04 X-Stat-Signature: yf4rb3t6f65xdbfgyjaib3b8dqjdg9t5 X-HE-Tag: 1622127923-996110 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: James Morse Hibernate contains a set of temporary EL2 vectors used to 'park' EL2 somewhere safe while all the memory is thrown in the air. Making kexec do its relocations with the MMU on means they have to be done at EL1, so EL2 has to be parked. This means yet another set of vectors. All these things do is HVC_SET_VECTORS and HVC_SOFT_RESTART, both of which are implemented by the hyp-stub. Lets copy it instead of re-inventing it. To do this the hyp-stub's entrails need to be packed neatly inside its 2K vectors. Start by moving the final 2K alignment inside the end marker, and add a build check that we didn't overflow 2K. Signed-off-by: James Morse Signed-off-by: Pavel Tatashin --- arch/arm64/kernel/hyp-stub.S | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S index 43d212618834..91aab4121463 100644 --- a/arch/arm64/kernel/hyp-stub.S +++ b/arch/arm64/kernel/hyp-stub.S @@ -41,9 +41,13 @@ SYM_CODE_START(__hyp_stub_vectors) ventry el1_irq_invalid // IRQ 32-bit EL1 ventry el1_fiq_invalid // FIQ 32-bit EL1 ventry el1_error_invalid // Error 32-bit EL1 + .align 11 +SYM_INNER_LABEL(__hyp_stub_vectors_end, SYM_L_LOCAL) SYM_CODE_END(__hyp_stub_vectors) - .align 11 +# Check the __hyp_stub_vectors didn't overflow +.org . - (__hyp_stub_vectors_end - __hyp_stub_vectors) + SZ_2K + SYM_CODE_START_LOCAL(elx_sync) cmp x0, #HVC_SET_VECTORS