From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Avi Kivity <avi@qumranet.com>
Cc: kvm <kvm@vger.kernel.org>, Carsten Otte <cotte@de.ibm.com>,
Olaf Schnapper <os@de.ibm.com>,
Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Subject: Re: [PATCH] kvm-userspace: fix memslot assignment
Date: Thu, 31 Jul 2008 10:01:07 +0200 [thread overview]
Message-ID: <200807311001.07426.borntraeger@de.ibm.com> (raw)
In-Reply-To: <488F18B9.1010700@qumranet.com>
Am Dienstag, 29. Juli 2008 schrieb Avi Kivity:
> They all start with 0 AFAIK (kvm also starts with 0, it just wants it to
> be a special slot).
Now my brain hurts....
Ok, so I read this as: ppc, ia64 and s390 can start with slot 0 and it is not a special slot.
On x86 slot 0 is special, if
* KVM_CAP_SET_TSS_ADDR is not available
or
* The ioctl VM_CAP_SET_TSS_ADDR returns <=0
Since my opteron box died recently I cannot test that on x86 at the moment.
What do you think about the following patch
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
libkvm/libkvm.c | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)
Index: kvm-userspace/libkvm/libkvm.c
===================================================================
--- kvm-userspace.orig/libkvm/libkvm.c
+++ kvm-userspace/libkvm/libkvm.c
@@ -75,25 +75,21 @@ void init_slots(void)
int get_free_slot(kvm_context_t kvm)
{
- int i;
- int tss_ext;
-
-#if defined(KVM_CAP_SET_TSS_ADDR) && !defined(__s390__)
- tss_ext = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_SET_TSS_ADDR);
-#else
- tss_ext = 0;
-#endif
+ int i = 0;
/*
- * on older kernels where the set tss ioctl is not supprted we must save
- * slot 0 to hold the extended memory, as the vmx will use the last 3
- * pages of this slot.
+ * on older x86 kernels where the set tss ioctl is not supported we
+ * must save slot 0 to hold the extended memory, as the vmx will
+ * use the last 3 pages of this slot.
*/
- if (tss_ext > 0)
- i = 0;
- else
- i = 1;
-
+#if defined(__x86_64__) || defined(__i386__)
+#if defined(KVM_CAP_SET_TSS_ADDR)
+ if (ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_SET_TSS_ADDR) > 0)
+ i++;
+#else
+ i++;
+#endif
+#endif
for (; i < KVM_MAX_NUM_MEM_REGIONS; ++i)
if (!slots[i].len)
return i;
next prev parent reply other threads:[~2008-07-31 8:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-25 15:38 [PATCH] kvm-userspace: fix memslot assignment Christian Borntraeger
2008-07-27 8:18 ` Avi Kivity
2008-07-28 16:55 ` Christian Borntraeger
2008-07-29 13:18 ` Avi Kivity
2008-07-31 8:01 ` Christian Borntraeger [this message]
2008-07-31 11:24 ` Avi Kivity
2008-07-31 12:03 ` Izik Eidos
2008-07-31 12:53 ` Christian Borntraeger
2008-07-31 13:00 ` Avi Kivity
2008-07-31 14:57 ` Christian Borntraeger
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=200807311001.07426.borntraeger@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=avi@qumranet.com \
--cc=cotte@de.ibm.com \
--cc=ehrhardt@linux.vnet.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=os@de.ibm.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