From patchwork Wed Mar 10 17:57:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12128961 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.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,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=unavailable 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 ADE0CC433E0 for ; Wed, 10 Mar 2021 18:14:56 +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 2122864DC4 for ; Wed, 10 Mar 2021 18:14:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2122864DC4 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.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:Cc:To:From:Subject:References:Mime-Version: Message-Id:In-Reply-To:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YRDfI/7pAoPCktHF1isE3BClE1i4wGqKBh+OB/0tSVM=; b=cBnEeYyXaPCbQh VqSJjqOFhHP29kropS/kJq4MzZ/BYkxcG1mBZ35fzz2GWdclnWTPc9BE3rqnFFdZAcRSjbUpG9VmZ KukCx+77icu9tb7sy6INDqwPStGPd/uBMxYHQ7mEGPRRAs1Zxgd/6fkNo2fd4LVVkZfuWaVH3pPce FqxJaawylqUR+2CbFiH023P25yF04efHSwGDX07Sj6LgW1lR/9WInNDioqldDeB1LshLYK2iOgXpe TFQ3j7MWatgHrj53pdyOMnvB8VpvEbjF0GvAc9O/GxxeAiKtkrA9P8uMR5LJg69VN1Wvg/n+6Ccn5 +P5hV/8U3rJxhRwPz6+g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK3KM-007Tc4-T8; Wed, 10 Mar 2021 18:12:59 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK36w-007OZk-0o for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 17:59:08 +0000 Received: by mail-wr1-x449.google.com with SMTP id l10so8323706wry.16 for ; Wed, 10 Mar 2021 09:59:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=gpovMkXHvDEd7Q1vbye6zBnrPUcdwhSYcDTZCWLwbWg=; b=EykAkvQxBXiDzdm6FE4Uy5mf7/ey2u/c+U5eLurLHPbE8jOinaMNiPrzd4uPyZwUZL 2r0ZxYaUbj1XS7bDR/Mb1V8xcCBkPAGfIzGS5aU2R8y9FQN6UiYCnReXBwvS+lmODCoR SuLRCs3v6esu/pGnhhVYIhxo5hM8+cAzHRNj6ARFbIIXvItGTWgs46jw+pcEOvB6mOCk tYi+qFS0/ePTkbt0zYmXp2NVpom3ZglGq//Drt94PX6dESV2KONoPjhoxQjYEj1GZ6sA I7bAth+4o+atC2uZJUJNQSU8KOV+souLg6H4/Yv5ckKbF63NE/By69s4N3aq6kMVvb2t 6FKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=gpovMkXHvDEd7Q1vbye6zBnrPUcdwhSYcDTZCWLwbWg=; b=bQbipoobOJv/xNXs1LphyI59RCwAyApvO9HIHVlCtnzojOfL4an6go78RzEIJGxXGO WWoLCJ4BQSRk6qr02+ePWNU1GIz+yFfrKm2QDnMhb/0IGjGj62nkPOi+IfPVH9OV79pp EWsb18qsuM+J156+kFKBQmBvjqlVhOpf/WhVsKJ4Z3l4TPTLe7Osi1FnoCRzO51viCVq a8aS3lMEoiZqHR1chya/zVnPkWBDb9ulOCiNtntWn9NWVPThQsly0C5qvQGk9WOwyNxN 7BH39uIqfHET1YOiHGXPNuEGRBgBcDm2EoCNYmjfAiNGi3h+1qItkt3P0LJ38KFFoxyU JKQg== X-Gm-Message-State: AOAM530zi2UFRFzloycfeP1v5xHTrQzD68jw63zJbyEMwe8oUDPJWuXk vZUmj3TJcg+AYLtPEoRWndEcY1iPPifO X-Google-Smtp-Source: ABdhPJziRnNwKB8Ne6xf3o0qOfV9qCZo6Q3H55q9W1Ku8THlZcg0eIahqVQjh17lDsKSyjkP5RcbAP3UO7Jm X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a05:600c:2247:: with SMTP id a7mr4544145wmm.131.1615399145092; Wed, 10 Mar 2021 09:59:05 -0800 (PST) Date: Wed, 10 Mar 2021 17:57:49 +0000 In-Reply-To: <20210310175751.3320106-1-qperret@google.com> Message-Id: <20210310175751.3320106-33-qperret@google.com> Mime-Version: 1.0 References: <20210310175751.3320106-1-qperret@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH v4 32/34] KVM: arm64: Page-align the .hyp sections From: Quentin Perret To: catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com Cc: android-kvm@google.com, linux-kernel@vger.kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, tabba@google.com, mark.rutland@arm.com, dbrazdil@google.com, mate.toth-pal@arm.com, seanjc@google.com, qperret@google.com, robh+dt@kernel.org, ardb@kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_175906_355485_5B59577C X-CRM114-Status: GOOD ( 13.46 ) 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 We will soon unmap the .hyp sections from the host stage 2 in Protected nVHE mode, which obviously works with at least page granularity, so make sure to align them correctly. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kernel/vmlinux.lds.S | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index e96173ce211b..709d2c433c5e 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -15,9 +15,11 @@ #define HYPERVISOR_DATA_SECTIONS \ HYP_SECTION_NAME(.rodata) : { \ + . = ALIGN(PAGE_SIZE); \ __hyp_rodata_start = .; \ *(HYP_SECTION_NAME(.data..ro_after_init)) \ *(HYP_SECTION_NAME(.rodata)) \ + . = ALIGN(PAGE_SIZE); \ __hyp_rodata_end = .; \ } @@ -72,21 +74,14 @@ ENTRY(_text) jiffies = jiffies_64; #define HYPERVISOR_TEXT \ - /* \ - * Align to 4 KB so that \ - * a) the HYP vector table is at its minimum \ - * alignment of 2048 bytes \ - * b) the HYP init code will not cross a page \ - * boundary if its size does not exceed \ - * 4 KB (see related ASSERT() below) \ - */ \ - . = ALIGN(SZ_4K); \ + . = ALIGN(PAGE_SIZE); \ __hyp_idmap_text_start = .; \ *(.hyp.idmap.text) \ __hyp_idmap_text_end = .; \ __hyp_text_start = .; \ *(.hyp.text) \ HYPERVISOR_EXTABLE \ + . = ALIGN(PAGE_SIZE); \ __hyp_text_end = .; #define IDMAP_TEXT \ @@ -322,11 +317,12 @@ SECTIONS #include "image-vars.h" /* - * The HYP init code and ID map text can't be longer than a page each, - * and should not cross a page boundary. + * The HYP init code and ID map text can't be longer than a page each. The + * former is page-aligned, but the latter may not be with 16K or 64K pages, so + * it should also not cross a page boundary. */ -ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K, - "HYP init code too big or misaligned") +ASSERT(__hyp_idmap_text_end - __hyp_idmap_text_start <= PAGE_SIZE, + "HYP init code too big") ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K, "ID map text too big or misaligned") #ifdef CONFIG_HIBERNATION