From: Anthony Liguori <anthony@codemonkey.ws>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: kvm-devel <kvm-devel@lists.sourceforge.net>,
virtualization <virtualization@lists.osdl.org>,
Anthony Liguori <aliguori@us.ibm.com>
Subject: Re: [kvm-devel] [PATCH 1/3] KVM paravirt_ops infrastructure
Date: Wed, 30 May 2007 20:15:33 -0500 [thread overview]
Message-ID: <465E21B5.1090605@codemonkey.ws> (raw)
In-Reply-To: <1180573347.30202.135.camel@localhost.localdomain>
Rusty Russell wrote:
> On Wed, 2007-05-30 at 09:52 -0500, Anthony Liguori wrote:
>
>> This patch adds the basic infrastructure for paravirtualizing a KVM
>> guest.
>>
>
> Hi Anthony!
>
> Nice patch, comments below.
>
>
>> Discovery of running under KVM is done by sharing a page of memory
>> between
>> the guest and host (initially through an MSR write).
>>
>
> I missed the shared page in this patch? If you are going to do that,
> perhaps putting the hypercall magic in that page is a good idea?
>
para_state is the shared page. The address is passed to the KVM via the
MSR (so it's a shared page owned by the guest).
>> +extern unsigned char hypercall_addr[4];
>>
>
> Perhaps in a header?
>
>
>> +asm (
>> + ".globl hypercall_addr\n"
>> + ".align 4\n"
>> + "hypercall_addr:\n"
>> + "movl $-38, %eax\n"
>> + "ret\n"
>> +);
>>
>
> I don't think we want the hypercall returning Linux error numbers, and
> magic numbers are bad too. ud2 here I think.
>
Yeah, you're not the first one to suggest this. The thing is, KVM
already has host-side support for a hypercall API. I didn't want to
change that unless I had to. However, based on the prior feedback re:
using CPUID, I will be changing it so I'll update this too.
>> + para_state->guest_version = KVM_PARA_API_VERSION;
>> + para_state->host_version = -1;
>> + para_state->size = sizeof(*para_state);
>> + para_state->ret = 0;
>> + para_state->hypercall_gpa = __pa(hypercall_addr);
>>
>
> Two versions, size *and* ret? This seems like overkill...
>
Yeah, I agree :-) I actually am not a huge fan of using version
numbers. I think I'm going to try the next patch using a single version
number and a feature bitmap. Some of the optimizations (like MMU
batching) don't make sense in a NPT/EPT environment but the guest
shouldn't have to be aware of that.
>> + if (wrmsr_safe(MSR_KVM_API_MAGIC, __pa(para_state), 0)) {
>> + printk(KERN_INFO "KVM guest: WRMSR probe failed.\n");
>> + return -ENOENT;
>> + }
>>
>
> How about printk(KERN_INFO "I am not a KVM guest\n");?
>
>
>> +static int __init kvm_guest_init(void)
>> +{
>> + int rc;
>> +
>> + rc = kvm_guest_register_para(smp_processor_id());
>> + if (rc) {
>> + printk(KERN_INFO "paravirt KVM unavailable\n");
>>
>
> Double-printk when KVM isn't detected seems overkill. Perhaps you could
> just fold this all into one function...
>
Already have.
> (Personal gripe: I consider a variable named "rc" to be an admission of
> semantic defeat... "err" would be better here...)
>
I'm not sure I agree that's one's better than the other. Although I
guess if (err) { reads a little better...
Regards,
Anthony Liguori
> Thanks!
> Rusty.
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> kvm-devel mailing list
> kvm-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/kvm-devel
>
>
next prev parent reply other threads:[~2007-05-31 1:15 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-30 14:49 [PATCH 0/3] KVM paravirt_ops implementation Anthony Liguori
2007-05-30 14:52 ` [PATCH 1/3] KVM paravirt_ops infrastructure Anthony Liguori
2007-05-30 16:42 ` [kvm-devel] " Nakajima, Jun
[not found] ` <97D612E30E1F88419025B06CB4CF1BE10259AAD7-1a9uaKK1+wJcIJlls4ac1rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-05-30 18:11 ` Anthony Liguori
[not found] ` <465DBE3A.6030908-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-05-30 19:04 ` Nakajima, Jun
[not found] ` <97D612E30E1F88419025B06CB4CF1BE10259AD83-1a9uaKK1+wJcIJlls4ac1rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-05-31 17:31 ` Anthony Liguori
[not found] ` <465F0688.1050702-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-05-31 18:47 ` Nakajima, Jun
2007-05-31 1:02 ` Rusty Russell
2007-05-31 1:15 ` Anthony Liguori [this message]
[not found] ` <1180573347.30202.135.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-05-31 7:48 ` Avi Kivity
2007-05-31 9:58 ` Andi Kleen
[not found] ` <200705311158.28632.ak-l3A5Bk7waGM@public.gmane.org>
2007-05-31 10:11 ` Ingo Molnar
[not found] ` <20070531101116.GA10872-X9Un+BFzKDI@public.gmane.org>
2007-05-31 10:40 ` Andi Kleen
[not found] ` <200705311240.19794.ak-l3A5Bk7waGM@public.gmane.org>
2007-05-31 11:12 ` Rusty Russell
2007-05-31 17:28 ` [kvm-devel] " Anthony Liguori
2007-05-31 17:29 ` Anthony Liguori
2007-05-30 14:53 ` [PATCH 2/3][PARAVIRT] Make IO delay a NOP Anthony Liguori
[not found] ` <465D8F03.7000201-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-05-30 14:53 ` [PATCH 3/3] Eliminate read_cr3 on TLB flush Anthony Liguori
[not found] ` <465D8FF5.6040804-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-05-30 15:01 ` Andi Kleen
2007-05-30 15:32 ` Anthony Liguori
2007-05-30 15:38 ` Jeremy Fitzhardinge
2007-05-30 17:11 ` [kvm-devel] " Nakajima, Jun
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=465E21B5.1090605@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=aliguori@us.ibm.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=rusty@rustcorp.com.au \
--cc=virtualization@lists.osdl.org \
/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).