[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v16 1/5] arm/vpci: honor access size when returning an error


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Wed, 22 May 2024 19:04:47 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=bsUpyP7kn8eJLu3oRss/4HmR2ID1rVQETHF+4Cg0ngM=; b=P43QVttNmWrJtAYcft59UTzzubcoirQvHunvU/I7kY26475AGWUMiRheUuStv9SzOIV3jIdrrO2jPUhylWXYLr3dQv3isid9XLN5f/ObifxoKAXCFxVAlBz7MfJ1BvnOnx9IlbGYCqn9QUdzzRgOB8gHqFE+7mq8Nq5pi6eBnONED6mCTFT88Sb25hPP0lFQJNJRSeAXyIWkOX9VV+l+mv0tACBFnmh1B3bYZ8Qs1vE6aQiqpaqdyIeY4CuHpgr7d9E6tddUX9XiH583DyOtfjkXWO/DxIT5AkH+9XkFWQkVs+/38u9JKXrWWxhTNBr9fX8bBYfLGLuAxMXPL3Mciw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ItF2QukBqKduBfq5POk2PKKhD/mdapQ2ocl+HtQ7ymO0PBrNpSdgUcyFByEtATmCtOGKJDvaWh8cOlxrUf/BOcbshR1rC3bd6laeuhkk3jHZWNO2kS9qgMSFUag1rBHrP/5aXLYFMRWsYlIV0NhG3tv65B8pWF58LYCyz/EL6UMcyv2Yf7RmgMubvo/h0YD0IpAhkdunJFaH7GNmoiSIkvFnN8nRfcnHetFr2zencNAzdc3U1BrXWJ68LM6ygOu9X1bwf4hN3fcSxPqf3t+WU6wWHrPy2i8Du90iRWHhD9tJAOcUjYwI/WhxPZGXGljHTb82+DIPN6S1czYm4AlEdA==
  • Cc: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Wed, 22 May 2024 23:05:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 5/22/24 18:59, Stewart Hildebrand wrote:
> From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
> 
> Guest can try to read config space using different access sizes: 8,
> 16, 32, 64 bits. We need to take this into account when we are
> returning an error back to MMIO handler, otherwise it is possible to
> provide more data than requested: i.e. guest issues LDRB instruction
> to read one byte, but we are writing 0xFFFFFFFFFFFFFFFF in the target
> register.
> 
> Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>

I forgot to pick up Julien's ack [0].

[0] 
https://lore.kernel.org/xen-devel/8fa02e06-d8dc-4e73-a58e-e4d84b090ea8@xxxxxxx/

> ---
> v14->v15:
> * re-order so this patch comes before ("xen/arm: translate virtual PCI
>   bus topology for guests")
> * s/access_mask/invalid/
> * add U suffix to 1
> * s/uint8_t/unsigned int/
> * s/uint64_t/register_t/
> * although Julien gave an Acked-by on v14, I omitted it due to the
>   changes made in v15
> 
> v9->10:
> * New patch in v10.
> ---
>  xen/arch/arm/vpci.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/vpci.c b/xen/arch/arm/vpci.c
> index 3bc4bb55082a..b63a356bb4a8 100644
> --- a/xen/arch/arm/vpci.c
> +++ b/xen/arch/arm/vpci.c
> @@ -29,6 +29,8 @@ static int vpci_mmio_read(struct vcpu *v, mmio_info_t *info,
>  {
>      struct pci_host_bridge *bridge = p;
>      pci_sbdf_t sbdf = vpci_sbdf_from_gpa(bridge, info->gpa);
> +    const unsigned int access_size = (1U << info->dabt.size) * 8;
> +    const register_t invalid = GENMASK_ULL(access_size - 1, 0);
>      /* data is needed to prevent a pointer cast on 32bit */
>      unsigned long data;
>  
> @@ -39,7 +41,7 @@ static int vpci_mmio_read(struct vcpu *v, mmio_info_t *info,
>          return 1;
>      }
>  
> -    *r = ~0ul;
> +    *r = invalid;
>  
>      return 0;
>  }




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.