From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751706AbdG1JGY (ORCPT ); Fri, 28 Jul 2017 05:06:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59358 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751595AbdG1JGX (ORCPT ); Fri, 28 Jul 2017 05:06:23 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5CA7A10E2E Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=bhe@redhat.com Date: Fri, 28 Jul 2017 17:06:19 +0800 From: Baoquan He To: Joerg Roedel Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 10/13] iommu/amd: Allocate memory below 4G for dev table if translation pre-enabled Message-ID: <20170728090619.GM24304@x1> References: <1500627551-12930-1-git-send-email-bhe@redhat.com> <1500627551-12930-11-git-send-email-bhe@redhat.com> <20170727155550.GO3610@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170727155550.GO3610@suse.de> User-Agent: Mutt/1.7.0 (2016-08-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 28 Jul 2017 09:06:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joerg, On 07/27/17 at 05:55pm, Joerg Roedel wrote: > On Fri, Jul 21, 2017 at 04:59:08PM +0800, Baoquan He wrote: > > AMD pointed out it's unsafe to update the device-table while iommu > > is enabled. It turns out that device-table pointer update is split > > up into two 32bit writes in the IOMMU hardware. So updating it while > > the IOMMU is enabled could have some nasty side effects. > > > > The only way to work around this is to allocate the device-table below > > 4GB if translation is pre-enabled in kdump kernel. If allocation failed, > > still use the old one. > > Not only for the kdump kernel. The old device table must also be below > 4GB so that its pointer can be updated with a 32bit write. > > If the old table is above 4GB you still need the second write to zero > the upper parts of the pointer in hardware. Do you mean the allocation of amd_iommu_dev_table in early_amd_iommu_init() also need be addressed for 1st kernel? Seems we don't make sure that for 1st kernel, like adding GFP_DMA32 flag when allocate amd_iommu_dev_table in amd_iommu_dev_table early_amd_iommu_init().