[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-4.17 6/6] vpci: refuse BAR writes only if the BAR is mapped
- To: xen-devel@xxxxxxxxxxxxxxxxxxxx
- From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Date: Thu, 20 Oct 2022 11:46:49 +0200
- 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
- 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=978VHNm8HL9oE714Wo1de7N2hjymmg8SC4PEXMhjlqM=; b=WytDwgb09+7FH+9KS6eKm2RmTZEDXSaVqXwaXA6vl5B3Q58EW0h2jYQFss8/koCS9MhGp7QMgsxVJY77TLWGpuX/EGcX/SIyy+QhzbeDDtwnJKs6j/6YmvPqTrSYbNghRm5aCho+jke6goQmDwqcaqSy1y4k3hcAVIW/Yg/2fjVGMdTpxV/dB1P62s40Ax12Fw3DplSv9JpyOpEs0wrPJElrti2PcIiXDXp4eBpXm/tQ1ZiIQt7BcUYdYBuJuk1ZiUqVSxrrGBHR9kO+05VAARsYeQZAvrgtZOdRTyIaKqm41NVlOs71bFWvA3QSj15roSCaxleDj0DWqTICGjay2A==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PbKTDR6ps1JcwFL/ihu0dhIjFZL/m/MUetodNn7mEeGkzx4MITqqBlipbLZi33s8ds6YNbhrINqqgIA43C11FdEnkM22LSH87ig283d4VyLZ71tW4CZgfhapx78IOE6QgFstXcEx9r7hIR7HkZFWx5p22Hfl8EUwmP3Ztq/Ij6IERFlgVVYwFIiYw9+PPBS55qBJZJijfgLyAnjzULoAUqmr0zU4hj2jXgVd8+I3Fjyldy/Ze1It4QZxawDSxnT8YCI6m8muantJVLrYxYsH/oUrjBSiIJoBSON3W2hv5CSmv83lbyfIHUH9Pb/nmBdWxYLn/pvncKS+rM0K2CdaGA==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Delivery-date: Thu, 20 Oct 2022 09:47:46 +0000
- Ironport-data: A9a23:f1ROfapG/MSzAn/xKsJYQKlFlU1eBmJiZBIvgKrLsJaIsI4StFCzt garIBmEM6uJNGP9e9BwOt+wp0gD6JfVz4BgTARq/ikxQXsV9JuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYGYpLeNdYH9JoQp5nOIkiZJfj9G8Agec0 fv/uMSaM1K+s9JOGjt8B5mr9VU+4ZwehBtC5gZkPKgR5AeH/5UoJMl3yZ+ZfiOQrrZ8RoZWd 86bpJml82XQ+QsaC9/Nut4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5iXBYoUm9Fii3hojxE4 I4lWapc6+seFvakdOw1C3G0GszlVEFM0OevzXOX6aR/w6BaGpdFLjoH4EweZOUlFuhL7W5mr NNIBB8/aFe6t8Hu7569EbZVqe4AM5y+VG8fkikIITDxK98DGcqGeIOToNhS0XE3m9xEGuvYa 4wBcz1zYR/cYhpJfFAKFJY5m+TujX76G9FagAvN+exrvC6Ok0oti9ABM/KMEjCObd9SkUuC4 HrP4kzyAw0ANczZwj2Amp6prr+Sw32qBNxMfFG+3uNBsFqQgVEQMhQ9dFy2/NeQsBaXRM0Kf iT4/QJr98De7neDXtT7GhG1vnOAlhodQMZLVf037hmXzajZ6BrfAXILJgOtc/Qjvc4yACcsj 1aPltaxXzh36uXJEjSa66ueqi60NW4NN2geaCQYTAwDpd7+vIU0iRGJRdFmeEKosuDI9fjL6 2jihEADa38716bnC43TEYj7vg+R
- Ironport-hdrordr: A9a23:rE/ohal2o5r048uXgmWY41TMPJDpDfO3imdD5ihNYBxZY6Wkfp +V8cjzhCWftN9OYhodcLC7V5Voj0msl6KdhrNhR4tKPTOWw1dASbsP0WKM+UyFJ8STzI5gPO JbAtFD4b7LfCdHZLjBkW6F+r8bqbHokZxAx92ut0uFJTsaF52IhD0JbzpzfHcGJzWvUvECZe ehD4d81kydUEVSSv7+KmgOXuDFqdGOvJX6YSQeDxpizAWVlzun5JPzDhDdh34lInty6IZn1V KAvx3y562lvf3+4hjA11XL55ATvNf60NNMCOGFl8BQADTxjQSDYphnRtS5zXkIidDqzGxvvM jHoh8mMcg2w3TNflutqR+o4AXk2CZG0Q6W9XaoxV/Y5eDpTjMzDMRMwahDdAHC1kYmtNZglI pWwmOwrfNsfF/9tRW4w+KNewBhl0Kyr3Znu/UUlWZjXYwXb6IUhZAD/XlSDIwLEEvBmc0a+d FVfY/hDcttABKnhyizhBgu/DXsZAV4Iv6+eDlMhiTPuAIm30yQzCMjtb4idzk7hdAAoqJ/lp T525RT5c9zp/AtHNNA7Z86MK2K40z2MGbx2TGpUCPaPZBCHU7xgLjKx5hwzN2WWfUzvegPcd L6IRhliVI=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Writes to the BARs are ignored if memory decoding is enabled for the
device, and the same happen with ROM BARs if the write is an attempt
to change the position of the BAR without disabling it first.
The reason of ignoring such writes is a limitation in Xen, as it would
need to unmap the BAR, change the address, and remap the BAR at the
new position, which the current logic doesn't support.
Some devices however seem to have the memory decoding bit hardcoded to
enabled, and attempts to disable it don't get reflected on the
command register.
This causes issues for well behaved guests that disable memory
decoding and then try to size the BARs, as vPCI will think memory
decoding is still enabled and ignore the write.
Since vPCI doesn't explicitly care about whether the memory decoding
bit is disabled as long as the BAR is not mapped in the guest p2m use
the information in the vpci_bar to check whether the BAR is mapped,
and refuse writes only based on that information.
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
xen/drivers/vpci/header.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 4d7f8f4a30..4b39737b76 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -388,7 +388,7 @@ static void cf_check bar_write(
else
val &= PCI_BASE_ADDRESS_MEM_MASK;
- if ( pci_conf_read16(pdev->sbdf, PCI_COMMAND) & PCI_COMMAND_MEMORY )
+ if ( bar->enabled )
{
/* If the value written is the current one avoid printing a warning. */
if ( val != (uint32_t)(bar->addr >> (hi ? 32 : 0)) )
@@ -425,7 +425,7 @@ static void cf_check rom_write(
uint16_t cmd = pci_conf_read16(pdev->sbdf, PCI_COMMAND);
bool new_enabled = val & PCI_ROM_ADDRESS_ENABLE;
- if ( (cmd & PCI_COMMAND_MEMORY) && header->rom_enabled && new_enabled )
+ if ( rom->enabled && new_enabled )
{
gprintk(XENLOG_WARNING,
"%pp: ignored ROM BAR write with memory decoding enabled\n",
--
2.37.3
|