Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp409039pxf; Wed, 31 Mar 2021 06:33:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzU+fj3cdyoQNEnS7zNErgEjdIiH91eiimD7jhCJl1+h26G3vLWvMJkb/fQj+VTsXcQMMSl X-Received: by 2002:a17:906:5902:: with SMTP id h2mr3522354ejq.416.1617197588673; Wed, 31 Mar 2021 06:33:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617197588; cv=none; d=google.com; s=arc-20160816; b=dxztW3OodbtyDeuoO0IRh5FWGMy4bJrd35DDxr1J4S0qA8Fjj+rl4lhNE2I2FTRIgI 2P2UJrFAhBjcfZpq5d1X6fr39LRyYYaryVOiL3TqTXy0XIthM0uBlTHO4rIFga8mnnyv RBrCphepDyFQvgTd4ttlWUeU4W26eAJ4zSM1LQb+uIhY9d2Y8XS4ulshleygVL0AGn1u NSvHGPYUWL9i8GMFdKjnz/mNCmkruYW9EyDAjcC/Xf1/X/lPEnyB3oi7dXLuwU+BVceR Gb5HE1esTKIbiQi+l0UB65I56bQi5+ptMOz3T2jgAEN6qHu+/wO9LOZQOoBZl7oxAa8Q 7v5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=G0CRqLqXvRiG1/XBSQU7fXbBsXpuUCmZ+DzzZxxUzIo=; b=j6aTY6CheW4YBjd3+mNcefNJwjH6nDhIWoZiNcA4RvrEKEkGeua6pST2JlJWVsVvz/ 07ugg76JNROdCVy57ARD2aVWluuDJNGaAfmdnIZ+k6WxfKbVRUGK4cFeykFT2OrT7hCn jdV9x7JO1s2ErR3SBVz7zHM1N4zX7vOTzYkQCfK0Bihlw82MR/tqgCn6nZV9U7L9VkPq 003xaiN0iTXwRmKZ56X/fzRZF7EI4UHZa8o7myGBCsp/jt5Xe8+Oxd/RhQEKlBh1ysh7 17zW0ZdZr476jLM9ZJVE45pVQ1ccEbq3l/f22sGGnG4sKx1urnvK/i1PocYQULdW6ZtA bj3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rpChXq0E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g25si1698480ejf.697.2021.03.31.06.32.45; Wed, 31 Mar 2021 06:33:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rpChXq0E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235794AbhCaNbS (ORCPT + 99 others); Wed, 31 Mar 2021 09:31:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235775AbhCaNbF (ORCPT ); Wed, 31 Mar 2021 09:31:05 -0400 Received: from mail-wm1-x349.google.com (mail-wm1-x349.google.com [IPv6:2a00:1450:4864:20::349]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9396EC061574 for ; Wed, 31 Mar 2021 06:31:04 -0700 (PDT) Received: by mail-wm1-x349.google.com with SMTP id n2so567186wmi.2 for ; Wed, 31 Mar 2021 06:31:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=G0CRqLqXvRiG1/XBSQU7fXbBsXpuUCmZ+DzzZxxUzIo=; b=rpChXq0EFgKIpVkS59ynQK6JSC0ep27UrPlpHOIVXXkfEXuY1WiqSTcyQmMkdr6XPW 53JPsCxnplpk4AqN/UvbynyFxEGzP9Rkq1sDPNgNceVhS5YpfVel6aA/w4KaFNV4vBL+ QAFVKTMZV/lVWqCLIk5bsq1MIBrRkA/Ooyp+rx78E8X8PzrXals9D+IfBPlLMlBal7B2 j9drq3kA22qdFUjiiv/1chYzZQIwhn77vvgUXToIwPnCIbU22Ww6RXQnMF7obLxEdoX1 9ex5kaUnqXGhNbhsmM+ethxGc/m0mPttOb29qF0OS9eSSj0QbOP/jOa/4Jluy5hhGv27 6S2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=G0CRqLqXvRiG1/XBSQU7fXbBsXpuUCmZ+DzzZxxUzIo=; b=lk93lkMlVuolZMvKnZjkBDarpvvDRWlRFSHBBdev/o0Taj07iiy6oFI0/zowQJpA/U rppQEHsSYpvsZ6tG9XQBVKy1xg2nKng5SY3sVSk6zWB1gMg/Q4D92vYvQSQduIDJ184q LqONGsbc7LgtnXIjVzimr8Hl9N3ry9GTBVpg3+ySaGePqbb28g/EWKhsIJoWLF7ii+5H 3gjTOwIedrjhTjLG1YLYUZNgaj254Tb0uhXpYIj5EnPrxHl2IPyRhwHDtv1nmH0a2Z/l UmC+hTwEUp8X9lhC66kbfX4Lmk895+v8Ap7DlRHNpXU5n3DjYvhXkO/WMKz0CFmIOUTM ahTw== X-Gm-Message-State: AOAM530CxwT7cnF7trpSk/5H5v+n3X8uth5ZskGlGas/La7JlUZITclz 5m+ucLMH9HICADzWTUpGTVpfMw7hlxqHhg== X-Received: from dbrazdil.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:7f9b]) (user=dbrazdil job=sendgmr) by 2002:adf:fb05:: with SMTP id c5mr3869165wrr.302.1617197463183; Wed, 31 Mar 2021 06:31:03 -0700 (PDT) Date: Wed, 31 Mar 2021 13:30:48 +0000 Message-Id: <20210331133048.63311-1-dbrazdil@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog Subject: [PATCH] KVM: arm64: Support PREL/PLT relocs in EL2 code From: David Brazdil To: kvmarm@lists.cs.columbia.edu Cc: Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, David Brazdil Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gen-hyprel tool parses object files of the EL2 portion of KVM and generates runtime relocation data. While only filtering for R_AARCH64_ABS64 relocations in the input object files, it has an allow-list of relocation types that are used for relative addressing. Other, unexpected, relocation types are rejected and cause the build to fail. This allow-list did not include the position-relative relocation types R_AARCH64_PREL64/32/16 and the recently introduced _PLT32. While not seen used by toolchains in the wild, add them to the allow-list for completeness. Fixes: 8c49b5d43d4c ("KVM: arm64: Generate hyp relocation data") Cc: Reported-by: Will Deacon Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/gen-hyprel.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/gen-hyprel.c b/arch/arm64/kvm/hyp/nvhe/gen-hyprel.c index ead02c6a7628..6bc88a756cb7 100644 --- a/arch/arm64/kvm/hyp/nvhe/gen-hyprel.c +++ b/arch/arm64/kvm/hyp/nvhe/gen-hyprel.c @@ -50,6 +50,18 @@ #ifndef R_AARCH64_ABS64 #define R_AARCH64_ABS64 257 #endif +#ifndef R_AARCH64_PREL64 +#define R_AARCH64_PREL64 260 +#endif +#ifndef R_AARCH64_PREL32 +#define R_AARCH64_PREL32 261 +#endif +#ifndef R_AARCH64_PREL16 +#define R_AARCH64_PREL16 262 +#endif +#ifndef R_AARCH64_PLT32 +#define R_AARCH64_PLT32 314 +#endif #ifndef R_AARCH64_LD_PREL_LO19 #define R_AARCH64_LD_PREL_LO19 273 #endif @@ -371,6 +383,12 @@ static void emit_rela_section(Elf64_Shdr *sh_rela) case R_AARCH64_ABS64: emit_rela_abs64(rela, sh_orig_name); break; + /* Allow position-relative data relocations. */ + case R_AARCH64_PREL64: + case R_AARCH64_PREL32: + case R_AARCH64_PREL16: + case R_AARCH64_PLT32: + break; /* Allow relocations to generate PC-relative addressing. */ case R_AARCH64_LD_PREL_LO19: case R_AARCH64_ADR_PREL_LO21: -- 2.31.0.291.g576ba9dcdaf-goog