From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530216464649957.9094288303129; Thu, 28 Jun 2018 13:07:44 -0700 (PDT) Received: from localhost ([::1]:38290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdCf-0000MR-Le for importer@patchew.org; Thu, 28 Jun 2018 16:07:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAM-00072d-OW for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAK-0008NM-C3 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:18 -0400 Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]:32829) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAK-0008Lm-1B for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:16 -0400 Received: by mail-wr0-x231.google.com with SMTP id k7-v6so3188824wrq.0 for ; Thu, 28 Jun 2018 13:05:15 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=wMlfOQHFDxi+nN5eTRbhhKF/fvLQk/+6e3NvTS/+AaI=; b=lZbjP6Y7G0TlZwbk/GgA0mwVi4+RXw8Yvc6BIzFSjTKfMut7N8+CZf6ix8Scr1cF4T T/4qFK795Cr4E7bHiYReg1vEe+2EyMJo1Bt6Ix6nfiOIElDbznQpVg53gfnNfVMbSB5h vB9ZBtdz6z1hMVUf/Fd1OSngalqe4dIIU5+FdRkKM8URRmnDF2nAiiRZ/rZ/hpMUU9ch lOcFlLf85SLkZLjRqV2y8nKWqncONlilhdmor7Fqg33smLf6r3G9F3p7YP7KdaGBwTnT pDE13KcKzNSR94CB0MgadnjEPxLMZ3nA0tx0Kuy3JIAcnVybgUjGZx960BdxSD2kD4jt WtJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=wMlfOQHFDxi+nN5eTRbhhKF/fvLQk/+6e3NvTS/+AaI=; b=kKbJ6zyqVoY9016PM1VZQK25jPGFUw5zqaX05+NNlu7zPuur7EQ+8/qGeSm0Z9F5mn FVyi7MKdz4ABcm4Bh6mD5i6OaWqY30GWlda/h3SfojvMVmgFXhz+oTwKfE+U71Jv+4Ap x695BDqYWgyV34EY/ecSA/onr8XnuTESyMEL9WObViop+DG/xqeskqklXUrApQLQwOSz lEGkKdaooCy1LJJPudL/CQcCXRajCarlq82zUwIi3n8GFARkHhe8o6wDfKnXlVYZ+IWO 3Hgp8bQsuodz0CJzPCQlV2tQ9Lq2rzy03Ugco50oqCZWKOhXtWr3Yn8CXbyUuMWeLnLT SypA== X-Gm-Message-State: APt69E0q/fEevikjSnXn+8xQE49KD9LG3VEF/t3+n01xcyqb1XSN6MFh pJCjYT76nmNH2DbwRFxnERt9xMpm X-Google-Smtp-Source: AAOMgpdNZLIzJLl9acRR+xhb9zpHqk1x18mi4p0pTBLJ0CDe+B575eDVSMM1sfRafQUdD56AQIc+fg== X-Received: by 2002:adf:9736:: with SMTP id r51-v6mr9612670wrb.5.1530216314619; Thu, 28 Jun 2018 13:05:14 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:11 +0200 Message-Id: <1530216310-52873-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::231 Subject: [Qemu-devel] [PULL 01/60] exec: Fix MAP_RAM for cached access X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Auger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Auger When an IOMMUMemoryRegion is in front of a virtio device, address_space_cache_init does not set cache->ptr as the memory region is not RAM. However when the device performs an access, we end up in glue() which performs the translation and then uses MAP_RAM. This latter uses the unset ptr and returns a wrong value which leads to a SIGSEV in address_space_lduw_internal_cached_slow, for instance. In slow path cache->ptr is NULL and MAP_RAM must redirect to qemu_map_ram_ptr((mr)->ram_block, ofs). As MAP_RAM, IS_DIRECT and INVALIDATE are the same in _cached_slow and non cached mode, let's remove those macros. This fixes the use cases featuring vIOMMU (Intel and ARM SMMU) which lead to a SIGSEV. Fixes: 48564041a73a (exec: reintroduce MemoryRegion caching) Signed-off-by: Eric Auger Message-Id: <1528895946-28677-1-git-send-email-eric.auger@redhat.com> Signed-off-by: Paolo Bonzini --- exec.c | 6 ------ memory_ldst.inc.c | 47 ++++++++++++++++++++++------------------------- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/exec.c b/exec.c index 1e37f75..9f35e34 100644 --- a/exec.c +++ b/exec.c @@ -3702,9 +3702,6 @@ void cpu_physical_memory_unmap(void *buffer, hwaddr l= en, #define ARG1 as #define SUFFIX #define TRANSLATE(...) address_space_translate(as, __VA_ARGS__) -#define IS_DIRECT(mr, is_write) memory_access_is_direct(mr, is_write) -#define MAP_RAM(mr, ofs) qemu_map_ram_ptr((mr)->ram_block, ofs) -#define INVALIDATE(mr, ofs, len) invalidate_and_set_dirty(mr, ofs, len) #define RCU_READ_LOCK(...) rcu_read_lock() #define RCU_READ_UNLOCK(...) rcu_read_unlock() #include "memory_ldst.inc.c" @@ -3841,9 +3838,6 @@ address_space_write_cached_slow(MemoryRegionCache *ca= che, hwaddr addr, #define ARG1 cache #define SUFFIX _cached_slow #define TRANSLATE(...) address_space_translate_cached(cache, __V= A_ARGS__) -#define IS_DIRECT(mr, is_write) memory_access_is_direct(mr, is_write) -#define MAP_RAM(mr, ofs) (cache->ptr + (ofs - cache->xlat)) -#define INVALIDATE(mr, ofs, len) invalidate_and_set_dirty(mr, ofs, len) #define RCU_READ_LOCK() ((void)0) #define RCU_READ_UNLOCK() ((void)0) #include "memory_ldst.inc.c" diff --git a/memory_ldst.inc.c b/memory_ldst.inc.c index 1548398..acf865b 100644 --- a/memory_ldst.inc.c +++ b/memory_ldst.inc.c @@ -34,7 +34,7 @@ static inline uint32_t glue(address_space_ldl_internal, S= UFFIX)(ARG1_DECL, =20 RCU_READ_LOCK(); mr =3D TRANSLATE(addr, &addr1, &l, false, attrs); - if (l < 4 || !IS_DIRECT(mr, false)) { + if (l < 4 || !memory_access_is_direct(mr, false)) { release_lock |=3D prepare_mmio_access(mr); =20 /* I/O case */ @@ -50,7 +50,7 @@ static inline uint32_t glue(address_space_ldl_internal, S= UFFIX)(ARG1_DECL, #endif } else { /* RAM case */ - ptr =3D MAP_RAM(mr, addr1); + ptr =3D qemu_map_ram_ptr(mr->ram_block, addr1); switch (endian) { case DEVICE_LITTLE_ENDIAN: val =3D ldl_le_p(ptr); @@ -110,7 +110,7 @@ static inline uint64_t glue(address_space_ldq_internal,= SUFFIX)(ARG1_DECL, =20 RCU_READ_LOCK(); mr =3D TRANSLATE(addr, &addr1, &l, false, attrs); - if (l < 8 || !IS_DIRECT(mr, false)) { + if (l < 8 || !memory_access_is_direct(mr, false)) { release_lock |=3D prepare_mmio_access(mr); =20 /* I/O case */ @@ -126,7 +126,7 @@ static inline uint64_t glue(address_space_ldq_internal,= SUFFIX)(ARG1_DECL, #endif } else { /* RAM case */ - ptr =3D MAP_RAM(mr, addr1); + ptr =3D qemu_map_ram_ptr(mr->ram_block, addr1); switch (endian) { case DEVICE_LITTLE_ENDIAN: val =3D ldq_le_p(ptr); @@ -184,14 +184,14 @@ uint32_t glue(address_space_ldub, SUFFIX)(ARG1_DECL, =20 RCU_READ_LOCK(); mr =3D TRANSLATE(addr, &addr1, &l, false, attrs); - if (!IS_DIRECT(mr, false)) { + if (!memory_access_is_direct(mr, false)) { release_lock |=3D prepare_mmio_access(mr); =20 /* I/O case */ r =3D memory_region_dispatch_read(mr, addr1, &val, 1, attrs); } else { /* RAM case */ - ptr =3D MAP_RAM(mr, addr1); + ptr =3D qemu_map_ram_ptr(mr->ram_block, addr1); val =3D ldub_p(ptr); r =3D MEMTX_OK; } @@ -220,7 +220,7 @@ static inline uint32_t glue(address_space_lduw_internal= , SUFFIX)(ARG1_DECL, =20 RCU_READ_LOCK(); mr =3D TRANSLATE(addr, &addr1, &l, false, attrs); - if (l < 2 || !IS_DIRECT(mr, false)) { + if (l < 2 || !memory_access_is_direct(mr, false)) { release_lock |=3D prepare_mmio_access(mr); =20 /* I/O case */ @@ -236,7 +236,7 @@ static inline uint32_t glue(address_space_lduw_internal= , SUFFIX)(ARG1_DECL, #endif } else { /* RAM case */ - ptr =3D MAP_RAM(mr, addr1); + ptr =3D qemu_map_ram_ptr(mr->ram_block, addr1); switch (endian) { case DEVICE_LITTLE_ENDIAN: val =3D lduw_le_p(ptr); @@ -297,12 +297,12 @@ void glue(address_space_stl_notdirty, SUFFIX)(ARG1_DE= CL, =20 RCU_READ_LOCK(); mr =3D TRANSLATE(addr, &addr1, &l, true, attrs); - if (l < 4 || !IS_DIRECT(mr, true)) { + if (l < 4 || !memory_access_is_direct(mr, true)) { release_lock |=3D prepare_mmio_access(mr); =20 r =3D memory_region_dispatch_write(mr, addr1, val, 4, attrs); } else { - ptr =3D MAP_RAM(mr, addr1); + ptr =3D qemu_map_ram_ptr(mr->ram_block, addr1); stl_p(ptr, val); =20 dirty_log_mask =3D memory_region_get_dirty_log_mask(mr); @@ -334,7 +334,7 @@ static inline void glue(address_space_stl_internal, SUF= FIX)(ARG1_DECL, =20 RCU_READ_LOCK(); mr =3D TRANSLATE(addr, &addr1, &l, true, attrs); - if (l < 4 || !IS_DIRECT(mr, true)) { + if (l < 4 || !memory_access_is_direct(mr, true)) { release_lock |=3D prepare_mmio_access(mr); =20 #if defined(TARGET_WORDS_BIGENDIAN) @@ -349,7 +349,7 @@ static inline void glue(address_space_stl_internal, SUF= FIX)(ARG1_DECL, r =3D memory_region_dispatch_write(mr, addr1, val, 4, attrs); } else { /* RAM case */ - ptr =3D MAP_RAM(mr, addr1); + ptr =3D qemu_map_ram_ptr(mr->ram_block, addr1); switch (endian) { case DEVICE_LITTLE_ENDIAN: stl_le_p(ptr, val); @@ -361,7 +361,7 @@ static inline void glue(address_space_stl_internal, SUF= FIX)(ARG1_DECL, stl_p(ptr, val); break; } - INVALIDATE(mr, addr1, 4); + invalidate_and_set_dirty(mr, addr1, 4); r =3D MEMTX_OK; } if (result) { @@ -406,14 +406,14 @@ void glue(address_space_stb, SUFFIX)(ARG1_DECL, =20 RCU_READ_LOCK(); mr =3D TRANSLATE(addr, &addr1, &l, true, attrs); - if (!IS_DIRECT(mr, true)) { + if (!memory_access_is_direct(mr, true)) { release_lock |=3D prepare_mmio_access(mr); r =3D memory_region_dispatch_write(mr, addr1, val, 1, attrs); } else { /* RAM case */ - ptr =3D MAP_RAM(mr, addr1); + ptr =3D qemu_map_ram_ptr(mr->ram_block, addr1); stb_p(ptr, val); - INVALIDATE(mr, addr1, 1); + invalidate_and_set_dirty(mr, addr1, 1); r =3D MEMTX_OK; } if (result) { @@ -439,7 +439,7 @@ static inline void glue(address_space_stw_internal, SUF= FIX)(ARG1_DECL, =20 RCU_READ_LOCK(); mr =3D TRANSLATE(addr, &addr1, &l, true, attrs); - if (l < 2 || !IS_DIRECT(mr, true)) { + if (l < 2 || !memory_access_is_direct(mr, true)) { release_lock |=3D prepare_mmio_access(mr); =20 #if defined(TARGET_WORDS_BIGENDIAN) @@ -454,7 +454,7 @@ static inline void glue(address_space_stw_internal, SUF= FIX)(ARG1_DECL, r =3D memory_region_dispatch_write(mr, addr1, val, 2, attrs); } else { /* RAM case */ - ptr =3D MAP_RAM(mr, addr1); + ptr =3D qemu_map_ram_ptr(mr->ram_block, addr1); switch (endian) { case DEVICE_LITTLE_ENDIAN: stw_le_p(ptr, val); @@ -466,7 +466,7 @@ static inline void glue(address_space_stw_internal, SUF= FIX)(ARG1_DECL, stw_p(ptr, val); break; } - INVALIDATE(mr, addr1, 2); + invalidate_and_set_dirty(mr, addr1, 2); r =3D MEMTX_OK; } if (result) { @@ -512,7 +512,7 @@ static void glue(address_space_stq_internal, SUFFIX)(AR= G1_DECL, =20 RCU_READ_LOCK(); mr =3D TRANSLATE(addr, &addr1, &l, true, attrs); - if (l < 8 || !IS_DIRECT(mr, true)) { + if (l < 8 || !memory_access_is_direct(mr, true)) { release_lock |=3D prepare_mmio_access(mr); =20 #if defined(TARGET_WORDS_BIGENDIAN) @@ -527,7 +527,7 @@ static void glue(address_space_stq_internal, SUFFIX)(AR= G1_DECL, r =3D memory_region_dispatch_write(mr, addr1, val, 8, attrs); } else { /* RAM case */ - ptr =3D MAP_RAM(mr, addr1); + ptr =3D qemu_map_ram_ptr(mr->ram_block, addr1); switch (endian) { case DEVICE_LITTLE_ENDIAN: stq_le_p(ptr, val); @@ -539,7 +539,7 @@ static void glue(address_space_stq_internal, SUFFIX)(AR= G1_DECL, stq_p(ptr, val); break; } - INVALIDATE(mr, addr1, 8); + invalidate_and_set_dirty(mr, addr1, 8); r =3D MEMTX_OK; } if (result) { @@ -576,8 +576,5 @@ void glue(address_space_stq_be, SUFFIX)(ARG1_DECL, #undef ARG1 #undef SUFFIX #undef TRANSLATE -#undef IS_DIRECT -#undef MAP_RAM -#undef INVALIDATE #undef RCU_READ_LOCK #undef RCU_READ_UNLOCK --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530216466710350.69976268887956; Thu, 28 Jun 2018 13:07:46 -0700 (PDT) Received: from localhost ([::1]:38291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdCj-0000Qq-Rc for importer@patchew.org; Thu, 28 Jun 2018 16:07:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAN-00072q-4v for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAL-0008QF-KL for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:19 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:42434) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAK-0008NG-Ux for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:17 -0400 Received: by mail-wr0-x244.google.com with SMTP id p1-v6so6688307wrs.9 for ; Thu, 28 Jun 2018 13:05:16 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=7PCO3sY0LVrkJV5WwF/ERjzZGwttHSuUxDPbGD8p85E=; b=YT+5rq8AC25SQs9Uq6EYID1rCTdQXij4E2daZ5IdjyPaWY7u7JlatxzLCn3osqhz/U SUSfTAShNH7siok7nwAuWRTPaz/BHdwh3B+cONv6Ubzzea2cw2ygAWcBn2dYpCUZxpxD 2iRS1JjhFrqCnX8zA7TqtzqdINEDNLi1nFxS0i98/M8EopCkF4dtoxlakB0mhRaD8Hod 3Tnsz2dkaZWLoy0+wh4EhMEnDt9WBT1R0S3/fr4hEQxHRJUQUdM+BnRbTPt+8wEnfMMy vPNjL8096d6Hlf9rnxpoyEww4njgSFW5x7Xk0iCkAeM90kIUmqiu5h7cTBxOna87vQUh 8FwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=7PCO3sY0LVrkJV5WwF/ERjzZGwttHSuUxDPbGD8p85E=; b=gLHthey4Zzl8XXwOAa753erpQmxqNw+LVrVKUQyU4QPw5WzRFYitBqw/YDWhLZzMEm rmm9vOtil9ZJr6y3uhh/BSeVgKC3x5Q86KfNIFBRdiGmszDql8Yze1L73WTbyBFjhEKc ozu3oakDkY766GS7RmrybhMHfQ65uzJ0Hbsu4i2H9UsZx7q3kXxQzCONQ9jHbSRo3p/N EmaXRfXyn8cdB4orZ1waHpIOI18nv8cXLX7HIcaA60f4qFy2o4bNtQ0WVbSN36+K/96D Gg55tannxk9FjFfAWB0Nc1vhqgK3B1YjrL6h2JYg03Ke2lQ39V78DebbUZg7Ko/W2zSl AHtA== X-Gm-Message-State: APt69E1o58MMS9eI0LLUN8duSlLVCtvu/muxhUD5j0jPBWsb+vC/EW+5 kQI0vvMEnOolV8Sxwd17in9qKyZ/ X-Google-Smtp-Source: AAOMgpe8Ij9mtyn5HAe74ZMynX4HPYYlu7Wwq30EQuUA9NdQp7IGwuRPHQrCbsLqzf8GhawSIta38g== X-Received: by 2002:a5d:428a:: with SMTP id k10-v6mr6085394wrq.225.1530216315581; Thu, 28 Jun 2018 13:05:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:12 +0200 Message-Id: <1530216310-52873-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PULL 02/60] move public invalidate APIs out of translate-all.{c, h}, clean up X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Place them in exec.c, exec-all.h and ram_addr.h. This removes knowledge of translate-all.h (which is an internal header) from several files outside accel/tcg and removes knowledge of AddressSpace from translate-all.c (as it only operates on ram_addr_t). Signed-off-by: Paolo Bonzini --- accel/tcg/translate-all.c | 28 ++++++---------------------- accel/tcg/translate-all.h | 1 - exec.c | 29 +++++++++++++++++++++++++---- include/exec/exec-all.h | 8 ++++---- include/exec/ram_addr.h | 2 ++ linux-user/mmap.c | 1 - target/xtensa/op_helper.c | 9 +-------- trace/control-target.c | 1 - 8 files changed, 38 insertions(+), 41 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index f0c3fd4..4b601bd 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -46,7 +46,7 @@ #endif #endif #else -#include "exec/address-spaces.h" +#include "exec/ram_addr.h" #endif =20 #include "exec/cputlb.h" @@ -1934,7 +1934,11 @@ void tb_invalidate_phys_page_range(tb_page_addr_t st= art, tb_page_addr_t end, * * Called with mmap_lock held for user-mode emulation. */ -void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end) +#ifdef CONFIG_SOFTMMU +void tb_invalidate_phys_range(ram_addr_t start, ram_addr_t end) +#else +void tb_invalidate_phys_range(target_ulong start, target_ulong end) +#endif { struct page_collection *pages; tb_page_addr_t next; @@ -2073,26 +2077,6 @@ static bool tb_invalidate_phys_page(tb_page_addr_t a= ddr, uintptr_t pc) } #endif =20 -#if !defined(CONFIG_USER_ONLY) -void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs att= rs) -{ - ram_addr_t ram_addr; - MemoryRegion *mr; - hwaddr l =3D 1; - - rcu_read_lock(); - mr =3D address_space_translate(as, addr, &addr, &l, false, attrs); - if (!(memory_region_is_ram(mr) - || memory_region_is_romd(mr))) { - rcu_read_unlock(); - return; - } - ram_addr =3D memory_region_get_ram_addr(mr) + addr; - tb_invalidate_phys_page_range(ram_addr, ram_addr + 1, 0); - rcu_read_unlock(); -} -#endif /* !defined(CONFIG_USER_ONLY) */ - /* user-mode: call with mmap_lock held */ void tb_check_watchpoint(CPUState *cpu) { diff --git a/accel/tcg/translate-all.h b/accel/tcg/translate-all.h index e6cb963..08e2f23 100644 --- a/accel/tcg/translate-all.h +++ b/accel/tcg/translate-all.h @@ -30,7 +30,6 @@ void tb_invalidate_phys_page_fast(struct page_collection = *pages, tb_page_addr_t start, int len); void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t en= d, int is_cpu_write_access); -void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end); void tb_check_watchpoint(CPUState *cpu); =20 #ifdef CONFIG_USER_ONLY diff --git a/exec.c b/exec.c index 9f35e34..610d0c0 100644 --- a/exec.c +++ b/exec.c @@ -1028,13 +1028,36 @@ const char *parse_cpu_model(const char *cpu_model) } =20 #if defined(CONFIG_USER_ONLY) -static void breakpoint_invalidate(CPUState *cpu, target_ulong pc) +void tb_invalidate_phys_addr(target_ulong addr) { mmap_lock(); - tb_invalidate_phys_page_range(pc, pc + 1, 0); + tb_invalidate_phys_page_range(addr, addr + 1, 0); mmap_unlock(); } + +static void breakpoint_invalidate(CPUState *cpu, target_ulong pc) +{ + tb_invalidate_phys_addr(pc); +} #else +void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs att= rs) +{ + ram_addr_t ram_addr; + MemoryRegion *mr; + hwaddr l =3D 1; + + rcu_read_lock(); + mr =3D address_space_translate(as, addr, &addr, &l, false, attrs); + if (!(memory_region_is_ram(mr) + || memory_region_is_romd(mr))) { + rcu_read_unlock(); + return; + } + ram_addr =3D memory_region_get_ram_addr(mr) + addr; + tb_invalidate_phys_page_range(ram_addr, ram_addr + 1, 0); + rcu_read_unlock(); +} + static void breakpoint_invalidate(CPUState *cpu, target_ulong pc) { MemTxAttrs attrs; @@ -3146,9 +3169,7 @@ static void invalidate_and_set_dirty(MemoryRegion *mr= , hwaddr addr, } if (dirty_log_mask & (1 << DIRTY_MEMORY_CODE)) { assert(tcg_enabled()); - mmap_lock(); tb_invalidate_phys_range(addr, addr + length); - mmap_unlock(); dirty_log_mask &=3D ~(1 << DIRTY_MEMORY_CODE); } cpu_physical_memory_set_dirty_range(addr, length, dirty_log_mask); diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 25a6f28..6a7e7a8 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -299,14 +299,14 @@ static inline void tlb_flush_page_by_mmuidx_all_cpus_= synced(CPUState *cpu, static inline void tlb_flush_by_mmuidx_all_cpus(CPUState *cpu, uint16_t id= xmap) { } + static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, uint16_t idxmap) { } -static inline void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, - MemTxAttrs attrs) -{ -} + +void tb_invalidate_phys_addr(target_ulong addr); +void tb_invalidate_phys_range(target_ulong start, target_ulong end); #endif =20 #define CODE_GEN_ALIGN 16 /* must be >=3D of the size of a icach= e line */ diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 33c361c..cf4ce06 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -93,6 +93,8 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, = Error **errp); #define DIRTY_CLIENTS_ALL ((1 << DIRTY_MEMORY_NUM) - 1) #define DIRTY_CLIENTS_NOCODE (DIRTY_CLIENTS_ALL & ~(1 << DIRTY_MEMORY_COD= E)) =20 +void tb_invalidate_phys_range(ram_addr_t start, ram_addr_t end); + static inline bool cpu_physical_memory_get_dirty(ram_addr_t start, ram_addr_t length, unsigned client) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 9168a20..d0c50e4 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -20,7 +20,6 @@ =20 #include "qemu.h" #include "qemu-common.h" -#include "translate-all.h" =20 //#define DEBUG_MMAP =20 diff --git a/target/xtensa/op_helper.c b/target/xtensa/op_helper.c index 8a8c763..bbbbb33 100644 --- a/target/xtensa/op_helper.c +++ b/target/xtensa/op_helper.c @@ -36,11 +36,6 @@ #include "qemu/timer.h" #include "fpu/softfloat.h" =20 -#ifdef CONFIG_USER_ONLY -/* tb_invalidate_phys_range */ -#include "accel/tcg/translate-all.h" -#endif - #ifndef CONFIG_USER_ONLY =20 void xtensa_cpu_do_unaligned_access(CPUState *cs, @@ -114,9 +109,7 @@ static void tb_invalidate_virtual_addr(CPUXtensaState *= env, uint32_t vaddr) =20 static void tb_invalidate_virtual_addr(CPUXtensaState *env, uint32_t vaddr) { - mmap_lock(); - tb_invalidate_phys_range(vaddr, vaddr + 1); - mmap_unlock(); + tb_invalidate_phys_addr(vaddr); } =20 #endif diff --git a/trace/control-target.c b/trace/control-target.c index 706b2ce..ceb55c7 100644 --- a/trace/control-target.c +++ b/trace/control-target.c @@ -11,7 +11,6 @@ #include "cpu.h" #include "trace-root.h" #include "trace/control.h" -#include "translate-all.h" =20 =20 void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state) --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530216635698542.5974184557381; Thu, 28 Jun 2018 13:10:35 -0700 (PDT) Received: from localhost ([::1]:38302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdFS-0002tr-TY for importer@patchew.org; Thu, 28 Jun 2018 16:10:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAN-00072v-8i for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAL-0008Qk-VB for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:19 -0400 Received: from mail-wr0-x229.google.com ([2a00:1450:400c:c0c::229]:41886) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAL-0008Ou-NS for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:17 -0400 Received: by mail-wr0-x229.google.com with SMTP id h10-v6so6671295wrq.8 for ; Thu, 28 Jun 2018 13:05:17 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=peiX5D+2uTI2Rlhwxu4ElB3MlS7Zl1y5IQCbsU37Vbc=; b=ufuTywwoRPDTCRqZykFB1yyP5IaaDlUpplpf6oXhw63guNDjflE+88byPVunp5in4G dtLPLU14BKya7AnCxFeqnB5LB3XMnulZJQHM9VxxerYa6LFJsTsG60Ohf+I3NFvKGHJb 1n52WIO5YTowydJLiUB47JEv3EoWgEyFGdQrYm0gYOBw7T3OSQEOUuGcpj9nP8c0+MhF jsg89yLZsUR8C/yP8p5ZYqlysEnNkXMcibGyzQ8FWSLMid5GHghmQRQjw6uVPxqvrkv6 Ar6hiphRKyA6hniR+mP4eMudXAa3kPBVfUM3e3S3eY4uMlUhnlThSmShUDktyVasBLEN hx+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=peiX5D+2uTI2Rlhwxu4ElB3MlS7Zl1y5IQCbsU37Vbc=; b=JAGDzrECCTnnv/tFQI0ibSvuBJPqEIpqQqA0i5bvhVuwrB/CgLf1BSkI1dlyfjMzMb FTLDAR4S5F8Qi+xTL6zqcv11WlpOhSWapURgbxwu5OfMWpJkhplHTNhc/olcCTgfjaV+ M3bfUsL2QhdqVSGAYGXNcPz4TDAO4ztrK2F8Et35vhaT6Ax5mW9o4Y0UvAl1XzkFGeh/ znG3PVruEASTlblQ8cocc4tOBm03UtDkTcGgLGCzwzhACEkS63L7AoO+vz4MZCYdRSfY KVdwVao2T5N9H0UhYrvlEInotyny1vxCTt7Mf22+LK28XUIWgepGNEH+YynYOXYEf2bl BmQQ== X-Gm-Message-State: APt69E20HkV8HwD6dAtpK1cqIzqIZlXD7LXNiOYcYS5hQJYqxrfEuZUa zxVOudpd8IDHyPW5If8XWbOBuAGr X-Google-Smtp-Source: AAOMgpc8Nl4F6gnAzb9SF47KS7BalRfsfi2MIIKap4BFsfLyivqdmb294y04Foz5zYlpaDM9SkZByQ== X-Received: by 2002:adf:fe46:: with SMTP id m6-v6mr9566922wrs.171.1530216316422; Thu, 28 Jun 2018 13:05:16 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:13 +0200 Message-Id: <1530216310-52873-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::229 Subject: [Qemu-devel] [PULL 03/60] chardev: don't splatter terminal settings on exit if not previously set X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Daniel P. Berrang=C3=A9 The stdio chardev finalize method calls term_exit() to restore the original terminal settings that were saved in the "oldtty" global. If the qemu_chr_open_stdio() method exited with an error, we might not have any original terminal settings saved in "oldtty" yet. eg $ qemu-system-x86_64 -monitor stdio -daemonize qemu-system-x86_64: -monitor stdio: cannot use stdio with -daemonize will cause QEMU to splatter the terminal settings with an all-zeros "struct termios", with predictably unpleasant results. Fortunately the existing "stdio_in_use" flag is suitable witness for whether "oldtty" contains settings that need restoring. Signed-off-by: Daniel P. Berrang=C3=A9 Message-Id: <20180604123043.13985-1-berrange@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- chardev/char-stdio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chardev/char-stdio.c b/chardev/char-stdio.c index 96375f2..9624220 100644 --- a/chardev/char-stdio.c +++ b/chardev/char-stdio.c @@ -46,8 +46,10 @@ static bool stdio_echo_state; =20 static void term_exit(void) { - tcsetattr(0, TCSANOW, &oldtty); - fcntl(0, F_SETFL, old_fd0_flags); + if (stdio_in_use) { + tcsetattr(0, TCSANOW, &oldtty); + fcntl(0, F_SETFL, old_fd0_flags); + } } =20 static void qemu_chr_set_echo_stdio(Chardev *chr, bool echo) --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530216524453757.4383980734164; Thu, 28 Jun 2018 13:08:44 -0700 (PDT) Received: from localhost ([::1]:38292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdDf-0001Gb-Kd for importer@patchew.org; Thu, 28 Jun 2018 16:08:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAO-00073O-5D for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAN-0008UK-4S for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:20 -0400 Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]:46757) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAM-0008R8-MZ for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:19 -0400 Received: by mail-wr0-x231.google.com with SMTP id t6-v6so6664887wrq.13 for ; Thu, 28 Jun 2018 13:05:18 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4zBDUnudCImQV0crNK+0EvzSB+zVFH0eZEvdtpweepI=; b=tLmeJR5TfKvZGaqy3sASSul3Zv9ZGPql/FTfGMetM4sry1JtldqVFXvA8k96G5/ElG Nu/NGwuviHS6xGuoP+gU7EfmkhqymAvzpPASxqHzuV/UZnS9Kh6bIrocEN0Z3Wi8WxkH 5/VSuhxgNqIWfnD2YYIdEiCzle8uVAlRSFe5diFk6tgOtLlng9mDkO2cUxWbaTEvOsic JHVYSgGkLg+v+GQkPBuUqY6aRtK9IflmwbA5cB4YcM+G7/xic+QHRnJHimLYs47VnT+y UONMDcABn72hLId69nCUREEJI4OmQy5ypNF43+yf6WcONPTCpJfOaB1Agv8Yfj+04TdT LTaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=4zBDUnudCImQV0crNK+0EvzSB+zVFH0eZEvdtpweepI=; b=fFl5NmKcaHNK+7QsZ0+uNvE8ZP8eTZGyy/138zN/eBa64ZSEH4gw1bbHPXvXC0zo3o 1hbD1cA9Lifs2bgTCgd9BuBqshUTmrRq8fZpEumoBnFNyx8UDWduBP2LAf4B3DsOZBlm Bk9ML9wG7jTQ3mK2wbEHZEn3REgmT4yhnrkB8pfwqzaj1S5ua79MIoXJdUeki3ZkgdHx c/m5u9c/iLL3zMwfvzAKjcRg2dlMnzvDeMthwND/REqukXeNrddVi/KW5mEzqeN1sJ0D b7P08fCmJNC4QsM+J65I/ujRgjPDut1nrbkVmK9sZpgaHTPXLVOM1OhQ4MucN5Hf0Qx/ 1MSg== X-Gm-Message-State: APt69E0WgkhORp40fOVA7rt7R2W64swr5j6Ji9mqwziWKPhq4szxBE3G ATJOa0hcB+wgBj7nrkCLUO6k+9Rr X-Google-Smtp-Source: AAOMgpdpo7beaya0Lt7nLzf1WyifPjQclvWq2iylT6H525QXLrbyvrjW6goctDWFABKW++ENk8QGPA== X-Received: by 2002:adf:c301:: with SMTP id n1-v6mr10278300wrf.270.1530216317360; Thu, 28 Jun 2018 13:05:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:14 +0200 Message-Id: <1530216310-52873-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::231 Subject: [Qemu-devel] [PULL 04/60] main-loop: document IOCanReadHandler X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi Message-Id: <20180602085259.17853-1-stefanha@redhat.com> Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/main-loop.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index 6b4b60b..721aa24 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -168,6 +168,20 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFun= c *func, void *opaque); /* async I/O support */ =20 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); + +/** + * IOCanReadHandler: Return the number of bytes that #IOReadHandler can ac= cept + * + * This function reports how many bytes #IOReadHandler is prepared to acce= pt. + * #IOReadHandler may be invoked with up to this number of bytes. If this + * function returns 0 then #IOReadHandler is not invoked. + * + * This function is typically called from an event loop. If the number of + * bytes changes outside the event loop (e.g. because a vcpu thread draine= d the + * buffer), then it is necessary to kick the event loop so that this funct= ion + * is called again. aio_notify() or qemu_notify_event() can be used to ki= ck + * the event loop. + */ typedef int IOCanReadHandler(void *opaque); =20 /** --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530216802888438.6388574516426; Thu, 28 Jun 2018 13:13:22 -0700 (PDT) Received: from localhost ([::1]:38319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdIA-0005Ff-2v for importer@patchew.org; Thu, 28 Jun 2018 16:13:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAP-00074B-9s for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAN-0008WR-Qq for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:21 -0400 Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]:35373) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAN-0008Tv-KM for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:19 -0400 Received: by mail-wr0-x231.google.com with SMTP id c13-v6so6679841wrq.2 for ; Thu, 28 Jun 2018 13:05:19 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Lq15VOsfqpHpPD+9CIPW7Xgd9tFBt5Of95lOEI4j25w=; b=DScNkTIb1REnwH+iT+6KNgldf4X/lvDnXrOPEOATi8zDotWsD3+wIq3H7gc9NeRsXJ RQsRzqGChoKaCGfxM0SuL+Bh970ws+aNAXF7CWu8mihQUbHcjybCV9oca2vdORN05xXD TaPdW/4H8CNx6VdMtiAAZmyBuvNesDtTTQMN7/r0pyn1AvTsGvFkjcNQJLJ5rX0B3/jm 3nF+yJTjyqiR5KpU/xhPyyeLSCwj3AkCfBSMR8MWW/hRZoTP9zyShrHkIrv4Rc8rC/z+ G2YDrxCOueynkhECFgCbtMKh5MU/a8jtzeqF2Tt3G/jNmib3IGBk358K5XqlqMv65oc3 G9CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Lq15VOsfqpHpPD+9CIPW7Xgd9tFBt5Of95lOEI4j25w=; b=LXBvNvJyA5GbhHFl+16vRsIAt6kO+iBZEiRp9qyaA49He3EF6l4wrfb/fB3Nr9Z6yD LM98jAh5anU7IKFEs1jFg5VVi4h9FZFLOpkA97HS5Z8SIvrIWGmmNhKxsQtAmQsxc9Rs Up+q/02ZwhLgUU24L2qvZsl6vEOHDHGQxFk+3CAqgMhulMamnmh/DzT4R8XyNLB6yM8k GQ8pvKNijVZimwi+AzHcnglbHPqdtM28HxS0SRXoPcVlfZo3W6vHrsq1/Cu7oFBXGF8f 6glGtR9KeA1abcmTP6nnq0A27zmnLHAgftVAm4Pbo91blwxq/5NGsa/gelmqpSj/ahH3 9fTg== X-Gm-Message-State: APt69E03PVApVYNt9bNiTwwE+7zVdSqXnBRM72ijUdhX0TgLQZ2ptURO YIS8Boiuv0Ld3vBPSxdrwXN2v5AZ X-Google-Smtp-Source: AAOMgpcY+TfjW0wYyVcyOD7ahW4asF2Ff5DNlmbxTI4S4tgeyHTyYl3XgVbGlcHmw6dEPN5+ADpDRg== X-Received: by 2002:adf:c7c3:: with SMTP id y3-v6mr9875155wrg.230.1530216318261; Thu, 28 Jun 2018 13:05:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:15 +0200 Message-Id: <1530216310-52873-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::231 Subject: [Qemu-devel] [PULL 05/60] hw/char/serial: Only retry if qemu_chr_fe_write returns 0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Sergio Lopez Only retry on serial_xmit if qemu_chr_fe_write returns 0, as this is the only recoverable error. Retrying with any other scenario, in addition to being a waste of CPU cycles, can compromise the Guest stability if by the vCPU issuing the write and the main loop thread are, by chance or explicit pinning, running on the same pCPU. Previous discussion: https://lists.nongnu.org/archive/html/qemu-devel/2018-05/msg06998.html Signed-off-by: Sergio Lopez Message-Id: <1528185295-14199-1-git-send-email-slp@redhat.com> Signed-off-by: Paolo Bonzini --- hw/char/serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/char/serial.c b/hw/char/serial.c index 605b0d0..6de6c29 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -260,7 +260,7 @@ static void serial_xmit(SerialState *s) if (s->mcr & UART_MCR_LOOP) { /* in loopback mode, say that we just received a char */ serial_receive1(s, &s->tsr, 1); - } else if (qemu_chr_fe_write(&s->chr, &s->tsr, 1) !=3D 1 && + } else if (qemu_chr_fe_write(&s->chr, &s->tsr, 1) =3D=3D 0 && s->tsr_retry < MAX_XMIT_RETRY) { assert(s->watch_tag =3D=3D 0); s->watch_tag =3D --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530216640657259.45732307116066; Thu, 28 Jun 2018 13:10:40 -0700 (PDT) Received: from localhost ([::1]:38304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdFX-0002zo-Rs for importer@patchew.org; Thu, 28 Jun 2018 16:10:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAQ-00074z-KN for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAP-00008S-Ff for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:22 -0400 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:46654) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAO-00005F-Oj for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:21 -0400 Received: by mail-wr0-x241.google.com with SMTP id t6-v6so6664963wrq.13 for ; Thu, 28 Jun 2018 13:05:20 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=a0agPKEsNAB2C2qkwtnEDQob0f31zBM/LulJ/RPkBic=; b=ZKo2ZIfJFKz0Q6mK8HwvsXcNwdVoHa3Eoo/frYh2VrV+5L45gP9trlG1Y0f29sOjhY lmZ8EUKftHiJeze30PlMmQ8gyOsf2qHo5JsM9xd/AoJV91Wu+DeHFqU28+OGwBG7UWjP zqaMhXu+kSl+9mqHHrRfxI5U5paJ6ivZGP3MEvrI76PIohuK+2iZB9szD/QMIgd6sCWF n6ETsSRYpNDsmXNqsxC0uARkTSEwe6YM+YaDIkneimyZq6GjDsD8BPDXGpSbLZ6cyhXZ 4riOy/ENW16CheNB9Av3biv0BZ0cTpc5dIGfb8mipzqfaBWX7fECM19cGXKw+2zZ8q6c rO7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=a0agPKEsNAB2C2qkwtnEDQob0f31zBM/LulJ/RPkBic=; b=tuO66EZyRJMXuKocNfmtillEusmCCEoWmZEpKa5vNeW+WeI0i+6IdHe2vjoR1FQB8g PAqnAIcy0uUlc0ML/ylARwSdjLAxQe1qvmUoXkkjzyxjLklKz1PbYcdJzuuGsSyOXu9t qAB/9qevoZ9x6Godcht2P8B/PlquaoRm+q4q/xLAAIBf+TJqbK5vZ4yZj4+38fLyGVVO PhtspY2sGOGRGcNUhKAiNSSx9iK6HlY0wuqRKTCp/6bdx5tDR4Y1x9NCjbLe6ySgs/5T S2ZBEWZjxwpZYk5FsHYNtlL6G0axUhXSWqbSkXYr86I8fz54hhAFNRTbrcBYfDpP2+l9 bn5Q== X-Gm-Message-State: APt69E1uU1TY3NPPDPQCHqNM435aS96FfzfAAP5Tk2WQBo9N2e/QbX6A LnMu7ZSmBCYrzb5BaGaOdA6tnFHx X-Google-Smtp-Source: AAOMgpedOHuBst9xbB9dN+P+ifYR90EhnszZBa7dUiclVx8mMq1PscklolSDGHoR+Fud7m4Ph/H99g== X-Received: by 2002:adf:ebc3:: with SMTP id v3-v6mr9793996wrn.33.1530216319378; Thu, 28 Jun 2018 13:05:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:16 +0200 Message-Id: <1530216310-52873-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 06/60] target/i386: Fix BLSR and BLSI X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson The implementation of these two instructions was swapped. At the same time, unify the setup of eflags for the insn group. Reported-by: Ricardo Ribalda Delgado Signed-off-by: Richard Henderson Message-Id: <20170712192902.15493-1-rth@twiddle.net> Signed-off-by: Paolo Bonzini --- target/i386/translate.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/target/i386/translate.c b/target/i386/translate.c index 697a918..c918494 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -4059,34 +4059,26 @@ static void gen_sse(CPUX86State *env, DisasContext = *s, int b, ot =3D mo_64_32(s->dflag); gen_ldst_modrm(env, s, modrm, ot, OR_TMP0, 0); =20 + tcg_gen_mov_tl(cpu_cc_src, cpu_T0); switch (reg & 7) { case 1: /* blsr By,Ey */ - tcg_gen_neg_tl(cpu_T1, cpu_T0); + tcg_gen_subi_tl(cpu_T1, cpu_T0, 1); tcg_gen_and_tl(cpu_T0, cpu_T0, cpu_T1); - gen_op_mov_reg_v(ot, s->vex_v, cpu_T0); - gen_op_update2_cc(); - set_cc_op(s, CC_OP_BMILGB + ot); break; - case 2: /* blsmsk By,Ey */ - tcg_gen_mov_tl(cpu_cc_src, cpu_T0); - tcg_gen_subi_tl(cpu_T0, cpu_T0, 1); - tcg_gen_xor_tl(cpu_T0, cpu_T0, cpu_cc_src); - tcg_gen_mov_tl(cpu_cc_dst, cpu_T0); - set_cc_op(s, CC_OP_BMILGB + ot); + tcg_gen_subi_tl(cpu_T1, cpu_T0, 1); + tcg_gen_xor_tl(cpu_T0, cpu_T0, cpu_T1); break; - case 3: /* blsi By, Ey */ - tcg_gen_mov_tl(cpu_cc_src, cpu_T0); - tcg_gen_subi_tl(cpu_T0, cpu_T0, 1); - tcg_gen_and_tl(cpu_T0, cpu_T0, cpu_cc_src); - tcg_gen_mov_tl(cpu_cc_dst, cpu_T0); - set_cc_op(s, CC_OP_BMILGB + ot); + tcg_gen_neg_tl(cpu_T1, cpu_T0); + tcg_gen_and_tl(cpu_T0, cpu_T0, cpu_T1); break; - default: goto unknown_op; } + tcg_gen_mov_tl(cpu_cc_dst, cpu_T0); + gen_op_mov_reg_v(ot, s->vex_v, cpu_T0); + set_cc_op(s, CC_OP_BMILGB + ot); break; =20 default: --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530216695665900.1859129512158; Thu, 28 Jun 2018 13:11:35 -0700 (PDT) Received: from localhost ([::1]:38309 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdGQ-0003mG-RX for importer@patchew.org; Thu, 28 Jun 2018 16:11:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAR-00075X-9t for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAQ-00009Z-3K for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:23 -0400 Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]:32825) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAP-00007Z-Ob for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:21 -0400 Received: by mail-wr0-x22c.google.com with SMTP id k7-v6so3189088wrq.0 for ; Thu, 28 Jun 2018 13:05:21 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=vX2nWPvHp6qL6Q4OQcC9SAL4B+ajrA/bHfCDF71YLvw=; b=Gm9NUyw1vEm4ML6u03H8zAsCqJMybhprtMAfCIdGP8z2lZ97S+WL7jUpvcFkiRMxvi RQDgzjMJdahtZ89z5yq+/SnUYPh0ccMHxkcn4eLY7XFDULu9neqAFn2bzZDZb+j8fbp4 4PXEjPe3Z6IMaBUJP2hnMnjNwy8UH1b25UM4oPOt+F+btCOj77vcRCzowUY2fOj1UzSH Zg9mDkcQSwtKyMgaXZF4cOAl3TZStc7AfBxYIorjf1c+yuNquw5kFqUvbSmPDSOUHkv6 8GoPA5aZr/L99tToec0Wj2IQ5wQwMNwbWHHIQKvr5m8UufFlhZbMfuD7bmwSrIjFszoz OjpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=vX2nWPvHp6qL6Q4OQcC9SAL4B+ajrA/bHfCDF71YLvw=; b=VHgryI+0lsuZsF0cG8wfpkDyRglY9Lo0YGpYpASbdSpXtanG10mFDg/BiQr43Ql6Cy Z5DlOnGb9KL0ebZghUkOAIENjiX32rNGuJfGhJWnVYKNICO+LD9ibNEVmvijaf7gxJWU Cxq6USxOTYCkS7EJ0Rmsl3Jxsk1MtP1LZ7TxAiDo8CYAOMB6gZAJbgCYxjNqLyA7VRiA yPnbIbn6+iNgPC9RRYebpI/K4Hw4TDEVZWk9W9mYDAeEHb+Q2fO6dAOXdxEisr6TRtTj OFOoF1x53i3xjxC9WnU0mHfJEE6LOzNyM0wiNewVMpaTmeIGLuUmn8OHcjI3CqKxWpwr AUXA== X-Gm-Message-State: APt69E0etMQLCKZxBuU9WcUPbugTHSflcGmnxbmp7JWYqGmpJOuy0rnE Dhm90Fva92ziK/wcnzkNpoiYTZDj X-Google-Smtp-Source: AAOMgpf12rqgDog5uME+o3F/8wYkrB0MC3I0ETL9NCmLjmAKUspND+XS0JfEX6B7Gj73REWxAUH/XA== X-Received: by 2002:adf:acc3:: with SMTP id o61-v6mr10305431wrc.34.1530216320352; Thu, 28 Jun 2018 13:05:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:17 +0200 Message-Id: <1530216310-52873-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22c Subject: [Qemu-devel] [PULL 07/60] whpx: commit missing file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Not included by mistake in commit 327fccb288976f95808efa968082fc9d4a9ced84. Signed-off-by: Paolo Bonzini --- target/i386/whp-dispatch.h | 56 ++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 56 insertions(+) create mode 100644 target/i386/whp-dispatch.h diff --git a/target/i386/whp-dispatch.h b/target/i386/whp-dispatch.h new file mode 100644 index 0000000..d8d3485 --- /dev/null +++ b/target/i386/whp-dispatch.h @@ -0,0 +1,56 @@ +#include "windows.h" +#include + +#include +#include + +#ifndef WHP_DISPATCH_H +#define WHP_DISPATCH_H + + +#define LIST_WINHVPLATFORM_FUNCTIONS(X) \ + X(HRESULT, WHvGetCapability, (WHV_CAPABILITY_CODE CapabilityCode, VOID* = CapabilityBuffer, UINT32 CapabilityBufferSizeInBytes, UINT32* WrittenSizeIn= Bytes)) \ + X(HRESULT, WHvCreatePartition, (WHV_PARTITION_HANDLE* Partition)) \ + X(HRESULT, WHvSetupPartition, (WHV_PARTITION_HANDLE Partition)) \ + X(HRESULT, WHvDeletePartition, (WHV_PARTITION_HANDLE Partition)) \ + X(HRESULT, WHvGetPartitionProperty, (WHV_PARTITION_HANDLE Partition, WHV= _PARTITION_PROPERTY_CODE PropertyCode, VOID* PropertyBuffer, UINT32 Propert= yBufferSizeInBytes, UINT32* WrittenSizeInBytes)) \ + X(HRESULT, WHvSetPartitionProperty, (WHV_PARTITION_HANDLE Partition, WHV= _PARTITION_PROPERTY_CODE PropertyCode, const VOID* PropertyBuffer, UINT32 P= ropertyBufferSizeInBytes)) \ + X(HRESULT, WHvMapGpaRange, (WHV_PARTITION_HANDLE Partition, VOID* Source= Address, WHV_GUEST_PHYSICAL_ADDRESS GuestAddress, UINT64 SizeInBytes, WHV_M= AP_GPA_RANGE_FLAGS Flags)) \ + X(HRESULT, WHvUnmapGpaRange, (WHV_PARTITION_HANDLE Partition, WHV_GUEST_= PHYSICAL_ADDRESS GuestAddress, UINT64 SizeInBytes)) \ + X(HRESULT, WHvTranslateGva, (WHV_PARTITION_HANDLE Partition, UINT32 VpIn= dex, WHV_GUEST_VIRTUAL_ADDRESS Gva, WHV_TRANSLATE_GVA_FLAGS TranslateFlags,= WHV_TRANSLATE_GVA_RESULT* TranslationResult, WHV_GUEST_PHYSICAL_ADDRESS* G= pa)) \ + X(HRESULT, WHvCreateVirtualProcessor, (WHV_PARTITION_HANDLE Partition, U= INT32 VpIndex, UINT32 Flags)) \ + X(HRESULT, WHvDeleteVirtualProcessor, (WHV_PARTITION_HANDLE Partition, U= INT32 VpIndex)) \ + X(HRESULT, WHvRunVirtualProcessor, (WHV_PARTITION_HANDLE Partition, UINT= 32 VpIndex, VOID* ExitContext, UINT32 ExitContextSizeInBytes)) \ + X(HRESULT, WHvCancelRunVirtualProcessor, (WHV_PARTITION_HANDLE Partition= , UINT32 VpIndex, UINT32 Flags)) \ + X(HRESULT, WHvGetVirtualProcessorRegisters, (WHV_PARTITION_HANDLE Partit= ion, UINT32 VpIndex, const WHV_REGISTER_NAME* RegisterNames, UINT32 Registe= rCount, WHV_REGISTER_VALUE* RegisterValues)) \ + X(HRESULT, WHvSetVirtualProcessorRegisters, (WHV_PARTITION_HANDLE Partit= ion, UINT32 VpIndex, const WHV_REGISTER_NAME* RegisterNames, UINT32 Registe= rCount, const WHV_REGISTER_VALUE* RegisterValues)) \ + + +#define LIST_WINHVEMULATION_FUNCTIONS(X) \ + X(HRESULT, WHvEmulatorCreateEmulator, (const WHV_EMULATOR_CALLBACKS* Cal= lbacks, WHV_EMULATOR_HANDLE* Emulator)) \ + X(HRESULT, WHvEmulatorDestroyEmulator, (WHV_EMULATOR_HANDLE Emulator)) \ + X(HRESULT, WHvEmulatorTryIoEmulation, (WHV_EMULATOR_HANDLE Emulator, VOI= D* Context, const WHV_VP_EXIT_CONTEXT* VpContext, const WHV_X64_IO_PORT_ACC= ESS_CONTEXT* IoInstructionContext, WHV_EMULATOR_STATUS* EmulatorReturnStatu= s)) \ + X(HRESULT, WHvEmulatorTryMmioEmulation, (WHV_EMULATOR_HANDLE Emulator, V= OID* Context, const WHV_VP_EXIT_CONTEXT* VpContext, const WHV_MEMORY_ACCESS= _CONTEXT* MmioInstructionContext, WHV_EMULATOR_STATUS* EmulatorReturnStatus= )) \ + + +#define WHP_DEFINE_TYPE(return_type, function_name, signature) \ + typedef return_type (WINAPI *function_name ## _t) signature; + +#define WHP_DECLARE_MEMBER(return_type, function_name, signature) \ + function_name ## _t function_name; + +/* Define function typedef */ +LIST_WINHVPLATFORM_FUNCTIONS(WHP_DEFINE_TYPE) +LIST_WINHVEMULATION_FUNCTIONS(WHP_DEFINE_TYPE) + +struct WHPDispatch { + LIST_WINHVPLATFORM_FUNCTIONS(WHP_DECLARE_MEMBER) + LIST_WINHVEMULATION_FUNCTIONS(WHP_DECLARE_MEMBER) +}; + +extern struct WHPDispatch whp_dispatch; + +bool init_whp_dispatch(void); + + +#endif /* WHP_DISPATCH_H */ --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530216972153725.9386994553211; Thu, 28 Jun 2018 13:16:12 -0700 (PDT) Received: from localhost ([::1]:38337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdKt-0007tZ-8u for importer@patchew.org; Thu, 28 Jun 2018 16:16:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAS-00076x-KA for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAR-0000C5-Gb for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:24 -0400 Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]:43337) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAR-0000AL-7u for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:23 -0400 Received: by mail-wr0-x232.google.com with SMTP id c5-v6so6680844wrs.10 for ; Thu, 28 Jun 2018 13:05:23 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=26Fv7Ds6niWBbLSjOAJLcfQ5P/bjyv+RSulzBQsE2Xc=; b=HuHWa8hcaP4kdSxwLkxUsplSRYKoq3dpUyp4u1OAGZAcIcyHlOcQv5v6uWEDUvftig V+bw2UQ65OIG/eEodFUuUlWRYz8PP+E66xm4x+WBexdX/DjU24t5GyoioKDDPkIugsWD uu2dpz5wz8Zc2lbt6uU3fxUYa626nW1CtH5j/ILAqDZr/R66QVUk1qtr+fsDzzA9TKAW v3iyypUfmXrKkwzXEviSt8fAo3TgRplSUg+guM3VuLVVdRqDAqmO5k4cxHR+/xJ3X9Bi blBjm8jKUmZzXHZ0Bnf6iCUN8cwpmFx5pwazq+/HmvWWVk9fUgjto8FS9QHLMYb0CWaI nV+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=26Fv7Ds6niWBbLSjOAJLcfQ5P/bjyv+RSulzBQsE2Xc=; b=IYmeMtgB2sheTRCGiklAl2+H9z/2q2YBk2vforJA6ICeoUJHEW6iDDE3t5QdXyDwBD sezA+XPAPjUDPFJr02QbJK+jliFhQWs69G4M3D5xvq4LPsIIIejMLcuyT0YnjbxAbOKq fP2WNWcj0uqVzruLXlJJKJ2FPtzz8tp14hW3qMPko0ecuj/n1JL8LpUaeJ4EQSDs/UVu q4E8kaIuBvsFI/S3KhzXMBJ63I8Q3g3vaxgLAClvLKzY2DVR4jeRF2+ymiwmqp4tVxkW hsJIlbbbtyCltuxAuJSpDzv7+QWc8KvtiMWayRyL4enq/4Ga5C+35IOcARwnjFnWSfRt eTEw== X-Gm-Message-State: APt69E1In9rvwFNak5zOGPnkhTh/a8xe3gR38c+ISOpLAnXoFXOQie7M /mWlLkOPmUsOfkX+hvASwxZlJgNY X-Google-Smtp-Source: AAOMgpf28bfT8koqQhCNBYq4uxVbp6VjIVhM6upylBluUuRE/9KOFXgCM9EuiBs5CxQZmYVs+qiYIw== X-Received: by 2002:adf:f08e:: with SMTP id n14-v6mr10153316wro.49.1530216321842; Thu, 28 Jun 2018 13:05:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:18 +0200 Message-Id: <1530216310-52873-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::232 Subject: [Qemu-devel] [PULL 08/60] memory-device: turn alignment assert into check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand The start of the address space indicates which maximum alignment is supported by our machine (e.g. ppc, x86 1GB). This is helpful to catch fragmenting guest physical memory in strange fashions. Right now we can crash QEMU by e.g. (there might be easier examples) qemu-system-x86_64 -m 256M,maxmem=3D20G,slots=3D2 \ -object memory-backend-file,id=3Dmem0,size=3D8192M,mem-path=3D/dev/zero,al= ign=3D8192M \ -device pc-dimm,id=3Ddimm1,memdev=3Dmem0 Signed-off-by: David Hildenbrand Message-Id: <20180607154705.6316-2-david@redhat.com> Reviewed-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- hw/mem/memory-device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c index 3e04f39..6de4f70 100644 --- a/hw/mem/memory-device.c +++ b/hw/mem/memory-device.c @@ -116,9 +116,15 @@ uint64_t memory_device_get_free_addr(MachineState *ms,= const uint64_t *hint, address_space_start =3D ms->device_memory->base; address_space_end =3D address_space_start + memory_region_size(&ms->device_memory->mr); - g_assert(QEMU_ALIGN_UP(address_space_start, align) =3D=3D address_spac= e_start); g_assert(address_space_end >=3D address_space_start); =20 + /* address_space_start indicates the maximum alignment we expect */ + if (QEMU_ALIGN_UP(address_space_start, align) !=3D address_space_start= ) { + error_setg(errp, "the alignment (0%" PRIx64 ") is not supported", + align); + return 0; + } + memory_device_check_addable(ms, size, errp); if (*errp) { return 0; --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530216717241263.16869630973963; Thu, 28 Jun 2018 13:11:57 -0700 (PDT) Received: from localhost ([::1]:38310 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdGj-00042E-6h for importer@patchew.org; Thu, 28 Jun 2018 16:11:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAW-00079b-9T for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAS-0000ER-R6 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:27 -0400 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:37246) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAS-0000Cq-IY for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:24 -0400 Received: by mail-wr0-x22b.google.com with SMTP id k6-v6so6687292wrp.4 for ; Thu, 28 Jun 2018 13:05:24 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=20P9TTLf8usIx6WjiRTM94wgZ5jkWGrAQzKQ7FtQM8w=; b=bwGMDQquu/LJE3kOBwpty2PTQJ1aBN0q8fRq/Hg5DR/CcPWNSVsu5U4UmWIUNUe1VK AlqEtRCNi1a/JNjDv+A1R/qqpuXtJbomBJ5eMxaZ7PF0ppx+Zf51ODSu6YuDKpkZqIGY V86m8CjZ4xAkzhu8g2BoEPvLjrn1U1gBU1h1DfNRiz22g8H0vBL2HbC13i1KwZf5jMfs 3mhP6HSYWp66VJqxT8a1BWM8Z6QmIwjimzvWQ6w6RDORPz6PsrzhVIF5DXBh7PiGj5jT 9FNT2cfu/xd2WHipZNxf9T9/HYiAvpdLtGHHy1rnKMG4QaSPaXOm9oz2BDCeECMhcT3s OAxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=20P9TTLf8usIx6WjiRTM94wgZ5jkWGrAQzKQ7FtQM8w=; b=PcoeYH3LwVln4lPqryMYWPI2Je/5cNujO9eQGGdV2in1CK18Yx7P6pRWRPbWk5Qkj2 t3ntJeHvX6MLWeh++BhgoJGTg0pr0yUsdBlhvg4RaE02TPx6CIkcPex5OfByyZZ9lYfN 0U4zCMSvGZBHn5R28ojK0mRMHVbynoVMA0GxXel082RKXnStQq6Z0ADJIQ3bRje5ZyDl BFcCYXcXIdml7XLVRqPyKJ5hjDv737yuHD+DvcvQ1q/C39av1i2c2zrzTF81kxaCdM0w 36Aoonnw0Kb3yVofMd2z7agKQ94wMaLYkNzwCfho1weBe0klQ0PkyUT2K14Kk9fMoMVs fFOg== X-Gm-Message-State: APt69E0tT+szzQQp69IgsKnGRE8KMMxoT4WnugmhWE++NE9Wl4ZMW+o4 39jDISNOV0FuWvuY89LfiOpX5Lys X-Google-Smtp-Source: AAOMgpfCiEP+7Yh3/zyjhl9czdkwbcmG2MZVtBRAuWZglQdJp+eF3rdRgnjSg7vBXwfMFKtsZfXElg== X-Received: by 2002:adf:a9cf:: with SMTP id b73-v6mr9664556wrd.48.1530216323228; Thu, 28 Jun 2018 13:05:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:19 +0200 Message-Id: <1530216310-52873-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22b Subject: [Qemu-devel] [PULL 09/60] exec: check that alignment is a power of two X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Right now we can crash QEMU using e.g. qemu-system-x86_64 -m 256M,maxmem=3D20G,slots=3D2 \ -object memory-backend-file,id=3Dmem0,size=3D12288,mem-path=3D/dev/zero,al= ign=3D12288 \ -device pc-dimm,id=3Ddimm1,memdev=3Dmem0 qemu-system-x86_64: util/mmap-alloc.c:115: qemu_ram_mmap: Assertion `is_power_of_2(align)' failed Fix this by adding a proper check. Signed-off-by: David Hildenbrand Message-Id: <20180607154705.6316-3-david@redhat.com> Reviewed-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- exec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exec.c b/exec.c index 610d0c0..cdcf769 100644 --- a/exec.c +++ b/exec.c @@ -1841,6 +1841,10 @@ static void *file_ram_alloc(RAMBlock *block, " must be multiples of page size 0x%zx", block->mr->align, block->page_size); return NULL; + } else if (block->mr->align && !is_power_of_2(block->mr->align)) { + error_setg(errp, "alignment 0x%" PRIx64 + " must be a power of two", block->mr->align); + return NULL; } block->mr->align =3D MAX(block->page_size, block->mr->align); #if defined(__s390x__) --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530216806253953.6111164301954; Thu, 28 Jun 2018 13:13:26 -0700 (PDT) Received: from localhost ([::1]:38320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdID-0005JA-D9 for importer@patchew.org; Thu, 28 Jun 2018 16:13:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAW-00079Y-87 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAT-0000Fu-VZ for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:27 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:38580) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAT-0000EY-GJ for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:25 -0400 Received: by mail-wr0-x243.google.com with SMTP id e18-v6so6690684wrs.5 for ; Thu, 28 Jun 2018 13:05:25 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=xqSzARrgUhz3MLYpyOPMSZGJdmSf99ltKL8TIxTV4MU=; b=GSWijIpNeJ5Kp/dXube3WCsT80GnPR6hkKWQ6Z8eihAsD7X1r8JWmi/A2ER/gaeSWk 4IHaH7MQnwBUSvqu6arL09R15dy0F7j9IL/k4FCBfLcFyoR6P3zWNi1H5pBvsq8/rH6l Q+xGJJv6T5C7n5dAKOiuzmtIuoqXXcL73KZnhAxZuhBAh7jiop4HWKaWEExdvGMq0AU4 /7+USRhPDHi4WsngpDI6kG2q3KfWldy6rdtK03n0NGCYceMzCt5NLGgoPbbBIos30fU/ JV2kgJp6RAVZh6Mr6sfqZ4xbA6P1NOJlO9dSynNKWrCrLVj17gqXOGSJK18P7/5DI0Ij JFcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=xqSzARrgUhz3MLYpyOPMSZGJdmSf99ltKL8TIxTV4MU=; b=G2UsEq+Zuf34/2HxBTYwnRHMjjR/xo+EBAzrpqCkz14zGTZa7X9uIS67FTzu8o0MVB 9rYGQEaxfKEEb8hbbnbPtbF3pK/0ByqPF0vTzTXkLu6dNzIO3xKboYZFi/NC6kd3IC6I cqSGoRVrVPHDd5yScbHReFqMA+VJrUOoLFQCGlHqT0h5tYu9ywriHMLR3eFObIPO03aK bunqVUWTDknIXKyOQlzOq3zkBg63y9IHtVyQurWumItjRIOKU2M+gNsBpGrkJr8WGk5h Ji7cRhCGGmbqH0XBb/Jnw5fYT5Am8o9qCamC8vrS+H8hEJ9vX/sPnodlCHLm/thLYEP4 zfew== X-Gm-Message-State: APt69E14ZJnJGu3g82z/7CQjiDrFp4vI4+uc3QKBMNLDcPXvNLipBk4C HqIj6PmzESdWU2G7cHsWWD2zlQEZ X-Google-Smtp-Source: AAOMgpdDLq/FbM4+cQu9asAH7+aXy0NsHMPR5cd7cMPtCYTNDwFwqI/0UJQPYrPCZ6LCYdxmZkhUGA== X-Received: by 2002:adf:82cf:: with SMTP id 73-v6mr9583783wrc.77.1530216324161; Thu, 28 Jun 2018 13:05:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:20 +0200 Message-Id: <1530216310-52873-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 10/60] kvm: Delete the slot if and only if the KVM_MEM_READONLY flag is changed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Shannon Zhao Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Shannon Zhao According to KVM commit 75d61fbc, it needs to delete the slot before changing the KVM_MEM_READONLY flag. But QEMU commit 235e8982 only check whether KVM_MEM_READONLY flag is set instead of changing. It doesn't need to delete the slot if the KVM_MEM_READONLY flag is not changed. This fixes a issue that migrating a VM at the OVMF startup stage and VM is executing the codes in rom. Between the deleting and adding the slot in kvm_set_user_memory_region, there is a chance that guest access rom and trap to KVM, then KVM can't find the corresponding memslot. While KVM (on ARM) injects an abort to guest due to the broken hva, then guest will get stuck. Signed-off-by: Shannon Zhao Message-Id: <1526462314-19720-1-git-send-email-zhaoshenglong@huawei.com> Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 17 ++++++++--------- include/sysemu/kvm_int.h | 1 + 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index ffee68e..eb7db92 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -256,7 +256,7 @@ int kvm_physical_memory_addr_from_host(KVMState *s, voi= d *ram, return 0; } =20 -static int kvm_set_user_memory_region(KVMMemoryListener *kml, KVMSlot *slo= t) +static int kvm_set_user_memory_region(KVMMemoryListener *kml, KVMSlot *slo= t, bool new) { KVMState *s =3D kvm_state; struct kvm_userspace_memory_region mem; @@ -267,7 +267,7 @@ static int kvm_set_user_memory_region(KVMMemoryListener= *kml, KVMSlot *slot) mem.userspace_addr =3D (unsigned long)slot->ram; mem.flags =3D slot->flags; =20 - if (slot->memory_size && mem.flags & KVM_MEM_READONLY) { + if (slot->memory_size && !new && (mem.flags ^ slot->old_flags) & KVM_M= EM_READONLY) { /* Set the slot size to 0 before setting the slot to the desired * value. This is needed based on KVM commit 75d61fbc. */ mem.memory_size =3D 0; @@ -275,6 +275,7 @@ static int kvm_set_user_memory_region(KVMMemoryListener= *kml, KVMSlot *slot) } mem.memory_size =3D slot->memory_size; ret =3D kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, &mem); + slot->old_flags =3D mem.flags; trace_kvm_set_user_memory(mem.slot, mem.flags, mem.guest_phys_addr, mem.memory_size, mem.userspace_addr, ret); return ret; @@ -391,17 +392,14 @@ static int kvm_mem_flags(MemoryRegion *mr) static int kvm_slot_update_flags(KVMMemoryListener *kml, KVMSlot *mem, MemoryRegion *mr) { - int old_flags; - - old_flags =3D mem->flags; mem->flags =3D kvm_mem_flags(mr); =20 /* If nothing changed effectively, no need to issue ioctl */ - if (mem->flags =3D=3D old_flags) { + if (mem->flags =3D=3D mem->old_flags) { return 0; } =20 - return kvm_set_user_memory_region(kml, mem); + return kvm_set_user_memory_region(kml, mem, false); } =20 static int kvm_section_update_flags(KVMMemoryListener *kml, @@ -755,7 +753,8 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, =20 /* unregister the slot */ mem->memory_size =3D 0; - err =3D kvm_set_user_memory_region(kml, mem); + mem->flags =3D 0; + err =3D kvm_set_user_memory_region(kml, mem, false); if (err) { fprintf(stderr, "%s: error unregistering slot: %s\n", __func__, strerror(-err)); @@ -771,7 +770,7 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, mem->ram =3D ram; mem->flags =3D kvm_mem_flags(mr); =20 - err =3D kvm_set_user_memory_region(kml, mem); + err =3D kvm_set_user_memory_region(kml, mem, true); if (err) { fprintf(stderr, "%s: error registering slot: %s\n", __func__, strerror(-err)); diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index 888557a..f838412 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -20,6 +20,7 @@ typedef struct KVMSlot void *ram; int slot; int flags; + int old_flags; } KVMSlot; =20 typedef struct KVMMemoryListener { --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217172085221.35186434593038; Thu, 28 Jun 2018 13:19:32 -0700 (PDT) Received: from localhost ([::1]:38349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdO5-0001n4-Ao for importer@patchew.org; Thu, 28 Jun 2018 16:19:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAW-00079f-Cx for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAU-0000HF-Sn for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:28 -0400 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:55461) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAU-0000Fy-KB for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:26 -0400 Received: by mail-wm0-x22c.google.com with SMTP id v16-v6so11054850wmv.5 for ; Thu, 28 Jun 2018 13:05:26 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=/EzWCZymR/XFULCXrJs5I7W2DDvAnvZnLfMZIlUNdtk=; b=TDiCx7tSv7A4Rpk3NQ/YotCJf66VHNPmIRSilynVIj3pO8Gh5teSvmfXojNQSTKZ6s B6ac0V6sA3K/XJdJ3Qb8JHY2xzga7D9MbS+xBc8Dl11kdTOQfcvuUkN43Ci62XrpgBRS SdYkXQJlnG6oGz0kW0DTMyeJ2uqxrMXdOmvIVWaPctL2tkerECyP640nxHUQNgFA2XZ9 ZglRyMBcm9GtmaCJntgFfBscCj+yQsbSXSFTL3FkIC1qNwponkg54etB7OArGVysDkmh mpwarPWTPKpFEYC7wewuKGnxe3j/9n/NGxtYt3msJ+aqXCDu6zlp6OAKz6b8AZNDLl3z us4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=/EzWCZymR/XFULCXrJs5I7W2DDvAnvZnLfMZIlUNdtk=; b=T7qajv+vZ/zIO9EyGWqcydo+ynyP+rvp0YW/Fg2nj2tFR109JtFjJgA2oBeAk7Tgul oA8ECq1XqMfxTDn6fBdwMPXkdb0VVOuaAZ7IBGBPjQyRaxaLs290q8+Ugalr09fPzz64 xH4i3y93tOtiDKg43T7qSJm3x4eP++HSwxx2zfdFcj4WPUXrqAfoBFanPF80DHR7RpKa fF/mPHDbS/m1K6+5pfGtkfZJRudN0eN7V2qrdCI+d9VkB+Mx1pefPud6nw097ZmNBSca kS903/o8IVY0Uay3qnz58zzz/t8TzypTeqWqpK9eXkvQEsEebWiBCRffE9X39z40FCox 1Naw== X-Gm-Message-State: APt69E1fkRU1VcOyWEWdsa+Q2VKjoxA4vW9Zd/CC8rUpibLvfYVGBz+w gN+QhE9TIQeWxDdqGRFlMb5sYbPH X-Google-Smtp-Source: AAOMgpeePwHU3Ax188c7Zx1FkxByBNote2NKcfbk9IZBEgUjjMwys1iMQ/82dL9en6ULrYBt2M8+dA== X-Received: by 2002:a1c:84d0:: with SMTP id g199-v6mr9959265wmd.90.1530216325258; Thu, 28 Jun 2018 13:05:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:21 +0200 Message-Id: <1530216310-52873-12-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22c Subject: [Qemu-devel] [PULL 11/60] tests/atomic_add-bench: add -m option to use mutexes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Emilio G. Cota" , Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" This allows us to use atomic-add-bench as a microbenchmark for evaluating qemu_mutex_lock's performance. Signed-off-by: Emilio G. Cota [cherry picked from https://github.com/cota/qemu/commit/f04f34df] Signed-off-by: Peter Xu Message-Id: <20180425025459.5258-2-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- tests/atomic_add-bench.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/atomic_add-bench.c b/tests/atomic_add-bench.c index caa1e8e..f96d448 100644 --- a/tests/atomic_add-bench.c +++ b/tests/atomic_add-bench.c @@ -8,6 +8,7 @@ struct thread_info { } QEMU_ALIGNED(64); =20 struct count { + QemuMutex lock; unsigned long val; } QEMU_ALIGNED(64); =20 @@ -18,11 +19,13 @@ static unsigned int n_ready_threads; static struct count *counts; static unsigned int duration =3D 1; static unsigned int range =3D 1024; +static bool use_mutex; static bool test_start; static bool test_stop; =20 static const char commands_string[] =3D " -n =3D number of threads\n" + " -m =3D use mutexes instead of atomic increments\n" " -d =3D duration in seconds\n" " -r =3D range (will be rounded up to pow2)"; =20 @@ -59,7 +62,13 @@ static void *thread_func(void *arg) =20 info->r =3D xorshift64star(info->r); index =3D info->r & (range - 1); - atomic_inc(&counts[index].val); + if (use_mutex) { + qemu_mutex_lock(&counts[index].lock); + counts[index].val +=3D 1; + qemu_mutex_unlock(&counts[index].lock); + } else { + atomic_inc(&counts[index].val); + } } return NULL; } @@ -91,6 +100,9 @@ static void create_threads(void) th_info =3D g_new(struct thread_info, n_threads); counts =3D qemu_memalign(64, sizeof(*counts) * range); memset(counts, 0, sizeof(*counts) * range); + for (i =3D 0; i < range; i++) { + qemu_mutex_init(&counts[i].lock); + } =20 for (i =3D 0; i < n_threads; i++) { struct thread_info *info =3D &th_info[i]; @@ -131,7 +143,7 @@ static void parse_args(int argc, char *argv[]) int c; =20 for (;;) { - c =3D getopt(argc, argv, "hd:n:r:"); + c =3D getopt(argc, argv, "hd:n:mr:"); if (c < 0) { break; } @@ -145,6 +157,9 @@ static void parse_args(int argc, char *argv[]) case 'n': n_threads =3D atoi(optarg); break; + case 'm': + use_mutex =3D true; + break; case 'r': range =3D pow2ceil(atoi(optarg)); break; --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217365108756.2174987262695; Thu, 28 Jun 2018 13:22:45 -0700 (PDT) Received: from localhost ([::1]:38370 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdRC-0004Qs-7U for importer@patchew.org; Thu, 28 Jun 2018 16:22:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAX-0007BD-Vi for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAW-0000JL-D5 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:29 -0400 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:54422) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAV-0000HU-IF for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:28 -0400 Received: by mail-wm0-x22c.google.com with SMTP id i139-v6so10967516wmf.4 for ; Thu, 28 Jun 2018 13:05:27 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=owCGhLAFULbHajhHqpQGqRHMpNzLB41GNsGhlkCIbl0=; b=jhZ8/NpFCRDzlJkkZj2J6B7l0CXALlWOheqvGbfqduT3HMYmjrVH6wgSLQD9NQgVD8 qlojIio9kLLvTim0vUhCVDGOMW4KkwVnMCQqHkGKkifjlu0UukHkxEDL0XmMrXeOetF6 emOLRayZ20ScW01LGAMo2cV0QdfL7iF3Gadm61jyl95AYwHRHSDlSeVydbH8cvNBx4o4 Kr9rh0LO8oqT+USBfk4k+UjBNUQWCGPnZzGiBiKV1iz1ch+k2xaI6UYZ2LiOR4Bq1rCn e5YkFdsaFMaOblK5+a9eS1zLLSee0SedvPFO4BYa60KUyfoDpb/DkZGOj8YPAjqPaeRX 25Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=owCGhLAFULbHajhHqpQGqRHMpNzLB41GNsGhlkCIbl0=; b=o+JjDsH1rmTjJie81ekNu/+0OHVvMZZBeojzC+RR44NyYVqYKDRvBsjm5aKlEuZFSB cXIZkYjX2LHOrxVV4nSt2Lei9UqlcaQvZMeqOOKKF4/kbVRAOx7k8cnE97O1eQvu27LJ yX7mRhoSNMJhmBzomGvlrudkAlTZuqdrrYjtvgOwYcJgNoXnPGAnIVexOE/lHe845f8H jgt87OdfvOw/PP7oSBosbY1x7xXzw45ZD+QTXdkTp9oeKX2AvLNewOoUV6UgyaITuGwK 2XJSLIYqqrdeC89+TijpjWyrDtJf/v0zC6RVzv/DL6RNcHJW/Xnju15HKNRY4n5MLpCJ E6gg== X-Gm-Message-State: APt69E2dD6MN1QvJmgiItj+Kkxw4BtiQGAZ91sCSCAG34iaYIVEYC6JG SdD8rGUTWldQO3lT8/poXK0WmBVt X-Google-Smtp-Source: AAOMgpcK/Gfk+71aeRd6VBPaSeoGqI0PM7NMfzh6zxuIS1pB7yxm8eLiuFVqLQyZMGwWOWhhUR3ccA== X-Received: by 2002:a1c:45db:: with SMTP id l88-v6mr8802935wmi.19.1530216326260; Thu, 28 Jun 2018 13:05:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:22 +0200 Message-Id: <1530216310-52873-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22c Subject: [Qemu-devel] [PULL 12/60] qemu-thread: introduce qemu-thread-common.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu Introduce some hooks for the shared part of qemu thread between POSIX and Windows implementations. Note that in qemu_mutex_unlock_impl() we moved the call before unlock operation which should make more sense. And we don't need qemu_mutex_post_unlock() hook. Put all these shared hooks into the header files. It should be internal to qemu-thread but not for qemu-thread users, hence put into util/ directory. Reviewed-by: Emilio G. Cota Signed-off-by: Peter Xu Message-Id: <20180425025459.5258-3-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- util/qemu-thread-common.h | 43 +++++++++++++++++++++++++++++++++++++++++++ util/qemu-thread-posix.c | 19 ++++++++----------- util/qemu-thread-win32.c | 17 ++++++++--------- 3 files changed, 59 insertions(+), 20 deletions(-) create mode 100644 util/qemu-thread-common.h diff --git a/util/qemu-thread-common.h b/util/qemu-thread-common.h new file mode 100644 index 0000000..d329208 --- /dev/null +++ b/util/qemu-thread-common.h @@ -0,0 +1,43 @@ +/* + * Common qemu-thread implementation header file. + * + * Copyright Red Hat, Inc. 2018 + * + * Authors: + * Peter Xu , + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_THREAD_COMMON_H +#define QEMU_THREAD_COMMON_H + +#include "qemu/typedefs.h" +#include "qemu/thread.h" +#include "trace.h" + +static inline void qemu_mutex_post_init(QemuMutex *mutex) +{ + mutex->initialized =3D true; +} + +static inline void qemu_mutex_pre_lock(QemuMutex *mutex, + const char *file, int line) +{ + trace_qemu_mutex_lock(mutex, file, line); +} + +static inline void qemu_mutex_post_lock(QemuMutex *mutex, + const char *file, int line) +{ + trace_qemu_mutex_locked(mutex, file, line); +} + +static inline void qemu_mutex_pre_unlock(QemuMutex *mutex, + const char *file, int line) +{ + trace_qemu_mutex_unlock(mutex, file, line); +} + +#endif diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index a1c34ba..dfa66ff 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -14,7 +14,7 @@ #include "qemu/thread.h" #include "qemu/atomic.h" #include "qemu/notify.h" -#include "trace.h" +#include "qemu-thread-common.h" =20 static bool name_threads; =20 @@ -43,7 +43,7 @@ void qemu_mutex_init(QemuMutex *mutex) err =3D pthread_mutex_init(&mutex->lock, NULL); if (err) error_exit(err, __func__); - mutex->initialized =3D true; + qemu_mutex_post_init(mutex); } =20 void qemu_mutex_destroy(QemuMutex *mutex) @@ -62,13 +62,11 @@ void qemu_mutex_lock_impl(QemuMutex *mutex, const char = *file, const int line) int err; =20 assert(mutex->initialized); - trace_qemu_mutex_lock(mutex, file, line); - + qemu_mutex_pre_lock(mutex, file, line); err =3D pthread_mutex_lock(&mutex->lock); if (err) error_exit(err, __func__); - - trace_qemu_mutex_locked(mutex, file, line); + qemu_mutex_post_lock(mutex, file, line); } =20 int qemu_mutex_trylock_impl(QemuMutex *mutex, const char *file, const int = line) @@ -78,7 +76,7 @@ int qemu_mutex_trylock_impl(QemuMutex *mutex, const char = *file, const int line) assert(mutex->initialized); err =3D pthread_mutex_trylock(&mutex->lock); if (err =3D=3D 0) { - trace_qemu_mutex_locked(mutex, file, line); + qemu_mutex_post_lock(mutex, file, line); return 0; } if (err !=3D EBUSY) { @@ -92,11 +90,10 @@ void qemu_mutex_unlock_impl(QemuMutex *mutex, const cha= r *file, const int line) int err; =20 assert(mutex->initialized); + qemu_mutex_pre_unlock(mutex, file, line); err =3D pthread_mutex_unlock(&mutex->lock); if (err) error_exit(err, __func__); - - trace_qemu_mutex_unlock(mutex, file, line); } =20 void qemu_rec_mutex_init(QemuRecMutex *mutex) @@ -160,9 +157,9 @@ void qemu_cond_wait_impl(QemuCond *cond, QemuMutex *mut= ex, const char *file, con int err; =20 assert(cond->initialized); - trace_qemu_mutex_unlock(mutex, file, line); + qemu_mutex_pre_unlock(mutex, file, line); err =3D pthread_cond_wait(&cond->cond, &mutex->lock); - trace_qemu_mutex_locked(mutex, file, line); + qemu_mutex_post_lock(mutex, file, line); if (err) error_exit(err, __func__); } diff --git a/util/qemu-thread-win32.c b/util/qemu-thread-win32.c index ab60c0d..b303188 100644 --- a/util/qemu-thread-win32.c +++ b/util/qemu-thread-win32.c @@ -19,7 +19,7 @@ #include "qemu-common.h" #include "qemu/thread.h" #include "qemu/notify.h" -#include "trace.h" +#include "qemu-thread-common.h" #include =20 static bool name_threads; @@ -46,7 +46,7 @@ static void error_exit(int err, const char *msg) void qemu_mutex_init(QemuMutex *mutex) { InitializeSRWLock(&mutex->lock); - mutex->initialized =3D true; + qemu_mutex_post_init(mutex); } =20 void qemu_mutex_destroy(QemuMutex *mutex) @@ -59,10 +59,9 @@ void qemu_mutex_destroy(QemuMutex *mutex) void qemu_mutex_lock_impl(QemuMutex *mutex, const char *file, const int li= ne) { assert(mutex->initialized); - trace_qemu_mutex_lock(mutex, file, line); - + qemu_mutex_pre_lock(mutex, file, line); AcquireSRWLockExclusive(&mutex->lock); - trace_qemu_mutex_locked(mutex, file, line); + qemu_mutex_post_lock(mutex, file, line); } =20 int qemu_mutex_trylock_impl(QemuMutex *mutex, const char *file, const int = line) @@ -72,7 +71,7 @@ int qemu_mutex_trylock_impl(QemuMutex *mutex, const char = *file, const int line) assert(mutex->initialized); owned =3D TryAcquireSRWLockExclusive(&mutex->lock); if (owned) { - trace_qemu_mutex_locked(mutex, file, line); + qemu_mutex_post_lock(mutex, file, line); return 0; } return -EBUSY; @@ -81,7 +80,7 @@ int qemu_mutex_trylock_impl(QemuMutex *mutex, const char = *file, const int line) void qemu_mutex_unlock_impl(QemuMutex *mutex, const char *file, const int = line) { assert(mutex->initialized); - trace_qemu_mutex_unlock(mutex, file, line); + qemu_mutex_pre_unlock(mutex, file, line); ReleaseSRWLockExclusive(&mutex->lock); } =20 @@ -145,9 +144,9 @@ void qemu_cond_broadcast(QemuCond *cond) void qemu_cond_wait_impl(QemuCond *cond, QemuMutex *mutex, const char *fil= e, const int line) { assert(cond->initialized); - trace_qemu_mutex_unlock(mutex, file, line); + qemu_mutex_pre_unlock(mutex, file, line); SleepConditionVariableSRW(&cond->var, &mutex->lock, INFINITE, 0); - trace_qemu_mutex_locked(mutex, file, line); + qemu_mutex_post_lock(mutex, file, line); } =20 void qemu_sem_init(QemuSemaphore *sem, int init) --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530216865062440.9421602667195; Thu, 28 Jun 2018 13:14:25 -0700 (PDT) Received: from localhost ([::1]:38321 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdJ7-00063h-4B for importer@patchew.org; Thu, 28 Jun 2018 16:14:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAY-0007Be-8O for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAW-0000KZ-Qd for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:30 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:51455) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAW-0000Id-IR for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:28 -0400 Received: by mail-wm0-x241.google.com with SMTP id w137-v6so11045995wmw.1 for ; Thu, 28 Jun 2018 13:05:28 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=3EWaxMKGlE5P48LNnpAUTWc7xkRhr/qftI18YCJyCCc=; b=a1vyjC5THAPLEXaR6H/cjoo03+ewyryL/PIQ56YdDiUg8els9G3EHKrXd1wSk83wGl 8N46veEfdwqScu0060V1fUmXzXAan8ENyf7Dz5VCcYqcp+V/D3jVRJeN9OfssZPJS9UP eZrDGAdE7VPs+LPfN9jGHM1MkFpx02Nk4CbaVCfVrGzgMBnWiX68iRGH1RNRCNf9hl/y OtSLdDwnQxELxRbpsljwD1uXQvmcuSQMEEgK2XMJ28mYY6aG27v2gAuPcY9uAd7KLt2j xlDVzGaOtnYvU1lmcYiPYR49DpT82BBeGQgCEzXuRKChoxewMbKOaDSoUPXxOumCnA5l mpww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=3EWaxMKGlE5P48LNnpAUTWc7xkRhr/qftI18YCJyCCc=; b=KtyngGPR+O3+4ke2Tjf/RmBSsid0JYWYiioM7K5IjGI18bV0arCz+kD8W2fk5l7JXO 6qHfT4By+hV1dd4U0nMfhBxc33IDQ3psRo8AWbVhSNVZxXtf+OjL1tzRKe6R7R5lqDvP xQpulSclYWfacs2kGlB5otxRFbdJ46S4yEceSWu6tNTcm73+0gfLY2sPJoXHQI3tUxt7 gdmCrlLPPm/8aANtD20li/rvS8ilObc3ykXDWi89Sox2MxiDc3YxDOZLQho/pVwyWhHv Z3qzkSquE5RiWhvPp+HZH1W3g/RAAOMj5WAArMClsJRfSoflB+VjBlGry0ROVtONwaXU V08w== X-Gm-Message-State: APt69E1ip2FpDEmIlwssO3aVcOoNHBlNOSQAUupCsfO1hA2tRz+P3jHL VXzjzUayY8ELOPRhBWxotRzJOJ9P X-Google-Smtp-Source: AAOMgpeWe1qgjhGgIdWAXOt5aKBYtRlPs0EVXSO378cU6P9GtE4cvOPgc1iNEH08pQAG2H4k1nVc9w== X-Received: by 2002:a1c:a341:: with SMTP id m62-v6mr5902514wme.3.1530216327186; Thu, 28 Jun 2018 13:05:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:23 +0200 Message-Id: <1530216310-52873-14-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 13/60] QemuMutex: support --enable-debug-mutex X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We have had some tracing tools for mutex but it's not easy to use them for e.g. dead locks. Let's provide "--enable-debug-mutex" parameter when configure to allow QemuMutex to store the last owner that took specific lock. It will be easy to use this tool to debug deadlocks since we can directly know who took the lock then as long as we can have a debugger attached to the process. Reviewed-by: Emilio G. Cota Signed-off-by: Peter Xu Message-Id: <20180425025459.5258-4-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- configure | 10 ++++++++++ include/qemu/thread-posix.h | 4 ++++ include/qemu/thread-win32.h | 4 ++++ util/qemu-thread-common.h | 12 ++++++++++++ 4 files changed, 30 insertions(+) diff --git a/configure b/configure index 4d12cfb..3f53aa7 100755 --- a/configure +++ b/configure @@ -456,6 +456,7 @@ replication=3D"yes" vxhs=3D"" libxml2=3D"" docker=3D"no" +debug_mutex=3D"no" =20 # cross compilers defaults, can be overridden with --cross-cc-ARCH cross_cc_aarch64=3D"aarch64-linux-gnu-gcc" @@ -1411,6 +1412,10 @@ for opt do ;; --disable-git-update) git_update=3Dno ;; + --enable-debug-mutex) debug_mutex=3Dyes + ;; + --disable-debug-mutex) debug_mutex=3Dno + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1685,6 +1690,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: crypto-afalg Linux AF_ALG crypto backend driver vhost-user vhost-user support capstone capstone disassembler support + debug-mutex mutex debugging support =20 NOTE: The object files are built at the place where configure is launched EOF @@ -5951,6 +5957,7 @@ echo "seccomp support $seccomp" echo "coroutine backend $coroutine" echo "coroutine pool $coroutine_pool" echo "debug stack usage $debug_stack_usage" +echo "mutex debugging $debug_mutex" echo "crypto afalg $crypto_afalg" echo "GlusterFS support $glusterfs" echo "gcov $gcov_tool" @@ -6704,6 +6711,9 @@ fi if test "$capstone" !=3D "no" ; then echo "CONFIG_CAPSTONE=3Dy" >> $config_host_mak fi +if test "$debug_mutex" =3D "yes" ; then + echo "CONFIG_DEBUG_MUTEX=3Dy" >> $config_host_mak +fi =20 # Hold two types of flag: # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name = on diff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h index f3f47e4..fd27b34 100644 --- a/include/qemu/thread-posix.h +++ b/include/qemu/thread-posix.h @@ -12,6 +12,10 @@ typedef QemuMutex QemuRecMutex; =20 struct QemuMutex { pthread_mutex_t lock; +#ifdef CONFIG_DEBUG_MUTEX + const char *file; + int line; +#endif bool initialized; }; =20 diff --git a/include/qemu/thread-win32.h b/include/qemu/thread-win32.h index 3a05e3b..d668d78 100644 --- a/include/qemu/thread-win32.h +++ b/include/qemu/thread-win32.h @@ -5,6 +5,10 @@ =20 struct QemuMutex { SRWLOCK lock; +#ifdef CONFIG_DEBUG_MUTEX + const char *file; + int line; +#endif bool initialized; }; =20 diff --git a/util/qemu-thread-common.h b/util/qemu-thread-common.h index d329208..a0ea7c0 100644 --- a/util/qemu-thread-common.h +++ b/util/qemu-thread-common.h @@ -19,6 +19,10 @@ =20 static inline void qemu_mutex_post_init(QemuMutex *mutex) { +#ifdef CONFIG_DEBUG_MUTEX + mutex->file =3D NULL; + mutex->line =3D 0; +#endif mutex->initialized =3D true; } =20 @@ -31,12 +35,20 @@ static inline void qemu_mutex_pre_lock(QemuMutex *mutex, static inline void qemu_mutex_post_lock(QemuMutex *mutex, const char *file, int line) { +#ifdef CONFIG_DEBUG_MUTEX + mutex->file =3D file; + mutex->line =3D line; +#endif trace_qemu_mutex_locked(mutex, file, line); } =20 static inline void qemu_mutex_pre_unlock(QemuMutex *mutex, const char *file, int line) { +#ifdef CONFIG_DEBUG_MUTEX + mutex->file =3D NULL; + mutex->line =3D 0; +#endif trace_qemu_mutex_unlock(mutex, file, line); } =20 --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217539656714.7696420275956; Thu, 28 Jun 2018 13:25:39 -0700 (PDT) Received: from localhost ([::1]:38384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdU2-0007DJ-Tr for importer@patchew.org; Thu, 28 Jun 2018 16:25:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAb-0007C9-1i for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAX-0000Lr-Jr for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:30 -0400 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:38381) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAX-0000KF-7h for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:29 -0400 Received: by mail-wm0-x22c.google.com with SMTP id 69-v6so10225700wmf.3 for ; Thu, 28 Jun 2018 13:05:29 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=yv188HNYiqPvfgNxa/+s6K1wC14fapSQisEUVPD8eDY=; b=tR19uKlByr94rMqBAUm+/CdeXUQkgh1FXr/QGzca1bQnSenKAHlsllYUN88kBE7zA0 toZnMSW2w/G+SR+FrIUjlwJk1E9WweHOuqvN9PiJ7IEGKwDoZGnQaoZDhowZZBXXxAIB xxp+pywb/XAqfEqTX3o6Kk7Hesq0C9zMhip3zTcfFo6AuLlReamkV5/i9UyVc9EnJsgR KQPdU77PJK2ITPKcF/Uh9Xh+so5jkySDNeGNGahu9GySlzUrKgOd08P6lRZ3qiJ2gyRn 46kdxweo0q1pjOXqy1dArHuTkzOZG92Xtx3RhOwNnSh6S7c8uGn85lJhzXF1riyQFAYq diyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=yv188HNYiqPvfgNxa/+s6K1wC14fapSQisEUVPD8eDY=; b=tuYHzRtx/noJw7j3/s/31VBRMZsTyNiuFVb5WOHfqUXahageuxyH3saUN4dR30GOYc 0hM+jMWZxiQY9xH5PKjr1TEW33ox2sFSjpHHuEnRpoOPIy3kVYi+4vulkpnZs8L6oDWG IGiCIx6toIi0MVbViYr6zJ88Ou20jlHYG1ApXRLhwEE0zdd82LmK15y0i+8CbcSQlb6M +F0XttpaD9MUdFvFAY2GY4OKPIZwZBQnpwlfFnu25c8MgiUWcgl24TXmAOyA+nQUwrYM ZPmtVCed5u0VQi/WhqqtpjsdQeLSTaxVTnzSYXrsV6ifqymzGqV8QOCVUakBT2m8TCP8 nCMw== X-Gm-Message-State: APt69E344YX+o0YqUkqRBbt/p4DkNhf7vx6dLsCsh/hiGK0C4G5TTpqE 5CvxMA4xgBtMSsb0K/wHvKKMqXIz X-Google-Smtp-Source: AAOMgpcmjPO087BoepbeBBEaPQtYzjyRxJwmDhC5NJEhb/nmQvfaP00Zi4AXiKc9zAeqEN/wgW5yqw== X-Received: by 2002:a1c:5a45:: with SMTP id o66-v6mr6959741wmb.31.1530216328010; Thu, 28 Jun 2018 13:05:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:24 +0200 Message-Id: <1530216310-52873-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22c Subject: [Qemu-devel] [PULL 14/60] configure: enable debug-mutex if debug enabled X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu Reviewed-by: Emilio G. Cota Signed-off-by: Peter Xu Message-Id: <20180425025459.5258-5-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 3f53aa7..ca7de4f 100755 --- a/configure +++ b/configure @@ -1042,6 +1042,7 @@ for opt do --enable-debug) # Enable debugging options that aren't excessively noisy debug_tcg=3D"yes" + debug_mutex=3D"yes" debug=3D"yes" strip_opt=3D"no" fortify_source=3D"no" --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530216879338844.0012916621174; Thu, 28 Jun 2018 13:14:39 -0700 (PDT) Received: from localhost ([::1]:38322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdJO-0006LQ-GG for importer@patchew.org; Thu, 28 Jun 2018 16:14:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAb-0007CB-1m for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAZ-0000Na-06 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:32 -0400 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:43832) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAY-0000MV-IW for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:30 -0400 Received: by mail-wr0-x241.google.com with SMTP id c5-v6so6681106wrs.10 for ; Thu, 28 Jun 2018 13:05:30 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=k4U0DeNL4LEPg5UIzmSZdI2Mn4wyplZmbJei5YIj3hI=; b=e5GK+drx0wT+Z91aej1Xn6j2thedGxwzc43Sra8pm+7wY4x82OIpCUps7xMwzMFyoy Vbwr5B1aDVUAGK8nA0Oq4M96JdsQU+aY5C87QUQ03wQwoV7D90lYaCcWFO6dDm8sw1DK Rw14gtRyZTUkZPuClE8RpsUGW1xjw3oDYuqYRgSEs80DlNc8GkXzM+wGm7P9i4uP9M5y 2wiXvpD+4+Af5r9/uheKtC6GRArhTlmPLAghOgAMc5MpLn8rAAqhr/ZpZgt5Gd8TKb9K wQy1cKG2iXJPMmucDAOR3dSbLvQYknC+3UHe9TVY6xg2WMpDelIAsQwBV0T7GjkjcP1j mnCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=k4U0DeNL4LEPg5UIzmSZdI2Mn4wyplZmbJei5YIj3hI=; b=hwUNIvBiESVL7pcD8BJSVP4cNFl5QBoIsfhskNGGFULDT3hPxfC7EHdW2f7IuCtZMP sE1nNoreEjIeM59VSG+3xMHN7KqWUuVr7lfy57FGV8i5AYKKyvt5HWGCpK1wN2Zd0oMc 8WBlTwh7ha+mPcRfRRoPhOFiuaZFaK36Tk/oL6GID4eiADIsb/ocwD7v9I2oMQuQxsLp 0mHaWKCD/HXz1qWf9omoMV3CmVJ55FJNNAg47RPh+Z/aIeg9Tp+x6Dj0hGQVlCuDjMik NLdT9d2bweZlJS9TraXwahQ5aJoeX4Gpk35Lbd6E8+pEe/jG85Et5HWj3xmDzKN4WWQb EJaQ== X-Gm-Message-State: APt69E2yTVxf4KKrMHNbcbC+ej3wkp107ewLiCLcHeLoDlmQYC+mx2Mz 8RLhpirrNtELDo20caFO0rhju+Kv X-Google-Smtp-Source: AAOMgpfAlZZLSI55x/TXtxXzC9IKZHQA1xsFsgZXTtd5Xevi7VRxeydB1sh0AW8oV+PhEbVxWNJ43A== X-Received: by 2002:adf:d4c5:: with SMTP id w5-v6mr9561269wrk.185.1530216329028; Thu, 28 Jun 2018 13:05:29 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:25 +0200 Message-Id: <1530216310-52873-16-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 15/60] Replace '-enable-kvm' with '-accel kvm' in docs and help texts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth The preferred way to select the KVM accelerator is to use "-accel kvm" these days, so let's be consistent in our documentation and help texts. Signed-off-by: Thomas Huth Message-Id: <1528866321-23886-3-git-send-email-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- docs/COLO-FT.txt | 8 ++++---- docs/can.txt | 4 ++-- docs/multi-thread-compression.txt | 2 +- docs/multiseat.txt | 2 +- docs/specs/tpm.txt | 8 ++++---- hw/block/dataplane/virtio-blk.c | 4 ++-- hw/scsi/virtio-scsi-dataplane.c | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/COLO-FT.txt b/docs/COLO-FT.txt index e289be2..d7c7dcd 100644 --- a/docs/COLO-FT.txt +++ b/docs/COLO-FT.txt @@ -113,16 +113,16 @@ by using 'x-colo-lost-heartbeat' command. =3D=3D Test procedure =3D=3D 1. Startup qemu Primary: -# qemu-kvm -enable-kvm -m 2048 -smp 2 -qmp stdio -vnc :7 -name primary \ - -device piix3-usb-uhci \ +# qemu-system-x86_64 -accel kvm -m 2048 -smp 2 -qmp stdio -name primary \ + -device piix3-usb-uhci -vnc :7 \ -device usb-tablet -netdev tap,id=3Dhn0,vhost=3Doff \ -device virtio-net-pci,id=3Dnet-pci0,netdev=3Dhn0 \ -drive if=3Dvirtio,id=3Dprimary-disk0,driver=3Dquorum,read-pattern=3Dfif= o,vote-threshold=3D1,\ children.0.file.filename=3D1.raw,\ children.0.driver=3Draw -S Secondary: -# qemu-kvm -enable-kvm -m 2048 -smp 2 -qmp stdio -vnc :7 -name secondary \ - -device piix3-usb-uhci \ +# qemu-system-x86_64 -accel kvm -m 2048 -smp 2 -qmp stdio -name secondary \ + -device piix3-usb-uhci -vnc :7 \ -device usb-tablet -netdev tap,id=3Dhn0,vhost=3Doff \ -device virtio-net-pci,id=3Dnet-pci0,netdev=3Dhn0 \ -drive if=3Dnone,id=3Dsecondary-disk0,file.filename=3D1.raw,driver=3Draw= ,node-name=3Dnode0 \ diff --git a/docs/can.txt b/docs/can.txt index a357105..7ba23b2 100644 --- a/docs/can.txt +++ b/docs/can.txt @@ -52,7 +52,7 @@ The ''kvaser_pci'' board/device model is compatible with = and has been tested wit The tested setup was Linux 4.9 kernel on the host and guest side. Example for qemu-system-x86_64: =20 - qemu-system-x86_64 -enable-kvm -kernel /boot/vmlinuz-4.9.0-4-amd64 \ + qemu-system-x86_64 -accel kvm -kernel /boot/vmlinuz-4.9.0-4-amd64 \ -initrd ramdisk.cpio \ -virtfs local,path=3Dshareddir,security_model=3Dnone,mount_tag=3Dsha= reddir \ -object can-bus,id=3Dcanbus0 \ @@ -104,4 +104,4 @@ Links to other resources Slides http://rtime.felk.cvut.cz/publications/public/rtlws2015-qemu-can-slid= es.pdf (5) Linux SocketCAN utilities - https://github.com/linux-can/can-utils/ \ No newline at end of file + https://github.com/linux-can/can-utils/ diff --git a/docs/multi-thread-compression.txt b/docs/multi-thread-compress= ion.txt index d0caaf7..bb88c6b 100644 --- a/docs/multi-thread-compression.txt +++ b/docs/multi-thread-compression.txt @@ -62,7 +62,7 @@ RAM: 128G NIC: Intel I350 (10/100/1000Mbps) Host OS: CentOS 7 64-bit Guest OS: RHEL 6.5 64-bit -Parameter: qemu-system-x86_64 -enable-kvm -smp 4 -m 4096 +Parameter: qemu-system-x86_64 -accel kvm -smp 4 -m 4096 /share/ia32e_rhel6u5.qcow -monitor stdio =20 There is no additional application is running on the guest when doing diff --git a/docs/multiseat.txt b/docs/multiseat.txt index 807518c..dc28cdb 100644 --- a/docs/multiseat.txt +++ b/docs/multiseat.txt @@ -18,7 +18,7 @@ or =20 Next put together the qemu command line (sdk/gtk): =20 -qemu -enable-kvm -usb $memory $disk $whatever \ +qemu -accel kvm -usb $memory $disk $whatever \ -display [ sdl | gtk ] \ -vga std \ -device usb-tablet diff --git a/docs/specs/tpm.txt b/docs/specs/tpm.txt index c230c4c..70ad4a0 100644 --- a/docs/specs/tpm.txt +++ b/docs/specs/tpm.txt @@ -98,7 +98,7 @@ QEMU files related to the TPM passthrough device: Command line to start QEMU with the TPM passthrough device using the host's hardware TPM /dev/tpm0: =20 -qemu-system-x86_64 -display sdl -enable-kvm \ +qemu-system-x86_64 -display sdl -accel kvm \ -m 1024 -boot d -bios bios-256k.bin -boot menu=3Don \ -tpmdev passthrough,id=3Dtpm0,path=3D/dev/tpm0 \ -device tpm-tis,tpmdev=3Dtpm0 test.img @@ -164,7 +164,7 @@ swtpm socket --tpmstate dir=3D/tmp/mytpm1 \ Command line to start QEMU with the TPM emulator device communicating with the swtpm: =20 -qemu-system-x86_64 -display sdl -enable-kvm \ +qemu-system-x86_64 -display sdl -accel kvm \ -m 1024 -boot d -bios bios-256k.bin -boot menu=3Don \ -chardev socket,id=3Dchrtpm,path=3D/tmp/mytpm1/swtpm-sock \ -tpmdev emulator,id=3Dtpm0,chardev=3Dchrtpm \ @@ -222,7 +222,7 @@ swtpm socket --tpmstate dir=3D/tmp/mytpm1 \ =20 In a 2nd terminal start the VM: =20 -qemu-system-x86_64 -display sdl -enable-kvm \ +qemu-system-x86_64 -display sdl -accel kvm \ -m 1024 -boot d -bios bios-256k.bin -boot menu=3Don \ -chardev socket,id=3Dchrtpm,path=3D/tmp/mytpm1/swtpm-sock \ -tpmdev emulator,id=3Dtpm0,chardev=3Dchrtpm \ @@ -255,7 +255,7 @@ swtpm socket --tpmstate dir=3D/tmp/mytpm1 \ In the 2nd terminal restore the state of the VM using the additonal '-incoming' option. =20 -qemu-system-x86_64 -display sdl -enable-kvm \ +qemu-system-x86_64 -display sdl -accel kvm \ -m 1024 -boot d -bios bios-256k.bin -boot menu=3Don \ -chardev socket,id=3Dchrtpm,path=3D/tmp/mytpm1/swtpm-sock \ -tpmdev emulator,id=3Dtpm0,chardev=3Dchrtpm \ diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-bl= k.c index d648aeb..8c37bd3 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -190,8 +190,8 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) /* Set up guest notifier (irq) */ r =3D k->set_guest_notifiers(qbus->parent, nvqs, true); if (r !=3D 0) { - fprintf(stderr, "virtio-blk failed to set guest notifier (%d), " - "ensure -enable-kvm is set\n", r); + error_report("virtio-blk failed to set guest notifier (%d), " + "ensure -accel kvm is set.", r); goto fail_guest_notifiers; } =20 diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplan= e.c index 912e500..b995bab 100644 --- a/hw/scsi/virtio-scsi-dataplane.c +++ b/hw/scsi/virtio-scsi-dataplane.c @@ -142,8 +142,8 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev) /* Set up guest notifier (irq) */ rc =3D k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, t= rue); if (rc !=3D 0) { - fprintf(stderr, "virtio-scsi: Failed to set guest notifiers (%d), " - "ensure -enable-kvm is set\n", rc); + error_report("virtio-scsi: Failed to set guest notifiers (%d), " + "ensure -accel kvm is set.", rc); goto fail_guest_notifiers; } =20 --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153021704353635.90767911320677; Thu, 28 Jun 2018 13:17:23 -0700 (PDT) Received: from localhost ([::1]:38339 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdM2-0000MF-K3 for importer@patchew.org; Thu, 28 Jun 2018 16:17:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAb-0007CA-1o for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAZ-0000Oi-Bd for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:32 -0400 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:39705) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAZ-0000My-4p for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:31 -0400 Received: by mail-wm0-x234.google.com with SMTP id p11-v6so10223452wmc.4 for ; Thu, 28 Jun 2018 13:05:31 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=4ijFTJHMnKwIMRfEJb4Ln6y2Q/nySaCPRXrRlbQfTDY=; b=EGi4pdHbNbhxDNkDlRZ3/70c1i8SMtR+3A/2QyFVBAvhaHMa4Xn87bdoNnEFKZFG/T QJRO5cM/BpHUrS1UH0hl2cPdnaLdvOOXtDToeegWlOo5UMNjqKqUPkRICuDtGFMUFT5a bBw2/PfbZG+xdUmbML8Y9nFENzQuNK50s5jKtkwkkTorHOgbw5QBYprt5yAYzuuDmPtZ dCP2zV2pzkCY5UdzYEnNJFV7JOZP3pTs9KWWmFEDkwxPww1d8ZWmsJxWnlwDLf3gOf7k Pq/fLmXVpB9T3OkIn5f91jq431+eOGfv7o63WXg5lb2POZe+Xm4aBvjEBt/ZiLqaOGI1 bAkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=4ijFTJHMnKwIMRfEJb4Ln6y2Q/nySaCPRXrRlbQfTDY=; b=LKQfbqlQzsAWPAps9xVlPWEGVte+9GyZ5H9o0Bu7OUGs9GjIbzx+0rPhD/rRxoA8UP Puuwj++FadsE7HrjzenYUQgF0WsAFs3jc1frhJHbaex9aEy5NHgg6IlJwI6T48hUR3fl /1lpAbOOwcIYBc0XSiKAfDzBmNPcnXFbWvrKqNghYIGtS/CIYH7KKUqUIxbsoxabrQkz 924u9ygvPAhH0ggySSlsvaz4suzvDF56ykdrE5CK8TpWaSP+CKy+xUcYUNuY6OuK+t85 GApQK0le+0lO0CnUJMVyrRP5toUp1iYUts82bddjyyoxslrae0Y3j0nY5lT8MDjon3xV Xxmg== X-Gm-Message-State: APt69E1FryZtKoLVVHnMsy2DE4USPwY6hWwhjruzUxJSM8Vb2yG6Wa6t aCg8J21WGW5nq8YvHHXMWf42FA4w X-Google-Smtp-Source: AAOMgpdFXwkgOHD/wPKNv6CP1Kiqf0y+6xBc+ZguJk5UQklZFMmRgagTNeGuJrBLymzgT50YrkT46Q== X-Received: by 2002:a1c:30d7:: with SMTP id w206-v6mr8877280wmw.153.1530216329846; Thu, 28 Jun 2018 13:05:29 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:26 +0200 Message-Id: <1530216310-52873-17-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::234 Subject: [Qemu-devel] [PULL 16/60] qemu-options: Add missing newline to -accel help text X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Andres Gomez Del Real , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eduardo Habkost The newline was removed by commit c97d6d2c, and broke -help output: Before this patch: $ qemu-system-x86_64 -help | grep smp thread=3Dsingle|multi (enable multi-threaded TCG)-smp [..= .] After this patch: $ qemu-system-x86_64 -help | grep smp -smp [cpus=3D]n[,maxcpus=3Dcpus][,cores=3Dcores][,threads=3Dthreads][,soc= kets=3Dsockets] Fixes: c97d6d2cdf97edb4aebe832fdba65d701ad7bcb6 Cc: Sergio Andres Gomez Del Real Signed-off-by: Eduardo Habkost Message-Id: <20180611195607.3015-1-ehabkost@redhat.com> Signed-off-by: Paolo Bonzini --- qemu-options.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-options.hx b/qemu-options.hx index d5b0c26..2707728 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -130,7 +130,7 @@ ETEXI DEF("accel", HAS_ARG, QEMU_OPTION_accel, "-accel [accel=3D]accelerator[,thread=3Dsingle|multi]\n" " select accelerator (kvm, xen, hax, hvf, whpx or tcg; = use 'help' for a list)\n" - " thread=3Dsingle|multi (enable multi-threaded TCG)", Q= EMU_ARCH_ALL) + " thread=3Dsingle|multi (enable multi-threaded TCG)\n",= QEMU_ARCH_ALL) STEXI @item -accel @var{name}[,prop=3D@var{value}[,...]] @findex -accel --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530216979067149.32916404386242; Thu, 28 Jun 2018 13:16:19 -0700 (PDT) Received: from localhost ([::1]:38338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdL0-0007zf-8Y for importer@patchew.org; Thu, 28 Jun 2018 16:16:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAb-0007CD-7v for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAa-0000RD-AC for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:33 -0400 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:53876) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAa-0000PJ-26 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:32 -0400 Received: by mail-wm0-x231.google.com with SMTP id b188-v6so4901561wme.3 for ; Thu, 28 Jun 2018 13:05:31 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=N+koExkxy3DF4WMLrr6qJgGmlW4P0brbpmD2cDSpq2Q=; b=Cu8/FHl+srWfZomBXIaiHbdwnvr4D5CySw/6KfCffhji5GZAebo0qBrQarboO6aTje 6jBFP+UxL5LbbJRJY1EDI+EyucT6kW9aGBlxTEZeo2i2tJKBVo1gbg8OobctqI8pCwkF OVE2DXErSSVVYI2HdlCjXoMZUdnKrr6cpzdxreGeuFaMd6qb22nujXd1LRX9RX+ZqYBi VgZUrZVevure2DcifVg598aKeeua9spr6IpRehulqgmcLsEM31SQiy0pu63rMwpU3WmL FW0FNPZ88AFD9lgaiMG2V3TieOThliZ042eAu1nIh8RVD2ncfPbBdQP+zCiywylq3dGl ulMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=N+koExkxy3DF4WMLrr6qJgGmlW4P0brbpmD2cDSpq2Q=; b=kvt3ltAd7IrESjZAugZtntw/jOLzEAZi0jUEedBxp64cSe39kKc049GvTCDRuEzFKL Lgit4khxL7Wq1CKQK00UlU1MNn/NER4IKq2Pp98Fz8QJXi4jZv8ZSrEQc88hGaHee+qS h8H+mTKKCooLKtXPRF660YCLFnsJFP94Y+PzGdsKBP0ByuOTXHxDnB2Uxr/SSkEgvk/d R3RTFbRr75UZ1eO+VZx8fDA+tw55kTrvqSgZLvhH6nM7nBjslzjRYN0IKaz42B5fCaDF DDG4xmyRwz3ekOtleYUN20L2M34upgKOQt9OpO3v+a89/pYDkeAOy7le9DLaGSrtMxeH KtRQ== X-Gm-Message-State: APt69E01jX3op+N3enYDMvJaX9XyfYKFMKiKtNr5Vu5zEGqeN460gTpT /RW7/d5p61aD421RfcNLHmPPmb3q X-Google-Smtp-Source: AAOMgpckxrdYHWRG0ttDpz8VeH/h2mUeuXgM3hNXBYh1/QDbezPDS4WFc6KnipkBGWuLdxX2/gcVCw== X-Received: by 2002:a1c:e80f:: with SMTP id f15-v6mr9068994wmh.137.1530216330746; Thu, 28 Jun 2018 13:05:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:27 +0200 Message-Id: <1530216310-52873-18-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::231 Subject: [Qemu-devel] [PULL 17/60] pc-dimm: remove leftover "struct pc_dimms_capacity" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Not needed anymore, let's drop it. Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Signed-off-by: David Hildenbrand Message-Id: <20180619134141.29478-2-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/mem/pc-dimm.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 12da89d..62b34a9 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -27,11 +27,6 @@ #include "sysemu/numa.h" #include "trace.h" =20 -typedef struct pc_dimms_capacity { - uint64_t size; - Error **errp; -} pc_dimms_capacity; - void pc_dimm_memory_plug(DeviceState *dev, MachineState *machine, uint64_t align, Error **errp) { --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217242934185.57080540172717; Thu, 28 Jun 2018 13:20:42 -0700 (PDT) Received: from localhost ([::1]:38352 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdPG-0002op-4B for importer@patchew.org; Thu, 28 Jun 2018 16:20:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAe-0007Fa-B3 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAb-0000Sm-9J for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:36 -0400 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:37461) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAb-0000RK-1f for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:33 -0400 Received: by mail-wr0-x242.google.com with SMTP id k6-v6so6687596wrp.4 for ; Thu, 28 Jun 2018 13:05:32 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=pGBPjQv4iVxrnBOwF56X6ZfN58M7mHOC4l+yOotFfDo=; b=RLl+BmY0nuiqp0OQZ+hzkF6Ka750WEQc3xWQ3AyXJXBnpAXRYjv0xcVJJKpls8dEez b4XZ+jtVJhDu3VT6d32tFjWvvy2+9Ag7UN7NBv9QJ/bPc0hE3U8G6mxFSfdsSQVqtdUU NoVhSbr6J25pk5RG+IRvoXQNu5FYDoSOqqjIhmm55HN4jTcQPYeB9i9J3QzqkJMN9FbB zBBjN9lvjebKSQuKuscS3nO6U0Nx23C9P2kWjdv4i68J0RqflT8fXNvQNVa6c9Bq76bA /HbMytWPNBkW4KD2pPIvR/t0ZF5V/y4bDmYfnlM08R5JG37AGAqLHN0eHrRLHDX68r4/ 2LXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=pGBPjQv4iVxrnBOwF56X6ZfN58M7mHOC4l+yOotFfDo=; b=UNQgBCLPyRJGyG7RGb1nF9X29zrtdd6xC0if/vk3n9gqrw9pnm9vIMXIcN47z3PO2Q 5LaKD+GzQ2dzN9mB0FSPZWH+QtUkJYbJbteHAGa5ixCcATQHiXQ6Pt+dUoTAVxnEGusz F+QCUw8sw+gDEjp8EJ3nCOjoxFjQ7qUsRzgGQ9N0TCpP8b1Y/5f4updti2VSL7RyMmJj aZmlAeFTiuV+oqGJBLe805MGZsMZA82P/JBC1EQcitEUhmqjvTdlI9tD/czU1G/M2rXN GNUf2tOEOsnqBeyVPW3CxFKr7q7W0aRAfaJNwHRHBvuzNU5gIp2aO2pNn+NQnJAmQz9a D4cw== X-Gm-Message-State: APt69E1fFIftzCaFVjzESfSK77p3TtIEpHChFolMwtxkDuOcLjkOmnTx rPW5yReZYHkDBsI+XNbVZjkYYmzJ X-Google-Smtp-Source: AAOMgpeQXGPea1lSqCSFzGpu7QpSLI8pvr7TPzUa2hOzkJT+dOFhWBkzgKG4MOhQMTQT4LZ1f5cKyg== X-Received: by 2002:adf:96b2:: with SMTP id u47-v6mr10108534wrb.204.1530216331729; Thu, 28 Jun 2018 13:05:31 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:28 +0200 Message-Id: <1530216310-52873-19-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 18/60] pc: rename pc_dimm_(plug|unplug|...)* into pc_memory_(plug|unplug|...)* X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Use a similar naming scheme as spapr. This way, we can go ahead and rename e.g. pc_dimm_memory_plug to pc_dimm_plug, which avoids confusion. Reviewed-by: Igor Mammedov Reviewed-by: David Gibson Signed-off-by: David Hildenbrand Message-Id: <20180619134141.29478-3-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 622e49d..f9250ff 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1674,8 +1674,8 @@ void ioapic_init_gsi(GSIState *gsi_state, const char = *parent_name) } } =20 -static void pc_dimm_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void pc_memory_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { HotplugHandlerClass *hhc; Error *local_err =3D NULL; @@ -1728,8 +1728,8 @@ out: error_propagate(errp, local_err); } =20 -static void pc_dimm_unplug_request(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void pc_memory_unplug_request(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { HotplugHandlerClass *hhc; Error *local_err =3D NULL; @@ -1759,8 +1759,8 @@ out: error_propagate(errp, local_err); } =20 -static void pc_dimm_unplug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void pc_memory_unplug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); HotplugHandlerClass *hhc; @@ -2015,7 +2015,7 @@ static void pc_machine_device_plug_cb(HotplugHandler = *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - pc_dimm_plug(hotplug_dev, dev, errp); + pc_memory_plug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { pc_cpu_plug(hotplug_dev, dev, errp); } @@ -2025,7 +2025,7 @@ static void pc_machine_device_unplug_request_cb(Hotpl= ugHandler *hotplug_dev, DeviceState *dev, Error **= errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - pc_dimm_unplug_request(hotplug_dev, dev, errp); + pc_memory_unplug_request(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { pc_cpu_unplug_request_cb(hotplug_dev, dev, errp); } else { @@ -2038,7 +2038,7 @@ static void pc_machine_device_unplug_cb(HotplugHandle= r *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - pc_dimm_unplug(hotplug_dev, dev, errp); + pc_memory_unplug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { pc_cpu_unplug_cb(hotplug_dev, dev, errp); } else { --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217177814293.31166612848403; Thu, 28 Jun 2018 13:19:37 -0700 (PDT) Received: from localhost ([::1]:38351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdOD-0001se-10 for importer@patchew.org; Thu, 28 Jun 2018 16:19:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAe-0007FZ-Aq for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAc-0000UR-9U for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:36 -0400 Received: from mail-wr0-x22f.google.com ([2a00:1450:400c:c0c::22f]:37251) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAc-0000T8-0f for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:34 -0400 Received: by mail-wr0-x22f.google.com with SMTP id k6-v6so6687640wrp.4 for ; Thu, 28 Jun 2018 13:05:33 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=8HJqoIgW2SOlZERvdCuYvIalarQkquMATz1VXgQvpt4=; b=XvOzDl1hVoAIT69KHuSePhJWD5rC4sCeaqmDUumeEqM2h8BLe7kjFObiD13XY7gmeP huz3052NjA8opExYfcUTVjhEODIQB2Q2U6U4p8Bg1xB+Azs1Yn0uSM/J+23ElBP34gYR WALWPl1JYrugXYzJiOy4+JnZenDqf1a3USGohxqyWZwqBAWsrsJsKb7SGerBW+O2SZJR GQRadgAuChtHfk0uznpDUmE1DoM9Nhx1lxAo/SRiliUOy0GWoDprR7m1uDd7bqcQKhrw uo89lmIhfKOL6byESdf9rFvGnd3YCQ3H4tMF2Mv6Ie0YTWoo2XtqzLfAdoW7zFcIbvJC u36A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=8HJqoIgW2SOlZERvdCuYvIalarQkquMATz1VXgQvpt4=; b=CqGzBRGgwcltsfLpBhVph7Xk7SiHeGY5j3+Is0Zk8h+fgAlQ7PkYVapdE2JbAeoDaF gU4UEoKpTthzT1OEHhnqItfjlQGU3M6xirUnvXqdp8t2354WXpub2VsrEVCCYWkuYFEd YdkRHDs7iwNXAv6TzKzmB5mHwObvwv/RDXshOyU6fQGACUqEeF2prcO02+vcw4DpOZ8L NahS2EnJ/+8mp2c/nZ27ix8Upv/+/rF/ivXaQXzzqEZPyjFeBfKCisqcxl9bPWaThSoZ E49Fc3AAroqAtsR2ruo8Bi1ms2Htff1IRI3PGLvC0PcNK8xqHtdEr++h6iRovkRawpQq FbMA== X-Gm-Message-State: APt69E2yjucDQZK4Lk9lCPcvmdyoaYZ51QnEH+5Z7ZiR3BTE5qLBmHZo E5YRXbp9imvpxW00sPPtaYsiVIdX X-Google-Smtp-Source: AAOMgpc6N4NqseN5T7abtqAOp2aJnHfJFE9G+eE8EEZ4EuT6teYyHEi2zuyXVmRlpwn0RRZ+h+GKzw== X-Received: by 2002:adf:bb08:: with SMTP id r8-v6mr2015791wrg.244.1530216332693; Thu, 28 Jun 2018 13:05:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:29 +0200 Message-Id: <1530216310-52873-20-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22f Subject: [Qemu-devel] [PULL 19/60] pc-dimm: rename pc_dimm_memory_* to pc_dimm_* X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Let's rename it to make it look more consistent. Reviewed-by: Igor Mammedov Reviewed-by: David Gibson Signed-off-by: David Hildenbrand Message-Id: <20180619134141.29478-4-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 4 ++-- hw/mem/pc-dimm.c | 6 +++--- hw/ppc/spapr.c | 6 +++--- include/hw/mem/pc-dimm.h | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f9250ff..f23133f 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1713,7 +1713,7 @@ static void pc_memory_plug(HotplugHandler *hotplug_de= v, goto out; } =20 - pc_dimm_memory_plug(dev, MACHINE(pcms), align, &local_err); + pc_dimm_plug(dev, MACHINE(pcms), align, &local_err); if (local_err) { goto out; } @@ -1773,7 +1773,7 @@ static void pc_memory_unplug(HotplugHandler *hotplug_= dev, goto out; } =20 - pc_dimm_memory_unplug(dev, MACHINE(pcms)); + pc_dimm_unplug(dev, MACHINE(pcms)); object_unparent(OBJECT(dev)); =20 out: diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 62b34a9..9e0c83e 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -27,8 +27,8 @@ #include "sysemu/numa.h" #include "trace.h" =20 -void pc_dimm_memory_plug(DeviceState *dev, MachineState *machine, - uint64_t align, Error **errp) +void pc_dimm_plug(DeviceState *dev, MachineState *machine, uint64_t align, + Error **errp) { int slot; PCDIMMDevice *dimm =3D PC_DIMM(dev); @@ -84,7 +84,7 @@ out: error_propagate(errp, local_err); } =20 -void pc_dimm_memory_unplug(DeviceState *dev, MachineState *machine) +void pc_dimm_unplug(DeviceState *dev, MachineState *machine) { PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 0d032a1..3a1bd73 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3160,7 +3160,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, align =3D memory_region_get_alignment(mr); size =3D memory_region_size(mr); =20 - pc_dimm_memory_plug(dev, MACHINE(ms), align, &local_err); + pc_dimm_plug(dev, MACHINE(ms), align, &local_err); if (local_err) { goto out; } @@ -3183,7 +3183,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, return; =20 out_unplug: - pc_dimm_memory_unplug(dev, MACHINE(ms)); + pc_dimm_unplug(dev, MACHINE(ms)); out: error_propagate(errp, local_err); } @@ -3332,7 +3332,7 @@ static void spapr_memory_unplug(HotplugHandler *hotpl= ug_dev, DeviceState *dev) sPAPRMachineState *spapr =3D SPAPR_MACHINE(hotplug_dev); sPAPRDIMMState *ds =3D spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(= dev)); =20 - pc_dimm_memory_unplug(dev, MACHINE(hotplug_dev)); + pc_dimm_unplug(dev, MACHINE(hotplug_dev)); object_unparent(OBJECT(dev)); spapr_pending_dimm_unplugs_remove(spapr, ds); } diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index 627c860..860343d 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -78,7 +78,7 @@ typedef struct PCDIMMDeviceClass { =20 int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp); =20 -void pc_dimm_memory_plug(DeviceState *dev, MachineState *machine, - uint64_t align, Error **errp); -void pc_dimm_memory_unplug(DeviceState *dev, MachineState *machine); +void pc_dimm_plug(DeviceState *dev, MachineState *machine, uint64_t align, + Error **errp); +void pc_dimm_unplug(DeviceState *dev, MachineState *machine); #endif --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217076485386.6413139353158; Thu, 28 Jun 2018 13:17:56 -0700 (PDT) Received: from localhost ([::1]:38340 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdMT-0000dW-2U for importer@patchew.org; Thu, 28 Jun 2018 16:17:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAe-0007Fc-BR for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAd-0000VT-3d for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:36 -0400 Received: from mail-wr0-x22a.google.com ([2a00:1450:400c:c0c::22a]:36281) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAc-0000UE-Sf for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:35 -0400 Received: by mail-wr0-x22a.google.com with SMTP id f16-v6so6686837wrm.3 for ; Thu, 28 Jun 2018 13:05:34 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=9Q0dN0FY1dujCdFHkQIpDdt3v5e4rTbvA8g7i9lgtTM=; b=RQWg6Jjx/ya6agmr2hWlufvuCL6/uVIx9gihBymhLTY2jRCOd6luWP7i75R02765qn bP2nvHHd9gz7EbSz5E2K1/tKPf8XvLKhy8wpAiTB2faxJfVaiVR0Bu31485SzaPsL6pr 2UL+kaujTqX/++IbaGVUGeytf26WSsXREqhnoFyoFenkeruFSiYpuHfmkdcVlrqqw0mB FUlSksBd+02/vTR0rFNWVToUwZibw++mDwf9Oe5LfeVr4/A/BVUNIKrtFzin6u92m2tn NfrgRSDJk425p2p/mViL9usA3KCX76nujk2/lxtZNKGQnhXXlq9nu+3QX7qR7xNdfoN9 KjKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=9Q0dN0FY1dujCdFHkQIpDdt3v5e4rTbvA8g7i9lgtTM=; b=Kw0HUT7zb5600Dv+UszAEGx+EaYEYHG58peMLAXB+vEEain1qZXg+K0SQC2vTrhjkU L1JZ8uwPXuoNnJEJx3D3C/4+BwlE0o//EDksEtkGW0lqfOWcYLAkZk8K+P+HOWb4WbpK peqZt3NzR+IcHhEJlv9eyWE75knCgKoNbxJcCIMtPUUcTrVZqyBct/ELxLcSsAklu6pi sa5v4laI6Bur+R0bhaWmGgX65fS5HVWTxWCtPk0YHlCTh6liKKCyO2YruzhdJHsSYP+h Zam0yUMkhaihskJqD4a5o4zgdQQVrPe+tBmQvN8KdBEn+W2v3QdZE1Xf0rAuqIECcaoA dvkA== X-Gm-Message-State: APt69E2aYyfu3Djle4d+xCb9jNJHVMTzQhe/hDD1zvLSy/l2GfxXlyQo 4TjVsP63DdJnrzpwHT9AWGA/3BUU X-Google-Smtp-Source: AAOMgpfzxH9QMMgrYpUx+I7s2FplINwN6B1MtnBf2W0d+7JXX8eqedCLxdMep10zdBQJexDjItJxYg== X-Received: by 2002:adf:8188:: with SMTP id 8-v6mr10259105wra.89.1530216333520; Thu, 28 Jun 2018 13:05:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:30 +0200 Message-Id: <1530216310-52873-21-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22a Subject: [Qemu-devel] [PULL 20/60] pc-dimm: remove pc_dimm_get_free_slot() from header X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Not used outside of pc-dimm.c and there shouldn't be other users. If other devices (e.g. memory devices) ever have to also use slots, then we will have to factor this out. Reviewed-by: Igor Mammedov Reviewed-by: David Gibson Signed-off-by: David Hildenbrand Message-Id: <20180619134141.29478-5-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/mem/pc-dimm.c | 4 +++- include/hw/mem/pc-dimm.h | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 9e0c83e..7387963 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -27,6 +27,8 @@ #include "sysemu/numa.h" #include "trace.h" =20 +static int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **e= rrp); + void pc_dimm_plug(DeviceState *dev, MachineState *machine, uint64_t align, Error **errp) { @@ -111,7 +113,7 @@ static int pc_dimm_slot2bitmap(Object *obj, void *opaqu= e) return 0; } =20 -int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp) +static int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **e= rrp) { unsigned long *bitmap; int slot =3D 0; diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index 860343d..cf71247 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -76,8 +76,6 @@ typedef struct PCDIMMDeviceClass { MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm); } PCDIMMDeviceClass; =20 -int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp); - void pc_dimm_plug(DeviceState *dev, MachineState *machine, uint64_t align, Error **errp); void pc_dimm_unplug(DeviceState *dev, MachineState *machine); --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15302177147061013.8904041794641; Thu, 28 Jun 2018 13:28:34 -0700 (PDT) Received: from localhost ([::1]:38400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdWs-0001BY-0D for importer@patchew.org; Thu, 28 Jun 2018 16:28:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAf-0007H6-G4 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAe-0000Xq-0d for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:37 -0400 Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]:42008) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAd-0000Vm-Po for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:35 -0400 Received: by mail-wr0-x22c.google.com with SMTP id p1-v6so6689122wrs.9 for ; Thu, 28 Jun 2018 13:05:35 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=3sDzIljycktkXNbH2ZEzSM90tNHYtaUKt5pi1OAYcJw=; b=o6oqyXyoFfjXezbzJWHc+StrGW7SmXSQwDMOYB574XMh+qzX9kIi5wcb8xR+Nn/tVu pcEqz2WzYyBDUfAi9Ob18WhPiO1djDPHpVAKu+lyKmu8RfXcDq4SiZKPJRG6wxZbUWRI cD2tomGmb8u06hTf1Tn6kEL9j0h4rAw01nQNcb+FdMliqN0Y89IpCmW3EZcpLpF7GwAI lQ8CuYU2+4zp4fY+VxitugAtp44qtdcN+22PjPgs+WaZj9Pz3DBWNfIQwlyi7tvojCmK OuWxfIWiBkbauQZl3gm1cDr2CHQZn8IAtcJfZsqDPErTlK7clR4NqJYvobO8kPUggHAP YKew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=3sDzIljycktkXNbH2ZEzSM90tNHYtaUKt5pi1OAYcJw=; b=DVy7iRovwEzWHUiEwoZ7Ka0bh8BVXyZmYQE3rzBXTWEiX6hzbQxpdKxeiCPNvh9O8U cKCJoA8wAx1TchRszM/+w4RjV1IcR2wBQYyBxyNoOUwhNGEQaACENE0qCfVNAW4WAicD uKcmqqEVgOmmC1BEWNlNfDMplLi5NSe+b33Kwu2I470OwE5kSQgiweYkoagslmi54fTM xuoFvwyAFn9f/EAnJI10rGK4a+tbcuXsQPQ+BwxNCdy4aVoEvM3gZDIu8S/bPEJAKBDF S0tJWrWN6a4Bsx4r+weC2L7fEWZOYbGiLbFqE3WcbQ6NCKircgano38TW+tZJHNSz7Zs DYkg== X-Gm-Message-State: APt69E3zKC8hQsjN++fEDXhyO9CP0/V87gULyLqlRmlT521L1ErEdraE wahp7C3zXlVOkehXmiUZTSPpcQOW X-Google-Smtp-Source: AAOMgpcTOJMvKNrallDyHLohXgXk9EL0wXZmd7zgc221Hl5D3wZWuEl0x9+ges7Eo3SljH10fH1lvg== X-Received: by 2002:adf:9d93:: with SMTP id p19-v6mr10149294wre.12.1530216334530; Thu, 28 Jun 2018 13:05:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:31 +0200 Message-Id: <1530216310-52873-22-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22c Subject: [Qemu-devel] [PULL 21/60] pc: factor out pc specific dimm checks into pc_memory_pre_plug() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand We can perform these checks before the device is actually realized. Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Signed-off-by: David Hildenbrand Message-Id: <20180619134141.29478-6-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f23133f..2db032a 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1674,6 +1674,29 @@ void ioapic_init_gsi(GSIState *gsi_state, const char= *parent_name) } } =20 +static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *d= ev, + Error **errp) +{ + const PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); + const bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); + + /* + * When -no-acpi is used with Q35 machine type, no ACPI is built, + * but pcms->acpi_dev is still created. Check !acpi_enabled in + * addition to cover this case. + */ + if (!pcms->acpi_dev || !acpi_enabled) { + error_setg(errp, + "memory hotplug is not enabled: missing acpi device or = acpi disabled"); + return; + } + + if (is_nvdimm && !pcms->acpi_nvdimm_state.is_enabled) { + error_setg(errp, "nvdimm is not enabled: missing 'nvdimm' in '-M'"= ); + return; + } +} + static void pc_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -1696,23 +1719,6 @@ static void pc_memory_plug(HotplugHandler *hotplug_d= ev, align =3D memory_region_get_alignment(mr); } =20 - /* - * When -no-acpi is used with Q35 machine type, no ACPI is built, - * but pcms->acpi_dev is still created. Check !acpi_enabled in - * addition to cover this case. - */ - if (!pcms->acpi_dev || !acpi_enabled) { - error_setg(&local_err, - "memory hotplug is not enabled: missing acpi device or = acpi disabled"); - goto out; - } - - if (is_nvdimm && !pcms->acpi_nvdimm_state.is_enabled) { - error_setg(&local_err, - "nvdimm is not enabled: missing 'nvdimm' in '-M'"); - goto out; - } - pc_dimm_plug(dev, MACHINE(pcms), align, &local_err); if (local_err) { goto out; @@ -2006,7 +2012,9 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + pc_memory_pre_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { pc_cpu_pre_plug(hotplug_dev, dev, errp); } } --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217262500499.0923094321953; Thu, 28 Jun 2018 13:21:02 -0700 (PDT) Received: from localhost ([::1]:38358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdPZ-0003By-Ne for importer@patchew.org; Thu, 28 Jun 2018 16:21:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAg-0007HF-2k for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAf-0000Zo-7L for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:38 -0400 Received: from mail-wr0-x235.google.com ([2a00:1450:400c:c0c::235]:37257) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAf-0000Yd-0R for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:37 -0400 Received: by mail-wr0-x235.google.com with SMTP id k6-v6so6687746wrp.4 for ; Thu, 28 Jun 2018 13:05:36 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=3vbZZBEoM62MO9oAA1r50TRiZYCl6URbZao2kU5LNFU=; b=VVVHvM2EJWpJoi9Hoo+WbS0jPjs35KcvmA5zZGQ0Ltsgjar4MKV0hE8j9pfsGzfpFT ZIzqK7wxR+edK+CVsVK28dmVeE/8AR5Klm0HEqwsTJnq1DLEK3VQaMeeIVHZlmUsxevZ SSyv1oIeCDWgDQmI+fB5MU7b273LrhZiM1LdKb8+/9ebUZaqebAFSz4UOHUGn8cLxk6e vtqrudlmvQyg5pA80fO451hkyFDINuBidoVBXqoiPz1Q5gN0FiHqgijXHoCY6vH8QUpE LNhiibAU8L2BiMxRJzxYT/t6qpIWci9yU52ngxX3VK+gG3ZnZQWXS5GGVH2B376Pyzul A8hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=3vbZZBEoM62MO9oAA1r50TRiZYCl6URbZao2kU5LNFU=; b=ZXFH9xEUahSKic93CF4qL3zm2i0B5mvHLFM6Lia/igirV8KfSBr7nJEXQ8QJjX01CT GK5nMBMRMUOhHTzAJS402+J2tpypdERywqnfUCdQUPOVuAWZ9ajRRqqGa9LI7+ZGgsLS Z7hAPGAfvjlevxek+5O/ubWQh/7/t/2bLBXKHX6ZFS8jZxNOe5OSSVZniKUv3+Ouo8m2 utMUuyPw0wIRHqsGACPhv0ER4ZxZp9MNKDv6BPja+ap8X3u51Al+xWn4L77IaLwUJ3kA EYxwKOxHYTNrAL4SgvG43W4sHSrHEybzQ1J2AtkpeEiHirb07lXgI/yDS0Epv7Xx9TUz 1m/w== X-Gm-Message-State: APt69E2bGi+wqmDfEsOoupcy501ogaIqehTjKbwiwT0N7+UUh07UTSvp rAhXpVAHrzRYRLoMYgVua0Dcf+rZ X-Google-Smtp-Source: AAOMgpfCni231IY6W3LIouV7YpqZyEw5UxE4vxOmPsH9sryr+FDsBEDJgJpkCklgl8HE6mjwYSGhUg== X-Received: by 2002:adf:aadb:: with SMTP id i27-v6mr2699809wrc.149.1530216335730; Thu, 28 Jun 2018 13:05:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:32 +0200 Message-Id: <1530216310-52873-23-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::235 Subject: [Qemu-devel] [PULL 22/60] nvdimm: no need to overwrite get_vmstate_memory_region() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Our parent class (PC_DIMM) provides exactly the same function. Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Signed-off-by: David Hildenbrand Message-Id: <20180619134141.29478-7-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/mem/nvdimm.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index 4087aca..f974acc 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -166,11 +166,6 @@ static void nvdimm_write_label_data(NVDIMMDevice *nvdi= mm, const void *buf, memory_region_set_dirty(mr, backend_offset, size); } =20 -static MemoryRegion *nvdimm_get_vmstate_memory_region(PCDIMMDevice *dimm) -{ - return host_memory_backend_get_memory(dimm->hostmem, &error_abort); -} - static void nvdimm_class_init(ObjectClass *oc, void *data) { PCDIMMDeviceClass *ddc =3D PC_DIMM_CLASS(oc); @@ -178,7 +173,6 @@ static void nvdimm_class_init(ObjectClass *oc, void *da= ta) =20 ddc->realize =3D nvdimm_realize; ddc->get_memory_region =3D nvdimm_get_memory_region; - ddc->get_vmstate_memory_region =3D nvdimm_get_vmstate_memory_region; =20 nvc->read_label_data =3D nvdimm_read_label_data; nvc->write_label_data =3D nvdimm_write_label_data; --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217370798476.08788111033846; Thu, 28 Jun 2018 13:22:50 -0700 (PDT) Received: from localhost ([::1]:38371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdRG-0004XC-EX for importer@patchew.org; Thu, 28 Jun 2018 16:22:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAh-0007Hk-Jq for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAg-0000bA-DV for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:39 -0400 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]:42010) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAg-0000aB-2x for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:38 -0400 Received: by mail-wr0-x22e.google.com with SMTP id p1-v6so6689204wrs.9 for ; Thu, 28 Jun 2018 13:05:37 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=/vFXuwJ9Iby1cM5bAqhnlf3ZGlZGZOceNi5Fs9aajoA=; b=nAlCmGr51AND1+vRd2lhk1dVFhu8tnxO8uKbplqmnoMRlCmoAeVO4HD1ZjJapTE8Do MsLqXg0vkl5s0Kbb8J8l2KnAiNIDWZ6zwWCas90x4PtjL6a2Z6M+kClFFp+jPllkANpp 4Q8rbKhbV7xGwQ+d4Mc0y21nu+MsTQa3MfX4iDtjo/cCxJVg6BR8aHBKLdMiUo2WsgHA F4ZChrKqIi6roYZs/fQnPW/mAR4LnBZViv+eUcU2vA1dg0myb5yaSneGiqFlsXB9wCVl d3pe/8jlVB5MDi4csnu2pHhpiEr5EQZsAay/J9kOi5kI2vEwFuqs9SPYNJXO0CEShsVw ur/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=/vFXuwJ9Iby1cM5bAqhnlf3ZGlZGZOceNi5Fs9aajoA=; b=ksA4+jsk83k2DRmjhzEKLDrSOtevelt2rXmbuEykIKYWhqANnItEbMqOFyAfpV1ZT0 BwpkBvnZrTU8RBQ9HjQ6yy+40vdhnbROvLJOthyKMRbAlDIn8cS5kNiVupzV90vuPpqv GMVQgVXiEOpVLLzZDtAxclQ2V2GeV0xs9kooMZz5BNNkwwzfnsNHE51f30yw5+5cEOXN UsSNwfY1+Qb3OlTKWxFPqS4PPv0wkVvjnFsOLkWy8X+o4lZl/1gDVgcBeU9/1p0Ls5dg xkgZ23BzUmAg0v57r4BNQ2h4RnXDhzT4yQMN26tDe3+RDV8X81RJspXLvrljY+4YLROD 5Efw== X-Gm-Message-State: APt69E0HTMLvXTvq1zyjqXAViZ2/cn/Rl+PAaDFtbus88D/12DOSNI87 NTqpWv5AyvG4vgqSRqNnl3PtrGX1 X-Google-Smtp-Source: AAOMgpeuxx4jSivUFsMVDMGm5MQkzaCLpvaOq4RQa/8/0QRtIBISQ3X7dRjJdF7JGgomlsbtzTQy2A== X-Received: by 2002:adf:f08e:: with SMTP id n14-v6mr10153838wro.49.1530216336751; Thu, 28 Jun 2018 13:05:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:33 +0200 Message-Id: <1530216310-52873-24-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22e Subject: [Qemu-devel] [PULL 23/60] hostmem: drop error variable from host_memory_backend_get_memory() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Unused, so let's remove it. Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Signed-off-by: David Hildenbrand Message-Id: <20180619134141.29478-8-david@redhat.com> Signed-off-by: Paolo Bonzini --- backends/hostmem.c | 3 +-- hw/mem/nvdimm.c | 4 ++-- hw/mem/pc-dimm.c | 4 ++-- hw/misc/ivshmem.c | 3 +-- include/sysemu/hostmem.h | 3 +-- numa.c | 3 +-- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index 3627e61..4908946 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -247,8 +247,7 @@ bool host_memory_backend_mr_inited(HostMemoryBackend *b= ackend) return memory_region_size(&backend->mr) !=3D 0; } =20 -MemoryRegion * -host_memory_backend_get_memory(HostMemoryBackend *backend, Error **errp) +MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend) { return host_memory_backend_mr_inited(backend) ? &backend->mr : NULL; } diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index f974acc..df97162 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -105,7 +105,7 @@ static MemoryRegion *nvdimm_get_memory_region(PCDIMMDev= ice *dimm, Error **errp) =20 static void nvdimm_realize(PCDIMMDevice *dimm, Error **errp) { - MemoryRegion *mr =3D host_memory_backend_get_memory(dimm->hostmem, err= p); + MemoryRegion *mr =3D host_memory_backend_get_memory(dimm->hostmem); NVDIMMDevice *nvdimm =3D NVDIMM(dimm); uint64_t align, pmem_size, size =3D memory_region_size(mr); =20 @@ -161,7 +161,7 @@ static void nvdimm_write_label_data(NVDIMMDevice *nvdim= m, const void *buf, =20 memcpy(nvdimm->label_data + offset, buf, size); =20 - mr =3D host_memory_backend_get_memory(dimm->hostmem, &error_abort); + mr =3D host_memory_backend_get_memory(dimm->hostmem); backend_offset =3D memory_region_size(mr) - nvdimm->label_size + offse= t; memory_region_set_dirty(mr, backend_offset, size); } diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 7387963..73f0eee 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -226,12 +226,12 @@ static MemoryRegion *pc_dimm_get_memory_region(PCDIMM= Device *dimm, Error **errp) return NULL; } =20 - return host_memory_backend_get_memory(dimm->hostmem, errp); + return host_memory_backend_get_memory(dimm->hostmem); } =20 static MemoryRegion *pc_dimm_get_vmstate_memory_region(PCDIMMDevice *dimm) { - return host_memory_backend_get_memory(dimm->hostmem, &error_abort); + return host_memory_backend_get_memory(dimm->hostmem); } =20 static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 16f0370..ee01c5e 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -909,8 +909,7 @@ static void ivshmem_common_realize(PCIDevice *dev, Erro= r **errp) if (s->hostmem !=3D NULL) { IVSHMEM_DPRINTF("using hostmem\n"); =20 - s->ivshmem_bar2 =3D host_memory_backend_get_memory(s->hostmem, - &error_abort); + s->ivshmem_bar2 =3D host_memory_backend_get_memory(s->hostmem); } else { Chardev *chr =3D qemu_chr_fe_get_driver(&s->server_chr); assert(chr); diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 5beb0ef..6e6bd2c 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -62,8 +62,7 @@ struct HostMemoryBackend { }; =20 bool host_memory_backend_mr_inited(HostMemoryBackend *backend); -MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend, - Error **errp); +MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend); =20 void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mappe= d); bool host_memory_backend_is_mapped(HostMemoryBackend *backend); diff --git a/numa.c b/numa.c index 33572bf..94f758c 100644 --- a/numa.c +++ b/numa.c @@ -523,8 +523,7 @@ void memory_region_allocate_system_memory(MemoryRegion = *mr, Object *owner, if (!backend) { continue; } - MemoryRegion *seg =3D host_memory_backend_get_memory(backend, - &error_fatal); + MemoryRegion *seg =3D host_memory_backend_get_memory(backend); =20 if (memory_region_is_mapped(seg)) { char *path =3D object_get_canonical_path_component(OBJECT(back= end)); --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217428141945.4168891775433; Thu, 28 Jun 2018 13:23:48 -0700 (PDT) Received: from localhost ([::1]:38374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdSF-0005Oh-6x for importer@patchew.org; Thu, 28 Jun 2018 16:23:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAi-0007Hn-95 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAh-0000cJ-6P for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:40 -0400 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:35986) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAg-0000b0-VV for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:39 -0400 Received: by mail-wm0-x235.google.com with SMTP id u18-v6so10302528wmc.1 for ; Thu, 28 Jun 2018 13:05:38 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=vxf6iVR65OjcO2by+2Ila130ohQCjQlQqsr0LhaLa0k=; b=nIOOQ3uJcZoDhJ6xvEp8V4ODzDCco0kyMrlHw+cjoalfXheJVw6tp+Lhg7r+JUhGmb ANqtgccmoflBnHqcW+Ae4Di2vR9e7QbBbTm+XSBg803abgkVrQpkKTVQR6jMRTYfofhr +Nl0gcjSCtWEyClgHeJadH/XXo34VL92gjm9bH+wLvse3mkWA81H04rNE/e80+S3nlAY F05zLESyMK9vx96+rS/9OaiWxGtbDQoJAHMdNsmI+ElarsG1a5MBiQVU9GcvnOXQEJ1S 0Fv5Cd5iXiC9OkJywV0TJHaL4cMivkkv00ftspZ+4dU1OXKfgc9pU870BnX5x7PFHh1F ptZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=vxf6iVR65OjcO2by+2Ila130ohQCjQlQqsr0LhaLa0k=; b=hjhE6zqedrPC5OOEizOF0HtujorB10Ni7AzmYQsGy3aTvkTXlhsabqS3vaJG+ozPFE yFGTyH8HET4QWACteSwrkZjrW109gpXhUxDqtwGzeN1fjWGzSEA9KLgnEL/EazD1nY/m KAuMw2TVHXFCWiM+mx+8N6K/9OGmu8OtAvq8pKpCO2eFMDBEh1swXmtLZtaaWy3LM1Hz 6zuPxc64vMzLDVJQxeY+0s3uEGUFg8/xOGpSD5Wx84yHE//phvpDxKfDshFYSGXz9r1U 7PDcdkb0ceQHl0dUTYuTnSSKuk+LcCNtqXcKGMRTTu8pkZCNz5L42UFXEICw2Q/ssjhG aH7w== X-Gm-Message-State: APt69E1MC2U3wr1Pz9TZ+h19/tZJ+z2QbG55nvLhPqZbN2yf9/kxouPb NONqFZPEYi2x6LAWLk4GwezjhVYk X-Google-Smtp-Source: AAOMgpeBHXH0SAsp0SZiPoGtiSbkCtBYRHNHbWHy8KX1Ysmct0X0HtbMkNXemNs4QthLBQB/rCSYtg== X-Received: by 2002:a1c:d391:: with SMTP id k139-v6mr8870373wmg.45.1530216337653; Thu, 28 Jun 2018 13:05:37 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:34 +0200 Message-Id: <1530216310-52873-25-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::235 Subject: [Qemu-devel] [PULL 24/60] pc-dimm: merge get_(vmstate_)memory_region() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Importantly, get_vmstate_memory_region() should also fail with a proper error if called before the device is realized. For a PCDIMM, both functions are to return the same thing, so share the implementation. All current users are called after the device has been realized, so we can expect the calls to succeed. Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Signed-off-by: David Hildenbrand Message-Id: <20180619134141.29478-9-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/mem/pc-dimm.c | 13 +++++-------- include/hw/mem/pc-dimm.h | 3 ++- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 73f0eee..4ff39b5 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -35,7 +35,8 @@ void pc_dimm_plug(DeviceState *dev, MachineState *machine= , uint64_t align, int slot; PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm); + MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm, + &error_abort= ); Error *local_err =3D NULL; MemoryRegion *mr; uint64_t addr; @@ -90,7 +91,8 @@ void pc_dimm_unplug(DeviceState *dev, MachineState *machi= ne) { PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm); + MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm, + &error_abort= ); MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); =20 memory_device_unplug_region(machine, mr); @@ -229,11 +231,6 @@ static MemoryRegion *pc_dimm_get_memory_region(PCDIMMD= evice *dimm, Error **errp) return host_memory_backend_get_memory(dimm->hostmem); } =20 -static MemoryRegion *pc_dimm_get_vmstate_memory_region(PCDIMMDevice *dimm) -{ - return host_memory_backend_get_memory(dimm->hostmem); -} - static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md) { const PCDIMMDevice *dimm =3D PC_DIMM(md); @@ -298,7 +295,7 @@ static void pc_dimm_class_init(ObjectClass *oc, void *d= ata) dc->desc =3D "DIMM memory module"; =20 ddc->get_memory_region =3D pc_dimm_get_memory_region; - ddc->get_vmstate_memory_region =3D pc_dimm_get_vmstate_memory_region; + ddc->get_vmstate_memory_region =3D pc_dimm_get_memory_region; =20 mdc->get_addr =3D pc_dimm_md_get_addr; /* for a dimm plugged_size =3D=3D region_size */ diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index cf71247..5679a80 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -73,7 +73,8 @@ typedef struct PCDIMMDeviceClass { /* public */ void (*realize)(PCDIMMDevice *dimm, Error **errp); MemoryRegion *(*get_memory_region)(PCDIMMDevice *dimm, Error **errp); - MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm); + MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm, + Error **errp); } PCDIMMDeviceClass; =20 void pc_dimm_plug(DeviceState *dev, MachineState *machine, uint64_t align, --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217890614135.5877858644485; Thu, 28 Jun 2018 13:31:30 -0700 (PDT) Received: from localhost ([::1]:38421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdZh-0003Zq-Qd for importer@patchew.org; Thu, 28 Jun 2018 16:31:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAj-0007JL-HT for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAi-0000eE-DD for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:41 -0400 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:34779) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAi-0000cG-5G for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:40 -0400 Received: by mail-wm0-x236.google.com with SMTP id l15-v6so240633wmc.1 for ; Thu, 28 Jun 2018 13:05:40 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=9GOGJ6pkt/3AOlRppXnUaZT1JYCpviZq549cIzuY0Og=; b=qN28VqR0bar0mkdljOPb90xvFpfkAUCN5riKPnlF8Pf1x5W3GFLIHv4cR2mo4gS/4G mpWD9+lEYbJv7Dikk+06foKa8+3SYJM4ByEOs7KcgbF0b+PCS+HaQNOfJwani7NgjlaQ /kA/WlpyJOSleIK5Lo5nS5Prbv3i8iqDzMB5m+5O1Xt7fl4oT9K4Smnt4XNyxe7nHdpL 2HoguVWh2F8ki9RPIjcgTX+2SxC4ROkpa5KtRO1lH8rjVuFJg2i9D2XChSnNBaXfspUn qxtE2us+7H6d5XroDBvW7K70A+yd2g9NUP/2JBfUBLNeWIeTytqZiqNPti5GPQYGH7+2 WB1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=9GOGJ6pkt/3AOlRppXnUaZT1JYCpviZq549cIzuY0Og=; b=rJ2TAT/Wag0it77VcCooxWT5qGb2+vBayfO46mNdRlhxaFo8UPmr82EPwyaFNNM4Yf 8zpvIldTJ5zPYSAippemxjiOKI7400r0sh68U7oB4IvXjmlJHiPpePkXdcVOh6cbqeVd 3LBEzp5xvKCwX6i7l+z5meGdjL1wQAqO0ZOV0k3ot59TJhTFhboMOh0uoAZonv6ylkpl XqOqQGvU1aR8Q0N77l2xzF7XcwwGj1PrI6sI5AkScWJ9NyuPiQLCv3YZJz40aufHjExR 8n1ETDPiVJBRqCBNG/cEiTj5K7E+Z1qCHvkBVI8L+luBuQW3vp/D0EzSNjoP9KamIBYw wqzg== X-Gm-Message-State: APt69E1lNoHnHgpvANsQ8SHgtWQXNm3e7H+tLPxKRUiUHX8P4QCmqxpH u4TOJLe2xAUWnhii/9rw5k9ovO6W X-Google-Smtp-Source: AAOMgpcjn9YRG613E4uhITOYhpU3mmPWxcY6p+Kw7GBOL4wyap6W6Ibgs9jAO7sXyYnOwRl3PkIzjg== X-Received: by 2002:a1c:1815:: with SMTP id 21-v6mr9387610wmy.72.1530216338525; Thu, 28 Jun 2018 13:05:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:35 +0200 Message-Id: <1530216310-52873-26-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::236 Subject: [Qemu-devel] [PULL 25/60] nvdimm: convert "unarmed" into a static property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand We don't allow to modify it after realization. So we can simply turn it into a static property. Reviewed-by: David Gibson Signed-off-by: David Hildenbrand Message-Id: <20180619134141.29478-10-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/mem/nvdimm.c | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index df97162..7260c9c 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -64,36 +64,11 @@ out: error_propagate(errp, local_err); } =20 -static bool nvdimm_get_unarmed(Object *obj, Error **errp) -{ - NVDIMMDevice *nvdimm =3D NVDIMM(obj); - - return nvdimm->unarmed; -} - -static void nvdimm_set_unarmed(Object *obj, bool value, Error **errp) -{ - NVDIMMDevice *nvdimm =3D NVDIMM(obj); - Error *local_err =3D NULL; - - if (memory_region_size(&nvdimm->nvdimm_mr)) { - error_setg(&local_err, "cannot change property value"); - goto out; - } - - nvdimm->unarmed =3D value; - - out: - error_propagate(errp, local_err); -} - static void nvdimm_init(Object *obj) { object_property_add(obj, NVDIMM_LABEL_SIZE_PROP, "int", nvdimm_get_label_size, nvdimm_set_label_size, NULL, NULL, NULL); - object_property_add_bool(obj, NVDIMM_UNARMED_PROP, - nvdimm_get_unarmed, nvdimm_set_unarmed, NULL); } =20 static MemoryRegion *nvdimm_get_memory_region(PCDIMMDevice *dimm, Error **= errp) @@ -166,13 +141,20 @@ static void nvdimm_write_label_data(NVDIMMDevice *nvd= imm, const void *buf, memory_region_set_dirty(mr, backend_offset, size); } =20 +static Property nvdimm_properties[] =3D { + DEFINE_PROP_BOOL(NVDIMM_UNARMED_PROP, NVDIMMDevice, unarmed, false), + DEFINE_PROP_END_OF_LIST(), +}; + static void nvdimm_class_init(ObjectClass *oc, void *data) { PCDIMMDeviceClass *ddc =3D PC_DIMM_CLASS(oc); NVDIMMClass *nvc =3D NVDIMM_CLASS(oc); + DeviceClass *dc =3D DEVICE_CLASS(oc); =20 ddc->realize =3D nvdimm_realize; ddc->get_memory_region =3D nvdimm_get_memory_region; + dc->props =3D nvdimm_properties; =20 nvc->read_label_data =3D nvdimm_read_label_data; nvc->write_label_data =3D nvdimm_write_label_data; --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217543376825.2560329999333; Thu, 28 Jun 2018 13:25:43 -0700 (PDT) Received: from localhost ([::1]:38385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdU6-0007IH-JW for importer@patchew.org; Thu, 28 Jun 2018 16:25:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAk-0007Jx-45 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAi-0000f6-UQ for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:42 -0400 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:51036) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAi-0000dP-Nb for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:40 -0400 Received: by mail-wm0-x22e.google.com with SMTP id e16-v6so10987406wmd.0 for ; Thu, 28 Jun 2018 13:05:40 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=1w0ykkM392cue2WJE2KlhI1CWjJDHSb9ao6Ec7SquuI=; b=lafvf0UqYN1gONEGF2g3o9BGASpCv1JFFiUv63rx0FBJ1yp5idJUwiQPaoeUdfNMAg JyIQgdchZy4nqcRSI/BC5FF9gJsg2uCfl9oD9iK+PFFLPATklK/dnmxxLVWgK+uYZtud Ww5b75kxUqeZ6IYemc7ghJPSss4vmj2+V0MrJ2FnjpnLMtobHn1WKS+mQ2NcsfXKyeUM JErPn8b9tflV/+5xb8KDPufYvv1qIOfEUyIW32m0aCyyl4UjU7vhKyPtQtKnupZ2qNpN XdoPlvh5oVMTodSoVmME9tS5dlH9XRdjv/Dcm3h5JhmZbfhv9KaaSNJt92SqGsTePB6/ biEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=1w0ykkM392cue2WJE2KlhI1CWjJDHSb9ao6Ec7SquuI=; b=GJPkyi/oNBNbQIj5HW3LgkSbOULZgdPeGDldyiA/cYbbKYHYiG3FtYHP7hn/g38fHb jVeyvqS83tNlESlwUqZdLidUhb/d1+9/ZZ07vPVcjoeI3Mxr95MYY31GH9kdvWMOAv9l xbbZELlnJGwfWCiH8V0s8tHOFQHmXZNZ4A5VxmvHdEnZxVxUOaoQP49vCaW9HNGYdTid j4GGyUwJstMTJSl189ugiA7PummRo4XilJ3vnE+qoi4grX+pFJw9vhnK8YizQxe9Y2zT MIhEZZMZBSnR0RF5YurhS8tnkAqRxf5kk8Z8+7LQs6UQ6RwBUpn+3p0rHTf8qPH8DzyX o0mA== X-Gm-Message-State: APt69E30a2ct0+Q1nzdKJ2Ro+9pjQmC8GFUJBCNm1URNZFDiLguM8C74 YSfUk6jqls3HvgVQzeyrJp+at3+b X-Google-Smtp-Source: AAOMgpe9IiMlbKAAux20IeKra8azJqvbNpLXxtZVouqbTIbzn3qJ8X7Hicw2Q3zpiEJH/ZxiM9edUQ== X-Received: by 2002:a1c:5b0d:: with SMTP id p13-v6mr9384580wmb.53.1530216339415; Thu, 28 Jun 2018 13:05:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:36 +0200 Message-Id: <1530216310-52873-27-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22e Subject: [Qemu-devel] [PULL 26/60] nvdimm: convert nvdimm_mr into a pointer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand This way we can easily check if the region has already been inititalized without having to rely on the size of an uninitialized region being 0. Free the region in nvdimm_finalize() and not in unrealize() as we will allow to create the region before realization in following patches. Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Signed-off-by: David Hildenbrand Message-Id: <20180619134141.29478-11-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/mem/nvdimm.c | 17 +++++++++++++---- include/hw/mem/nvdimm.h | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index 7260c9c..afd3912 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -43,7 +43,7 @@ static void nvdimm_set_label_size(Object *obj, Visitor *v= , const char *name, Error *local_err =3D NULL; uint64_t value; =20 - if (memory_region_size(&nvdimm->nvdimm_mr)) { + if (nvdimm->nvdimm_mr) { error_setg(&local_err, "cannot change property value"); goto out; } @@ -71,11 +71,18 @@ static void nvdimm_init(Object *obj) NULL, NULL); } =20 +static void nvdimm_finalize(Object *obj) +{ + NVDIMMDevice *nvdimm =3D NVDIMM(obj); + + g_free(nvdimm->nvdimm_mr); +} + static MemoryRegion *nvdimm_get_memory_region(PCDIMMDevice *dimm, Error **= errp) { NVDIMMDevice *nvdimm =3D NVDIMM(dimm); =20 - return &nvdimm->nvdimm_mr; + return nvdimm->nvdimm_mr; } =20 static void nvdimm_realize(PCDIMMDevice *dimm, Error **errp) @@ -102,9 +109,10 @@ static void nvdimm_realize(PCDIMMDevice *dimm, Error *= *errp) return; } =20 - memory_region_init_alias(&nvdimm->nvdimm_mr, OBJECT(dimm), + nvdimm->nvdimm_mr =3D g_new(MemoryRegion, 1); + memory_region_init_alias(nvdimm->nvdimm_mr, OBJECT(dimm), "nvdimm-memory", mr, 0, pmem_size); - nvdimm->nvdimm_mr.align =3D align; + nvdimm->nvdimm_mr->align =3D align; } =20 /* @@ -167,6 +175,7 @@ static TypeInfo nvdimm_info =3D { .class_init =3D nvdimm_class_init, .instance_size =3D sizeof(NVDIMMDevice), .instance_init =3D nvdimm_init, + .instance_finalize =3D nvdimm_finalize, }; =20 static void nvdimm_register_types(void) diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h index 9340631..c5c9b3c 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -74,7 +74,7 @@ struct NVDIMMDevice { * it's the PMEM region in NVDIMM device, which is presented to * guest via ACPI NFIT and _FIT method if NVDIMM hotplug is supported. */ - MemoryRegion nvdimm_mr; + MemoryRegion *nvdimm_mr; =20 /* * The 'on' value results in the unarmed flag set in ACPI NFIT, --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15302180842801014.404331166654; Thu, 28 Jun 2018 13:34:44 -0700 (PDT) Received: from localhost ([::1]:38433 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdcp-0005uP-Gm for importer@patchew.org; Thu, 28 Jun 2018 16:34:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAk-0007Ki-Qv for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAj-0000hH-Qz for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:42 -0400 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]:55465) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAj-0000fC-Jn for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:41 -0400 Received: by mail-wm0-x22f.google.com with SMTP id v16-v6so11055508wmv.5 for ; Thu, 28 Jun 2018 13:05:41 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Xg8VIZVEBTONb3gwCC5sfD3NmTWixaD0hRBlo34Y29o=; b=SZ2HoVP4VezO+qjMgUoEQdBK5zdVbi6aVRo/YpN1gmdIP8jKUHDokuaf6isVN/WdK+ xhJXG1YnZsOrkrX/Fb6fP9n26SQaJrTVv5cGWhUHM1k9YdBfbjHpwXb0M7JPf3hTdo64 wijq1Tcxhw8nbwCGGJ/Y4/D5ZKi/Vpx9ci5HdxStts6yj+hhI75qybeo0lqpvI+NKXuO j8NS8AEjTl4W6EYUzoNAGk4zcrkm3K4dCiDLalZxGI+cvTY5lEOpDYMPDAM+X736AoNA f/n6SvMjsHmWUdURSvRLIQevZBGUA4CjVmSrAGhM1GughFJSF4J6GzbzgTpm66ZPdF7e xGPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Xg8VIZVEBTONb3gwCC5sfD3NmTWixaD0hRBlo34Y29o=; b=PYanxoCovpVv7rvNWhQd+NK+XJfq2hst3bfpQ1y8O5AgsIkmPn1My2rsjO3Esps6NS 0fqyuJKDgwUb5QC81EGPj6fmdK8hcxaIGU/tuBD2i9P0CL5veIKT3uCWTXLqL5GTHV9+ bz5xgRl/AgiJNXSoIiQm1K3rvJWYL92h/loqd36Z8sJdNx+it5GHIlz6wJsPFQbrVJYU ZlnK81uCqPnFkD22WOleQIMtGX9mZRu1VMvY/gN1fdj0el/dntEquku7rFIYfBOV+kgE OtqkP5KIq73/VYO/8K8YX23SUxhLZ0EaFUgZd2KzL2gZ+9boW9g5A9NicQd4XRvwslbj 1raw== X-Gm-Message-State: APt69E1k+LAbdyfKPOixrWwWfBoRMrocdfINNYoESa73X6fxopX+NFU9 lRamGcAlFLq8cpQDXuthCnlCB91u X-Google-Smtp-Source: AAOMgpc0+vsQE4oAJxajxwN0musuC+3hmVt1E7mSzkZr1YS1bld2lAviFOxYzUbSOGVIp3v99Y46OQ== X-Received: by 2002:a1c:1983:: with SMTP id 125-v6mr9170974wmz.79.1530216340302; Thu, 28 Jun 2018 13:05:40 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:37 +0200 Message-Id: <1530216310-52873-28-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22f Subject: [Qemu-devel] [PULL 27/60] nvdimm: make get_memory_region() perform checks and initialization X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand We might get a call to get_memory_region() before the device has been realized. We should return a consistent value, as the return value will e.g. later on be used in the pre_plug handler. To avoid duplicating too much code, factor the initialization and checks out into a helper function. Reviewed-by: Igor Mammedov Reviewed-by: David Gibson Signed-off-by: David Hildenbrand Message-Id: <20180619134141.29478-12-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/mem/nvdimm.c | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index afd3912..021d1c3 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -78,20 +78,22 @@ static void nvdimm_finalize(Object *obj) g_free(nvdimm->nvdimm_mr); } =20 -static MemoryRegion *nvdimm_get_memory_region(PCDIMMDevice *dimm, Error **= errp) +static void nvdimm_prepare_memory_region(NVDIMMDevice *nvdimm, Error **err= p) { - NVDIMMDevice *nvdimm =3D NVDIMM(dimm); + PCDIMMDevice *dimm =3D PC_DIMM(nvdimm); + uint64_t align, pmem_size, size; + MemoryRegion *mr; =20 - return nvdimm->nvdimm_mr; -} + g_assert(!nvdimm->nvdimm_mr); =20 -static void nvdimm_realize(PCDIMMDevice *dimm, Error **errp) -{ - MemoryRegion *mr =3D host_memory_backend_get_memory(dimm->hostmem); - NVDIMMDevice *nvdimm =3D NVDIMM(dimm); - uint64_t align, pmem_size, size =3D memory_region_size(mr); + if (!dimm->hostmem) { + error_setg(errp, "'" PC_DIMM_MEMDEV_PROP "' property must be set"); + return; + } =20 + mr =3D host_memory_backend_get_memory(dimm->hostmem); align =3D memory_region_get_alignment(mr); + size =3D memory_region_size(mr); =20 pmem_size =3D size - nvdimm->label_size; nvdimm->label_data =3D memory_region_get_ram_ptr(mr) + pmem_size; @@ -115,6 +117,30 @@ static void nvdimm_realize(PCDIMMDevice *dimm, Error *= *errp) nvdimm->nvdimm_mr->align =3D align; } =20 +static MemoryRegion *nvdimm_get_memory_region(PCDIMMDevice *dimm, Error **= errp) +{ + NVDIMMDevice *nvdimm =3D NVDIMM(dimm); + Error *local_err =3D NULL; + + if (!nvdimm->nvdimm_mr) { + nvdimm_prepare_memory_region(nvdimm, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return NULL; + } + } + return nvdimm->nvdimm_mr; +} + +static void nvdimm_realize(PCDIMMDevice *dimm, Error **errp) +{ + NVDIMMDevice *nvdimm =3D NVDIMM(dimm); + + if (!nvdimm->nvdimm_mr) { + nvdimm_prepare_memory_region(nvdimm, errp); + } +} + /* * the caller should check the input parameters before calling * label read/write functions. --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217719502606.0521887759556; Thu, 28 Jun 2018 13:28:39 -0700 (PDT) Received: from localhost ([::1]:38401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdWw-0001El-7Z for importer@patchew.org; Thu, 28 Jun 2018 16:28:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAn-0007OO-BP for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAk-0000iW-Oj for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:45 -0400 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:34770) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAk-0000hR-Ed for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:42 -0400 Received: by mail-wm0-x22c.google.com with SMTP id l15-v6so240723wmc.1 for ; Thu, 28 Jun 2018 13:05:42 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=9UKw9Hh6eSvzgMnxW9RFSxnWEw/OZZkIxNE4vR1mso4=; b=nIqEM12XR5cFbKcsZcENSxWYzsI9rzVTwTmg81/TZpBtSxR4JwHkLksPkXKLMhd1zA Zg5p4y91VHa9rSrIqNNINonpra4J86weZixrumkFt2OBhRWBpZYgA/l7opv22e1nzsWZ AUgG4JyjFZAsLLR3sSM/faVZlTspDrb2R9RQ4JcCwpxDPidj6ww0mXRXUtDUsA/tvH1v hdVjWO/R3M9PrWvaVO4HngOPrPHPDw72pjD9SxRhF+aMVaTDFgHZ5BpAPXnItQIT2BOG cRYBtCJxvoG9/xfDGt+sfEPYyJvzfwcHPupsvcx8HpBYK/Rgig0kBlqn8WHTAbrhrOP+ jy1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=9UKw9Hh6eSvzgMnxW9RFSxnWEw/OZZkIxNE4vR1mso4=; b=gL6h67EA2D3yRPQxbu3o3/peem5LW0jXEvHBLjxjluGX4snoYDjyZiW3pDXBQ4Km/+ gETD0X3EROLH27UKD159U69M5RFB38wn/Lg+EsE3oe0ue8LoX/WDl+J14YjC8LT+dHv8 3nCF6QtLiwbigleLw0IL3wWvAMBeeOOaVgWJp2ZV/83LYOkmAYLUnTxV91N73+ZeK4Te UWLtBAr97vO7JkurcugSCpEz64qovGSrt2plF95jbw2M+StKcn5/YcDbi8BMruaVTLSw wnYvFe6tIkUZOdy8nbR1ePgxujsCHNnlZGetBCNuvHshfClnA0S8fooRrIZrOxAfPU67 wkmw== X-Gm-Message-State: APt69E2rZ5S6+oBkx/yVyEcnKxt1KcB8tvpJq3GQMOVl6XyE6s6QKdFT I4s7GnonNltIPOUACgU5YfmrTTt0 X-Google-Smtp-Source: AAOMgpfSboSOgS9D2FbhejWcISW9oBSlK4g//8EPH+tmp9mCiAgZRxnxWoumHriio/QCV1iwdtLjiQ== X-Received: by 2002:a1c:818e:: with SMTP id c136-v6mr9339689wmd.107.1530216341233; Thu, 28 Jun 2018 13:05:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:38 +0200 Message-Id: <1530216310-52873-29-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22c Subject: [Qemu-devel] [PULL 28/60] pc-dimm: get_memory_region() will not fail after realize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Let's try to reduce error handling a bit. In the plug/unplug case, the device was realized and therefore we can assume that getting access to the memory region will not fail. For get_vmstate_memory_region() this is already handled that way. Document both cases. Reviewed-by: Igor Mammedov Reviewed-by: David Gibson Signed-off-by: David Hildenbrand Message-Id: <20180619134141.29478-13-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 7 +------ hw/mem/pc-dimm.c | 7 +------ hw/ppc/spapr.c | 12 ++---------- include/hw/mem/pc-dimm.h | 6 ++++-- 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2db032a..f310040 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1706,15 +1706,10 @@ static void pc_memory_plug(HotplugHandler *hotplug_= dev, PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr; + MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); uint64_t align =3D TARGET_PAGE_SIZE; bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); =20 - mr =3D ddc->get_memory_region(dimm, &local_err); - if (local_err) { - goto out; - } - if (memory_region_get_alignment(mr) && pcmc->enforce_aligned_dimm) { align =3D memory_region_get_alignment(mr); } diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 4ff39b5..65843bc 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -37,15 +37,10 @@ void pc_dimm_plug(DeviceState *dev, MachineState *machi= ne, uint64_t align, PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm, &error_abort= ); + MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); Error *local_err =3D NULL; - MemoryRegion *mr; uint64_t addr; =20 - mr =3D ddc->get_memory_region(dimm, &local_err); - if (local_err) { - goto out; - } - addr =3D object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err); if (local_err) { diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 3a1bd73..b32b971 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3149,14 +3149,10 @@ static void spapr_memory_plug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, sPAPRMachineState *ms =3D SPAPR_MACHINE(hotplug_dev); PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr; + MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); uint64_t align, size, addr; uint32_t node; =20 - mr =3D ddc->get_memory_region(dimm, &local_err); - if (local_err) { - goto out; - } align =3D memory_region_get_alignment(mr); size =3D memory_region_size(mr); =20 @@ -3344,16 +3340,12 @@ static void spapr_memory_unplug_request(HotplugHand= ler *hotplug_dev, Error *local_err =3D NULL; PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr; + MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); uint32_t nr_lmbs; uint64_t size, addr_start, addr; int i; sPAPRDRConnector *drc; =20 - mr =3D ddc->get_memory_region(dimm, &local_err); - if (local_err) { - goto out; - } size =3D memory_region_size(mr); nr_lmbs =3D size / SPAPR_MEMORY_BLOCK_SIZE; =20 diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index 5679a80..26ebb7d 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -62,9 +62,11 @@ typedef struct PCDIMMDevice { * @realize: called after common dimm is realized so that the dimm based * devices get the chance to do specified operations. * @get_memory_region: returns #MemoryRegion associated with @dimm which - * is directly mapped into the physical address space of guest. + * is directly mapped into the physical address space of guest. Will not + * fail after the device was realized. * @get_vmstate_memory_region: returns #MemoryRegion which indicates the - * memory of @dimm should be kept during live migration. + * memory of @dimm should be kept during live migration. Will not fail + * after the device was realized. */ typedef struct PCDIMMDeviceClass { /* private */ --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217603017661.2357622542927; Thu, 28 Jun 2018 13:26:43 -0700 (PDT) Received: from localhost ([::1]:38392 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdV4-0008Bz-1w for importer@patchew.org; Thu, 28 Jun 2018 16:26:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAn-0007OQ-Cj for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAl-0000k3-SO for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:45 -0400 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:51039) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAl-0000il-LE for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:43 -0400 Received: by mail-wm0-x231.google.com with SMTP id e16-v6so10987541wmd.0 for ; Thu, 28 Jun 2018 13:05:43 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=w2epYMMgupDcHFe33/shx0Ht+lrTafKP/MYgPM4y8Ws=; b=Jpu/IPpXRO9Fo5fdOEWhizGf989Celnk6DYksBunMNjzvdqv1PjSR9rt9yenOCIiWW C4EPviWoG4YvlStrddD5dRy65zgCm7pzBKhj5OiVQCLgf/MY+qEZbsqpZjPrB2kznVtm JlnHJ1KFM9ni3prNA5C05mGtSThT9bUnthgpG5+z8AuU45r/X/HUYGILnT1b3toBQYwE Ywuwo7zYl2sXFR/7HVi1GniXBdnm53xuX851BDwY3Cpewu7KE+tlF93CHRsgKYig3hy3 cs+AEDUkB+6G9aZbeyTMYM1awEJO6GWDxW6Hb7YkpX3T6bhCgpzUhb9uYjnP5AhwNWsT 1JQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=w2epYMMgupDcHFe33/shx0Ht+lrTafKP/MYgPM4y8Ws=; b=osAt0NV+fgmlkzdwCilDFKzQiK+f6Y4Bnz5bo9V3gW0Tv10cZBV8QMDWKEnGiVoyul bCsGQ0jsFpUjmufD8ZPtJap2KZOQhQvhyILGdV73bLqbsTzXNezMf7Bvx5CWnRGIDQ0Z MUI0g0/+W9a0Ygidjhko0WYjdnB3AER91lotOy90RE6DXLOfWaaVFApS7bG+lC7vqy8j MdrKEkFe1/aGAPi/EmS5wbh+mY1O1elFSfH35sKfepbgOSNZb2aECbCBohKRS+oho/ll 5Of/8Rw36aUsfoifFFXg2b+85Fc6Lxb0h9sBPSyIbUOdIlvSPrdeRAOoZcXYDl1+TVvu gvhQ== X-Gm-Message-State: APt69E3xgVJ4u94pU1GekBNrK4Q14pNhkOMXcPPEV6EUiDvQPprnAFaf Tdo+kS5SMDZgUm7mX2cvR5k9HEu/ X-Google-Smtp-Source: AAOMgpd8KoLK2uQpcVxeIla+y0g7h2pvgqfIytxnDJ66DefE6idB+HautiELJ9WnHjMQyXN7fFtiwg== X-Received: by 2002:a1c:84d0:: with SMTP id g199-v6mr9959831wmd.90.1530216342225; Thu, 28 Jun 2018 13:05:42 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:39 +0200 Message-Id: <1530216310-52873-30-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::231 Subject: [Qemu-devel] [PULL 29/60] numa: report all DIMM/NVDIMMs as plugged memory X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Right now, there is some inconsistency between hotplugged and coldplugged memory. DIMMs added via "-device" result in different stats than DIMMs added using "device_add". E.g. [...] -numa node,nodeid=3D0,cpus=3D0-1 -numa node,nodeid=3D1,cpus=3D2-3 \ -m 4G,maxmem=3D20G,slots=3D2 \ -object memory-backend-ram,id=3Dmem0,size=3D8G \ -device pc-dimm,id=3Ddimm0,memdev=3Dmem0 \ -object memory-backend-ram,id=3Dmem1,size=3D8G \ -device nvdimm,id=3Ddimm1,memdev=3Dmem1,node=3D1 Results in NUMA info (qemu) info numa info numa 2 nodes node 0 cpus: 0 1 node 0 size: 10240 MB node 0 plugged: 0 MB node 1 cpus: 2 3 node 1 size: 10240 MB node 1 plugged: 0 MB But in memory size summary: (qemu) info memory_size_summary info memory_size_summary base memory: 4294967296 plugged memory: 17179869184 Make this consistent by reporting all hot and coldplugged memory a.k.a. DIMM and NVDIMM as "plugged". Fixes: 31959e82fb0 ("hmp: extend "info numa" with hotplugged memory informa= tion") Signed-off-by: David Hildenbrand Message-Id: <20180622144045.737-1-david@redhat.com> Signed-off-by: Paolo Bonzini --- numa.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/numa.c b/numa.c index 94f758c..5f6367b 100644 --- a/numa.c +++ b/numa.c @@ -566,10 +566,8 @@ static void numa_stat_memory_devices(NumaNodeMem node_= mem[]) =20 if (pcdimm_info) { node_mem[pcdimm_info->node].node_mem +=3D pcdimm_info->siz= e; - if (pcdimm_info->hotpluggable && pcdimm_info->hotplugged) { - node_mem[pcdimm_info->node].node_plugged_mem +=3D - pcdimm_info->size; - } + node_mem[pcdimm_info->node].node_plugged_mem +=3D + pcdimm_info->size; } } } --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530218255754210.7441365231258; Thu, 28 Jun 2018 13:37:35 -0700 (PDT) Received: from localhost ([::1]:38452 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdfb-0008Jn-0j for importer@patchew.org; Thu, 28 Jun 2018 16:37:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAn-0007Oy-NI for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAm-0000kP-Jh for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:45 -0400 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:38237) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAm-0000jp-CK for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:44 -0400 Received: by mail-wr0-x22d.google.com with SMTP id e18-v6so6691406wrs.5 for ; Thu, 28 Jun 2018 13:05:44 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cBf2TsfTyBYpL/Uku4NrqdbyAja64azSLBMRb0kYDSk=; b=G73B0Aw0DsMsF9r3Ejy236ptU7r6jJy3bn7B++/15UcyQhHernDiMLN+GezIHnlAIo gjF5IytrAK46V+Wu1gGqlgxSxdO2UZfx1t8sWdIoiKPDrxe2avAdgqjiDTsaInyOFI0z YItP8S8rv0ykIX6RDAq8Ql+IynNwyCwnYX6+k+dArpPKeu7DQyKY4kGfpVhMVScDOA9R rOGJdw4gZ1xB2Lqlj0jy2dOdz/Z+AVchaSmRj3SjccUeImOvJK6m0Flh3FL7mBJO2p2e Et5G7/zXQu2//YcSAdcfnc5vg3xAjmgtEbVVHYUwKDDvIznNLl54VgEFwodi9zYhABEu QQYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=cBf2TsfTyBYpL/Uku4NrqdbyAja64azSLBMRb0kYDSk=; b=gf4M9UrX1ZvHhc7QflG4lbAdUs3Qdqu0M+hKiZCV8uLWvdztECI7wa5n9VrS53IApY W8GV5o8EGyZ8Za1LbfxHM+EWAX3VZQVMjnCoPn9DLA3hX6WRgNHR/B9cvG6LVTzRc1iv AGBYLrqZ/z7oQ1MUWraTmvd2XNkXi8Y4IAiX1sJbWszdkbchz9j3ko4XBR1Z2Azp9HBP CDUkxlR/+7ztoL5+6cVC1RIk9aKqWY9hiasRWCK6T6gxOl2qgFQvJL6i7ctAn7/OPn2g WtwuTEZeGPNLmIoDC+TR5lcoBfUbpSpRDK7uobYfgYBjvB7jdWnEslnO6liYWovzkRas WVWA== X-Gm-Message-State: APt69E3nukjWRRL+b/TQ197A/7TgYyuamPHtxHcmQec7LAM6k8p3nvLP neqROoPu6Jch0TGJb2v+jFwW/PM4 X-Google-Smtp-Source: AAOMgpeeXctkmj7V81RYhyYN4INkTA38I+uJJT78EXR5F6Z7jBX3lFrSwtYd75wMFPHBzYHxYUrLlw== X-Received: by 2002:adf:82cf:: with SMTP id 73-v6mr9584382wrc.77.1530216343075; Thu, 28 Jun 2018 13:05:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:40 +0200 Message-Id: <1530216310-52873-31-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22d Subject: [Qemu-devel] [PULL 30/60] osdep: work around Coverity parsing errors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Coverity does not like the new _Float* types that are used by recent glibc, and croaks on every single file that includes stdlib.h. Add dummy typedefs to please it. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- include/qemu/osdep.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 9ed6242..a91068d 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -33,6 +33,21 @@ #else #include "exec/poison.h" #endif +#ifdef __COVERITY__ +/* Coverity does not like the new _Float* types that are used by + * recent glibc, and croaks on every single file that includes + * stdlib.h. These typedefs are enough to please it. + * + * Note that these fix parse errors so they cannot be placed in + * scripts/coverity-model.c. + */ +typedef float _Float32; +typedef double _Float32x; +typedef double _Float64; +typedef __float80 _Float64x; +typedef __float128 _Float128; +#endif + #include "qemu/compiler.h" =20 /* Older versions of C++ don't get definitions of various macros from --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217776112286.5214212005793; Thu, 28 Jun 2018 13:29:36 -0700 (PDT) Received: from localhost ([::1]:38403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdXr-00020k-Al for importer@patchew.org; Thu, 28 Jun 2018 16:29:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAo-0007QL-O0 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAn-0000lF-Kr for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:46 -0400 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:44573) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAn-0000kZ-CZ for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:45 -0400 Received: by mail-wr0-x22d.google.com with SMTP id p12-v6so6676008wrn.11 for ; Thu, 28 Jun 2018 13:05:45 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=8ZclH3YotouT5S7Xrrk9q5V6JDABlpyhauy18H9S4kc=; b=pFSFUTG1bDxFiC9qQbRDjJbxhXE+AusSsCzPsGCOqINluyjTxac9U3+D+a1i34qmH4 KI1WxO4RPH3x+loNRCQ3ElDwnQuz0Ni2eg1+n+gjE33uumBAS0fgJ0U7wCsoPx61IwME UuZOKZs70EJezVq7KIUtUB+o3mlqg9CvReCd9rvnq7Kwrq0HxAXF2RvlsRwLY9BQYsVf zXCTSZAo8X1DqtCWmXd2OMH2ZO/hj9nB58kYpijs4Zl/Cj76C5J3uiY2DXFq2Cvsgrpe w6sG4EfCCVVFlypr5z6HpAb9+Tyj1I6ETx+VnM1IazzjBm8RCJGJQe5DJ+nRqkeEOEAM w5Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=8ZclH3YotouT5S7Xrrk9q5V6JDABlpyhauy18H9S4kc=; b=beoGQJ2J6UgGnX5R7mDs48KpcZ0Kw5edMu+0V6by3z+uKGvP2h8x74SN3HLd0v9YZL vwLbMDrJD5xRvSiiiuGtGdvyhfBzSSQRFqQabnahCF0IGaeBj7QHPkLqexlNg+VzRF6c ydVsrgv+y64Ib4GbdxLhfed6bS7EZE6kNL1qtSxoQBvj5A1vcn9h23AsQcGgk8RQjoRL zkMv/m7+TUYKG05Mglrf13kTTAJ4N/lepT8i48yE5c3hXWVN20BBB6adEiQEhD8N/Ds3 EcN/6HHa0dTGv1knNrI9MI4jLIgNwvz/OhayPSZXh+Zr2RQUNE7QwcrnH7MgBZbB6w9P cDzg== X-Gm-Message-State: APt69E2xy2/pfCNkJ9zliCJzwRJ13skI4gWpM92vvnZ+f4VRVAlG9YoM f9FkVQP8ik6qvvHKl1KGSwnQDpJF X-Google-Smtp-Source: AAOMgpcqyPMoLCbTB71vRneqOcFy8IyF0zjjHk4guiynni8Xd7UO30L7qDSuCfBOnagU/pmDUymiQw== X-Received: by 2002:adf:fb43:: with SMTP id c3-v6mr10215475wrs.32.1530216344085; Thu, 28 Jun 2018 13:05:44 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:41 +0200 Message-Id: <1530216310-52873-32-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22d Subject: [Qemu-devel] [PULL 31/60] Deprecate the -enable-hax option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth We currently have got three ways of turning on the HAX accelerator: "-machine accel=3Dhax", "-accel hax" and "-enable-hax". That's really confusing and overloaded. Since "-accel" is our preferred way to enable an accelerator nowadays, and "-accel hax" is even less to type than "-enable-hax", let's deprecate the "-enable-hax" option now. Note: While "-enable-kvm" is available since a long time and can hardly be removed since it is used in a lot of upper layer tools and scripts, the "-enable-hax" option is still rather new and not very widespread yet, so I think that it should be OK if we remove this in a couple of releases again (we'll see whether someone complains after seeing the deprecation message - then we could still reconsider to keep it if there a well-founded reasons). Signed-off-by: Thomas Huth Message-Id: <1529950933-28347-1-git-send-email-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- qemu-doc.texi | 5 +++++ qemu-options.hx | 2 +- vl.c | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/qemu-doc.texi b/qemu-doc.texi index 16fcb47..1cb3ba4 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -2912,6 +2912,11 @@ Option @option{-virtioconsole} has been replaced by The @code{-clock} option is ignored since QEMU version 1.7.0. There is no replacement since it is not needed anymore. =20 +@subsection -enable-hax (since 3.0.0) + +The @option{-enable-hax} option has been replaced by @option{-accel hax}. +Both options have been introduced in QEMU version 2.9.0. + @section QEMU Machine Protocol (QMP) commands =20 @subsection block-dirty-bitmap-add "autoload" parameter (since 2.12.0) diff --git a/qemu-options.hx b/qemu-options.hx index 2707728..3e45483 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3421,7 +3421,7 @@ STEXI Enable HAX (Hardware-based Acceleration eXecution) support. This option is only available if HAX support is enabled when compiling. HAX is only applicable to MAC and Windows platform, and thus does not conflict with -KVM. +KVM. This option is deprecated, use @option{-accel hax} instead. ETEXI =20 DEF("xen-domid", HAS_ARG, QEMU_OPTION_xen_domid, diff --git a/vl.c b/vl.c index d26f19b..7c9f19a 100644 --- a/vl.c +++ b/vl.c @@ -3581,6 +3581,7 @@ int main(int argc, char **argv, char **envp) qemu_opts_parse_noisily(olist, "accel=3Dkvm", false); break; case QEMU_OPTION_enable_hax: + warn_report("Option is deprecated, use '-accel hax' instea= d"); olist =3D qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "accel=3Dhax", false); break; --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217891691718.8731229794247; Thu, 28 Jun 2018 13:31:31 -0700 (PDT) Received: from localhost ([::1]:38422 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdZi-0003bB-Tz for importer@patchew.org; Thu, 28 Jun 2018 16:31:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAp-0007RC-9Y for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAo-0000mx-FC for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:47 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:46660) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAo-0000lb-8u for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:46 -0400 Received: by mail-wr0-x243.google.com with SMTP id t6-v6so6665863wrq.13 for ; Thu, 28 Jun 2018 13:05:46 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LEJpmGTR1sh04RSAdXZRZhe7n//wduG1WmzvBNmdzrg=; b=pmghTR3NdlMvs0XgCem5jUVjHJOlVaR7q8FGHyQHYZBdVTAoqHTLQUiUlfckjJLA/G 4ZmQ+voUMTu9O1cDBadQoT09GL/pjh/rCI0xXPUaRnkEOzDg4coWV/Gio/C4U/r9s6YU IXJ2jywM7IFx3LGELm5U9y/LfXmy2E8suxaCLGQvuLyeCXXxkS7WfrJ3aPW/ux14lGXr aHAULnExWhjsWCcsOWscPi4Q4x/GX+qM+gsvwVpOqBKdeTiYOfVLynJXBlc2tMLduUxE kozaZeI+ZqhWdHcaUrWYALt3mxvz1oLx1gvPMDcoU0uzOBbDC1aEv6j3HPmgjoebIje5 Yjlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=LEJpmGTR1sh04RSAdXZRZhe7n//wduG1WmzvBNmdzrg=; b=ALucBT07cSFJj9QiUM5Mj//l85isOO2TMdocE+0bIRsjcWz6oJcuhoohfDbkZzdsFl ldwoWdiXDY83Lhjy6STTw8c1yue/nzA//M2o/HRucTQMXHTIgiWNrN35A6rVoUN230MB sW34mBuyx1OSXakvQBpTfQApVGbjlXecMxKVRiOLdF7vd57Gbq4NWgWaOjIWZdjc1e+L F9sDd0GUeg4OXw42gxp6sI7c6y1DRFoKjpRTPd8E/5IGOwc4GyDrF9ZWYSBlUKaZ3HA0 rOECxeseiut4dAVzvD99KD+FE2SH5Dto2wnqLk6wmmbYwzkPkrdmGdhK4N+qOfnngwQ5 LFFw== X-Gm-Message-State: APt69E0pHjV8vAYH1VPqOlU698KONIghrBpxo+u2+yeVzBroB1hs3tuE a/CqM9XhgrVqde7PLwwi3ADkGa5Q X-Google-Smtp-Source: AAOMgpcshmBAB6domDX6ckZM0d9ZqTwAIK3SRq5/Q7V/RWlaPKSIRT8E/pdZtj1PWP8jaKEMDluNYw== X-Received: by 2002:adf:c377:: with SMTP id e52-v6mr9514204wrg.257.1530216345026; Thu, 28 Jun 2018 13:05:45 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:42 +0200 Message-Id: <1530216310-52873-33-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 32/60] pr-helper: fix --socket-path default in help X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Currently --help shows "(default '(null)')" for the -k/--socket-path option. Fix it by getting the default path in /var/run. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scsi/qemu-pr-helper.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index d0f8317..4057cf3 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -74,8 +74,16 @@ static int uid =3D -1; static int gid =3D -1; #endif =20 +static void compute_default_paths(void) +{ + if (!socket_path) { + socket_path =3D qemu_get_local_state_pathname("run/qemu-pr-helper.= sock"); + } +} + static void usage(const char *name) { + compute_default_paths(); (printf) ( "Usage: %s [OPTIONS] FILE\n" "Persistent Reservation helper program for QEMU\n" @@ -845,13 +853,6 @@ static const char *socket_activation_validate_opts(voi= d) return NULL; } =20 -static void compute_default_paths(void) -{ - if (!socket_path) { - socket_path =3D qemu_get_local_state_pathname("run/qemu-pr-helper.= sock"); - } -} - static void termsig_handler(int signum) { atomic_cmpxchg(&state, RUNNING, TERMINATE); --=20 1.8.3.1 From nobody Mon Feb 9 00:51:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530218085828143.49216748700792; Thu, 28 Jun 2018 13:34:45 -0700 (PDT) Received: from localhost ([::1]:38434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdcq-0005up-UJ for importer@patchew.org; Thu, 28 Jun 2018 16:34:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAq-0007T4-Gs for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAp-0000oJ-LU for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:48 -0400 Received: from mail-wr0-x236.google.com ([2a00:1450:400c:c0c::236]:32836) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAp-0000nF-DI for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:47 -0400 Received: by mail-wr0-x236.google.com with SMTP id k7-v6so3190053wrq.0 for ; Thu, 28 Jun 2018 13:05:47 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NNxdw9EfoglPw0eE0yAPZpny98Ei/3+q+kS3oSgkaso=; b=HuUnQOWNAODYzoDtINl70KDtCu4ZNoPKDCAOWVy7HFE7VWf80TRQnatZLx7UVcTKbf 8utkQIW2oBOHjRwSkSvY0+2eaWIJXCkIbSVPFsuOUmGUVgOD6An41ExFxPs1M7y2HuyR UyylS4DJ39P0yUQyFHZZJ6GXXttq94/GCI5+v+NU+2e2LOpzN8I0Eh008Mpy0XJkYkEG iVw9CQRdIHnitzBPihhv9qYdZYdfKZzrCkn1Ta/9Lnv9Ljdk1zIOMf0KHVSDuVRTl3sT Ed/mIzZx5PsO8QzV6mrLCHW62cgUSC2EYmE7J10AHGwBEsTgl4qLX7T4C6h/lNvxOCNI AzVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=NNxdw9EfoglPw0eE0yAPZpny98Ei/3+q+kS3oSgkaso=; b=h6TCDgj7enNnv9jPklnLK+/NeReIc7X620VlZqmnZXvSIRHP8B1cDBz3uXe1u7yA9S 0Gv1KeAxcKiLhNpY0ELCLruXJz78lRXOR/EZ++HabT7X6K9Cg4iz2KVZoGIfwZrn2Haj iHuoQsBNVOoZQpeFctLQKSkRqmpNRpMvmaZEhNurvPDattmg94YjDwz7a5sK9mMVcOpx EQTBOdJiBzmFEYn8iblSN8Is7TDTlL+kx7CC8XXAy1oLYUk7Wg9HVD319ZshXfR17Min ukSRDKTgE2Mkkz1CLVTQlzigjdXwmLwQ+ZTXVSZWNNCm9WglSx1tk/CS0ZMHUbZ0sfng Gbng== X-Gm-Message-State: APt69E38sCofhAndxLPK0Re19GHS88niXs3s5HVsAZhIhfmiZ2Bp14Mu e4rXfn7lUH9zc2cZhJ0J2TgKdHh+ X-Google-Smtp-Source: AAOMgpcKHUEOPuvoLwUezKIb+ftFBPhO39F7C0hXyvTfAJ8EMjBUuFxixFF+wSLX0nIwULQ/NEpEEg== X-Received: by 2002:adf:f98a:: with SMTP id f10-v6mr9803728wrr.105.1530216346069; Thu, 28 Jun 2018 13:05:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:43 +0200 Message-Id: <1530216310-52873-34-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::236 Subject: [Qemu-devel] [PULL 33/60] pr-helper: fix assertion failure on failed multipath PERSISTENT RESERVE IN X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 The response size is expected to be zero if the SCSI status is not "GOOD", but nothing was resetting it. This can be reproduced simply by "sg_persist -s /dev/sdb" where /dev/sdb in the guest is a scsi-block device corresponding to a multipath device on the host. Before: PR in (Read full status): Aborted command and on the host: prh_write_response: Assertion `resp->sz =3D=3D 0' failed. After: PR in (Read full status): bad field in cdb or parameter list (perhaps unsupported service action) Reported-by: Jiri Belka Reviewed-by: Michal Privoznik Signed-off-by: Paolo Bonzini Reviewed-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scsi/qemu-pr-helper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index 4057cf3..0218d65 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -558,7 +558,11 @@ static int do_pr_in(int fd, const uint8_t *cdb, uint8_= t *sense, #ifdef CONFIG_MPATH if (is_mpath(fd)) { /* multipath_pr_in fills the whole input buffer. */ - return multipath_pr_in(fd, cdb, sense, data, *resp_sz); + int r =3D multipath_pr_in(fd, cdb, sense, data, *resp_sz); + if (r !=3D GOOD) { + *resp_sz =3D 0; + } + return r; } #endif =20 --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530218253242241.69818301010764; Thu, 28 Jun 2018 13:37:33 -0700 (PDT) Received: from localhost ([::1]:38451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdfY-0008Iv-Fk for importer@patchew.org; Thu, 28 Jun 2018 16:37:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAr-0007UD-E6 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAq-0000ou-Ed for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:49 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:37435) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAq-0000oF-7u for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:48 -0400 Received: by mail-wm0-x242.google.com with SMTP id n17-v6so9764067wmh.2 for ; Thu, 28 Jun 2018 13:05:48 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=SJWSu/co/e56+DQruRImg1DYHL9dO8HtFEc5qpwCORQ=; b=JriNtKE8tX6vW2SpTg8MIpqthV94YDCXZOO6m82FzgC5EZFxdHyb/U/iRJBMCaRMTV M1xmeQYbN+uffdZbuQXH5LjLrc8ZwGCh46M2JOd6uboH8ca88TPaXlzXafp1eCaWSuGO 9TYdFNjCdnSc4pWGYPgFIqDnmPyeKnNCTN6INcy0aw+yjuMz8VaUJz4N/aSIgj7j8UKf 1MnFajhlvR43xcY0dNF0LvAZv6FZ0gksM7N19xeaB0RC7+k9rTdH0dGtsJWQyU7j0t2t EhZnKMsXbVzAEbwi8SRThIKs/oV2JF8P/F4uYamFYyhDPw65pPVKe7emC7szS1qq9tOG Nn2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=SJWSu/co/e56+DQruRImg1DYHL9dO8HtFEc5qpwCORQ=; b=Qspk+y1YXO/UXT9fBOtfiA4nZ6ejNqAEmjwXAN4T5jedJqoCDqGP0dCqgSxlsReLRw fZdWS5wdg3kQeWSxIauSPK/eJkCMhE/qvothTeJFdFYM3Hc7xtmLzXyma7BBUeeS6E0/ cUIEvExVxBTxsnjMgKETVmbBjDRod6WrFrjxxWfzQAEroZAhNcSiC/oBZZRfoosdU3hC guW5LMMGP4PaUWHE1/y25stvhZsZhceb3hJ0SohfUMVnxG27QSEMmAfGprHLRGycpO7y n916113x1WRMFvshUy1oCMHWGGPGV+/E5fu/YW1vRrvFWv7SHyxodb8V8pYjtynodPE/ a+qg== X-Gm-Message-State: APt69E15oJ2e4sna9S96MNNSmBn5oOaiuSZTysusso01uDimRWBu/one z1SzoZZZXG1ov4NLh2MhTOV9Cnyc X-Google-Smtp-Source: AAOMgpd6/Tu9bfBkMjvSNy9MmmxgZNWQM5T2VgEmQ8x5VT6/aGlhhXhWjdLszLBIWEaBiurTOouRgg== X-Received: by 2002:a1c:ad50:: with SMTP id w77-v6mr9551213wme.54.1530216346949; Thu, 28 Jun 2018 13:05:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:44 +0200 Message-Id: <1530216310-52873-35-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 34/60] pr-manager-helper: avoid SIGSEGV when writing to the socket fail X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When writing to the qemu-pr-helper socket failed, the persistent reservation manager was correctly disconnecting the socket, but it did not clear pr_mgr->ioc. So the rest of the code did not know that the socket had been disconnected, accessed pr_mgr->ioc and happily caused a crash. To reproduce, it is enough to stop qemu-pr-helper between QEMU startup and executing e.g. sg_persist -k /dev/sdb. Reviewed-by: Michal Privoznik Signed-off-by: Paolo Bonzini --- scsi/pr-manager-helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c index 82ff6b6..0c0fe38 100644 --- a/scsi/pr-manager-helper.c +++ b/scsi/pr-manager-helper.c @@ -71,6 +71,7 @@ static int pr_manager_helper_write(PRManagerHelper *pr_mg= r, if (n_written <=3D 0) { assert(n_written !=3D QIO_CHANNEL_ERR_BLOCK); object_unref(OBJECT(pr_mgr->ioc)); + pr_mgr->ioc =3D NULL; return n_written < 0 ? -EINVAL : 0; } =20 --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217968767382.6558778334363; Thu, 28 Jun 2018 13:32:48 -0700 (PDT) Received: from localhost ([::1]:38424 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdaq-0004N4-5G for importer@patchew.org; Thu, 28 Jun 2018 16:32:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAs-0007VG-91 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAr-0000pz-Bs for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:50 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:43836) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAr-0000p7-5B for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:49 -0400 Received: by mail-wr0-x244.google.com with SMTP id c5-v6so6681814wrs.10 for ; Thu, 28 Jun 2018 13:05:49 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=lwGal+cYmL5tuooR3D3HxGQkn5aetGa//QdgjO06iPc=; b=d9AyztKelDXh+a3/Aij5c/ib/vKyrdWobCySwpfHNRPkJICcbV9M6fmou/9AfqqYCy OIEWcjRBIIAu/P/MCxmla45y8NxiWfqE4TsqAMIyRJb25KcdwEXYdJAGciruxTCTtj0i S22kgJhC+EsxeowYh/iPemCOabEdWSck25CM9R5FGFHmDoUNang3IllYgUZ9P3Vq3Fen GDgF/+HjHVJq3byqo7fyQJih9kPAvVAtMxX7GkO7W8N0CYyepomtK7D4S5LoFUxhxNRz NiW+94P7kHtN2C+yfu2I/2iJ02dxHtoUR7F+vPN01Y7sZdnGsUuEfhE1c0MGYz/Ki1HC W84Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=lwGal+cYmL5tuooR3D3HxGQkn5aetGa//QdgjO06iPc=; b=Qzko7OG9GltWnQ5i5FVJ/qvQaZmeKaTCdm8XX6Vr6mg4WWgwSxISmV0g60X2cF12kI YcXaT1Q6p3qvrjdnN75LlucImWX/iXg5cXUqwX3T6aPWKxVEz0QSwjjjwNK9HPEAgxk+ Kde2ACxSZoVG9bd0/56kmBbXK2EoX6ORd7V9m39MAZ4dCvGiv1Pl3AN6YbHsuq9xbiq+ 54Alp8iFLXZLV848uhl9FRV3nV3bdr9TuLb7V46DLTX7pJvG+MDFqpAUcdYdi4VZQ9Ez j+9XmVCrXM97eNHug9Wkw6GbuiZpmDkkq8YGN1bByV2CdtDUOuow3KmI9tPkmlR5S4h1 0/+w== X-Gm-Message-State: APt69E1bzYV4iHMiH+WmdQEdYOfkpOZ/MKmlNkIHSZC1oxDlDU02Pw3q uOL07jSlQFVmKtModeF5D8h6xJUm X-Google-Smtp-Source: AAOMgpfUoC7M5PamQj1C+bDhlZHP/zz7mpgoaRx+YeOhXA8JdOx/YpEgS31JYQmgWDIctYGstMEimg== X-Received: by 2002:adf:d4c5:: with SMTP id w5-v6mr9561857wrk.185.1530216347892; Thu, 28 Jun 2018 13:05:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:45 +0200 Message-Id: <1530216310-52873-36-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PULL 35/60] pr-manager: put stubs in .c file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- include/scsi/pr-manager.h | 9 --------- scsi/Makefile.objs | 1 + scsi/pr-manager-stub.c | 24 ++++++++++++++++++++++++ 3 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 scsi/pr-manager-stub.c diff --git a/include/scsi/pr-manager.h b/include/scsi/pr-manager.h index 5d2f13a..71971ae 100644 --- a/include/scsi/pr-manager.h +++ b/include/scsi/pr-manager.h @@ -41,15 +41,6 @@ BlockAIOCB *pr_manager_execute(PRManager *pr_mgr, BlockCompletionFunc *complete, void *opaque); =20 -#ifdef CONFIG_LINUX PRManager *pr_manager_lookup(const char *id, Error **errp); -#else -static inline PRManager *pr_manager_lookup(const char *id, Error **errp) -{ - /* The classes do not exist at all! */ - error_setg(errp, "No persistent reservation manager with id '%s'", id); - return NULL; -} -#endif =20 #endif diff --git a/scsi/Makefile.objs b/scsi/Makefile.objs index 4d25e47..bb8789c 100644 --- a/scsi/Makefile.objs +++ b/scsi/Makefile.objs @@ -1,3 +1,4 @@ block-obj-y +=3D utils.o =20 block-obj-$(CONFIG_LINUX) +=3D pr-manager.o pr-manager-helper.o +block-obj-$(call lnot,$(CONFIG_LINUX)) +=3D pr-manager-stub.o diff --git a/scsi/pr-manager-stub.c b/scsi/pr-manager-stub.c new file mode 100644 index 0000000..632f17c --- /dev/null +++ b/scsi/pr-manager-stub.c @@ -0,0 +1,24 @@ +/* + * Persistent reservation manager - stub for non-Linux platforms + * + * Copyright (c) 2018 Red Hat, Inc. + * + * Author: Paolo Bonzini + * + * This code is licensed under the LGPL. + * + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "scsi/pr-manager.h" +#include "trace.h" +#include "qapi/qapi-types-block.h" +#include "qapi/qapi-commands-block.h" + +PRManager *pr_manager_lookup(const char *id, Error **errp) +{ + /* The classes do not exist at all! */ + error_setg(errp, "No persistent reservation manager with id '%s'", id); + return NULL; +} --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217514201963.0174828067776; Thu, 28 Jun 2018 13:25:14 -0700 (PDT) Received: from localhost ([::1]:38379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdTd-0006bd-9X for importer@patchew.org; Thu, 28 Jun 2018 16:25:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAt-0007XP-Pp for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAs-0000ra-Jd for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:51 -0400 Received: from mail-wr0-x22f.google.com ([2a00:1450:400c:c0c::22f]:41894) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAs-0000qg-91 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:50 -0400 Received: by mail-wr0-x22f.google.com with SMTP id h10-v6so6672550wrq.8 for ; Thu, 28 Jun 2018 13:05:50 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=s6FUk87YKGeyiKgWUIZtX/7jlAuSyOv4eI+XEFoPLok=; b=cSFD0AyZNHPFwboSuOaUP9vmLmll6y1Q4aucLXuPfocR70wKlxI6JW69VpoVswXHDN nExuq64HIBMALYg23zS+ZLrIPBqj1xk6i69HIqcjwQSQbzupRTYNMY2VI76J30AsdcZN bY6mrnx7HfJpfYtXQ+lYTy3t6pkVj69+t6UNiGOyP+287Cd92fCFBBxUbKwebvf4J+D+ q+/aUaX72EJQR64wqYfVUTWapA/lLq32Gxk7u9mnro/JEvwHS+sn2cdoS4pHjuY2LU/x eBBNKT3KGd6D3ZGbSll7GCkXR0bGtIsjJlDspGKUdAMKCQkQW9fAHuNhM3HJY9JzaPVQ sdhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=s6FUk87YKGeyiKgWUIZtX/7jlAuSyOv4eI+XEFoPLok=; b=h8AYaFOorx1i4JeiNvm5eN3gG+5XvrZRICqd+yWtuQKSQMHvdp+e5a+e+HpOYIY6W3 74UdeAMKwfIDlbNDopNKALQq7Y9Ob2S1VNEluxGqGeRhGYR2inT3b2Svxxci0LoOYjC0 gEjffnbf97D+iye5c1YktdrzJSPoD+yIr6FGh+5pYQuYNAOb3DUivqn5RYwIGkkkSnLU gYGuz/thXlP0rNNE9NqokBFe/+xHKMZTBWAcoYocyBtFwAqZpI1iOInxyGyr6VcjZIFe i9PptM6bcaa9QqVV2TI781bUUDJCY07vPQPr/q7kIAV6/poIcituM0gqS9Zvdy2YOMQy aVKw== X-Gm-Message-State: APt69E3LNz2lHKdUVbjD7epHf7syscfx+BBXRdtt8VipmhaiqMG1pqW8 vmzGEGV89WoCx+1C/LGqZCwuJ9Df X-Google-Smtp-Source: AAOMgpc38ekYlcaHEnAGaY5d8wfMh/Hjt2fFV1NsM+6SuTktuZ4Ws06941ixI2zYgvmmCrGa/jve7g== X-Received: by 2002:adf:fe46:: with SMTP id m6-v6mr9568007wrs.171.1530216348955; Thu, 28 Jun 2018 13:05:48 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:46 +0200 Message-Id: <1530216310-52873-37-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22f Subject: [Qemu-devel] [PULL 36/60] pr-manager: add query-pr-managers QMP command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This command lets you query the connection status of each pr-manager-helper object. Signed-off-by: Paolo Bonzini --- include/scsi/pr-manager.h | 2 ++ qapi/block.json | 28 ++++++++++++++++++++++++++++ scsi/pr-manager-helper.c | 13 +++++++++++++ scsi/pr-manager-stub.c | 6 ++++++ scsi/pr-manager.c | 45 +++++++++++++++++++++++++++++++++++++++++++= ++ 5 files changed, 94 insertions(+) diff --git a/include/scsi/pr-manager.h b/include/scsi/pr-manager.h index 71971ae..50a77b0 100644 --- a/include/scsi/pr-manager.h +++ b/include/scsi/pr-manager.h @@ -33,8 +33,10 @@ typedef struct PRManagerClass { =20 /* */ int (*run)(PRManager *pr_mgr, int fd, struct sg_io_hdr *hdr); + bool (*is_connected)(PRManager *pr_mgr); } PRManagerClass; =20 +bool pr_manager_is_connected(PRManager *pr_mgr); BlockAIOCB *pr_manager_execute(PRManager *pr_mgr, AioContext *ctx, int fd, struct sg_io_hdr *hdr, diff --git a/qapi/block.json b/qapi/block.json index ca807f1..8765c29 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -78,6 +78,34 @@ 'data': { 'device': 'str', 'name': 'str' } } =20 ## +# @PRManagerInfo: +# +# Information about a persistent reservation manager +# +# @id: the identifier of the persistent reservation manager +# +# @connected: true if the persistent reservation manager is connected to +# the underlying storage or helper +# +# Since: 3.0 +## +{ 'struct': 'PRManagerInfo', + 'data': {'id': 'str', 'connected': 'bool'} } + +## +# @query-pr-managers: +# +# Returns a list of information about each persistent reservation manager. +# +# Returns: a list of @PRManagerInfo for each persistent reservation manager +# +# Since: 3.0 +## +{ 'command': 'query-pr-managers', 'returns': ['PRManagerInfo'], + 'allow-preconfig': true } + + +## # @blockdev-snapshot-internal-sync: # # Synchronously take an internal snapshot of a block device, when the diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c index 0c0fe38..b11481b 100644 --- a/scsi/pr-manager-helper.c +++ b/scsi/pr-manager-helper.c @@ -235,6 +235,18 @@ out: return ret; } =20 +static bool pr_manager_helper_is_connected(PRManager *p) +{ + PRManagerHelper *pr_mgr =3D PR_MANAGER_HELPER(p); + bool result; + + qemu_mutex_lock(&pr_mgr->lock); + result =3D (pr_mgr->ioc !=3D NULL); + qemu_mutex_unlock(&pr_mgr->lock); + + return result; +} + static void pr_manager_helper_complete(UserCreatable *uc, Error **errp) { PRManagerHelper *pr_mgr =3D PR_MANAGER_HELPER(uc); @@ -284,6 +296,7 @@ static void pr_manager_helper_class_init(ObjectClass *k= lass, &error_abort); uc_klass->complete =3D pr_manager_helper_complete; prmgr_klass->run =3D pr_manager_helper_run; + prmgr_klass->is_connected =3D pr_manager_helper_is_connected; } =20 static const TypeInfo pr_manager_helper_info =3D { diff --git a/scsi/pr-manager-stub.c b/scsi/pr-manager-stub.c index 632f17c..738b6d7 100644 --- a/scsi/pr-manager-stub.c +++ b/scsi/pr-manager-stub.c @@ -22,3 +22,9 @@ PRManager *pr_manager_lookup(const char *id, Error **errp) error_setg(errp, "No persistent reservation manager with id '%s'", id); return NULL; } + + +PRManagerInfoList *qmp_query_pr_managers(Error **errp) +{ + return NULL; +} diff --git a/scsi/pr-manager.c b/scsi/pr-manager.c index 87c45db..2a8f300 100644 --- a/scsi/pr-manager.c +++ b/scsi/pr-manager.c @@ -17,6 +17,10 @@ #include "block/thread-pool.h" #include "scsi/pr-manager.h" #include "trace.h" +#include "qapi/qapi-types-block.h" +#include "qapi/qapi-commands-block.h" + +#define PR_MANAGER_PATH "/objects" =20 typedef struct PRManagerData { PRManager *pr_mgr; @@ -64,6 +68,14 @@ BlockAIOCB *pr_manager_execute(PRManager *pr_mgr, data, complete, opaque); } =20 +bool pr_manager_is_connected(PRManager *pr_mgr) +{ + PRManagerClass *pr_mgr_class =3D + PR_MANAGER_GET_CLASS(pr_mgr); + + return !pr_mgr_class->is_connected || pr_mgr_class->is_connected(pr_mg= r); +} + static const TypeInfo pr_manager_info =3D { .parent =3D TYPE_OBJECT, .name =3D TYPE_PR_MANAGER, @@ -105,5 +117,38 @@ pr_manager_register_types(void) type_register_static(&pr_manager_info); } =20 +static int query_one_pr_manager(Object *object, void *opaque) +{ + PRManagerInfoList ***prev =3D opaque; + PRManagerInfoList *elem; + PRManagerInfo *info; + PRManager *pr_mgr; + + pr_mgr =3D (PRManager *)object_dynamic_cast(object, TYPE_PR_MANAGER); + if (!pr_mgr) { + return 0; + } + + elem =3D g_new0(PRManagerInfoList, 1); + info =3D g_new0(PRManagerInfo, 1); + info->id =3D object_get_canonical_path_component(object); + info->connected =3D pr_manager_is_connected(pr_mgr); + elem->value =3D info; + elem->next =3D NULL; + + **prev =3D elem; + *prev =3D &elem->next; + return 0; +} + +PRManagerInfoList *qmp_query_pr_managers(Error **errp) +{ + PRManagerInfoList *head =3D NULL; + PRManagerInfoList **prev =3D &head; + Object *container =3D container_get(object_get_root(), PR_MANAGER_PATH= ); + + object_child_foreach(container, query_one_pr_manager, &prev); + return head; +} =20 type_init(pr_manager_register_types); --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530218427449919.1508840189633; Thu, 28 Jun 2018 13:40:27 -0700 (PDT) Received: from localhost ([::1]:38464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdiM-0002Je-J9 for importer@patchew.org; Thu, 28 Jun 2018 16:40:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAw-0007aL-LE for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAt-0000sT-GH for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:54 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:37463) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAt-0000rh-9X for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:51 -0400 Received: by mail-wr0-x243.google.com with SMTP id k6-v6so6688251wrp.4 for ; Thu, 28 Jun 2018 13:05:51 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=mO0hAaOtHPtWRlC0Qa+Uf+wdjguiZp5fFePRKqCfNrk=; b=pq75xC1wcxZGgGZFNTjFS098xx8LHMhmDK93WSiTngeTjgZ7CVEgrKOnoL50LlniK0 jSDRY6pQpp323nn+b5d0NabidnyuFsOLIShsjzyLSlpNJqadaP8PEK9CL5M34uBTOqS2 8T0uHd2KXXrsmJDEqjPYLY3eTQlQ85yaMl9qJEPDL3djIbQbpYPP52IrkbEDbxXps5v7 CK4F/qpH4B0hX/ri48ZKuCxxAENV/83n88nnLcOZgRsmJU9v8iwpSe7L8BWt78Sez/Xu VvLKeQ6NEWQlCd51eL+pvdub+34ypRWI7Nv39DqQhP1XsacNHYeW3nNOOjgd4t1WZMLd u62g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=mO0hAaOtHPtWRlC0Qa+Uf+wdjguiZp5fFePRKqCfNrk=; b=HPJKk3gx34QWXmSAk+Jj8ojibE5sKU6sjeJ/agiWAzG4VhnBLW8qWjZCbOAiwkG4/h FpPqdP5Ei0x6QOJYGgziGvAPa9Pmhxe614ZpGBLP83ebS1iCcwDCW4fLi8jy5CvBTC6b UskiMh1wf7r5AUqD2ukUY2AVT1/epgDDWkoDTgwM35wDsXQt6bKwosrmmi4jiXfV1zjl pkn3UY+jOM58+f7fhtEaDm6jWhn5X3ahffeL441l5youY6NidzTZo+uUyJRgxy3Lv0Rc C4wKQ8Zno306S3HefKW05y31eI/4Rmz5sgsOOhBjmByduBsTDU5EoCfwh+TUSmghPDDP Z7sg== X-Gm-Message-State: APt69E2rLatYs94a0KAGCfZx9ZZnQUBT76vIH47kcWYlAWG0p0LU4kQm sF4dMZmr4+CdmrFopWNkUngTDZSj X-Google-Smtp-Source: AAOMgpdBBRo8PyAw1Nbl+zHNDSDGJfblV8nFd6E88T8g146vbHg7G6Esq18XGKfxJBdcXwdQn8BtBA== X-Received: by 2002:adf:c301:: with SMTP id n1-v6mr10279403wrf.270.1530216349910; Thu, 28 Jun 2018 13:05:49 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:47 +0200 Message-Id: <1530216310-52873-38-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 37/60] pr-manager-helper: report event on connection/disconnection X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Let management know if there were any problems communicating with qemu-pr-helper. The event is edge-triggered, and is sent every time the connection status of the pr-manager-helper object changes. Signed-off-by: Paolo Bonzini --- qapi/block.json | 24 ++++++++++++++++++++++++ scsi/pr-manager-helper.c | 14 ++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/qapi/block.json b/qapi/block.json index 8765c29..11f01f2 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -359,6 +359,30 @@ 'data': { 'device': 'str', 'id': 'str', 'tray-open': 'bool' } } =20 ## +# @PR_MANAGER_STATUS_CHANGED: +# +# Emitted whenever the connected status of a persistent reservation +# manager changes. +# +# @id: The id of the PR manager object +# +# @connected: true if the PR manager is connected to a backend +# +# Since: 3.0 +# +# Example: +# +# <- { "event": "PR_MANAGER_STATUS_CHANGED", +# "data": { "id": "pr-helper0", +# "connected": true +# }, +# "timestamp": { "seconds": 1519840375, "microseconds": 450486 } } +# +## +{ 'event': 'PR_MANAGER_STATUS_CHANGED', + 'data': { 'id': 'str', 'connected': 'bool' } } + +## # @QuorumOpType: # # An enumeration of the quorum operation types diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c index b11481b..519a296 100644 --- a/scsi/pr-manager-helper.c +++ b/scsi/pr-manager-helper.c @@ -17,6 +17,7 @@ #include "io/channel.h" #include "io/channel-socket.h" #include "pr-helper.h" +#include "qapi/qapi-events-block.h" =20 #include =20 @@ -38,6 +39,16 @@ typedef struct PRManagerHelper { QIOChannel *ioc; } PRManagerHelper; =20 +static void pr_manager_send_status_changed_event(PRManagerHelper *pr_mgr) +{ + char *id =3D object_get_canonical_path_component(OBJECT(pr_mgr)); + + if (id) { + qapi_event_send_pr_manager_status_changed(id, !!pr_mgr->ioc, + &error_abort); + } +} + /* Called with lock held. */ static int pr_manager_helper_read(PRManagerHelper *pr_mgr, void *buf, int sz, Error **errp) @@ -47,6 +58,7 @@ static int pr_manager_helper_read(PRManagerHelper *pr_mgr, if (r < 0) { object_unref(OBJECT(pr_mgr->ioc)); pr_mgr->ioc =3D NULL; + pr_manager_send_status_changed_event(pr_mgr); return -EINVAL; } =20 @@ -72,6 +84,7 @@ static int pr_manager_helper_write(PRManagerHelper *pr_mg= r, assert(n_written !=3D QIO_CHANNEL_ERR_BLOCK); object_unref(OBJECT(pr_mgr->ioc)); pr_mgr->ioc =3D NULL; + pr_manager_send_status_changed_event(pr_mgr); return n_written < 0 ? -EINVAL : 0; } =20 @@ -127,6 +140,7 @@ static int pr_manager_helper_initialize(PRManagerHelper= *pr_mgr, goto out_close; } =20 + pr_manager_send_status_changed_event(pr_mgr); return 0; =20 out_close: --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153021860038694.73357699427709; Thu, 28 Jun 2018 13:43:20 -0700 (PDT) Received: from localhost ([::1]:38486 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdl9-0005Qx-LC for importer@patchew.org; Thu, 28 Jun 2018 16:43:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAw-0007aN-LN for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAu-0000tv-IU for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:54 -0400 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]:45170) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAu-0000so-As for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:52 -0400 Received: by mail-wr0-x22e.google.com with SMTP id u7-v6so6680497wrn.12 for ; Thu, 28 Jun 2018 13:05:52 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4U9Frdyn/LQ+KGr1l0uYUNbDOcw2OBREf0dl2maskiU=; b=XK9MOa8h7fGpUy7vi6kCu0N1AyK43p7x+h90D6qn6N6nDbSAxYocGJ0eQxGTfhjE94 syvoaD13XlMjBILNf0mmIU928FusR6OeRQZ5Vy2TczQdoKYrJ1lrhc5Gqei2kNdtlK4v iC/Iw/8bitz5nps1DgZUTrr+RYyE8lNEhQfmgOELuFoXiY36IYeaTEUf3sxL2MH5PTYh 8Wvq1gBB6bapBZLAZDBB+CbKKP1pjiIYTkDYihUfUADFidzvBIyH6Eq6s+mEMdh96bdA Sy6xviKoQ48z3oBVkClHoTIiL0B23IWK+fBu3odDMWRGFfI7hlKOf1VQwO5D7T9NdcZW Ffhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=4U9Frdyn/LQ+KGr1l0uYUNbDOcw2OBREf0dl2maskiU=; b=qoJgmutxF44jSCtabtQ3tfV2XbK5OnP8OFbhjn5D7No+u9mUYus+bXgeCsdtm0dDmJ U+VdGcZB61ph0mu44MsvclWUC99q77SjIYLjdid44W2gT0Fuu3MRkRjKoe1C/R1y84bZ GJpawMFztWHH9FyscPm073JRtPbF6bG34mBnlnXqgZuXMpzErbSPsyyW/x2JBvyDvgpa HVvTFCLnP3OT5GBBgWAAc13I9D9eu17GfnDnYxIBofzc8TTHg/nTQ55RS/j0yemy3vuK 8hfZwz28LXKooZ9CT0pC+PO2NwQYg+2HwivSVIu0Ye2TUFSVX72P0WWfS65l+3IhjH4r i55w== X-Gm-Message-State: APt69E0aZq8Qts4B6RgcFvK2Ou7GtX3HaeVisIBqPgkFyXe4ggThpfPp ura1PGz2W7b+gouCSRtOwCdszlhh X-Google-Smtp-Source: AAOMgpdJsRKe1PCr/YdY/9QO4bizVsRPNM9b/x5OMCX9uqGrPJGePhMUcBeZleRJXS//LbuM5pDSfg== X-Received: by 2002:adf:9102:: with SMTP id j2-v6mr10170802wrj.57.1530216351077; Thu, 28 Jun 2018 13:05:51 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:48 +0200 Message-Id: <1530216310-52873-39-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22e Subject: [Qemu-devel] [PULL 38/60] hw/mips/jazz: create ESP device directly via qdev X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Mark Cave-Ayland MIPS jazz is the last user of the legacy esp_init() function so move creati= on of the ESP device over to use qdev. Note that the esp_reset and dma_enable qemu_irqs are currently unused and so we do not wire these up and instead remove the variables to prevent the compiler emitting unused variable warnings. Signed-off-by: Mark Cave-Ayland Message-Id: <20180613094727.11326-2-mark.cave-ayland@ilande.co.uk> Signed-off-by: Paolo Bonzini Tested-by: Herv=C3=A9 Poussineau --- hw/mips/mips_jazz.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c index 90cb306..1afbe3c 100644 --- a/hw/mips/mips_jazz.c +++ b/hw/mips/mips_jazz.c @@ -145,10 +145,10 @@ static void mips_jazz_init(MachineState *machine, ISABus *isa_bus; ISADevice *pit; DriveInfo *fds[MAX_FD]; - qemu_irq esp_reset, dma_enable; MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *bios =3D g_new(MemoryRegion, 1); MemoryRegion *bios2 =3D g_new(MemoryRegion, 1); + SysBusESPState *sysbus_esp; ESPState *esp; =20 /* init CPUs */ @@ -281,8 +281,21 @@ static void mips_jazz_init(MachineState *machine, } =20 /* SCSI adapter */ - esp =3D esp_init(0x80002000, 0, rc4030_dma_read, rc4030_dma_write, dma= s[0], - qdev_get_gpio_in(rc4030, 5), &esp_reset, &dma_enable); + dev =3D qdev_create(NULL, TYPE_ESP); + sysbus_esp =3D ESP_STATE(dev); + esp =3D &sysbus_esp->esp; + esp->dma_memory_read =3D rc4030_dma_read; + esp->dma_memory_write =3D rc4030_dma_write; + esp->dma_opaque =3D dmas[0]; + sysbus_esp->it_shift =3D 0; + /* XXX for now until rc4030 has been changed to use DMA enable signal = */ + esp->dma_enabled =3D 1; + qdev_init_nofail(dev); + + sysbus =3D SYS_BUS_DEVICE(dev); + sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(rc4030, 5)); + sysbus_mmio_map(sysbus, 0, 0x80002000); + scsi_bus_legacy_handle_cmdline(&esp->bus); =20 /* Floppy */ --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530218426693796.3628940191437; Thu, 28 Jun 2018 13:40:26 -0700 (PDT) Received: from localhost ([::1]:38463 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdiM-0002Gv-1A for importer@patchew.org; Thu, 28 Jun 2018 16:40:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAw-0007aM-LI for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAv-0000vU-EY for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:54 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:44036) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAv-0000u7-7Y for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:53 -0400 Received: by mail-wr0-x244.google.com with SMTP id p12-v6so6676349wrn.11 for ; Thu, 28 Jun 2018 13:05:53 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OTU9nOzigmCSPzLcxmr/6iAJCHWRunYdD8W68iYnPMw=; b=mg9phm4LTR2gv7E8FjV0d4pquLCLFCPwKM6QizzJfier9K9CKXojG4YH1uuxgoYbgy VhAjsXg+zYW+vMOQWpkdqMazRks5SZVOtPEGlA+fnpGEr3qBkkcEuJ79PzZlLaGujQwq daxu576mVtKzl3b47bVhrzDqiItChbHxs3Y3y+/de8G/gn34R3aHn5eUe1BCsdWe7Z+b S/098EIeTgMZUQ471kLD+7ddJ7pigyT8ePi4ATx4sHg15nbIlPqgnHiAxUYn0paV9rHA a8C2LUGRa+l4lgdu1clSpeAetMLckXBZnGw1LaOvjdFdsrK1Iu7HVvgjGiDlBMN/s6uJ UITQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=OTU9nOzigmCSPzLcxmr/6iAJCHWRunYdD8W68iYnPMw=; b=kgmGui1zlsFIOI4VXifo8quFdlPIJ5/pEvqagsvkYRupEyOfpoXFd+4JiuTvwOazAJ xk2HlNaz6lF9xnwGYDq/OsMDpVTqNlGB6qX9wP4jT/8BKTTouxVrs91AVzx0xXNXGF2y Dkhjp88vLWqts31VOJiTJ8ik/XBYNEFEs3Gn92p4eiExmTzOw/miI8HHZ7ErcUUUdksW Y6dD2DLrO+batInfPAvowpAkC4N0igBRjASlz8/IdLj3Jqxb6vsfPJ7jL6UtN3XQxOzT c59bEWqh+NO2JzMr5qeQZ5okctHA4M2+CYbMzb795CPzQSutd2ZcF2fI7DEVHk+xs4tu Dveg== X-Gm-Message-State: APt69E3k3ZYrh4aV1ayiXyEY8Owc0XslDusKKoG8Iw0ZqicSkTK+Fkbs xthFNutXwMp9xTZWFqTlnExxUbIb X-Google-Smtp-Source: AAOMgpd4uP6NYQ3+TMCa39yrYIT+o0qi6vLvHdy4l9VDqL/iiXnzQj3+bSU/d0M62uFYpd4jtCZcfA== X-Received: by 2002:adf:ebc3:: with SMTP id v3-v6mr9795044wrn.33.1530216351954; Thu, 28 Jun 2018 13:05:51 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:49 +0200 Message-Id: <1530216310-52873-40-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PULL 39/60] esp: remove legacy esp_init() function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Mark Cave-Ayland Remove the legacy esp_init() function now that there are no more remaining users. Signed-off-by: Mark Cave-Ayland Message-Id: <20180613094727.11326-3-mark.cave-ayland@ilande.co.uk> Signed-off-by: Paolo Bonzini Tested-by: Herv=C3=A9 Poussineau --- hw/scsi/esp.c | 30 ------------------------------ include/hw/scsi/esp.h | 5 ----- 2 files changed, 35 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 9ed9727..630d923 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -619,36 +619,6 @@ static const MemoryRegionOps sysbus_esp_mem_ops =3D { .valid.accepts =3D esp_mem_accepts, }; =20 -ESPState *esp_init(hwaddr espaddr, int it_shift, - ESPDMAMemoryReadWriteFunc dma_memory_read, - ESPDMAMemoryReadWriteFunc dma_memory_write, - void *dma_opaque, qemu_irq irq, qemu_irq *reset, - qemu_irq *dma_enable) -{ - DeviceState *dev; - SysBusDevice *s; - SysBusESPState *sysbus; - ESPState *esp; - - dev =3D qdev_create(NULL, TYPE_ESP); - sysbus =3D ESP_STATE(dev); - esp =3D &sysbus->esp; - esp->dma_memory_read =3D dma_memory_read; - esp->dma_memory_write =3D dma_memory_write; - esp->dma_opaque =3D dma_opaque; - sysbus->it_shift =3D it_shift; - /* XXX for now until rc4030 has been changed to use DMA enable signal = */ - esp->dma_enabled =3D 1; - qdev_init_nofail(dev); - s =3D SYS_BUS_DEVICE(dev); - sysbus_connect_irq(s, 0, irq); - sysbus_mmio_map(s, 0, espaddr); - *reset =3D qdev_get_gpio_in(dev, 0); - *dma_enable =3D qdev_get_gpio_in(dev, 1); - - return esp; -} - static const struct SCSIBusInfo esp_scsi_info =3D { .tcq =3D false, .max_target =3D ESP_MAX_DEVS, diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index 93fdace..682a0d2 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -131,11 +131,6 @@ typedef struct { #define TCHI_FAS100A 0x4 #define TCHI_AM53C974 0x12 =20 -ESPState *esp_init(hwaddr espaddr, int it_shift, - ESPDMAMemoryReadWriteFunc dma_memory_read, - ESPDMAMemoryReadWriteFunc dma_memory_write, - void *dma_opaque, qemu_irq irq, qemu_irq *reset, - qemu_irq *dma_enable); void esp_dma_enable(ESPState *s, int irq, int level); void esp_request_cancelled(SCSIRequest *req); void esp_command_complete(SCSIRequest *req, uint32_t status, size_t resid); --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530218766819501.48124030750785; Thu, 28 Jun 2018 13:46:06 -0700 (PDT) Received: from localhost ([::1]:38508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdnl-0008J1-Vq for importer@patchew.org; Thu, 28 Jun 2018 16:46:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAx-0007b4-FF for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAw-0000wj-Az for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:55 -0400 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:46017) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAw-0000vZ-2e for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:54 -0400 Received: by mail-wr0-x242.google.com with SMTP id u7-v6so6680561wrn.12 for ; Thu, 28 Jun 2018 13:05:53 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=lnP/SVhv3c3srDgVWrVnoDRYNY1ZOuDavKllehni4wk=; b=hHdPKYXg5kVuZB96eNnRWWncs0A5p3GvnRCtJbu9eww831eAD2huCZYpInDqLrSGcA 1mlW5UBfrYlxQ8TFJ6XPWR+nNMpy9J9/EZ52N2hq8MTJYyIvJFt+7tfF++YepCUka/G0 8QUBW/FmxIKWIYfF1Ee2JT37i3hBUOnNylzn0p+2tPRD9mK3GZjcCFvBa5xJDxrN1OI5 v0PK9ObiosPxpaXRx8scGQ5YMDrGHtn9qiXoJ742WymKWxgfNjA4C2GJ3BuoddbBArxw Je/7w+D1qNPUWhMeueZ85Z97GYLGHEtSFWAQF4Y9leW2FWDEP0Mv/HcCGChISDN00Fek 1r0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=lnP/SVhv3c3srDgVWrVnoDRYNY1ZOuDavKllehni4wk=; b=Oe1Iz8WpIVqpaFbutvVQOGUr7biLi5SuHMRNMGmV5ELNDmCRqbjFJnCuHHu98PbtnV ybvpSAtsdYShsVL9ZBBa+OMsP1jzXEPgy+5eg4U/6U6SHEDMf0RWvLPo4lbTYV8n1j0V 9QnV0x8ejwoJUoGbP+Lg08E2Bmwo/nEcY5Mue+effW6ji+dOkl+9dEeuWljDNTv3W4LP l+K1dmv3kFOJ+wTtQPtYi6cdWFKoq11ip/PwZkbE50pG6Hf113S768MPnJsMjBYq5xSh oKNUXDkDl88fLKhgBXVoD3/aJLD0mHFxDIQj7qqe6PICmfA/ljh2AUeG0Qbi4ZYWiI0C eSpQ== X-Gm-Message-State: APt69E0lq53tT/cejZBgI2mIXYjqmksluJMYI9ibQvO1e5FqlqVAYHnH L/WtBuvnC+rbZhpc2j62kC6bHOq5 X-Google-Smtp-Source: AAOMgpdbHyzqEL6iXBgk54Me60vIPXLLESF+lx+kL8i8TLi4XIkvDRwKmYDuP9bKOi55PO7fMNaymA== X-Received: by 2002:adf:8188:: with SMTP id 8-v6mr10259759wra.89.1530216352774; Thu, 28 Jun 2018 13:05:52 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:50 +0200 Message-Id: <1530216310-52873-41-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 40/60] WHPX workaround bug in OSVW handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Justin Terry \(VM\)" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Justin Terry (VM)" Adds a workaround to an incorrect value setting CPUID Fn8000_0001_ECX[bit 9 OSVW] =3D 1. This can cause a guest linux kernel to panic when an issue to rdmsr C001_0140h returns 0. Disabling this feature correctly allows the guest to boot without accessing the osv workarounds. Signed-off-by: Justin Terry (VM) Message-Id: <20180605221500.21674-1-juterry@microsoft.com> Signed-off-by: Paolo Bonzini --- target/i386/whpx-all.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/target/i386/whpx-all.c b/target/i386/whpx-all.c index 6b42096..99501ba 100644 --- a/target/i386/whpx-all.c +++ b/target/i386/whpx-all.c @@ -964,6 +964,16 @@ static int whpx_vcpu_run(CPUState *cpu) rdx =3D vcpu->exit_ctx.CpuidAccess.DefaultResultRdx; rbx =3D vcpu->exit_ctx.CpuidAccess.DefaultResultRbx; break; + case 0x80000001: + rax =3D vcpu->exit_ctx.CpuidAccess.DefaultResultRax; + /* Remove any support of OSVW */ + rcx =3D + vcpu->exit_ctx.CpuidAccess.DefaultResultRcx & + ~CPUID_EXT3_OSVW; + + rdx =3D vcpu->exit_ctx.CpuidAccess.DefaultResultRdx; + rbx =3D vcpu->exit_ctx.CpuidAccess.DefaultResultRbx; + break; default: rax =3D vcpu->exit_ctx.CpuidAccess.DefaultResultRax; rcx =3D vcpu->exit_ctx.CpuidAccess.DefaultResultRcx; @@ -1382,12 +1392,13 @@ static int whpx_accel_init(MachineState *ms) goto error; } =20 - UINT32 cpuidExitList[] =3D {1}; + UINT32 cpuidExitList[] =3D {1, 0x80000001}; hr =3D whp_dispatch.WHvSetPartitionProperty( whpx->partition, WHvPartitionPropertyCodeCpuidExitList, cpuidExitList, RTL_NUMBER_OF(cpuidExitList) * sizeof(UINT32)); + if (FAILED(hr)) { error_report("WHPX: Failed to set partition CpuidExitList hr=3D%08= lx", hr); --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530218139659386.63781692833004; Thu, 28 Jun 2018 13:35:39 -0700 (PDT) Received: from localhost ([::1]:38437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYddi-0006jn-TO for importer@patchew.org; Thu, 28 Jun 2018 16:35:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAy-0007ce-7m for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAx-0000y1-7v for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:56 -0400 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:43835) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAx-0000wu-0S for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:55 -0400 Received: by mail-wr0-x242.google.com with SMTP id c5-v6so6682014wrs.10 for ; Thu, 28 Jun 2018 13:05:54 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=QF/kNaXicyap5zS8PbToiF8fNXhM2h7AN0o9/gNB3VA=; b=q3NkM6h8Kb8Pjdwcv01zIE2IEQjB/z3WdvGej0k6xe9khpokKnQGPjVKgXNkJLemL5 g/iTBVTsHiP6yRQec/5eMssC3K9mjIZjGyGMSwf5HhL8ARmmfBbvdH4N7wak6FLvIs0E HfIYrR3B9CaiiqmabjGlTodk5shyCOpAUdDGIkNx+nNOOUeEdbarHiZ0ztc8e6w8HctS GNxzN2QCLYkcpeK0CtfXrmpkvJSz9n603JUyQhfERtnW33Hrbd57ndIW0pFOQenzrvgl bvue2kkfl20AH2+Q+2z18wWcLAU+7nC3xpeDCJwOn9nwlng2k2w2VviAGvk5m3oAthyM ETSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=QF/kNaXicyap5zS8PbToiF8fNXhM2h7AN0o9/gNB3VA=; b=U43krB5VtEuCCjs7ffFtk+FXNJW5ykbQAC1uHrQp0bRmDioSU52RlXPil1t2SuPPH8 e4JkvHJT6FGwfFcamEbnZlX1Xl/hhwZ0gtPX+WXYSAJDEF/55WWLGLR1vbBEjn134vBY yyBwbtDv+CCpI0IbZSd4O/6lKD7BYSnMF8xGAb4sB5vQjQHr5GKVGT6x0Kk9qMyf1976 aJWKsKImJ3k4s2x/0E4pnlU71sjN1fO0x2PlJ4jmekbN1UJDP5Me7zmVa8TvciZk+VVj zw6879xzOrHG73N3TJH6NeA1YKqmsRsiTNoLNXDjDIezB0pscS6TlNk2z91PoK8Z5HFh /GHA== X-Gm-Message-State: APt69E0/LHC/f16tkAsZJvLb3H71CHhszajrt3Drt4tWdVABcAQCFHVk zxWM0SHEHXWsWAsc1kS7biMg0e+C X-Google-Smtp-Source: AAOMgpdcGs7SSnIgYjhvfos6xD255emA+AKfIBcF9qaZpNi2jWJO9YYAcwfEpv+XtDGC1m/JWGr++g== X-Received: by 2002:adf:ed52:: with SMTP id u18-v6mr9494378wro.262.1530216353741; Thu, 28 Jun 2018 13:05:53 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:51 +0200 Message-Id: <1530216310-52873-42-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 41/60] WHPX: register for unrecognized MSR exits X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Justin Terry \(VM\)" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Justin Terry (VM)" Some variations of Linux kernels end up accessing MSR's that the Windows Hypervisor doesn't implement which causes a GP to be returned to the guest. This fix registers QEMU for unimplemented MSR access and globally returns 0= on reads and ignores writes. This behavior is allows the Linux kernel to probe= the MSR with a write/read/check sequence it does often without failing the acce= ss. Signed-off-by: Justin Terry (VM) Message-Id: <20180605221500.21674-2-juterry@microsoft.com> Signed-off-by: Paolo Bonzini --- target/i386/whpx-all.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/target/i386/whpx-all.c b/target/i386/whpx-all.c index 99501ba..57e53e1 100644 --- a/target/i386/whpx-all.c +++ b/target/i386/whpx-all.c @@ -932,6 +932,7 @@ static int whpx_vcpu_run(CPUState *cpu) =20 case WHvRunVpExitReasonX64InterruptWindow: vcpu->window_registered =3D 0; + ret =3D 0; break; =20 case WHvRunVpExitReasonX64Halt: @@ -943,6 +944,40 @@ static int whpx_vcpu_run(CPUState *cpu) ret =3D 1; break; =20 + case WHvRunVpExitReasonX64MsrAccess: { + WHV_REGISTER_VALUE reg_values[3] =3D {0}; + WHV_REGISTER_NAME reg_names[3]; + UINT32 reg_count; + + reg_names[0] =3D WHvX64RegisterRip; + reg_names[1] =3D WHvX64RegisterRax; + reg_names[2] =3D WHvX64RegisterRdx; + + reg_values[0].Reg64 =3D + vcpu->exit_ctx.VpContext.Rip + + vcpu->exit_ctx.VpContext.InstructionLength; + + /* + * For all unsupported MSR access we: + * ignore writes + * return 0 on read. + */ + reg_count =3D vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite ? + 1 : 3; + + hr =3D whp_dispatch.WHvSetVirtualProcessorRegisters( + whpx->partition, + cpu->cpu_index, + reg_names, reg_count, + reg_values); + + if (FAILED(hr)) { + error_report("WHPX: Failed to set MsrAccess state " + " registers, hr=3D%08lx", hr); + } + ret =3D 0; + break; + } case WHvRunVpExitReasonX64Cpuid: { WHV_REGISTER_VALUE reg_values[5]; WHV_REGISTER_NAME reg_names[5]; @@ -1010,7 +1045,6 @@ static int whpx_vcpu_run(CPUState *cpu) case WHvRunVpExitReasonUnrecoverableException: case WHvRunVpExitReasonInvalidVpRegisterValue: case WHvRunVpExitReasonUnsupportedFeature: - case WHvRunVpExitReasonX64MsrAccess: case WHvRunVpExitReasonException: default: error_report("WHPX: Unexpected VP exit code %d", @@ -1378,6 +1412,7 @@ static int whpx_accel_init(MachineState *ms) } =20 memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY)); + prop.ExtendedVmExits.X64MsrExit =3D 1; prop.ExtendedVmExits.X64CpuidExit =3D 1; hr =3D whp_dispatch.WHvSetPartitionProperty( whpx->partition, @@ -1386,8 +1421,8 @@ static int whpx_accel_init(MachineState *ms) sizeof(WHV_PARTITION_PROPERTY)); =20 if (FAILED(hr)) { - error_report("WHPX: Failed to enable partition extended X64CpuidEx= it" - " hr=3D%08lx", hr); + error_report("WHPX: Failed to enable partition extended X64MsrExit= and" + " X64CpuidExit hr=3D%08lx", hr); ret =3D -EINVAL; goto error; } --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530219031584748.4665491325457; Thu, 28 Jun 2018 13:50:31 -0700 (PDT) Received: from localhost ([::1]:38524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYds6-0003Nc-QJ for importer@patchew.org; Thu, 28 Jun 2018 16:50:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAz-0007eg-W4 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAy-0000zs-F4 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:57 -0400 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:51042) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAy-0000yV-4V for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:56 -0400 Received: by mail-wm0-x233.google.com with SMTP id e16-v6so10988119wmd.0 for ; Thu, 28 Jun 2018 13:05:56 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=fV3TtfIT7p+pqtrmvhOtYj5D5G8NxO1/wN0xoD8R1sk=; b=n1txqVjrktjzPy51tjRnY2G/Vq6ifLzGD9zMB+dpruIK1h1hHR16NpHygTR1QKSRBn n1Cg9Kg17QVUm0+PpnWsAFCK0DCd1M6ZuxKVmtSBw6p/k0xSwRsUDguOfkvLB8XVMS7B 00HBip96x9D4rRqrkoYR8swIovNzZt+SHG68FxrGIRLdTXzPcmIXiztVUyViRKiRFEm0 44bOfinVi8d6p5U0OH3anzqDcVT9cB4H+6ovcN+mnH8H2QrmpDIuSOwqbM2TGFDhzJ39 WtIhtcYduC9012IMoV3gsRpqNRm1YgyfCZUFAxwxbEqYJqR3JKNeOMvHu0nrsnGC2FlH nWSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=fV3TtfIT7p+pqtrmvhOtYj5D5G8NxO1/wN0xoD8R1sk=; b=PhEROC2iF/NgOr5MeXK+9gL97GlzkE7dOt8OH/p9/SLaoDZg8Jb4enMd7LRGV63Z7F MWj+KatTryNoFypL0LayoizG3iG71jHmIRA/yyCuK3HdYC2MdJ+eGPgJJOU0+fzycYqh onXME5NjMuU0qqWzx2DHHMbOtVdeXOg2Ox+H9OIAyj7s8He8wI330M92E+UeImFRTi05 reeDL1QUvUhYO8VKgRR17iHGoH8HNOoLeVV80SghTkE1dnrq4KYT9AlEigJdkeRGwuFO aA/LwVoZJhSim2YK6MjqTt7vw67Z6hCJZx6t5UwkZIjdVcZw7Z/NxylATj/FeHWHtadj CgwQ== X-Gm-Message-State: APt69E309fd0nGVAQJC8dPxvU5tlEnV73Rgv0ymtrd4h7CgNpIxDsHTA Zntnhah8NILewu1W/kifHYF3ESzD X-Google-Smtp-Source: AAOMgpfxDqltjzLzrWEjrdNwaFuhNHVp5crf7QlSujfVxFCaoFwJZueNkyBYrnNTOc+p0S+yXtnt2Q== X-Received: by 2002:a1c:1205:: with SMTP id 5-v6mr3666730wms.41.1530216354767; Thu, 28 Jun 2018 13:05:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:52 +0200 Message-Id: <1530216310-52873-43-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::233 Subject: [Qemu-devel] [PULL 42/60] memory/hmp: Print owners/parents in "info mtree" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alexey Kardashevskiy This adds owners/parents (which are the same, just occasionally owner=3D=3DNULL) printing for memory regions; a new '-o' flag enabled new output. Signed-off-by: Alexey Kardashevskiy Message-Id: <20180604032511.6980-1-aik@ozlabs.ru> Signed-off-by: Paolo Bonzini --- hmp-commands-info.hx | 7 ++--- include/exec/memory.h | 2 +- memory.c | 72 ++++++++++++++++++++++++++++++++++++++++++++---= ---- monitor.c | 4 ++- 4 files changed, 70 insertions(+), 15 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 6db3457..59bdd8f 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -253,10 +253,11 @@ ETEXI =20 { .name =3D "mtree", - .args_type =3D "flatview:-f,dispatch_tree:-d", - .params =3D "[-f][-d]", + .args_type =3D "flatview:-f,dispatch_tree:-d,owner:-o", + .params =3D "[-f][-d][-o]", .help =3D "show memory tree (-f: dump flat view for address = spaces;" - "-d: dump dispatch tree, valid with -f only)", + "-d: dump dispatch tree, valid with -f only);" + "-o: dump region owners/parents", .cmd =3D hmp_info_mtree, }, =20 diff --git a/include/exec/memory.h b/include/exec/memory.h index 050323f..448d41a 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1665,7 +1665,7 @@ void memory_global_dirty_log_start(void); void memory_global_dirty_log_stop(void); =20 void mtree_info(fprintf_function mon_printf, void *f, bool flatview, - bool dispatch_tree); + bool dispatch_tree, bool owner); =20 /** * memory_region_request_mmio_ptr: request a pointer to an mmio diff --git a/memory.c b/memory.c index 21aa57d..e9cd446 100644 --- a/memory.c +++ b/memory.c @@ -2858,10 +2858,49 @@ typedef QTAILQ_HEAD(mrqueue, MemoryRegionList) Memo= ryRegionListHead; int128_sub((size), int128_one())) : 0) #define MTREE_INDENT " " =20 +static void mtree_expand_owner(fprintf_function mon_printf, void *f, + const char *label, Object *obj) +{ + DeviceState *dev =3D (DeviceState *) object_dynamic_cast(obj, TYPE_DEV= ICE); + + mon_printf(f, " %s:{%s", label, dev ? "dev" : "obj"); + if (dev && dev->id) { + mon_printf(f, " id=3D%s", dev->id); + } else { + gchar *canonical_path =3D object_get_canonical_path(obj); + if (canonical_path) { + mon_printf(f, " path=3D%s", canonical_path); + g_free(canonical_path); + } else { + mon_printf(f, " type=3D%s", object_get_typename(obj)); + } + } + mon_printf(f, "}"); +} + +static void mtree_print_mr_owner(fprintf_function mon_printf, void *f, + const MemoryRegion *mr) +{ + Object *owner =3D mr->owner; + Object *parent =3D memory_region_owner((MemoryRegion *)mr); + + if (!owner && !parent) { + mon_printf(f, " orphan"); + return; + } + if (owner) { + mtree_expand_owner(mon_printf, f, "owner", owner); + } + if (parent && parent !=3D owner) { + mtree_expand_owner(mon_printf, f, "parent", parent); + } +} + static void mtree_print_mr(fprintf_function mon_printf, void *f, const MemoryRegion *mr, unsigned int level, hwaddr base, - MemoryRegionListHead *alias_print_queue) + MemoryRegionListHead *alias_print_queue, + bool owner) { MemoryRegionList *new_ml, *ml, *next_ml; MemoryRegionListHead submr_print_queue; @@ -2907,7 +2946,7 @@ static void mtree_print_mr(fprintf_function mon_print= f, void *f, } mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): alias %s @%s " TARGET_FMT_plx - "-" TARGET_FMT_plx "%s\n", + "-" TARGET_FMT_plx "%s", cur_start, cur_end, mr->priority, memory_region_type((MemoryRegion *)mr), @@ -2916,15 +2955,22 @@ static void mtree_print_mr(fprintf_function mon_pri= ntf, void *f, mr->alias_offset, mr->alias_offset + MR_SIZE(mr->size), mr->enabled ? "" : " [disabled]"); + if (owner) { + mtree_print_mr_owner(mon_printf, f, mr); + } } else { mon_printf(f, - TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s= \n", + TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s= ", cur_start, cur_end, mr->priority, memory_region_type((MemoryRegion *)mr), memory_region_name(mr), mr->enabled ? "" : " [disabled]"); + if (owner) { + mtree_print_mr_owner(mon_printf, f, mr); + } } + mon_printf(f, "\n"); =20 QTAILQ_INIT(&submr_print_queue); =20 @@ -2947,7 +2993,7 @@ static void mtree_print_mr(fprintf_function mon_print= f, void *f, =20 QTAILQ_FOREACH(ml, &submr_print_queue, mrqueue) { mtree_print_mr(mon_printf, f, ml->mr, level + 1, cur_start, - alias_print_queue); + alias_print_queue, owner); } =20 QTAILQ_FOREACH_SAFE(ml, &submr_print_queue, mrqueue, next_ml) { @@ -2960,6 +3006,7 @@ struct FlatViewInfo { void *f; int counter; bool dispatch_tree; + bool owner; }; =20 static void mtree_print_flatview(gpointer key, gpointer value, @@ -3000,7 +3047,7 @@ static void mtree_print_flatview(gpointer key, gpoint= er value, mr =3D range->mr; if (range->offset_in_region) { p(f, MTREE_INDENT TARGET_FMT_plx "-" - TARGET_FMT_plx " (prio %d, %s): %s @" TARGET_FMT_plx "\n", + TARGET_FMT_plx " (prio %d, %s): %s @" TARGET_FMT_plx, int128_get64(range->addr.start), int128_get64(range->addr.start) + MR_SIZE(range->addr.size), mr->priority, @@ -3009,13 +3056,17 @@ static void mtree_print_flatview(gpointer key, gpoi= nter value, range->offset_in_region); } else { p(f, MTREE_INDENT TARGET_FMT_plx "-" - TARGET_FMT_plx " (prio %d, %s): %s\n", + TARGET_FMT_plx " (prio %d, %s): %s", int128_get64(range->addr.start), int128_get64(range->addr.start) + MR_SIZE(range->addr.size), mr->priority, range->readonly ? "rom" : memory_region_type(mr), memory_region_name(mr)); } + if (fvi->owner) { + mtree_print_mr_owner(p, f, mr); + } + p(f, "\n"); range++; } =20 @@ -3041,7 +3092,7 @@ static gboolean mtree_info_flatview_free(gpointer key= , gpointer value, } =20 void mtree_info(fprintf_function mon_printf, void *f, bool flatview, - bool dispatch_tree) + bool dispatch_tree, bool owner) { MemoryRegionListHead ml_head; MemoryRegionList *ml, *ml2; @@ -3053,7 +3104,8 @@ void mtree_info(fprintf_function mon_printf, void *f,= bool flatview, .mon_printf =3D mon_printf, .f =3D f, .counter =3D 0, - .dispatch_tree =3D dispatch_tree + .dispatch_tree =3D dispatch_tree, + .owner =3D owner, }; GArray *fv_address_spaces; GHashTable *views =3D g_hash_table_new(g_direct_hash, g_direct_equ= al); @@ -3085,14 +3137,14 @@ void mtree_info(fprintf_function mon_printf, void *= f, bool flatview, =20 QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { mon_printf(f, "address-space: %s\n", as->name); - mtree_print_mr(mon_printf, f, as->root, 1, 0, &ml_head); + mtree_print_mr(mon_printf, f, as->root, 1, 0, &ml_head, owner); mon_printf(f, "\n"); } =20 /* print aliased regions */ QTAILQ_FOREACH(ml, &ml_head, mrqueue) { mon_printf(f, "memory-region: %s\n", memory_region_name(ml->mr)); - mtree_print_mr(mon_printf, f, ml->mr, 1, 0, &ml_head); + mtree_print_mr(mon_printf, f, ml->mr, 1, 0, &ml_head, owner); mon_printf(f, "\n"); } =20 diff --git a/monitor.c b/monitor.c index 0730a27..0988eb4 100644 --- a/monitor.c +++ b/monitor.c @@ -2007,8 +2007,10 @@ static void hmp_info_mtree(Monitor *mon, const QDict= *qdict) { bool flatview =3D qdict_get_try_bool(qdict, "flatview", false); bool dispatch_tree =3D qdict_get_try_bool(qdict, "dispatch_tree", fals= e); + bool owner =3D qdict_get_try_bool(qdict, "owner", false); =20 - mtree_info((fprintf_function)monitor_printf, mon, flatview, dispatch_t= ree); + mtree_info((fprintf_function)monitor_printf, mon, flatview, dispatch_t= ree, + owner); } =20 static void hmp_info_numa(Monitor *mon, const QDict *qdict) --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530218310083119.43395639619393; Thu, 28 Jun 2018 13:38:30 -0700 (PDT) Received: from localhost ([::1]:38454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdgT-0000f2-8B for importer@patchew.org; Thu, 28 Jun 2018 16:38:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAz-0007ec-VL for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAz-00010p-5v for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:57 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:46018) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAy-0000zm-Vl for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:57 -0400 Received: by mail-wr0-x243.google.com with SMTP id u7-v6so6680676wrn.12 for ; Thu, 28 Jun 2018 13:05:56 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=plGlCngryDW1DGkgHiRZZeagMif9c186ENIkI1Is7ws=; b=SkH+qguqfUkb9TAQiLAelUrkjAIFMVNWdB9HVxA+ZMKxDU5LEXG6b2BNerW4b0QGYm ngtGpq/hWiIPgbABk1u1gD4tcTk6bRNauOZQNOxYIk8IihbWG60JNfBCfdyI55JJqcaH 7W7GG6XB35FcbUz4lq5BSMNMUd7Yn2CFvFNrGLDEYGMZuSJYKiXfGdxTC5aoIbI1Gk3n 0G8jI1uszG5HaVWUt1a+MvvXLe3Ggt5eocjMSCQZFeROZqohciQubvPn8PbUjOXVhxiv JsdvRHwS4U/oG/x6k2uqpCzODep2V8mVl55PYGrWMBSdfw/EKiFb2LZmZ7aHPTwjPNN+ yxwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=plGlCngryDW1DGkgHiRZZeagMif9c186ENIkI1Is7ws=; b=VnkKwCz4Y2bsIAIWXeqBkoX+ZKDvras9pFqPn195xupNM5Hl+hjOJ8XhfHKwGsxTKh 6uk8KsJyzzBr3fufB1ZRikmtqrO1PlAdpl+i9uu4kOgVmQPll4NzZVwJVHd7hh/mqkaH jgDWXbCPSNHGPqFBCQzE1DF7pgrl9jX+0Vfbn+L1c1BV10+UzUT3uFzJzvCqiXDYdoUr v9nGwMXd+yelWSJU5f3ZzzfXBD2SPQ9jEsvvnpiLELNdLswMnk79NaEaszDVFDvT+cHM 7W0Zjs0t0VS5egC7eSRhkzmF1YRjbpvzAglQXlojtsw30/+e+8HvFtVann9iFdTVtLbM E46g== X-Gm-Message-State: APt69E17/h79uVNJZLyEdI80VlZyy1xKxZxV20e8NKWVu5k9z/kG2F9e LWwYEziQxPX4BE9hf9COIzD25QrR X-Google-Smtp-Source: AAOMgpc0+eMfnIExH3OKmI/k66FcfWalgKYBHqg78WUeOms/7e5IxM0l+asn0Mi1YTGgguBTFH++Fw== X-Received: by 2002:adf:aadb:: with SMTP id i27-v6mr2700437wrc.149.1530216355727; Thu, 28 Jun 2018 13:05:55 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:53 +0200 Message-Id: <1530216310-52873-44-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 43/60] target-i386: Add NMI interception to SVM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Kiszka Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jan Kiszka Check for SVM interception prior to injecting an NMI. Tested via the Jailhouse hypervisor. Signed-off-by: Jan Kiszka Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/seg_helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/i386/seg_helper.c b/target/i386/seg_helper.c index 600a4d7..00301a0 100644 --- a/target/i386/seg_helper.c +++ b/target/i386/seg_helper.c @@ -1337,6 +1337,7 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interru= pt_request) ret =3D true; } else if ((interrupt_request & CPU_INTERRUPT_NMI) && !(env->hflags2 & HF2_NMI_MASK)) { + cpu_svm_check_intercept_param(env, SVM_EXIT_NMI, 0, 0); cs->interrupt_request &=3D ~CPU_INTERRUPT_NMI; env->hflags2 |=3D HF2_NMI_MASK; do_interrupt_x86_hardirq(env, EXCP02_NMI, 1); --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153021769719970.93617816822689; Thu, 28 Jun 2018 13:28:17 -0700 (PDT) Received: from localhost ([::1]:38397 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdWR-0000rf-Cl for importer@patchew.org; Thu, 28 Jun 2018 16:28:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdB1-0007gB-GG for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdB0-00012H-LT for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:59 -0400 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:33401) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdB0-00011d-D9 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:58 -0400 Received: by mail-wr0-x241.google.com with SMTP id k7-v6so3190460wrq.0 for ; Thu, 28 Jun 2018 13:05:58 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=kE/jupScQ4lsNxXj9NxInJUVYJ/NNVk0XyvvXwkTTiM=; b=qOMv7Cjagg/KET2QpwYMwe5shcEaXTkE9eVxQCgThRbVdvvkEol7NDpU5uUjkaBKPc cZ8YlbQWxWER7gt+ZPKedYYmFgkh/nMbMx3GxKyXKkfqTx1x/LUMGFTVsYNu7TxhBvOX TT1tv0LbMUlYDrTn27h7MMR5lidhf6TQmPZA2JxkPdOMcELiyG5wC0bNHYhzI/ovJ34A c9mvEZVC8aeWZY3WcA5OsWCRtsalNLSUTEEJ7MbdFF+RoXVNKBew8xrVqAmrdfhY6M6v CIDnlvDMj7Ak2j6+VvFgwm4OobBPcIlmYt0x2sxAk+LegT6MR1nrBmTyJQ9wgVYO/EN4 JsnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=kE/jupScQ4lsNxXj9NxInJUVYJ/NNVk0XyvvXwkTTiM=; b=Gk9BQGjpwARypOLvBOB5dSjY4YBltH2vvxWgkqGrnUFhB4ym3/q1kZL13d0DfKgLJ6 et3EDAnDHwmGhec7ZvhDEEJFa+bZwa4BS5FrnghVmNU5AXKxu7tWVyTNZD227xIR5SBX fk6UOzfJNM6grMutBpoQc3LuFeCErwVreB/vuYo3wcdDO5efEIW003LRnvlO9sFW39wY jgba2/A/5du+/nCCKU5l+rv1CxOSF5vVgK1f1U9/rPChJ/HchTxeBokhZsD+OqdUGnoC DIpYsbtci/IZPlBz/4Y6cZjcvnTyIZkJ72TPm+LfOYxxWi57phy8HLT9YXeTaY+wQYwU zJtQ== X-Gm-Message-State: APt69E0tx+mzcC5lRF33xvntCeJqieK+FB72eL5LqoRCBU9+xdtfSqUh z6VitdmA3GLjwLi+/JtnPX6pvogU X-Google-Smtp-Source: AAOMgpc0pDq2oPUiYEHFUem4S8Jycoifa2x67mNjrqPOG3EYvas3XZXWTGW5M3K74KT7L5uXAdtrLg== X-Received: by 2002:a5d:4a92:: with SMTP id o18-v6mr9244240wrq.132.1530216357151; Thu, 28 Jun 2018 13:05:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:54 +0200 Message-Id: <1530216310-52873-45-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 44/60] target-i386: Allow interrupt injection after STGI X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Kiszka Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jan Kiszka We need to terminate the translation block after STGI so that pending interrupts can be injected. This fixes pending NMI injection for Jailhouse which uses "stgi; clgi" to open a brief injection window. Signed-off-by: Jan Kiszka Message-Id: <37939b244dda0e9cccf96ce50f2b15df1e48315d.1522769774.git.jan.ki= szka@web.de> Signed-off-by: Paolo Bonzini --- target/i386/translate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/i386/translate.c b/target/i386/translate.c index c918494..07d185e 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -7444,8 +7444,9 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) break; } gen_update_cc_op(s); - gen_jmp_im(pc_start - s->cs_base); gen_helper_stgi(cpu_env); + gen_jmp_im(s->pc - s->cs_base); + gen_eob(s); break; =20 case 0xdd: /* CLGI */ --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530217861589168.02939494566272; Thu, 28 Jun 2018 13:31:01 -0700 (PDT) Received: from localhost ([::1]:38419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdZE-0003Dl-PH for importer@patchew.org; Thu, 28 Jun 2018 16:31:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38363) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdB2-0007hV-MT for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdB1-00013W-NT for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:00 -0400 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:44574) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdB1-00012l-Gg for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:59 -0400 Received: by mail-wr0-x22d.google.com with SMTP id p12-v6so6676611wrn.11 for ; Thu, 28 Jun 2018 13:05:59 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=D7j+JrT4aWmCaO9cr3g7WjWrpebQrHPdnGEcwaHk42I=; b=HKdmS/0AWnhjlNN4KLBtzMPFCBVONroot2MDELgvA0ZXFK5PiFyztFB7uXXXPBsnTg wTiWNHRhb5e/mRFxlsHqIo2X0rDkLN7Je1RWx9oe8SE4RUcwRSditCR8jpThfGXKeBp1 dtRUfc+LSVUHBnosfUx6+ri/VzG/CfTLiCJddwG0eCzEcKPA/DIXWjOB/4KZ+THOSOyY G9F83Jpn9+dlnXzy9THsiaedcxVt8kZKnWjplzrKYW4TtJ6IwBWljJLsntO5+9uXBEOX BQkMrmjsgq+/mnyl/gGRcPVODFfT+Mk736baJubGxLVg9Ylii3ljERUgVqFBavgRg18f ciEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=D7j+JrT4aWmCaO9cr3g7WjWrpebQrHPdnGEcwaHk42I=; b=hRl16qJD8yDcoxE4SD/tJdGZW3FpmqcsGPrwLPH/cWvppprVu5ll3RONbS1We8M3Zk wAxgpiQsZ3ZRupRDIBLrr4IAv8CQvXkOXlGMCkXZTaJVqWELkuuzkGdPSCQigjY3+ngh tdizAPtWZAvmSWNc87uKLlY//kpR0iu7b0Bhjy3cFxbwvULradfVjnZTkl/vplddyWf4 Br0OS9lgRbDxSKknoMeGrPpog78WgP+sV8CcxJliA/LPLcP5vtwl8R1Ef3LmYkxnmabL c7kR+CVRJflQYufRNRvhhOEY5lK/HatQ59q35BxyXnRE2KQ/n34/mlR4BZPoxEpA2dAu QDUA== X-Gm-Message-State: APt69E2tIAZZYtOh1MoypYRj8f1M508lBlOeRLGrHTB9bMl/O9YtHXa6 izlAw+FVkjM5qh/97VGNhGxSWfEZ X-Google-Smtp-Source: AAOMgpeHNZvT+6t8gjiDa+h/hnH09RIA30BICBHNNhDSDvwlw/e+LdnPVAS9eYnIZNmbBh/NNnh3hg== X-Received: by 2002:adf:adc9:: with SMTP id w67-v6mr2238682wrc.135.1530216358251; Thu, 28 Jun 2018 13:05:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:55 +0200 Message-Id: <1530216310-52873-46-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22d Subject: [Qemu-devel] [PULL 45/60] target-i386: Mark cpu_vmexit noreturn X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Kiszka Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jan Kiszka It calls cpu_loop_exit in system emulation mode (and should never be called in user emulation mode). Signed-off-by: Jan Kiszka Message-Id: <6f4d44ffde55d074cbceb48309c1678600abad2f.1522769774.git.jan.ki= szka@web.de> Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 4 ++-- target/i386/svm_helper.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 89c82be..16c59b7 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1840,8 +1840,8 @@ void helper_lock_init(void); /* svm_helper.c */ void cpu_svm_check_intercept_param(CPUX86State *env1, uint32_t type, uint64_t param, uintptr_t retaddr); -void cpu_vmexit(CPUX86State *nenv, uint32_t exit_code, uint64_t exit_info_= 1, - uintptr_t retaddr); +void QEMU_NORETURN cpu_vmexit(CPUX86State *nenv, uint32_t exit_code, + uint64_t exit_info_1, uintptr_t retaddr); void do_vmexit(CPUX86State *env, uint32_t exit_code, uint64_t exit_info_1); =20 /* seg_helper.c */ diff --git a/target/i386/svm_helper.c b/target/i386/svm_helper.c index 3504923..f245aec 100644 --- a/target/i386/svm_helper.c +++ b/target/i386/svm_helper.c @@ -62,6 +62,7 @@ void helper_invlpga(CPUX86State *env, int aflag) void cpu_vmexit(CPUX86State *nenv, uint32_t exit_code, uint64_t exit_info_= 1, uintptr_t retaddr) { + assert(0); } =20 void helper_svm_check_intercept_param(CPUX86State *env, uint32_t type, --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530219192488999.7446975997809; Thu, 28 Jun 2018 13:53:12 -0700 (PDT) Received: from localhost ([::1]:38545 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYduh-0005PN-R5 for importer@patchew.org; Thu, 28 Jun 2018 16:53:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdB5-0007md-Qg for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdB2-00014U-M2 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:03 -0400 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:51045) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdB2-00013d-CF for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:00 -0400 Received: by mail-wm0-x236.google.com with SMTP id e16-v6so10988311wmd.0 for ; Thu, 28 Jun 2018 13:06:00 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=7LhHkWfGrPACkIDj7jqNYhloK8htfRjQmVoSrLFRO1g=; b=XlM8tFVEDybC+S59X964+gBGgU6qJHlaWgeEx4h9gql5T+Jb4Fei44CKl5v2k01tXw c5Cnu5WuzaPWtCpoafFKVnib6gk+4c/faP4PCq3Ct3FqGIO5DOK+I5sr0QA0mlN5BIK1 Zi0TxO38S1SuT15YPAjusGCsOxdeG99zCSF05aYgcsROzW9B58bde2WySw1r7cPOJ6qE MOkuqEmfjhSP84ZGan5OOWVt2taN/DEx5rmmwAf4RMmF1shcIwQgOqZMc/5RSf9LAJbo 57jffyIWbe9SViV4iz/QW16DptTm2lira9ctQgTzk0j9uVP0+sSTMgmYAoI0RkU7E5je Yh+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=7LhHkWfGrPACkIDj7jqNYhloK8htfRjQmVoSrLFRO1g=; b=jKveRONHCqc7RETJxWaa7gibmklhh/rBwbK8TNjbUboihyyUlFJ/nuiXOGgVsKg8C1 HnRqucSZ2PiKRsiSBhwsrwYppq77mdN7sFN2bdimkVY05GF85uVYxYD6wj9yy/p+Ya+X wNlJ97vwiF2tcqxLhkhcE45ApShAQ5mVw4wLWJwkFohxqB/8EF3yjxp0wKu11Npzj0q0 fYrxhwZVslACLodZTwszeXEbSuLl8BlaDWYtvCilsGk4GiUf7mqJ7y/Vxq5KACwtkbhS 2c95lfiPq93rpXesSPma7PdzWOwNzoeiTIakLPnM4YLstdjVT2m8Qxl5NQkmPpCMrJ3u 6Hhg== X-Gm-Message-State: APt69E2Ckr/Vk0cq8KeGxxJjMeqTk+po133Vu7zvRqut3PipRe2EVNPw X/pZZ4WZucbuF3qGvZvDpO7v2Ohz X-Google-Smtp-Source: AAOMgpcDbYfEwbQQMJYPCDma+8l4aGAp/7H6yu7GkWZ6svgDWlwVgwD5LQAFkReDlNI8DQd0v4TB+g== X-Received: by 2002:a1c:ed07:: with SMTP id l7-v6mr9686812wmh.139.1530216359107; Thu, 28 Jun 2018 13:05:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:56 +0200 Message-Id: <1530216310-52873-47-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::236 Subject: [Qemu-devel] [PULL 46/60] doc: another fix to "info pic" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu Something that commit 254316fa1f ("intc: make HMP 'info irq' and 'info pic' commands available on all targets", 2016-10-04) forgot to touch up. Signed-off-by: Peter Xu Message-Id: <20171229073104.3810-2-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- hmp-commands-info.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 59bdd8f..a482b6e 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -201,7 +201,7 @@ ETEXI STEXI @item info pic @findex info pic -Show i8259 (PIC) state. +Show PIC state. ETEXI =20 { --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530219338768280.1774534545225; Thu, 28 Jun 2018 13:55:38 -0700 (PDT) Received: from localhost ([::1]:38559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdx0-0007Sj-QQ for importer@patchew.org; Thu, 28 Jun 2018 16:55:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdB5-0007mZ-QP for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdB3-00015g-Gj for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:03 -0400 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:55466) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdB3-00014a-AN for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:01 -0400 Received: by mail-wm0-x22e.google.com with SMTP id v16-v6so11056475wmv.5 for ; Thu, 28 Jun 2018 13:06:01 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=lBT7UZ4knHYqw8V7rEZaCIgsJmCMBiKDeZzIrT6JN+I=; b=baNFO1p3fEHN9X4+a8ICSKiXIec/T+ZfnZVQ10OukiswxwVz9Lccl1dg6dQ2yLXGo+ CjArncJaAo6yL4k3uR6O/3pmkzDueHHJqXbSJfgKZMBqkYNFPF1W61HXbcSpOAnn1Btu GIaT3hk1eNLmQBPhFQdInwiEuYZq1p3IFM1rX0fzhD0IXyP8XNoykZ4zJv+6zY5wtwBg VqNVxlVWJxzZtZlp9pYvPDUzWd6WOJpwOPlobo8Hzk2o0JzfJiG7VR20BGjHDuyWN7dy O4P8fe9ft/E3OsJncsObaUPzU2t5mmf+AMBK7N05Qwl5XrnXtBU0p/mTydpYk23PNcNa sJeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=lBT7UZ4knHYqw8V7rEZaCIgsJmCMBiKDeZzIrT6JN+I=; b=WLJ/UX5HXOrAZqL22DRilorkbS9oHCagoXKhjYGmOiHq+G5MhuHJjJ+5YQjFKlngSs h/iROooFS0cMb8H2E2GyW3mW/lJyhDGRBA+vRayRIgoTSayLYNNm2/9Yn9WWWz4LcGET gdP2BRc2IvSxcgVIMgbGKWc7tbO+XM3unNx523L/Ugiss//huZ5BVuOuw7rLGAUVbkAr /FL9nQLeSo26EBdoYOa61Xv6cZBY/vsX/Dr0rV5s3rdBGW6Ag0Xiy3gnqfgP1csaKEpS vO4ZlDxgKP+ddzke+FUGmYUFC4+Q/slBtbZaPH/MaSjZ9senqYypf069uR1JP8HQpsPu 6r2w== X-Gm-Message-State: APt69E0yp+91WloRWMXb8DPaN51Ko63LbSQVp54K3TYzLJUXO9FWmz7e StTgKEq2/7/EJUHsLzFOxgwYX4uN X-Google-Smtp-Source: AAOMgpeKiDVwgc1LCu4Uk6/vZVWFKV/Wf9K5EJSCa2ZHPKiGDfCPABvvVDoBg+QDrKVr2DhkdD8kcA== X-Received: by 2002:a1c:d391:: with SMTP id k139-v6mr8871002wmg.45.1530216359973; Thu, 28 Jun 2018 13:05:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:57 +0200 Message-Id: <1530216310-52873-48-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22e Subject: [Qemu-devel] [PULL 47/60] ioapic: support "info pic" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu People start to use "info pic" for all kinds of irqchip dumps. Let x86 ioapic join the family. It dumps the same thing as "info ioapic". Signed-off-by: Peter Xu Message-Id: <20171229073104.3810-3-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- hw/intc/ioapic_common.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hw/intc/ioapic_common.c b/hw/intc/ioapic_common.c index 3b3d0a7..c62ba27 100644 --- a/hw/intc/ioapic_common.c +++ b/hw/intc/ioapic_common.c @@ -24,6 +24,7 @@ #include "monitor/monitor.h" #include "hw/i386/ioapic.h" #include "hw/i386/ioapic_internal.h" +#include "hw/intc/intc.h" #include "hw/sysbus.h" =20 /* ioapic_no count start from 0 to MAX_IOAPICS, @@ -142,6 +143,15 @@ static void ioapic_common_realize(DeviceState *dev, Er= ror **errp) ioapic_no++; } =20 +static void ioapic_print_info(InterruptStatsProvider *obj, + Monitor *mon) +{ + IOAPICCommonState *s =3D IOAPIC_COMMON(obj); + + ioapic_dispatch_pre_save(s); + ioapic_print_redtbl(mon, s); +} + static const VMStateDescription vmstate_ioapic_common =3D { .name =3D "ioapic", .version_id =3D 3, @@ -161,9 +171,11 @@ static const VMStateDescription vmstate_ioapic_common = =3D { static void ioapic_common_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); + InterruptStatsProviderClass *ic =3D INTERRUPT_STATS_PROVIDER_CLASS(kla= ss); =20 dc->realize =3D ioapic_common_realize; dc->vmsd =3D &vmstate_ioapic_common; + ic->print_info =3D ioapic_print_info; } =20 static const TypeInfo ioapic_common_type =3D { @@ -173,6 +185,10 @@ static const TypeInfo ioapic_common_type =3D { .class_size =3D sizeof(IOAPICCommonClass), .class_init =3D ioapic_common_class_init, .abstract =3D true, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_INTERRUPT_STATS_PROVIDER }, + { } + }, }; =20 static void ioapic_common_register_types(void) --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530218598489611.9110090339802; Thu, 28 Jun 2018 13:43:18 -0700 (PDT) Received: from localhost ([::1]:38487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdl7-0005R8-Nw for importer@patchew.org; Thu, 28 Jun 2018 16:43:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdB5-0007ma-QR for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdB4-00016i-CL for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:03 -0400 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:51035) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdB4-00015m-61 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:02 -0400 Received: by mail-wm0-x22b.google.com with SMTP id e16-v6so10988374wmd.0 for ; Thu, 28 Jun 2018 13:06:02 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.06.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:06:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=bGFAIAol5bgILjTV5x+gDhCijsyoSNZY2Mi0l9k1tLs=; b=W/blbWC++FOxi+FsU2RXVIAwP+tVM+a9w45dGVUM3h6yiEAvbIxUxYZgdJeK/na4CS lLiFr1/1UTQU3J4XZT8lTrYfUBdCDO8y2WSjvjq5QsHbv30Y0cvtEP5E48ktbK94oZ0u N4z0ptevaz0EFMnXVPyPom01Xg40G0qmLcfT/nOrCOeaq8AdTknM/mlTchglnSCkWTW3 Z4eUp2e0N/oZ3WzhXmP0jokHZKNF4Repwc+jpll8TRzUYI4XDtZqMycWlK6x1VR4b2YN 1wu/zG2fie851bJzRj1RVt5N4ZIf0LE39UR7RmV7VhqzMw3DhWzlvH+tMrVE1Y0GhJly s1Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=bGFAIAol5bgILjTV5x+gDhCijsyoSNZY2Mi0l9k1tLs=; b=NVreXoGmmL5s5wFPulggdOudO7zyWRVMMyLiwCVYocrgL/2/ZraH309GgpE8z8lsXq R2HfjEZlE5TtLE9p6m24+TdVKzvW9e31zdPTR2tF0hHRHpmp9V3BeSMiHKmWoOOOWp4x sF4iG5bsdk9KPEqK9JmFtiNQpsbZ48LGYQ76aeyhcE6mEvsg6DmsHyzxi3zw414EnZmf MpuSoiwHQP3R64CP7kvPvZ7Um0UAAKm++eSZOy9KyZYscqoXvESvYNcK+XR5kwan0RfF awHwtbb6Mk3HNKkXSfUCM0F/fgz5GNRHEBQ2kURKqmNxLrIHL0qJhnjYndsNBfLhLrIJ uj0w== X-Gm-Message-State: APt69E3avNSkUKKpawwjkPBs/4eTFEvHLu7uYEPJzeYfzwgpXVUvgt+h xHpCzsnZcsVdDdRmUGjEkLjD8hlg X-Google-Smtp-Source: AAOMgpcHshN362+dkuxjIuakRykUpAv6oMkf27QO+iiLtdMjwTt3PaDHokCdHpkXDwbbitj0ew7+jQ== X-Received: by 2002:a1c:328a:: with SMTP id y132-v6mr9115760wmy.70.1530216360952; Thu, 28 Jun 2018 13:06:00 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:58 +0200 Message-Id: <1530216310-52873-49-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22b Subject: [Qemu-devel] [PULL 48/60] ioapic: some proper indents when dump info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu So that now it looks better when with other irqchips. Signed-off-by: Peter Xu Message-Id: <20171229073104.3810-4-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- hw/intc/ioapic_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/intc/ioapic_common.c b/hw/intc/ioapic_common.c index c62ba27..a02c135 100644 --- a/hw/intc/ioapic_common.c +++ b/hw/intc/ioapic_common.c @@ -59,7 +59,7 @@ void ioapic_print_redtbl(Monitor *mon, IOAPICCommonState = *s) uint32_t remote_irr =3D 0; int i; =20 - monitor_printf(mon, "ioapic ver=3D0x%x id=3D0x%02x sel=3D0x%02x", + monitor_printf(mon, "ioapic0: ver=3D0x%x id=3D0x%02x sel=3D0x%02x", s->version, s->id, s->ioregsel); if (s->ioregsel) { monitor_printf(mon, " (redir[%u])\n", @@ -71,7 +71,7 @@ void ioapic_print_redtbl(Monitor *mon, IOAPICCommonState = *s) uint64_t entry =3D s->ioredtbl[i]; uint32_t delm =3D (uint32_t)((entry & IOAPIC_LVT_DELIV_MODE) >> IOAPIC_LVT_DELIV_MODE_SHIFT); - monitor_printf(mon, "pin %-2u 0x%016"PRIx64" dest=3D%"PRIx64 + monitor_printf(mon, " pin %-2u 0x%016"PRIx64" dest=3D%"PRIx64 " vec=3D%-3"PRIu64" %s %-5s %-6s %-6s %s\n", i, entry, (entry >> IOAPIC_LVT_DEST_SHIFT) & @@ -86,8 +86,8 @@ void ioapic_print_redtbl(Monitor *mon, IOAPICCommonState = *s) remote_irr |=3D entry & IOAPIC_LVT_TRIGGER_MODE ? (entry & IOAPIC_LVT_REMOTE_IRR ? (1 << i) : 0) : 0; } - ioapic_irr_dump(mon, "IRR", s->irr); - ioapic_irr_dump(mon, "Remote IRR", remote_irr); + ioapic_irr_dump(mon, " IRR", s->irr); + ioapic_irr_dump(mon, " Remote IRR", remote_irr); } =20 void ioapic_reset_common(DeviceState *dev) --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530218071740279.3489935216386; Thu, 28 Jun 2018 13:34:31 -0700 (PDT) Received: from localhost ([::1]:38431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdcN-0005X0-Fr for importer@patchew.org; Thu, 28 Jun 2018 16:34:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38411) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdB6-0007nb-Jn for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdB5-00018c-Gc for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:04 -0400 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:39184) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdB5-00017E-9I for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:03 -0400 Received: by mail-wr0-x241.google.com with SMTP id b8-v6so6678959wro.6 for ; Thu, 28 Jun 2018 13:06:03 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.06.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=NaPr4d6wMv8dmWjXdDQYgDuyCuX3DHy+VoxoQ0J/GnY=; b=ih7Wiyl5uNIN3nz4iXcE9emSfQpkT1GdIo+UgesZvEmZaPPlBBlOEeQcaGIpMWqgMN 3pdKs6ku+Mz39yJ1LpG/6AgSB9Vfc1WVBH105ZXyDHNrdV5kvkiF56SOXT0P/dwNS0bJ F03Fc9am9teUi68vJ5+Ac0BjPW/vLyQvOoWfFgxZ3TlnnNNQxGhfSGY40bOThHR7yJII WCabjX3q+TFww+mSSGhgLLyrdvMWRYRs1sFybPKs7XrViFIiKDERZoSxMrG99bChdkwC 2W4g2uejbwOTXx3MbKAIxE6jLKFcs5vig3U/vAlQzJblWCu/WOwlM7zJ5ndU8e8K66oA zJFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=NaPr4d6wMv8dmWjXdDQYgDuyCuX3DHy+VoxoQ0J/GnY=; b=EiAoKNhUpKsu0nok2NCtPCB4/p7AL1RIQh8GNU4SAvwmEIibGwL/78O3tghsQo4bE0 IY/ek1quDb91abMxyxQaPaaVmi7NXKrLNCUG0NtD5vlRr6/oVGTOOZPm8zKmWEA1K7vF IlEeELJWt8eeVVvjtNadO9EO5DvbwpRHRaijlllIYrHTyu9BQEMEgP3QWLL2/zfkjBuL ozC4tq+5f2P6fAEcLzraRm6oEMysuBsUM4UoGWjKhIywtsrtiOVC3r4782YXjnHwbRjL /mltrmPlXTFXy0PC5DrCs0pA8LXt3D8gGQOjW7831LO5qU2PIg04fzO2TCOVc59NOs6Z QLEA== X-Gm-Message-State: APt69E2XQ4RyFPjNsPJsApmFXCL0jx2DwBIbN3R5kiZw1KicZO/GsvhX k9irpN0D5FCNzbkfKpBqIHyXNNNU X-Google-Smtp-Source: AAOMgpdBG0D95BHBY6BKlxfga0t1EtI6UIezhQLGTfiePHSTiu3hgH/slq5tTBVcN7ke3MQT4PU/+Q== X-Received: by 2002:adf:fb43:: with SMTP id c3-v6mr10216085wrs.32.1530216362001; Thu, 28 Jun 2018 13:06:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:59 +0200 Message-Id: <1530216310-52873-50-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 49/60] ioapic: support "info irq" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu This include both userspace and in-kernel ioapic. Note that the numbers can be inaccurate for kvm-ioapic. One reason is the same with kvm-i8259, that when irqfd is used, irqs can be delivered all inside kernel without our notice. Meanwhile, kvm-ioapic is specially treated when irq numbers Message-Id: <20171229073104.3810-5-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/kvm/ioapic.c | 2 ++ hw/intc/ioapic.c | 1 + hw/intc/ioapic_common.c | 23 +++++++++++++++++++++++ include/hw/i386/ioapic_internal.h | 3 +++ 4 files changed, 29 insertions(+) diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c index 646f624..5274dc7 100644 --- a/hw/i386/kvm/ioapic.c +++ b/hw/i386/kvm/ioapic.c @@ -132,8 +132,10 @@ static void kvm_ioapic_reset(DeviceState *dev) static void kvm_ioapic_set_irq(void *opaque, int irq, int level) { KVMIOAPICState *s =3D opaque; + IOAPICCommonState *common =3D IOAPIC_COMMON(s); int delivered; =20 + ioapic_stat_update_irq(common, irq, level); delivered =3D kvm_set_irq(kvm_state, s->kvm_gsi_base + irq, level); apic_report_irq_delivered(delivered); } diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index c45f073..222f3f7 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -148,6 +148,7 @@ static void ioapic_set_irq(void *opaque, int vector, in= t level) * the cleanest way of doing it but it should work. */ =20 trace_ioapic_set_irq(vector, level); + ioapic_stat_update_irq(s, vector, level); if (vector =3D=3D 0) { vector =3D 2; } diff --git a/hw/intc/ioapic_common.c b/hw/intc/ioapic_common.c index a02c135..692dc37 100644 --- a/hw/intc/ioapic_common.c +++ b/hw/intc/ioapic_common.c @@ -35,6 +35,28 @@ */ int ioapic_no; =20 +void ioapic_stat_update_irq(IOAPICCommonState *s, int irq, int level) +{ + if (level !=3D s->irq_level[irq]) { + s->irq_level[irq] =3D level; + if (level =3D=3D 1) { + s->irq_count[irq]++; + } + } +} + +static bool ioapic_get_statistics(InterruptStatsProvider *obj, + uint64_t **irq_counts, + unsigned int *nb_irqs) +{ + IOAPICCommonState *s =3D IOAPIC_COMMON(obj); + + *irq_counts =3D s->irq_count; + *nb_irqs =3D IOAPIC_NUM_PINS; + + return true; +} + static void ioapic_irr_dump(Monitor *mon, const char *name, uint32_t bitma= p) { int i; @@ -176,6 +198,7 @@ static void ioapic_common_class_init(ObjectClass *klass= , void *data) dc->realize =3D ioapic_common_realize; dc->vmsd =3D &vmstate_ioapic_common; ic->print_info =3D ioapic_print_info; + ic->get_statistics =3D ioapic_get_statistics; } =20 static const TypeInfo ioapic_common_type =3D { diff --git a/include/hw/i386/ioapic_internal.h b/include/hw/i386/ioapic_int= ernal.h index a11d86d..9848f39 100644 --- a/include/hw/i386/ioapic_internal.h +++ b/include/hw/i386/ioapic_internal.h @@ -109,10 +109,13 @@ struct IOAPICCommonState { uint64_t ioredtbl[IOAPIC_NUM_PINS]; Notifier machine_done; uint8_t version; + uint64_t irq_count[IOAPIC_NUM_PINS]; + int irq_level[IOAPIC_NUM_PINS]; }; =20 void ioapic_reset_common(DeviceState *dev); =20 void ioapic_print_redtbl(Monitor *mon, IOAPICCommonState *s); +void ioapic_stat_update_irq(IOAPICCommonState *s, int irq, int level); =20 #endif /* QEMU_IOAPIC_INTERNAL_H */ --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530218224936418.03222667097964; Thu, 28 Jun 2018 13:37:04 -0700 (PDT) Received: from localhost ([::1]:38448 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdf5-0007xn-Ut for importer@patchew.org; Thu, 28 Jun 2018 16:37:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdB7-0007ow-HJ for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdB6-0001Aw-Ei for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:05 -0400 Received: from mail-wr0-x236.google.com ([2a00:1450:400c:c0c::236]:37260) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdB6-00018x-6n for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:04 -0400 Received: by mail-wr0-x236.google.com with SMTP id k6-v6so6688692wrp.4 for ; Thu, 28 Jun 2018 13:06:04 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.06.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=HqdkZvuZFptqxiBqqh4bmffOtnL5I5a+6d1WVhwewCU=; b=iJwIR8AZxdYRe9nXCFbabzZYfJc8wIV+S5yVwJ6v85tmWceV5BX2qbhHIk6EbjI7su slKHEryG0Zteb2p0TDEotVyqcSNnP6n1wBVnp7ynQL7WxDT4AsVUjIfgaMd+E83U2G0I pgaaLOro1i44814pL0xAcwVmhG+1on+A7Gp770BDgAuk7ck84x3CMW5dqaOtf0DKzC6i rxxrGN20joOsXIJBmxJUkKq4KHvvVpv98lEyX39TZ943dJHa9SBqZ2F8Hk4qVrQwhpd2 EVOznnk2OJa2K2zeui89Db03ArF2u1PzuiKGc7lo++Jfm1wohWq/DZYNP7P/jv07BnZo khPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=HqdkZvuZFptqxiBqqh4bmffOtnL5I5a+6d1WVhwewCU=; b=As4+R/jLYKoSmYbXNK9z9LiZ0BzuNsFnhhHD+T0hyfRgvboIvArsqgpUX2u024+wu+ z38HzCjen4e/HCxmL9KYsKIyDlJDCj5EIXgbS2beMxQ5ZKtoorcJrtsd9qkVbLpTHsPP jumIlET7R9+GditPYThxBDK6ubxjNcc3rAukdqP4lpbpQtMJZp5+rALnktw6wpELFgpL O/zk91uogbselqnYRKUBObvpFf//YhbkHMiU7If4e5DTSR+2ashaopEkZptq2zD/+ohS axROflmMk2TOXkSvAWeMyJSUQQW9Rw6mU95Okz+PrVAvFdo+8s52/EvZp45AiF6rntij Cgpw== X-Gm-Message-State: APt69E1DvH++WhdHG47Ge5Y88sjj2AfwSc4TmSddNNn+mTRHJkQiv/Vc PWREHkc9lccBOvAXLqjaRKBR+vRh X-Google-Smtp-Source: AAOMgpcX5W7gL/tMY865OSqKvqXmyR78x4QIC2wt++rG7g5G2h2vfyinCm+n9Nmg/+NyfcsxnzUCSA== X-Received: by 2002:adf:c377:: with SMTP id e52-v6mr9514752wrg.257.1530216362944; Thu, 28 Jun 2018 13:06:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:05:00 +0200 Message-Id: <1530216310-52873-51-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::236 Subject: [Qemu-devel] [PULL 50/60] hmp: obsolete "info ioapic" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu Let's start to use "info pic" just like other platforms. For now we keep the command for a while so that old users can know what is the new command to use. Signed-off-by: Peter Xu Message-Id: <20171229073104.3810-6-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/kvm/ioapic.c | 9 --------- hw/intc/ioapic.c | 11 ----------- include/hw/i386/pc.h | 3 --- target/i386/monitor.c | 8 ++------ 4 files changed, 2 insertions(+), 29 deletions(-) diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c index 5274dc7..5b40d75 100644 --- a/hw/i386/kvm/ioapic.c +++ b/hw/i386/kvm/ioapic.c @@ -112,15 +112,6 @@ static void kvm_ioapic_put(IOAPICCommonState *s) } } =20 -void kvm_ioapic_dump_state(Monitor *mon, const QDict *qdict) -{ - IOAPICCommonState *s =3D IOAPIC_COMMON(object_resolve_path("ioapic", N= ULL)); - - assert(s); - kvm_ioapic_get(s); - ioapic_print_redtbl(mon, s); -} - static void kvm_ioapic_reset(DeviceState *dev) { IOAPICCommonState *s =3D IOAPIC_COMMON(dev); diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index 222f3f7..b393780 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -234,17 +234,6 @@ void ioapic_eoi_broadcast(int vector) } } =20 -void ioapic_dump_state(Monitor *mon, const QDict *qdict) -{ - int i; - - for (i =3D 0; i < MAX_IOAPICS; i++) { - if (ioapics[i] !=3D 0) { - ioapic_print_redtbl(mon, ioapics[i]); - } - } -} - static uint64_t ioapic_mem_read(void *opaque, hwaddr addr, unsigned int size) { diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 316230e..4d99d69 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -154,9 +154,6 @@ int pic_get_output(DeviceState *d); =20 /* ioapic.c */ =20 -void kvm_ioapic_dump_state(Monitor *mon, const QDict *qdict); -void ioapic_dump_state(Monitor *mon, const QDict *qdict); - /* Global System Interrupts */ =20 #define GSI_NUM_PINS IOAPIC_NUM_PINS diff --git a/target/i386/monitor.c b/target/i386/monitor.c index a890b3c..6bbb3a9 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -658,12 +658,8 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qd= ict) =20 void hmp_info_io_apic(Monitor *mon, const QDict *qdict) { - if (kvm_irqchip_in_kernel() && - !kvm_irqchip_is_split()) { - kvm_ioapic_dump_state(mon, qdict); - } else { - ioapic_dump_state(mon, qdict); - } + monitor_printf(mon, "This command is obsolete and will be " + "removed soon. Please use 'info pic' instead.\n"); } =20 SevInfo *qmp_query_sev(Error **errp) --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530218398702105.77042981127374; Thu, 28 Jun 2018 13:39:58 -0700 (PDT) Received: from localhost ([::1]:38461 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdhu-0001s3-01 for importer@patchew.org; Thu, 28 Jun 2018 16:39:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdB8-0007qW-SC for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdB7-0001Da-Gn for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:06 -0400 Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]:33824) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdB7-0001BF-5B for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:05 -0400 Received: by mail-wr0-x231.google.com with SMTP id a12-v6so6696549wro.1 for ; Thu, 28 Jun 2018 13:06:05 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.06.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=GIAKt95pMF87VnIjy3k+f8byIK6fvVRPB5Njv5iPqQ8=; b=shLze0t68p5iQ+xQipNQqOgt6aJFMUlkyMwF/y7y2vClA5GW4xh8q1Zhw/7YHBgYXa viKSpdZfu0fz8JXOXVlH1zUhdPaabfKIsurcyw9BGB7oDH2Pe3QSwyM2nMFuXJ4o/Yf+ ym1/YX0YqvoRf1rP+hgSKP7u4/jBrFFYOHByjRLpOcviQ9Agknmn3M2r/QmQAYHBWqmh YKur+1aVJabSfQ284LfMhb3Ku72QQXcH8Cl1u2shrsHdwiSUstzQGKAhfAyRUfq6M6Mg NKnInzDdtN0kiUU5S7UX1E6WEXb46X/N7tsL6wn7BR7tILOGAHiu0zZOMEY2+/Syd0ig LSKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=GIAKt95pMF87VnIjy3k+f8byIK6fvVRPB5Njv5iPqQ8=; b=UCrAZsM9vD/b5a2O2ACXa1UqCrWR5HHeCL4KKt+aDWVSimBlT8AvAofWaKRUBrnubo GdraOMjVt5nh9nGZ6Wwuj6g+9O9G8khAD7yGMAK9GTijSu1QlQATNPtebm6uoJ9oJ87N N7dY8rybFXpVGIjuxCtuFL3zpU2jJOajEaHzVXYJ68dBE11o2gfIOYPU2RG5507Rtntc IEvMJPpBBXCLbcoy89NesgsRN6LYyVXPOrAJ5It12M6nIlplP4PNhIlg+6BhwPdzrgOE /VNJhE/Kwsvz4/w0buXthM3aLy+UG03A+mUoFOPWtCsd+LRePwVls9zC1wffYnwlcmLh lQig== X-Gm-Message-State: APt69E0HJpJium9Kx5pfXeYYP/n4gPhbfryHXRGdSqY/A6Y93e5s7U4F /dO1ajD2nOkt//z0a4S/oVkCRSw0 X-Google-Smtp-Source: AAOMgpcH1iyIsRRqbNdBfybO2XTUS7bq3Bb5Fufquzra0jCdL0hdJgzNpPOS1oLKe/qi6w0gNi3DVg== X-Received: by 2002:a5d:428a:: with SMTP id k10-v6mr6086952wrq.225.1530216363890; Thu, 28 Jun 2018 13:06:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:05:01 +0200 Message-Id: <1530216310-52873-52-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::231 Subject: [Qemu-devel] [PULL 51/60] kvm: support -overcommit cpu-pm=on|off X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Michael S. Tsirkin" With this flag, kvm allows guest to control host CPU power state. This increases latency for other processes using same host CPU in an unpredictable way, but if decreases idle entry/exit times for the running VCPU, so to use it QEMU needs a hint about whether host CPU is overcommitted, hence the flag name. Follow-up patches will expose this capability to guest (using mwait leaf). Based on a patch by Wanpeng Li . Signed-off-by: Michael S. Tsirkin Message-Id: <20180622192148.178309-2-mst@redhat.com> Signed-off-by: Paolo Bonzini --- include/sysemu/sysemu.h | 1 + qemu-options.hx | 24 ++++++++++++++++++++++++ target/i386/kvm.c | 23 +++++++++++++++++++++++ vl.c | 32 +++++++++++++++++++++++++++++++- 4 files changed, 79 insertions(+), 1 deletion(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index e893f72..b921c6f 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -128,6 +128,7 @@ extern bool boot_strict; extern uint8_t *boot_splash_filedata; extern size_t boot_splash_filedata_size; extern bool enable_mlock; +extern bool enable_cpu_pm; extern uint8_t qemu_extra_params_fw[2]; extern QEMUClockType rtc_clock; extern const char *mem_path; diff --git a/qemu-options.hx b/qemu-options.hx index 3e45483..81b1e99 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3325,6 +3325,30 @@ mlocking qemu and guest memory can be enabled via @o= ption{mlock=3Don} (enabled by default). ETEXI =20 +DEF("overcommit", HAS_ARG, QEMU_OPTION_overcommit, + "--overcommit [mem-lock=3Don|off][cpu-pm=3Don|off]\n" + " run qemu with overcommit hints\n" + " mem-lock=3Don|off controls memory lock support (defau= lt: off)\n" + " cpu-pm=3Don|off controls cpu power management (defaul= t: off)\n", + QEMU_ARCH_ALL) +STEXI +@item -overcommit mem-lock=3Don|off +@item -overcommit cpu-pm=3Don|off +@findex -overcommit +Run qemu with hints about host resource overcommit. The default is +to assume that host overcommits all resources. + +Locking qemu and guest memory can be enabled via @option{mem-lock=3Don} (d= isabled +by default). This works when host memory is not overcommitted and reduces= the +worst-case latency for guest. This is equivalent to @option{realtime}. + +Guest ability to manage power state of host cpus (increasing latency for o= ther +processes on the same host cpu, but decreasing latency for guest) can be +enabled via @option{cpu-pm=3Don} (disabled by default). This works best w= hen +host CPU is not overcommitted. When used, host estimates of CPU cycle and = power +utilization will be incorrect, not taking into account guest idle time. +ETEXI + DEF("gdb", HAS_ARG, QEMU_OPTION_gdb, \ "-gdb dev wait for gdb connection on 'dev'\n", QEMU_ARCH_ALL) STEXI diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 2d174f3..dc991f6 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1387,6 +1387,29 @@ int kvm_arch_init(MachineState *ms, KVMState *s) smram_machine_done.notify =3D register_smram_listener; qemu_add_machine_init_done_notifier(&smram_machine_done); } + + if (enable_cpu_pm) { + int disable_exits =3D kvm_check_extension(s, KVM_CAP_X86_DISABLE_E= XITS); + int ret; + +/* Work around for kernel header with a typo. TODO: fix header and drop. */ +#if defined(KVM_X86_DISABLE_EXITS_HTL) && !defined(KVM_X86_DISABLE_EXITS_H= LT) +#define KVM_X86_DISABLE_EXITS_HLT KVM_X86_DISABLE_EXITS_HTL +#endif + if (disable_exits) { + disable_exits &=3D (KVM_X86_DISABLE_EXITS_MWAIT | + KVM_X86_DISABLE_EXITS_HLT | + KVM_X86_DISABLE_EXITS_PAUSE); + } + + ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_DISABLE_EXITS, 0, + disable_exits); + if (ret < 0) { + error_report("kvm: guest stopping CPU not supported: %s", + strerror(-ret)); + } + } + return 0; } =20 diff --git a/vl.c b/vl.c index 7c9f19a..ef6cfce 100644 --- a/vl.c +++ b/vl.c @@ -142,6 +142,7 @@ ram_addr_t ram_size; const char *mem_path =3D NULL; int mem_prealloc =3D 0; /* force preallocation of physical target memory */ bool enable_mlock =3D false; +bool enable_cpu_pm =3D false; int nb_nics; NICInfo nd_table[MAX_NICS]; int autostart; @@ -390,6 +391,22 @@ static QemuOptsList qemu_realtime_opts =3D { }, }; =20 +static QemuOptsList qemu_overcommit_opts =3D { + .name =3D "overcommit", + .head =3D QTAILQ_HEAD_INITIALIZER(qemu_overcommit_opts.head), + .desc =3D { + { + .name =3D "mem-lock", + .type =3D QEMU_OPT_BOOL, + }, + { + .name =3D "cpu-pm", + .type =3D QEMU_OPT_BOOL, + }, + { /* end of list */ } + }, +}; + static QemuOptsList qemu_msg_opts =3D { .name =3D "msg", .head =3D QTAILQ_HEAD_INITIALIZER(qemu_msg_opts.head), @@ -3906,7 +3923,20 @@ int main(int argc, char **argv, char **envp) if (!opts) { exit(1); } - enable_mlock =3D qemu_opt_get_bool(opts, "mlock", true); + /* Don't override the -overcommit option if set */ + enable_mlock =3D enable_mlock || + qemu_opt_get_bool(opts, "mlock", true); + break; + case QEMU_OPTION_overcommit: + opts =3D qemu_opts_parse_noisily(qemu_find_opts("overcommi= t"), + optarg, false); + if (!opts) { + exit(1); + } + /* Don't override the -realtime option if set */ + enable_mlock =3D enable_mlock || + qemu_opt_get_bool(opts, "mem-lock", false); + enable_cpu_pm =3D qemu_opt_get_bool(opts, "cpu-pm", false); break; case QEMU_OPTION_msg: opts =3D qemu_opts_parse_noisily(qemu_find_opts("msg"), op= targ, --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530218766814630.0420500374556; Thu, 28 Jun 2018 13:46:06 -0700 (PDT) Received: from localhost ([::1]:38507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdnm-0008Hc-Lc for importer@patchew.org; Thu, 28 Jun 2018 16:46:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38453) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdB9-0007r2-Cw for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdB8-0001Hd-Ar for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:07 -0400 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:43333) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdB8-0001Di-3Z for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:06 -0400 Received: by mail-wr0-x22b.google.com with SMTP id c5-v6so6682437wrs.10 for ; Thu, 28 Jun 2018 13:06:06 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.06.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=11b/2Qh4va607wMFix7Rh5tVqH0iqJ2Q2iZsA8zdnww=; b=EPMoYAAwdj7eQrBIpZYE7Ex3PUuZiIYcdxNSLg32Q6bkZPCLOFV+pjvbY4AHcANxdx 2UDDfunLtUL0cQEeHre1vnA2+VMO706yHNqPmaghsmdQfOOLdyqEGPHx/2IUUmUWH8e3 7ECm9M2pWftJLEykascz+7PCR8rS9MIcDgTKiW5uEJJjR5SgbEFu7FeAMKYVqOhQKbYl F642H2w2esUq8xcO1XFJcL6LA3ZsO+3L/MEu5ilrZj/mrXh50kMdEZKypcs7VGqVgrXO vBWgdtXAS2NuTCbq1Ij5tGao6GcBI22eU5Wh5pjtbpxq1xQO5QH0hzKOGKOfMlAoRpvV 8nsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=11b/2Qh4va607wMFix7Rh5tVqH0iqJ2Q2iZsA8zdnww=; b=lu4zBnF0+kpE/ac+Mv3r838rXvwO89Hm+ezUBek3EZdGGg69Rg/mVlLKdOdttMtxOY BzZ90X6Uu5Z+cHjbzpC7/p7Ef/bmko6rYhNpvKWjLbsn4x/nntvdsPl0nIhyBUpPpi/6 2K3uStQEgSxND29yRqQFtCg91y2TtGnVkAEeMf/lXapE0xmxb+9m4ipVfSMOnDqCukCy 7J9VA9yGxoJahq4ZmcWiysX7sAzo7n4hsLcaNQgVUiBWZskLOVd4HS2GLR4ELSyTkMm0 nfnhmUqC9e2XqMVaa1E3Tcp/5o5Bv8rOglcnR/etmKowftc5Xt4eJJXOZ0BVu+tABG4h U9cg== X-Gm-Message-State: APt69E10zTmbyi2ZVzXK8za+YkE6pIB+EqxoRNR1PFB5iZO49z8QA7dw ykDFVSBDccrWr5ke4b6B9heBPOsW X-Google-Smtp-Source: AAOMgpcmcGANfn4ZAziIx/EzdTckn0uAFE1JMmbcA5TbOcRSEvxQFtL+0d23lrNlQgQCS2lHi4QY6g== X-Received: by 2002:adf:c301:: with SMTP id n1-v6mr10279909wrf.270.1530216364825; Thu, 28 Jun 2018 13:06:04 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:05:02 +0200 Message-Id: <1530216310-52873-53-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22b Subject: [Qemu-devel] [PULL 52/60] i386/cpu: make -cpu host support monitor/mwait X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Michael S. Tsirkin" When guest CPU PM is enabled, and with -cpu host, expose the host CPU MWAIT leaf in the CPUID so guest can make good PM decisions. Note: the result is 100% CPU utilization reported by host as host no longer knows that the CPU is halted. Signed-off-by: Michael S. Tsirkin Reviewed-by: Eduardo Habkost Message-Id: <20180622192148.178309-3-mst@redhat.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 19 ++++++++++++++----- target/i386/cpu.h | 9 +++++++++ target/i386/kvm.c | 9 +++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e6c2f8a..b54f36a 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3959,11 +3959,11 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, } break; case 5: - /* mwait info: needed for Core compatibility */ - *eax =3D 0; /* Smallest monitor-line size in bytes */ - *ebx =3D 0; /* Largest monitor-line size in bytes */ - *ecx =3D CPUID_MWAIT_EMX | CPUID_MWAIT_IBE; - *edx =3D 0; + /* MONITOR/MWAIT Leaf */ + *eax =3D cpu->mwait.eax; /* Smallest monitor-line size in bytes */ + *ebx =3D cpu->mwait.ebx; /* Largest monitor-line size in bytes */ + *ecx =3D cpu->mwait.ecx; /* flags */ + *edx =3D cpu->mwait.edx; /* mwait substates */ break; case 6: /* Thermal and Power Leaf */ @@ -4811,6 +4811,15 @@ static void x86_cpu_realizefn(DeviceState *dev, Erro= r **errp) goto out; } =20 + if (xcc->host_cpuid_required && enable_cpu_pm) { + host_cpuid(5, 0, &cpu->mwait.eax, &cpu->mwait.ebx, + &cpu->mwait.ecx, &cpu->mwait.edx); + env->features[FEAT_1_ECX] |=3D CPUID_EXT_MONITOR; + } + /* mwait extended info: needed for Core compatibility */ + /* We always wake on interrupt even if host does not have the capabili= ty */ + cpu->mwait.ecx |=3D CPUID_MWAIT_EMX | CPUID_MWAIT_IBE; + if (cpu->apic_id =3D=3D UNASSIGNED_APIC_ID) { error_setg(errp, "apic-id property was not initialized properly"); return; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 16c59b7..8eaefee 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1382,6 +1382,15 @@ struct X86CPU { /* if true the CPUID code directly forward host cache leaves to the gu= est */ bool cache_info_passthrough; =20 + /* if true the CPUID code directly forwards + * host monitor/mwait leaves to the guest */ + struct { + uint32_t eax; + uint32_t ebx; + uint32_t ecx; + uint32_t edx; + } mwait; + /* Features that were filtered out because of missing host capabilitie= s */ uint32_t filtered_features[FEATURE_WORDS]; =20 diff --git a/target/i386/kvm.c b/target/i386/kvm.c index dc991f6..c5f72d6 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -366,6 +366,15 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uin= t32_t function, if (!kvm_irqchip_in_kernel()) { ret &=3D ~CPUID_EXT_X2APIC; } + + if (enable_cpu_pm) { + int disable_exits =3D kvm_check_extension(s, + KVM_CAP_X86_DISABLE_EX= ITS); + + if (disable_exits & KVM_X86_DISABLE_EXITS_MWAIT) { + ret |=3D CPUID_EXT_MONITOR; + } + } } else if (function =3D=3D 6 && reg =3D=3D R_EAX) { ret |=3D CPUID_6_EAX_ARAT; /* safe to allow because of emulated AP= IC */ } else if (function =3D=3D 7 && index =3D=3D 0 && reg =3D=3D R_EBX) { --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15302189633690.026711295257200618; Thu, 28 Jun 2018 13:49:23 -0700 (PDT) Received: from localhost ([::1]:38520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdr0-0002Eb-H4 for importer@patchew.org; Thu, 28 Jun 2018 16:49:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdBC-0007tu-B1 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdB9-0001NC-RD for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:10 -0400 Received: from mail-wr0-x22f.google.com ([2a00:1450:400c:c0c::22f]:46759) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdB9-0001K7-Ft for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:07 -0400 Received: by mail-wr0-x22f.google.com with SMTP id t6-v6so6666629wrq.13 for ; Thu, 28 Jun 2018 13:06:07 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.06.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:06:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GDgZXFirqN3hkxub2DWMSQBD0isAaC7Ur3UyfK/hkeA=; b=DTL4jBUY+PzMhURsOe62TRmV0XWGSUo6LE8w+JeKbvAglpxX7rKnXdIhkPjHYBIfP0 a+EFN19oEZonLbLGAMVXGjR7cUArEt2sx1xKtFCjcSvptV6/oPCZpHy/CCKWJKiWh9Oq 1W76osxf75Amj1l8Y/0XMdwhVB1DNGSKf0U7r2DY3uBmfkuhS5Ip4N7kh0Gi11iMLOHh IF+1KTvzEXyryznur5hziSqd8YYLUR8X9LQ1JzGKSv9hgC/gYbOrRvx/+FQKnbrdlWdl 4TOFwDKoMAg7A/LIAQyG83ZAZ4XAVWFZntALYY9AS5k9b/VuBlTPXfbWMqLy3Ercw0HA gX/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=GDgZXFirqN3hkxub2DWMSQBD0isAaC7Ur3UyfK/hkeA=; b=mKyBOI0CBiSAnWoCRlp2mHM010XY6T2d6vF+kPldpErmSwt4HkCQ1SJy1eJ+Rd9IUf Tds1i18FtZ1vX3Dthz6lumdXHOWDX+D5ZUJVwYgzNeeQhTkB4BSzC+3DbN6NKEYdO6l7 TazzzUPix8d7G5FWNngLsLYYvNdfUmfg7rPByg43K90OwKzavrOom+LSBX4BZPtKwefk 1SKBaPDCNqpTMrTlLjaZNouZI96kcZw1Zfp+v8SKSrs30VLbk/U7xyfZyS4JgYajk/8C cJnXCi12KTe+PVj3DYSGPP4GFWtQeW6+jmm3Kp2iV0CmtGWJdC9uzSIF/+kKmH4Fi0uD MTng== X-Gm-Message-State: APt69E2Zdp45HjW6TVQAoHqiaTfxyF6RyPP7FjSPkbtcZ77QKVSJpbtL gvgUZh4aKiI7vUiL0fEtq+BmG8BU X-Google-Smtp-Source: AAOMgpctSXA2flIfoNiDjlpQksz6x8WcU0T3eVLCHT5wc2HeD5pIfQ/ty4qlYhyhPx/EKJdCOVGNGA== X-Received: by 2002:adf:83a6:: with SMTP id 35-v6mr9890838wre.13.1530216365965; Thu, 28 Jun 2018 13:06:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:05:03 +0200 Message-Id: <1530216310-52873-54-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22f Subject: [Qemu-devel] [PULL 53/60] dump: add Windows dump format to dump-guest-memory X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viktor Prutyanov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Viktor Prutyanov This patch adds Windows crashdumping feature. Now QEMU can produce ELF-dump containing Windows crashdump header, which can help to convert to a valid WinDbg-understandable crashdump file, or immediately create such file. The crashdump will be obtained by joining physical memory dump and 8K header exposed through vmcoreinfo/fw_cfg device by guest driver at BSOD time. Opti= on '-w' was added to dump-guest-memory command. At the moment, only x64 configuration is supported. Suitable driver can be found at https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/fwcfg64 Signed-off-by: Viktor Prutyanov Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180517162342.4330-2-viktor.prutyanov@virtuozzo.com> Signed-off-by: Paolo Bonzini --- Makefile.target | 1 + dump.c | 24 ++++++- hmp-commands.hx | 13 ++-- hmp.c | 9 ++- qapi/misc.json | 5 +- win_dump.c | 209 ++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ win_dump.h | 87 +++++++++++++++++++++++ 7 files changed, 339 insertions(+), 9 deletions(-) create mode 100644 win_dump.c create mode 100644 win_dump.h diff --git a/Makefile.target b/Makefile.target index a9d8928..4d56298 100644 --- a/Makefile.target +++ b/Makefile.target @@ -143,6 +143,7 @@ obj-y +=3D hw/ obj-y +=3D memory.o obj-y +=3D memory_mapping.o obj-y +=3D dump.o +obj-$(TARGET_X86_64) +=3D win_dump.o obj-y +=3D migration/ram.o LIBS :=3D $(libs_softmmu) $(LIBS) =20 diff --git a/dump.c b/dump.c index b54cd42..04467b3 100644 --- a/dump.c +++ b/dump.c @@ -29,6 +29,10 @@ #include "qemu/error-report.h" #include "hw/misc/vmcoreinfo.h" =20 +#ifdef TARGET_X86_64 +#include "win_dump.h" +#endif + #include #ifdef CONFIG_LZO #include @@ -1866,7 +1870,11 @@ static void dump_process(DumpState *s, Error **errp) Error *local_err =3D NULL; DumpQueryResult *result =3D NULL; =20 - if (s->has_format && s->format !=3D DUMP_GUEST_MEMORY_FORMAT_ELF) { + if (s->has_format && s->format =3D=3D DUMP_GUEST_MEMORY_FORMAT_WIN_DMP= ) { +#ifdef TARGET_X86_64 + create_win_dump(s, &local_err); +#endif + } else if (s->has_format && s->format !=3D DUMP_GUEST_MEMORY_FORMAT_EL= F) { create_kdump_vmcore(s, &local_err); } else { create_vmcore(s, &local_err); @@ -1970,6 +1978,13 @@ void qmp_dump_guest_memory(bool paging, const char *= file, } #endif =20 +#ifndef TARGET_X86_64 + if (has_format && format =3D=3D DUMP_GUEST_MEMORY_FORMAT_WIN_DMP) { + error_setg(errp, "Windows dump is only available for x86-64"); + return; + } +#endif + #if !defined(WIN32) if (strstart(file, "fd:", &p)) { fd =3D monitor_get_fd(cur_mon, p, errp); @@ -2044,5 +2059,12 @@ DumpGuestMemoryCapability *qmp_query_dump_guest_memo= ry_capability(Error **errp) item->value =3D DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY; #endif =20 + /* Windows dump is available only if target is x86_64 */ +#ifdef TARGET_X86_64 + item->next =3D g_malloc0(sizeof(DumpGuestMemoryFormatList)); + item =3D item->next; + item->value =3D DUMP_GUEST_MEMORY_FORMAT_WIN_DMP; +#endif + return cap; } diff --git a/hmp-commands.hx b/hmp-commands.hx index ba9cdb8..c1fc747 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1136,30 +1136,33 @@ ETEXI =20 { .name =3D "dump-guest-memory", - .args_type =3D "paging:-p,detach:-d,zlib:-z,lzo:-l,snappy:-s,file= name:F,begin:l?,length:l?", - .params =3D "[-p] [-d] [-z|-l|-s] filename [begin length]", + .args_type =3D "paging:-p,detach:-d,windmp:-w,zlib:-z,lzo:-l,snap= py:-s,filename:F,begin:l?,length:l?", + .params =3D "[-p] [-d] [-z|-l|-s|-w] filename [begin length]", .help =3D "dump guest memory into file 'filename'.\n\t\t\t" "-p: do paging to get guest's memory mapping.\n\t\t\= t" "-d: return immediately (do not wait for completion)= .\n\t\t\t" "-z: dump in kdump-compressed format, with zlib comp= ression.\n\t\t\t" "-l: dump in kdump-compressed format, with lzo compr= ession.\n\t\t\t" "-s: dump in kdump-compressed format, with snappy co= mpression.\n\t\t\t" + "-w: dump in Windows crashdump format (can be used i= nstead of ELF-dump converting),\n\t\t\t" + " for Windows x64 guests with vmcoreinfo driver o= nly.\n\t\t\t" "begin: the starting physical address.\n\t\t\t" "length: the memory size, in bytes.", .cmd =3D hmp_dump_guest_memory, }, =20 - STEXI @item dump-guest-memory [-p] @var{filename} @var{begin} @var{length} -@item dump-guest-memory [-z|-l|-s] @var{filename} +@item dump-guest-memory [-z|-l|-s|-w] @var{filename} @findex dump-guest-memory Dump guest memory to @var{protocol}. The file can be processed with crash = or -gdb. Without -z|-l|-s, the dump format is ELF. +gdb. Without -z|-l|-s|-w, the dump format is ELF. -p: do paging to get guest's memory mapping. -z: dump in kdump-compressed format, with zlib compression. -l: dump in kdump-compressed format, with lzo compression. -s: dump in kdump-compressed format, with snappy compression. + -w: dump in Windows crashdump format (can be used instead of ELF-d= ump converting), + for Windows x64 guests with vmcoreinfo driver only filename: dump file name. begin: the starting physical address. It's optional, and should be specified together with length. diff --git a/hmp.c b/hmp.c index 0da0b0a..41f5e39 100644 --- a/hmp.c +++ b/hmp.c @@ -2014,6 +2014,7 @@ void hmp_device_del(Monitor *mon, const QDict *qdict) void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; + bool win_dmp =3D qdict_get_try_bool(qdict, "windmp", false); bool paging =3D qdict_get_try_bool(qdict, "paging", false); bool zlib =3D qdict_get_try_bool(qdict, "zlib", false); bool lzo =3D qdict_get_try_bool(qdict, "lzo", false); @@ -2028,12 +2029,16 @@ void hmp_dump_guest_memory(Monitor *mon, const QDic= t *qdict) enum DumpGuestMemoryFormat dump_format =3D DUMP_GUEST_MEMORY_FORMAT_EL= F; char *prot; =20 - if (zlib + lzo + snappy > 1) { - error_setg(&err, "only one of '-z|-l|-s' can be set"); + if (zlib + lzo + snappy + win_dmp > 1) { + error_setg(&err, "only one of '-z|-l|-s|-w' can be set"); hmp_handle_error(mon, &err); return; } =20 + if (win_dmp) { + dump_format =3D DUMP_GUEST_MEMORY_FORMAT_WIN_DMP; + } + if (zlib) { dump_format =3D DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB; } diff --git a/qapi/misc.json b/qapi/misc.json index c6bc18a..29da785 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -1677,10 +1677,13 @@ # # @kdump-snappy: kdump-compressed format with snappy-compressed # +# @win-dmp: Windows full crashdump format, +# can be used instead of ELF converting (since 2.13) +# # Since: 2.0 ## { 'enum': 'DumpGuestMemoryFormat', - 'data': [ 'elf', 'kdump-zlib', 'kdump-lzo', 'kdump-snappy' ] } + 'data': [ 'elf', 'kdump-zlib', 'kdump-lzo', 'kdump-snappy', 'win-dmp' ] } =20 ## # @dump-guest-memory: diff --git a/win_dump.c b/win_dump.c new file mode 100644 index 0000000..58255c1 --- /dev/null +++ b/win_dump.c @@ -0,0 +1,209 @@ +/* + * Windows crashdump + * + * Copyright (c) 2018 Virtuozzo International GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "elf.h" +#include "cpu.h" +#include "exec/hwaddr.h" +#include "monitor/monitor.h" +#include "sysemu/kvm.h" +#include "sysemu/dump.h" +#include "sysemu/sysemu.h" +#include "sysemu/memory_mapping.h" +#include "sysemu/cpus.h" +#include "qapi/error.h" +#include "qapi/qmp/qerror.h" +#include "qemu/error-report.h" +#include "hw/misc/vmcoreinfo.h" +#include "win_dump.h" + +static size_t write_run(WinDumpPhyMemRun64 *run, int fd, Error **errp) +{ + void *buf; + uint64_t addr =3D run->BasePage << TARGET_PAGE_BITS; + uint64_t size =3D run->PageCount << TARGET_PAGE_BITS; + uint64_t len =3D size; + + buf =3D cpu_physical_memory_map(addr, &len, false); + if (!buf) { + error_setg(errp, "win-dump: failed to map run"); + return 0; + } + if (len !=3D size) { + error_setg(errp, "win-dump: failed to map entire run"); + len =3D 0; + goto out_unmap; + } + + len =3D qemu_write_full(fd, buf, len); + if (len !=3D size) { + error_setg(errp, QERR_IO_ERROR); + } + +out_unmap: + cpu_physical_memory_unmap(buf, addr, false, len); + + return len; +} + +static void write_runs(DumpState *s, WinDumpHeader64 *h, Error **errp) +{ + WinDumpPhyMemDesc64 *desc =3D &h->PhysicalMemoryBlock; + WinDumpPhyMemRun64 *run =3D desc->Run; + Error *local_err =3D NULL; + int i; + + for (i =3D 0; i < desc->NumberOfRuns; i++) { + s->written_size +=3D write_run(run + i, s->fd, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + } +} + +static void patch_mm_pfn_database(WinDumpHeader64 *h, Error **errp) +{ + if (cpu_memory_rw_debug(first_cpu, + h->KdDebuggerDataBlock + KDBG_MM_PFN_DATABASE_OFFSET64, + (uint8_t *)&h->PfnDatabase, sizeof(h->PfnDatabase), 0)) { + error_setg(errp, "win-dump: failed to read MmPfnDatabase"); + return; + } +} + +static void patch_bugcheck_data(WinDumpHeader64 *h, Error **errp) +{ + uint64_t KiBugcheckData; + + if (cpu_memory_rw_debug(first_cpu, + h->KdDebuggerDataBlock + KDBG_KI_BUGCHECK_DATA_OFFSET64, + (uint8_t *)&KiBugcheckData, sizeof(KiBugcheckData), 0)) { + error_setg(errp, "win-dump: failed to read KiBugcheckData"); + return; + } + + if (cpu_memory_rw_debug(first_cpu, + KiBugcheckData, + h->BugcheckData, sizeof(h->BugcheckData), 0)) { + error_setg(errp, "win-dump: failed to read bugcheck data"); + return; + } +} + +/* + * This routine tries to correct mistakes in crashdump header. + */ +static void patch_header(WinDumpHeader64 *h) +{ + Error *local_err =3D NULL; + + h->RequiredDumpSpace =3D sizeof(WinDumpHeader64) + + (h->PhysicalMemoryBlock.NumberOfPages << TARGET_PAGE_BITS); + h->PhysicalMemoryBlock.unused =3D 0; + h->unused1 =3D 0; + + /* + * We assume h->DirectoryBase and current CR3 are the same when we acc= ess + * memory by virtual address. In other words, we suppose current conte= xt + * is system context. It is definetely true in case of BSOD. + */ + + patch_mm_pfn_database(h, &local_err); + if (local_err) { + warn_report_err(local_err); + local_err =3D NULL; + } + patch_bugcheck_data(h, &local_err); + if (local_err) { + warn_report_err(local_err); + } +} + +static void check_header(WinDumpHeader64 *h, Error **errp) +{ + const char Signature[] =3D "PAGE"; + const char ValidDump[] =3D "DU64"; + + if (memcmp(h->Signature, Signature, sizeof(h->Signature))) { + error_setg(errp, "win-dump: invalid header, expected '%.4s'," + " got '%.4s'", Signature, h->Signature); + return; + } + + if (memcmp(h->ValidDump, ValidDump, sizeof(h->ValidDump))) { + error_setg(errp, "win-dump: invalid header, expected '%.4s'," + " got '%.4s'", ValidDump, h->ValidDump); + return; + } +} + +static void check_kdbg(WinDumpHeader64 *h, Error **errp) +{ + const char OwnerTag[] =3D "KDBG"; + char read_OwnerTag[4]; + + if (cpu_memory_rw_debug(first_cpu, + h->KdDebuggerDataBlock + KDBG_OWNER_TAG_OFFSET64, + (uint8_t *)&read_OwnerTag, sizeof(read_OwnerTag), 0)) { + error_setg(errp, "win-dump: failed to read OwnerTag"); + return; + } + + if (memcmp(read_OwnerTag, OwnerTag, sizeof(read_OwnerTag))) { + error_setg(errp, "win-dump: invalid KDBG OwnerTag," + " expected '%.4s', got '%.4s'," + " KdDebuggerDataBlock seems to be encrypted", + OwnerTag, read_OwnerTag); + return; + } +} + +void create_win_dump(DumpState *s, Error **errp) +{ + WinDumpHeader64 *h =3D (WinDumpHeader64 *)(s->guest_note + + VMCOREINFO_ELF_NOTE_HDR_SIZE); + Error *local_err =3D NULL; + + if (s->guest_note_size !=3D sizeof(WinDumpHeader64) + + VMCOREINFO_ELF_NOTE_HDR_SIZE) { + error_setg(errp, "win-dump: invalid vmcoreinfo note size"); + return; + } + + check_header(h, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + check_kdbg(h, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + patch_header(h); + + s->total_size =3D h->RequiredDumpSpace; + + s->written_size =3D qemu_write_full(s->fd, h, sizeof(*h)); + if (s->written_size !=3D sizeof(*h)) { + error_setg(errp, QERR_IO_ERROR); + return; + } + + write_runs(s, h, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } +} diff --git a/win_dump.h b/win_dump.h new file mode 100644 index 0000000..2812418 --- /dev/null +++ b/win_dump.h @@ -0,0 +1,87 @@ +/* + * Windows crashdump + * + * Copyright (c) 2018 Virtuozzo International GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +typedef struct WinDumpPhyMemRun64 { + uint64_t BasePage; + uint64_t PageCount; +} QEMU_PACKED WinDumpPhyMemRun64; + +typedef struct WinDumpPhyMemDesc64 { + uint32_t NumberOfRuns; + uint32_t unused; + uint64_t NumberOfPages; + WinDumpPhyMemRun64 Run[43]; +} QEMU_PACKED WinDumpPhyMemDesc64; + +typedef struct WinDumpExceptionRecord { + uint32_t ExceptionCode; + uint32_t ExceptionFlags; + uint64_t ExceptionRecord; + uint64_t ExceptionAddress; + uint32_t NumberParameters; + uint32_t unused; + uint64_t ExceptionInformation[15]; +} QEMU_PACKED WinDumpExceptionRecord; + +typedef struct WinDumpHeader64 { + char Signature[4]; + char ValidDump[4]; + uint32_t MajorVersion; + uint32_t MinorVersion; + uint64_t DirectoryTableBase; + uint64_t PfnDatabase; + uint64_t PsLoadedModuleList; + uint64_t PsActiveProcessHead; + uint32_t MachineImageType; + uint32_t NumberProcessors; + union { + struct { + uint32_t BugcheckCode; + uint32_t unused0; + uint64_t BugcheckParameter1; + uint64_t BugcheckParameter2; + uint64_t BugcheckParameter3; + uint64_t BugcheckParameter4; + }; + uint8_t BugcheckData[40]; + }; + uint8_t VersionUser[32]; + uint64_t KdDebuggerDataBlock; + union { + WinDumpPhyMemDesc64 PhysicalMemoryBlock; + uint8_t PhysicalMemoryBlockBuffer[704]; + }; + union { + uint8_t ContextBuffer[3000]; + }; + WinDumpExceptionRecord Exception; + uint32_t DumpType; + uint32_t unused1; + uint64_t RequiredDumpSpace; + uint64_t SystemTime; + char Comment[128]; + uint64_t SystemUpTime; + uint32_t MiniDumpFields; + uint32_t SecondaryDataState; + uint32_t ProductType; + uint32_t SuiteMask; + uint32_t WriterStatus; + uint8_t unused2; + uint8_t KdSecondaryVersion; + uint8_t reserved[4018]; +} QEMU_PACKED WinDumpHeader64; + +void create_win_dump(DumpState *s, Error **errp); + +#define KDBG_OWNER_TAG_OFFSET64 0x10 +#define KDBG_KI_BUGCHECK_DATA_OFFSET64 0x88 +#define KDBG_MM_PFN_DATABASE_OFFSET64 0xC0 + +#define VMCOREINFO_ELF_NOTE_HDR_SIZE 24 --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15302185714781016.1964894209976; Thu, 28 Jun 2018 13:42:51 -0700 (PDT) Received: from localhost ([::1]:38484 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdkg-0004tn-Gi for importer@patchew.org; Thu, 28 Jun 2018 16:42:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdBB-0007tf-5h for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdBA-0001Oc-78 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:09 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:38583) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdBA-0001Li-0j for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:08 -0400 Received: by mail-wr0-x243.google.com with SMTP id e18-v6so6692293wrs.5 for ; Thu, 28 Jun 2018 13:06:07 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.06.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=YmiUtSDzsLXe4lgYznzawmq90OdH7hPnhbdZR6+GcLM=; b=ImR8QH0LfmMr9PpMHavGPmwDkNqfMnHqsQdGg7fSkfZZSqhzrS0YSp0J0xJEihHgmy MLgfSFkfnW79BidiZEXYzmG6OaGpB9Pi5IfV5CQkKibinFV7va3qO9DaERGvO38wUzGb 3vX6yX60iMN5PCDsStdmHdwajZJ2Cq5WJQlOjBL0mNjdAp16Ifx8NesTNnpG3vgsbabm sk1edOmN2B2WJLsGUdKfXj6v49GmHT722w2ObrTTiZVO+AaJKZrec8yl9dK4684UrVL3 wRz9ZQAVlo9ZDJgnzDGx3z/8laK7Udlk2mBjpfJWRv59180oklGWt+nuZOPhMyAqe9YV rpxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=YmiUtSDzsLXe4lgYznzawmq90OdH7hPnhbdZR6+GcLM=; b=qtdWHt58Y+rOOqUgTVjo7Bf9RI0Fsnd43pbU7RNAGPevw0txpoknKqS2NdevYHdeeQ 2i2ht8v44ufqfD/DIuo6nrQ8z4QrnozI3paFJJYFtG5HYoug6d8AhOOxvgZ1T/dgaIEc pYP3HIuDa/0Cgf8wDywSXvOgourQ38HSZd4hGxzjVYFcT3gGrlfmcFjJm9G4H98JuBwM eTsWStzsbM6yL+EIwZgQqNnBdLr00DZtyNeBGU45XT2+mCJDvr6sETkFJi6b9CMASAvr IZwLEJF//79nW8vARIYV6neOXoLqkAJRTHr66ahYS+RKJkYFFS4Am9s5lioEN1v3iT69 Yc5g== X-Gm-Message-State: APt69E2TEV5dsuL+pzcbTnRUyWRqrs6kjRyCCTsLuxQ2vuJ5/t0noh3v NSD0eQGDg4sqO6wfS1qlUlEiACDE X-Google-Smtp-Source: AAOMgpfJfFij27ECeASOKrOPyH1L/MW/w4JskyWPwg9IOicwCRpwyzKX/ADslsXVoUrmdtVRi6pRUw== X-Received: by 2002:adf:bb08:: with SMTP id r8-v6mr2016825wrg.244.1530216366768; Thu, 28 Jun 2018 13:06:06 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:05:04 +0200 Message-Id: <1530216310-52873-55-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 54/60] dump: use system context in Windows dump X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viktor Prutyanov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Viktor Prutyanov We use CPU #0 to access guest virtual memory, but it can execute user thread at that moment. So, switch CR3 to PageDirectoryBase from header and restore original value at the end. Signed-off-by: Viktor Prutyanov Message-Id: <20180517162342.4330-3-viktor.prutyanov@virtuozzo.com> Signed-off-by: Paolo Bonzini --- win_dump.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/win_dump.c b/win_dump.c index 58255c1..7d956ca 100644 --- a/win_dump.c +++ b/win_dump.c @@ -111,12 +111,6 @@ static void patch_header(WinDumpHeader64 *h) h->PhysicalMemoryBlock.unused =3D 0; h->unused1 =3D 0; =20 - /* - * We assume h->DirectoryBase and current CR3 are the same when we acc= ess - * memory by virtual address. In other words, we suppose current conte= xt - * is system context. It is definetely true in case of BSOD. - */ - patch_mm_pfn_database(h, &local_err); if (local_err) { warn_report_err(local_err); @@ -171,6 +165,8 @@ void create_win_dump(DumpState *s, Error **errp) { WinDumpHeader64 *h =3D (WinDumpHeader64 *)(s->guest_note + VMCOREINFO_ELF_NOTE_HDR_SIZE); + X86CPU *first_x86_cpu =3D X86_CPU(first_cpu); + uint64_t saved_cr3 =3D first_x86_cpu->env.cr[3]; Error *local_err =3D NULL; =20 if (s->guest_note_size !=3D sizeof(WinDumpHeader64) + @@ -185,10 +181,17 @@ void create_win_dump(DumpState *s, Error **errp) return; } =20 + /* + * Further access to kernel structures by virtual addresses + * should be made from system context. + */ + + first_x86_cpu->env.cr[3] =3D h->DirectoryTableBase; + check_kdbg(h, &local_err); if (local_err) { error_propagate(errp, local_err); - return; + goto out_cr3; } =20 patch_header(h); @@ -198,12 +201,17 @@ void create_win_dump(DumpState *s, Error **errp) s->written_size =3D qemu_write_full(s->fd, h, sizeof(*h)); if (s->written_size !=3D sizeof(*h)) { error_setg(errp, QERR_IO_ERROR); - return; + goto out_cr3; } =20 write_runs(s, h, &local_err); if (local_err) { error_propagate(errp, local_err); - return; + goto out_cr3; } + +out_cr3: + first_x86_cpu->env.cr[3] =3D saved_cr3; + + return; } --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153021913943238.39056964466431; Thu, 28 Jun 2018 13:52:19 -0700 (PDT) Received: from localhost ([::1]:38543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdtq-0004nx-OF for importer@patchew.org; Thu, 28 Jun 2018 16:52:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdBE-0007uA-Bz for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdBB-0001Rn-6o for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:12 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:34404) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdBA-0001P3-VM for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:09 -0400 Received: by mail-wr0-x243.google.com with SMTP id a12-v6so6696671wro.1 for ; Thu, 28 Jun 2018 13:06:08 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.06.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=WZIKc4Qj6OdJt/OsldqtubpQGgVOZ8CfHk3rcKtqcso=; b=jFm6mt3/rzszNft0FY0O3pDzV/0iVvhVNIbT18YuFHUbrdy3Oq46Cr9tp+9C+y/901 PkZ9F8y5hjtV5w6MfXgOVNYsU6ZsqafdtS6jqbUjkeSlZYXpbux6Mfag8s3FPFFBy1IP 00f99xENNrlI9/pn9qg/bZ697yhP2vhtHEp/VqGnJRZnQSm84kEplOPuLnUmx5Zgyvac LqNCVl9SNdNMvMychuum4+VH9q/EH41twIlNYHx7czBMRokGuQAfBq4vibDghC1fOM1K EdPmlBhB395+3F69+Rvo2uS5kOUb9g9SGN0GIxjaDTn+FfdgyteuDVdP3Hq5WZPun+O0 FsPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=WZIKc4Qj6OdJt/OsldqtubpQGgVOZ8CfHk3rcKtqcso=; b=q4kQ1q4tzkmwG+WSmTQ/pm4205AS3FxQL00U+0mI5OF9kYmLmKd7ycI+cXxTqXBQ2y 5PC9k+QdwgP5+C6D8bFuzKQAhgxGJ/84dfxzSPlbVNGOUdfioGfO/LgkxyzRIJJNTi4w FNMrQ+tPrwGdrnS16WJF96q9JCxSBi6hfOfAlfup2+JREXmcjXfnzAH2WOa9ODaflt+5 dmXyso/gg+R4nrQ6P0RGwdL2DVsXN+3tqCJkLeckrAX2tB93+dUH+QsuMxzLKNdsRB8F XiorXcYITgiqiV+OFRfb1T4o/ANOTL84AyDdC+R8epvyDzpHZPujHMqNULnFe0h8kALf R4Rw== X-Gm-Message-State: APt69E0womytkl3/5bGkci2WVSpAS2+kJdXDAmcLuPXvef9D1zxAP5jT jCrQNelzWHhWcpNlm93LG3+O9ctE X-Google-Smtp-Source: AAOMgpcjXZCzPmxkj7n2duVGJKK8TxeZi3k9za+uaJ+iyfyc8APy1487dkwPn2JCcih/f//EedyP5g== X-Received: by 2002:adf:8188:: with SMTP id 8-v6mr10260244wra.89.1530216367759; Thu, 28 Jun 2018 13:06:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:05:05 +0200 Message-Id: <1530216310-52873-56-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 55/60] dump: add fallback KDBG using in Windows dump X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viktor Prutyanov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Viktor Prutyanov KdDebuggerDataBlock may be encrypted in guest memory and dump will be useless in this case. But guest driver can obtain decrypted KDBG and expose its address through BugcheckParameter1 field in raw header. After this patch, QEMU will be able to use fallback KdDebuggerDataBlock. Signed-off-by: Viktor Prutyanov Message-Id: <20180517162342.4330-4-viktor.prutyanov@virtuozzo.com> Signed-off-by: Paolo Bonzini --- win_dump.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/win_dump.c b/win_dump.c index 7d956ca..2d9afb5 100644 --- a/win_dump.c +++ b/win_dump.c @@ -144,21 +144,37 @@ static void check_kdbg(WinDumpHeader64 *h, Error **er= rp) { const char OwnerTag[] =3D "KDBG"; char read_OwnerTag[4]; + uint64_t KdDebuggerDataBlock =3D h->KdDebuggerDataBlock; + bool try_fallback =3D true; =20 +try_again: if (cpu_memory_rw_debug(first_cpu, - h->KdDebuggerDataBlock + KDBG_OWNER_TAG_OFFSET64, + KdDebuggerDataBlock + KDBG_OWNER_TAG_OFFSET64, (uint8_t *)&read_OwnerTag, sizeof(read_OwnerTag), 0)) { error_setg(errp, "win-dump: failed to read OwnerTag"); return; } =20 if (memcmp(read_OwnerTag, OwnerTag, sizeof(read_OwnerTag))) { - error_setg(errp, "win-dump: invalid KDBG OwnerTag," - " expected '%.4s', got '%.4s'," - " KdDebuggerDataBlock seems to be encrypted", - OwnerTag, read_OwnerTag); - return; + if (try_fallback) { + /* + * If attempt to use original KDBG failed + * (most likely because of its encryption), + * we try to use KDBG obtained by guest driver. + */ + + KdDebuggerDataBlock =3D h->BugcheckParameter1; + try_fallback =3D false; + goto try_again; + } else { + error_setg(errp, "win-dump: invalid KDBG OwnerTag," + " expected '%.4s', got '%.4s'", + OwnerTag, read_OwnerTag); + return; + } } + + h->KdDebuggerDataBlock =3D KdDebuggerDataBlock; } =20 void create_win_dump(DumpState *s, Error **errp) --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530219489223519.5543275657046; Thu, 28 Jun 2018 13:58:09 -0700 (PDT) Received: from localhost ([::1]:38585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdzU-0001H1-Cl for importer@patchew.org; Thu, 28 Jun 2018 16:58:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdBE-0007uB-DH for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdBC-0001VK-Br for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:12 -0400 Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]:44574) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdBC-0001Sc-1f for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:10 -0400 Received: by mail-wr0-x22c.google.com with SMTP id p12-v6so6677024wrn.11 for ; Thu, 28 Jun 2018 13:06:09 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.06.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:06:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=XeAnBuglpv9lhjXM9B8Q0eLKC8Ttj1XRH0jKUu9D5I8=; b=mFOW4Q/GtL+I3jN8go+OT6xOMcr2UweANvPhqwL8Wl+8A5hM03qLK5bdFNBeiO48FT 6YuBnaeITzsAOqSPKig1aWyMWLZ6lQLkhbgDcEXk1JLaEgCA+Bp/OySXYYOWOJURe7Vk VChe/DjE6DFNy5cqxWnYkc+zfFwpAl/txdiUvIidVExaXr944T/gF85YmsaqqKJG06c/ uAjqJGWgW91aRUi/KUi5KMcrSZZZwi/cZngh8Stl9b0CLVr/MCMueYdKQKHGxH6zA9Zv eHPMDBHk6nNQfj/574nW0Hbf9WPDY72+INRe6I8CvoECUpf4dSLtyEJlvwIzkKLJDtYE FLpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=XeAnBuglpv9lhjXM9B8Q0eLKC8Ttj1XRH0jKUu9D5I8=; b=lPJOE1pbVm5M7BBmJcXmiVLchbF4qXMEppMT2BmxcZRogyYB0+UbLz55ez2wNQRSfy MOZHKA+6unKrUPJBAOsCbIKVdMmSyAhT3nSb+BHtQ5OluCyV9SmiMs7xkvgdRa3UHIPX ncbKK918jL9+UVFyWNZ6jvcac4BdfBlaKuK0fZVGPrzZkmVJmJ+8GHRr/kq+XE2zvUiM oKFDm9SL7mlhtwAyWbbRpDRwG2EP+9O2cHGBkpTnlf6r/iWGtFjCG3lu8oEr+997PUDc g/nkw4VMgKDGmFaBaxacLZR1v5UIeruQWRRaTlWhM+GCuNnzap6dpmg64VdWY2gTFGUd qqlQ== X-Gm-Message-State: APt69E0p17SvU4Df6U/vUQDaUQdjhUFCXxFeT9VlmbeC/qgZz8+F1Lm1 JpdCyu7cNKjstL+9AreF27wpOP4d X-Google-Smtp-Source: AAOMgpfroV5iRrSW3N07BBOy962Hp4+JTr0MqF/Nf7EJ6dhjHi4OmDo3rfFyVfpQbUpQOxMCpOnyfw== X-Received: by 2002:adf:ed52:: with SMTP id u18-v6mr9494848wro.262.1530216368752; Thu, 28 Jun 2018 13:06:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:05:06 +0200 Message-Id: <1530216310-52873-57-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22c Subject: [Qemu-devel] [PULL 56/60] dump: add Windows live system dump X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viktor Prutyanov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Viktor Prutyanov Unlike dying Windows, live system memory doesn't contain correct register contexts. But they can be populated with QEMU register values. After this patch, QEMU will be able to produce guest Windows live system dump. Signed-off-by: Viktor Prutyanov Message-Id: <20180517162342.4330-5-viktor.prutyanov@virtuozzo.com> Signed-off-by: Paolo Bonzini --- win_dump.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++- win_dump.h | 95 +++++++++++++++++++++++++++++++++++-- 2 files changed, 246 insertions(+), 5 deletions(-) diff --git a/win_dump.c b/win_dump.c index 2d9afb5..b15c191 100644 --- a/win_dump.c +++ b/win_dump.c @@ -97,6 +97,14 @@ static void patch_bugcheck_data(WinDumpHeader64 *h, Erro= r **errp) error_setg(errp, "win-dump: failed to read bugcheck data"); return; } + + /* + * If BugcheckCode wasn't saved, we consider guest OS as alive. + */ + + if (!h->BugcheckCode) { + h->BugcheckCode =3D LIVE_SYSTEM_DUMP; + } } =20 /* @@ -177,12 +185,139 @@ try_again: h->KdDebuggerDataBlock =3D KdDebuggerDataBlock; } =20 +struct saved_context { + WinContext ctx; + uint64_t addr; +}; + +static void patch_and_save_context(WinDumpHeader64 *h, + struct saved_context *saved_ctx, + Error **errp) +{ + uint64_t KiProcessorBlock; + uint16_t OffsetPrcbContext; + CPUState *cpu; + int i =3D 0; + + if (cpu_memory_rw_debug(first_cpu, + h->KdDebuggerDataBlock + KDBG_KI_PROCESSOR_BLOCK_OFFSET64, + (uint8_t *)&KiProcessorBlock, sizeof(KiProcessorBlock), 0)) { + error_setg(errp, "win-dump: failed to read KiProcessorBlock"); + return; + } + + if (cpu_memory_rw_debug(first_cpu, + h->KdDebuggerDataBlock + KDBG_OFFSET_PRCB_CONTEXT_OFFSET64, + (uint8_t *)&OffsetPrcbContext, sizeof(OffsetPrcbContext), 0)) { + error_setg(errp, "win-dump: failed to read OffsetPrcbContext"); + return; + } + + CPU_FOREACH(cpu) { + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + uint64_t Prcb; + uint64_t Context; + WinContext ctx; + + if (cpu_memory_rw_debug(first_cpu, + KiProcessorBlock + i * sizeof(uint64_t), + (uint8_t *)&Prcb, sizeof(Prcb), 0)) { + error_setg(errp, "win-dump: failed to read" + " CPU #%d PRCB location", i); + return; + } + + if (cpu_memory_rw_debug(first_cpu, + Prcb + OffsetPrcbContext, + (uint8_t *)&Context, sizeof(Context), 0)) { + error_setg(errp, "win-dump: failed to read" + " CPU #%d ContextFrame location", i); + return; + } + + saved_ctx[i].addr =3D Context; + + ctx =3D (WinContext){ + .ContextFlags =3D WIN_CTX_ALL, + .MxCsr =3D env->mxcsr, + + .SegEs =3D env->segs[0].selector, + .SegCs =3D env->segs[1].selector, + .SegSs =3D env->segs[2].selector, + .SegDs =3D env->segs[3].selector, + .SegFs =3D env->segs[4].selector, + .SegGs =3D env->segs[5].selector, + .EFlags =3D cpu_compute_eflags(env), + + .Dr0 =3D env->dr[0], + .Dr1 =3D env->dr[1], + .Dr2 =3D env->dr[2], + .Dr3 =3D env->dr[3], + .Dr6 =3D env->dr[6], + .Dr7 =3D env->dr[7], + + .Rax =3D env->regs[R_EAX], + .Rbx =3D env->regs[R_EBX], + .Rcx =3D env->regs[R_ECX], + .Rdx =3D env->regs[R_EDX], + .Rsp =3D env->regs[R_ESP], + .Rbp =3D env->regs[R_EBP], + .Rsi =3D env->regs[R_ESI], + .Rdi =3D env->regs[R_EDI], + .R8 =3D env->regs[8], + .R9 =3D env->regs[9], + .R10 =3D env->regs[10], + .R11 =3D env->regs[11], + .R12 =3D env->regs[12], + .R13 =3D env->regs[13], + .R14 =3D env->regs[14], + .R15 =3D env->regs[15], + + .Rip =3D env->eip, + .FltSave =3D { + .MxCsr =3D env->mxcsr, + }, + }; + + if (cpu_memory_rw_debug(first_cpu, Context, + (uint8_t *)&saved_ctx[i].ctx, sizeof(WinContext), 0)) { + error_setg(errp, "win-dump: failed to save CPU #%d context", i= ); + return; + } + + if (cpu_memory_rw_debug(first_cpu, Context, + (uint8_t *)&ctx, sizeof(WinContext), 1)) { + error_setg(errp, "win-dump: failed to write CPU #%d context", = i); + return; + } + + i++; + } +} + +static void restore_context(WinDumpHeader64 *h, + struct saved_context *saved_ctx) +{ + int i; + Error *err =3D NULL; + + for (i =3D 0; i < h->NumberProcessors; i++) { + if (cpu_memory_rw_debug(first_cpu, saved_ctx[i].addr, + (uint8_t *)&saved_ctx[i].ctx, sizeof(WinContext), 1)) { + error_setg(&err, "win-dump: failed to restore CPU #%d context"= , i); + warn_report_err(err); + } + } +} + void create_win_dump(DumpState *s, Error **errp) { WinDumpHeader64 *h =3D (WinDumpHeader64 *)(s->guest_note + VMCOREINFO_ELF_NOTE_HDR_SIZE); X86CPU *first_x86_cpu =3D X86_CPU(first_cpu); uint64_t saved_cr3 =3D first_x86_cpu->env.cr[3]; + struct saved_context *saved_ctx =3D NULL; Error *local_err =3D NULL; =20 if (s->guest_note_size !=3D sizeof(WinDumpHeader64) + @@ -212,20 +347,37 @@ void create_win_dump(DumpState *s, Error **errp) =20 patch_header(h); =20 + saved_ctx =3D g_new(struct saved_context, h->NumberProcessors); + + /* + * Always patch context because there is no way + * to determine if the system-saved context is valid + */ + + patch_and_save_context(h, saved_ctx, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto out_free; + } + s->total_size =3D h->RequiredDumpSpace; =20 s->written_size =3D qemu_write_full(s->fd, h, sizeof(*h)); if (s->written_size !=3D sizeof(*h)) { error_setg(errp, QERR_IO_ERROR); - goto out_cr3; + goto out_restore; } =20 write_runs(s, h, &local_err); if (local_err) { error_propagate(errp, local_err); - goto out_cr3; + goto out_restore; } =20 +out_restore: + restore_context(h, saved_ctx); +out_free: + g_free(saved_ctx); out_cr3: first_x86_cpu->env.cr[3] =3D saved_cr3; =20 diff --git a/win_dump.h b/win_dump.h index 2812418..f9e1faf 100644 --- a/win_dump.h +++ b/win_dump.h @@ -80,8 +80,97 @@ typedef struct WinDumpHeader64 { =20 void create_win_dump(DumpState *s, Error **errp); =20 -#define KDBG_OWNER_TAG_OFFSET64 0x10 -#define KDBG_KI_BUGCHECK_DATA_OFFSET64 0x88 -#define KDBG_MM_PFN_DATABASE_OFFSET64 0xC0 +#define KDBG_OWNER_TAG_OFFSET64 0x10 +#define KDBG_MM_PFN_DATABASE_OFFSET64 0xC0 +#define KDBG_KI_BUGCHECK_DATA_OFFSET64 0x88 +#define KDBG_KI_PROCESSOR_BLOCK_OFFSET64 0x218 +#define KDBG_OFFSET_PRCB_CONTEXT_OFFSET64 0x338 =20 #define VMCOREINFO_ELF_NOTE_HDR_SIZE 24 + +#define WIN_CTX_X64 0x00100000L + +#define WIN_CTX_CTL 0x00000001L +#define WIN_CTX_INT 0x00000002L +#define WIN_CTX_SEG 0x00000004L +#define WIN_CTX_FP 0x00000008L +#define WIN_CTX_DBG 0x00000010L + +#define WIN_CTX_FULL (WIN_CTX_X64 | WIN_CTX_CTL | WIN_CTX_INT | WIN_CTX= _FP) +#define WIN_CTX_ALL (WIN_CTX_FULL | WIN_CTX_SEG | WIN_CTX_DBG) + +#define LIVE_SYSTEM_DUMP 0x00000161 + +typedef struct WinM128A { + uint64_t low; + int64_t high; +} QEMU_ALIGNED(16) WinM128A; + +typedef struct WinContext { + uint64_t PHome[6]; + + uint32_t ContextFlags; + uint32_t MxCsr; + + uint16_t SegCs; + uint16_t SegDs; + uint16_t SegEs; + uint16_t SegFs; + uint16_t SegGs; + uint16_t SegSs; + uint32_t EFlags; + + uint64_t Dr0; + uint64_t Dr1; + uint64_t Dr2; + uint64_t Dr3; + uint64_t Dr6; + uint64_t Dr7; + + uint64_t Rax; + uint64_t Rcx; + uint64_t Rdx; + uint64_t Rbx; + uint64_t Rsp; + uint64_t Rbp; + uint64_t Rsi; + uint64_t Rdi; + uint64_t R8; + uint64_t R9; + uint64_t R10; + uint64_t R11; + uint64_t R12; + uint64_t R13; + uint64_t R14; + uint64_t R15; + + uint64_t Rip; + + struct { + uint16_t ControlWord; + uint16_t StatusWord; + uint8_t TagWord; + uint8_t Reserved1; + uint16_t ErrorOpcode; + uint32_t ErrorOffset; + uint16_t ErrorSelector; + uint16_t Reserved2; + uint32_t DataOffset; + uint16_t DataSelector; + uint16_t Reserved3; + uint32_t MxCsr; + uint32_t MxCsr_Mask; + WinM128A FloatRegisters[8]; + WinM128A XmmRegisters[16]; + uint8_t Reserved4[96]; + } FltSave; + + WinM128A VectorRegister[26]; + uint64_t VectorControl; + + uint64_t DebugControl; + uint64_t LastBranchToRip; + uint64_t LastBranchFromRip; + uint64_t LastExceptionToRip; + uint64_t LastExceptionFromRip; +} QEMU_ALIGNED(16) WinContext; --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153021962708093.1330778139777; Thu, 28 Jun 2018 14:00:27 -0700 (PDT) Received: from localhost ([::1]:38596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYe1i-0003Ku-8s for importer@patchew.org; Thu, 28 Jun 2018 17:00:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdBG-0007wn-GL for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdBD-0001ZA-QK for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:14 -0400 Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]:43340) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdBD-0001Wp-E0 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:11 -0400 Received: by mail-wr0-x232.google.com with SMTP id c5-v6so6682654wrs.10 for ; Thu, 28 Jun 2018 13:06:11 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.06.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=65mv/m0X3ItLUWwZTYyNRoZjAMoEmmEccMc5UBQn3zg=; b=gNvUhi7gkaWEIpntT5urMPuJyNugM1K62leXgKDAAQWx1LOIF6OkUs2XSfV+S0bag6 DZIZzLUtS3yI8kXvklsYYWHQ0nkMLlpm0Wb7X0M3KCIHP1m0l3c8u9VuVoLPjoMkbxBx vDL9wsGOMTecF+b+9DRS7S/izPNmbCuCogBUI6ol8/r05U0oXca1sObBkMWzWTcHuJDZ H3eVIwcTiw/SCtaMOjt+p+Uw20YtTjZQiaG3I7EoqTYocFE5CTycJ+vHgRnsgGydHdYn A3xOKSdF4jLPNJszy7WRqbH8FcUowfyVZb2UPfKlLklCE9J6v0ig0CCByit2m/dLfbxa 8t6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=65mv/m0X3ItLUWwZTYyNRoZjAMoEmmEccMc5UBQn3zg=; b=fAmGG1Ac5kKHiDCvdTpjI1vi8p79V6Zjigfxaz8Mic4V4fXptkBeO2nCg+tWLjDA3Z k+Pkcxam3dbAeByFLica0VptSJwRsTnH34teg5m9vPmkafalz0qxPMrygT62fQdaFq8Q TEe/39Pel27OQFbRR1KhLal+LMiaWTAoWWEL1Y03SFjcWqdnhmR9GfJyY5GsKoDz8ZuL BXqv2oAWPqB6fdNABuKWbgYN1a1lunY3iYnaBdl+L7MXJr/ez4mHUV+/gMU9ltfEmnb5 Ken6eEtkV7QMT4mrSN/XACtgX/DPwh6OlemzQnB5ecRTdnQlQnN0Nrai18k6eJ3/mfvT 1uEg== X-Gm-Message-State: APt69E1Evr1YDumggT97j4cGB9XbkV8E7besbpiqtD9pJ/INh7v0heBf DpbnXw+tSfTUyf+tdhseFXcR5uQa X-Google-Smtp-Source: AAOMgpd9ewoad8zdKxi2Gl8EvI/oMAAbGABRG4vYHbDzJMMaPvZWx1RkJD52R5E3zBczytnsQDG8CA== X-Received: by 2002:adf:9d93:: with SMTP id p19-v6mr10150477wre.12.1530216370060; Thu, 28 Jun 2018 13:06:10 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:05:07 +0200 Message-Id: <1530216310-52873-58-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::232 Subject: [Qemu-devel] [PULL 57/60] hw/scsi: cleanups before VPD BL emulation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Henrique Barboza Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza To add support for the emulation of Block Limits VPD page for passthrough devices, a few adjustments in the current code base is required to avoid repetition and improve clarity. In scsi-generic.c, detach the Inquiry handling from scsi_read_complete and put it into a new function called scsi_handle_inquiry_reply. This change aims to avoid cluttering of scsi_read_complete when we more logic in the Inquiry response handling is added in the next patches, centralizing the changes in the new function. In scsi-disk.c, take the build of all emulated VPD pages from scsi_disk_emulate_inquiry and make it available to other files into a non-static function called scsi_disk_emulate_vpd_page. Making it public will allow the future VPD BL emulation code for passthrough devices to use it from scsi-generic.c, avoiding copy/pasting this code solely for that purpose. It also has the advantage of providing emulation of all VPD pages in case we need to emulate other pages in other scenarios. As a bonus, scsi_disk_emulate_inquiry got tidier. Signed-off-by: Daniel Henrique Barboza Message-Id: <20180627172432.11120-2-danielhb413@gmail.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-disk.c | 407 +++++++++++++++++++++++++--------------------= ---- hw/scsi/scsi-generic.c | 71 +++++---- include/hw/scsi/scsi.h | 1 + 3 files changed, 249 insertions(+), 230 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index aeaf611..664d634 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -585,219 +585,228 @@ static uint8_t *scsi_get_buf(SCSIRequest *req) return (uint8_t *)r->iov.iov_base; } =20 -static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) +int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf) { SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, req->dev); - int buflen =3D 0; - int start; - - if (req->cmd.buf[1] & 0x1) { - /* Vital product data */ - uint8_t page_code =3D req->cmd.buf[2]; - - outbuf[buflen++] =3D s->qdev.type & 0x1f; - outbuf[buflen++] =3D page_code ; // this page - outbuf[buflen++] =3D 0x00; - outbuf[buflen++] =3D 0x00; - start =3D buflen; - - switch (page_code) { - case 0x00: /* Supported page codes, mandatory */ - { - DPRINTF("Inquiry EVPD[Supported pages] " - "buffer size %zd\n", req->cmd.xfer); - outbuf[buflen++] =3D 0x00; // list of supported pages (this pa= ge) - if (s->serial) { - outbuf[buflen++] =3D 0x80; // unit serial number - } - outbuf[buflen++] =3D 0x83; // device identification - if (s->qdev.type =3D=3D TYPE_DISK) { - outbuf[buflen++] =3D 0xb0; // block limits - outbuf[buflen++] =3D 0xb1; /* block device characteristics= */ - outbuf[buflen++] =3D 0xb2; // thin provisioning - } - break; - } - case 0x80: /* Device serial number, optional */ - { - int l; + uint8_t page_code =3D req->cmd.buf[2]; + int start, buflen =3D 0; =20 - if (!s->serial) { - DPRINTF("Inquiry (EVPD[Serial number] not supported\n"); - return -1; - } + outbuf[buflen++] =3D s->qdev.type & 0x1f; + outbuf[buflen++] =3D page_code; + outbuf[buflen++] =3D 0x00; + outbuf[buflen++] =3D 0x00; + start =3D buflen; =20 - l =3D strlen(s->serial); - if (l > 36) { - l =3D 36; - } + switch (page_code) { + case 0x00: /* Supported page codes, mandatory */ + { + DPRINTF("Inquiry EVPD[Supported pages] " + "buffer size %zd\n", req->cmd.xfer); + outbuf[buflen++] =3D 0x00; /* list of supported pages (this page) = */ + if (s->serial) { + outbuf[buflen++] =3D 0x80; /* unit serial number */ + } + outbuf[buflen++] =3D 0x83; /* device identification */ + if (s->qdev.type =3D=3D TYPE_DISK) { + outbuf[buflen++] =3D 0xb0; /* block limits */ + outbuf[buflen++] =3D 0xb1; /* block device characteristics */ + outbuf[buflen++] =3D 0xb2; /* thin provisioning */ + } + break; + } + case 0x80: /* Device serial number, optional */ + { + int l; =20 - DPRINTF("Inquiry EVPD[Serial number] " - "buffer size %zd\n", req->cmd.xfer); - memcpy(outbuf+buflen, s->serial, l); - buflen +=3D l; - break; + if (!s->serial) { + DPRINTF("Inquiry (EVPD[Serial number] not supported\n"); + return -1; } =20 - case 0x83: /* Device identification page, mandatory */ - { - const char *str =3D s->serial ?: blk_name(s->qdev.conf.blk); - int max_len =3D s->serial ? 20 : 255 - 8; - int id_len =3D strlen(str); + l =3D strlen(s->serial); + if (l > 36) { + l =3D 36; + } =20 - if (id_len > max_len) { - id_len =3D max_len; - } - DPRINTF("Inquiry EVPD[Device identification] " - "buffer size %zd\n", req->cmd.xfer); - - outbuf[buflen++] =3D 0x2; // ASCII - outbuf[buflen++] =3D 0; // not officially assigned - outbuf[buflen++] =3D 0; // reserved - outbuf[buflen++] =3D id_len; // length of data following - memcpy(outbuf+buflen, str, id_len); - buflen +=3D id_len; - - if (s->qdev.wwn) { - outbuf[buflen++] =3D 0x1; // Binary - outbuf[buflen++] =3D 0x3; // NAA - outbuf[buflen++] =3D 0; // reserved - outbuf[buflen++] =3D 8; - stq_be_p(&outbuf[buflen], s->qdev.wwn); - buflen +=3D 8; - } + DPRINTF("Inquiry EVPD[Serial number] " + "buffer size %zd\n", req->cmd.xfer); + memcpy(outbuf + buflen, s->serial, l); + buflen +=3D l; + break; + } =20 - if (s->qdev.port_wwn) { - outbuf[buflen++] =3D 0x61; // SAS / Binary - outbuf[buflen++] =3D 0x93; // PIV / Target port / NAA - outbuf[buflen++] =3D 0; // reserved - outbuf[buflen++] =3D 8; - stq_be_p(&outbuf[buflen], s->qdev.port_wwn); - buflen +=3D 8; - } + case 0x83: /* Device identification page, mandatory */ + { + const char *str =3D s->serial ?: blk_name(s->qdev.conf.blk); + int max_len =3D s->serial ? 20 : 255 - 8; + int id_len =3D strlen(str); =20 - if (s->port_index) { - outbuf[buflen++] =3D 0x61; // SAS / Binary - outbuf[buflen++] =3D 0x94; // PIV / Target port / relative= target port - outbuf[buflen++] =3D 0; // reserved - outbuf[buflen++] =3D 4; - stw_be_p(&outbuf[buflen + 2], s->port_index); - buflen +=3D 4; - } - break; + if (id_len > max_len) { + id_len =3D max_len; } - case 0xb0: /* block limits */ - { - unsigned int unmap_sectors =3D - s->qdev.conf.discard_granularity / s->qdev.blocksize; - unsigned int min_io_size =3D - s->qdev.conf.min_io_size / s->qdev.blocksize; - unsigned int opt_io_size =3D - s->qdev.conf.opt_io_size / s->qdev.blocksize; - unsigned int max_unmap_sectors =3D - s->max_unmap_size / s->qdev.blocksize; - unsigned int max_io_sectors =3D - s->max_io_size / s->qdev.blocksize; - - if (s->qdev.type =3D=3D TYPE_ROM) { - DPRINTF("Inquiry (EVPD[%02X] not supported for CDROM\n", - page_code); - return -1; - } - if (s->qdev.type =3D=3D TYPE_DISK) { - int max_transfer_blk =3D blk_get_max_transfer(s->qdev.conf= .blk); - int max_io_sectors_blk =3D - max_transfer_blk / s->qdev.blocksize; - - max_io_sectors =3D - MIN_NON_ZERO(max_io_sectors_blk, max_io_sectors); - - /* min_io_size and opt_io_size can't be greater than - * max_io_sectors */ - if (min_io_size) { - min_io_size =3D MIN(min_io_size, max_io_sectors); - } - if (opt_io_size) { - opt_io_size =3D MIN(opt_io_size, max_io_sectors); - } - } - /* required VPD size with unmap support */ - buflen =3D 0x40; - memset(outbuf + 4, 0, buflen - 4); - - outbuf[4] =3D 0x1; /* wsnz */ - - /* optimal transfer length granularity */ - outbuf[6] =3D (min_io_size >> 8) & 0xff; - outbuf[7] =3D min_io_size & 0xff; - - /* maximum transfer length */ - outbuf[8] =3D (max_io_sectors >> 24) & 0xff; - outbuf[9] =3D (max_io_sectors >> 16) & 0xff; - outbuf[10] =3D (max_io_sectors >> 8) & 0xff; - outbuf[11] =3D max_io_sectors & 0xff; - - /* optimal transfer length */ - outbuf[12] =3D (opt_io_size >> 24) & 0xff; - outbuf[13] =3D (opt_io_size >> 16) & 0xff; - outbuf[14] =3D (opt_io_size >> 8) & 0xff; - outbuf[15] =3D opt_io_size & 0xff; - - /* max unmap LBA count, default is 1GB */ - outbuf[20] =3D (max_unmap_sectors >> 24) & 0xff; - outbuf[21] =3D (max_unmap_sectors >> 16) & 0xff; - outbuf[22] =3D (max_unmap_sectors >> 8) & 0xff; - outbuf[23] =3D max_unmap_sectors & 0xff; - - /* max unmap descriptors, 255 fit in 4 kb with an 8-byte heade= r. */ - outbuf[24] =3D 0; - outbuf[25] =3D 0; - outbuf[26] =3D 0; - outbuf[27] =3D 255; - - /* optimal unmap granularity */ - outbuf[28] =3D (unmap_sectors >> 24) & 0xff; - outbuf[29] =3D (unmap_sectors >> 16) & 0xff; - outbuf[30] =3D (unmap_sectors >> 8) & 0xff; - outbuf[31] =3D unmap_sectors & 0xff; - - /* max write same size */ - outbuf[36] =3D 0; - outbuf[37] =3D 0; - outbuf[38] =3D 0; - outbuf[39] =3D 0; - - outbuf[40] =3D (max_io_sectors >> 24) & 0xff; - outbuf[41] =3D (max_io_sectors >> 16) & 0xff; - outbuf[42] =3D (max_io_sectors >> 8) & 0xff; - outbuf[43] =3D max_io_sectors & 0xff; - break; + DPRINTF("Inquiry EVPD[Device identification] " + "buffer size %zd\n", req->cmd.xfer); + + outbuf[buflen++] =3D 0x2; /* ASCII */ + outbuf[buflen++] =3D 0; /* not officially assigned */ + outbuf[buflen++] =3D 0; /* reserved */ + outbuf[buflen++] =3D id_len; /* length of data following */ + memcpy(outbuf + buflen, str, id_len); + buflen +=3D id_len; + + if (s->qdev.wwn) { + outbuf[buflen++] =3D 0x1; /* Binary */ + outbuf[buflen++] =3D 0x3; /* NAA */ + outbuf[buflen++] =3D 0; /* reserved */ + outbuf[buflen++] =3D 8; + stq_be_p(&outbuf[buflen], s->qdev.wwn); + buflen +=3D 8; } - case 0xb1: /* block device characteristics */ - { - buflen =3D 8; - outbuf[4] =3D (s->rotation_rate >> 8) & 0xff; - outbuf[5] =3D s->rotation_rate & 0xff; - outbuf[6] =3D 0; - outbuf[7] =3D 0; - break; + + if (s->qdev.port_wwn) { + outbuf[buflen++] =3D 0x61; /* SAS / Binary */ + outbuf[buflen++] =3D 0x93; /* PIV / Target port / NAA */ + outbuf[buflen++] =3D 0; /* reserved */ + outbuf[buflen++] =3D 8; + stq_be_p(&outbuf[buflen], s->qdev.port_wwn); + buflen +=3D 8; } - case 0xb2: /* thin provisioning */ - { - buflen =3D 8; - outbuf[4] =3D 0; - outbuf[5] =3D 0xe0; /* unmap & write_same 10/16 all supported = */ - outbuf[6] =3D s->qdev.conf.discard_granularity ? 2 : 1; - outbuf[7] =3D 0; - break; + + if (s->port_index) { + outbuf[buflen++] =3D 0x61; /* SAS / Binary */ + + /* PIV/Target port/relative target port */ + outbuf[buflen++] =3D 0x94; + + outbuf[buflen++] =3D 0; /* reserved */ + outbuf[buflen++] =3D 4; + stw_be_p(&outbuf[buflen + 2], s->port_index); + buflen +=3D 4; } - default: + break; + } + case 0xb0: /* block limits */ + { + unsigned int unmap_sectors =3D + s->qdev.conf.discard_granularity / s->qdev.blocksize; + unsigned int min_io_size =3D + s->qdev.conf.min_io_size / s->qdev.blocksize; + unsigned int opt_io_size =3D + s->qdev.conf.opt_io_size / s->qdev.blocksize; + unsigned int max_unmap_sectors =3D + s->max_unmap_size / s->qdev.blocksize; + unsigned int max_io_sectors =3D + s->max_io_size / s->qdev.blocksize; + + if (s->qdev.type =3D=3D TYPE_ROM) { + DPRINTF("Inquiry (EVPD[%02X] not supported for CDROM\n", + page_code); return -1; } - /* done with EVPD */ - assert(buflen - start <=3D 255); - outbuf[start - 1] =3D buflen - start; - return buflen; + if (s->qdev.type =3D=3D TYPE_DISK) { + int max_transfer_blk =3D blk_get_max_transfer(s->qdev.conf.blk= ); + int max_io_sectors_blk =3D + max_transfer_blk / s->qdev.blocksize; + + max_io_sectors =3D + MIN_NON_ZERO(max_io_sectors_blk, max_io_sectors); + + /* min_io_size and opt_io_size can't be greater than + * max_io_sectors */ + if (min_io_size) { + min_io_size =3D MIN(min_io_size, max_io_sectors); + } + if (opt_io_size) { + opt_io_size =3D MIN(opt_io_size, max_io_sectors); + } + } + /* required VPD size with unmap support */ + buflen =3D 0x40; + memset(outbuf + 4, 0, buflen - 4); + + outbuf[4] =3D 0x1; /* wsnz */ + + /* optimal transfer length granularity */ + outbuf[6] =3D (min_io_size >> 8) & 0xff; + outbuf[7] =3D min_io_size & 0xff; + + /* maximum transfer length */ + outbuf[8] =3D (max_io_sectors >> 24) & 0xff; + outbuf[9] =3D (max_io_sectors >> 16) & 0xff; + outbuf[10] =3D (max_io_sectors >> 8) & 0xff; + outbuf[11] =3D max_io_sectors & 0xff; + + /* optimal transfer length */ + outbuf[12] =3D (opt_io_size >> 24) & 0xff; + outbuf[13] =3D (opt_io_size >> 16) & 0xff; + outbuf[14] =3D (opt_io_size >> 8) & 0xff; + outbuf[15] =3D opt_io_size & 0xff; + + /* max unmap LBA count, default is 1GB */ + outbuf[20] =3D (max_unmap_sectors >> 24) & 0xff; + outbuf[21] =3D (max_unmap_sectors >> 16) & 0xff; + outbuf[22] =3D (max_unmap_sectors >> 8) & 0xff; + outbuf[23] =3D max_unmap_sectors & 0xff; + + /* max unmap descriptors, 255 fit in 4 kb with an 8-byte header */ + outbuf[24] =3D 0; + outbuf[25] =3D 0; + outbuf[26] =3D 0; + outbuf[27] =3D 255; + + /* optimal unmap granularity */ + outbuf[28] =3D (unmap_sectors >> 24) & 0xff; + outbuf[29] =3D (unmap_sectors >> 16) & 0xff; + outbuf[30] =3D (unmap_sectors >> 8) & 0xff; + outbuf[31] =3D unmap_sectors & 0xff; + + /* max write same size */ + outbuf[36] =3D 0; + outbuf[37] =3D 0; + outbuf[38] =3D 0; + outbuf[39] =3D 0; + + outbuf[40] =3D (max_io_sectors >> 24) & 0xff; + outbuf[41] =3D (max_io_sectors >> 16) & 0xff; + outbuf[42] =3D (max_io_sectors >> 8) & 0xff; + outbuf[43] =3D max_io_sectors & 0xff; + break; + } + case 0xb1: /* block device characteristics */ + { + buflen =3D 8; + outbuf[4] =3D (s->rotation_rate >> 8) & 0xff; + outbuf[5] =3D s->rotation_rate & 0xff; + outbuf[6] =3D 0; + outbuf[7] =3D 0; + break; + } + case 0xb2: /* thin provisioning */ + { + buflen =3D 8; + outbuf[4] =3D 0; + outbuf[5] =3D 0xe0; /* unmap & write_same 10/16 all supported */ + outbuf[6] =3D s->qdev.conf.discard_granularity ? 2 : 1; + outbuf[7] =3D 0; + break; + } + default: + return -1; + } + /* done with EVPD */ + assert(buflen - start <=3D 255); + outbuf[start - 1] =3D buflen - start; + return buflen; +} + +static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) +{ + SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, req->dev); + int buflen =3D 0; + + if (req->cmd.buf[1] & 0x1) { + /* Vital product data */ + return scsi_disk_emulate_vpd_page(req, outbuf); } =20 /* Standard INQUIRY data */ @@ -3039,6 +3048,10 @@ static Property scsi_block_properties[] =3D { DEFINE_PROP_DRIVE("drive", SCSIDiskState, qdev.conf.blk), DEFINE_PROP_BOOL("share-rw", SCSIDiskState, qdev.conf.share_rw, false), DEFINE_PROP_UINT16("rotation_rate", SCSIDiskState, rotation_rate, 0), + DEFINE_PROP_UINT64("max_unmap_size", SCSIDiskState, max_unmap_size, + DEFAULT_MAX_UNMAP_SIZE), + DEFINE_PROP_UINT64("max_io_size", SCSIDiskState, max_io_size, + DEFAULT_MAX_IO_SIZE), DEFINE_PROP_INT32("scsi_version", SCSIDiskState, qdev.default_scsi_ver= sion, -1), DEFINE_PROP_END_OF_LIST(), diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index 03bce8f..a04a704 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -142,6 +142,43 @@ static int execute_command(BlockBackend *blk, return 0; } =20 +static void scsi_handle_inquiry_reply(SCSIGenericReq *r, SCSIDevice *s) +{ + /* + * EVPD set to zero returns the standard INQUIRY data. + * + * Check if scsi_version is unset (-1) to avoid re-defining it + * each time an INQUIRY with standard data is received. + * scsi_version is initialized with -1 in scsi_generic_reset + * and scsi_disk_reset, making sure that we'll set the + * scsi_version after a reset. If the version field of the + * INQUIRY response somehow changes after a guest reboot, + * we'll be able to keep track of it. + * + * On SCSI-2 and older, first 3 bits of byte 2 is the + * ANSI-approved version, while on later versions the + * whole byte 2 contains the version. Check if we're dealing + * with a newer version and, in that case, assign the + * whole byte. + */ + if (s->scsi_version =3D=3D -1 && !(r->req.cmd.buf[1] & 0x01)) { + s->scsi_version =3D r->buf[2] & 0x07; + if (s->scsi_version > 2) { + s->scsi_version =3D r->buf[2]; + } + } + if (s->type =3D=3D TYPE_DISK && r->req.cmd.buf[2] =3D=3D 0xb0) { + uint32_t max_transfer =3D + blk_get_max_transfer(s->conf.blk) / s->blocksize; + + assert(max_transfer); + stl_be_p(&r->buf[8], max_transfer); + /* Also take care of the opt xfer len. */ + stl_be_p(&r->buf[12], + MIN_NON_ZERO(max_transfer, ldl_be_p(&r->buf[12]))); + } +} + static void scsi_read_complete(void * opaque, int ret) { SCSIGenericReq *r =3D (SCSIGenericReq *)opaque; @@ -194,39 +231,7 @@ static void scsi_read_complete(void * opaque, int ret) } } if (r->req.cmd.buf[0] =3D=3D INQUIRY) { - /* - * EVPD set to zero returns the standard INQUIRY data. - * - * Check if scsi_version is unset (-1) to avoid re-defining it - * each time an INQUIRY with standard data is received. - * scsi_version is initialized with -1 in scsi_generic_reset - * and scsi_disk_reset, making sure that we'll set the - * scsi_version after a reset. If the version field of the - * INQUIRY response somehow changes after a guest reboot, - * we'll be able to keep track of it. - * - * On SCSI-2 and older, first 3 bits of byte 2 is the - * ANSI-approved version, while on later versions the - * whole byte 2 contains the version. Check if we're dealing - * with a newer version and, in that case, assign the - * whole byte. - */ - if (s->scsi_version =3D=3D -1 && !(r->req.cmd.buf[1] & 0x01)) { - s->scsi_version =3D r->buf[2] & 0x07; - if (s->scsi_version > 2) { - s->scsi_version =3D r->buf[2]; - } - } - if (s->type =3D=3D TYPE_DISK && r->req.cmd.buf[2] =3D=3D 0xb0) { - uint32_t max_transfer =3D - blk_get_max_transfer(s->conf.blk) / s->blocksize; - - assert(max_transfer); - stl_be_p(&r->buf[8], max_transfer); - /* Also take care of the opt xfer len. */ - stl_be_p(&r->buf[12], - MIN_NON_ZERO(max_transfer, ldl_be_p(&r->buf[12]))); - } + scsi_handle_inquiry_reply(r, s); } scsi_req_data(&r->req, len); scsi_req_unref(&r->req); diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index e35137e..138eb79 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -186,6 +186,7 @@ void scsi_device_report_change(SCSIDevice *dev, SCSISen= se sense); void scsi_device_unit_attention_reported(SCSIDevice *dev); void scsi_generic_read_device_identification(SCSIDevice *dev); int scsi_device_get_sense(SCSIDevice *dev, uint8_t *buf, int len, bool fix= ed); +int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf); SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int target, int lu= n); =20 /* scsi-generic.c. */ --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153021874239697.55334968937757; Thu, 28 Jun 2018 13:45:42 -0700 (PDT) Received: from localhost ([::1]:38501 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdnM-0007mr-Qg for importer@patchew.org; Thu, 28 Jun 2018 16:45:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdBG-0007x3-IQ for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdBE-0001bu-Ml for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:14 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:50760) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdBE-0001Yo-B3 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:12 -0400 Received: by mail-wm0-x242.google.com with SMTP id e16-v6so10988863wmd.0 for ; Thu, 28 Jun 2018 13:06:12 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.06.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:06:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=GeeFo2ZE3Zs/DOHWbzlKZcK4Y0iSJ+znqfWdiRViv1c=; b=IrmmZFtwpWN+DADByRDm1QPANt8P11BUYeBWJ3t91p8ImILGROjD43M1A8jZ449/vc QgZt8nAOZcnYKASNsRgfSYvfVj9VEF+4C1ogtMsWKqo8mSP5eDsDkrsSpo6n4jUt2rvR QBen2eh/3tvi5bH30a22pC88d4xxbs3wiRxgE6Dv9kj8etqzyCgT6bnvKxWcZJII9IF8 h2dLGDG17QA7z7Or/4fa1/QNKJFrFJVthtXFF0U6J5hHcvcDQN+p3UPuSD4DnzvXfSSO puxQOhtuePDtfupyYkiii6kXUeup80zYkiOO6uYL9Gqy7RYmEYehuFnJuHPTCbRviHXj 37UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=GeeFo2ZE3Zs/DOHWbzlKZcK4Y0iSJ+znqfWdiRViv1c=; b=WNcycMNV0xSQ9JJONfdw8flqoMdOMRgmZ4akMhs5epRy6ostUbYc4G4VtEV9l4eDsy FVuxGOfT/ZNsfaqmF6mz+3ZSm7OK5j0nsQrv9x1jM996TBkd0CMCIjiQHkgZnt6gD3lz MZurQzlHbwV2lS1CCLbQWOARrcu5/tNUUvfoaN7dIuZTf+Lpiq1tM6ftCgO5UkF8BD+6 FoF9Jpx9Fa8X5+dGi8m1VbBa4/El6eULeRzL/QNxjVolgC1M0HF6Z6CVGpGIXCm+R+VS fm0RG+EhjKN53tLT6dto3mBisoRxNJohCuMf8AL2AOr0biuou84rV2CN4+xHNbnjsuvz k8jg== X-Gm-Message-State: APt69E1dovUsxPZKHYMv5YlcFYbU2+l16FJr6kcbgYpapbD3kMvq8NVG J5X++FyJ9srotjMmtDmb8/2MdRor X-Google-Smtp-Source: AAOMgpfHNx+cGLVL9CVA7Dw6trNEuHAjI3h9vWQXfZoirkfARK9BjT6R6vB0WqmWkeZQVX16Q9nvww== X-Received: by 2002:a1c:8d8d:: with SMTP id p135-v6mr8861402wmd.34.1530216371075; Thu, 28 Jun 2018 13:06:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:05:08 +0200 Message-Id: <1530216310-52873-59-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 58/60] hw/scsi: centralize SG_IO calls into single function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Henrique Barboza Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza For the VPD Block Limits emulation with SCSI passthrough, we'll issue an Inquiry request with EVPD set to retrieve the available VPD pages of the device. This would be done in a way similar of what scsi_generic_read_device_identification does: create a SCSI command and a reply buffer, fill in the sg_io_hdr_t structure, call blk_ioctl, check if an error occurred, process the response. This same process is done in other 2 functions, get_device_type and get_stream_blocksize. They differ in the command/reply buffer and post-processing, everything else is almost a copy/paste. Instead of adding a forth copy/pasted-ish code when adding the passthrough VPD BL emulation, this patch extirpates this repetition of those 3 functions and put it into a new one called scsi_SG_IO_FROM_DEV. Any future code that wants to execute an SG_DXFER_FROM_DEV to the device can use it, avoiding filling sg_io_hdr_t again and et cetera. Signed-off-by: Daniel Henrique Barboza Message-Id: <20180627172432.11120-3-danielhb413@gmail.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-disk.c | 18 +++------------ hw/scsi/scsi-generic.c | 61 +++++++++++++++++++++++++---------------------= ---- include/hw/scsi/scsi.h | 2 ++ 3 files changed, 36 insertions(+), 45 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 664d634..b0b39f1 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2578,8 +2578,6 @@ static int get_device_type(SCSIDiskState *s) { uint8_t cmd[16]; uint8_t buf[36]; - uint8_t sensebuf[8]; - sg_io_hdr_t io_header; int ret; =20 memset(cmd, 0, sizeof(cmd)); @@ -2587,19 +2585,9 @@ static int get_device_type(SCSIDiskState *s) cmd[0] =3D INQUIRY; cmd[4] =3D sizeof(buf); =20 - memset(&io_header, 0, sizeof(io_header)); - io_header.interface_id =3D 'S'; - io_header.dxfer_direction =3D SG_DXFER_FROM_DEV; - io_header.dxfer_len =3D sizeof(buf); - io_header.dxferp =3D buf; - io_header.cmdp =3D cmd; - io_header.cmd_len =3D sizeof(cmd); - io_header.mx_sb_len =3D sizeof(sensebuf); - io_header.sbp =3D sensebuf; - io_header.timeout =3D 6000; /* XXX */ - - ret =3D blk_ioctl(s->qdev.conf.blk, SG_IO, &io_header); - if (ret < 0 || io_header.driver_status || io_header.host_status) { + ret =3D scsi_SG_IO_FROM_DEV(s->qdev.conf.blk, cmd, sizeof(cmd), + buf, sizeof(buf)); + if (ret < 0) { return -1; } s->qdev.type =3D buf[0]; diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index a04a704..61abc27 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -409,35 +409,48 @@ static int read_naa_id(const uint8_t *p, uint64_t *p_= wwn) return -EINVAL; } =20 -void scsi_generic_read_device_identification(SCSIDevice *s) +int scsi_SG_IO_FROM_DEV(BlockBackend *blk, uint8_t *cmd, uint8_t cmd_size, + uint8_t *buf, uint8_t buf_size) { - uint8_t cmd[6]; - uint8_t buf[250]; - uint8_t sensebuf[8]; sg_io_hdr_t io_header; + uint8_t sensebuf[8]; int ret; - int i, len; - - memset(cmd, 0, sizeof(cmd)); - memset(buf, 0, sizeof(buf)); - cmd[0] =3D INQUIRY; - cmd[1] =3D 1; - cmd[2] =3D 0x83; - cmd[4] =3D sizeof(buf); =20 memset(&io_header, 0, sizeof(io_header)); io_header.interface_id =3D 'S'; io_header.dxfer_direction =3D SG_DXFER_FROM_DEV; - io_header.dxfer_len =3D sizeof(buf); + io_header.dxfer_len =3D buf_size; io_header.dxferp =3D buf; io_header.cmdp =3D cmd; - io_header.cmd_len =3D sizeof(cmd); + io_header.cmd_len =3D cmd_size; io_header.mx_sb_len =3D sizeof(sensebuf); io_header.sbp =3D sensebuf; io_header.timeout =3D 6000; /* XXX */ =20 - ret =3D blk_ioctl(s->conf.blk, SG_IO, &io_header); + ret =3D blk_ioctl(blk, SG_IO, &io_header); if (ret < 0 || io_header.driver_status || io_header.host_status) { + return -1; + } + return 0; +} + +void scsi_generic_read_device_identification(SCSIDevice *s) +{ + uint8_t cmd[6]; + uint8_t buf[250]; + int ret; + int i, len; + + memset(cmd, 0, sizeof(cmd)); + memset(buf, 0, sizeof(buf)); + cmd[0] =3D INQUIRY; + cmd[1] =3D 1; + cmd[2] =3D 0x83; + cmd[4] =3D sizeof(buf); + + ret =3D scsi_SG_IO_FROM_DEV(s->conf.blk, cmd, sizeof(cmd), + buf, sizeof(buf)); + if (ret < 0) { return; } =20 @@ -470,8 +483,6 @@ static int get_stream_blocksize(BlockBackend *blk) { uint8_t cmd[6]; uint8_t buf[12]; - uint8_t sensebuf[8]; - sg_io_hdr_t io_header; int ret; =20 memset(cmd, 0, sizeof(cmd)); @@ -479,21 +490,11 @@ static int get_stream_blocksize(BlockBackend *blk) cmd[0] =3D MODE_SENSE; cmd[4] =3D sizeof(buf); =20 - memset(&io_header, 0, sizeof(io_header)); - io_header.interface_id =3D 'S'; - io_header.dxfer_direction =3D SG_DXFER_FROM_DEV; - io_header.dxfer_len =3D sizeof(buf); - io_header.dxferp =3D buf; - io_header.cmdp =3D cmd; - io_header.cmd_len =3D sizeof(cmd); - io_header.mx_sb_len =3D sizeof(sensebuf); - io_header.sbp =3D sensebuf; - io_header.timeout =3D 6000; /* XXX */ - - ret =3D blk_ioctl(blk, SG_IO, &io_header); - if (ret < 0 || io_header.driver_status || io_header.host_status) { + ret =3D scsi_SG_IO_FROM_DEV(blk, cmd, sizeof(cmd), buf, sizeof(buf)); + if (ret < 0) { return -1; } + return (buf[9] << 16) | (buf[10] << 8) | buf[11]; } =20 diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index 138eb79..75eced3 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -187,6 +187,8 @@ void scsi_device_unit_attention_reported(SCSIDevice *de= v); void scsi_generic_read_device_identification(SCSIDevice *dev); int scsi_device_get_sense(SCSIDevice *dev, uint8_t *buf, int len, bool fix= ed); int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf); +int scsi_SG_IO_FROM_DEV(BlockBackend *blk, uint8_t *cmd, uint8_t cmd_size, + uint8_t *buf, uint8_t buf_size); SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int target, int lu= n); =20 /* scsi-generic.c. */ --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530219118722805.0681869577325; Thu, 28 Jun 2018 13:51:58 -0700 (PDT) Received: from localhost ([::1]:38541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdtT-0004Xw-3F for importer@patchew.org; Thu, 28 Jun 2018 16:51:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdBI-00082E-6H for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdBF-0001eW-TT for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:16 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:35312) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdBF-0001cc-Gn for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:13 -0400 Received: by mail-wr0-x243.google.com with SMTP id c13-v6so6681908wrq.2 for ; Thu, 28 Jun 2018 13:06:13 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.06.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:06:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Bvpe4L8YodM1hErEwYX1kAMLUvBezWvUn5I4YSBENK8=; b=aUDk9atQ7fLNpMw//rnHac5qlwl5FIu8dZlAHT6QfAKbZGZcYzVp4ATP1h49PT8IOR YDiqnUHNNRRvxnmXrAINn7eHVYCA8v97gY8z88WrO7dlvbToU8tYief55LeebcdUzw4t lP1LSVLpUw8W5PPvnUK8BydrSKdqa5YMdb+NrX3a2FO0epZOYc4wrr7NpN5OWnH9CG43 jVDIeQQVtb/B6tCPxxZn4Sndki3PmnG3F9KTuLgPWUYUFTHM0+S9PlVjgW/V6BQxiqJs EkYpFlPEi/XPrUKB0ohil+Vbq+7YV2PQLE6nZvAl7tvH7dNClat21mcClhr/E3LrmJkq I1fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Bvpe4L8YodM1hErEwYX1kAMLUvBezWvUn5I4YSBENK8=; b=HwPiOp2pGkmm7jfZqRvWkVyeJKvlYzsKC2kUMjUlyy79oN/AVMpcmpPSooXidPAesV Vg4vi7viqR8RqOecaleKbPmFeRppdHrxqedZSxGPjg0YcwEnRAu90bf9EP4rPyXw2vmK jh1TUmywpOCYbLDzZKo59D7Qnte/i6w3dWB46IguL3Fg3p9JwRGdChHqmWlFGPcljpYh AMvkg7z+nixM+Zfk/kc+1ffmE/eI7qMasLsjgIK3lplNAhq0uy1BJzIXyHaRi5D5WSsA 0ehLQNwxLTBfg7WXCrqY2yhp56thQpAJjDbSCC93Q9q6J19tP8kHvF2h/UpUm+Dq3fxc IN6w== X-Gm-Message-State: APt69E3qgR5o1Zl7x9MPlvoxCWlzBpBRHn+8aVw5UeAk/3nxwo3AtcBW rlBDdTHieCr0Wm9N9htOPn1e+O+G X-Google-Smtp-Source: AAOMgpdG34w7OVWJaZzAxgzaA3hxDNSh/27OBMeZuh7I09VDkf27xZvTHZQifG0W9rFpsnVgHwjObA== X-Received: by 2002:a5d:4a92:: with SMTP id o18-v6mr9244690wrq.132.1530216372200; Thu, 28 Jun 2018 13:06:12 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:05:09 +0200 Message-Id: <1530216310-52873-60-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 59/60] hw/scsi: add VPD Block Limits emulation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Henrique Barboza Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza The VPD Block Limits Inquiry page is optional, allowing SCSI devices to not implement it. This is the case for devices like the MegaRAID SAS 9361-8i and Microsemi PM8069. In case of SCSI passthrough, the response of this request is used by the QEMU SCSI layer to set the max_io_sectors that the guest device will support, based on the value of the max_sectors_kb that the device has set in the host at that time. Without this response, the guest kernel is free to assume any value of max_io_sectors for the SCSI device. If this value is greater than the value from the host, SCSI Sense errors will occur because the guest will send read/write requests that are larger than the underlying host device is configured to support. An example of this behavior can be seen in [1]. A workaround is to set the max_sectors_kb host value back in the guest kernel (a process that can be automated using rc.local startup scripts and the like), but this has several drawbacks: - it can be troublesome if the guest has many passthrough devices that needs this tuning; - if a change in max_sectors_kb is made in the host side, manual change in the guests will also be required; - during an OS install it is difficult, and sometimes not possible, to go to a terminal and change the max_sectors_kb prior to the installation. This means that the disk can't be used during the install process. The easiest alternative here is to roll back to scsi-hd, install the guest and then go back to SCSI passthrough when the installation is done and max_sectors_kb can be set. An easier way would be to QEMU handle the absence of the Block Limits VPD device response, setting max_io_sectors accordingly and allowing the guest to use the device without the hassle. This patch adds emulation of the Block Limits VPD response for SCSI passthrough devices of type TYPE_DISK that doesn't support it. The following changes were made: - scsi_handle_inquiry_reply will now check the available VPD pages from the Inquiry EVPD reply. In case the device does not - a new function called scsi_generic_set_vpd_bl_emulation, that is called during device realize, was created to set a new flag 'needs_vpd_bl_emulation' of the device. This function retrieves the Inquiry EVPD response of the device to check for VPD BL support. - scsi_handle_inquiry_reply will now check the available VPD pages from the Inquiry EVPD reply in case the device needs VPD BL emulation, adding the Block Limits page (0xb0) to the list. This will make the guest kernel aware of the support that we're now providing by emulation. - a new function scsi_emulate_block_limits creates the emulated Block Limits response. This function is called inside scsi_read_complete in case the device requires Block Limits VPD emulation and we detected a SCSI Sense error in the VPD Block Limits reply that was issued from the guest kernel to the device. This error is expected: we're reporting support from our side, but the device isn't aware of it. With this patch, the guest now queries the Block Limits page during the device configuration because it is being advertised in the Supported Pages response. It will either receive the Block Limits page from the hardware, if it supports it, or will receive an emulated response from QEMU. At any rate, the guest now has the information to set the max_sectors_kb parameter accordingly, sparing the user of SCSI sense errors that would happen without the emulated response and in the absence of Block Limits support from the hardware. [1] https://bugzilla.redhat.com/show_bug.cgi?id=3D1566195 Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1566195 Reported-by: Dac Nguyen Signed-off-by: Daniel Henrique Barboza Message-Id: <20180627172432.11120-4-danielhb413@gmail.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-disk.c | 2 +- hw/scsi/scsi-generic.c | 132 +++++++++++++++++++++++++++++++++++++++++++++= ---- include/hw/scsi/scsi.h | 3 +- 3 files changed, 125 insertions(+), 12 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index b0b39f1..55a34b3 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2645,7 +2645,7 @@ static void scsi_block_realize(SCSIDevice *dev, Error= **errp) s->features |=3D (1 << SCSI_DISK_F_NO_REMOVABLE_DEVOPS); =20 scsi_realize(&s->qdev, errp); - scsi_generic_read_device_identification(&s->qdev); + scsi_generic_read_device_inquiry(&s->qdev); } =20 typedef struct SCSIBlockReq { diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index 61abc27..d60c4d0 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -144,6 +144,8 @@ static int execute_command(BlockBackend *blk, =20 static void scsi_handle_inquiry_reply(SCSIGenericReq *r, SCSIDevice *s) { + uint8_t page, page_len; + /* * EVPD set to zero returns the standard INQUIRY data. * @@ -167,22 +169,57 @@ static void scsi_handle_inquiry_reply(SCSIGenericReq = *r, SCSIDevice *s) s->scsi_version =3D r->buf[2]; } } - if (s->type =3D=3D TYPE_DISK && r->req.cmd.buf[2] =3D=3D 0xb0) { - uint32_t max_transfer =3D - blk_get_max_transfer(s->conf.blk) / s->blocksize; =20 - assert(max_transfer); - stl_be_p(&r->buf[8], max_transfer); - /* Also take care of the opt xfer len. */ - stl_be_p(&r->buf[12], - MIN_NON_ZERO(max_transfer, ldl_be_p(&r->buf[12]))); + if (s->type =3D=3D TYPE_DISK && (r->req.cmd.buf[1] & 0x01)) { + page =3D r->req.cmd.buf[2]; + if (page =3D=3D 0xb0) { + uint32_t max_transfer =3D + blk_get_max_transfer(s->conf.blk) / s->blocksize; + + assert(max_transfer); + stl_be_p(&r->buf[8], max_transfer); + /* Also take care of the opt xfer len. */ + stl_be_p(&r->buf[12], + MIN_NON_ZERO(max_transfer, ldl_be_p(&r->buf[12]))); + } else if (page =3D=3D 0x00 && s->needs_vpd_bl_emulation) { + /* + * Now we're capable of supplying the VPD Block Limits + * response if the hardware can't. Add it in the INQUIRY + * Supported VPD pages response in case we are using the + * emulation for this device. + * + * This way, the guest kernel will be aware of the support + * and will use it to proper setup the SCSI device. + */ + page_len =3D r->buf[3]; + r->buf[page_len + 4] =3D 0xb0; + r->buf[3] =3D ++page_len; + } } } =20 +static int scsi_emulate_block_limits(SCSIGenericReq *r) +{ + r->buflen =3D scsi_disk_emulate_vpd_page(&r->req, r->buf); + r->io_header.sb_len_wr =3D 0; + + /* + * We have valid contents in the reply buffer but the + * io_header can report a sense error coming from + * the hardware in scsi_command_complete_noio. Clean + * up the io_header to avoid reporting it. + */ + r->io_header.driver_status =3D 0; + r->io_header.status =3D 0; + + return r->buflen; +} + static void scsi_read_complete(void * opaque, int ret) { SCSIGenericReq *r =3D (SCSIGenericReq *)opaque; SCSIDevice *s =3D r->req.dev; + SCSISense sense; int len; =20 assert(r->req.aiocb !=3D NULL); @@ -199,6 +236,27 @@ static void scsi_read_complete(void * opaque, int ret) DPRINTF("Data ready tag=3D0x%x len=3D%d\n", r->req.tag, len); =20 r->len =3D -1; + + /* + * Check if this is a VPD Block Limits request that + * resulted in sense error but would need emulation. + * In this case, emulate a valid VPD response. + */ + if (s->needs_vpd_bl_emulation) { + int is_vpd_bl =3D r->req.cmd.buf[0] =3D=3D INQUIRY && + r->req.cmd.buf[1] & 0x01 && + r->req.cmd.buf[2] =3D=3D 0xb0; + + if (is_vpd_bl && sg_io_sense_from_errno(-ret, &r->io_header, &sens= e)) { + len =3D scsi_emulate_block_limits(r); + /* + * No need to let scsi_read_complete go on and handle an + * INQUIRY VPD BL request we created manually. + */ + goto req_complete; + } + } + if (len =3D=3D 0) { scsi_command_complete_noio(r, 0); goto done; @@ -233,6 +291,8 @@ static void scsi_read_complete(void * opaque, int ret) if (r->req.cmd.buf[0] =3D=3D INQUIRY) { scsi_handle_inquiry_reply(r, s); } + +req_complete: scsi_req_data(&r->req, len); scsi_req_unref(&r->req); =20 @@ -434,7 +494,49 @@ int scsi_SG_IO_FROM_DEV(BlockBackend *blk, uint8_t *cm= d, uint8_t cmd_size, return 0; } =20 -void scsi_generic_read_device_identification(SCSIDevice *s) +/* + * Executes an INQUIRY request with EVPD set to retrieve the + * available VPD pages of the device. If the device does + * not support the Block Limits page (page 0xb0), set + * the needs_vpd_bl_emulation flag for future use. + */ +static void scsi_generic_set_vpd_bl_emulation(SCSIDevice *s) +{ + uint8_t cmd[6]; + uint8_t buf[250]; + uint8_t page_len; + int ret, i; + + memset(cmd, 0, sizeof(cmd)); + memset(buf, 0, sizeof(buf)); + cmd[0] =3D INQUIRY; + cmd[1] =3D 1; + cmd[2] =3D 0x00; + cmd[4] =3D sizeof(buf); + + ret =3D scsi_SG_IO_FROM_DEV(s->conf.blk, cmd, sizeof(cmd), + buf, sizeof(buf)); + if (ret < 0) { + /* + * Do not assume anything if we can't retrieve the + * INQUIRY response to assert the VPD Block Limits + * support. + */ + s->needs_vpd_bl_emulation =3D false; + return; + } + + page_len =3D buf[3]; + for (i =3D 4; i < page_len + 4; i++) { + if (buf[i] =3D=3D 0xb0) { + s->needs_vpd_bl_emulation =3D false; + return; + } + } + s->needs_vpd_bl_emulation =3D true; +} + +static void scsi_generic_read_device_identification(SCSIDevice *s) { uint8_t cmd[6]; uint8_t buf[250]; @@ -479,6 +581,16 @@ void scsi_generic_read_device_identification(SCSIDevic= e *s) } } =20 +void scsi_generic_read_device_inquiry(SCSIDevice *s) +{ + scsi_generic_read_device_identification(s); + if (s->type =3D=3D TYPE_DISK) { + scsi_generic_set_vpd_bl_emulation(s); + } else { + s->needs_vpd_bl_emulation =3D false; + } +} + static int get_stream_blocksize(BlockBackend *blk) { uint8_t cmd[6]; @@ -580,7 +692,7 @@ static void scsi_generic_realize(SCSIDevice *s, Error *= *errp) =20 /* Only used by scsi-block, but initialize it nevertheless to be clean= . */ s->default_scsi_version =3D -1; - scsi_generic_read_device_identification(s); + scsi_generic_read_device_inquiry(s); } =20 const SCSIReqOps scsi_generic_req_ops =3D { diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index 75eced3..21a3a6f 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -87,6 +87,7 @@ struct SCSIDevice uint64_t port_wwn; int scsi_version; int default_scsi_version; + bool needs_vpd_bl_emulation; }; =20 extern const VMStateDescription vmstate_scsi_device; @@ -184,7 +185,7 @@ void scsi_device_purge_requests(SCSIDevice *sdev, SCSIS= ense sense); void scsi_device_set_ua(SCSIDevice *sdev, SCSISense sense); void scsi_device_report_change(SCSIDevice *dev, SCSISense sense); void scsi_device_unit_attention_reported(SCSIDevice *dev); -void scsi_generic_read_device_identification(SCSIDevice *dev); +void scsi_generic_read_device_inquiry(SCSIDevice *dev); int scsi_device_get_sense(SCSIDevice *dev, uint8_t *buf, int len, bool fix= ed); int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf); int scsi_SG_IO_FROM_DEV(BlockBackend *blk, uint8_t *cmd, uint8_t cmd_size, --=20 1.8.3.1 From nobody Mon Feb 9 00:51:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530219284349437.9208771655144; Thu, 28 Jun 2018 13:54:44 -0700 (PDT) Received: from localhost ([::1]:38557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdwB-0006XC-A9 for importer@patchew.org; Thu, 28 Jun 2018 16:54:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdBH-00080d-Mj for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdBG-0001gt-LF for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:15 -0400 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]:37253) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdBG-0001ea-EJ for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:14 -0400 Received: by mail-wr0-x22e.google.com with SMTP id k6-v6so6689076wrp.4 for ; Thu, 28 Jun 2018 13:06:14 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.06.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=o+nkNwRakOqNcLHJIz2rtJm7d1CX5+MB94kB1BbNP5c=; b=FTmieeQ1KHjstAPigyLaB63P1+a5Rxj1616fsalOX6OY63h4WZuhjnhQBjcL/V7e6B RQLeZrpvhBi1gXtyRmn5YTxLPUBl1bO9BWM2FMddnbX2IYopEYJ6981TDylPVUrhqiK7 qb1+kEEqmpAAiDnW0KL08RIoDous4qNXhlBL16+cbgfb2GdYYUmXiqd42Lnu17pG+J8a PgjGWILituYPtpgrssAW21kO6bDqDnTyhuPfTzh3YTPjJOmyUq/cekqh1VPVOOCLmLM5 +qOYbwNwSaxxnyosZ4L8ONAd+XVpRMPkQU1oLyzvafT4nnBCjCuCa/Au7k3fK8UGGHMY KB2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=o+nkNwRakOqNcLHJIz2rtJm7d1CX5+MB94kB1BbNP5c=; b=e4WEtrlBEIHiwpCHLwPN01d+xL8pSXPvymAKbo3krKa47M1zjzET7uJkl/GEgCU04M MT1gDNUQoki7cWXiZR7cfUQ0Azdg+sBlsS+UQJxgRzWIzuKlMkaggyl6eRwKw/VZW9w3 2RZG6r2MMDv97BZZauFbNI0Jfy8gMCvep/9DzX6zYQsPciCc7bzCi2lqhPfeyw4hBeO6 2/w2tLokXBNKdgKx/4aIP3us6rUrFwz0O1i/KPlp0v5peO1uqQ0ybH3FUyWYML4Cp5Mj qmpSxPNZNdBeeEWcb3Uu/oACMFYd2qs9b0t0WL8WVSvEzSbZ646gSAta4/Noia+b3KKY HBbw== X-Gm-Message-State: APt69E13QKZVG2cBTeh9+pMBOGzl50abej0P/L72+/Tp6oaw8WRA/CeF hF8jWXnYJbie3d7OEU9RdGGQ7SrJ X-Google-Smtp-Source: AAOMgpdWaOB/hTjQRrbOxUYQSlOqisOtzvqe846AiDkme8dihnRpZs9gR0TGhXz9pBvnb2OwwLLnSQ== X-Received: by 2002:adf:adc9:: with SMTP id w67-v6mr2239155wrc.135.1530216373098; Thu, 28 Jun 2018 13:06:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:05:10 +0200 Message-Id: <1530216310-52873-61-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22e Subject: [Qemu-devel] [PULL 60/60] tests/boot-serial: Do not delete the output file in case of errors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth Peter reported that the boot-serial tester sometimes runs into timeouts with SPARC guests. It's currently completely unclear whether this is due to too much load on the host machine (so that the guest really just ran too slow), or whether there is something wrong with the guest's firmware boot. For further debugging, we need the serial output of the guest in case of errors, so instead of unlinking the file immediately, this is now only done in case of success. In case of error, print the name of the file with the serial output via g_error() (which then also calls abort() internally to mark the test as failed). Signed-off-by: Thomas Huth Message-Id: <1526977831-31129-1-git-send-email-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- tests/boot-serial-test.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index 4d6815c..952a2e7 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -111,9 +111,8 @@ static testdef_t tests[] =3D { { NULL } }; =20 -static void check_guest_output(const testdef_t *test, int fd) +static bool check_guest_output(const testdef_t *test, int fd) { - bool output_ok =3D false; int i, nbr =3D 0, pos =3D 0, ccnt; char ch; =20 @@ -125,8 +124,7 @@ static void check_guest_output(const testdef_t *test, i= nt fd) pos +=3D 1; if (test->expect[pos] =3D=3D '\0') { /* We've reached the end of the expected string! */ - output_ok =3D true; - goto done; + return true; } } else { pos =3D 0; @@ -136,8 +134,7 @@ static void check_guest_output(const testdef_t *test, i= nt fd) g_usleep(10000); } =20 -done: - g_assert(output_ok); + return false; } =20 static void test_machine(const void *data) @@ -180,12 +177,16 @@ static void test_machine(const void *data) "-no-shutdown -serial chardev:serial0 %s", codeparam, code ? codetmp : "", test->machine, serialtmp, test->extra); - unlink(serialtmp); if (code) { unlink(codetmp); } =20 - check_guest_output(test, ser_fd); + if (!check_guest_output(test, ser_fd)) { + g_error("Failed to find expected string. Please check '%s'", + serialtmp); + } + unlink(serialtmp); + qtest_quit(global_qtest); =20 close(ser_fd); --=20 1.8.3.1