From nobody Tue Apr 30 08:57:31 2024 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 15178592946606.907063185473362; Mon, 5 Feb 2018 11:34:54 -0800 (PST) Received: from localhost ([::1]:54778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimXV-0000Oe-OT for importer@patchew.org; Mon, 05 Feb 2018 14:34:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimRy-00049u-Iq for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimRw-0004pW-CD for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:10 -0500 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:36766) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimRw-0004p2-1C for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:08 -0500 Received: by mail-wm0-x231.google.com with SMTP id f3so28128122wmc.1 for ; Mon, 05 Feb 2018 11:29:07 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:05 -0800 (PST) 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=/6MiLBWU7tFv7qP7gebKJ8YA49GO8wOln0CYQD4Og44=; b=dLTo7c/LBgZzzqH3Hl2Drmc6v5SGFfBO8DX9e+Kv34o08Zg/1g2PwCPU2NMsfW57bz GQBF4rgUiTq23IANR/Yt/JtzEXI7ZlzM2qlN6oHLSN5kjqdXk3vK9ExrFa2cVM/6PJ54 /Qy9UvEJ4Tf1Ya/kofYqK1gZdntEypUjZ0SjHqnoA8hdItGWam/mNo3ANcQ+ATWLhkOb YNMqdx2cyQbdcf2t0gTDXxKBO68XcRYuveT2QhknMcmPAan/QRzzBh+2/+5BaP6kk02D yy8w35T4U1LQsSWMBqSn/Nj1aAp0GSZH+nhufh5N6CO2RzZ0XXoUuJHiuWr9ew/2VpSw AQWg== 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=/6MiLBWU7tFv7qP7gebKJ8YA49GO8wOln0CYQD4Og44=; b=ONkbp1wVlXS2eOes+MKmU3OVerZgQr6WqM1ku0b+PYhB+QWggUAnAnoHpRuMa8qqvp q7hxe5zFhyQH3G6jvWGY7kPcwLQbJAZmpEz9Z3rYAaC89GeBK7jgRSNsyzK5gPy77V5K 9Uknk5WqCBObeIobg4aHgb3056K18cT0sADjFnzHsij14++Z6ihmnOj9sCvPKHAIBhKg HYQv0gp5npgf+J2huuYMpNnDn3rqOSgVOWnIvCt8vzHohsM9dnkopnkl7kAEyFiMb6Ao NM4jeDewROftRrolL6h1Bic+KMYQba+2da03FW2WHX8AwJusish73rA7Ryzg5J1A8JfA JbWA== X-Gm-Message-State: APf1xPBo9qLNVKF6PLEIEjjbfb+GJDBJ8wXw9jFftVTcLU66QttYqbYM tzH0YfnN9lCAgpL9Bn0BjqGMk7dy X-Google-Smtp-Source: AH8x224BPk8qUNum//bUeWrt/b/NEo6o046HEPhucH4FTr8YXUBt1+diNxa3H6t5m5T/2PNRejVtRg== X-Received: by 10.28.234.200 with SMTP id g69mr272260wmi.137.1517858946502; Mon, 05 Feb 2018 11:29:06 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:15 +0100 Message-Id: <1517858941-5538-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 01/47] memory: update comments and fix some typos 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: Jay Zhou 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: Jay Zhou Signed-off-by: Jay Zhou Message-Id: <1515043788-38300-1-git-send-email-jianjay.zhou@huawei.com> Signed-off-by: Paolo Bonzini --- include/exec/memory.h | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 07c5d6d..67e4ee3 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -324,7 +324,7 @@ FlatView *address_space_to_flatview(AddressSpace *as); * MemoryRegionSection: describes a fragment of a #MemoryRegion * * @mr: the region, or %NULL if empty - * @address_space: the address space the region is mapped in + * @fv: the flat view of the address space the region is mapped in * @offset_within_region: the beginning of the section, relative to @mr's = start * @size: the size of the section; will not exceed @mr's boundaries * @offset_within_address_space: the address of the first byte of the sect= ion @@ -610,6 +610,7 @@ void memory_region_init_rom_nomigrate(MemoryRegion *mr, * @mr: the #MemoryRegion to be initialized. * @owner: the object that tracks the region's reference count * @ops: callbacks for write access handling (must not be NULL). + * @opaque: passed to the read and write callbacks of the @ops structure. * @name: Region name, becomes part of RAMBlock name used in migration str= eam * must be unique within any device * @size: size of the region. @@ -653,11 +654,10 @@ static inline void memory_region_init_reservation(Mem= oryRegion *mr, * An IOMMU region translates addresses and forwards accesses to a target * memory region. * - * @typename: QOM class name * @_iommu_mr: the #IOMMUMemoryRegion to be initialized * @instance_size: the IOMMUMemoryRegion subclass instance size + * @mrtypename: the type name of the #IOMMUMemoryRegion * @owner: the object that tracks the region's reference count - * @ops: a function that translates addresses into the @target region * @name: used for debugging; not visible to the user or ABI * @size: size of the region. */ @@ -827,8 +827,8 @@ static inline IOMMUMemoryRegion *memory_region_get_iomm= u(MemoryRegion *mr) * memory_region_get_iommu_class_nocheck: returns iommu memory region class * if an iommu or NULL if not * - * Returns pointer to IOMMUMemoryRegioniClass if a memory region is an iom= mu, - * otherwise NULL. This is fast path avoinding QOM checking, use with caut= ion. + * Returns pointer to IOMMUMemoryRegionClass if a memory region is an iomm= u, + * otherwise NULL. This is fast path avoiding QOM checking, use with cauti= on. * * @mr: the memory region being queried */ @@ -993,7 +993,8 @@ int memory_region_get_fd(MemoryRegion *mr); * protecting the pointer, such as a reference to the region that includes * the incoming ram_addr_t. * - * @mr: the memory region being queried. + * @ptr: the host pointer to be converted + * @offset: the offset within memory region */ MemoryRegion *memory_region_from_host(void *ptr, ram_addr_t *offset); =20 @@ -1270,7 +1271,7 @@ void memory_region_clear_global_locking(MemoryRegion = *mr); * @size: the size of the access to trigger the eventfd * @match_data: whether to match against @data, instead of just @addr * @data: the data to match against the guest write - * @fd: the eventfd to be triggered when @addr, @size, and @data all match. + * @e: event notifier to be triggered when @addr, @size, and @data all mat= ch. **/ void memory_region_add_eventfd(MemoryRegion *mr, hwaddr addr, @@ -1290,7 +1291,7 @@ void memory_region_add_eventfd(MemoryRegion *mr, * @size: the size of the access to trigger the eventfd * @match_data: whether to match against @data, instead of just @addr * @data: the data to match against the guest write - * @fd: the eventfd to be triggered when @addr, @size, and @data all match. + * @e: event notifier to be triggered when @addr, @size, and @data all mat= ch. */ void memory_region_del_eventfd(MemoryRegion *mr, hwaddr addr, @@ -1526,7 +1527,7 @@ bool memory_region_request_mmio_ptr(MemoryRegion *mr,= hwaddr addr); * will need to request the pointer again. * * @mr: #MemoryRegion associated to the pointer. - * @addr: address within that region + * @offset: offset within the memory region * @size: size of that area. */ void memory_region_invalidate_mmio_ptr(MemoryRegion *mr, hwaddr offset, @@ -1595,6 +1596,7 @@ void address_space_destroy(AddressSpace *as); * @addr: address within that address space * @attrs: memory transaction attributes * @buf: buffer with the data transferred + * @len: the number of bytes to read or write * @is_write: indicates the transfer direction */ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, @@ -1612,6 +1614,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr= addr, * @addr: address within that address space * @attrs: memory transaction attributes * @buf: buffer with the data transferred + * @len: the number of bytes to write */ MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, @@ -1810,7 +1813,7 @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSp= ace *as, hwaddr addr, * called from an RCU critical section, to avoid that the last reference * to the returned region disappears after address_space_translate returns. * - * @as: #AddressSpace to be accessed + * @fv: #FlatView to be accessed * @addr: address within that address space * @xlat: pointer to address within the returned memory region section's * #MemoryRegion. @@ -1868,7 +1871,7 @@ void *address_space_map(AddressSpace *as, hwaddr addr, * the amount of memory that was actually read or written by the caller. * * @as: #AddressSpace used - * @addr: address within that address space + * @buffer: host pointer as returned by address_space_map() * @len: buffer length as returned by address_space_map() * @access_len: amount of data actually transferred * @is_write: indicates the transfer direction @@ -1905,7 +1908,7 @@ static inline bool memory_access_is_direct(MemoryRegi= on *mr, bool is_write) * or failed (eg unassigned memory, device rejected the transaction, * IOMMU fault). * - * @as: #AddressSpace to be accessed + * @fv: #FlatView to be accessed * @addr: address within that address space * @attrs: memory transaction attributes * @buf: buffer with the data transferred --=20 1.8.3.1 From nobody Tue Apr 30 08:57:31 2024 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 1517859097837954.609309881337; Mon, 5 Feb 2018 11:31:37 -0800 (PST) Received: from localhost ([::1]:54760 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimUF-0005mO-RU for importer@patchew.org; Mon, 05 Feb 2018 14:31:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimRy-00049v-JM for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimRx-0004qW-DR for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:10 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:50511) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimRx-0004pw-5k for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:09 -0500 Received: by mail-wm0-x244.google.com with SMTP id f71so28282268wmf.0 for ; Mon, 05 Feb 2018 11:29:09 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:06 -0800 (PST) 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=r+QLzjPswmAuctyIET/AfMhbiI36fUMUhvchhJzj40E=; b=Yw9dlEIGtLY1csvsGnylxRdyKR5ailabkKqCQ9V01rWHwdbPWtEB8oFHOpASrYDnm2 0487gHJdGSiZOGLJExyCj7jAfx2SBTRwUnQkoWCbk4iXKWm6YGpMpFbBCdXrpq08BR0D OtMogLS9dNz99OLjONShlNJFNoEcPWJoSi7k/yH3KquWOA58GmGFqy9cU20lXztq7O/B Jp4iRWi/bTk4OOL8pv0joBokNGvrLksB/W80uIKJxvH2XnZFw9qiS4xqD3OuVak1SYlP eE4Sf5f0/z1wW3/4qMamSxT17XYx0nSs/jy0WdzmAGEtMZXfY5gFFogstdAOMxBcCXcK LisA== 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=r+QLzjPswmAuctyIET/AfMhbiI36fUMUhvchhJzj40E=; b=NF00uP/FCecfpZf9nBXYjzjit46Lxpg8mFLeyg89pYcw6a2JaHfmdHYuPaxgRfTkvn 9eFXPXrZDoyndFDQdsk6dJUtj8nG9P8RIZiFO6tW6qQnQysXLaqKhfUB/iSG90JwxBqk PKA93pQRUhjjl3jyG/tSOqYpuPKClVsd+ZPSkwMbQXl0YvqDcj76ptvJS7r42R2NjNdK xOcxCliLRJXt7IBKrW2G57KFlmOrGTKonp9gXmouG+ZCpritJCs/TJY4Qr74lSIB4zQO Gf25doO2SyJsnVjXlGuxiyxHBRMs+dZIUAeZkOPX6q4q/WihhVwubwq8FoK3wT92zpYK kTeQ== X-Gm-Message-State: APf1xPCeqm2uEfqDrneMNhbdpZOuAuYuIMi1Z0dtyBpjd7X5vYm+cjh2 htB5OphsHRKMCZLm/kjHZZdCiSib X-Google-Smtp-Source: AH8x224iZiiuDI55YEvKwrdBV+pFpU8oUWkY7hy4ZuZgWOXqW0kI+AaQJXtta9b+ww1Go9OHdjVt0g== X-Received: by 10.28.29.130 with SMTP id d124mr322407wmd.139.1517858947778; Mon, 05 Feb 2018 11:29:07 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:16 +0100 Message-Id: <1517858941-5538-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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:c09::244 Subject: [Qemu-devel] [PULL 02/47] qdev: rename typedef qdev_resetfn() -> DeviceReset() 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: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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: Philippe Mathieu-Daud=C3=A9 following the DeviceRealize and DeviceUnrealize typedefs, this unify a bit the new QOM API. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20180114020412.26160-2-f4bug@amsat.org> Reviewed-by: Laurent Vivier Signed-off-by: Paolo Bonzini --- include/hw/qdev-core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 51473ee..85fa26d 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -32,9 +32,9 @@ typedef enum DeviceCategory { =20 typedef int (*qdev_initfn)(DeviceState *dev); typedef int (*qdev_event)(DeviceState *dev); -typedef void (*qdev_resetfn)(DeviceState *dev); typedef void (*DeviceRealize)(DeviceState *dev, Error **errp); typedef void (*DeviceUnrealize)(DeviceState *dev, Error **errp); +typedef void (*DeviceReset)(DeviceState *dev); typedef void (*BusRealize)(BusState *bus, Error **errp); typedef void (*BusUnrealize)(BusState *bus, Error **errp); =20 @@ -117,7 +117,7 @@ typedef struct DeviceClass { bool hotpluggable; =20 /* callbacks */ - void (*reset)(DeviceState *dev); + DeviceReset reset; DeviceRealize realize; DeviceUnrealize unrealize; =20 --=20 1.8.3.1 From nobody Tue Apr 30 08:57:31 2024 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 1517859297190953.4379483214947; Mon, 5 Feb 2018 11:34:57 -0800 (PST) Received: from localhost ([::1]:54777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimXU-0000LZ-0I for importer@patchew.org; Mon, 05 Feb 2018 14:34:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimRz-0004Ar-Mt for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimRy-0004rN-Cx for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:11 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:38687) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimRy-0004qe-5N for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:10 -0500 Received: by mail-wm0-x244.google.com with SMTP id 141so27956862wme.3 for ; Mon, 05 Feb 2018 11:29:10 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:08 -0800 (PST) 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=jvPQQYXG7bl2k1dTyE0wfJnklOUeK/4RRnu7NC/O/ZM=; b=tFXJ11cklJsGVwq0+MnrO4Bu0N7ffqrRslPNF1ZPp87lxeS7MRNurPgVBO2D/Vi6nK N/0JwLSd4LVc8Pv33ScHvbLDFKH+9v5c6oGMas7jmEIAYINSfnXoc9RntfuA6YTTI3Xg QFjDn/C3t604WlxOo0Ir4gwqGCxAAstwuhl0HtMeFdnoPIimw3EPYBrQ02V7mpfISQRa dWtfTVIyIaEhHzMGYOrM2mzn5ySeR9GHTZnV0ETizGa5KjFt09+rN055/ziIgQLrLSU1 FyD8rTyzbPAyWfPi00s1bv13c+4kpKsOY5wzSHMkHL/W5qGeKoF2e+/291uEPhtE83m/ t4zQ== 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=jvPQQYXG7bl2k1dTyE0wfJnklOUeK/4RRnu7NC/O/ZM=; b=QSWaTrQADrkAO8XLM4Mx6zRFnxud6ra823wsT6ah4bq78JhC6LoL0TT9lThCSpCr4d jmg6ipcnYMRUiQ7SiNO+EkH1G305uZBrtz5MZ4R4dOzJEfOEdoML6YV9r7H2kpFYre3T Nfl2Jke/Pvu1QwfmuvYWeo/V5/bgtRbiz4p4QHnl1f6RKn0ZoxsjUC5XrvrFNeey5oeN IRqp0hpB1NboAKEtza1sqeGBEvk1GFHHBvrMBMqhn57HjXo36A3T0vlG0m+3XZLPjpDh fCXicunHQKDQOngQaifAi7ep++cUXleaTQvQp6OZMJIzLJNYGTaaHjy4LhX/2oX5YWr7 0duA== X-Gm-Message-State: APf1xPCLMyv2dbxOZctqxKGO4zG/cYQlSRK7uKlMY8Es0uXQRxyKAMqZ jxfBS5LEA/L273Nqu7DD3BAGyaR2 X-Google-Smtp-Source: AH8x226fy9Vkd9UK1JwNisIuebPKA7Z3mVTD1BzZE3p8AD2KXTe7Wx55w2ZJ7/3qxpPl65EcpIEZNw== X-Received: by 10.28.182.5 with SMTP id g5mr318825wmf.44.1517858948822; Mon, 05 Feb 2018 11:29:08 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:17 +0100 Message-Id: <1517858941-5538-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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:c09::244 Subject: [Qemu-devel] [PULL 03/47] qdev: add helpers to be more explicit when using abstract QOM parent functions 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: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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: Philippe Mathieu-Daud=C3=A9 QOM API learning curve is quite hard, in particular when devices inherit fr= om abstract parent. To be more explicit about when a device class change the parent hooks, add = few helpers hoping a device class_init() will be easier to understand. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20180114020412.26160-3-f4bug@amsat.org> Reviewed-by: Laurent Vivier Signed-off-by: Paolo Bonzini --- hw/core/qdev.c | 24 ++++++++++++++++++++++++ include/hw/qdev-core.h | 10 ++++++++++ 2 files changed, 34 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 2456035..11f8a27 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1075,6 +1075,30 @@ static void device_class_init(ObjectClass *class, vo= id *data) dc->user_creatable =3D true; } =20 +void device_class_set_parent_reset(DeviceClass *dc, + DeviceReset dev_reset, + DeviceReset *parent_reset) +{ + *parent_reset =3D dc->reset; + dc->reset =3D dev_reset; +} + +void device_class_set_parent_realize(DeviceClass *dc, + DeviceRealize dev_realize, + DeviceRealize *parent_realize) +{ + *parent_realize =3D dc->realize; + dc->realize =3D dev_realize; +} + +void device_class_set_parent_unrealize(DeviceClass *dc, + DeviceUnrealize dev_unrealize, + DeviceUnrealize *parent_unrealize) +{ + *parent_unrealize =3D dc->unrealize; + dc->unrealize =3D dev_unrealize; +} + void device_reset(DeviceState *dev) { DeviceClass *klass =3D DEVICE_GET_CLASS(dev); diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 85fa26d..18c0251 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -382,6 +382,16 @@ void qdev_machine_init(void); */ void device_reset(DeviceState *dev); =20 +void device_class_set_parent_reset(DeviceClass *dc, + DeviceReset dev_reset, + DeviceReset *parent_reset); +void device_class_set_parent_realize(DeviceClass *dc, + DeviceRealize dev_realize, + DeviceRealize *parent_realize); +void device_class_set_parent_unrealize(DeviceClass *dc, + DeviceUnrealize dev_unrealize, + DeviceUnrealize *parent_unrealize); + const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev); =20 const char *qdev_fw_name(DeviceState *dev); --=20 1.8.3.1 From nobody Tue Apr 30 08:57:31 2024 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 1517859111286447.65035874561784; Mon, 5 Feb 2018 11:31:51 -0800 (PST) Received: from localhost ([::1]:54762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimUY-0005yz-Bm for importer@patchew.org; Mon, 05 Feb 2018 14:31:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimS3-0004F2-KU for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimS0-0004sL-GU for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:15 -0500 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:51267) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimS0-0004rq-3p for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:12 -0500 Received: by mail-wm0-x230.google.com with SMTP id r71so28443193wmd.1 for ; Mon, 05 Feb 2018 11:29:12 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:09 -0800 (PST) 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=La/13hWpITRlUZzDfm/V/9BKqjnBV04HLGWAaO04tlo=; b=plpaXNqSKHRggOLNk3OdU2j8a+rmHYx31YLs1OcDCsdazz8vNd0ri2M45Nwuv0D9xO 26Jb2RHQxaO9zXJo4eWmFYuDNmeX0sddzvJadA6t0iXhIuuZ4VIrGAdsmjoK8+HEyE2L sKfr7gP4BI45H2rIPPORR19hUaweLm+VG0IeRvm4uvDdWR0UMiSbfY8xkUrsbi/6auBC 2H0HvgUbV79hJ/1Ks9sexkEF0YO67xbyMxw88DECX/RBDuws39AR9aRrhMcqHrCyOPeT JVjfX5rGQ/dwyvy+p18k9Pe1peE5KFF6FPcSqUP03ZaUeKEChWJScMv2rHZ3IReADU0+ jV9w== 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=La/13hWpITRlUZzDfm/V/9BKqjnBV04HLGWAaO04tlo=; b=Dm3mooYwAfosOPj4Wg6aQ4IoBz8SnqKWgw6bRrQtGEduhUtcL4HSMoikgSKC7pND8c syM9dNPFRqajYb8Tu1Fqm1M6N9BHTk4PfcJQxIXqZDK4478vq0irqSqC/wThV21w4ro0 NIhCb1SZG6y2vBwX7gZA9OUGAWuq3aGwTVp43yyXkcI2FbF4wvTV9bGSIw9uTbzod93T q8tOEBrPu7DuUbyQdz2skv0gh82ufEqyxf7YW/h1jcp3oCzOJ2ZxdbXOeA36zl18WMhB vO6GcUMEcg0Ce6Qe0wBlEkP/ippqVObOutH5bXY0Asw6riz97ulA0srj1FpWRqOvFbjA O7jQ== X-Gm-Message-State: APf1xPBTphhdCKyDlGh5iCuLV8Yf4KpunJqLewF5nITKDyxE5zC+3+M5 BHAliSX0Nyjoxy4mg4QqCVY57U8w X-Google-Smtp-Source: AH8x227ihbC/95IMEPfqHNrMwfD59A3G+oUp+uRy22zIsVdJFBFduxIGzHlFxqC5BjU4rt2P4bC+ow== X-Received: by 10.28.54.26 with SMTP id d26mr284287wma.59.1517858950324; Mon, 05 Feb 2018 11:29:10 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:18 +0100 Message-Id: <1517858941-5538-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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:c09::230 Subject: [Qemu-devel] [PULL 04/47] qdev: use device_class_set_parent_realize/unrealize/reset() 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: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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: Philippe Mathieu-Daud=C3=A9 changes generated using the following Coccinelle patch: @@ type DeviceParentClass; DeviceParentClass *pc; DeviceClass *dc; identifier parent_fn; identifier child_fn; @@ ( +device_class_set_parent_realize(dc, child_fn, &pc->parent_fn); -pc->parent_fn =3D dc->realize; ... -dc->realize =3D child_fn; | +device_class_set_parent_unrealize(dc, child_fn, &pc->parent_fn); -pc->parent_fn =3D dc->unrealize; ... -dc->unrealize =3D child_fn; | +device_class_set_parent_reset(dc, child_fn, &pc->parent_fn); -pc->parent_fn =3D dc->reset; ... -dc->reset =3D child_fn; ) Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20180114020412.26160-4-f4bug@amsat.org> Reviewed-by: Marcel Apfelbaum Acked-by: David Gibson Acked-by: Cornelia Huck Reviewed-by: Laurent Vivier Signed-off-by: Paolo Bonzini --- hw/i386/kvm/i8254.c | 4 ++-- hw/i386/kvm/i8259.c | 3 +-- hw/input/adb-kbd.c | 4 ++-- hw/input/adb-mouse.c | 4 ++-- hw/intc/arm_gic.c | 3 +-- hw/intc/arm_gic_kvm.c | 7 +++---- hw/intc/arm_gicv3.c | 3 +-- hw/intc/arm_gicv3_its_kvm.c | 3 +-- hw/intc/arm_gicv3_kvm.c | 7 +++---- hw/intc/i8259.c | 3 +-- hw/net/vmxnet3.c | 4 ++-- hw/pci-bridge/gen_pcie_root_port.c | 3 +-- hw/scsi/vmw_pvscsi.c | 4 ++-- hw/timer/i8254.c | 3 +-- hw/vfio/amd-xgbe.c | 4 ++-- hw/vfio/calxeda-xgmac.c | 4 ++-- hw/virtio/virtio-pci.c | 4 ++-- target/alpha/cpu.c | 4 ++-- target/arm/cpu.c | 4 ++-- target/cris/cpu.c | 4 ++-- target/hppa/cpu.c | 4 ++-- target/i386/cpu.c | 8 ++++---- target/lm32/cpu.c | 5 ++--- target/m68k/cpu.c | 5 ++--- target/microblaze/cpu.c | 5 ++--- target/mips/cpu.c | 5 ++--- target/moxie/cpu.c | 5 ++--- target/nios2/cpu.c | 4 ++-- target/openrisc/cpu.c | 5 ++--- target/ppc/translate_init.c | 8 ++++---- target/s390x/cpu.c | 4 ++-- target/sh4/cpu.c | 4 ++-- target/sparc/cpu.c | 4 ++-- target/tilegx/cpu.c | 4 ++-- target/tricore/cpu.c | 4 ++-- target/unicore32/cpu.c | 4 ++-- target/xtensa/cpu.c | 4 ++-- 37 files changed, 73 insertions(+), 88 deletions(-) diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c index 521a584..13f20f4 100644 --- a/hw/i386/kvm/i8254.c +++ b/hw/i386/kvm/i8254.c @@ -315,8 +315,8 @@ static void kvm_pit_class_init(ObjectClass *klass, void= *data) PITCommonClass *k =3D PIT_COMMON_CLASS(klass); DeviceClass *dc =3D DEVICE_CLASS(klass); =20 - kpc->parent_realize =3D dc->realize; - dc->realize =3D kvm_pit_realizefn; + device_class_set_parent_realize(dc, kvm_pit_realizefn, + &kpc->parent_realize); k->set_channel_gate =3D kvm_pit_set_gate; k->get_channel_info =3D kvm_pit_get_channel_info; dc->reset =3D kvm_pit_reset; diff --git a/hw/i386/kvm/i8259.c b/hw/i386/kvm/i8259.c index b91e980..05394cd 100644 --- a/hw/i386/kvm/i8259.c +++ b/hw/i386/kvm/i8259.c @@ -142,8 +142,7 @@ static void kvm_i8259_class_init(ObjectClass *klass, vo= id *data) DeviceClass *dc =3D DEVICE_CLASS(klass); =20 dc->reset =3D kvm_pic_reset; - kpc->parent_realize =3D dc->realize; - dc->realize =3D kvm_pic_realize; + device_class_set_parent_realize(dc, kvm_pic_realize, &kpc->parent_real= ize); k->pre_save =3D kvm_pic_get; k->post_load =3D kvm_pic_put; } diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c index 354f56e..266aed1 100644 --- a/hw/input/adb-kbd.c +++ b/hw/input/adb-kbd.c @@ -374,8 +374,8 @@ static void adb_kbd_class_init(ObjectClass *oc, void *d= ata) ADBDeviceClass *adc =3D ADB_DEVICE_CLASS(oc); ADBKeyboardClass *akc =3D ADB_KEYBOARD_CLASS(oc); =20 - akc->parent_realize =3D dc->realize; - dc->realize =3D adb_kbd_realizefn; + device_class_set_parent_realize(dc, adb_kbd_realizefn, + &akc->parent_realize); set_bit(DEVICE_CATEGORY_INPUT, dc->categories); =20 adc->devreq =3D adb_kbd_request; diff --git a/hw/input/adb-mouse.c b/hw/input/adb-mouse.c index c900423..47e88fa 100644 --- a/hw/input/adb-mouse.c +++ b/hw/input/adb-mouse.c @@ -228,8 +228,8 @@ static void adb_mouse_class_init(ObjectClass *oc, void = *data) ADBDeviceClass *adc =3D ADB_DEVICE_CLASS(oc); ADBMouseClass *amc =3D ADB_MOUSE_CLASS(oc); =20 - amc->parent_realize =3D dc->realize; - dc->realize =3D adb_mouse_realizefn; + device_class_set_parent_realize(dc, adb_mouse_realizefn, + &amc->parent_realize); set_bit(DEVICE_CATEGORY_INPUT, dc->categories); =20 adc->devreq =3D adb_mouse_request; diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 724bc9f..ea0323f 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -1461,8 +1461,7 @@ static void arm_gic_class_init(ObjectClass *klass, vo= id *data) DeviceClass *dc =3D DEVICE_CLASS(klass); ARMGICClass *agc =3D ARM_GIC_CLASS(klass); =20 - agc->parent_realize =3D dc->realize; - dc->realize =3D arm_gic_realize; + device_class_set_parent_realize(dc, arm_gic_realize, &agc->parent_real= ize); } =20 static const TypeInfo arm_gic_info =3D { diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c index ae095d0..6f467e6 100644 --- a/hw/intc/arm_gic_kvm.c +++ b/hw/intc/arm_gic_kvm.c @@ -591,10 +591,9 @@ static void kvm_arm_gic_class_init(ObjectClass *klass,= void *data) =20 agcc->pre_save =3D kvm_arm_gic_get; agcc->post_load =3D kvm_arm_gic_put; - kgc->parent_realize =3D dc->realize; - kgc->parent_reset =3D dc->reset; - dc->realize =3D kvm_arm_gic_realize; - dc->reset =3D kvm_arm_gic_reset; + device_class_set_parent_realize(dc, kvm_arm_gic_realize, + &kgc->parent_realize); + device_class_set_parent_reset(dc, kvm_arm_gic_reset, &kgc->parent_rese= t); } =20 static const TypeInfo kvm_arm_gic_info =3D { diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c index f0c967b..479c667 100644 --- a/hw/intc/arm_gicv3.c +++ b/hw/intc/arm_gicv3.c @@ -385,8 +385,7 @@ static void arm_gicv3_class_init(ObjectClass *klass, vo= id *data) ARMGICv3Class *agc =3D ARM_GICV3_CLASS(klass); =20 agcc->post_load =3D arm_gicv3_post_load; - agc->parent_realize =3D dc->realize; - dc->realize =3D arm_gic_realize; + device_class_set_parent_realize(dc, arm_gic_realize, &agc->parent_real= ize); } =20 static const TypeInfo arm_gicv3_info =3D { diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c index bf290b8..eea6a73 100644 --- a/hw/intc/arm_gicv3_its_kvm.c +++ b/hw/intc/arm_gicv3_its_kvm.c @@ -245,11 +245,10 @@ static void kvm_arm_its_class_init(ObjectClass *klass= , void *data) =20 dc->realize =3D kvm_arm_its_realize; dc->props =3D kvm_arm_its_props; - ic->parent_reset =3D dc->reset; + device_class_set_parent_reset(dc, kvm_arm_its_reset, &ic->parent_reset= ); icc->send_msi =3D kvm_its_send_msi; icc->pre_save =3D kvm_arm_its_pre_save; icc->post_load =3D kvm_arm_its_post_load; - dc->reset =3D kvm_arm_its_reset; } =20 static const TypeInfo kvm_arm_its_info =3D { diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 481fe54..ec37177 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -795,10 +795,9 @@ static void kvm_arm_gicv3_class_init(ObjectClass *klas= s, void *data) =20 agcc->pre_save =3D kvm_arm_gicv3_get; agcc->post_load =3D kvm_arm_gicv3_put; - kgc->parent_realize =3D dc->realize; - kgc->parent_reset =3D dc->reset; - dc->realize =3D kvm_arm_gicv3_realize; - dc->reset =3D kvm_arm_gicv3_reset; + device_class_set_parent_realize(dc, kvm_arm_gicv3_realize, + &kgc->parent_realize); + device_class_set_parent_reset(dc, kvm_arm_gicv3_reset, &kgc->parent_re= set); } =20 static const TypeInfo kvm_arm_gicv3_info =3D { diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c index 1602255..76f3d87 100644 --- a/hw/intc/i8259.c +++ b/hw/intc/i8259.c @@ -443,8 +443,7 @@ static void i8259_class_init(ObjectClass *klass, void *= data) PICClass *k =3D PIC_CLASS(klass); DeviceClass *dc =3D DEVICE_CLASS(klass); =20 - k->parent_realize =3D dc->realize; - dc->realize =3D pic_realize; + device_class_set_parent_realize(dc, pic_realize, &k->parent_realize); dc->reset =3D pic_reset; } =20 diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 0654d59..3648630 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -2664,8 +2664,8 @@ static void vmxnet3_class_init(ObjectClass *class, vo= id *data) c->class_id =3D PCI_CLASS_NETWORK_ETHERNET; c->subsystem_vendor_id =3D PCI_VENDOR_ID_VMWARE; c->subsystem_id =3D PCI_DEVICE_ID_VMWARE_VMXNET3; - vc->parent_dc_realize =3D dc->realize; - dc->realize =3D vmxnet3_realize; + device_class_set_parent_realize(dc, vmxnet3_realize, + &vc->parent_dc_realize); dc->desc =3D "VMWare Paravirtualized Ethernet v3"; dc->reset =3D vmxnet3_qdev_reset; dc->vmsd =3D &vmstate_vmxnet3; diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_ro= ot_port.c index 0e2f2e8..3dbacc6 100644 --- a/hw/pci-bridge/gen_pcie_root_port.c +++ b/hw/pci-bridge/gen_pcie_root_port.c @@ -137,8 +137,7 @@ static void gen_rp_dev_class_init(ObjectClass *klass, v= oid *data) dc->vmsd =3D &vmstate_rp_dev; dc->props =3D gen_rp_props; =20 - rpc->parent_realize =3D dc->realize; - dc->realize =3D gen_rp_realize; + device_class_set_parent_realize(dc, gen_rp_realize, &rpc->parent_reali= ze); =20 rpc->aer_vector =3D gen_rp_aer_vector; rpc->interrupts_init =3D gen_rp_interrupts_init; diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c index 27749c0..a3a019e 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -1284,8 +1284,8 @@ static void pvscsi_class_init(ObjectClass *klass, voi= d *data) k->device_id =3D PCI_DEVICE_ID_VMWARE_PVSCSI; k->class_id =3D PCI_CLASS_STORAGE_SCSI; k->subsystem_id =3D 0x1000; - pvs_k->parent_dc_realize =3D dc->realize; - dc->realize =3D pvscsi_realize; + device_class_set_parent_realize(dc, pvscsi_realize, + &pvs_k->parent_dc_realize); dc->reset =3D pvscsi_reset; dc->vmsd =3D &vmstate_pvscsi; dc->props =3D pvscsi_properties; diff --git a/hw/timer/i8254.c b/hw/timer/i8254.c index dbc4a0b..1057850 100644 --- a/hw/timer/i8254.c +++ b/hw/timer/i8254.c @@ -358,8 +358,7 @@ static void pit_class_initfn(ObjectClass *klass, void *= data) PITCommonClass *k =3D PIT_COMMON_CLASS(klass); DeviceClass *dc =3D DEVICE_CLASS(klass); =20 - pc->parent_realize =3D dc->realize; - dc->realize =3D pit_realizefn; + device_class_set_parent_realize(dc, pit_realizefn, &pc->parent_realize= ); k->set_channel_gate =3D pit_set_channel_gate; k->get_channel_info =3D pit_get_channel_info_common; k->post_load =3D pit_post_load; diff --git a/hw/vfio/amd-xgbe.c b/hw/vfio/amd-xgbe.c index fab196c..0c4ec4b 100644 --- a/hw/vfio/amd-xgbe.c +++ b/hw/vfio/amd-xgbe.c @@ -34,8 +34,8 @@ static void vfio_amd_xgbe_class_init(ObjectClass *klass, = void *data) DeviceClass *dc =3D DEVICE_CLASS(klass); VFIOAmdXgbeDeviceClass *vcxc =3D VFIO_AMD_XGBE_DEVICE_CLASS(klass); - vcxc->parent_realize =3D dc->realize; - dc->realize =3D amd_xgbe_realize; + device_class_set_parent_realize(dc, amd_xgbe_realize, + &vcxc->parent_realize); dc->desc =3D "VFIO AMD XGBE"; dc->vmsd =3D &vfio_platform_amd_xgbe_vmstate; /* Supported by TYPE_VIRT_MACHINE */ diff --git a/hw/vfio/calxeda-xgmac.c b/hw/vfio/calxeda-xgmac.c index 7bb17af..24cee6d 100644 --- a/hw/vfio/calxeda-xgmac.c +++ b/hw/vfio/calxeda-xgmac.c @@ -34,8 +34,8 @@ static void vfio_calxeda_xgmac_class_init(ObjectClass *kl= ass, void *data) DeviceClass *dc =3D DEVICE_CLASS(klass); VFIOCalxedaXgmacDeviceClass *vcxc =3D VFIO_CALXEDA_XGMAC_DEVICE_CLASS(klass); - vcxc->parent_realize =3D dc->realize; - dc->realize =3D calxeda_xgmac_realize; + device_class_set_parent_realize(dc, calxeda_xgmac_realize, + &vcxc->parent_realize); dc->desc =3D "VFIO Calxeda XGMAC"; dc->vmsd =3D &vfio_platform_calxeda_xgmac_vmstate; /* Supported by TYPE_VIRT_MACHINE */ diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 9ae10f0..c20537f 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1907,8 +1907,8 @@ static void virtio_pci_class_init(ObjectClass *klass,= void *data) k->vendor_id =3D PCI_VENDOR_ID_REDHAT_QUMRANET; k->revision =3D VIRTIO_PCI_ABI_VERSION; k->class_id =3D PCI_CLASS_OTHERS; - vpciklass->parent_dc_realize =3D dc->realize; - dc->realize =3D virtio_pci_dc_realize; + device_class_set_parent_realize(dc, virtio_pci_dc_realize, + &vpciklass->parent_dc_realize); dc->reset =3D virtio_pci_reset; } =20 diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 7d6366b..55675ce 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -233,8 +233,8 @@ static void alpha_cpu_class_init(ObjectClass *oc, void = *data) CPUClass *cc =3D CPU_CLASS(oc); AlphaCPUClass *acc =3D ALPHA_CPU_CLASS(oc); =20 - acc->parent_realize =3D dc->realize; - dc->realize =3D alpha_cpu_realizefn; + device_class_set_parent_realize(dc, alpha_cpu_realizefn, + &acc->parent_realize); =20 cc->class_by_name =3D alpha_cpu_class_by_name; cc->has_work =3D alpha_cpu_has_work; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 9da6ea5..89ccdea 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1722,8 +1722,8 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) CPUClass *cc =3D CPU_CLASS(acc); DeviceClass *dc =3D DEVICE_CLASS(oc); =20 - acc->parent_realize =3D dc->realize; - dc->realize =3D arm_cpu_realizefn; + device_class_set_parent_realize(dc, arm_cpu_realizefn, + &acc->parent_realize); dc->props =3D arm_cpu_properties; =20 acc->parent_reset =3D cc->reset; diff --git a/target/cris/cpu.c b/target/cris/cpu.c index 949c7a6..db8d088 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -260,8 +260,8 @@ static void cris_cpu_class_init(ObjectClass *oc, void *= data) CPUClass *cc =3D CPU_CLASS(oc); CRISCPUClass *ccc =3D CRIS_CPU_CLASS(oc); =20 - ccc->parent_realize =3D dc->realize; - dc->realize =3D cris_cpu_realizefn; + device_class_set_parent_realize(dc, cris_cpu_realizefn, + &ccc->parent_realize); =20 ccc->parent_reset =3D cc->reset; cc->reset =3D cris_cpu_reset; diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 5213347..7b635cc 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -168,8 +168,8 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *= data) CPUClass *cc =3D CPU_CLASS(oc); HPPACPUClass *acc =3D HPPA_CPU_CLASS(oc); =20 - acc->parent_realize =3D dc->realize; - dc->realize =3D hppa_cpu_realizefn; + device_class_set_parent_realize(dc, hppa_cpu_realizefn, + &acc->parent_realize); =20 cc->class_by_name =3D hppa_cpu_class_by_name; cc->has_work =3D hppa_cpu_has_work; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a49d222..d70954b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4705,10 +4705,10 @@ static void x86_cpu_common_class_init(ObjectClass *= oc, void *data) CPUClass *cc =3D CPU_CLASS(oc); DeviceClass *dc =3D DEVICE_CLASS(oc); =20 - xcc->parent_realize =3D dc->realize; - xcc->parent_unrealize =3D dc->unrealize; - dc->realize =3D x86_cpu_realizefn; - dc->unrealize =3D x86_cpu_unrealizefn; + device_class_set_parent_realize(dc, x86_cpu_realizefn, + &xcc->parent_realize); + device_class_set_parent_unrealize(dc, x86_cpu_unrealizefn, + &xcc->parent_unrealize); dc->props =3D x86_cpu_properties; =20 xcc->parent_reset =3D cc->reset; diff --git a/target/lm32/cpu.c b/target/lm32/cpu.c index 6f5c147..96c2499 100644 --- a/target/lm32/cpu.c +++ b/target/lm32/cpu.c @@ -236,9 +236,8 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *= data) CPUClass *cc =3D CPU_CLASS(oc); DeviceClass *dc =3D DEVICE_CLASS(oc); =20 - lcc->parent_realize =3D dc->realize; - dc->realize =3D lm32_cpu_realizefn; - + device_class_set_parent_realize(dc, lm32_cpu_realizefn, + &lcc->parent_realize); lcc->parent_reset =3D cc->reset; cc->reset =3D lm32_cpu_reset; =20 diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 98919b3..6a80be0 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -255,9 +255,8 @@ static void m68k_cpu_class_init(ObjectClass *c, void *d= ata) CPUClass *cc =3D CPU_CLASS(c); DeviceClass *dc =3D DEVICE_CLASS(c); =20 - mcc->parent_realize =3D dc->realize; - dc->realize =3D m68k_cpu_realizefn; - + device_class_set_parent_realize(dc, m68k_cpu_realizefn, + &mcc->parent_realize); mcc->parent_reset =3D cc->reset; cc->reset =3D m68k_cpu_reset; =20 diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 5700652..d8df2fb 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -258,9 +258,8 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) CPUClass *cc =3D CPU_CLASS(oc); MicroBlazeCPUClass *mcc =3D MICROBLAZE_CPU_CLASS(oc); =20 - mcc->parent_realize =3D dc->realize; - dc->realize =3D mb_cpu_realizefn; - + device_class_set_parent_realize(dc, mb_cpu_realizefn, + &mcc->parent_realize); mcc->parent_reset =3D cc->reset; cc->reset =3D mb_cpu_reset; =20 diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 069f935..497706b 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -174,9 +174,8 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) CPUClass *cc =3D CPU_CLASS(c); DeviceClass *dc =3D DEVICE_CLASS(c); =20 - mcc->parent_realize =3D dc->realize; - dc->realize =3D mips_cpu_realizefn; - + device_class_set_parent_realize(dc, mips_cpu_realizefn, + &mcc->parent_realize); mcc->parent_reset =3D cc->reset; cc->reset =3D mips_cpu_reset; =20 diff --git a/target/moxie/cpu.c b/target/moxie/cpu.c index f1389e5..4170284 100644 --- a/target/moxie/cpu.c +++ b/target/moxie/cpu.c @@ -102,9 +102,8 @@ static void moxie_cpu_class_init(ObjectClass *oc, void = *data) CPUClass *cc =3D CPU_CLASS(oc); MoxieCPUClass *mcc =3D MOXIE_CPU_CLASS(oc); =20 - mcc->parent_realize =3D dc->realize; - dc->realize =3D moxie_cpu_realizefn; - + device_class_set_parent_realize(dc, moxie_cpu_realizefn, + &mcc->parent_realize); mcc->parent_reset =3D cc->reset; cc->reset =3D moxie_cpu_reset; =20 diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 4742e52..fbfaa2c 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -187,8 +187,8 @@ static void nios2_cpu_class_init(ObjectClass *oc, void = *data) CPUClass *cc =3D CPU_CLASS(oc); Nios2CPUClass *ncc =3D NIOS2_CPU_CLASS(oc); =20 - ncc->parent_realize =3D dc->realize; - dc->realize =3D nios2_cpu_realizefn; + device_class_set_parent_realize(dc, nios2_cpu_realizefn, + &ncc->parent_realize); dc->props =3D nios2_properties; ncc->parent_reset =3D cc->reset; cc->reset =3D nios2_cpu_reset; diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index e0394b8b0..20b115a 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -132,9 +132,8 @@ static void openrisc_cpu_class_init(ObjectClass *oc, vo= id *data) CPUClass *cc =3D CPU_CLASS(occ); DeviceClass *dc =3D DEVICE_CLASS(oc); =20 - occ->parent_realize =3D dc->realize; - dc->realize =3D openrisc_cpu_realizefn; - + device_class_set_parent_realize(dc, openrisc_cpu_realizefn, + &occ->parent_realize); occ->parent_reset =3D cc->reset; cc->reset =3D openrisc_cpu_reset; =20 diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 55c99c9..e7b1044 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -10556,12 +10556,12 @@ static void ppc_cpu_class_init(ObjectClass *oc, v= oid *data) CPUClass *cc =3D CPU_CLASS(oc); DeviceClass *dc =3D DEVICE_CLASS(oc); =20 - pcc->parent_realize =3D dc->realize; - pcc->parent_unrealize =3D dc->unrealize; + device_class_set_parent_realize(dc, ppc_cpu_realizefn, + &pcc->parent_realize); + device_class_set_parent_unrealize(dc, ppc_cpu_unrealizefn, + &pcc->parent_unrealize); pcc->pvr_match =3D ppc_pvr_match_default; pcc->interrupts_big_endian =3D ppc_cpu_interrupts_big_endian_always; - dc->realize =3D ppc_cpu_realizefn; - dc->unrealize =3D ppc_cpu_unrealizefn; dc->props =3D ppc_cpu_properties; =20 pcc->parent_reset =3D cc->reset; diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index d2e6b9f..979469d 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -464,8 +464,8 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) CPUClass *cc =3D CPU_CLASS(scc); DeviceClass *dc =3D DEVICE_CLASS(oc); =20 - scc->parent_realize =3D dc->realize; - dc->realize =3D s390_cpu_realizefn; + device_class_set_parent_realize(dc, s390_cpu_realizefn, + &scc->parent_realize); dc->props =3D s390x_cpu_properties; dc->user_creatable =3D true; =20 diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index e0b99fb..e37c187 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -236,8 +236,8 @@ static void superh_cpu_class_init(ObjectClass *oc, void= *data) CPUClass *cc =3D CPU_CLASS(oc); SuperHCPUClass *scc =3D SUPERH_CPU_CLASS(oc); =20 - scc->parent_realize =3D dc->realize; - dc->realize =3D superh_cpu_realizefn; + device_class_set_parent_realize(dc, superh_cpu_realizefn, + &scc->parent_realize); =20 scc->parent_reset =3D cc->reset; cc->reset =3D superh_cpu_reset; diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index c7adc28..ff6ed91 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -858,8 +858,8 @@ static void sparc_cpu_class_init(ObjectClass *oc, void = *data) CPUClass *cc =3D CPU_CLASS(oc); DeviceClass *dc =3D DEVICE_CLASS(oc); =20 - scc->parent_realize =3D dc->realize; - dc->realize =3D sparc_cpu_realizefn; + device_class_set_parent_realize(dc, sparc_cpu_realizefn, + &scc->parent_realize); dc->props =3D sparc_cpu_properties; =20 scc->parent_reset =3D cc->reset; diff --git a/target/tilegx/cpu.c b/target/tilegx/cpu.c index c140b46..b7451bd 100644 --- a/target/tilegx/cpu.c +++ b/target/tilegx/cpu.c @@ -141,8 +141,8 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void= *data) CPUClass *cc =3D CPU_CLASS(oc); TileGXCPUClass *tcc =3D TILEGX_CPU_CLASS(oc); =20 - tcc->parent_realize =3D dc->realize; - dc->realize =3D tilegx_cpu_realizefn; + device_class_set_parent_realize(dc, tilegx_cpu_realizefn, + &tcc->parent_realize); =20 tcc->parent_reset =3D cc->reset; cc->reset =3D tilegx_cpu_reset; diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 179c997..2edaef1 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -153,8 +153,8 @@ static void tricore_cpu_class_init(ObjectClass *c, void= *data) CPUClass *cc =3D CPU_CLASS(c); DeviceClass *dc =3D DEVICE_CLASS(c); =20 - mcc->parent_realize =3D dc->realize; - dc->realize =3D tricore_cpu_realizefn; + device_class_set_parent_realize(dc, tricore_cpu_realizefn, + &mcc->parent_realize); =20 mcc->parent_reset =3D cc->reset; cc->reset =3D tricore_cpu_reset; diff --git a/target/unicore32/cpu.c b/target/unicore32/cpu.c index 17dc150..fb837aa 100644 --- a/target/unicore32/cpu.c +++ b/target/unicore32/cpu.c @@ -132,8 +132,8 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *= data) CPUClass *cc =3D CPU_CLASS(oc); UniCore32CPUClass *ucc =3D UNICORE32_CPU_CLASS(oc); =20 - ucc->parent_realize =3D dc->realize; - dc->realize =3D uc32_cpu_realizefn; + device_class_set_parent_realize(dc, uc32_cpu_realizefn, + &ucc->parent_realize); =20 cc->class_by_name =3D uc32_cpu_class_by_name; cc->has_work =3D uc32_cpu_has_work; diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 1c982a0..4573388 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -151,8 +151,8 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void= *data) CPUClass *cc =3D CPU_CLASS(oc); XtensaCPUClass *xcc =3D XTENSA_CPU_CLASS(cc); =20 - xcc->parent_realize =3D dc->realize; - dc->realize =3D xtensa_cpu_realizefn; + device_class_set_parent_realize(dc, xtensa_cpu_realizefn, + &xcc->parent_realize); =20 xcc->parent_reset =3D cc->reset; cc->reset =3D xtensa_cpu_reset; --=20 1.8.3.1 From nobody Tue Apr 30 08:57:31 2024 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 1517859299211778.5793068725379; Mon, 5 Feb 2018 11:34:59 -0800 (PST) Received: from localhost ([::1]:54779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimXa-0000TU-Cl for importer@patchew.org; Mon, 05 Feb 2018 14:34:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44432) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimS1-0004C2-NY for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimS0-0004sU-RP for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:13 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:40264) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimS0-0004s6-KY for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:12 -0500 Received: by mail-wr0-x241.google.com with SMTP id i56so30827489wra.7 for ; Mon, 05 Feb 2018 11:29:12 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:10 -0800 (PST) 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=Cr7evntZWgskomAFEjmTUN0CD9fknNIEbwXMH5R/Nb8=; b=NSMMMpmNcNW8+/jGCa5F2GMnzd+W7mWdodPJQy0DM7T8GcWMxVMX0Zk/ijzyJdQ7A1 r01zKNcLyFm6z1C6S6ZNCK3BEuL9Aj93p4ULLi7eop+Y7gops03CnPp4JwufGWSeGVkG SgWH30drA7dsgB6tJbI6Oved7FB3RLOeSDNm5BilL2lvoBb8FhQ4Dj4ErkoxmUkAriMQ /4x3Pl3Z68rwL3IgIPesuiMKxX4gf9lYX2gyOfJT6lih6JVXl+xxbj8nnoCDkmgIG7IB 80Hs5u732+zgqIrAiFGp3FmMrztFjQRIAsWt//BkxtwDo0vMG7fiFnLtk2/GOCCw+OmH tEsg== 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=Cr7evntZWgskomAFEjmTUN0CD9fknNIEbwXMH5R/Nb8=; b=dOBsQ48+Ux+H3fo3IbxTRzDLdePLhBVdFWnU07mm1Yw6gWL7YzTMNCasRgHC2m11Qn fqxZ8QRuw5nLXaWXvzbH7tYRIMHbPU+j7LomcobCxicB16YV84k+XlZliPGCED9uOcGB FAPm1lDAsEOrtaH0bChN1wqywD6heb71HHEUAB0leIljW7IxVw2yxLHLyiX3iHX0R3FV Pb9KYEjI8fGkwPQ3iKjlqEhYQw3SwH7JwMEYndP1abE+lQTZe6+hupE1OPiD30drl4w6 issTbk+wy67RnKr5ntMqrPpqXgmtSq1NiMaE8l5NhI2At2iFkQ8IDmxgtip2KRP5Zx9s 1Idg== X-Gm-Message-State: AKwxytc5OaDg7/Du3DR+yS1JagSOq7sSIq28gLDMF6tnpONSIk5ZKE68 +kDuK4D12qT3UY0fT6PKLDLs8+Qs X-Google-Smtp-Source: AH8x226ywx9p67v+p12d2nrcpQVSebbIyf6eGJYK0KyyskGymQ0ZwW5OnlKhwZMZYTYlhRIkRKmcxA== X-Received: by 10.223.177.141 with SMTP id q13mr27084289wra.148.1517858951234; Mon, 05 Feb 2018 11:29:11 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:19 +0100 Message-Id: <1517858941-5538-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 05/47] kvm: Add kvm_set_user_memory tracepoint 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 a tracepoint to trace the KVM_SET_USER_MEMORY_REGION ioctl parameters which is quite useful for debugging VFIO memory regions being actually registered with KVM. Signed-off-by: Alexey Kardashevskiy Message-Id: <20171215052326.21386-1-aik@ozlabs.ru> Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 6 +++++- accel/kvm/trace-events | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index f290f48..b91fcb7 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -235,6 +235,7 @@ static int kvm_set_user_memory_region(KVMMemoryListener= *kml, KVMSlot *slot) { KVMState *s =3D kvm_state; struct kvm_userspace_memory_region mem; + int ret; =20 mem.slot =3D slot->slot | (kml->as_id << 16); mem.guest_phys_addr =3D slot->start_addr; @@ -248,7 +249,10 @@ static int kvm_set_user_memory_region(KVMMemoryListene= r *kml, KVMSlot *slot) kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, &mem); } mem.memory_size =3D slot->memory_size; - return kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, &mem); + ret =3D kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, &mem); + trace_kvm_set_user_memory(mem.slot, mem.flags, mem.guest_phys_addr, + mem.memory_size, mem.userspace_addr, ret); + return ret; } =20 int kvm_destroy_vcpu(CPUState *cpu) diff --git a/accel/kvm/trace-events b/accel/kvm/trace-events index f89ba55..58e98ef 100644 --- a/accel/kvm/trace-events +++ b/accel/kvm/trace-events @@ -12,4 +12,5 @@ kvm_irqchip_commit_routes(void) "" kvm_irqchip_add_msi_route(char *name, int vector, int virq) "dev %s vector= %d virq %d" kvm_irqchip_update_msi_route(int virq) "Updating MSI route virq=3D%d" kvm_irqchip_release_virq(int virq) "virq %d" +kvm_set_user_memory(uint32_t slot, uint32_t flags, uint64_t guest_phys_add= r, uint64_t memory_size, uint64_t userspace_addr, int ret) "Slot#%d flags= =3D0x%x gpa=3D0x%"PRIx64 " size=3D0x%"PRIx64 " ua=3D0x%"PRIx64 " ret=3D%d" =20 --=20 1.8.3.1 From nobody Tue Apr 30 08:57:31 2024 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 1517859481841230.4685776953097; Mon, 5 Feb 2018 11:38:01 -0800 (PST) Received: from localhost ([::1]:54803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimaN-0003XB-HR for importer@patchew.org; Mon, 05 Feb 2018 14:37:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimS2-0004DM-Kn for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimS1-0004sw-Uo for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:14 -0500 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:54129) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimS1-0004sc-O3 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:13 -0500 Received: by mail-wm0-x22d.google.com with SMTP id t74so28413145wme.3 for ; Mon, 05 Feb 2018 11:29:13 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:11 -0800 (PST) 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=i8P/pvQossrmc9/83QDW5deyo4l3SuF2d5BXveP6VJc=; b=Dgk6kDcv2SRt9E9yZmYn4Yn9HkDwR/m3S5Cf3Wk2Obwxk/2JXFa+G3opPJS//6axae lwm7P6/4KKCvzpvQZIX5B7QqPy8Y0O6kbuTCMnE8TLqP6dGAGq5KA8ZhzvqObUQgSO1S DecEgWCqblt00bSQ5KNlnbnIN2txstOjmWvo9YxuDwZ9KuZiO752mIGHnprtAgzn4ZJH 22QhB6u/BmOguQBGCEoWc/hhA5vRPhNGWU9M587Nc2V5BNDz6wZND4rp2rb1QG0thK5I GVIug4V5r9bxWtg3NojuaP+Cc2TpxkRqiO4omq/BX5ywrvuIUW0P115+FuVBrIRGdQ4M coAg== 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=i8P/pvQossrmc9/83QDW5deyo4l3SuF2d5BXveP6VJc=; b=SP/1Hao5AJ6q4FgYgZmUBe5KB1GAdqsrGkBzVgY7mJofsH75T0TLdxWi9e9DsiBVnP tpfMXr33InrbflddBsvsfQbtyYhhP8H6xPHdx15qEhoGgsFLHKzXdgbSb2kESmmgd4vd mEUeCeePhmHF+wBl8hqUCNicB8wmFK5ARj34Aj7Nmgxay76OUKt8uVRgqYjXorXSI5mR n1dwTBd4ZLq7OPDBINQtWzJLwbzYHGjY4tmDjKfUkr6JKz+HPjzjAaAd7Nr0IoCB9Y9a 6GmAVy9gUfQPO3+KKiPV6861mubTR5wqV7I1tVz0/5DEcuxuVOJ1mv2Zf3ltPzLD+sov FzKw== X-Gm-Message-State: APf1xPDeYjV6+XaAUgn1CIb3piGDxV2IaCozgeRSUsiZSSSn1ibqS5H0 4WjE2OCIJ/iRtEWcm/XNWqLN552D X-Google-Smtp-Source: AH8x227oEaiIzYQhphA7G8Lf13icJblNdsCMrenNQtrjYa3mf+IVJ39j0LiJNzBa1R8NcuHPmsTQMQ== X-Received: by 10.28.109.10 with SMTP id i10mr330308wmc.107.1517858952297; Mon, 05 Feb 2018 11:29:12 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:20 +0100 Message-Id: <1517858941-5538-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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::22d Subject: [Qemu-devel] [PULL 06/47] qemu: improve hugepage allocation failure message 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: Marcelo Tosatti 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: Marcelo Tosatti Improve hugepage allocation failure message, indicating what is happening to the user. Signed-off-by: Marcelo Tosatti Message-Id: <20180115201700.GA4439@amt.cnet> Signed-off-by: Paolo Bonzini --- numa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/numa.c b/numa.c index 83675a0..a9528aa 100644 --- a/numa.c +++ b/numa.c @@ -463,6 +463,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion= *mr, Object *owner, if (mem_prealloc) { exit(1); } + error_report("falling back to regular RAM allocation."); =20 /* Legacy behavior: if allocation failed, fall back to * regular RAM allocation. --=20 1.8.3.1 From nobody Tue Apr 30 08:57:31 2024 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 1517859480745917.0240312139127; Mon, 5 Feb 2018 11:38:00 -0800 (PST) Received: from localhost ([::1]:54805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimaV-0003f0-WA for importer@patchew.org; Mon, 05 Feb 2018 14:38:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimS4-0004FY-6U for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimS3-0004tG-06 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:16 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:53751) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimS2-0004t2-Po; Mon, 05 Feb 2018 14:29:14 -0500 Received: by mail-wm0-x244.google.com with SMTP id t74so28413216wme.3; Mon, 05 Feb 2018 11:29:14 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:12 -0800 (PST) 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=rpwexmsWeX/u9PEXyRYUKrXxKEFMSyBL+EPmACu+mNk=; b=WBwixpwEcfq56rBfxXgVkhkLHZCgRBsK2TPZ7uiPaW++xP/BVdlFefQc+yDoqhDP46 cT8gPjpFxZol913RdmYhKfrJDanrcPXMSRKZXFfh9fdj4PMeULQLiQLjnq2H1xePdJB5 HrfycvZrz41nJRC+ZucAx60fWaviwJNtF43Upaz0ZiNs15jz9hgtojVNKhmCv437yjOc nbx8fFMPs8HEYmXvwQG+FGHmxupCbQAKxCyZwyNAxeOJUrLr427ZBMqD1RfxDw4K76VU CApf77SHxhud2InxeiLa3oeCeG45ESlpyMrGRw70MHDl7MTKuL4Y3vyyUEfm7zRyOiqC VFGA== 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=rpwexmsWeX/u9PEXyRYUKrXxKEFMSyBL+EPmACu+mNk=; b=X35/Ypfy0ExhgLXzSYmtSl/WBRPs8CW340VfrSvpydxDReE2r4vEfEevMRlxarSAJT DUaR2fapyQ6ctM3RoyeDApRZNtH84DLLNdLp5EwaApE0jWy5IQtxb9qj8vF+Dh3mHsHc 0jmdeyLhgdLcbvO8YKESzt1hZZ9XzLGgZeE6VV/zpFL1LV/PS+ovieG6S6E8vS2jvGKe apOuAN0lJaDFeXQp30u33U7/ZtB9wbDDjVEGQ65dBLepUOpZH+VIXM+K/guf6IheG+EA soQj8xBZsJr2PAJeSmPX1zIAeMO0GUOjF78NwD/cTrtxx39xrAKbasxpcMjhumHkgekr 6ygA== X-Gm-Message-State: APf1xPBCzzNaLomal010UTdPQwKWbkEV3hAVyAhUB05kPz7HccscG9BA nq1DusoIsyeFQ3I/NMceLZxXgX6v X-Google-Smtp-Source: AH8x227kLnvjuFDU/wUISEUOqSTEYY9ZZsW6fn1AtrJKTIwPsD7CMi2ikdN7ebEUI/B2Tf8QemwN2g== X-Received: by 10.28.214.67 with SMTP id n64mr274860wmg.25.1517858953461; Mon, 05 Feb 2018 11:29:13 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:21 +0100 Message-Id: <1517858941-5538-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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::244 Subject: [Qemu-devel] [PULL 07/47] memory: set ioeventfd_update_pending after address_space_update_ioeventfds 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: linzhecheng , qemu-stable@nongnu.org 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: linzhecheng We should set ioeventfd_update_pending same as memory_region_update_pending. Signed-off-by: linzhecheng Message-Id: <1515934519-16158-1-git-send-email-linzc@zju.edu.cn> Cc: qemu-stable@nongnu.org Fixes: ade9c1aac5292ff698fa550adebe794c37d86cc9 Signed-off-by: Paolo Bonzini --- memory.c | 1 + 1 file changed, 1 insertion(+) diff --git a/memory.c b/memory.c index 449a142..9e83496 100644 --- a/memory.c +++ b/memory.c @@ -1091,6 +1091,7 @@ void memory_region_transaction_commit(void) address_space_update_ioeventfds(as); } memory_region_update_pending =3D false; + ioeventfd_update_pending =3D false; MEMORY_LISTENER_CALL_GLOBAL(commit, Forward); } else if (ioeventfd_update_pending) { QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { --=20 1.8.3.1 From nobody Tue Apr 30 08:57:31 2024 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 1517859309642473.89258236056617; Mon, 5 Feb 2018 11:35:09 -0800 (PST) Received: from localhost ([::1]:54780 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimXk-0000dF-PA for importer@patchew.org; Mon, 05 Feb 2018 14:35:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimS8-0004KK-78 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimS4-0004to-AJ for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:20 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:36855) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimS4-0004tT-2u for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:16 -0500 Received: by mail-wm0-x242.google.com with SMTP id f3so28128817wmc.1 for ; Mon, 05 Feb 2018 11:29:15 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:13 -0800 (PST) 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=TITI2OCRY2Mfon2BC1d9xXnyLOWoGMyhe+5CAN9ypug=; b=nAEd/OVdudDTejj8OhcWjoTaqgHR+/169rGnfjDp7xu032T6ByZLwUFk9FsfTz7nLJ qTqeHyLSOeRh6YPEa1RmfGnKpQOf2044SY0CUsVayFSSrmiQGl8fxAl7vmIqkQEKSXIN 4gd2LinVWZD9FmxDz3/Lb0TdvlSttMTVAAtXqaLwtNZgr4zi5GcYoGus4CH5WKLNdx00 c4Ojf95qBbmBn3LnEMAc6bzd9FIqSvloodF+1WYAo5VEz2rx53BU09P7Lk3vo8zAtTTk RpVjeGybQdOA3TP7L1EyFvDNPioSOdnsr87nBrECj2cxDCFXGnMxYzEToxUM7z81ivMC vQog== 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=TITI2OCRY2Mfon2BC1d9xXnyLOWoGMyhe+5CAN9ypug=; b=SYIpDspLkVUBU2EOCdsfzN96T9T/+au0T5wqO6p+UQtMVubt9oj3HWAq3TCGo4zZLc DeeYol22RCiVJ10nvh8OR3nx7hHDN4+5HBf+GPmVRsTs0kz6deqlNRdUsbqUMuVvjuDk SG61PPGM1GcD2NCc/mBmQVv4SxovdbPDil6VDovV9caxVhRn9OJr6p1htPSI/R78nGYo Grjb4IQLkOjppZc9FlHWJCGPQhnDlOk5IlKreYxeBzACk2rqbR2JxhYZEFKxT6tDUW1Z mIk6ozG+uhaUeWma1KR+YcHqmWPjQMTXqgrkUeDCgzEE9MpKdi/mWbyWQP9VieCThvbV NqMg== X-Gm-Message-State: APf1xPBZcw8mLZNgOJiwXZ2Dy2obVKUn1oa70bw2dptvi5YwqeNSajEH hyiXIWwo9oYd0+JfemHFLOMOlDva X-Google-Smtp-Source: AH8x224PIlADzifFXH0Oo6Red8fmhjfpuRQS/4AZXLDt5GdNr8wirAHl4GNH6AYEQc/Cv47pdH8lLQ== X-Received: by 10.28.167.5 with SMTP id q5mr352862wme.90.1517858954607; Mon, 05 Feb 2018 11:29:14 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:22 +0100 Message-Id: <1517858941-5538-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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:c09::242 Subject: [Qemu-devel] [PULL 08/47] scsi-generic: Simplify error handling code 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: Fam Zheng 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: Fam Zheng Coverity doesn't like the ignored return value introduced in 9d3b155186c278 (hw/block: Fix the return type), and other callers are converted already in ceff3e1f01. This one was added lately in d9bcd6f7f23a and missed the train. Do it now. Signed-off-by: Fam Zheng Message-Id: <20180118025245.13042-1-famz@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-generic.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index ba70c0d..7414fe2 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -482,7 +482,6 @@ static void scsi_generic_realize(SCSIDevice *s, Error *= *errp) int rc; int sg_version; struct sg_scsi_id scsiid; - Error *local_err =3D NULL; =20 if (!s->conf.blk) { error_setg(errp, "drive property not set"); @@ -516,11 +515,9 @@ static void scsi_generic_realize(SCSIDevice *s, Error = **errp) error_setg(errp, "SG_GET_SCSI_ID ioctl failed"); return; } - blkconf_apply_backend_options(&s->conf, - blk_is_read_only(s->conf.blk), - true, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!blkconf_apply_backend_options(&s->conf, + blk_is_read_only(s->conf.blk), + true, errp)) { return; } =20 --=20 1.8.3.1 From nobody Tue Apr 30 08:57:31 2024 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 1517859714254967.3807569027139; Mon, 5 Feb 2018 11:41:54 -0800 (PST) Received: from localhost ([::1]:54831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimeH-0007wn-DJ for importer@patchew.org; Mon, 05 Feb 2018 14:41:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimS8-0004KM-8Z for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimS5-0004u8-Fo for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:20 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:45168) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimS5-0004ty-8N for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:17 -0500 Received: by mail-wr0-x241.google.com with SMTP id h9so17829663wre.12 for ; Mon, 05 Feb 2018 11:29:17 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:15 -0800 (PST) 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=1ShQnaEkab7105rHvBPeWNxPe7p0HME/jk5v8iziPtY=; b=U+09lxng0vJmxSGmmx58C4KMQJ2HWfA9kIlfwxqdRz42KRjQKKbpltKvETp8wuPP7/ dio6pWuHsj7qw1/v/kawUO9aY1Sjp903mSTNTpwqR6N3dd5JTyD7VznHWqYv5eKiv00z RLhr13Z0jRfrUtrEUeQZ0ENguq4jHNhjdy6QiPptcAj5qj9cZar2JrNA2LNX48tlLRVY ZkPod3QvyqdLlLKLoIyvlu1c/dqKjhJwDtNbEbNVywNbI58kEGRU8Vp+nIdw0gYIgCs4 TCGlcXJk7fd7XiuSFAnc5LSEYtUm8CXHoCPmUxZ6sRb6bseKYJacQC8OZ7ri53m78TIs 4s7A== 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=1ShQnaEkab7105rHvBPeWNxPe7p0HME/jk5v8iziPtY=; b=FhDMvpIU+kQt8U+8IJEiLowRI6RXhVmghul7aGWYGa856p2CSDW2eofPyOllLS3Laz 7QcAFne7EFEOw5R3uVX6Xz3A79CAa4BXks9JbknYBYVqjcTGvNFIMqrz88aLV5fYO9AH bOq7qO6qwDVlE8sUpn514YdIGkjuz+CTgKcHmAR8kz3oFo1KdRHgDCZ8s19JtMiV1AQH BoAxzhj4jV12Sw9Xd0qSd2WbunegGfDJHKhFLtVlJVI+ijVxbC/7/Bnsv8xXXTCHVEn7 VFJOjSSx3CFFP2q/SWJ9fEfRQisKOQcmp+QnbusuMbIzdC6QIPdmnseZCHjw6An0lxSv FnCw== X-Gm-Message-State: AKwxytduzc7w9Y4UYWzGmMDAP3ZYsu7XIa3BF1i1KDdX6VAghb3SoHgR fZcdHHMy5zrrvRnZH0JshkUmMN2U X-Google-Smtp-Source: AH8x224J8mYdIvxSmpjkpB32NaX1LlCn9r9wNluIrtf+QNAxRThsiKFXs03ilnjHuw9RbWqXaWFtZg== X-Received: by 10.223.184.213 with SMTP id c21mr36355922wrg.57.1517858955859; Mon, 05 Feb 2018 11:29:15 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:23 +0100 Message-Id: <1517858941-5538-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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::241 Subject: [Qemu-devel] [PULL 09/47] chardev: fix incorrect unref of source 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 From: Peter Xu glib reported error when pty chardev used: $ ./qemu-system-x86_64 -chardev pty,id=3Dfoo -device isa-serial,chardev=3Df= oo qemu-system-x86_64: -chardev pty,id=3Dfoo: char device redirected to /dev/p= ts/2 (label foo) (qemu-system-x86_64:27885): GLib-CRITICAL **: g_source_unref: assertion 'so= urce !=3D NULL' failed (qemu-system-x86_64:27885): GLib-CRITICAL **: g_source_unref: assertion 'so= urce !=3D NULL' failed This patch fixes that. Fixes: 2c716ba150 ("chardev: introduce qemu_chr_timeout_add_ms()") CC: Paolo Bonzini Reported-by: Marc-Andr=C3=83=C2=A9 Lureau Signed-off-by: Peter Xu Message-Id: <20180118052049.31119-1-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- chardev/char-pty.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/chardev/char-pty.c b/chardev/char-pty.c index 89315e6..68fd4e2 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -51,15 +51,32 @@ typedef struct { static void pty_chr_update_read_handler_locked(Chardev *chr); static void pty_chr_state(Chardev *chr, int connected); =20 +static void pty_chr_timer_cancel(PtyChardev *s) +{ + if (s->timer_src) { + g_source_destroy(s->timer_src); + g_source_unref(s->timer_src); + s->timer_src =3D NULL; + } +} + +static void pty_chr_open_src_cancel(PtyChardev *s) +{ + if (s->open_source) { + g_source_destroy(s->open_source); + g_source_unref(s->open_source); + s->open_source =3D NULL; + } +} + static gboolean pty_chr_timer(gpointer opaque) { struct Chardev *chr =3D CHARDEV(opaque); PtyChardev *s =3D PTY_CHARDEV(opaque); =20 qemu_mutex_lock(&chr->chr_write_lock); - s->timer_src =3D NULL; - g_source_unref(s->open_source); - s->open_source =3D NULL; + pty_chr_timer_cancel(s); + pty_chr_open_src_cancel(s); if (!s->connected) { /* Next poll ... */ pty_chr_update_read_handler_locked(chr); @@ -68,15 +85,6 @@ static gboolean pty_chr_timer(gpointer opaque) return FALSE; } =20 -static void pty_chr_timer_cancel(PtyChardev *s) -{ - if (s->timer_src) { - g_source_destroy(s->timer_src); - g_source_unref(s->timer_src); - s->timer_src =3D NULL; - } -} - /* Called with chr_write_lock held. */ static void pty_chr_rearm_timer(Chardev *chr, int ms) { @@ -195,11 +203,7 @@ static void pty_chr_state(Chardev *chr, int connected) PtyChardev *s =3D PTY_CHARDEV(chr); =20 if (!connected) { - if (s->open_source) { - g_source_destroy(s->open_source); - g_source_unref(s->open_source); - s->open_source =3D NULL; - } + pty_chr_open_src_cancel(s); remove_fd_in_watch(chr); s->connected =3D 0; /* (re-)connect poll interval for idle guests: once per second. --=20 1.8.3.1 From nobody Tue Apr 30 08:57:31 2024 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 1517859478587821.6553319806452; Mon, 5 Feb 2018 11:37:58 -0800 (PST) Received: from localhost ([::1]:54804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimaQ-0003Yr-U8 for importer@patchew.org; Mon, 05 Feb 2018 14:37:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimS8-0004KJ-6k for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimS6-0004ud-Je for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:20 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:40437) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimS6-0004uJ-D4 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:18 -0500 Received: by mail-wm0-x242.google.com with SMTP id v123so28068425wmd.5 for ; Mon, 05 Feb 2018 11:29:18 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:16 -0800 (PST) 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=XlkV6N9xu9Upoqu8seXCsK4k/H1VD/V9qi0GW6vkK54=; b=ao9Eu2epmJTZWuvhXqhUcZGhB7D+TbwKZjGcL5Tk0scxwGOWIkvUkegD9ndDLZO4qg QYq3ZXj//ZM4pD+M+hFEvMT3z29EWNZnoXesB3LpLNwArb9tjn/Y+ALj4056uQ+TZYx3 0Hpsqw4TqcMnH9YnXl7TCp8cMd3DeQ4DRVfvn/ByqBesjIIO9/If3sP7/LSGwYwlP2fe mce3gHxy1yu5kPKjIuP6XZDqhAkonJKcyeZ5oOgX41qJVzz0SPb2wtNmzH4LbYRfG6Qt 187nqRM2axhtihYGij5XO185u+Db8WrPd66HSnQgq9vaBW+fm1vxHBpe5Gx2eKgeEpVe YI2A== 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=XlkV6N9xu9Upoqu8seXCsK4k/H1VD/V9qi0GW6vkK54=; b=rZZ5Ag34rKeQAPSrMxdKe7N3XqV9t+aKETCsOd5LXneY7NpAPabYLEgfVr+VSgjJlS YCNBZIHaTikss9P2Vn9DGh8QlOdvpYO9dM06H62JCLwjM1sYypvv40RMbyM3kUy6Idoc miFDrYZJwhj/FumtQZmXLCCNSmHM0wcOyuIoGywBMYZsdw2GZmDzvHmkIzbCV76mwr4N pFhvhOBu61NfwpqzMwYpRZ+TZ22tfvu6FgPjqJQhbn1OxW83qeB/nL/STYVClZebL8zN +t9wGsGEQ/TtMC+mefPaNc6SBL0b5gKlCExNS3Ta06ERim550FLdU/SQ9C6KbF8sIq4b TWng== X-Gm-Message-State: APf1xPAfX5TOiI8epL6aYVou4wWWkBC5M1W21XBjn+QsEBavUisxkvCp WzbJm2D18h6VM5pjNv40VVezVIwf X-Google-Smtp-Source: AH8x226LyLFpTxsHkw8hML4u3oV8M13VTu7tvI7Sn5OLL0OwU6DFyW06UMC/aHfKI657B2vy3hdSlA== X-Received: by 10.28.85.194 with SMTP id j185mr290285wmb.31.1517858956978; Mon, 05 Feb 2018 11:29:16 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:24 +0100 Message-Id: <1517858941-5538-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 10/47] readline: don't free completions in readline_free() 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: Greg Kurz 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: Greg Kurz Since commit e5dc1a6c6c43, QEMU aborts on exit if completion was used in the monitor: *** Error in `obj/ppc64-softmmu/qemu-system-ppc64': double free or corruption (fasttop): 0x00000100331069d0 *** /home/greg/Work/qemu/qemu-spapr/util/readline.c:514 /home/greg/Work/qemu/qemu-spapr/monitor.c:586 /home/greg/Work/qemu/qemu-spapr/monitor.c:4125 argv=3D, envp=3D) at /home/greg/Work/qemu/qemu-spapr/vl.c:4795 Completion strings are not persistent accross completions (why would they?). They are allocated under readline_completion(), which already takes care of freeing them before returning. Maybe all completion related bits should be moved out of ReadLineState to a dedicated structure ? In the meantime, let's drop the offending lines from readline_free() to fix the crash. Signed-off-by: Greg Kurz Message-Id: <151627206353.4505.4602428849861610759.stgit@bahia.lan> Fixes: e5dc1a6c6c43 Signed-off-by: Paolo Bonzini --- util/readline.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/util/readline.c b/util/readline.c index 24ec839..ec91ee0 100644 --- a/util/readline.c +++ b/util/readline.c @@ -510,9 +510,6 @@ void readline_free(ReadLineState *rs) for (i =3D 0; i < READLINE_MAX_CMDS; i++) { g_free(rs->history[i]); } - for (i =3D 0; i < READLINE_MAX_COMPLETIONS; i++) { - g_free(rs->completions[i]); - } g_free(rs); } =20 --=20 1.8.3.1 From nobody Tue Apr 30 08:57:31 2024 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 15178598442171001.1501710717342; Mon, 5 Feb 2018 11:44:04 -0800 (PST) Received: from localhost ([::1]:54845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimgI-0001If-5g for importer@patchew.org; Mon, 05 Feb 2018 14:43:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimS9-0004LM-81 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimS7-0004vE-To for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:21 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:38687) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimS7-0004ur-LV for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:19 -0500 Received: by mail-wm0-x241.google.com with SMTP id 141so27957692wme.3 for ; Mon, 05 Feb 2018 11:29:19 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:17 -0800 (PST) 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=7DZVD9VIzMG9D2UWvxfoz6CsrR8vmYWfEFJvQfMGE+c=; b=OMs44m3XeNGXFgfAyh9hGkF03O1cV8VkdsrHWq11dy+wcDghCzl3nsxnKbKWolNBLA IvnXdquFiKDwvKuyO1+KjmCHDlIhHMjOUVNnJWFCyC4PULo4F0Q2BjdTp5t1Si4ad4cC s8Ge+WNM7sgYkS3ZGGGIb/YoQvUWSPNM3ItRDRO9gvsR2nXYUU8uwOYOKbsyXOmQ75Ln yi6Q87sPyf52OLF62UtN3VWGgQm/QjcNyxmKZmbmREreVqhtX5DgQwWqJUOBGIP0qVPY HE/+hfO+SShkT5N1+0CyQXKAgnotsMbS/JwDAM4SmZfxIITil1il9Xu2E6/CaGq9YQ9i 5mqw== 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=7DZVD9VIzMG9D2UWvxfoz6CsrR8vmYWfEFJvQfMGE+c=; b=fT1lQFkTrzrPnYTfKwPG2Nc3lAGbivwprhMKI1iFu4ESkjsNO3BeK2nGrc4d9SqgdG Mspo5UDclh79qDlsucPV12G7FuhJTuXxXg1kjfWuxgAxj1eYKDvuxrwJo/AS35RAtm6h vrzPnEEmgvoByMxkJdXNyL1ignvk7rJ1Qtj+CA3Muq1KWXnP4JzJkZuEXKItT0Ju8AD5 9+xbWf461cBIYEeUqYqTXedmO/TgwZisjlTFWDBBbknboQqifmPuq/xsWUkCmYANi+XY UdzsLAhFRzXk5C8LsEroPro4g2qq+LCqGCu+qFGza8U4Ok7mBOH4jLYlsC7W5pEnIG/o yJLw== X-Gm-Message-State: APf1xPBRpD0o2NU+xzm00FVEiHRntUOgh2gX9tdJeG6R40HjICsOP7n5 QCrlRP0dZMMEALmGav23MvsE/7/u X-Google-Smtp-Source: AH8x226ByNqKe5cWxiJuIssNMmNRx/z2YFrbO65kvsz9wCn/hXiQIod3pQecXRhYRknYd7YQaCrxqg== X-Received: by 10.28.209.206 with SMTP id i197mr307238wmg.102.1517858958225; Mon, 05 Feb 2018 11:29:18 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:25 +0100 Message-Id: <1517858941-5538-12-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 11/47] scripts/qemu-gdb/timers.py: define encoding in header comment 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: Greg Kurz 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: Greg Kurz This is required otherwise python complains because of the accentuated letter in Alex's last name: Traceback (most recent call last): File "scripts/qemu-gdb.py", line 29, in from qemugdb import aio, mtree, coroutine, tcg, timers File "scripts/qemugdb/timers.py", line 1 SyntaxError: Non-ASCII character '\xc3' in file scripts/qemugdb/timers.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details Signed-off-by: Greg Kurz Message-Id: <151629549711.18276.15497684562308683805.stgit@bahia.lan> Signed-off-by: Paolo Bonzini --- scripts/qemugdb/timers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/qemugdb/timers.py b/scripts/qemugdb/timers.py index be71a00..51ea04b 100644 --- a/scripts/qemugdb/timers.py +++ b/scripts/qemugdb/timers.py @@ -1,4 +1,5 @@ #!/usr/bin/python +# -*- coding: utf-8 -*- # GDB debugging support # # Copyright 2017 Linaro Ltd --=20 1.8.3.1 From nobody Tue Apr 30 08:57:31 2024 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 15178596571501005.6433216780879; Mon, 5 Feb 2018 11:40:57 -0800 (PST) Received: from localhost ([::1]:54829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimdM-00071z-8u for importer@patchew.org; Mon, 05 Feb 2018 14:40:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSA-0004Lp-5G for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimS8-0004vs-UY for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:22 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:39626) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimS8-0004vJ-My for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:20 -0500 Received: by mail-wm0-x241.google.com with SMTP id b21so28072091wme.4 for ; Mon, 05 Feb 2018 11:29:20 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:18 -0800 (PST) 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=pBNw2N2PYmDefLURfSD+jyg9E2oNRgCbEmbV6JqF4oc=; b=sWWX1hUQNh5l72qKkDBbun/gU6Z5tuoPCgitbSFlOgiH6SPPtZ3hbSxe6W6RoWoV6Y YbNfjV036yNQTYXkSxGj+idUBePFXXFf3Hj1hVyCNeBGsYk14LJ0Jadxls0ROk18KZMh Srjj4mebsYQhOszurcvvEQ/GmTA0S0Dz8HcQFkbozrmuxdK6TpTKOMor58j+xuzicAiT vOfX+npkXX007TOB3kUkyO97fl8fZ4DzQHGitvlAuMuI6vwTdPUrTeddzNMoa5EaJZVf nqkIPxB0GLcGFQQskz4Rw5bgw6aS8z+12c2HRV0skE+AFc1vgaSWd+p8bQo6EKtUf6M6 25xA== 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=pBNw2N2PYmDefLURfSD+jyg9E2oNRgCbEmbV6JqF4oc=; b=JEFxdz71n7tFr3ri/HgOTtqwe8bB/bt7cfATcpKnAjeF0NcRPKpxSwE5QDz4PrRg27 T1Yr3Uh5wCNg+uctw3DmHt3qeMXnubqrtoQO3g//7IrnuzlHpFCLOfsnDRC3BE3HZ7DI qmi+//tF+TZttCGcSvYYWoRWY0s7olyRHZvdt5XybYNT3HGRPZFHhDX+m4yBK4cDl63R nnIYZUq/35XV0NyX9KkOiFJyM1zN5nEYn5Kq42439M7lgwfYHuizv9hDvkFUgHmu3BAC 5S/H6bSiMOh+UrngIiNA2zWfk7sPYO5rGLg/mMp3LE8IajIDH4OTMLVq5NTmmARjlP/Y DJNw== X-Gm-Message-State: APf1xPBsno+F8AFhfmK+ttn2qNeY5C1Qv1Sw+j4rNejQIkre/D4IWrP3 s88U5TG3nGoCCfBMKCIaMV8OH5LN X-Google-Smtp-Source: AH8x225NNqUvI8gry8p6Eg1u3FeG7mUgyp7lS6zNJA25dDFwdLwWqkA0UJHRr4B/9TujQZvYF49cmA== X-Received: by 10.28.29.130 with SMTP id d124mr322748wmd.139.1517858959317; Mon, 05 Feb 2018 11:29:19 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:26 +0100 Message-Id: <1517858941-5538-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 12/47] memory-internal.h: Remove obsolete claim that header is obsolete 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 Maydell 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 Maydell The memory-internal.h header claims that it is for "obsolete exec.c functions" which "will be removed soon". This statement was added in 2011, six years ago, but the header is still here. (Admittedly none of the prototypes added in commit 67d95c153bef55f6 are still in the header.) It's convenient to have a place to put prototypes for functions which are used internally to the various .c files of the memory system or by the accel/tcg code, which is inevitably fairly closely coupled. So keep the header but update the comments to reflect what we're actually using it for. Signed-off-by: Peter Maydell Message-Id: <1511276888-17834-1-git-send-email-peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini --- include/exec/memory-internal.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h index 98d8296..4162474 100644 --- a/include/exec/memory-internal.h +++ b/include/exec/memory-internal.h @@ -1,5 +1,5 @@ /* - * Declarations for obsolete exec.c functions + * Declarations for functions which are internal to the memory subsystem. * * Copyright 2011 Red Hat, Inc. and/or its affiliates * @@ -12,8 +12,9 @@ */ =20 /* - * This header is for use by exec.c and memory.c ONLY. Do not include it. - * The functions declared here will be removed soon. + * This header is for use by exec.c, memory.c and accel/tcg/cputlb.c ONLY, + * for declarations which are shared between the memory subsystem's + * internals and the TCG TLB code. Do not include it from elsewhere. */ =20 #ifndef MEMORY_INTERNAL_H --=20 1.8.3.1 From nobody Tue Apr 30 08:57:31 2024 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 151785990033853.782234022283546; Mon, 5 Feb 2018 11:45:00 -0800 (PST) Received: from localhost ([::1]:54848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimhH-0002Hr-GW for importer@patchew.org; Mon, 05 Feb 2018 14:44:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSB-0004Lv-LF for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSA-0004wc-6o for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:23 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:37744) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimS9-0004wE-W1 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:22 -0500 Received: by mail-wm0-x243.google.com with SMTP id v71so28090128wmv.2 for ; Mon, 05 Feb 2018 11:29:21 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:19 -0800 (PST) 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=somttfHucE5sQl1uQ5kuPxvIv6tPw0EHJ7VrGVqAlxM=; b=W2V77ogN/vPSmy23bnCkn3tKIUPC1t+DmLV+wnyLQrA81vTwPm5Q2CdWxc5um4rqxH TgYUJZpSAgeifg0DgQdsyuGfmc7Ufj/zVLgO8eGE2EFbgOArI9jMxSRWjpruxmopk7ka Lugkh9OOPQme3zC3gs8KNAuLh4q/cTJpZlpjcu2AnFxk8QiEjJD/GMtIOHQ3NRJa8Xiv omJQNKNFGnonl079CDrmpt1jjjGmtlKN6K9hIvHbGZKOMjirJ/9KkBqWdl7LC3l0kWsQ IPYbcjki2TpNqXsVeO0yuOsDSgHkByqlKNXO4za68trFMDbXImu0OADIHEqWMVL3LxJg TbAA== 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=somttfHucE5sQl1uQ5kuPxvIv6tPw0EHJ7VrGVqAlxM=; b=ND3a5ADwQFhocFx7jsfJSwIBIq6SKTyLGMULTfN/vpxZQnE5ZbSEm5a7VukUPxOr3A 0qNwSWgOsMS5FiOHXLWCrLpfks2IYwTzWY8vwhrsTkRLsAP/VTa7iiqu+HgwD0W+8gWu gQGHUHTB4hExQuW7HAOuifs3wvIEtraUcW7b76Vl0IP39wZbZsYqR/ymkQxK7ULahe/Q tNTrmuX8NxZdLpxq+caHuwhIztNd4EaOw243CduL/yu0zfO8DCGf/nCSIL52AqdYpZ/i 1R6v/LvYsw3NnOF7tz6fvheb8dQ8CEVjj71zDhEfOsL7uBN3xesF1fnafZR5Mgn5Uy+v EbOg== X-Gm-Message-State: APf1xPC+1gNQMj0ZS7255QkkkX9gZt5VipFoaeOyTBdQsXKFFVaCCLBP EW3U1yDPjq36ZtT023Qe8bgXNJ4K X-Google-Smtp-Source: AH8x225nNGhrrK7KZ8nvUlzcc7XyTrzcjODK765TIYdc9G6pBHZegb5wtw/6n6W0buHq2c59Xt56fg== X-Received: by 10.28.183.8 with SMTP id h8mr339045wmf.72.1517858960543; Mon, 05 Feb 2018 11:29:20 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:27 +0100 Message-Id: <1517858941-5538-14-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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::243 Subject: [Qemu-devel] [PULL 13/47] i2c: Add a CONFIG_I2C master switch to the configuration files 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 i2c core and the at24c EEPROM should only be compiled and linked on the machines that support i2c. Otherwise it's quite strange to see the at24c-eeprom to be "available" on qemu-system-s390x for example. Signed-off-by: Thomas Huth Message-Id: <1516634853-15883-1-git-send-email-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- default-configs/arm-softmmu.mak | 1 + default-configs/i386-softmmu.mak | 1 + default-configs/mips-softmmu-common.mak | 1 + default-configs/ppc-softmmu.mak | 1 + default-configs/ppcemb-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/i2c/Makefile.objs | 2 +- hw/nvram/Makefile.objs | 2 +- 8 files changed, 8 insertions(+), 2 deletions(-) diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.= mak index b0d6e65..ca34cf4 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -67,6 +67,7 @@ CONFIG_CADENCE=3Dy CONFIG_XGMAC=3Dy CONFIG_EXYNOS4=3Dy CONFIG_PXA2XX=3Dy +CONFIG_I2C=3Dy CONFIG_BITBANG_I2C=3Dy CONFIG_FRAMEBUFFER=3Dy CONFIG_XILINX_SPIPS=3Dy diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmm= u.mak index ac27700..3326e3e 100644 --- a/default-configs/i386-softmmu.mak +++ b/default-configs/i386-softmmu.mak @@ -62,3 +62,4 @@ CONFIG_HYPERV_TESTDEV=3D$(CONFIG_KVM) CONFIG_PXB=3Dy CONFIG_ACPI_VMGENID=3Dy CONFIG_FW_CFG_DMA=3Dy +CONFIG_I2C=3Dy diff --git a/default-configs/mips-softmmu-common.mak b/default-configs/mips= -softmmu-common.mak index 7d8f5db..e31f046 100644 --- a/default-configs/mips-softmmu-common.mak +++ b/default-configs/mips-softmmu-common.mak @@ -34,3 +34,4 @@ CONFIG_ISA_TESTDEV=3Dy CONFIG_EMPTY_SLOT=3Dy CONFIG_MIPS_CPS=3Dy CONFIG_MIPS_ITU=3Dy +CONFIG_I2C=3Dy diff --git a/default-configs/ppc-softmmu.mak b/default-configs/ppc-softmmu.= mak index 3baed6a..65680d8 100644 --- a/default-configs/ppc-softmmu.mak +++ b/default-configs/ppc-softmmu.mak @@ -23,6 +23,7 @@ CONFIG_PLATFORM_BUS=3Dy CONFIG_ETSEC=3Dy CONFIG_SM501=3Dy CONFIG_IDE_SII3112=3Dy +CONFIG_I2C=3Dy =20 # For Macs CONFIG_MAC=3Dy diff --git a/default-configs/ppcemb-softmmu.mak b/default-configs/ppcemb-so= ftmmu.mak index 5db4618..bc5e1b3 100644 --- a/default-configs/ppcemb-softmmu.mak +++ b/default-configs/ppcemb-softmmu.mak @@ -17,3 +17,4 @@ CONFIG_XILINX=3Dy CONFIG_XILINX_ETHLITE=3Dy CONFIG_SM501=3Dy CONFIG_IDE_SII3112=3Dy +CONFIG_I2C=3Dy diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-so= ftmmu.mak index b2104ad..1c6cda1 100644 --- a/default-configs/x86_64-softmmu.mak +++ b/default-configs/x86_64-softmmu.mak @@ -62,3 +62,4 @@ CONFIG_HYPERV_TESTDEV=3D$(CONFIG_KVM) CONFIG_PXB=3Dy CONFIG_ACPI_VMGENID=3Dy CONFIG_FW_CFG_DMA=3Dy +CONFIG_I2C=3Dy diff --git a/hw/i2c/Makefile.objs b/hw/i2c/Makefile.objs index 0594dea..37cacde 100644 --- a/hw/i2c/Makefile.objs +++ b/hw/i2c/Makefile.objs @@ -1,4 +1,4 @@ -common-obj-y +=3D core.o smbus.o smbus_eeprom.o +common-obj-$(CONFIG_I2C) +=3D core.o smbus.o smbus_eeprom.o common-obj-$(CONFIG_DDC) +=3D i2c-ddc.o common-obj-$(CONFIG_VERSATILE_I2C) +=3D versatile_i2c.o common-obj-$(CONFIG_ACPI_X86) +=3D smbus_ich9.o diff --git a/hw/nvram/Makefile.objs b/hw/nvram/Makefile.objs index 0f4ee71..a912d25 100644 --- a/hw/nvram/Makefile.objs +++ b/hw/nvram/Makefile.objs @@ -1,6 +1,6 @@ common-obj-$(CONFIG_DS1225Y) +=3D ds1225y.o common-obj-y +=3D eeprom93xx.o -common-obj-y +=3D eeprom_at24c.o +common-obj-$(CONFIG_I2C) +=3D eeprom_at24c.o common-obj-y +=3D fw_cfg.o common-obj-y +=3D chrp_nvram.o common-obj-$(CONFIG_MAC_NVRAM) +=3D mac_nvram.o --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860084442825.1425884349062; Mon, 5 Feb 2018 11:48:04 -0800 (PST) Received: from localhost ([::1]:54869 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimkF-0004zm-Dc for importer@patchew.org; Mon, 05 Feb 2018 14:48:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSC-0004M7-Dg for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSB-0004xK-Dy for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:24 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:39207) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSB-0004wo-6H for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:23 -0500 Received: by mail-wr0-x244.google.com with SMTP id f6so29195560wra.6 for ; Mon, 05 Feb 2018 11:29:23 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:20 -0800 (PST) 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=s27aO5dEoAZDcU7yyZv+20aYY9kcZU84dFr3e+0gV5E=; b=sw7khpAz7GQeRwkgRXIbY2IHJdK/48R/BIyqMxA5Zhi76CvUIikt7G4YnT7l8OVBPU /eGhIKWzyfeXLBi7P77RblEVPyHETGuY05WJcSmECyzH1jr2RR+AjtlN6WfAF8rNP0CP DybG7X5rQVD9qe3VE64QK9Qc5Km+LaI/f17zmgT8CaXoJ13sBp7x3noi15R6jDhzWrsg ocZgtK/znlNmmFiABedyxlcUdMpHOjW8CT38ZJhxQ0RsH3Ws/1a9q1jDnSP6oOZ4zqzf qMYL8IalJKLyRWavO/IrzxrTQOj2vOFqoGL6egQzkQMnUgnLYDxaKuFomPGlc92QMefD zleg== 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=s27aO5dEoAZDcU7yyZv+20aYY9kcZU84dFr3e+0gV5E=; b=Fc6/PjBgKqD+RPDtw9xmvISIRC7IUfHOcdWgbbwvudvv/DJXoUBc6TJmiADrGRLP1U Lzjyz+Vyi1eTkRP/PvStqhzD/fUj0r3fV2kf520TGB3ywDhIC1J4EQegQZ6R9AocmzgP pwE+Svl73bTvrFQZVY72V8iKyKrWnHGStCprs8rANH52i9PyfgXdItw1TTsQl+74m0Sv CXzrDbaJYhxfVJ5laH6LJF2bL25gDyPQjuBbOlFFqeJ6C1Coz/Kc/XWoU9zHh2iBd8pB rjRvTgVQO/mcRvr3bQrFRspBFOy4PrmyLHKk8q1iQhADZi2ASAPeW2L7F/bQwSWMl/s+ cn3Q== X-Gm-Message-State: AKwxytc+/t4xlj7646aUPWzn8JqoKJYWoQt5YEXKqaFPxL+LmeSqnr5H Fj1u5AScWKBVrFlX39s5oyGsQyeV X-Google-Smtp-Source: AH8x224NrchwxOG9D6waKAraOMeZnyNVyCekgGp1MpbZABN/3crQTWDW+zgW/Nt9eL4Shk042MDWmg== X-Received: by 10.223.184.150 with SMTP id i22mr7736472wrf.132.1517858961739; Mon, 05 Feb 2018 11:29:21 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:28 +0100 Message-Id: <1517858941-5538-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 14/47] Add missing hvdos public domain attribution: 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: Izik Eidus 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: Izik Eidus hvf.c and vmx.h contain code from hvdos.c that is released as public domain: from hvdos github: https://github.com/mist64/hvdos "License See LICENSE.txt (2-clause-BSD). In order to simplify use of this code as a template, you can consider any p= arts from "hvdos.c" and "interface.h" as being in the public domain." Signed-off-by: Izik Eidus Message-Id: <20180123123639.35255-2-izik@veertu.com> Signed-off-by: Paolo Bonzini --- target/i386/hvf/hvf.c | 3 +++ target/i386/hvf/vmx.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 010866e..ab4820c 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -17,6 +17,9 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, see . + * + * This file contain code under public domain from the hvdos project: + * https://github.com/mist64/hvdos */ #include "qemu/osdep.h" #include "qemu-common.h" diff --git a/target/i386/hvf/vmx.h b/target/i386/hvf/vmx.h index 9dfcd2f..162a7d5 100644 --- a/target/i386/hvf/vmx.h +++ b/target/i386/hvf/vmx.h @@ -17,6 +17,9 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, see . + * + * This file contain code under public domain from the hvdos project: + * https://github.com/mist64/hvdos */ =20 #ifndef VMX_H --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860023836240.12122618618434; Mon, 5 Feb 2018 11:47:03 -0800 (PST) Received: from localhost ([::1]:54867 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimjH-0004Av-2C for importer@patchew.org; Mon, 05 Feb 2018 14:47:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSD-0004NZ-IL for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSC-0004xu-Gg for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:25 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:39627) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSC-0004xU-9y for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:24 -0500 Received: by mail-wm0-x242.google.com with SMTP id b21so28072374wme.4 for ; Mon, 05 Feb 2018 11:29:24 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:22 -0800 (PST) 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=gar+gQak+RUDzr8SO7oX/gvEo4mthsuX9VjZqZ1Loyc=; b=FwTv4N5loW7JAeuly/66VYQYQgcx41+W0hjQXHGDoV4Ny3hiIOjOb7hDjvlskmnWoD 3jUwiB4e0v60qbG4JedWys03jU5k/PTNjGs+8APurepBSSnMC02bdgX3P4KnCY99K9fm 6mXCc8x4a55ILo1vEdFkjlJ0Sv6QRd0bE/1PUURR1avDe7yfVo2HYMBVlHoNRAoJQwfa vvrDdo8/1OoMDPA+PnEGI9pK/EBpS22UdnJ8qBPt/pdv0/yKc7rSm4sovL9Sq7kWsONY hm24r7vOvPhaGkS3jrna1oS6GW+vedBv4xYQb0Dp47fFz71oQ3c0jbi6IJ3EJ8fo4idt 4DbA== 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=gar+gQak+RUDzr8SO7oX/gvEo4mthsuX9VjZqZ1Loyc=; b=Vkqkl3v5s7EFzuRvITP23gpfSFRK9fJaFPTyS3/KZyEFwtGYqd/CrF58ntXZjI61o/ bX3buql17vPRluNTkfY2uwSTiaJpHRjSz8glK352Iu8YOk1L9EU6jat+43AafRsPhtBR E1hH/6+B1diKXYDFZkc8Kbi3JtsQxH5hatdkwvRPxqu8kH9gfy2z9bBfHSAE4kTcWD3E 21ckkmH5kFdiTttTc/aJUB1qX9r2fV4V88nLgU7me10eaLSTZsFLg7qROsRlGfHnbc5Y vmDcgv4zrjVI3+VXPCR+rubG2tvf+6aO6uNdqINYGX972LkPpl5m2AfTCfAQtyTiVi1c Jpvw== X-Gm-Message-State: APf1xPCwM/YMjnVa95h9QTW6kicmRK22mUhu7zqw6tUa158FsStfXa5i AvH7tDR8GzViotPHhEFoeLfTTNpj X-Google-Smtp-Source: AH8x224Gl/fwURFBIDucEoNjzq8J7CV8ML2nIGRvcKCIWU6Fj3oVNxBtzfVz6b+/E0t+0a8IqCB3+g== X-Received: by 10.28.46.88 with SMTP id u85mr326923wmu.12.1517858962908; Mon, 05 Feb 2018 11:29:22 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:29 +0100 Message-Id: <1517858941-5538-16-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 15/47] hvf: ept_emulation_fault() needs NetApp BSD attribution 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" Add the BSD license there. Reported-by: Izik Eidus Message-Id: <20180123123639.35255-3-izik@veertu.com> Signed-off-by: Paolo Bonzini --- target/i386/hvf/hvf.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index ab4820c..85e5964 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -20,6 +20,30 @@ * * This file contain code under public domain from the hvdos project: * https://github.com/mist64/hvdos + * + * Parts Copyright (c) 2011 NetApp, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP= OSE + * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENT= IAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STR= ICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY W= AY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ #include "qemu/osdep.h" #include "qemu-common.h" --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 15178596539351005.0501931958054; Mon, 5 Feb 2018 11:40:53 -0800 (PST) Received: from localhost ([::1]:54828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimdE-0006vl-3M for importer@patchew.org; Mon, 05 Feb 2018 14:40:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSE-0004P0-Sj for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSD-0004yq-ML for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:26 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:39629) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSD-0004yE-D9 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:25 -0500 Received: by mail-wm0-x244.google.com with SMTP id b21so28072446wme.4 for ; Mon, 05 Feb 2018 11:29:25 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:23 -0800 (PST) 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=Fhm5PyXzibe7e3ZlTuswG0A6TMZspbCtNDUMI4GnL8g=; b=Pm+LPJ1RI58v6bQHzX9wMLSqOB5V7QbrY1lQngkDvDwxSyd5dEhTd0aQclKK92cRFu u6NnbYMg2P/Cg0jkdJxPMEKWcOmWHmJPlv7GqLgKhDfGbKlt4TwHIUyv1gnh7JrnA9fK T14ik6fwdXulHPDqhCEiq1ivzGDdRPGNfDwaAvb2wW54rtyt8Y9xK2w23LGe8CuI1n9w zDZ4q+TC11Y1Wjoj4EeWpCRWPzgIByF1dZ9Ww/xs4anfGgIILy4fsnOeOQ2cMWo4kB5g MPIRGfVYsBerqH11XFbnsA0FFvU7bbiDHPbCsopVM8OlvIQWt6C/uXrC4wpdKCi0e/AR utRw== 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=Fhm5PyXzibe7e3ZlTuswG0A6TMZspbCtNDUMI4GnL8g=; b=Htoxkx4bubVtuWwRJUD5oWGiQqK/zQtPyV26hbJvtJnXOF5C+HUj3bLZTYZqtwOwAY axVnzktqaXz7LTBGAtsYZNC9sCzQY4X0Z0ZBJ8NmzjLMc581FTAxnd4YfMoEo5LX7Gnq ZF3kHWVHKauQR1a6fVpAsB483y9lMAx/M+dATeA/cKUhY7B8yRaTWhWZffNRm2BaGAn+ iF7L0Oi+ao3TXwYfzT+VTD3vhOuHO1o0XaPK6IXgFeuYVTrKvNiOHAu3TUd3vyYZKR/X B9kfWb3IixANPAjU8L+gsweJra0Dma8xjR9sa0XNFqFboWWr4ktpXQYD8DBUw7ekBM2y TIcQ== X-Gm-Message-State: APf1xPBx9X+WwZF2r1OKgJxs+GC4gpjJQ8dLcS/ErFhMIks/sldgvaTN bZvATqZ4hUOAlUhniP19jgA5jfb8 X-Google-Smtp-Source: AH8x227T45tWSyqLbdHJRVeah3iOQksttQUn1D5bVMgpiU786DUWvfHOQ+6GOGEVoJiCOoocfXUcpg== X-Received: by 10.28.214.67 with SMTP id n64mr275122wmg.25.1517858964032; Mon, 05 Feb 2018 11:29:24 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:30 +0100 Message-Id: <1517858941-5538-17-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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::244 Subject: [Qemu-devel] [PULL 16/47] Drop remaining bits of ia64 host support 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 Maydell 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 Maydell We dropped support for ia64 host CPUs in the 2.11 release (removing the TCG backend for it, and advertising the support as being completely removed in the changelog). However there are a few bits and pieces of code still floating about. Remove those, too. We can drop the check in configure for "ia64 or hppa host?" entirely, because we don't support hppa hosts either any more. Signed-off-by: Peter Maydell Message-Id: <1516897189-11035-1-git-send-email-peter.maydell@linaro.org> Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- accel/tcg/user-exec.c | 33 --------------------------------- configure | 5 ----- include/qemu/processor.h | 3 --- include/qemu/timer.h | 9 --------- linux-user/syscall.c | 7 +------ 5 files changed, 1 insertion(+), 56 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index a0a4a19..7789958 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -503,39 +503,6 @@ int cpu_signal_handler(int host_signum, void *pinfo, v= oid *puc) return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); } =20 -#elif defined(__ia64) - -#ifndef __ISR_VALID - /* This ought to be in ... */ -# define __ISR_VALID 1 -#endif - -int cpu_signal_handler(int host_signum, void *pinfo, void *puc) -{ - siginfo_t *info =3D pinfo; - ucontext_t *uc =3D puc; - unsigned long ip; - int is_write =3D 0; - - ip =3D uc->uc_mcontext.sc_ip; - switch (host_signum) { - case SIGILL: - case SIGFPE: - case SIGSEGV: - case SIGBUS: - case SIGTRAP: - if (info->si_code && (info->si_segvflags & __ISR_VALID)) { - /* ISR.W (write-access) is bit 33: */ - is_write =3D (info->si_isr >> 33) & 1; - } - break; - - default: - break; - } - return handle_cpu_signal(ip, info, is_write, (sigset_t *)&uc->uc_sigma= sk); -} - #elif defined(__s390__) =20 int cpu_signal_handler(int host_signum, void *pinfo, diff --git a/configure b/configure index 302fdc9..bdbd097 100755 --- a/configure +++ b/configure @@ -636,8 +636,6 @@ elif check_define _ARCH_PPC ; then fi elif check_define __mips__ ; then cpu=3D"mips" -elif check_define __ia64__ ; then - cpu=3D"ia64" elif check_define __s390__ ; then if check_define __s390x__ ; then cpu=3D"s390x" @@ -4744,9 +4742,6 @@ if test "$coroutine_pool" =3D ""; then fi =20 if test "$debug_stack_usage" =3D "yes"; then - if test "$cpu" =3D "ia64" -o "$cpu" =3D "hppa"; then - error_exit "stack usage debugging is not supported for $cpu" - fi if test "$coroutine_pool" =3D "yes"; then echo "WARN: disabling coroutine pool for stack usage debugging" coroutine_pool=3Dno diff --git a/include/qemu/processor.h b/include/qemu/processor.h index 8b25702..8e16c92 100644 --- a/include/qemu/processor.h +++ b/include/qemu/processor.h @@ -12,9 +12,6 @@ #if defined(__i386__) || defined(__x86_64__) # define cpu_relax() asm volatile("rep; nop" ::: "memory") =20 -#elif defined(__ia64__) -# define cpu_relax() asm volatile("hint @pause" ::: "memory") - #elif defined(__aarch64__) # define cpu_relax() asm volatile("yield" ::: "memory") =20 diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 1b518bc..3b5a54b 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -931,15 +931,6 @@ static inline int64_t cpu_get_host_ticks(void) return val; } =20 -#elif defined(__ia64) - -static inline int64_t cpu_get_host_ticks(void) -{ - int64_t val; - asm volatile ("mov %0 =3D ar.itc" : "=3Dr"(val) :: "memory"); - return val; -} - #elif defined(__s390__) =20 static inline int64_t cpu_get_host_ticks(void) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7437894..df1edf0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -36,10 +36,6 @@ #include #include #include -#ifdef __ia64__ -int __clone2(int (*fn)(void *), void *child_stack_base, - size_t stack_size, int flags, void *arg, ...); -#endif #include #include #include @@ -246,8 +242,7 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type= 4 arg4,type5 arg5, \ #define __NR_sys_inotify_add_watch __NR_inotify_add_watch #define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch =20 -#if defined(__alpha__) || defined (__ia64__) || defined(__x86_64__) || \ - defined(__s390x__) +#if defined(__alpha__) || defined(__x86_64__) || defined(__s390x__) #define __NR__llseek __NR_lseek #endif =20 --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517859872119766.0851375509759; Mon, 5 Feb 2018 11:44:32 -0800 (PST) Received: from localhost ([::1]:54846 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimgp-0001mv-7q for importer@patchew.org; Mon, 05 Feb 2018 14:44:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSI-0004TO-PR for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSE-0004zL-Pu for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:30 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:50515) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSE-0004yu-Hl for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:26 -0500 Received: by mail-wm0-x244.google.com with SMTP id f71so28283658wmf.0 for ; Mon, 05 Feb 2018 11:29:26 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:24 -0800 (PST) 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=BOfiUSjtQJ+osNkiyYn4ZtfYbb0n7gBqVviymGZ5lc0=; b=UsKjxI0eED2iavQcQmYRT+vcJiAYcXeY28wqsMcobvvrV+upRtU+Alc+UJzbr7m805 JixL8SflkcoBHJxH3wSBXO0iLRnbKGrf1nxYA0JDskfXeHDxVNTtQG7ncFrkwViYsJEi JgGji6tnKzsNJ7pfYh/SqQSiOU/9tSIRYBLUmUPMmXSdaUQsr8BGB7VFgDTMJyKxHJy8 jyCGvocgdlaYeeYXz1RUtaiziix763vz5nvpemzWOGwyp3VnhtF26B2IDR1zIb4yjbEo m2i4SdX5iY9kN2kV89LJFd0gY70NOhVcCcFDNeDNQ4ASTICy4Aln8UFkAsOq1z+qShC/ 8NXA== 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=BOfiUSjtQJ+osNkiyYn4ZtfYbb0n7gBqVviymGZ5lc0=; b=B7ml+n0M2RTZUHlmteRJ/TTPuyZOJVAiQSWhzJjXe+7cLuak0RQ5pl1IjEYN0GOkeP IMwia79UIgO3wtS5dUYyLZIgakWwi0/KIVyOKFan5uinEZLsPdtYg00m11fAKAS8gx7x Wah5uOGjbLTLO+sHHKtoNKn11WMYStDiXj8016RMu+AAdRaInkP5zCZJaGGLvNVMa7Mc hPPe0I5adwzrKrtBMQZ+0jZrL34kJvFZoP1ZjyLvNHTCRJHi+xlqCqSoF2JQe+IQ1viU SqCCwVv2yuiBic1RrEuUx1BWqb0m2xxlWtccWOVdR+3U9pCVtM+r2mwGZRBY6YLchYSc Sl9w== X-Gm-Message-State: APf1xPD/mlccPORy1JRrPyIp+JkTl78Jv3qB/kjYxCdPbTBVQJcvkZ+9 4eefXET0J/uFwr61l4r8uoRDuPUq X-Google-Smtp-Source: AH8x226mSb+q3E0/reVpSAlsJHEAMm9K/3l6UdeIXd2KDYeOv9PbNjPcr/YLQuZVokga3xmtStEwIw== X-Received: by 10.28.29.81 with SMTP id d78mr327112wmd.65.1517858965198; Mon, 05 Feb 2018 11:29:25 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:31 +0100 Message-Id: <1517858941-5538-18-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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::244 Subject: [Qemu-devel] [PULL 17/47] sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr 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" From: "Daniel P. Berrange" The inet_parse() function looks for 'ipv4' and 'ipv6' flags, but only treats them as bare bool flags. The normal QemuOpts parsing would allow on/off values to be set too. This updates inet_parse() so that its handling of the 'ipv4' and 'ipv6' flags matches that done by QemuOpts. This impacts the NBD block driver parsing the legacy filename syntax and the migration code parsing the socket scheme. Signed-off-by: Daniel P. Berrange Message-Id: <20180125171412.21627-1-berrange@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini --- util/qemu-sockets.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index d6a1e17..fbbef69 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -554,6 +554,33 @@ err: } =20 /* compatibility wrapper */ +static int inet_parse_flag(const char *flagname, const char *optstr, bool = *val, + Error **errp) +{ + char *end; + size_t len; + + end =3D strstr(optstr, ","); + if (end) { + if (end[1] =3D=3D ',') { /* Reject 'ipv6=3Don,,foo' */ + error_setg(errp, "error parsing '%s' flag '%s'", flagname, opt= str); + return -1; + } + len =3D end - optstr; + } else { + len =3D strlen(optstr); + } + if (len =3D=3D 0 || (len =3D=3D 3 && strncmp(optstr, "=3Don", len) =3D= =3D 0)) { + *val =3D true; + } else if (len =3D=3D 4 && strncmp(optstr, "=3Doff", len) =3D=3D 0) { + *val =3D false; + } else { + error_setg(errp, "error parsing '%s' flag '%s'", flagname, optstr); + return -1; + } + return 0; +} + int inet_parse(InetSocketAddress *addr, const char *str, Error **errp) { const char *optstr, *h; @@ -561,6 +588,7 @@ int inet_parse(InetSocketAddress *addr, const char *str= , Error **errp) char port[33]; int to; int pos; + char *begin; =20 memset(addr, 0, sizeof(*addr)); =20 @@ -602,11 +630,19 @@ int inet_parse(InetSocketAddress *addr, const char *s= tr, Error **errp) addr->has_to =3D true; addr->to =3D to; } - if (strstr(optstr, ",ipv4")) { - addr->ipv4 =3D addr->has_ipv4 =3D true; + begin =3D strstr(optstr, ",ipv4"); + if (begin) { + if (inet_parse_flag("ipv4", begin + 5, &addr->ipv4, errp) < 0) { + return -1; + } + addr->has_ipv4 =3D true; } - if (strstr(optstr, ",ipv6")) { - addr->ipv6 =3D addr->has_ipv6 =3D true; + begin =3D strstr(optstr, ",ipv6"); + if (begin) { + if (inet_parse_flag("ipv6", begin + 5, &addr->ipv6, errp) < 0) { + return -1; + } + addr->has_ipv6 =3D true; } return 0; } --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517859514447777.3703469268031; Mon, 5 Feb 2018 11:38:34 -0800 (PST) Received: from localhost ([::1]:54806 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimb3-0004KP-J4 for importer@patchew.org; Mon, 05 Feb 2018 14:38:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSI-0004TM-PM for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSF-0004zf-TI for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:30 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:35284) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSF-0004zV-LB for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:27 -0500 Received: by mail-wm0-x243.google.com with SMTP id r78so28126347wme.0 for ; Mon, 05 Feb 2018 11:29:27 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:25 -0800 (PST) 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=FJKBfqnnQegyCTCkFo5AulZCHkBzLyOoPQXwsPdK/GE=; b=EydVSadA3bdEceBqu6Ldouu0ByUGYT036dkVLV4Khllk1R/hYdhuuoFkNY1hOcn5Sj TWoHeW/6tuhJYBSRJkjl0KENFiAoQ78GQWXAANoe4wCK6njxA+PzcL+McSCA/zt0n2Uu 3gmdILjq4o5hUC1TqluKpjWpsQNCON9rdHXIcBWbfbQmlkbngpZmpoZ9fDYcwkJWhcfN NTJ8TQ24Bjifw4Vkxx7lVnqpcw4A0PfJZzofE66wzTNeHmAbydnroWrT7AbLvF2lQrvH bTsyr1usXnbbiFhA8Fs3+RC6X/BZaAbGtZ0aSXoR+dLmurF0g9PAwfONCqhP/ghnk+ne e/UQ== 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=FJKBfqnnQegyCTCkFo5AulZCHkBzLyOoPQXwsPdK/GE=; b=K47lkKx4NcE1qb/7cv+z6kISlAbHSX4YJk9QfQItvcWp55GAmhJp/A4hTZCfQcQTRw ViKSwItV55SHd++4HkMh1dcF76fM1Xy8U+ISqRTNiilnRDQAEU6XScczW6dvVvjJ+ebc Xpo5H2/C7gz6aiZHMf7Rwru8MdI46nbPq4fa8N8ZUnL49TapoLwqnC+ItXYjJTzZcPLm akCBCpqdeohzf2xu1BL2WZFvSt4JkBTgpLVaXnLm6qS3KgR9RS+XMEolNBCprvbz4BjQ acbFOzZi4SUjjdsow8AMPDgmKgNDm8K6dgyIXzF4MWV+1wvsxmqPXJFrzYv/9sDZcXel Zxrg== X-Gm-Message-State: APf1xPD7G1b7XCVpQ551Q/JcFP5iRjb5Gx2koTI/q5c4v5eZ7X6z4HAT 1ESLd1zzDxSA4frn0q6nupPEP/Lh X-Google-Smtp-Source: AH8x227DJEcIvz3AYZzBu1idEJNOO2xRJjVC1ONtbN55azCOlu74K270BYrN55YO/Op9RfjtHTQPjA== X-Received: by 10.28.194.137 with SMTP id s131mr357761wmf.3.1517858966292; Mon, 05 Feb 2018 11:29:26 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:32 +0100 Message-Id: <1517858941-5538-19-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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:c09::243 Subject: [Qemu-devel] [PULL 18/47] exynos4210: workaround UBSAN compilation error 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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: Marc-Andr=C3=A9 Lureau gcc 5.4.0-6ubuntu1~16.04.5 build with UBSAN enabled error: CC hw/display/exynos4210_fimd.o /home/petmay01/linaro/qemu-for-merges/hw/display/exynos4210_fimd.c: In function =E2=80=98fimd_get_buffer_id=E2=80=99: /home/petmay01/linaro/qemu-for-merges/hw/display/exynos4210_fimd.c:1105:5: error: case label does not reduce to an integer constant case FIMD_WINCON_BUF2_STAT: Because FIMD_WINCON_BUF2_STAT case contains an integer overflow, use U suffix to get the unsigned type. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180116151152.4040-2-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- hw/display/exynos4210_fimd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c index fd0b2be..86e37e9 100644 --- a/hw/display/exynos4210_fimd.c +++ b/hw/display/exynos4210_fimd.c @@ -98,7 +98,7 @@ #define FIMD_WINCON_BUFSTATUS ((1 << 21) | (1 << 31)) #define FIMD_WINCON_BUF0_STAT ((0 << 21) | (0 << 31)) #define FIMD_WINCON_BUF1_STAT ((1 << 21) | (0 << 31)) -#define FIMD_WINCON_BUF2_STAT ((0 << 21) | (1 << 31)) +#define FIMD_WINCON_BUF2_STAT ((0 << 21) | (1U << 31)) #define FIMD_WINCON_BUFSELECT ((1 << 20) | (1 << 30)) #define FIMD_WINCON_BUF0_SEL ((0 << 20) | (0 << 30)) #define FIMD_WINCON_BUF1_SEL ((1 << 20) | (0 << 30)) --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517859691866355.4462288955108; Mon, 5 Feb 2018 11:41:31 -0800 (PST) Received: from localhost ([::1]:54830 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimdv-0007au-34 for importer@patchew.org; Mon, 05 Feb 2018 14:41:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44715) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSI-0004TP-PQ for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSH-000509-1y for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:30 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:42667) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSG-0004zt-Qf for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:28 -0500 Received: by mail-wr0-x242.google.com with SMTP id 41so29436230wrc.9 for ; Mon, 05 Feb 2018 11:29:28 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:26 -0800 (PST) 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=vx1IYjNVlI9hYiKry/Au943/cHSY0etBuDZoyFk4JGs=; b=l8ddXg04fkUvguRXtBGx2DFQIdtbWTykfMoE6OL4lvrUJ59AWcz0/S8cSAlXEkn+7F fDf+3FdkCHeCBk4JkQGtt0nPKQhh9lftQZy185JnVGKrSoKshzg6jCSWeGdtK8LLWQKu Yuqq3hQsma4yM/4QnXlLy2pU5KY+8hsJ4+F3OkzIRCxtXuiMATDhGqeg6J9kd8ifB45/ fxqq2syFPRinncVcarX67BNuqlVyVWMFlzFKlhxGjzq9WUyec9hUiby4OAe42b6mXYg4 3LjYsugbf6Z6uXNcciYrIIJqaIUDxP+7aH922BQkeBD3WhtcU7UBXTXv5roliKHhi0ix DZ/A== 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=vx1IYjNVlI9hYiKry/Au943/cHSY0etBuDZoyFk4JGs=; b=E0KozBFfcbBGv96kgtVQCiKssKU/FE0jQirajzfRKn3wdajvsnafHKi3iuf/Rj8puZ cOmgfIvwh8d2NycJv8nzbUid6uZtXksW3QrXHl6VvF90tFpwag6PDYqCBR+CKQyGiMPu NG7ysPHDaxEd9Y48Eonkk8T6Dnf408CivAwQ9HxNDMksr8nsOYZK6+nfythTZyJMvT09 LJrFK6xI6+15Ovw2lDQDX0NgdEMys7lfRxj07k4bRE4GWw3vHPdZ+656qvlkXcRCXNpx am/XGvbcL7iJbg0xhXO1f+w/0rdf5AhOqaUe/AIFC+/OotKiL7lZzsVS+qmo/RP7hsF4 DLyw== X-Gm-Message-State: AKwxytck/EaMsh7kupN8fkJ8fc9UtUVVezlfl79eQktIiVQeIpgGcpIQ eYYulvrEQlgOCH7eg+uS9MNhqeAv X-Google-Smtp-Source: AH8x224502ZayK+mYt2pYbLI9NUZd2zOnG8aNuIHSW4uFKTiGXr861dILTySspG800UBgS/Rxirdcg== X-Received: by 10.223.176.174 with SMTP id i43mr29130327wra.77.1517858967384; Mon, 05 Feb 2018 11:29:27 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:33 +0100 Message-Id: <1517858941-5538-20-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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::242 Subject: [Qemu-devel] [PULL 19/47] build-sys: add --enable-sanitizers 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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: Marc-Andr=C3=A9 Lureau Typical slowdown introduced by AddressSanitizer is 2x. UBSan shouldn't have much impact on runtime cost. Enable it by default when --enable-debug, unless --disable-sanitizers. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180116151152.4040-3-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- configure | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/configure b/configure index bdbd097..bbfcd9f 100755 --- a/configure +++ b/configure @@ -342,6 +342,7 @@ rdma=3D"" gprof=3D"no" debug_tcg=3D"no" debug=3D"no" +sanitizers=3D"" fortify_source=3D"" strip_opt=3D"yes" tcg_interpreter=3D"no" @@ -993,6 +994,10 @@ for opt do strip_opt=3D"no" fortify_source=3D"no" ;; + --enable-sanitizers) sanitizers=3D"yes" + ;; + --disable-sanitizers) sanitizers=3D"no" + ;; --enable-sparse) sparse=3D"yes" ;; --disable-sparse) sparse=3D"no" @@ -1474,6 +1479,7 @@ Advanced options (experts only): --firmwarepath=3DPATH search PATH for firmware files --with-confsuffix=3DSUFFIX suffix for QEMU data inside datadir/libdir/sy= sconfdir [$confsuffix] --enable-debug enable common debug build options + --enable-sanitizers enable default sanitizers --disable-strip disable stripping binaries --disable-werror disable compilation abort on warning --disable-stack-protector disable compiler-provided stack protection @@ -5201,6 +5207,28 @@ if compile_prog "" "" ; then fi =20 ########################################## +# checks for sanitizers + +write_c_skeleton + +have_asan=3Dno +have_ubsan=3Dno + +# enable sanitizers by default if --enable-debug +if test "$sanitizers" =3D "" -a "$debug" =3D "yes"; then + sanitizers=3Dyes +fi + +if test "$sanitizers" =3D "yes" ; then + if compile_prog "$CPU_CFLAGS -Werror -fsanitize=3Daddress" ""; then + have_asan=3Dyes + fi + if compile_prog "$CPU_CFLAGS -Werror -fsanitize=3Dundefined" ""; then + have_ubsan=3Dyes + fi +fi + +########################################## # End of CC checks # After here, no more $cc or $ld runs =20 @@ -5224,6 +5252,13 @@ else CFLAGS=3D"-O2 $CFLAGS" fi =20 +if test "$have_asan" =3D "yes"; then + CFLAGS=3D"-fsanitize=3Daddress $CFLAGS" +fi +if test "$have_ubsan" =3D "yes"; then + CFLAGS=3D"-fsanitize=3Dundefined $CFLAGS" +fi + ########################################## # Do we have libnfs if test "$libnfs" !=3D "no" ; then --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 151786024280580.32594358982817; Mon, 5 Feb 2018 11:50:42 -0800 (PST) Received: from localhost ([::1]:54901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimme-0007EK-Ua for importer@patchew.org; Mon, 05 Feb 2018 14:50:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSJ-0004UI-MW for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSI-00050f-8j for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:31 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:37745) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSH-00050Q-V2 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:30 -0500 Received: by mail-wm0-x242.google.com with SMTP id v71so28090748wmv.2 for ; Mon, 05 Feb 2018 11:29:29 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:27 -0800 (PST) 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=VDZrU5NcX76pwOo12ryQxmZ0w8YromSY7jk4bGoI6pk=; b=catRXLVrGCV7t8Qk3/pFZ/uSvy4KdqhEF/Znm1eFH7Y4AmlIPHBZTgkZ7DgZ9xBQe1 FdfGIpwZ/sdzpZwbQsXHJtOTBVVhNfmRYAQH3cicPhTX2T0Tc23f8EwbbPK/oz14kAF0 rbE6JQ1RWQoHTlzE2ErWywSjMnmba52MMtiffpavy41cDIFguT9yaeBfmfVVIWxyvsTS ua5tXvQfE9AwRngE6iCHYkY2c8NZhxVR591zAYE1vXL+993tpxFD39kaMUSgpk+qp8kR kptyXb4tztySQ+Wz0dCG8dR1fqGwFf/Qls7W/b5wlniXTdPyzH2ttm8UbPCD4Ag/G+v2 706Q== 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=VDZrU5NcX76pwOo12ryQxmZ0w8YromSY7jk4bGoI6pk=; b=FvYJtq0DfeF7UbDnQXIPJRiKkEYofZwkVz3ZVe5InlPSGIHf4LhS6DkSmjdJll/8+D Pqyn7INGX81he2h3se3S7wTisvZNFK3lhE5lOUhXD9hLM8YmG9AC5DtYihiaDu2ocP73 Y3CWtp8Z3yp4UZG4rSJLZ0JUrpJTpteF1/gNLsRlGZe8IFml0ecqDgLs74miOn+Mov9g Z7e509mKuobIT3ndMV2lF1fU8YRxrsPcEq3Bu/JDQsdF0jTNh9BDEyRWlVCkwy07ALs/ 9c2Uk1g4dKjozE6UF8BlomsGs+18GfKZuTm3jtSlbw32HZc0yUH9vbdXARwLH9jmNQe6 0FIQ== X-Gm-Message-State: APf1xPDGno2xxUiC2a/PuHoq9FWXlazlkdPWWzyZTGLYMe/vTsJGNM1i ZEXqK25YaOkPFZxFsiDrRnAjz5SI X-Google-Smtp-Source: AH8x226f0QhghLSBXLnHL1CRPdzDBzqF6Mt9QsANJZjEk1+/R0gVsX+bMG4Yd/i9T0l/9oCfuRi79w== X-Received: by 10.28.193.7 with SMTP id r7mr269317wmf.153.1517858968468; Mon, 05 Feb 2018 11:29:28 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:34 +0100 Message-Id: <1517858941-5538-21-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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:c09::242 Subject: [Qemu-devel] [PULL 20/47] ucontext: annotate coroutine stack for ASAN 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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: Marc-Andr=C3=A9 Lureau It helps ASAN to detect more leaks on coroutine stacks, and to get rid of some extra warnings. Before: tests/test-coroutine -p /basic/lifecycle /basic/lifecycle: =3D=3D20781=3D=3DWARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases! =3D=3D20781=3D=3DWARNING: ASan is ignoring requested __asan_handle_no_retur= n: stack top: 0x7ffcb184d000; bottom 0x7ff6c4cfd000; size: 0x0005ecb50000 (25446121472) False positive error reports may follow For details see https://github.com/google/sanitizers/issues/189 OK After: tests/test-coroutine -p /basic/lifecycle /basic/lifecycle: =3D=3D21110=3D=3DWARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases! OK A similar work would need to be done for sigaltstack & windows fibers to have similar coverage. Since ucontext is preferred, I didn't bother checking the other coroutine implementations for now. Update travis to fix the build with ASAN annotations. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180116151152.4040-4-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- .travis.yml | 3 ++- configure | 30 +++++++++++++++++++++++++++++ include/qemu/compiler.h | 4 ++++ util/coroutine-ucontext.c | 48 +++++++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 84 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f583839..f2291e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,12 +13,13 @@ addons: - libattr1-dev - libbrlapi-dev - libcap-ng-dev + - libgcc-6-dev - libgnutls-dev - libgtk-3-dev - libiscsi-dev - liblttng-ust-dev - - libnfs-dev - libncurses5-dev + - libnfs-dev - libnss3-dev - libpixman-1-dev - libpng12-dev diff --git a/configure b/configure index bbfcd9f..0b5c812 100755 --- a/configure +++ b/configure @@ -5213,6 +5213,8 @@ write_c_skeleton =20 have_asan=3Dno have_ubsan=3Dno +have_asan_iface_h=3Dno +have_asan_iface_fiber=3Dno =20 # enable sanitizers by default if --enable-debug if test "$sanitizers" =3D "" -a "$debug" =3D "yes"; then @@ -5226,12 +5228,29 @@ if test "$sanitizers" =3D "yes" ; then if compile_prog "$CPU_CFLAGS -Werror -fsanitize=3Dundefined" ""; then have_ubsan=3Dyes fi + + if check_include "sanitizer/asan_interface.h" ; then + have_asan_iface_h=3Dyes + fi + + cat > $TMPC << EOF +#include +int main(void) { + __sanitizer_start_switch_fiber(0, 0, 0); + return 0; +} +EOF + if compile_prog "$CPU_CFLAGS -Werror -fsanitize=3Daddress" "" ; then + have_asan_iface_fiber=3Dyes + fi fi =20 ########################################## # End of CC checks # After here, no more $cc or $ld runs =20 +write_c_skeleton + if test "$gcov" =3D "yes" ; then CFLAGS=3D"-fprofile-arcs -ftest-coverage -g $CFLAGS" LDFLAGS=3D"-fprofile-arcs -ftest-coverage $LDFLAGS" @@ -5254,6 +5273,13 @@ fi =20 if test "$have_asan" =3D "yes"; then CFLAGS=3D"-fsanitize=3Daddress $CFLAGS" + if test "$have_asan_iface_h" =3D "no" ; then + echo "ASAN build enabled, but ASAN header missing." \ + "Without code annotation, the report may be inferior." + elif test "$have_asan_iface_fiber" =3D "no" ; then + echo "ASAN build enabled, but ASAN header is too old." \ + "Without code annotation, the report may be inferior." + fi fi if test "$have_ubsan" =3D "yes"; then CFLAGS=3D"-fsanitize=3Dundefined $CFLAGS" @@ -6242,6 +6268,10 @@ if test "$valgrind_h" =3D "yes" ; then echo "CONFIG_VALGRIND_H=3Dy" >> $config_host_mak fi =20 +if test "$have_asan_iface_fiber" =3D "yes" ; then + echo "CONFIG_ASAN_IFACE_FIBER=3Dy" >> $config_host_mak +fi + if test "$has_environ" =3D "yes" ; then echo "CONFIG_HAS_ENVIRON=3Dy" >> $config_host_mak fi diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 340e5fd..5fcc4f7 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -111,4 +111,8 @@ #define GCC_FMT_ATTR(n, m) #endif =20 +#ifndef __has_feature +#define __has_feature(x) 0 /* compatibility with non-clang compilers */ +#endif + #endif /* COMPILER_H */ diff --git a/util/coroutine-ucontext.c b/util/coroutine-ucontext.c index 6621f3f..926d340 100644 --- a/util/coroutine-ucontext.c +++ b/util/coroutine-ucontext.c @@ -31,6 +31,13 @@ #include #endif =20 +#if defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer) +#ifdef CONFIG_ASAN_IFACE_FIBER +#define CONFIG_ASAN 1 +#include +#endif +#endif + typedef struct { Coroutine base; void *stack; @@ -59,11 +66,37 @@ union cc_arg { int i[2]; }; =20 +static void finish_switch_fiber(void *fake_stack_save) +{ +#ifdef CONFIG_ASAN + const void *bottom_old; + size_t size_old; + + __sanitizer_finish_switch_fiber(fake_stack_save, &bottom_old, &size_ol= d); + + if (!leader.stack) { + leader.stack =3D (void *)bottom_old; + leader.stack_size =3D size_old; + } +#endif +} + +static void start_switch_fiber(void **fake_stack_save, + const void *bottom, size_t size) +{ +#ifdef CONFIG_ASAN + __sanitizer_start_switch_fiber(fake_stack_save, bottom, size); +#endif +} + static void coroutine_trampoline(int i0, int i1) { union cc_arg arg; CoroutineUContext *self; Coroutine *co; + void *fake_stack_save =3D NULL; + + finish_switch_fiber(NULL); =20 arg.i[0] =3D i0; arg.i[1] =3D i1; @@ -72,9 +105,13 @@ static void coroutine_trampoline(int i0, int i1) =20 /* Initialize longjmp environment and switch back the caller */ if (!sigsetjmp(self->env, 0)) { + start_switch_fiber(&fake_stack_save, + leader.stack, leader.stack_size); siglongjmp(*(sigjmp_buf *)co->entry_arg, 1); } =20 + finish_switch_fiber(fake_stack_save); + while (true) { co->entry(co->entry_arg); qemu_coroutine_switch(co, co->caller, COROUTINE_TERMINATE); @@ -87,6 +124,7 @@ Coroutine *qemu_coroutine_new(void) ucontext_t old_uc, uc; sigjmp_buf old_env; union cc_arg arg =3D {0}; + void *fake_stack_save =3D NULL; =20 /* The ucontext functions preserve signal masks which incurs a * system call overhead. sigsetjmp(buf, 0)/siglongjmp() does not @@ -122,8 +160,12 @@ Coroutine *qemu_coroutine_new(void) =20 /* swapcontext() in, siglongjmp() back out */ if (!sigsetjmp(old_env, 0)) { + start_switch_fiber(&fake_stack_save, co->stack, co->stack_size); swapcontext(&old_uc, &uc); } + + finish_switch_fiber(fake_stack_save); + return &co->base; } =20 @@ -169,13 +211,19 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to= _, CoroutineUContext *from =3D DO_UPCAST(CoroutineUContext, base, from_); CoroutineUContext *to =3D DO_UPCAST(CoroutineUContext, base, to_); int ret; + void *fake_stack_save =3D NULL; =20 current =3D to_; =20 ret =3D sigsetjmp(from->env, 0); if (ret =3D=3D 0) { + start_switch_fiber(action =3D=3D COROUTINE_TERMINATE ? + NULL : &fake_stack_save, to->stack, to->stack_s= ize); siglongjmp(to->env, action); } + + finish_switch_fiber(fake_stack_save); + return ret; } =20 --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860056191174.1738297959747; Mon, 5 Feb 2018 11:47:36 -0800 (PST) Received: from localhost ([::1]:54868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimjn-0004cD-CQ for importer@patchew.org; Mon, 05 Feb 2018 14:47:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSK-0004VB-6h for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSJ-00051C-7Y for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:32 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:42668) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSJ-00050j-1q for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:31 -0500 Received: by mail-wr0-x243.google.com with SMTP id 41so29436343wrc.9 for ; Mon, 05 Feb 2018 11:29:30 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:28 -0800 (PST) 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=Thddhq8pp/TkQWl58iyosVukeRmXROUTNlFe6RXinM4=; b=u/cPUxWTB237yd41nsAvlRQixiGvzPsSSXeNdoQ4F79SM9C6ZoOQV0s4up60qG6PHk +lWGM5Wh4bCcv6wKSw6XYarsCk3VodgLEhnW4UMFBlJMDhrpDjX1JsjzffKdacnljybw gozpAxbQyCD5wLbiQpbehAQDvdAhguAOBKWCF+Rivx5NWX9J/WVotdgc40LzECvHJeHS xKonJ0wWsmaXN0oJn8IhbtCUP+Z5awqGrdXR8nKx78Lb9hDZc9IUuc4Sal2q4mgjH/yZ uMNgiTPnZacbbkQ12skhMcWnqniThjmuJb0eUor8o3S1MOLmgsjguxGVZGd/FRlM5t5A ER8g== 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=Thddhq8pp/TkQWl58iyosVukeRmXROUTNlFe6RXinM4=; b=YDRsO+2hVikyyoJfqgayx3E5ungmH1RQw5d5rcHRW9YjHXf1YamB9XM/Rfbu7C2LTw C/ZhYGF79h9m0vLLgDTMbJh+N2P/tg/TCpol7BGDlSKGVcfooQh+lqUNlSzxSVr51dGh UM6mJQuehxpIW7MH0Qa1Zfhoj+nP61mxrlzWANnRreqk3pAPMdWSWE7TT/9RxuKtBE6F /m/caZF57ApotFPO63rSeXTygT2ctx2JAcNDsFUqtL8MjnMZzVcK2uU9IiKGhd3V2Ku5 1qjWjX5MW4s/qRlKVu6n+9dIYNAhvw2su2ahUAApTyCo9Q6/7Q27hRSAJhJgX8aDFHzV wCzg== X-Gm-Message-State: AKwxytdmDFgYxVGFHdR/O0ljs9E17ffALDz6ytgN24p8U1J7TwLsSfaX gZCFIVja7F8SGN7nB6Vcniamkdyh X-Google-Smtp-Source: AH8x2253DvP6cYgW9X+HosvfmEtI4nuGT796a3lqOLyNmx4TflLeIn3+EtXDjIIsBIc9doDxDUOaGA== X-Received: by 10.223.160.27 with SMTP id k27mr20840210wrk.5.1517858969630; Mon, 05 Feb 2018 11:29:29 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:35 +0100 Message-Id: <1517858941-5538-22-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 21/47] vhost: add traces for memory listeners 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 Trace these operations on two memory listeners. It helps to verify the new memory listener fix, and good to keep them there. Signed-off-by: Peter Xu Message-Id: <20180122060244.29368-2-peterx@redhat.com> Acked-by: Michael S. Tsirkin Reviewed-by: Paolo Bonzini Signed-off-by: Paolo Bonzini --- hw/virtio/trace-events | 6 ++++++ hw/virtio/vhost.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 775461a..2b8f81e 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -25,3 +25,9 @@ virtio_balloon_handle_output(const char *name, uint64_t g= pa) "section name: %s g virtio_balloon_get_config(uint32_t num_pages, uint32_t actual) "num_pages:= %d actual: %d" virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d= oldactual: %d" virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon tar= get: 0x%"PRIx64" num_pages: %d" + +# hw/virtio/vhost.c +vhost_region_add(void *p, const char *mr) "dev %p mr %s" +vhost_region_del(void *p, const char *mr) "dev %p mr %s" +vhost_iommu_region_add(void *p, const char *mr) "dev %p mr %s" +vhost_iommu_region_del(void *p, const char *mr) "dev %p mr %s" diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 386aef8..c4f654c 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -27,6 +27,7 @@ #include "hw/virtio/virtio-access.h" #include "migration/blocker.h" #include "sysemu/dma.h" +#include "trace.h" =20 /* enabled until disconnected backend stabilizes */ #define _VHOST_DEBUG 1 @@ -687,6 +688,7 @@ static void vhost_region_add(MemoryListener *listener, return; } =20 + trace_vhost_region_add(dev, section->mr->name ?: NULL); ++dev->n_mem_sections; dev->mem_sections =3D g_renew(MemoryRegionSection, dev->mem_sections, dev->n_mem_sections); @@ -706,6 +708,7 @@ static void vhost_region_del(MemoryListener *listener, return; } =20 + trace_vhost_region_del(dev, section->mr->name ?: NULL); vhost_set_memory(listener, section, false); memory_region_unref(section->mr); for (i =3D 0; i < dev->n_mem_sections; ++i) { @@ -743,6 +746,8 @@ static void vhost_iommu_region_add(MemoryListener *list= ener, return; } =20 + trace_vhost_iommu_region_add(dev, section->mr->name ?: NULL); + iommu =3D g_malloc0(sizeof(*iommu)); end =3D int128_add(int128_make64(section->offset_within_region), section->size); @@ -771,6 +776,8 @@ static void vhost_iommu_region_del(MemoryListener *list= ener, return; } =20 + trace_vhost_iommu_region_del(dev, section->mr->name ?: NULL); + QLIST_FOREACH(iommu, &dev->iommu_list, iommu_next) { if (iommu->mr =3D=3D section->mr && iommu->n.start =3D=3D section->offset_within_region) { --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860405214377.30177884720524; Mon, 5 Feb 2018 11:53:25 -0800 (PST) Received: from localhost ([::1]:54927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimpQ-0001Lw-Bm for importer@patchew.org; Mon, 05 Feb 2018 14:53:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSL-0004WS-El for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSK-00051s-EN for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:33 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:54431) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSK-00051K-6o for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:32 -0500 Received: by mail-wm0-x241.google.com with SMTP id i186so28241972wmi.4 for ; Mon, 05 Feb 2018 11:29:32 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:29 -0800 (PST) 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=QWWqoVmUgDBF6ZqgMFJHCmF7mbf49XDtfK9MMB58vPU=; b=nRqU6nfW7IjS6PLMDY37Kg0CwtHonW8NA62zHTRlHTC0qU0cRm2nL/gONShMRSnR3s wmyDMMUtiSyzkK+h4A3k+F9xo1NHbuUvZbDgLaedA8mCdG6ETt7nZIfDx+qeMizy+Rie 4W7GFWSvqInjMZEKPwR7Fb/IORO/+YSY56fd8W0FznuCVWtNPwgAtQfkvzpEZlub8z0X yjrV6ppWz3ihRNdpIDFG/pA712Sxagpr7J8px964ndMnw/5i+IVOwEm9ScbF1s5AGYDq bbhu2JzdomjKDSH4Gc23uKk8TuQsKouVNYo9pFgmWuMm99rkGCBLk+lgncu1ipiEk5L2 NEDQ== 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=QWWqoVmUgDBF6ZqgMFJHCmF7mbf49XDtfK9MMB58vPU=; b=E2WlTtHH8BZyPXev1+9fonfkgvZlRiM8dprpSmeyUrhsVBM+rAl7oLqImfipNnqtre Mmv6qr4s5D0YjHHXEp8S7kjN90vjHZWAcyIJtdZvfhfHZo0Bpd502ieuMnPTsNwN6AAd Azbe41UZ5uv5EelI3CxPjGMTSVtGp02ptiSw+MrcGZDdbXs8ZrpZH+LFjtTUnpXq8Rj1 iKJhyRAz1ehHbEE12dX4CZz0u7WFDoJwxLeIyPdy68ADlqyhUgGcdoH7qKwgFKndxu// 1pOqfen9sYo4DFdS4iqikO42bguZ7Uzwn4RW1jrrvMxtd2EHxWv1Oj8x0RhcqH6a/ryB xP4A== X-Gm-Message-State: APf1xPCaGSWT+bq7w7yYgq+9fuC1sBUslcu7JIa8ZjwTuPrpzQbQwOfY oYMGMjSq2/novA+gDAWNyL+QPbFZ X-Google-Smtp-Source: AH8x226Qc6wnotj6GL/9cl13G+a0++Z4Y45X0BFsox2Rw6e4Jkb+G25Y0LD1KgB+vt72wesogrV5lg== X-Received: by 10.28.177.7 with SMTP id a7mr285002wmf.143.1517858970850; Mon, 05 Feb 2018 11:29:30 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:36 +0100 Message-Id: <1517858941-5538-23-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 22/47] arm: postpone device listener unregister 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 It's a preparation for follow-up patch to call region_del() in memory_listener_unregister(), otherwise all device addr attached with kvm_devices_head will be reset before calling kvm_arm_set_device_addr. Signed-off-by: Peter Xu Message-Id: <20180122060244.29368-3-peterx@redhat.com> Reviewed-by: Paolo Bonzini Signed-off-by: Paolo Bonzini --- target/arm/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 211a7bf..1219d00 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -266,7 +266,6 @@ static void kvm_arm_machine_init_done(Notifier *notifie= r, void *data) { KVMDevice *kd, *tkd; =20 - memory_listener_unregister(&devlistener); QSLIST_FOREACH_SAFE(kd, &kvm_devices_head, entries, tkd) { if (kd->kda.addr !=3D -1) { kvm_arm_set_device_addr(kd); @@ -274,6 +273,7 @@ static void kvm_arm_machine_init_done(Notifier *notifie= r, void *data) memory_region_unref(kd->mr); g_free(kd); } + memory_listener_unregister(&devlistener); } =20 static Notifier notify =3D { --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517859834270646.9822877808699; Mon, 5 Feb 2018 11:43:54 -0800 (PST) Received: from localhost ([::1]:54844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimgA-0001DH-IC for importer@patchew.org; Mon, 05 Feb 2018 14:43:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSM-0004XJ-Bm for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSL-00052L-FW for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:34 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:51311) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSL-00051w-8l for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:33 -0500 Received: by mail-wm0-x242.google.com with SMTP id r71so28444914wmd.1 for ; Mon, 05 Feb 2018 11:29:33 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:31 -0800 (PST) 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=zyY3NTlfOa8/ThsZ8be8KK/ujZm7cAClR+FjBfoWCUU=; b=M/s20Gv0D3Igghn8mUgDiGCJdlb9i3lr7+4lQIoqjE2rh19SuWoFd1s88tqtyFICoM tmKH7B5Lvbe5PCH9HZHfzcHv0U9oy3VjM27Li6Mw8uAbnQ1ZHXdncgC6i7/8XkkYKM1v HAaakaKEf2rJZ+gx99rzIHleGUIr0DmFDUL60hh1jYrAha3wgNgYWV5baHlKYaMvPpTS WvtG/X6DqS35dfi89IpIPaHDysEgeqAZiA+3SZLPr+LOcwOXCMsRnZXWsyKQfZQAZqtU G94lUtIuEsi1byAp0uSu7DMBNhc1OR8k2JnDJ/juQARy2BO9tfhVaRakUpRkm7vTnbCv Us/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=zyY3NTlfOa8/ThsZ8be8KK/ujZm7cAClR+FjBfoWCUU=; b=CkAg1IL2ymqyZN5qZrMytiw4nrzos95FkIXjNxtw0PyWoiWXEr1UM1M/4fZsJmGH9j y+iVKvAQWsRDvqjgWqE/Ib8FtqPV8QYo3XVPvy0ruMTU6dkC3H2WJx3nnsa3UJVN25S3 XgaLVwNoDvO1f07R4eTnODcTbgVg5wnisbv03/yiTqic9Q8svDqbx9zNMJyx30o7h3YQ Vi5t0wPiRUP5f1cpKstMqxba/TzoF91LpD79etqVzE6dwFNRFmtua6ZTW1f5l0VO8VTr 7Em8ySC+RzsN+x/6Iz3kKBGuiZXsW6Xu1h9/XWFPAaNgeCnZQ2Rpw3J/GyqlC8JPGg06 YZsQ== X-Gm-Message-State: APf1xPARbgDSAMehd6yQzXSadu52MsAbdm3kOhcSDjVBZkB32I4D57Zv vhn+QOcDNBfDLmvx0LJVO+QIC/ld X-Google-Smtp-Source: AH8x224ybpqukpRUNFSKTt2KZPEUPvamjehoBJwMWn6o8X6j2pbuZBGCFAPfBWYVi7JBRm+DKB1l5w== X-Received: by 10.28.22.201 with SMTP id 192mr295400wmw.45.1517858971903; Mon, 05 Feb 2018 11:29:31 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:37 +0100 Message-Id: <1517858941-5538-24-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 23/47] vfio: listener unregister before unset container 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 After next patch, listener unregister will need the container to be alive. Let's move this unregister phase to be before unset container, since that operation will free the backend container in kernel, otherwise we'll get these after next patch: qemu-system-x86_64: VFIO_UNMAP_DMA: -22 qemu-system-x86_64: vfio_dma_unmap(0x559bf53a4590, 0x0, 0xa0000) =3D -22 (I= nvalid argument) Signed-off-by: Peter Xu Message-Id: <20180122060244.29368-4-peterx@redhat.com> Reviewed-by: Paolo Bonzini Acked-by: Alex Williamson Signed-off-by: Paolo Bonzini --- hw/vfio/common.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index b77be3a..76cf28d 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1161,19 +1161,27 @@ static void vfio_disconnect_container(VFIOGroup *gr= oup) { VFIOContainer *container =3D group->container; =20 + QLIST_REMOVE(group, container_next); + group->container =3D NULL; + + /* + * Explicitly release the listener first before unset container, + * since unset may destroy the backend container if it's the last + * group. + */ + if (QLIST_EMPTY(&container->group_list)) { + vfio_listener_release(container); + } + if (ioctl(group->fd, VFIO_GROUP_UNSET_CONTAINER, &container->fd)) { error_report("vfio: error disconnecting group %d from container", group->groupid); } =20 - QLIST_REMOVE(group, container_next); - group->container =3D NULL; - if (QLIST_EMPTY(&container->group_list)) { VFIOAddressSpace *space =3D container->space; VFIOGuestIOMMU *giommu, *tmp; =20 - vfio_listener_release(container); QLIST_REMOVE(container, next); =20 QLIST_FOREACH_SAFE(giommu, &container->giommu_list, giommu_next, t= mp) { --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860571966995.3460196081452; Mon, 5 Feb 2018 11:56:11 -0800 (PST) Received: from localhost ([::1]:54951 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eims7-00042k-55 for importer@patchew.org; Mon, 05 Feb 2018 14:56:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSN-0004ZD-RG for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSM-00053O-OX for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:35 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:33340) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSM-00052r-Ft for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:34 -0500 Received: by mail-wr0-x241.google.com with SMTP id s5so30857596wra.0 for ; Mon, 05 Feb 2018 11:29:34 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:32 -0800 (PST) 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=duxPAdgEDwYuPdhiyDg+5L/lwS+q9MNbOkH5DGI/Ni0=; b=BElalunYvTffBK/Ha+0YJ9L7aMqxDWFthYhHlZy+f4HpRCmhmJFEueNCbYgdf/tLP4 qbk55UgIfQ85VhJMcFYVVnlwUqCyxeH76tsu1KGfL3m9rs+uNWpUUpFMya7RY6PahlN8 LyI52Aq0/Yq5TuEImDhjQXUM7RUQauGG91LrzERYHm5T/CMisxkmnwR/NLjbb/3+DRog X0bzrqQcZ/GeWoWne/1mUwxnd32hS15172gfDMrbcqZVdApgBkOfpz7mgNLhxhBHPIu5 gbgaCnRTl65EaaNbYkhJsZjyIarGih7V9CPOC/Ay+IhGbAiGh2RNYLspIdgBlUsh7Lzh xdsw== 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=duxPAdgEDwYuPdhiyDg+5L/lwS+q9MNbOkH5DGI/Ni0=; b=YQWkss+ytQ61CISHQEt2eXoyjU26NQr/IEnFzkTq3cfxS/HO8lkagEXnNwv5MleIxe 9SFOZeGVvxSdLJAWNgLUPqzIg3DARJnjgHckhaFlcUqMoNQrEwc24pbrCHKonnGpKnxl +I6W0Ddfj5/jU9ooWx4g90Ldq1Cz9CEhb8Ml5ujWrkflAjyYN4F4F0r+I7R1Y9pU1roO t95GNIWABiOCYSkTY35+HIj+miGf70CB/kNfVi1PPcSGT4Pj7CCqEJ4a+BKJoR0ybPlG G8U8pV+0ziIP+AX419Q8QyYzE/jtih+F9VpXZTzrb46BPeAN4rXI4l1tzsjKERUIq+hd eb6g== X-Gm-Message-State: AKwxytcle44WcnEwrG/ux8B0KTRWF30w/qm9hV3OJfv1Z2BmaxEqE5ew WG5JQNengi0CNhZIKqu1fnVsg8Ay X-Google-Smtp-Source: AH8x2249n11S69SQk5EjZL8LjSY2/F5DQG0Sgehc2iAKO/BDuiQFn/YoTTBpM4SYEa87KjmEDhxBWA== X-Received: by 10.223.135.184 with SMTP id b53mr37628487wrb.204.1517858973099; Mon, 05 Feb 2018 11:29:33 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:38 +0100 Message-Id: <1517858941-5538-25-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 24/47] memory: do explicit cleanup when remove listeners 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 When unregister memory listeners, we should call, e.g., region_del() (and possibly other undo operations) on every existing memory region sections there, otherwise we may leak resources that are held during the region_add(). This patch undo the stuff for the listeners, which emulates the case when the address space is set from current to an empty state. I found this problem when debugging a refcount leak issue that leads to a device unplug event lost (please see the "Bug:" line below). In that case, the leakage of resource is the PCI BAR memory region refcount. And since memory regions are not keeping their own refcount but onto their owners, so the vfio-pci device's (who is the owner of the PCI BAR memory regions) refcount is leaked, and event missing. We had encountered similar issues before and fixed in other way (ee4c112846, "vhost: Release memory references on cleanup"). This patch can be seen as a more high-level fix of similar problems that are caused by the resource leaks from memory listeners. So now we can remove the explicit unref of memory regions since that'll be done altogether during unregistering of listeners now. Bug: https://bugzilla.redhat.com/show_bug.cgi?id=3D1531393 Signed-off-by: Peter Xu Message-Id: <20180122060244.29368-5-peterx@redhat.com> Reviewed-by: Paolo Bonzini Signed-off-by: Paolo Bonzini --- hw/virtio/vhost.c | 4 ---- memory.c | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index c4f654c..d16c0c8 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1368,10 +1368,6 @@ void vhost_dev_cleanup(struct vhost_dev *hdev) if (hdev->mem) { /* those are only safe after successful init */ memory_listener_unregister(&hdev->memory_listener); - for (i =3D 0; i < hdev->n_mem_sections; ++i) { - MemoryRegionSection *section =3D &hdev->mem_sections[i]; - memory_region_unref(section->mr); - } QLIST_REMOVE(hdev, entry); } if (hdev->migration_blocker) { diff --git a/memory.c b/memory.c index 9e83496..5686698 100644 --- a/memory.c +++ b/memory.c @@ -2612,6 +2612,32 @@ static void listener_add_address_space(MemoryListene= r *listener, flatview_unref(view); } =20 +static void listener_del_address_space(MemoryListener *listener, + AddressSpace *as) +{ + FlatView *view; + FlatRange *fr; + + if (listener->begin) { + listener->begin(listener); + } + view =3D address_space_get_flatview(as); + FOR_EACH_FLAT_RANGE(fr, view) { + MemoryRegionSection section =3D section_from_flat_range(fr, view); + + if (fr->dirty_log_mask && listener->log_stop) { + listener->log_stop(listener, §ion, fr->dirty_log_mask, 0); + } + if (listener->region_del) { + listener->region_del(listener, §ion); + } + } + if (listener->commit) { + listener->commit(listener); + } + flatview_unref(view); +} + void memory_listener_register(MemoryListener *listener, AddressSpace *as) { MemoryListener *other =3D NULL; @@ -2652,6 +2678,7 @@ void memory_listener_unregister(MemoryListener *liste= ner) return; } =20 + listener_del_address_space(listener, listener->address_space); QTAILQ_REMOVE(&memory_listeners, listener, link); QTAILQ_REMOVE(&listener->address_space->listeners, listener, link_as); listener->address_space =3D NULL; --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860213768702.223094979058; Mon, 5 Feb 2018 11:50:13 -0800 (PST) Received: from localhost ([::1]:54900 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimmF-0006q4-SR for importer@patchew.org; Mon, 05 Feb 2018 14:50:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSP-0004aZ-2V for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSN-00053h-Qg for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:37 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:36858) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSN-00053U-Iy for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:35 -0500 Received: by mail-wm0-x241.google.com with SMTP id f3so28130267wmc.1 for ; Mon, 05 Feb 2018 11:29:35 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:33 -0800 (PST) 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=+sm1uQmd1WeyEGpmgDszGRfkjxoF5elWYX7UmQxRAtU=; b=anCU4ycmHzsr18Pe1hXto0K0WEwuxoOF7iSBidDn+0YX99SN7CLAPJiUskB1a4Dv4P hANUghnWkzIYSBIbQbSGWxzOqBsovA486cSYVDNeqd4JTWwpfMa2THocfhZIS65CIH94 Fx83jxE6KGLAuC7+HC3BZqSe+2zpoZz1No+gRb4FmZfKnSNDiMMH6pNMefnj1vn3wYej lnnC56Qw0ouRQ++IP/ronNLIZbScbRfFiNkK4xFBnCIEoBAxgyhS8TRDydzagUJfT8Mn ThFx2CsBP5lLeBo5MvGDrxsS5qyv87nkl1Iw97AhH5LnSRN7uIMv2f5WqUiZAq7NWEcb jfpQ== 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=+sm1uQmd1WeyEGpmgDszGRfkjxoF5elWYX7UmQxRAtU=; b=Z/Dwp8TVc7mLN2xeNSliix6qsF1ko33FdHc8tf0LZtCUA2I0ObBitESSxJLUmzBg6Z Czr5UHdhs2LFMsupV+/pT5bsvr56vjBIJ45pGH6mKLUwjBFD00kKgZu5SednnMJ9ZxnB RotP+aT4Zu6dtQxPSg67pIQZWzmCLWU3ncZLzacw1panj3CciQF6zKTj9olAUOMVyhXX pKLss80Q5xAYCyxdPddvNrtp6JpfVEu2F2XDhPEzC3W5LGrTlJ6Q33AlzEPDXlDQsmO9 a+pHb6F6IHB30C1pCOVG9a8AJWMdKBin4G1t8DMQOLAxB87DbXVayiwRNq2JHy05aqw/ TfIw== X-Gm-Message-State: APf1xPBikDMu7CImaKDumcJcig/9xhtb9cF9t3Un3b384ZUOB/YGUB8z +uGgMOqF4ntJNNkuHPi/cgbiE1lz X-Google-Smtp-Source: AH8x224yX8B2mrSqbmXyd2+D6RKpWVY/9zGG3Nq7PIjmjUXbUNa/gqPf6AlImMi1dgn0v4yB6VuOpA== X-Received: by 10.28.220.66 with SMTP id t63mr307349wmg.100.1517858974142; Mon, 05 Feb 2018 11:29:34 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:39 +0100 Message-Id: <1517858941-5538-26-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 25/47] chardev/char-socket: add POLLHUP handler 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: Klim Kireev 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: Klim Kireev The following behavior was observed for QEMU configured by libvirt to use guest agent as usual for the guests without virtio-serial driver (Windows or the guest remaining in BIOS stage). In QEMU on first connect to listen character device socket the listen socket is removed from poll just after the accept(). virtio_serial_guest_ready() returns 0 and the descriptor of the connected Unix socket is removed from poll and it will not be present in poll() until the guest will initialize the driver and change the state of the serial to "guest connected". In libvirt connect() to guest agent is performed on restart and is run under VM state lock. Connect() is blocking and can wait forever. In this case libvirt can not perform ANY operation on that VM. The bug can be easily reproduced this way: Terminal 1: qemu-system-x86_64 -m 512 -device pci-serial,chardev=3Dserial1 -chardev soc= ket,id=3Dserial1,path=3D/tmp/console.sock,server,nowait (virtio-serial and isa-serial also fit) Terminal 2: minicom -D unix\#/tmp/console.sock (type something and press enter) C-a x (to exit) Do 3 times: minicom -D unix\#/tmp/console.sock C-a x It needs 4 connections, because the first one is accepted by QEMU, then two= are queued by the kernel, and the 4th blocks. The problem is that QEMU doesn't add a read watcher after succesful read until the guest device wants to acquire recieved data, so I propose to install a separate pullhup watcher regardless of whether the device waits for data or not. Signed-off-by: Klim Kireev Message-Id: <20180125135129.9305-1-klim.kireev@virtuozzo.com> Signed-off-by: Paolo Bonzini --- chardev/char-socket.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 77cdf48..a340af6 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -42,6 +42,7 @@ typedef struct { QIOChannel *ioc; /* Client I/O channel */ QIOChannelSocket *sioc; /* Client master channel */ QIONetListener *listener; + GSource *hup_source; QCryptoTLSCreds *tls_creds; int connected; int max_size; @@ -352,6 +353,12 @@ static void tcp_chr_free_connection(Chardev *chr) s->read_msgfds_num =3D 0; } =20 + if (s->hup_source !=3D NULL) { + g_source_destroy(s->hup_source); + g_source_unref(s->hup_source); + s->hup_source =3D NULL; + } + tcp_set_msgfds(chr, NULL, 0); remove_fd_in_watch(chr); object_unref(OBJECT(s->sioc)); @@ -455,6 +462,15 @@ static gboolean tcp_chr_read(QIOChannel *chan, GIOCond= ition cond, void *opaque) return TRUE; } =20 +static gboolean tcp_chr_hup(QIOChannel *channel, + GIOCondition cond, + void *opaque) +{ + Chardev *chr =3D CHARDEV(opaque); + tcp_chr_disconnect(chr); + return G_SOURCE_REMOVE; +} + static int tcp_chr_sync_read(Chardev *chr, const uint8_t *buf, int len) { SocketChardev *s =3D SOCKET_CHARDEV(chr); @@ -528,6 +544,12 @@ static void tcp_chr_connect(void *opaque) tcp_chr_read, chr, chr->gcontext); } + + s->hup_source =3D qio_channel_create_watch(s->ioc, G_IO_HUP); + g_source_set_callback(s->hup_source, (GSourceFunc)tcp_chr_hup, + chr, NULL); + g_source_attach(s->hup_source, chr->gcontext); + qemu_chr_be_event(chr, CHR_EVENT_OPENED); } =20 --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860021779527.7188539980888; Mon, 5 Feb 2018 11:47:01 -0800 (PST) Received: from localhost ([::1]:54866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimjE-00047S-S0 for importer@patchew.org; Mon, 05 Feb 2018 14:47:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSR-0004dJ-T0 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSP-00054E-4W for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:39 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:33630) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSO-000541-TW for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:37 -0500 Received: by mail-wm0-x242.google.com with SMTP id x4-v6so14586036wmc.0 for ; Mon, 05 Feb 2018 11:29:36 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:34 -0800 (PST) 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=/BcBK52QDUslaIzvep9QkNP18vkykrhqx+VVpa2xSMs=; b=eWDmOZWCUa62XyhdIakh3/i+T10RIli/6TInodOYGTrO2a6P97WVzIEsrTstCigWMG v5O53JAUlEs/HfREdONzJLb9kpwIaDj9hhughk/ppdjt4e1IxwHL0CYOiB4rbI42YL+I EtC2S54W5L86+a8s78fKXrbcUdbl1OtS2pI2860FW4v2iiY5DzQhU2wRi1NoznLnFLen mQC8z+KpXiiiept8fx5mnALXznoxAYaBytry1FZMOkvi7CiUhHlIneCTGSmbE9PIW25X od92Si9xb7VKYcqaI/IipNrozT967zX1W9tb11gGExPRTaB32GWkEB+rNaGq1DlzYlRM nJtA== 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=/BcBK52QDUslaIzvep9QkNP18vkykrhqx+VVpa2xSMs=; b=lFfHLzBwA4sAeSr6MkM9qjrVaBdu3kcoNRscASgQvQPWrWSJH4CpzSfIUv02r2xuwG Oc+auPSfFCUSQl4uYzdsSgMrg+ho4QM8G7yAFMRtqmKnyIFIZaBUpHBQmgYJ1qx9Qucb e1/1acgLnQcJLbHN0INVnPST6waiEPw0Y7RTENWSauSgCDVqjYgiLHw4rddsPQcQJj8R 9NnW3cmzdzCjxZU2kGSx1hqk69gMwePD2/HtIcNmAYP/VHCiweOe5I2awwYApX7CEM5i 6i5MwrpR/SICrI2CQ3qdF+Y8DCalOxp7HnY6oLINz2Yjy5fKmcUTiDZsMcuXOyFIg6RW 109g== X-Gm-Message-State: APf1xPAsNRndLXhSjZOomq0uUwAYZqO8ousuJliTZJy3qGZ4cAD4MFO1 2DNtYajQq8745nc37Um1E7dYdXM9 X-Google-Smtp-Source: AH8x225yMJM578PIDbbkBp9rfs/rYzbLM2BY1knglZy1yI+AbKtq6ed1x3JzUYI8Sp3MI/02I+RFmg== X-Received: by 10.28.169.200 with SMTP id s191mr324035wme.9.1517858975554; Mon, 05 Feb 2018 11:29:35 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:40 +0100 Message-Id: <1517858941-5538-27-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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:c09::242 Subject: [Qemu-devel] [PULL 26/47] ivshmem: Don't update non-existent MSI routes 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: Ladi Prosek 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: Ladi Prosek As of commit 660c97eef6f8 ("ivshmem: use kvm irqfd for msi notifications"), QEMU crashes with: kvm_irqchip_commit_routes: Assertion `ret =3D=3D 0' failed. if the ivshmem device is configured with more vectors than what the server supports. This is caused by the ivshmem_vector_unmask() being called on vectors that have not been initialized by ivshmem_add_kvm_msi_virq(). This commit fixes it by adding a simple check to the mask and unmask callbacks. Note that the opposite mismatch, if the server supplies more vectors than what the device is configured for, is already handled and leads to output like: Too many eventfd received, device has 1 vectors To reproduce the assert, run: ivshmem-server -n 0 and QEMU with: -device ivshmem-doorbell,chardev=3Div -chardev socket,path=3D/tmp/ivshmem_socket,id=3Div then load the Windows driver, at the time of writing available at: https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/ivshmem The issue is believed to have been masked by other guest drivers, notably Linux ones, not enabling MSI-X on the device. Fixes: 660c97eef6f8 ("ivshmem: use kvm irqfd for msi notifications") Signed-off-by: Ladi Prosek Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster Message-Id: <20171211072110.9058-2-lprosek@redhat.com> Signed-off-by: Paolo Bonzini --- hw/misc/ivshmem.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 4919011..0b471d9 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -316,6 +316,10 @@ static int ivshmem_vector_unmask(PCIDevice *dev, unsig= ned vector, int ret; =20 IVSHMEM_DPRINTF("vector unmask %p %d\n", dev, vector); + if (!v->pdev) { + error_report("ivshmem: vector %d route does not exist", vector); + return -EINVAL; + } =20 ret =3D kvm_irqchip_update_msi_route(kvm_state, v->virq, msg, dev); if (ret < 0) { @@ -330,12 +334,16 @@ static void ivshmem_vector_mask(PCIDevice *dev, unsig= ned vector) { IVShmemState *s =3D IVSHMEM_COMMON(dev); EventNotifier *n =3D &s->peers[s->vm_id].eventfds[vector]; + MSIVector *v =3D &s->msi_vectors[vector]; int ret; =20 IVSHMEM_DPRINTF("vector mask %p %d\n", dev, vector); + if (!v->pdev) { + error_report("ivshmem: vector %d route does not exist", vector); + return; + } =20 - ret =3D kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, n, - s->msi_vectors[vector].vir= q); + ret =3D kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, n, v->virq); if (ret !=3D 0) { error_report("remove_irqfd_notifier_gsi failed"); } --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860375714903.8804702446502; Mon, 5 Feb 2018 11:52:55 -0800 (PST) Received: from localhost ([::1]:54925 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimow-0000wb-SU for importer@patchew.org; Mon, 05 Feb 2018 14:52:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSR-0004dN-Tp for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSQ-00054a-8b for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:39 -0500 Received: from mail-wr0-x22f.google.com ([2a00:1450:400c:c0c::22f]:37775) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSQ-00054M-1Q for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:38 -0500 Received: by mail-wr0-x22f.google.com with SMTP id a43so23273386wrc.4 for ; Mon, 05 Feb 2018 11:29:37 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:35 -0800 (PST) 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=Jem13yd952MepaFHkWvQJXBwnlImBJSSf/Bn/4DDSR0=; b=hGkBp+7OBERzRp1VgFHJkQ7LTnSoHwaoVLi3iGIxtINqcsQ/o+ps6BVHx19cDX33DO jpuZvKHAHhGUX0L58N1I6jRT77O+86CExK+AJTDzXM577WRR1PnDtayRnS0cKLrJJc1w Mq2fZGm1SR1lSFNUZhhNY6wQBrTmcw314d2L0UtzbZxpvK4+tI4oEJQheq445ysjOp21 v5oHzmZNB2XGjv5CXSDmG5L4fAvSXSzchwgYNSBKXPDtkzCLPc210xQ9jq87GY+fuKl9 B/SU4faYEpwz8Ms6ycI5JTRR+GH8Hn/lJfdVcDykwen5WYkEtgE5Z2hPn4kPaKIUEhII px1g== 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=Jem13yd952MepaFHkWvQJXBwnlImBJSSf/Bn/4DDSR0=; b=r3F9TxHbpiSRb0oGSYpSkfcbNF/tX4oqH9bzu0y/a4gosKPLEJ7n/2aHUz9KN71Gkb qfGxOF11JmyXPxAhVtIC8iU8PVm6koy2/4rrOSFl+4DU69zknskJxhUe43GfIGlRcFxt 36zJ1sglnsfGHlcKXXjY1PW/1wpcEVvUiow+S+/FZ4nqoBGYzAwPBrIxq8BY5fxyNGdl N8Lt2vvxCLKx+qZ9NeyGUmMmLNcXC7nSEaRaC6l623EsxiL8omj0bc6ZA3oT6A8YZzVk y0eS1Cdcr/DX4h8RQ5TargStkVcip31n2qMl9asyN8pZWAl12JAySyPPS5RMl1zOAKDa s6NA== X-Gm-Message-State: AKwxytepO0cNaATcG2zdhfU9v5bgYK7FCLXBonlXQH+x+LTMD1hWfPLf UYDfR+U/p1SAHW3reDMxbI8OxyLA X-Google-Smtp-Source: AH8x224YJjyZ4at99wWVsQsNGqN3kGMoxyXK60HGc7/EKUhvxB46loadXM2z6qVoPim7cZoaeV7qZw== X-Received: by 10.223.184.213 with SMTP id c21mr36356633wrg.57.1517858976629; Mon, 05 Feb 2018 11:29:36 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:41 +0100 Message-Id: <1517858941-5538-28-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 27/47] ivshmem: Always remove irqfd notifiers 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: Ladi Prosek 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: Ladi Prosek As of commit 660c97eef6f8 ("ivshmem: use kvm irqfd for msi notifications"), QEMU crashes with: ivshmem: msix_set_vector_notifiers failed msix_unset_vector_notifiers: Assertion `dev->msix_vector_use_notifier && de= v->msix_vector_release_notifier' failed. if MSI-X is repeatedly enabled and disabled on the ivshmem device, for exam= ple by loading and unloading the Windows ivshmem driver. This is because msix_unset_vector_notifiers() doesn't call any of the release notifier call= backs since MSI-X is already disabled at that point (msix_enabled() returning fal= se is how this transition is detected in the first place). Thus ivshmem_vector= _mask() doesn't run and when MSI-X is subsequently enabled again ivshmem_vector_unm= ask() fails. This is fixed by keeping track of unmasked vectors and making sure that ivshmem_vector_mask() always runs on MSI-X disable. Fixes: 660c97eef6f8 ("ivshmem: use kvm irqfd for msi notifications") Signed-off-by: Ladi Prosek Reviewed-by: Markus Armbruster Message-Id: <20171211072110.9058-3-lprosek@redhat.com> Signed-off-by: Paolo Bonzini --- hw/misc/ivshmem.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 0b471d9..95e85e4 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -76,6 +76,7 @@ typedef struct Peer { typedef struct MSIVector { PCIDevice *pdev; int virq; + bool unmasked; } MSIVector; =20 typedef struct IVShmemState { @@ -320,6 +321,7 @@ static int ivshmem_vector_unmask(PCIDevice *dev, unsign= ed vector, error_report("ivshmem: vector %d route does not exist", vector); return -EINVAL; } + assert(!v->unmasked); =20 ret =3D kvm_irqchip_update_msi_route(kvm_state, v->virq, msg, dev); if (ret < 0) { @@ -327,7 +329,13 @@ static int ivshmem_vector_unmask(PCIDevice *dev, unsig= ned vector, } kvm_irqchip_commit_routes(kvm_state); =20 - return kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, NULL, v->virq); + ret =3D kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, NULL, v->virq= ); + if (ret < 0) { + return ret; + } + v->unmasked =3D true; + + return 0; } =20 static void ivshmem_vector_mask(PCIDevice *dev, unsigned vector) @@ -342,11 +350,14 @@ static void ivshmem_vector_mask(PCIDevice *dev, unsig= ned vector) error_report("ivshmem: vector %d route does not exist", vector); return; } + assert(v->unmasked); =20 ret =3D kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, n, v->virq); - if (ret !=3D 0) { + if (ret < 0) { error_report("remove_irqfd_notifier_gsi failed"); + return; } + v->unmasked =3D false; } =20 static void ivshmem_vector_poll(PCIDevice *dev, @@ -816,11 +827,20 @@ static void ivshmem_disable_irqfd(IVShmemState *s) PCIDevice *pdev =3D PCI_DEVICE(s); int i; =20 + msix_unset_vector_notifiers(pdev); + for (i =3D 0; i < s->peers[s->vm_id].nb_eventfds; i++) { + /* + * MSI-X is already disabled here so msix_unset_vector_notifiers() + * didn't call our release notifier. Do it now to keep our masks = and + * unmasks balanced. + */ + if (s->msi_vectors[i].unmasked) { + ivshmem_vector_mask(pdev, i); + } ivshmem_remove_kvm_msi_virq(s, i); } =20 - msix_unset_vector_notifiers(pdev); } =20 static void ivshmem_write_config(PCIDevice *pdev, uint32_t address, --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860555571665.5037091849316; Mon, 5 Feb 2018 11:55:55 -0800 (PST) Received: from localhost ([::1]:54946 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimrg-0003bJ-7s for importer@patchew.org; Mon, 05 Feb 2018 14:55:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSS-0004eE-OR for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSR-000553-FH for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:40 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:55659) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSR-00054g-7n for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:39 -0500 Received: by mail-wm0-x244.google.com with SMTP id 143so28225646wma.5 for ; Mon, 05 Feb 2018 11:29:39 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:37 -0800 (PST) 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=62JDn1g3Yq8CJid9S66wLSXdmUGYN1Se6/uUtICu6gU=; b=MaPA6zwqZxCpqPN33s0MvRe5HGwN7c35uEo1HfvznlC1qHQ/KHc6V1fQoIDveiB5lH PZzS9tLHkCjVhY+opOc3IYdoIYT/o4VweJP59mu9tXUDqJ/BzP0GVzYd3ktRBORQrdxl GIrjCn/r5Vs5ziwzm9mMW60ATB3RKAiMdC4KAEOcf2+F2k1VYGrInxMkM4YADdlSrIDQ hmsN/bsKkI6zkJwr4onoJmKaKjf/GGvF9OMkzKHLgHZLneNvWRi5YypP1Fk9QZpNYqoO wyANSwNC122ax55uZ6HzkHGat7vpwPdW++lB/hAXSIacNUSwYdf4BSW/q1XhvoL6nKiK np2A== 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=62JDn1g3Yq8CJid9S66wLSXdmUGYN1Se6/uUtICu6gU=; b=MB9OVBGESjisvA6vPmzNVTBy9CAUYhk5MFsqAScnlL7zEyhLYvQ0HFt6UzqN6UOPJu ByHxQxFfrxkG91XyZnq08243Lc12+6VBIIqvDjBDQ0udnKwfDqeL7wz/CZacadW0crlk lVgo+zy08v9em5h34k2+1EMq61Aw24QB7ryvxEz3na7bkE9kLxRUrw6P9zRuwiwlqRP6 AJNjTYIm88PSikpYOlModItHUE9LChJOcY805PQh3WGT9SgXS8L62SBu+u80TC8yNMQF QruDHnq2lP49nFdcDtQmLY33PNO9CZSy9dCOGbtzwW8SN403785s/Q8j+3Qz7K369o5L 8fww== X-Gm-Message-State: APf1xPAwnDRIwLTLLnbkZb+yPQ/MpWInLB8oDvQ9kOEXulil9hbC5+My pOdL1uJObHLuwSdS5nKGGzAOSCUj X-Google-Smtp-Source: AH8x226lLsUaR1c0QNwh8yhFWJlItfRZOoVjzZhn1XmW29MBbkeLF2VHFFzunz2P83sD7gljPM1eyA== X-Received: by 10.28.20.206 with SMTP id 197mr282508wmu.19.1517858977795; Mon, 05 Feb 2018 11:29:37 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:42 +0100 Message-Id: <1517858941-5538-29-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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::244 Subject: [Qemu-devel] [PULL 28/47] ivshmem: Improve MSI irqfd error 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: Ladi Prosek 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: Ladi Prosek Adds a rollback path to ivshmem_enable_irqfd() and fixes ivshmem_disable_irqfd() to bail if irqfd has not been enabled. To reproduce, run: ivshmem-server -n 0 and QEMU with: -device ivshmem-doorbell,chardev=3Div -chardev socket,path=3D/tmp/ivshmem_socket,id=3Div then load, unload, and load again the Windows driver, at the time of writing available at: https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/ivshmem The issue is believed to have been masked by other guest drivers, notably Linux ones, not enabling MSI-X on the device. Signed-off-by: Ladi Prosek Reviewed-by: Markus Armbruster Message-Id: <20171211072110.9058-4-lprosek@redhat.com> Signed-off-by: Paolo Bonzini --- hw/misc/ivshmem.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 95e85e4..fe1d8d1 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -785,6 +785,20 @@ static int ivshmem_setup_interrupts(IVShmemState *s, E= rror **errp) return 0; } =20 +static void ivshmem_remove_kvm_msi_virq(IVShmemState *s, int vector) +{ + IVSHMEM_DPRINTF("ivshmem_remove_kvm_msi_virq vector:%d\n", vector); + + if (s->msi_vectors[vector].pdev =3D=3D NULL) { + return; + } + + /* it was cleaned when masked in the frontend. */ + kvm_irqchip_release_virq(kvm_state, s->msi_vectors[vector].virq); + + s->msi_vectors[vector].pdev =3D NULL; +} + static void ivshmem_enable_irqfd(IVShmemState *s) { PCIDevice *pdev =3D PCI_DEVICE(s); @@ -796,7 +810,7 @@ static void ivshmem_enable_irqfd(IVShmemState *s) ivshmem_add_kvm_msi_virq(s, i, &err); if (err) { error_report_err(err); - /* TODO do we need to handle the error? */ + goto undo; } } =20 @@ -805,21 +819,14 @@ static void ivshmem_enable_irqfd(IVShmemState *s) ivshmem_vector_mask, ivshmem_vector_poll)) { error_report("ivshmem: msix_set_vector_notifiers failed"); + goto undo; } -} + return; =20 -static void ivshmem_remove_kvm_msi_virq(IVShmemState *s, int vector) -{ - IVSHMEM_DPRINTF("ivshmem_remove_kvm_msi_virq vector:%d\n", vector); - - if (s->msi_vectors[vector].pdev =3D=3D NULL) { - return; +undo: + while (--i >=3D 0) { + ivshmem_remove_kvm_msi_virq(s, i); } - - /* it was cleaned when masked in the frontend. */ - kvm_irqchip_release_virq(kvm_state, s->msi_vectors[vector].virq); - - s->msi_vectors[vector].pdev =3D NULL; } =20 static void ivshmem_disable_irqfd(IVShmemState *s) @@ -827,6 +834,10 @@ static void ivshmem_disable_irqfd(IVShmemState *s) PCIDevice *pdev =3D PCI_DEVICE(s); int i; =20 + if (!pdev->msix_vector_use_notifier) { + return; + } + msix_unset_vector_notifiers(pdev); =20 for (i =3D 0; i < s->peers[s->vm_id].nb_eventfds; i++) { --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860210895121.60576632228481; Mon, 5 Feb 2018 11:50:10 -0800 (PST) Received: from localhost ([::1]:54899 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimm9-0006ng-Jy for importer@patchew.org; Mon, 05 Feb 2018 14:50:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimST-0004f7-F4 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSS-00055R-F2 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:41 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:44261) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSS-000559-7n for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:40 -0500 Received: by mail-wr0-x244.google.com with SMTP id v31so30823550wrc.11 for ; Mon, 05 Feb 2018 11:29:40 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:38 -0800 (PST) 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=MP54IJI95co9B4VzCAdbd2nkHR3OwYYVcYo5SiJ80RU=; b=ciF74+dkuM/cRX//6YR4LXIpYKuUQ/cslgtQaffoM00E56gOfW2Dz8spS9JH8/BiiI /c+rActoA8E7awzj1ExYzf2Cd8lkLAIhXLyj/rAaKDOl7a3cDBatydEBiXqPRjlPAfVT 1S7INM7a3r+Tf3oZWE1q+XETKWStmFN1C4abuSzvtqaRvqICr7FUO1BdRsFBTvQKbI58 TXYguvWYIbMyokX7JC76VAtL0s0t/hdhw0UL9nh21hdsUTXdxhAYx06B669uhXKxy2mk FxAlyhrF+3j15UWgD0RKtMSjh/ZeFUHBv999sBvioH3bwKAWl3onHlPdMOWiCS17REQM 9+fw== 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=MP54IJI95co9B4VzCAdbd2nkHR3OwYYVcYo5SiJ80RU=; b=Mcy1Ed/xTJUWWGqBz9dRNPUkOcx35lvQnaR1hMD9Tge6hWryiObKx3uTEDvHtc2xzE e1TEvKnQfeXZouLqZpEfJWlQ2mFykql/7g/TSMlVy0sVQdrVarqqV+vAVThGi8jOZBiP 15eXKJlfmN6oJFP6rNYtEylQdrHSlmjwT8tSH5i4m9TpNN3bBT+QNzggj0TGYBojWDM7 8ziN3SbOhwID64O/1Vb5gH9iFR18Dd6qI2pynMWDaqxapfgcyT9cWd7gQeGrHVUwkqVU FMIVwv1Wj7RnDyhIqiDoejv00WJkxS6Y/3d8Zx5YibGcDe/MxFK52dFgz7qfMtZ9k6hm iMeA== X-Gm-Message-State: AKwxytfZbyfCOSuJJVR3C37I1KwmJJ2v9vfqwlOWh6wpgeGzcjRcprN4 G3rP895E1tar8nw8C1oNtsevMy8w X-Google-Smtp-Source: AH8x227LsJMIwGoEC0a99pCeMGKG875NqazaL/+yvanfyaWTA2qV5ph+Yr/qyNivthQs7t0QxVYv6w== X-Received: by 10.223.199.71 with SMTP id b7mr12289981wrh.89.1517858978909; Mon, 05 Feb 2018 11:29:38 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:43 +0100 Message-Id: <1517858941-5538-30-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 29/47] ivshmem: Disable irqfd on device reset 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: Ladi Prosek 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: Ladi Prosek The effects of ivshmem_enable_irqfd() was not undone on device reset. This manifested as: ivshmem_add_kvm_msi_virq: Assertion `!s->msi_vectors[vector].pdev' failed. when irqfd was enabled before reset and then enabled again after reset, mak= ing ivshmem_enable_irqfd() run for the second time. To reproduce, run: ivshmem-server and QEMU with: -device ivshmem-doorbell,chardev=3Div -chardev socket,path=3D/tmp/ivshmem_socket,id=3Div then install the Windows driver, at the time of writing available at: https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/ivshmem and crash-reboot the guest by inducing a BSOD. Signed-off-by: Ladi Prosek Message-Id: <20171211072110.9058-5-lprosek@redhat.com> Signed-off-by: Paolo Bonzini --- hw/misc/ivshmem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index fe1d8d1..16f0370 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -757,10 +757,14 @@ static void ivshmem_msix_vector_use(IVShmemState *s) } } =20 +static void ivshmem_disable_irqfd(IVShmemState *s); + static void ivshmem_reset(DeviceState *d) { IVShmemState *s =3D IVSHMEM_COMMON(d); =20 + ivshmem_disable_irqfd(s); + s->intrstatus =3D 0; s->intrmask =3D 0; if (ivshmem_has_feature(s, IVSHMEM_MSI)) { --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860376322683.6054348225636; Mon, 5 Feb 2018 11:52:56 -0800 (PST) Received: from localhost ([::1]:54924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimov-0000ul-0I for importer@patchew.org; Mon, 05 Feb 2018 14:52:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSU-0004gU-Gc for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimST-00055t-M9 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:42 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33630) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimST-00055f-Fj for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:41 -0500 Received: by mail-wm0-x241.google.com with SMTP id x4-v6so14586362wmc.0 for ; Mon, 05 Feb 2018 11:29:41 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:39 -0800 (PST) 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=7Suhzx1G0BczQ9t0tuMGG42VKRRcEbsYC2Kilrn26rA=; b=r9k03Xpkp0kgeMx91kOeJcSrt/wPFUCB0c4h5xXN0PBC0bSGdSAvcFepW2ni/oSNvy pUivaZqd7UnYfeMZicVWIfG628/K3qV5gAMbY0d104yqrhMCApQfY40yEsygPpoXWsZv 3Ce0orwJoC//hkcZxLxr7Nj2DDHDQP3AWe++uO1TQfANBaDs+mjVFX3ewna1EmACdS8C AqrDxjGh3RqzUg+tzCfXRFFs+/D/IF5LNQqAHqRfhMRD0EJMyQCJYcjy26Q5uwW1Mj5P RyY9SgkLzWOrTwSE8TZOCy/I9tVT7aQH6B8EgpRSPl8WTL/K+3t/O2AwiKMT5Ci4mjaf 2OJg== 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=7Suhzx1G0BczQ9t0tuMGG42VKRRcEbsYC2Kilrn26rA=; b=HYiP/6eQH2qd0CugWSc4Hgd5u0Q5+0czrer762jG4lzWYV1cStm4hC5Xo9DQOVbnfH gupnoEWjrRKjcHft6izaIuJjZsddwrCMkA5XsAnzv9b/EfeDdSh0HPHKu3urCFi6L0Yy fQftBpyR6JzkAh8+s695NK8FDD3YdpEpqru7m/ee0VryTX1Z4tudIIOQ+YQGWMPa0M8f ufnNkDrJ8FR67oD4TogSIFc14oHeGdYZ0n9w5PghDCvtmJ3j3hS9tNhwXI3HWvB9iave xQ+Kt9Vt0bWQh/S44+PV9CeEskiUk6ByTg5F4egmOsnB4UrvjqdZmMyhA7o0EhKLvyzv cqcQ== X-Gm-Message-State: APf1xPA/HgJ7XA7Mnf6fTl+/6iwtAUCC/+2XxX5EWIA9Am08S/KVbpkm CQn8EB9PNsidKrptHHqrvDSDsP8u X-Google-Smtp-Source: AH8x225LV1zi4h7jMJAspPHzAdNTx44yjYh7r4iGbNXIC8TJeLXyXsH56E5Os72aBF7/o+F+gETvkA== X-Received: by 10.28.47.73 with SMTP id v70mr328047wmv.41.1517858980141; Mon, 05 Feb 2018 11:29:40 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:44 +0100 Message-Id: <1517858941-5538-31-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 30/47] cpus: hax: register/unregister thread with RCU, exit loop on 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: , 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 --- cpus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cpus.c b/cpus.c index 2cb0af9..08a8462 100644 --- a/cpus.c +++ b/cpus.c @@ -1473,6 +1473,7 @@ static void *qemu_hax_cpu_thread_fn(void *arg) CPUState *cpu =3D arg; int r; =20 + rcu_register_thread(); qemu_mutex_lock_iothread(); qemu_thread_get_self(cpu->thread); =20 @@ -1484,7 +1485,7 @@ static void *qemu_hax_cpu_thread_fn(void *arg) hax_init_vcpu(cpu); qemu_cond_signal(&qemu_cpu_cond); =20 - while (1) { + do { if (cpu_can_run(cpu)) { r =3D hax_smp_cpu_exec(cpu); if (r =3D=3D EXCP_DEBUG) { @@ -1493,7 +1494,8 @@ static void *qemu_hax_cpu_thread_fn(void *arg) } =20 qemu_wait_io_event(cpu); - } + } while (!cpu->unplug || cpu_can_run(cpu)); + rcu_unregister_thread(); return NULL; } =20 --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860264374560.374554683187; Mon, 5 Feb 2018 11:51:04 -0800 (PST) Received: from localhost ([::1]:54908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimn9-0007mi-HC for importer@patchew.org; Mon, 05 Feb 2018 14:51:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSV-0004hU-GM for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSU-00056W-SZ for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:43 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:33344) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSU-000562-L5 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:42 -0500 Received: by mail-wr0-x244.google.com with SMTP id s5so30857966wra.0 for ; Mon, 05 Feb 2018 11:29:42 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:40 -0800 (PST) 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=DIj29L6RO71rSyYRSt1PIYo0LB9jVXqxYAJNw0mt4zc=; b=HbYNkYol9qLUyEaRkT8eEodbICmvoVj+DNqE2Qs2V5p9R0l9pOR018mTKWbX1Z3X7J 7kjb2rPqCq7MyC5UlniVX60uQP8G4e1W4LL+xSYzPT/9IWLoSBhBA+xYH7CRnmSemLaZ 1/6GVXs8oYYnOm9LR4qu5K+fEgDfDNqBo0N3iCuxi1+x3jej2DxKn1Ut15dNEx3npIDL AT7URI41+a9v8uNzutocIpQa5u7i0z5LU2TMfBJxuQ3TmPRPCP5nE462r/8tpm0GNNNM 0qSn6PhBARTpxGQBtmnHxcVFo/L9/89MVI08PJKOfRJflVAMczfzhuYs7ELkYSRQycWo +Fxg== 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=DIj29L6RO71rSyYRSt1PIYo0LB9jVXqxYAJNw0mt4zc=; b=DTGEnNG9D8es063w2uCML6CMo2QhrAZev/7uOFE9xEswtegi/60loDfXyIdqWOJ86k YSQza2F/UlZ95HirIR6yd51F2GbdOWXoLl9TqM0AE2ZqhdXheGYG6vEe052UrA7y2z4j 9ryZ90PbFw+KfyBwndLoNZ8bsYML8hj1Yv/cwXiwxnZQ+f7h3casy8A1f1UCezdlnLGK ZZ5KByK4te9rTDEIqTf88Ipm+qbWu2hnaZbZRKAs+8lIzOsgyXvtR4M7jp9mWutjqecM h1vBy5URXldBP521pw1WKsJKUxu0PMuJUz14cyZ009BawtgoH/UnVeGMWdMeMJoYb0AW JMvw== X-Gm-Message-State: AKwxyteS9brgazjt2iEEcrgu8T7nLmAEGx3iWrKwLVTrqnAlp9e/Biup XNIjd3i21XrdAea0jjyh08+DTcUw X-Google-Smtp-Source: AH8x2242vnYONw+hTzdCb/MMymhcLmrICz33BuHIZ+yRwiyv/XjWXAbSeMVXoCqUFCSZXcHjMZX/yw== X-Received: by 10.223.190.143 with SMTP id i15mr26198107wrh.145.1517858981257; Mon, 05 Feb 2018 11:29:41 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:45 +0100 Message-Id: <1517858941-5538-32-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 31/47] cpus: kvm: unregister thread with RCU 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 --- cpus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpus.c b/cpus.c index 08a8462..1063dac 100644 --- a/cpus.c +++ b/cpus.c @@ -1205,6 +1205,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg) cpu->created =3D false; qemu_cond_signal(&qemu_cpu_cond); qemu_mutex_unlock_iothread(); + rcu_unregister_thread(); return NULL; } =20 --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860737622356.6088140368072; Mon, 5 Feb 2018 11:58:57 -0800 (PST) Received: from localhost ([::1]:54979 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimum-0006TJ-Jn for importer@patchew.org; Mon, 05 Feb 2018 14:58:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSW-0004iy-PL for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSW-000572-0u for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:44 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:38691) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSV-00056r-Ps for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:43 -0500 Received: by mail-wm0-x242.google.com with SMTP id 141so27959696wme.3 for ; Mon, 05 Feb 2018 11:29:43 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:41 -0800 (PST) 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=BEIbBrMt0Q7AOi3hQXLUmv/BeFE+PR4W1+CZ+LeGXrM=; b=mQvgzT9uSkDuGquTLlNBECrSA8ZXAXUuSDJZCOgy44WAKRCDiutor16GFt+jNyGjmE IO+v97ctrMablMrztYlWvPgC6fCeorpRTAOEqiN1XEMjU/mkQTLA83jN6gos1MTLGGYD 6DByXHJcFf0yENBfRy0Yj5iba6p3QGln9BOl1JDVqXz6p5aJrxbbHPGyGCdv5NcJRG9y sRgALGG2+l9Fq4mU2V/rzRLOx1NG7mba2eUPAnf531osgOT+r2n8Tk3Mxw7xtQNtzn4k MdtjkNaGC7ayThXSKXJBLTfTip3Q286iaBCCidSBRTUDIIfZjFW9jwVC8knB/hACsUxC NiYg== 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=BEIbBrMt0Q7AOi3hQXLUmv/BeFE+PR4W1+CZ+LeGXrM=; b=svUMn7t6SjgtnAtSQCfEK9+ianpdZS00yKx1X2UZwy9qDAFg1+VLHiQUxdaVnp/XcT xdV0R0XTZbBW+iuu6Yx3F51j0KxLoMIOkVIYMUWbfiA/j5TOUbp+LlHzO3EFVfWD8VLh Y/akCpZybc/XV9Lhwr+5OoCF9FuL/iMbuBrpdP4pXR3gIIepBNOh2Bq+rR8n6EpDBpQu XYBU39sbhOqQEfHbTK6hbr8Wr0OfOInGDY36HlgEheEzqXRYmxBrPMqCC8TcMHaR1YO/ /y5joLqB5wmSmslgnKjdfZrSs+W7OUy0hEsVdTn3hPYjWjbXaG47ZnsTcT0jADVZMHWJ 7b2A== X-Gm-Message-State: APf1xPDIlyL+c1iuLB34H5V48hqSmrsGfx471F04EpxrNcymmMzPQ+10 OaFTEpVRjDcETHQYPKzWPL/71j/H X-Google-Smtp-Source: AH8x2250rHrmb8x1P6D/cRBVimXhCfePuXWMAm3oT7osi+5LuXvOKjz5c+b7hoPWGszscq/NZ/XV/g== X-Received: by 10.28.147.196 with SMTP id v187mr359141wmd.128.1517858982469; Mon, 05 Feb 2018 11:29:42 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:46 +0100 Message-Id: <1517858941-5538-33-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 32/47] cpus: dummy: unregister thread with RCU, exit loop on 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: , 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 --- cpus.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cpus.c b/cpus.c index 1063dac..190ad5a 100644 --- a/cpus.c +++ b/cpus.c @@ -1234,7 +1234,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) cpu->created =3D true; qemu_cond_signal(&qemu_cpu_cond); =20 - while (1) { + do { qemu_mutex_unlock_iothread(); do { int sig; @@ -1246,8 +1246,9 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) } qemu_mutex_lock_iothread(); qemu_wait_io_event(cpu); - } + } while (!cpu->unplug); =20 + rcu_unregister_thread(); return NULL; #endif } --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860602433313.5854330740864; Mon, 5 Feb 2018 11:56:42 -0800 (PST) Received: from localhost ([::1]:54952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimsb-0004VK-Hy for importer@patchew.org; Mon, 05 Feb 2018 14:56:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSb-0004np-0Z for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSX-00057S-2I for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:49 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:38692) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSW-000579-QX for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:44 -0500 Received: by mail-wm0-x243.google.com with SMTP id 141so27959789wme.3 for ; Mon, 05 Feb 2018 11:29:44 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:42 -0800 (PST) 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=q6dT5ZEbYgVMr5DUowL6yhGthRWsCbbzKOArewmM3rE=; b=l7KbnCoDh5XSKBguDav2BEyatJ9jitoUq8sZUunp8Gt4eDpMLP5HYdRZsgFGCKm7RD tDH0bGTjHF2CJrDSK76NJtcYi49k0MSLfjVrldwe7aM0XM1hfuXGqHKnnYVTu7y16GWB +IZiboyC4TM58QxOBW9mclDh4N2NNCNtqW8yCulid0hfjuHuxEdb7v+5/zjiyfQHr6zr xCu5gvJOFO/gRdaym0K43Gf57Amg2dr3jRMbnjFzEL031nPWMm771vQrb371o1IJ2UBA 4GMMftI17uFHRrW1g7g6kxE/QHjIDWrz6dhhIdlCae5j/k+oHkS0O6kpcUO6PPHCLf1/ TeIg== 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=q6dT5ZEbYgVMr5DUowL6yhGthRWsCbbzKOArewmM3rE=; b=Zck6QguZqCts5fb9uu3zlGdxpjomDORKC0S4dNJzSdWD9KlaT4XPiAvr4rKsYQ8l7f sp4Nqrrra24vj0lZa6IzI7ImjvNznWAw+A9QmZvDf9RHP/VTaoc5nw/W3CjPI9OpMQQQ lziB3v8nmveh5hQ9n4HUQimzGTzVRtLsNVgjgMlYut+SChXT3BCFW5VztJuhZD0STfzi x/jy+A7tUhN7fgoOzZYDqjlJiXhPFpXHsv8GsNkURykJBfIEUaM/m6n/fFxZNIq86d68 TFsmtZnpJiJtWe/JE5pcFNFa9IsINmXJBAgtysCtSkKRAfg/Na7vxZM/c2NKnUY0lRPk mTQA== X-Gm-Message-State: APf1xPARuELIkogk/va6vmJuwbWL8BqS9bILvvfkEeqgyWwsWUAlSjjp fx2ZKCoF5jnBllsC4PlwEq1a2iui X-Google-Smtp-Source: AH8x224NsMoWZW+0xbKgVEfN9lOnh8Ayu9yIDuzk7V3rgm9HS7JgI1Y5ewV4Nu7/Y6ShfGntfu89Qw== X-Received: by 10.28.22.201 with SMTP id 192mr295710wmw.45.1517858983485; Mon, 05 Feb 2018 11:29:43 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:47 +0100 Message-Id: <1517858941-5538-34-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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::243 Subject: [Qemu-devel] [PULL 33/47] cpus: tcg: unregister thread with RCU, fix exiting of loop on 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: , 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" Keep running until cpu_can_run(cpu) becomes false, for consistency with other acceslerators. Signed-off-by: Paolo Bonzini --- cpus.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cpus.c b/cpus.c index 190ad5a..269d527 100644 --- a/cpus.c +++ b/cpus.c @@ -1467,6 +1467,7 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg) deal_with_unplugged_cpus(); } =20 + rcu_unregister_thread(); return NULL; } =20 @@ -1603,18 +1604,17 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) /* Ignore everything else? */ break; } - } else if (cpu->unplug) { - qemu_tcg_destroy_vcpu(cpu); - cpu->created =3D false; - qemu_cond_signal(&qemu_cpu_cond); - qemu_mutex_unlock_iothread(); - return NULL; } =20 atomic_mb_set(&cpu->exit_request, 0); qemu_wait_io_event(cpu); - } + } while (!cpu->unplug || cpu_can_run(cpu)); =20 + qemu_tcg_destroy_vcpu(cpu); + cpu->created =3D false; + qemu_cond_signal(&qemu_cpu_cond); + qemu_mutex_unlock_iothread(); + rcu_unregister_thread(); return NULL; } =20 --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860437135721.3672194690058; Mon, 5 Feb 2018 11:53:57 -0800 (PST) Received: from localhost ([::1]:54928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimpw-0001qa-9y for importer@patchew.org; Mon, 05 Feb 2018 14:53:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSb-0004nn-07 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSY-00057l-4q for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:49 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:33632) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSX-00057b-Ub for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:46 -0500 Received: by mail-wm0-x243.google.com with SMTP id x4-v6so14586666wmc.0 for ; Mon, 05 Feb 2018 11:29:45 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:43 -0800 (PST) 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=c/zrBucjLezDQPhcZVbqcdvP4b7C+Xx6b9cSS9uRzDs=; b=PDyUwcDUnJUiXunjq215nQMH5O1jtvHVlR5kGzPhY7WcxoNE72Alx8rwfFJV/BfJDo 9xZSJwlbbbkJXal2zOQ9fBhx3fAaBiPsSOB5ZQ48jd12lqoBWIyOdeoRCOydBtLLouun YhqhMzOnW+AaohTKGCQhruoFfGXnqc4HQs5vLpDfD6eAFaaFkP4i6FsR/wc00f72XW/8 4aNwtO4sO7trRqjuz/Kvf9Yzl+eA+YtxzUtaOFi84wM9h23hzw41MLCh7LfqQ+euRZ0J VGgWhUeoCp0rpBWT21nGDnpgi+f8uwQeMvI+8Zxa+6BTsaUO3hSr23Q7s1WQj6qZMgeN NVlA== 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=c/zrBucjLezDQPhcZVbqcdvP4b7C+Xx6b9cSS9uRzDs=; b=I4mJael0vH4NruOpQnoU7bu6TEbfaBFEsyjn5noSsW8DZ8d/fgrrkOQHSloWdWwNcH PqREKPjTBJR9iFI1hP1ZqB7j+STJhYk5nT49hi2gpV2jLG24eW0Y+PVq+m0qgBBysvRu Rhtv0d+W8Q9nwIH1ASZAIKVixPTIqs5Klf+yQKAxnTAc8jVgVRbXAX1TV+FMQqHXIzlo V1QZ3Fh0RfjDa90MArXjS5sM6rZnNsUs1hKxI58GBbIpGwRKzFW+NCdYPj3aic5EAVbV ZBZ4Y0ZVhO6cMIewcu9T5Pcn2wDG1WREFtfUwUSIsE/dznhMOHtUqC756Tf+1b9KSNbs VFGQ== X-Gm-Message-State: APf1xPBxHolLuHxT/73kXITIWjsi7/ChmK8QfFCpKhiJOw5rb7sOOTN+ GE2OiaqE3b/xEhyGV+N4xitQvtHs X-Google-Smtp-Source: AH8x225oUKh5bA5YV1VQxlmerna4ClijxljT+kPehq/3/btXp4C2mgRtmej6E2frF+Q1Dr/dFVDOIQ== X-Received: by 10.28.183.8 with SMTP id h8mr339778wmf.72.1517858984619; Mon, 05 Feb 2018 11:29:44 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:48 +0100 Message-Id: <1517858941-5538-35-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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::243 Subject: [Qemu-devel] [PULL 34/47] cpus: hvf: unregister thread with RCU 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 --- cpus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpus.c b/cpus.c index 269d527..fe127ac 100644 --- a/cpus.c +++ b/cpus.c @@ -1541,6 +1541,7 @@ static void *qemu_hvf_cpu_thread_fn(void *arg) cpu->created =3D false; qemu_cond_signal(&qemu_cpu_cond); qemu_mutex_unlock_iothread(); + rcu_unregister_thread(); return NULL; } =20 --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860771392363.62791582974126; Mon, 5 Feb 2018 11:59:31 -0800 (PST) Received: from localhost ([::1]:54980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimvH-0006uc-CH for importer@patchew.org; Mon, 05 Feb 2018 14:59:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSb-0004no-0B for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSZ-000586-83 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:49 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:40267) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSZ-00057w-0U for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:47 -0500 Received: by mail-wr0-x242.google.com with SMTP id i56so30829121wra.7 for ; Mon, 05 Feb 2018 11:29:46 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:44 -0800 (PST) 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=x5MYHsc7NtHgb7srTO4LKsshNaqbEndMQs6j3A3SvY8=; b=EeXuhem/l40tZysXtCE6Syu0Z84IaA01GqhnWXWbNn6ByGWEKWEmWkhg13qzt3ySwf TR3p5y+pEady1Dquiz6Zsro1fMdGHk6txTt69LH0QQaSjRFc0+Lvr2WOvQJsqz8j3kMx jBRsK/NFW+xdqC6E1ioIG8huOri++Ji2uoGtN88w+QvfckhMCZozOATSg94nzuZAnwy+ NK0xnywEa6OCVcfb6eCKBScpjVgAiNWQL8q/zasbWA+4j8iwyilUR0CvfhuO7vGinPLB LHBoD4vmhpzgqTPjxRL0gfovyVsTMenkQaQTLbdzeg1ffy6oCftA/Y/X+vFuLX/LKquD Cblg== 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=x5MYHsc7NtHgb7srTO4LKsshNaqbEndMQs6j3A3SvY8=; b=F/+hOreRWB3nvAZrtex+67P+/SEpfH4Y48vx5wNOLDoopzurQ7NqjZVukkDenDXo0E iJ32IMCTRXwMHDJtZWhH6hkZ9x3UAOgmuT595FFBIMAr5/idESLQGIhQSegzSaKECyov 7z6pILlFN6+nnS+dSf6yPFRCrgQUvAZFnQ4vboBwBWps00zUodvce2DknitHrDLU2Q9C HnQeXra3hDYF47O823VgWmvB3aIPQrQ4ayMFiRLTHVXqoyAfiIz6aRXHo9v2tRfkv0Sr sG8yiYgceTfzFFP1X4xDwMKrqwbNNJmg4Ylp/P2DLHd5JRL1zUWDOGaf+BBgv/8Naq6F 4Qgw== X-Gm-Message-State: AKwxytdjwM4+e2I8pVhBYc8k4i3vkqBypARJo0YFLeS7YRmuC3hi0+l8 hXo+muG86haISEzPWplROnrUgCDz X-Google-Smtp-Source: AH8x226bcHOCTSv1fonGuVqL4Q9QMiR8QZWWx4sJosG2g3LwaNU4kxhv36JlG6raxybL4B2ot6fZfg== X-Received: by 10.223.176.174 with SMTP id i43mr29130937wra.77.1517858985653; Mon, 05 Feb 2018 11:29:45 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:49 +0100 Message-Id: <1517858941-5538-36-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 35/47] cpus: join thread when removing a vCPU 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" If no one joins the thread, its associated memory is leaked. Reported-by: CheneyLin Signed-off-by: Paolo Bonzini --- cpus.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/cpus.c b/cpus.c index fe127ac..8d8bb7c 100644 --- a/cpus.c +++ b/cpus.c @@ -1752,19 +1752,14 @@ void resume_all_vcpus(void) } } =20 -void cpu_remove(CPUState *cpu) +void cpu_remove_sync(CPUState *cpu) { cpu->stop =3D true; cpu->unplug =3D true; qemu_cpu_kick(cpu); -} - -void cpu_remove_sync(CPUState *cpu) -{ - cpu_remove(cpu); - while (cpu->created) { - qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); - } + qemu_mutex_unlock_iothread(); + qemu_thread_join(cpu->thread); + qemu_mutex_lock_iothread(); } =20 /* For temporary buffers for forming a name */ --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860779029218.15473336415698; Mon, 5 Feb 2018 11:59:39 -0800 (PST) Received: from localhost ([::1]:54981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimvS-00074o-5y for importer@patchew.org; Mon, 05 Feb 2018 14:59:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSb-0004pA-O0 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSa-00058m-LO for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:49 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:38696) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSa-00058S-Ak for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:48 -0500 Received: by mail-wm0-x242.google.com with SMTP id 141so27960116wme.3 for ; Mon, 05 Feb 2018 11:29:48 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:46 -0800 (PST) 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=S+6Km1w+DuiS1Hg7b5R/3ZTexlS8LdD6/d4EXjWagAs=; b=IE7bJuC5JPge4JjFQzVLiZ4y0gaYl7MUQIltAbfX5dMKGusxtOJInYTNNoHzQivYMQ xtE75it6+wpqokiRrbvVJAfBXquMY/HUZVL2Fxp8HnTydjfy/Yrjmkf2rWZ8CeCvHtHz kN+aZNlV1HCS849qb6AatYVWRPFxzWiHhJ40x3TQjiF47Jg6SGqVgf0MzJK+jcbHzqdg Fpo5b4Drr2eI7F2PmrpuB2exYBQ2lnSTtBktrIL6L+lh7ciwjujAnyHZVDZohP0l56Ts 3VEB90CSx3gBC3mD6JgXL9382McDGjreZU99ZNMO/021qF9+6cTLL2BR7FlEki0IgfJO gr+A== 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=S+6Km1w+DuiS1Hg7b5R/3ZTexlS8LdD6/d4EXjWagAs=; b=UqwCOmTtwwif7saoHO7HUl/fPJcb6ZtZdoEPKASdMEMisxCi1/i8Dqrt9thK3IumgP F9bFA7lsFP4+QCi8LyTNrotLoaeXMFtjT/Jt/sbwL+T23vF/P9IqBhDoltonVf8vZlj4 eF+GBnOleY8nKu1hEBil5YgHG/yVo4VLZ7JE3EUClmjkTjqI/hZGbjMCjJIxKd+fHRS0 D3eE/1SRrWYm4bkLYjHNeCu/8ScAPXykvAIsSXnjTqHFdhbcCixsw4bSO4KvvDcEXF+k P3bJZwWkxLAcsdJOrVUdyOu/4II5aWqPruP4lsXyfepm5rfLFDz6aiujsM5IcS+hf1Nk +Ecw== X-Gm-Message-State: APf1xPDL7V8hSvinaS5c+eTnvFTt4EDT8mr7BME5w4Wl2vtyPxXjxCKx mQOA8Q0ljJripwLbgfMhudpM2tl5 X-Google-Smtp-Source: AH8x226A9C5BLT/1NtSdg9LqgcKatxh94EZyFWSyqHrnWgwf73Nml1cy78KXQlxVxucd1tDqNIx14A== X-Received: by 10.28.220.66 with SMTP id t63mr307693wmg.100.1517858986900; Mon, 05 Feb 2018 11:29:46 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:50 +0100 Message-Id: <1517858941-5538-37-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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:c09::242 Subject: [Qemu-devel] [PULL 36/47] memfd: add error argument, instead of perror() 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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: Marc-Andr=C3=A9 Lureau This will allow callers to silence error report when the call is allowed to failed. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180201132757.23063-2-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- hw/virtio/vhost.c | 8 +++++++- include/qemu/memfd.h | 5 +++-- util/memfd.c | 57 +++++++++++++++++++++++++++---------------------= ---- 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index d16c0c8..338e439 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -330,6 +330,7 @@ static uint64_t vhost_get_log_size(struct vhost_dev *de= v) =20 static struct vhost_log *vhost_log_alloc(uint64_t size, bool share) { + Error *err =3D NULL; struct vhost_log *log; uint64_t logsize =3D size * sizeof(*(log->log)); int fd =3D -1; @@ -338,7 +339,12 @@ static struct vhost_log *vhost_log_alloc(uint64_t size= , bool share) if (share) { log->log =3D qemu_memfd_alloc("vhost-log", logsize, F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_S= EAL, - &fd); + &fd, &err); + if (err) { + error_report_err(err); + g_free(log); + return NULL; + } memset(log->log, 0, logsize); } else { log->log =3D g_malloc0(logsize); diff --git a/include/qemu/memfd.h b/include/qemu/memfd.h index 41c24d8..b9d0987 100644 --- a/include/qemu/memfd.h +++ b/include/qemu/memfd.h @@ -16,9 +16,10 @@ #define F_SEAL_WRITE 0x0008 /* prevent writes */ #endif =20 -int qemu_memfd_create(const char *name, size_t size, unsigned int seals); +int qemu_memfd_create(const char *name, size_t size, unsigned int seals, + Error **errp); void *qemu_memfd_alloc(const char *name, size_t size, unsigned int seals, - int *fd); + int *fd, Error **errp); void qemu_memfd_free(void *ptr, size_t size, int fd); bool qemu_memfd_check(void); =20 diff --git a/util/memfd.c b/util/memfd.c index dce61f9..8d27307 100644 --- a/util/memfd.c +++ b/util/memfd.c @@ -27,6 +27,7 @@ =20 #include "qemu/osdep.h" =20 +#include "qapi/error.h" #include "qemu/memfd.h" =20 #if defined CONFIG_LINUX && !defined CONFIG_MEMFD @@ -51,11 +52,11 @@ static int memfd_create(const char *name, unsigned int = flags) #define MFD_ALLOW_SEALING 0x0002U #endif =20 -int qemu_memfd_create(const char *name, size_t size, unsigned int seals) +int qemu_memfd_create(const char *name, size_t size, + unsigned int seals, Error **errp) { - int mfd =3D -1; - #ifdef CONFIG_LINUX + int mfd =3D -1; unsigned int flags =3D MFD_CLOEXEC; =20 if (seals) { @@ -64,23 +65,26 @@ int qemu_memfd_create(const char *name, size_t size, un= signed int seals) =20 mfd =3D memfd_create(name, flags); if (mfd < 0) { - return -1; + goto err; } =20 if (ftruncate(mfd, size) =3D=3D -1) { - perror("ftruncate"); - close(mfd); - return -1; + goto err; } =20 if (seals && fcntl(mfd, F_ADD_SEALS, seals) =3D=3D -1) { - perror("fcntl"); - close(mfd); - return -1; + goto err; } -#endif =20 return mfd; + +err: + if (mfd >=3D 0) { + close(mfd); + } +#endif + error_setg_errno(errp, errno, "failed to create memfd"); + return -1; } =20 /* @@ -90,14 +94,14 @@ int qemu_memfd_create(const char *name, size_t size, un= signed int seals) * sealing. */ void *qemu_memfd_alloc(const char *name, size_t size, unsigned int seals, - int *fd) + int *fd, Error **errp) { void *ptr; - int mfd =3D qemu_memfd_create(name, size, seals); + int mfd =3D qemu_memfd_create(name, size, seals, NULL); =20 /* some systems have memfd without sealing */ if (mfd =3D=3D -1) { - mfd =3D qemu_memfd_create(name, size, 0); + mfd =3D qemu_memfd_create(name, size, 0, NULL); } =20 if (mfd =3D=3D -1) { @@ -109,27 +113,26 @@ void *qemu_memfd_alloc(const char *name, size_t size,= unsigned int seals, unlink(fname); g_free(fname); =20 - if (mfd =3D=3D -1) { - perror("mkstemp"); - return NULL; - } - - if (ftruncate(mfd, size) =3D=3D -1) { - perror("ftruncate"); - close(mfd); - return NULL; + if (mfd =3D=3D -1 || + ftruncate(mfd, size) =3D=3D -1) { + goto err; } } =20 ptr =3D mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, mfd, 0); if (ptr =3D=3D MAP_FAILED) { - perror("mmap"); - close(mfd); - return NULL; + goto err; } =20 *fd =3D mfd; return ptr; + +err: + error_setg_errno(errp, errno, "failed to allocate shared memory"); + if (mfd >=3D 0) { + close(mfd); + } + return NULL; } =20 void qemu_memfd_free(void *ptr, size_t size, int fd) @@ -157,7 +160,7 @@ bool qemu_memfd_check(void) int fd; void *ptr; =20 - ptr =3D qemu_memfd_alloc("test", 4096, 0, &fd); + ptr =3D qemu_memfd_alloc("test", 4096, 0, &fd, NULL); memfd_check =3D ptr ? MEMFD_OK : MEMFD_KO; qemu_memfd_free(ptr, 4096, fd); } --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860959316194.28701136209258; Mon, 5 Feb 2018 12:02:39 -0800 (PST) Received: from localhost ([::1]:55063 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimyM-0001Jd-FT for importer@patchew.org; Mon, 05 Feb 2018 15:02:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSc-0004qB-OR for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSb-00059S-P8 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:50 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:43242) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSb-00058s-HL for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:49 -0500 Received: by mail-wr0-x243.google.com with SMTP id b52so10520999wrd.10 for ; Mon, 05 Feb 2018 11:29:49 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:47 -0800 (PST) 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=EqCOYwuRO1GjaOjOSLjtoAPpfjqY+gsE9sH7/uNXNGY=; b=X42KynGeViG3kMy1BPwbd8fDNfJwA6QdC6FCyOT6hMvE6DX17seZDJMeYfc9ddAnOf wRY1ZZ7orVK+4+jsJf4Ys2XtE+H6Q3kigd7n1ne87fWLol5dgDZcZMmT1lhYzHSPwIfA Fdz9Z7u5P3Tt7sxJmblCjxEnI8jsXAeh10jwvOrnx+2/aKnSkS3c9QY/3liL3EkQzhjg /aL2J1tq+1p4R3UtFstGxjRqgKM/HyyK9jz0oh77m9MJovApRJ8IQdonNePwmO8aBSmV lUrVv22pdOxetBEVHFWSaOS0DIxrzgS7lgA+Q+LBZcdr48p6LgsglhOzPKNws+O5m2+o N7hQ== 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=EqCOYwuRO1GjaOjOSLjtoAPpfjqY+gsE9sH7/uNXNGY=; b=WUPV62wwOiOlE5P3FQm3DyVZv4Z0wwTMYXPW/kI920h5sMl+U+FVSN45F0U122FFqL I6cwWDaYhoOZ0ZwgPeLIdFgSyW9fbFn3/oNXH/BHav1eulQVSj9w9gN5+d1i08vqT5cJ CE+7ODUM+LL23jWpxnxNGn6JmxTheWRPzuODTBfxUaYhVGFpetCKO0nrzPPfnAPBCf1v lyG+IOK7XxOdKxTV9er/q0wrsM8C7ljKx1UBi+nbREluGG5NT0MlLZK6FCOdwBuJFalL 4qbVVQtLqhW6/befWjxqlOSZon7bVsQL2nAbX9XlE1IP+vKmcVe0BKOtxs9pUMhbwufd LDhg== X-Gm-Message-State: AKwxytegWuV6lomJEaO51YOLJzaBol32la9G/8CMEYuF4oyt9FufsSXl EpvQxC1/46JucuJGjl1cR+KQ17Gk X-Google-Smtp-Source: AH8x227NOka/rRGV0wqJi+UP9L1Aqv1auw1pl3jQbPeao9DF/72pxube41pkkJPPD+9zPJMMdCnOLQ== X-Received: by 10.223.150.116 with SMTP id c49mr32766062wra.225.1517858988163; Mon, 05 Feb 2018 11:29:48 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:51 +0100 Message-Id: <1517858941-5538-38-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 37/47] memfd: add hugetlb support 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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: Marc-Andr=C3=A9 Lureau Linux commit 749df87bd7bee5a79cef073f5d032ddb2b211de8 (v4.14-rc1) added a new flag MFD_HUGETLB to memfd_create() that specify the file to be created resides in the hugetlbfs filesystem. This is the generic hugetlbfs filesystem not associated with any specific mount point. hugetlbfs does not support sealing operations in v4.14, therefore specifying MFD_ALLOW_SEALING with MFD_HUGETLB will result in EINVAL. However, I added sealing support in "[PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory" series, queued in -mm tree for v4.16. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180201132757.23063-3-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- include/qemu/memfd.h | 4 ++-- util/memfd.c | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/qemu/memfd.h b/include/qemu/memfd.h index b9d0987..1d3ecc7 100644 --- a/include/qemu/memfd.h +++ b/include/qemu/memfd.h @@ -16,8 +16,8 @@ #define F_SEAL_WRITE 0x0008 /* prevent writes */ #endif =20 -int qemu_memfd_create(const char *name, size_t size, unsigned int seals, - Error **errp); +int qemu_memfd_create(const char *name, size_t size, bool hugetlb, + unsigned int seals, Error **errp); void *qemu_memfd_alloc(const char *name, size_t size, unsigned int seals, int *fd, Error **errp); void qemu_memfd_free(void *ptr, size_t size, int fd); diff --git a/util/memfd.c b/util/memfd.c index 8d27307..7594af7 100644 --- a/util/memfd.c +++ b/util/memfd.c @@ -52,7 +52,11 @@ static int memfd_create(const char *name, unsigned int f= lags) #define MFD_ALLOW_SEALING 0x0002U #endif =20 -int qemu_memfd_create(const char *name, size_t size, +#ifndef MFD_HUGETLB +#define MFD_HUGETLB 0x0004U +#endif + +int qemu_memfd_create(const char *name, size_t size, bool hugetlb, unsigned int seals, Error **errp) { #ifdef CONFIG_LINUX @@ -62,6 +66,9 @@ int qemu_memfd_create(const char *name, size_t size, if (seals) { flags |=3D MFD_ALLOW_SEALING; } + if (hugetlb) { + flags |=3D MFD_HUGETLB; + } =20 mfd =3D memfd_create(name, flags); if (mfd < 0) { @@ -97,11 +104,11 @@ void *qemu_memfd_alloc(const char *name, size_t size, = unsigned int seals, int *fd, Error **errp) { void *ptr; - int mfd =3D qemu_memfd_create(name, size, seals, NULL); + int mfd =3D qemu_memfd_create(name, size, false, seals, NULL); =20 /* some systems have memfd without sealing */ if (mfd =3D=3D -1) { - mfd =3D qemu_memfd_create(name, size, 0, NULL); + mfd =3D qemu_memfd_create(name, size, false, 0, NULL); } =20 if (mfd =3D=3D -1) { --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517861142540740.5324802467118; Mon, 5 Feb 2018 12:05:42 -0800 (PST) Received: from localhost ([::1]:55084 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ein1J-0003zJ-Pt for importer@patchew.org; Mon, 05 Feb 2018 15:05:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSd-0004rX-VO for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSd-00059u-1f for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:51 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:35757) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSc-00059e-RH for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:50 -0500 Received: by mail-wr0-x244.google.com with SMTP id w50so30854520wrc.2 for ; Mon, 05 Feb 2018 11:29:50 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:48 -0800 (PST) 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=j0fmaggeLBIIMPcKajeL9+vW9OzXi4W64ELeIQD+utQ=; b=aoyqyoYKK+7As49hTkKkF9NWwE21OZmrWNlmZRsYxrJlEvyDgvyJYKAHSRnGHOGBAf zWwTyJ+WV5bboWv24oSp+4czqIkeZnEjHy7htIewCijuBuN17irVw/RjgSfcUOWh/b8q yLMbfZO+r95vj20aY0H6xWqFuGRXE/tviQKrY+h5pHt8a3OyAVya/B5aZikv6fCDBIFg VY9TcYBxYNeC8XBRehjRVE68rOfj+rCkz8qZGlgmHcEjJJCgafFnxyn8gNYVb4HIgpBo Aa0ZEIU/WTWXxX9B9lHSQ6sQZSSSBLsHrvAWc3xCWaJ65j6aEX8Dfgjc4M5yMVAPcBV+ 0ceA== 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=j0fmaggeLBIIMPcKajeL9+vW9OzXi4W64ELeIQD+utQ=; b=Mw51QJ5ueVlEJajgA6lEQC+9II913jGIMZHmeFnWFNWsr7803URPXqp3bFMp0ZrOeS f8R6J7W8NTrLRMy5bI3oViFkKaTbeJ393rUxBW+u+ZctlJihc/Z+yI+67iihN64gD+oa GxS69wusYsR+GMpwr38vTJfaencfZjzqfJLAfQRClzV3UzZ0tBGjKUaairnDxybeiuJx e8gkpxcZzWHxYP5nlo8VzcLXJMKQOX35Inu3PfR08D100bjbp3Kw0ksC1FhvnfogybD7 TdtILiO7JY3RV6pGipNJtuBU1EEaycvMrXjtdvz5nIBlqCdMnCr9YO63hgpRxPkxPFyu FXWA== X-Gm-Message-State: AKwxytd26BGgvjYVsRnEJ+bc3WKP4FlYaeJfZXaFsytTX6jniEVpHknq YMKYOr8GcChjFt9ou/3Of/EVNFwL X-Google-Smtp-Source: AH8x224GPPPQa950ixevtVsk9VE7x1rOp7YlCCMLKErhjR9KyXCfEZZWjHb3zowyXO3NPOipM22SMA== X-Received: by 10.223.170.221 with SMTP id i29mr28310836wrc.270.1517858989452; Mon, 05 Feb 2018 11:29:49 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:52 +0100 Message-Id: <1517858941-5538-39-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 38/47] memfd: add hugetlbsize argument 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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: Marc-Andr=C3=A9 Lureau Learn to specificy hugetlb size as qemu_memfd_create() argument. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180201132757.23063-4-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- include/qemu/memfd.h | 2 +- util/memfd.c | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/qemu/memfd.h b/include/qemu/memfd.h index 1d3ecc7..de10198 100644 --- a/include/qemu/memfd.h +++ b/include/qemu/memfd.h @@ -17,7 +17,7 @@ #endif =20 int qemu_memfd_create(const char *name, size_t size, bool hugetlb, - unsigned int seals, Error **errp); + uint64_t hugetlbsize, unsigned int seals, Error **er= rp); void *qemu_memfd_alloc(const char *name, size_t size, unsigned int seals, int *fd, Error **errp); void qemu_memfd_free(void *ptr, size_t size, int fd); diff --git a/util/memfd.c b/util/memfd.c index 7594af7..07d579e 100644 --- a/util/memfd.c +++ b/util/memfd.c @@ -29,6 +29,7 @@ =20 #include "qapi/error.h" #include "qemu/memfd.h" +#include "qemu/host-utils.h" =20 #if defined CONFIG_LINUX && !defined CONFIG_MEMFD #include @@ -56,9 +57,22 @@ static int memfd_create(const char *name, unsigned int f= lags) #define MFD_HUGETLB 0x0004U #endif =20 +#ifndef MFD_HUGE_SHIFT +#define MFD_HUGE_SHIFT 26 +#endif + int qemu_memfd_create(const char *name, size_t size, bool hugetlb, - unsigned int seals, Error **errp) + uint64_t hugetlbsize, unsigned int seals, Error **er= rp) { + int htsize =3D hugetlbsize ? ctz64(hugetlbsize) : 0; + + if (htsize && 1 << htsize !=3D hugetlbsize) { + error_setg(errp, "Hugepage size must be a power of 2"); + return -1; + } + + htsize =3D htsize << MFD_HUGE_SHIFT; + #ifdef CONFIG_LINUX int mfd =3D -1; unsigned int flags =3D MFD_CLOEXEC; @@ -68,8 +82,8 @@ int qemu_memfd_create(const char *name, size_t size, bool= hugetlb, } if (hugetlb) { flags |=3D MFD_HUGETLB; + flags |=3D htsize; } - mfd =3D memfd_create(name, flags); if (mfd < 0) { goto err; @@ -104,11 +118,11 @@ void *qemu_memfd_alloc(const char *name, size_t size,= unsigned int seals, int *fd, Error **errp) { void *ptr; - int mfd =3D qemu_memfd_create(name, size, false, seals, NULL); + int mfd =3D qemu_memfd_create(name, size, false, 0, seals, NULL); =20 /* some systems have memfd without sealing */ if (mfd =3D=3D -1) { - mfd =3D qemu_memfd_create(name, size, false, 0, NULL); + mfd =3D qemu_memfd_create(name, size, false, 0, 0, NULL); } =20 if (mfd =3D=3D -1) { --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517861340025586.6076267170458; Mon, 5 Feb 2018 12:09:00 -0800 (PST) Received: from localhost ([::1]:55573 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ein4V-00079M-3b for importer@patchew.org; Mon, 05 Feb 2018 15:08:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSf-0004tn-UA for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSe-0005AK-HJ for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:53 -0500 Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]:45700) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSe-0005A1-6z for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:52 -0500 Received: by mail-wr0-x22c.google.com with SMTP id h9so17831248wre.12 for ; Mon, 05 Feb 2018 11:29:52 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:49 -0800 (PST) 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=LxXNfdZs2kqvd0E1ttBrdCpVkd1NiyAs40dm2REnc2E=; b=CDfD9w+i4uz9zpKhratxDb68TUURlm19WmEd5J9zE7TqCeupqV+bKvEvcoJWhq6GMZ 8mC4Y3gcsWc8uWQMa7lpocQGGsaX74GZ3yiPP8UxFAI3jgWB1X27AbU5n50jupEre1JO H73cn5K6Yvw3DDsuDmpl8ttgKbVRVvLIsfYzLGD1q4n4fj580bQvC9HQCKttl9vXjstZ eoCaFAUCPzOIohpGX+f45wpBpzLPLSp0o0gSqh44yerlp1B7nF03/ZqkpNVnKj2gFOcV EOQ1qOp+lYOeC5dP1Cjcl2Sv3KH6GJHZ346hDsC1LZEETrEZ1c/Mr3dwMN2HAumqVV+B l3kg== 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=LxXNfdZs2kqvd0E1ttBrdCpVkd1NiyAs40dm2REnc2E=; b=RT5k5kSTyNb1hG30bACgg6nFAFDkCh1g+NdEB0qH/MtByPS6jj7hEyuNUG3fEZQKfM QbMiOC3q9vYNoqzokz3KMI0v8/HT7C9xghtwq+3SsiISMR5Iuq6KbaZVY9gX5gASOYb8 UHHGhpk8384AlSgOj9pVUxmGjmwRZfRruGwcNse5ACQxRqBg5fQisJ4OIIc7gtUGzfQT 8KkXzkD3Wg0PWTkeVHnKSyBRE7QHPKp8mejcKJiJ2N2ns5HVj4TB+jgFEnwNiy4b3UNK OkpcLLI3FGTbFFnXIFmV8UTn/aQojkLPbOMcygzWzuUJWMrbULBtFxgrLld+CKDREvN5 QNiw== X-Gm-Message-State: AKwxytdQHmVbH7c1HupqLZh6wd4FpKKopJd8f5Ab2llrC/7vybU/CNsV xUN0w4mdCanlY2xY8mLBJe19vXHz X-Google-Smtp-Source: AH8x225M9lumGqOIR8nyoVPeVZ9OBMshCepk6VcU5GHM/NUQjBwDAQ5X5oNwS+SqQ7oAt4thYSFWAQ== X-Received: by 10.223.138.194 with SMTP id z2mr31277938wrz.230.1517858990528; Mon, 05 Feb 2018 11:29:50 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:53 +0100 Message-Id: <1517858941-5538-40-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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::22c Subject: [Qemu-devel] [PULL 39/47] Add memfd based hostmem 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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: Marc-Andr=C3=A9 Lureau Add a new memory backend, similar to hostmem-file, except that it doesn't need to create files. It also enforces memory sealing. This backend is mainly useful for sharing the memory with other processes. Note that Linux supports transparent huge-pages of shmem/memfd memory since 4.8. It is relatively easier to set up THP than a dedicate hugepage mount point by using "madvise" in /sys/kernel/mm/transparent_hugepage/shmem_enabled. Since 4.14, memfd allows to set hugetlb requirement explicitly. Pending for merge in 4.16 is memfd sealing support for hugetlb backed memory. Usage: -object memory-backend-memfd,id=3Dmem1,size=3D1G Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180201132757.23063-5-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- backends/Makefile.objs | 2 + backends/hostmem-memfd.c | 170 +++++++++++++++++++++++++++++++++++++++++++= ++++ qemu-options.hx | 22 ++++++ 3 files changed, 194 insertions(+) create mode 100644 backends/hostmem-memfd.c diff --git a/backends/Makefile.objs b/backends/Makefile.objs index 0400799..67eeeba 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -8,3 +8,5 @@ common-obj-$(CONFIG_LINUX) +=3D hostmem-file.o =20 common-obj-y +=3D cryptodev.o common-obj-y +=3D cryptodev-builtin.o + +common-obj-$(CONFIG_LINUX) +=3D hostmem-memfd.o diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c new file mode 100644 index 0000000..1e20fe0 --- /dev/null +++ b/backends/hostmem-memfd.c @@ -0,0 +1,170 @@ +/* + * QEMU host memfd memory backend + * + * Copyright (C) 2018 Red Hat Inc + * + * Authors: + * Marc-Andr=C3=A9 Lureau + * + * 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-common.h" +#include "sysemu/hostmem.h" +#include "sysemu/sysemu.h" +#include "qom/object_interfaces.h" +#include "qemu/memfd.h" +#include "qapi/error.h" + +#define TYPE_MEMORY_BACKEND_MEMFD "memory-backend-memfd" + +#define MEMORY_BACKEND_MEMFD(obj) \ + OBJECT_CHECK(HostMemoryBackendMemfd, (obj), TYPE_MEMORY_BACKEND_MEMFD) + +typedef struct HostMemoryBackendMemfd HostMemoryBackendMemfd; + +struct HostMemoryBackendMemfd { + HostMemoryBackend parent_obj; + + bool hugetlb; + uint64_t hugetlbsize; + bool seal; +}; + +static void +memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) +{ + HostMemoryBackendMemfd *m =3D MEMORY_BACKEND_MEMFD(backend); + char *name; + int fd; + + if (!backend->size) { + error_setg(errp, "can't create backend with size 0"); + return; + } + + if (host_memory_backend_mr_inited(backend)) { + return; + } + + backend->force_prealloc =3D mem_prealloc; + fd =3D qemu_memfd_create(TYPE_MEMORY_BACKEND_MEMFD, backend->size, + m->hugetlb, m->hugetlbsize, m->seal ? + F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL : 0, + errp); + if (fd =3D=3D -1) { + return; + } + + name =3D object_get_canonical_path(OBJECT(backend)); + memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), + name, backend->size, true, fd, errp); + g_free(name); +} + +static bool +memfd_backend_get_hugetlb(Object *o, Error **errp) +{ + return MEMORY_BACKEND_MEMFD(o)->hugetlb; +} + +static void +memfd_backend_set_hugetlb(Object *o, bool value, Error **errp) +{ + MEMORY_BACKEND_MEMFD(o)->hugetlb =3D value; +} + +static void +memfd_backend_set_hugetlbsize(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + HostMemoryBackendMemfd *m =3D MEMORY_BACKEND_MEMFD(obj); + Error *local_err =3D NULL; + uint64_t value; + + if (host_memory_backend_mr_inited(MEMORY_BACKEND(obj))) { + error_setg(&local_err, "cannot change property value"); + goto out; + } + + visit_type_size(v, name, &value, &local_err); + if (local_err) { + goto out; + } + if (!value) { + error_setg(&local_err, "Property '%s.%s' doesn't take value '%" + PRIu64 "'", object_get_typename(obj), name, value); + goto out; + } + m->hugetlbsize =3D value; +out: + error_propagate(errp, local_err); +} + +static void +memfd_backend_get_hugetlbsize(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + HostMemoryBackendMemfd *m =3D MEMORY_BACKEND_MEMFD(obj); + uint64_t value =3D m->hugetlbsize; + + visit_type_size(v, name, &value, errp); +} + +static bool +memfd_backend_get_seal(Object *o, Error **errp) +{ + return MEMORY_BACKEND_MEMFD(o)->seal; +} + +static void +memfd_backend_set_seal(Object *o, bool value, Error **errp) +{ + MEMORY_BACKEND_MEMFD(o)->seal =3D value; +} + +static void +memfd_backend_instance_init(Object *obj) +{ + HostMemoryBackendMemfd *m =3D MEMORY_BACKEND_MEMFD(obj); + + /* default to sealed file */ + m->seal =3D true; +} + +static void +memfd_backend_class_init(ObjectClass *oc, void *data) +{ + HostMemoryBackendClass *bc =3D MEMORY_BACKEND_CLASS(oc); + + bc->alloc =3D memfd_backend_memory_alloc; + + object_class_property_add_bool(oc, "hugetlb", + memfd_backend_get_hugetlb, + memfd_backend_set_hugetlb, + &error_abort); + object_class_property_add(oc, "hugetlbsize", "int", + memfd_backend_get_hugetlbsize, + memfd_backend_set_hugetlbsize, + NULL, NULL, &error_abort); + object_class_property_add_bool(oc, "seal", + memfd_backend_get_seal, + memfd_backend_set_seal, + &error_abort); +} + +static const TypeInfo memfd_backend_info =3D { + .name =3D TYPE_MEMORY_BACKEND_MEMFD, + .parent =3D TYPE_MEMORY_BACKEND, + .instance_init =3D memfd_backend_instance_init, + .class_init =3D memfd_backend_class_init, + .instance_size =3D sizeof(HostMemoryBackendMemfd), +}; + +static void register_types(void) +{ + type_register_static(&memfd_backend_info); +} + +type_init(register_types); diff --git a/qemu-options.hx b/qemu-options.hx index 8ce427d..265cf9f 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4024,6 +4024,28 @@ Memory backend objects offer more control than the @= option{-m} option that is traditionally used to define guest RAM. Please refer to @option{memory-backend-file} for a description of the options. =20 +@item -object memory-backend-memfd,id=3D@var{id},merge=3D@var{on|off},dump= =3D@var{on|off},prealloc=3D@var{on|off},size=3D@var{size},host-nodes=3D@var= {host-nodes},policy=3D@var{default|preferred|bind|interleave},seal=3D@var{o= n|off},hugetlb=3D@var{on|off},hugetlbsize=3D@var{size} + +Creates an anonymous memory file backend object, which allows QEMU to +share the memory with an external process (e.g. when using +vhost-user). The memory is allocated with memfd and optional +sealing. (Linux only) + +The @option{seal} option creates a sealed-file, that will block +further resizing the memory ('on' by default). + +The @option{hugetlb} option specify the file to be created resides in +the hugetlbfs filesystem (since Linux 4.14). Used in conjunction with +the @option{hugetlb} option, the @option{hugetlbsize} option specify +the hugetlb page size on systems that support multiple hugetlb page +sizes (it must be a power of 2 value supported by the system). + +In some versions of Linux, the @option{hugetlb} option is incompatible +with the @option{seal} option (requires at least Linux 4.16). + +Please refer to @option{memory-backend-file} for a description of the +other options. + @item -object rng-random,id=3D@var{id},filename=3D@var{/dev/random} =20 Creates a random number generator backend which obtains entropy from --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860968629939.9046106743269; Mon, 5 Feb 2018 12:02:48 -0800 (PST) Received: from localhost ([::1]:55064 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimyV-0001Vl-Px for importer@patchew.org; Mon, 05 Feb 2018 15:02:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSg-0004uI-CT for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSf-0005AS-9F for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:54 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:38697) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSf-0005AG-1Z for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:53 -0500 Received: by mail-wm0-x242.google.com with SMTP id 141so27960501wme.3 for ; Mon, 05 Feb 2018 11:29:52 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:50 -0800 (PST) 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=TO3X8l/HPQO9VfUH8HjLeAcxUOWjRk5eUSTTk3BVMbI=; b=rcmG1wuvUA8wj7hl4eoXo4Txhwo6vu8gkhzLFSr+A6YW7tf/2n+NHGL09Uz9YJjyHL fj46qwTLNG2jYJXr5IkBy1njktrmGp0UUO0/5dzIv5frKvfzWm2nQ+bl72SIG8ycqxY3 ZbjSWcMnOYDpZM6NhSfmyKK4f71JaXlbqVlEE4talMt+yVsG9lsvlBa9FyT/XwY7PdXG D96S6Jp6+h9xYJIgV2WAtTb0MUruGloCQXCZaw4umtS3OMwrneeUjnNRDEFbqp+4KHQY aZ2IsjATJb+FijEB4mSy5QGRuP6XDAogYRgEx+RtMuz57SfrOf70pp7hciD2q6T9jDnS Xo0Q== 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=TO3X8l/HPQO9VfUH8HjLeAcxUOWjRk5eUSTTk3BVMbI=; b=KM6heqhFF8qBOFjVGcRycyL5ta3I38LJaSRxLnuM87Y0stW0VrndA+f9Q8SzxLj0Pj Hp/gPmWtcHZpbDDLTdX2GJHauJ1r7uAAt5UiOyE+Hz0YTRbTeuKgJdXiuqqUME9xkOqR Smai5W5vbFrYUuTlAisqz17cqm0lp6Thp21ELj2ttRe6I1vFp9cxPBB401rBteXwBfB7 eT9F0+13B0HsKm/auFITjVBnW8pYR62qhvrrcdUwy6a7uYaoxK1W6k1g5w91iagYKWSe 1hLAs65BPh3TxBVo0Byk/MmxHWDSljtKVTeHLBOP4n2hpnTxuYJbZVqNNj4y0DUDpUaI jJ6A== X-Gm-Message-State: APf1xPBSBbuwiaw66meeGZSYdKzIAJhX0pJvVvxJ9rv6cideEjP2m6n0 8dF0+k7J8tFFcF6Y2SzzHMlNcIbx X-Google-Smtp-Source: AH8x225oAsV+zWdJOBw8bs9tfNmlkBDlN05Ajojdx8HQvDZGnVGgDPY5D51/46I4A83hK5kCBRpALg== X-Received: by 10.28.129.70 with SMTP id c67mr340398wmd.160.1517858991635; Mon, 05 Feb 2018 11:29:51 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:54 +0100 Message-Id: <1517858941-5538-41-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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:c09::242 Subject: [Qemu-devel] [PULL 40/47] tests: keep compiling failing vhost-user tests 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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: Marc-Andr=C3=A9 Lureau Let's protect the failing tests under a QTEST_VHOST_USER_FIXME environment variable, so we keep compiling the tests and we can easily run them. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180201132757.23063-6-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- tests/vhost-user-test.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index ec6ac9d..713ff5c 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -30,8 +30,6 @@ #include #include =20 -#define VHOST_USER_NET_TESTS_WORKING 0 /* broken as of 2.10.0 */ - /* GLIB version compatibility flags */ #if !GLIB_CHECK_VERSION(2, 26, 0) #define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT(1000000)) @@ -765,7 +763,7 @@ static void wait_for_rings_started(TestServer *s, size_= t count) g_mutex_unlock(&s->data_mutex); } =20 -#if VHOST_USER_NET_TESTS_WORKING && defined(CONFIG_HAS_GLIB_SUBPROCESS_TES= TS) +#if defined(CONFIG_HAS_GLIB_SUBPROCESS_TESTS) static inline void test_server_connect(TestServer *server) { test_server_create_chr(server, ",reconnect=3D1"); @@ -956,16 +954,19 @@ int main(int argc, char **argv) qtest_add_func("/vhost-user/migrate", test_migrate); qtest_add_func("/vhost-user/multiqueue", test_multiqueue); =20 -#if VHOST_USER_NET_TESTS_WORKING && defined(CONFIG_HAS_GLIB_SUBPROCESS_TES= TS) - qtest_add_func("/vhost-user/reconnect/subprocess", - test_reconnect_subprocess); - qtest_add_func("/vhost-user/reconnect", test_reconnect); - qtest_add_func("/vhost-user/connect-fail/subprocess", - test_connect_fail_subprocess); - qtest_add_func("/vhost-user/connect-fail", test_connect_fail); - qtest_add_func("/vhost-user/flags-mismatch/subprocess", - test_flags_mismatch_subprocess); - qtest_add_func("/vhost-user/flags-mismatch", test_flags_mismatch); +#if defined(CONFIG_HAS_GLIB_SUBPROCESS_TESTS) + /* keeps failing on build-system since Aug 15 2017 */ + if (getenv("QTEST_VHOST_USER_FIXME")) { + qtest_add_func("/vhost-user/reconnect/subprocess", + test_reconnect_subprocess); + qtest_add_func("/vhost-user/reconnect", test_reconnect); + qtest_add_func("/vhost-user/connect-fail/subprocess", + test_connect_fail_subprocess); + qtest_add_func("/vhost-user/connect-fail", test_connect_fail); + qtest_add_func("/vhost-user/flags-mismatch/subprocess", + test_flags_mismatch_subprocess); + qtest_add_func("/vhost-user/flags-mismatch", test_flags_mismatch); + } #endif =20 ret =3D g_test_run(); --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517861112794758.0324740162819; Mon, 5 Feb 2018 12:05:12 -0800 (PST) Received: from localhost ([::1]:55082 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ein0p-0003YZ-W9 for importer@patchew.org; Mon, 05 Feb 2018 15:05:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSk-0004wi-05 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSg-0005Aw-GT for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:58 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:38698) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSg-0005AZ-8W for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:54 -0500 Received: by mail-wm0-x243.google.com with SMTP id 141so27960598wme.3 for ; Mon, 05 Feb 2018 11:29:54 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:52 -0800 (PST) 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=Zc9F7o8UIA7P05BR6PSLeC5O+xN14PD1ZSyL2lQIm3A=; b=NnvpKZWy+tgaMh9gD+sMZXgQrZQXQpHduCNwU7aOMsx/qMzAV4QbS3IZjrW3u67lUP tJlaN0Y7HcSAtXB8pENLD1o9O1EZIByN0IKugx0fPCkapiAnr+zdBiG4w86qp7YNaL/C 1Ehl/10Mcn9uqw1INKCTK+fPc5RKO1ZNg5PwCmorKH1e6DXDy6qEOYr+V5eVzDkPhPY7 hAK4LgTLG4m9VrEXkVgPFVOI4+rNj5OKPk/MRBd8/KHuTCoJRMXsoINwepdDYIA5kya9 j/i7w9ystiQdx46IRQDHyh0cqoewMrU/KAmpe42wTgMwhTSQlLjy1AELUXQ9q9dF29OQ g0/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:mime-version:content-transfer-encoding; bh=Zc9F7o8UIA7P05BR6PSLeC5O+xN14PD1ZSyL2lQIm3A=; b=avbHBTG6BJ8ZNA9opvLLS5EcEeq3qOAncuarFoAQqOSbhK8Ydl39A5sj81NnrtUlfn tP/8mwJinBKn7repI8c4wdW0KiZ5Uh3F0xrhDcOFyLp16nwyG7v3kugkbH2zkL2nx1nw 3yskw8Kh9HNWv2HyAHcWvq8kHvLBL2D3n4YE6aRmZhXRJrdLwacswKsQJ8yvOKgX26Dj GaDZmK2TV7KWnrTx68MGusMFBpRPEx7fgFFynOF/kULj9z2FJrdlzSTcPwhIGyLEM5JK vaCAG0ljvL/a3gHks5BqQTXkuFZR2qIPW75QI6J7W/f6WOgItUTPI5STcAOmknlBYWKz fP3w== X-Gm-Message-State: APf1xPAxohDMISeCqHFhwB6EE2gMxb+LgOAL2FMvo8celtJ1TkuOPOk6 UZdVKuljYgTKdVBhJfoEnAQyXek2 X-Google-Smtp-Source: AH8x225sYLzYdwxxLV9VCSZKLVUVQShuN37SJMJqLEoSNhNDExPMG1Im2Ighslf4rcDf+ieJJ+0muA== X-Received: by 10.28.234.200 with SMTP id g69mr273444wmi.137.1517858992817; Mon, 05 Feb 2018 11:29:52 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:55 +0100 Message-Id: <1517858941-5538-42-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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:c09::243 Subject: [Qemu-devel] [PULL 41/47] vhost-user-test: make read-guest-mem setup its own qemu 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180201132757.23063-7-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- tests/vhost-user-test.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 713ff5c..a22075f 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -48,6 +48,14 @@ #define QEMU_CMD QEMU_CMD_MEM QEMU_CMD_CHR \ QEMU_CMD_NETDEV QEMU_CMD_NET =20 +#define GET_QEMU_CMD(s) \ + g_strdup_printf(QEMU_CMD, 512, 512, (root), (s)->chr_name, \ + (s)->socket_path, "", (s)->chr_name) + +#define GET_QEMU_CMDE(s, mem, chr_opts, extra, ...) \ + g_strdup_printf(QEMU_CMD extra, (mem), (mem), (root), (s)->chr_name, \ + (s)->socket_path, (chr_opts), (s)->chr_name, ##__VA_AR= GS__) + #define HUGETLBFS_MAGIC 0x958458f6 =20 /*********** FROM hw/virtio/vhost-user.c *********************************= ****/ @@ -159,6 +167,10 @@ typedef struct TestServer { QGuestAllocator *alloc; } TestServer; =20 +static TestServer *test_server_new(const gchar *name); +static void test_server_free(TestServer *server); +static void test_server_listen(TestServer *server); + static const char *tmpfs; static const char *root; =20 @@ -225,9 +237,8 @@ static void wait_for_fds(TestServer *s) g_mutex_unlock(&s->data_mutex); } =20 -static void read_guest_mem(const void *data) +static void read_guest_mem_server(TestServer *s) { - TestServer *s =3D (void *)data; uint32_t *guest_mem; int i, j; size_t size; @@ -492,14 +503,6 @@ static void test_server_listen(TestServer *server) test_server_create_chr(server, ",server,nowait"); } =20 -#define GET_QEMU_CMD(s) \ - g_strdup_printf(QEMU_CMD, 512, 512, (root), (s)->chr_name, \ - (s)->socket_path, "", (s)->chr_name) - -#define GET_QEMU_CMDE(s, mem, chr_opts, extra, ...) \ - g_strdup_printf(QEMU_CMD extra, (mem), (mem), (root), (s)->chr_name, \ - (s)->socket_path, (chr_opts), (s)->chr_name, ##__VA_AR= GS__) - static gboolean _test_server_free(TestServer *server) { int i; @@ -652,7 +655,7 @@ static void test_read_guest_mem(void) =20 init_virtio_dev(server, 1u << VIRTIO_NET_F_MAC); =20 - read_guest_mem(server); + read_guest_mem_server(server); =20 uninit_virtio_dev(server); =20 @@ -730,7 +733,7 @@ static void test_migrate(void) global_qtest =3D to; qmp_eventwait("RESUME"); =20 - read_guest_mem(dest); + read_guest_mem_server(dest); =20 uninit_virtio_dev(s); =20 --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860551629641.738542760136; Mon, 5 Feb 2018 11:55:51 -0800 (PST) Received: from localhost ([::1]:54947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimrg-0003bM-SR for importer@patchew.org; Mon, 05 Feb 2018 14:55:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSj-0004wh-WE for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSh-0005BM-On for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:58 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:34083) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSh-0005B5-EI for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:55 -0500 Received: by mail-wm0-x241.google.com with SMTP id j21-v6so14631243wmh.1 for ; Mon, 05 Feb 2018 11:29:55 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:53 -0800 (PST) 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=haT8bH6OqTB/E+sH6525Xi15y1UyEDWbz6P75GW5sP8=; b=BnNtJLh8i5uBhXByTSa0zX21PMH12hZVIvJfmNYVTUggrCDmwZkfP1jguki5JrShpl bAFHBtwy8ltgXjdbOGzjb9DeplN/2gwyjtM2Uqv/k5jZdN7zHV4Y/wnrOHFjjGcJHlZb /7ilS71DkgNPRbUHVabjajscybc20AD//HktAkWFkL9yknRJ2Azpmu2qof5qAGj1yFTw nGkadd3fZCt86IaMWKCoamBz2z0KnkB1QLcGPdh2HinxWYfJIPakymLbShfJUgJc8/dE Kwr3Jf6+1UE0Iz6e14EGPPV7fTSx88ejNEIGwX6Sbu3gyC0leaLNDPuDMfTO9GMGSFvK 0/ag== 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=haT8bH6OqTB/E+sH6525Xi15y1UyEDWbz6P75GW5sP8=; b=cucAr1nLwNJX35+Nf8LfHytMeVofO89xqltdgwtUyD2onoTwFTcSzfzE8npm08zlvV mJkE+nLrXvMlSNChhNr0e8Pw3BQTtibbPAiuP8ykXFuPx4DS3Ou/Cu4r3ti1zR72ohJW MLx8Fc1LUY/lzK1Icxmm2mgKlSmSXDTYSS9/6wRoMonAHkiJiO2yTMXhp5hWSVg4expm k71dbncyiBeRkTyQ3j93NZOPCSIEChZyPsheJ4WW/3CaY78vWg88zR/8+wDkwaAmt1dj xWiXfeP3Q5OMOJRKRYD7awQz+Dr17hUw3bDMcN6CQqg/k5Zd2jfJvMWiR0ACbTRp1CDB 1rwg== X-Gm-Message-State: APf1xPD+bjbml7iGnN5rswLXJYpIrcFBryD73Y8i9jEaNVtjX+wJBZhd sYxQdRQAlXqMzOMK7f7zpw7YlCns X-Google-Smtp-Source: AH8x2279F3ZIQNZ1ow/6J3ne7DTPUS9jxfKYliU/hb7l1qz93ZFXVruyGszCLrMAISZh+uai3mqhdA== X-Received: by 10.28.29.130 with SMTP id d124mr323798wmd.139.1517858993997; Mon, 05 Feb 2018 11:29:53 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:56 +0100 Message-Id: <1517858941-5538-43-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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:c09::241 Subject: [Qemu-devel] [PULL 42/47] tests: use memfd in vhost-user-test 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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: Marc-Andr=C3=A9 Lureau This will exercise the memfd memory backend and should generally be better for testing than memory-backend-file (thanks to anonymous files and sealing). If memfd is available, it is preferred. However, in order to check that file & memfd backends both work correctly, the read-guest-mem test is checked explicitly for each. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180201132757.23063-8-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- tests/vhost-user-test.c | 90 +++++++++++++++++++++++++++++++++++----------= ---- 1 file changed, 64 insertions(+), 26 deletions(-) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index a22075f..95eb449 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -17,6 +17,7 @@ #include "qemu/range.h" #include "qemu/sockets.h" #include "chardev/char-fe.h" +#include "qemu/memfd.h" #include "sysemu/sysemu.h" #include "libqos/libqos.h" #include "libqos/pci-pc.h" @@ -39,23 +40,14 @@ #define HAVE_MONOTONIC_TIME #endif =20 -#define QEMU_CMD_MEM " -m %d -object memory-backend-file,id=3Dmem,size= =3D%dM,"\ +#define QEMU_CMD_MEM " -m %d -object memory-backend-file,id=3Dmem,size= =3D%dM," \ "mem-path=3D%s,share=3Don -numa node,memdev=3Dmem" +#define QEMU_CMD_MEMFD " -m %d -object memory-backend-memfd,id=3Dmem,size= =3D%dM," \ + " -numa node,memdev=3Dmem" #define QEMU_CMD_CHR " -chardev socket,id=3D%s,path=3D%s%s" #define QEMU_CMD_NETDEV " -netdev vhost-user,id=3Dnet0,chardev=3D%s,vhostf= orce" #define QEMU_CMD_NET " -device virtio-net-pci,netdev=3Dnet0" =20 -#define QEMU_CMD QEMU_CMD_MEM QEMU_CMD_CHR \ - QEMU_CMD_NETDEV QEMU_CMD_NET - -#define GET_QEMU_CMD(s) \ - g_strdup_printf(QEMU_CMD, 512, 512, (root), (s)->chr_name, \ - (s)->socket_path, "", (s)->chr_name) - -#define GET_QEMU_CMDE(s, mem, chr_opts, extra, ...) \ - g_strdup_printf(QEMU_CMD extra, (mem), (mem), (root), (s)->chr_name, \ - (s)->socket_path, (chr_opts), (s)->chr_name, ##__VA_AR= GS__) - #define HUGETLBFS_MAGIC 0x958458f6 =20 /*********** FROM hw/virtio/vhost-user.c *********************************= ****/ @@ -174,6 +166,33 @@ static void test_server_listen(TestServer *server); static const char *tmpfs; static const char *root; =20 +enum test_memfd { + TEST_MEMFD_AUTO, + TEST_MEMFD_YES, + TEST_MEMFD_NO, +}; + +static char *get_qemu_cmd(TestServer *s, + int mem, enum test_memfd memfd, const char *mem_= path, + const char *chr_opts, const char *extra) +{ + if (memfd =3D=3D TEST_MEMFD_AUTO && qemu_memfd_check()) { + memfd =3D TEST_MEMFD_YES; + } + + if (memfd =3D=3D TEST_MEMFD_YES) { + return g_strdup_printf(QEMU_CMD_MEMFD QEMU_CMD_CHR + QEMU_CMD_NETDEV QEMU_CMD_NET "%s", mem, mem, + s->chr_name, s->socket_path, + chr_opts, s->chr_name, extra); + } else { + return g_strdup_printf(QEMU_CMD_MEM QEMU_CMD_CHR + QEMU_CMD_NETDEV QEMU_CMD_NET "%s", mem, mem, + mem_path, s->chr_name, s->socket_path, + chr_opts, s->chr_name, extra); + } +} + static void init_virtio_dev(TestServer *s, uint32_t features_mask) { uint32_t features; @@ -639,8 +658,9 @@ GSourceFuncs test_migrate_source_funcs =3D { .check =3D test_migrate_source_check, }; =20 -static void test_read_guest_mem(void) +static void test_read_guest_mem(const void *arg) { + enum test_memfd memfd =3D GPOINTER_TO_INT(arg); TestServer *server =3D NULL; char *qemu_cmd =3D NULL; QTestState *s =3D NULL; @@ -648,7 +668,7 @@ static void test_read_guest_mem(void) server =3D test_server_new("test"); test_server_listen(server); =20 - qemu_cmd =3D GET_QEMU_CMD(server); + qemu_cmd =3D get_qemu_cmd(server, 512, memfd, root, "", ""); =20 s =3D qtest_start(qemu_cmd); g_free(qemu_cmd); @@ -670,7 +690,7 @@ static void test_migrate(void) char *uri =3D g_strdup_printf("%s%s", "unix:", dest->mig_path); QTestState *global =3D global_qtest, *from, *to; GSource *source; - gchar *cmd; + gchar *cmd, *tmp; QDict *rsp; guint8 *log; guint64 size; @@ -678,7 +698,7 @@ static void test_migrate(void) test_server_listen(s); test_server_listen(dest); =20 - cmd =3D GET_QEMU_CMDE(s, 2, "", ""); + cmd =3D get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, "", ""); from =3D qtest_start(cmd); g_free(cmd); =20 @@ -687,7 +707,9 @@ static void test_migrate(void) size =3D get_log_size(s); g_assert_cmpint(size, =3D=3D, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8)= ); =20 - cmd =3D GET_QEMU_CMDE(dest, 2, "", " -incoming %s", uri); + tmp =3D g_strdup_printf(" -incoming %s", uri); + cmd =3D get_qemu_cmd(dest, 2, TEST_MEMFD_AUTO, root, "", tmp); + g_free(tmp); to =3D qtest_init(cmd); g_free(cmd); =20 @@ -800,7 +822,7 @@ static void test_reconnect_subprocess(void) char *cmd; =20 g_thread_new("connect", connect_thread, s); - cmd =3D GET_QEMU_CMDE(s, 2, ",server", ""); + cmd =3D get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, ",server", ""); qtest_start(cmd); g_free(cmd); =20 @@ -838,7 +860,7 @@ static void test_connect_fail_subprocess(void) =20 s->test_fail =3D true; g_thread_new("connect", connect_thread, s); - cmd =3D GET_QEMU_CMDE(s, 2, ",server", ""); + cmd =3D get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, ",server", ""); qtest_start(cmd); g_free(cmd); =20 @@ -868,7 +890,7 @@ static void test_flags_mismatch_subprocess(void) =20 s->test_flags =3D TEST_FLAGS_DISCONNECT; g_thread_new("connect", connect_thread, s); - cmd =3D GET_QEMU_CMDE(s, 2, ",server", ""); + cmd =3D get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, ",server", ""); qtest_start(cmd); g_free(cmd); =20 @@ -903,11 +925,21 @@ static void test_multiqueue(void) s->queues =3D 2; test_server_listen(s); =20 - cmd =3D g_strdup_printf(QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV ",qu= eues=3D%d " - "-device virtio-net-pci,netdev=3Dnet0,mq=3Don,ve= ctors=3D%d", - 512, 512, root, s->chr_name, - s->socket_path, "", s->chr_name, - s->queues, s->queues * 2 + 2); + if (qemu_memfd_check()) { + cmd =3D g_strdup_printf( + QEMU_CMD_MEMFD QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=3D%d " + "-device virtio-net-pci,netdev=3Dnet0,mq=3Don,vectors=3D%d", + 512, 512, s->chr_name, + s->socket_path, "", s->chr_name, + s->queues, s->queues * 2 + 2); + } else { + cmd =3D g_strdup_printf( + QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=3D%d " + "-device virtio-net-pci,netdev=3Dnet0,mq=3Don,vectors=3D%d", + 512, 512, root, s->chr_name, + s->socket_path, "", s->chr_name, + s->queues, s->queues * 2 + 2); + } qtest_start(cmd); g_free(cmd); =20 @@ -953,7 +985,13 @@ int main(int argc, char **argv) /* run the main loop thread so the chardev may operate */ thread =3D g_thread_new(NULL, thread_function, loop); =20 - qtest_add_func("/vhost-user/read-guest-mem", test_read_guest_mem); + if (qemu_memfd_check()) { + qtest_add_data_func("/vhost-user/read-guest-mem/memfd", + GINT_TO_POINTER(TEST_MEMFD_YES), + test_read_guest_mem); + } + qtest_add_data_func("/vhost-user/read-guest-mem/memfile", + GINT_TO_POINTER(TEST_MEMFD_NO), test_read_guest_me= m); qtest_add_func("/vhost-user/migrate", test_migrate); qtest_add_func("/vhost-user/multiqueue", test_multiqueue); =20 --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860924400898.2486068774621; Mon, 5 Feb 2018 12:02:04 -0800 (PST) Received: from localhost ([::1]:55062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimxn-0000up-EC for importer@patchew.org; Mon, 05 Feb 2018 15:02:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSk-0004wj-0d for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSi-0005Bk-TB for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:58 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:35903) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSi-0005BS-M9 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:56 -0500 Received: by mail-wr0-x241.google.com with SMTP id y3so21002549wrh.3 for ; Mon, 05 Feb 2018 11:29:56 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:54 -0800 (PST) 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=ZaDs/iG7KH18a3eDR4Hx2y6pvLj+R8Ohv70wfgb3MCw=; b=HHIOzMJX7ZKDvEzk18Bu9mzfn/cmceIXa1Ho6/9MJR1WI8SxLk3Gl5iU1Q37NmwN7M 6MCc8QyBxiixsM+6fnI7YgJ3AhU0b6H4DyxyKlLBQmU8LGeFx9+SfuXafXgLDs+qjk75 HOngf11OxraTWsQfa1uT7QYtFKke7esVf7zThaDsyNa1AWNmE+Dz22qJIis9LK8vP6lr FSqiq69FFceemM2a22L9Zlc6lCr8/lC33x5llgQuf4iOCWDDLCTjFpwoRYAnDlGH/f1F 0S03JlgPPEPjAZIbDjpTW4N9CXu4kAI7PCpU92NeoifOUOEVTOQLgzsoM6JNQbq3viCX AEzA== 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=ZaDs/iG7KH18a3eDR4Hx2y6pvLj+R8Ohv70wfgb3MCw=; b=KVoINwmGkasbWPgCVED7SQZcpA7txNjiz1BHZUV7A+VlKBnOOVPb4qycujX3rAU1T7 pKl5uzGRR9nbdD8qQrMGCxDpAjaH/ysKbVN5XvJus9G8kHS+KU/8ibqRE00Wwic6+i8/ 4WnbqprRCG6IE0ckiEdIjpQ53sCFujDe9OCBvkHOgM5JFSKUILFqVhZcG//59tPb1NJq NwTRCOc2G1nHft3ne3s5IAcpFHVYs6s5pZsJ3JxRRgLEgcQi8Fx4HlkYWSR7faQyczVN CNDu3bEgw1LdYWN0RAgWl9KurK2/OueasqHAcGOkKxtSB9CDgHPxCjecIJLvb5O8qGMM UCRA== X-Gm-Message-State: AKwxytcKQnKFwr4/eMb2GPwMmWSmNU2psbI/774LyTc/tJKMMUtIfx5O NbkrtJvfECCUx7NIzmXt02HcsUgi X-Google-Smtp-Source: AH8x225/+fZm3YGDMY6tqwQe4nxPj7X23965wC0QKSClo25tpVj0SFyMf5CHycYZBeZTsY6Fl2/Qlg== X-Received: by 10.223.164.148 with SMTP id g20mr44104103wrb.49.1517858995287; Mon, 05 Feb 2018 11:29:55 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:57 +0100 Message-Id: <1517858941-5538-44-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 43/47] tests/test-filter-redirector: move close() 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: Klim Kireev 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: Klim Kireev Since we have separate handler on POLLHUP, which drops data after closing the connection we need to fix this test, because it sends data and instantly close the socket creating race condition. In some cases on other end of socket client closes it faster than reads data. To prevent it I suggest to close socket after recieving. Signed-off-by: Klim Kireev Message-Id: <20180201134831.17709-1-klim.kireev@virtuozzo.com> Signed-off-by: Paolo Bonzini --- tests/test-filter-redirector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-filter-redirector.c b/tests/test-filter-redirector.c index f256614..fbaf19b 100644 --- a/tests/test-filter-redirector.c +++ b/tests/test-filter-redirector.c @@ -186,7 +186,6 @@ static void test_redirector_rx(void) =20 ret =3D iov_send(send_sock, iov, 2, 0, sizeof(size) + sizeof(send_buf)= ); g_assert_cmpint(ret, =3D=3D, sizeof(send_buf) + sizeof(size)); - close(send_sock); =20 ret =3D qemu_recv(backend_sock[0], &len, sizeof(len), 0); g_assert_cmpint(ret, =3D=3D, sizeof(len)); @@ -197,6 +196,7 @@ static void test_redirector_rx(void) ret =3D qemu_recv(backend_sock[0], recv_buf, len, 0); g_assert_cmpstr(recv_buf, =3D=3D, send_buf); =20 + close(send_sock); g_free(recv_buf); unlink(sock_path0); unlink(sock_path1); --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517861540346973.7696631345309; Mon, 5 Feb 2018 12:12:20 -0800 (PST) Received: from localhost ([::1]:55948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ein7j-0001hn-Fi for importer@patchew.org; Mon, 05 Feb 2018 15:12:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSl-0004yV-Fh for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:30:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSk-0005C9-6l for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:59 -0500 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:54138) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSj-0005Bs-Tj for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:58 -0500 Received: by mail-wm0-x231.google.com with SMTP id t74so28416658wme.3 for ; Mon, 05 Feb 2018 11:29:57 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:55 -0800 (PST) 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=Mf9Zwxp17Q2zaiYy5cXuiYPBIKxNAKqmFNwpTspDSHo=; b=vgVXMNjsjoAm49VGhGrobm3XHv/uZQ/DllLHMKzd0pHZyK/lmqo30MOgJ9DZpd4Eui e6FywOkhP/PNuDDDFZIWolNzZGFy/5g91ogfMjwKfiLvj84DAMow0Zlq+a+ff/YhW7mM enwFXX+3zRHn7kt7VGhpHlB/eSn9RGCbrOaVfwZ5ZHcMcfUIAk7UcULt7tss+F1cCGLA 9niq0B8trpR4jdx0F0qcsAUG/VaPisU0u9gg5hv3J+KJKRuqEqrb3fkl7FmJQSvSQPag cTv3CroNRlbABZdskT5xYsyAgrMsdyDeM17LtNCrq8KHhYFaxfD1i1YfzInVbc5e+3c/ IbtQ== 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=Mf9Zwxp17Q2zaiYy5cXuiYPBIKxNAKqmFNwpTspDSHo=; b=CPaMybKmv8O0jqFldT3g0XPDKbMFDKVFmDb0AHg1sTyKt3O57KnkHeVIKq+sxQpZTO RqziFwSNYniGCKz74VhPuQJo5hOXkwKYvkTHJoFuE8ey3EWeHqcJhzMyPP0Xwqn/A1CY 3/3Gz2WTzkjTcYS6LAJ9THWx3hL1WG3qKI/Jn49pnvF25lTfZpq4K0oI0GWZlDsoF+yy 2CqRtbCaYnp7fHGBSzv3KAQrhZ7fiGDMsb43TXwfMPzpjLdhy635YVxzNn1tV1LmU4AB oTkxy4A5CgB1IHaOS6bXV44HtgrltGPdHk/8WPOIE9qb3riVP2vqeltZnGvXYxMYoynQ BH6w== X-Gm-Message-State: APf1xPDKOfuCXAyYMp9/RbohVHw+5u4zZqSRW8LMvEZyy3UxiaRZXARC yznYBm5AlMXBdyLDOQqJlTD9f3aU X-Google-Smtp-Source: AH8x225WhyITCOIAIW+76nUUHvlwqbAJpulWJSbWA7em3AY17izdhK1uCyTv1Ycn7UJlYfhoA0ZVXA== X-Received: by 10.28.238.202 with SMTP id j71mr328599wmi.34.1517858996461; Mon, 05 Feb 2018 11:29:56 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:58 +0100 Message-Id: <1517858941-5538-45-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 44/47] Add the Windows Hypervisor Platform accelerator. 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)" Introduces the configure support for the new Windows Hypervisor Platform th= at allows for hypervisor acceleration from usermode components on the Windows platform. Signed-off-by: Justin Terry (VM) Message-Id: <1516655269-1785-2-git-send-email-juterry@microsoft.com> Signed-off-by: Paolo Bonzini --- configure | 48 +++++++++++++++++++++++++++++++++++++++++++++++- qemu-options.hx | 8 ++++---- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 0b5c812..0e79dee 100755 --- a/configure +++ b/configure @@ -222,6 +222,17 @@ supported_hvf_target() { return 1 } =20 +supported_whpx_target() { + test "$whpx" =3D "yes" || return 1 + glob "$1" "*-softmmu" || return 1 + case "${1%-softmmu}" in + i386|x86_64) + return 0 + ;; + esac + return 1 +} + supported_target() { case "$1" in *-softmmu) @@ -248,6 +259,7 @@ supported_target() { supported_xen_target "$1" && return 0 supported_hax_target "$1" && return 0 supported_hvf_target "$1" && return 0 + supported_whpx_target "$1" && return 0 print_error "TCG disabled, but hardware accelerator not available for = '$target'" return 1 } @@ -338,6 +350,7 @@ vhost_user=3D"" kvm=3D"no" hax=3D"no" hvf=3D"no" +whpx=3D"no" rdma=3D"" gprof=3D"no" debug_tcg=3D"no" @@ -1058,6 +1071,10 @@ for opt do ;; --enable-hvf) hvf=3D"yes" ;; + --disable-whpx) whpx=3D"no" + ;; + --enable-whpx) whpx=3D"yes" + ;; --disable-tcg-interpreter) tcg_interpreter=3D"no" ;; --enable-tcg-interpreter) tcg_interpreter=3D"yes" @@ -1557,6 +1574,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: kvm KVM acceleration support hax HAX acceleration support hvf Hypervisor.framework acceleration support + whpx Windows Hypervisor Platform acceleration support rdma RDMA-based migration support vde support for vde network netmap support for netmap network @@ -2456,6 +2474,30 @@ if test "$xen_pv_domain_build" =3D "yes" && fi =20 ########################################## +# Windows Hypervisor Platform accelerator (WHPX) check +if test "$whpx" !=3D "no" ; then + cat > $TMPC << EOF +#include +#include +#include +int main(void) { + WHV_CAPABILITY whpx_cap; + WHvGetCapability(WHvCapabilityCodeFeatures, &whpx_cap, sizeof(whpx_cap= )); + return 0; +} +EOF + if compile_prog "" "-lwinhvplatform -lwinhvemulation" ; then + libs_softmmu=3D"$libs_softmmu -lwinhvplatform -lwinhvemulation" + whpx=3D"yes" + else + if test "$whpx" =3D "yes"; then + feature_not_found "winhvplatform" "winhvemulation is not insta= lled" + fi + whpx=3D"no" + fi +fi + +########################################## # Sparse probe if test "$sparse" !=3D "no" ; then if has cgcc; then @@ -5653,6 +5695,7 @@ echo "Install blobs $blobs" echo "KVM support $kvm" echo "HAX support $hax" echo "HVF support $hvf" +echo "WHPX support $whpx" echo "TCG support $tcg" if test "$tcg" =3D "yes" ; then echo "TCG debug enabled $debug_tcg" @@ -5820,7 +5863,7 @@ if test "$mingw32" =3D "yes" ; then echo "CONFIG_QGA_NTDDDISK=3Dy" >> $config_host_mak fi if test "$guest_agent_msi" =3D "yes"; then - echo "QEMU_GA_MSI_ENABLED=3Dyes" >> $config_host_mak =20 + echo "QEMU_GA_MSI_ENABLED=3Dyes" >> $config_host_mak echo "QEMU_GA_MSI_MINGW_DLL_PATH=3D${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $= config_host_mak echo "QEMU_GA_MSI_WITH_VSS=3D${QEMU_GA_MSI_WITH_VSS}" >> $config_host_= mak echo "QEMU_GA_MSI_ARCH=3D${QEMU_GA_MSI_ARCH}" >> $config_host_mak @@ -6753,6 +6796,9 @@ fi if supported_hvf_target $target; then echo "CONFIG_HVF=3Dy" >> $config_target_mak fi +if supported_whpx_target $target; then + echo "CONFIG_WHPX=3Dy" >> $config_target_mak +fi if test "$target_bigendian" =3D "yes" ; then echo "TARGET_WORDS_BIGENDIAN=3Dy" >> $config_target_mak fi diff --git a/qemu-options.hx b/qemu-options.hx index 265cf9f..d15c171 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -31,7 +31,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ "-machine [type=3D]name[,prop[=3Dvalue][,...]]\n" " selects emulated machine ('-machine help' for list)\n" " property accel=3Daccel1[:accel2[:...]] selects accele= rator\n" - " supported accelerators are kvm, xen, hax, hvf or tcg = (default: tcg)\n" + " supported accelerators are kvm, xen, hax, hvf, whpx o= r tcg (default: tcg)\n" " kernel_irqchip=3Don|off|split controls accelerated ir= qchip support (default=3Doff)\n" " vmport=3Don|off|auto controls emulation of vmport (de= fault: auto)\n" " kvm_shadow_mem=3Dsize of KVM shadow MMU in bytes\n" @@ -66,7 +66,7 @@ Supported machine properties are: @table @option @item accel=3D@var{accels1}[:@var{accels2}[:...]] This is used to enable an accelerator. Depending on the target architectur= e, -kvm, xen, hax, hvf or tcg can be available. By default, tcg is used. If th= ere is +kvm, xen, hax, hvf, whpx or tcg can be available. By default, tcg is used.= If there is more than one accelerator specified, the next one is used if the previous = one fails to initialize. @item kernel_irqchip=3Don|off @@ -126,13 +126,13 @@ ETEXI =20 DEF("accel", HAS_ARG, QEMU_OPTION_accel, "-accel [accel=3D]accelerator[,thread=3Dsingle|multi]\n" - " select accelerator (kvm, xen, hax, hvf or tcg; use 'h= elp' for a list)\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) STEXI @item -accel @var{name}[,prop=3D@var{value}[,...]] @findex -accel This is used to enable an accelerator. Depending on the target architectur= e, -kvm, xen, hax, hvf or tcg can be available. By default, tcg is used. If th= ere is +kvm, xen, hax, hvf, whpx or tcg can be available. By default, tcg is used.= If there is more than one accelerator specified, the next one is used if the previous = one fails to initialize. @table @option --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 15178617384281020.080802861768; Mon, 5 Feb 2018 12:15:38 -0800 (PST) Received: from localhost ([::1]:56748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1einAs-0005Df-S0 for importer@patchew.org; Mon, 05 Feb 2018 15:15:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSm-00050L-CB for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:30:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSl-0005CY-8I for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:30:00 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:35844) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSl-0005CE-1t for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:59 -0500 Received: by mail-wm0-x243.google.com with SMTP id f3so28132185wmc.1 for ; Mon, 05 Feb 2018 11:29:58 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:56 -0800 (PST) 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=OAFdrf6BGWmewLqCJxU/zX6u/FunP/LSTpq9J0+IwSA=; b=pzua7c7o6hkiy4m7EYu52BGcQusTNHO2A7FTfW3GmeHfZxgfEiO/1AvtJJbTMrxcUR NRNuAnWOdr6lHIsOyl8teCV7T4Gv5Y82g3tL4xI/r8WpJqCxzB11aZ8NnsZYgjkXYs6S PPhBqTp+wFxLOjwBlBfhuxf4SrlnivyNUKqz+S3Eekxk28/YBGV/v8FVTWFLLBiAEKXv tUIB1ceeqcu9c98BNMHHcMhl3QamKockFEmGQMhPK10Cdif50as5z6FXSGd+BXJtFKMS aNZ/5XZ9jDoec5ywm+ylR4Pb1eJraT8AOc1w5HlFQdDYqpvpqBKjSED7BbIPTqyF2rdc 8MkA== 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=OAFdrf6BGWmewLqCJxU/zX6u/FunP/LSTpq9J0+IwSA=; b=epobqiu36NbqOmkp0cyzZFb2Zc9R6bC7rgBQoi4LM3p3ofFmD6urX9DZGn0FVOs39q IMJZTQeswxUOsAeiPMKQqdJNg8dbAy8GjlngVgqMqZX6s9rtCbcuyxTb4psc8Nfc+Yko B/dzhiUfZ+mumvCbWwVvGfpZjkNlKijhPksq+ks/kvmTbQNDO2JNeZ7tUuusJF5VMJiq gAOftWNkaze67RvO+v7Zpcd7JfLA0yqZJgMjzs073cSK99/CWLEMfwGGWvK6vQyLYj0V ZdJHIBDbCweWlOec11/1kD+pPbrIxPa7iR67wSC3RdlILwo7t77iT1DVH74cqnA8yMHe ltQQ== X-Gm-Message-State: APf1xPA9Rk+DYq1TnDJXl/fbeczCOlrTpL1GoEB0oecnhP9tQMsSrNa1 vlXl7S9Vt3VEQ2zWyRbrKLg+WVm5 X-Google-Smtp-Source: AH8x226WdPc4MUVB9F64A+Uo72/Jtx1HD2nZIH29VsRWtmn6T1aQEXUgSvqdALdUuFowzSO24fDzWw== X-Received: by 10.28.54.26 with SMTP id d26mr285536wma.59.1517858997699; Mon, 05 Feb 2018 11:29:57 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:59 +0100 Message-Id: <1517858941-5538-46-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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::243 Subject: [Qemu-devel] [PULL 45/47] Add the WHPX vcpu API 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 support for the Windows Hypervisor Platform accelerator (WHPX) stubs a= nd introduces the whpx.h sysemu API for managing the vcpu scheduling and management. Signed-off-by: Justin Terry (VM) Message-Id: <1516655269-1785-3-git-send-email-juterry@microsoft.com> Signed-off-by: Paolo Bonzini --- accel/stubs/Makefile.objs | 9 +++++---- accel/stubs/whpx-stub.c | 48 +++++++++++++++++++++++++++++++++++++++++++= ++++ include/sysemu/whpx.h | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 accel/stubs/whpx-stub.c create mode 100644 include/sysemu/whpx.h diff --git a/accel/stubs/Makefile.objs b/accel/stubs/Makefile.objs index 779343b..3894caf 100644 --- a/accel/stubs/Makefile.objs +++ b/accel/stubs/Makefile.objs @@ -1,4 +1,5 @@ -obj-$(call lnot,$(CONFIG_HAX)) +=3D hax-stub.o -obj-$(call lnot,$(CONFIG_HVF)) +=3D hvf-stub.o -obj-$(call lnot,$(CONFIG_KVM)) +=3D kvm-stub.o -obj-$(call lnot,$(CONFIG_TCG)) +=3D tcg-stub.o +obj-$(call lnot,$(CONFIG_HAX)) +=3D hax-stub.o +obj-$(call lnot,$(CONFIG_HVF)) +=3D hvf-stub.o +obj-$(call lnot,$(CONFIG_WHPX)) +=3D whpx-stub.o +obj-$(call lnot,$(CONFIG_KVM)) +=3D kvm-stub.o +obj-$(call lnot,$(CONFIG_TCG)) +=3D tcg-stub.o diff --git a/accel/stubs/whpx-stub.c b/accel/stubs/whpx-stub.c new file mode 100644 index 0000000..5fb049c --- /dev/null +++ b/accel/stubs/whpx-stub.c @@ -0,0 +1,48 @@ +/* + * QEMU Windows Hypervisor Platform accelerator (WHPX) stub + * + * Copyright Microsoft Corp. 2017 + * + * 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-common.h" +#include "cpu.h" +#include "sysemu/whpx.h" + +int whpx_init_vcpu(CPUState *cpu) +{ + return -1; +} + +int whpx_vcpu_exec(CPUState *cpu) +{ + return -1; +} + +void whpx_destroy_vcpu(CPUState *cpu) +{ +} + +void whpx_vcpu_kick(CPUState *cpu) +{ +} + +void whpx_cpu_synchronize_state(CPUState *cpu) +{ +} + +void whpx_cpu_synchronize_post_reset(CPUState *cpu) +{ +} + +void whpx_cpu_synchronize_post_init(CPUState *cpu) +{ +} + +void whpx_cpu_synchronize_pre_loadvm(CPUState *cpu) +{ +} diff --git a/include/sysemu/whpx.h b/include/sysemu/whpx.h new file mode 100644 index 0000000..89592ae --- /dev/null +++ b/include/sysemu/whpx.h @@ -0,0 +1,40 @@ +/* + * QEMU Windows Hypervisor Platform accelerator (WHPX) support + * + * Copyright Microsoft, Corp. 2017 + * + * Authors: + * + * 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_WHPX_H +#define QEMU_WHPX_H + +#include "config-host.h" +#include "qemu-common.h" + +int whpx_init_vcpu(CPUState *cpu); +int whpx_vcpu_exec(CPUState *cpu); +void whpx_destroy_vcpu(CPUState *cpu); +void whpx_vcpu_kick(CPUState *cpu); + + +void whpx_cpu_synchronize_state(CPUState *cpu); +void whpx_cpu_synchronize_post_reset(CPUState *cpu); +void whpx_cpu_synchronize_post_init(CPUState *cpu); +void whpx_cpu_synchronize_pre_loadvm(CPUState *cpu); + +#ifdef CONFIG_WHPX + +int whpx_enabled(void); + +#else /* CONFIG_WHPX */ + +#define whpx_enabled() (0) + +#endif /* CONFIG_WHPX */ + +#endif /* QEMU_WHPX_H */ --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517861171216487.6328812369328; Mon, 5 Feb 2018 12:06:11 -0800 (PST) Received: from localhost ([::1]:55089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ein1m-0004MD-6r for importer@patchew.org; Mon, 05 Feb 2018 15:06:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSs-00056N-3T for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:30:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSo-0005Fi-3a for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:30:06 -0500 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:38523) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSn-0005Dn-FM for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:30:02 -0500 Received: by mail-wm0-x230.google.com with SMTP id 141so27961150wme.3 for ; Mon, 05 Feb 2018 11:30:01 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:58 -0800 (PST) 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=C9XA7dqDMa4sqDM0VyzgOYm3vCUKmYb4NK5LOIq0V2Y=; b=jiFEfF6PTNxUuyidGmORy2CjOU5QwIRDNn1BbQIA3PcwHIosw2kuTUXm9LfZCKI6gl MddbQSKV23tzqzHUNlgL5cQL1yZe+rRTpNT/8+9xwQfjTwfBCiQ61MjtlbALFoH1o0KQ iBI7Rqb/9myrPrtXjcgQY0PGhceAfsD0MgGR8nMQS+iAZXUDLfKmv8XwXpk52DdM/cZK T//H+mnj0HB9xDc20LtA2YPN3Uv46AaS2l9DrYZ0TDLSHelbRqpuFIQuXvY5hfjcuI8/ xy0x2eldj9UWbjR2bYEpzSaAxOWwZbG3r5j4cBklUzo1nyTKdiArQTw7Npjr1EiUtdRK kp8A== 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=C9XA7dqDMa4sqDM0VyzgOYm3vCUKmYb4NK5LOIq0V2Y=; b=AJuRmuS9kqLpO8XDW8J475ZjqUBjOHBMquIMWfkXjqAVMcoP2f6Z06L8PVNotCeTV+ icNsAob4IsoSBE6DppuJ2jr8oGAhfHu4EdT5NyDR77jY+O5TJAEljvB9pLFOC6C6nwQT HjDFdEl9HKddSdf1M0GBWk6pDZapzIc+bXCpQWE+hIaUe7BGZbpFr4ZFxu0soMUn0zVi wYLiTFEtko80SMDJ5UuooOCuO4JXLCtOPklpoc4Ht9TXQOZn3sUgVQrSOlYANxSdq+4k r+p4XBQ9m4RxeboeIntkhfeDUsynWMwIUYJcfBmxt3q4y+KdJ7RKAKRTq6p7N+6l8rbV M4UQ== X-Gm-Message-State: APf1xPCWP/HmLQv9YWL6WLrs2bl/aYxzvRBl5DwtAmaSWOThHM1Bqk3f 4EevKtAYYrmtjwpiTN+r6NmBGsIY X-Google-Smtp-Source: AH8x226DcvEnA8eu+E+sIPKWWad9+iNtPICySNSNImGkkw9a1qD9ZG/36RvPhPqkqM/wWOCerAZ7cw== X-Received: by 10.28.32.15 with SMTP id g15mr307042wmg.22.1517858999520; Mon, 05 Feb 2018 11:29:59 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:29:00 +0100 Message-Id: <1517858941-5538-47-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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::230 Subject: [Qemu-devel] [PULL 46/47] Introduce the WHPX impl 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)" Implements the Windows Hypervisor Platform accelerator (WHPX) target. Which acts as a hypervisor accelerator for QEMU on the Windows platform. This ena= bles QEMU much greater speed over the emulated x86_64 path's that are taken on Windows today. 1. Adds support for vPartition management. 2. Adds support for vCPU management. 3. Adds support for MMIO/PortIO. 4. Registers the WHPX ACCEL_CLASS. Signed-off-by: Justin Terry (VM) Message-Id: <1516655269-1785-4-git-send-email-juterry@microsoft.com> Signed-off-by: Paolo Bonzini --- target/i386/Makefile.objs | 1 + target/i386/whpx-all.c | 1366 +++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 1367 insertions(+) create mode 100644 target/i386/whpx-all.c diff --git a/target/i386/Makefile.objs b/target/i386/Makefile.objs index 44103a6..f5c6ef2 100644 --- a/target/i386/Makefile.objs +++ b/target/i386/Makefile.objs @@ -14,3 +14,4 @@ ifdef CONFIG_DARWIN obj-$(CONFIG_HAX) +=3D hax-all.o hax-mem.o hax-darwin.o obj-$(CONFIG_HVF) +=3D hvf/ endif +obj-$(CONFIG_WHPX) +=3D whpx-all.o diff --git a/target/i386/whpx-all.c b/target/i386/whpx-all.c new file mode 100644 index 0000000..0015b27 --- /dev/null +++ b/target/i386/whpx-all.c @@ -0,0 +1,1366 @@ +/* + * QEMU Windows Hypervisor Platform accelerator (WHPX) + * + * Copyright Microsoft Corp. 2017 + * + * 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 "cpu.h" +#include "exec/address-spaces.h" +#include "exec/exec-all.h" +#include "exec/ioport.h" +#include "qemu-common.h" +#include "strings.h" +#include "sysemu/accel.h" +#include "sysemu/whpx.h" +#include "sysemu/sysemu.h" +#include "sysemu/cpus.h" +#include "qemu/main-loop.h" +#include "hw/boards.h" +#include "qemu/error-report.h" +#include "qemu/queue.h" +#include "qapi/error.h" +#include "migration/blocker.h" + +#include +#include + +struct whpx_state { + uint64_t mem_quota; + WHV_PARTITION_HANDLE partition; + uint32_t exit_ctx_size; +}; + +static const WHV_REGISTER_NAME whpx_register_names[] =3D { + + /* X64 General purpose registers */ + WHvX64RegisterRax, + WHvX64RegisterRcx, + WHvX64RegisterRdx, + WHvX64RegisterRbx, + WHvX64RegisterRsp, + WHvX64RegisterRbp, + WHvX64RegisterRsi, + WHvX64RegisterRdi, + WHvX64RegisterR8, + WHvX64RegisterR9, + WHvX64RegisterR10, + WHvX64RegisterR11, + WHvX64RegisterR12, + WHvX64RegisterR13, + WHvX64RegisterR14, + WHvX64RegisterR15, + WHvX64RegisterRip, + WHvX64RegisterRflags, + + /* X64 Segment registers */ + WHvX64RegisterEs, + WHvX64RegisterCs, + WHvX64RegisterSs, + WHvX64RegisterDs, + WHvX64RegisterFs, + WHvX64RegisterGs, + WHvX64RegisterLdtr, + WHvX64RegisterTr, + + /* X64 Table registers */ + WHvX64RegisterIdtr, + WHvX64RegisterGdtr, + + /* X64 Control Registers */ + WHvX64RegisterCr0, + WHvX64RegisterCr2, + WHvX64RegisterCr3, + WHvX64RegisterCr4, + WHvX64RegisterCr8, + + /* X64 Debug Registers */ + /* + * WHvX64RegisterDr0, + * WHvX64RegisterDr1, + * WHvX64RegisterDr2, + * WHvX64RegisterDr3, + * WHvX64RegisterDr6, + * WHvX64RegisterDr7, + */ + + /* X64 Floating Point and Vector Registers */ + WHvX64RegisterXmm0, + WHvX64RegisterXmm1, + WHvX64RegisterXmm2, + WHvX64RegisterXmm3, + WHvX64RegisterXmm4, + WHvX64RegisterXmm5, + WHvX64RegisterXmm6, + WHvX64RegisterXmm7, + WHvX64RegisterXmm8, + WHvX64RegisterXmm9, + WHvX64RegisterXmm10, + WHvX64RegisterXmm11, + WHvX64RegisterXmm12, + WHvX64RegisterXmm13, + WHvX64RegisterXmm14, + WHvX64RegisterXmm15, + WHvX64RegisterFpMmx0, + WHvX64RegisterFpMmx1, + WHvX64RegisterFpMmx2, + WHvX64RegisterFpMmx3, + WHvX64RegisterFpMmx4, + WHvX64RegisterFpMmx5, + WHvX64RegisterFpMmx6, + WHvX64RegisterFpMmx7, + WHvX64RegisterFpControlStatus, + WHvX64RegisterXmmControlStatus, + + /* X64 MSRs */ + WHvX64RegisterTsc, + WHvX64RegisterEfer, +#ifdef TARGET_X86_64 + WHvX64RegisterKernelGsBase, +#endif + WHvX64RegisterApicBase, + /* WHvX64RegisterPat, */ + WHvX64RegisterSysenterCs, + WHvX64RegisterSysenterEip, + WHvX64RegisterSysenterEsp, + WHvX64RegisterStar, +#ifdef TARGET_X86_64 + WHvX64RegisterLstar, + WHvX64RegisterCstar, + WHvX64RegisterSfmask, +#endif + + /* Interrupt / Event Registers */ + /* + * WHvRegisterPendingInterruption, + * WHvRegisterInterruptState, + * WHvRegisterPendingEvent0, + * WHvRegisterPendingEvent1 + * WHvX64RegisterDeliverabilityNotifications, + */ +}; + +struct whpx_register_set { + WHV_REGISTER_VALUE values[RTL_NUMBER_OF(whpx_register_names)]; +}; + +struct whpx_vcpu { + WHV_EMULATOR_HANDLE emulator; + bool window_registered; + bool interruptable; + uint64_t tpr; + uint64_t apic_base; + WHV_X64_PENDING_INTERRUPTION_REGISTER interrupt_in_flight; + + /* Must be the last field as it may have a tail */ + WHV_RUN_VP_EXIT_CONTEXT exit_ctx; +}; + +static bool whpx_allowed; + +struct whpx_state whpx_global; + + +/* + * VP support + */ + +static struct whpx_vcpu *get_whpx_vcpu(CPUState *cpu) +{ + return (struct whpx_vcpu *)cpu->hax_vcpu; +} + +static WHV_X64_SEGMENT_REGISTER whpx_seg_q2h(const SegmentCache *qs, int v= 86, + int r86) +{ + WHV_X64_SEGMENT_REGISTER hs; + unsigned flags =3D qs->flags; + + hs.Base =3D qs->base; + hs.Limit =3D qs->limit; + hs.Selector =3D qs->selector; + + if (v86) { + hs.Attributes =3D 0; + hs.SegmentType =3D 3; + hs.Present =3D 1; + hs.DescriptorPrivilegeLevel =3D 3; + hs.NonSystemSegment =3D 1; + + } else { + hs.Attributes =3D (flags >> DESC_TYPE_SHIFT); + + if (r86) { + /* hs.Base &=3D 0xfffff; */ + } + } + + return hs; +} + +static SegmentCache whpx_seg_h2q(const WHV_X64_SEGMENT_REGISTER *hs) +{ + SegmentCache qs; + + qs.base =3D hs->Base; + qs.limit =3D hs->Limit; + qs.selector =3D hs->Selector; + + qs.flags =3D ((uint32_t)hs->Attributes) << DESC_TYPE_SHIFT; + + return qs; +} + +static void whpx_set_registers(CPUState *cpu) +{ + struct whpx_state *whpx =3D &whpx_global; + struct whpx_vcpu *vcpu =3D get_whpx_vcpu(cpu); + struct CPUX86State *env =3D (CPUArchState *)(cpu->env_ptr); + X86CPU *x86_cpu =3D X86_CPU(cpu); + struct whpx_register_set vcxt =3D {0}; + HRESULT hr; + int idx =3D 0; + int i; + int v86, r86; + + assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu)); + + v86 =3D (env->eflags & VM_MASK); + r86 =3D !(env->cr[0] & CR0_PE_MASK); + + vcpu->tpr =3D cpu_get_apic_tpr(x86_cpu->apic_state); + vcpu->apic_base =3D cpu_get_apic_base(x86_cpu->apic_state); + + /* Indexes for first 16 registers match between HV and QEMU definition= s */ + for (idx =3D 0; idx < CPU_NB_REGS64; idx +=3D 1) { + vcxt.values[idx].Reg64 =3D env->regs[idx]; + } + + /* Same goes for RIP and RFLAGS */ + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterRip); + vcxt.values[idx++].Reg64 =3D env->eip; + + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterRflags); + vcxt.values[idx++].Reg64 =3D env->eflags; + + /* Translate 6+4 segment registers. HV and QEMU order matches */ + assert(idx =3D=3D WHvX64RegisterEs); + for (i =3D 0; i < 6; i +=3D 1, idx +=3D 1) { + vcxt.values[idx].Segment =3D whpx_seg_q2h(&env->segs[i], v86, r86); + } + + assert(idx =3D=3D WHvX64RegisterLdtr); + vcxt.values[idx++].Segment =3D whpx_seg_q2h(&env->ldt, 0, 0); + + assert(idx =3D=3D WHvX64RegisterTr); + vcxt.values[idx++].Segment =3D whpx_seg_q2h(&env->tr, 0, 0); + + assert(idx =3D=3D WHvX64RegisterIdtr); + vcxt.values[idx].Table.Base =3D env->idt.base; + vcxt.values[idx].Table.Limit =3D env->idt.limit; + idx +=3D 1; + + assert(idx =3D=3D WHvX64RegisterGdtr); + vcxt.values[idx].Table.Base =3D env->gdt.base; + vcxt.values[idx].Table.Limit =3D env->gdt.limit; + idx +=3D 1; + + /* CR0, 2, 3, 4, 8 */ + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCr0); + vcxt.values[idx++].Reg64 =3D env->cr[0]; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCr2); + vcxt.values[idx++].Reg64 =3D env->cr[2]; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCr3); + vcxt.values[idx++].Reg64 =3D env->cr[3]; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCr4); + vcxt.values[idx++].Reg64 =3D env->cr[4]; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCr8); + vcxt.values[idx++].Reg64 =3D vcpu->tpr; + + /* 8 Debug Registers - Skipped */ + + /* 16 XMM registers */ + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterXmm0); + for (i =3D 0; i < 16; i +=3D 1, idx +=3D 1) { + vcxt.values[idx].Reg128.Low64 =3D env->xmm_regs[i].ZMM_Q(0); + vcxt.values[idx].Reg128.High64 =3D env->xmm_regs[i].ZMM_Q(1); + } + + /* 8 FP registers */ + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterFpMmx0); + for (i =3D 0; i < 8; i +=3D 1, idx +=3D 1) { + vcxt.values[idx].Fp.AsUINT128.Low64 =3D env->fpregs[i].mmx.MMX_Q(0= ); + /* vcxt.values[idx].Fp.AsUINT128.High64 =3D + env->fpregs[i].mmx.MMX_Q(1); + */ + } + + /* FP control status register */ + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterFpControlStatus); + vcxt.values[idx].FpControlStatus.FpControl =3D env->fpuc; + vcxt.values[idx].FpControlStatus.FpStatus =3D + (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; + vcxt.values[idx].FpControlStatus.FpTag =3D 0; + for (i =3D 0; i < 8; ++i) { + vcxt.values[idx].FpControlStatus.FpTag |=3D (!env->fptags[i]) << i; + } + vcxt.values[idx].FpControlStatus.Reserved =3D 0; + vcxt.values[idx].FpControlStatus.LastFpOp =3D env->fpop; + vcxt.values[idx].FpControlStatus.LastFpRip =3D env->fpip; + idx +=3D 1; + + /* XMM control status register */ + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterXmmControlStatus); + vcxt.values[idx].XmmControlStatus.LastFpRdp =3D 0; + vcxt.values[idx].XmmControlStatus.XmmStatusControl =3D env->mxcsr; + vcxt.values[idx].XmmControlStatus.XmmStatusControlMask =3D 0x0000ffff; + idx +=3D 1; + + /* MSRs */ + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterTsc); + vcxt.values[idx++].Reg64 =3D env->tsc; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterEfer); + vcxt.values[idx++].Reg64 =3D env->efer; +#ifdef TARGET_X86_64 + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterKernelGsBase); + vcxt.values[idx++].Reg64 =3D env->kernelgsbase; +#endif + + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterApicBase); + vcxt.values[idx++].Reg64 =3D vcpu->apic_base; + + /* WHvX64RegisterPat - Skipped */ + + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterSysenterCs); + vcxt.values[idx++].Reg64 =3D env->sysenter_cs; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterSysenterEip); + vcxt.values[idx++].Reg64 =3D env->sysenter_eip; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterSysenterEsp); + vcxt.values[idx++].Reg64 =3D env->sysenter_esp; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterStar); + vcxt.values[idx++].Reg64 =3D env->star; +#ifdef TARGET_X86_64 + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterLstar); + vcxt.values[idx++].Reg64 =3D env->lstar; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCstar); + vcxt.values[idx++].Reg64 =3D env->cstar; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterSfmask); + vcxt.values[idx++].Reg64 =3D env->fmask; +#endif + + /* Interrupt / Event Registers - Skipped */ + + assert(idx =3D=3D RTL_NUMBER_OF(whpx_register_names)); + + hr =3D WHvSetVirtualProcessorRegisters(whpx->partition, cpu->cpu_index, + whpx_register_names, + RTL_NUMBER_OF(whpx_register_names= ), + &vcxt.values[0]); + + if (FAILED(hr)) { + error_report("WHPX: Failed to set virtual processor context, hr=3D= %08lx", + hr); + __debugbreak(); + } + + return; +} + +static void whpx_get_registers(CPUState *cpu) +{ + struct whpx_state *whpx =3D &whpx_global; + struct whpx_vcpu *vcpu =3D get_whpx_vcpu(cpu); + struct CPUX86State *env =3D (CPUArchState *)(cpu->env_ptr); + X86CPU *x86_cpu =3D X86_CPU(cpu); + struct whpx_register_set vcxt; + uint64_t tpr, apic_base; + HRESULT hr; + int idx =3D 0; + int i; + + assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu)); + + hr =3D WHvGetVirtualProcessorRegisters(whpx->partition, cpu->cpu_index, + whpx_register_names, + RTL_NUMBER_OF(whpx_register_names= ), + &vcxt.values[0]); + if (FAILED(hr)) { + error_report("WHPX: Failed to get virtual processor context, hr=3D= %08lx", + hr); + __debugbreak(); + } + + /* Indexes for first 16 registers match between HV and QEMU definition= s */ + for (idx =3D 0; idx < CPU_NB_REGS64; idx +=3D 1) { + env->regs[idx] =3D vcxt.values[idx].Reg64; + } + + /* Same goes for RIP and RFLAGS */ + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterRip); + env->eip =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterRflags); + env->eflags =3D vcxt.values[idx++].Reg64; + + /* Translate 6+4 segment registers. HV and QEMU order matches */ + assert(idx =3D=3D WHvX64RegisterEs); + for (i =3D 0; i < 6; i +=3D 1, idx +=3D 1) { + env->segs[i] =3D whpx_seg_h2q(&vcxt.values[idx].Segment); + } + + assert(idx =3D=3D WHvX64RegisterLdtr); + env->ldt =3D whpx_seg_h2q(&vcxt.values[idx++].Segment); + assert(idx =3D=3D WHvX64RegisterTr); + env->tr =3D whpx_seg_h2q(&vcxt.values[idx++].Segment); + assert(idx =3D=3D WHvX64RegisterIdtr); + env->idt.base =3D vcxt.values[idx].Table.Base; + env->idt.limit =3D vcxt.values[idx].Table.Limit; + idx +=3D 1; + assert(idx =3D=3D WHvX64RegisterGdtr); + env->gdt.base =3D vcxt.values[idx].Table.Base; + env->gdt.limit =3D vcxt.values[idx].Table.Limit; + idx +=3D 1; + + /* CR0, 2, 3, 4, 8 */ + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCr0); + env->cr[0] =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCr2); + env->cr[2] =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCr3); + env->cr[3] =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCr4); + env->cr[4] =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCr8); + tpr =3D vcxt.values[idx++].Reg64; + if (tpr !=3D vcpu->tpr) { + vcpu->tpr =3D tpr; + cpu_set_apic_tpr(x86_cpu->apic_state, tpr); + } + + /* 8 Debug Registers - Skipped */ + + /* 16 XMM registers */ + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterXmm0); + for (i =3D 0; i < 16; i +=3D 1, idx +=3D 1) { + env->xmm_regs[i].ZMM_Q(0) =3D vcxt.values[idx].Reg128.Low64; + env->xmm_regs[i].ZMM_Q(1) =3D vcxt.values[idx].Reg128.High64; + } + + /* 8 FP registers */ + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterFpMmx0); + for (i =3D 0; i < 8; i +=3D 1, idx +=3D 1) { + env->fpregs[i].mmx.MMX_Q(0) =3D vcxt.values[idx].Fp.AsUINT128.Low6= 4; + /* env->fpregs[i].mmx.MMX_Q(1) =3D + vcxt.values[idx].Fp.AsUINT128.High64; + */ + } + + /* FP control status register */ + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterFpControlStatus); + env->fpuc =3D vcxt.values[idx].FpControlStatus.FpControl; + env->fpstt =3D (vcxt.values[idx].FpControlStatus.FpStatus >> 11) & 0x7; + env->fpus =3D vcxt.values[idx].FpControlStatus.FpStatus & ~0x3800; + for (i =3D 0; i < 8; ++i) { + env->fptags[i] =3D !((vcxt.values[idx].FpControlStatus.FpTag >> i)= & 1); + } + env->fpop =3D vcxt.values[idx].FpControlStatus.LastFpOp; + env->fpip =3D vcxt.values[idx].FpControlStatus.LastFpRip; + idx +=3D 1; + + /* XMM control status register */ + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterXmmControlStatus); + env->mxcsr =3D vcxt.values[idx].XmmControlStatus.XmmStatusControl; + idx +=3D 1; + + /* MSRs */ + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterTsc); + env->tsc =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterEfer); + env->efer =3D vcxt.values[idx++].Reg64; +#ifdef TARGET_X86_64 + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterKernelGsBase); + env->kernelgsbase =3D vcxt.values[idx++].Reg64; +#endif + + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterApicBase); + apic_base =3D vcxt.values[idx++].Reg64; + if (apic_base !=3D vcpu->apic_base) { + vcpu->apic_base =3D apic_base; + cpu_set_apic_base(x86_cpu->apic_state, vcpu->apic_base); + } + + /* WHvX64RegisterPat - Skipped */ + + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterSysenterCs); + env->sysenter_cs =3D vcxt.values[idx++].Reg64;; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterSysenterEip); + env->sysenter_eip =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterSysenterEsp); + env->sysenter_esp =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterStar); + env->star =3D vcxt.values[idx++].Reg64; +#ifdef TARGET_X86_64 + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterLstar); + env->lstar =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCstar); + env->cstar =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterSfmask); + env->fmask =3D vcxt.values[idx++].Reg64; +#endif + + /* Interrupt / Event Registers - Skipped */ + + assert(idx =3D=3D RTL_NUMBER_OF(whpx_register_names)); + + return; +} + +static HRESULT CALLBACK whpx_emu_ioport_callback( + void *ctx, + WHV_EMULATOR_IO_ACCESS_INFO *IoAccess) +{ + MemTxAttrs attrs =3D { 0 }; + address_space_rw(&address_space_io, IoAccess->Port, attrs, + (uint8_t *)&IoAccess->Data, IoAccess->AccessSize, + IoAccess->Direction); + return S_OK; +} + +static HRESULT CALLBACK whpx_emu_memio_callback( + void *ctx, + WHV_EMULATOR_MEMORY_ACCESS_INFO *ma) +{ + cpu_physical_memory_rw(ma->GpaAddress, ma->Data, ma->AccessSize, + ma->Direction); + return S_OK; +} + +static HRESULT CALLBACK whpx_emu_getreg_callback( + void *ctx, + const WHV_REGISTER_NAME *RegisterNames, + UINT32 RegisterCount, + WHV_REGISTER_VALUE *RegisterValues) +{ + HRESULT hr; + struct whpx_state *whpx =3D &whpx_global; + CPUState *cpu =3D (CPUState *)ctx; + + hr =3D WHvGetVirtualProcessorRegisters(whpx->partition, cpu->cpu_index, + RegisterNames, RegisterCount, + RegisterValues); + if (FAILED(hr)) { + error_report("WHPX: Failed to get virtual processor registers," + " hr=3D%08lx", hr); + __debugbreak(); + } + + return hr; +} + +static HRESULT CALLBACK whpx_emu_setreg_callback( + void *ctx, + const WHV_REGISTER_NAME *RegisterNames, + UINT32 RegisterCount, + const WHV_REGISTER_VALUE *RegisterValues) +{ + HRESULT hr; + struct whpx_state *whpx =3D &whpx_global; + CPUState *cpu =3D (CPUState *)ctx; + + hr =3D WHvSetVirtualProcessorRegisters(whpx->partition, cpu->cpu_index, + RegisterNames, RegisterCount, + RegisterValues); + if (FAILED(hr)) { + error_report("WHPX: Failed to set virtual processor registers," + " hr=3D%08lx", hr); + __debugbreak(); + } + + /* + * The emulator just successfully wrote the register state. We clear t= he + * dirty state so we avoid the double write on resume of the VP. + */ + cpu->vcpu_dirty =3D false; + + return hr; +} + +static HRESULT CALLBACK whpx_emu_translate_callback( + void *ctx, + WHV_GUEST_VIRTUAL_ADDRESS Gva, + WHV_TRANSLATE_GVA_FLAGS TranslateFlags, + WHV_TRANSLATE_GVA_RESULT_CODE *TranslationResult, + WHV_GUEST_PHYSICAL_ADDRESS *Gpa) +{ + HRESULT hr; + struct whpx_state *whpx =3D &whpx_global; + CPUState *cpu =3D (CPUState *)ctx; + WHV_TRANSLATE_GVA_RESULT res; + + hr =3D WHvTranslateGva(whpx->partition, cpu->cpu_index, + Gva, TranslateFlags, &res, Gpa); + if (FAILED(hr)) { + error_report("WHPX: Failed to translate GVA, hr=3D%08lx", hr); + __debugbreak(); + } else { + *TranslationResult =3D res.ResultCode; + } + + return hr; +} + +static const WHV_EMULATOR_CALLBACKS whpx_emu_callbacks =3D { + .WHvEmulatorIoPortCallback =3D whpx_emu_ioport_callback, + .WHvEmulatorMemoryCallback =3D whpx_emu_memio_callback, + .WHvEmulatorGetVirtualProcessorRegisters =3D whpx_emu_getreg_callback, + .WHvEmulatorSetVirtualProcessorRegisters =3D whpx_emu_setreg_callback, + .WHvEmulatorTranslateGvaPage =3D whpx_emu_translate_callback, +}; + +static int whpx_handle_mmio(CPUState *cpu, WHV_MEMORY_ACCESS_CONTEXT *ctx) +{ + HRESULT hr; + struct whpx_vcpu *vcpu =3D get_whpx_vcpu(cpu); + WHV_EMULATOR_STATUS emu_status; + + hr =3D WHvEmulatorTryMmioEmulation(vcpu->emulator, cpu, ctx, &emu_stat= us); + if (FAILED(hr)) { + __debugbreak(); + error_report("WHPX: Failed to parse MMIO access, hr=3D%08lx", hr); + return -1; + } + + if (!emu_status.EmulationSuccessful) { + __debugbreak(); + error_report("WHPX: Failed to emulate MMIO access"); + return -1; + } + + return 0; +} + +static int whpx_handle_portio(CPUState *cpu, + WHV_X64_IO_PORT_ACCESS_CONTEXT *ctx) +{ + HRESULT hr; + struct whpx_vcpu *vcpu =3D get_whpx_vcpu(cpu); + WHV_EMULATOR_STATUS emu_status; + + hr =3D WHvEmulatorTryIoEmulation(vcpu->emulator, cpu, ctx, &emu_status= ); + if (FAILED(hr)) { + __debugbreak(); + error_report("WHPX: Failed to parse PortIO access, hr=3D%08lx", hr= ); + return -1; + } + + if (!emu_status.EmulationSuccessful) { + __debugbreak(); + error_report("WHPX: Failed to emulate PortMMIO access"); + return -1; + } + + return 0; +} + +static int whpx_handle_halt(CPUState *cpu) +{ + struct CPUX86State *env =3D (CPUArchState *)(cpu->env_ptr); + int ret =3D 0; + + qemu_mutex_lock_iothread(); + if (!((cpu->interrupt_request & CPU_INTERRUPT_HARD) && + (env->eflags & IF_MASK)) && + !(cpu->interrupt_request & CPU_INTERRUPT_NMI)) { + cpu->exception_index =3D EXCP_HLT; + cpu->halted =3D true; + ret =3D 1; + } + qemu_mutex_unlock_iothread(); + + return ret; +} + +static void whpx_vcpu_pre_run(CPUState *cpu) +{ + HRESULT hr; + struct whpx_state *whpx =3D &whpx_global; + struct whpx_vcpu *vcpu =3D get_whpx_vcpu(cpu); + struct CPUX86State *env =3D (CPUArchState *)(cpu->env_ptr); + X86CPU *x86_cpu =3D X86_CPU(cpu); + int irq; + WHV_X64_PENDING_INTERRUPTION_REGISTER new_int =3D {0}; + UINT32 reg_count =3D 0; + WHV_REGISTER_VALUE reg_values[3] =3D {0}; + WHV_REGISTER_NAME reg_names[3]; + + qemu_mutex_lock_iothread(); + + /* Inject NMI */ + if (!vcpu->interrupt_in_flight.InterruptionPending && + cpu->interrupt_request & (CPU_INTERRUPT_NMI | CPU_INTERRUPT_SMI)) { + if (cpu->interrupt_request & CPU_INTERRUPT_NMI) { + cpu->interrupt_request &=3D ~CPU_INTERRUPT_NMI; + vcpu->interruptable =3D false; + new_int.InterruptionType =3D WHvX64PendingNmi; + new_int.InterruptionPending =3D 1; + new_int.InterruptionVector =3D 2; + } + if (cpu->interrupt_request & CPU_INTERRUPT_SMI) { + qemu_mutex_lock_iothread(); + cpu->interrupt_request &=3D ~CPU_INTERRUPT_SMI; + __debugbreak(); + qemu_mutex_unlock_iothread(); + } + } + + /* + * Force the VCPU out of its inner loop to process any INIT requests or + * commit pending TPR access. + */ + if (cpu->interrupt_request & (CPU_INTERRUPT_INIT | CPU_INTERRUPT_TPR))= { + if ((cpu->interrupt_request & CPU_INTERRUPT_INIT) && + !(env->hflags & HF_SMM_MASK)) { + cpu->exit_request =3D 1; + } + if (cpu->interrupt_request & CPU_INTERRUPT_TPR) { + cpu->exit_request =3D 1; + } + } + + /* Get pending hard interruption or replay one that was overwritten */ + if (!vcpu->interrupt_in_flight.InterruptionPending && + vcpu->interruptable && (env->eflags & IF_MASK)) { + assert(!new_int.InterruptionPending); + if (cpu->interrupt_request & CPU_INTERRUPT_HARD) { + cpu->interrupt_request &=3D ~CPU_INTERRUPT_HARD; + irq =3D cpu_get_pic_interrupt(env); + if (irq >=3D 0) { + new_int.InterruptionType =3D WHvX64PendingInterrupt; + new_int.InterruptionPending =3D 1; + new_int.InterruptionVector =3D irq; + } + } + } + + /* Setup interrupt state if new one was prepared */ + if (new_int.InterruptionPending) { + reg_values[reg_count].PendingInterruption =3D new_int; + reg_names[reg_count] =3D WHvRegisterPendingInterruption; + reg_count +=3D 1; + } + + /* Sync the TPR to the CR8 if was modified during the intercept */ + reg_values[reg_count].Reg64 =3D cpu_get_apic_tpr(x86_cpu->apic_state); + if (reg_values[reg_count].Reg64 !=3D vcpu->tpr) { + vcpu->tpr =3D reg_values[reg_count].Reg64; + cpu->exit_request =3D 1; + reg_names[reg_count] =3D WHvX64RegisterCr8; + reg_count +=3D 1; + } + + /* Update the state of the interrupt delivery notification */ + if (cpu->interrupt_request & CPU_INTERRUPT_HARD) { + reg_values[reg_count].DeliverabilityNotifications.InterruptNotific= ation + =3D 1; + if (vcpu->window_registered !=3D 1) { + vcpu->window_registered =3D 1; + } + reg_names[reg_count] =3D WHvX64RegisterDeliverabilityNotifications; + reg_count +=3D 1; + } + + qemu_mutex_unlock_iothread(); + + if (reg_count) { + hr =3D WHvSetVirtualProcessorRegisters(whpx->partition, cpu->cpu_i= ndex, + reg_names, reg_count, reg_val= ues); + if (FAILED(hr)) { + error_report("WHPX: Failed to set interrupt state registers," + " hr=3D%08lx", hr); + __debugbreak(); + } + } + + return; +} + +static void whpx_vcpu_post_run(CPUState *cpu) +{ + HRESULT hr; + struct whpx_state *whpx =3D &whpx_global; + struct whpx_vcpu *vcpu =3D get_whpx_vcpu(cpu); + struct CPUX86State *env =3D (CPUArchState *)(cpu->env_ptr); + X86CPU *x86_cpu =3D X86_CPU(cpu); + WHV_REGISTER_VALUE reg_values[4]; + const WHV_REGISTER_NAME reg_names[4] =3D { + WHvX64RegisterRflags, + WHvX64RegisterCr8, + WHvRegisterPendingInterruption, + WHvRegisterInterruptState, + }; + + hr =3D WHvGetVirtualProcessorRegisters(whpx->partition, cpu->cpu_index, + reg_names, 4, reg_values); + if (FAILED(hr)) { + error_report("WHPX: Failed to get interrupt state regusters," + " hr=3D%08lx", hr); + __debugbreak(); + vcpu->interruptable =3D false; + return; + } + + assert(reg_names[0] =3D=3D WHvX64RegisterRflags); + env->eflags =3D reg_values[0].Reg64; + + assert(reg_names[1] =3D=3D WHvX64RegisterCr8); + if (vcpu->tpr !=3D reg_values[1].Reg64) { + vcpu->tpr =3D reg_values[1].Reg64; + qemu_mutex_lock_iothread(); + cpu_set_apic_tpr(x86_cpu->apic_state, vcpu->tpr); + qemu_mutex_unlock_iothread(); + } + + assert(reg_names[2] =3D=3D WHvRegisterPendingInterruption); + vcpu->interrupt_in_flight =3D reg_values[2].PendingInterruption; + + assert(reg_names[3] =3D=3D WHvRegisterInterruptState); + vcpu->interruptable =3D !reg_values[3].InterruptState.InterruptShadow; + + return; +} + +static void whpx_vcpu_process_async_events(CPUState *cpu) +{ + struct CPUX86State *env =3D (CPUArchState *)(cpu->env_ptr); + X86CPU *x86_cpu =3D X86_CPU(cpu); + struct whpx_vcpu *vcpu =3D get_whpx_vcpu(cpu); + + if ((cpu->interrupt_request & CPU_INTERRUPT_INIT) && + !(env->hflags & HF_SMM_MASK)) { + + do_cpu_init(x86_cpu); + cpu->vcpu_dirty =3D true; + vcpu->interruptable =3D true; + } + + if (cpu->interrupt_request & CPU_INTERRUPT_POLL) { + cpu->interrupt_request &=3D ~CPU_INTERRUPT_POLL; + apic_poll_irq(x86_cpu->apic_state); + } + + if (((cpu->interrupt_request & CPU_INTERRUPT_HARD) && + (env->eflags & IF_MASK)) || + (cpu->interrupt_request & CPU_INTERRUPT_NMI)) { + cpu->halted =3D false; + } + + if (cpu->interrupt_request & CPU_INTERRUPT_SIPI) { + if (!cpu->vcpu_dirty) { + whpx_get_registers(cpu); + } + do_cpu_sipi(x86_cpu); + } + + if (cpu->interrupt_request & CPU_INTERRUPT_TPR) { + cpu->interrupt_request &=3D ~CPU_INTERRUPT_TPR; + if (!cpu->vcpu_dirty) { + whpx_get_registers(cpu); + } + apic_handle_tpr_access_report(x86_cpu->apic_state, env->eip, + env->tpr_access_type); + } + + return; +} + +static int whpx_vcpu_run(CPUState *cpu) +{ + HRESULT hr; + struct whpx_state *whpx =3D &whpx_global; + struct whpx_vcpu *vcpu =3D get_whpx_vcpu(cpu); + int ret; + + whpx_vcpu_process_async_events(cpu); + if (cpu->halted) { + cpu->exception_index =3D EXCP_HLT; + atomic_set(&cpu->exit_request, false); + return 0; + } + + qemu_mutex_unlock_iothread(); + cpu_exec_start(cpu); + + do { + if (cpu->vcpu_dirty) { + whpx_set_registers(cpu); + cpu->vcpu_dirty =3D false; + } + + whpx_vcpu_pre_run(cpu); + + if (atomic_read(&cpu->exit_request)) { + whpx_vcpu_kick(cpu); + } + + for (;;) { + hr =3D WHvRunVirtualProcessor(whpx->partition, cpu->cpu_index, + &vcpu->exit_ctx, whpx->exit_ctx_si= ze); + + if (SUCCEEDED(hr) && (vcpu->exit_ctx.ExitReason =3D=3D + WHvRunVpExitReasonAlerted)) { + WHvCancelRunVirtualProcessor(whpx->partition, cpu->cpu_ind= ex, + 0); + } else { + break; + } + } + + if (FAILED(hr)) { + error_report("WHPX: Failed to exec a virtual processor," + " hr=3D%08lx", hr); + ret =3D -1; + break; + } + + whpx_vcpu_post_run(cpu); + + switch (vcpu->exit_ctx.ExitReason) { + case WHvRunVpExitReasonMemoryAccess: + ret =3D whpx_handle_mmio(cpu, &vcpu->exit_ctx.MemoryAccess); + break; + + case WHvRunVpExitReasonX64IoPortAccess: + ret =3D whpx_handle_portio(cpu, &vcpu->exit_ctx.IoPortAccess); + break; + + case WHvRunVpExitReasonX64InterruptWindow: + vcpu->window_registered =3D 0; + break; + + case WHvRunVpExitReasonX64Halt: + ret =3D whpx_handle_halt(cpu); + break; + + case WHvRunVpExitReasonCanceled: + cpu->exception_index =3D EXCP_INTERRUPT; + ret =3D 1; + break; + + case WHvRunVpExitReasonNone: + case WHvRunVpExitReasonUnrecoverableException: + case WHvRunVpExitReasonInvalidVpRegisterValue: + case WHvRunVpExitReasonUnsupportedFeature: + case WHvRunVpExitReasonX64MsrAccess: + case WHvRunVpExitReasonX64Cpuid: + case WHvRunVpExitReasonException: + case WHvRunVpExitReasonAlerted: + default: + error_report("WHPX: Unexpected VP exit code %d", + vcpu->exit_ctx.ExitReason); + whpx_get_registers(cpu); + qemu_mutex_lock_iothread(); + qemu_system_guest_panicked(cpu_get_crash_info(cpu)); + qemu_mutex_unlock_iothread(); + break; + } + + } while (!ret); + + cpu_exec_end(cpu); + qemu_mutex_lock_iothread(); + current_cpu =3D cpu; + + atomic_set(&cpu->exit_request, false); + + return ret < 0; +} + +static void do_whpx_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data a= rg) +{ + whpx_get_registers(cpu); + cpu->vcpu_dirty =3D true; +} + +static void do_whpx_cpu_synchronize_post_reset(CPUState *cpu, + run_on_cpu_data arg) +{ + whpx_set_registers(cpu); + cpu->vcpu_dirty =3D false; +} + +static void do_whpx_cpu_synchronize_post_init(CPUState *cpu, + run_on_cpu_data arg) +{ + whpx_set_registers(cpu); + cpu->vcpu_dirty =3D false; +} + +static void do_whpx_cpu_synchronize_pre_loadvm(CPUState *cpu, + run_on_cpu_data arg) +{ + cpu->vcpu_dirty =3D true; +} + +/* + * CPU support. + */ + +void whpx_cpu_synchronize_state(CPUState *cpu) +{ + if (!cpu->vcpu_dirty) { + run_on_cpu(cpu, do_whpx_cpu_synchronize_state, RUN_ON_CPU_NULL); + } +} + +void whpx_cpu_synchronize_post_reset(CPUState *cpu) +{ + run_on_cpu(cpu, do_whpx_cpu_synchronize_post_reset, RUN_ON_CPU_NULL); +} + +void whpx_cpu_synchronize_post_init(CPUState *cpu) +{ + run_on_cpu(cpu, do_whpx_cpu_synchronize_post_init, RUN_ON_CPU_NULL); +} + +void whpx_cpu_synchronize_pre_loadvm(CPUState *cpu) +{ + run_on_cpu(cpu, do_whpx_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL); +} + +/* + * Vcpu support. + */ + +static Error *whpx_migration_blocker; + +int whpx_init_vcpu(CPUState *cpu) +{ + HRESULT hr; + struct whpx_state *whpx =3D &whpx_global; + struct whpx_vcpu *vcpu; + Error *local_error =3D NULL; + + /* Add migration blockers for all unsupported features of the + * Windows Hypervisor Platform + */ + if (whpx_migration_blocker =3D=3D NULL) { + error_setg(&whpx_migration_blocker, + "State blocked due to non-migratable CPUID feature support," + "dirty memory tracking support, and XSAVE/XRSTOR support"); + + (void)migrate_add_blocker(whpx_migration_blocker, &local_error); + if (local_error) { + error_report_err(local_error); + error_free(whpx_migration_blocker); + migrate_del_blocker(whpx_migration_blocker); + return -EINVAL; + } + } + + vcpu =3D g_malloc0(FIELD_OFFSET(struct whpx_vcpu, exit_ctx) + + whpx->exit_ctx_size); + + if (!vcpu) { + error_report("WHPX: Failed to allocte VCPU context."); + return -ENOMEM; + } + + hr =3D WHvEmulatorCreateEmulator(whpx_emu_callbacks, &vcpu->emulator); + if (FAILED(hr)) { + error_report("WHPX: Failed to setup instruction completion support= ," + " hr=3D%08lx", hr); + g_free(vcpu); + return -EINVAL; + } + + hr =3D WHvCreateVirtualProcessor(whpx->partition, cpu->cpu_index, 0); + if (FAILED(hr)) { + error_report("WHPX: Failed to create a virtual processor," + " hr=3D%08lx", hr); + WHvEmulatorDestroyEmulator(vcpu->emulator); + g_free(vcpu); + return -EINVAL; + } + + vcpu->interruptable =3D true; + + cpu->vcpu_dirty =3D true; + cpu->hax_vcpu =3D (struct hax_vcpu_state *)vcpu; + + return 0; +} + +int whpx_vcpu_exec(CPUState *cpu) +{ + int ret; + int fatal; + + for (;;) { + if (cpu->exception_index >=3D EXCP_INTERRUPT) { + ret =3D cpu->exception_index; + cpu->exception_index =3D -1; + break; + } + + fatal =3D whpx_vcpu_run(cpu); + + if (fatal) { + error_report("WHPX: Failed to exec a virtual processor"); + abort(); + } + } + + return ret; +} + +void whpx_destroy_vcpu(CPUState *cpu) +{ + struct whpx_state *whpx =3D &whpx_global; + struct whpx_vcpu *vcpu =3D get_whpx_vcpu(cpu); + + WHvDeleteVirtualProcessor(whpx->partition, cpu->cpu_index); + WHvEmulatorDestroyEmulator(vcpu->emulator); + g_free(cpu->hax_vcpu); + return; +} + +void whpx_vcpu_kick(CPUState *cpu) +{ + struct whpx_state *whpx =3D &whpx_global; + WHvCancelRunVirtualProcessor(whpx->partition, cpu->cpu_index, 0); +} + +/* + * Memory support. + */ + +static void whpx_update_mapping(hwaddr start_pa, ram_addr_t size, + void *host_va, int add, int rom, + const char *name) +{ + struct whpx_state *whpx =3D &whpx_global; + HRESULT hr; + + /* + if (add) { + printf("WHPX: ADD PA:%p Size:%p, Host:%p, %s, '%s'\n", + (void*)start_pa, (void*)size, host_va, + (rom ? "ROM" : "RAM"), name); + } else { + printf("WHPX: DEL PA:%p Size:%p, Host:%p, '%s'\n", + (void*)start_pa, (void*)size, host_va, name); + } + */ + + if (add) { + hr =3D WHvMapGpaRange(whpx->partition, + host_va, + start_pa, + size, + (WHvMapGpaRangeFlagRead | + WHvMapGpaRangeFlagExecute | + (rom ? 0 : WHvMapGpaRangeFlagWrite))); + } else { + hr =3D WHvUnmapGpaRange(whpx->partition, + start_pa, + size); + } + + if (FAILED(hr)) { + error_report("WHPX: Failed to %s GPA range '%s' PA:%p, Size:%p byt= es," + " Host:%p, hr=3D%08lx", + (add ? "MAP" : "UNMAP"), name, + (void *)start_pa, (void *)size, host_va, hr); + } +} + +static void whpx_process_section(MemoryRegionSection *section, int add) +{ + MemoryRegion *mr =3D section->mr; + hwaddr start_pa =3D section->offset_within_address_space; + ram_addr_t size =3D int128_get64(section->size); + unsigned int delta; + uint64_t host_va; + + if (!memory_region_is_ram(mr)) { + return; + } + + delta =3D qemu_real_host_page_size - (start_pa & ~qemu_real_host_page_= mask); + delta &=3D ~qemu_real_host_page_mask; + if (delta > size) { + return; + } + start_pa +=3D delta; + size -=3D delta; + size &=3D qemu_real_host_page_mask; + if (!size || (start_pa & ~qemu_real_host_page_mask)) { + return; + } + + host_va =3D (uintptr_t)memory_region_get_ram_ptr(mr) + + section->offset_within_region + delta; + + whpx_update_mapping(start_pa, size, (void *)host_va, add, + memory_region_is_rom(mr), mr->name); +} + +static void whpx_region_add(MemoryListener *listener, + MemoryRegionSection *section) +{ + memory_region_ref(section->mr); + whpx_process_section(section, 1); +} + +static void whpx_region_del(MemoryListener *listener, + MemoryRegionSection *section) +{ + whpx_process_section(section, 0); + memory_region_unref(section->mr); +} + +static void whpx_transaction_begin(MemoryListener *listener) +{ +} + +static void whpx_transaction_commit(MemoryListener *listener) +{ +} + +static void whpx_log_sync(MemoryListener *listener, + MemoryRegionSection *section) +{ + MemoryRegion *mr =3D section->mr; + + if (!memory_region_is_ram(mr)) { + return; + } + + memory_region_set_dirty(mr, 0, int128_get64(section->size)); +} + +static MemoryListener whpx_memory_listener =3D { + .begin =3D whpx_transaction_begin, + .commit =3D whpx_transaction_commit, + .region_add =3D whpx_region_add, + .region_del =3D whpx_region_del, + .log_sync =3D whpx_log_sync, + .priority =3D 10, +}; + +static void whpx_memory_init(void) +{ + memory_listener_register(&whpx_memory_listener, &address_space_memory); +} + +static void whpx_handle_interrupt(CPUState *cpu, int mask) +{ + cpu->interrupt_request |=3D mask; + + if (!qemu_cpu_is_self(cpu)) { + qemu_cpu_kick(cpu); + } +} + +/* + * Partition support + */ + +static int whpx_accel_init(MachineState *ms) +{ + struct whpx_state *whpx; + int ret; + HRESULT hr; + WHV_CAPABILITY whpx_cap; + WHV_PARTITION_PROPERTY prop; + + whpx =3D &whpx_global; + + memset(whpx, 0, sizeof(struct whpx_state)); + whpx->mem_quota =3D ms->ram_size; + + hr =3D WHvGetCapability(WHvCapabilityCodeHypervisorPresent, &whpx_cap, + sizeof(whpx_cap)); + if (FAILED(hr) || !whpx_cap.HypervisorPresent) { + error_report("WHPX: No accelerator found, hr=3D%08lx", hr); + ret =3D -ENOSPC; + goto error; + } + + hr =3D WHvCreatePartition(&whpx->partition); + if (FAILED(hr)) { + error_report("WHPX: Failed to create partition, hr=3D%08lx", hr); + ret =3D -EINVAL; + goto error; + } + + memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY)); + prop.PropertyCode =3D WHvPartitionPropertyCodeProcessorCount; + prop.ProcessorCount =3D smp_cpus; + hr =3D WHvSetPartitionProperty(whpx->partition, + &prop, + sizeof(WHV_PARTITION_PROPERTY)); + + if (FAILED(hr)) { + error_report("WHPX: Failed to set partition core count to %d," + " hr=3D%08lx", smp_cores, hr); + ret =3D -EINVAL; + goto error; + } + + hr =3D WHvSetupPartition(whpx->partition); + if (FAILED(hr)) { + error_report("WHPX: Failed to setup partition, hr=3D%08lx", hr); + ret =3D -EINVAL; + goto error; + } + + whpx->exit_ctx_size =3D WHvGetRunExitContextSize(); + assert(whpx->exit_ctx_size); + + whpx_memory_init(); + + cpu_interrupt_handler =3D whpx_handle_interrupt; + + printf("Windows Hypervisor Platform accelerator is operational\n"); + return 0; + + error: + + if (NULL !=3D whpx->partition) { + WHvDeletePartition(whpx->partition); + whpx->partition =3D NULL; + } + + + return ret; +} + +int whpx_enabled(void) +{ + return whpx_allowed; +} + +static void whpx_accel_class_init(ObjectClass *oc, void *data) +{ + AccelClass *ac =3D ACCEL_CLASS(oc); + ac->name =3D "WHPX"; + ac->init_machine =3D whpx_accel_init; + ac->allowed =3D &whpx_allowed; +} + +static const TypeInfo whpx_accel_type =3D { + .name =3D ACCEL_CLASS_NAME("whpx"), + .parent =3D TYPE_ACCEL, + .class_init =3D whpx_accel_class_init, +}; + +static void whpx_type_init(void) +{ + type_register_static(&whpx_accel_type); +} + +type_init(whpx_type_init); --=20 1.8.3.1 From nobody Tue Apr 30 08:57:32 2024 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 1517860713683752.7110508461508; Mon, 5 Feb 2018 11:58:33 -0800 (PST) Received: from localhost ([::1]:54978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimuO-00065Q-RH for importer@patchew.org; Mon, 05 Feb 2018 14:58:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSp-00053I-DZ for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:30:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSo-0005Fo-5Q for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:30:03 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:35844) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSn-0005En-RC for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:30:02 -0500 Received: by mail-wm0-x242.google.com with SMTP id f3so28132387wmc.1 for ; Mon, 05 Feb 2018 11:30:01 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:59 -0800 (PST) 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=EQ63Km+3XgvzI4DjglpFWxH3jTTpA0ZNuGcMcMJX7Ys=; b=GATT/0BjgKo8+nSsZ/dDTqpyAw2f4ehwF7WAcfo2lFZqHnDnYyLI/maAOk9Lr5vnT7 5hXQu4PQ9NYinBPFBlahYhAbdj0axUUADDp4j+12DLl3y1snR+y+L73WiGflmgnQkLln OInchFXZrm9ijFGP7t4S2UNY6Pj3vDKgc9qDYsiIFi5hYnv6KeAHQ6Q/ITk/eF0qV7GZ aOFurx7JOaB604lb01ySaRZvoFj4yhSKn60lhuxqA2Kbm2Rg1A5pWiUDkIteXb9RNlla tXcWWq95teoK+tzTm4VMQC1ehskqEuvywuUWhk8z+r7iIv1Q5s5/huxu19dR9ZHT+GrB dPEA== 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=EQ63Km+3XgvzI4DjglpFWxH3jTTpA0ZNuGcMcMJX7Ys=; b=XooWsMqf5ZfeMWy6zgqDmzro1o02m2pujaqLvBagez5I3sOcEfcCclJD/EBXVshC3L HXpbaVfJsq+KCfV16KdE75d8xnyscrZTnMp/gw8YpRZedd7PWwIinwfs93cI5iVvdy0q ItU9QH8HCxQef37qng0LlFgONPk/iyB7YOD8FUeXwhr3zgkMG3sJ01w6UFtE+kZ3wSa9 ewszAUTGBuejJIR3lU4+biJ8z5/pgkJaIyT+wMmlwx2WYI4R2VeNjK/G4Glc8h+C3nbT iIu+FB1twmnMox+jeekVqwGD3JYko8d0LpC4/hqq+pSmCX0bvhUWd8Ir7ehF5G+rbGnz P1nw== X-Gm-Message-State: APf1xPBT7AFlBZsqYo5EUJ2+s4fFnXFwwsyPhNBLiwgrTip5nJckyt0B +GBZpEHuwHBnUbvzSZHGEq4/Skf6 X-Google-Smtp-Source: AH8x227Bqym/i6xd3WG7MVt/BBI7FyQO9ZK2OoMgaB5YQUiX+SkTwkXr8Ls1JEdauqFm9lrHnUFQ3A== X-Received: by 10.28.29.81 with SMTP id d78mr328238wmd.65.1517859000465; Mon, 05 Feb 2018 11:30:00 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:29:01 +0100 Message-Id: <1517858941-5538-48-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-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 47/47] Add the WHPX acceleration enlightenments 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)" Implements the WHPX accelerator cpu enlightenments to actually use the whpx= -all accelerator on Windows platforms. Signed-off-by: Justin Terry (VM) Message-Id: <1516655269-1785-5-git-send-email-juterry@microsoft.com> [Register/unregister VCPU thread with RCU. - Paolo] Signed-off-by: Paolo Bonzini --- cpus.c | 69 +++++++++++++++++++++++++++++++++++++++++++= +++- include/sysemu/hw_accel.h | 13 +++++++++ target/i386/helper.c | 2 +- 3 files changed, 82 insertions(+), 2 deletions(-) diff --git a/cpus.c b/cpus.c index 8d8bb7c..6825fe1 100644 --- a/cpus.c +++ b/cpus.c @@ -38,6 +38,7 @@ #include "sysemu/kvm.h" #include "sysemu/hax.h" #include "sysemu/hvf.h" +#include "sysemu/whpx.h" #include "qmp-commands.h" #include "exec/exec-all.h" =20 @@ -1545,6 +1546,49 @@ static void *qemu_hvf_cpu_thread_fn(void *arg) return NULL; } =20 +static void *qemu_whpx_cpu_thread_fn(void *arg) +{ + CPUState *cpu =3D arg; + int r; + + rcu_register_thread(); + + qemu_mutex_lock_iothread(); + qemu_thread_get_self(cpu->thread); + cpu->thread_id =3D qemu_get_thread_id(); + current_cpu =3D cpu; + + r =3D whpx_init_vcpu(cpu); + if (r < 0) { + fprintf(stderr, "whpx_init_vcpu failed: %s\n", strerror(-r)); + exit(1); + } + + /* signal CPU creation */ + cpu->created =3D true; + qemu_cond_signal(&qemu_cpu_cond); + + do { + if (cpu_can_run(cpu)) { + r =3D whpx_vcpu_exec(cpu); + if (r =3D=3D EXCP_DEBUG) { + cpu_handle_guest_debug(cpu); + } + } + while (cpu_thread_is_idle(cpu)) { + qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex); + } + qemu_wait_io_event_common(cpu); + } while (!cpu->unplug || cpu_can_run(cpu)); + + whpx_destroy_vcpu(cpu); + cpu->created =3D false; + qemu_cond_signal(&qemu_cpu_cond); + qemu_mutex_unlock_iothread(); + rcu_unregister_thread(); + return NULL; +} + #ifdef _WIN32 static void CALLBACK dummy_apc_func(ULONG_PTR unused) { @@ -1635,7 +1679,9 @@ static void qemu_cpu_kick_thread(CPUState *cpu) } #else /* _WIN32 */ if (!qemu_cpu_is_self(cpu)) { - if (!QueueUserAPC(dummy_apc_func, cpu->hThread, 0)) { + if (whpx_enabled()) { + whpx_vcpu_kick(cpu); + } else if (!QueueUserAPC(dummy_apc_func, cpu->hThread, 0)) { fprintf(stderr, "%s: QueueUserAPC failed with error %lu\n", __func__, GetLastError()); exit(1); @@ -1877,6 +1923,25 @@ static void qemu_hvf_start_vcpu(CPUState *cpu) } } =20 +static void qemu_whpx_start_vcpu(CPUState *cpu) +{ + char thread_name[VCPU_THREAD_NAME_SIZE]; + + cpu->thread =3D g_malloc0(sizeof(QemuThread)); + cpu->halt_cond =3D g_malloc0(sizeof(QemuCond)); + qemu_cond_init(cpu->halt_cond); + snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/WHPX", + cpu->cpu_index); + qemu_thread_create(cpu->thread, thread_name, qemu_whpx_cpu_thread_fn, + cpu, QEMU_THREAD_JOINABLE); +#ifdef _WIN32 + cpu->hThread =3D qemu_thread_get_handle(cpu->thread); +#endif + while (!cpu->created) { + qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); + } +} + static void qemu_dummy_start_vcpu(CPUState *cpu) { char thread_name[VCPU_THREAD_NAME_SIZE]; @@ -1915,6 +1980,8 @@ void qemu_init_vcpu(CPUState *cpu) qemu_hvf_start_vcpu(cpu); } else if (tcg_enabled()) { qemu_tcg_init_vcpu(cpu); + } else if (whpx_enabled()) { + qemu_whpx_start_vcpu(cpu); } else { qemu_dummy_start_vcpu(cpu); } diff --git a/include/sysemu/hw_accel.h b/include/sysemu/hw_accel.h index 469ffda..d2ddfb5 100644 --- a/include/sysemu/hw_accel.h +++ b/include/sysemu/hw_accel.h @@ -14,6 +14,7 @@ #include "qom/cpu.h" #include "sysemu/hax.h" #include "sysemu/kvm.h" +#include "sysemu/whpx.h" =20 static inline void cpu_synchronize_state(CPUState *cpu) { @@ -23,6 +24,9 @@ static inline void cpu_synchronize_state(CPUState *cpu) if (hax_enabled()) { hax_cpu_synchronize_state(cpu); } + if (whpx_enabled()) { + whpx_cpu_synchronize_state(cpu); + } } =20 static inline void cpu_synchronize_post_reset(CPUState *cpu) @@ -33,6 +37,9 @@ static inline void cpu_synchronize_post_reset(CPUState *c= pu) if (hax_enabled()) { hax_cpu_synchronize_post_reset(cpu); } + if (whpx_enabled()) { + whpx_cpu_synchronize_post_reset(cpu); + } } =20 static inline void cpu_synchronize_post_init(CPUState *cpu) @@ -43,6 +50,9 @@ static inline void cpu_synchronize_post_init(CPUState *cp= u) if (hax_enabled()) { hax_cpu_synchronize_post_init(cpu); } + if (whpx_enabled()) { + whpx_cpu_synchronize_post_init(cpu); + } } =20 static inline void cpu_synchronize_pre_loadvm(CPUState *cpu) @@ -53,6 +63,9 @@ static inline void cpu_synchronize_pre_loadvm(CPUState *c= pu) if (hax_enabled()) { hax_cpu_synchronize_pre_loadvm(cpu); } + if (whpx_enabled()) { + whpx_cpu_synchronize_pre_loadvm(cpu); + } } =20 #endif /* QEMU_HW_ACCEL_H */ diff --git a/target/i386/helper.c b/target/i386/helper.c index f63eb3d..9fba146 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -986,7 +986,7 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess = access) X86CPU *cpu =3D x86_env_get_cpu(env); CPUState *cs =3D CPU(cpu); =20 - if (kvm_enabled()) { + if (kvm_enabled() || whpx_enabled()) { env->tpr_access_type =3D access; =20 cpu_interrupt(cs, CPU_INTERRUPT_TPR); --=20 1.8.3.1