kvm book3s issues
Subsystems (2)
Hi Alex !
After a bit of digging as to why the karmic installer dies, I found out that you don't set the right SRR1 bits when forwarding a program check exception to the guest.
I also did a couple of minor fixups (though the s/mtmsr/mtmsrd may not be necessary, I think the clearing of HID5 is). Patch below, haven't had a chance to clean it up into a proper submission yet.
I didn't go very much further yet with the karmic graphical installer, but that isn't a surprise. I'll try the text one as soon as I get to d/l the alternate ISO.
Cheers,
Ben.
arch/powerpc/kvm/book3s.c +2 -0
@@ -627,6 +627,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,#endif if ((vcpu->arch.last_inst & 0xff0007ff) ! (INS_DCBZ & 0xfffffff7)) { + vcpu->arch.msr |= (vcpu->arch.shadow_msr &0x1f0000ull );kvmppc_book3s_queue_irqprio (vcpu, exit_nr); r =RESUME_GUEST ;break ;
@@ -642,6 +643,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,case EMULATE_FAIL :printk (KERN_CRIT "%s: emulation at %lx failed (%08x)\n" , __func__, vcpu->arch.pc, vcpu->arch.last_inst); + vcpu->arch.msr |= (vcpu->arch.shadow_msr &0x1f0000ull );kvmppc_book3s_queue_irqprio (vcpu, exit_nr); r =RESUME_GUEST ;break ;
arch/powerpc/kvm/book3s_64_interrupts.S +2 -1
@@ -241,8 +241,9 @@ kvmppc_handler_highmem: rldicl. r5, r5, 0, 63 /* CR = ((r5 & 1) = 0) */ beq no_dcbz32_off + li r4,0 mfspr r5,SPRN_HID5 - rldimi r5,r5,6,56 + rldimi r5,r4,6,56 mtspr SPRN_HID5,r5 no_dcbz32_off:
arch/powerpc/kvm/book3s_64_slb.S +2 -2
@@ -205,11 +205,11 @@ ld_last_inst: /* 1) enable paging for data */ mfmsr r9 ori r11, r9, MSR_DR /* Enable paging for data */ - mtmsr r11 + mtmsrd r11 /* 2) fetch the instruction */ lwz r0, 0(r10) /* 3) disable paging again */ - mtmsr r9 + mtmsrd r9 no_ld_last_inst:
Quoted 6 lines · Benjamin Herrenschmidt
Hi Alex !
After a bit of digging as to why the karmic installer dies, I found out
that you don't set the right SRR1 bits when forwarding a program check exception to the guest.
Cool, thanks for trying things out and debugging them! :-)
Quoted 18 lines
I also did a couple of minor fixups (though the s/mtmsr/mtmsrd may not be necessary, I think the clearing of HID5 is). Patch below, haven't had
a chance to clean it up into a proper submission yet.I didn't go very much further yet with the karmic graphical installer, but that isn't a surprise. I'll try the text one as soon as I get to d/l
the alternate ISO.Cheers,
Ben.arch/powerpc/kvm/book3s.c +0
-0
arch/powerpc/kvm/book3s.c int kvmppc_handle_exit(struct kvm_run *run, · line 630
Quoted 4 lines
arch/powerpc/kvm/book3s.c +1
-0@@ -627,6 +627,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,#endif if ((vcpu->arch.last_inst & 0xff0007ff) !> (INS_DCBZ & 0xfffffff7)) { + vcpu->arch.msr |= (vcpu->arch.shadow_msr &0x1f0000ull );
What bits are those? It might be good to use real #define's here :-).
Quoted 18 lines
arch/powerpc/kvm/book3s.c +1
-0kvmppc_book3s_queue_irqprio (vcpu, exit_nr); r =RESUME_GUEST ;break ;@@ -642,6 +643,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, case EMULATE_FAIL: printk(KERN_CRIT "%s: emulation at %lx failed (%08x)\n", __func__, vcpu->arch.pc, vcpu->arch.last_inst); + vcpu->arch.msr |= (vcpu->arch.shadow_msr &0x1f0000ull );kvmppc_book3s_queue_irqprio (vcpu, exit_nr); r =RESUME_GUEST ;break;arch/powerpc/ renamed from arch/powerpc/kvm/book3s_64_interrupts.S +0
-0
kvm/book3s_64_interrupts.S
index 7b55d80..22f2962 100644
arch/powerpc/kvm/book3s_64_interrupts.S kvmppc_handler_highmem: · line 246
Quoted 7 lines
arch/powerpc/kvm/book3s_64_interrupts.S +2
-1@@ -241,8 +241,9 @@ kvmppc_handler_highmem: rldicl. r5, r5, 0, 63 /* CR = ((r5 & 1) = 0) */ beq no_dcbz32_off + li r4,0 mfspr r5,SPRN_HID5 - rldimi r5,r5,6,56 + rldimi r5,r4,6,56
When you're on a G5 you never get into this code path, right? You're using the dcbz binary patched emulation instead.
So what you do is you replace
HID5 &= ~DCBZ32;
with
HID5 = 0;
Is that intentional?
Quoted 9 lines
arch/powerpc/kvm/book3s_64_interrupts.S +0
-0mtspr SPRN_HID5,r5
no_dcbz32_off:arch/powerpc/kvm/ renamed from arch/powerpc/kvm/book3s_64_slb.S +0
-0
book3s_64_slb.S
index ecd237a..c574cf7 100644
arch/powerpc/kvm/book3s_64_slb.S ld_last_inst: · line 208
Quoted 5 lines
arch/powerpc/kvm/book3s_64_slb.S +1
-1@@ -205,11 +205,11 @@ ld_last_inst: /* 1) enable paging for data */ mfmsr r9 ori r11, r9, MSR_DR /* Enable paging for data */ - mtmsr r11 + mtmsrd r11
Wasn't mtmsrd this extra cool new version that takes a second argument so one can only set IF?
Alex
Quoted 4 lines · Alexander Graf
Review
Quoted 2 lines
if ((vcpu->arch.last_inst & 0xff0007ff) !> > (INS_DCBZ & 0xfffffff7)) {(quoted diff) +1
-0+ vcpu->arch.msr |= (vcpu->arch.shadow_msr & 0x1f0000ull);What bits are those? It might be good to use real #define's here :-).
They are some of those SRR1 bits that don't match MSR bits, used to convey informations on program check and machine check. I think the only #define we have for them are actually deep inside traps.c.
Quoted 9 lines
Quoted 9 lines
arch/powerpc/ renamed from arch/powerpc/kvm/book3s_64_interrupts.S +0
-0
kvm/book3s_64_interrupts.S
index 7b55d80..22f2962 100644arch/powerpc/kvm/book3s_64_interrupts.S +0
-0@@ -241,8 +241,9 @@ kvmppc_handler_highmem: rldicl. r5, r5, 0, 63 /* CR = ((r5 & 1) = 0) */ beq no_dcbz32_off
Quoted 7 lines
arch/powerpc/kvm/book3s_64_interrupts.S kvmppc_handler_highmem: · line 246
Quoted 4 lines
arch/powerpc/kvm/book3s_64_interrupts.S +2
-1+ li r4,0 mfspr r5,SPRN_HID5 - rldimi r5,r5,6,56 + rldimi r5,r4,6,56When you're on a G5 you never get into this code path, right? You're using the dcbz binary patched emulation instead.
Why ? The G5 is a 970 which supports HID5 and has no hypervisor to get in the way so it works fine with the dcbz hack (I added printks to verify it was enabled).
Quoted 7 lines
So what you do is you replace
HID5 &= ~DCBZ32;
with
HID5 = 0;
No. What I do is replace
HID5 = (HID5 & ~0xc0) | ((HID5 & 0x3) << 6)
with
HID5 = (HID5 & ~0xc0)
At least that's my understanding :-)
Quoted 4 lines
Is that intentional?
Quoted 2 lines
arch/powerpc/kvm/book3s_64_interrupts.S +0
-0mtspr SPRN_HID5,r5
Quoted 15 lines
arch/powerpc/kvm/book3s_64_slb.S ld_last_inst: · line 208
Quoted 12 lines
no_dcbz32_off:arch/powerpc/kvm/ renamed from arch/powerpc/kvm/book3s_64_slb.S +0
-0
book3s_64_slb.S
index ecd237a..c574cf7 100644arch/powerpc/kvm/book3s_64_slb.S +1
-1@@ -205,11 +205,11 @@ ld_last_inst: /* 1) enable paging for data */ mfmsr r9 ori r11, r9, MSR_DR /* Enable paging for data */ - mtmsr r11 + mtmsrd r11Wasn't mtmsrd this extra cool new version that takes a second argument so one can only set IF?
Extra argument is optional in the asm but yeah. Though I think mtmsr also takes it (the L bit basically). No, the difference is that mtmsrd can write all 64-bit of the MSR while mtmsr only the low 32-bit. Now in your case that's fine, both would work, I just did that change as a reflex :-) (Ie. mtmsr will preserve the top 32-bit of the MSR anyway)
Note: The karmic installer still goes bonkers a bit later, I don't know why yet (works without -enable-kvm). I need to run it without it's "quiet" thingy so I can see what's happening :-)
Cheers,
Ben.
Quoted 1 line
Alex
Quoted 11 lines · Benjamin Herrenschmidt
Quoted 4 lines · Alexander Graf
Review
Quoted 2 lines
if ((vcpu->arch.last_inst & 0xff0007ff) !>>> (INS_DCBZ & 0xfffffff7)) {(quoted diff) +1
-0+ vcpu->arch.msr |= (vcpu->arch.shadow_msr & 0x1f0000ull);What bits are those? It might be good to use real #define's here :-).
They are some of those SRR1 bits that don't match MSR bits, used to convey informations on program check and machine check. I think the only
#define we have for them are actually deep insidetraps.c.
I see ;-).
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
arch/powerpc/ renamed from arch/powerpc/kvm/book3s_64_interrupts.S +0
-0
kvm/book3s_64_interrupts.S
index 7b55d80..22f2962 100644arch/powerpc/kvm/book3s_64_interrupts.S +0
-0@@ -241,8 +241,9 @@ kvmppc_handler_highmem: rldicl. r5, r5, 0, 63 /* CR = ((r5 & 1) = 0) */ beq no_dcbz32_offQuoted 7 lines
arch/powerpc/kvm/book3s_64_interrupts.S kvmppc_handler_highmem: · line 246
Quoted 4 lines
arch/powerpc/kvm/book3s_64_interrupts.S +2
-1+ li r4,0 mfspr r5,SPRN_HID5 - rldimi r5,r5,6,56 + rldimi r5,r4,6,56When you're on a G5 you never get into this code path, right? You're using the dcbz binary patched emulation instead.
Quoted 3 lines
Why ? The G5 is a 970 which supports HID5 and has no hypervisor to get in the way so it works fine with the dcbz hack (I added printks to verify it was enabled).
Oh right. Mac OS X enables it too - I forgot.
Quoted 15 lines
Quoted 8 lines
So what you do is you replace
HID5 &= ~DCBZ32;
with
HID5 = 0;
No. What I do is replace
HID5 = (HID5 & ~0xc0) | ((HID5 & 0x3) << 6)with
Quoted 7 lines
HID5 = (HID5 & ~0xc0)At least that's my understanding :-)
Quoted 2 lines
arch/powerpc/kvm/book3s_64_interrupts.S +1
-0+ li r4,0mfspr r5,SPRN_HID5
r5 = *HID5
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S kvmppc_handler_highmem: · line 245
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S +0
-1- rldimi r5,r5,6,56
Take r5, remove some bits, write into r5
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S kvmppc_handler_highmem: · line 246
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S +1
-0+ rldimi r5,r4,6,56
Take r4, remove some bits, write into r5.
Or did I miss anything?
Quoted 22 lines
Quoted 5 lines
Is that intentional?
Quoted 2 lines
arch/powerpc/kvm/book3s_64_interrupts.S +0
-0mtspr SPRN_HID5,r5Quoted 16 lines
arch/powerpc/kvm/book3s_64_slb.S ld_last_inst: · line 208
Quoted 12 lines
no_dcbz32_off:arch/powerpc/kvm/ renamed from arch/powerpc/kvm/book3s_64_slb.S +0
-0
book3s_64_slb.S
index ecd237a..c574cf7 100644arch/powerpc/kvm/book3s_64_slb.S +1
-1@@ -205,11 +205,11 @@ ld_last_inst: /* 1) enable paging for data */ mfmsr r9 ori r11, r9, MSR_DR /* Enable paging for data */ - mtmsr r11 + mtmsrd r11Wasn't mtmsrd this extra cool new version that takes a second argument
so one can only set IF?
Quoted 6 lines
Extra argument is optional in the asm but yeah. Though I think mtmsr also takes it (the L bit basically). No, the difference is that mtmsrd can write all 64-bit of the MSR while mtmsr only the low 32-bit. Now in
your case that's fine, both would work, I just did that change as a reflex :-) (Ie. mtmsr will preserve the top 32-bit of the MSR anyway)
Ah, right. Thanks for the catch!
Quoted 4 lines
Note: The karmic installer still goes bonkers a bit later, I don't know
why yet (works without -enable-kvm). I need to run it without it's "quiet" thingy so I can see what's happening :-)
Hum, would be interesting to know where it breaks. Either way you're running the guest pretty far already as userspace is apparently running. So that's good news :-).
Alex
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
arch/powerpc/kvm/book3s_64_interrupts.S +1
-0+ li r4,0mfspr r5,SPRN_HID5
r5 = *HID5
So far so good...
Quoted 3 lines
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S kvmppc_handler_highmem: · line 245
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S +0
-1- rldimi r5,r5,6,56Take r5, remove some bits, write into r5
Hrm... nope :-)
rldimi will insert into the destination (r5) bits 56..57 the corresponding bits from the source (r5) after that source has been rotated left by 6 bits.
That means inserting the 2 low bits of r5 into r5[56:57] afaik :-)
Quoted 3 lines
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S kvmppc_handler_highmem: · line 246
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S +1
-0+ rldimi r5,r4,6,56Take r4, remove some bits, write into r5.
My variant will insert the bits from r4 which is 0, means it's going to insert 0's in r5[56:57] which is what you want (clear the two dcbz special bits) right ?
Quoted 1 line
Or did I miss anything?
I think you did :-)
Quoted 8 lines
Quoted 4 lines
Note: The karmic installer still goes bonkers a bit later, I don't know
why yet (works without -enable-kvm). I need to run it without it's "quiet" thingy so I can see what's happening :-)Hum, would be interesting to know where it breaks. Either way you're running the guest pretty far already as userspace is apparently running. So that's good news :-).
Yeah, I'll track it down when I have some time, I have some other emergency right now.
Cheers,
Ben.
Quoted 24 lines · Benjamin Herrenschmidt
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
arch/powerpc/kvm/book3s_64_interrupts.S +1
-0+ li r4,0mfspr r5,SPRN_HID5
r5 = *HID5
So far so good...
Quoted 3 lines
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S kvmppc_handler_highmem: · line 245
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S +0
-1- rldimi r5,r5,6,56Take r5, remove some bits, write into r5
Hrm... nope :-)
rldimi will insert into the destination (r5) bits 56..57 the corresponding bits from the source (r5) after that source has been rotated left by 6 bits.
That means inserting the 2 low bits of r5 into r5[56:57] afaik :-)
Quoted 3 lines
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S kvmppc_handler_highmem: · line 246
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S +1
-0+ rldimi r5,r4,6,56Take r4, remove some bits, write into r5.
Quoted 8 lines
My variant will insert the bits from r4 which is 0, means it's going to
insert 0's in r5[56:57] which is what you want (clear the two dcbz special bits) right ?Quoted 1 line
Or did I miss anything?
I think you did :-)
Wow, and there I thought I finally mastered the rotate instructions :-).
Alex
Quoted 31 lines · Alexander Graf
Quoted 29 lines · Benjamin Herrenschmidt
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
arch/powerpc/kvm/book3s_64_interrupts.S +1
-0+ li r4,0mfspr r5,SPRN_HID5
r5 = *HID5
So far so good...
Quoted 3 lines
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S kvmppc_handler_highmem: · line 245
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S +0
-1- rldimi r5,r5,6,56Take r5, remove some bits, write into r5
Hrm... nope :-)
rldimi will insert into the destination (r5) bits 56..57 the corresponding bits from the source (r5) after that source has been rotated left by 6 bits.
That means inserting the 2 low bits of r5 into r5[56:57] afaik :-)
Quoted 3 lines
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S kvmppc_handler_highmem: · line 246
Quoted 1 line
arch/powerpc/kvm/book3s_64_interrupts.S +1
-0+ rldimi r5,r4,6,56Take r4, remove some bits, write into r5.
My variant will insert the bits from r4 which is 0, means it's going to
insert 0's in r5[56:57] which is what you want (clear the two dcbz special bits) right ?
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Or did I miss anything?
I think you did :-)
Wow, and there I thought I finally mastered the rotate instructions :-).
Well, that's a rotate-and-insert in fact :-) But please dbl check the doco to make sure I didn't get it wrong.
Also sadly, you cannot use rlwinm in this case to clear bits because that would put crap into the top half of the register
Cheers,
Ben.