Received: by 10.223.185.116 with SMTP id b49csp2559572wrg; Thu, 15 Feb 2018 13:38:43 -0800 (PST) X-Google-Smtp-Source: AH8x224Af2zqSfi+sexnCT8iWRMH/400IpZaMNMv/eiLM67Gku8JJjMPSYV2RbXJ5fZIgmxy3DHe X-Received: by 10.99.64.197 with SMTP id n188mr3312837pga.21.1518730723348; Thu, 15 Feb 2018 13:38:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518730723; cv=none; d=google.com; s=arc-20160816; b=O95Y8Mq5gBChfzog9vKdasYXdqYWeQjL+kTwIhyAkXz9KWSme0tIIveLbArVhTfMpo sSY6xiAAw+Wde478fyE7z7uFLE/tl2zYUcm2fGF9G6a5JVaQuF1ZLyrS1tdSwHRRr+BA y7VgtWX5/Ta0Dceh/jMD8shNbWsG5C3WD0/1HM4IAwcXITD3Da1qNmbJPaGopcQ4xlWU B4vZkAhv9k/X5qPFIBZy3As/g63L8Yu3kMj8brdaOtoO1QyITddsEECJych2k0r/PmSO qD9aWglH9Xp3CseF9YSl/bC0EyjQGziQmtzm0+2arB4bAGRRxkehw+px0yRMpZwA+oKS TQrA== 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=4kHOqRFARhpcj5YXNyqEQ4QDS5Bp8s14z1sB2ZwUT4g=; b=qfZpIvtpiLghxxK+BQmt7xbsKA92uxCFkrIYTkvw95UfkbGASJf7vsvTzEOLJWirFB ojRS0XjsdyBHP+nvYULRmNfqDw+5tAKeQ25EcHv6DKQxDLnXHTDPIzpV+nx8I5c3bb74 BZF76j0XfvhoYaW7oTHtAJkA8TGUs0NW2Jo62J+qzxnayGa+U1/xMmlNPse9rZIW1sRX s8SDVkwwp7cZ3jTfSTYNGINuI1yWp0/SWwWD9ZJuSMBdIGonR5WjV+DSg2/1JoRqMugl htQU7R5ZOlfQ01p7LXLuU6Fp9f58QKktksAw6KWzsR6I0mm7CkHRa2LUz9Az4p2NPige qg/Q== 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 s21si4402460pfm.325.2018.02.15.13.38.28; Thu, 15 Feb 2018 13:38:43 -0800 (PST) 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 S1164463AbeBOPbl (ORCPT + 99 others); Thu, 15 Feb 2018 10:31:41 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:55996 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164416AbeBOPbg (ORCPT ); Thu, 15 Feb 2018 10:31:36 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 29956E7F; Thu, 15 Feb 2018 15:31:36 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Laura Abbott , Shanker Donthineni , Will Deacon , Ard Biesheuvel Subject: [PATCH 4.14 046/195] [Variant 3/Meltdown] arm64: mm: Introduce TTBR_ASID_MASK for getting at the ASID in the TTBR Date: Thu, 15 Feb 2018 16:15:37 +0100 Message-Id: <20180215151708.038968792@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@linuxfoundation.org> User-Agent: quilt/0.65 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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Will Deacon Commit b519538dfefc upstream. There are now a handful of open-coded masks to extract the ASID from a TTBR value, so introduce a TTBR_ASID_MASK and use that instead. Suggested-by: Mark Rutland Reviewed-by: Mark Rutland Tested-by: Laura Abbott Tested-by: Shanker Donthineni Signed-off-by: Will Deacon Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/asm-uaccess.h | 3 ++- arch/arm64/include/asm/mmu.h | 1 + arch/arm64/include/asm/uaccess.h | 4 ++-- arch/arm64/kernel/entry.S | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) --- a/arch/arm64/include/asm/asm-uaccess.h +++ b/arch/arm64/include/asm/asm-uaccess.h @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -17,7 +18,7 @@ msr ttbr0_el1, \tmp1 // set reserved TTBR0_EL1 isb sub \tmp1, \tmp1, #SWAPPER_DIR_SIZE - bic \tmp1, \tmp1, #(0xffff << 48) + bic \tmp1, \tmp1, #TTBR_ASID_MASK msr ttbr1_el1, \tmp1 // set reserved ASID isb .endm --- a/arch/arm64/include/asm/mmu.h +++ b/arch/arm64/include/asm/mmu.h @@ -18,6 +18,7 @@ #define MMCF_AARCH32 0x1 /* mm context flag for AArch32 executables */ #define USER_ASID_FLAG (UL(1) << 48) +#define TTBR_ASID_MASK (UL(0xffff) << 48) #ifndef __ASSEMBLY__ --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -112,7 +112,7 @@ static inline void __uaccess_ttbr0_disab write_sysreg(ttbr + SWAPPER_DIR_SIZE, ttbr0_el1); isb(); /* Set reserved ASID */ - ttbr &= ~(0xffffUL << 48); + ttbr &= ~TTBR_ASID_MASK; write_sysreg(ttbr, ttbr1_el1); isb(); } @@ -131,7 +131,7 @@ static inline void __uaccess_ttbr0_enabl /* Restore active ASID */ ttbr1 = read_sysreg(ttbr1_el1); - ttbr1 |= ttbr0 & (0xffffUL << 48); + ttbr1 |= ttbr0 & TTBR_ASID_MASK; write_sysreg(ttbr1, ttbr1_el1); isb(); --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -205,7 +205,7 @@ alternative_else_nop_endif .if \el != 0 mrs x21, ttbr1_el1 - tst x21, #0xffff << 48 // Check for the reserved ASID + tst x21, #TTBR_ASID_MASK // Check for the reserved ASID orr x23, x23, #PSR_PAN_BIT // Set the emulated PAN in the saved SPSR b.eq 1f // TTBR0 access already disabled and x23, x23, #~PSR_PAN_BIT // Clear the emulated PAN in the saved SPSR