Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1156680ybl; Tue, 3 Dec 2019 02:40:58 -0800 (PST) X-Google-Smtp-Source: APXvYqx9Zk8yfg7aGgqB0dNoP/GCtpCmlEHBYyeZ1HTq8QZz5By//USyF5CUpcvKBMoiTyWbo1in X-Received: by 2002:a05:6830:1459:: with SMTP id w25mr2426754otp.270.1575369658317; Tue, 03 Dec 2019 02:40:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575369658; cv=none; d=google.com; s=arc-20160816; b=O8V9Xofe2hKix2Yceg7l2Plggdu/S3SmOT2yZI53Yw7GNZ2JeO74DMGnJPJfcRvNbd 825EJUOoU3105W7l/XKLi3NQ4mZToZ382DdkQfR8tYVbHD78NeopBtLXdw7lcxA2415V TSg91q0r5yL28r7SNw5h/3uQBopmLKMAL7GQlhqAN8hJL94RGEruLliRr+H8qIxaqDW8 +jzWe/7A/Hql5eAZvnEZNCL3Hv+gaWRNZ3YVf2gXi3Kuhq189dFAbShQrZVylagcae5G 6V1waDf/KKD7pvldWuusUmYII9GtsbIBZSlHGwe1eYsLi8HB4Z8B9zgiChs++AYu0UJ4 /y9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=tjiMN6LeUPNjJMmite8qgri0Zc8ea/4OrgELOIsqSBY=; b=mT965FEcUM9EZDo+ML2f5TXSzq+DGkWywEs3fFTCSj2Oltjai9tpAACqQP83HmDCsT SlmBYz5ghOqAFuyBgHn4rnXA0TM29MIX0yecG0TvUgrwLi8BgSeMFmlho2sld7UIzlqJ J+C/4WzdmDFn2lNYw5IkE9OoqWJKT6JQdYnUPnSiR0YY2J9GOMySm8Tuo7FsnzgpC9Ee /mjl7f2b41W4z4vQ/monFPZaesLt6O7vbl3Pm/XSI9aCZd/6fcC6/qffX4vTjwIEohDP EVorS5/Aou00lp8cPAVWc8cBUsUq23cMcmXFfQs8Qj9JGByGXRM0FHzErThQ0Xu3a2Ib A1Ow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z17si1037700oih.192.2019.12.03.02.40.46; Tue, 03 Dec 2019 02:40:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726179AbfLCKjx (ORCPT + 99 others); Tue, 3 Dec 2019 05:39:53 -0500 Received: from mx2.suse.de ([195.135.220.15]:39104 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725773AbfLCKjx (ORCPT ); Tue, 3 Dec 2019 05:39:53 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 36A81B25A; Tue, 3 Dec 2019 10:39:51 +0000 (UTC) Subject: Re: [PATCH v1] xen-pciback: optionally allow interrupt enable flag writes To: =?UTF-8?Q?Marek_Marczykowski-G=c3=b3recki?= Cc: xen-devel@lists.xenproject.org, Ross Lagerwall , YueHaibing , Simon Gaiser , Stefano Stabellini , Boris Ostrovsky , Juergen Gross , open list References: <20191203054222.7966-1-marmarek@invisiblethingslab.com> From: Jan Beulich Message-ID: <9ccf765b-f828-52db-6778-18e605a80a02@suse.com> Date: Tue, 3 Dec 2019 11:40:03 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <20191203054222.7966-1-marmarek@invisiblethingslab.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03.12.2019 06:41, Marek Marczykowski-Górecki wrote: > @@ -117,6 +118,35 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data) > pci_clear_mwi(dev); > } > > + if (dev_data && dev_data->allow_interrupt_control) { > + if (!(cmd->val & PCI_COMMAND_INTX_DISABLE) && > + (value & PCI_COMMAND_INTX_DISABLE)) { > + pci_intx(dev, 0); > + } else if ((cmd->val & PCI_COMMAND_INTX_DISABLE) && > + !(value & PCI_COMMAND_INTX_DISABLE)) { > + /* Do not allow enabling INTx together with MSI or MSI-X. */ > + /* Do not trust dev->msi(x)_enabled here, as enabling could be done > + * bypassing the pci_*msi* functions, by the qemu. > + */ > + err = pci_read_config_word(dev, > + dev->msi_cap + PCI_MSI_FLAGS, > + &cap_value); > + if (!err && (cap_value & PCI_MSI_FLAGS_ENABLE)) > + err = -EBUSY; > + if (!err) > + err = pci_read_config_word(dev, > + dev->msix_cap + PCI_MSIX_FLAGS, > + &cap_value); What about a device without MSI and/or MSI-X? Wouldn't you read from (close to) config space offset 0 in this case, interpreting some unrelated bit(s) as the MSI / MSI-X enable one(s)? Just as an initial implementation related remark. I'm still to think about the idea as a whole, albeit I find the argument pretty convincing at the first glance of devices being able to raise MSI anyway even when disabled as per the config space setting. (Of course, as with any config space settings, devices providing backdoor access would open similar avenues.) Jan