qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Fedin <p.fedin@samsung.com>
To: 'Paolo Bonzini' <pbonzini@redhat.com>,
	'Andrey Smetanin' <asmetanin@virtuozzo.com>,
	kvm@vger.kernel.org
Cc: 'Gleb Natapov' <gleb@kernel.org>,
	"'Denis V. Lunev'" <den@openvz.org>,
	'Peter Hornyack' <peterhornyack@google.com>,
	'Roman Kagan' <rkagan@virtuozzo.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4 5/5] kvm/x86: Hyper-V kvm exit
Date: Mon, 21 Dec 2015 10:44:08 +0300	[thread overview]
Message-ID: <00db01d13bc3$60969d80$21c3d880$@samsung.com> (raw)
In-Reply-To: <56742DF7.9000902@redhat.com>

 Hello!

 Replying to everything in one message.

> > As far as i understand this code, KVM_EXIT_HYPERV is called when one
> > of three MSRs are accessed. But, shouldn't we have implemented
> > instead something more generic, like KVM_EXIT_REG_IO, which would
> > work similar to KVM_EXIT_PIO or KVM_EXIT_MMIO, but carry register
> > code and value?
> 
> Yes, we considered that.  There were actually patches for this as well.

 Ah, i missed them, what a pity. There are lots of patches, i don't review them all. Actually i have noticed the change only after
it appeared in linux-next.

>  However, in this case the register is still emulated in the kernel, and
> userspace just gets informed of the new value.

 I see, but this doesn't change the semantic. All we need to do is to tell the userland that "register has been written".
Additionally to this we could do whatever we want, including caching the data in kernel, using it in kernel, and processing reads in
kernel.

> If we do get that, we will just rename KVM_EXIT_HYPERV to
> KVM_EXIT_MSR_ACCESS, and KVM_EXIT_HYPERV_SYNIC to
> KVM_EXIT_MSR_HYPERV_SYNIC, and struct kvm_hyperv_exit to kvm_msr_exit.

 Actually, i see this in more generic way, something like:

		/* KVM_EXIT_REG_ACCESS */
		struct {
			__u64 reg;
			__u64 data;
			__u8  is_write;
		} mmio;
 
 'data' and 'is_write' are self-explanatory, 'reg' would be generalized register code, the same as used for KVM_(GET|SET)_ONE_REG:
 - for ARM64: ARM64_SYS_REG(op0, op1, crn, crm, op2) - see
http://lxr.free-electrons.com/source/arch/arm64/include/uapi/asm/kvm.h#L189
 - for x86  : to be defined (i know, we don't use ..._ONE_REG operations here yet), like X86_MSR_REG(id), where the macro itself is:

	#define X86_MSR_REG(id) (KVM_REG_X86 | KVM_REG_X86_MSR | KVM_REG_SIZE_U64 | (id))

 - for other architectures: to be defined in a similar way, once needed.

> On brief inspection of Andrey's patch (I have not been following
> closely) it looks like the kvm_hyperv_exit struct that's returned to
> userspace contains more data (control, evt_page, and msg_page fields)
> than simply the value of the MSR, so would the desired SynIC exit fit
> into a general-purpose exit for MSR emulation?

 I have looked at the code too, and these three fields are nothing more than values of respective MSR's:

	case HV_X64_MSR_SCONTROL:
		synic->control = data;
		if (!host)
			synic_exit(synic, msr);
		break;

....

	case HV_X64_MSR_SIEFP:
		if (data & HV_SYNIC_SIEFP_ENABLE)
			if (kvm_clear_guest(vcpu->kvm,
					    data & PAGE_MASK, PAGE_SIZE)) {
				ret = 1;
				break;
			}
		synic->evt_page = data;
		if (!host)
			synic_exit(synic, msr);
		break;
	case HV_X64_MSR_SIMP:
		if (data & HV_SYNIC_SIMP_ENABLE)
			if (kvm_clear_guest(vcpu->kvm,
					    data & PAGE_MASK, PAGE_SIZE)) {
				ret = 1;
				break;
			}
		synic->msg_page = data;
		if (!host)
			synic_exit(synic, msr);
		break;

 So, every time one of these thee MSRs is written, we get a vmexit with values of all three registers, and that's all. We could
easily have 'synic_exit(synic, msr, data)' in all three cases, and i think the userspace could easily deal with proposed
KVM_EXIT_REG_ACCESS, just cache these values internally if needed.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

  parent reply	other threads:[~2015-12-21  7:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-10 12:36 [Qemu-devel] [PATCH v4 0/5] KVM: Hyper-V synthetic interrupt controller Andrey Smetanin
2015-11-10 12:36 ` [Qemu-devel] [PATCH v4 1/5] kvm/irqchip: kvm_arch_irq_routing_update renaming split Andrey Smetanin
2015-11-10 12:36 ` [Qemu-devel] [PATCH v4 2/5] kvm/x86: split ioapic-handled and EOI exit bitmaps Andrey Smetanin
2015-11-10 12:36 ` [Qemu-devel] [PATCH v4 3/5] kvm/x86: per-vcpu apicv deactivation support Andrey Smetanin
2015-11-10 12:36 ` [Qemu-devel] [PATCH v4 4/5] kvm/x86: Hyper-V synthetic interrupt controller Andrey Smetanin
2015-11-10 12:36 ` [Qemu-devel] [PATCH v4 5/5] kvm/x86: Hyper-V kvm exit Andrey Smetanin
2015-12-18 15:19   ` Pavel Fedin
2015-12-18 15:53     ` Denis V. Lunev
2015-12-18 16:01     ` Paolo Bonzini
2015-12-18 18:10       ` Peter Hornyack
2015-12-18 18:23         ` Paolo Bonzini
2015-12-18 18:39         ` Roman Kagan
2015-12-21 12:59           ` Andrey Smetanin
2015-12-21 13:28             ` Pavel Fedin
2015-12-21 13:48               ` Andrey Smetanin
2015-12-21 15:21                 ` Pavel Fedin
2015-12-18 18:25       ` 'Roman Kagan'
2015-12-21  7:44       ` Pavel Fedin [this message]
2015-12-18 18:00     ` 'Roman Kagan'

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='00db01d13bc3$60969d80$21c3d880$@samsung.com' \
    --to=p.fedin@samsung.com \
    --cc=asmetanin@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=gleb@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterhornyack@google.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rkagan@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).