From patchwork Thu Apr 8 04:05:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12189931 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.6 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,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 09844C433ED for ; Thu, 8 Apr 2021 04:05:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7BB97611BE for ; Thu, 8 Apr 2021 04:05:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7BB97611BE 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 10EF56B0080; Thu, 8 Apr 2021 00:05:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 098A86B0081; Thu, 8 Apr 2021 00:05:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E37CB6B0082; Thu, 8 Apr 2021 00:05:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id C65F46B0080 for ; Thu, 8 Apr 2021 00:05:41 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 83ACD181BA3E0 for ; Thu, 8 Apr 2021 04:05:41 +0000 (UTC) X-FDA: 78007860882.18.2E87130 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by imf04.hostedemail.com (Postfix) with ESMTP id E4B91130 for ; Thu, 8 Apr 2021 04:05:39 +0000 (UTC) Received: by mail-qk1-f172.google.com with SMTP id g15so942999qkl.4 for ; Wed, 07 Apr 2021 21:05:40 -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=2ZHo6bqqoFQHDt1XsnxWzUIHllyauSrjIJToDTBiZLY=; b=X9eAU/eM3040QGUYmUbw7fYBZz3JtF3avBuvT24i1+XpVGvbIi9BNTH2rSlvhxMZ6p vB7bmo+61os1iTwbbNQRR69s0xibH9y2Zh+JxqbT2cEzOMZyXY4XleOC3VU2OQbelf4e qUx64StBUbF+O1txg2vRkmFpmHWn5MioQBG/fANNQ2YzUxTJC8uDaJ4j6/ABFGO80TmL lT7jf5YqjgaPI2Fa4vi35ToQnOb1K/7GhDLWSoB81CHHWcprY9EhPAQcUKCUF69eeTrQ 5rcxFBkWQYTv7dEA+PHoUkVJSA2Bu07e+E9jh6dpYWIsqXcT3kY8zV4f1HpZcTG33b+V 3i2A== 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=h+B8OabvQIFQzjcnjw7XlkPGULtOc3BdndRapayXoJUVgY1SXR+xQbZKTgi4Z85DSa OpTp5F96Tn+65Cug+w8sWm/bGRZpwoxcgjI+9JdUnljUqoMOvut0iXUwnwqxmTQZxmxs lYtEHC9jq9p0u7BYalna9Zos0YFbqRQit0/KBrTNLXH7fgDarvpS4Bto33opeTzXbEb0 FhqKw7N49k0mwwb7fPjROm+NloI2j0EWfHQ7FgHaWYR8JAq1xdW7ht1Asf2AjMgl4kSK kkSepSjEWMqWcu7WOFUdvSzv44sqxzHxwar1Tl52VwQqXhOdNrzPkR5qI5h3/tEUWPqy BQUw== X-Gm-Message-State: AOAM5307df79CeKyFZ1cUh8CaNttl2hflHE4r2GbHX2fdnBr8F1GiQc/ XuylGPI3O2D36kXLcvgzNN7cAA== X-Google-Smtp-Source: ABdhPJxYXvk2FxZ0FX2jOzjDLvti4P2RgEhIeGGR2Vwo3ThVtxJOO1wAhCh/APii2j5zwyiwpg/lrg== X-Received: by 2002:a37:78b:: with SMTP id 133mr6607278qkh.109.1617854740543; Wed, 07 Apr 2021 21:05:40 -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 207sm18177874qkl.125.2021.04.07.21.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Apr 2021 21:05:39 -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 Subject: [PATCH v13 01/18] arm64: hyp-stub: Check the size of the HYP stub's vectors Date: Thu, 8 Apr 2021 00:05:20 -0400 Message-Id: <20210408040537.2703241-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408040537.2703241-1-pasha.tatashin@soleen.com> References: <20210408040537.2703241-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: E4B91130 X-Stat-Signature: fmj5g1m4p6jjgnphj4hyuc3ougn58km4 Received-SPF: none (soleen.com>: No applicable sender policy available) receiver=imf04; identity=mailfrom; envelope-from=""; helo=mail-qk1-f172.google.com; client-ip=209.85.222.172 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617854739-832172 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 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