From mboxrd@z Thu Jan 1 00:00:00 1970 From: ddaney@caviumnetworks.com (David Daney) Date: Wed, 10 Feb 2016 10:42:18 -0800 Subject: [PATCH] arm64: Add workaround for Cavium erratum 27456 In-Reply-To: <20160210181522.GW1052@arm.com> References: <1455046156-10582-1-git-send-email-ddaney.cavm@gmail.com> <20160210092822.GA1052@arm.com> <56BB7C91.5010205@caviumnetworks.com> <20160210181522.GW1052@arm.com> Message-ID: <56BB848A.6060603@caviumnetworks.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 02/10/2016 10:15 AM, Will Deacon wrote: > On Wed, Feb 10, 2016 at 10:08:17AM -0800, David Daney wrote: >> On 02/10/2016 01:28 AM, Will Deacon wrote: >>> On Tue, Feb 09, 2016 at 11:29:16AM -0800, David Daney wrote: >>>> From: Andrew Pinski >>>> >>>> On ThunderX T88 pass 1.x through 2.1 parts, broadcast TLBI >>>> instructions may cause the icache to become invalid if it contains >>>> data for a non-current ASID. >>>> >>>> This patch implements the workaround (which flushes the local icache >>>> when switching the mm) by using code patching. >>> >>> So, to be clear, is this "just" a performance problem as opposed to a >>> correctness issue? >> >> No. It is a correctness issue. Without this workaround in place, userspace >> programs end up executing the wrong instructions, which leads to >> unpredictable behavior and program crashes. > > Ok, so I think the description in the commit log isn't quite right. An > "invalid" line in i-cache simply means that it needs to be refetched. > What you're talking about sounds like data corruption. Yes. I guess I will be sending v3 with an improved description. > > I also don't understand how the workaround fixes things like TLBIs due > to copy-on-write faults triggered by another core. Caveat: I don't fully understand the internal ICache implementation details. But ... External broadcast TLBIs arriving for the current ASID (as set in TTBR0_EL1) are handled properly. The issue is that cached data for other ASIDs, under some circumstances, may be inadvertently "blessed" into the current ASID. If we take care that no data for "foreign" ASIDs is in the Icache, the problematical case can never occur. > Also, what's the > interaction with virtual machines, or is the VMID not affected in the > same way as the ASID? Ah, the $10^6 question. Current information on how this interacts with KVM is less well developed. We think the workaround doesn't cause failures in virtual machines. I realize that this is different than asserting that virtual machines are guaranteed to operate error free. > > Sorry to be a pain on this, but we need to understand the issue well > enough to maintain the workaround in the future! > >>> If so, do you have any numbers with and without this >>> change? >> >> We tried to measure it, but the impact is not measurable in the tests we >> have done. Switching the mm is not often done so the extra ICache >> invalidation is rare. > > Oh, sure. I was only interested in perf figures if this was a performance > problem rather than a functional one. > > Will > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752952AbcBJSm1 (ORCPT ); Wed, 10 Feb 2016 13:42:27 -0500 Received: from mail-bl2on0081.outbound.protection.outlook.com ([65.55.169.81]:29856 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752415AbcBJSmZ (ORCPT ); Wed, 10 Feb 2016 13:42:25 -0500 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=caviumnetworks.com; Message-ID: <56BB848A.6060603@caviumnetworks.com> Date: Wed, 10 Feb 2016 10:42:18 -0800 From: David Daney User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Will Deacon CC: David Daney , , Mark Rutland , Catalin Marinas , Marc Zyngier , , Andrew Pinski , David Daney Subject: Re: [PATCH] arm64: Add workaround for Cavium erratum 27456 References: <1455046156-10582-1-git-send-email-ddaney.cavm@gmail.com> <20160210092822.GA1052@arm.com> <56BB7C91.5010205@caviumnetworks.com> <20160210181522.GW1052@arm.com> In-Reply-To: <20160210181522.GW1052@arm.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [64.2.3.194] X-ClientProxiedBy: BLUPR07CA077.namprd07.prod.outlook.com (25.160.24.32) To CY1PR07MB2135.namprd07.prod.outlook.com (25.164.112.13) X-Microsoft-Exchange-Diagnostics: 1;CY1PR07MB2135;2:pGtP+ASVc0JbpsjyXZ3CilaryDWvFsPNgGuCC+bEk2O1R/vFUTd2WeV457Dmn1giXFs32aK5PYR8ni9VBOSrDVCOL3FAPQuWsHU0PrludvjR7c9QDddmKn5jm1SHNLRT5QNblhWlelq9Z+KCs1OB5w==;3:qqpLw2K52sW/EE4k4g0bOX9+CjmeqPz9weEIEI/Vy/4e4IJaeMiZ8q20jNfF1Nzi8g0J/avLGy0fbYx9eXs/ojaM4E+yEgkw6vgrSbx+2EdTbOlaixZBR1xAsqvavW8r;25:CHDSIFzdLnVJhezx9ucbZRNWFyy/+s63tCYvdZTuEmKPVDMHea4iHniFkVrtGRzN9kWklDFU+9/BnfzwOhr0KUZVLcJvbllQvQDb/CweAxbUr/vp2DJai0CUVaGdY7m1temDxzjO15hetY0eNnA8DhQav9JO/9Vs3BGugXJIAdH/IKCHj9hrIiCkFZy5WN7gbJK6ayO/90/AEV9MSKzLu5/wGRm491+8p97mRVOgbO1WPohhpXGsLnKdWQFPdERn/jA6YWschVhdjw+5fR0Icv1NWZCKKVf1hiWblHWn3G743EwuvaSY1LYV+qc4bsFR X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR07MB2135; X-MS-Office365-Filtering-Correlation-Id: d3a0f747-68d1-4d66-1757-08d33249ea67 X-Microsoft-Exchange-Diagnostics: 1;CY1PR07MB2135;20:SOB9SzmczlDiF8h84GiFC3mnx3AQ2swWsuQyuK3bpUX5UPafPtDZmMOoxCCqdCjU2dwOR1Zt88nSoFHryd4/Udv2qU9mVNbBVPvXfRuaLBCY2jGJq0JpNMLuVNFhYf41IrPVK+H6D89VyYyjZR8FbeH2l2Lbzn5/CQMZT7IgWHkzMd9+W6Jxgneu2jdQSCSz0woGWKnJp/ArNfLucShxgL2XLInf4H72cd5IvVuiJycIY01IAmb4z6dzzZrEINALs/rK/wCWkAFEhYob2SZ+gisngUJcIbqKpOaxlKSDsyOSTKDJIN2hV4wczdEyMZLcaNWQq3evzvjMt7CfwdINzXuvldkezcaUQibSc3LB1fph/I0AL3pxMR8cC2Lie3U9rWMB40kncNYS2gD0R7TiZvKlTmB+Ltw3ZTeY8oCox+woy4S2GGibhjQBvVfuF2K34zw/7xM/Vo9Mq4XD+ZXf8PFWTfwnGwmr6uVw5SinfMNG88QAYV2npVnK1mD10iHusS15asnB+0YDIMri3Q26j1U/wUgdYxRJU99UFou9K8d0cJ1TXQ0JX8fnjxSqeMKoAF97sqdnAJksEmCiGd97J/h9zo30NI4fG2SMctD39WM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001);SRVR:CY1PR07MB2135;BCL:0;PCL:0;RULEID:;SRVR:CY1PR07MB2135; X-Microsoft-Exchange-Diagnostics: 1;CY1PR07MB2135;4:dHXhyFUuSKWnsKSzdg8ICO/cfUecVQYMg8vtq65YsZQu41PoPK6w+R12Jnk8JNKSZTx0ZS7p8ZhnuaQRO06exuUPda4Jl0f2yQyXUYaDZG5bRNa2YQ5GfFFTmD11+JYUimQHl7NUDvQeZLcELcaOVSzM/a2IlPqPVPZtBopOwos15upFvUItCnkg6VXwPbEF12dyJZ6TqesqwlWZK3oLzN2yi4wjxzkM6VxvVnAZij76ETOzIs7N9XMuOejpTgfS4QH7LSA4bVMv2ZQpV6G5v6cXt8TVM1mviI3jZGQfuoAzmvErZkKMwZ0ZasH7TIU+F5ZKC4BWGZkzWEHtSHPd/iGlisjxawSYRqC8n+BfswAzkGAHBTGwCw8wFmlUkL7L X-Forefront-PRVS: 0848C1A6AA X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(377454003)(24454002)(479174004)(230700001)(2906002)(50466002)(4326007)(36756003)(77096005)(2950100001)(23756003)(19580395003)(19580405001)(3846002)(4001350100001)(110136002)(5001960100002)(5008740100001)(1096002)(92566002)(586003)(65956001)(189998001)(83506001)(47776003)(87976001)(42186005)(93886004)(66066001)(53416004)(5004730100002)(40100003)(50986999)(54356999)(65816999)(122386002)(76176999)(33656002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR07MB2135;H:dl.caveonetworks.com;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?iso-8859-1?Q?1;CY1PR07MB2135;23:682yhdsoMHTEMb5KkokFwoRSjRo8PknDBWg0Fbx?= =?iso-8859-1?Q?sEx7UuJy/ubVLBILajNVWPHAcic1JgkMP5DDqncMr3h85REOXfcbbzO7ED?= =?iso-8859-1?Q?oTn8e39WT3nIRXH7keXkc5oUNbQuH9HfEuPJryd+R3DN54iRTngCiJ6RVV?= =?iso-8859-1?Q?vJSDot4As4tzci4/muQh/8KyWs9yp5MuG4yUXWgQ7ywJGNlvF6Vt/JjezT?= =?iso-8859-1?Q?JmE0B/zBRl2SY80fsRoAC3Jq4E9ZIOzOkZU0VF5w02Jg7KiFEac+U/huxk?= =?iso-8859-1?Q?5NiZ1UVbmm8lVd6Z/TIAxoArKTDPRAlgYHr5vqSMUbKaJox5WaLF3KRMBh?= =?iso-8859-1?Q?zL+rMV2MTceC6Qh7fup9EsMLBtC5ZxLL2XFcYzxaJ+XWUcBWPJ1CCnZNrY?= =?iso-8859-1?Q?sbBRcsFyEFxFXoPgDleKm+W1FEbkVOMp/tAZr/jJxLv3sY0sjBheK/abXw?= =?iso-8859-1?Q?M0aTBCx5XfZAtG6DbmdPs+rL+I8g3keKaaYOuw2NGaHwqDjayKzJJqsY0E?= =?iso-8859-1?Q?XrFl4AxeAZoXqb5AwfrB6GdlzvQVOa0ASawsRQY7GdiPy4O55WJvKjdlx+?= =?iso-8859-1?Q?GtCDNuf9tgvrBZb51YrNAlC/2AbNxzfG0iHVFEXASJEEZt6W4bL27zaHBJ?= =?iso-8859-1?Q?X7Em/sauyY4dfH0y17ya5XdYdiaI/KuAlzFGw5E4VQVVf3NJpuesCPgm3g?= =?iso-8859-1?Q?iVR6eZziU8Qn1GG7infEEfMkwPc4JXJB2y8GdVbW3dXPVopAPMwaTIHiiO?= =?iso-8859-1?Q?s4vatw+6xUmwvJdLWTfkt9i8u6Vjb2n9xhalreru/KGS6tqoRF8BnVc9dO?= =?iso-8859-1?Q?MmyyG5hDwwaqfwJF5B2cDshXE5+F/t0U2VgzheZPJSes0tqWErQTQ5ojoc?= =?iso-8859-1?Q?r9X4pwFKV/8BmR9O5lcKpAYgGr0fPWYTKvhMHB8f+0WkS7NImdNuC5248t?= =?iso-8859-1?Q?IOkouwPcytnJ2VbV/rT88eI21ASDqQAdBSQYN6WY6lNOd68QoBNCWoGI8z?= =?iso-8859-1?Q?fmpgXP84TVfovaae0i4Sys7Q6OrTP2glBZpkZ82Wn6GMmwUd8ZhJbRRTQn?= =?iso-8859-1?Q?ZyxYjFjV99ONQFpCYKPwJkvTld1j5ha9hgBKTaq02o=3D?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR07MB2135;5:kVksRmoAH/Z4fsYyNWvuuPnap70Ac/7wGIG3eOPZB3edPkhNXm9S4JKCzBpCx/HacOoKYKYGH59IEn/TkUp3x2FEtI34Y+sm9jXX+M6IZFB65oKg5d7VXQH3PM3salor6lAU8U1153BxX0t/gqZVPw==;24:HXl5suTxVXfkY3N9IWEmxwnFczkI1sGabzT69KNa/jz7uYCA80Sev5s9gZW4ivbYukVu7BX7+Tuu2zJIDDO96Rskok0D5YGFRP6AU3s++LY= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2016 18:42:22.2716 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2135 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/10/2016 10:15 AM, Will Deacon wrote: > On Wed, Feb 10, 2016 at 10:08:17AM -0800, David Daney wrote: >> On 02/10/2016 01:28 AM, Will Deacon wrote: >>> On Tue, Feb 09, 2016 at 11:29:16AM -0800, David Daney wrote: >>>> From: Andrew Pinski >>>> >>>> On ThunderX T88 pass 1.x through 2.1 parts, broadcast TLBI >>>> instructions may cause the icache to become invalid if it contains >>>> data for a non-current ASID. >>>> >>>> This patch implements the workaround (which flushes the local icache >>>> when switching the mm) by using code patching. >>> >>> So, to be clear, is this "just" a performance problem as opposed to a >>> correctness issue? >> >> No. It is a correctness issue. Without this workaround in place, userspace >> programs end up executing the wrong instructions, which leads to >> unpredictable behavior and program crashes. > > Ok, so I think the description in the commit log isn't quite right. An > "invalid" line in i-cache simply means that it needs to be refetched. > What you're talking about sounds like data corruption. Yes. I guess I will be sending v3 with an improved description. > > I also don't understand how the workaround fixes things like TLBIs due > to copy-on-write faults triggered by another core. Caveat: I don't fully understand the internal ICache implementation details. But ... External broadcast TLBIs arriving for the current ASID (as set in TTBR0_EL1) are handled properly. The issue is that cached data for other ASIDs, under some circumstances, may be inadvertently "blessed" into the current ASID. If we take care that no data for "foreign" ASIDs is in the Icache, the problematical case can never occur. > Also, what's the > interaction with virtual machines, or is the VMID not affected in the > same way as the ASID? Ah, the $10^6 question. Current information on how this interacts with KVM is less well developed. We think the workaround doesn't cause failures in virtual machines. I realize that this is different than asserting that virtual machines are guaranteed to operate error free. > > Sorry to be a pain on this, but we need to understand the issue well > enough to maintain the workaround in the future! > >>> If so, do you have any numbers with and without this >>> change? >> >> We tried to measure it, but the impact is not measurable in the tests we >> have done. Switching the mm is not often done so the extra ICache >> invalidation is rare. > > Oh, sure. I was only interested in perf figures if this was a performance > problem rather than a functional one. > > Will >