From nobody Wed Nov 27 09:50:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1699267244; cv=none; d=zohomail.com; s=zohoarc; b=cduaHuyC2gV94MlaYqQzAKU/VUAoFcvIUNdMZAq3ginokjL25RpCmOEFov7wxXOExpyMeuZoMGlz1DXStCQ5gwh9q0wFIGBDKVA9asvaib/rHgJiBQo638ivHvhQ2gq+F8biEfZS1fk0XnP+e3vFzuyWR8scf35mhk0d3/pTYxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699267244; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wOMw/UywJs8oL1LQQcgtToi+dJjeH7aP4AFa7EtnSbM=; b=NOcL9C3jweL1DnXWEb5qZjYGJS3XP5MiZgzshwafOVO8xPOuLhYj1UI81IvTRnPg4rcODG4/0sa0ooyXmuTaIpdNphgWVC0+ViQIqK4iuoar+zsaPrOHmfcTi1l29SiX0dSu/lQAb/WRZTvn5ujfs82sgKzS2OqdMT+bGkmJTd0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1699267244801284.8852605061294; Mon, 6 Nov 2023 02:40:44 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.627876.978736 (Exim 4.92) (envelope-from ) id 1qzx1g-00011K-A1; Mon, 06 Nov 2023 10:40:12 +0000 Received: by outflank-mailman (output) from mailman id 627876.978736; Mon, 06 Nov 2023 10:40:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qzx1g-00011C-4t; Mon, 06 Nov 2023 10:40:12 +0000 Received: by outflank-mailman (input) for mailman id 627876; Mon, 06 Nov 2023 10:40:10 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qzx1e-00010s-CZ for xen-devel@lists.xenproject.org; Mon, 06 Nov 2023 10:40:10 +0000 Received: from casper.infradead.org (casper.infradead.org [2001:8b0:10b:1236::1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d9d8e9b5-7c90-11ee-9b0e-b553b5be7939; Mon, 06 Nov 2023 11:40:07 +0100 (CET) Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qzx1P-005R1g-J6; Mon, 06 Nov 2023 10:39:56 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.96.2 #2 (Red Hat Linux)) id 1qzx1P-000qFx-2a; Mon, 06 Nov 2023 10:39:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: d9d8e9b5-7c90-11ee-9b0e-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=wOMw/UywJs8oL1LQQcgtToi+dJjeH7aP4AFa7EtnSbM=; b=lUwHxNJ1U1La7N7HYHVdJ5UMsn L8ZcNKscZiT57bK7PQz2qfH1Pug1s7gtF1UB9Qji6aLEC9gfsjAsIdOJwPdRy/F/k3F+ce++T32+8 eE8N+RrSBOuq4MsSShJMGOSb6Q3bcuJnlVvYQKyOrcA3rJs6NAUto8yac1SEV/F5Jt9e/NH8i0Nwq Bah8ewkbmFCtdlxyGBAdeceVBaU4xgbna65iOtV4uDZE61AVW3WnewCx3ytOYQhaM/pjG9CDl+Nue klanfVjqoByXh3jztUzwBeZGiNvXkPVtDz/JOFUWbgLTFQ49tyAiDj3KaV89rMjfyTMuFmzaIu19O nK5wZ4Zg==; From: David Woodhouse To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Stefano Stabellini , Anthony Perard , Paul Durrant , Kevin Wolf , Hanna Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcelo Tosatti , xen-devel@lists.xenproject.org, qemu-block@nongnu.org, kvm@vger.kernel.org Subject: [PULL 1/7] i386/xen: Don't advertise XENFEAT_supervisor_mode_kernel Date: Mon, 6 Nov 2023 10:39:49 +0000 Message-ID: <20231106103955.200867-2-dwmw2@infradead.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231106103955.200867-1-dwmw2@infradead.org> References: <20231106103955.200867-1-dwmw2@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-ZohoMail-DKIM: pass (identity @infradead.org) X-ZM-MESSAGEID: 1699267246646100015 Content-Type: text/plain; charset="utf-8" From: David Woodhouse This confuses lscpu into thinking it's running in PVH mode. Cc: qemu-stable@nongnu.org Fixes: bedcc139248 ("i386/xen: implement HYPERVISOR_xen_version") Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-emu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index 76348f9d5d..0055441b2e 100644 --- a/target/i386/kvm/xen-emu.c +++ b/target/i386/kvm/xen-emu.c @@ -267,7 +267,6 @@ static bool kvm_xen_hcall_xen_version(struct kvm_xen_ex= it *exit, X86CPU *cpu, fi.submap |=3D 1 << XENFEAT_writable_page_tables | 1 << XENFEAT_writable_descriptor_tables | 1 << XENFEAT_auto_translated_physmap | - 1 << XENFEAT_supervisor_mode_kernel | 1 << XENFEAT_hvm_callback_vector | 1 << XENFEAT_hvm_safe_pvclock | 1 << XENFEAT_hvm_pirqs; --=20 2.41.0 From nobody Wed Nov 27 09:50:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699267235668187.19343407449912; Mon, 6 Nov 2023 02:40:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzx1j-0001Qm-Pu; Mon, 06 Nov 2023 05:40:16 -0500 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 1qzx1h-0001QW-Sl; Mon, 06 Nov 2023 05:40:13 -0500 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qzx1d-0007hU-So; Mon, 06 Nov 2023 05:40:13 -0500 Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qzx1R-00ARzu-0T; Mon, 06 Nov 2023 10:39:57 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.96.2 #2 (Red Hat Linux)) id 1qzx1P-000qG1-2r; Mon, 06 Nov 2023 10:39:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=bUIwWhSmxxhL6AS/9ZXbE9mq6OB7mrxWvKvI7fmMtUk=; b=PKghrx40QFAYvqzmoIilm9wA2v pxZ4oYhwBBymCgCvc2Usep0OkshnQ9Rwj2ML4rAPFff0nwvxNOOgCpLIhKFfZopoZz6V8n3pnLQ5d CMv725X/ZTTpYldzx15AzhXXWx2ND9Dt4ek5Uy9Vt1nPHDw6LewWuAuFU+bLiEYuYfK8bfOxlxsN2 SFAeRgy0QbzGk+nFD7rctc7gjWEhxy/Z7fYhfXO/rBWJ/ZlNLlGf4sCrEboyJupti1CBCOlqROAdf M3mlUGHG2Yl8MCbvml+3PT7xKfd/AMvTSKDHLPPs2e8R537YDpdqMY5HwnN8efhApCB97O/WgTONw tmskLnaA==; From: David Woodhouse To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Stefano Stabellini , Anthony Perard , Paul Durrant , Kevin Wolf , Hanna Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcelo Tosatti , xen-devel@lists.xenproject.org, qemu-block@nongnu.org, kvm@vger.kernel.org Subject: [PULL 2/7] i386/xen: fix per-vCPU upcall vector for Xen emulation Date: Mon, 6 Nov 2023 10:39:50 +0000 Message-ID: <20231106103955.200867-3-dwmw2@infradead.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231106103955.200867-1-dwmw2@infradead.org> References: <20231106103955.200867-1-dwmw2@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SRS-Rewrite: SMTP reverse-path rewritten from by desiato.infradead.org. See http://www.infradead.org/rpr.html 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: none client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; envelope-from=BATV+aa7b7dce24b49c47a83c+7379+infradead.org+dwmw2@desiato.srs.infradead.org; helo=desiato.infradead.org X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=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: fail (Header signature does not verify) X-ZM-MESSAGEID: 1699267237098100005 Content-Type: text/plain; charset="utf-8" From: David Woodhouse The per-vCPU upcall vector support had three problems. Firstly it was using the wrong hypercall argument and would always return -EFAULT when the guest tried to set it up. Secondly it was using the wrong ioctl() to pass the vector to the kernel and thus the *kernel* would always return -EINVAL. Finally, even when delivering the event directly from userspace with an MSI, it put the destination CPU ID into the wrong bits of the MSI address. Linux doesn't (yet) use this mode so it went without decent testing for a while. Cc: qemu-stable@nongnu.org Fixes: 105b47fdf2d0 ("i386/xen: implement HVMOP_set_evtchn_upcall_vector") Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-emu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index 0055441b2e..7c504d9fa4 100644 --- a/target/i386/kvm/xen-emu.c +++ b/target/i386/kvm/xen-emu.c @@ -306,7 +306,7 @@ static int kvm_xen_set_vcpu_callback_vector(CPUState *c= s) =20 trace_kvm_xen_set_vcpu_callback(cs->cpu_index, vector); =20 - return kvm_vcpu_ioctl(cs, KVM_XEN_HVM_SET_ATTR, &xva); + return kvm_vcpu_ioctl(cs, KVM_XEN_VCPU_SET_ATTR, &xva); } =20 static void do_set_vcpu_callback_vector(CPUState *cs, run_on_cpu_data data) @@ -440,7 +440,8 @@ void kvm_xen_inject_vcpu_callback_vector(uint32_t vcpu_= id, int type) * deliver it as an MSI. */ MSIMessage msg =3D { - .address =3D APIC_DEFAULT_ADDRESS | X86_CPU(cs)->apic_id, + .address =3D APIC_DEFAULT_ADDRESS | + (X86_CPU(cs)->apic_id << MSI_ADDR_DEST_ID_SHIFT), .data =3D vector | (1UL << MSI_DATA_LEVEL_SHIFT), }; kvm_irqchip_send_msi(kvm_state, msg); @@ -849,8 +850,7 @@ static bool kvm_xen_hcall_hvm_op(struct kvm_xen_exit *e= xit, X86CPU *cpu, int ret =3D -ENOSYS; switch (cmd) { case HVMOP_set_evtchn_upcall_vector: - ret =3D kvm_xen_hcall_evtchn_upcall_vector(exit, cpu, - exit->u.hcall.params[0]); + ret =3D kvm_xen_hcall_evtchn_upcall_vector(exit, cpu, arg); break; =20 case HVMOP_pagetable_dying: --=20 2.41.0 From nobody Wed Nov 27 09:50:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1699267247; cv=none; d=zohomail.com; s=zohoarc; b=ZVbTZ5/Iqjjh3UJP4ffVzghJhqNG+arbBZ9dfoDpSQTmpgng3Am5OEicaL3hTmYMacPIlkwPOkEBtSlafXethwtHjZBLdhpQb3luSFReIUbvAEp3CgVB7nDKWm6hT/9kbTCjWcdkTv8PutqYx31PV8fj3Td73PH7vFywnnInu6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699267247; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8y74Lolq5T0LDv+PFoxvm3kC9HGA3LQOfihqJijE5SE=; b=lHxhjKn/u7GJBzK68MWkRHq/WBM3PXZuk0JCirEpeqK6Pf5NIkMszmo41btrq25k5KbZ+VJZSKbtHvo/xGsMuUyRgB75JjZAyi05MpmaEguVzqitpTrIZs6hxjgpbsqN3lEb5Dwh/r2gz8P333GEI2WPfxJ/QqujfkjPB+kFmOE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1699267247041824.0751188959108; Mon, 6 Nov 2023 02:40:47 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.627883.978805 (Exim 4.92) (envelope-from ) id 1qzx1p-0002xW-78; Mon, 06 Nov 2023 10:40:21 +0000 Received: by outflank-mailman (output) from mailman id 627883.978805; Mon, 06 Nov 2023 10:40:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qzx1p-0002xM-3R; Mon, 06 Nov 2023 10:40:21 +0000 Received: by outflank-mailman (input) for mailman id 627883; Mon, 06 Nov 2023 10:40:19 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qzx1n-00010s-Da for xen-devel@lists.xenproject.org; Mon, 06 Nov 2023 10:40:19 +0000 Received: from desiato.infradead.org (desiato.infradead.org [2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id dfb94609-7c90-11ee-9b0e-b553b5be7939; Mon, 06 Nov 2023 11:40:16 +0100 (CET) Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qzx1R-00ARzv-0U; Mon, 06 Nov 2023 10:39:57 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.96.2 #2 (Red Hat Linux)) id 1qzx1P-000qG5-39; Mon, 06 Nov 2023 10:39:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: dfb94609-7c90-11ee-9b0e-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=8y74Lolq5T0LDv+PFoxvm3kC9HGA3LQOfihqJijE5SE=; b=FSFn3mS59GJdfRIIZe12qeoM/o IUERkSlLtCLvpnlYwLH6az4jVaFuBqFZkAJYtUxAo0HgeY2vOdA36i6m6Xj4q+yrSvHLLL2j8Pw/W NKOSTnOExI8mA2isNjoZuF5apu2cXNSLP8kzai1deGgZD2IZD/Hrz3+3NwSZR3IeJob91PC3k4AWQ B0BKwsh538eW76PLt8gjOJLhI1itgLev1mjgpKRRzza9kuDHtICG5LUlsQ3jRZCw1cSrtTAMPmoiY Hv6JfsUoHvVQIlRmEQ3q/UaaKJ/SA99AcAd9/0uipDjNbLGPP+viqyvqV/EeKhZ8uTATdsoiArTSz 7O0eEqyw==; From: David Woodhouse To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Stefano Stabellini , Anthony Perard , Paul Durrant , Kevin Wolf , Hanna Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcelo Tosatti , xen-devel@lists.xenproject.org, qemu-block@nongnu.org, kvm@vger.kernel.org Subject: [PULL 3/7] hw/xen: select kernel mode for per-vCPU event channel upcall vector Date: Mon, 6 Nov 2023 10:39:51 +0000 Message-ID: <20231106103955.200867-4-dwmw2@infradead.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231106103955.200867-1-dwmw2@infradead.org> References: <20231106103955.200867-1-dwmw2@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by desiato.infradead.org. See http://www.infradead.org/rpr.html X-ZohoMail-DKIM: pass (identity @infradead.org) X-ZM-MESSAGEID: 1699267248659100019 Content-Type: text/plain; charset="utf-8" From: David Woodhouse A guest which has configured the per-vCPU upcall vector may set the HVM_PARAM_CALLBACK_IRQ param to fairly much anything other than zero. For example, Linux v6.0+ after commit b1c3497e604 ("x86/xen: Add support for HVMOP_set_evtchn_upcall_vector") will just do this after setting the vector: /* Trick toolstack to think we are enlightened. */ if (!cpu) rc =3D xen_set_callback_via(1); That's explicitly setting the delivery to GSI#1, but it's supposed to be overridden by the per-vCPU vector setting. This mostly works in Qemu *except* for the logic to enable the in-kernel handling of event channels, which falsely determines that the kernel cannot accelerate GSI delivery in this case. Add a kvm_xen_has_vcpu_callback_vector() to report whether vCPU#0 has the vector set, and use that in xen_evtchn_set_callback_param() to enable the kernel acceleration features even when the param *appears* to be set to target a GSI. Preserve the Xen behaviour that when HVM_PARAM_CALLBACK_IRQ is set to *zero* the event channel delivery is disabled completely. (Which is what that bizarre guest behaviour is working round in the first place.) Cc: qemu-stable@nongnu.org Fixes: 91cce756179 ("hw/xen: Add xen_evtchn device for event channel emulat= ion") Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_evtchn.c | 6 ++++++ include/sysemu/kvm_xen.h | 1 + target/i386/kvm/xen-emu.c | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c index a731738411..3d6f4b4a0a 100644 --- a/hw/i386/kvm/xen_evtchn.c +++ b/hw/i386/kvm/xen_evtchn.c @@ -490,6 +490,12 @@ int xen_evtchn_set_callback_param(uint64_t param) break; } =20 + /* If the guest has set a per-vCPU callback vector, prefer that. */ + if (gsi && kvm_xen_has_vcpu_callback_vector()) { + in_kernel =3D kvm_xen_has_cap(EVTCHN_SEND); + gsi =3D 0; + } + if (!ret) { /* If vector delivery was turned *off* then tell the kernel */ if ((s->callback_param >> CALLBACK_VIA_TYPE_SHIFT) =3D=3D diff --git a/include/sysemu/kvm_xen.h b/include/sysemu/kvm_xen.h index 595abfbe40..961c702c4e 100644 --- a/include/sysemu/kvm_xen.h +++ b/include/sysemu/kvm_xen.h @@ -22,6 +22,7 @@ int kvm_xen_soft_reset(void); uint32_t kvm_xen_get_caps(void); void *kvm_xen_get_vcpu_info_hva(uint32_t vcpu_id); +bool kvm_xen_has_vcpu_callback_vector(void); void kvm_xen_inject_vcpu_callback_vector(uint32_t vcpu_id, int type); void kvm_xen_set_callback_asserted(void); int kvm_xen_set_vcpu_virq(uint32_t vcpu_id, uint16_t virq, uint16_t port); diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index 7c504d9fa4..75b2c557b9 100644 --- a/target/i386/kvm/xen-emu.c +++ b/target/i386/kvm/xen-emu.c @@ -424,6 +424,13 @@ void kvm_xen_set_callback_asserted(void) } } =20 +bool kvm_xen_has_vcpu_callback_vector(void) +{ + CPUState *cs =3D qemu_get_cpu(0); + + return cs && !!X86_CPU(cs)->env.xen_vcpu_callback_vector; +} + void kvm_xen_inject_vcpu_callback_vector(uint32_t vcpu_id, int type) { CPUState *cs =3D qemu_get_cpu(vcpu_id); --=20 2.41.0 From nobody Wed Nov 27 09:50:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1699267240; cv=none; d=zohomail.com; s=zohoarc; b=PlFhcQrcL/j9M8CqKfsfpZbFnK9GZmrhUCXp22hJsfMZjQOo72szQQqCU0kZ3c+IXpujv6o0D1AMQ1LEP58wAoQAyj5huXIf0LjLE3XNDe762Y3Tutqd+xeBOcYFsM7jWet1Vz+l4dNEwz8Ct6IJdd6Z5bgZ7cODlX2fe1TWGrw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699267240; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UEnjaXF9IbVpfGR6pVwSlj7B+44LHx3n6ww2MVgkTpA=; b=SzAOOy7TMtPu1iNHR06aSay9/JWJLO13H3WcZa1OnBz7d9NmSBHEnnW0fE0cmC7agfy1nr3Tdou7tMO9pruPfBEZ7dTiH6Np2AwB7tjMlwGTBouqf8qj78qTapPNYE94TCerxr4fF/hao6Tb7U8qP5FN2bYtGFtBhTS5rjh7h3w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1699267240281367.32408766344486; Mon, 6 Nov 2023 02:40:40 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.627879.978753 (Exim 4.92) (envelope-from ) id 1qzx1h-0001I4-AN; Mon, 06 Nov 2023 10:40:13 +0000 Received: by outflank-mailman (output) from mailman id 627879.978753; Mon, 06 Nov 2023 10:40:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qzx1g-0001FD-Vr; Mon, 06 Nov 2023 10:40:12 +0000 Received: by outflank-mailman (input) for mailman id 627879; Mon, 06 Nov 2023 10:40:12 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qzx1g-00010s-1d for xen-devel@lists.xenproject.org; Mon, 06 Nov 2023 10:40:12 +0000 Received: from casper.infradead.org (casper.infradead.org [2001:8b0:10b:1236::1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d9838fad-7c90-11ee-9b0e-b553b5be7939; Mon, 06 Nov 2023 11:40:07 +0100 (CET) Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qzx1P-005R1h-Og; Mon, 06 Nov 2023 10:39:56 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.96.2 #2 (Red Hat Linux)) id 1qzx1Q-000qG9-09; Mon, 06 Nov 2023 10:39:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: d9838fad-7c90-11ee-9b0e-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=UEnjaXF9IbVpfGR6pVwSlj7B+44LHx3n6ww2MVgkTpA=; b=v9GGJRYSotjmH5aMKb615be3Wh A1SIx3pqMqmeGy+3oNTCGKnqFJdb5KIGg/zpCYxMEK7EBG7CvNqv+7uzJTgzNZhqT0p2zeACSmuQA AE9Kr3tGyv2X7LVTKZOoFBHE46N3ry/HY7XkMw5A+oxo7NStJih00MnU/DfEkCStM2lAuuFIbtAo8 Spa3GytWn1hjEQUXwjU6P8Y23QDIdFc+5uHZFRkSkz0ARD998Lnm06p8S8FoaQUDm1amp/qKAkVpx 9pHknZWs5urn5hg6GhsU81PlAY/6Iu3JLqi8s6vVBCnHktWnbr8Ks22660tRwpyHG5cuC/T6JHDQ5 N2C6zWEA==; From: David Woodhouse To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Stefano Stabellini , Anthony Perard , Paul Durrant , Kevin Wolf , Hanna Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcelo Tosatti , xen-devel@lists.xenproject.org, qemu-block@nongnu.org, kvm@vger.kernel.org Subject: [PULL 4/7] hw/xen: don't clear map_track[] in xen_gnttab_reset() Date: Mon, 6 Nov 2023 10:39:52 +0000 Message-ID: <20231106103955.200867-5-dwmw2@infradead.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231106103955.200867-1-dwmw2@infradead.org> References: <20231106103955.200867-1-dwmw2@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-ZohoMail-DKIM: pass (identity @infradead.org) X-ZM-MESSAGEID: 1699267242613100011 Content-Type: text/plain; charset="utf-8" From: David Woodhouse The refcounts actually correspond to 'active_ref' structures stored in a GHashTable per "user" on the backend side (mostly, per XenDevice). If we zero map_track[] on reset, then when the backend drivers get torn down and release their mapping we hit the assert(s->map_track[ref] !=3D 0) in gnt_unref(). So leave them in place. Each backend driver will disconnect and reconnect as the guest comes back up again and reconnects, and it all works out OK in the end as the old refs get dropped. Cc: qemu-stable@nongnu.org Fixes: de26b2619789 ("hw/xen: Implement soft reset for emulated gnttab") Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_gnttab.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/hw/i386/kvm/xen_gnttab.c b/hw/i386/kvm/xen_gnttab.c index 21c30e3659..839ec920a1 100644 --- a/hw/i386/kvm/xen_gnttab.c +++ b/hw/i386/kvm/xen_gnttab.c @@ -541,7 +541,5 @@ int xen_gnttab_reset(void) s->entries.v1[GNTTAB_RESERVED_XENSTORE].flags =3D GTF_permit_access; s->entries.v1[GNTTAB_RESERVED_XENSTORE].frame =3D XEN_SPECIAL_PFN(XENS= TORE); =20 - memset(s->map_track, 0, s->max_frames * ENTRIES_PER_FRAME_V1); - return 0; } --=20 2.41.0 From nobody Wed Nov 27 09:50:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1699267235; cv=none; d=zohomail.com; s=zohoarc; b=QbCgA+MoBGFtGDzFYmBsBykw3hGjhFZhkJFYui8YE4SZPooydEYpzrPiWz0vYAqQiIwQmDRExJFE+akNj8xDOfzEgmnD3obgBvtADSKpdNFfnk4uB6PBmx7nGlCk/Vi2b98T2jLhab1AXwpCXwrrqXAxgXgkKzSHJRJRVEIK7Cg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699267235; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2aX82uZpC1qyK8a13DdVvtrvr4nDdAxx84xCzWlWkQE=; b=gJvbSlFWdF8HKT7Jq7u0rtUAOMTDBUNaiOSsaCjrf+zURC/343cAtYFPHLHbkvHQfA7X/UIiGnOenEHIEnqWVK6ZvAOmFq4YYOegLGAbgvsm98VMDF/w/hhwBJjnlNgPCJeIpIv0w/jh1O8PdAT7XZ0IyhRJ5f2zNWjBg8aXFjA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1699267235937853.9414002729476; Mon, 6 Nov 2023 02:40:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.627881.978768 (Exim 4.92) (envelope-from ) id 1qzx1i-0001dg-2C; Mon, 06 Nov 2023 10:40:14 +0000 Received: by outflank-mailman (output) from mailman id 627881.978768; Mon, 06 Nov 2023 10:40:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qzx1h-0001a9-QM; Mon, 06 Nov 2023 10:40:13 +0000 Received: by outflank-mailman (input) for mailman id 627881; Mon, 06 Nov 2023 10:40:12 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qzx1g-00010q-CY for xen-devel@lists.xenproject.org; Mon, 06 Nov 2023 10:40:12 +0000 Received: from desiato.infradead.org (desiato.infradead.org [2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id db10bb24-7c90-11ee-98da-6d05b1d4d9a1; Mon, 06 Nov 2023 11:40:09 +0100 (CET) Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qzx1R-00ARzw-0T; Mon, 06 Nov 2023 10:39:57 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.96.2 #2 (Red Hat Linux)) id 1qzx1Q-000qGD-0J; Mon, 06 Nov 2023 10:39:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: db10bb24-7c90-11ee-98da-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description; bh=2aX82uZpC1qyK8a13DdVvtrvr4nDdAxx84xCzWlWkQE=; b=Lsa03UYsBW/tPFhN+jMR5L26U/ TVzIcfwnVOKWq5iVAbYsqR6CCu2/cqD2aOvhXmFK94xOl7AaqnrWzCxnvgNIK+qbGL3dSymFt2T1w TxnN1TH0mJkh1qzM/BhXXPzV7ivfJRv24SyfrEi9Wn71X/x5BxUf3616HSSSnHGXSzY5RLRicYzGq 7YwIXlaz/0icDCQWAP1xDbdRgUrI64/oY3c6TeFVPJwinCYCKUzxgRZ0K+HaQk+yAufoKx5SztD5n PuPTmD1h8oBzywh7Jh1H9fiiYouwogazRnsvbqM526NkjyZpNfe1bEFjOBIPG7UHC0kDEpTVLKQW6 aL2RWHyQ==; From: David Woodhouse To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Stefano Stabellini , Anthony Perard , Paul Durrant , Kevin Wolf , Hanna Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcelo Tosatti , xen-devel@lists.xenproject.org, qemu-block@nongnu.org, kvm@vger.kernel.org Subject: [PULL 5/7] hw/xen: fix XenStore watch delivery to guest Date: Mon, 6 Nov 2023 10:39:53 +0000 Message-ID: <20231106103955.200867-6-dwmw2@infradead.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231106103955.200867-1-dwmw2@infradead.org> References: <20231106103955.200867-1-dwmw2@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by desiato.infradead.org. See http://www.infradead.org/rpr.html X-ZohoMail-DKIM: pass (identity @infradead.org) X-ZM-MESSAGEID: 1699267236866100001 From: David Woodhouse When fire_watch_cb() found the response buffer empty, it would call deliver_watch() to generate the XS_WATCH_EVENT message in the response buffer and send an event channel notification to the guest=E2=80=A6 without actually *copying* the response buffer into the ring. So there was nothing for the guest to see. The pending response didn't actually get processed into the ring until the guest next triggered some activity from its side. Add the missing call to put_rsp(). It might have been slightly nicer to call xen_xenstore_event() here, which would *almost* have worked. Except for the fact that it calls xen_be_evtchn_pending() to check that it really does have an event pending (and clear the eventfd for next time). And under Xen it's defined that setting that fd to O_NONBLOCK isn't guaranteed to work, so the emu implementation follows suit. This fixes Xen device hot-unplug. Cc: qemu-stable@nongnu.org Fixes: 0254c4d19df ("hw/xen: Add xenstore wire implementation and implement= ation stubs") Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_xenstore.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c index 660d0b72f9..8e716a7009 100644 --- a/hw/i386/kvm/xen_xenstore.c +++ b/hw/i386/kvm/xen_xenstore.c @@ -1357,10 +1357,12 @@ static void fire_watch_cb(void *opaque, const char = *path, const char *token) } else { deliver_watch(s, path, token); /* - * If the message was queued because there was already ring activi= ty, - * no need to wake the guest. But if not, we need to send the evtc= hn. + * Attempt to queue the message into the actual ring, and send + * the event channel notification if any bytes are copied. */ - xen_be_evtchn_notify(s->eh, s->be_port); + if (s->rsp_pending && put_rsp(s) > 0) { + xen_be_evtchn_notify(s->eh, s->be_port); + } } } =20 --=20 2.41.0 From nobody Wed Nov 27 09:50:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1699267243; cv=none; d=zohomail.com; s=zohoarc; b=WDoRdh3bUHTLC3yEwagH9Jxs6W46IVE6xI+OZ2EBqD5iCwPkfVAMn7e1KykZ8s1RUm1PnEuP3/dAo8GpEKAOAqVgH5hTUgBtHSKwWRze7lXSw/WePoAehp7G3hJ+5RyCSRukMuhBWeigNSZGXrKa2d8Crn+qGFqeOcmuzWNKBfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699267243; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oTzSlnwFiwNNyo9+XLJSozlV3tES1c1DD/ZmREeHw24=; b=nRiOp+FWUKG112sI7twGzI/kJTnW9a4fMFTBmlj2X0TidR+rxYwCcsd+cWEa0FqWKeJeciE/iAwqmaFBC0M5HqmaTa0Jg8gAjBwOEl5Uf2wkzOdHHTwRpEdfuCAW7UYZ2fnt7/Xb8CieTOV3GLtrl0EWSHBtlzUQdy/nRiU3PnI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1699267243723542.4191167465594; Mon, 6 Nov 2023 02:40:43 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.627878.978746 (Exim 4.92) (envelope-from ) id 1qzx1g-00019R-Ta; Mon, 06 Nov 2023 10:40:12 +0000 Received: by outflank-mailman (output) from mailman id 627878.978746; Mon, 06 Nov 2023 10:40:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qzx1g-00016R-Kp; Mon, 06 Nov 2023 10:40:12 +0000 Received: by outflank-mailman (input) for mailman id 627878; Mon, 06 Nov 2023 10:40:11 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qzx1d-00010q-16 for xen-devel@lists.xenproject.org; Mon, 06 Nov 2023 10:40:11 +0000 Received: from casper.infradead.org (casper.infradead.org [2001:8b0:10b:1236::1]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d9d0841d-7c90-11ee-98da-6d05b1d4d9a1; Mon, 06 Nov 2023 11:40:07 +0100 (CET) Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qzx1P-005R1i-Rt; Mon, 06 Nov 2023 10:39:56 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.96.2 #2 (Red Hat Linux)) id 1qzx1Q-000qGH-0X; Mon, 06 Nov 2023 10:39:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: d9d0841d-7c90-11ee-98da-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=oTzSlnwFiwNNyo9+XLJSozlV3tES1c1DD/ZmREeHw24=; b=AFLH666BhTE9iLsKwkcxfjYYVk EK1GRnKx1eeQSIv4t+AlzQ51FcOiV4PCFI+D9tzyDeaMe6dga8PYsEugIJlk8ThSR6cXwK2AKXIxM vYAXj7UM09WBHcehjYNl+F4q/IdDbIauXkudVIoN/MgOzhWFA+Pyh9VobKDkjCaBQ0r3+ac+bZ7f4 vjf/MzboSSR81s4957qqdvrSVWv9ufNI6hAQ3y8jvHLmnO/b1ZYN4vlIQa8/WUDuCtsOyPoL13Siu 1oguA+OYtjBq95Y5Tnq77a8QjdpITiik2VpWIa7KX8H7aNQBgSFdL60drlP/vZ+JFZUNtSuxNPsF8 R+CngbmA==; From: David Woodhouse To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Stefano Stabellini , Anthony Perard , Paul Durrant , Kevin Wolf , Hanna Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcelo Tosatti , xen-devel@lists.xenproject.org, qemu-block@nongnu.org, kvm@vger.kernel.org Subject: [PULL 6/7] hw/xen: take iothread mutex in xen_evtchn_reset_op() Date: Mon, 6 Nov 2023 10:39:54 +0000 Message-ID: <20231106103955.200867-7-dwmw2@infradead.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231106103955.200867-1-dwmw2@infradead.org> References: <20231106103955.200867-1-dwmw2@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-ZohoMail-DKIM: pass (identity @infradead.org) X-ZM-MESSAGEID: 1699267244620100013 Content-Type: text/plain; charset="utf-8" From: David Woodhouse The xen_evtchn_soft_reset() function requires the iothread mutex, but is also called for the EVTCHNOP_reset hypercall. Ensure the mutex is taken in that case. Cc: qemu-stable@nongnu.org Fixes: a15b10978fe6 ("hw/xen: Implement EVTCHNOP_reset") Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_evtchn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c index 3d6f4b4a0a..b2b4be9983 100644 --- a/hw/i386/kvm/xen_evtchn.c +++ b/hw/i386/kvm/xen_evtchn.c @@ -1135,6 +1135,7 @@ int xen_evtchn_reset_op(struct evtchn_reset *reset) return -ESRCH; } =20 + QEMU_IOTHREAD_LOCK_GUARD(); return xen_evtchn_soft_reset(); } =20 --=20 2.41.0 From nobody Wed Nov 27 09:50:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1699267237; cv=none; d=zohomail.com; s=zohoarc; b=QwE0ObZ9u5ZoUR7JDW7FP80fUeHWF8RNyqUkvfF1dQaGGirNwPVPWci4VkWtnq+MGsLLRTuKCkuKKnlZBpppy4GLVuXnVkSXq2Z2dkJeZbCVGTa1e5c6NqOfCeZ+nRiB1cmF3EoHQeO4d6g6IIU2uIGtQTgYGbO6mhv0PvJl+vU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699267237; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4uz818AY0/m+FRzGeIhGz1ZTqpxzLihnWApmCN46dps=; b=W8J/VsEU9W+/c4KiVvxDE6cQYiMiWSU6YxqUJHrYmKzDnQkjFpGltN4c2g8wAo8+6yblbOzzdIghBieHCCKtGciE7bHcPzKsSCdj01zwFITUOsfhn7bc4ajGjhxvCqZIXk5gddKFE2YMtpprteDgKdu7K81M9tynGbn7cg5nSL4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1699267237205119.04872075117441; Mon, 6 Nov 2023 02:40:37 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.627877.978737 (Exim 4.92) (envelope-from ) id 1qzx1g-00014j-F8; Mon, 06 Nov 2023 10:40:12 +0000 Received: by outflank-mailman (output) from mailman id 627877.978737; Mon, 06 Nov 2023 10:40:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qzx1g-00013Y-CJ; Mon, 06 Nov 2023 10:40:12 +0000 Received: by outflank-mailman (input) for mailman id 627877; Mon, 06 Nov 2023 10:40:11 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qzx1f-00010s-1h for xen-devel@lists.xenproject.org; Mon, 06 Nov 2023 10:40:11 +0000 Received: from casper.infradead.org (casper.infradead.org [2001:8b0:10b:1236::1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d9cf4d07-7c90-11ee-9b0e-b553b5be7939; Mon, 06 Nov 2023 11:40:07 +0100 (CET) Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qzx1P-005R1j-Rh; Mon, 06 Nov 2023 10:39:56 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.96.2 #2 (Red Hat Linux)) id 1qzx1Q-000qGL-0i; Mon, 06 Nov 2023 10:39:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: d9cf4d07-7c90-11ee-9b0e-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=4uz818AY0/m+FRzGeIhGz1ZTqpxzLihnWApmCN46dps=; b=fKwQs5UAJQKDc4KMhJikM8x0P+ jPOTGf+YxCgZTG/biDh3QzX3JwAbu0gE40tBY8XR/RZ3HilkTvWvdgtoMbVM/GryZUjrqPv/srYx4 +ipkc9VhfDcYvAyXEPUXUUHSwPPlvgV05kdutHUN0YQWlbfVFPhtzdPr9P3gzllPa+c2RQrgYl6xO 6BYbsvGDvWMmLVvsAho+MJkjTcjB/wbjsPkkpXi882fTxrvbre3s1QCQSJw92wKxWoLxH0GOWQ49U osQBPzD5cm4z9Xb9QrnOHQjCv0800KW3Xgu428Cxh5JoUgybYy4O1wohQagI+6cxYjmo5Ua7CiFYT qbjp+IOg==; From: David Woodhouse To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Stefano Stabellini , Anthony Perard , Paul Durrant , Kevin Wolf , Hanna Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcelo Tosatti , xen-devel@lists.xenproject.org, qemu-block@nongnu.org, kvm@vger.kernel.org Subject: [PULL 7/7] hw/xen: use correct default protocol for xen-block on x86 Date: Mon, 6 Nov 2023 10:39:55 +0000 Message-ID: <20231106103955.200867-8-dwmw2@infradead.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231106103955.200867-1-dwmw2@infradead.org> References: <20231106103955.200867-1-dwmw2@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-ZohoMail-DKIM: pass (identity @infradead.org) X-ZM-MESSAGEID: 1699267238562100007 Content-Type: text/plain; charset="utf-8" From: David Woodhouse Even on x86_64 the default protocol is the x86-32 one if the guest doesn't specifically ask for x86-64. Cc: qemu-stable@nongnu.org Fixes: b6af8926fb85 ("xen: add implementations of xen-block connect and dis= connect functions...") Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/block/xen-block.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index a07cd7eb5d..bfa53960c3 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -115,9 +115,13 @@ static void xen_block_connect(XenDevice *xendev, Error= **errp) return; } =20 - if (xen_device_frontend_scanf(xendev, "protocol", "%ms", - &str) !=3D 1) { - protocol =3D BLKIF_PROTOCOL_NATIVE; + if (xen_device_frontend_scanf(xendev, "protocol", "%ms", &str) !=3D 1)= { + /* x86 defaults to the 32-bit protocol even for 64-bit guests. */ + if (object_dynamic_cast(OBJECT(qdev_get_machine()), "x86-machine")= ) { + protocol =3D BLKIF_PROTOCOL_X86_32; + } else { + protocol =3D BLKIF_PROTOCOL_NATIVE; + } } else { if (strcmp(str, XEN_IO_PROTO_ABI_X86_32) =3D=3D 0) { protocol =3D BLKIF_PROTOCOL_X86_32; --=20 2.41.0