From nobody Mon Nov 23 04:26:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1793320735; cv=none; d=zohomail.com; s=zohoarc; b=ciEDjraioByGwA+7Q7DjBPUJYQvYIoXvMorPo3cZD67rlwts6I8fz4Bz+yn2FVDVkPtgb1czzybhBx3d+sjj970pz+QYgo9sJXdY+QfCl5loJvWG8PtksvBvrvJmYZgysgga3hnFdWWtvSiHcVm9O4TYWPPQror+egL6Uet5Swc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793320735; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=O7UOLG7qLDkhqiUSc32Mb+g0QQ9McU5BeJZscq4zAds=; b=Qnl6+Zhx9BTe0gJp3XhMHRwTUmBLi97a8AlwABwEOouNsHSBAUYY+BSvohFIRQFwBr5PyhVDKBH1kpjTjazJcJOo8d2dBs/1uj5rnjVG12befiegFZhR3ZqVdvcQtF++PjHUo/xgcDM0bm07WTpemyw7iGVtiEEmzaueXLP6JwQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793320735744188.4221816695947; Thu, 29 Oct 2026 17:38:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMadj-0004Yc-QS; Thu, 29 Oct 2026 20:38:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMadZ-0004WJ-Ry for qemu-devel@nongnu.org; Thu, 29 Oct 2026 20:38:29 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMadW-0003ci-6k for qemu-devel@nongnu.org; Thu, 29 Oct 2026 20:38:29 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69TLYNiC1913021; Fri, 30 Oct 2026 00:38:21 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4hme5mr4ch-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=OK); Fri, 30 Oct 2026 00:38:21 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.11/8.18.1.11) with ESMTP id 69TNg6vS2004177; Fri, 30 Oct 2026 00:38:19 GMT Received: from alaljime-e5-test-20240903-1847.osdevelopmeniad.oraclevcn.com (alaljime-e5-test-20240903-1847.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.206]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4hmg231tmh-2; Fri, 30 Oct 2026 00:38:18 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=O7UOL G7qLDkhqiUSc32Mb+g0QQ9McU5BeJZscq4zAds=; b=SMHDQdgOHQY1JsDrE3sjb 8kZ6JXwMVx8w5cY4m3KauMCRmdHmAs9O3RG2T7nc39wHRlo+mOunyaRAwSRkiKMw jxVMJNxp7DHqdPKTvx3hnmlWYyROdAim8UBaPYe0Qy4G8zRVivWtkHY3wP0cowxk 8As2kdI+DTtzwnaW41ZwmcQk2hFR4cl92NboQ+6WCJEWb3fQaghfEd3ObIyHlCCF xCsx5DggbfmeVv9jpovOgoy69m+xIy+g5CNLh5YTxNEMc4l6Ormru//w8vHsz8TK mufAe2n4etCin6bwdE8KOpHOL7MPasupKv6138DrKr/395PWKSOVjF5mNt6IFmOA A== From: Alejandro Jimenez To: mst@redhat.com, dongli.zhang@oracle.com Cc: qemu-devel@nongnu.org, sarunkod@amd.com, pbonzini@redhat.com, richard.henderson@linaro.org, joe.jin@oracle.com, alejandro.j.jimenez@oracle.com Subject: [PATCH v3 1/5] amd_iommu: Do not create duplicate MSI capability Date: Fri, 30 Oct 2026 00:38:13 +0000 Message-ID: <20261030003817.3521476-2-alejandro.j.jimenez@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261030003817.3521476-1-alejandro.j.jimenez@oracle.com> References: <20261030003817.3521476-1-alejandro.j.jimenez@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-10-29_07,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610300001 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDMwMDAwMSBTYWx0ZWRfX7jIFYUgijWWY aGD7zbtm+7nE73cxqes7JuS+v+EY7vIAtvNeTpQwsbIXV7EANKwEomwkj7dct54/wC2/uFthIoF NoA6qyS8LxE0jkgM2lvR++rn2VT52H5Av0rvV57dnJQjhBRzgzAl X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDMwMDAwMSBTYWx0ZWRfX83kzk0hle8ZT 9P5lz7YxkHiv/fUPLDQW8zPw/Tj/qONMruBBE3wjwNSvJLTijwDcf+dvr4dyps7zVtzckIiGE1X 0ckfV6lhEFI7+UHu4tlJ4mZAPqZuOixL44y2Ibu2og+VMOtiZ7HRPRjhnmxgiOzOT32CPZ4so/r IduQpb+YSZW3HelgC1dOKZ3gs9UgY82V2fTmeDHcfWkkT+ApEXHWhaKqsHlpJ6IxgARtPL0S1r9 buhsNpbZUvfITjhGhfkrU47qSW/QKktKjW0ruCYlgIxXUWjudggbkcfEeIINCb4L915l5o1riqO Hae2PhwHB2PQ8AqebV1j7YgDyxeV6oWRruXahAUrj2VC2x7hM5shjpY5p6i7pqptHzTf9DdYmk9 d9JdDRPVrVpoKKhKDtdrFJjKWPpcY6gn2jYtdvc/v8b+A3hxYT3aVt23zfygRvSOiG9++cmsNKa Le0PQBeWomOzy0AEpsA== X-Authority-Analysis: v=2.4 cv=TvFzFzXh c=1 sm=1 tr=0 ts=6ae3e6fd b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=3I1J8UUJPc9JN9BFgKH3:22 a=yPCof4ZbAAAA:8 a=zd2uoN0lAAAA:8 a=w9z83O1xWNOsbQloCHQA:9 a=WmVTiCyuxqgg3mnwYu6p:22 X-Proofpoint-GUID: SsZARSDI27OQ9_UI11KWv2WGxAfsXXaB X-Proofpoint-ORIG-GUID: SsZARSDI27OQ9_UI11KWv2WGxAfsXXaB Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=alejandro.j.jimenez@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, KHOP_DYNAMIC=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1793320738756154100 Content-Type: text/plain; charset="utf-8" From: Dongli Zhang amdvi_pci_realize() manually adds an MSI capability before calling msi_init(). msi_init() creates the MSI capability itself, so the device can expose duplicate MSI capabilities to the guest. Drop the manual MSI capability and let msi_init() create the single MSI capability used by QEMU. Otherwise, there are duplicate MSI capabilities in guest VM lspci. [root@vm ~]# lspci -vvv -s 00:02.0 00:02.0 IOMMU: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 10h-1f= h) I/O Memory Management Unit Subsystem: Red Hat, Inc. Device 1100 Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Steppi= ng- SERR+ FastB2B- DisINTx+ Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=3Dfast >TAbort- SERR- Fixes: d29a09ca6842 ("hw/i386: Introduce AMD IOMMU") Signed-off-by: Dongli Zhang Reviewed-by: Sairaj Kodilkar Reviewed-by: Alejandro Jimenez Signed-off-by: Alejandro Jimenez --- hw/i386/amd_iommu.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 2d5c7b5cdf..fa590c9223 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -2576,11 +2576,6 @@ static void amdvi_pci_realize(PCIDevice *pdev, Error= **errp) } s->capab_offset =3D ret; =20 - ret =3D pci_add_capability(pdev, PCI_CAP_ID_MSI, 0, - AMDVI_CAPAB_REG_SIZE, errp); - if (ret < 0) { - return; - } ret =3D pci_add_capability(pdev, PCI_CAP_ID_HT, 0, AMDVI_CAPAB_REG_SIZE, errp); if (ret < 0) { --=20 2.47.3 From nobody Mon Nov 23 04:26:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1793320748; cv=none; d=zohomail.com; s=zohoarc; b=OdvUG52bvh7rBqGLARaRBQR48/ay4nlRB540+1PiGsL4TYYaX+Cwst9Kg5AYuwFYvipqgk8IefcPEXsgzzHkk+Ss8Lln3sKQo1TqQYWSPDMvurHMBeGBFaOe6pbcSTjZtH3x354NBIXV/klsIz4h/dKhmUGe3D9rN9eD0GDFqDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793320748; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AtYLt7/3L/KneBSziO5uJ6zinKJBVgez4qpoyfItFrY=; b=SNtZv+howU8dls0iS4uIEpLJEXZcdstwHEy5srAbzFKojFhChqIycfdjwFI2+36q/hnTShMUATWXvkJO3b+N1qhxnILWoGczHci8/qswsQKcKIjAyZmYE+7iKgxzn+w0148PUUYpjbtO6hpOa+ds8hVMmSRFVvTLHFp4mgbQfAg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793320748538476.5913562280415; Thu, 29 Oct 2026 17:39:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMadi-0004Xz-At; Thu, 29 Oct 2026 20:38:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMadY-0004Vv-JK for qemu-devel@nongnu.org; Thu, 29 Oct 2026 20:38:28 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMadW-0003ch-5k for qemu-devel@nongnu.org; Thu, 29 Oct 2026 20:38:28 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69TLYlh12256631; Fri, 30 Oct 2026 00:38:21 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4hme61r42h-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=OK); Fri, 30 Oct 2026 00:38:21 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.11/8.18.1.11) with ESMTP id 69TNgAJQ2004302; Fri, 30 Oct 2026 00:38:20 GMT Received: from alaljime-e5-test-20240903-1847.osdevelopmeniad.oraclevcn.com (alaljime-e5-test-20240903-1847.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.206]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4hmg231tmh-3; Fri, 30 Oct 2026 00:38:20 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=AtYLt 7/3L/KneBSziO5uJ6zinKJBVgez4qpoyfItFrY=; b=DQlZRo2jEk2rWWZ1pOlCB eKihcrfDwii1QqgggF84wNHXcC6LWVZO709PeN5gx7nmitrazKKuZAKzCEJPR5GB m5WCbwddrkZ3gNB5+EV5y75TlerGJUYQHB+xxaEixzuNYNQvYiyNU96dxXrv7MqH U68dfgt1bxeLZ4idYkAOd28j8dZk2x7BDx2zHd3FtWjDSvJtFmseJf/J4C64+3ug dVjaySIpFZpN0VE5KDzUvQlCKt080yl37uBXuOZ9fz/r6hmz7YCu9/jNQm9mOZDJ UZ19fYN2zSC28WrUN7GYK2CX2BA4LbWVbxBAFh7HEvivm2tVLcZuaa3X4OzVRw5R Q== From: Alejandro Jimenez To: mst@redhat.com, dongli.zhang@oracle.com Cc: qemu-devel@nongnu.org, sarunkod@amd.com, pbonzini@redhat.com, richard.henderson@linaro.org, joe.jin@oracle.com, alejandro.j.jimenez@oracle.com Subject: [PATCH v3 2/5] amd_iommu: Use full BDF when reporting page faults Date: Fri, 30 Oct 2026 00:38:14 +0000 Message-ID: <20261030003817.3521476-3-alejandro.j.jimenez@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261030003817.3521476-1-alejandro.j.jimenez@oracle.com> References: <20261030003817.3521476-1-alejandro.j.jimenez@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-10-29_07,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610300001 X-Authority-Analysis: v=2.4 cv=L9qI0OT8 c=1 sm=1 tr=0 ts=6ae3e6fd b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=EIcjfB9IiI4px24ztqRk:22 a=yPCof4ZbAAAA:8 a=zd2uoN0lAAAA:8 a=ocuUHAh6soMjp_LHbv0A:9 a=WmVTiCyuxqgg3mnwYu6p:22 X-Proofpoint-GUID: Nm4nQkXfE1RoEE4csZGTHWoT376C_Qlm X-Proofpoint-ORIG-GUID: Nm4nQkXfE1RoEE4csZGTHWoT376C_Qlm X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDMwMDAwMSBTYWx0ZWRfXyz0PB4N21J3Q 3cJ8DmqsilAFDuUmYDNGzSJ+dyNtWUmG+ow9njBn9pVGn74VfB4ERogeJ6jELnrskcDdDOQ7zne TtBk1D2PkHlNEAHAan+6JyQdtRVrRsg4D4HRHnGcSQ0vcqV+s5uvqPwhOevd8BE8LfBfyKnJEOi 5AaKGuml6k5ElDM1iU5yZHN9zgdVZwtQKeP02eutCvUroEwlcKW8IZf+QhMMoHY25goc6+WLXTp +l8ocDxCf1TjKfs05+sn9cS1bCpJQm3RrdZcrPp8QbaZs+YPDq7PaDtwm8ErHhTkPRo5HzuggbC oWPdzckP/xtS7Ev/2P2w/ibo1EUmlzZuhUr7CcWmRh3fz8Q4pjcDK7K4rfYaDLqc7ERfwQC1X7u HW31oaPq53ikRhk86UsKHRD3dhXGS6IkktdfB+7Tbj/I4dBM1JlxFt2nzbWWIb4VFgk3tLpiuF4 UhlKrpxaa5YUQcXNDxA== X-Proofpoint-Spam-Info: AW1haW4tMjYxMDMwMDAwMSBTYWx0ZWRfX2f6sVcki4McR G/IsECIT0V20NIg0JzlDtXuVdRHAhkq7ZKh4BnkRp7pWDZ28o4g0u84a5ZTIEsiszcCTjYFIFQc PYLg+tB/Wl0Mhq9L6szyen44x1VJU9/Q0y6x4tK8DPU+mA3p4+CW Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=alejandro.j.jimenez@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, KHOP_DYNAMIC=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1793320749700158500 Content-Type: text/plain; charset="utf-8" From: Dongli Zhang AMDVIAddressSpace->devfn only contains the PCI device/function number. AMD-Vi event log entries require the full DeviceID, including the PCI bus number. When reporting IO page faults for devices behind a pcie-root-port, QEMU logs the fault against the wrong requester. For example, a fault from 01:00.0 is reported as 00:00.0 because only devfn is passed to amdvi_page_fault(). [root@vm ~]# lspci ... ... 01:00.0 Ethernet controller: Red Hat, Inc. Virtio 1.0 network device (rev 0= 1) [ 58.154050] pci 0000:00:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain= =3D0x0000 address=3D0xc0000000 flags=3D0x000a] [ 58.156968] pci 0000:00:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain= =3D0x0000 address=3D0xc0000000 flags=3D0x000a] Use the full BDF consistently for AMD-Vi address spaces and pass it to page fault and page-table access error reporting. Fixes: d29a09ca6842 ("hw/i386: Introduce AMD IOMMU") Signed-off-by: Dongli Zhang Reviewed-by: Sairaj Kodilkar Reviewed-by: Alejandro Jimenez Signed-off-by: Alejandro Jimenez --- hw/i386/amd_iommu.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index fa590c9223..f52a922c69 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -66,6 +66,16 @@ typedef struct AMDVIIOTLBEntry { uint64_t page_mask; /* physical page size */ } AMDVIIOTLBEntry; =20 +static uint16_t amdvi_get_devid(PCIBus *bus, uint8_t devfn) +{ + return PCI_BUILD_BDF(pci_bus_num(bus), devfn); +} + +static uint16_t amdvi_get_as_devid(AMDVIAddressSpace *as) +{ + return amdvi_get_devid(as->bus, as->devfn); +} + /* * These 'fault' reasons have an overloaded meaning since they are not only * intended for describing reasons that generate an IO_PAGE_FAULT as per t= he AMD @@ -460,7 +470,7 @@ static gboolean amdvi_find_as_by_devid(gpointer key, gp= ointer value, const AMDVIAsKey *as =3D key; const uint16_t *devidp =3D user_data; =20 - return *devidp =3D=3D PCI_BUILD_BDF(pci_bus_num(as->bus), as->devfn); + return *devidp =3D=3D amdvi_get_devid(as->bus, as->devfn); } =20 static AMDVIAddressSpace *amdvi_get_as_by_devid(AMDVIState *s, uint16_t de= vid) @@ -665,7 +675,7 @@ static inline uint64_t amdvi_get_pte_entry(AMDVIState *= s, uint64_t pte_addr, =20 static int amdvi_as_to_dte(AMDVIAddressSpace *as, uint64_t *dte) { - uint16_t devid =3D PCI_BUILD_BDF(pci_bus_num(as->bus), as->devfn); + uint16_t devid =3D amdvi_get_as_devid(as); AMDVIState *s =3D as->iommu_state; =20 if (!amdvi_get_dte(s, devid, dte)) { @@ -764,6 +774,7 @@ static int fetch_pte(AMDVIAddressSpace *as, hwaddr addr= ess, uint64_t dte, uint8_t pt_level, next_pt_level; IOMMUAccessFlags perms; int ret; + uint16_t devid =3D amdvi_get_as_devid(as); =20 *page_size =3D 0; =20 @@ -781,7 +792,7 @@ static int fetch_pte(AMDVIAddressSpace *as, hwaddr addr= ess, uint64_t dte, * Pointer and indexing the top level table using the IOVA from the re= quest. */ pte_addr =3D NEXT_PTE_ADDR(dte, pt_level, address); - *pte =3D amdvi_get_pte_entry(as->iommu_state, pte_addr, as->devfn); + *pte =3D amdvi_get_pte_entry(as->iommu_state, pte_addr, devid); =20 if (*pte =3D=3D (uint64_t)-1) { /* @@ -837,7 +848,7 @@ static int fetch_pte(AMDVIAddressSpace *as, hwaddr addr= ess, uint64_t dte, *page_size =3D PTE_LEVEL_PAGE_SIZE(pt_level); =20 pte_addr =3D NEXT_PTE_ADDR(*pte, pt_level, address); - *pte =3D amdvi_get_pte_entry(as->iommu_state, pte_addr, as->devfn); + *pte =3D amdvi_get_pte_entry(as->iommu_state, pte_addr, devid); =20 if (*pte =3D=3D (uint64_t)-1) { /* Failure to read PTE. Page walk skips a page_size chunk */ @@ -1898,6 +1909,7 @@ static void amdvi_page_walk(AMDVIAddressSpace *as, ui= nt64_t *dte, uint8_t mode; uint64_t pte; int fetch_ret; + uint16_t devid =3D amdvi_get_as_devid(as); =20 /* make sure the DTE has TV =3D 1 */ if (!(dte[0] & AMDVI_DEV_TRANSLATION_VALID)) { @@ -1931,7 +1943,7 @@ static void amdvi_page_walk(AMDVIAddressSpace *as, ui= nt64_t *dte, if (fetch_ret < 0 || !IOMMU_PTE_PRESENT(pte) || perms !=3D (perms & amdvi_get_perms(pte))) { =20 - amdvi_page_fault(as->iommu_state, as->devfn, addr, perms); + amdvi_page_fault(as->iommu_state, devid, addr, perms); trace_amdvi_page_fault(addr); return; } @@ -1958,7 +1970,7 @@ static void amdvi_do_translate(AMDVIAddressSpace *as,= hwaddr addr, bool is_write, IOMMUTLBEntry *ret) { AMDVIState *s =3D as->iommu_state; - uint16_t devid =3D PCI_BUILD_BDF(pci_bus_num(as->bus), as->devfn); + uint16_t devid =3D amdvi_get_as_devid(as); AMDVIIOTLBEntry *iotlb_entry =3D amdvi_iotlb_lookup(s, addr, devid); uint64_t entry[4]; int dte_ret; --=20 2.47.3 From nobody Mon Nov 23 04:26:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1793320761; cv=none; d=zohomail.com; s=zohoarc; b=EivEzIil1ZZ0ovtJc07l04+9vl3wfm8d59JU1Anx+xAwzCMMZWdSRrScqUqY3qP91TNZh1dxWmdmh+vWvjzlUGzWqDbZNpfqqhWGY5ef/JtPdLnTf48BXHEUG5cBH+gUjyWge/dusWLxBIqVqrmRcvxpul0ZsbflvQS7kfraXsM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793320761; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8AO9zX02KKkYjQiAA6XL64wtAq8lOksvsfSsNfqqeLk=; b=YAGenGk8TAqy15IjrZY2Eqb6HI1MkjKntbbMHy6eJMgILQeCNloWoniMz+hGUEa0M1utBeluwb/flVfiWW8ek1M5MqHgfzuqOx87s5Scmvw2G/E14cd5UnBd6QbJTZ4iJddMf7lpHuym184SvwvpGULQxJEBWKGWiov1Y7a2NKU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179332076174842.00707322169285; Thu, 29 Oct 2026 17:39:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMadl-0004Z3-8y; Thu, 29 Oct 2026 20:38:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMada-0004WO-75 for qemu-devel@nongnu.org; Thu, 29 Oct 2026 20:38:30 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMadW-0003cy-OM for qemu-devel@nongnu.org; Thu, 29 Oct 2026 20:38:29 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69TLZ0JR2257137; Fri, 30 Oct 2026 00:38:23 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4hme61r42j-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=OK); Fri, 30 Oct 2026 00:38:23 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.11/8.18.1.11) with ESMTP id 69TNgCf52004316; Fri, 30 Oct 2026 00:38:22 GMT Received: from alaljime-e5-test-20240903-1847.osdevelopmeniad.oraclevcn.com (alaljime-e5-test-20240903-1847.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.206]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4hmg231tmh-4; Fri, 30 Oct 2026 00:38:21 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=8AO9z X02KKkYjQiAA6XL64wtAq8lOksvsfSsNfqqeLk=; b=YAy4p5yx5RLkKlfxH9R55 e6Du+vsBAGr5OXtQk0h1zCVBvrQ7rJoxqKvULv+8eqqT4+yVhhfRK13bz6eRrKEn ZcycgPxc4MNHc71qjblFY3dyeUFf/LvXthsae74ki0vHSdyOqqcynY/ltSNSZoVb Xf7qFwW2oYuyrnMzFwO63K1lav9OlS+3qfqwSIgKSgom6Vi4qFwV0qwgGaqsLCLt vINhOdI156L1LBmUae5q7w4cw5DtMQakGwvu51QH8X3jcal7Qm4Ml0eIJhnc0M54 CF5N9qklXnTyONA4ajF90e4u0oHJmO+GPzDL8M3vSHBH9oau03Pq5mhi5qDrZ9C5 g== From: Alejandro Jimenez To: mst@redhat.com, dongli.zhang@oracle.com Cc: qemu-devel@nongnu.org, sarunkod@amd.com, pbonzini@redhat.com, richard.henderson@linaro.org, joe.jin@oracle.com, alejandro.j.jimenez@oracle.com Subject: [PATCH v3 3/5] amd_iommu: Define MMIO register masks Date: Fri, 30 Oct 2026 00:38:15 +0000 Message-ID: <20261030003817.3521476-4-alejandro.j.jimenez@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261030003817.3521476-1-alejandro.j.jimenez@oracle.com> References: <20261030003817.3521476-1-alejandro.j.jimenez@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-10-29_07,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610300001 X-Authority-Analysis: v=2.4 cv=L9qI0OT8 c=1 sm=1 tr=0 ts=6ae3e6ff b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=EIcjfB9IiI4px24ztqRk:22 a=yPCof4ZbAAAA:8 a=zd2uoN0lAAAA:8 a=FWg1iXwi4-l0suFNVhsA:9 a=WmVTiCyuxqgg3mnwYu6p:22 X-Proofpoint-GUID: tn-lda6tzF0RIsVcDPoOq_gKrYqsH4aF X-Proofpoint-ORIG-GUID: tn-lda6tzF0RIsVcDPoOq_gKrYqsH4aF X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDMwMDAwMSBTYWx0ZWRfX5Ctws/713zk7 qiJJxRC31+VRo4urlrBWD3WcSoThenFvENSW5UIrA0PvLJRx+03hywq407anJiBq+9fQY2MyOuI eLiewLNI6I+KxNgOtuurCqZVP7YM6rynHCkkUQYesdTHJ3UG5BFTRrLQ/5dn1R+0X/nN3B8Oq5u dkYmXp4KsqPySUi/WkYUl71DmBs7sHC4iX7FJfI8MCY/8k+ZS53JRiXpKRU7xqKgm9DptFd4LOX Ap9EPGYDWg+sFURmlXLkWqqRlkgAmVBL5vxY1AFB8LA8HhY0XgQ1YfErVrAVXQ9jkup7sNulg0y /bgXmgoOQ6kjGDmwNBWKpYvO7gBstqA44xsjTRBCTK5tsLSh242srA41BkihV8OdaBytVRZ0dYZ IkCI/d0WQLSjRgO7Jkiv+PZjKMX3C7ccceI3VBgv2cfsNAWIPOyC2cWkOlDh/4tH8lnzPnhNeC9 x618ZdER9m6sKm6D1cQ== X-Proofpoint-Spam-Info: AW1haW4tMjYxMDMwMDAwMSBTYWx0ZWRfX2pr1rl0HCWaK yF8hd65PhWnriL0mWTNJaAgbXWjgd8lME9PEVT0vlEaO9hgXNsEOuS0xxxLTj4H95XLcTx4EFJV EIsgacZMhTNzepsr2/TxqMZrHzsZs0Ydj5oSC4p1NW+bGdzcNJHz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=alejandro.j.jimenez@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, KHOP_DYNAMIC=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1793320763812158500 Content-Type: text/plain; charset="utf-8" From: Dongli Zhang The MMIO read-only and write-1-to-clear masks used by amdvi_init() are currently hardcoded. The hardcoded values look ambiguous. Define named masks for the AMD-Vi MMIO registers to make the code easier to read and understand. No functional change is intended. Suggested-by: Sairaj Kodilkar Signed-off-by: Dongli Zhang Reviewed-by: Sairaj Kodilkar Reviewed-by: Alejandro Jimenez [ajz: apply Sairaj's naming requests, update all code references] Signed-off-by: Alejandro Jimenez --- hw/i386/amd_iommu.c | 18 ++++++++++-------- hw/i386/amd_iommu.h | 24 ++++++++++++++++++++---- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index f52a922c69..a7f735f691 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -294,7 +294,7 @@ static void amdvi_log_event(AMDVIState *s, uint64_t *ev= t) =20 /* event logging not enabled */ if (!s->evtlog_enabled || amdvi_test_mask(s, AMDVI_MMIO_STATUS, - AMDVI_MMIO_STATUS_EVT_OVF)) { + AMDVI_MMIO_STATUS_EVTLOG_OVF)) { return; } =20 @@ -304,7 +304,8 @@ static void amdvi_log_event(AMDVIState *s, uint64_t *ev= t) if (evtlog_tail_next =3D=3D s->evtlog_head) { /* generate overflow interrupt */ if (s->evtlog_intr) { - amdvi_assign_orq(s, AMDVI_MMIO_STATUS, AMDVI_MMIO_STATUS_EVT_O= VF); + amdvi_assign_orq(s, AMDVI_MMIO_STATUS, + AMDVI_MMIO_STATUS_EVTLOG_OVF); amdvi_generate_msi_interrupt(s); } return; @@ -325,7 +326,7 @@ static void amdvi_log_event(AMDVIState *s, uint64_t *ev= t) amdvi_writeq_raw(s, AMDVI_MMIO_EVENT_TAIL, s->evtlog_tail); =20 if (s->evtlog_intr) { - amdvi_assign_orq(s, AMDVI_MMIO_STATUS, AMDVI_MMIO_STATUS_EVENT_INT= ); + amdvi_assign_orq(s, AMDVI_MMIO_STATUS, AMDVI_MMIO_STATUS_EVTLOG_IN= T); amdvi_generate_msi_interrupt(s); } } @@ -1694,9 +1695,9 @@ static void amdvi_handle_control_write(AMDVIState *s) amdvi_assign_andq(s, AMDVI_MMIO_STATUS, ~AMDVI_MMIO_STATUS_CMDBUF_= RUN); } if (s->evtlog_enabled) { - amdvi_assign_orq(s, AMDVI_MMIO_STATUS, AMDVI_MMIO_STATUS_EVT_RUN); + amdvi_assign_orq(s, AMDVI_MMIO_STATUS, AMDVI_MMIO_STATUS_EVTLOG_RU= N); } else { - amdvi_assign_andq(s, AMDVI_MMIO_STATUS, ~AMDVI_MMIO_STATUS_EVT_RUN= ); + amdvi_assign_andq(s, AMDVI_MMIO_STATUS, ~AMDVI_MMIO_STATUS_EVTLOG_= RUN); } =20 trace_amdvi_control_status(control); @@ -1751,7 +1752,7 @@ static inline void amdvi_handle_evtbase_write(AMDVISt= ate *s) { uint64_t val =3D amdvi_readq(s, AMDVI_MMIO_EVENT_BASE); =20 - if (amdvi_readq(s, AMDVI_MMIO_STATUS) & AMDVI_MMIO_STATUS_EVENT_INT) + if (amdvi_readq(s, AMDVI_MMIO_STATUS) & AMDVI_MMIO_STATUS_EVTLOG_INT) /* Do not reset if eventlog interrupt bit is set*/ return; =20 @@ -2572,8 +2573,9 @@ static void amdvi_init(AMDVIState *s) memset(s->mmior, 0, AMDVI_MMIO_SIZE); amdvi_set_quad(s, AMDVI_MMIO_EXT_FEATURES, amdvi_extended_feature_register(s), - 0xffffffffffffffef, 0); - amdvi_set_quad(s, AMDVI_MMIO_STATUS, 0, 0x98, 0x67); + AMDVI_MMIO_EXT_FEATURE_RO_MASK, 0); + amdvi_set_quad(s, AMDVI_MMIO_STATUS, 0, AMDVI_MMIO_STATUS_RO_MASK, + AMDVI_MMIO_STATUS_W1C_MASK); } =20 static void amdvi_pci_realize(PCIDevice *pdev, Error **errp) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 948d8611b1..00842fd487 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -107,11 +107,25 @@ #define AMDVI_MMIO_CONTROL_INTCAPXTEN (1ULL << 51) =20 /* MMIO status register bits */ -#define AMDVI_MMIO_STATUS_CMDBUF_RUN (1 << 4) -#define AMDVI_MMIO_STATUS_EVT_RUN (1 << 3) +#define AMDVI_MMIO_STATUS_EVTLOG_OVF (1 << 0) +#define AMDVI_MMIO_STATUS_EVTLOG_INT (1 << 1) #define AMDVI_MMIO_STATUS_COMP_INT (1 << 2) -#define AMDVI_MMIO_STATUS_EVENT_INT (1 << 1) -#define AMDVI_MMIO_STATUS_EVT_OVF (1 << 0) +#define AMDVI_MMIO_STATUS_EVTLOG_RUN (1 << 3) +#define AMDVI_MMIO_STATUS_CMDBUF_RUN (1 << 4) +#define AMDVI_MMIO_STATUS_PPRLOG_OVF (1 << 5) +#define AMDVI_MMIO_STATUS_PPRLOG_INT (1 << 6) +#define AMDVI_MMIO_STATUS_PPRLOG_RUN (1 << 7) +#define AMDVI_MMIO_STATUS_GALOG_RUN (1 << 8) +#define AMDVI_MMIO_STATUS_GALOG_OVF (1 << 9) +#define AMDVI_MMIO_STATUS_GALOG_INT (1 << 10) + +#define AMDVI_MMIO_STATUS_RO_MASK \ + (AMDVI_MMIO_STATUS_EVTLOG_RUN | AMDVI_MMIO_STATUS_CMDBUF_RUN | \ + AMDVI_MMIO_STATUS_PPRLOG_RUN) +#define AMDVI_MMIO_STATUS_W1C_MASK \ + (AMDVI_MMIO_STATUS_EVTLOG_OVF | AMDVI_MMIO_STATUS_EVTLOG_INT | \ + AMDVI_MMIO_STATUS_COMP_INT | AMDVI_MMIO_STATUS_PPRLOG_OVF | \ + AMDVI_MMIO_STATUS_PPRLOG_INT) =20 #define AMDVI_CMDBUF_ID_BYTE 0x07 #define AMDVI_CMDBUF_ID_RSHIFT 4 @@ -230,6 +244,8 @@ (AMDVI_FEATURE_PREFETCH | AMDVI_FEATURE_IA | AMDVI_FEATURE_GT | \ AMDVI_GATS_MODE | AMDVI_HATS_MODE | AMDVI_FEATURE_GA) =20 +#define AMDVI_MMIO_EXT_FEATURE_RO_MASK 0xffffffffffffffefULL + /* capabilities header */ #define AMDVI_CAPAB_FEATURES (AMDVI_CAPAB_FLAT_EXT | \ AMDVI_CAPAB_FLAG_NPCACHE | AMDVI_CAPAB_FLAG_IOTLBSUP \ --=20 2.47.3 From nobody Mon Nov 23 04:26:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1793320734; cv=none; d=zohomail.com; s=zohoarc; b=cK/t/hbp5YH8wWIz9wTaF/SE4C1qjjfAeqJd0KKQa2WO3UkBAx4sgRt1j18Z3oHHAzJRzAOB/FA+BL5mvR3AuLlARSNfz5ht9mn1cDGY5fkP7y3QaAi/IZXcDvAwR6O6sMLHEc8BZA4ptBGUCMVb3juD17W0iC4trxMe+FQl01Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793320734; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fS878JvDwSoxy21uWvQp1e6kUR96roNKbLzoZATfr7c=; b=SRCOURJyQ1dMyGMLKvPrKO8ReP731FpnD1HsBcEr731yXq4x3UYYj7BqeM7GXAMHmk+ChSrAe2F9XgAExZDje+Y6woNhzC1qMXO/YsLo2+dhFTGkPaEPskCJnMk46L4kUwNGLB7rHu3/EnJFbarqPBYVMJDGTe1hgKD/TLnYh6Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793320734260509.1306805069813; Thu, 29 Oct 2026 17:38:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMada-0004WU-Js; Thu, 29 Oct 2026 20:38:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMadY-0004Vo-89 for qemu-devel@nongnu.org; Thu, 29 Oct 2026 20:38:28 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMadW-0003d0-EF for qemu-devel@nongnu.org; Thu, 29 Oct 2026 20:38:27 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69TLXjH73672987; Fri, 30 Oct 2026 00:38:24 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4hme5m04b0-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=OK); Fri, 30 Oct 2026 00:38:24 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.11/8.18.1.11) with ESMTP id 69TNg6vT2004177; Fri, 30 Oct 2026 00:38:23 GMT Received: from alaljime-e5-test-20240903-1847.osdevelopmeniad.oraclevcn.com (alaljime-e5-test-20240903-1847.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.206]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4hmg231tmh-5; Fri, 30 Oct 2026 00:38:22 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=fS878 JvDwSoxy21uWvQp1e6kUR96roNKbLzoZATfr7c=; b=hYyp/04hEGxpBnBAn3tlL 9yZ9JvgYUSFHs3BP7FcQfY3we5zj3mTGxw4hRR4eo/G3GKi1PQWa/IpPcqmHskjv 8AhPmTZB3ntNHIY+VvH+bC6XhUruiktdLGdbNlLlk9A9CVHtxBlCDNrv4denGHBv XsyC0IuGTyE/AvGKYlrjnM4hu0WE10Zj55wWzisThYQ9PeL6NNfzRLQGfCYsrXPz gOWMY4jGNMj6+d6lZf4szQEX/bOoQfNFUZ3kHRzw4FO/reTs1aHAQQ+XpyDygKQ7 LTj6NwPDpgqN9IX5d/0gsqXQL8IH+M3/rSh7g/I6x4Ver5QkrX0+nFmvCHJ906ir w== From: Alejandro Jimenez To: mst@redhat.com, dongli.zhang@oracle.com Cc: qemu-devel@nongnu.org, sarunkod@amd.com, pbonzini@redhat.com, richard.henderson@linaro.org, joe.jin@oracle.com, alejandro.j.jimenez@oracle.com Subject: [PATCH v3 4/5] amd_iommu: Make extended feature register read-only Date: Fri, 30 Oct 2026 00:38:16 +0000 Message-ID: <20261030003817.3521476-5-alejandro.j.jimenez@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261030003817.3521476-1-alejandro.j.jimenez@oracle.com> References: <20261030003817.3521476-1-alejandro.j.jimenez@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-10-29_07,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610300001 X-Authority-Analysis: v=2.4 cv=T6EZ3PKQ c=1 sm=1 tr=0 ts=6ae3e700 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=BqU2WV_vvsyTyxaotp0D:22 a=yPCof4ZbAAAA:8 a=zd2uoN0lAAAA:8 a=7djCcrdboBqnOOnk728A:9 a=WmVTiCyuxqgg3mnwYu6p:22 X-Proofpoint-GUID: wDKLyuU7kYR1J5m0A3PnM95-i2AzBbX6 X-Proofpoint-ORIG-GUID: wDKLyuU7kYR1J5m0A3PnM95-i2AzBbX6 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDMwMDAwMSBTYWx0ZWRfX8gjnLIf5qbEo zSCyUNohqAQXBSszHMUKSBR8ocxogykixod6+dKlR1euKf1jjS5LVSdKSFVIDg/hU9I4lPfoA3a h4s2PE1ZxmBoDgOoW7ds9g25w5SBBhEwgnitljTqkQQ1Oolgeh7ljlmLjYg7xbyIQ+3HVbW0M/m H21sZlx9v1P2e/fZw3YgUN+dmA48yM9VmCiNatVqaJyTsLHz2CsUKoTnVoSjLsXVaBbCjxejxTQ uX4Z9/Rn6RYEnwnaNklUyDzci1WAUH6oyKnYG5ZWtQnBQ4eyMi+iSNZD3wvmMNESZvEnlIG6awb 4zRX42LDDDtfpe4RVS2sZDQYvS8NShLzAIQEpol8h9oeA+vEDPhqrD+JuebuQrAEn1QtIe8Jdgc Gk7os6fcWrTGPk8Nl6ExH6i+G31bGg83jLYLj5uAYl3Nj0IPEBKVWT/GZ/k8jk8m62xDUrvaUo7 D8lRG8yUz9Vc8duc1CA== X-Proofpoint-Spam-Info: AW1haW4tMjYxMDMwMDAwMSBTYWx0ZWRfX/d0OeQ3wu+Pz rd6m0Re2Ouzasp66qv6aRths/jzxrw838YKZxAyRt10HK9wkK56zBnDKNs67s3B/gK2jQErOw/d GNHVTmZm7MV0nWnDqc1eTT3Cs/89DfKmKHS4DwLw2q7nyJMvChzG Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=alejandro.j.jimenez@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, KHOP_DYNAMIC=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1793320735528158500 Content-Type: text/plain; charset="utf-8" From: Dongli Zhang AMDVI_MMIO_EXT_FEATURES is populated from QEMU's advertised AMD-Vi extended feature set during reset. Guest writes to this register do not enable or disable any corresponding QEMU emulation behavior. Make the register fully read-only so the visible feature bits remain controlled by QEMU. According to the AMD IOMMU SDM, bits 25:24 (DualPprLogSup), 29:28 (DualEventLogSup), and 37 (USSup) are not specified as RO. This commit modifies only bit 4 (GTSup), while leaving the rest as they are. Suggested-by: Sairaj Kodilkar Signed-off-by: Dongli Zhang Reviewed-by: Sairaj Kodilkar Reviewed-by: Alejandro Jimenez [ajz: Remove guest modification claim. AMDVI_MMIO_EXT_FEATURES writes are not handled in amdvi_mmio_write(), so a guest cannot modify the register] Signed-off-by: Alejandro Jimenez --- hw/i386/amd_iommu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 00842fd487..b0a721bc00 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -244,7 +244,7 @@ (AMDVI_FEATURE_PREFETCH | AMDVI_FEATURE_IA | AMDVI_FEATURE_GT | \ AMDVI_GATS_MODE | AMDVI_HATS_MODE | AMDVI_FEATURE_GA) =20 -#define AMDVI_MMIO_EXT_FEATURE_RO_MASK 0xffffffffffffffefULL +#define AMDVI_MMIO_EXT_FEATURE_RO_MASK (~0ULL) =20 /* capabilities header */ #define AMDVI_CAPAB_FEATURES (AMDVI_CAPAB_FLAT_EXT | \ --=20 2.47.3 From nobody Mon Nov 23 04:26:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1793320743; cv=none; d=zohomail.com; s=zohoarc; b=KTEHcIPM5EKTl7m336j7aYUR7QiFI6+GpDyOPHUS+bEmZQV5ZaPOJSoudQg+tkSPGPUVs7zoopuO1BUSWVjQ/9lIfGpSJICeb76/PAhHoSm/iC1e1u/KbOk7tpc8bT+/okJs7jy8iwfn8uEYDedB4vddxFbp0fiUiHjfVZogImU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793320743; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OmBs+FrQ/XtXVbUQyk/xjCjt9d7HevdPxF1DNOshKjA=; b=T4z5vzaI2GKY1zEqXPeqOxWXqjqFYxlcDn1ZdM0YYUU49K0IKbyhbU6Sql4XS7GSbQ/E8HPKPhKgqeDD7J5qXz6rr+8k1yDgh1eUZQYtWbxNUNNdJ/mbBGfR/TkGppuFAUsCoB2eSBhsZMVFlfto4VlG91s4YutR4k4GrYgDp4I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179332074362496.60384335099127; Thu, 29 Oct 2026 17:39:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMadm-0004ZH-G5; Thu, 29 Oct 2026 20:38:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMadk-0004Yu-Mw for qemu-devel@nongnu.org; Thu, 29 Oct 2026 20:38:40 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMadY-0003d9-Dg for qemu-devel@nongnu.org; Thu, 29 Oct 2026 20:38:30 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69U0BBbb409647; Fri, 30 Oct 2026 00:38:25 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4hme5pr4bc-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=OK); Fri, 30 Oct 2026 00:38:24 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.11/8.18.1.11) with ESMTP id 69TNg94t2004283; Fri, 30 Oct 2026 00:38:24 GMT Received: from alaljime-e5-test-20240903-1847.osdevelopmeniad.oraclevcn.com (alaljime-e5-test-20240903-1847.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.250.206]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4hmg231tmh-6; Fri, 30 Oct 2026 00:38:23 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=OmBs+ FrQ/XtXVbUQyk/xjCjt9d7HevdPxF1DNOshKjA=; b=GBJ09t6uQ6utPDa041JeY AO7hFass3pdH/3RT6QY8ycEP6D95ppZmK8FQTIfMw85ADr9tLR/kz2hiG/0/7ruT fcww2R24pU7ggej4cuIPIi8OjuhNDr9OTk38E1EU28/qTkHngkOtp9MM+gZTukF9 qGh0ufrnaQeTgS74gBJ3dB5Y/Oau7aoHMI+KIr9z9XngQWQDfULt9c6BMk9tAdHm tfwVce6fe8biEjwyNOsJKEMSkVu1O1jBupVkWiJIQxaEZVL2ReALn/SU73LoKG38 qRj7A7zznDpwezN/q78966cSqDR9B+73MgS8gZS3C138V7YK7Bto32tM2c8pMuhn Q== From: Alejandro Jimenez To: mst@redhat.com, dongli.zhang@oracle.com Cc: qemu-devel@nongnu.org, sarunkod@amd.com, pbonzini@redhat.com, richard.henderson@linaro.org, joe.jin@oracle.com, alejandro.j.jimenez@oracle.com Subject: [PATCH v3 5/5] amd_iommu: Do not latch unsupported GA log status bits Date: Fri, 30 Oct 2026 00:38:17 +0000 Message-ID: <20261030003817.3521476-6-alejandro.j.jimenez@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261030003817.3521476-1-alejandro.j.jimenez@oracle.com> References: <20261030003817.3521476-1-alejandro.j.jimenez@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-10-29_07,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610300001 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDMwMDAwMSBTYWx0ZWRfXxHBVY0sj3fF2 05LI+pmFqY1ss3vUMAZOJyieaPxlRXfb542acnj1YF8tolm83Ofco37Eb1OqgSOBrGIOtFkguC2 9femzmnPpx6Lp2AeajX/P8iNCsSb4qu7/rG2jgLYbY7q6/e1cR9sspUH7ZJksJu6QrB+MmohFEj YnHIuqyYUi1coUqfKtliWIG670n/18TUWYWfHHWi3uy+YwpttxfXx8d2Mrytdtil5dAxm/zHqVp m8Zt2dvmMg1B4SVxYTwIjQGoCJuk0aUr9L6j7cP0AywHLVK8oLF1dHU9qGNrWv5f64AZcdKoas3 5AeUCbYSg/SgNeCESqoRbbmG08v50nfYYXwLQbHXSwXusNw4BEgF/eNeUYx+LeyWBBwnkbdty1F 4YQNC796uG5htSfB2BwIVb7o6R69ba7J66fRtZHuh4GWpv16rIb8rm5TVxtRQOG7aribri5966L XAT0eaFh8U2dmzeg0YQ== X-Authority-Analysis: v=2.4 cv=SI/Xx+vH c=1 sm=1 tr=0 ts=6ae3e700 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=RD47p0oAkeU5bO7t-o6f:22 a=yPCof4ZbAAAA:8 a=Lma_THHDjEIY_MpWOOcA:9 a=WmVTiCyuxqgg3mnwYu6p:22 X-Proofpoint-GUID: iDXP-0_yeM_gmLLh1O0JJbELq9X3QwD_ X-Proofpoint-Spam-Info: AW1haW4tMjYxMDMwMDAwMSBTYWx0ZWRfX1U8D/Ux57c43 SyI1KW64QGazn3SS9nL0vftas8X9fQLA8EXPAHjy6fV7ExUdobO5HWAIhUlSKweuoOI7KZn0/Gw ZUe+Pyns1p9vvSR2kPQlzQDS64zQBbLjd1cqkJfPqdimiYVuj9tn X-Proofpoint-ORIG-GUID: iDXP-0_yeM_gmLLh1O0JJbELq9X3QwD_ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=alejandro.j.jimenez@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, KHOP_DYNAMIC=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1793320745527158500 Content-Type: text/plain; charset="utf-8" From: Dongli Zhang When QEMU records an AMD-Vi event-log entry for an IO page fault, it sets the event interrupt status bit and injects the event interrupt. Linux kernel prior to commit 2379f3485239 ("iommu/amd: Refactor IOMMU interrupt handling logic for Event, PPR, and GA logs") clears the status register with a combined mask AMD_IOMMU_INT_MASK when handling any IOMMU interrupt. That mask includes the GA log interrupt (MMIO_STATUS_GALOG_INT_MASK) and overflow (MMIO_STATUS_GALOG_OVERFLOW_MASK) bits, even when the interrupt being handled is only an event-log interrupt. QEMU does not produce GA log entries or set GA log status. However, the emulated status register still accepts guest writes to the GA log status bits as normal writes. As a result, a guest status clear write that includes those bits can latch a spurious GA log overflow. The guest then observes GA log status that QEMU did not generate and repeatedly restarts the GA log. The below guest dmesg logs are from v6.4 Linux kernel. [ 57.818224] virtio-pci 0000:01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT= domain=3D0x0000 address=3D0xc0000000 flags=3D0x0009] [ 57.821130] virtio-pci 0000:01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT= domain=3D0x0000 address=3D0xc0000000 flags=3D0x0009] [ 57.824003] AMD-Vi: IOMMU GA Log overflow [ 57.825099] AMD-Vi: IOMMU GA Log restarting [ 57.826338] AMD-Vi: IOMMU GA Log overflow [ 57.827425] AMD-Vi: IOMMU GA Log restarting [ 57.828657] AMD-Vi: IOMMU GA Log overflow [ 57.829758] AMD-Vi: IOMMU GA Log restarting [ 57.830986] AMD-Vi: IOMMU GA Log overflow [ 57.832063] AMD-Vi: IOMMU GA Log restarting Mainline Linux commit 2379f3485239 ("iommu/amd: Refactor IOMMU interrupt handling logic for Event, PPR, and GA logs") avoids triggering this by chance by clearing only the status bits for the log being handled. However, older guests still use the combined clear mask. Add the GA log interrupt and overflow bits to the AMDVI_MMIO_STATUS w1cmask so guest writes cannot create unsupported GA log status. Add AMDVI_MMIO_STATUS_GALOG_RUN to AMDVI_MMIO_STATUS_RO_MASK. This does not implement GA log production. It only prevents guest status clear writes from creating GA log status that QEMU did not generate to emulate IO page fault for guest Linux kernel. Fixes: 12499b23315b ("x86_iommu/amd: Enable Guest virtual APIC support") Signed-off-by: Dongli Zhang Reviewed-by: Alejandro Jimenez [ajz: Add GALOG_RUN to the read-only mask per Sairaj's request] Signed-off-by: Alejandro Jimenez --- hw/i386/amd_iommu.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index b0a721bc00..3d2ee9faf5 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -121,11 +121,12 @@ =20 #define AMDVI_MMIO_STATUS_RO_MASK \ (AMDVI_MMIO_STATUS_EVTLOG_RUN | AMDVI_MMIO_STATUS_CMDBUF_RUN | \ - AMDVI_MMIO_STATUS_PPRLOG_RUN) + AMDVI_MMIO_STATUS_PPRLOG_RUN | AMDVI_MMIO_STATUS_GALOG_RUN) #define AMDVI_MMIO_STATUS_W1C_MASK \ (AMDVI_MMIO_STATUS_EVTLOG_OVF | AMDVI_MMIO_STATUS_EVTLOG_INT | \ AMDVI_MMIO_STATUS_COMP_INT | AMDVI_MMIO_STATUS_PPRLOG_OVF | \ - AMDVI_MMIO_STATUS_PPRLOG_INT) + AMDVI_MMIO_STATUS_PPRLOG_INT | AMDVI_MMIO_STATUS_GALOG_OVF | \ + AMDVI_MMIO_STATUS_GALOG_INT) =20 #define AMDVI_CMDBUF_ID_BYTE 0x07 #define AMDVI_CMDBUF_ID_RSHIFT 4 --=20 2.47.3