[PATCH v10 4/6] ARM: add vdso user-space code

Catalin Marinas catalin.marinas at arm.com
Tue Feb 24 02:17:55 PST 2015


On Fri, Feb 20, 2015 at 04:52:16PM -0500, Christopher Covington wrote:
> On 02/18/2015 07:12 AM, Venkappa Mala wrote:
> > Catalin Marinas <catalin.marinas <at> arm.com> writes:
> >> IIRC there were some discussions about Linux booting in secure mode on
> >> ARMv7 with no firmware to initialise the Hyp registers. If that's the
> >> case for you, we could restart that discussion and try to initialise
> >> CNTVOFF in the kernel running in _secure_ mode (possibly with some CPU
> >> notifiers in the generic timer code).
> > 
> > My test environment is like CNTVOFF initialization is not taken care in 
> > the firmware, HYP mode is disabled and kernel is booted with Secure SVC 
> > PL1 mode. As you have mentioned about restarting the thread, perhaps, it 
> > will be good to have a discussion in the following  thread rather than 
> > restarting the thread.
> > arm: Handle starting up in secure mode
> > https://lkml.org/lkml/2014/9/16/552
> > 
> > May I know your opinion about this one?
> 
> Catalin pointed out that accesses to NSACR may trap. I have not yet found a
> reason why trying to write to CNTFRQ wouldn't work.

Writing CNTFRQ from non-secure mode would trap as well. For whatever
reason, the architecture doesn't allow you to easily detect whether the
code runs in secure or non-secure mode (unless it is EL2/Hyp which is
always non-secure). The detection mechanism would have to involve
trapping of an undefined instruction but it doesn't need to be done
early during boot.

Otherwise, I think in the arch timer code we could do something like:

	if (!is_hyp_mode_available() && !arch_timer_user_virtual &&
	    arch_timer_ppi[PHYS_SECURE_PPI]) {
		/*
		 * Assume the kernel is running in secure mode. Program
		 * the CNVOFF and CNTFRQ registers.
		 */
		...
	}

-- 
Catalin



More information about the linux-arm-kernel mailing list