Skip to content
Snippets Groups Projects
  1. Jan 08, 2022
    • Frédéric Pétrot's avatar
      qemu/int128: addition of div/rem 128-bit operations · e9d07601
      Frédéric Pétrot authored
      
      Addition of div and rem on 128-bit integers, using the 128/64->128 divu and
      64x64->128 mulu in host-utils.
      These operations will be used within div/rem helpers in the 128-bit riscv
      target.
      
      Signed-off-by: default avatarFrédéric Pétrot <frederic.petrot@univ-grenoble-alpes.fr>
      Co-authored-by: default avatarFabien Portas <fabien.portas@grenoble-inp.org>
      Reviewed-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Message-id: 20220106210108.138226-4-frederic.petrot@univ-grenoble-alpes.fr
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      e9d07601
    • Frédéric Pétrot's avatar
      exec/memop: Adding signed quad and octo defines · c7f9dd54
      Frédéric Pétrot authored
      
      Adding defines to handle signed 64-bit and unsigned 128-bit quantities in
      memory accesses.
      
      Signed-off-by: default avatarFrédéric Pétrot <frederic.petrot@univ-grenoble-alpes.fr>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Reviewed-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Message-id: 20220106210108.138226-3-frederic.petrot@univ-grenoble-alpes.fr
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      c7f9dd54
    • Frédéric Pétrot's avatar
      exec/memop: Adding signedness to quad definitions · fc313c64
      Frédéric Pétrot authored
      
      Renaming defines for quad in their various forms so that their signedness is
      now explicit.
      Done using git grep as suggested by Philippe, with a bit of hand edition to
      keep assignments aligned.
      
      Signed-off-by: default avatarFrédéric Pétrot <frederic.petrot@univ-grenoble-alpes.fr>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Reviewed-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Message-id: 20220106210108.138226-2-frederic.petrot@univ-grenoble-alpes.fr
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      fc313c64
    • Philipp Tomsich's avatar
      target/riscv: Fix position of 'experimental' comment · dfdb46a3
      Philipp Tomsich authored
      
      When commit 0643c12e dropped the 'x-' prefix for Zb[abcs] and set
      them to be enabled by default, the comment about experimental
      extensions was kept in place above them.  This moves it down a few
      lines to only cover experimental extensions.
      
      References: 0643c12e ("target/riscv: Enable bitmanip Zb[abcs] instructions")
      
      Signed-off-by: default avatarPhilipp Tomsich <philipp.tomsich@vrull.eu>
      Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Message-id: 20220106134020.1628889-1-philipp.tomsich@vrull.eu
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      dfdb46a3
    • Frank Chang's avatar
      target/riscv: rvv-1.0: Call the correct RVF/RVD check function for narrowing... · 79e6176e
      Frank Chang authored
      target/riscv: rvv-1.0: Call the correct RVF/RVD check function for narrowing fp/int type-convert insns
      
      vfncvt.f.xu.w, vfncvt.f.x.w convert double-width integer to single-width
      floating-point. Therefore, should use require_rvf() to check whether
      RVF/RVD is enabled.
      
      vfncvt.f.f.w, vfncvt.rod.f.f.w convert double-width floating-point to
      single-width integer. Therefore, should use require_scale_rvf() to check
      whether RVF/RVD is enabled.
      
      Signed-off-by: default avatarFrank Chang <frank.chang@sifive.com>
      Acked-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Message-Id: <20220105022247.21131-4-frank.chang@sifive.com>
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      79e6176e
    • Frank Chang's avatar
      target/riscv: rvv-1.0: Call the correct RVF/RVD check function for widening... · 91cade44
      Frank Chang authored
      target/riscv: rvv-1.0: Call the correct RVF/RVD check function for widening fp/int type-convert insns
      
      vfwcvt.xu.f.v, vfwcvt.x.f.v, vfwcvt.rtz.xu.f.v and vfwcvt.rtz.x.f.v
      convert single-width floating-point to double-width integer.
      Therefore, should use require_rvf() to check whether RVF/RVD is enabled.
      
      vfwcvt.f.xu.v, vfwcvt.f.x.v convert single-width integer to double-width
      floating-point, and vfwcvt.f.f.v convert double-width floating-point to
      single-width floating-point. Therefore, should use require_scale_rvf() to
      check whether RVF/RVD is enabled.
      
      Signed-off-by: default avatarFrank Chang <frank.chang@sifive.com>
      Acked-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Message-Id: <20220105022247.21131-3-frank.chang@sifive.com>
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      91cade44
    • Frank Chang's avatar
      target/riscv: rvv-1.0: Call the correct RVF/RVD check function for widening fp insns · 629ccdaa
      Frank Chang authored
      
      Vector widening floating-point instructions should use
      require_scale_rvf() instead of require_rvf() to check whether RVF/RVD is
      enabled.
      
      Signed-off-by: default avatarFrank Chang <frank.chang@sifive.com>
      Acked-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Message-Id: <20220105022247.21131-2-frank.chang@sifive.com>
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      629ccdaa
    • Bin Meng's avatar
      roms/opensbi: Upgrade from v0.9 to v1.0 · b3e02049
      Bin Meng authored
      
      Upgrade OpenSBI from v0.9 to v1.0 and the pre-built bios images.
      
      The v1.0 release includes the following commits:
      
      ec5274b platform: implement K210 system reset
      5487cf0 include: sbi: Simplify HSM state define names
      8df1f9a lib: sbi: Use SBI_HSM_STATE_xyz defines instead of SBI_STATE_xyz defines
      7c867fd lib: sbi: Rename sbi_hsm_hart_started_mask() function
      638c948 lib: sbi: Remove redundant sbi_hsm_hart_started() function
      ca864a9 lib: sbi: Fix error codes returned by HSM start() and stop() functions
      6290a22 include: sbi: Add HSM suspend related defines
      4b05df6 lib: sbi: Add sbi_hart_reinit() function
      807d71c include: sbi: Add hart_suspend() platform callback
      7475689 lib: sbi: Implement SBI HSM suspend function
      b9cf617 include: sbi: Upgrade SBI implementation version to v0.3
      50d4fde lib: Remove redundant sbi_platform_ipi_clear() calls
      ff5bd94 include: sbi: SBI function IDs for RFENCE extension
      22d8ee9 firmware: Use lla to access all global symbols
      0f20e8a firmware: Support position independent execution
      ddad02d lib: sbi: illegal CSR 0x306 access in hpm_allowed()
      bfc85c7 include: headers: Replace __ASSEMBLY__ with __ASSEMBLER__
      9190ad1 lib/utils: Support the official clint DT bindings
      ca3f358 lib/utils: Drop the 'compat' parameter of fdt_plic_fixup()
      4edc822 lib/utils: Support fixing up the official DT bindings of PLIC
      4ef2f5d firware: optimize the exception exit code
      3d8a952 lib: fix csr detect support
      e71a7c1 firmware: Remove redundant add instruction from trap restore path
      d4a94ea include: types: Add __aligned(x) to define the minimum alignement
      d0e406f include: sbi: Allow direct initialization via SPIN_LOCK_INIT()
      4d8e2f1 lib: sbi: Replace test-and-set locks by ticket locks
      70ffc3e lib: sbi: fix atomic_add_return
      27a16b1 docs: fix link to OpenPiton documentation
      b1df1ac lib: sbi: Domains can be registered only before finalizing domains
      7495bce lib: sbi: Add sbi_domain_memregion_init() API
      4dc0001 lib: sbi: Add sbi_domain_root_add_memregion() API
      8b56980 lib: utils/sys: Add CLINT memregion in the root domain
      fc37c97 lib: sbi: Make the root domain instance global variable
      e7e4bcd lib: utils: Copy over restricted root domain memregions to FDT domains
      f41196a lib: sbi: Make sbi_domain_memregion_initfw() a local function
      c5d0645 lib: utils: Implement "64bit-mmio" property parsing
      49e422c lib: utils: reset: Add T-HEAD sample platform reset driver
      0d56293 lib: sbi: Fix sbi_domain_root_add_memregion() for merging memregions
      bf3ef53 firmware: Enable FW_PIC by default
      1db8436 platform: Remove platform/thead
      6d1642f docs: generic: Add T-HEAD C9xx series processors
      a3689db lib: sbi: Remove domains_root_regions() platform callback
      068ca08 lib: sbi: Simplify console platform operations
      559a8f1 lib: sbi: Simplify timer platform operations
      dc39c7b lib: sbi: Simplify ipi platform operations
      043d088 lib: sbi: Simplify system reset platform operations
      a84a1dd lib: sbi: Simplify HSM platform operations
      e9a27ab lib: sbi: Show devices provided by platform in boot prints
      632e27b docs/platform: sifive_fu540: Update U-Boot defconfig name
      117fb6d lib: utils/serial: Add support for Gaisler APBUART
      552f53f docs: platform: Sort platform names
      d4177e7 docs: platform: Describe sifive_fu540 as supported generic platform
      26998f3 platform: Remove sifive/fu540 platform
      f90c4c2 lib: sbi: Have spinlock checks return bool
      e822b75 lib: utils/serial: Support Synopsys DesignWare APB UART
      6139ab2 Makefile: unconditionally disable SSP
      c9ef2bc lib: utils: Add strncpy macro to libfdt_env.h
      ee7c2b2 lib: utils/fdt: Don't use sbi_string functions
      fe92347 lib: utils/fdt: Replace strcmp with strncmp
      b2dbbc0 lib: Check region base for merging in sbi_domain_root_add_memregion()
      54d7def lib: utils: Try other FDT drivers when we see SBI_ENODEV
      d9ba653 docs: debugging OpenSBI
      66c4fca lib: utils: consider ':' in stdout-path
      f30b189 lib: sbi_scratch: remove owner from sbi_scratch_alloc_offset
      a03ea2e platform: andes/ae350: Cosmetic fixes in plicsw.c
      b32fac4 docs/platform: andes-ae350: Fix missing spaces
      de446cc platform: andes/ae350: Drop plicsw_get_pending()
      434198e platform: andes/ae350: Drop plicsw_ipi_sync()
      1da3d80 lib: sbi_scratch: zero out scratch memory on all harts
      360ab88 lib: utils: missing initialization in thead_reset_init
      79f9b42 lib: sbi: Fix GET_F64_REG inline assembly
      eb90e0a lib: utils/libfdt: Upgrade to v1.6.1 release
      cdcf907 lib: sign conflict in sbi_tlb_entry_process()
      9901794 lib: sign conflict in wake_coldboot_harts()
      11c345f lib: simplify sbi_fifo_inplace_update()
      4519e29 lib: utils/timer: Add ACLINT MTIMER library
      5a049fe lib: utils/ipi: Add ACLINT MSWI library
      bd5d208 lib: utils: Add FDT parsing API common for both ACLINT and CLINT
      56fc5f7 lib: utils/ipi: Add FDT based ACLINT MSWI IPI driver
      03d6bb5 lib: utils/timer: Add FDT based ACLINT MTIMER driver
      a731c7e platform: Replace CLINT library usage with ACLINT library
      b7f2cd2 lib: utils: reset: unify naming of 'sifive_test' device
      197e089 docs/platform: thead-c9xx: Remove FW_PIC=y
      17e23b6 platform: generic: Terminate platform.name with null
      3e8b31a docs: Add device tree bindings for SBI PMU extension
      fde28fa lib: sbi: Detect mcountinihibit support at runtime
      d3a96cc lib: sbi: Remove stray '\' character
      0829f2b lib: sbi: Detect number of bits implemented in mhpmcounter
      9c9b4ad lib: sbi: Disable m/scounteren & enable mcountinhibit
      41ae63c include: Add a list empty check function
      fd9116b lib: sbi: Remove redundant boot time print statement
      49966db lib: sbi: Use csr_read/write_num to read/update PMU counters
      e7cc7a3 lib: sbi: Add PMU specific platform hooks
      13d40f2 lib: sbi: Add PMU support
      ae72ec0 utils: fdt: Add fdt helper functions to parse PMU DT nodes
      37f9b0f lib: sbi: Implement SBI PMU extension
      764a17d lib: sbi: Implement firmware counters
      ec1b8bb lib: sbi: Improve TLB function naming
      0e12aa8 platform: generic: Add PMU support
      14c7f71 firmware: Minor optimization in _scratch_init()
      dafaa0f docs: Correct a typo in platform_guide.md
      abfce9b docs: Make <xyz> visible in the rendered platform guide
      dcb756b firmware: Remove the sanity checks in fw_save_info()
      b88b366 firmware: Define a macro for version of struct fw_dynamic_info
      a76ac44 lib: sbi: Fix sbi_pmu_exit() for systems not having MCOUNTINHIBIT csr
      7f1be8a fw_base: Don't mark fw_platform_init as both global and weak
      397afe5 fw_base: Put data in .data rather than .text
      a3d328a firmware: Explicitly pass -pie to the linker, not just the driver
      09ad811 firmware: Only default FW_PIC to y if supported
      2942777 Makefile: Support building with Clang and LLVM binutils
      17729d4 lib: utils: Drop dependency on libgcc by importing part of FreeBSD's libquad
      e931f38 lib: utils/fdt: Add fdt_parse_phandle_with_args() API
      36b8eff lib: utils/gpio: Add generic GPIO configuration library
      c14f1fe lib: utils/gpio: Add simple FDT based GPIO framework
      4c3df2a lib: utils/gpio: Add minimal SiFive GPIO driver
      e3d6919 lib: utils/reset: Add generic GPIO reset driver
      7210e90 firmware: use __SIZEOF_LONG__ for field offsets in fw_dynamic.h
      f3a8f60 include: types: Use __builtin_offsetof when supported
      8a1475b firmware: Remove the unhelpful alignment codes before fdt relocation
      a4555e5 docs: Document parameters passed to firmware and alignment requirement
      2c74dc3 docs: Document FW_PIC compile time option
      81eb708 README: Update toolchain information
      9890391 Makefile: Manually forward RELAX_FLAG to the assembler when linking with LLD
      74db0ac firmware: use _fw_start for load address
      217d5e4 generic: fu740: add workaround for CIP-1200 errata
      ce03c88 lib: utils: remove unused variable in fdt_reset_init
      e928472 lib: utils: support both of gpio-poweroff, gpio-reset
      d244f3d lib: sbi: Fix bug in strncmp function when count is 0
      47a4765 lib: utils/fdt: Change addr and size to uint64_t
      e0d1b9d lib: utils/timer: Allow separate base addresses for MTIME and MTIMECMP
      7a3a0cc lib: utils: Extend fdt_get_node_addr_size() for multiple register sets
      f3a0eb8 lib: utils/fdt: Extend fdt_parse_aclint_node() function
      b35f782 lib: utils/timer: Allow ACLINT MTIMER supporting only 32-bit MMIO
      7aa6c9a lib: utils/timer: Simplify MTIMER synchronization
      33eac76 lib: sbi: Fix bug in sbi_ecall_rfence that misses checking
      ee27437 lib: sbi_trap: Restore redirect for access faults
      b1d3e91 payloads/test: Add support for SBI v0.2 ecalls
      bd316e2 lib: sbi: Correct typo in faults delegation CSR name
      c262306 lib: sbi: protect dprintf output with spinlock
      1718b16 lib: sbi: Checking fifo validness in sbi_fifo_is_empty and is_full
      bd35521 lib: sbi: Refine the way to construct platform features
      0274a96 lib: utils/reset: Sort fdt_reset driver list
      395ff7e lib: utils/reset: Add a sunxi watchdog reset driver
      3477f08 lib: sbi: fix ctz bug
      12753d2 lib: sbi: add some macros to detect BUG at runtime
      51113fe lib: sbi: Add BUG() macro for csr_read/write_num() and misa_string()
      72154f4 lib: utils/fdt: Add fdt_parse_timebase_frequency() function
      12e7af9 lib: sbi: Add timer frequency to struct sbi_timer_device
      6355155 lib: sbi: Print timer frequency at boot time
      9d0ab35 lib: sbi: Add generic timer delay loop function
      fa59dd3 lib: utils/reset: use sbi_timer_mdelay() in gpio reset driver
      754d511 lib: utils: identify supported GPIO reset methods
      516161c lib: sbi: convert reset to list
      9283d50 lib: sbi: add priority for reset handler
      c38973e lib: sbi: Save context for all non-retentive suspend types
      67cbbcb lib: sbi: system reset with invalid parameters
      422eda4 Makefile: Add build time and compiler info string
      78c2b19 lib: utils/irqchip: Automatically delegate T-HEAD PLIC access
      309e8bd lib: utils/reset: Register separate GPIO system reset devices
      723aa88 lib: sbi: Refine addr format in sbi_printf
      c891acc include: sbi_utils: Introduce an helper to get fdt base address
      013ba4e lib: sbi: Fix GPA passed to __sbi_hfence_gvma_xyz() functions
      0979ffd lib: utils/gpio: use list for drivers
      2fe2f55 lib: sbi: move sbi_boot_print_general()
      57f094e platform: generic: move fdt_reset_init to final_init
      be245ac lib: sbi: error handling in fdt_reset_init()
      a74daf2 riscv: Add new CSRs introduced by Sscofpmf[1] extension
      7084ad9 lib: sbi: Update csr_read/write_num for PMU
      867c653 lib: sbi: Detect Sscofpmf extension at run time
      9134c36 lib: sbi: Delegate PMU counter overflow interrupt to S mode
      730f01b lib: sbi: Support sscofpmf extension in OpenSBI
      2363f95 lib: sbi: Always enable access for all counters
      0c304b6 lib: sbi: Allow programmable counters to monitor cycle/instret events
      1e14732 lib: sbi: Reset the mhpmevent value upon counter reset
      b628cfd lib: sbi: Counter info width should be zero indexed
      b28f070 lib: sbi: Enable PMU extension for platforms without mcountinhibit
      15906a3 lib: utils: Rename the prefix in PMU DT properties
      b8845e4 lib: sbi: Fix initial value mask while updating the counters
      31fe5a7 lib: sbi: Fix PMP address bits detection
      94eba23 lib: utils/reset: add priority to gpio reset
      1d462e0 lib: utils/reset: separate driver init func
      2c964a2 lib: utils/i2c: Add generic I2C configuration library
      6ca6bca lib: utils/i2c: Add simple FDT based I2C framework
      13a1158 lib: utils/i2c: Add minimal SiFive I2C driver
      f374496 platform: sifive_fu740: add platform reset driver
      d335a17 lib: sbi: clear pmpcfg.A before setting in pmp_set()
      52af6e4 lib: utils: Add LiteX UART support
      22d556d lib: sbi: Fix spelling of "address" in sbi_domain.c
      7a22c78 lib: sbi: Fix missing space
      7e77706 lib: sbi: Resolve the uninitialized complaint in sbi_pmu
      14faee6 lib: sbi: Improve fatal error handling
      2428987 lib: pmu: support the event ID encoded by a bitmap.
      66fbcc0 docs/platform: spike: Enhance Spike examples
      460041c lib: pmu: check SSCOF before masking
      69d7e53 Makefile: Fix -msave-restore compile warning with CLANG-10 (or lower)
      d249d65 lib: sbi: Fix compile errors using -Os option
      f270359 Makefile: Improve the method to disable -m(no-)save-restore option
      2082153 lib: sbi: simplify pmp_set(), pmp_get()
      d30bde3 firmware: Move memcpy/memset mapping to fw_base.S
      48f91ee include: Bump-up version to 1.0
      
      Signed-off-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Reviewed-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      b3e02049
    • Alistair Francis's avatar
      hw/riscv: virt: Allow support for 32 cores · d4452c69
      Alistair Francis authored
      Linux supports up to 32 cores for both 32-bit and 64-bit RISC-V, so
      let's set that as the maximum for the virt board.
      
      Resolves: https://gitlab.com/qemu-project/qemu/-/issues/435
      
      
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: default avatarAnup Patel <anup.patel@wdc.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Message-Id: <20220105213937.1113508-9-alistair.francis@opensource.wdc.com>
      d4452c69
    • Alistair Francis's avatar
      hw/riscv: Use error_fatal for SoC realisation · 8f972e5b
      Alistair Francis authored
      
      When realising the SoC use error_fatal instead of error_abort as the
      process can fail and report useful information to the user.
      
      Currently a user can see this:
      
         $ ../qemu/bld/qemu-system-riscv64 -M sifive_u -S -monitor stdio -display none -drive if=pflash
          QEMU 6.1.93 monitor - type 'help' for more information
          (qemu) Unexpected error in sifive_u_otp_realize() at ../hw/misc/sifive_u_otp.c:229:
          qemu-system-riscv64: OTP drive size < 16K
          Aborted (core dumped)
      
      Which this patch addresses
      
      Reported-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Tested-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Message-Id: <20220105213937.1113508-8-alistair.francis@opensource.wdc.com>
      8f972e5b
    • Alistair Francis's avatar
      target/riscv: Enable the Hypervisor extension by default · 07cb270a
      Alistair Francis authored
      
      Let's enable the Hypervisor extension by default. This doesn't affect
      named CPUs (such as lowrisc-ibex or sifive-u54) but does enable the
      Hypervisor extensions by default for the virt machine.
      
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: default avatarAnup Patel <anup.patel@wdc.com>
      Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Message-Id: <20220105213937.1113508-7-alistair.francis@opensource.wdc.com>
      07cb270a
    • Alistair Francis's avatar
      target/riscv: Mark the Hypervisor extension as non experimental · 6ca7155a
      Alistair Francis authored
      
      The Hypervisor spec is now frozen, so remove the experimental tag.
      
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: default avatarAnup Patel <anup.patel@wdc.com>
      Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Message-Id: <20220105213937.1113508-6-alistair.francis@opensource.wdc.com>
      6ca7155a
    • Alistair Francis's avatar
      hw/intc: sifive_plic: Cleanup remaining functions · 41bcc44a
      Alistair Francis authored
      
      We can remove the original sifive_plic_irqs_pending() function and
      instead just use the sifive_plic_claim() function (renamed to
      sifive_plic_claimed()) to determine if any interrupts are pending.
      
      This requires move the side effects outside of sifive_plic_claimed(),
      but as they are only invoked once that isn't a problem.
      
      We have also removed all of the old #ifdef debugging logs, so let's
      cleanup the last remaining debug function while we are here.
      
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Message-Id: <20220105213937.1113508-5-alistair.francis@opensource.wdc.com>
      41bcc44a
    • Alistair Francis's avatar
      hw/intc: sifive_plic: Cleanup the read function · b79e1c76
      Alistair Francis authored
      
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Message-Id: <20220105213937.1113508-4-alistair.francis@opensource.wdc.com>
      b79e1c76
    • Alistair Francis's avatar
      hw/intc: sifive_plic: Cleanup the write function · fb926d57
      Alistair Francis authored
      
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Message-Id: <20220105213937.1113508-3-alistair.francis@opensource.wdc.com>
      fb926d57
    • Alistair Francis's avatar
      hw/intc: sifive_plic: Add a reset function · 83b92b8e
      Alistair Francis authored
      
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Message-Id: <20220105213937.1113508-2-alistair.francis@opensource.wdc.com>
      83b92b8e
    • Jim Shu's avatar
      hw/dma: sifive_pdma: permit 4/8-byte access size of PDMA registers · e6b0408a
      Jim Shu authored
      
      It's obvious that PDMA supports 64-bit access of 64-bit registers, and
      in previous commit, we confirm that PDMA supports 32-bit access of
      both 32/64-bit registers. Thus, we configure 32/64-bit memory access
      of PDMA registers as valid in general.
      
      Signed-off-by: default avatarJim Shu <jim.shu@sifive.com>
      Reviewed-by: default avatarFrank Chang <frank.chang@sifive.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Reviewed-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Tested-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Message-id: 20220104063408.658169-3-jim.shu@sifive.com
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      e6b0408a
    • Jim Shu's avatar
      hw/dma: sifive_pdma: support high 32-bit access of 64-bit register · 6fd3f397
      Jim Shu authored
      
      Real PDMA supports high 32-bit read/write memory access of 64-bit
      register.
      
      The following result is PDMA tested in U-Boot on Unmatched board:
      
      1. Real PDMA allows high 32-bit read/write to 64-bit register.
      => mw.l 0x3000000 0x0                      <= Disclaim channel 0
      => mw.l 0x3000000 0x1                      <= Claim channel 0
      => mw.l 0x3000010 0x80000000               <= Write low 32-bit NextDest (NextDest = 0x280000000)
      => mw.l 0x3000014 0x2                      <= Write high 32-bit NextDest
      => md.l 0x3000010 1                        <= Dump low 32-bit NextDest
      03000010: 80000000
      => md.l 0x3000014 1                        <= Dump high 32-bit NextDest
      03000014: 00000002
      => mw.l 0x3000018 0x80001000               <= Write low 32-bit NextSrc (NextSrc = 0x280001000)
      => mw.l 0x300001c 0x2                      <= Write high 32-bit NextSrc
      => md.l 0x3000018 1                        <= Dump low 32-bit NextSrc
      03000010: 80001000
      => md.l 0x300001c 1                        <= Dump high 32-bit NextSrc
      03000014: 00000002
      
      2. PDMA transfer from 0x280001000 to 0x280000000 is OK.
      => mw.q 0x3000008 0x4                      <= NextBytes = 4
      => mw.l 0x3000004 0x22000000               <= wsize = rsize = 2 (2^2 = 4 bytes)
      => mw.l 0x280000000 0x87654321             <= Fill test data to dst
      => mw.l 0x280001000 0x12345678             <= Fill test data to src
      => md.l 0x280000000 1; md.l 0x280001000 1  <= Dump src/dst memory contents
      280000000: 87654321                              !Ce.
      280001000: 12345678                              xV4.
      => md.l 0x3000000 8                        <= Dump PDMA status
      03000000: 00000001 22000000 00000004 00000000    ......."........
      03000010: 80000000 00000002 80001000 00000002    ................
      => mw.l 0x3000000 0x3                      <= Set channel 0 run and claim bits
      => md.l 0x3000000 8                        <= Dump PDMA status
      03000000: 40000001 22000000 00000004 00000000    ...@..."........
      03000010: 80000000 00000002 80001000 00000002    ................
      => md.l 0x280000000 1; md.l 0x280001000 1  <= Dump src/dst memory contents
      280000000: 12345678                               xV4.
      280001000: 12345678                               xV4.
      
      Signed-off-by: default avatarJim Shu <jim.shu@sifive.com>
      Reviewed-by: default avatarFrank Chang <frank.chang@sifive.com>
      Reviewed-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Tested-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Message-id: 20220104063408.658169-2-jim.shu@sifive.com
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      6fd3f397
    • Nikita Shubin's avatar
      target/riscv/pmp: fix no pmp illegal intrs · 0fbb5d2d
      Nikita Shubin authored
      
      As per the privilege specification, any access from S/U mode should fail
      if no pmp region is configured and pmp is present, othwerwise access
      should succeed.
      
      Fixes: d102f19a (target/riscv/pmp: Raise exception if no PMP entry is configured)
      Signed-off-by: default avatarNikita Shubin <n.shubin@yadro.com>
      Reviewed-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Message-id: 20211214092659.15709-1-nikita.shubin@maquefel.me
      Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      0fbb5d2d
    • Richard Henderson's avatar
      Merge tag 'for_upstream' of git://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging · d7007537
      Richard Henderson authored
      
      virtio,pci,pc: features,fixes,cleanups
      
      New virtio mem options.
      A vhost-user cleanup.
      Control over smbios entry point type.
      Config interrupt support for vdpa.
      Fixes, cleanups all over the place.
      
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      
      # gpg: Signature made Fri 07 Jan 2022 04:30:41 PM PST
      # gpg:                using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469
      # gpg:                issuer "mst@redhat.com"
      # gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" [undefined]
      # gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>" [undefined]
      # gpg: WARNING: This key is not certified with a trusted signature!
      # gpg:          There is no indication that the signature belongs to the owner.
      # Primary key fingerprint: 0270 606B 6F3C DF3D 0B17  0970 C350 3912 AFBE 8E67
      #      Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA  8A0D 281F 0DB8 D28D 5469
      
      * tag 'for_upstream' of git://git.kernel.org/pub/scm/virt/kvm/mst/qemu
      
      : (55 commits)
        tests: acpi: Add updated TPM related tables
        acpi: tpm: Add missing device identification objects
        tests: acpi: prepare for updated TPM related tables
        virtio/vhost-vsock: don't double close vhostfd, remove redundant cleanup
        hw/scsi/vhost-scsi: don't double close vhostfd on error
        hw/scsi/vhost-scsi: don't leak vqs on error
        docs: reSTify virtio-balloon-stats documentation and move to docs/interop
        hw/i386/pc: Add missing property descriptions
        acpihp: simplify acpi_pcihp_disable_root_bus
        tests: acpi: SLIC: update expected blobs
        tests: acpi: add SLIC table test
        tests: acpi: whitelist expected blobs before changing them
        acpi: fix QEMU crash when started with SLIC table
        intel-iommu: correctly check passthrough during translation
        virtio-mem: Set "unplugged-inaccessible=auto" for the 7.0 machine on x86
        virtio-mem: Support VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE
        linux-headers: sync VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE
        MAINTAINERS: Add a separate entry for acpi/VIOT tables
        virtio: signal after wrapping packed used_idx
        virtio-mem: Support "prealloc=on" option
        ...
      
      Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      d7007537
    • Stefan Berger's avatar
      tests: acpi: Add updated TPM related tables · ca745d22
      Stefan Berger authored
      
      The updated TPM related tables have the following additions:
      
         Device (TPM)
         {
             Name (_HID, "MSFT0101" /* TPM 2.0 Security Device */)  // _HID: Hardware ID
      +      Name (_STR, "TPM 2.0 Device")  // _STR: Description String
      +      Name (_UID, One)  // _UID: Unique ID
             Name (_STA, 0x0F)  // _STA: Status
             Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
      
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Ani Sinha <ani@anisinha.ca>
      Signed-off-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Acked-by: default avatarAni Sinha <ani@anisinha.ca>
      Message-id: 20211223022310.575496-4-stefanb@linux.ibm.com
      Message-Id: <20220104175806.872996-4-stefanb@linux.ibm.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      ca745d22
    • Stefan Berger's avatar
      acpi: tpm: Add missing device identification objects · 5903646d
      Stefan Berger authored
      Add missing TPM device identification objects _STR and _UID. They will
      appear as files 'description' and 'uid' under Linux sysfs.
      
      Following inspection of sysfs entries for hardware TPMs we chose
      uid '1'.
      
      Cc: Shannon Zhao <shannon.zhaosl@gmail.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Ani Sinha <ani@anisinha.ca>
      Resolves: https://gitlab.com/qemu-project/qemu/-/issues/708
      
      
      Signed-off-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Reviewed-by: default avatarAni Sinha <ani@anisinha.ca>
      Reviewed-by: default avatarShannon Zhao <shannon.zhaosl@gmail.com>
      Message-id: 20211223022310.575496-3-stefanb@linux.ibm.com
      Message-Id: <20220104175806.872996-3-stefanb@linux.ibm.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarIgor Mammedov <imammedo@redhat.com>
      5903646d
    • Stefan Berger's avatar
      tests: acpi: prepare for updated TPM related tables · b193e5f9
      Stefan Berger authored
      
      Replace existing TPM related tables, that are about to change, with
      empty files.
      
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Ani Sinha <ani@anisinha.ca>
      Signed-off-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Acked-by: default avatarAni Sinha <ani@anisinha.ca>
      Message-id: 20211223022310.575496-2-stefanb@linux.ibm.com
      Message-Id: <20220104175806.872996-2-stefanb@linux.ibm.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Acked-by: default avatarIgor Mammedov <imammedo@redhat.com>
      b193e5f9
    • Daniil Tatianin's avatar
      virtio/vhost-vsock: don't double close vhostfd, remove redundant cleanup · d731ab31
      Daniil Tatianin authored
      
      In case of an error during initialization in vhost_dev_init, vhostfd is
      closed in vhost_dev_cleanup. Remove close from err_virtio as it's both
      redundant and causes a double close on vhostfd.
      
      Signed-off-by: default avatarDaniil Tatianin <d-tatianin@yandex-team.ru>
      Message-Id: <20211129125204.1108088-1-d-tatianin@yandex-team.ru>
      Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      d731ab31
    • Daniil Tatianin's avatar
      hw/scsi/vhost-scsi: don't double close vhostfd on error · 539ba1ac
      Daniil Tatianin authored
      
      vhost_dev_init calls vhost_dev_cleanup on error, which closes vhostfd,
      don't double close it.
      
      Signed-off-by: default avatarDaniil Tatianin <d-tatianin@yandex-team.ru>
      Message-Id: <20211129132358.1110372-2-d-tatianin@yandex-team.ru>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      539ba1ac
    • Daniil Tatianin's avatar
      hw/scsi/vhost-scsi: don't leak vqs on error · b259772a
      Daniil Tatianin authored
      
      vhost_dev_init calls vhost_dev_cleanup in case of an error during
      initialization, which zeroes out the entire vsc->dev as well as the
      vsc->dev.vqs pointer. This prevents us from properly freeing it in free_vqs.
      Keep a local copy of the pointer so we can free it later.
      
      Signed-off-by: default avatarDaniil Tatianin <d-tatianin@yandex-team.ru>
      Message-Id: <20211129132358.1110372-1-d-tatianin@yandex-team.ru>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      b259772a
    • Thomas Huth's avatar
      docs: reSTify virtio-balloon-stats documentation and move to docs/interop · 14dc58e3
      Thomas Huth authored
      
      The virtio-balloon-stats documentation might be useful for people that
      are implementing software that talks to QEMU via QMP, so this should
      reside in the docs/interop/ directory. While we're at it, also convert
      the file to restructured text and mention it in the MAINTAINERS file.
      
      Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
      Message-Id: <20220105115245.420945-1-thuth@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      14dc58e3
    • Thomas Huth's avatar
      hw/i386/pc: Add missing property descriptions · 44bff376
      Thomas Huth authored
      
      When running "qemu-system-x86_64 -M pc,help" I noticed that some
      properties were still missing their description. Add them now so
      that users get at least a slightly better idea what they are all
      about.
      
      Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
      Message-Id: <20211206134255.94784-1-thuth@redhat.com>
      Reviewed-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      44bff376
    • Ani Sinha's avatar
      acpihp: simplify acpi_pcihp_disable_root_bus · 78480268
      Ani Sinha authored
      
      Get rid of the static variable that keeps track of whether hotplug has been
      disabled on the root pci bus. Simply use qbus_is_hotpluggable() api to
      perform the same check. This eliminates additional if conditional and
      simplifies the function.
      
      Signed-off-by: default avatarAni Sinha <ani@anisinha.ca>
      Message-Id: <1640764674-7784-1-git-send-email-ani@anirban.org>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      78480268
    • Igor Mammedov's avatar
      tests: acpi: SLIC: update expected blobs · c8adb4d2
      Igor Mammedov authored
      
      Signed-off-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Message-Id: <20211227193120.1084176-5-imammedo@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      c8adb4d2
    • Igor Mammedov's avatar
      tests: acpi: add SLIC table test · 11edfabe
      Igor Mammedov authored
      
      When user uses '-acpitable' to add SLIC table, some ACPI
      tables (FADT) will change its 'Oem ID'/'Oem Table ID' fields to
      match that of SLIC. Test makes sure thati QEMU handles
      those fields correctly when SLIC table is added with
      '-acpitable' option.
      
      Signed-off-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Message-Id: <20211227193120.1084176-4-imammedo@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      11edfabe
    • Igor Mammedov's avatar
      tests: acpi: whitelist expected blobs before changing them · e71f6ab9
      Igor Mammedov authored
      
      Signed-off-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Message-Id: <20211227193120.1084176-3-imammedo@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      e71f6ab9
    • Igor Mammedov's avatar
      acpi: fix QEMU crash when started with SLIC table · 8cdb99af
      Igor Mammedov authored
      if QEMU is started with used provided SLIC table blob,
      
        -acpitable sig=SLIC,oem_id='CRASH ',oem_table_id="ME",oem_rev=00002210,asl_compiler_id="",asl_compiler_rev=00000000,data=/dev/null
      it will assert with:
      
        hw/acpi/aml-build.c:61:build_append_padded_str: assertion failed: (len <= maxlen)
      
      and following backtrace:
      
        ...
        build_append_padded_str (array=0x555556afe320, str=0x555556afdb2e "CRASH ME", maxlen=0x6, pad=0x20) at hw/acpi/aml-build.c:61
        acpi_table_begin (desc=0x7fffffffd1b0, array=0x555556afe320) at hw/acpi/aml-build.c:1727
        build_fadt (tbl=0x555556afe320, linker=0x555557ca3830, f=0x7fffffffd318, oem_id=0x555556afdb2e "CRASH ME", oem_table_id=0x555556afdb34 "ME") at hw/acpi/aml-build.c:2064
        ...
      
      which happens due to acpi_table_begin() expecting NULL terminated
      oem_id and oem_table_id strings, which is normally the case, but
      in case of user provided SLIC table, oem_id points to table's blob
      directly and as result oem_id became longer than expected.
      
      Fix issue by handling oem_id consistently and make acpi_get_slic_oem()
      return NULL terminated strings.
      
      PS:
      After [1] refactoring, oem_id semantics became inconsistent, where
      NULL terminated string was coming from machine and old way pointer
      into byte array coming from -acpitable option. That used to work
      since build_header() wasn't expecting NULL terminated string and
      blindly copied the 1st 6 bytes only.
      
      However commit [2] broke that by replacing build_header() with
      acpi_table_begin(), which was expecting NULL terminated string
      and was checking oem_id size.
      
      1) 602b4582 ("acpi: Permit OEM ID and OEM table ID fields to be changed")
      2)
      Fixes: 4b56e1e4 ("acpi: build_fadt: use acpi_table_begin()/acpi_table_end() instead of build_header()")
      Resolves: https://gitlab.com/qemu-project/qemu/-/issues/786
      
      
      Signed-off-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Message-Id: <20211227193120.1084176-2-imammedo@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Tested-by: default avatarDenis Lisov <dennis.lissov@gmail.com>
      Tested-by: default avatarAlexander Tsoy <alexander@tsoy.me>
      Cc: qemu-stable@nongnu.org
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      8cdb99af
    • Jason Wang's avatar
      intel-iommu: correctly check passthrough during translation · 5178d78f
      Jason Wang authored
      
      When scalable mode is enabled, the passthrough more is not determined
      by the context entry but PASID entry, so switch to use the logic of
      vtd_dev_pt_enabled() to determine the passthrough mode in
      vtd_do_iommu_translate().
      
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <20220105041945.13459-2-jasowang@redhat.com>
      Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      5178d78f
    • David Hildenbrand's avatar
      virtio-mem: Set "unplugged-inaccessible=auto" for the 7.0 machine on x86 · 60f1f77c
      David Hildenbrand authored
      
      Set the new default to "auto", keeping it set to "off" for compat
      machines. This property is only available for x86 targets.
      
      Reviewed-by: default avatarMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: default avatarPankaj Gupta <pankaj.gupta@ionos.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Message-Id: <20211217134039.29670-4-david@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      60f1f77c
    • David Hildenbrand's avatar
      virtio-mem: Support VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE · 23ad8dec
      David Hildenbrand authored
      
      With VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, we signal the VM that reading
      unplugged memory is not supported. We have to fail feature negotiation
      in case the guest does not support VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE.
      
      First, VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE is required to properly handle
      memory backends (or architectures) without support for the shared zeropage
      in the hypervisor cleanly. Without the shared zeropage, even reading an
      unpopulated virtual memory location can populate real memory and
      consequently consume memory in the hypervisor. We have a guaranteed shared
      zeropage only on MAP_PRIVATE anonymous memory.
      
      Second, we want VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE to be the default
      long-term as even populating the shared zeropage can be problematic: for
      example, without THP support (possible) or without support for the shared
      huge zeropage with THP (unlikely), the PTE page tables to hold the shared
      zeropage entries can consume quite some memory that cannot be reclaimed
      easily.
      
      Third, there are other optimizations+features (e.g., protection of
      unplugged memory, reducing the total memory slot size and bitmap sizes)
      that will require VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE.
      
      We really only support x86 targets with virtio-mem for now (and
      Linux similarly only support x86), but that might change soon, so prepare
      for different targets already.
      
      Add a new "unplugged-inaccessible" tristate property for x86 targets:
      - "off" will keep VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE unset and legacy
        guests working.
      - "on" will set VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE and stop legacy guests
        from using the device.
      - "auto" selects the default based on support for the shared zeropage.
      
      Warn in case the property is set to "off" and we don't have support for the
      shared zeropage.
      
      For existing compat machines, the property will default to "off", to
      not change the behavior but eventually warn about a problematic setup.
      Short-term, we'll set the property default to "auto" for new QEMU machines.
      Mid-term, we'll set the property default to "on" for new QEMU machines.
      Long-term, we'll deprecate the parameter and disallow legacy
      guests completely.
      
      The property has to match on the migration source and destination. "auto"
      will result in the same VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE setting as long
      as the qemu command line (esp. memdev) match -- so "auto" is good enough
      for migration purposes and the parameter doesn't have to be migrated
      explicitly.
      
      Reviewed-by: default avatarMichal Privoznik <mprivozn@redhat.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Message-Id: <20211217134039.29670-3-david@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      23ad8dec
    • David Hildenbrand's avatar
      linux-headers: sync VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE · 3ff9b192
      David Hildenbrand authored
      
      Let's synchronize the new feature flag, available in Linux since
      v5.16-rc1.
      
      Reviewed-by: default avatarMichal Privoznik <mprivozn@redhat.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Message-Id: <20211217134039.29670-2-david@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      3ff9b192
    • Ani Sinha's avatar
      MAINTAINERS: Add a separate entry for acpi/VIOT tables · d135536d
      Ani Sinha authored
      
      All work related to VIOT tables are being done by Jean. Adding him as the
      maintainer for acpi VIOT table code in qemu.
      
      Signed-off-by: default avatarAni Sinha <ani@anisinha.ca>
      Message-Id: <20211213045924.344214-1-ani@anisinha.ca>
      Acked-by: default avatarJean-Philippe Brucker <jean-philippe@linaro.org>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      d135536d
    • Stefan Hajnoczi's avatar
      virtio: signal after wrapping packed used_idx · 750539c4
      Stefan Hajnoczi authored
      
      Packed Virtqueues wrap used_idx instead of letting it run freely like
      Split Virtqueues do. If the used ring wraps more than once there is no
      way to compare vq->signalled_used and vq->used_idx in
      virtio_packed_should_notify() since they are modulo vq->vring.num.
      
      This causes the device to stop sending used buffer notifications when
      when virtio_packed_should_notify() is called less than once each time
      around the used ring.
      
      It is possible to trigger this with virtio-blk's dataplane
      notify_guest_bh() irq coalescing optimization. The call to
      virtio_notify_irqfd() (and virtio_packed_should_notify()) is deferred to
      a BH. If the guest driver is polling it can complete and submit more
      requests before the BH executes, causing the used ring to wrap more than
      once. The result is that the virtio-blk device ceases to raise
      interrupts and I/O hangs.
      
      Cc: Tiwei Bie <tiwei.bie@intel.com>
      Cc: Jason Wang <jasowang@redhat.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Message-Id: <20211130134510.267382-1-stefanha@redhat.com>
      Fixes: 86044b24 ("virtio: basic packed virtqueue support")
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      750539c4
    • David Hildenbrand's avatar
      virtio-mem: Support "prealloc=on" option · 09b3b7e0
      David Hildenbrand authored
      
      For scarce memory resources, such as hugetlb, we want to be able to
      prealloc such memory resources in order to not crash later on access. On
      simple user errors we could otherwise easily run out of memory resources
      an crash the VM -- pretty much undesired.
      
      For ordinary memory devices, such as DIMMs, we preallocate memory via the
      memory backend for such use cases; however, with virtio-mem we're dealing
      with sparse memory backends; preallocating the whole memory backend
      destroys the whole purpose of virtio-mem.
      
      Instead, we want to preallocate memory when actually exposing memory to the
      VM dynamically, and fail plugging memory gracefully + warn the user in case
      preallocation fails.
      
      A common use case for hugetlb will be using "reserve=off,prealloc=off" for
      the memory backend and "prealloc=on" for the virtio-mem device. This
      way, no huge pages will be reserved for the process, but we can recover
      if there are no actual huge pages when plugging memory. Libvirt is
      already prepared for this.
      
      Note that preallocation cannot protect from the OOM killer -- which
      holds true for any kind of preallocation in QEMU. It's primarily useful
      only for scarce memory resources such as hugetlb, or shared file-backed
      memory. It's of little use for ordinary anonymous memory that can be
      swapped, KSM merged, ... but we won't forbid it.
      
      Reviewed-by: default avatarMichal Privoznik <mprivozn@redhat.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Message-Id: <20211217134611.31172-9-david@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      09b3b7e0
Loading