From patchwork Fri Jun 14 03:07:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 10994161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE29A14C0 for ; Fri, 14 Jun 2019 03:18:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E059E2623D for ; Fri, 14 Jun 2019 03:18:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D47E027CF9; Fri, 14 Jun 2019 03:18:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 66E882623D for ; Fri, 14 Jun 2019 03:18:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=oj7JrtYS1CUNDqinSc0kNkx/RLjQPdcL+7WB8XEckus=; b=UffnYM3/CVIOOz /Z48NHrt7FrUZP6rkw7wGQRkW1UfkDgt5MzTCVPDOulv5NQjS82DThwtWoPGcZ248xaFthQh0D2aP TlEOQTsDmbaZZVwLM4rFZywXlde7PCzho0/XH9HZuzMG/ZkVeewXr4zFfXidWU5Vnxt5cL4NYiQHx wLAq2WHffWs4NEjmdfzxSbSO4+WqAlAZ+EhQndZQYbIS8HVWHpGjBolUSV1WUoDPRLe0vu9GaoFFu TnhBcMDS5WZddD41vwBtXUfHI2T27Oa2NJLZeq4iQq/k/7xdy085ASGYwyC39t6MxVqeXDf4R/BCZ nj7lcBkQllwzd9//sV1g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hbcj5-0006N3-0D; Fri, 14 Jun 2019 03:18:03 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hbcdp-0000RB-Su for linux-arm-kernel@lists.infradead.org; Fri, 14 Jun 2019 03:12:40 +0000 Received: by mail-pg1-x544.google.com with SMTP id d30so671931pgm.7 for ; Thu, 13 Jun 2019 20:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FJU6AKZYmaWbov8SdJbQnRPRbYy33d5KJviuZzujVLk=; b=YrcvAeSGhO45tP17Rj0WtR5s4BK3jEYUh+NId6My01EnBc6fQOndzVVJcCKlZPE2sv AlQwDjj6xSPf9flbs2HG1+hEd661VSkzhWlQK/h3zMp5Pq7SG2Ow6UQ5P82Qte7XZyOh /p5/Y/dMH9ybqE6m4ws6cqKEaegYm6Xh7fC4jivkqpTJoB0hDGQP1aXo6RK6WNYGGCht 8MN6NHlgIhl3XzSqPXCCspLAQ/1Wjx+Yo7BEpV0L2NmIofv8gWJnupmYazoGkvEg3ShG 8oQDdplctgWkaKaUmIsAJVf8q/LWWoWRLO6JczPvHL4xVwrDGCfd1I2j4dhbi0Mlr99X WT4Q== 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=FJU6AKZYmaWbov8SdJbQnRPRbYy33d5KJviuZzujVLk=; b=EHXIxV/EdbzdHw+x46cDLxaglIMRmZqynxFmh+RYhmcEjXblbFZnHV84Ibp/tDFiPD wr+MkyyrsnpS/Hrqq+kbhJHcKxQ0Eab2TvTI0/TY56KTPUBiC/uftxbEPNzE7z3JzwSb Mb62SaLEpctbe8rAG5xRPNo/CiJuVK9R0gJrVvqlZ5DUFoMzRvNJd4JRLeK+tqbfFBq/ M1Qegb8y4ZaChi2n86a0IkJ7kTYbVFb05nouROrTIQNBLFJav/WGR8xs/NFaLdQsv68N bCI6rlt/wyjUF5qVLNrzYA/Wuc5TVkQvA+opy+u+hTktm6jh7YusGKKBXy++7yfeHdSH bOnw== X-Gm-Message-State: APjAAAXOvk9mrq/B3CWM5B+f7QHjUA5uir2u2hKTErNybg67X1ddn5IQ okGoXBnIaOjJ6Xak/FROYfcBCKycMwE= X-Google-Smtp-Source: APXvYqy+Qor9YksPPwljQlQQ6K2Ur1FZpSd7AAt7mUVgH3K8wVHk409FP9xAx/VeWdPCnT1Y+P0quQ== X-Received: by 2002:a62:6143:: with SMTP id v64mr59569090pfb.42.1560481956440; Thu, 13 Jun 2019 20:12:36 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id 85sm1140276pgb.52.2019.06.13.20.12.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 20:12:35 -0700 (PDT) From: Viresh Kumar To: linux-arm-kernel@lists.infradead.org, Julien Thierry Subject: [PATCH v4.4 16/45] arm64: Move post_ttbr_update_workaround to C code Date: Fri, 14 Jun 2019 08:37:59 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190613_201238_042234_A386735E X-CRM114-Status: GOOD ( 11.42 ) 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 , Marc Zyngier , Viresh Kumar , Will Deacon , stable@vger.kernel.org, mark.brown@arm.com, Catalin Marinas , Russell King Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier commit 95e3de3590e3f2358bb13f013911bc1bfa5d3f53 upstream. We will soon need to invoke a CPU-specific function pointer after changing page tables, so move post_ttbr_update_workaround out into C code to make this possible. Signed-off-by: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas [ v4.4: Removed cpufeature.h, included alternative.h, dropped entry.S changes and adapted to drop alternative_if_not ] Signed-off-by: Viresh Kumar --- arch/arm64/include/asm/assembler.h | 18 ------------------ arch/arm64/mm/context.c | 10 ++++++++++ arch/arm64/mm/proc.S | 3 +-- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index 8ab46508e836..2b30363a3a89 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -23,7 +23,6 @@ #ifndef __ASM_ASSEMBLER_H #define __ASM_ASSEMBLER_H -#include #include #include #include @@ -283,21 +282,4 @@ lr .req x30 // link register .Ldone\@: .endm -/* - * Errata workaround post TTBR0_EL1 update. - */ - .macro post_ttbr0_update_workaround -#ifdef CONFIG_CAVIUM_ERRATUM_27456 -alternative_if_not ARM64_WORKAROUND_CAVIUM_27456 - ret - nop - nop - nop -alternative_else - ic iallu - dsb nsh - isb -#endif - .endm - #endif /* __ASM_ASSEMBLER_H */ diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c index e87f53ff5f58..492d2968fa8f 100644 --- a/arch/arm64/mm/context.c +++ b/arch/arm64/mm/context.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -185,6 +186,15 @@ void check_and_switch_context(struct mm_struct *mm, unsigned int cpu) cpu_switch_mm(mm->pgd, mm); } +/* Errata workaround post TTBRx_EL1 update. */ +asmlinkage void post_ttbr_update_workaround(void) +{ + asm(ALTERNATIVE("nop; nop; nop", + "ic iallu; dsb nsh; isb", + ARM64_WORKAROUND_CAVIUM_27456, + CONFIG_CAVIUM_ERRATUM_27456)); +} + static int asids_init(void) { int fld = cpuid_feature_extract_field(read_cpuid(ID_AA64MMFR0_EL1), 4); diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S index 4eb1084e203a..a70b712ca94a 100644 --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S @@ -139,8 +139,7 @@ ENTRY(cpu_do_switch_mm) bfi x0, x1, #48, #16 // set the ASID msr ttbr0_el1, x0 // set TTBR0 isb - post_ttbr0_update_workaround - ret + b post_ttbr_update_workaround // Back to C code... ENDPROC(cpu_do_switch_mm) .section ".text.init", #alloc, #execinstr