From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 333A7C2D0A3 for ; Tue, 3 Nov 2020 12:17:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D67E422243 for ; Tue, 3 Nov 2020 12:17:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604405868; bh=BCgiu9K0Vqk44ZIzAPpCiD5ozFp8P1v2e6umqroeIWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mNvj/fwCnINC00/TT0JIDkUgLK/ZdaTwCtz3wXf7dZZlO/0CTjK2L1LTP8CSiZm+j uIqTsDUkALSEBUqMm6HDoOsx1oltAHsSFnuMY7gkIKYngLeQPa2+QD5d0Gdg1rcKpJ FfUDp0tUlWjwfTcvphSHjau6FNHTp2AyCRP+fNac= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729082AbgKCMRr (ORCPT ); Tue, 3 Nov 2020 07:17:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:38336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729063AbgKCMRe (ORCPT ); Tue, 3 Nov 2020 07:17:34 -0500 Received: from localhost.localdomain (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5EFC92240C; Tue, 3 Nov 2020 12:17:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604405853; bh=BCgiu9K0Vqk44ZIzAPpCiD5ozFp8P1v2e6umqroeIWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kw3wHPhXk4rskprK8mBpamdvL2GCzA8ksI4tAq5mCcBT1gkO5UV5Nr+73FKJpd4Bv Uu9H8Eq2lWNvAmd1aQvkQPz9JK+6yhGFCzb/p8V4y3ZTvq9fslGrG0Uhpw1b9Jxyra I6cSgsNvF/t5+WY9+OuSNvGDTja250yeCyedtKr0= From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: Will Deacon , Kees Cook , Catalin Marinas , Sami Tolvanen , Masahiro Yamada , Peter Zijlstra , linux-kernel@vger.kernel.org Subject: [PATCH v4 3/4] arm64: alternatives: Remove READ_ONCE() usage during patch operation Date: Tue, 3 Nov 2020 12:17:20 +0000 Message-Id: <20201103121721.5166-4-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201103121721.5166-1-will@kernel.org> References: <20201103121721.5166-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for patching the internals of READ_ONCE() itself, replace its usage on the alternatives patching patch with a volatile variable instead. Acked-by: Peter Zijlstra (Intel) Signed-off-by: Will Deacon --- arch/arm64/kernel/alternative.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c index 73039949b5ce..a57cffb752e8 100644 --- a/arch/arm64/kernel/alternative.c +++ b/arch/arm64/kernel/alternative.c @@ -21,7 +21,8 @@ #define ALT_ORIG_PTR(a) __ALT_PTR(a, orig_offset) #define ALT_REPL_PTR(a) __ALT_PTR(a, alt_offset) -static int all_alternatives_applied; +/* Volatile, as we may be patching the guts of READ_ONCE() */ +static volatile int all_alternatives_applied; static DECLARE_BITMAP(applied_alternatives, ARM64_NCAPS); @@ -205,7 +206,7 @@ static int __apply_alternatives_multi_stop(void *unused) /* We always have a CPU 0 at this point (__init) */ if (smp_processor_id()) { - while (!READ_ONCE(all_alternatives_applied)) + while (!all_alternatives_applied) cpu_relax(); isb(); } else { @@ -217,7 +218,7 @@ static int __apply_alternatives_multi_stop(void *unused) BUG_ON(all_alternatives_applied); __apply_alternatives(®ion, false, remaining_capabilities); /* Barriers provided by the cache flushing */ - WRITE_ONCE(all_alternatives_applied, 1); + all_alternatives_applied = 1; } return 0; -- 2.29.1.341.ge80a0c044ae-goog