xen/arm: Correctly save/restore CNTKCTL_EL1
authorJulien Grall <julien.grall@linaro.org>
Thu, 1 May 2014 10:54:40 +0000 (11:54 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 1 May 2014 10:54:58 +0000 (11:54 +0100)
commit893256ffae0cf3be34a33a15efe2f2058b4b4fb7
tree9fd05040a645f32a13b1fdca16d8c27f04b2b976
parent9f2f1298d021196223470fb06be79b3dbf2f53e5
xen/arm: Correctly save/restore CNTKCTL_EL1

CNTKCTL_EL1 is used by the guest to control access to the timer from
userspace.  It therefore needs to be save/restored by Xen as part of
the VCPU state.

By default Linux on ARM64 exposes the timer to userspace.  Furthermore on
ARM64, Linux provides helpers in a VDSO (gettimeofday/__do_get_tspec)
that use the timer counter.  Conversely, during CPU bring up, Xen will
set CNTKCTL_EL1 to 0 (i.e disallow timer access to the userspace).  As
a result, currently, if dom0 has 1 VCPU which is migrated to another
PCPU, init might crash.

Alternatively, a guest (malicious or not) might decide to disable
access to the timer from userspace.  If the register is not
save/restored, when a DOM0 VCPU runs again, a similar crash would
result.

Also, drop CNTKCTL_EL1 initialization in init_timer_interrupt.  Xen
should let the guest deal with this register.

This is XSA-91 / CVE-2014-3125.

Reported-by: Chen Baozi <baozich@gmail.com>
Signed-off-by: Julien Grall <julien.grall@linaro.org>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arch/arm/domain.c
xen/arch/arm/time.c
xen/include/asm-arm/domain.h