From patchwork Wed Mar 3 00:22:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12114151 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.8 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 CBFABC433E0 for ; Wed, 3 Mar 2021 19:38:57 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 3286A601FB for ; Wed, 3 Mar 2021 19:38:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3286A601FB 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=desiato.20200630; 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=jf4fJUJSA9KF2U1nNQDZaCT9B1ALjOLGT9H4Hag4XfM=; b=KR+CGUUU5v2ifJWRWb8qMsI7b N2wrj2GLXv53QAv6Viq4LLps43KYkezvqLzI74B1ICjsCizCrmmtsy3lwBlaEcm9poGQSDLNxgbki 1h9qLjCh0Wy61GAwsiOBsMuXYjkrb/vohfN7S/d5oqQ74zVqJH9AgUJO8NDbOJduhOmD6IMdPxq+7 G9buhjhm9tu31RWSqjBKZ9P9MlgVkDfrNkko4omdTVzhltGLJ0XmKbyTzJUJKbhgiSXr60LNdPkxf /a9R5VOYpit7ZKe0HtFAFbdElA/dgi4vA8NVk4rn/A2Dh3U8S/+n9EEhjaT2oawc0M2Xea+wYSMlr ray6gULHw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHXI8-006F8G-Hl; Wed, 03 Mar 2021 19:36:16 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHT3Y-005I6u-Q9 for linux-arm-kernel@desiato.infradead.org; Wed, 03 Mar 2021 15:04:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=2ZHo6bqqoFQHDt1XsnxWzUIHllyauSrjIJToDTBiZLY=; b=FYGPnhLj6niG8ng7uI2M0ZSiAf /S6F+vitVqjVPeCpPzde1GrWzVMLFDY3v3/zfaQJXvf88vIoGGIoKkHNPmZ1Zh5H52QXBwHLqyNhZ hXJzMbiSWzWlflxqxX0zfd5I5mmiNqozYfpvVyahp3bzC+kLiOiidTuBSiN+sPkypPVKpHjIqlD21 qqd4YcNk4XlTuQJyZMEGr7OTY42dMkCwapMYGcWCdvM/H7v9jeIBaHep3zWsxoNKBg+Fbix0/2+jZ CJHKjWkvQUyyJXtDqlhsJhxg2wcQ4afh2OR9jMfumuICs0mw66PQEAOnLgn2TgFXoP69uzG7U3Zns Ir4Cl9BQ==; Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHFIr-000jc4-PL for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 00:23:51 +0000 Received: by mail-qk1-x72d.google.com with SMTP id l4so7558064qkl.0 for ; Tue, 02 Mar 2021 16:23:40 -0800 (PST) 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=2ZHo6bqqoFQHDt1XsnxWzUIHllyauSrjIJToDTBiZLY=; b=HFHYvchu6CpdqexxuDSsNYf6zc2J6VEKWIBzKSjPVt7Oj5tn2/oRKB1PtdVtAhgBcu 8QtnWiz/7P8/LqX5wFb1aqUQju3puj7mBA1eY2moIHPzNRpZr6tHqSrfP6M19tFtCndA Dw7uvs/8X/wLRsL+Y2oTYcwh4VUTm1gb0QoWI27HLxniuFGEj0KhR+xLWCeoEvbTnu+7 iDZO6hGQaznymI4Z7Kti3JjhODZC9KYEwl0lPssNr6T7Q8YrqF4+AmY67n+7+DzGelJs WYrCxrVf4ENesVrOPXLzb1mOiHh9nKU3H9yCHxRR06iUcT7IO02sj3oVqitQee/e+0NO HyTg== 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=2ZHo6bqqoFQHDt1XsnxWzUIHllyauSrjIJToDTBiZLY=; b=RA9uvPs6N4WAMjFmwib6ZXuguuNXivPKYTQOasTzkgxSzDk8O3e0gSWGPGebTZ57BW lamwC6ps/sOMrxCnbmqte0JKSv4UTmVxNzq6kU7p6swQCAjm2UuFHd29uC0jPR8IqlNP b24W4Dyod+nyLpaBSUbMFVr1yDUnp68N/skv83PfheiV/DiwR0CIP9X0/vq6hcProkip py6QCM5O8OSdDPWkxf4kxggPxwW02db9TL2WHF88DN6i/pcgW/BuppFKeWLIaxkTrJNj wn0a/JNRL7kime4rDkPnNlrFNj7O2f64VGvA+IjAbkf8AzOE/ccnH3DGuMNWhVRJv8wK kY7A== X-Gm-Message-State: AOAM530OXFzh3d1nHXgA03BZJ50JjwRcuFBpwPpIb1HZgmSHBmIyi+NE Kg4ltBVuAXwfohYK2NgjqMUo+A== X-Google-Smtp-Source: ABdhPJwsTtNwrwyfksF0JxhDL724PEtC95EO+MO9/7fXbkyN8TnG2jdsy9RcmwXwPeG1L2V0hRnmfQ== X-Received: by 2002:a37:4743:: with SMTP id u64mr16003296qka.350.1614730954363; Tue, 02 Mar 2021 16:22:34 -0800 (PST) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id r3sm16690512qkm.129.2021.03.02.16.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 16:22:34 -0800 (PST) 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 Subject: [PATCH v12 01/17] arm64: hyp-stub: Check the size of the HYP stub's vectors Date: Tue, 2 Mar 2021 19:22:14 -0500 Message-Id: <20210303002230.1083176-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210303002230.1083176-1-pasha.tatashin@soleen.com> References: <20210303002230.1083176-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-20210303_002351_858896_1DAE4817 X-CRM114-Status: GOOD ( 11.43 ) 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 5eccbd62fec8..572b28646005 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(el1_sync) cmp x0, #HVC_SET_VECTORS