From nobody Sun May 12 17:55:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1710253730; cv=none; d=zohomail.com; s=zohoarc; b=E7dY97JRTF2lqrZiIW2GclfefUbCNnku+8PyxT37pABOVQsNSWmFZm2FXAKAsat9RGFACv9qlpr1+4C+Jd7UtbM3VKqyMkoUR/i/Y1zOEyN0rT9JdRuRnkqQ70uERX3We2i9Fg+2zr3wyWVeu01e+Qu3yGQBsnVpLpt97cjHRpI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710253730; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KV5ZYoaHLmWxMWoTm01z+WFnwLPqemdbnw4H9NY/m5g=; b=PxT/VEx19ohOjxu0DfD45PtJbIVU5BDVhi8BUp+/IW4rnxBcQ5EMs4BZUi/XSqoB0gfZotcoa2iZEhbDvHBpAC+D3QX2JxRHY+PcM3Seknv5YUL49XwTONDEb0PXVmpjCW0s6KVLLAl1mqcA1Gx8YIc2jFclTtVnCm+keQhQ4d0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710253730972641.7944224062653; Tue, 12 Mar 2024 07:28:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk37J-0005Rx-S5; Tue, 12 Mar 2024 10:28:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rk36x-0005NA-Jy for qemu-devel@nongnu.org; Tue, 12 Mar 2024 10:28:13 -0400 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk36v-0005P1-Ag for qemu-devel@nongnu.org; Tue, 12 Mar 2024 10:28:11 -0400 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-512e4f4e463so7619277e87.1 for ; Tue, 12 Mar 2024 07:28:08 -0700 (PDT) Received: from localhost.localdomain (cpc92320-cmbg19-2-0-cust35.5-4.cable.virginm.net. [82.13.64.36]) by smtp.gmail.com with ESMTPSA id t13-20020a05600c198d00b00412b0e51ef9sm12810270wmq.31.2024.03.12.07.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 07:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1710253687; x=1710858487; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KV5ZYoaHLmWxMWoTm01z+WFnwLPqemdbnw4H9NY/m5g=; b=D3weMhcyg6l86G8cjFIhxFkuxYNcrqd2jZgvo8xQaBh3nCNfeDwaXWSKhT7Ax0Y2je LdYXUN4sAaXBA5OwqBMtX+/9sFX5XEaytSlNGunDTtL3aScc3YSpoMhbuU85grl4ro/s IEtfPDOWnP7s/ItC2jzARQIstJ+3JYvFpgyTA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710253687; x=1710858487; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KV5ZYoaHLmWxMWoTm01z+WFnwLPqemdbnw4H9NY/m5g=; b=PK3rOgvCQPmSap2M1agtEJKKG7f/3Vu0ByFrDw8hspg3/uby3wyEPetJIN29ncx2sP PXF3U7kskaGC4NWI12bO7mWJ2j/e6iILOtJbiUv1oH6uJoXse5DMFbbdWrkUEtalbkh7 dP5dUjn4LGCUH8lN7kRSleOQ3ChzyAk2QI/7Hf7mCJv531di0tfb/ueQKqGZFXwN+5sI QBpguSA6SQuA/rXE6wacUNpDZ4CrpmiTiSq/nyKRDRh0XMa5+GJhwCR7u34qU7FuNE5t gozHo3PvklxRTlRzQNaVXu2AWFdfj8SBCTqg6dcewB/qWrplCWeSy4hqhZVLFXrgAuXd QxlQ== X-Gm-Message-State: AOJu0YxY0XVh+E4cm/NMcxpS9W1b2DsBSdiVuUuBXA+35jkJjKTOFIPL vRfSFnOs1nWWrCjgmpr3R8o028BY+49wHpgAhVBCENsfE/S9ziQphMK+ELD5gTg/dMaj/bZXFQc x X-Google-Smtp-Source: AGHT+IHxcatKHz1Lw5UPK3bYSr7CQ6xYEictmegTTCZPXUOugN4Ji7BehjBt+Tk1QwsXItEqzOEItQ== X-Received: by 2002:a05:6512:48c6:b0:513:8030:fde9 with SMTP id er6-20020a05651248c600b005138030fde9mr2754940lfb.58.1710253686936; Tue, 12 Mar 2024 07:28:06 -0700 (PDT) From: Anthony PERARD To: qemu-devel@nongnu.org Cc: Ross Lagerwall Subject: [PULL 1/3] xen/pt: Emulate multifunction bit in header type Date: Tue, 12 Mar 2024 14:27:55 +0000 Message-Id: <20240312142757.34141-2-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312142757.34141-1-anthony.perard@citrix.com> References: <20240312142757.34141-1-anthony.perard@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=anthony.perard@cloud.com; helo=mail-lf1-x12f.google.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1710253731871100001 Content-Type: text/plain; charset="utf-8" From: Ross Lagerwall The intention of the code appears to have been to unconditionally set the multifunction bit but since the emulation mask is 0x00 it has no effect. Instead, emulate the bit and set it based on the multifunction property of the PCIDevice (which can be set using QAPI). This allows making passthrough devices appear as functions in a Xen guest. Signed-off-by: Ross Lagerwall Reviewed-by: Paul Durrant Message-Id: <20231103172601.1319375-1-ross.lagerwall@citrix.com> Signed-off-by: Anthony PERARD --- hw/xen/xen_pt_config_init.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c index ba4cd78238..3edaeab1e3 100644 --- a/hw/xen/xen_pt_config_init.c +++ b/hw/xen/xen_pt_config_init.c @@ -292,7 +292,10 @@ static int xen_pt_header_type_reg_init(XenPCIPassthrou= ghState *s, uint32_t *data) { /* read PCI_HEADER_TYPE */ - *data =3D reg->init_val | 0x80; + *data =3D reg->init_val; + if ((PCI_DEVICE(s)->cap_present & QEMU_PCI_CAP_MULTIFUNCTION)) { + *data |=3D PCI_HEADER_TYPE_MULTI_FUNCTION; + } return 0; } =20 @@ -677,7 +680,7 @@ static XenPTRegInfo xen_pt_emu_reg_header0[] =3D { .size =3D 1, .init_val =3D 0x00, .ro_mask =3D 0xFF, - .emu_mask =3D 0x00, + .emu_mask =3D PCI_HEADER_TYPE_MULTI_FUNCTION, .init =3D xen_pt_header_type_reg_init, .u.b.read =3D xen_pt_byte_reg_read, .u.b.write =3D xen_pt_byte_reg_write, --=20 Anthony PERARD From nobody Sun May 12 17:55:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1710253719; cv=none; d=zohomail.com; s=zohoarc; b=YXSXN/8WQJ7g4ufE8Y8W0KSogsP9r7MeyafQ7G8kzHhkzX6IfpkQtvikVw46ncoOuiCI6qD2web1NdlPFPcOaoIzyJBLGjNjGEEz9/yDssz64VDw85BVBN6pbLpaoMDtkc2xhHxw8WWgyNMUY5SvzpbJBPqfGxfl6y250HJKcaU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710253719; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=l8yhocMsTnBM9RxbWE+rnkoHnCZQapESNY+2+Nhur+g=; b=doaReZ1midEtApgtgMz7CTbq2AycAPGThSD68kCuIcRmML5RTJ3Occm6YRKAJPBJPEHyY7VfNJMhUIB3vh+lsf9COQfnaahKQsVTXIkHgJK7AD9EpNnquyHxWFyYmAxTW6YuaBacg0ALzih7Ptf2YVvtnEeDZknFzXZfFMrv78k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710253718997207.94601342748592; Tue, 12 Mar 2024 07:28:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk375-0005Nt-RS; Tue, 12 Mar 2024 10:28:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rk36z-0005NE-80 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 10:28:13 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk36v-0005PL-Bx for qemu-devel@nongnu.org; Tue, 12 Mar 2024 10:28:12 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-413e642806fso169495e9.2 for ; Tue, 12 Mar 2024 07:28:09 -0700 (PDT) Received: from localhost.localdomain (cpc92320-cmbg19-2-0-cust35.5-4.cable.virginm.net. [82.13.64.36]) by smtp.gmail.com with ESMTPSA id t13-20020a05600c198d00b00412b0e51ef9sm12810270wmq.31.2024.03.12.07.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 07:28:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1710253688; x=1710858488; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l8yhocMsTnBM9RxbWE+rnkoHnCZQapESNY+2+Nhur+g=; b=HX2N7E6U/HOsAQyGxZ7NHQBXsZyOwy0kjTW6zxPMytZ3A07GI6ljxeaZq6FWtLXZl9 8sM9pI9Ns7P/E3EL5qU20SkHd3yfETd4HyqE5cYdG/NyvqYhyIsvnGSLW6uTr3ENzYhf QO1+RN+q5UBB46tVh0d9kut81D+pX4vJY2dGk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710253688; x=1710858488; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l8yhocMsTnBM9RxbWE+rnkoHnCZQapESNY+2+Nhur+g=; b=APbSWf9VMkE9aCZOhIaz00YduSJMzZLwYUyTbIDZUBLVoU8WFWUSP8P2rZ50vdc+7x /iNgSSSGa/aDX9ewrMWXMl2lCyKfzzN+/3drbyHXPXsntI7mOmb6Ui2tsaRv+d6BrFSI RhbACLAdKqmYrZ1hMkNtuM0zX8HfFH4iRSMOLfoK1v9Bkq5TBrp99pISTECfxPMQ0KZ5 mT20Z8aXCNFTOuEo8VLFLugAHV+SWo135RB3GfUq8VYuPhCdXlyfeLJ+DpAvG8mUjnEo DQuHHLQqO5A03qQCIvLKCjHMc0gI5/T6TOrxKwc0bZT4T2z7+FB+GOS6JRNyyw5FOB4X gxfw== X-Gm-Message-State: AOJu0YzkLoWB1uiHOk5+5c38fKZOT9fbQusONGr2f9ddrDIe6qHOwIa/ XjvgiBw+dm5f3pWgAg7hMzECMe9aDzs5YIA9kvhdbjEJDo/caRiLjjepuK2Fs06WYaFSOvQ3XfB A X-Google-Smtp-Source: AGHT+IFwwMUJ7IS7QPhDsUKLmaL2ThpgcxUY4sHiuWDlxBPvSNMOq0R7FMOkswp3Hq0AM9ENHwuErA== X-Received: by 2002:a05:600c:3d9b:b0:413:38c6:2c7a with SMTP id bi27-20020a05600c3d9b00b0041338c62c7amr1370102wmb.22.1710253687811; Tue, 12 Mar 2024 07:28:07 -0700 (PDT) From: Anthony PERARD To: qemu-devel@nongnu.org Cc: Peng Fan Subject: [PULL 2/3] xen: Drop out of coroutine context xen_invalidate_map_cache_entry Date: Tue, 12 Mar 2024 14:27:56 +0000 Message-Id: <20240312142757.34141-3-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312142757.34141-1-anthony.perard@citrix.com> References: <20240312142757.34141-1-anthony.perard@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=anthony.perard@cloud.com; helo=mail-wm1-x32d.google.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1710253719892100005 Content-Type: text/plain; charset="utf-8" From: Peng Fan xen_invalidate_map_cache_entry is not expected to run in a coroutine. Without this, there is crash: signo=3Dsigno@entry=3D6, no_tid=3Dno_tid@entry=3D0) at pthread_kill.c:44 threadid=3D) at pthread_kill.c:78 at /usr/src/debug/glibc/2.38+git-r0/sysdeps/posix/raise.c:26 fmt=3D0xffff9e1ca8a8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=3Dassertion@entry=3D0xaaaae0d25740 "!qemu_in_coroutine()", file=3Dfile@entry=3D0xaaaae0d301a8 "../qemu-xen-dir-remote/block/graph-= lock.c", line=3Dline@entry=3D260, function=3Dfunction@entry=3D0xaaaae0e522c0 <__PRETTY_FUNCTION__.3> "bdr= v_graph_rdlock_main_loop") at assert.c:92 assertion=3Dassertion@entry=3D0xaaaae0d25740 "!qemu_in_coroutine()", file=3Dfile@entry=3D0xaaaae0d301a8 "../qemu-xen-dir-remote/block/graph-= lock.c", line=3Dline@entry=3D260, function=3Dfunction@entry=3D0xaaaae0e522c0 <__PRETTY_FUNCTION__.3> "bdr= v_graph_rdlock_main_loop") at assert.c:101 at ../qemu-xen-dir-remote/block/graph-lock.c:260 at /home/Freenix/work/sw-stash/xen/upstream/tools/qemu-xen-dir-remote/i= nclude/block/graph-lock.h:259 host=3Dhost@entry=3D0xffff742c8000, size=3Dsize@entry=3D2097152) at ../qemu-xen-dir-remote/block/io.c:3362 host=3D0xffff742c8000, size=3D2097152) at ../qemu-xen-dir-remote/block/block-backend.c:2859 host=3D, size=3D, max_size=3D) at ../qemu-xen-dir-remote/block/block-ram-registrar.c:33 size=3D2097152, max_size=3D2097152) at ../qemu-xen-dir-remote/hw/core/numa.c:883 buffer=3Dbuffer@entry=3D0xffff743c5000 "") at ../qemu-xen-dir-remote/hw/xen/xen-mapcache.c:475 buffer=3Dbuffer@entry=3D0xffff743c5000 "") at ../qemu-xen-dir-remote/hw/xen/xen-mapcache.c:487 as=3Das@entry=3D0xaaaae1ca3ae8 , buffer=3D0xffff7= 43c5000, len=3D, is_write=3Dis_write@entry=3Dtrue, access_len=3Daccess_len@entry=3D32768) at ../qemu-xen-dir-remote/system/physmem.c:3199 dir=3DDMA_DIRECTION_FROM_DEVICE, len=3D, buffer=3D, as=3D0xaaaae1ca3ae8 ) at /home/Freenix/work/sw-stash/xen/upstream/tools/qemu-xen-dir-remote/i= nclude/sysemu/dma.h:236 elem=3Delem@entry=3D0xaaaaf620aa30, len=3Dlen@entry=3D32769) at ../qemu-xen-dir-remote/hw/virtio/virtio.c:758 elem=3Delem@entry=3D0xaaaaf620aa30, len=3Dlen@entry=3D32769, idx=3Didx@= entry=3D0) at ../qemu-xen-dir-remote/hw/virtio/virtio.c:919 elem=3Delem@entry=3D0xaaaaf620aa30, len=3D32769) at ../qemu-xen-dir-remote/hw/virtio/virtio.c:994 req=3Dreq@entry=3D0xaaaaf620aa30, status=3Dstatus@entry=3D0 '\000') at ../qemu-xen-dir-remote/hw/block/virtio-blk.c:67 ret=3D0) at ../qemu-xen-dir-remote/hw/block/virtio-blk.c:136 at ../qemu-xen-dir-remote/block/block-backend.c:1559 --Type for more, q to quit, c to continue without paging-- at ../qemu-xen-dir-remote/block/block-backend.c:1614 i1=3D) at ../qemu-xen-dir-remote/util/coroutine-ucontext= .c:177 at ../sysdeps/unix/sysv/linux/aarch64/setcontext.S:123 Signed-off-by: Peng Fan Reviewed-by: Stefano Stabellini Message-Id: <20240124021450.21656-1-peng.fan@oss.nxp.com> Signed-off-by: Anthony PERARD --- hw/xen/xen-mapcache.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index 4f956d048e..7f59080ba7 100644 --- a/hw/xen/xen-mapcache.c +++ b/hw/xen/xen-mapcache.c @@ -476,11 +476,37 @@ static void xen_invalidate_map_cache_entry_unlocked(u= int8_t *buffer) g_free(entry); } =20 -void xen_invalidate_map_cache_entry(uint8_t *buffer) +typedef struct XenMapCacheData { + Coroutine *co; + uint8_t *buffer; +} XenMapCacheData; + +static void xen_invalidate_map_cache_entry_bh(void *opaque) { + XenMapCacheData *data =3D opaque; + mapcache_lock(); - xen_invalidate_map_cache_entry_unlocked(buffer); + xen_invalidate_map_cache_entry_unlocked(data->buffer); mapcache_unlock(); + + aio_co_wake(data->co); +} + +void coroutine_mixed_fn xen_invalidate_map_cache_entry(uint8_t *buffer) +{ + if (qemu_in_coroutine()) { + XenMapCacheData data =3D { + .co =3D qemu_coroutine_self(), + .buffer =3D buffer, + }; + aio_bh_schedule_oneshot(qemu_get_current_aio_context(), + xen_invalidate_map_cache_entry_bh, &data); + qemu_coroutine_yield(); + } else { + mapcache_lock(); + xen_invalidate_map_cache_entry_unlocked(buffer); + mapcache_unlock(); + } } =20 void xen_invalidate_map_cache(void) --=20 Anthony PERARD From nobody Sun May 12 17:55:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1710253716; cv=none; d=zohomail.com; s=zohoarc; b=cEzcT0RWsUOHfbvYV8dCSmzlntkAf4uHKQl6eothELBwLMsLfpMuvbtbCBxqx3tFYowVTh7yuxQ3SehUKG2Ci93MwOywPpPnxgwOCDgqM0yF0OWin+1DlgX0QE35AKutVS8fQHZ3mHbdiptMD0CvkgMQfecRaOj2n4/AunVaN2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710253716; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/HKnaDlEe60prpVqOOnUpQEQIKkbmlWPjhwDXh5f4Us=; b=Kn0MxOTIc7rWVYzidYtI+j2r2QtUoTtvIwH0lyMeqCr6N1rSADwWApJePrGlEL2HcQH7jrP1sqwqJXCmmzeyyOl0ciYkwo+vzjs24roDH4bjFgOBsgGuIVVqxMmXuX/6OwvQ3oRuyzIzmrDIp9px5HCCcL4gyePcMoBT+mLZlB4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710253716305941.3882906893176; Tue, 12 Mar 2024 07:28:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk379-0005OK-My; Tue, 12 Mar 2024 10:28:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rk36z-0005NF-89 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 10:28:13 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk36w-0005Pz-8c for qemu-devel@nongnu.org; Tue, 12 Mar 2024 10:28:12 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-41331166961so6692685e9.1 for ; Tue, 12 Mar 2024 07:28:09 -0700 (PDT) Received: from localhost.localdomain (cpc92320-cmbg19-2-0-cust35.5-4.cable.virginm.net. [82.13.64.36]) by smtp.gmail.com with ESMTPSA id t13-20020a05600c198d00b00412b0e51ef9sm12810270wmq.31.2024.03.12.07.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 07:28:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1710253688; x=1710858488; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/HKnaDlEe60prpVqOOnUpQEQIKkbmlWPjhwDXh5f4Us=; b=Wb9z11oVwuwSlKwq5ldVsQWjefRIfBPWJVH9dHK3oDPAnJvKP9VOOFkpp3UdjJKi/1 ZMiMVnDosDlJQVD6WiuF4J7i4afNQx5g1ujoM4kAbATod7yQbORz8t8ZI4WNzLpSVg9R JiCrrxKifYeEWzHi2Rf4bVNRqLKwKrN+Vn8po= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710253688; x=1710858488; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/HKnaDlEe60prpVqOOnUpQEQIKkbmlWPjhwDXh5f4Us=; b=a/REEEWSO4XdLowfjavV8F4y2aF7gPjv1Er9o0MGUTyFFBDw5WSe4oXk7Mrl0ctLqd pGpthZplhFJJdcXgKBiHDeVX8+i2wVh7lxx71GjpxZ/m6VG8U7NLZOtkSCJhXB7btFHl mFNdzVhL+h0oS9vzJBP2/zujnz+WU+cCrKF9lBLQOF7lPQEDcNe0P+HOtR5puJlgXnKG H2moZlIXCZHkHH3fvOKVA3JtBseMUgJWd2+7ziaTM8bQvYoLAAKR+FDtsF4lnvrXHU8f A9WblRgCqFM+Sj+qMf+KykSQn0tCw6Ymi7vXTPaRZUJ3jhiJ6jjp+Q8U9geTl4wV3M43 Es6g== X-Gm-Message-State: AOJu0YwJtQPxN/k4IWuS6VwJ8/unkjgjRbyBvOy9zRXnIYMWtQn6mgfu X+UhVkturBpnjSuOszWDJC0yD0rjw35IEWq9GaIozwplEq+tiieAJtwRxXstWoweEfVB1K0gWdU x X-Google-Smtp-Source: AGHT+IE75osoSUzpQVWxFnEp79N1bEFbcdqUUk+T0bTtBjE9bDwyEXvCsJAWLfQieFqh+wyQzP3z1w== X-Received: by 2002:a05:600c:3b8d:b0:413:1f8d:f97f with SMTP id n13-20020a05600c3b8d00b004131f8df97fmr6714661wms.29.1710253688564; Tue, 12 Mar 2024 07:28:08 -0700 (PDT) From: Anthony PERARD To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Subject: [PULL 3/3] i386: load kernel on xen using DMA Date: Tue, 12 Mar 2024 14:27:57 +0000 Message-Id: <20240312142757.34141-4-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312142757.34141-1-anthony.perard@citrix.com> References: <20240312142757.34141-1-anthony.perard@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=anthony.perard@cloud.com; helo=mail-wm1-x332.google.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1710253717966100001 From: Marek Marczykowski-G=C3=B3recki Kernel on Xen is loaded via fw_cfg. Previously it used non-DMA version, which loaded the kernel (and initramfs) byte by byte. Change this to DMA, to load in bigger chunks. This change alone reduces load time of a (big) kernel+initramfs from ~10s down to below 1s. This change was suggested initially here: https://lore.kernel.org/xen-devel/20180216204031.000052e9@gmail.com/ Apparently this alone is already enough to get massive speedup. Signed-off-by: Marek Marczykowski-G=C3=B3recki Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Anthony PERARD Message-Id: <20210426034709.595432-1-marmarek@invisiblethingslab.com> Signed-off-by: Anthony PERARD --- hw/i386/pc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f5ff970acf..4f322e0856 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -718,7 +718,8 @@ void xen_load_linux(PCMachineState *pcms) =20 assert(MACHINE(pcms)->kernel_filename !=3D NULL); =20 - fw_cfg =3D fw_cfg_init_io(FW_CFG_IO_BASE); + fw_cfg =3D fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4, + &address_space_memory); fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus); rom_set_fw(fw_cfg); =20 --=20 Anthony PERARD