From nobody Mon Nov 25 07:32:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1715697340; cv=pass; d=zohomail.com; s=zohoarc; b=jPyJXoc4MQvl8G4OCxKtWTJqsttNzmj2cHNaqwSdXF/E96KYvx5QTohqyCS1kGX7wQ2zsiOBBPj9GDJMuDQODHXnFwcTs7qAuo2M5kKLbpVdMuz3t7/+kTeSO3HzqAgtgqgpH8OpIz/nIiS5mmZJMbhBju8Nsd4t3Z98Vk+rJk0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715697340; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RhlHUD9Uu3FrjzdtnmRTwtlA65attPhQDXfrRmCx33g=; b=nZry7EqXhjQP34N0JF9OUv7bRbHZHCUdepq6aKselNNEbajbRP91un7awFC3U0w7PM47QVz7Dx5JbxGsd2+/0tlw+LxNzbEcRC/XVUS53qjURc1FLr/Ms2qLZ160ipzeZ8DNjKNwdMs+3XlNFwCCd+Ell554kr7ZLNRkwlqJgfE= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1715697339967451.84365437614565; Tue, 14 May 2024 07:35:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.721593.1125152 (Exim 4.92) (envelope-from ) id 1s6tFV-00070s-3y; Tue, 14 May 2024 14:35:25 +0000 Received: by outflank-mailman (output) from mailman id 721593.1125152; Tue, 14 May 2024 14:35:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s6tFV-00070i-1D; Tue, 14 May 2024 14:35:25 +0000 Received: by outflank-mailman (input) for mailman id 721593; Tue, 14 May 2024 14:35:23 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s6tFT-0004xK-Q3 for xen-devel@lists.xenproject.org; Tue, 14 May 2024 14:35:23 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2060e.outbound.protection.outlook.com [2a01:111:f400:7e88::60e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 31c564ed-11ff-11ef-909d-e314d9c70b13; Tue, 14 May 2024 16:35:23 +0200 (CEST) Received: from MW3PR06CA0002.namprd06.prod.outlook.com (2603:10b6:303:2a::7) by SN7PR12MB7977.namprd12.prod.outlook.com (2603:10b6:806:340::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Tue, 14 May 2024 14:35:18 +0000 Received: from SJ5PEPF000001CC.namprd05.prod.outlook.com (2603:10b6:303:2a:cafe::c2) by MW3PR06CA0002.outlook.office365.com (2603:10b6:303:2a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55 via Frontend Transport; Tue, 14 May 2024 14:35:17 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by SJ5PEPF000001CC.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.21 via Frontend Transport; Tue, 14 May 2024 14:35:16 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 14 May 2024 09:35:15 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 14 May 2024 09:35:15 -0500 Received: from ubuntu.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 14 May 2024 09:35:09 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 31c564ed-11ff-11ef-909d-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bgo3z8RKUAeMa3//VZ3E6/Ae26SG+P7cyiZBEFk3moTngK7Bz0Ag3Gzsi2adNamwxPM7HvBikDOT9SJ3mR9eTUSGc++JyrwHhox62XVHkS2Fav/9XKXUlmwOO5yTtfO7WxGyohe8r46FaXBrd4ZtqNfzChPjKVnAN+vILRao3J+NYa37Er5+t3nAZSVt4YG+NT4EYZrbBg0ywJ/uevMz0v+/grPbcDY7KfRLhGCEQOU8lKQAo5kzQZNAa1IdyFarz+X9HPIoow5svG/GGtLuH29osMf4vX05egH5VWuhTUSeceBXhHfWiDrNHKsKt1n9z3EZMdSaUS1GYCAcudcemw== 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=RhlHUD9Uu3FrjzdtnmRTwtlA65attPhQDXfrRmCx33g=; b=WLMXxnfJwS3y8MFsQlfqpi4x4s4vPKNJrzd5ayzyobaOpFUfRdQZmmfzS25LsXc/Iaoj2Q+WDkppJyDdsy31gYgrFE6j8NSszLb1EKPVoh6EzYnO3P69EA/TjL8RHWhEzI5cNmP6cgMOZvDpiTLhtI76PJq9IslSLyTGO1m9ISWzdAgCw0nNbKKX4csT5g5sx3YqlNWxXX7fGVuXeeC0wMi83HdjHumcgbRGHVJxb2l3+VspNNGgoys7t8ktwamSMfV3Esq76xIlN4Y0DnXIEsb7YHA7TINn07HgvjOtO6b7u6uP7qvJZZxkircuNIyhEsvVScfbG7qPW9L/nC53Bg== 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RhlHUD9Uu3FrjzdtnmRTwtlA65attPhQDXfrRmCx33g=; b=oZ2V6bMennaAUQdIMkXrd8Z40e1W+DZlj9XdxEG57oVnuhpmT3RjykTbjOrEyrnyWP1OwqXiLR14q/8L4YNTp1HNzW58jCI/3C2moJ++X9Lyyj8Ms5GdgtOBGF86kCw5lIVgC0q36njeGuj200/NfNhTAjAS4BVtKj2LnzgA7ak= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Stewart Hildebrand To: CC: Volodymyr Babchuk , Stewart Hildebrand , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH v14 5/5] arm/vpci: honor access size when returning an error Date: Tue, 14 May 2024 10:33:57 -0400 Message-ID: <20240514143400.152280-6-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240514143400.152280-1-stewart.hildebrand@amd.com> References: <20240514143400.152280-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB05.amd.com: stewart.hildebrand@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CC:EE_|SN7PR12MB7977:EE_ X-MS-Office365-Filtering-Correlation-Id: b0ef63ab-8853-4624-2182-08dc742312ce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?IRQdCSQ76CNm6BAyrpNWu5W0Gq18D7L2QRGuVj/HmSj/CzJC4jYK+lHewJNV?= =?us-ascii?Q?3Hs8qrW5bw2bfysC+foYio+wSwdyR00iSU04q6j1+Hc1sX2X2jzUytJHyJLx?= =?us-ascii?Q?gW7dVIyP+bag4ZBUBxMVcADEAiSs3RrPnsvZEIq0JP+UV+suf/L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V4m9bKoeR3NzXDMaIxb4q+YtcuwVfFTEw?= =?us-ascii?Q?RjDhNqkYOKw0z8z7DlVwxPAy40KLieAIEckLM8FR3n96PMQDPnBaBe5TRDzf?= =?us-ascii?Q?Xx4N3VCl11FFtcBtaLfIOPzopF/ecGeND0sZCbJB1xo822faNOgTOM18SyJN?= =?us-ascii?Q?ZbM4Wz/lKvo34oZ7Kgu25AxVjo8ulytX55hmVFDWm3NuEkJGP43afHgZUjgY?= =?us-ascii?Q?jVP8iZ+sB00YHinpFPBPv4HXaFcfLjPWxIAi0uoPKYLvFovlxYQca7sJVDqB?= =?us-ascii?Q?xSMWNrPddZ9hirmZ4Q6OQPD5w+l9vkeBob5sYaftr9nE7pcn6/fNIaERq3hM?= =?us-ascii?Q?3sDw4nMLJBL+As1P2HEZIJkWBt7U?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(376005)(1800799015)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2024 14:35:16.6850 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b0ef63ab-8853-4624-2182-08dc742312ce X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001CC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7977 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1715697340761100001 Content-Type: text/plain; charset="utf-8" From: Volodymyr Babchuk 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 Signed-off-by: Stewart Hildebrand Acked-by: Julien Grall --- v9->10: * New patch in v10. --- 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 348ba0fbc860..aaf9d9120c3d 100644 --- a/xen/arch/arm/vpci.c +++ b/xen/arch/arm/vpci.c @@ -41,6 +41,8 @@ static int vpci_mmio_read(struct vcpu *v, mmio_info_t *in= fo, { struct pci_host_bridge *bridge =3D p; pci_sbdf_t sbdf; + const uint8_t access_size =3D (1 << info->dabt.size) * 8; + const uint64_t access_mask =3D GENMASK_ULL(access_size - 1, 0); /* data is needed to prevent a pointer cast on 32bit */ unsigned long data; =20 @@ -48,7 +50,7 @@ static int vpci_mmio_read(struct vcpu *v, mmio_info_t *in= fo, =20 if ( !vpci_sbdf_from_gpa(v->domain, bridge, info->gpa, &sbdf) ) { - *r =3D ~0UL; + *r =3D access_mask; return 1; } =20 @@ -59,7 +61,7 @@ static int vpci_mmio_read(struct vcpu *v, mmio_info_t *in= fo, return 1; } =20 - *r =3D ~0UL; + *r =3D access_mask; =20 return 0; } --=20 2.43.2