From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752030AbdAaMjR (ORCPT ); Tue, 31 Jan 2017 07:39:17 -0500 Received: from foss.arm.com ([217.140.101.70]:36822 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751726AbdAaMjM (ORCPT ); Tue, 31 Jan 2017 07:39:12 -0500 Date: Tue, 31 Jan 2017 12:37:36 +0000 From: Mark Rutland To: Christopher Covington Cc: Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Christoffer Dall , Marc Zyngier , Catalin Marinas , Will Deacon , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, shankerd@codeaurora.org, timur@codeaurora.org, Jonathan Corbet , linux-doc@vger.kernel.org, Jon Masters , Neil Leeder , Mark Langsdorf Subject: Re: [PATCH v4 2/4] arm64: Work around Falkor erratum 1003 Message-ID: <20170131123735.GD11191@leverpostej> References: <20170125155232.10277-1-cov@codeaurora.org> <20170125155232.10277-2-cov@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170125155232.10277-2-cov@codeaurora.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 25, 2017 at 10:52:30AM -0500, Christopher Covington wrote: > The Qualcomm Datacenter Technologies Falkor v1 CPU may allocate TLB entries > using an incorrect ASID when TTBRx_EL1 is being updated. When the erratum > is triggered, page table entries using the new translation table base > address (BADDR) will be allocated into the TLB using the old ASID. All > circumstances leading to the incorrect ASID being cached in the TLB arise > when software writes TTBRx_EL1[ASID] and TTBRx_EL1[BADDR], a memory > operation is in the process of performing a translation using the specific > TTBRx_EL1 being written, and the memory operation uses a translation table > descriptor designated as non-global. EL2 and EL3 code changing the EL1&0 > ASID is not subject to this erratum because hardware is prohibited from > performing translations from an out-of-context translation regime. > > Consider the following pseudo code. > > write new BADDR and ASID values to TTBRx_EL1 > > Replacing the above sequence with the one below will ensure that no TLB > entries with an incorrect ASID are used by software. > > write reserved value to TTBRx_EL1[ASID] > ISB > write new value to TTBRx_EL1[BADDR] > ISB > write new value to TTBRx_EL1[ASID] > ISB > > When the above sequence is used, page table entries using the new BADDR > value may still be incorrectly allocated into the TLB using the reserved > ASID. Yet this will not reduce functionality, since TLB entries incorrectly > tagged with the reserved ASID will never be hit by a later instruction. Based on my understanding that entries allocated to the reserved ASID will not be used for subsequent page table walks (and so we don't have asynchronous behaviour to contend with), this sounds fine to me. Thanks for taking the time to clarify the details on that. > Based on work by Shanker Donthineni > > Signed-off-by: Christopher Covington > --- > Documentation/arm64/silicon-errata.txt | 1 + > arch/arm64/Kconfig | 11 +++++++++++ > arch/arm64/include/asm/assembler.h | 23 +++++++++++++++++++++++ > arch/arm64/include/asm/cpucaps.h | 3 ++- > arch/arm64/include/asm/mmu_context.h | 8 +++++++- > arch/arm64/kernel/cpu_errata.c | 7 +++++++ > arch/arm64/mm/context.c | 11 +++++++++++ > arch/arm64/mm/proc.S | 1 + > 8 files changed, 63 insertions(+), 2 deletions(-) Don't we need to use pre_ttbr0_update_workaround in for CONFIG_ARM64_SW_TTBR0_PAN? We implicitly switch to the reserved ASID for the empty table in __uaccess_ttbr0_disable. That also means we have to invalidate the reserved ASID so as to not accidentally hit while uaccess is disabled. Thanks, Mark. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Rutland Subject: Re: [PATCH v4 2/4] arm64: Work around Falkor erratum 1003 Date: Tue, 31 Jan 2017 12:37:36 +0000 Message-ID: <20170131123735.GD11191@leverpostej> References: <20170125155232.10277-1-cov@codeaurora.org> <20170125155232.10277-2-cov@codeaurora.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Mark Langsdorf , linux-doc@vger.kernel.org, kvm@vger.kernel.org, Marc Zyngier , Catalin Marinas , timur@codeaurora.org, Jonathan Corbet , Will Deacon , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Neil Leeder , Jon Masters , Paolo Bonzini , kvmarm@lists.cs.columbia.edu To: Christopher Covington Return-path: Content-Disposition: inline In-Reply-To: <20170125155232.10277-2-cov@codeaurora.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu List-Id: kvm.vger.kernel.org On Wed, Jan 25, 2017 at 10:52:30AM -0500, Christopher Covington wrote: > The Qualcomm Datacenter Technologies Falkor v1 CPU may allocate TLB entries > using an incorrect ASID when TTBRx_EL1 is being updated. When the erratum > is triggered, page table entries using the new translation table base > address (BADDR) will be allocated into the TLB using the old ASID. All > circumstances leading to the incorrect ASID being cached in the TLB arise > when software writes TTBRx_EL1[ASID] and TTBRx_EL1[BADDR], a memory > operation is in the process of performing a translation using the specific > TTBRx_EL1 being written, and the memory operation uses a translation table > descriptor designated as non-global. EL2 and EL3 code changing the EL1&0 > ASID is not subject to this erratum because hardware is prohibited from > performing translations from an out-of-context translation regime. > > Consider the following pseudo code. > > write new BADDR and ASID values to TTBRx_EL1 > > Replacing the above sequence with the one below will ensure that no TLB > entries with an incorrect ASID are used by software. > > write reserved value to TTBRx_EL1[ASID] > ISB > write new value to TTBRx_EL1[BADDR] > ISB > write new value to TTBRx_EL1[ASID] > ISB > > When the above sequence is used, page table entries using the new BADDR > value may still be incorrectly allocated into the TLB using the reserved > ASID. Yet this will not reduce functionality, since TLB entries incorrectly > tagged with the reserved ASID will never be hit by a later instruction. Based on my understanding that entries allocated to the reserved ASID will not be used for subsequent page table walks (and so we don't have asynchronous behaviour to contend with), this sounds fine to me. Thanks for taking the time to clarify the details on that. > Based on work by Shanker Donthineni > > Signed-off-by: Christopher Covington > --- > Documentation/arm64/silicon-errata.txt | 1 + > arch/arm64/Kconfig | 11 +++++++++++ > arch/arm64/include/asm/assembler.h | 23 +++++++++++++++++++++++ > arch/arm64/include/asm/cpucaps.h | 3 ++- > arch/arm64/include/asm/mmu_context.h | 8 +++++++- > arch/arm64/kernel/cpu_errata.c | 7 +++++++ > arch/arm64/mm/context.c | 11 +++++++++++ > arch/arm64/mm/proc.S | 1 + > 8 files changed, 63 insertions(+), 2 deletions(-) Don't we need to use pre_ttbr0_update_workaround in for CONFIG_ARM64_SW_TTBR0_PAN? We implicitly switch to the reserved ASID for the empty table in __uaccess_ttbr0_disable. That also means we have to invalidate the reserved ASID so as to not accidentally hit while uaccess is disabled. Thanks, Mark. From mboxrd@z Thu Jan 1 00:00:00 1970 From: mark.rutland@arm.com (Mark Rutland) Date: Tue, 31 Jan 2017 12:37:36 +0000 Subject: [PATCH v4 2/4] arm64: Work around Falkor erratum 1003 In-Reply-To: <20170125155232.10277-2-cov@codeaurora.org> References: <20170125155232.10277-1-cov@codeaurora.org> <20170125155232.10277-2-cov@codeaurora.org> Message-ID: <20170131123735.GD11191@leverpostej> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Wed, Jan 25, 2017 at 10:52:30AM -0500, Christopher Covington wrote: > The Qualcomm Datacenter Technologies Falkor v1 CPU may allocate TLB entries > using an incorrect ASID when TTBRx_EL1 is being updated. When the erratum > is triggered, page table entries using the new translation table base > address (BADDR) will be allocated into the TLB using the old ASID. All > circumstances leading to the incorrect ASID being cached in the TLB arise > when software writes TTBRx_EL1[ASID] and TTBRx_EL1[BADDR], a memory > operation is in the process of performing a translation using the specific > TTBRx_EL1 being written, and the memory operation uses a translation table > descriptor designated as non-global. EL2 and EL3 code changing the EL1&0 > ASID is not subject to this erratum because hardware is prohibited from > performing translations from an out-of-context translation regime. > > Consider the following pseudo code. > > write new BADDR and ASID values to TTBRx_EL1 > > Replacing the above sequence with the one below will ensure that no TLB > entries with an incorrect ASID are used by software. > > write reserved value to TTBRx_EL1[ASID] > ISB > write new value to TTBRx_EL1[BADDR] > ISB > write new value to TTBRx_EL1[ASID] > ISB > > When the above sequence is used, page table entries using the new BADDR > value may still be incorrectly allocated into the TLB using the reserved > ASID. Yet this will not reduce functionality, since TLB entries incorrectly > tagged with the reserved ASID will never be hit by a later instruction. Based on my understanding that entries allocated to the reserved ASID will not be used for subsequent page table walks (and so we don't have asynchronous behaviour to contend with), this sounds fine to me. Thanks for taking the time to clarify the details on that. > Based on work by Shanker Donthineni > > Signed-off-by: Christopher Covington > --- > Documentation/arm64/silicon-errata.txt | 1 + > arch/arm64/Kconfig | 11 +++++++++++ > arch/arm64/include/asm/assembler.h | 23 +++++++++++++++++++++++ > arch/arm64/include/asm/cpucaps.h | 3 ++- > arch/arm64/include/asm/mmu_context.h | 8 +++++++- > arch/arm64/kernel/cpu_errata.c | 7 +++++++ > arch/arm64/mm/context.c | 11 +++++++++++ > arch/arm64/mm/proc.S | 1 + > 8 files changed, 63 insertions(+), 2 deletions(-) Don't we need to use pre_ttbr0_update_workaround in for CONFIG_ARM64_SW_TTBR0_PAN? We implicitly switch to the reserved ASID for the empty table in __uaccess_ttbr0_disable. That also means we have to invalidate the reserved ASID so as to not accidentally hit while uaccess is disabled. Thanks, Mark.