Add KVM support for Book3s_64 (PPC64) hosts v3
KVM for PowerPC only supports embedded cores at the moment.
While it makes sense to virtualize on small machines, it's even more fun to do so on big boxes. So I figured we need KVM for PowerPC64 as well.
This patchset implements KVM support for Book3s_64 hosts and guest support for Book3s_64 and G3/G4.
To really make use of this, you will also need a modified version of qemu that can deal with KVM on desktop cores. I will send out patches for those later, but want to get feedback on the kernel side first.
In the meanwhile, use the qemu version from
http://www.powerkvm.org/powerkvm.git which already includes all required patches to run G3/G4 and G5 guests.
To not spam on everyone on the list, I figured I'd send this as a git pull request this time. If I did anything wrong, please tell me :-).
V1 -> V2:
- extend sregs with padding
- new naming scheme (ppc64 -> book3s_64; 74xx -> book3s_32)
- to_phys -> in-kernel tophys()
- loadimm -> LOAD_REG_IMMEDIATE
- call .ko kvm.ko
- set magic paca bit later
- run guest code with PACA->soft_enabled=true
- pt_regs for host state saving (guest too?)
- only do HV dcbz trick on 970
- refuse to run on LPAR because of missing SLB pieces
V2 -> V3:
- fix DAR/DSISR saving
- allow running on LPAR by modifying the SLB shadow
- change the SLB implementation to use a mem-backed cache and do full world switch on enter/exit. gets rid of "context" magic
- be more aggressive about DEC injection
- remove fast ld/st because we're always in host context
- don't use SPRGs in real->paged transition
- implement dirty log
- remove MMIO speedup code
- SPRG cleanup
- rename SPRG3 -> SPRN_SPRG_PACA
- rename SPRG1 -> SPRN_SPRG_SCRATCH0
- don't use SPRG2
TODO:
- use MMU Notifiers
- use u64* for dirty log
The following changes since commit 84a3c0818fe9d7a1e34c188d6182793f213a6a66:
Gleb Natapov (1):
KVM: Reduce runnability interface with arch support code
are available in the git repository at:
git://csgraf.de/kvm ppc-v3
Alexander Graf (25):
Move dirty logging code to sub-arch Pass PVR in sregs
Add Book3s definitions
Add Book3s fields to vcpu structs
Add asm/kvm_book3s.h
Add Book3s_64 intercept helpers
Add book3s_64 highmem asm code
Add SLB switching code for entry/exit Add interrupt handling code
Add book3s.c
Add book3s_64 Host MMU handling
Add book3s_64 guest MMU
Add book3s_32 guest MMU
Add book3s_64 specific opcode emulation Add mfdec emulation
Add desktop PowerPC specific emulation Make head_64.S aware of KVM real mode code Add Book3s_64 offsets to asm-offsets.c Export symbols for KVM module
Export KVM symbols for module
Add fields to PACA
Export new PACA constants in asm-offsets Include Book3s_64 target in buildsystem Fix trace.h
Enable 32bit dirty log pointers on 64bit host
arch/powerpc/include/asm/exception.h | 2 + arch/powerpc/include/asm/kvm.h | 2 + arch/powerpc/include/asm/kvm_asm.h | 49 ++ arch/powerpc/include/asm/kvm_book3s.h | 135 ++++ arch/powerpc/include/asm/kvm_book3s_64_asm.h | 58 ++ arch/powerpc/include/asm/kvm_host.h | 76 +++- arch/powerpc/include/asm/kvm_ppc.h | 1 + arch/powerpc/include/asm/paca.h | 9 + arch/powerpc/kernel/asm-offsets.c | 18 + arch/powerpc/kernel/exceptions-64s.S | 8 + arch/powerpc/kernel/head_64.S | 6 + arch/powerpc/kernel/ppc_ksyms.c | 3 +- arch/powerpc/kernel/time.c | 1 + arch/powerpc/kvm/Kconfig | 17 + arch/powerpc/kvm/Makefile | 27 +- arch/powerpc/kvm/book3s.c | 919 ++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_32_mmu.c | 354 ++++++++++ arch/powerpc/kvm/book3s_64_emulate.c | 338 ++++++++++ arch/powerpc/kvm/book3s_64_exports.c | 24 + arch/powerpc/kvm/book3s_64_interrupts.S | 392 +++++++++++ arch/powerpc/kvm/book3s_64_mmu.c | 469 +++++++++++++ arch/powerpc/kvm/book3s_64_mmu_host.c | 412 ++++++++++++ arch/powerpc/kvm/book3s_64_rmhandlers.S | 131 ++++ arch/powerpc/kvm/book3s_64_slb.S | 277 ++++++++ arch/powerpc/kvm/booke.c | 5 + arch/powerpc/kvm/emulate.c | 43 ++- arch/powerpc/kvm/powerpc.c | 5 - arch/powerpc/kvm/trace.h | 6 +- arch/powerpc/mm/hash_utils_64.c | 2 + arch/powerpc/mm/mmu_context_hash64.c | 4 + arch/powerpc/mm/slb.c | 2 + kernel/fork.c | 1 + virt/kvm/kvm_main.c | 5 + 33 files changed, 3786 insertions(+), 15 deletions(-) create mode 100644 arch/powerpc/include/asm/kvm_book3s.h create mode 100644 arch/powerpc/include/asm/kvm_book3s_64_asm.h create mode 100644 arch/powerpc/kvm/book3s.c create mode 100644 arch/powerpc/kvm/book3s_32_mmu.c create mode 100644 arch/powerpc/kvm/book3s_64_emulate.c create mode 100644 arch/powerpc/kvm/book3s_64_exports.c create mode 100644 arch/powerpc/kvm/book3s_64_interrupts.S create mode 100644 arch/powerpc/kvm/book3s_64_mmu.c create mode 100644 arch/powerpc/kvm/book3s_64_mmu_host.c create mode 100644 arch/powerpc/kvm/book3s_64_rmhandlers.S create mode 100644 arch/powerpc/kvm/book3s_64_slb.S
Quoted 12 lines · Alexander Graf
KVM for PowerPC only supports embedded cores at the moment.
While it makes sense to virtualize on small machines, it's even more fun to do so on big boxes. So I figured we need KVM for PowerPC64 as well.
This patchset implements KVM support for
Book3s_64hosts and guest support forBook3s_64and G3/G4.To really make use of this, you will also need a modified version of qemu that can deal with KVM on desktop cores. I will send out patches for those later, but want to get feedback on the kernel side first.
Quoted 8 lines
In the meanwhile, use the qemu version from
http://www.powerkvm.org/powerkvm.git which already includes all required patches to run G3/G4 and G5 guests.To not spam on everyone on the list, I figured I'd send this as a git pull request this time. If I did anything wrong, please tell me :-).
I will need some acks from ppc people. Obviously for the non-kvm bits, but also for the kvm bits as I am not qualified to review ppc code.
Quoted 2 lines
- use MMU Notifiers
What's the plan here?
Quoted 3 lines
- use u64* for dirty log
Is this a userspace interface issue? if so it will need to be addressed before merging.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 24 lines · Avi Kivity
Quoted 23 lines · Alexander Graf
KVM for PowerPC only supports embedded cores at the moment.
While it makes sense to virtualize on small machines, it's even more fun
to do so on big boxes. So I figured we need KVM for PowerPC64 as well.This patchset implements KVM support for
Book3s_64hosts and guest support
forBook3s_64and G3/G4.To really make use of this, you will also need a modified version of qemu
that can deal with KVM on desktop cores. I will send out patches for those
later, but want to get feedback on the kernel side first.In the meanwhile, use the qemu version from
http://www.powerkvm.org/powerkvm.git which already includes all required
patches to run G3/G4 and G5 guests.
Quoted 8 lines
Quoted 4 lines
To not spam on everyone on the list, I figured I'd send this as a git pull
request this time. If I did anything wrong, please tell me :-).I will need some acks from ppc people. Obviously for the non-kvm bits, but also for the kvm bits as I am not qualified to review ppc code.
Right, FWIW Ben would actually even prefer to take the whole thing in his tree.
Quoted 4 lines
Quoted 2 lines
- use MMU Notifiers
What's the plan here?
Implement MMU Notifiers as soon as I fully understand them? :-) I'm aware of the basic concept, but the callbacks still seem somewhat magical to me.
Quoted 6 lines
Quoted 3 lines
- use u64* for dirty log
Is this a userspace interface issue? if so it will need to be addressed before merging.
Yes, on big endian having a 64-bit kernel and 32-bit userspace breaks when dirty log is ulong*. Nobody saw this until now, because it's not a big deal on little endian.
I sent a patch doing the qemu side of things already, but haven't went through the kvm bits yet. Basically we can't use set_bit and test_bit for the dirty log, because they require us to have the bitmap as ulong*.
Alex
Quoted 7 lines · Alexander Graf
Quoted 3 lines
I will need some acks from ppc people. Obviously for the non-kvm bits, but also for the kvm bits as I am not qualified to review ppc code.
Right, FWIW Ben would actually even prefer to take the whole thing in his tree.
That's likely to cause conflicts if some kvm API changes and needs modifications to this code. Perhaps the best option is for the non-kvm changes to go through the ppc tree, and for me to duplicate (but not push) them.
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
- use MMU Notifiers
What's the plan here?
Implement MMU Notifiers as soon as I fully understand them? :-) I'm aware of the basic concept, but the callbacks still seem somewhat magical to me.
Ask and I'll do my best to answer.
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
- use u64* for dirty log
Is this a userspace interface issue? if so it will need to be addressed before merging.
Quoted 8 lines
Yes, on big endian having a 64-bit kernel and 32-bit userspace breaks when dirty log is ulong*. Nobody saw this until now, because it's not a big deal on little endian.
I sent a patch doing the qemu side of things already, but haven't went through the kvm bits yet. Basically we can't use
set_bitandtest_bitfor the dirty log, because they require us to have the bitmap as ulong*.
Yuck. What do we do? Implement set_bit_u64() and friends?
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 6 lines · Avi Kivity
Quoted 5 lines · Alexander Graf
Quoted 3 lines
I will need some acks from ppc people. Obviously for the non-kvm bits, but also for the kvm bits as I am not qualified to review ppc code.
Quoted 7 lines
Quoted 2 lines
Right, FWIW Ben would actually even prefer to take the whole thing in his tree.
That's likely to cause conflicts if some kvm API changes and needs modifications to this code. Perhaps the best option is for the non- kvm changes to go through the ppc tree, and for me to duplicate (but not push) them.
I agree, but that's for you two to decide I guess :-). Let's just wait for Ben to wake up.
Quoted 10 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
- use MMU Notifiers
What's the plan here?
Implement MMU Notifiers as soon as I fully understand them? :-) I'm aware of the basic concept, but the callbacks still seem somewhat magical to me.
Ask and I'll do my best to answer.
Cool, next week :-). The current version works fine without. And I need a weekend for a change :-D.
Quoted 11 lines
Quoted 11 lines
Quoted 6 lines
Quoted 3 lines
- use u64* for dirty log
Is this a userspace interface issue? if so it will need to be addressed before merging.
Yes, on big endian having a 64-bit kernel and 32-bit userspace breaks when dirty log is ulong*. Nobody saw this until now, because it's not a big deal on little endian.
Quoted 7 lines
Quoted 5 lines
I sent a patch doing the qemu side of things already, but haven't went through the kvm bits yet. Basically we can't use
set_bitandtest_bitfor the dirty log, because they require us to have the bitmap as ulong*.Yuck. What do we do? Implement
set_bit_u64()and friends?
That's what I'd think we should do, yes.
For qemu I sent a patch that always uses "uint64_t" because that works fine with the current code (32-bit on 64-bit uses the right bytes for LE, 64-bit on 64-bit doesn't change). PPC is not implement yet for anyone either and for now we only have dirty logging with 64 bit kernels and 32-bit or 64-bit userspace, so that's fine too.
As soon as someone implement dirty logging on a 32-bit big endian target, it will break though, so before that day comes we need to change set_bit to set_bit_64.
Alex
Quoted 2 lines · Alexander Graf
Cool, next week :-). The current version works fine without. And I need a weekend for a change :-D.
Having returned from a 10-day weekend, I can only recommend this.
Quoted 12 lines
Quoted 2 lines
Yuck. What do we do? Implement
set_bit_u64()and friends?That's what I'd think we should do, yes.
For qemu I sent a patch that always uses "
uint64_t" because that works fine with the current code (32-bit on 64-bit uses the right bytes for LE, 64-bit on 64-bit doesn't change). PPC is not implement yet for anyone either and for now we only have dirty logging with 64 bit kernels and 32-bit or 64-bit userspace, so that's fine too.
Quoted 3 lines
As soon as someone implement dirty logging on a 32-bit big endian target, it will break though, so before that day comes we need to change
set_bittoset_bit_64.
Perhaps we can get away with disabling 32-on-64 for the configurations that break to start with.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 5 lines · Avi Kivity
Quoted 2 lines · Alexander Graf
Cool, next week :-). The current version works fine without. And I need a weekend for a change :-D.
Having returned from a 10-day weekend, I can only recommend this.
Hope you had fun and didn't read too much mail :-).
Quoted 12 lines
Quoted 12 lines
Quoted 1 line
Yuck. What do we do? Implement
set_bit_u64()and friends?That's what I'd think we should do, yes.
For qemu I sent a patch that always uses "
uint64_t" because that works fine with the current code (32-bit on 64-bit uses the right bytes for LE, 64-bit on 64-bit doesn't change). PPC is not implement yet for anyone either and for now we only have dirty logging with 64 bit kernels and 32-bit or 64-bit userspace, so that's fine too.
Quoted 6 lines
Quoted 3 lines
As soon as someone implement dirty logging on a 32-bit big endian target, it will break though, so before that day comes we need to change
set_bittoset_bit_64.Perhaps we can get away with disabling 32-on-64 for the configurations that break to start with.
32-on-64 only breaks for big endian which nobody except for this target implements. Since my PPC enabling patches for qemu change the type to uint64_t always, nobody is broken right now.
Alex
Quoted 17 lines · Avi Kivity
Quoted 10 lines · Alexander Graf
Quoted 5 lines · Avi Kivity
Quoted 2 lines · Alexander Graf
Cool, next week :-). The current version works fine without. And I need a weekend for a change :-D.
Having returned from a 10-day weekend, I can only recommend this.
Hope you had fun and didn't read too much mail :-).
I didn't read _any_ email.
Quoted 3 lines
Quoted 2 lines
Perhaps we can get away with disabling 32-on-64 for the configurations that break to start with.
Quoted 6 lines
Quoted 4 lines
32-on-64 only breaks for big endian which nobody except for this target implements. Since my PPC enabling patches for qemu change the type to
uint64_talways, nobody is broken right now.That assumes you implement
set_bit_u64(), no?
No, little endian works as-is :-).
Quoted 10 lines · Alexander Graf
Quoted 5 lines · Avi Kivity
Quoted 2 lines · Alexander Graf
Cool, next week :-). The current version works fine without. And I need a weekend for a change :-D.
Having returned from a 10-day weekend, I can only recommend this.
Hope you had fun and didn't read too much mail :-).
I didn't read _any_ email.
Quoted 7 lines
Quoted 2 lines
Perhaps we can get away with disabling 32-on-64 for the configurations that break to start with.
32-on-64 only breaks for big endian which nobody except for this target implements. Since my PPC enabling patches for qemu change the type to
uint64_talways, nobody is broken right now.
That assumes you implement set_bit_u64(), no?
Signature · 1 line
error compiling committee.c: too many arguments to function
Am 26.07.2009 um 14:54 schrieb Alexander Graf <[email protected]>:
Quoted 20 lines · Avi Kivity
Quoted 18 lines · Alexander Graf
Quoted 10 lines · Avi Kivity
Quoted 6 lines · Alexander Graf
Quoted 2 lines
Cool, next week :-). The current version works fine without. And I need a weekend for a change :-D.
Having returned from a 10-day weekend, I can only recommend this.
Hope you had fun and didn't read too much mail :-).
I didn't read _any_ email.
Quoted 3 lines
Quoted 2 lines
Perhaps we can get away with disabling 32-on-64 for the configurations that break to start with.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
32-on-64 only breaks for big endian which nobody except for this target implements. Since my PPC enabling patches for qemu change the type to
uint64_talways, nobody is broken right now.That assumes you implement
set_bit_u64(), no?No, little endian works as-is :-).
Let me rephrase: It shouldn't if I understand little endian correctly :).
I haven't actually verified that 32 on 64 doesn't break. But then again that's a rather uncommon configuration for x86 anyways, but really common on ppc.
Alex
Quoted 11 lines · Alexander Graf
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
Quoted 3 lines
Perhaps we can get away with disabling 32-on-64 for the configurations that break to start with.
32-on-64 only breaks for big endian which nobody except for this target implements. Since my PPC enabling patches for qemu change the type to
uint64_talways, nobody is broken right now.That assumes you implement
set_bit_u64(), no?
Quoted 8 lines
Quoted 1 line
No, little endian works as-is :-).
Let me rephrase: It shouldn't if I understand little endian correctly :).
I haven't actually verified that 32 on 64 doesn't break. But then again that's a rather uncommon configuration for x86 anyways, but really common on ppc.
I meant disable 32-on-64 ppc. 32-on-64 x86 is supported and works (though it is rare).
Given that you say 32-on-64 ppc is common, it could only be a short term fix until we implemlement u64 bitops. Alternatively we can mangle the bitmap when copying it to userspace.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
Am 26.07.2009 um 19:53 schrieb Avi Kivity <[email protected]>:
Quoted 22 lines · Alexander Graf
Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Perhaps we can get away with disabling 32-on-64 for the configurations that break to start with.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
32-on-64 only breaks for big endian which nobody except for this target implements. Since my PPC enabling patches for qemu change the type to
uint64_talways, nobody is broken right now.That assumes you implement
set_bit_u64(), no?No, little endian works as-is :-).
Quoted 6 lines
Let me rephrase: It shouldn't if I understand little endian correctly :).
I haven't actually verified that 32 on 64 doesn't break. But then again that's a rather uncommon configuration for x86 anyways, but really common on ppc.
Quoted 6 lines
I meant disable 32-on-64 ppc. 32-on-64 x86 is supported and works (though it is rare).
Given that you say 32-on-64 ppc is common, it could only be a short term fix until we implemlement u64 bitops. Alternatively we can mangle the bitmap when copying it to userspace.
When we just interpret the bitmap as u64* do we break 32 on 64 x86? If not, that makes it work for 32 on 64 ppc, because the kernel is always 64.
Alex
Quoted 1 line · Avi Kivity
Yuck. What do we do? Implement
set_bit_u64()and friends?
We may be able to hijack some of the filesystem ones... those are used for on-disk format so should fit the bill
Cheers,
Ben.
Quoted 11 lines · Alexander Graf
Quoted 9 lines · Avi Kivity
Quoted 7 lines · Alexander Graf
Quoted 3 lines
I will need some acks from ppc people. Obviously for the non-kvm bits, but also for the kvm bits as I am not qualified to review ppc code.
Right, FWIW Ben would actually even prefer to take the whole thing in his tree.
Quoted 7 lines
Quoted 4 lines
That's likely to cause conflicts if some kvm API changes and needs modifications to this code. Perhaps the best option is for the non- kvm changes to go through the ppc tree, and for me to duplicate (but not push) them.
I agree, but that's for you two to decide I guess :-). Let's just wait for Ben to wake up.
I need to review and test a bit, hopefully I'll have a better idea of what goes where some time this week.
Cheers,
Ben.
Quoted 8 lines · Avi Kivity
Quoted 4 lines
As soon as someone implement dirty logging on a 32-bit big endian target, it will break though, so before that day comes we need to change
set_bittoset_bit_64.Perhaps we can get away with disabling 32-on-64 for the configurations
that break to start with.
Well, 32-on-64 is probably still the most widely used configuration on ppc
Cheers,
Ben.
Quoted 3 lines · Alexander Graf
When we just interpret the bitmap as u64* do we break 32 on 64 x86? If not, that makes it work for 32 on 64 ppc, because the kernel is always 64.
It just a matter of having the bits in the right place. The kernel will not always be 64-bit though, for example it's no for kvm/e500 or kvm/440 and there's no reason those could get gfx at some stage.
Now, the kernel -does- provide _le variants of the bitops, and those have the side advantage of being agnostic to 32 vs. 64 bit so maybe that what we should use everywhere ?
Look at ppc's bitops.h, it has nice descriptions of the format.
Cheers,
Ben.
Quoted 8 lines · Avi Kivity
Quoted 2 lines · Alexander Graf
Quoted 2 lines
I will need some acks from ppc people. Obviously for the non-kvm bits, but also for the kvm bits as I am not qualified to review
ppc
Quoted 4 lines
Quoted 1 line
code.
Right, FWIW Ben would actually even prefer to take the whole thing
Quoted 8 lines
in
Quoted 1 line
his tree.
That's likely to cause conflicts if some kvm API changes and needs modifications to this code. Perhaps the best option is for the non-kvm
changes to go through the ppc tree, and for me to duplicate (but not push) them.
The way I've done this in the past is to get acks from PPC maintainers, and then push the patches through Avi.
If a "generic" PPC patch is required by a KVM patch, pushing them through different trees would leave KVM broken for weeks until it all ends up merged in Linus's tree.
Despite Ben's newfound interest in KVM, I don't see a good reason to change this model. :)
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
Quoted 11 lines · Hollis Blanchard
The way I've done this in the past is to get acks from PPC maintainers,
and then push the patches through Avi.If a "generic" PPC patch is required by a KVM patch, pushing them through different trees would leave KVM broken for weeks until it all ends up merged in Linus's tree.
Despite Ben's newfound interest in KVM, I don't see a good reason to change this model. :)
Depends how invasive the powerpc bits are. I'll figure something out.
Cheers,
Ben.
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 8 lines · Hollis Blanchard
The way I've done this in the past is to get acks from PPC maintainers,
and then push the patches through Avi.If a "generic" PPC patch is required by a KVM patch, pushing them through different trees would leave KVM broken for weeks until it all ends up merged in Linus's tree.
Quoted 6 lines
Quoted 3 lines
Despite Ben's newfound interest in KVM, I don't see a good reason to change this model. :)
Depends how invasive the powerpc bits are. I'll figure something out.
Yes. If they are invasive, the best way is to carry the non-kvm changes in both trees, and for me to push after you (I'll omit the duplicates when pushing).
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 3 lines · Alexander Graf
When we just interpret the bitmap as u64* do we break 32 on 64 x86? If not, that makes it work for 32 on 64 ppc, because the kernel is always 64.
No. little-endian is insensitive to the word size for bitops.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 8 lines · Alexander Graf
KVM for PowerPC only supports embedded cores at the moment.
While it makes sense to virtualize on small machines, it's even more fun to do so on big boxes. So I figured we need KVM for PowerPC64 as well.
This patchset implements KVM support for
Book3s_64hosts and guest support forBook3s_64and G3/G4.
Quoted 7 lines
To really make use of this, you will also need a modified version of qemu that can deal with KVM on desktop cores. I will send out patches for those later, but want to get feedback on the kernel side first.
In the meanwhile, use the qemu version from
http://www.powerkvm.org/powerkvm.git which already includes all required patches to run G3/G4 and G5 guests.
The git pull request is good when the series is good to pull or for testing, but for review patches are nice :-)
So I never got enough time to look into too much details so far (I'm still up for a little walkthrough on IRC one of these days btw) but I did look at the changes to the powerpc core code and they look ok to me.
The only thing I couldn't quite figure out is why you are adding exports for mm_alloc() and switch_slb().
I spotted tons of stuff that could be optimized, especially in the interrupt handling (but then, we all agree that using a magic page is going to be much better), and I suppose we need to have a close look at some aspects of the MMU emulation.
But for now, I'm happy with the merge, feel free to add my Acked-by, just make sure it's marked CONFIG_EXPERIMENTAL.
Avi, are you taking care of it from here ?
Cheers,
Ben.
Quoted 125 lines
To not spam on everyone on the list, I figured I'd send this as a git pull request this time. If I did anything wrong, please tell me :-).
V1 -> V2:
- extend sregs with padding
- new naming scheme (ppc64 ->book3s_64; 74xx ->book3s_32)
-to_phys-> in-kerneltophys()
- loadimm ->LOAD_REG_IMMEDIATE
- call .ko kvm.ko
- set magic paca bit later
- run guest code with PACA->soft_enabled=true
-pt_regsfor host state saving (guest too?)
- only do HV dcbz trick on 970
- refuse to run on LPAR because of missing SLB piecesV2 -> V3:
- fix DAR/DSISR saving
- allow running on LPAR by modifying the SLB shadow
- change the SLB implementation to use a mem-backed cache and do full world switch on enter/exit. gets rid of "context" magic
- be more aggressive about DEC injection
- remove fast ld/st because we're always in host context
- don't use SPRGs inreal->pagedtransition
- implement dirty log
- remove MMIO speedup code
- SPRG cleanup
- rename SPRG3 ->SPRN_SPRG_PACA
- rename SPRG1 ->SPRN_SPRG_SCRATCH0
- don't use SPRG2TODO:
- use MMU Notifiers
- use u64* for dirty logThe following changes since commit
84a3c0818fe9d7a1e34c188d6182793f213a6a66:
Gleb Natapov (1):
KVM: Reduce runnability interface with arch support codeare available in the git repository at:
git://csgraf.de/kvmppc-v3Alexander Graf (25):
Move dirty logging code to sub-arch Pass PVR in sregs
Add Book3s definitions
Add Book3s fields to vcpu structs
Addasm/kvm_book3s.h
AddBook3s_64intercept helpers
Addbook3s_64highmem asm code
Add SLB switching code for entry/exit Add interrupt handling code
Addbook3s.c
Addbook3s_64Host MMU handling
Addbook3s_64guest MMU
Addbook3s_32guest MMU
Addbook3s_64specific opcode emulation Add mfdec emulation
Add desktop PowerPC specific emulation Makehead_64.Saware of KVM real mode code AddBook3s_64offsets toasm-offsets.cExport symbols for KVM module
Export KVM symbols for module
Add fields to PACA
Export new PACA constants in asm-offsets IncludeBook3s_64target in buildsystem Fixtrace.h
Enable 32bit dirty log pointers on 64bit hostarch/powerpc/include/asm/exception.h | 2 + arch/powerpc/include/asm/kvm.h | 2 + arch/powerpc/include/asm/kvm_asm.h | 49 ++ arch/powerpc/include/asm/kvm_book3s.h | 135 ++++ arch/powerpc/include/asm/kvm_book3s_64_asm.h | 58 ++ arch/powerpc/include/asm/kvm_host.h | 76 +++- arch/powerpc/include/asm/kvm_ppc.h | 1 + arch/powerpc/include/asm/paca.h | 9 + arch/powerpc/kernel/asm-offsets.c | 18 + arch/powerpc/kernel/exceptions-64s.S | 8 + arch/powerpc/kernel/head_64.S | 6 + arch/powerpc/kernel/ppc_ksyms.c | 3 +- arch/powerpc/kernel/time.c | 1 + arch/powerpc/kvm/Kconfig | 17 + arch/powerpc/kvm/Makefile | 27 +- arch/powerpc/kvm/book3s.c | 919 ++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_32_mmu.c | 354 ++++++++++ arch/powerpc/kvm/book3s_64_emulate.c | 338 ++++++++++ arch/powerpc/kvm/book3s_64_exports.c | 24 + arch/powerpc/kvm/book3s_64_interrupts.S | 392 +++++++++++ arch/powerpc/kvm/book3s_64_mmu.c | 469 +++++++++++++ arch/powerpc/kvm/book3s_64_mmu_host.c | 412 ++++++++++++ arch/powerpc/kvm/book3s_64_rmhandlers.S | 131 ++++ arch/powerpc/kvm/book3s_64_slb.S | 277 ++++++++ arch/powerpc/kvm/booke.c | 5 + arch/powerpc/kvm/emulate.c | 43 ++- arch/powerpc/kvm/powerpc.c | 5 - arch/powerpc/kvm/trace.h | 6 +- arch/powerpc/mm/hash_utils_64.c | 2 + arch/powerpc/mm/mmu_context_hash64.c | 4 + arch/powerpc/mm/slb.c | 2 + kernel/fork.c | 1 + virt/kvm/kvm_main.c | 5 + 33 files changed, 3786 insertions(+), 15 deletions(-) create mode 100644 arch/powerpc/include/asm/kvm_book3s.h create mode 100644 arch/powerpc/include/asm/kvm_book3s_64_asm.h create mode 100644 arch/powerpc/kvm/book3s.c create mode 100644 arch/powerpc/kvm/book3s_32_mmu.c create mode 100644 arch/powerpc/kvm/book3s_64_emulate.c create mode 100644 arch/powerpc/kvm/book3s_64_exports.c create mode 100644 arch/powerpc/kvm/book3s_64_interrupts.S create mode 100644 arch/powerpc/kvm/book3s_64_mmu.c create mode 100644 arch/powerpc/kvm/book3s_64_mmu_host.c create mode 100644 arch/powerpc/kvm/book3s_64_rmhandlers.S create mode 100644 arch/powerpc/kvm/book3s_64_slb.S--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 18 lines · Benjamin Herrenschmidt
Quoted 17 lines · Alexander Graf
KVM for PowerPC only supports embedded cores at the moment.
While it makes sense to virtualize on small machines, it's even more fun
to do so on big boxes. So I figured we need KVM for PowerPC64 as well.This patchset implements KVM support for
Book3s_64hosts and guest support
forBook3s_64and G3/G4.To really make use of this, you will also need a modified version of qemu
that can deal with KVM on desktop cores. I will send out patches for those
later, but want to get feedback on the kernel side first.
Quoted 7 lines
Quoted 4 lines
In the meanwhile, use the qemu version from
http://www.powerkvm.org/powerkvm.git which already includes all required
patches to run G3/G4 and G5 guests.The git pull request is good when the series is good to pull or for testing, but for review patches are nice :-)
Ok, guess I'll go back to sending patches in the future then ;-).
Quoted 7 lines
So I never got enough time to look into too much details so far (I'm still up for a little walkthrough on IRC one of these days btw) but I did look at the changes to the powerpc core code and they look ok to me.
The only thing I couldn't quite figure out is why you are adding exports for
mm_alloc()andswitch_slb().
Well, we need mm_alloc to reserve a VA range. And since that happens in module code, it needs to be exported.
As far as switch_slb goes, I think with the new "always switch the full SLB in entry/exit code" logic, that's not required anymore.
Quoted 1 line
I spotted tons of stuff that could be optimized
Yes. It might also be worth collecting all the potential optimizations on some wiki, so if someone feels like jumping in on this project, he knows where to start. It'd even be good for us, because I always tend to forget where exactly the code is the worst :-).
Quoted 3 lines
, especially in the
interrupt handling (but then, we all agree that using a magic page is going to be much better)
The interrupt handling is a separate beast that should be handled more generically, but the current code works for KVM at least. Let's take baby steps here.
Quoted 2 lines
, and I suppose we need to have a close
look at some aspects of the MMU emulation.
I fully agree. The MMU emulation could probably also get quite some speedups. For the first version I merely wanted to have something that boots and runs Linux.
Quoted 2 lines
But for now, I'm happy with the merge, feel free to add my Acked-by, just make sure it's marked
CONFIG_EXPERIMENTAL.
It definitely is experimental still, so yes, I agree.
Should I send out a v4 that removes the slb_switch export and marks things as experimental?
Alex
Quoted 2 lines
Well, we need
mm_allocto reserve a VA range. And since that happens in module code, it needs to be exported.
Hrm... I've missed where you call it. Can't you directly allocate a context ID instead of a whole mm ?
Quoted 2 lines
As far as
switch_slbgoes, I think with the new "always switch the full SLB in entry/exit code" logic, that's not required anymore.
Ok. In general, I'd rather keep the KVM SLB switching separate from the "normal" one since there's different constraints anyways.
Quoted 2 lines
Should I send out a v4 that removes the
slb_switchexport and marks things as experimental?
Please, and add my Acks. Pls dbl check the need for mm_alloc() though.
Cheers,
Ben.
Quoted 5 lines · Benjamin Herrenschmidt
Quoted 2 lines
Well, we need
mm_allocto reserve a VA range. And since that happens in module code, it needs to be exported.Hrm... I've missed where you call it. Can't you directly allocate a context ID instead of a whole mm ?
It's in the vcpu init code:
./book3s.c:862: vcpu->arch.mm_guest = mm_alloc();
And the mm_alloc() call was the closest I could find to only allocate a context ID. I didn't really want to change too much code in there unless I really have to and it seems like mm_alloc doesn't have that much overhead.
Quoted 5 lines
Quoted 2 lines
As far as
switch_slbgoes, I think with the new "always switch the full SLB in entry/exit code" logic, that's not required anymore.Ok. In general, I'd rather keep the KVM SLB switching separate from the "normal" one since there's different constraints anyways.
Yes, that's why we're at v3 already :-).
Quoted 4 lines
Quoted 2 lines
Should I send out a v4 that removes the
slb_switchexport and marks things as experimental?Please, and add my Acks. Pls dbl check the need for
mm_alloc()though.
I'm open for suggestions on how to get a context_id easily/cleanly without exporting mm_alloc.
Alex
Quoted 12 lines · Alexander Graf
Quoted 5 lines · Benjamin Herrenschmidt
Quoted 2 lines
Well, we need
mm_allocto reserve a VA range. And since that happens in module code, it needs to be exported.Hrm... I've missed where you call it. Can't you directly allocate a context ID instead of a whole mm ?
It's in the vcpu init code:
./book3s.c:862:
vcpu->arch.mm_guest=mm_alloc();
Quoted 7 lines
And the
mm_alloc()call was the closest I could find to only allocate a context ID. I didn't really want to change too much code in there unless I really have to and it seems likemm_allocdoesn't have that much overhead.I'm open for suggestions on how to get a
context_ideasily/cleanly without exportingmm_alloc.
I see ... init_new_context() and destroy_context() only operate on an mm_struct... Well, in that case, I'm open to something that would change those two to __init_new_context() and __destroy_conext() that respectively return the new ID and take an ID as an argument, which you can export, and have static inlines in mmu-context.h that implement init_new_context() and destroy_context() in terms of the above.
Cheers,
Ben.
Quoted 13 lines · Benjamin Herrenschmidt
Quoted 12 lines · Alexander Graf
KVM for PowerPC only supports embedded cores at the moment.
While it makes sense to virtualize on small machines, it's even more fun to do so on big boxes. So I figured we need KVM for PowerPC64 as well.
This patchset implements KVM support for
Book3s_64hosts and guest support forBook3s_64and G3/G4.To really make use of this, you will also need a modified version of qemu that can deal with KVM on desktop cores. I will send out patches for those later, but want to get feedback on the kernel side first.
Quoted 6 lines
Quoted 3 lines
In the meanwhile, use the qemu version from
http://www.powerkvm.org/powerkvm.git which already includes all required patches to run G3/G4 and G5 guests.The git pull request is good when the series is good to pull or for testing, but for review patches are nice :-)
Yeah, I actually went looking for the v3 patchset last week, and gave up trying to extract it from git...
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center