Re: [PATCH 02/24] KVM: Provide callback to get/set control registers in emulator ops.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 09, 2010 at 04:18:09PM +0200, Avi Kivity wrote:
> On 03/09/2010 04:09 PM, Gleb Natapov wrote:
> >Use this callback instead of directly call kvm function. Also rename
> >realmode_(set|get)_cr to emulator_(set|get)_cr since function has nothing
> >to do with real mode.
> >
> >
> >+	ulong (*get_cr)(int cr, struct kvm_vcpu *vcpu);
> >+	void (*set_cr)(int cr, ulong val, struct kvm_vcpu *vcpu);
> >  };
> 
> Note, passing a vcpu means we are still tightly coupled to kvm.  Can
> be fixed later.
> 
Yes, that is on my todo.

> >+static unsigned long emulator_get_cr(int cr, struct kvm_vcpu *vcpu)
> >+{
> >+	unsigned long value;
> >+
> >+	switch (cr) {
> >+	case 0:
> >+		value = kvm_read_cr0(vcpu);
> >+		break;
> >+	case 2:
> >+		value = vcpu->arch.cr2;
> >+		break;
> >+	case 3:
> >+		value = vcpu->arch.cr3;
> >+		break;
> >+	case 4:
> >+		value = kvm_read_cr4(vcpu);
> >+		break;
> >+	case 8:
> >+		value = kvm_get_cr8(vcpu);
> >+		break;
> >+	default:
> >+		vcpu_printf(vcpu, "%s: unexpected cr %u\n", __func__, cr);
> >+		return 0;
> 
> This printk is triggerable by guest code (as the patch didn't
> introduce this, it can be fixed later).
> 
> The emulator should #UD on unrecognised control registers.
inject #UD on access to non-existing CR patch does this.

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

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux