MIPS: KVM: Consult HWREna before emulating RDHWR
authorJames Hogan <james.hogan@imgtec.com>
Fri, 14 Mar 2014 13:06:09 +0000 (13:06 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 19 Mar 2014 16:01:43 +0000 (17:01 +0100)
commit26f4f3b57862642296a2e613674e7f00d91c022f
tree34eff1982a3d9fcfd65a8f9d8a14bd6f87fd3949
parent15505679362270d02c449626385cb74af8905514
MIPS: KVM: Consult HWREna before emulating RDHWR

The ability to read hardware registers from userland with the RDHWR
instruction should depend upon the corresponding bit of the HWREna
register being set, otherwise a reserved instruction exception should be
generated.

However KVM's current emulation ignores the guest's HWREna and always
emulates RDHWR instructions even if the guest OS has disallowed them.

Therefore rework the RDHWR emulation code to check for privilege or the
corresponding bit in the guest HWREna bit. Also remove the #if 0 case
for the UserLocal register. I presume it was there for debug purposes
but it seems unnecessary now that the guest can control whether it
causes a guest exception.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Gleb Natapov <gleb@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sanjay Lal <sanjayl@kymasys.com>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/mips/include/asm/kvm_host.h
arch/mips/kvm/kvm_mips_emul.c