Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5154156rdb; Tue, 12 Dec 2023 23:41:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqIRAE5HZur7nz3AuQi23TDmsZcW/i3ynR41VYia2YvLQ5irlZ/DeW4+ADGlG25u83hgF8 X-Received: by 2002:a05:6808:1a23:b0:3b9:d9d6:16bf with SMTP id bk35-20020a0568081a2300b003b9d9d616bfmr10020185oib.36.1702453285295; Tue, 12 Dec 2023 23:41:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702453285; cv=none; d=google.com; s=arc-20160816; b=TQ1wFM4AuzsXpgcIrrKVOk5uUZJLmvgS5mBE8IdBajFpjp9Alhkc4Q0b45smySf5qR Y8Lv8RvvFDudQe5dMiG/xf8M8//OmssM4KG4lgMufrLW5bLiFV1WjKp6CzmDPLfz7fSg ySljmqEhNXe9rAiEcCM9RikV4PElopchwaFPqkyhUyHKCF1wYNte21AC/jeybnlmxpmS zIrldwKdpraeBh7BPSRnRTeDQJ0ZxrsNlI8tBD5tDGRcFxPTe/7XLI91bTAYgvMrRjgx 6L/petezg8xQpCDIf//eMiwH+vH7uf/jpHnDRTHf6vpNQdQTp93abBtrYKHMUSDF60vs fCfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=8o4drzMaers2hVmDmJfFYBeEGuJUWOd6VhlCrOEzu1U=; fh=NB8RPLYgFKC1ZVDMuNTrzm4bv/uX8OT/rjB3qBPY9iQ=; b=VlJZpg+09xIc3BYkhc5IQikiEqboWgULMLbu/V7EJcxwBfuJoZ4y73Oydpc1BZzSrg dA14T02uPE67pPi0Siuxf2OSyi3tBzsXZeU8I4Dc/IIaSAz/cvp4opnookWcA2oXYYWl 7ncP4Joei2ShHtYrf5trtWkRsyKWtQJpGFfOtw1ZpXQJfmwdKkiA2sKevS53YSa9UBAi v79oFGQVNufI0N0JJao4E6SukAxMI8/6MjbifADQDljxsc94tUjoGfO1v4Jgb50Fmr59 Ru/23yvETm+qaDw+Er6kD7hsGZaB59WU+g1+4oOgV3vLWZOAwBjThPhTwL+uX/UsUU8w kiMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=X+wr5WTx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id j64-20020a638b43000000b005bd11902100si9314102pge.840.2023.12.12.23.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 23:41:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=X+wr5WTx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9BBDB80475C3; Tue, 12 Dec 2023 23:41:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233247AbjLMHlH (ORCPT + 99 others); Wed, 13 Dec 2023 02:41:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378846AbjLMHlC (ORCPT ); Wed, 13 Dec 2023 02:41:02 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70EB4E4 for ; Tue, 12 Dec 2023 23:41:07 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40c517d0de5so14619775e9.0 for ; Tue, 12 Dec 2023 23:41:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1702453266; x=1703058066; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=8o4drzMaers2hVmDmJfFYBeEGuJUWOd6VhlCrOEzu1U=; b=X+wr5WTx6PNGRrbiNPnrzBvSOjODDBkgnTnde/FOWaq/LWfgvMj3a5XtR8luEn+dws XpUKAaq4fkbN4FH6kI0aw+s/TR2OnzcrRpvrgOKvHHkpBkeIqKfTaNYgDPDaYNsF72mx jG4joFnQ5+yw4ffey11dwB10BydYY+Z/QY3dvkCh5hl8+n2kc3HbkgdMdfTUk/x0jl27 hy8SlcrmqFlTokhQkYX2B+fbKPRrhcFaiwRBcvHpRel2i+cX64nkV9N7VbpjJmG7LHd/ UGBk0vig5nVihxdjf4ZrlDPj9VckSuds3WjZ+lkl12y+mMfHhZC+RG1Mi2wul6iRL4oR 1q6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702453266; x=1703058066; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8o4drzMaers2hVmDmJfFYBeEGuJUWOd6VhlCrOEzu1U=; b=YNtIHLx0usvGzsczNyVNKHsbTM2rrNll3CVFBzk6vqqRcr5OweLvCMSMxNQDfrvYDt ms63VDX/lwCbSfnEFTI50vSZAlHbCwcRlZiV65Tg/Ci5OsikRDB1nhn+e1+MJjNOifzk QeJ2DP15FnqaBChqZQdhOwLkjGnn++opMk7PVUUj8VVUlrsiP/hR0R8ZiNIxVYIL/qYn Elwx6D7kpMFm2sgxENVG/KwyZgu8LQzPxAhWOPRiftd8jXldjKbZiSltrcKyVfvgSHsk voXOdFnDJSRjU0qrSYlGxaxRBF2rPCdRnfIMO6yqqwC9XxjHwaGRa3uXH+GIRsycFBjv 15RQ== X-Gm-Message-State: AOJu0Yx/LS7p7Xh4P/m90e1SLbV6K52GAZepYHfokEqDj60Tuv1mhVs/ f25CO9ZoT0xgsCBVpc3MqL7v X-Received: by 2002:a7b:ce14:0:b0:40b:5464:b241 with SMTP id m20-20020a7bce14000000b0040b5464b241mr3516231wmc.4.1702453265671; Tue, 12 Dec 2023 23:41:05 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id fj5-20020a05600c0c8500b0040b2976eb02sm19458404wmb.10.2023.12.12.23.41.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Dec 2023 23:41:05 -0800 (PST) Message-ID: Date: Wed, 13 Dec 2023 08:41:00 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC KERNEL PATCH v2 2/3] xen/pvh: Unmask irq for passthrough device in PVH dom0 Content-Language: en-US To: "Chen, Jiqian" Cc: Stefano Stabellini , Juergen Gross , Oleksandr Tyshchenko , "xen-devel@lists.xenproject.org" , "linux-kernel@vger.kernel.org" , "Huang, Ray" , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: <15275706-5c31-4e29-aa29-9f5e90526219@suse.com> <50ca26a1-38e3-45fb-9c39-56e4d04de3e0@suse.com> From: Jan Beulich Aut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XJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 12 Dec 2023 23:41:22 -0800 (PST) On 13.12.2023 08:14, Chen, Jiqian wrote: > On 2023/12/12 19:39, Roger Pau Monné wrote: >> On Tue, Dec 12, 2023 at 12:19:49PM +0100, Jan Beulich wrote: >>> On 12.12.2023 12:18, Roger Pau Monné wrote: >>>> On Tue, Dec 12, 2023 at 10:38:08AM +0100, Jan Beulich wrote: >>>>> (I think the Cc list is too long here, but then I don't know who to >>>>> keep and who to possibly drop.) >>>>> >>>>> On 12.12.2023 09:49, Roger Pau Monné wrote: >>>>>> On Tue, Dec 12, 2023 at 06:16:43AM +0000, Chen, Jiqian wrote: >>>>>>> On 2023/12/11 23:45, Roger Pau Monné wrote: >>>>>>>> On Wed, Dec 06, 2023 at 06:07:26AM +0000, Chen, Jiqian wrote: >>>>>>>>> +static int xen_pvh_setup_gsi(gsi_info_t *gsi_info) >>>>>>>>> +{ >>>>>>>>> + struct physdev_setup_gsi setup_gsi; >>>>>>>>> + >>>>>>>>> + setup_gsi.gsi = gsi_info->gsi; >>>>>>>>> + setup_gsi.triggering = (gsi_info->trigger == ACPI_EDGE_SENSITIVE ? 0 : 1); >>>>>>>>> + setup_gsi.polarity = (gsi_info->polarity == ACPI_ACTIVE_HIGH ? 0 : 1); >>>>>>>>> + >>>>>>>>> + return HYPERVISOR_physdev_op(PHYSDEVOP_setup_gsi, &setup_gsi); >>>>>>>>> +} >>>>>>>> >>>>>>>> Hm, why not simply call pcibios_enable_device() from pciback? What >>>>>>> pcibios_enable_device had been called when using cmd "xl pci-assignable-add sbdf" from pciback. But it didn't do map_pirq and setup_gsi. >>>>>>> Because pcibios_enable_device-> pcibios_enable_irq-> __acpi_register_gsi(acpi_register_gsi_ioapic PVH specific) >>>>>>>> you are doing here using the hypercalls is a backdoor into what's done >>>>>>>> automatically by Xen on IO-APIC accesses by a PVH dom0. >>>>>>> But the gsi didn't be unmasked, and vioapic_hwdom_map_gsi is never called. >>>>>>> So, I think in pciback, if we can do what vioapic_hwdom_map_gsi does. >>>>>>> >>>>>> >>>>>> I see, it does setup the IO-APIC pin but doesn't unmask it, that's >>>>>> what I feared. >>>>>> >>>>>>>> It will be much more natural for the PVH dom0 model to simply use the >>>>>>>> native way to configure and unmask the IO-APIC pin, and that would >>>>>>>> correctly setup the triggering/polarity and bind it to dom0 without >>>>>>>> requiring the usage of any hypercalls. >>>>>>> Do you still prefer that I called unmask_irq in pcistub_init_device, as this v2 patch do? >>>>>>> But Thomas Gleixner think it is not suitable to export unmask_irq. >>>>>> >>>>>> Yeah, that wasn't good. >>>>>> >>>>>>>> >>>>>>>> Is that an issue since in that case the gsi will get mapped and bound >>>>>>>> to dom0? >>>>>>> Dom0 do map_pirq is to pass the check xc_domain_irq_permission()-> pirq_access_permitted(), >>>>>> >>>>>> Can we see about finding another way to fix this check? >>>>>> >>>>>> One option would be granting permissions over the IRQ in >>>>>> PHYSDEVOP_setup_gsi? >>>>> >>>>> There's no domain available there, and imo it's also the wrong interface to >>>>> possibly grant any permissions. >>>> >>>> Well, the domain is the caller. >>> >>> Granting permission to itself? >> >> See below in the previous email, the issue is not with the >> permissions, which are correctly assigned from >> dom0_setup_permissions(), but the usage of domain_pirq_to_irq() in >> pirq_access_permitted() as called by XEN_DOMCTL_irq_permission. >> There's no need to play with the permissions at all. > Yes, the problem is pci_add_dm_done-> xc_domain_irq_permission-> XEN_DOMCTL_irq_permission-> pirq_access_permitted->domain_pirq_to_irq->return irq is 0, so it failed. > I am think that since the PVH doesn't use pirq, can we just skip this irq_permission check for PVH? If not the pIRQ, then the real IRQ would need checking for permissions. You won't get away without any checking at all, I'm afraid. Jan