From nobody Sun Nov 24 08:38:41 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1726067317; cv=none; d=zohomail.com; s=zohoarc; b=oFoe1X8QeHhKzyv1qtFtjjjgUXHwi2DzZHNDH4aMMknuSeTZn5sG2e/AztfC8PA5borJnec+U5BhrnL1+g3UOJMSmDDxJsuOBO7tBBTvsqThFWn9V6SmnbV/u7qcYy1utz86JlJt2+r6p1sl193QiD/dwRUl5YSE0VZjOcXUNjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726067317; h=Content-Type: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=bY3kFhk2MQOhFrrXbGMngbSdwByo8f4uY8jy3ERVqew=; b=QflJWFIFh2/u221uksHk5U64Lm1P9aHv24vshYpb6LLPNdQ4hev/VbkS5KZcu6NyGU1z6mQ+m6opP2ZmBPDa5rLHTHR0Bl1FlXTJZIq7/JG29jigdyaBG326uagSG7/GmMjp+JjrSi5yoDVsiNwogboZTaBIJuDQWyRPWG/6Ou0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726067317037693.0463650521766; Wed, 11 Sep 2024 08:08:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOn7-0003ig-Ph; Wed, 11 Sep 2024 10:57:59 -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 1soOhk-00078a-Ib for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1soOha-0007Dt-Sd for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52:20 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-412-0xm-B_Y7OL--D-ct_F0bXg-1; Wed, 11 Sep 2024 09:51:54 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5c3c256e2a3so5362058a12.2 for ; Wed, 11 Sep 2024 06:51:53 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d258354d1sm620068366b.13.2024.09.11.06.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726066332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bY3kFhk2MQOhFrrXbGMngbSdwByo8f4uY8jy3ERVqew=; b=cZOl26mRMJ/eJnI/OdKQr8YFGRU5qnjDxfcT+ogVKaP8n49g7KY87qHCPmX1xUdZg/qZoq VB8Gx1bLhFl+p9sDGumKJIKmNkyd3QRi25OH7t0crXllFyWV11ZsMWjwpPOE80iDTFDPUH jG58bJvR4W5yoJk61kKdEm9S9dvVuBY= X-MC-Unique: 0xm-B_Y7OL--D-ct_F0bXg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062712; x=1726667512; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bY3kFhk2MQOhFrrXbGMngbSdwByo8f4uY8jy3ERVqew=; b=LV4wkkVSb0zFluHNAqdsKi+C20owZuNSPTNQ1lOwXzxIIoW5kwuziqf5bePiK7j2Kq 5GgzQZr4zQxqqa4d6HSayU5DWWb0l8x15lVW1CvBDw4VZHrBv1ZI2OrIh1CZlLDkc3Q7 EICB+PzkrLt0LN0H9ggOo4zgVX50sfZddV1KHXQkXdkF2vNG8kG2PMM74sP3SU5Nwyum 26Uye73rt50oEXxdYdKlfJ9oY+mxfMKyBaKa05s6JtDfnr7+9WpiGMuDifPCZdQIZP0g sZldntAq431+uDy8+EMvvmbBpOFMxdL817fyHPoqns22958EPmltWF+L4gAEmu1puCsS zhQA== X-Gm-Message-State: AOJu0Yxi5QIl4oHEYG4SYqUBCRopbPgbqADNUlCjVDSvjNkwn3kzSzcy Nm7ssSuFdO7finMvAI6TEhvs3ck4R5o2RiGokLDQhDpizwnt50nL5hzh5+mOoJHG39lh1nXvuTY 2MAJTcqU1eWOcz5M38mZv8GDLAs79/98chx5q3IitlHiNTJdzDyjoho/u+HE3txKwb+K/dUPqwN djPBW7UYROUSAiDwBJjHmKwT2dKgS1KQ== X-Received: by 2002:a17:906:d54b:b0:a8c:d6a3:d03a with SMTP id a640c23a62f3a-a8ffab18781mr379087666b.21.1726062712056; Wed, 11 Sep 2024 06:51:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdUTOIul3p3RXD60SbSrV4T0ZNZ8f38tSJB3JJikoRHl9kx7775iRWvtWUySz6TnMaK7nc1Q== X-Received: by 2002:a17:906:d54b:b0:a8c:d6a3:d03a with SMTP id a640c23a62f3a-a8ffab18781mr379083266b.21.1726062711359; Wed, 11 Sep 2024 06:51:51 -0700 (PDT) Date: Wed, 11 Sep 2024 09:51:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhenzhong Duan , =?utf-8?Q?Cl=C3=A9ment?= Mathieu--Drif , Yi Liu , Jason Wang , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 08/18] intel_iommu: Fix invalidation descriptor type field Message-ID: <663168943d3db6d9b51d3dfa0998848a6e6eda71.1726062663.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 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 @redhat.com) X-ZM-MESSAGEID: 1726067318262116600 From: Zhenzhong Duan According to spec, invalidation descriptor type is 7bits which is concatenation of bits[11:9] and bits[3:0] of invalidation descriptor. Currently we only pick bits[3:0] as the invalidation type and treat bits[11:9] as reserved zero. This is not a problem for now as bits[11:9] is zero for all current invalidation types. But it will break if newer type occupies bits[11:9]. Fix it by taking bits[11:9] into type and make reserved bits check accurate. Suggested-by: Cl=C3=A9ment Mathieu--Drif Signed-off-by: Zhenzhong Duan Reviewed-by: Yi Liu Reviewed-by: Cl=C3=A9ment Mathieu--Drif Message-Id: <20240814071321.2621384-2-zhenzhong.duan@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 11 ++++++----- hw/i386/intel_iommu.c | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 5f32c36943..13d5d129ae 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -356,7 +356,8 @@ union VTDInvDesc { typedef union VTDInvDesc VTDInvDesc; =20 /* Masks for struct VTDInvDesc */ -#define VTD_INV_DESC_TYPE 0xf +#define VTD_INV_DESC_TYPE(val) ((((val) >> 5) & 0x70ULL) | \ + ((val) & 0xfULL)) #define VTD_INV_DESC_CC 0x1 /* Context-cache Invalidate De= sc */ #define VTD_INV_DESC_IOTLB 0x2 #define VTD_INV_DESC_DEVICE 0x3 @@ -372,7 +373,7 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_WAIT_IF (1ULL << 4) #define VTD_INV_DESC_WAIT_FN (1ULL << 6) #define VTD_INV_DESC_WAIT_DATA_SHIFT 32 -#define VTD_INV_DESC_WAIT_RSVD_LO 0Xffffff80ULL +#define VTD_INV_DESC_WAIT_RSVD_LO 0Xfffff180ULL #define VTD_INV_DESC_WAIT_RSVD_HI 3ULL =20 /* Masks for Context-cache Invalidation Descriptor */ @@ -383,7 +384,7 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_CC_DID(val) (((val) >> 16) & VTD_DOMAIN_ID_MAS= K) #define VTD_INV_DESC_CC_SID(val) (((val) >> 32) & 0xffffUL) #define VTD_INV_DESC_CC_FM(val) (((val) >> 48) & 3UL) -#define VTD_INV_DESC_CC_RSVD 0xfffc00000000ffc0ULL +#define VTD_INV_DESC_CC_RSVD 0xfffc00000000f1c0ULL =20 /* Masks for IOTLB Invalidate Descriptor */ #define VTD_INV_DESC_IOTLB_G (3ULL << 4) @@ -393,7 +394,7 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_IOTLB_DID(val) (((val) >> 16) & VTD_DOMAIN_ID_MAS= K) #define VTD_INV_DESC_IOTLB_ADDR(val) ((val) & ~0xfffULL) #define VTD_INV_DESC_IOTLB_AM(val) ((val) & 0x3fULL) -#define VTD_INV_DESC_IOTLB_RSVD_LO 0xffffffff0000ff00ULL +#define VTD_INV_DESC_IOTLB_RSVD_LO 0xffffffff0000f100ULL #define VTD_INV_DESC_IOTLB_RSVD_HI 0xf80ULL #define VTD_INV_DESC_IOTLB_PASID_PASID (2ULL << 4) #define VTD_INV_DESC_IOTLB_PASID_PAGE (3ULL << 4) @@ -406,7 +407,7 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_DEVICE_IOTLB_SIZE(val) ((val) & 0x1) #define VTD_INV_DESC_DEVICE_IOTLB_SID(val) (((val) >> 32) & 0xFFFFULL) #define VTD_INV_DESC_DEVICE_IOTLB_RSVD_HI 0xffeULL -#define VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO 0xffff0000ffe0fff8 +#define VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO 0xffff0000ffe0f1f0 =20 /* Rsvd field masks for spte */ #define VTD_SPTE_SNP 0x800ULL diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 16d2885fcc..68cb72a481 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2744,7 +2744,7 @@ static bool vtd_process_inv_desc(IntelIOMMUState *s) return false; } =20 - desc_type =3D inv_desc.lo & VTD_INV_DESC_TYPE; + desc_type =3D VTD_INV_DESC_TYPE(inv_desc.lo); /* FIXME: should update at first or at last? */ s->iq_last_desc_type =3D desc_type; =20 --=20 MST