From nobody Sun May 19 23:34:09 2024 Delivered-To: importer@patchew.org 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=lists.gnu.org; Authentication-Results: mx.zohomail.com; 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=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1575540092; cv=none; d=zohomail.com; s=zohoarc; b=RHjC2Z1+9AqVnADDhwTW4EcjVK+xFfJWVvnozRJ2HSpvlmcc7KN0e3Uk0Mnms4kMn1P5KeRFBeCjZoAHmhawjrdHQMqT0KPZWNjfBW8j6sLAW0suG1tYzycnpxRbYBRIA/qg0PFlTg4QKwtQczmjIPRlInoFdLMIraHyXrLlcgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575540092; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=WOgmsP4Pg6nynyDAhy/OFhQ/NSs3A1q3fPitnwX/XlU=; b=LeofmxePKZwYVQrLM55Da+5NjnIFPDbpkrSnM+J57vTtYWmoG7TEmQ/XvZ7T5QS+TjjAENkL10rs7eb6XWMJ+3rG+/JraRwI4gul4C7k4xc/dLUvS59GzSj9Dhu5544/XARRkQfpR7TBn6KahYUH2aSCd+9kV908BcqF1OnDfgg= ARC-Authentication-Results: i=1; mx.zohomail.com; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1575540092743857.3841384849326; Thu, 5 Dec 2019 02:01:32 -0800 (PST) Received: from localhost ([::1]:52206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icnww-00053w-Nh for importer@patchew.org; Thu, 05 Dec 2019 05:01:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33106) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icnvL-00048Y-Gk for qemu-devel@nongnu.org; Thu, 05 Dec 2019 04:59:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icnvJ-00009B-7a for qemu-devel@nongnu.org; Thu, 05 Dec 2019 04:59:51 -0500 Received: from mga02.intel.com ([134.134.136.20]:7856) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1icnvI-00005j-S1 for qemu-devel@nongnu.org; Thu, 05 Dec 2019 04:59:49 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Dec 2019 01:59:42 -0800 Received: from yisun1-ubuntu.bj.intel.com ([10.238.156.100]) by fmsmga001.fm.intel.com with ESMTP; 05 Dec 2019 01:59:40 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,281,1571727600"; d="scan'208";a="219160278" From: Yi Sun To: qemu-devel@nongnu.org Subject: [PATCH v1] intel_iommu: fix bug to read DMAR_RTADDR_REG Date: Thu, 5 Dec 2019 17:54:39 +0800 Message-Id: <20191205095439.29114-1-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 2.15.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.20 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jasowang@redhat.com, Yi Sun , dgilbert@redhat.com, peterx@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Should directly read DMAR_RTADDR_REG but not using 's->root'. Because 's->root' is modified in 'vtd_root_table_setup()' so that the first 12 bits are omitted. This causes the guest iommu debugfs cannot show pasid tables. Signed-off-by: Yi Sun Reviewed-by: Peter Xu --- hw/i386/intel_iommu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 43c94b993b..ee06993675 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2610,16 +2610,15 @@ static uint64_t vtd_mem_read(void *opaque, hwaddr a= ddr, unsigned size) switch (addr) { /* Root Table Address Register, 64-bit */ case DMAR_RTADDR_REG: + val =3D vtd_get_quad_raw(s, DMAR_RTADDR_REG); if (size =3D=3D 4) { - val =3D s->root & ((1ULL << 32) - 1); - } else { - val =3D s->root; + val =3D val & ((1ULL << 32) - 1); } break; =20 case DMAR_RTADDR_REG_HI: assert(size =3D=3D 4); - val =3D s->root >> 32; + val =3D vtd_get_quad_raw(s, DMAR_RTADDR_REG) >> 32; break; =20 /* Invalidation Queue Address Register, 64-bit */ --=20 2.17.1