Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp448303pxb; Wed, 20 Jan 2021 10:53:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/PMl15nn7RB/4yg2NuYQGQG5TK0EmdvZgvwY41cFe87g8WO7VPWZFRFpNVq7Mwc2BUp2q X-Received: by 2002:a50:acc1:: with SMTP id x59mr8371270edc.43.1611168784222; Wed, 20 Jan 2021 10:53:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611168784; cv=none; d=google.com; s=arc-20160816; b=grDtMsQq5C/z1oSbUMgc2XqdOtRrkA+2d/cUyghzKMQgEedzTrYKoDj8vf/Gk3L4Lw VTmh0LEzWnrVU3ErHyffv2Gi/dioTbw5HZ5ZUBLj+7PwyxRATQTEv3KJ+niIW/ntLjpL h0wCMp2ULF+v9Utya9rdNsEzK0ymI6IcKU3iYs9oCQM5TbWYWwufQ1AyGis2UlMtpwSf 94UzhyugHtQEuTp/1fr7ZHwU+FAnZmRh7ODFu3d4NnPExvZNQeZXBooeHNIJxHSFq8i5 UGZ48VRMspAr4WdKJk5qM+Cw+1SIQ5siJIjnp+3KxSme1Qsfng6E3XBMFuLxpxBiRVS5 g2RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=0FqY4Y9ekqo9Njl4eE4yftVIgAdbgRXuwSrgrFbU1KY=; b=ONvI4OUBW3E9xJFZeLzIG/SGfVKg7PtpYNjf3kwhDZzET3ydZF90kB/h5XWwzb+ZFm txFFMddrmD7jRSbMhowAOc4FOoAgLKpQEK2Q1OGbrr1VDq/qqBJdTpHcZ/EEESktFq2E mMRP0Rg9onqUeLdjlbGtAZ3zcfzp15lgxadCTn4KmKP+WIFbP6kVJepPguj5lRTQeVlU nc5tr5uBFAqM3+Jn3bMD5qOZCElqZZvig5BZqwRXxEZbOsCVXUaaKHvMOiTsWPE7WDAg qQKeLg0RVjWPNDwFEzxYl8ZBc8Axx9Au3elc8C8pSGIjvYoTfRfgU3nyKVZOkntWUiut iC7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=n2oArYMs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z11si784107edp.546.2021.01.20.10.52.39; Wed, 20 Jan 2021 10:53:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=n2oArYMs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392191AbhATSvH (ORCPT + 99 others); Wed, 20 Jan 2021 13:51:07 -0500 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:55430 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390729AbhATSMF (ORCPT ); Wed, 20 Jan 2021 13:12:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1611166326; x=1642702326; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=0FqY4Y9ekqo9Njl4eE4yftVIgAdbgRXuwSrgrFbU1KY=; b=n2oArYMsNAxf9OPtAtzAl8Tp/o3kGHhlSgRm4dtYt1xEKhBpGNFxbqPQ +ALRxgjUqIY1L2kMRuQWfnlDarH5DzU5khCRacimSM7qsAwatZcKyyICg Yz1MHYQVhpD9p3yCdb5IPClfCb/MqmtiXxBInCcWsp8FvDI9DrNJyEwzg Q=; X-IronPort-AV: E=Sophos;i="5.79,361,1602547200"; d="scan'208";a="112258151" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 20 Jan 2021 18:11:17 +0000 Received: from EX13MTAUWC002.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com (Postfix) with ESMTPS id CC0E3A21D6; Wed, 20 Jan 2021 18:11:15 +0000 (UTC) Received: from EX13D20UWC001.ant.amazon.com (10.43.162.244) by EX13MTAUWC002.ant.amazon.com (10.43.162.240) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 20 Jan 2021 18:11:15 +0000 Received: from edge-m1-r3-201.e-iad16.amazon.com (10.43.161.179) by EX13D20UWC001.ant.amazon.com (10.43.162.244) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 20 Jan 2021 18:10:35 +0000 Subject: Re: [RFC PATCH 3/7] arm64: mm: use nGnRnE instead of nGnRE on Apple processors To: Mohamed Mediouni CC: , Catalin Marinas , Will Deacon , Mark Rutland , Marc Zyngier , Hector Martin , , Stan Skowronek References: <20210120132717.395873-1-mohamed.mediouni@caramail.com> <20210120132717.395873-4-mohamed.mediouni@caramail.com> <17579DC5-13AF-48E1-9B72-91B14AB485FA@caramail.com> From: Alexander Graf Message-ID: <6047872c-8a40-4159-aeb6-ea439bfafd82@amazon.com> Date: Wed, 20 Jan 2021 19:10:33 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <17579DC5-13AF-48E1-9B72-91B14AB485FA@caramail.com> Content-Language: en-US X-Originating-IP: [10.43.161.179] X-ClientProxiedBy: EX13D49UWC002.ant.amazon.com (10.43.162.215) To EX13D20UWC001.ant.amazon.com (10.43.162.244) Content-Type: text/plain; charset="windows-1252"; format="flowed" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20.01.21 19:06, Mohamed Mediouni wrote: > = >> On 20 Jan 2021, at 17:47, Alexander Graf wrote: >> >> On 20.01.21 14:27, Mohamed Mediouni wrote: >>> Use nGnRnE instead of nGnRE on Apple SoCs to workaround a serious hardw= are quirk. >>> On Apple processors, writes using the nGnRE device memory type get drop= ped in flight, >>> getting to nowhere. >>> Signed-off-by: Stan Skowronek >>> Signed-off-by: Mohamed Mediouni >>> --- >>> arch/arm64/mm/proc.S | 26 ++++++++++++++++++++++++++ >>> 1 file changed, 26 insertions(+) >>> diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S >>> index 1f7ee8c8b7b8..06436916f137 100644 >>> --- a/arch/arm64/mm/proc.S >>> +++ b/arch/arm64/mm/proc.S >>> @@ -51,6 +51,25 @@ >>> #define TCR_KASAN_HW_FLAGS 0 >>> #endif >>> +#ifdef CONFIG_ARCH_APPLE >> >> Is there any particular reason for this #ifdef? >> >> >> Alex >> > Not a particular reason, as we explicitly check for the implementer ID. H= owever, > without CONFIG_ARCH_APPLE, other parts of the support for Apple CPUs > will not be available anyway. The ifdef below for code looks ok to me, I'm explicitly wondering why = you're guarding the #define :) Alex >>> + >>> +/* >>> + * Apple cores appear to black-hole writes done with nGnRE. >>> + * We settled on a work-around that uses MAIR vs changing every single= user of >>> + * nGnRE across the arm64 code. >>> + */ >>> + >>> +#define MAIR_EL1_SET_APPLE \ >>> + (MAIR_ATTRIDX(MAIR_ATTR_DEVICE_nGnRnE, MT_DEVICE_nGnRnE) | \ >>> + MAIR_ATTRIDX(MAIR_ATTR_DEVICE_nGnRnE, MT_DEVICE_nGnRE) | \ >>> + MAIR_ATTRIDX(MAIR_ATTR_DEVICE_GRE, MT_DEVICE_GRE) | \ >>> + MAIR_ATTRIDX(MAIR_ATTR_NORMAL_NC, MT_NORMAL_NC) | \ >>> + MAIR_ATTRIDX(MAIR_ATTR_NORMAL, MT_NORMAL) | \ >>> + MAIR_ATTRIDX(MAIR_ATTR_NORMAL_WT, MT_NORMAL_WT) | \ >>> + MAIR_ATTRIDX(MAIR_ATTR_NORMAL, MT_NORMAL_TAGGED)) >>> + >>> +#endif >>> + >>> /* >>> * Default MAIR_EL1. MT_NORMAL_TAGGED is initially mapped as Normal m= emory and >>> * changed during __cpu_setup to Normal Tagged if the system supports= MTE. >>> @@ -432,6 +451,13 @@ SYM_FUNC_START(__cpu_setup) >>> * Memory region attributes >>> */ >>> mov_q x5, MAIR_EL1_SET >>> +#ifdef CONFIG_ARCH_APPLE >>> + mrs x0, MIDR_EL1 >>> + lsr w0, w0, #24 >>> + mov_q x1, MAIR_EL1_SET_APPLE >>> + cmp x0, #0x61 // 0x61 =3D Implementer: A= pple >>> + csel x5, x1, x5, eq >>> +#endif >>> #ifdef CONFIG_ARM64_MTE >>> mte_tcr .req x20 >>> -- >>> 2.29.2 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879