]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Merge tag 'kvm_mips_4.12_1' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan...
authorRadim Krčmář <rkrcmar@redhat.com>
Thu, 6 Apr 2017 12:47:03 +0000 (14:47 +0200)
committerRadim Krčmář <rkrcmar@redhat.com>
Thu, 6 Apr 2017 12:47:03 +0000 (14:47 +0200)
From: James Hogan <james.hogan@imgtec.com>

KVM: MIPS: VZ support, Octeon III, and TLBR

Add basic support for the MIPS Virtualization Module (generally known as
MIPS VZ) in KVM. We primarily support the ImgTec P5600, P6600, I6400,
and Cavium Octeon III cores so far. Support is included for the
following VZ / guest hardware features:
- MIPS32 and MIPS64, r5 (VZ requires r5 or later) and r6
- TLBs with GuestID (IMG cores) or Root ASID Dealias (Octeon III)
- Shared physical root/guest TLB (IMG cores)
- FPU / MSA
- Cop0 timer (up to 1GHz for now due to soft timer limit)
- Segmentation control (EVA)
- Hardware page table walker (HTW) both for root and guest TLB

Also included is a proper implementation of the TLBR instruction for the
trap & emulate MIPS KVM implementation.

Preliminary MIPS architecture changes are applied directly with Ralf's
ack.

1  2 
Documentation/virtual/kvm/api.txt

index fd106899afd1b2cf53d88d0fd2aacc85625ebe57,e601c8f01fd92ae1b25dd2fce13e17016fadff5c..753e88e5eb2ae7a3fc6455891de638d7f420cabe
@@@ -115,12 -115,17 +115,17 @@@ will access the virtual machine's physi
  corresponds to guest physical address zero.  Use of mmap() on a VM fd
  is discouraged if userspace memory allocation (KVM_CAP_USER_MEMORY) is
  available.
- You most certainly want to use 0 as machine type.
+ You probably want to use 0 as machine type.
  
  In order to create user controlled virtual machines on S390, check
  KVM_CAP_S390_UCONTROL and use the flag KVM_VM_S390_UCONTROL as
  privileged user (CAP_SYS_ADMIN).
  
+ To use hardware assisted virtualization on MIPS (VZ ASE) rather than
+ the default trap & emulate implementation (which changes the virtual
+ memory layout to fit in user mode), check KVM_CAP_MIPS_VZ and use the
+ flag KVM_VM_MIPS_VZ.
  
  4.3 KVM_GET_MSR_INDEX_LIST
  
@@@ -2068,11 -2073,23 +2073,23 @@@ registers, find a list below
    MIPS  | KVM_REG_MIPS_CP0_ENTRYLO0     | 64
    MIPS  | KVM_REG_MIPS_CP0_ENTRYLO1     | 64
    MIPS  | KVM_REG_MIPS_CP0_CONTEXT      | 64
+   MIPS  | KVM_REG_MIPS_CP0_CONTEXTCONFIG| 32
    MIPS  | KVM_REG_MIPS_CP0_USERLOCAL    | 64
+   MIPS  | KVM_REG_MIPS_CP0_XCONTEXTCONFIG| 64
    MIPS  | KVM_REG_MIPS_CP0_PAGEMASK     | 32
+   MIPS  | KVM_REG_MIPS_CP0_PAGEGRAIN    | 32
+   MIPS  | KVM_REG_MIPS_CP0_SEGCTL0      | 64
+   MIPS  | KVM_REG_MIPS_CP0_SEGCTL1      | 64
+   MIPS  | KVM_REG_MIPS_CP0_SEGCTL2      | 64
+   MIPS  | KVM_REG_MIPS_CP0_PWBASE       | 64
+   MIPS  | KVM_REG_MIPS_CP0_PWFIELD      | 64
+   MIPS  | KVM_REG_MIPS_CP0_PWSIZE       | 64
    MIPS  | KVM_REG_MIPS_CP0_WIRED        | 32
+   MIPS  | KVM_REG_MIPS_CP0_PWCTL        | 32
    MIPS  | KVM_REG_MIPS_CP0_HWRENA       | 32
    MIPS  | KVM_REG_MIPS_CP0_BADVADDR     | 64
+   MIPS  | KVM_REG_MIPS_CP0_BADINSTR     | 32
+   MIPS  | KVM_REG_MIPS_CP0_BADINSTRP    | 32
    MIPS  | KVM_REG_MIPS_CP0_COUNT        | 32
    MIPS  | KVM_REG_MIPS_CP0_ENTRYHI      | 64
    MIPS  | KVM_REG_MIPS_CP0_COMPARE      | 32
    MIPS  | KVM_REG_MIPS_CP0_CONFIG4      | 32
    MIPS  | KVM_REG_MIPS_CP0_CONFIG5      | 32
    MIPS  | KVM_REG_MIPS_CP0_CONFIG7      | 32
+   MIPS  | KVM_REG_MIPS_CP0_XCONTEXT     | 64
    MIPS  | KVM_REG_MIPS_CP0_ERROREPC     | 64
    MIPS  | KVM_REG_MIPS_CP0_KSCRATCH1    | 64
    MIPS  | KVM_REG_MIPS_CP0_KSCRATCH2    | 64
    MIPS  | KVM_REG_MIPS_CP0_KSCRATCH4    | 64
    MIPS  | KVM_REG_MIPS_CP0_KSCRATCH5    | 64
    MIPS  | KVM_REG_MIPS_CP0_KSCRATCH6    | 64
+   MIPS  | KVM_REG_MIPS_CP0_MAAR(0..63)  | 64
    MIPS  | KVM_REG_MIPS_COUNT_CTL        | 64
    MIPS  | KVM_REG_MIPS_COUNT_RESUME     | 64
    MIPS  | KVM_REG_MIPS_COUNT_HZ         | 64
@@@ -2162,6 -2181,10 +2181,10 @@@ hardware, host kernel, guest, and wheth
  with the RI and XI bits (if they exist) in bits 63 and 62 respectively, and
  the PFNX field starting at bit 30.
  
+ MIPS MAARs (see KVM_REG_MIPS_CP0_MAAR(*) above) have the following id bit
+ patterns:
+   0x7030 0000 0001 01 <reg:8>
  MIPS KVM control registers (see above) have the following id bit patterns:
    0x7030 0000 0002 <reg:16>
  
@@@ -3377,69 -3400,6 +3400,69 @@@ struct kvm_ppc_resize_hpt 
        __u32 pad;
  };
  
 +4.104 KVM_X86_GET_MCE_CAP_SUPPORTED
 +
 +Capability: KVM_CAP_MCE
 +Architectures: x86
 +Type: system ioctl
 +Parameters: u64 mce_cap (out)
 +Returns: 0 on success, -1 on error
 +
 +Returns supported MCE capabilities. The u64 mce_cap parameter
 +has the same format as the MSR_IA32_MCG_CAP register. Supported
 +capabilities will have the corresponding bits set.
 +
 +4.105 KVM_X86_SETUP_MCE
 +
 +Capability: KVM_CAP_MCE
 +Architectures: x86
 +Type: vcpu ioctl
 +Parameters: u64 mcg_cap (in)
 +Returns: 0 on success,
 +         -EFAULT if u64 mcg_cap cannot be read,
 +         -EINVAL if the requested number of banks is invalid,
 +         -EINVAL if requested MCE capability is not supported.
 +
 +Initializes MCE support for use. The u64 mcg_cap parameter
 +has the same format as the MSR_IA32_MCG_CAP register and
 +specifies which capabilities should be enabled. The maximum
 +supported number of error-reporting banks can be retrieved when
 +checking for KVM_CAP_MCE. The supported capabilities can be
 +retrieved with KVM_X86_GET_MCE_CAP_SUPPORTED.
 +
 +4.106 KVM_X86_SET_MCE
 +
 +Capability: KVM_CAP_MCE
 +Architectures: x86
 +Type: vcpu ioctl
 +Parameters: struct kvm_x86_mce (in)
 +Returns: 0 on success,
 +         -EFAULT if struct kvm_x86_mce cannot be read,
 +         -EINVAL if the bank number is invalid,
 +         -EINVAL if VAL bit is not set in status field.
 +
 +Inject a machine check error (MCE) into the guest. The input
 +parameter is:
 +
 +struct kvm_x86_mce {
 +      __u64 status;
 +      __u64 addr;
 +      __u64 misc;
 +      __u64 mcg_status;
 +      __u8 bank;
 +      __u8 pad1[7];
 +      __u64 pad2[3];
 +};
 +
 +If the MCE being reported is an uncorrected error, KVM will
 +inject it as an MCE exception into the guest. If the guest
 +MCG_STATUS register reports that an MCE is in progress, KVM
 +causes an KVM_EXIT_SHUTDOWN vmexit.
 +
 +Otherwise, if the MCE is a corrected error, KVM will just
 +store it in the corresponding bank (provided this bank is
 +not holding a previously reported uncorrected error).
 +
  5. The kvm_run structure
  ------------------------
  
@@@ -4210,3 -4170,68 +4233,68 @@@ This capability, if KVM_CHECK_EXTENSIO
  available, means that that the kernel can support guests using the
  hashed page table MMU defined in Power ISA V3.00 (as implemented in
  the POWER9 processor), including in-memory segment tables.
+ 8.5 KVM_CAP_MIPS_VZ
+ Architectures: mips
+ This capability, if KVM_CHECK_EXTENSION on the main kvm handle indicates that
+ it is available, means that full hardware assisted virtualization capabilities
+ of the hardware are available for use through KVM. An appropriate
+ KVM_VM_MIPS_* type must be passed to KVM_CREATE_VM to create a VM which
+ utilises it.
+ If KVM_CHECK_EXTENSION on a kvm VM handle indicates that this capability is
+ available, it means that the VM is using full hardware assisted virtualization
+ capabilities of the hardware. This is useful to check after creating a VM with
+ KVM_VM_MIPS_DEFAULT.
+ The value returned by KVM_CHECK_EXTENSION should be compared against known
+ values (see below). All other values are reserved. This is to allow for the
+ possibility of other hardware assisted virtualization implementations which
+ may be incompatible with the MIPS VZ ASE.
+  0: The trap & emulate implementation is in use to run guest code in user
+     mode. Guest virtual memory segments are rearranged to fit the guest in the
+     user mode address space.
+  1: The MIPS VZ ASE is in use, providing full hardware assisted
+     virtualization, including standard guest virtual memory segments.
+ 8.6 KVM_CAP_MIPS_TE
+ Architectures: mips
+ This capability, if KVM_CHECK_EXTENSION on the main kvm handle indicates that
+ it is available, means that the trap & emulate implementation is available to
+ run guest code in user mode, even if KVM_CAP_MIPS_VZ indicates that hardware
+ assisted virtualisation is also available. KVM_VM_MIPS_TE (0) must be passed
+ to KVM_CREATE_VM to create a VM which utilises it.
+ If KVM_CHECK_EXTENSION on a kvm VM handle indicates that this capability is
+ available, it means that the VM is using trap & emulate.
+ 8.7 KVM_CAP_MIPS_64BIT
+ Architectures: mips
+ This capability indicates the supported architecture type of the guest, i.e. the
+ supported register and address width.
+ The values returned when this capability is checked by KVM_CHECK_EXTENSION on a
+ kvm VM handle correspond roughly to the CP0_Config.AT register field, and should
+ be checked specifically against known values (see below). All other values are
+ reserved.
+  0: MIPS32 or microMIPS32.
+     Both registers and addresses are 32-bits wide.
+     It will only be possible to run 32-bit guest code.
+  1: MIPS64 or microMIPS64 with access only to 32-bit compatibility segments.
+     Registers are 64-bits wide, but addresses are 32-bits wide.
+     64-bit guest code may run but cannot access MIPS64 memory segments.
+     It will also be possible to run 32-bit guest code.
+  2: MIPS64 or microMIPS64 with access to all address segments.
+     Both registers and addresses are 64-bits wide.
+     It will be possible to run 64-bit or 32-bit guest code.