Received: by 10.213.65.68 with SMTP id h4csp714415imn; Fri, 6 Apr 2018 07:43:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+h92HJPEI63PmqDDikaviEaW3Omc7BA5qBcPmEzQduvey5wFcCy/8DGdpPdICaLF+b5d29 X-Received: by 2002:a17:902:850b:: with SMTP id bj11-v6mr27955525plb.35.1523025822877; Fri, 06 Apr 2018 07:43:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523025822; cv=none; d=google.com; s=arc-20160816; b=sseuy0uR0yDccirIc+RN/uskcosFjDwUGVHw5JL8fQ7Dyg4p9A4wDOq5UeobjYe/Zu UpQD6Gel7iVAFRhciy5k3tzNMpnlNh4M6hQ2Sq5DYgThfhXv+2T7itgY4tx3RR17YHtj A3kVzjSDDF9b3gPT82gEzxbqDAjmEuilMyMnBc4p5AypPRRW94bLZONjQO6vjbeSxCcJ YNg+S+VktLjcm0lOkG9gRCYyLatHTFL+JDM+jQU6uFdfWNxYNVGpCclKsqvoKDwYAaPj yU0osboZrSSXuL9V2sMbe7oOYKLcIJoqCr6ys6Sgb+1mMV7NM7RlxwCAo0RnH9Th7Riq BoMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=w9E5D5irbPQAGQRuGlut8ydCvsF3+aN1yoWQGIzbiEc=; b=lGJVcVeiBZVL2ukxkGmWXk9mU4cTrbWv7fK8iubS32Thzs2ou5qNYq0gCIyPnfa163 xUqfSzplngsSburbAeM9iKEx1pEb4aqlYHE32uewCdSJCqytiB3BJClnfb/OTr5nMWXm h+2EQw2KsXyMXBNGk156o63qxRisuvFWyzPYsQv6ardJmN+ZG2m8IHI3SBKRME3+Vn8g 1R3CQGHU9mRskErjTXGH+2z5dkj4pF0rHxfE8KI5ktWmS1jOtTRYm/yD1/cLiqVLpQz8 7+Rsm+uDNiTxQSnBH72bok2YI/J/VGLdAfFxhz/ySaCCStJRiXNyh665wCp0ew3FIL6n WA1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1si7023413pgv.736.2018.04.06.07.43.28; Fri, 06 Apr 2018 07:43:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755911AbeDFNen (ORCPT + 99 others); Fri, 6 Apr 2018 09:34:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58420 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753046AbeDFNej (ORCPT ); Fri, 6 Apr 2018 09:34:39 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 80954D85; Fri, 6 Apr 2018 13:34:38 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Mark Rutland , Laura Abbott , Shanker Donthineni , Will Deacon , Greg Hackmann , Alex Shi Subject: [PATCH 4.9 051/102] arm64: mm: Move ASID from TTBR0 to TTBR1 Date: Fri, 6 Apr 2018 15:23:32 +0200 Message-Id: <20180406084338.789334380@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084331.507038179@linuxfoundation.org> References: <20180406084331.507038179@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Will Deacon commit 7655abb95386 upstream. In preparation for mapping kernelspace and userspace with different ASIDs, move the ASID to TTBR1 and update switch_mm to context-switch TTBR0 via an invalid mapping (the zero page). Reviewed-by: Mark Rutland Tested-by: Laura Abbott Tested-by: Shanker Donthineni Signed-off-by: Will Deacon Signed-off-by: Alex Shi [v4.9 backport] Signed-off-by: Mark Rutland [v4.9 backport] Tested-by: Will Deacon Tested-by: Greg Hackmann Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/mmu_context.h | 7 +++++++ arch/arm64/include/asm/pgtable-hwdef.h | 1 + arch/arm64/include/asm/proc-fns.h | 6 ------ arch/arm64/mm/proc.S | 9 ++++++--- 4 files changed, 14 insertions(+), 9 deletions(-) --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -50,6 +50,13 @@ static inline void cpu_set_reserved_ttbr isb(); } +static inline void cpu_switch_mm(pgd_t *pgd, struct mm_struct *mm) +{ + BUG_ON(pgd == swapper_pg_dir); + cpu_set_reserved_ttbr0(); + cpu_do_switch_mm(virt_to_phys(pgd),mm); +} + /* * TCR.T0SZ value to use when the ID map is active. Usually equals * TCR_T0SZ(VA_BITS), unless system RAM is positioned very high in --- a/arch/arm64/include/asm/pgtable-hwdef.h +++ b/arch/arm64/include/asm/pgtable-hwdef.h @@ -272,6 +272,7 @@ #define TCR_TG1_4K (UL(2) << TCR_TG1_SHIFT) #define TCR_TG1_64K (UL(3) << TCR_TG1_SHIFT) +#define TCR_A1 (UL(1) << 22) #define TCR_ASID16 (UL(1) << 36) #define TCR_TBI0 (UL(1) << 37) #define TCR_HA (UL(1) << 39) --- a/arch/arm64/include/asm/proc-fns.h +++ b/arch/arm64/include/asm/proc-fns.h @@ -35,12 +35,6 @@ extern u64 cpu_do_resume(phys_addr_t ptr #include -#define cpu_switch_mm(pgd,mm) \ -do { \ - BUG_ON(pgd == swapper_pg_dir); \ - cpu_do_switch_mm(virt_to_phys(pgd),mm); \ -} while (0) - #endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */ #endif /* __ASM_PROCFNS_H */ --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S @@ -132,9 +132,12 @@ ENDPROC(cpu_do_resume) * - pgd_phys - physical address of new TTB */ ENTRY(cpu_do_switch_mm) + mrs x2, ttbr1_el1 mmid x1, x1 // get mm->context.id - bfi x0, x1, #48, #16 // set the ASID - msr ttbr0_el1, x0 // set TTBR0 + bfi x2, x1, #48, #16 // set the ASID + msr ttbr1_el1, x2 // in TTBR1 (since TCR.A1 is set) + isb + msr ttbr0_el1, x0 // now update TTBR0 isb alternative_if ARM64_WORKAROUND_CAVIUM_27456 ic iallu @@ -222,7 +225,7 @@ ENTRY(__cpu_setup) * both user and kernel. */ ldr x10, =TCR_TxSZ(VA_BITS) | TCR_CACHE_FLAGS | TCR_SMP_FLAGS | \ - TCR_TG_FLAGS | TCR_ASID16 | TCR_TBI0 + TCR_TG_FLAGS | TCR_ASID16 | TCR_TBI0 | TCR_A1 tcr_set_idmap_t0sz x10, x9 /*