From patchwork Fri Mar 5 20:21:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 12119429 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=-21.8 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,MENTIONS_GIT_HOSTING, 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 7AF1DC433E0 for ; Fri, 5 Mar 2021 20:23:19 +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 BF3116509F for ; Fri, 5 Mar 2021 20:23:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF3116509F 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:Mime-Version:Message-Id:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=UETrOzgd9dEESlMF+PehcFSDmncigthsw23iq4487EU=; b=q+2IsceE++AhqrHPD6UsW6lZHR ZD3Bof6Yg8oOYNHZpQyuVmCgalIZx8LYvqN5uhDMRKOwu6low9+bfzuHJ3Y+/28IIpp1LYY52mMGU WuoDkEwYbkH52ZrkjdHtLCuuTLxQd1wYxhVb3jkXSo4FIsqS7opC8i7kPoFxdO9kKzbO83XaadTou 2HSVjTW+X2kn0+jpIRKu0a5op7Q3trTHyHGQDGNy4kW14m7oMOBEJVHkN0RE2qtKfzI/sHEpCjtQ8 +C8EsDW4pEw0Ouzpp/QFx5Wn9HjDI34bidDy11NtZ7tttNNmGUQkGcqkPAUZkkLSBZCICVxzuKM03 EiLI2Keg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lIGx6-00GLOo-RQ; Fri, 05 Mar 2021 20:21:37 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lIGx0-00GLMd-VA for linux-arm-kernel@lists.infradead.org; Fri, 05 Mar 2021 20:21:33 +0000 Received: by mail-yb1-xb49.google.com with SMTP id v6so3714768ybk.9 for ; Fri, 05 Mar 2021 12:21:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=ulCKWwAgru14Pv0YBVciE6nHg3ZbaOajNEmz/MDhZ0E=; b=sUy/MKxPm0e0JaDZ61ZMVYmchygwUzsxZVRFhQ7ZB6rmk6BwKXl14SNbFoDUTOKgFa 0ZKz2GEdT6lCTv01QXUfs5j8jrrEPZnjznZ5fha2ou4kuOABBQfjF8z70CrDys7tlVir 3gH/EzvBcog9XTOaiVntPn9TJh0HdgKMRTYaEO86WDpFDX0uwo5S3c/KCefXmBFLTzLm i5NmOaBz7F/XIIWrZsaxhcpEb/dhSAGbBDiZYbh8quMAQGNavxnkkzMF+sGatxLHj9AC qKVBGb0/X80WMyGrAzKqxERNLhvZyx7tJI0leqSAdxwM+FfRUXZZ5xYLZX+NP18/qMl1 yNyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=ulCKWwAgru14Pv0YBVciE6nHg3ZbaOajNEmz/MDhZ0E=; b=CrahfXk8/bPNJ3DHRHZDshfIL4A9p92IFqvuQqESDI4RCPIiCqaeIIR6VoECj/HjLa 4Q67wDoo8rp25O96L+hGn9aWcsExw1sjuAcDsPIh/kM77hXy80VWtjqE+oqPGx2KBQZx 7xK+MqnEmwaT94HLOAH+NQN7Nf75HQGKVakZ5IzBHx7Xdvt9OmesQi9eukrgjf1BC55+ UB2n/OHWrbmB+sBtNs+C+tI50CbDhp3puwXCmJhRJRJaTj/8ES/s3RZbgPMeAas1UUFb n7ZZIdwfVVVJc0Ktr5c5RKSnW0jJ1YEOoYoAUR2f7Zvy/iGcXV6f3g3JxAwv+FgHXYi4 2TZw== X-Gm-Message-State: AOAM5314Mrdr9y7/KMEEMnuCb/1nHvwghqreZ7ZSHOHm/kLTiT2AFRyT cJW4eKOpMjZUkyqbkgIwGxQKQ/4kL8387N6M8uQ= X-Google-Smtp-Source: ABdhPJzugclOPUcMl5rWpXYbl208BWEimx+fJTo5zFfMCx70e7i5TD/OVFvRhSrWZ4lMnOshHJ+EWZ1oZ8vlNNhorTs= X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:1d29:d678:6e3a:704d]) (user=samitolvanen job=sendgmr) by 2002:a25:8706:: with SMTP id a6mr15467374ybl.158.1614975687742; Fri, 05 Mar 2021 12:21:27 -0800 (PST) Date: Fri, 5 Mar 2021 12:21:24 -0800 Message-Id: <20210305202124.3768527-1-samitolvanen@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH] KVM: arm64: Don't use cbz/adr with external symbols From: Sami Tolvanen To: Marc Zyngier , James Morse Cc: Nathan Chancellor , Nick Desaulniers , Ard Biesheuvel , Kees Cook , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, Sami Tolvanen X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210305_202131_510868_678D1691 X-CRM114-Status: GOOD ( 13.86 ) 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 allmodconfig + CONFIG_LTO_CLANG_THIN=y fails to build due to following linker errors: ld.lld: error: irqbypass.c:(function __guest_enter: .text+0x21CC): relocation R_AARCH64_CONDBR19 out of range: 2031220 is not in [-1048576, 1048575]; references hyp_panic >>> defined in vmlinux.o ld.lld: error: irqbypass.c:(function __guest_enter: .text+0x21E0): relocation R_AARCH64_ADR_PREL_LO21 out of range: 2031200 is not in [-1048576, 1048575]; references hyp_panic >>> defined in vmlinux.o This is because with LTO, the compiler ends up placing hyp_panic() more than 1MB away from __guest_enter(). Use an unconditional branch and adr_l instead to fix the issue. Link: https://github.com/ClangBuiltLinux/linux/issues/1317 Reported-by: Nathan Chancellor Suggested-by: Marc Zyngier Suggested-by: Ard Biesheuvel Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook Tested-by: Nathan Chancellor Acked-by: Will Deacon --- arch/arm64/kvm/hyp/entry.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) base-commit: 280d542f6ffac0e6d65dc267f92191d509b13b64 diff --git a/arch/arm64/kvm/hyp/entry.S b/arch/arm64/kvm/hyp/entry.S index b0afad7a99c6..c62265951467 100644 --- a/arch/arm64/kvm/hyp/entry.S +++ b/arch/arm64/kvm/hyp/entry.S @@ -85,8 +85,10 @@ SYM_INNER_LABEL(__guest_exit_panic, SYM_L_GLOBAL) // If the hyp context is loaded, go straight to hyp_panic get_loaded_vcpu x0, x1 - cbz x0, hyp_panic + cbnz x0, 1f + b hyp_panic +1: // The hyp context is saved so make sure it is restored to allow // hyp_panic to run at hyp and, subsequently, panic to run in the host. // This makes use of __guest_exit to avoid duplication but sets the @@ -94,7 +96,7 @@ SYM_INNER_LABEL(__guest_exit_panic, SYM_L_GLOBAL) // current state is saved to the guest context but it will only be // accurate if the guest had been completely restored. adr_this_cpu x0, kvm_hyp_ctxt, x1 - adr x1, hyp_panic + adr_l x1, hyp_panic str x1, [x0, #CPU_XREG_OFFSET(30)] get_vcpu_ptr x1, x0