From nobody Fri Nov 29 04:51: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=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1648664287; cv=none; d=zohomail.com; s=zohoarc; b=UyjguHKvthSf6oNH6qwv0FfeulOsJ97pt+2HrLMw5kcOFfZZ/DYVMdfzT9ltxaPyclpqaeZ9xZVasWCc0xI7LQDvM0uAL77vlzrbdNzvIIB7iWEJk7hVG74t8VkpdnoaNHZnFysiTZzj+eL88nOaEW4J6mK0uEkWxVk0Hj7yaRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648664287; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=ZCIuaw/P3XMLRkUNQuqL8M82sLjVQz3hz9QA3xFRvLU=; b=NayO017ieWgyrkxRdJ14ljX2jOntjFnik4xI4dswGQCl6kPxDnctHxi/pBjCH6Gcp3i82UeL8JMHNsAPxE9cMjVx8UoZ4aEjOIOnb4OLJXOJX+FcgOwOi7ObJorMLhGo67pf5apQDzcRl/zGaqMUU3znmBS7Ayqf+saNto4H1OA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1648664287774427.1810832049481; Wed, 30 Mar 2022 11:18:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.296469.504677 (Exim 4.92) (envelope-from ) id 1nZct7-0002RH-6v; Wed, 30 Mar 2022 18:17:45 +0000 Received: by outflank-mailman (output) from mailman id 296469.504677; Wed, 30 Mar 2022 18:17:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nZct7-0002R5-3R; Wed, 30 Mar 2022 18:17:45 +0000 Received: by outflank-mailman (input) for mailman id 296469; Wed, 30 Mar 2022 18:17:43 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nZct5-0001M9-Ib for xen-devel@lists.xenproject.org; Wed, 30 Mar 2022 18:17:43 +0000 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [2607:f8b0:4864:20::734]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b085af41-b055-11ec-8fbc-03012f2f19d4; Wed, 30 Mar 2022 20:17:42 +0200 (CEST) Received: by mail-qk1-x734.google.com with SMTP id k125so17371415qkf.0 for ; Wed, 30 Mar 2022 11:17:42 -0700 (PDT) Received: from pm2-ws13.praxislan02.com ([2001:470:8:67e:ba27:ebff:fee8:ce27]) by smtp.gmail.com with ESMTPSA id e15-20020ac8670f000000b002e22d9c756dsm14849314qtp.30.2022.03.30.11.17.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 11:17:40 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b085af41-b055-11ec-8fbc-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZCIuaw/P3XMLRkUNQuqL8M82sLjVQz3hz9QA3xFRvLU=; b=mDEZNeZH+oPu8ubbp48pijTzq+D5SD8yHENfkw5L0VReCC75KRqi5gTIsqcghMqGfS KuLHMt//xGA81zMwKUh01nvtV5SA3moBcvSk6fZvIQmLMTHKu/euh2VYiu3UINTL2Vyd j+qV5qpq8J3lUjUgnvDEcWKyQCGz0ZsZjjb9u0bnLcQkjjijl6c5rpcDEE0pw+gBvBUP 8Rsh1pOpPVRXfyYKUH31TlibWWnhx0DgDhyEWCZyYKyKN7qoGJXpcVaa+MbnCn9l5LMl Tda94+pxQVE2RUSnJRzQq0jsROZ9ItPFc8lwtuNUfy4qKw0PqW0YyzzuDjQRBG7R3HnC 3LAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZCIuaw/P3XMLRkUNQuqL8M82sLjVQz3hz9QA3xFRvLU=; b=mnz2t4okSzjXZUmEQfa4WLHSYUqky1BBYyeBv4yG+YqbnJsHtzzs7RTdk4LW+ASqD1 XqrSqAF57F3Kk0zL0hRz7b2O+Vy++dl0NcSdQGu6fw0B6LcgO32AAhjFjhKOeY81eNBG +XwleHoxxNhnRjkY0Km6DE6Mg9gh7IWEHnNGdHCYDVT1UZrG2gVN4dSHmCcwSQfXuANP Uu+8MDPuGFnnvxwUwhK8sqJNfpwtzf919c6sr1q54C26QcBwMkuKFcUMslIHCzfXlDKY hA/9J6GQwZbTNKAMbrhBoiK/3QXT/cnVG2e9MMzoYEr7gImrUcuw59vv4NQwyv7R2Ybs Cvjg== X-Gm-Message-State: AOAM530d61pRBNWCtVImxndDk2JLdM3bNG0U6kCZwV/O1hb9aIRbnibi L3sTQgTTAare2bdPhtyXmomBE5sc5uM= X-Google-Smtp-Source: ABdhPJzdC79ao0S0ML/h7NX2ZQgJTlsOsPLYfFYRw6jmTBM8d/M02cro0Xcxh+OTzGR4MuO0kdgdUw== X-Received: by 2002:a05:620a:137a:b0:680:bca2:5c66 with SMTP id d26-20020a05620a137a00b00680bca25c66mr717883qkl.750.1648664261360; Wed, 30 Mar 2022 11:17:41 -0700 (PDT) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , "Daniel P. Smith" Subject: [PATCH] x86/irq: Skip unmap_domain_pirq XSM during destruction Date: Wed, 30 Mar 2022 14:17:34 -0400 Message-Id: <20220330181734.30319-1-jandryuk@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1648664288780100001 xsm_unmap_domain_irq was seen denying unmap_domain_pirq when called from complete_domain_destroy as an RCU callback. The source context was an unexpected, random domain. Since this is a xen-internal operation, we don't want the XSM hook denying the operation. Check d->is_dying and skip the check when the domain is dead. The RCU callback runs when a domain is in that state. Suggested-by: Roger Pau Monn=C3=A9 Signed-off-by: Jason Andryuk Reviewed-by: Daniel P. Smith --- Dan wants to change current to point at DOMID_IDLE when the RCU callback runs. I think Juergen's commit 53594c7bd197 "rcu: don't use stop_machine_run() for rcu_barrier()" may have changed this since it mentions stop_machine_run scheduled the idle vcpus to run the callbacks for the old code. Would that be as easy as changing rcu_do_batch() to do: + /* Run as "Xen" not a random domain's vcpu. */ + vcpu =3D get_current(); + set_current(idle_vcpu[smp_processor_id()]); list->func(list); + set_current(vcpu); or is using set_current() only acceptable as part of context_switch? xen/arch/x86/irq.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index 285ac399fb..16488d287c 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -2340,10 +2340,14 @@ int unmap_domain_pirq(struct domain *d, int pirq) nr =3D msi_desc->msi.nvec; } =20 - ret =3D xsm_unmap_domain_irq(XSM_HOOK, d, irq, - msi_desc ? msi_desc->dev : NULL); - if ( ret ) - goto done; + /* When called by complete_domain_destroy via RCU, current is a random + * domain. Skip the XSM check since this is a Xen-initiated action. */ + if ( d->is_dying !=3D DOMDYING_dead ) { + ret =3D xsm_unmap_domain_irq(XSM_HOOK, d, irq, + msi_desc ? msi_desc->dev : NULL); + if ( ret ) + goto done; + } =20 forced_unbind =3D pirq_guest_force_unbind(d, info); if ( forced_unbind ) --=20 2.35.1