1. 30 8月, 2018 1 次提交
  2. 03 7月, 2018 1 次提交
    • G
      vga: disable global_vmstate for 3.0+ machine types · 1fcfdc43
      Gerd Hoffmann 提交于
      Move global_vmstate from vga_common_init() parameter to VGACommonState
      field.  Set global_vmstate to true for isa vga devices, so nothing
      changes here.  virtio-vga and secondary-vga already set global_vmstate
      to false so no change here either.  All other pci vga devices get a new
      global-vmstate property, defaulting to false.  A compat property flips
      it to true for older machine types.
      
      With this in place you don't get a vmstate section naming conflict any
      more when adding multiple pci vga devices to your vm.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      Message-Id: <20180702163345.17892-1-kraxel@redhat.com>
      1fcfdc43
  3. 02 7月, 2018 1 次提交
  4. 04 6月, 2018 1 次提交
    • G
      vga: cleanup surface handling · 6bc2fd57
      Gerd Hoffmann 提交于
      Just set the full_update flag if we need a new DisplaySurface.  Create
      a new surface when the flag is set instead of having two places where
      qemu_create_displaysurface_from() is called.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      Message-id: 20180525131318.28437-1-kraxel@redhat.com
      6bc2fd57
  5. 24 5月, 2018 1 次提交
    • G
      vga: catch depth 0 · a89fe6c3
      Gerd Hoffmann 提交于
      depth == 0 is used to indicate 256 color modes.  Our region calculation
      goes wrong in that case.  So detect that and just take the safe code
      path we already have for the wraparound case.
      
      While being at it also catch depth == 15 (where our region size
      calculation goes wrong too).  And make the comment more verbose,
      explaining what is going on here.
      
      Without this windows guest install might trigger an assert due to trying
      to check dirty bitmap outside the snapshot region.
      
      Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1575541Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      Message-id: 20180514103117.21059-1-kraxel@redhat.com
      a89fe6c3
  6. 12 3月, 2018 1 次提交
  7. 13 2月, 2018 1 次提交
  8. 25 1月, 2018 1 次提交
    • L
      vga: check the validation of memory addr when draw text · 191f59dc
      linzhecheng 提交于
      Start a vm with qemu-kvm -enable-kvm -vnc :66 -smp 1 -m 1024 -hda
      redhat_5.11.qcow2  -device pcnet -vga cirrus,
      then use VNC client to connect to VM, and excute the code below in guest
      OS will lead to qemu crash:
      
      int main()
       {
          iopl(3);
          srand(time(NULL));
          int a,b;
          while(1){
      	a = rand()%0x100;
      	b = 0x3c0 + (rand()%0x20);
              outb(a,b);
          }
          return 0;
      }
      
      The above code is writing the registers of VGA randomly.
      We can write VGA CRT controller registers index 0x0C or 0x0D
      (which is the start address register) to modify the
      the display memory address of the upper left pixel
      or character of the screen. The address may be out of the
      range of vga ram. So we should check the validation of memory address
      when reading or writing it to avoid segfault.
      Signed-off-by: Nlinzhecheng <linzhecheng@huawei.com>
      Message-id: 20180111132724.13744-1-linzhecheng@huawei.com
      Fixes: CVE-2018-5683
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      191f59dc
  9. 18 12月, 2017 3 次提交
  10. 10 11月, 2017 1 次提交
  11. 17 10月, 2017 3 次提交
  12. 01 9月, 2017 3 次提交
  13. 31 8月, 2017 1 次提交
  14. 15 7月, 2017 1 次提交
  15. 28 6月, 2017 1 次提交
  16. 11 5月, 2017 1 次提交
  17. 24 4月, 2017 2 次提交
    • G
      vga: make display updates thread safe. · fec5e8c9
      Gerd Hoffmann 提交于
      The vga code clears the dirty bits *after* reading the framebuffer
      memory.  So if the guest framebuffer updates hits the race window
      between vga reading the framebuffer and vga clearing the dirty bits
      vga will miss that update
      
      Fix it by using the new memory_region_copy_and_clear_dirty()
      memory_region_copy_get_dirty() functions.  That way we clear the
      dirty bitmap before reading the framebuffer.  Any guest display
      updates happening in parallel will be properly tracked in the
      dirty bitmap then and the next display refresh will pick them up.
      
      Problem triggers with mttcg only.  Before mttcg was merged tcg
      never ran in parallel to vga emulation.  Using kvm will hide the
      problem too, due to qemu operating on a userspace copy of the
      kernel's dirty bitmap.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      Message-id: 20170421091632.30900-5-kraxel@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      fec5e8c9
    • G
      vga: add vga_scanline_invalidated helper · f3289f6f
      Gerd Hoffmann 提交于
      Add vga_scanline_invalidated helper to check whenever a scanline was
      invalidated.  Add a sanity check to fix OOB read access for display
      heights larger than 2048.
      
      Only cirrus uses this, for hardware cursor rendering, so having this
      work properly for the first 2048 scanlines only shouldn't be a problem
      as the cirrus can't handle large resolutions anyway.  Also changing the
      invalidated_y_table size would break live migration.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      Message-id: 20170421091632.30900-4-kraxel@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      f3289f6f
  18. 10 2月, 2017 1 次提交
  19. 20 6月, 2016 1 次提交
    • E
      coccinelle: Remove unnecessary variables for function return value · 9be38598
      Eduardo Habkost 提交于
      Use Coccinelle script to replace 'ret = E; return ret' with
      'return E'. The script will do the substitution only when the
      function return type and variable type are the same.
      
      Manual fixups:
      
      * audio/audio.c: coding style of "read (...)" and "write (...)"
      * block/qcow2-cluster.c: wrap line to make it shorter
      * block/qcow2-refcount.c: change indentation of wrapped line
      * target-tricore/op_helper.c: fix coding style of
        "remainder|quotient"
      * target-mips/dsp_helper.c: reverted changes because I don't
        want to argue about checkpatch.pl
      * ui/qemu-pixman.c: fix line indentation
      * block/rbd.c: restore blank line between declarations and
        statements
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <1465855078-19435-4-git-send-email-ehabkost@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      [Unused Coccinelle rule name dropped along with a redundant comment;
      whitespace touched up in block/qcow2-cluster.c; stale commit message
      paragraph deleted]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      9be38598
  20. 23 5月, 2016 1 次提交
    • G
      vga: add sr_vbe register set · 94ef4f33
      Gerd Hoffmann 提交于
      Commit "fd3c136b vga: make sure vga register setup for vbe stays intact
      (CVE-2016-3712)." causes a regression.  The win7 installer is unhappy
      because it can't freely modify vga registers any more while in vbe mode.
      
      This patch introduces a new sr_vbe register set.  The vbe_update_vgaregs
      will fill sr_vbe[] instead of sr[].  Normal vga register reads and
      writes go to sr[].  Any sr register read access happens through a new
      sr() helper function which will read from sr_vbe[] with vbe active and
      from sr[] otherwise.
      
      This way we can allow guests update sr[] registers as they want, without
      allowing them disrupt vbe video modes that way.
      
      Cc: qemu-stable@nongnu.org
      Reported-by: NThomas Lamprecht <thomas@lamprecht.org>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      Message-id: 1463475294-14119-1-git-send-email-kraxel@redhat.com
      94ef4f33
  21. 02 5月, 2016 5 次提交
    • G
      vga: make sure vga register setup for vbe stays intact (CVE-2016-3712). · fd3c136b
      Gerd Hoffmann 提交于
      Call vbe_update_vgaregs() when the guest touches GFX, SEQ or CRT
      registers, to make sure the vga registers will always have the
      values needed by vbe mode.  This makes sure the sanity checks
      applied by vbe_fixup_regs() are effective.
      
      Without this guests can muck with shift_control, can turn on planar
      vga modes or text mode emulation while VBE is active, making qemu
      take code paths meant for CGA compatibility, but with the very
      large display widths and heigts settable using VBE registers.
      
      Which is good for one or another buffer overflow.  Not that
      critical as they typically read overflows happening somewhere
      in the display code.  So guests can DoS by crashing qemu with a
      segfault, but it is probably not possible to break out of the VM.
      
      Fixes: CVE-2016-3712
      Reported-by: NZuozhi Fzz <zuozhi.fzz@alibaba-inc.com>
      Reported-by: NP J P <ppandit@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      fd3c136b
    • G
      vga: update vga register setup on vbe changes · 2068192d
      Gerd Hoffmann 提交于
      Call the new vbe_update_vgaregs() function on vbe configuration
      changes, to make sure vga registers are up-to-date.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      2068192d
    • G
      vga: factor out vga register setup · 7fa5c2c5
      Gerd Hoffmann 提交于
      When enabling vbe mode qemu will setup a bunch of vga registers to make
      sure the vga emulation operates in correct mode for a linear
      framebuffer.  Move that code to a separate function so we can call it
      from other places too.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      7fa5c2c5
    • G
      vga: add vbe_enabled() helper · bfa0f151
      Gerd Hoffmann 提交于
      Makes code a bit easier to read.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      bfa0f151
    • G
      vga: fix banked access bounds checking (CVE-2016-3710) · 3bf18170
      Gerd Hoffmann 提交于
      vga allows banked access to video memory using the window at 0xa00000
      and it supports a different access modes with different address
      calculations.
      
      The VBE bochs extentions support banked access too, using the
      VBE_DISPI_INDEX_BANK register.  The code tries to take the different
      address calculations into account and applies different limits to
      VBE_DISPI_INDEX_BANK depending on the current access mode.
      
      Which is probably effective in stopping misprogramming by accident.
      But from a security point of view completely useless as an attacker
      can easily change access modes after setting the bank register.
      
      Drop the bogus check, add range checks to vga_mem_{readb,writeb}
      instead.
      
      Fixes: CVE-2016-3710
      Reported-by: NQinghao Tang <luodalongde@gmail.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      3bf18170
  22. 23 3月, 2016 2 次提交
    • 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
  23. 29 1月, 2016 1 次提交
  24. 08 1月, 2016 1 次提交
    • O
      ui/curses: Fix color attribute of monitor for curses · 4083733d
      OGAWA Hirofumi 提交于
      Current text_console_update() writes totally broken color attributes
      to console_write_ch(). The format now is writing,
      
      [WRONG]
      	bold << 21 | fg << 12 | bg << 8 | char
      	fg == 3bits curses color number
      	bg == 3bits curses color number
      
      I can't see this format is where come from. Anyway, this doesn't work
      at all.
      
      What curses expects is actually (and vga.c is using),
      
      [RIGHT]
      	bold << 21 | bg << 11 | fg << 8 | char
      	fg == 3bits vga color number
      	bg == 3bits vga color number
      
      And curses set COLOR_PAIR() up to match this format, and curses's
      chtype. I.e,
      
      	bold | color_pair | char
      	color_pair == (bg << 3 | fg)
      
      To fix, this simply uses VGA color number everywhere except curses.c
      internal. Then, convert it to above [RIGHT] format to write by
      console_write_ch(). And as bonus, this reduces to expose curses define
      to other parts (removes COLOR_* from console.c).
      
      [Tested the first line is displayed as white on blue back for monitor
      in curses console]
      Signed-off-by: NOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Message-id: 87r3j95407.fsf@mail.parknet.co.jp
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      4083733d
  25. 18 9月, 2015 1 次提交
    • M
      Fix bad error handling after memory_region_init_ram() · f8ed85ac
      Markus Armbruster 提交于
      Symptom:
      
          $ qemu-system-x86_64 -m 10000000
          Unexpected error in ram_block_add() at /work/armbru/qemu/exec.c:1456:
          upstream-qemu: cannot set up guest memory 'pc.ram': Cannot allocate memory
          Aborted (core dumped)
      
      Root cause: commit ef701d7b screwed up handling of out-of-memory
      conditions.  Before the commit, we report the error and exit(1), in
      one place, ram_block_add().  The commit lifts the error handling up
      the call chain some, to three places.  Fine.  Except it uses
      &error_abort in these places, changing the behavior from exit(1) to
      abort(), and thus undoing the work of commit 39228250 "exec: Don't
      abort when we can't allocate guest memory".
      
      The three places are:
      
      * memory_region_init_ram()
      
        Commit 49946538 (right after commit ef701d7b) lifted the error
        handling further, through memory_region_init_ram(), multiplying the
        incorrect use of &error_abort.  Later on, imitation of existing
        (bad) code may have created more.
      
      * memory_region_init_ram_ptr()
      
        The &error_abort is still there.
      
      * memory_region_init_rom_device()
      
        Doesn't need fixing, because commit 33e0eb52 (soon after commit
        ef701d7b) lifted the error handling further, and in the process
        changed it from &error_abort to passing it up the call chain.
        Correct, because the callers are realize() methods.
      
      Fix the error handling after memory_region_init_ram() with a
      Coccinelle semantic patch:
      
          @r@
          expression mr, owner, name, size, err;
          position p;
          @@
                  memory_region_init_ram(mr, owner, name, size,
          (
          -                              &error_abort
          +                              &error_fatal
          |
                                         err@p
          )
                                        );
          @script:python@
              p << r.p;
          @@
          print "%s:%s:%s" % (p[0].file, p[0].line, p[0].column)
      
      When the last argument is &error_abort, it gets replaced by
      &error_fatal.  This is the fix.
      
      If the last argument is anything else, its position is reported.  This
      lets us check the fix is complete.  Four positions get reported:
      
      * ram_backend_memory_alloc()
      
        Error is passed up the call chain, ultimately through
        user_creatable_complete().  As far as I can tell, it's callers all
        handle the error sanely.
      
      * fsl_imx25_realize(), fsl_imx31_realize(), dp8393x_realize()
      
        DeviceClass.realize() methods, errors handled sanely further up the
        call chain.
      
      We're good.  Test case again behaves:
      
          $ qemu-system-x86_64 -m 10000000
          qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory
          [Exit 1 ]
      
      The next commits will repair the rest of commit ef701d7b's damage.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1441983105-26376-3-git-send-email-armbru@redhat.com>
      Reviewed-by: NPeter Crosthwaite <crosthwaite.peter@gmail.com>
      f8ed85ac
  26. 12 6月, 2015 1 次提交
    • J
      migration: Use normal VMStateDescriptions for Subsections · 5cd8cada
      Juan Quintela 提交于
      We create optional sections with this patch.  But we already have
      optional subsections.  Instead of having two mechanism that do the
      same, we can just generalize it.
      
      For subsections we just change:
      
      - Add a needed function to VMStateDescription
      - Remove VMStateSubsection (after removal of the needed function
        it is just a VMStateDescription)
      - Adjust the whole tree, moving the needed function to the corresponding
        VMStateDescription
      Signed-off-by: NJuan Quintela <quintela@redhat.com>
      5cd8cada
  27. 19 3月, 2015 1 次提交
    • S
      Fix remaining warnings from Sparse (void return) · e7ae771f
      Stefan Weil 提交于
      Sparse report:
      
      hw/display/vga.c:2000:5: warning: returning void-valued expression
      hw/intc/arm_gic.c:707:9: warning: returning void-valued expression
      hw/intc/etraxfs_pic.c:138:9: warning: returning void-valued expression
      hw/nvram/fw_cfg.c:475:5: warning: returning void-valued expression
      hw/timer/a9gtimer.c:124:5: warning: returning void-valued expression
      hw/tpm/tpm_tis.c:794:5: warning: returning void-valued expression
      hw/usb/hcd-musb.c:558:9: warning: returning void-valued expression
      hw/usb/hcd-musb.c:776:13: warning: returning void-valued expression
      hw/usb/hcd-musb.c:867:5: warning: returning void-valued expression
      hw/usb/hcd-musb.c:932:5: warning: returning void-valued expression
      include/qom/cpu.h:584:5: warning: returning void-valued expression
      monitor.c:4686:13: warning: returning void-valued expression
      monitor.c:4690:13: warning: returning void-valued expression
      
      Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Cc: Andreas Färber <afaerber@suse.de>
      Cc: Luiz Capitulino <lcapitulino@redhat.com>
      Signed-off-by: NStefan Weil <sw@weilnetz.de>
      Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
      e7ae771f
  28. 03 3月, 2015 1 次提交