1. 31 10月, 2012 14 次提交
    • E
      i386: kvm: reformat filter_features_for_kvm() code · b8091f24
      Eduardo Habkost 提交于
      Cosmetic, but it will also help to make futher patches easier to review.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      b8091f24
    • E
      i386: kvm: filter CPUID feature words earlier, on cpu.c · bc74b7db
      Eduardo Habkost 提交于
      cpu.c contains the code that will check if all requested CPU features
      are available, so the filtering of KVM features must be there, so we can
      implement "check" and "enforce" properly.
      
      The only point where kvm_arch_init_vcpu() is called on i386 is:
      
      - cpu_x86_init()
        - x86_cpu_realize() (after cpu_x86_register() is called)
          - qemu_init_vcpu()
            - qemu_kvm_start_vcpu()
              - qemu_kvm_thread_fn() (on a new thread)
                - kvm_init_vcpu()
                  - kvm_arch_init_vcpu()
      
      With this patch, the filtering will be done earlier, at:
      - cpu_x86_init()
        - cpu_x86_register() (before x86_cpu_realize() is called)
      
      Also, the KVM CPUID filtering will now be done at the same place where
      the TCG CPUID feature filtering is done. Later, the code can be changed
      to use the same filtering code for the "check" and "enforce" modes, as
      now the cpu.c code knows exactly which CPU features are going to be
      exposed to the guest (and much earlier).
      
      One thing I was worrying about when doing this is that
      kvm_arch_get_supported_cpuid() depends on kvm_irqchip_in_kernel(), and
      maybe the 'kvm_kernel_irqchip' global variable wasn't initialized yet at
      CPU creation time. But kvm_kernel_irqchip is initialized during
      kvm_init(), that is called very early (much earlier than the machine
      init function), and kvm_init() is already a requirement to run the
      GET_SUPPORTED_CPUID ioctl() (as kvm_init() initializes the kvm_state
      global variable).
      
      Side note: it would be nice to keep KVM-specific code inside kvm.c. The
      problem is that properly implementing -cpu check/enforce code (that's
      inside cpu.c) depends directly on the feature bit filtering done using
      kvm_arch_get_supported_cpuid(). Currently -cpu check/enforce is broken
      because it simply uses the host CPU feature bits instead of
      GET_SUPPORTED_CPUID, and we need to fix that.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      bc74b7db
    • E
      i386: kvm: mask cpuid_ext4_features bits earlier · c9da8382
      Eduardo Habkost 提交于
      This way all the filtering by GET_SUPPORTED_CPUID is being done at the
      same place in the code.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      c9da8382
    • E
      i386: kvm: mask cpuid_kvm_features earlier · ea85c9e4
      Eduardo Habkost 提交于
      Instead of masking the KVM feature bits very late (while building the
      KVM_SET_CPUID2 data), mask it out on env->cpuid_kvm_features, at the
      same point where the other feature words are masked out.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      ea85c9e4
    • E
      i386: kvm: x2apic is not supported without in-kernel irqchip · 41e5e76d
      Eduardo Habkost 提交于
      This is necessary so that x2apic is not improperly enabled when the
      in-kernel irqchip is disabled.
      
      This won't generate a warning with "-cpu ...,check" because the current
      check/enforce code is broken (it checks the host CPU data directly,
      instead of using kvm_arch_get_supported_cpuid()), but it will be
      eventually fixed to properly report the missing x2apic flag.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      41e5e76d
    • E
      i386: kvm: set CPUID_EXT_TSC_DEADLINE_TIMER on kvm_arch_get_supported_cpuid() · ac67ee26
      Eduardo Habkost 提交于
      This moves the CPUID_EXT_TSC_DEADLINE_TIMER CPUID flag hacking from
      kvm_arch_init_vcpu() to kvm_arch_get_supported_cpuid().
      
      Full git grep for kvm_arch_get_supported_cpuid:
      
         kvm.h:uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
         target-i386/cpu.c:        x86_cpu_def->cpuid_7_0_ebx_features = kvm_arch_get_supported_cpuid(kvm_state, 0x7, 0, R_EBX);
         target-i386/cpu.c:            *eax = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EAX);
         target-i386/cpu.c:            *ebx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EBX);
         target-i386/cpu.c:            *ecx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_ECX);
         target-i386/cpu.c:            *edx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EDX);
         target-i386/cpu.c:            *eax = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EAX);
         target-i386/cpu.c:            *ebx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EBX);
         target-i386/cpu.c:            *ecx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_ECX);
         target-i386/cpu.c:            *edx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EDX);
         target-i386/kvm.c:uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
         target-i386/kvm.c:        cpuid_1_edx = kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
         target-i386/kvm.c:    env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
       * target-i386/kvm.c:    env->cpuid_ext_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_ECX);
         target-i386/kvm.c:    env->cpuid_ext2_features &= kvm_arch_get_supported_cpuid(s, 0x80000001,
         target-i386/kvm.c:    env->cpuid_ext3_features &= kvm_arch_get_supported_cpuid(s, 0x80000001,
         target-i386/kvm.c:    env->cpuid_svm_features  &= kvm_arch_get_supported_cpuid(s, 0x8000000A,
         target-i386/kvm.c:        kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX);
         target-i386/kvm.c:            kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);
      
      Note that there is only one call for CPUID[1].ECX above (*), and it is
      the one that gets hacked to include CPUID_EXT_TSC_DEADLINE_TIMER, so we
      can simply make kvm_arch_get_supported_cpuid() set it, to let the rest
      of the code know the flag can be safely set by QEMU.
      
      One thing I was worrying about when doing this is that now
      kvm_arch_get_supported_cpuid() depends on kvm_irqchip_in_kernel(). But
      the 'kvm_kernel_irqchip' global variable is initialized during
      kvm_init(), that is called very early, and kvm_init() is already a
      requirement to run the GET_SUPPORTED_CPUID ioctl() (as kvm_init() is the
      function that initializes the 'kvm_state' global variable).
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      ac67ee26
    • E
      i386: kvm: set CPUID_EXT_HYPERVISOR on kvm_arch_get_supported_cpuid() · 84bd945c
      Eduardo Habkost 提交于
      Full grep for kvm_arch_get_supported_cpuid:
      
         kvm.h:uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
         target-i386/cpu.c:        x86_cpu_def->cpuid_7_0_ebx_features = kvm_arch_get_supported_cpuid(kvm_state, 0x7, 0, R_EBX);
         target-i386/cpu.c:            *eax = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EAX);
         target-i386/cpu.c:            *ebx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EBX);
         target-i386/cpu.c:            *ecx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_ECX);
         target-i386/cpu.c:            *edx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EDX);
         target-i386/cpu.c:            *eax = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EAX);
         target-i386/cpu.c:            *ebx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EBX);
         target-i386/cpu.c:            *ecx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_ECX);
         target-i386/cpu.c:            *edx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EDX);
         target-i386/kvm.c:uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
         target-i386/kvm.c:        cpuid_1_edx = kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
         target-i386/kvm.c:    env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
       * target-i386/kvm.c:    env->cpuid_ext_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_ECX);
         target-i386/kvm.c:    env->cpuid_ext2_features &= kvm_arch_get_supported_cpuid(s, 0x80000001,
         target-i386/kvm.c:    env->cpuid_ext3_features &= kvm_arch_get_supported_cpuid(s, 0x80000001,
         target-i386/kvm.c:    env->cpuid_svm_features  &= kvm_arch_get_supported_cpuid(s, 0x8000000A,
         target-i386/kvm.c:        kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX);
         target-i386/kvm.c:            kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);
      
      Note that there is only one call for CPUID[1].ECX above (*), and it is
      the one that gets hacked to include CPUID_EXT_HYPERVISOR, so we can
      simply make kvm_arch_get_supported_cpuid() set it, to let the rest of
      the code automatically know that the flag can be safely set by QEMU.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      84bd945c
    • E
      i386: kvm: kvm_arch_get_supported_cpuid: replace if+switch with single 'if' · c2acb022
      Eduardo Habkost 提交于
      Additional fixups will be added, and making them a single 'if/else if'
      chain makes it clearer than two nested switch statements.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      c2acb022
    • E
      i386: kvm: extract try_get_cpuid() loop to get_supported_cpuid() function · dd87f8a6
      Eduardo Habkost 提交于
      No behavior change, just code movement.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      dd87f8a6
    • E
      i386: kvm: extract CPUID entry lookup to cpuid_find_entry() function · 4fb73f1d
      Eduardo Habkost 提交于
      No behavior change, just code movement.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      4fb73f1d
    • E
      i386: kvm: extract register switch to cpuid_entry_get_reg() function · 829ae2f9
      Eduardo Habkost 提交于
      No behavior change: just code movement.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      829ae2f9
    • E
      i386: kvm: kvm_arch_get_supported_cpuid: use 'entry' variable · 47111e2c
      Eduardo Habkost 提交于
      The reg switch will be moved to a separate function, so store the entry
      pointer in a variable.
      
      No behavior change, just code movement.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      47111e2c
    • E
      i386: kvm: kvm_arch_get_supported_cpuid: clean up has_kvm_features check · 8c723b79
      Eduardo Habkost 提交于
      Instead of a function-specific has_kvm_features variable, simply use a
      "found" variable that will be checked in case we have to use the legacy
      get_para_features() interface.
      
      No behavior change, just code cleanup.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      8c723b79
    • E
      i386: kvm: kvm_arch_get_supported_cpuid: move R_EDX hack outside of for loop · 7b46e5ce
      Eduardo Habkost 提交于
      The for loop will become a separate function, so clean it up so it can
      become independent from the bit hacking for R_EDX.
      
      No behavior change[1], just code movement.
      
      [1] Well, only if the kernel returned CPUID leafs 1 or 0x80000001 as
          unsupported, but there's no kernel version that does that.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
      7b46e5ce
  2. 29 10月, 2012 1 次提交
  3. 28 10月, 2012 2 次提交
  4. 23 10月, 2012 1 次提交
    • A
      Rename target_phys_addr_t to hwaddr · a8170e5e
      Avi Kivity 提交于
      target_phys_addr_t is unwieldly, violates the C standard (_t suffixes are
      reserved) and its purpose doesn't match the name (most target_phys_addr_t
      addresses are not target specific).  Replace it with a finger-friendly,
      standards conformant hwaddr.
      
      Outstanding patchsets can be fixed up with the command
      
        git rebase -i --exec 'find -name "*.[ch]"
                              | xargs s/target_phys_addr_t/hwaddr/g' origin
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      a8170e5e
  5. 14 10月, 2012 1 次提交
  6. 05 10月, 2012 1 次提交
  7. 01 10月, 2012 1 次提交
    • H
      x86: Implement SMEP and SMAP · a9321a4d
      H. Peter Anvin 提交于
      This patch implements Supervisor Mode Execution Prevention (SMEP) and
      Supervisor Mode Access Prevention (SMAP) for x86.  The purpose of the
      patch, obviously, is to help kernel developers debug the support for
      those features.
      
      A fair bit of the code relates to the handling of CPUID features.  The
      CPUID code probably would get greatly simplified if all the feature
      bit words were unified into a single vector object, but in the
      interest of producing a minimal patch for SMEP/SMAP, and because I had
      very limited time for this project, I followed the existing style.
      
      [ v2: don't change the definition of the qemu64 CPU shorthand, since
        that breaks loading old snapshots.  Per Anthony Liguori this can be
        fixed once the CPU feature set is snapshot.
      
        Change the coding style slightly to conform to checkpatch.pl. ]
      Signed-off-by: NH. Peter Anvin <hpa@linux.intel.com>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      a9321a4d
  8. 30 9月, 2012 5 次提交
  9. 28 9月, 2012 1 次提交
  10. 23 9月, 2012 1 次提交
  11. 21 9月, 2012 7 次提交
  12. 10 9月, 2012 1 次提交
  13. 31 8月, 2012 1 次提交
  14. 29 8月, 2012 2 次提交
    • M
      kvm: get/set PV EOI MSR · bc9a839d
      Michael S. Tsirkin 提交于
      Support get/set of new PV EOI MSR, for migration.
      Add an optional section for MSR value - send it
      out in case MSR was changed from the default value (0).
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      bc9a839d
    • A
      target-i386: disable pv eoi to fix migration across QEMU versions · ef8621b1
      Anthony Liguori 提交于
      We have a problem with how we handle migration with KVM paravirt features.
      We unconditionally enable paravirt features regardless of whether we know how
      to migrate them.
      
      We also don't tie paravirt features to specific machine types so an old QEMU on
      a new kernel would expose features that never existed.
      
      The 1.2 cycle is over and as things stand, migration is broken.  Michael has
      another series that adds support for migrating PV EOI and attempts to make it
      work correctly for different machine types.
      
      After speaking with Michael on IRC, we agreed to take this patch plus 1 & 4
      from his series.  This makes sure QEMU can migrate PV EOI if it's enabled, but
      does not enable it by default.
      
      This also means that we won't unconditionally enable new features for guests
      future proofing us from this happening again in the future.
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      ef8621b1
  15. 24 8月, 2012 1 次提交