From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757096AbdEKPnL (ORCPT ); Thu, 11 May 2017 11:43:11 -0400 Received: from foss.arm.com ([217.140.101.70]:49830 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757055AbdEKPm6 (ORCPT ); Thu, 11 May 2017 11:42:58 -0400 Date: Thu, 11 May 2017 16:42:19 +0100 From: Mark Rutland To: Suzuki K Poulose , marc.zyngier@arm.com Cc: peterz@infradead.org, catalin.marinas@arm.com, bigeasy@linutronix.de, will.deacon@arm.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCHv2] arm64/cpufeature: don't use mutex in bringup path Message-ID: <20170511154219.GC19626@leverpostej> References: <1494514878-26878-1-git-send-email-mark.rutland@arm.com> <498b2e16-538a-d5ea-7843-2ebbff2007df@arm.com> <20170511153719.GB19626@leverpostej> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170511153719.GB19626@leverpostej> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 11, 2017 at 04:37:20PM +0100, Mark Rutland wrote: > On Thu, May 11, 2017 at 04:15:38PM +0100, Suzuki K Poulose wrote: > > On 11/05/17 16:01, Mark Rutland wrote: > > >+static inline bool cpus_have_const_cap(int num) > > >+{ > > >+ if (static_branch_likely(&arm64_const_caps_ready)) > > >+ return __cpus_have_const_cap(num); > > >+ else > > >+ return cpus_have_cap(num); > > > > We use cpus_have_const_cap() from hyp code, via has_vhe() and we could potentially > > try to access unmapped kernel data from hyp if we fallback to cpus_have_cap(). > > However, it looks like we have already set arm64_const_caps_ready, so should not > > hit it in practise. May be we could add a stricter version of the helper ? > > > > static inline cpus_have_const_cap_strict(int num) > > { > > BUG_ON(!static_branch_likely(&arm64_const_caps_ready); > > return __cpus_have_const_cap(num); > > } > > Just to check, is that the only user of cpus_have_const_cap() at hyp? > > If so, I can do something like the above, patching to use > it for has_vhe(). > > We don't have a BUG handler at hyp, but that should trigger a hyp panic, > which I guess is good enough. > > Marc, thoughts? The other option, given this is *only* used at hyp, is: static inline bool has_vhe(void) { return !!(read_sysreg(HCR_EL2) & HCR_E2H); } ... though I assume we may have avoided that deliberately. Thanks, Mark.