1. 18 4月, 2016 2 次提交
    • T
      ppc: Fix the bad exception NIP value and the range check in LSWX · 537d3e8e
      Thomas Huth 提交于
      The range checks in the LSWX instruction are completely insufficient:
      They do not take the wrap-around case into account, and the check
      "reg < rx" should be "reg <= rx" instead. Fix it by using the new
      lsw_reg_in_range() helper function that is already used for LSWI, too.
      
      Then there is a second problem: In case the INVAL exception is generated,
      the NIP value is wrong, it currently points to the instruction before
      the LSWX instruction. This is because gen_lswx() already decreases the
      NIP value by 4 (to be prepared for page fault exceptions), and
      powerpc_excp() later decreases it again by 4 while handling the program
      exception. So to get this right, we've got to undo the "- 4" from
      gen_lswx() here before calling helper_raise_exception_err().
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      537d3e8e
    • T
      ppc: Fix the range check in the LSWI instruction · afbee712
      Thomas Huth 提交于
      There are two issues: First, the number of registers that are used has
      to be calculated with "(nb + 3) / 4" (i.e. round always up, not down).
      Second, the "start <= ra && (start + nr - 32) > ra" condition for the
      wrap-around case is wrong: It has to be tested with "||" instead of "&&".
      Since we can reuse this check later for the LSWX instruction, let's
      place the fixed code into a helper function, too.
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      afbee712
  2. 05 4月, 2016 1 次提交
  3. 24 3月, 2016 13 次提交
  4. 23 3月, 2016 3 次提交
    • V
      util: move declarations out of qemu-common.h · f348b6d1
      Veronia Bahaa 提交于
      Move declarations out of qemu-common.h for functions declared in
      utils/ files: e.g. include/qemu/path.h for utils/path.c.
      Move inline functions out of qemu-common.h and into new files (e.g.
      include/qemu/bcd.h)
      Signed-off-by: NVeronia Bahaa <veroniabahaa@gmail.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f348b6d1
    • R
      Replaced get_tick_per_sec() by NANOSECONDS_PER_SECOND · 73bcb24d
      Rutuja Shah 提交于
      This patch replaces get_ticks_per_sec() calls with the macro
      NANOSECONDS_PER_SECOND. Also, as there are no callers, get_ticks_per_sec()
      is then removed.  This replacement improves the readability and
      understandability of code.
      
      For example,
      
          timer_mod(fdctrl->result_timer,
      	      qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (get_ticks_per_sec() / 50));
      
      NANOSECONDS_PER_SECOND makes it obvious that qemu_clock_get_ns
      matches the unit of the expression on the right side of the plus.
      Signed-off-by: NRutuja Shah <rutu.shah.26@gmail.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      73bcb24d
    • M
      include/qemu/osdep.h: Don't include qapi/error.h · da34e65c
      Markus Armbruster 提交于
      Commit 57cb38b3 included qapi/error.h into qemu/osdep.h to get the
      Error typedef.  Since then, we've moved to include qemu/osdep.h
      everywhere.  Its file comment explains: "To avoid getting into
      possible circular include dependencies, this file should not include
      any other QEMU headers, with the exceptions of config-host.h,
      compiler.h, os-posix.h and os-win32.h, all of which are doing a
      similar job to this file and are under similar constraints."
      qapi/error.h doesn't do a similar job, and it doesn't adhere to
      similar constraints: it includes qapi-types.h.  That's in excess of
      100KiB of crap most .c files don't actually need.
      
      Add the typedef to qemu/typedefs.h, and include that instead of
      qapi/error.h.  Include qapi/error.h in .c files that need it and don't
      get it now.  Include qapi-types.h in qom/object.h for uint16List.
      
      Update scripts/clean-includes accordingly.  Update it further to match
      reality: replace config.h by config-target.h, add sysemu/os-posix.h,
      sysemu/os-win32.h.  Update the list of includes in the qemu/osdep.h
      comment quoted above similarly.
      
      This reduces the number of objects depending on qapi/error.h from "all
      of them" to less than a third.  Unfortunately, the number depending on
      qapi-types.h shrinks only a little.  More work is needed for that one.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  5. 19 3月, 2016 1 次提交
  6. 16 3月, 2016 7 次提交
  7. 01 3月, 2016 1 次提交
    • L
      tcg: Add type for vCPU pointers · 1bcea73e
      Lluís Vilanova 提交于
      Adds the 'TCGv_env' type for pointers to 'CPUArchState' objects. The
      tracing infrastructure later needs to differentiate between regular
      pointers and pointers to vCPUs.
      
      Also changes all targets to use the new 'TCGv_env' type instead of the
      generic 'TCGv_ptr'. As of now, the change is merely cosmetic ('TCGv_env'
      translates into 'TCGv_ptr'), but that could change in the future to
      enforce the difference.
      
      Note that a 'TCGv_env' type (for 'CPUState') is not added, since all
      helpers currently receive the architecture-specific
      pointer ('CPUArchState').
      Signed-off-by: NLluís Vilanova <vilanova@ac.upc.edu>
      Acked-by: NRichard Henderson <rth@twiddle.net>
      Message-id: 145641859552.30295.7821536833590725201.stgit@localhost
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      1bcea73e
  8. 25 2月, 2016 3 次提交
    • T
      ppc/kvm: Tell the user what might be wrong when using bad CPU types with kvm-hv · 388e47c7
      Thomas Huth 提交于
      Using a CPU type that does not match the host is not possible when using
      the kvm-hv kernel module - the PVR is checked in the kernel function
      kvm_arch_vcpu_ioctl_set_sregs_hv() and rejected with -EINVAL if it
      does not match the host.
      However, when the user tries to specify a non-matching CPU type, QEMU
      currently only reports "kvm_init_vcpu failed: Invalid argument", and
      this is of course not very helpful for the user to solve the problem.
      So this patch adds a more descriptive error message that tells the
      user to specify "-cpu host" instead.
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      [Removed melodramatic '!' :)]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      388e47c7
    • T
      ppc/kvm: Use error_report() instead of cpu_abort() for user-triggerable errors · 072ed5f2
      Thomas Huth 提交于
      Setting the KVM_CAP_PPC_PAPR capability can fail if either the KVM
      kernel module does not support it, or if the specified vCPU type
      is not a 64-bit Book3-S CPU type. For example, the user can trigger
      it easily with "-M pseries -cpu G2leLS" when using the kvm-pr kernel
      module. So the error should not be reported with cpu_abort() since
      this function is rather meant for reporting programming errors than
      reporting user-triggerable errors (it prints out all CPU registers
      and then calls abort() to kills the program - two things that the
      normal user does not expect here) . So let's use error_report() with
      exit(1) here instead.
      A similar problem exists in the code that sets the KVM_CAP_PPC_EPR
      capability, so while we're at it, fix that, too.
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      072ed5f2
    • T
      hw/ppc/spapr: Implement the h_page_init hypercall · 3240dd9a
      Thomas Huth 提交于
      This hypercall either initializes a page with zeros, or copies
      another page.
      According to LoPAPR, the i-cache of the page should also be
      flushed if using H_ICACHE_INVALIDATE or H_ICACHE_SYNCHRONIZE,
      and the d-cache should be synchronized to the RAM if the
      H_ICACHE_SYNCHRONIZE flag is used. For this, two new functions
      are introduced, kvmppc_dcbst_range() and kvmppc_icbi()_range, which
      use the corresponding assembler instructions to flush the caches
      if running with KVM on Power. If the code runs with TCG instead,
      the code only uses tb_flush(), assuming that this will be
      enough for synchronization.
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      3240dd9a
  9. 23 2月, 2016 1 次提交
  10. 17 2月, 2016 3 次提交
  11. 09 2月, 2016 3 次提交
    • R
      tcg: Change tcg_global_mem_new_* to take a TCGv_ptr · e1ccc054
      Richard Henderson 提交于
      Thus, use cpu_env as the parameter, not TCG_AREG0 directly.
      Update all uses in the translators.
      Reviewed-by: NAurelien Jarno <aurelien@aurel32.net>
      Signed-off-by: NRichard Henderson <rth@twiddle.net>
      e1ccc054
    • E
      qom: Swap 'name' next to visitor in ObjectPropertyAccessor · d7bce999
      Eric Blake 提交于
      Similar to the previous patch, it's nice to have all functions
      in the tree that involve a visitor and a name for conversion to
      or from QAPI to consistently stick the 'name' parameter next
      to the Visitor parameter.
      
      Done by manually changing include/qom/object.h and qom/object.c,
      then running this Coccinelle script and touching up the fallout
      (Coccinelle insisted on adding some trailing whitespace).
      
          @ rule1 @
          identifier fn;
          typedef Object, Visitor, Error;
          identifier obj, v, opaque, name, errp;
          @@
           void fn
          - (Object *obj, Visitor *v, void *opaque, const char *name,
          + (Object *obj, Visitor *v, const char *name, void *opaque,
             Error **errp) { ... }
      
          @@
          identifier rule1.fn;
          expression obj, v, opaque, name, errp;
          @@
           fn(obj, v,
          -   opaque, name,
          +   name, opaque,
              errp)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1454075341-13658-20-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      d7bce999
    • E
      qapi: Swap visit_* arguments for consistent 'name' placement · 51e72bc1
      Eric Blake 提交于
      JSON uses "name":value, but many of our visitor interfaces were
      called with visit_type_FOO(v, &value, name, errp).  This can be
      a bit confusing to have to mentally swap the parameter order to
      match JSON order.  It's particularly bad for visit_start_struct(),
      where the 'name' parameter is smack in the middle of the
      otherwise-related group of 'obj, kind, size' parameters! It's
      time to do a global swap of the parameter ordering, so that the
      'name' parameter is always immediately after the Visitor argument.
      
      Additional reason in favor of the swap: the existing include/qjson.h
      prefers listing 'name' first in json_prop_*(), and I have plans to
      unify that file with the qapi visitors; listing 'name' first in
      qapi will minimize churn to the (admittedly few) qjson.h clients.
      
      Later patches will then fix docs, object.h, visitor-impl.h, and
      those clients to match.
      
      Done by first patching scripts/qapi*.py by hand to make generated
      files do what I want, then by running the following Coccinelle
      script to affect the rest of the code base:
       $ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
      I then had to apply some touchups (Coccinelle insisted on TAB
      indentation in visitor.h, and botched the signature of
      visit_type_enum() by rewriting 'const char *const strings[]' to
      the syntactically invalid 'const char*const[] strings').  The
      movement of parameters is sufficient to provoke compiler errors
      if any callers were missed.
      
          // Part 1: Swap declaration order
          @@
          type TV, TErr, TObj, T1, T2;
          identifier OBJ, ARG1, ARG2;
          @@
           void visit_start_struct
          -(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
           { ... }
      
          @@
          type bool, TV, T1;
          identifier ARG1;
          @@
           bool visit_optional
          -(TV v, T1 ARG1, const char *name)
          +(TV v, const char *name, T1 ARG1)
           { ... }
      
          @@
          type TV, TErr, TObj, T1;
          identifier OBJ, ARG1;
          @@
           void visit_get_next_type
          -(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
           { ... }
      
          @@
          type TV, TErr, TObj, T1, T2;
          identifier OBJ, ARG1, ARG2;
          @@
           void visit_type_enum
          -(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
           { ... }
      
          @@
          type TV, TErr, TObj;
          identifier OBJ;
          identifier VISIT_TYPE =~ "^visit_type_";
          @@
           void VISIT_TYPE
          -(TV v, TObj OBJ, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, TErr errp)
           { ... }
      
          // Part 2: swap caller order
          @@
          expression V, NAME, OBJ, ARG1, ARG2, ERR;
          identifier VISIT_TYPE =~ "^visit_type_";
          @@
          (
          -visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
          +visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
          |
          -visit_optional(V, ARG1, NAME)
          +visit_optional(V, NAME, ARG1)
          |
          -visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
          +visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
          |
          -visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
          +visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
          |
          -VISIT_TYPE(V, OBJ, NAME, ERR)
          +VISIT_TYPE(V, NAME, OBJ, ERR)
          )
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      51e72bc1
  12. 03 2月, 2016 1 次提交
  13. 01 2月, 2016 1 次提交
    • J
      target-ppc: mcrfs should always update FEX/VX and only clear exception bits · d1277156
      James Clarke 提交于
      Here is the description of the mcrfs instruction from the PowerPC Architecture
      Book, Version 2.02, Book I: PowerPC User Instruction Set Architecture
      (http://www.ibm.com/developerworks/systems/library/es-archguide-v2.html), found
      on page 120:
      
          The contents of FPSCR field BFA are copied to Condition Register field BF.
          All exception bits copied are set to 0 in the FPSCR. If the FX bit is
          copied, it is set to 0 in the FPSCR.
      
          Special Registers Altered:
              CR field BF
              FX OX                        (if BFA=0)
              UX ZX XX VXSNAN              (if BFA=1)
              VXISI VXIDI VXZDZ VXIMZ      (if BFA=2)
              VXVC                         (if BFA=3)
              VXSOFT VXSQRT VXCVI          (if BFA=5)
      
      However, currently every bit in FPSCR field BFA is set to 0, including ones not
      on that list.
      
      This can be seen in the following simple C program:
      
          #include <fenv.h>
          #include <stdio.h>
      
          int main(int argc, char **argv) {
              int ret;
              ret = fegetround();
              printf("Current rounding: %d\n", ret);
              ret = fesetround(FE_UPWARD);
              printf("Setting to FE_UPWARD (%d): %d\n", FE_UPWARD, ret);
              ret = fegetround();
              printf("Current rounding: %d\n", ret);
              ret = fegetround();
              printf("Current rounding: %d\n", ret);
              return 0;
          }
      
      which gave the output (before this commit):
      
          Current rounding: 0
          Setting to FE_UPWARD (2): 0
          Current rounding: 2
          Current rounding: 0
      
      instead of (after this commit):
      
          Current rounding: 0
          Setting to FE_UPWARD (2): 0
          Current rounding: 2
          Current rounding: 2
      
      The relevant disassembly is in fegetround(), which, on my system, is:
      
          __GI___fegetround:
          <+0>:   mcrfs  cr7, cr7
          <+4>:   mfcr   r3
          <+8>:   clrldi r3, r3, 62
          <+12>:  blr
      
      What happens is that, the first time fegetround() is called, FPSCR field 7 is
      retrieved. However, because of the bug in mcrfs, the entirety of field 7 is set
      to 0, which includes the rounding mode.
      
      There are other issues this will fix, such as condition flags not persisting
      when they should if read, and if you were to read a specific field with some
      exception bits set, but no others were set in the entire register, then the
      bits would be cleared correctly, but FEX/VX would not be updated to 0 as they
      should be.
      Signed-off-by: NJames Clarke <jrtc27@jrtc27.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      d1277156