From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44B5FC63798 for ; Fri, 27 Nov 2020 02:19:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC2302222A for ; Fri, 27 Nov 2020 02:19:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392217AbgK0CTh (ORCPT ); Thu, 26 Nov 2020 21:19:37 -0500 Received: from mga12.intel.com ([192.55.52.136]:47086 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726862AbgK0CTh (ORCPT ); Thu, 26 Nov 2020 21:19:37 -0500 IronPort-SDR: 8NLzduzmRdA21wl3Qty2vC+gSwAJ8gAXpkbSthH6L5s3Ra2/oHbgbUtKiRA15GkbCTMtO0aUk6 zry9f9DP7GwA== X-IronPort-AV: E=McAfee;i="6000,8403,9817"; a="151598331" X-IronPort-AV: E=Sophos;i="5.78,373,1599548400"; d="scan'208";a="151598331" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Nov 2020 18:19:37 -0800 IronPort-SDR: FodFk3QrbyI6BY9uQxnhwXY38q6hBzF/dolTaX28Cqh9/1CBQEKcVNVhbibbl5Hnd6FmorPjGt 7r5AXsbcaVIQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,373,1599548400"; d="scan'208";a="433391800" Received: from allen-box.sh.intel.com (HELO [10.239.159.28]) ([10.239.159.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Nov 2020 18:19:35 -0800 Cc: baolu.lu@linux.intel.com, Joerg Roedel , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, stable@kernel.vger.org Subject: Re: Question about domain_init (v5.3-v5.7) To: Jerry Snitselaar References: <87h7pd6v2k.fsf@redhat.com> <87a6v3hkd9.fsf@jsnitsel.users.ipa.redhat.com> From: Lu Baolu Message-ID: <72a7b338-2481-8c0a-5641-6f448557f6ee@linux.intel.com> Date: Fri, 27 Nov 2020 10:12:17 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <87a6v3hkd9.fsf@jsnitsel.users.ipa.redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jerry, On 11/27/20 5:35 AM, Jerry Snitselaar wrote: > > Lu Baolu @ 2020-11-26 04:01 MST: > >> Hi Jerry, >> >> On 2020/11/26 4:27, Jerry Snitselaar wrote: >>> Is there a reason we check the requested guest address width against >>> the >>> iommu's mgaw, instead of the agaw that we already know for the iommu? >>> I've run into a case with a new system where the mgaw reported is 57, >>> but if they set PAE to 46 instead of 52 in the bios, then sagaw reports >>> the highest supported agaw is 48 and the domain_init code fails here. In >> >> Isn't this a platform bug? If it's too late to fix it in the BIOS, you >> maybe have to add a platform specific quirk to set mgaw to the highest >> supported agaw? >> >> Best regards, >> baolu > > Is there somewhere you can point me to that discusses how they should be > setting the mgaw? I misunderstood when I previously asked you about > whether the mgaw could be a value that was greater than any of sagaw. > If it is a bios issue, then they should fix it there. MGAW indicates the max gpa width supported by 2nd translation. The VT-d spec requires that this value must be at least equal to the host physical addressibility. According to this, BIOS is good, right? For this failure case, domain_init() just wants to find a suitable agaw for the private domain. I think it makes sense to check against iommu->agaw instead of cap_mgaw. Best regards, baolu > >> >>> other places like prepare_domain_attach_device, the dmar domain agaw >>> gets adjusted down to the iommu agaw. The agaw of the iommu gets >>> determined based off what is reported for sagaw. I'm wondering if it >>> can't instead do: >>> --- >>> drivers/iommu/intel-iommu.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> diff --git a/drivers/iommu/intel-iommu.c >>> b/drivers/iommu/intel-iommu.c >>> index 6ca5c92ef2e5..a8e41ec36d9e 100644 >>> --- a/drivers/iommu/intel-iommu.c >>> +++ b/drivers/iommu/intel-iommu.c >>> @@ -1862,8 +1862,8 @@ static int domain_init(struct dmar_domain *domain, struct intel_iommu *iommu, >>> domain_reserve_special_ranges(domain); >>> /* calculate AGAW */ >>> - if (guest_width > cap_mgaw(iommu->cap)) >>> - guest_width = cap_mgaw(iommu->cap); >>> + if (guest_width > agaw_to_width(iommu->agaw)) >>> + guest_width = agaw_to_width(iommu->agaw); >>> domain->gaw = guest_width; >>> adjust_width = guestwidth_to_adjustwidth(guest_width); >>> agaw = width_to_agaw(adjust_width); >>> -- >>> 2.27.0 >>> >>> Thoughts? With the former code the ehci device for the ilo fails when >>> trying to get a private domain. >>> Thanks, >>> Jerry >>> >