From nobody Sat Apr 27 04:34:28 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=fail; 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=1595869589; cv=none; d=zohomail.com; s=zohoarc; b=MlmvoLldD4WFAZIb/4G2psLdLfRpniB9+ZYyDmFfHbsoLvhH1ULxuTBHWVj8fAGymXHV4x5aRnBHoN34ht7cA8jJU5QR81BsfZfLaYPXbV8GLOPZ+IGoXQ2/2AbZLVWZzLjetIVCglFhH4X8LsV2hPo2QBNzqPOkzQtcH3XEnHg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595869589; 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=ZL4c3yIKEvQVZwHEHudomdoyL2TgHZOuDiM0FwY1ul8=; b=RkzZSCEA5P08cVdyqoTTup0wUMqBtKLdIYrcn7RWKQMgZqg/k0nja1Ghh1aQmXkwa6xRXfeZvzGdxs30oOvKiqi3wyCYM894iXDCXsosXQfhTby262i9cGocrboGzKYlubfHIaRvRhZfoZ/te8yY7tpd2ytE9XgDNs3NkMxaxeA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1595869589062305.9028205415882; Mon, 27 Jul 2020 10:06:29 -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 1k06ZZ-0006qP-5r; Mon, 27 Jul 2020 17:05:57 +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 1k06ZX-0006qK-Dz for xen-devel@lists.xenproject.org; Mon, 27 Jul 2020 17:05:55 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 6dc71d84-d02b-11ea-a7b1-12813bfff9fa; Mon, 27 Jul 2020 17:05:53 +0000 (UTC) X-Inumbo-ID: 6dc71d84-d02b-11ea-a7b1-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1595869553; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Up0va2PHL+5mIou+IC4Y87q4ak8L8JXy1B8SeD1Qmuo=; b=H/6TthRiqEImLObwWiNtt7rj7iwF8BAlcLZNBs3K0NP5EGL3p3H9RVYb 90yDbpYkf8UpZnuVqWfI/W1NtFth4HM64O1bKYJphkUctRURBK2EaWecv VY3B/lky/VmmXtvdv4HTbTjagTAwge3x8wZEDSId5M79Lg4BiGw+jwKa0 A=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: 3NyJ2mKrVC5cGwM/IZpfLlAZeMKYPgseDdHEdrtodAuhDkLYDbi6eSn0FW/qhovh51HuBK0BGf MTJbaOvYa9NIe1o5Ry3qTfE72NiTRpA9PcEO0SPSm63l52XSGSpEHLIcPg0Ej1BrtcpWy7VHWq wr00foe33T3x+7UtxwGQf9PYmMFHAhb5HI03Aj2xB5FQrzt8uOQjvNS+4UNekypK1gUuOcfVFy rfqCoJmIMWFNU+UH65802BZYo4QvLQqOtCWpfReV/yO/UAHxqmHcV3Rrdo4RaDzx5HskJ7yMTk nQE= X-SBRS: 2.7 X-MesageID: 23469011 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.75,402,1589256000"; d="scan'208";a="23469011" From: Roger Pau Monne To: Subject: [PATCH v2 1/5] x86/hvm: fix vIO-APIC build without IRQ0_SPECIAL_ROUTING Date: Mon, 27 Jul 2020 19:05:35 +0200 Message-ID: <20200727170539.55798-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727170539.55798-1-roger.pau@citrix.com> References: <20200727170539.55798-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 , Wei Liu , Jan Beulich , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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. However such helper being a single line it's better to just inline it directly in vioapic_deliver where it's used. No functional change. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v1: - Remove pit_channel0_enabled altogether. --- xen/arch/x86/hvm/vioapic.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index b87facb0e0..b00037ea87 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -391,11 +391,6 @@ static void ioapic_inj_irq( vlapic_set_irq(target, vector, trig_mode); } =20 -static inline int pit_channel0_enabled(void) -{ - return pt_active(¤t->domain->arch.vpit.pt0); -} - static void vioapic_deliver(struct hvm_vioapic *vioapic, unsigned int pin) { uint16_t dest =3D vioapic->redirtbl[pin].fields.dest_id; @@ -421,7 +416,7 @@ static void vioapic_deliver(struct hvm_vioapic *vioapic= , unsigned int pin) { #ifdef IRQ0_SPECIAL_ROUTING /* Force round-robin to pick VCPU 0 */ - if ( (irq =3D=3D hvm_isa_irq_to_gsi(0)) && pit_channel0_enabled() ) + if ( (irq =3D=3D hvm_isa_irq_to_gsi(0)) && pt_active(&d->arch.vpit= .pt0) ) { v =3D d->vcpu ? d->vcpu[0] : NULL; target =3D v ? vcpu_vlapic(v) : NULL; @@ -446,7 +441,7 @@ static void vioapic_deliver(struct hvm_vioapic *vioapic= , unsigned int pin) { #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 ( (irq =3D=3D hvm_isa_irq_to_gsi(0)) && pt_active(&d->arch.vpit= .pt0) ) { if ( (v =3D d->vcpu ? d->vcpu[0] : NULL) !=3D NULL ) ioapic_inj_irq(vioapic, vcpu_vlapic(v), vector, --=20 2.27.0 From nobody Sat Apr 27 04:34:28 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=fail; 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=1595869588; cv=none; d=zohomail.com; s=zohoarc; b=JRjOplxKcmm4ZLBcpulU041u0FDsFl92rVRiZ71U+GR5KR3QTyv8WgzUqyYqTVZjaFHSO3Y9siPOSF23/WZKno73grZ9Bj0UNv3+mUhQJExC0nE+tVtJt67xUPbXmqDSmxDt6gsppsznd8fBjQX5jPCCMNui1Ef4mVE4nUdw3B4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595869588; 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=MDjfXWSFLaPY1d+sXPpNfLruRKN61vo/QD2rp7B54v4=; b=gMv2m34US9l079kX4ntNcQbG2QdxcN6Nn8sPtIorDkA+zpCwqtUMkIGovRbQJZ+3UNu3G8jwbhOVmaODztHsKCd9HxcTk+PIkprysd58PUmD7aCKxp8gDkg9X+pk5UVrduHCLQQ3bDq95wiibGhWHE2dfqIwOuJEyqFuHkcnqBI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1595869588980819.3174248620702; Mon, 27 Jul 2020 10:06:28 -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 1k06Zc-0006r0-Hu; Mon, 27 Jul 2020 17:06:00 +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 1k06Zc-0006qK-7U for xen-devel@lists.xenproject.org; Mon, 27 Jul 2020 17:06:00 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 6f1647b4-d02b-11ea-a7b1-12813bfff9fa; Mon, 27 Jul 2020 17:05:55 +0000 (UTC) X-Inumbo-ID: 6f1647b4-d02b-11ea-a7b1-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1595869555; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9BA2HuY2XfFbO7rOd5htwjlC8tyCla4CvMSRDDan0zM=; b=hvHbfeSU5EghLHXL0RE4MfWuUjtKOxBqV8nRz33X9lmu942Mmx3W0MQl NXSNgPZoG7VmOzuF64RdN7Q7qTHkngnSu3b1W22L8Z+I9RJ4zNuHVTsCf kfx8cpwXaxW0jwegLsYdCQ9jEyLHhSyb0+eRoQtwiRbgVaW0cNNPWVRtZ c=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: Cn+VFplSK30A9ca43AE3YL9md4WrnPn8Hd8a+AWow0raSKjK6EGyBpPdmEAToQ+UOrkXTHUPwr 0xkgbKh5R/r6OQ/Yt/bZtjewBYXoXMkehllRyFl9N4vJKukDB4zyoGt/tzExtPRE/tf7Q8rHGY 3YzHsq7bBlo0iHYFpkLbALQbdYVKqCC9hreyMI9J1GIiy93wKQdv+uGJiVpsLw4MNlXozw2oJQ PkGLS+mHAkzhteDah9IoEOTqheAA83On1BKqcsuj9MA/yrEcKnHO/rm9UlBHNIGm8MblLga+J4 sF0= X-SBRS: 2.7 X-MesageID: 23610699 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.75,402,1589256000"; d="scan'208";a="23610699" From: Roger Pau Monne To: Subject: [PATCH v2 2/5] x86/hvm: don't force vCPU 0 for IRQ 0 when using fixed destination mode Date: Mon, 27 Jul 2020 19:05:36 +0200 Message-ID: <20200727170539.55798-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727170539.55798-1-roger.pau@citrix.com> References: <20200727170539.55798-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 , Wei Liu , Jan Beulich , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 b00037ea87..123191db75 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -438,26 +438,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)) && pt_active(&d->arch.vpit= .pt0) ) - { - 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.27.0 From nobody Sat Apr 27 04:34:28 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=fail; 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=1595869588; cv=none; d=zohomail.com; s=zohoarc; b=Wrkwm8USq+c4o+hTcJjiRLXTs1n333zwUn1jDgXU2VA8DGso3D1o1cNhn+s8URlxanULaaDHnVdwOIBYMzjQc6aLJql4AWvq4ILwW9T5kBnPvdkiRWIPfaVvN1BfKMarT+bXvJHG7LfmknEaZ8/FDNLIKCcgHAKXllktt7CJSLg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595869588; 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=Hfl8/Q4w8lY+fuhBr3WkefO0PWdGIEjccRRn4tS5yYY=; b=SAfgf+MaX57fSkE2EvDhbWkhnc376dMTxLj6og4oo8/i4hc5twaoNx7vJHoiXyJAKScAHB4GUy9MyySbsM1QnZUlxSOAdq2cpCnsEXAz8rpEpLMOf2lP0kgsEm1Hki7tZQ9rUi4HNwSQ9B3NbTzBUxYHbWFkzuGBhe+RlNqA1GA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1595869588310719.2785068874191; Mon, 27 Jul 2020 10:06:28 -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 1k06Zi-0006sp-4h; Mon, 27 Jul 2020 17:06:06 +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 1k06Zh-0006qK-7w for xen-devel@lists.xenproject.org; Mon, 27 Jul 2020 17:06:05 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 7062a6ee-d02b-11ea-a7b1-12813bfff9fa; Mon, 27 Jul 2020 17:05:58 +0000 (UTC) X-Inumbo-ID: 7062a6ee-d02b-11ea-a7b1-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1595869559; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=saiDrgvFoGPsvHXwjrhIy9joLoxVibLVmDC510j+ikM=; b=TZ9nwE2DH71zn7T3PV+juoG9+N6zGMOToH/bDr1Oe5n3I9yhxf3tk36L gTgxeg/0OiucXSacAWIdnq1UOKZDQAFzbRczDhnNwVYfG11c/Ux98XPDd 0VAJ/wsafXs4XCd+r6KadlZfDI648LPPSF8k5VTbwzXVKkMZajQzXMV+D k=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: NgwrdsjxFH/xaOvgM3zcURG7VC2t47NoPT9WCA+NYDz0pOkGAEBir4ieksjaq60g1CaMvh66Yc oHyamu8lkusknUi3B9lV/UGWODQqIYOFWylWXp1/pdtO+rLYjcAPmds6eJ/Gs2WcWr6dVrgJ9Z iOsAU7lTqtT3B82XPtDrf5tFl00hAwGTTHY98J4VTTgMZXczofvtAXHUqbvQ1ZLCQg6LB6Z7xS 5zMM4luNKAbPztVazylyRJbRpcjAe02awLB5yTeBzVHN1JpuGZpjMGi0spnS6/wxgcJpjNmNc4 IL4= X-SBRS: 2.7 X-MesageID: 23613409 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.75,402,1589256000"; d="scan'208";a="23613409" From: Roger Pau Monne To: Subject: [PATCH v2 3/5] x86/hvm: fix ISA IRQ 0 handling when set as lowest priority mode in IO APIC Date: Mon, 27 Jul 2020 19:05:37 +0200 Message-ID: <20200727170539.55798-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727170539.55798-1-roger.pau@citrix.com> References: <20200727170539.55798-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 , Wei Liu , Jan Beulich , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 --- Changes since v1: - Add a comment regarding the vlapic_enabled check. --- NB: I haven't added a fallback to vCPU 0 if no destination is found, as it's not how real hardware behaves. I think we should assume that no user have relied on this bogus Xen behavior for IRQ 0 interrupt injection. --- xen/arch/x86/hvm/vioapic.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index 123191db75..67d4a6237f 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -415,12 +415,14 @@ 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)) && pt_active(&d->arch.vpit= .pt0) ) - { - 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)) && pt_active(&d->arch.vpit= .pt0) && + vlapic_match_dest(lapic0, NULL, 0, dest, dest_mode) && + /* Mimic the vlapic_enabled check found in vlapic_lowest_prio= . */ + vlapic_enabled(lapic0) ) + target =3D lapic0; else #endif target =3D vlapic_lowest_prio(d, NULL, 0, dest, dest_mode); --=20 2.27.0 From nobody Sat Apr 27 04:34:28 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=fail; 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=1595869589; cv=none; d=zohomail.com; s=zohoarc; b=A7ubgfPNNlAjMY1WDpVn/+lXf7cMTdT2hY3X22P1dqvk7KtCIwGpmfY1Lh4ZBKMn6aOoruTJq7vf5dLVV5CT4K7AovjRg3qzTeTk7jY25vS2RXJFP49MuMr2EUSDXXJxh9K4fixl+pgbqhCg+ajpq7RGqJ8vudHndxKPdCcEfNs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595869589; 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=zc/Qh7dHPVW9vXRILO6nHeg5S8fjCdvneUV8GBSE/TU=; b=Wqq84jNN91Bwo4KBeDogRYa11U+Sa3pky7dx4L8CzdS0Y/IkMOSSlebagzhk4OOo+XPG0svtuegemr950OZx5raefpStPWAbRAB2vnbeGHXZhg0mfZ/Ua6/6GYEHCGvHzibIj6tudv2d3wlYU2K3bR2uO5XrZRb22QaJK2Rpv6o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1595869589653329.1908160328031; Mon, 27 Jul 2020 10:06:29 -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 1k06Zn-0006uz-Ef; Mon, 27 Jul 2020 17:06:11 +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 1k06Zm-0006qK-89 for xen-devel@lists.xenproject.org; Mon, 27 Jul 2020 17:06:10 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 71a883fc-d02b-11ea-a7b1-12813bfff9fa; Mon, 27 Jul 2020 17:06:00 +0000 (UTC) X-Inumbo-ID: 71a883fc-d02b-11ea-a7b1-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1595869560; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+UrtDnq8F4eKIjcjNHn8k54mlLah4ENCqM3HBW0OiIE=; b=gRRbpzVUawqj5TxHdGBpiyB8+CjxxNXjIzboe1SnfvadfwT5M2EsUUwh Kjg1TfG5DXv03E9UiHCLg5gwGE+PuJPipuXRFkvSaDxs/90gC5UqXrK+Z cEQ+E8J8ALjVCfibQqSvUmp39D1ufBhZjR5qnExFxGBL6n75swfD9TgyU s=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: 2dtOmp8c2Nwrd+LUQ4J9RPBxhaEZfrC856jhgoQ+7Bw5E1CyN4gbGYR9OyI4x1PcqlfV58Rzqv 3BYXLDz/Ea9OY0JQoggv3zA2atPYZ4/eDbCaHnUWPnMKbItTX+9PXbzrDbNwarHC5a6JGoSYAx ula5+FWpHzijYGbT0T7FlaRq/o37xxIxQfcvkOcVEsVZcjOL/NJW//1i4FwzODJ1sqz9KMRvFz cPShm+jK6lXrdXtwg916Ne5pDATSeQQdQMXceGKkZia2/X8QR2tv6kFoIVuxJnwHwC7GCsXlNQ U/s= X-SBRS: 2.7 X-MesageID: 24144262 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.75,402,1589256000"; d="scan'208";a="24144262" From: Roger Pau Monne To: Subject: [PATCH v2 4/5] x86/vpt: only try to resume timers belonging to enabled devices Date: Mon, 27 Jul 2020 19:05:38 +0200 Message-ID: <20200727170539.55798-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727170539.55798-1-roger.pau@citrix.com> References: <20200727170539.55798-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 , Wei Liu , Jan Beulich , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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.27.0 From nobody Sat Apr 27 04:34:28 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=fail; 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=1595869588; cv=none; d=zohomail.com; s=zohoarc; b=ONx9QjIehsRNHr0NmB3ze2nFzPKCWG8RjwcwEJfGqdXibHwbHFE66WmTTrgv3sbXQhbNQyoKoe94h9m9sp8vEXjdOS7LY5cH1M8OOBSQhQ8EPLefIagVmGvl3r/+eX99WNPaHLIJRtQ8oF28SPkARfaQUAju/3KA6ZebGObq47c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595869588; 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=0jz9wIvDZuiZID0JIXeJ9zg+pUU1nefbB1xiWUaCZyg=; b=JvKFpEzUmlKXziCUY1gAPJ/eucaW0wAmAjzyLrwfxXvJNmwRffef2tIFhMxH1Zn4Lo2RhKb8R9oE6dplheq0TD7juguNnam7LA39bLgwEnnxfk2w/YqVJTJQIFvvFFPW2yfGFd+fLPV5s7x5OH4sHqkIu3Q1n8xRjdVoVpp4tBw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1595869588507332.4022966269516; Mon, 27 Jul 2020 10:06:28 -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 1k06Zf-0006s7-Rz; Mon, 27 Jul 2020 17:06:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k06Ze-0006s0-Vf for xen-devel@lists.xenproject.org; Mon, 27 Jul 2020 17:06:03 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 72e92cc6-d02b-11ea-8ad9-bc764e2007e4; Mon, 27 Jul 2020 17:06:02 +0000 (UTC) X-Inumbo-ID: 72e92cc6-d02b-11ea-8ad9-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1595869562; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dFV/5IIieWSOyYLpuMea63bzinjrU9UWYgTJ7LkynSg=; b=QN/r0ryMllnh41ZJKvznUKbIbis/5iIlLxAEBhsmugf+38kyo0ZAJPbD Ivv9H5uc2zmJ3IxCwawAQJ3QD3BMFpf1cL2Yz3KCORa/4DAKhu6bNbbhQ XMY6Z6XYyWzDBaArK3wTZwW+WRi3uxeYxG1lOd+vBU59emlFmlwf5rVwU M=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: yX0Ucm7OmM9ftMh86I8MenFv19Jl15favDXMS1gmwiOs726c9E7XWQ6DfS6NhCbf7Yx5kJlvun ICR0PpJB8CmlbWKP8a2CS8m4x4dRvg9TZATeU3UTnouR72F0u4sS++/mxdQ+m9xRGC+WuANi63 ANe5dWZrpj/Ur3UEuG74BTf4G92WneT9hdmOqi4hVFVnKIAeX9V+bbrWXru+MyXroPqGn9HBU0 1lKGaH01YRIvIe7PhSUGzPYHchfzMuzPzCmw6J7WYHBbkpEGiJ7vDxc2s9Pk76huPiTWGQypCD 35k= X-SBRS: 2.7 X-MesageID: 23469017 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.75,402,1589256000"; d="scan'208";a="23469017" From: Roger Pau Monne To: Subject: [PATCH v2 5/5] x86/hvm: only translate ISA interrupts to GSIs in virtual timers Date: Mon, 27 Jul 2020 19:05:39 +0200 Message-ID: <20200727170539.55798-6-roger.pau@citrix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727170539.55798-1-roger.pau@citrix.com> References: <20200727170539.55798-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 , Wei Liu , Jan Beulich , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 --- Changes since v1: - Delay the setting of gsi a bit. --- 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..c68bbd1558 100644 --- a/xen/arch/x86/hvm/vpt.c +++ b/xen/arch/x86/hvm/vpt.c @@ -86,13 +86,13 @@ static int pt_irq_vector(struct periodic_time *pt, enum= hvm_intsrc src) return pt->irq; =20 isa_irq =3D pt->irq; - gsi =3D hvm_isa_irq_to_gsi(isa_irq); =20 if ( src =3D=3D hvm_intsrc_pic ) return (v->domain->arch.hvm.vpic[isa_irq >> 3].irq_base + (isa_irq & 7)); =20 ASSERT(src =3D=3D hvm_intsrc_lapic); + gsi =3D pt->source =3D=3D PTSRC_isa ? hvm_isa_irq_to_gsi(isa_irq) : pt= ->irq; vector =3D vioapic_get_vector(v->domain, gsi); if ( vector < 0 ) { --=20 2.27.0