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: 12284633 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 297B9C47089 for ; Thu, 27 May 2021 15:48:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E541C613BF for ; Thu, 27 May 2021 15:48:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E541C613BF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DHLkK2RDAijd+5w1gsIFfsGcAh/A7S1BjHzk2NlDY/A=; b=pl+nnQbK1RpktU jRv+9mp1eDJn7NSO25I+WY/H7wVB9xsQOeoxedj1dupPcm3tqVzUOh+lR2ggfAxi6/pV3a0Am/yVq HmlWkrxGC9yu5xZgBTr5WsVZAwJhyJTjW6Eo6s9bfD11Gg75o2vJjs/9qbrmvqKpJ1aCjQMIRsOxO xbHo6S/cFKlFovBZc9awPEpS39kyjbW+D+ygp/zPJJq7K13PByOqpAz3UW76V5Q3xYdgW5uBQ/r2O r8ruquQljNvb4o94YvCb8o11K9zgH07KJedYlEoDfLKQ77XXLlgdgEdF3KZoQ/76riGDbiHV3yUG8 k47EkHMsc/6N0czuHuSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmICh-007KVS-H8; Thu, 27 May 2021 15:45:51 +0000 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmHZk-0071e3-Bi for linux-arm-kernel@lists.infradead.org; Thu, 27 May 2021 15:05:36 +0000 Received: by mail-qk1-x736.google.com with SMTP id o27so911936qkj.9 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=kLgdaNVgG0AzYpLu+FXoVYRBkTFGbKUClOYrVhg4eZryAM0bpVk8efl9526mN+zyzH x7rKncyENBbHXGrtiSa5whaHndrbTQB8XSBwhODB78B10pGt/FLew08VwaCjd2zXuLMc prTuBfriW29O+d4prvLMIO1SP8mByugENeyX/DKrB9cLmiklaLIGwlTLNzkanRyn25t2 VMIQOnYSiWn54bPqZwq2c+u0Ilidsn2BFovM65NG1UlaRDga9ktsact8l06tzwJdF+ne Y4S1vK3Z4iAfIT+eq6geDaID9j3/uKe/lFGiIp2nLVWpRRNOEMD2yDvyW2+osLCKScuV moHQ== X-Gm-Message-State: AOAM531XCief8cFrmHxDJcl6VOMGr0X6cfT0Tc7B8TD7HtuyWzkB3xf1 lYK1jJ0L6h1+0p+2X8uh1SKYNw13aUGq+tSs 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210527_080532_512420_DB08DEB9 X-CRM114-Status: GOOD ( 12.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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