Re: [PATCH v2 00/18] KVM for MIPS32 Processors

2013-01-24 Thread Ralf Baechle
On Wed, Nov 21, 2012 at 06:33:58PM -0800, Sanjay Lal wrote:

I've queued the patch set.  I've done a few stylistic changes such as
getting rid of all use of ulong and u_long data types in favor of
unsigned long.  I also ran into the following modpost error

  ERROR: kvm_arch_vcpu_postcreate [arch/mips/kvm/kvm.ko] undefined!

which I fixed by adding a trivial kvm_arch_vcpu_postcreate function:

int kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
{
return 0;
}

which may or may not be sufficient.

Enabling CONFIG_KVM_MIPS_VZ was causing build errors.  Since the support
code for the VZ ASE is not part of this series, I've ripped that out
entirely.

As for the __unused references, some are indeed unused with no apparent
reason for why the variables shouldn't be removed.  There are also
variables marked __unused which are being used - so no point in marking
them.  I've sorted that, too.

  Ralf
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 00/18] KVM for MIPS32 Processors

2013-01-24 Thread Sanjay Lal

On Jan 24, 2013, at 10:05 AM, Ralf Baechle wrote:

 On Wed, Nov 21, 2012 at 06:33:58PM -0800, Sanjay Lal wrote:
 
 I've queued the patch set.  I've done a few stylistic changes such as
 getting rid of all use of ulong and u_long data types in favor of
 unsigned long.  I also ran into the following modpost error
 
  ERROR: kvm_arch_vcpu_postcreate [arch/mips/kvm/kvm.ko] undefined!
 
 which I fixed by adding a trivial kvm_arch_vcpu_postcreate function:
 
 intkvm_arch_vcpu_postcreate((struct kvm_vcpu *vcpu)
 {
return 0;
 }
 
 which may or may not be sufficient.
 
 Enabling CONFIG_KVM_MIPS_VZ was causing build errors.  Since the support
 code for the VZ ASE is not part of this series, I've ripped that out
 entirely.
 
 As for the __unused references, some are indeed unused with no apparent
 reason for why the variables shouldn't be removed.  There are also
 variables marked __unused which are being used - so no point in marking
 them.  I've sorted that, too.
 
  Ralf


Thanks Ralf. the kvm_arch_vcpu_postcreate() fix is fine, as are the others.

Regards
Sanjay

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 00/18] KVM for MIPS32 Processors

2012-11-27 Thread Sanjay Lal

On Nov 26, 2012, at 1:53 PM, David Daney wrote:

 
 I have several general questions about this patch...
 
 On 11/21/2012 06:33 PM, Sanjay Lal wrote:
 The following patchset implements KVM support for MIPS32R2 processors,
 using Trap  Emulate, with basic runtime binary translation to improve
 performance.  The goal has been to keep the Guest kernel changes to a
 minimum.
 
 What is the point of minimizing guest kernel changes?
 
 Because you are using an invented memory map, instead of the architecturally 
 defined map, there is no hope of running a single kernel image both natively 
 and as a guest.  So why do you care about how many changes there are.

It makes porting the code easier.  Since we need a special guest kernel, 
keeping the changes to minimum helps when migrating from one Linux version to 
another.  At this point we've migrated the code from 2.6.32 to 3.7 with 3.0 
along the way, without any issues and anything more than an automatic merge.

 
 
 The patch is against Linux 3.7-rc6.  This is Version 2 of the patch set.
 
 There is a companion patchset for QEMU that adds KVM support for the
 MIPS target.
 
 KVM/MIPS should support MIPS32-R2 processors and beyond.
 It has been tested on the following platforms:
  - Malta Board with FPGA based 34K (Little Endian).
  - Sigma Designs TangoX board with a 24K based 8654 SoC (Little Endian).
  - Malta Board with 74K @ 1GHz (Little Endian).
  - OVPSim MIPS simulator from Imperas emulating a Malta board with
24Kc and 1074Kc cores (Little Endian).
 
 Unlike x86, there is no concept of a canonical MIPS system for you to 
 implement.  So the choice of emulating a Malta or one of the SigmaDesigns 
 boards doesn't seem to me to give you anything.
 
 Why not just define the guest system to be exactly the facilities provided by 
 the VirtIO drivers?

The above list is a list of host systems that we've tested KVM/MIPS on.  The 
guest kernel runs on the Malta system that is emulated by QEMU regardless of 
the host system.

And yes we do support VirtIO devices on the emulated Malta board to speed up 
I/O, but since they attach to the emulated systems' PCI bus, we still need a 
kernel and system that supports PCI.

Just an FYI, we'll be posting the QEMU patch set shortly.

 
 
 Perhaps it is obvious from the patches, but I wasn't able to figure out how 
 you solve the problem of the Root/Host kernel clobbering the K0 and K1 
 registers in its exception handlers.  These registers are also used by the 
 Guest kernel (aren't they)?

Yes k0/k1 do need to be saved as they are used by both the guest and host 
kernels.  The code is in kvm_locore.S around line 250 where the L1 exception 
vectors are installed.

Regards
Sanjay


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 00/18] KVM for MIPS32 Processors

2012-11-26 Thread David Daney


I have several general questions about this patch...

On 11/21/2012 06:33 PM, Sanjay Lal wrote:

The following patchset implements KVM support for MIPS32R2 processors,
using Trap  Emulate, with basic runtime binary translation to improve
performance.  The goal has been to keep the Guest kernel changes to a
minimum.


What is the point of minimizing guest kernel changes?

Because you are using an invented memory map, instead of the 
architecturally defined map, there is no hope of running a single kernel 
image both natively and as a guest.  So why do you care about how many 
changes there are.




The patch is against Linux 3.7-rc6.  This is Version 2 of the patch set.

There is a companion patchset for QEMU that adds KVM support for the
MIPS target.

KVM/MIPS should support MIPS32-R2 processors and beyond.
It has been tested on the following platforms:
  - Malta Board with FPGA based 34K (Little Endian).
  - Sigma Designs TangoX board with a 24K based 8654 SoC (Little Endian).
  - Malta Board with 74K @ 1GHz (Little Endian).
  - OVPSim MIPS simulator from Imperas emulating a Malta board with
24Kc and 1074Kc cores (Little Endian).


Unlike x86, there is no concept of a canonical MIPS system for you to 
implement.  So the choice of emulating a Malta or one of the 
SigmaDesigns boards doesn't seem to me to give you anything.


Why not just define the guest system to be exactly the facilities 
provided by the VirtIO drivers?



[...]


Perhaps it is obvious from the patches, but I wasn't able to figure out 
how you solve the problem of the Root/Host kernel clobbering the K0 and 
K1 registers in its exception handlers.  These registers are also used 
by the Guest kernel (aren't they)?


David Daney
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 00/18] KVM for MIPS32 Processors

2012-11-22 Thread Sanjay Lal
The following patchset implements KVM support for MIPS32R2 processors,
using Trap  Emulate, with basic runtime binary translation to improve
performance.  The goal has been to keep the Guest kernel changes to a
minimum.

The patch is against Linux 3.7-rc6.  This is Version 2 of the patch set.

There is a companion patchset for QEMU that adds KVM support for the 
MIPS target.

KVM/MIPS should support MIPS32-R2 processors and beyond.
It has been tested on the following platforms:
 - Malta Board with FPGA based 34K (Little Endian).
 - Sigma Designs TangoX board with a 24K based 8654 SoC (Little Endian).
 - Malta Board with 74K @ 1GHz (Little Endian).
 - OVPSim MIPS simulator from Imperas emulating a Malta board with 
   24Kc and 1074Kc cores (Little Endian).

Both Guest kernel and Guest Userspace execute in UM. The Guest address space is
as folows:
Guest User address space:   0x - 0x4000
Guest Kernel Unmapped:  0x4000 - 0x6000
Guest Kernel Mapped:0x6000 - 0x8000

As a result, Guest Usermode virtual memory is limited to 1GB.

Relase Notes

(1) 16K Page Size:
   Both Host Kernel and Guest Kernel should have the same page size, 
   currently at least 16K.  Note that due to cache aliasing issues, 
   4K page sizes are NOT supported.

(2) No HugeTLB/Large Page Support:
   Both the host kernel and Guest kernel should have the page size 
   set to at least 16K.
   This will be implemented in a future release.

(3) SMP Guests to not work
   Linux-3.7-rc2 based SMP guest hangs due to the following code sequence 
   in the generated TLB handlers:
LL/TLBP/SC
   Since the TLBP instruction causes a trap the reservation gets cleared
   when we ERET back to the guest. This causes the guest to hang in an 
   infinite loop.
   As a workaround, make sure that CONFIG_SMP is disabled for Guest kernels.
   This will be fixed in a future release.

(4) FPU support:
   Currently KVM/MIPS emulates a 24K CPU without a FPU.
   This will be fixed in a future release

--
Sanjay Lal (18):
  KVM/MIPS32: Infrastructure/build files.
  KVM/MIPS32: Arch specific KVM data structures.
  KVM/MIPS32: Entry point for trampolining to the guest and trap
handlers.
  KVM/MIPS32: MIPS arch specific APIs for KVM
  KVM/MIPS32: KVM Guest kernel support.
  KVM/MIPS32: Privileged instruction/target branch emulation.
  KVM/MIPS32: MMU/TLB operations for the Guest.
  KVM/MIPS32: Release notes and KVM module Makefile
  KVM/MIPS32: COP0 accesses profiling.
  KVM/MIPS32: Guest interrupt delivery.
  KVM/MIPS32: Routines to handle specific traps/exceptions while
executing the guest.
  MIPS: Export routines needed by the KVM module.
  MIPS: If KVM is enabled then use the KVM specific routine to flush
the TLBs on a ASID wrap.
  MIPS: ASM offsets for VCPU arch specific fields.
  MIPS: Pull in MIPS fix: fix endless loop when processing signals for
kernel tasks.
  MIPS: Export symbols used by KVM/MIPS module
  KVM/MIPS32: Do not call vcpu_load when injecting interrupts.
  KVM/MIPS32: Binary patching of select privileged instructions.

 arch/mips/Kbuild|4 +
 arch/mips/Kconfig   |   18 +
 arch/mips/configs/malta_kvm_defconfig   | 2268 +++
 arch/mips/configs/malta_kvm_guest_defconfig | 2237 ++
 arch/mips/include/asm/kvm.h |   55 +
 arch/mips/include/asm/kvm_host.h|  669 
 arch/mips/include/asm/mach-generic/spaces.h |9 +-
 arch/mips/include/asm/mmu_context.h |6 +
 arch/mips/include/asm/processor.h   |5 +
 arch/mips/include/asm/uaccess.h |   11 +-
 arch/mips/kernel/asm-offsets.c  |   66 +
 arch/mips/kernel/binfmt_elfo32.c|4 +
 arch/mips/kernel/cevt-r4k.c |4 +
 arch/mips/kernel/entry.S|7 +-
 arch/mips/kernel/smp.c  |1 +
 arch/mips/kernel/traps.c|7 +-
 arch/mips/kvm/00README.txt  |   31 +
 arch/mips/kvm/Kconfig   |   60 +
 arch/mips/kvm/Makefile  |   17 +
 arch/mips/kvm/kvm_cb.c  |   14 +
 arch/mips/kvm/kvm_locore.S  |  651 
 arch/mips/kvm/kvm_mips.c|  965 
 arch/mips/kvm/kvm_mips_comm.h   |   23 +
 arch/mips/kvm/kvm_mips_commpage.c   |   37 +
 arch/mips/kvm/kvm_mips_dyntrans.c   |  149 ++
 arch/mips/kvm/kvm_mips_emul.c   | 1840 ++
 arch/mips/kvm/kvm_mips_int.c|  243 +++
 arch/mips/kvm/kvm_mips_int.h|   49 +
 arch/mips/kvm/kvm_mips_opcode.h |   24 +
 arch/mips/kvm/kvm_mips_stats.c  |   81 +
 arch/mips/kvm/kvm_tlb.c |  932 +++
 arch/mips/kvm/kvm_trap_emul.c   |  482 ++
 arch/mips/kvm/trace.h   |