Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp650817imu; Fri, 11 Jan 2019 06:49:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN7kDVbD0UDtSE4JunLyg/BGJ8q7y38pnpPP1b82a7PB04KsHrWFrovHfqHZvxwV/41doNse X-Received: by 2002:a63:1560:: with SMTP id 32mr13348933pgv.383.1547218173966; Fri, 11 Jan 2019 06:49:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547218173; cv=none; d=google.com; s=arc-20160816; b=YtZwGVZ5dK2fMkpMEOCXVj/yUhRAZ9zqqB5aW6PtSGWg8+qtaqP7JMyJ8/DvJtMG9o s1mGYP510sWcU630ClxF9zeoTSdV3oliYYvnn3kDu9BoSfgGZlTnsgpTJnwgZYCkMIlS hsO8I75uCk5DA4QM2WsZwZvta7kE6nQ1sZpMW3rcOFjv3mh3l1VtyfVf1/HVGorY5sMk IvWS8hN4rKlijJR/fCBOfiCRA57zkFLm9YG55YT5Gg8AsNJ0vTAYHMG1x+VWcgYVaAYn 9nq4IiA0qq7af8X3iwoPFE2aNginZylzEH6gDr3lMwpCiOQ103+l7fnHP8mD4kjjjaZo sOUg== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/5bwOpbPyuzfyeG01yxGt5chk6gZKg/nA/m/5s3ayYI=; b=MT1CrHwDmsjLo4HkLjSzPRXhL36cP+w2B0/2m7xrGJ9iWs45RKSlKIt8AOwGMwYcOP MqvTVG3dyL0N6whGq5fOol+TjE+8P3lV3LsKtHwrJLheilR/QNsqNCBDcMPxxdgri55v U3qzOXsOwcVj8K+UJO9iqi8XtFhnnXv8AmXTQQEP7h3q5WCfViEEhKtGj47p4P8r9wG0 gpu9oIfGhORw4I1p0kj7f3adBauxzCyhmQ5MQumsnpJ0m4FlPyK2V2iYMPmpBMpcQXoC Qwx7e40F47luKebdSz5cy6mJeSVQpYYzdnVEHq2KIZNUswsXmy2BlOnB4+rEzAdGmO38 X36w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=S3KmBYxk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si1087475plq.371.2019.01.11.06.49.18; Fri, 11 Jan 2019 06:49:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=S3KmBYxk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391488AbfAKOrY (ORCPT + 99 others); Fri, 11 Jan 2019 09:47:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:38668 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391390AbfAKOrV (ORCPT ); Fri, 11 Jan 2019 09:47:21 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7DDE42063F; Fri, 11 Jan 2019 14:47:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547218040; bh=r7y15Grucrf0LGXelMlve6wIEgUgLw1S8IV4kcReYtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S3KmBYxkV3pb03Q/0J5cWzH6+U/lmsBwLclWG9Ox6Z4czSwQCl7CgyICLvLSwcwTU UnV+hlOzDVuw0KXP1hgjbA9NlT6iQa8m8fkqamIRt95KA9zDAqvKPyREdZ7HYBq0us NhtjcRjRCPons+PdKiRAxelUIpE5Lcx8Z18h2TLs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ashok Raj , Jacob Pan , Lu Baolu , "Ramos Falcon, Ernesto R" , Ricardo Neri , Sohil Mehta , Joerg Roedel Subject: [PATCH 4.4 83/88] iommu/vt-d: Handle domain agaw being less than iommu agaw Date: Fri, 11 Jan 2019 15:08:52 +0100 Message-Id: <20190111131059.557465397@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131045.137499039@linuxfoundation.org> References: <20190111131045.137499039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sohil Mehta commit 3569dd07aaad71920c5ea4da2d5cc9a167c1ffd4 upstream. The Intel IOMMU driver opportunistically skips a few top level page tables from the domain paging directory while programming the IOMMU context entry. However there is an implicit assumption in the code that domain's adjusted guest address width (agaw) would always be greater than IOMMU's agaw. The IOMMU capabilities in an upcoming platform cause the domain's agaw to be lower than IOMMU's agaw. The issue is seen when the IOMMU supports both 4-level and 5-level paging. The domain builds a 4-level page table based on agaw of 2. However the IOMMU's agaw is set as 3 (5-level). In this case the code incorrectly tries to skip page page table levels. This causes the IOMMU driver to avoid programming the context entry. The fix handles this case and programs the context entry accordingly. Fixes: de24e55395698 ("iommu/vt-d: Simplify domain_context_mapping_one") Cc: Cc: Ashok Raj Cc: Jacob Pan Cc: Lu Baolu Reviewed-by: Lu Baolu Reported-by: Ramos Falcon, Ernesto R Tested-by: Ricardo Neri Signed-off-by: Sohil Mehta Signed-off-by: Joerg Roedel Signed-off-by: Greg Kroah-Hartman --- drivers/iommu/intel-iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -2041,7 +2041,7 @@ static int domain_context_mapping_one(st * than default. Unnecessary for PT mode. */ if (translation != CONTEXT_TT_PASS_THROUGH) { - for (agaw = domain->agaw; agaw != iommu->agaw; agaw--) { + for (agaw = domain->agaw; agaw > iommu->agaw; agaw--) { ret = -ENOMEM; pgd = phys_to_virt(dma_pte_addr(pgd)); if (!dma_pte_present(pgd)) @@ -2055,7 +2055,7 @@ static int domain_context_mapping_one(st translation = CONTEXT_TT_MULTI_LEVEL; context_set_address_root(context, virt_to_phys(pgd)); - context_set_address_width(context, iommu->agaw); + context_set_address_width(context, agaw); } else { /* * In pass through mode, AW must be programmed to