From patchwork Tue Jan 5 07:19:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Chen X-Patchwork-Id: 11998245 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 038C4C433DB for ; Tue, 5 Jan 2021 07:20:55 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A0870224F9 for ; Tue, 5 Jan 2021 07:20:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A0870224F9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.61743.108736 (Exim 4.92) (envelope-from ) id 1kwgdq-0006K3-Fj; Tue, 05 Jan 2021 07:20:30 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 61743.108736; Tue, 05 Jan 2021 07:20:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kwgdq-0006Jw-CX; Tue, 05 Jan 2021 07:20:30 +0000 Received: by outflank-mailman (input) for mailman id 61743; Tue, 05 Jan 2021 07:20:29 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kwgdo-0006Jr-Rb for xen-devel@lists.xenproject.org; Tue, 05 Jan 2021 07:20:29 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (unknown [40.107.20.59]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 580a5848-eb1e-4845-8432-98dde192fab0; Tue, 05 Jan 2021 07:20:26 +0000 (UTC) Received: from AM6PR0202CA0044.eurprd02.prod.outlook.com (2603:10a6:20b:3a::21) by DB7PR08MB3899.eurprd08.prod.outlook.com (2603:10a6:10:7f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.21; Tue, 5 Jan 2021 07:20:23 +0000 Received: from VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:3a:cafe::6) by AM6PR0202CA0044.outlook.office365.com (2603:10a6:20b:3a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.20 via Frontend Transport; Tue, 5 Jan 2021 07:20:23 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT036.mail.protection.outlook.com (10.152.19.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.21 via Frontend Transport; Tue, 5 Jan 2021 07:20:22 +0000 Received: ("Tessian outbound 6af064f543d4:v71"); Tue, 05 Jan 2021 07:20:19 +0000 Received: from 014545ea30bd.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5613694E-6481-4AFE-90DF-AAD2DB36A674.1; Tue, 05 Jan 2021 07:20:03 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 014545ea30bd.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 05 Jan 2021 07:20:03 +0000 Received: from AM6P195CA0015.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:81::28) by VI1PR08MB4303.eurprd08.prod.outlook.com (2603:10a6:803:f6::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.19; Tue, 5 Jan 2021 07:20:02 +0000 Received: from AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:81:cafe::1a) by AM6P195CA0015.outlook.office365.com (2603:10a6:209:81::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.20 via Frontend Transport; Tue, 5 Jan 2021 07:20:01 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT018.mail.protection.outlook.com (10.152.16.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3721.21 via Frontend Transport; Tue, 5 Jan 2021 07:20:01 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2044.4; Tue, 5 Jan 2021 07:19:57 +0000 Received: from ais-wip-ds.shanghai.arm.com (10.169.190.87) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2044.4 via Frontend Transport; Tue, 5 Jan 2021 07:19:55 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 580a5848-eb1e-4845-8432-98dde192fab0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9ZBzzxGzKpaz/jymkQKpqP+oHhtY7DR0dss6B4Pcejk=; b=rRS0H7vjLxIkQXd3nhLr9F5ZGfJKXtk4pchGM4m+0DebV8Y97W6p6H1yecqgEvTm7yN78UPF83bIbvwP9Jc6xVYTrEPCeIOpsXhHZ26rwLWPvXyDjiOkhpyNWW7qvOB1gzVHx/bYjBk34pXo5vt0uE+Bv3lo/lNAKzaCTqOWA/0= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: 32e45b872d299242 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GDEI9MbGRSYo1NZkw4gCX64rSJDgMCkxv0WZrky+CrLH7tP2ujrPHgnXkdyi4utoEIQHI2CLC1BmGwLCkjQsGvzhaqDV18TZsJgMTF0cfO21cPauWWMebm2zZOfNokP+zNss+q3fhi/EbiiWxEH33lKoVjUhIRlMUtLAbfXwY1m/yDmmmUUjPnkSSiUHWrwscfiys+dGmYIiNe/h+Jyv/JsVZ/pjLSLJ/aGsWPrDbEr3FN9cN9OFnTUvgQI3VY51IYLAS8a6NoIzkn3QQGDL6nkkMzNa9JVjXKOZWMzb5GduC4Wfb/VSMGJ61v9XXbctU9wvBZc5U40QudIHcbTPqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9ZBzzxGzKpaz/jymkQKpqP+oHhtY7DR0dss6B4Pcejk=; b=VgZU3RD2R4XbTEOicKi7dRKXvNlDkFa7iSCmWWRoPWSlABhqBMbEC/lrUUYKbc0ZHzfnj5j7Z+a7A3OZOhucg6KW6pQ2LKVZ0hyr8jPvNQQ3tzY0gpJaWCf69w1KVlhY22He6FRS9f3m8Ir7rfOE/HB4H0KydIejVaMfuO2uyrNR9DFx49l0LlZxAm4y2tuuBAWZ0lHV0Yhm8/APG52pJoOeiXQJ/mVd2WXH5f2TAai40CXbjGZwMNfwrzmMkWO/3ISshnHeFNbB6sc7B9CeLEtaoYJa9VmnVaSfQdvi3ouKRHHTfOTqlJ6QC9vNgKBIfqxejBXi/QDBhH6iw4nBkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9ZBzzxGzKpaz/jymkQKpqP+oHhtY7DR0dss6B4Pcejk=; b=rRS0H7vjLxIkQXd3nhLr9F5ZGfJKXtk4pchGM4m+0DebV8Y97W6p6H1yecqgEvTm7yN78UPF83bIbvwP9Jc6xVYTrEPCeIOpsXhHZ26rwLWPvXyDjiOkhpyNWW7qvOB1gzVHx/bYjBk34pXo5vt0uE+Bv3lo/lNAKzaCTqOWA/0= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; From: Wei Chen To: , , , CC: , , , Subject: [PATCH 1/2] xen/arm: Correct the coding style of get_cycles Date: Tue, 5 Jan 2021 15:19:45 +0800 Message-ID: <20210105071946.1971229-1-wei.chen@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 232595d9-597f-494a-4bd6-08d8b14a5d34 X-MS-TrafficTypeDiagnostic: VI1PR08MB4303:|DB7PR08MB3899: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:5797;OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Tv8CDYRKhOdMyInAc+BVhmIB+bl9JjjvstiCQA0tBV2Y5W8cVcwzTf+os+FSUKQJZVEygqVpkDvwL0eDOOrHu9zoWaFopfi46QM8rj1E/FHXEZkpFXPeNOGPzxGsRxAe7bfo9M0Hgbu+WSkdKgi9TXG9tKbuirJvn/QvAkoMn0lxLrw0mn94DhzCKF1nY+ftdAKurWxdIR2Zdm+cYzjbuBhacio6MS1IU3rTLzkMMdZw21UZcse8nfvz9MzE2h5Ra3kd4a/Z9xQ0Yc1cCVtdaceSmgTjYco7+etDoeRnE+mgJyRpxji6avTpesyIhIQNsOHc2zd+6e04mLvX1wmomxRTdyEU5ZCc1MrFTD1RvBXdpAFFk+tOtzLGL09/A9m6CtjhsCOSO6CZEgQcFJbq1CJXqYxrIirymkqkPep8GvSkjsjkfU8R8Of/yl5YRj2oHkL7CHkt4yEr58jD/rcs2Q== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(39860400002)(346002)(136003)(396003)(376002)(46966006)(54906003)(110136005)(4326008)(316002)(8676002)(86362001)(1076003)(356005)(8936002)(81166007)(2906002)(70586007)(478600001)(6666004)(70206006)(82740400003)(426003)(83380400001)(44832011)(336012)(26005)(186003)(82310400003)(2616005)(47076005)(36756003)(5660300002)(7696005);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4303 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 93ae2a8d-12dc-45e0-adb3-08d8b14a50c2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eDhxJC1YKZd02XwilrEdGUg8mG/blz0D6M+CkhaApmf3JyXGjfY1Mggfpukuwf5AV36B/lYBqTfKv+GWsUJYp2ZmoiLcDuDQzAnaPxYOOovF57TfO8P7ZDxe4wiouJUCvhajI4v1r9GB+okaa3DTvAoGGi1WSlk1wHmB43gpa3qcntuhxhcXXfVEakcX3/zWP14giss7KPp027mAsieZfouNvm70itTCoFC5l5l7O8MZe7MFTLzQQZwQbKfb17m4vceMUrEGksOkXtk28FAL5Rul8aDwGXJYvqKcWwfFoY+n7DiyZxH0xK+XF7+LgfZikn4FSN5AV7jcg9aEz56jgTGsE+UEXlEVZD+oSRtQc+z3fNwsfvpBYgz2TmBQMuWebNAz2IXq6Yy6AJYuHc4va3Wwfm/Vno5uav+kCoV0uiyX1lL2XZ2Abz90iEvf/N7rjawpZ2vq8RtZ5lLuJFuoHQ== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(136003)(346002)(39860400002)(376002)(396003)(46966006)(5660300002)(86362001)(426003)(6666004)(7696005)(83380400001)(2616005)(70586007)(70206006)(36756003)(82740400003)(82310400003)(478600001)(110136005)(47076005)(54906003)(44832011)(1076003)(316002)(81166007)(8936002)(4326008)(2906002)(186003)(26005)(336012)(8676002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2021 07:20:22.1060 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 232595d9-597f-494a-4bd6-08d8b14a5d34 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3899 It seems the arm inline function get_cycles has used 8 spaces for line indent since 2012. This patch correct them to 4 spaces and remove extra space between function name and bracket. Signed-off-by: Wei Chen Acked-by: Julien Grall --- xen/include/asm-arm/time.h | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/xen/include/asm-arm/time.h b/xen/include/asm-arm/time.h index 1b2c13614b..5c4529ebb5 100644 --- a/xen/include/asm-arm/time.h +++ b/xen/include/asm-arm/time.h @@ -11,29 +11,29 @@ typedef uint64_t cycles_t; -static inline cycles_t get_cycles (void) +static inline cycles_t get_cycles(void) { - isb(); + isb(); + /* + * ARM_WORKAROUND_858921: Cortex-A73 (all versions) counter read + * can return a wrong value when the counter crosses a 32bit boundary. + */ + if ( !check_workaround_858921() ) + return READ_SYSREG64(CNTPCT_EL0); + else + { /* - * ARM_WORKAROUND_858921: Cortex-A73 (all versions) counter read - * can return a wrong value when the counter crosses a 32bit boundary. + * A recommended workaround for erratum 858921 is to: + * 1- Read twice CNTPCT. + * 2- Compare bit[32] of the two read values. + * - If bit[32] is different, keep the old value. + * - If bit[32] is the same, keep the new value. */ - if ( !check_workaround_858921() ) - return READ_SYSREG64(CNTPCT_EL0); - else - { - /* - * A recommended workaround for erratum 858921 is to: - * 1- Read twice CNTPCT. - * 2- Compare bit[32] of the two read values. - * - If bit[32] is different, keep the old value. - * - If bit[32] is the same, keep the new value. - */ - cycles_t old, new; - old = READ_SYSREG64(CNTPCT_EL0); - new = READ_SYSREG64(CNTPCT_EL0); - return (((old ^ new) >> 32) & 1) ? old : new; - } + cycles_t old, new; + old = READ_SYSREG64(CNTPCT_EL0); + new = READ_SYSREG64(CNTPCT_EL0); + return (((old ^ new) >> 32) & 1) ? old : new; + } } /* List of timer's IRQ */ From patchwork Tue Jan 5 07:19:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Chen X-Patchwork-Id: 11998247 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2CCBC433E0 for ; Tue, 5 Jan 2021 07:21:01 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 51CDE224F9 for ; Tue, 5 Jan 2021 07:21:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51CDE224F9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.61744.108748 (Exim 4.92) (envelope-from ) id 1kwgdw-0006LY-Od; Tue, 05 Jan 2021 07:20:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 61744.108748; Tue, 05 Jan 2021 07:20:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kwgdw-0006LQ-LM; Tue, 05 Jan 2021 07:20:36 +0000 Received: by outflank-mailman (input) for mailman id 61744; Tue, 05 Jan 2021 07:20:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kwgdu-0006Ky-W7 for xen-devel@lists.xenproject.org; Tue, 05 Jan 2021 07:20:35 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (unknown [40.107.20.78]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b20d0647-4758-435b-adc7-0e86d1f077f1; Tue, 05 Jan 2021 07:20:32 +0000 (UTC) Received: from DB6PR07CA0019.eurprd07.prod.outlook.com (2603:10a6:6:2d::29) by AM0PR08MB4177.eurprd08.prod.outlook.com (2603:10a6:208:132::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 5 Jan 2021 07:20:30 +0000 Received: from DB5EUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2d:cafe::9f) by DB6PR07CA0019.outlook.office365.com (2603:10a6:6:2d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.2 via Frontend Transport; Tue, 5 Jan 2021 07:20:30 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT057.mail.protection.outlook.com (10.152.20.235) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.21 via Frontend Transport; Tue, 5 Jan 2021 07:20:29 +0000 Received: ("Tessian outbound fc5cc0046d61:v71"); Tue, 05 Jan 2021 07:20:29 +0000 Received: from f5756446b793.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 868CF6E0-E7D9-42DB-BA9F-C8CAFF6460F8.1; Tue, 05 Jan 2021 07:20:14 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f5756446b793.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 05 Jan 2021 07:20:14 +0000 Received: from AM8P189CA0016.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::21) by DB7PR08MB3755.eurprd08.prod.outlook.com (2603:10a6:10:77::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.19; Tue, 5 Jan 2021 07:20:13 +0000 Received: from AM5EUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:218:cafe::e2) by AM8P189CA0016.outlook.office365.com (2603:10a6:20b:218::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.20 via Frontend Transport; Tue, 5 Jan 2021 07:20:12 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT024.mail.protection.outlook.com (10.152.16.175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3721.21 via Frontend Transport; Tue, 5 Jan 2021 07:20:11 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2044.4; Tue, 5 Jan 2021 07:20:00 +0000 Received: from ais-wip-ds.shanghai.arm.com (10.169.190.87) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2044.4 via Frontend Transport; Tue, 5 Jan 2021 07:19:57 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b20d0647-4758-435b-adc7-0e86d1f077f1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3senGGhHMGiySIHILlSB+Z4Hs/Io4eSyk8AgHdDNgVI=; b=EvH7Tg9+qUOn4wweyzGQpESl349/rew1fn+KPkg8V4DlVrmoLKS43jrZty+j06pB3a5HwrND+B8SQcWca84L8yMLpzaqFkCOj0QLjhNFxXL40hDRLsSd464Cle0ivAJ5xzOYzfhFVOwF0flykLKZrX2sUCGSCIdyHUJE3nq/RRA= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: 9c8db5e51b9a233d X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=miFAdZR3rUTVJtwkV3m/iRktQftKU1W95PnXvv4w7+KKEVIWirT+Ev2BooTqu2UGKDiohdWyzxZUUJOngcw1E80FthMcoFMiepqk1TxBdiKzn4KPF3uU3O68a0Egd3OYp/R4/jYKC3ZavHntIkefb65No5xLY1OghFN8A6Ao2oCKM3NpoYO4dgL95YsJIGg2HwCDX8OWezsizCjSutIzufouGxrODfoupZKx0RGoW0DQDqC/7mYOe0FuXdUaTaFfi7CSk9Kk/PrCL8bCAzQOiFBMakEFUIZdg3l8NkPPOBxdElophWsa55kNYNvQ8sKdqgFQXN7Xmab6OmqgmZ9Faw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3senGGhHMGiySIHILlSB+Z4Hs/Io4eSyk8AgHdDNgVI=; b=ABSd/DgXMlXyQjMGcTFEMMMX8z63AacWBetncdKspz28Q3YZKeeZVTuMZYWQ/kcgLxPc3PbFzicBso09JhxZ0lLJOpQDwhWeZDBhAfRmaWyjvuFA0BpmyDpM2/Yg1/KaIXIwEHnyfg3y7+pcQDKfY0SdqeDpYh8HKH+b5fJIK3wXzAEs5Fl5jBvHE2WEG7UMVDudf8/X+CtDVL4xWA3ajXjk2UqVdOoXbY55JeKMgV2QbZ8Xyj2E2UyY0ZOHwKwovlVDbiqAXAVPnDAR2UPq6uvHV7u2ymh5QW+3s6dx4eB7NFUZQ0tgN3xDCHvcpdw03h5oiBQyRT4Mp2pzGYWNWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3senGGhHMGiySIHILlSB+Z4Hs/Io4eSyk8AgHdDNgVI=; b=EvH7Tg9+qUOn4wweyzGQpESl349/rew1fn+KPkg8V4DlVrmoLKS43jrZty+j06pB3a5HwrND+B8SQcWca84L8yMLpzaqFkCOj0QLjhNFxXL40hDRLsSd464Cle0ivAJ5xzOYzfhFVOwF0flykLKZrX2sUCGSCIdyHUJE3nq/RRA= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; From: Wei Chen To: , , , CC: , , , Subject: [PATCH 2/2] xen/arm: Add defensive barrier in get_cycles for Arm64 Date: Tue, 5 Jan 2021 15:19:46 +0800 Message-ID: <20210105071946.1971229-2-wei.chen@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105071946.1971229-1-wei.chen@arm.com> References: <20210105071946.1971229-1-wei.chen@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c6834fc4-a55c-4a43-8b80-08d8b14a61c9 X-MS-TrafficTypeDiagnostic: DB7PR08MB3755:|AM0PR08MB4177: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: QVPTEJE8VxSYzOG6x4ilLk9s7CFLRdUzMwjnLHlGsmAhbuCHnmak/Xe/itXjCZSzSqBBCldF2O43RfQmF5S5hCaLGU5MiAAYpCMgTxNYdNBkYJzgMOYNbG+o3rB0fVQFNQlagMczRBtTXRH4igcQmP7KzUyi0BZZwOdP2xfLCrpx2xnBgVQMH9OdHGv3KuydAPsQudiuRdi1kps8KGzKRX7ovpzZlEwWK+DCpuPSc/BGmH3MCTuNgpvJ/PKPWzM9Z7Z4cmrkUOcdVUh/TVEYfiIwhsA3wiLakrmh8i4YkrhZotUA1/Cyy6FRoA/A/2M8rCOpjR62Svykz0JqCmZOhBayap9fTzCnTbBbgXSygc50yht7iMnFfm3jnkLPDZkDMilrEfiEQJ4LtTVHZ8THpI2zudCXrG15OuRnIcXyzBYj/A19zErmPi2YWtXjCm8LGUhqxQXpnjCDWPqel2FYTGLUF3HskjKgS4JxcMOqqGe5M0fQBLECixm5ns4NCbXHQ850GZkrDLO+6WKriH9YULkqlMo88Kd2mVK7MBnK+X8m2UeD/T6VDaXtl3fsGXse X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(396003)(136003)(376002)(39860400002)(346002)(46966006)(26005)(2616005)(186003)(82310400003)(83380400001)(336012)(426003)(5660300002)(82740400003)(7696005)(36756003)(47076005)(44832011)(966005)(110136005)(8676002)(86362001)(4326008)(54906003)(70206006)(6666004)(316002)(8936002)(2906002)(478600001)(70586007)(81166007)(1076003)(356005)(87944003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3755 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 4a32642a-4c80-4171-1502-08d8b14a569b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XIDflIA17vHTyoFJZQr60MWSZlI3Z5DaKBEor3zhT1ldyw0gORPdMWOr+qqax416viv7pObvf+/72zLB1efNmmwNzNMeo+Jr/hzUjHeFs01j01gV/0/CfZhWEK7Phntz14e/ooOWTGH0dYdDWgFQrvnZiRPq/5omK70/hojiCgQ06m42LscC/jjKLTJzyzavWg/l5HgEcB70JU6CgN2CaBjXRcsfiJvUvrGk1bdp/x6vLMG0WQ9eOeCJdPv3lHWpCa0I4KtP/Jjr+WUx4foNWmb1oYuLS8GfHsL7j2MRxTLxl/nvJ1P6BQwkubtfSXQJOvBzbyN0fAoujkuiyOxPwio2cCSyV7SNypw491G3uh3cYA947YZ2GjcMQNIk9WDV9fYnl1tN2Pz1kkWKznevRECktPzB1HyfFW8UAdwoNO258Lkm0V4oE2uP28CqrB3/CENQrCsm/kGSLY92c3B0djSDX5TaXft+B1YhdchJPzX4wqog/oK4WFzw9afO62tX4U8ovBIkhu57y7szqtTiJH1rb9WN5erNwl0uwFZDKPjb4Xa/3q1PnxGKgut/GjkR X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(376002)(136003)(346002)(39860400002)(396003)(46966006)(36756003)(86362001)(478600001)(44832011)(110136005)(54906003)(966005)(2616005)(426003)(5660300002)(1076003)(7696005)(8936002)(2906002)(8676002)(4326008)(6666004)(83380400001)(336012)(316002)(70586007)(70206006)(47076005)(186003)(81166007)(82740400003)(82310400003)(26005)(87944003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2021 07:20:29.9095 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6834fc4-a55c-4a43-8b80-08d8b14a61c9 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4177 As the dicsussion [1] in mailing list. We'd better to have a barrier after reading CNTPCT in get_cycles. If there is not any barrier there. When get_cycles being used in some seqlock critical context in the future, the seqlock can be speculated potentially. In order to reduce the impact of new barrier, we perfer to use enforce order instead of ISB [2]. Currently, enforce order is not applied to arm32 as this is not done in Linux at the date of this patch. If this is done in Linux it will need to be also done in Xen. [1] https://lists.xenproject.org/archives/html/xen-devel/2020-12/msg00181.html [2] https://lkml.org/lkml/2020/3/13/645 Signed-off-by: Wei Chen --- xen/include/asm-arm/time.h | 43 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/xen/include/asm-arm/time.h b/xen/include/asm-arm/time.h index 5c4529ebb5..3ef4e7cd3d 100644 --- a/xen/include/asm-arm/time.h +++ b/xen/include/asm-arm/time.h @@ -11,9 +11,26 @@ typedef uint64_t cycles_t; -static inline cycles_t get_cycles(void) +/* + * Ensure that reads of the counter are treated the same as memory reads + * for the purposes of ordering by subsequent memory barriers. + */ +#if defined(CONFIG_ARM_64) +#define read_cntpct_enforce_ordering(val) do { \ + u64 tmp, _val = (val); \ + \ + asm volatile( \ + "eor %0, %1, %1\n" \ + "add %0, sp, %0\n" \ + "ldr xzr, [%0]" \ + : "=r" (tmp) : "r" (_val)); \ +} while (0) +#else +#define read_cntpct_enforce_ordering(val) do {} while (0) +#endif + +static inline cycles_t read_cntpct_stable(void) { - isb(); /* * ARM_WORKAROUND_858921: Cortex-A73 (all versions) counter read * can return a wrong value when the counter crosses a 32bit boundary. @@ -36,6 +53,28 @@ static inline cycles_t get_cycles(void) } } +static inline cycles_t get_cycles(void) +{ + cycles_t cnt; + + isb(); + cnt = read_cntpct_stable(); + + /* + * If there is not any barrier here. When get_cycles being used in + * some seqlock critical context in the future, the seqlock can be + * speculated potentially. + * + * To prevent seqlock from being speculated silently, we add a barrier + * here defensively. Normally, we just need an ISB here is enough, but + * considering the minimum performance cost. We prefer to use enforce + * order here. + */ + read_cntpct_enforce_ordering(cnt); + + return cnt; +} + /* List of timer's IRQ */ enum timer_ppi {