From nobody Wed May 8 18:44:55 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; 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; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1591977453; cv=none; d=zohomail.com; s=zohoarc; b=NpuP0wEU5yru8oLy6hdZ7XSR+DAJN+jlF8SQshFKpqMx+qEmVElZ72bjJttDGyQsmHAP33jZ6i98/uCABzVROxpsim+N9/kbmeCkhWB+dpw/SOiOV4OH2wIwF0gUMKAotrZbtLQB644teBa8KnqPgIIHjVT4l1njZOiM0P62SeU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591977453; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZdYwruGRbIzTJB2r3JjY34mmBiO3cxjFz0kGgDFfRe0=; b=QBl5FErw/NwKtdP6sGi+OEh7F3KOx8SvFWfbUANmy7Im8GVb8H50NYTmemryaFbLMC7nYsTQMw2tQaCQK9i5INenCoAf0U50F4/TiXKLIK8WYf7nWu3l4UpVctUVymPEF7++CSWuDpIo68JLlaXAiOGyZx37CWe8dTJZVm5lkE4= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1591977453867796.4972333615782; Fri, 12 Jun 2020 08:57:33 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3O-0006K5-96; Fri, 12 Jun 2020 15:57:14 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3N-0006K0-4q for xen-devel@lists.xenproject.org; Fri, 12 Jun 2020 15:57:13 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 60389534-acc5-11ea-b5e3-12813bfff9fa; Fri, 12 Jun 2020 15:57:12 +0000 (UTC) X-Inumbo-ID: 60389534-acc5-11ea-b5e3-12813bfff9fa Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: tJYIR2S3Ocd5uXt8pWAoShrj2UMDT+WR9oxPAsF9CJqVNZYh0HUpjT7joDzDm7OYui4jLzBkIr 5i/INQSZZUgypeKxultSdhU11yxeTufQkknSiDM8gRz0szZ4pLgdA/v1SqCCgOwEer3uslnldD cKbpI2joK5PNzfo2XsCh1ndozWh2TtA+sa6dVcqVkaMxrMQYCAWrOQntbkwGoEOe1goRKcu19Z YCT6b2yJtr/jCEUIBEK3H+yQZ3+X/1Xoe31c6xUGRIeUZkrxQPXyqESLrG6ywIwmQEuCOhjz4W Cis= X-SBRS: 2.7 X-MesageID: 20213493 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,503,1583211600"; d="scan'208";a="20213493" From: Roger Pau Monne To: Subject: [PATCH for-4.14 1/8] x86/hvm: fix vIO-APIC build without IRQ0_SPECIAL_ROUTING Date: Fri, 12 Jun 2020 17:56:33 +0200 Message-ID: <20200612155640.4101-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200612155640.4101-1-roger.pau@citrix.com> References: <20200612155640.4101-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Roger Pau Monne , Wei Liu , Jan Beulich , paul@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" pit_channel0_enabled needs to be guarded with IRQ0_SPECIAL_ROUTING since it's only used when the special handling of ISA IRQ 0 is enabled. No functional change. Signed-off-by: Roger Pau Monn=C3=A9 --- xen/arch/x86/hvm/vioapic.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index b87facb0e0..bd41036137 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -391,10 +391,12 @@ static void ioapic_inj_irq( vlapic_set_irq(target, vector, trig_mode); } =20 +#ifdef IRQ0_SPECIAL_ROUTING static inline int pit_channel0_enabled(void) { return pt_active(¤t->domain->arch.vpit.pt0); } +#endif =20 static void vioapic_deliver(struct hvm_vioapic *vioapic, unsigned int pin) { --=20 2.26.2 From nobody Wed May 8 18:44:55 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; 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; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1591977455; cv=none; d=zohomail.com; s=zohoarc; b=eG9bsu0eZ2bvIAdO1gfF3Kz4T+uQZPVh50ZYIhuUgX4M5qlojZBr86c/zPSh8NSDyqCBocBbeePcS1tW9EvuiV+zt2MnJuQbP9xXAlDZx4JFX5vUYPcVqdyNzcPeRkM7R5YhgLhCLw73EoXTj7GqLle/gavsme0vyXNHS/N+I4o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591977455; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=E6TS5AKSYe7uT4Z5IDLFl+tJmRukgk6N8L3WLLAz8X0=; b=em5VTfnlqEurFgM2KJDcygdZ4TNO+VF+ad+0iTa6ecxZZfqh9YkfXdFk3yZ42tO7+fPqtXjddrEXeh+U/LpBDG9W7ygDPg9/MYm1Q2ZjeziHmMfP8gkLIEx1rcH4a9Gs0YqnsN3MChs2P54q+z8bkREi4TxXcZ2z+XcnGL0KM4M= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1591977455300965.406319378583; Fri, 12 Jun 2020 08:57:35 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3T-0006KW-Hc; Fri, 12 Jun 2020 15:57:19 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3S-0006K0-3P for xen-devel@lists.xenproject.org; Fri, 12 Jun 2020 15:57:18 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 61d895d8-acc5-11ea-b5e3-12813bfff9fa; Fri, 12 Jun 2020 15:57:14 +0000 (UTC) X-Inumbo-ID: 61d895d8-acc5-11ea-b5e3-12813bfff9fa Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: K6m2NGmVcam+h7MTcp4Z4ANjw6IUgDn+vvI1B0j51XUYS3mmrM7fV9TTaqqfE+23htLnVcwEwU Ma81K7w7rsxqyOQ4bzlJq4jzSwX8tHTz3mNH8atqZV01hDCaiEwvM2r0R7jPAMvbI6i9m9xkbF vz89E0ANtkjP0NuY6ND9GVMjEqygCHPUfObjN3vBPVcnD8KN8SEPaVyusYUT1VDaQVPD8vyA/D 7B+9qsMe7KfEJYlrIkBZ+jHmnjvuByNSZLK15zbcAb+ajOMpWCn7ZmMU5SbwNhGA8HaZNBt0xN A9s= X-SBRS: 2.7 X-MesageID: 20213495 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,503,1583211600"; d="scan'208";a="20213495" From: Roger Pau Monne To: Subject: [PATCH for-4.14 2/8] x86/hvm: don't force vCPU 0 for IRQ 0 when using fixed destination mode Date: Fri, 12 Jun 2020 17:56:34 +0200 Message-ID: <20200612155640.4101-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200612155640.4101-1-roger.pau@citrix.com> References: <20200612155640.4101-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Roger Pau Monne , Wei Liu , Jan Beulich , paul@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" When the IO APIC pin mapped to the ISA IRQ 0 has been configured to use fixed delivery mode do not forcefully route interrupts to vCPU 0, as the OS might have setup those interrupts to be injected to a different vCPU, and injecting to vCPU 0 can cause the OS to miss such interrupts or errors to happen due to unexpected vectors being injected on vCPU 0. In order to fix remove such handling altogether for fixed destination mode pins and just inject them according to the data setup in the IO-APIC entry. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- xen/arch/x86/hvm/vioapic.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index bd41036137..67472e5934 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -445,26 +445,11 @@ static void vioapic_deliver(struct hvm_vioapic *vioap= ic, unsigned int pin) } =20 case dest_Fixed: - { -#ifdef IRQ0_SPECIAL_ROUTING - /* Do not deliver timer interrupts to VCPU !=3D 0 */ - if ( (irq =3D=3D hvm_isa_irq_to_gsi(0)) && pit_channel0_enabled() ) - { - if ( (v =3D d->vcpu ? d->vcpu[0] : NULL) !=3D NULL ) - ioapic_inj_irq(vioapic, vcpu_vlapic(v), vector, - trig_mode, delivery_mode); - } - else -#endif - { - for_each_vcpu ( d, v ) - if ( vlapic_match_dest(vcpu_vlapic(v), NULL, - 0, dest, dest_mode) ) - ioapic_inj_irq(vioapic, vcpu_vlapic(v), vector, - trig_mode, delivery_mode); - } + for_each_vcpu ( d, v ) + if ( vlapic_match_dest(vcpu_vlapic(v), NULL, 0, dest, dest_mod= e) ) + ioapic_inj_irq(vioapic, vcpu_vlapic(v), vector, trig_mode, + delivery_mode); break; - } =20 case dest_NMI: { --=20 2.26.2 From nobody Wed May 8 18:44:55 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; 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; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1591977458; cv=none; d=zohomail.com; s=zohoarc; b=CagvEkegbhbq6/pVWNA3df0OAYDYOaBi+j6skENPrreA0qATgstdq225osnINeOLNcfes7MJL8UK6rf/e5ahKnMlc3X7t6JYpsQEkc6ldPrXgP6/8v4I8w11pa1gRRp06ZDBXzYVShl6OJqYGkTv+edY9nz31lHH03TvPNnQ0eQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591977458; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eVuSlIm9XvcUDXSq3i1OX6+XbM7GhXwbMQF6aSINeG0=; b=ISFY1P6x0mA8GKD00wVRzREoy9/4wwH1HyHxfowJRRSKNFItId+ArwWUE2K9nPE6d/Z65hy+J8yuDL2LIYFHzMK75bv3UVznwyHQkzRCCRWy+T41tLMo1PoHBF6nrRxov2jVFd4CqJhNrBbt3NYMIACB5xE8e5dGcUHaH4jcDeY= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1591977458574696.7448928663653; Fri, 12 Jun 2020 08:57:38 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3Y-0006Mu-89; Fri, 12 Jun 2020 15:57:24 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3X-0006K0-3T for xen-devel@lists.xenproject.org; Fri, 12 Jun 2020 15:57:23 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 634bb10a-acc5-11ea-b5e3-12813bfff9fa; Fri, 12 Jun 2020 15:57:16 +0000 (UTC) X-Inumbo-ID: 634bb10a-acc5-11ea-b5e3-12813bfff9fa Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: T+j6pxRDudaou500LkfMDI+m1tD8yDtRWmcbpWv2muc/5y6LqO1oKjg10JVhhI+nWh1siuqw4T SkEu5nTveJxFL0LQE5TiK/L0AKvsm3fxWay0VHapaf71VXLThYEO2erGauASxXHkv/dm6CCVBy YjCb0+A77cIpUK/kc8/ROnp39OVyOsiYIISZrfaiqIl9gWfN/z7xVk6svDjAk0/vkuUtJP/V6Q 6VJkn5THB2g2ghE5d1w9tRnGCl8ud+iYEFA5xnD3/lQFo8s2SvQ4/x699FkOYEbhCo0VIAYQiY eIw= X-SBRS: 2.7 X-MesageID: 20265891 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,503,1583211600"; d="scan'208";a="20265891" From: Roger Pau Monne To: Subject: [PATCH for-4.14 3/8] x86/hvm: fix ISA IRQ 0 handling when set as lowest priority mode in IO APIC Date: Fri, 12 Jun 2020 17:56:35 +0200 Message-ID: <20200612155640.4101-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200612155640.4101-1-roger.pau@citrix.com> References: <20200612155640.4101-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Roger Pau Monne , Wei Liu , Jan Beulich , paul@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Lowest priority destination mode does allow the vIO APIC code to select a vCPU to inject the interrupt to, but the selected vCPU must be part of the possible destinations configured for such IO APIC pin. Fix the code in order to only force vCPU 0 if it's part of the listed destinations. Signed-off-by: Roger Pau Monn=C3=A9 --- xen/arch/x86/hvm/vioapic.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index 67472e5934..e1417cc6a7 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -422,12 +422,13 @@ static void vioapic_deliver(struct hvm_vioapic *vioap= ic, unsigned int pin) case dest_LowestPrio: { #ifdef IRQ0_SPECIAL_ROUTING - /* Force round-robin to pick VCPU 0 */ - if ( (irq =3D=3D hvm_isa_irq_to_gsi(0)) && pit_channel0_enabled() ) - { - v =3D d->vcpu ? d->vcpu[0] : NULL; - target =3D v ? vcpu_vlapic(v) : NULL; - } + struct vlapic *lapic0 =3D vcpu_vlapic(d->vcpu[0]); + + /* Force to pick vCPU 0 if part of the destination list */ + if ( (irq =3D=3D hvm_isa_irq_to_gsi(0)) && pit_channel0_enabled() = && + vlapic_match_dest(lapic0, NULL, 0, dest, dest_mode) && + vlapic_enabled(lapic0) ) + target =3D lapic0; else #endif target =3D vlapic_lowest_prio(d, NULL, 0, dest, dest_mode); --=20 2.26.2 From nobody Wed May 8 18:44:55 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; 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; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1591977465; cv=none; d=zohomail.com; s=zohoarc; b=Pqdge/HUcASBl3fxfaWmX/zgSQUY3iko84t9fNtyxHBAs4JeoqjiSb9URwpy4cFe8aQOQnbxmIEJFKzNT2KomQWto3tqY7Lbm+1+Zl6hsWiTcPG2YR0CyPoUBrqam/SptBJNu+yg8Fl54mqM4wq7Xf1OPjGdywVRaI8AYMMXq34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591977465; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9FszIdUiBvmSDiOPiJlZ98Ad+idfNanaCDCMUg6qavc=; b=eArbU8a6cb7zjMEZ7wZ/pJ6+bX5uGwd8fcqEIZTYJsHddgjekDRvpwz4J1Hqjvqd28/LGQKk/XCMyf7kII5fO2/MCT1l/qR23dcQJN/ciuNSo3wFssSJHJN6a8g1xKaPuocSE8MrqGdCxNv+lBWzX6Q/otGnwP4RJ5V6quw9AHk= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1591977465075247.35733448983115; Fri, 12 Jun 2020 08:57:45 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3e-0006RM-5z; Fri, 12 Jun 2020 15:57:30 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3c-0006K0-3i for xen-devel@lists.xenproject.org; Fri, 12 Jun 2020 15:57:28 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 64878f00-acc5-11ea-b5e3-12813bfff9fa; Fri, 12 Jun 2020 15:57:18 +0000 (UTC) X-Inumbo-ID: 64878f00-acc5-11ea-b5e3-12813bfff9fa Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: eRFtV+V4WhEVoVjHDyCMwnWyvoCyKAzxQJKaFS42Ybaa5AaK/TbaSitMe4MGEUWWVFlyq8X3S2 f3+EWI/Ns2FNkYx30rBE4krpVQyHehlYT6KJQKkGHr+4PVrfFz8oyU+OUlDW60iE2BLyBDcfSE B+L2Qe935SRk+mUjCIp9SCOOZIHERNKdjx+g32oADaAl4TqkDG+68q6P6SJxyWUdn7BW3xHCZ8 4yH5ysQPR3jylPczxBDa0cNVkMigf/nMSpg5E3cG3Kw+3C37tcK2PE52UEHn1QyOFSHBc8t/5l XZM= X-SBRS: 2.7 X-MesageID: 20213502 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,503,1583211600"; d="scan'208";a="20213502" From: Roger Pau Monne To: Subject: [PATCH for-4.14 4/8] x86/vpt: only try to resume timers belonging to enabled devices Date: Fri, 12 Jun 2020 17:56:36 +0200 Message-ID: <20200612155640.4101-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200612155640.4101-1-roger.pau@citrix.com> References: <20200612155640.4101-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Roger Pau Monne , Wei Liu , Jan Beulich , paul@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Check whether the emulated device is actually enabled before trying to resume the associated timers. Thankfully all those structures are zeroed at initialization, and since the devices are not enabled they are never populated, which triggers the pt->vcpu check at the beginning of pt_resume forcing an exit from the function. While there limit the scope of i and make it unsigned. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- xen/arch/x86/hvm/vpt.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/hvm/vpt.c b/xen/arch/x86/hvm/vpt.c index 47f2c2aa64..62c87867c5 100644 --- a/xen/arch/x86/hvm/vpt.c +++ b/xen/arch/x86/hvm/vpt.c @@ -636,14 +636,19 @@ static void pt_resume(struct periodic_time *pt) =20 void pt_may_unmask_irq(struct domain *d, struct periodic_time *vlapic_pt) { - int i; - if ( d ) { - pt_resume(&d->arch.vpit.pt0); - pt_resume(&d->arch.hvm.pl_time->vrtc.pt); - for ( i =3D 0; i < HPET_TIMER_NUM; i++ ) - pt_resume(&d->arch.hvm.pl_time->vhpet.pt[i]); + if ( has_vpit(d) ) + pt_resume(&d->arch.vpit.pt0); + if ( has_vrtc(d) ) + pt_resume(&d->arch.hvm.pl_time->vrtc.pt); + if ( has_vhpet(d) ) + { + unsigned int i; + + for ( i =3D 0; i < HPET_TIMER_NUM; i++ ) + pt_resume(&d->arch.hvm.pl_time->vhpet.pt[i]); + } } =20 if ( vlapic_pt ) --=20 2.26.2 From nobody Wed May 8 18:44:55 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; 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; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1591977456; cv=none; d=zohomail.com; s=zohoarc; b=Ut41FIVm53QwrBA/duy0PPOB8NfFN4vVEkNX4hIOtnylZuliKVer496snUScmbS03vRieRk3KfLhcGgTsmeuYgVMUW+QpF2jj6hSKID9z75cQ7TzmObHiFEo8EtKbzjIB1CEAplqaoAcI/M1V08zdzJdrzn9Sml8xAukv+2S03Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591977456; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZSHuhCwkPORLvPyv9HJ/8a9mpQxByQfFeoRuvvRjONs=; b=RVOyb7TkOFOyhVSnWW3r30sFpcq/VdUmlGjjjzOkxddhYifldYsmI4Xcs4DegKBVyLrX+d+mJCDGYdZdxKxmkaC/QmnYsD/0KZT48Q7tqUW8QDhX8uWYkvbPcS40yyBhUIN5RGEFJ51g9vvT5wajsoRN9451iuAJOXJCA51CWBw= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1591977456178389.93343797416856; Fri, 12 Jun 2020 08:57:36 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3X-0006ML-QN; Fri, 12 Jun 2020 15:57:23 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3W-0006Lr-4d for xen-devel@lists.xenproject.org; Fri, 12 Jun 2020 15:57:22 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6624bcfa-acc5-11ea-bb8b-bc764e2007e4; Fri, 12 Jun 2020 15:57:21 +0000 (UTC) X-Inumbo-ID: 6624bcfa-acc5-11ea-bb8b-bc764e2007e4 Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: rVAZ4lcV09ivW5keN6zjsXLA88pLfNsACRUUlIrMjY0Np5SExn6kfS/MQ39zwDOZc/r4NY9NQi oa+niKpIOqTzC7qZN+SdHYA8agDCLiZZGPM6p/clhXW7jR/ogaTT4LeqZL6jwMN6f0X9egi3xX EBrvU2B3oUdCMR+ayxGN9l0tO26jz9tz/Try8F0FaOeVOaVrv7OmH0/pQoCeuh0iUT458ogL35 vmqnKSRxO9V4I1UAIuY/JInBXcH6MKNCARP07by0SEtbDOK+xK6iubEoG8YEGOX4DDj2OV53qW Hts= X-SBRS: 2.7 X-MesageID: 19919135 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,503,1583211600"; d="scan'208";a="19919135" From: Roger Pau Monne To: Subject: [PATCH for-4.14 5/8] x86/hvm: only translate ISA interrupts to GSIs in virtual timers Date: Fri, 12 Jun 2020 17:56:37 +0200 Message-ID: <20200612155640.4101-6-roger.pau@citrix.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200612155640.4101-1-roger.pau@citrix.com> References: <20200612155640.4101-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Roger Pau Monne , Wei Liu , Jan Beulich , paul@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Only call hvm_isa_irq_to_gsi for ISA interrupts, interrupts originating from an IO APIC pin already use a GSI and don't need to be translated. I haven't observed any issues from this, but I think it's better to use it correctly. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- xen/arch/x86/hvm/vpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/vpt.c b/xen/arch/x86/hvm/vpt.c index 62c87867c5..6a975fc668 100644 --- a/xen/arch/x86/hvm/vpt.c +++ b/xen/arch/x86/hvm/vpt.c @@ -86,7 +86,7 @@ static int pt_irq_vector(struct periodic_time *pt, enum h= vm_intsrc src) return pt->irq; =20 isa_irq =3D pt->irq; - gsi =3D hvm_isa_irq_to_gsi(isa_irq); + gsi =3D pt->source =3D=3D PTSRC_isa ? hvm_isa_irq_to_gsi(isa_irq) : pt= ->irq; =20 if ( src =3D=3D hvm_intsrc_pic ) return (v->domain->arch.hvm.vpic[isa_irq >> 3].irq_base --=20 2.26.2 From nobody Wed May 8 18:44:55 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; 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; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1591977458; cv=none; d=zohomail.com; s=zohoarc; b=c19KjpGatpR03AWdMDD+6xfk+utO+vU+RX3o2KDG3fWla/dhVdvSE2NF8vC8Mg45cZuxT/GaorezA8AFYLkoNGtNmWVAn5FXSo7j4D7Au4vyHWWsH28XsaAHAp+Jbgzzs3IdseylJTM2WmIfn5L+C6kltlsz/JiJW5yI0k8uw4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591977458; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/EvKvyud5VtviVIN9huLXWwHQagFilex8hB4AeWw32Y=; b=Jyydl4A+wbk0P1g6NSSc+1u2cecePVlIRJ02W3In9zttKZwdEUrzJfDtSl5ZincMPJyqxnGNEOpp5Dvf5P+wtcJwD+9+ufJLhcB8AfH6nrJRxyAGunu62A/dXVzBnaOke1L5U2t38UseR7afs7MRr0roKox3peuNnSY5XctVvMg= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1591977458221409.4175708848743; Fri, 12 Jun 2020 08:57:38 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3Z-0006O6-IE; Fri, 12 Jun 2020 15:57:25 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3Y-0006Lr-Ea for xen-devel@lists.xenproject.org; Fri, 12 Jun 2020 15:57:24 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 677d62be-acc5-11ea-bca7-bc764e2007e4; Fri, 12 Jun 2020 15:57:23 +0000 (UTC) X-Inumbo-ID: 677d62be-acc5-11ea-bca7-bc764e2007e4 Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: TVD0ttfOnIiXGEtsNobNcfdCmiF8/oXhdeOHH8SAseli8/+/JIfIRE4czWVeWo0K2B3KqhvRSo f6gs7CY0ghaN+EPFqfJSpQm1t8OU5V9/eseebNUQUKH+jGKUsm8H59xaX4Wn7T/PXub7KCWClY XGCyFgzWysjFbkfGj8zG+GZiC8XnUl1rX5omH4G86iYV7MVzw5B4Qd4f/oKo/Xg1iYnXslYzt9 BIBRtMeZN3jbT5j8GFW/C/luI3bYbhy4pZ2BAfTfy9OOA7tVP+DVV4PwjDNOp48ZENHtepvKJm ODw= X-SBRS: 2.7 X-MesageID: 20157334 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,503,1583211600"; d="scan'208";a="20157334" From: Roger Pau Monne To: Subject: [PATCH for-4.14 6/8] x86/vpt: fix injection to remote vCPU Date: Fri, 12 Jun 2020 17:56:38 +0200 Message-ID: <20200612155640.4101-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200612155640.4101-1-roger.pau@citrix.com> References: <20200612155640.4101-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Roger Pau Monne , Wei Liu , Jan Beulich , paul@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" vpt timers are usually added to the per-vCPU list of the vCPU where they get setup, but depending on the timer source type that vCPU might be different than the one where the interrupt vector gets injected. For example the PIT timer use a PIC or IO-APIC pin in order to select the destination vCPU and vector, which might not match the vCPU they are configured from. If such a situation happens pt_intr_post won't be called, and thus the vpt will be left in a limbo where the next interrupt won't be scheduled. Fix this by generalizing the special handling done to IO-APIC level interrupts to be applied always when the destination vCPU of the injected vector is different from the vCPU where the vpt belongs to (ie: usually the one it's been configured from). A further improvement as noted in a comment added to the code might be to move the vpt so it's handled by the same vCPU where the vector gets injected. Signed-off-by: Roger Pau Monn=C3=A9 --- xen/arch/x86/hvm/vpt.c | 80 +++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/xen/arch/x86/hvm/vpt.c b/xen/arch/x86/hvm/vpt.c index 6a975fc668..52ad5b90a7 100644 --- a/xen/arch/x86/hvm/vpt.c +++ b/xen/arch/x86/hvm/vpt.c @@ -358,59 +358,59 @@ int pt_update_irq(struct vcpu *v) * interrupt delivery case. Otherwise return -1 to do nothing. */ vlapic_set_irq(vcpu_vlapic(v), irq, 0); - pt_vector =3D irq; - break; + return irq; =20 case PTSRC_isa: hvm_isa_irq_deassert(v->domain, irq); if ( platform_legacy_irq(irq) && vlapic_accept_pic_intr(v) && v->domain->arch.hvm.vpic[irq >> 3].int_output ) - hvm_isa_irq_assert(v->domain, irq, NULL); + pt_vector =3D hvm_isa_irq_assert(v->domain, irq, NULL); else - { pt_vector =3D hvm_isa_irq_assert(v->domain, irq, vioapic_get_v= ector); - /* - * hvm_isa_irq_assert may not set the corresponding bit in vIRR - * when mask field of IOAPIC RTE is set. Check it again. - */ - if ( pt_vector < 0 || !vlapic_test_irq(vcpu_vlapic(v), pt_vect= or) ) - pt_vector =3D -1; - } + + if ( pt_vector < 0 ) + return pt_vector; + break; =20 case PTSRC_ioapic: pt_vector =3D hvm_ioapic_assert(v->domain, irq, level); - if ( pt_vector < 0 || !vlapic_test_irq(vcpu_vlapic(v), pt_vector) ) - { - pt_vector =3D -1; - if ( level ) + if ( pt_vector < 0 ) + return pt_vector; + + break; + } + + ASSERT(pt_vector >=3D 0); + if ( !vlapic_test_irq(vcpu_vlapic(v), pt_vector) ) + { + time_cb *cb =3D NULL; + void *cb_priv; + + /* + * Vector has been injected to a different vCPU, call pt_irq_fired= and + * execute the callback, since the destination vCPU(s) won't call + * pt_intr_post for it. + * + * TODO: move this vpt to one of the vCPUs where the vector gets + * injected. + */ + spin_lock(&v->arch.hvm.tm_lock); + /* Make sure the timer is still on the list. */ + list_for_each_entry ( pt, &v->arch.hvm.tm_list, list ) + if ( pt =3D=3D earliest_pt ) { - /* - * Level interrupts are always asserted because the pin as= sert - * count is incremented regardless of whether the pin is m= asked - * or the vector latched in IRR, so also execute the callb= ack - * associated with the timer. - */ - time_cb *cb =3D NULL; - void *cb_priv; - - spin_lock(&v->arch.hvm.tm_lock); - /* Make sure the timer is still on the list. */ - list_for_each_entry ( pt, &v->arch.hvm.tm_list, list ) - if ( pt =3D=3D earliest_pt ) - { - pt_irq_fired(v, pt); - cb =3D pt->cb; - cb_priv =3D pt->priv; - break; - } - spin_unlock(&v->arch.hvm.tm_lock); - - if ( cb !=3D NULL ) - cb(v, cb_priv); + pt_irq_fired(v, pt); + cb =3D pt->cb; + cb_priv =3D pt->priv; + break; } - } - break; + spin_unlock(&v->arch.hvm.tm_lock); + + if ( cb !=3D NULL ) + cb(v, cb_priv); + + pt_vector =3D -1; } =20 return pt_vector; --=20 2.26.2 From nobody Wed May 8 18:44:55 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; 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; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1591977464; cv=none; d=zohomail.com; s=zohoarc; b=X5lIpcdy3AW2gh9v26i3MMohGRhbjaekFuefEb0ijA+gBI9UCumwQ3mt/1ebr0uUfWoP2/1OMHJipWsze5X5IMl7CjhDpkQJm9F54EoJlW+evvvRIM4ZPSSHoaTv+UC2GnGFAkxHw6ebmCF4/TbjnLnw0F1TdZWog9MBQxyfPgs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591977464; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OS7ydjXecbpPAeCdxCAUdOKJmGS4Bi/atY5S8AYr15Y=; b=DKKbDsd+VGLjP2cThXC4GK6VmKoUdJxxWv+UUOqc4jEOQFvAenU0dDIB9skA6ubnEuFQkCsq6/qPZAl/rCxKWJof8IWrgBOXrCn5HMNzl8CLQA1oWBuJ/ieJlPGcjk3K+mCKlllyAmGYjZpYZDWycndUtMUDGDDtCzBNpZll3VA= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1591977464192140.05826842232182; Fri, 12 Jun 2020 08:57:44 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3c-0006QK-T6; Fri, 12 Jun 2020 15:57:28 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3b-0006Lr-7v for xen-devel@lists.xenproject.org; Fri, 12 Jun 2020 15:57:27 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 68f94766-acc5-11ea-bb8b-bc764e2007e4; Fri, 12 Jun 2020 15:57:26 +0000 (UTC) X-Inumbo-ID: 68f94766-acc5-11ea-bb8b-bc764e2007e4 Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: e9FMHbQmSlccb0Jggp39FUntV+V/2kY/Ao2hQtNDe/d3ibdKdm+2PCrv+MVa30FpSoq8nCZeyF utxdsI6K51kThM8vjkvV9DuV4cRHN2qFugt9dKv+i0FpLJYEfZ7zCp4wlF1dtLzC1zo0MtASSa RWHL67SkdL4x4mgB/KYbiuNcmyKc1MRIdiIBk4W29SjBYsyLQS/Ci4IGO58uHHHB+9fzAgnTee vbj5DA3vBx8KjhQ109vzwa1cptO6srROKY5cduAcAJGlkmRWtq1nwsJvU56XKVLWtQ4SgfT0GX 2Yc= X-SBRS: 2.7 X-MesageID: 20688217 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,503,1583211600"; d="scan'208";a="20688217" From: Roger Pau Monne To: Subject: [PATCH for-4.14 7/8] x86/hvm: add hardware domain support to hvm_isa_irq_to_gsi Date: Fri, 12 Jun 2020 17:56:39 +0200 Message-ID: <20200612155640.4101-8-roger.pau@citrix.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200612155640.4101-1-roger.pau@citrix.com> References: <20200612155640.4101-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Roger Pau Monne , Wei Liu , Jan Beulich , paul@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The current function has the ISA IRQ 0 hardcoded to GSI 2 for HVM domUs. Allow such function to also be used by the hardware domain by taking into account the ACPI interrupt overwrites in order to get the correct ISA to GSI mappings. This requires passing a domain parameter to the helper, since it's not guaranteed to always be called with current being the destination vCPU. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- xen/arch/x86/hvm/irq.c | 20 +++++++++++++++++--- xen/arch/x86/hvm/vioapic.c | 2 +- xen/arch/x86/hvm/vpic.c | 7 +++++-- xen/arch/x86/hvm/vpt.c | 5 +++-- xen/arch/x86/io_apic.c | 16 ++++++++-------- xen/include/asm-x86/hvm/irq.h | 2 +- xen/include/asm-x86/io_apic.h | 3 +++ 7 files changed, 38 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c index fd02cf2e8d..6cbea63f4c 100644 --- a/xen/arch/x86/hvm/irq.c +++ b/xen/arch/x86/hvm/irq.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -212,12 +213,25 @@ void hvm_gsi_deassert(struct domain *d, unsigned int = gsi) spin_unlock(&d->arch.hvm.irq_lock); } =20 +unsigned int hvm_isa_irq_to_gsi(const struct domain *d, unsigned int irq) +{ + int pin, apic; + + if ( !is_hardware_domain(d) ) + return irq ?: 2; + + pin =3D io_apic_find_isa_irq_pin(irq, mp_INT); + apic =3D io_apic_find_isa_irq_apic(irq, mp_INT); + + return (pin < 0 || apic < 0) ? irq : (io_apic_gsi_base(apic) + pin); +} + int hvm_isa_irq_assert(struct domain *d, unsigned int isa_irq, int (*get_vector)(const struct domain *d, unsigned int gsi)) { struct hvm_irq *hvm_irq =3D hvm_domain_irq(d); - unsigned int gsi =3D hvm_isa_irq_to_gsi(isa_irq); + unsigned int gsi =3D hvm_isa_irq_to_gsi(d, isa_irq); int vector =3D -1; =20 ASSERT(isa_irq <=3D 15); @@ -240,7 +254,7 @@ void hvm_isa_irq_deassert( struct domain *d, unsigned int isa_irq) { struct hvm_irq *hvm_irq =3D hvm_domain_irq(d); - unsigned int gsi =3D hvm_isa_irq_to_gsi(isa_irq); + unsigned int gsi =3D hvm_isa_irq_to_gsi(d, isa_irq); =20 ASSERT(isa_irq <=3D 15); =20 @@ -754,7 +768,7 @@ static int irq_load_isa(struct domain *d, hvm_domain_co= ntext_t *h) * This relies on the PCI IRQ state being loaded first. */ for ( irq =3D 0; platform_legacy_irq(irq); irq++ ) if ( test_bit(irq, &hvm_irq->isa_irq.i) ) - hvm_irq->gsi_assert_count[hvm_isa_irq_to_gsi(irq)]++; + hvm_irq->gsi_assert_count[hvm_isa_irq_to_gsi(d, irq)]++; =20 return 0; } diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index e1417cc6a7..34bec715b7 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -425,7 +425,7 @@ static void vioapic_deliver(struct hvm_vioapic *vioapic= , unsigned int pin) struct vlapic *lapic0 =3D vcpu_vlapic(d->vcpu[0]); =20 /* Force to pick vCPU 0 if part of the destination list */ - if ( (irq =3D=3D hvm_isa_irq_to_gsi(0)) && pit_channel0_enabled() = && + if ( (irq =3D=3D hvm_isa_irq_to_gsi(d, 0)) && pit_channel0_enabled= () && vlapic_match_dest(lapic0, NULL, 0, dest, dest_mode) && vlapic_enabled(lapic0) ) target =3D lapic0; diff --git a/xen/arch/x86/hvm/vpic.c b/xen/arch/x86/hvm/vpic.c index 61f4b6784c..0ce3371a80 100644 --- a/xen/arch/x86/hvm/vpic.c +++ b/xen/arch/x86/hvm/vpic.c @@ -230,6 +230,8 @@ static void vpic_ioport_write( } else { + struct domain *currd =3D current->domain; + /* OCW2 */ cmd =3D val >> 5; switch ( cmd ) @@ -260,8 +262,9 @@ static void vpic_ioport_write( /* Release lock and EOI the physical interrupt (if any). */ vpic_update_int_output(vpic); vpic_unlock(vpic); - hvm_dpci_eoi(current->domain, - hvm_isa_irq_to_gsi((addr >> 7) ? (irq|8) : ir= q), + hvm_dpci_eoi(currd, + hvm_isa_irq_to_gsi(currd, (addr >> 7) ? (irq = | 8) + : irq), NULL); return; /* bail immediately */ case 6: /* Set Priority */ diff --git a/xen/arch/x86/hvm/vpt.c b/xen/arch/x86/hvm/vpt.c index 52ad5b90a7..1b3f902106 100644 --- a/xen/arch/x86/hvm/vpt.c +++ b/xen/arch/x86/hvm/vpt.c @@ -86,7 +86,8 @@ static int pt_irq_vector(struct periodic_time *pt, enum h= vm_intsrc src) return pt->irq; =20 isa_irq =3D pt->irq; - gsi =3D pt->source =3D=3D PTSRC_isa ? hvm_isa_irq_to_gsi(isa_irq) : pt= ->irq; + gsi =3D pt->source =3D=3D PTSRC_isa ? hvm_isa_irq_to_gsi(v->domain, is= a_irq) + : pt->irq; =20 if ( src =3D=3D hvm_intsrc_pic ) return (v->domain->arch.hvm.vpic[isa_irq >> 3].irq_base @@ -128,7 +129,7 @@ static int pt_irq_masked(struct periodic_time *pt) if ( !(pic_imr & (1 << (pt->irq & 7))) && vlapic_accept_pic_intr(v= ) ) return 0; =20 - gsi =3D hvm_isa_irq_to_gsi(pt->irq); + gsi =3D hvm_isa_irq_to_gsi(v->domain, pt->irq); } =20 /* Fallthrough to check if the interrupt is masked on the IO APIC. */ diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index 878ee5192d..1c000e8f76 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -608,7 +608,7 @@ static int find_irq_entry(int apic, int pin, int type) /* * Find the pin to which IRQ[irq] (ISA) is connected */ -static int __init find_isa_irq_pin(int irq, int type) +int io_apic_find_isa_irq_pin(int irq, int type) { int i; =20 @@ -628,7 +628,7 @@ static int __init find_isa_irq_pin(int irq, int type) return -1; } =20 -static int __init find_isa_irq_apic(int irq, int type) +int io_apic_find_isa_irq_apic(int irq, int type) { int i; =20 @@ -1306,8 +1306,8 @@ static void __init enable_IO_APIC(void) * the i8259 probably is not connected the ioapic but give the * mptable a chance anyway. */ - i8259_pin =3D find_isa_irq_pin(0, mp_ExtINT); - i8259_apic =3D find_isa_irq_apic(0, mp_ExtINT); + i8259_pin =3D io_apic_find_isa_irq_pin(0, mp_ExtINT); + i8259_apic =3D io_apic_find_isa_irq_apic(0, mp_ExtINT); /* Trust the MP table if nothing is setup in the hardware */ if ((ioapic_i8259.pin =3D=3D -1) && (i8259_pin >=3D 0)) { printk(KERN_WARNING "ExtINT not setup in hardware but reported by = MP table\n"); @@ -1834,8 +1834,8 @@ static void __init unlock_ExtINT_logic(void) struct IO_APIC_route_entry entry0, entry1; unsigned char save_control, save_freq_select; =20 - pin =3D find_isa_irq_pin(8, mp_INT); - apic =3D find_isa_irq_apic(8, mp_INT); + pin =3D io_apic_find_isa_irq_pin(8, mp_INT); + apic =3D io_apic_find_isa_irq_apic(8, mp_INT); if ( pin =3D=3D -1 || apic =3D=3D -1 ) return; =20 @@ -1913,8 +1913,8 @@ static void __init check_timer(void) /*timer_ack =3D 1;*/ /*enable_8259A_irq(irq_to_desc(0));*/ =20 - pin1 =3D find_isa_irq_pin(0, mp_INT); - apic1 =3D find_isa_irq_apic(0, mp_INT); + pin1 =3D io_apic_find_isa_irq_pin(0, mp_INT); + apic1 =3D io_apic_find_isa_irq_apic(0, mp_INT); pin2 =3D ioapic_i8259.pin; apic2 =3D ioapic_i8259.apic; =20 diff --git a/xen/include/asm-x86/hvm/irq.h b/xen/include/asm-x86/hvm/irq.h index 532880d497..aa034bc73c 100644 --- a/xen/include/asm-x86/hvm/irq.h +++ b/xen/include/asm-x86/hvm/irq.h @@ -100,7 +100,7 @@ struct hvm_irq { #define hvm_domain_irq(d) ((d)->arch.hvm.irq) #define hvm_irq_size(cnt) offsetof(struct hvm_irq, gsi_assert_count[cnt]) =20 -#define hvm_isa_irq_to_gsi(isa_irq) ((isa_irq) ? : 2) +unsigned int hvm_isa_irq_to_gsi(const struct domain *d, unsigned int irq); =20 /* Check/Acknowledge next pending interrupt. */ struct hvm_intack hvm_vcpu_has_pending_irq(struct vcpu *v); diff --git a/xen/include/asm-x86/io_apic.h b/xen/include/asm-x86/io_apic.h index e006b2b8dd..1c63d1df56 100644 --- a/xen/include/asm-x86/io_apic.h +++ b/xen/include/asm-x86/io_apic.h @@ -205,4 +205,7 @@ unsigned highest_gsi(void); int ioapic_guest_read( unsigned long physbase, unsigned int reg, u32 *pval= ); int ioapic_guest_write(unsigned long physbase, unsigned int reg, u32 pval); =20 +int io_apic_find_isa_irq_pin(int irq, int type); +int io_apic_find_isa_irq_apic(int irq, int type); + #endif --=20 2.26.2 From nobody Wed May 8 18:44:55 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; 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; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1591977466; cv=none; d=zohomail.com; s=zohoarc; b=CJOyOeWVaQ6a+deFBNZ5QZrkN41wBLTnQuuyHMoCMvCPOGgsg6ODNRgDr1XKfIN55CQxZxuUPKefsCSx4ljiwL2L1Of9khm9jJYedGX62IQLZsdV8zevFrMvEqOTVzrC9qMdhHIdSuAVPDLfIeYYOIIl3h0r806HpGXZvvHiKxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591977466; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zdwNVvv/uZSDiw3r+aXCsaRtm7Kn5rzl0pi2LfPZ06U=; b=Dv3t5bTBZZQ22YEm+pHNa8V2zYm198i2qC3vPe7zkDl9YoEsZ07zHmvOHtiZU2IP3wPiL8b2Qf9GfS7pbGnm2bg8yieM3LZUL5fnvZ11mgCmII9tOXezEusvUCG1m2qB8sAuYEYm1eLv0ENhdqu2EGW+JEPVNnbNwGQSUNYRax4= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1591977466446848.7189277339486; Fri, 12 Jun 2020 08:57:46 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3h-0006Tn-Fb; Fri, 12 Jun 2020 15:57:33 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jjm3g-0006Lr-3G for xen-devel@lists.xenproject.org; Fri, 12 Jun 2020 15:57:32 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6a382f84-acc5-11ea-bb8b-bc764e2007e4; Fri, 12 Jun 2020 15:57:28 +0000 (UTC) X-Inumbo-ID: 6a382f84-acc5-11ea-bb8b-bc764e2007e4 Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: nk10nRa/UyvEBV7y95MSrL+xvq0BM4oOMyFXxhDkS9COEmbBEEVgBpmDzpoDGprQ6qVnQJMxYY cdUWfwWeyEOknClS0zJXDeJAzX56V9SNb1bAzIY5rfyY9cQPkTd2aCcG5iXeR3h4MGJKkDX/RZ 0oaEMHruPAp2CU86Sx0lGU+UmTq18Z7ngvJzl6ZVwphRqHagPxu6Y0tjkAK+t0ErfuBFmZvxX8 fPjqdMhEY53CPyxatGglmG0Owi38yqd5+pIyGEiCb78J5koTs2qVW8lL1K3u3uexy8P/X3YCkK lpA= X-SBRS: 2.7 X-MesageID: 20688223 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,503,1583211600"; d="scan'208";a="20688223" From: Roger Pau Monne To: Subject: [PATCH for-4.14 8/8] x86/hvm: enable emulated PIT for PVH dom0 Date: Fri, 12 Jun 2020 17:56:40 +0200 Message-ID: <20200612155640.4101-9-roger.pau@citrix.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200612155640.4101-1-roger.pau@citrix.com> References: <20200612155640.4101-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Roger Pau Monne , Wei Liu , Jan Beulich , paul@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Some video BIOS require a PIT in order to work properly, hence classic PV dom0 gets partial access to the physical PIT as long as it's not in use by Xen. Since PVH dom0 is built on top of HVM support, there's already an emulated PIT implementation available for use. Tweak the emulated PIT code so it injects interrupts directly into the vIO-APIC if the legacy PIC (i8259) is disabled. Make sure the GSI used matches the ISA IRQ 0 in the likely case there's an interrupt overwrite in the MADT ACPI table. Finally prevent the passthrough of the GSI that belongs to the PIT, since interrupts will be generated by the emulated PIT instead of the physical one. Signed-off-by: Roger Pau Monn=C3=A9 --- xen/arch/x86/domain.c | 5 +++-- xen/arch/x86/emul-i8254.c | 12 +++++++++--- xen/arch/x86/hvm/vioapic.c | 9 ++++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index fee6c3931a..dc0b4c2284 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -512,7 +512,8 @@ static bool emulation_flags_ok(const struct domain *d, = uint32_t emflags) if ( is_hvm_domain(d) ) { if ( is_hardware_domain(d) && - emflags !=3D (X86_EMU_VPCI | X86_EMU_LAPIC | X86_EMU_IOAPIC) ) + emflags !=3D (X86_EMU_VPCI | X86_EMU_LAPIC | X86_EMU_IOAPIC | + X86_EMU_PIT) ) return false; if ( !is_hardware_domain(d) && emflags !=3D (X86_EMU_ALL & ~X86_EMU_VPCI) && @@ -578,7 +579,7 @@ int arch_domain_create(struct domain *d, =20 emflags =3D config->arch.emulation_flags; =20 - if ( is_hardware_domain(d) && is_pv_domain(d) ) + if ( is_hardware_domain(d) ) emflags |=3D XEN_X86_EMU_PIT; =20 if ( emflags & ~XEN_X86_EMU_ALL ) diff --git a/xen/arch/x86/emul-i8254.c b/xen/arch/x86/emul-i8254.c index 73be4188ad..5aef0fe852 100644 --- a/xen/arch/x86/emul-i8254.c +++ b/xen/arch/x86/emul-i8254.c @@ -168,6 +168,7 @@ static void pit_load_count(PITState *pit, int channel, = int val) u32 period; struct hvm_hw_pit_channel *s =3D &pit->hw.channels[channel]; struct vcpu *v =3D vpit_vcpu(pit); + const struct domain *d =3D v ? v->domain : NULL; =20 ASSERT(spin_is_locked(&pit->lock)); =20 @@ -190,14 +191,18 @@ static void pit_load_count(PITState *pit, int channel= , int val) case 3: /* Periodic timer. */ TRACE_2D(TRC_HVM_EMUL_PIT_START_TIMER, period, period); - create_periodic_time(v, &pit->pt0, period, period, 0, pit_time_fir= ed,=20 + create_periodic_time(v, &pit->pt0, period, period, + has_vpic(d) ? 0 : hvm_isa_irq_to_gsi(d, 0), + pit_time_fired, &pit->count_load_time[channel], false); break; case 1: case 4: /* One-shot timer. */ TRACE_2D(TRC_HVM_EMUL_PIT_START_TIMER, period, 0); - create_periodic_time(v, &pit->pt0, period, 0, 0, pit_time_fired, + create_periodic_time(v, &pit->pt0, period, 0, + has_vpic(d) ? 0 : hvm_isa_irq_to_gsi(d, 0), + pit_time_fired, &pit->count_load_time[channel], false); break; default: @@ -455,7 +460,8 @@ void pit_reset(struct domain *d) { TRACE_0D(TRC_HVM_EMUL_PIT_STOP_TIMER); destroy_periodic_time(&pit->pt0); - pit->pt0.source =3D PTSRC_isa; + ASSERT(has_vpic(d) || has_vioapic(d)); + pit->pt0.source =3D has_vpic(d) ? PTSRC_isa : PTSRC_ioapic; } =20 spin_lock(&pit->lock); diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index 34bec715b7..8b95e4412f 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -268,7 +268,14 @@ static void vioapic_write_redirent( =20 spin_unlock(&d->arch.hvm.irq_lock); =20 - if ( is_hardware_domain(d) && unmasked ) + if ( is_hardware_domain(d) && unmasked && + /* + * A PVH dom0 can have an emulated PIT that should respect any + * interrupt overwrites found in the ACPI MADT table, so we need = to + * check to which GSI the ISA IRQ 0 is mapped in order to prevent + * identity mapping it. + */ + (!has_vpit(d) || gsi !=3D hvm_isa_irq_to_gsi(d, 0)) ) { /* * NB: don't call vioapic_hwdom_map_gsi while holding hvm.irq_lock --=20 2.26.2