On Wed, May 28, 2014 at 4:14 AM, Jidong Xiao <jidong.x...@gmail.com> wrote:
> Hi,
>
> In kvm_set_msr_common(), I see that the follow piece of code will
> handle the write operation to the register MSR_K7_HWCR.
>
> case MSR_K7_HWCR:
>           data &= ~(u64)0x40; /* ignore flush filter disable */
>           data &= ~(u64)0x100; /* ignore ignne emulation enable */
>           data &= ~(u64)0x8; /* ignore TLB cache disable */
>           if (data != 0) {
>                pr_unimpl(vcpu, "unimplemented HWCR wrmsr: 0x%llx\n",data);
>                return 1;
>            }
>           break;
>
> I am totally confused that, from this piece of code, we can see,
> nothing will actually be written to MSR_K7_HWCR, if so, why do we
> explicitly ignore some bits?
>
> if we don't want the guest to write 0x40, 0x100, 0x8 to this register,
> why don't we just return 1 and do nothing else. Like this:
>
> case MSR_K7_HWCR:
>          {
>                pr_unimpl(vcpu, "unimplemented HWCR wrmsr: 0x%llx\n",data);
>                return 1;
>            }
>
> Or, we can simply use the default case, which may also return 1.
>
> So, my question is, if we explicitly emulate this register, why do we
> also explicitly ignore all the write operation to this register?
>
I think I have figured out this by myself. The reason we explicitly
support MSR_K7_HWCR is, if we don't, when the guest attempts to write
to this register, KVM might inject general protection fault into
guest, and this, may crash the guest. To avoid this, we pretend to
support the write operation to this register, although we actually
will ignore the stuff written into this register.

-Jidong
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to