From patchwork Tue Jan 5 18:31:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12000115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AC5FC433DB for ; Tue, 5 Jan 2021 18:32:20 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C72D322D57 for ; Tue, 5 Jan 2021 18:32:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C72D322D57 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.62155.109891 (Exim 4.92) (envelope-from ) id 1kwr7e-0002oG-C6; Tue, 05 Jan 2021 18:31:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 62155.109891; Tue, 05 Jan 2021 18:31:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kwr7e-0002o9-8Q; Tue, 05 Jan 2021 18:31:58 +0000 Received: by outflank-mailman (input) for mailman id 62155; Tue, 05 Jan 2021 18:31: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 1kwr7d-0002o4-0M for xen-devel@lists.xenproject.org; Tue, 05 Jan 2021 18:31:57 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 8c0c2e5c-7379-456d-880c-5d52ea4f8a0d; Tue, 05 Jan 2021 18:31:55 +0000 (UTC) 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 Sender: "Xen-devel" X-Inumbo-ID: 8c0c2e5c-7379-456d-880c-5d52ea4f8a0d DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1609871515; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=3/JwtcNJKz/PpTsIYBbTkjh8Ohkphe/ShnTPF4YhdWQ=; b=cVmWZTmKbDWAjJIrrC1q1JPUP7kNwCmbp/8X6DmXo+VvjxSWzBtjvsIf DTE3kCNbsp1avak/7+9MnGgxLlibpJUlVkOp0CCYnOnfrs/ydAnM9jZCF yWvbvvEyYNHydgOE4VgaLPif9rp9b2RY/lYqAoDeH4vK9sftNBECTnwJh w=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: roztjlgBBJ0w6PMRoVjF+Pqi7H6WyAMIJidnyJgU22jcNN1NxJ8tlCJMh24HH1thsCbB+cRCuE LfOfdu31FknRA5Lo/wmlpvR23H2Wq5cXDS3GDHc48gKLyHU9u/1EiOT7nnf439USKIGBfenL/V RO6wngPMe7Mn8H3/hVMcpBkZyoMr3SpMys+ry3CgKEaGhHMoYiWjET8pKpwsuuBy97RirXKGpf XMu6qyUJL1PGB6oDFYouWn4G/BAZykrU8mnuaOXuecisWd7AuTdDFaaI0HGIfpJzPaJz+6/Xgz K+E= X-SBRS: 5.2 X-MesageID: 34442218 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.78,477,1599537600"; d="scan'208";a="34442218" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IiitC5D2o50gD+oCDydou3LllJeUA3iA3clVvgx5swKyYGNjPmRxvySbLV9HhThn85fdf6OKXoXoM0aLZVSn9HpMOp/d/+l0v2vI1wj9IbO2dxm5hI7TPGnJ7e+orZX72BJhz0wkV+YIjdyWDqKHwVqQRTyhPvpWqxWC7IC5cywmLoubc9UH0tp+75T7IMf2caQqzo4jOacpiC31EdPS56DrB1826NLqFei4FTnWhs9MUMu3GYjjWZgMqvzW9VmC39W6aKUtJojZXwMsyHgDBAwsU0g8/Q9dYUGSH5F4wltJVUGlzrv4YDV+8jyDpQ8r3rKlDII28uUGOi6REAx+cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CjHgdWgPnLPu/MxYHbPlytIJkzEAREeuae78TUct0gE=; b=LTHNIl4JBMnHyeOlffAeBnMyjYhjpshCttOKSktQCKoZLdF6hgNoX/XYUzkrCLlnSkEnm9OlJfzwbz4IaxCD+dDRO9k5vNUz6tvWzOZKUTTYcsyDsjOB2vrlB5772aHMXq4Sb1qVpQh9EBVyNS2+OmAul2KlJ7QhufvFaNkG6QihxpT/hSsceFgM5wHswa79yKgs7HHiAe8LZmXY/D2jw++1+r/d11uW41SFWei/dlZZXFOWhqLBPdAMKtiuyXeIMxNJDM8EW32z3C0j9BBJ2vqe5e2hy4ihMzQSW0LpOrAfNswdT7dfUrDATjtG7uXktLIoDTFXU06ImhKGJurBsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CjHgdWgPnLPu/MxYHbPlytIJkzEAREeuae78TUct0gE=; b=xWFtgqiUmM0Bq78D+4xGPiqMGnb+a1g5DcVHOmT0tJzDejStP9YgYmROd5Oh95C+ME3DQSmHnXFuv8f1T3/MfJzi0nbdXmL/luMzsYzkGKmw92krYuV8zBhFJrwZz3mZfCk+HzrIJ5xNfc1XSTzzUI3hWto4GpCmd8El4ejF7nE= From: Roger Pau Monne To: CC: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu , Paul Durrant Subject: [PATCH] x86/dpci: EOI interrupt regardless of it's masking status Date: Tue, 5 Jan 2021 19:31:43 +0100 Message-ID: <20210105183143.94547-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.29.2 X-ClientProxiedBy: MRXP264CA0011.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:15::23) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bd2a0616-04d4-4817-2893-08d8b1a82c04 X-MS-TrafficTypeDiagnostic: DS7PR03MB5607: X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BCm/kMDsEFRZIji2gIcWcksrm823OIjGuaLTpK4PcBeF4JB7P402iRqMrFXthku0dULXYYf/iMCv3eOlsUXIkW24u/Wuef0chYYpEvFRtGrr0heDUyC5ByL2fYZg9wGJFBmfCCjunM8EnnVVu6ysshW0DUXwVl4n9jT7zTkL1kqDqm7X20y5yeW6Uce2pQcGucBnvFKOc7JC23bXOqigkE60ue/BZom09W1mCHVtD+JzoLFGyO/GjPObIDvklXMeQo28mxA+3oMw5SBBpgf+w9IJ8dG4aHaiyGrntyyZ3YmkbUVHmaPaqMgNULeIZ8TvqZaEqIr8pkutD6RqB+WNXAv5+eroAU/IFR0LUVy+DBJBltslkFvJZLzqROMLAJ8ZbFcEBsIumB/cv63hE8W0YOPFp4EOj22BBo7Zw1Rka31+DZmuWQF8iDRxu5Yhf0/S X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(366004)(136003)(376002)(39860400002)(346002)(8676002)(2906002)(36756003)(956004)(26005)(83380400001)(6496006)(186003)(478600001)(66946007)(316002)(16526019)(66556008)(6666004)(6486002)(8936002)(5660300002)(66476007)(6916009)(1076003)(86362001)(54906003)(2616005)(4326008)(26953001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?tu0OVer5TP5cqYpYsoWbMQuuA1680o?= =?utf-8?q?EwgmQt16xSmi95e3bFgWkBZFsu4+pSd/oJflAwmxjkQ6fD/jhlJOcjdmakmHhauBy?= =?utf-8?q?UCHRpADFqnD8aphBNGeqo/X+MWKd28fAPKZQnw/c9wHdIm0sXQSJq7guvdWZf2IEc?= =?utf-8?q?nvqeLCgZc7EvDp7fGpsG0uaEsNaXHO2x1ulorlstPmXaPjk5Un1OxjsHOYHHg14Br?= =?utf-8?q?8O+5MNHwCCW9wY34/R2W5yNfSS5NDXGaNqu6tWozDBUcMqCNRHVKDCdNePkWt2udI?= =?utf-8?q?lXwOxJGhwQtgVOdfo3thahJVQpTbh1arC0V9fDvSCehvvOEhwCvJMbyF0MLwdi3c3?= =?utf-8?q?1zoHUN64MICP3m86SsjAPweLjCuoOtrdN6PENLJ01OwSSMP5P6Th4g23CsNXm832P?= =?utf-8?q?tMjQfZAxs6uOCO2PBu7DX/y3gkfDXev/5leZ9vAwgrDIxgS3TlmGdKeuVgf2+O5J9?= =?utf-8?q?IqsOOOIWMhqJlXvH6ZZx4s0lq9VB7IHsMPRZQX4pkc3SFjjOzqXcX02eFM+LkC4Nt?= =?utf-8?q?JsrKiL8veVQfHuwWrgOOpMq5PdWrYW3MyFuGnQ0tFuWw98DZEzj0tdhyTuTCk+UyL?= =?utf-8?q?lsFGnYW0aWw1xQOQbdkphAshxCHokXXqt0I7ZyLgUbY4mcgi6VH+tScip63DOtH5t?= =?utf-8?q?zZYEJCxjuBsj/lad/QPnzaUlQU9LlHxB36qW1tNtdWA0dZAXU+HIQIYxPxdEgstix?= =?utf-8?q?O18yXLqgOOXCInpBHMDu8PKa6ntdQVCtb+N84Loez5mxSocEQhg7EE9AQxN2yJxfG?= =?utf-8?q?kMw4GqoT7zvH+tva0d4tlfg96GaFP74wUDcSb1E4hwQneIuobbneKdxw82RYx8r1p?= =?utf-8?q?jzhor2Z/GNEfdZ2wlPAVxweVyrMi+gds2tcGm6ufXPhkFZsAGjImqqBVx35ypvSZL?= =?utf-8?q?wQtIdjqvMc/fcnejabHliM7JGdo0SFSNKmlYluEtsLnNu4t/eiEC2kwGhMaskCr7d?= =?utf-8?q?sjNS09WSPMH2Cq275+Q?= X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2021 18:31:52.2912 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-Network-Message-Id: bd2a0616-04d4-4817-2893-08d8b1a82c04 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZMDrbXN9VkM7lbppiJeGEdQnK/ZQ2qOQavn/S7IJa9OKqJSUaC6MTFJvjzj7heQovgdTmtJGDEN4RltBL1bPZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB5607 X-OriginatorOrg: citrix.com Modify hvm_pirq_eoi to always EOI the interrupt if required, instead of not doing such EOI if the interrupt is routed through the vIO-APIC and the entry is masked at the time the EOI is performed. Further unmask of the vIO-APIC pin won't EOI the interrupt, and thus the guest OS has to wait for the timeout to expire and the automatic EOI to be performed. This allows to simplify the helpers and drop the vioapic_redir_entry parameter from all of them. Fixes: ccfe4e08455 ('Intel vt-d specific changes in arch/x86/hvm/vmx/vtd.') Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Kind of RFC, I've been trying to figure out how this was supposed to work, and couldn't find any reason why the EOI is not performed if the interrupt is masked on the emulated IO-APIC. I might be missing something, but relying on the EOI timeout in that case seems wrong. --- xen/arch/x86/hvm/vioapic.c | 2 +- xen/arch/x86/hvm/vpic.c | 3 +-- xen/drivers/passthrough/x86/hvm.c | 21 ++++++++------------- xen/include/asm-x86/hvm/io.h | 3 +-- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index 7c462a44d4..eb6c143f74 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -521,7 +521,7 @@ void vioapic_update_EOI(struct domain *d, u8 vector) if ( is_iommu_enabled(d) ) { spin_unlock(&d->arch.hvm.irq_lock); - hvm_dpci_eoi(d, vioapic->base_gsi + pin, ent); + hvm_dpci_eoi(d, vioapic->base_gsi + pin); spin_lock(&d->arch.hvm.irq_lock); } diff --git a/xen/arch/x86/hvm/vpic.c b/xen/arch/x86/hvm/vpic.c index 3cf12581e9..c1c1de7fd0 100644 --- a/xen/arch/x86/hvm/vpic.c +++ b/xen/arch/x86/hvm/vpic.c @@ -263,8 +263,7 @@ static void vpic_ioport_write( vpic_update_int_output(vpic); vpic_unlock(vpic); hvm_dpci_eoi(current->domain, - hvm_isa_irq_to_gsi((addr >> 7) ? (pin | 8) : pin), - NULL); + hvm_isa_irq_to_gsi((addr >> 7) ? (pin | 8) : pin)); return; /* bail immediately */ case 6: /* Set Priority */ vpic->priority_add = (val + 1) & 7; diff --git a/xen/drivers/passthrough/x86/hvm.c b/xen/drivers/passthrough/x86/hvm.c index 41cfa2e200..edc8059518 100644 --- a/xen/drivers/passthrough/x86/hvm.c +++ b/xen/drivers/passthrough/x86/hvm.c @@ -950,8 +950,7 @@ static void hvm_dirq_assist(struct domain *d, struct hvm_pirq_dpci *pirq_dpci) spin_unlock(&d->event_lock); } -static void hvm_pirq_eoi(struct pirq *pirq, - const union vioapic_redir_entry *ent) +static void hvm_pirq_eoi(struct pirq *pirq) { struct hvm_pirq_dpci *pirq_dpci; @@ -968,7 +967,6 @@ static void hvm_pirq_eoi(struct pirq *pirq, * since interrupt is still not EOIed */ if ( --pirq_dpci->pending || - (ent && ent->fields.mask) || !pt_irq_need_timer(pirq_dpci->flags) ) return; @@ -977,19 +975,17 @@ static void hvm_pirq_eoi(struct pirq *pirq, } static void __hvm_dpci_eoi(struct domain *d, - const struct hvm_girq_dpci_mapping *girq, - const union vioapic_redir_entry *ent) + const struct hvm_girq_dpci_mapping *girq) { struct pirq *pirq = pirq_info(d, girq->machine_gsi); if ( !hvm_domain_use_pirq(d, pirq) ) hvm_pci_intx_deassert(d, girq->device, girq->intx); - hvm_pirq_eoi(pirq, ent); + hvm_pirq_eoi(pirq); } -static void hvm_gsi_eoi(struct domain *d, unsigned int gsi, - const union vioapic_redir_entry *ent) +static void hvm_gsi_eoi(struct domain *d, unsigned int gsi) { struct pirq *pirq = pirq_info(d, gsi); @@ -998,11 +994,10 @@ static void hvm_gsi_eoi(struct domain *d, unsigned int gsi, return; hvm_gsi_deassert(d, gsi); - hvm_pirq_eoi(pirq, ent); + hvm_pirq_eoi(pirq); } -void hvm_dpci_eoi(struct domain *d, unsigned int guest_gsi, - const union vioapic_redir_entry *ent) +void hvm_dpci_eoi(struct domain *d, unsigned int guest_gsi) { const struct hvm_irq_dpci *hvm_irq_dpci; const struct hvm_girq_dpci_mapping *girq; @@ -1013,7 +1008,7 @@ void hvm_dpci_eoi(struct domain *d, unsigned int guest_gsi, if ( is_hardware_domain(d) ) { spin_lock(&d->event_lock); - hvm_gsi_eoi(d, guest_gsi, ent); + hvm_gsi_eoi(d, guest_gsi); goto unlock; } @@ -1030,7 +1025,7 @@ void hvm_dpci_eoi(struct domain *d, unsigned int guest_gsi, goto unlock; list_for_each_entry ( girq, &hvm_irq_dpci->girq[guest_gsi], list ) - __hvm_dpci_eoi(d, girq, ent); + __hvm_dpci_eoi(d, girq); unlock: spin_unlock(&d->event_lock); diff --git a/xen/include/asm-x86/hvm/io.h b/xen/include/asm-x86/hvm/io.h index 558426b772..9453b9b2b7 100644 --- a/xen/include/asm-x86/hvm/io.h +++ b/xen/include/asm-x86/hvm/io.h @@ -118,8 +118,7 @@ bool handle_mmio_with_translation(unsigned long gla, unsigned long gpfn, struct npfec); bool handle_pio(uint16_t port, unsigned int size, int dir); void hvm_interrupt_post(struct vcpu *v, int vector, int type); -void hvm_dpci_eoi(struct domain *d, unsigned int guest_irq, - const union vioapic_redir_entry *ent); +void hvm_dpci_eoi(struct domain *d, unsigned int guest_irq); void msix_write_completion(struct vcpu *); #ifdef CONFIG_HVM