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=-17.3 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,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 132C9C433DB for ; Thu, 21 Jan 2021 16:04:18 +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 9F13E22DFA for ; Thu, 21 Jan 2021 16:04:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F13E22DFA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.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.72240.129920 (Exim 4.92) (envelope-from ) id 1l2cR9-0003Sc-PL; Thu, 21 Jan 2021 16:03:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 72240.129920; Thu, 21 Jan 2021 16:03:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l2cR9-0003SV-MN; Thu, 21 Jan 2021 16:03:55 +0000 Received: by outflank-mailman (input) for mailman id 72240; Thu, 21 Jan 2021 16:03:54 +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 1l2cR8-0003SQ-8o for xen-devel@lists.xenproject.org; Thu, 21 Jan 2021 16:03:54 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id fe541fe7-9d99-4e03-9c59-1fc4fc3b3259; Thu, 21 Jan 2021 16:03:53 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3D97DAB7A; Thu, 21 Jan 2021 16:03:52 +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: fe541fe7-9d99-4e03-9c59-1fc4fc3b3259 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611245032; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mi2MdZQNOR03OElIIfIrrDl73zzZ3xuiTT6s5PI7Uc0=; b=X7/OO9VPH1q1dMpFZ0J4M16v+zltXlMNrsNcnufDjN9YDUrCwCmdhkrFpJIaE/YuXytgx5 KitRkViGuyiKBhZZNc2OWttvAndAFfsUkHaXcoi1X5ZA+LMEADk7qWCEpVYEuPikKo3mfx 4kdZE7JRwQcJORTdNmWdQRz1FmX8PV8= Subject: Re: [PATCH v2 1/4] x86/vioapic: check IRR before attempting to inject interrupt after EOI To: Roger Pau Monne Cc: Andrew Cooper , Wei Liu , xen-devel@lists.xenproject.org References: <20210115142820.35224-1-roger.pau@citrix.com> <20210115142820.35224-2-roger.pau@citrix.com> From: Jan Beulich Message-ID: <1cdc469f-5ccf-6c0c-157c-31abca5f089d@suse.com> Date: Thu, 21 Jan 2021 17:03:51 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210115142820.35224-2-roger.pau@citrix.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 15.01.2021 15:28, Roger Pau Monne wrote: > In vioapic_update_EOI the irq_lock will be dropped in order to forward > the EOI to the dpci handler, so there's a window between clearing IRR > and checking if the line is asserted where IRR can change behind our > back. > > Fix this by checking whether IRR is set before attempting to inject a > new interrupt. > > Fixes: 06e3f8f2766 ('vt-d: Do dpci eoi outside of irq_lock.') > Signed-off-by: Roger Pau Monné It's fine this way, so Reviewed-by: Jan Beulich but how about a slightly different change: > --- a/xen/arch/x86/hvm/vioapic.c > +++ b/xen/arch/x86/hvm/vioapic.c > @@ -526,7 +526,7 @@ void vioapic_update_EOI(struct domain *d, u8 vector) > } > > if ( (ent->fields.trig_mode == VIOAPIC_LEVEL_TRIG) && > - !ent->fields.mask && > + !ent->fields.mask && !ent->fields.remote_irr && > hvm_irq->gsi_assert_count[vioapic->base_gsi + pin] ) > { > ent->fields.remote_irr = 1; The check is only needed if the lock was dropped intermediately, which happens only conditionally. So an alternative would seem to be if ( is_iommu_enabled(d) ) { spin_unlock(&d->arch.hvm.irq_lock); hvm_dpci_eoi(d, vioapic->base_gsi + pin, ent); spin_lock(&d->arch.hvm.irq_lock); if ( ent->fields.remote_irr ) continue; } in the code immediately above. Thoughts? Jan