From patchwork Tue Jan 5 18:05:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 12000019 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, 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 C3588C433E6 for ; Tue, 5 Jan 2021 18:07:47 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 8492F22D06 for ; Tue, 5 Jan 2021 18:07:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8492F22D06 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc: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:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5+v1yPjMDdROW1MYHx2/q292MM2rQWyCRWHdH5Xm0ok=; b=T5tk+2Q7UmpdGPOBSDEmgmNVj Yt/KoDbRAOtjRdPEdsiRDREmjDNM8gt19powryginuxJ7eHpTLgOa3bF3JjPxp81CNTgM6AU6Y5e+ yLFLR+WNZV2tRq3msjuXyPQHEoU6TjiY+aiWP0Z1HAD1UHYkq8rMgrsk+kfWELrfVAkqhP+w5ThrD rIIu6TC2cEnoqjS3UPQalS1YT7hp57WpbALiUiumnP967R1YqMUpKOpxe2fxg2Jr7OiUurQYFZ90Z d0KqWrPmAjeAD7wOcHi6hE4gO9+2Jqr2qSX2Ae6eqWAZKNwma9m0+4aF7k31MegvrK6j54drXAGfi dQmOpswpw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kwqij-0001TO-N3; Tue, 05 Jan 2021 18:06:13 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kwqiW-0001OM-Qq for linux-arm-kernel@lists.infradead.org; Tue, 05 Jan 2021 18:06:02 +0000 Received: by mail-wm1-x32f.google.com with SMTP id r4so369355wmh.5 for ; Tue, 05 Jan 2021 10:06:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4s4kC7CHwiZm9mv2QHLBsiW5mNoTxM3uNeHHcwGbjn8=; b=Xp8q0HPzSd/L5ty1dj9Lhbtp9EHrG0IFlx9wI2ylD0ujpGx5iKDRejeLVXFUQMsIC6 GtYZ1r97VgBDtNlCFXQGyhBxyH2UgV0oAMFgNf+zfEn2uNaW5F5ZY5hFU4rBBotBttZV Ez9NqLsfLybCw1F6vLmJlhU41dkQdfwSjXaOlTM0w4sScV4zD8rB/ZQ+zzoZAlxO23um pTKRQ1kmXyWQBERElli5iZ6nuyYSAhtOUuugXxR7GluR3vLn7BwITKmm9cqdVPbQw+PH Xf5ji8WYrP2AnhiRdel2xu2wl3gBJQc6NlmPfhaPPqQ42kWvfaUkxEvmSf4xWnlilhU6 zv7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4s4kC7CHwiZm9mv2QHLBsiW5mNoTxM3uNeHHcwGbjn8=; b=Ajn3xlysB0Rdu2SISdkdO/57brhzMFLCnXzE8BKC5lW5mFRBqa27FJxF5jJMPW2ekm kF8Hpb2SoZvC8QxuU6+GTgUCPVbTYbfanqFAEcR/HYtKEscGCfHmadTFcUU/wlCIW++Y fYqsNaUtWky4pqB9CWSm3OkQc0zPNP/1LawfINOXAGVfs+Yiv2UX5yi08NjT5UmuVyS3 bdWhi9qZAaznLlDc714iPHfsLhA4PqgI+6+pvmxMNYdDpkZaV46k6KrA75IxHO9gLBNu QSfYimCuTWgI3hO9H65tObCa/xlOlGSl9Wv4mc59JylxvNhBTDSIvztqA2QjiB4Egj4U bgUw== X-Gm-Message-State: AOAM532DLFlzTIESIUw25LeYKEVXNhmRs1B6ffNPaOJm5u538POMSbJM 6T4Xs4jKcbLP3CdcOv5neOtRZA== X-Google-Smtp-Source: ABdhPJxRBFRzG613rtvyFJCeGLgpeoBl59v2l9QUF4TI9LzcY5VpziqmJ9QhA/8AH0mZ8DHe5XtmjA== X-Received: by 2002:a1c:2d8a:: with SMTP id t132mr289011wmt.119.1609869959397; Tue, 05 Jan 2021 10:05:59 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:4957:71a5:7b5c:c94f]) by smtp.gmail.com with ESMTPSA id t10sm745477wrp.39.2021.01.05.10.05.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Jan 2021 10:05:58 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [PATCH v2 3/8] KVM: arm64: Add symbol at the beginning of each hyp section Date: Tue, 5 Jan 2021 18:05:36 +0000 Message-Id: <20210105180541.65031-4-dbrazdil@google.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210105180541.65031-1-dbrazdil@google.com> References: <20210105180541.65031-1-dbrazdil@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210105_130600_931179_6EDD5F51 X-CRM114-Status: GOOD ( 18.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Suzuki K Poulose , Catalin Marinas , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Marc Zyngier , David Brazdil , Will Deacon , Ard Biesheuvel , Julien Thierry Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Generating hyp relocations will require referencing positions at a given offset from the beginning of hyp sections. Since the final layout will not be determined until the linking of `vmlinux`, modify the hyp linker script to insert a symbol at the first byte of each hyp section to use as an anchor. The linker of `vmlinux` will place the symbols together with the sections. Signed-off-by: David Brazdil --- arch/arm64/include/asm/hyp_image.h | 29 +++++++++++++++++++++++++++-- arch/arm64/kvm/hyp/nvhe/hyp.lds.S | 4 ++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/hyp_image.h b/arch/arm64/include/asm/hyp_image.h index daa1a1da539e..f97b774b58f4 100644 --- a/arch/arm64/include/asm/hyp_image.h +++ b/arch/arm64/include/asm/hyp_image.h @@ -7,6 +7,9 @@ #ifndef __ARM64_HYP_IMAGE_H__ #define __ARM64_HYP_IMAGE_H__ +#define HYP_CONCAT(a, b) __HYP_CONCAT(a, b) +#define __HYP_CONCAT(a, b) a ## b + /* * KVM nVHE code has its own symbol namespace prefixed with __kvm_nvhe_, * to separate it from the kernel proper. @@ -21,9 +24,31 @@ */ #define HYP_SECTION_NAME(NAME) .hyp##NAME +/* Symbol defined at the beginning of each hyp section. */ +#define HYP_SECTION_SYMBOL_NAME(NAME) \ + HYP_CONCAT(__hyp_section_, HYP_SECTION_NAME(NAME)) + +/* + * Helper to generate linker script statements starting a hyp section. + * + * A symbol with a well-known name is defined at the first byte. This + * is used as a base for hyp relocations (see gen-hyprel.c). It must + * be defined inside the section so the linker of `vmlinux` cannot + * separate it from the section data. + */ +#define BEGIN_HYP_SECTION(NAME) \ + HYP_SECTION_NAME(NAME) : { \ + HYP_SECTION_SYMBOL_NAME(NAME) = .; + +/* Helper to generate linker script statements ending a hyp section. */ +#define END_HYP_SECTION \ + } + /* Defines an ELF hyp section from input section @NAME and its subsections. */ -#define HYP_SECTION(NAME) \ - HYP_SECTION_NAME(NAME) : { *(NAME NAME##.*) } +#define HYP_SECTION(NAME) \ + BEGIN_HYP_SECTION(NAME) \ + *(NAME NAME##.*) \ + END_HYP_SECTION /* * Defines a linker script alias of a kernel-proper symbol referenced by diff --git a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S index cfdc59b4329b..cd119d82d8e3 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S +++ b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S @@ -22,7 +22,7 @@ SECTIONS { * alignment for when linking into vmlinux. */ . = ALIGN(PAGE_SIZE); - HYP_SECTION_NAME(.data..percpu) : { + BEGIN_HYP_SECTION(.data..percpu) PERCPU_INPUT(L1_CACHE_BYTES) - } + END_HYP_SECTION }