Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3833909ybt; Tue, 30 Jun 2020 12:05:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjVHY2/7+2xne3ABmujoXRCLiaXG8CrkLBVYww++h2FSydQUMc1XPjs7Fy5U8UxP2RK7Y5 X-Received: by 2002:a50:f187:: with SMTP id x7mr23518213edl.59.1593543508493; Tue, 30 Jun 2020 11:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593543508; cv=none; d=google.com; s=arc-20160816; b=pf5gGDFYUwJeIAAI/+AsOQTEm8snUFZg/tBT4qxVZk0NIYx7QnwbeGe5cEL0xMOgBo iWNdzwL0Cs7GJJc7DrAwTcC+9yKx76+i5kvKBCA1LY0zAzGMC5NON4/VJB1o5O/MaT+W 2VBf9cCfq6AnjKLrPFb51FhM/7FADV9QQAaTpq3y2iKvspmOxoqhja1vtmy23AOb0cIx DvCFhXmar8PJYh21mIdtEvcnbDv59/izyBLTo2C718u4WZRqosAVPLiL+FoTe7ucw9wG f5WYv9mInUSK4uc6XkgvCUpFa0rZav9B9px27RQaajWBWA6fNBaM2fahFEs23eYYPtR7 nf5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DsGGO5meZvsNcFVy+iUqSE+QD1ROvyvNgALeNbc0CIA=; b=zowHlQrnZ+0eBtWgbJz5NqhHCteXzXRQ/BcmTeDb9cwyyv38zpeU8Gjb1bze6WEgV+ jRL28N77bEN6ZfnLcbMpGPVdyhP+nE30Qk6Qz5lLSi8L6wLDcNEF1E57hIlmSE/ennvv cG7rj4/f+iCe7wxEJkqqtRd5xScWB9v4gRd5Xf9rJ0W+4jBAskytqcwi6z9kc/yVGUFz bEDrrWrZuD6S3Nz70K+qTTdFQjEISSSGTI758elzo0iMNegM0OoARYv5Z2aao/eHu+Ql Zg/vc5k/5ZXqapit2/hX3Sc8W5/ZLIShwqEQ1ioJYSLlgCTGFzt+jPs2tuImXVfJlFPE JaKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0q+Ziga1; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s5si2213702eja.431.2020.06.30.11.58.06; Tue, 30 Jun 2020 11:58:28 -0700 (PDT) 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=@kernel.org header.s=default header.b=0q+Ziga1; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390470AbgF3Ri4 (ORCPT + 99 others); Tue, 30 Jun 2020 13:38:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:52262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388439AbgF3Riz (ORCPT ); Tue, 30 Jun 2020 13:38:55 -0400 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 218CE208D5; Tue, 30 Jun 2020 17:38:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593538734; bh=9ta772X0LhIYPaLbgcx1JUvYo6hXV5XVnuUlAptrUOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0q+Ziga1tPlskSYQCOixoO6Z7LOXNz3B6jLLCGqxp/nOY1c+yQMi4dmX9JM37+9y0 ZK9XtOGvfQUWp0T7YRsp5zuJSE8D4Xcg5v8WcxEy/7r+jxhV6fRVjnfN6L3KkrZKkU ebDLdVemnERh2RnFrQjwFEjyJUmdx4Rab8Jh0TpI= From: Will Deacon To: linux-kernel@vger.kernel.org Cc: Will Deacon , Sami Tolvanen , Nick Desaulniers , Kees Cook , Marco Elver , "Paul E. McKenney" , Josh Triplett , Matt Turner , Ivan Kokshaysky , Richard Henderson , Peter Zijlstra , Alan Stern , "Michael S. Tsirkin" , Jason Wang , Arnd Bergmann , Boqun Feng , Catalin Marinas , Mark Rutland , linux-arm-kernel@lists.infradead.org, linux-alpha@vger.kernel.org, virtualization@lists.linux-foundation.org, kernel-team@android.com Subject: [PATCH 17/18] arm64: alternatives: Remove READ_ONCE() usage during patch operation Date: Tue, 30 Jun 2020 18:37:33 +0100 Message-Id: <20200630173734.14057-18-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200630173734.14057-1-will@kernel.org> References: <20200630173734.14057-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org 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. 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 d1757ef1b1e7..87bca8d44084 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); @@ -217,7 +218,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 { @@ -229,7 +230,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.27.0.212.ge8ba1cc988-goog