* [Qemu-devel] [PATCH] kvm: ppc: detect old headers
@ 2011-04-17 8:49 Alexander Graf
0 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2011-04-17 8:49 UTC (permalink / raw)
To: qemu-devel
When compiling Qemu with older kernel headers, the PVR setting
mechanism isn't available yet. Unfortunately, back then I didn't add
a capability we could check against, so all we can do is add a configure
test to see if we support PVR setting. For BookE, we don't care yet.
While at it, also memset the sregs to zero, so we have sane state in
case we add fields later.
This fixes compilation errors with KVM enabled on older kernel headers
(like 2.6.32).
Signed-off-by: Alexander Graf <agraf@suse.de>
---
configure | 18 ++++++++++++++++++
target-ppc/kvm.c | 24 +++++++++++++++++++++---
2 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index da2da04..7b90e1e 100755
--- a/configure
+++ b/configure
@@ -1772,6 +1772,21 @@ recent kvm-kmod from http://sourceforge.net/projects/kvm."
fi
##########################################
+# test for ppc kvm pvr setting
+
+if test "$kvm" = "yes" && test "$cpu" = "ppc" -o "$cpu" = "ppc64"; then
+ cat > $TMPC <<EOF
+ #include <asm/kvm.h>
+ int main(void) { struct kvm_sregs s; s.pvr = 0; return 0; }
+EOF
+ if compile_prog "$kvm_cflags" "" ; then
+ kvm_ppc_pvr=yes
+ else
+ kvm_ppc_pvr=no
+ fi
+fi
+
+##########################################
# test for vhost net
if test "$vhost_net" != "no"; then
@@ -3241,6 +3256,9 @@ case "$target_arch2" in
if test $vhost_net = "yes" ; then
echo "CONFIG_VHOST_NET=y" >> $config_target_mak
fi
+ if test $kvm_ppc_pvr = "yes" ; then
+ echo "CONFIG_KVM_PPC_PVR=y" >> $config_target_mak
+ fi
fi
esac
if test "$target_bigendian" = "yes" ; then
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 2cfb24b..93d91df 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -80,10 +80,28 @@ int kvm_arch_init(KVMState *s)
int kvm_arch_init_vcpu(CPUState *cenv)
{
int ret = 0;
- struct kvm_sregs sregs;
- sregs.pvr = cenv->spr[SPR_PVR];
- ret = kvm_vcpu_ioctl(cenv, KVM_SET_SREGS, &sregs);
+ if ((cenv->mmu_model == POWERPC_MMU_BOOKE) ||
+ (cenv->mmu_model == POWERPC_MMU_BOOKE_FSL)) {
+ /* What we're really trying to say is "if we're on BookE, we use
+ the native PVR for now". This is the only sane way to check
+ it though, so we potentially confuse users that they can run
+ BookE guests on BookS. Let's hope nobody dares enough :) */
+ } else {
+#ifdef CONFIG_KVM_PPC_PVR
+ struct kvm_sregs sregs;
+
+ memset(&sregs, 0, sizeof(sregs));
+ sregs.pvr = cenv->spr[SPR_PVR];
+ ret = kvm_vcpu_ioctl(cenv, KVM_SET_SREGS, &sregs);
+#else
+ ret = -ENOSYS;
+#endif
+
+ if (ret) {
+ fprintf(stderr, "kvm error: missing PVR setting capability\n");
+ }
+ }
idle_timer = qemu_new_timer_ns(vm_clock, kvm_kick_env, cenv);
--
1.6.0.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH] kvm: ppc: detect old headers
@ 2011-05-03 11:54 Alexander Graf
2011-05-03 11:54 ` [Qemu-devel] [PATCH] kvm: ppc: warn user on PAGE_SIZE mismatch Alexander Graf
2011-05-03 12:14 ` [Qemu-devel] [PATCH] kvm: ppc: detect old headers Jan Kiszka
0 siblings, 2 replies; 8+ messages in thread
From: Alexander Graf @ 2011-05-03 11:54 UTC (permalink / raw)
To: QEMU-devel Developers; +Cc: Scott Wood
When compiling Qemu with older kernel headers, the PVR setting
mechanism isn't available yet. Unfortunately, back then I didn't add
a capability we could check against, so all we can do is add a configure
test to see if we support PVR setting. For BookE, we don't care yet.
This fixes compilation errors with KVM enabled on older kernel headers
(like 2.6.32).
Signed-off-by: Alexander Graf <agraf@suse.de>
---
configure | 18 ++++++++++++++++++
target-ppc/kvm.c | 16 +++++++++++++++-
2 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/configure b/configure
index fbf5d5f..adfbb40 100755
--- a/configure
+++ b/configure
@@ -1772,6 +1772,21 @@ recent kvm-kmod from http://sourceforge.net/projects/kvm."
fi
##########################################
+# test for ppc kvm pvr setting
+
+if test "$kvm" = "yes" && test "$cpu" = "ppc" -o "$cpu" = "ppc64"; then
+ cat > $TMPC <<EOF
+ #include <asm/kvm.h>
+ int main(void) { struct kvm_sregs s; s.pvr = 0; return 0; }
+EOF
+ if compile_prog "$kvm_cflags" "" ; then
+ kvm_ppc_pvr=yes
+ else
+ kvm_ppc_pvr=no
+ fi
+fi
+
+##########################################
# test for vhost net
if test "$vhost_net" != "no"; then
@@ -3257,6 +3272,9 @@ case "$target_arch2" in
if test $vhost_net = "yes" ; then
echo "CONFIG_VHOST_NET=y" >> $config_target_mak
fi
+ if test $kvm_ppc_pvr = "yes" ; then
+ echo "CONFIG_KVM_PPC_PVR=y" >> $config_target_mak
+ fi
fi
esac
if test "$target_bigendian" = "yes" ; then
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 5a1b6cb..ccf4668 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -94,19 +94,33 @@ static int kvm_arch_sync_sregs(CPUState *cenv)
int ret;
if (cenv->excp_model == POWERPC_EXCP_BOOKE) {
+ /* What we're really trying to say is "if we're on BookE, we use
+ the native PVR for now". This is the only sane way to check
+ it though, so we potentially confuse users that they can run
+ BookE guests on BookS. Let's hope nobody dares enough :) */
return 0;
} else {
if (!cap_segstate) {
- return 0;
+ fprintf(stderr, "kvm error: missing PVR setting capability\n");
+ return -ENOSYS;
}
}
+#if !defined(CONFIG_KVM_PPC_PVR)
+ if (1) {
+ fprintf(stderr, "kvm error: missing PVR setting capability\n");
+ return -ENOSYS;
+ }
+#endif
+
ret = kvm_vcpu_ioctl(cenv, KVM_GET_SREGS, &sregs);
if (ret) {
return ret;
}
+#ifdef CONFIG_KVM_PPC_PVR
sregs.pvr = cenv->spr[SPR_PVR];
+#endif
return kvm_vcpu_ioctl(cenv, KVM_SET_SREGS, &sregs);
}
--
1.6.0.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH] kvm: ppc: warn user on PAGE_SIZE mismatch
2011-05-03 11:54 [Qemu-devel] [PATCH] kvm: ppc: detect old headers Alexander Graf
@ 2011-05-03 11:54 ` Alexander Graf
2011-05-03 12:14 ` [Qemu-devel] [PATCH] kvm: ppc: detect old headers Jan Kiszka
1 sibling, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2011-05-03 11:54 UTC (permalink / raw)
To: QEMU-devel Developers; +Cc: Scott Wood
On PPC, the default PAGE_SIZE is 64kb. Unfortunately, the hardware
alignments don't match here: There are RAM and MMIO regions within
a single page when it's 64kb in size.
So the only way out for now is to tell the user that he should use 4k
PAGE_SIZE.
This patch gives the user a hint on that, telling him that failing to
register a prefix slot is most likely to be caused by mismatching PAGE_SIZE.
This way it's also more future-proof, as bigger PAGE_SIZE can easily be
supported by other machines then, as long as they stick to 64kb granularities.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
kvm-all.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/kvm-all.c b/kvm-all.c
index d92c20e..a30865e 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -590,6 +590,11 @@ static void kvm_set_phys_mem(target_phys_addr_t start_addr, ram_addr_t size,
if (err) {
fprintf(stderr, "%s: error registering prefix slot: %s\n",
__func__, strerror(-err));
+#ifdef TARGET_PPC
+ fprintf(stderr, "%s: This is probably because your kernel's " \
+ "PAGE_SIZE is too big. Please try to use 4k " \
+ "PAGE_SIZE!\n", __func__);
+#endif
abort();
}
}
--
1.6.0.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] kvm: ppc: detect old headers
2011-05-03 11:54 [Qemu-devel] [PATCH] kvm: ppc: detect old headers Alexander Graf
2011-05-03 11:54 ` [Qemu-devel] [PATCH] kvm: ppc: warn user on PAGE_SIZE mismatch Alexander Graf
@ 2011-05-03 12:14 ` Jan Kiszka
2011-05-03 12:28 ` Alexander Graf
1 sibling, 1 reply; 8+ messages in thread
From: Jan Kiszka @ 2011-05-03 12:14 UTC (permalink / raw)
To: Alexander Graf; +Cc: Scott Wood, QEMU-devel Developers
On 2011-05-03 13:54, Alexander Graf wrote:
> When compiling Qemu with older kernel headers, the PVR setting
> mechanism isn't available yet. Unfortunately, back then I didn't add
> a capability we could check against, so all we can do is add a configure
> test to see if we support PVR setting. For BookE, we don't care yet.
>
> This fixes compilation errors with KVM enabled on older kernel headers
> (like 2.6.32).
Why not finally import the latest kvm kernel headers into qemu? Would
save us a lot of current and future configure and #ifdef dances.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] kvm: ppc: detect old headers
2011-05-03 12:14 ` [Qemu-devel] [PATCH] kvm: ppc: detect old headers Jan Kiszka
@ 2011-05-03 12:28 ` Alexander Graf
2011-05-03 12:31 ` Jan Kiszka
0 siblings, 1 reply; 8+ messages in thread
From: Alexander Graf @ 2011-05-03 12:28 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Scott Wood, QEMU-devel Developers
On 03.05.2011, at 14:14, Jan Kiszka wrote:
> On 2011-05-03 13:54, Alexander Graf wrote:
>> When compiling Qemu with older kernel headers, the PVR setting
>> mechanism isn't available yet. Unfortunately, back then I didn't add
>> a capability we could check against, so all we can do is add a configure
>> test to see if we support PVR setting. For BookE, we don't care yet.
>>
>> This fixes compilation errors with KVM enabled on older kernel headers
>> (like 2.6.32).
>
> Why not finally import the latest kvm kernel headers into qemu? Would
> save us a lot of current and future configure and #ifdef dances.
Sure, sounds like a good topic for today's call?
Alex
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] kvm: ppc: detect old headers
2011-05-03 12:28 ` Alexander Graf
@ 2011-05-03 12:31 ` Jan Kiszka
2011-05-03 12:33 ` Alexander Graf
0 siblings, 1 reply; 8+ messages in thread
From: Jan Kiszka @ 2011-05-03 12:31 UTC (permalink / raw)
To: Alexander Graf; +Cc: Scott Wood, QEMU-devel Developers
On 2011-05-03 14:28, Alexander Graf wrote:
>
> On 03.05.2011, at 14:14, Jan Kiszka wrote:
>
>> On 2011-05-03 13:54, Alexander Graf wrote:
>>> When compiling Qemu with older kernel headers, the PVR setting
>>> mechanism isn't available yet. Unfortunately, back then I didn't add
>>> a capability we could check against, so all we can do is add a configure
>>> test to see if we support PVR setting. For BookE, we don't care yet.
>>>
>>> This fixes compilation errors with KVM enabled on older kernel headers
>>> (like 2.6.32).
>>
>> Why not finally import the latest kvm kernel headers into qemu? Would
>> save us a lot of current and future configure and #ifdef dances.
>
> Sure, sounds like a good topic for today's call?
Fine with me. Patch should be done by then as well.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] kvm: ppc: detect old headers
2011-05-03 12:31 ` Jan Kiszka
@ 2011-05-03 12:33 ` Alexander Graf
2011-05-03 13:02 ` Jan Kiszka
0 siblings, 1 reply; 8+ messages in thread
From: Alexander Graf @ 2011-05-03 12:33 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Scott Wood, QEMU-devel Developers, kvm@vger.kernel.org list
On 03.05.2011, at 14:31, Jan Kiszka wrote:
> On 2011-05-03 14:28, Alexander Graf wrote:
>>
>> On 03.05.2011, at 14:14, Jan Kiszka wrote:
>>
>>> On 2011-05-03 13:54, Alexander Graf wrote:
>>>> When compiling Qemu with older kernel headers, the PVR setting
>>>> mechanism isn't available yet. Unfortunately, back then I didn't add
>>>> a capability we could check against, so all we can do is add a configure
>>>> test to see if we support PVR setting. For BookE, we don't care yet.
>>>>
>>>> This fixes compilation errors with KVM enabled on older kernel headers
>>>> (like 2.6.32).
>>>
>>> Why not finally import the latest kvm kernel headers into qemu? Would
>>> save us a lot of current and future configure and #ifdef dances.
>>
>> Sure, sounds like a good topic for today's call?
>
> Fine with me. Patch should be done by then as well.
*shrug* I'm fairly indifferent on that topic. It would help users, so they can easier compile things, but requires us to keep the headers in sync. Do you have any good way of automating the process?
Alex
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] kvm: ppc: detect old headers
2011-05-03 12:33 ` Alexander Graf
@ 2011-05-03 13:02 ` Jan Kiszka
0 siblings, 0 replies; 8+ messages in thread
From: Jan Kiszka @ 2011-05-03 13:02 UTC (permalink / raw)
To: Alexander Graf
Cc: Scott Wood, QEMU-devel Developers, kvm@vger.kernel.org list
On 2011-05-03 14:33, Alexander Graf wrote:
>
> On 03.05.2011, at 14:31, Jan Kiszka wrote:
>
>> On 2011-05-03 14:28, Alexander Graf wrote:
>>>
>>> On 03.05.2011, at 14:14, Jan Kiszka wrote:
>>>
>>>> On 2011-05-03 13:54, Alexander Graf wrote:
>>>>> When compiling Qemu with older kernel headers, the PVR setting
>>>>> mechanism isn't available yet. Unfortunately, back then I didn't add
>>>>> a capability we could check against, so all we can do is add a configure
>>>>> test to see if we support PVR setting. For BookE, we don't care yet.
>>>>>
>>>>> This fixes compilation errors with KVM enabled on older kernel headers
>>>>> (like 2.6.32).
>>>>
>>>> Why not finally import the latest kvm kernel headers into qemu? Would
>>>> save us a lot of current and future configure and #ifdef dances.
>>>
>>> Sure, sounds like a good topic for today's call?
>>
>> Fine with me. Patch should be done by then as well.
>
> *shrug* I'm fairly indifferent on that topic. It would help users, so they can easier compile things, but requires us to keep the headers in sync. Do you have any good way of automating the process?
There will be a 'make update-kvm-headers' target, imported from
kvm-kmod. Can be run against some recent kernel, and the result will
just have to be committed & posted.
Moreover, I will drop alternative ways of pulling in headers (except via
CFLAGS overwriting). That will typically bite the patch submitter who
requires a header update and make her/him submit latest headers as well.
So far at least for the theory.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-05-03 13:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-03 11:54 [Qemu-devel] [PATCH] kvm: ppc: detect old headers Alexander Graf
2011-05-03 11:54 ` [Qemu-devel] [PATCH] kvm: ppc: warn user on PAGE_SIZE mismatch Alexander Graf
2011-05-03 12:14 ` [Qemu-devel] [PATCH] kvm: ppc: detect old headers Jan Kiszka
2011-05-03 12:28 ` Alexander Graf
2011-05-03 12:31 ` Jan Kiszka
2011-05-03 12:33 ` Alexander Graf
2011-05-03 13:02 ` Jan Kiszka
-- strict thread matches above, loose matches on Subject: below --
2011-04-17 8:49 Alexander Graf
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).