Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1030935ybh; Thu, 16 Jul 2020 00:52:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxh9WwY8hjrxFW1HmiiLiFg2pSZl5ZloWW9cpSdfPJJBJu4pxTKkWeHArqnAHxmb4sG7H+M X-Received: by 2002:a05:6402:22c1:: with SMTP id dm1mr3395251edb.187.1594885960121; Thu, 16 Jul 2020 00:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594885960; cv=none; d=google.com; s=arc-20160816; b=ohfsgqDgnV3dxWczYrSp95NTg3dkKEks7KUDRvoDZioAEmWLIrGC8AW1M5tWBfuSof NvQ8Yo3BhqKxYqq/B3ya+fer3EiPTaYhxTPi/1TFhH0yxHnZlt0WPjGbY3nrqHy3Uf93 I7ktfNlzinEuCTLb2uHlo29E20q6tJRrLFj0jA3G8YeZtsTc8OOn9teT2ugdfU8AHuTA ddHv2jt5Tn48HTNI3n+WW5ONEVxRZitBPaiwQ1y1n7y4OYohSoR0iHdUJhaGGEiPMKKa Hfj5YWQ+zkiFnb63/Fla2O8M1D6RZn8RJdSPJHrO7y3LkDDEMEBNGGy8ATNluLsOmY7N 2/0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=6zwh3uv/4dKOUDKuvTiQugEhD9LKpVaA1KJEov11HNA=; b=vWOXh7o2NbQsUPHbsb10NKGW+QlT5WXqk5WHACUrxl4K9lPDW6R8QXi/0XmcCAd+NR tWk0Mgd4dSCmQXw9ojhCTdZVkjJSVpzcu+qaSs6jg6Cc2VIR2UiuJwLooDcf8BtlpXWK ZlBFP8MCtQIzF8d+W6hk4jS/ez2EaiMkt0kMmKOZkylKCnZbjQvKl6RYjzH12RKCktJ1 w2sf9p3gzhXYj0eCfj8h8rhmhPmE/Os9kDULeCABhF46z0tr3JVcWzLfBMtQWNFPuYU/ ULG5mei+NholVKwTbAErICP289dla+k0gLx2Muc9e7RIlKejXYXkPmZQxh8r6zPLCXXW GYkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XZQAAKHB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z1si2746502eju.231.2020.07.16.00.52.17; Thu, 16 Jul 2020 00:52:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XZQAAKHB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725965AbgGPHwE (ORCPT + 99 others); Thu, 16 Jul 2020 03:52:04 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:22299 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725867AbgGPHwE (ORCPT ); Thu, 16 Jul 2020 03:52:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594885922; 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=6zwh3uv/4dKOUDKuvTiQugEhD9LKpVaA1KJEov11HNA=; b=XZQAAKHBIjeQ6YO3V45litMoaKslbOoMz9lm+yxZ6BCKFjReGnbxlXmAebzqtu6Urp1B7s aAv8yeZDGCePnIzDQObz/OLkj1Eet0wnbf+35rl97ln3I6rjfuihENWJSuZJ38xpwumdaB Xb19ADZ2wVs5/BF3A5yGGsuT5OxqvyU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-294-leaykoy7M9GUz5dciJ2ADQ-1; Thu, 16 Jul 2020 03:52:00 -0400 X-MC-Unique: leaykoy7M9GUz5dciJ2ADQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A915E107BEF5; Thu, 16 Jul 2020 07:51:58 +0000 (UTC) Received: from [10.36.115.54] (ovpn-115-54.ams2.redhat.com [10.36.115.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F72F2B6D6; Thu, 16 Jul 2020 07:51:56 +0000 (UTC) Subject: Re: [PATCH v4 4/7] iommu/vt-d: Handle non-page aligned address To: Jacob Pan , iommu@lists.linux-foundation.org, LKML , Lu Baolu , Joerg Roedel , David Woodhouse Cc: Yi Liu , "Tian, Kevin" , Raj Ashok References: <1594080774-33413-1-git-send-email-jacob.jun.pan@linux.intel.com> <1594080774-33413-5-git-send-email-jacob.jun.pan@linux.intel.com> From: Auger Eric Message-ID: <889b3fcd-482a-46b7-7b95-19555f73f907@redhat.com> Date: Thu, 16 Jul 2020 09:51:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <1594080774-33413-5-git-send-email-jacob.jun.pan@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacob, On 7/7/20 2:12 AM, Jacob Pan wrote: > From: Liu Yi L > > Address information for device TLB invalidation comes from userspace > when device is directly assigned to a guest with vIOMMU support. > VT-d requires page aligned address. This patch checks and enforce > address to be page aligned, otherwise reserved bits can be set in the > invalidation descriptor. Unrecoverable fault will be reported due to > non-zero value in the reserved bits. > > Fixes: 61a06a16e36d8 ("iommu/vt-d: Support flushing more translation > cache types") > Acked-by: Lu Baolu > Signed-off-by: Liu Yi L > Signed-off-by: Jacob Pan Reviewed-by: Eric Auger Thanks Eric > > --- > drivers/iommu/intel/dmar.c | 20 ++++++++++++++++++-- > 1 file changed, 18 insertions(+), 2 deletions(-) > > diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c > index d9f973fa1190..b2c53bada905 100644 > --- a/drivers/iommu/intel/dmar.c > +++ b/drivers/iommu/intel/dmar.c > @@ -1455,9 +1455,25 @@ void qi_flush_dev_iotlb_pasid(struct intel_iommu *iommu, u16 sid, u16 pfsid, > * Max Invs Pending (MIP) is set to 0 for now until we have DIT in > * ECAP. > */ > - desc.qw1 |= addr & ~mask; > - if (size_order) > + if (addr & GENMASK_ULL(size_order + VTD_PAGE_SHIFT, 0)) > + pr_warn_ratelimited("Invalidate non-aligned address %llx, order %d\n", addr, size_order); > + > + /* Take page address */ > + desc.qw1 = QI_DEV_EIOTLB_ADDR(addr); > + > + if (size_order) { > + /* > + * Existing 0s in address below size_order may be the least > + * significant bit, we must set them to 1s to avoid having > + * smaller size than desired. > + */ > + desc.qw1 |= GENMASK_ULL(size_order + VTD_PAGE_SHIFT, > + VTD_PAGE_SHIFT); > + /* Clear size_order bit to indicate size */ > + desc.qw1 &= ~mask; > + /* Set the S bit to indicate flushing more than 1 page */ > desc.qw1 |= QI_DEV_EIOTLB_SIZE; > + } > > qi_submit_sync(iommu, &desc, 1, 0); > } >