From nobody Mon Nov 25 09:54:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.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=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1716359452; cv=none; d=zohomail.com; s=zohoarc; b=frVmH6Knfi9LiFjcPEfAlmZ4//41ZvLcCKsxn684PgPGma2WBK93kXNpC5feceDKaWN1apI1Snn8iB56J125CbuDJvzBC0ADSX9PG4X0wJ2C6S7Sl36GqMeIG6inYxzN0W24ODuDcTiKVwCW+gVQue4ithBhKyUb1MYWOwkQZYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716359452; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sK17AonbvMdBhQkM/g5pO5qWEYgH+Uy+WpPQaqTXaO4=; b=JWcoMPmbAy8W7DkQjdexY1R+dOEBN0IqFjo/R+T/gzCwlapBVS6yIYwL3MAra2XI1UcVW5E/bp8s+GUNenwX5GyV4gSezubgKEF8Ojnyt+JYPvl0gb+uPH7q0arXJQ4O0Ei6mmjHCVHGI+P2WIFoC4T29E7mZi+ZwsoGcuLZOIw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17163594527841018.287987011962; Tue, 21 May 2024 23:30:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9fSi-000789-53; Wed, 22 May 2024 02:28:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9fRO-0005hx-0J for qemu-devel@nongnu.org; Wed, 22 May 2024 02:27:10 -0400 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9fRM-0006jy-8n for qemu-devel@nongnu.org; Wed, 22 May 2024 02:27:09 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 23:27:06 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 23:27:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716359228; x=1747895228; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jvy+iy1hOkE9h3oLFlev3YfseKo4APjCUCxIGJhkwOo=; b=Rwax7vnu2j6i4hqZfx6O9pJJlK7g8LxZ0gHKxsxmUU7v05TZ8n1QJEda ujrGLYKmzYhqG/qhJZa463Pgh/D/gsBUf6Jez8lfZfYM+By4qRbulhM++ dl5Qtk7zR4A7MELUQuzwpQHc4yi23ohY6RORHp7YOLQqLx7faDesfVR2/ SRPhZMFqus+XARA3y1liNnY0MX0AoOQJn/ab2dIchgEqU8stSxtdGco8g KmnXXP82WiOdtEi4hj6p8Lu09Lh+kdFeS8s0KjYA+525oBVhKpzAZwCVR acHsuQ5dxRNHJAFR8LUJDVLdzRSGGc1o9nBOfW4mNBOjQyDxRzo7zU5GY A==; X-CSE-ConnectionGUID: 2aoXNAvURCeYjlFipdvLMw== X-CSE-MsgGUID: xQndOPgcTrikIgY+2SAEPw== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="37972750" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="37972750" X-CSE-ConnectionGUID: 0UlVAaF3ThGmkBwwwqO5lg== X-CSE-MsgGUID: XihXTWhITxeUlgtwRj7Vpg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33597978" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, mst@redhat.com, peterx@redhat.com, jasowang@redhat.com, jgg@nvidia.com, nicolinc@nvidia.com, joao.m.martins@oracle.com, clement.mathieu--drif@eviden.com, kevin.tian@intel.com, yi.l.liu@intel.com, chao.p.peng@intel.com, Zhenzhong Duan , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PATCH rfcv2 15/17] intel_iommu: Set default aw_bits to 48 in scalable modren mode Date: Wed, 22 May 2024 14:23:11 +0800 Message-Id: <20240522062313.453317-16-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522062313.453317-1-zhenzhong.duan@intel.com> References: <20240522062313.453317-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=192.198.163.7; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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: 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 @intel.com) X-ZM-MESSAGEID: 1716359453262100001 Content-Type: text/plain; charset="utf-8" According to VTD spec, stage-1 page table could support 4-level and 5-level paging. However, 5-level paging translation emulation is unsupported yet. That means the only supported value for aw_bits is 48. So default aw_bits to 48 in scalable modern mode. In other cases, it is still default to 39 for compatibility. Add a check to ensure user specified value is 48 in modern mode for now. Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index e07daaba99..a4c241ea96 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3748,7 +3748,7 @@ static Property vtd_properties[] =3D { ON_OFF_AUTO_AUTO), DEFINE_PROP_BOOL("x-buggy-eim", IntelIOMMUState, buggy_eim, false), DEFINE_PROP_UINT8("aw-bits", IntelIOMMUState, aw_bits, - VTD_HOST_ADDRESS_WIDTH), + 0xff), DEFINE_PROP_BOOL("caching-mode", IntelIOMMUState, caching_mode, FALSE), DEFINE_PROP_BOOL("x-scalable-mode", IntelIOMMUState, scalable_mode, FA= LSE), DEFINE_PROP_BOOL("snoop-control", IntelIOMMUState, snoop_control, fals= e), @@ -4663,6 +4663,14 @@ static bool vtd_decide_config(IntelIOMMUState *s, Er= ror **errp) } } =20 + if (s->aw_bits =3D=3D 0xff) { + if (s->scalable_modern) { + s->aw_bits =3D VTD_HOST_AW_48BIT; + } else { + s->aw_bits =3D VTD_HOST_AW_39BIT; + } + } + if ((s->aw_bits !=3D VTD_HOST_AW_39BIT) && (s->aw_bits !=3D VTD_HOST_AW_48BIT) && !s->scalable_modern) { @@ -4671,6 +4679,12 @@ static bool vtd_decide_config(IntelIOMMUState *s, Er= ror **errp) return false; } =20 + if ((s->aw_bits !=3D VTD_HOST_AW_48BIT) && s->scalable_modern) { + error_setg(errp, "Supported values for aw-bits are: %d", + VTD_HOST_AW_48BIT); + return false; + } + if (s->scalable_mode && !s->dma_drain) { error_setg(errp, "Need to set dma_drain for scalable mode"); return false; --=20 2.34.1