x86/hvm: Handle x2apic MSRs via the new guest_{rd,wr}msr() infrastructure
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 26 Feb 2018 12:45:58 +0000 (12:45 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 5 Dec 2018 21:06:47 +0000 (21:06 +0000)
commit7824baee56248474346da138b906a3a5c5420458
tree69f9a75125233aae06b10278b135ae2eb2d5c817
parent689bc6244449fd988c32759201668738498ec261
x86/hvm: Handle x2apic MSRs via the new guest_{rd,wr}msr() infrastructure

Dispatch from the guest_{rd,wr}msr() functions.  The read side should be safe
outside of current context, but the write side is definitely not.  As the
toolstack has no legitimate reason to access the APIC registers via this
interface (not least because whether they are accessible at all depends on
guest settings), unilaterally reject access attempts outside of current
context.

Rename to guest_{rd,wr}msr_x2apic() for consistency, and alter the functions
to use X86EMUL_EXCEPTION rather than X86EMUL_UNHANDLEABLE.  The previous
callers turned UNHANDLEABLE into EXCEPTION, but using UNHANDLEABLE will now
interfere with the fallback to legacy MSR handling.

While altering guest_rdmsr_x2apic() make a couple of minor improvements.
Reformat the initialiser for readable[] so it indents in a more natural way,
and alter high to be a 64bit integer to avoid shifting 0 by 32 in the common
path.

Observant people might notice that we now don't let PV guests read the x2apic
MSRs.  They should never have been able to in the first place.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/vlapic.c
xen/arch/x86/msr.c
xen/include/asm-x86/hvm/hvm.h