[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v11 17/17] arm/vpci: honor access size when returning an error
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Date: Sat, 2 Dec 2023 01:27:07 +0000
- Accept-language: en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.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=XatSDoliS1e0RbDS2pE/RuspFe++g/oP6bCvkIjzp1E=; b=abI954K3Uifyls8k+aJGfmF0dmXIPoWk2DxTsFFSIYdNCO2gPCMFKWDG8KVZEUybqP65HqnwvjGEXCESFHwBngCgwRpqt6OPtFzzEAfm18IBH1MhsCMNhfi0y2+9GHRxLjyqfDB/0D/vrZxYwe2V3Ksqs76f3yfntNi/p5Vl8545kZJkm/jck2Ww1IeIdYV9Vpu3NOtFMxIvcvoA8s2HPGco73Pg61TaUSBn68wv0DKDRmZ8PwIvu8sy8gYccliAT65FkorlYR7Sy+TnqRlRwL7wL1Hyt5Mc/JoErNJFh1EQ7g4+yE3HUhGX5JjRVpAxiG9al0j4Yx9TaU6vlJTFNA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a7JNZrgUj2PpAz83t3yqhrFYTPLO4rXqg7kb8Q4pBN4HbrufLP4SJ4iLVUCxVJN3ZfVut9dNYGQrLxa8q2WtAXdWsJzpO7LMO8aXVJ/SdfvgYjnfSL+WBev0qngdPf+1lBR9FPM3tDXAtRAR+Ee7XPFaSqxON05xEjftqc1hT7U6SbxfIf2roWgFSAH+7C0keMoBu3SN5wUizyG1/9g/9a8YlyIDFtqAixqm07Qc8rmPwtuHPK4gCFzhz+PGWol5rS6apY67mAQxQTmsA777YWnwZ95PVIbRNt8c7/duo9p0ClkWMGUE2bsLATb9eg8afvBSiH/hSGxf6hMfd+iAog==
- Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Delivery-date: Sat, 02 Dec 2023 01:27:37 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHaJL6qzrPLCvUkHkyTdIPsJJSlOA==
- Thread-topic: [PATCH v11 17/17] arm/vpci: honor access size when returning an error
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>
---
xen/arch/arm/vpci.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/xen/arch/arm/vpci.c b/xen/arch/arm/vpci.c
index b6ef440f17..05a479096e 100644
--- a/xen/arch/arm/vpci.c
+++ b/xen/arch/arm/vpci.c
@@ -42,6 +42,8 @@ static int vpci_mmio_read(struct vcpu *v, mmio_info_t *info,
{
struct pci_host_bridge *bridge = p;
pci_sbdf_t sbdf;
+ const uint8_t access_size = (1 << info->dabt.size) * 8;
+ const uint64_t access_mask = GENMASK_ULL(access_size - 1, 0);
/* data is needed to prevent a pointer cast on 32bit */
unsigned long data;
@@ -49,7 +51,7 @@ static int vpci_mmio_read(struct vcpu *v, mmio_info_t *info,
if ( !vpci_sbdf_from_gpa(v->domain, bridge, info->gpa, &sbdf) )
{
- *r = ~0UL;
+ *r = access_mask;
return 1;
}
@@ -60,7 +62,7 @@ static int vpci_mmio_read(struct vcpu *v, mmio_info_t *info,
return 1;
}
- *r = ~0UL;
+ *r = access_mask;
return 0;
}
--
2.42.0
|