x86/PV: conditionally avoid raising #GP for early guest MSR reads
authorJan Beulich <jbeulich@suse.com>
Fri, 12 Mar 2021 11:02:42 +0000 (12:02 +0100)
committerIan Jackson <iwj@xenproject.org>
Fri, 12 Mar 2021 17:00:08 +0000 (17:00 +0000)
commit6eef0a99262cc903495879448cc4ffefe305ef2a
tree2ba7c1764e9c52acc1139307f6c967a79854e90a
parent9dc46386d89d83c73c41c2b19be83a73957c4393
x86/PV: conditionally avoid raising #GP for early guest MSR reads

Prior to 4.15 Linux, when running in PV mode, did not install a #GP
handler early enough to cover for example the rdmsrl_safe() of
MSR_K8_TSEG_ADDR in bsp_init_amd() (not to speak of the unguarded read
of MSR_K7_HWCR later in the same function). The respective change
(42b3a4cb5609 "x86/xen: Support early interrupts in xen pv guests") was
backported to 4.14, but no further - presumably since it wasn't really
easy because of other dependencies.

Therefore, to prevent our change in the handling of guest MSR accesses
to render PV Linux 4.13 and older unusable on at least AMD systems, make
the raising of #GP on this paths conditional upon the guest having
installed a handler, provided of course the MSR can be read in the first
place (we would have raised #GP in that case even before). Producing
zero for reads isn't necessarily correct and may trip code trying to
detect presence of MSRs early, but since such detection logic won't work
without a #GP handler anyway, this ought to be a fair workaround.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
Acked-by: Ian Jackson <iwj@xenproject.org>
xen/arch/x86/pv/emul-priv-op.c
xen/include/public/arch-x86/xen.h