Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp302675ybl; Wed, 11 Dec 2019 18:46:41 -0800 (PST) X-Google-Smtp-Source: APXvYqyPMAqPQVDKVeFxTG0C6KHPQcm7OgB2jomx7Uc21ciw664rbYAdabiBLTVavCongr6ziMcO X-Received: by 2002:a9d:4789:: with SMTP id b9mr5678402otf.110.1576118801473; Wed, 11 Dec 2019 18:46:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576118801; cv=none; d=google.com; s=arc-20160816; b=CRXq/wBq1XVGrI5/PfTFMeH1zFwcudPtDQkUs5xv3z7RZBWaqROO/22HYADcQNYW0c I975CDVAlkNZaG/oSUSapOUqeC5XR63/5KAhNYss9OiAiEZnfE1joKn2wlgtoN3jsIvp 1ft7EEJ6XWHJYwytltbjzkRsBEpiJeDHJXOVFRYqOqOddNYKcPOMriZyWtk/HOKqscKf PkXAAGDplY8I3PGk0KAd5h/XEjgzMBEoJrGV0dVqvbkXrEcrKNWvYAQLrveF+bHeRxuW +He4Y9gAYLEv6rHafEkta+DniOkK7Ff6rsdR7ZjDr5FJxFhNzNWu45TKvzZXcyTH0LHN rSCg== 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:to:subject:cc; bh=3pOd0bvoFmKmhmRpitqzgxq2m8bTzNMWWEiDr8T2+K4=; b=KzfuaYfCWibUws1xQNSNT3TXSPQk8oV+KAxcoUzX+lrGezlQV6V9BEGQqxwH9XabHm 4uaTkSUlRrv7HnElDk7pb7L7C2ttM9/etxtZQCOsId3In23piAn+8XNMeJJDHymhJt/Z lOapwE5y9zafdAUtKXh76trIjU+qpNeJwBCCFGDN+K+fDJu55UWk/NZT7jdy2c5MU04C svao/FxeUvr3m6ckiN2W0ssbF8ZjSlMsfC4ZJuRLQ0z0iKhqjmWWQhuPTpCT2YAB7Fox 5gDVuJmyc4SvQL6rYFQrHuowVeeOX+WGGlX000KwXPZQ094MovW+rel3/AXtF963HCLx 1rwg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m12si2243037otq.286.2019.12.11.18.46.28; Wed, 11 Dec 2019 18:46:41 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727789AbfLLCoe (ORCPT + 99 others); Wed, 11 Dec 2019 21:44:34 -0500 Received: from mga01.intel.com ([192.55.52.88]:5564 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727770AbfLLCoe (ORCPT ); Wed, 11 Dec 2019 21:44:34 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Dec 2019 18:44:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,304,1571727600"; d="scan'208";a="225754041" Received: from allen-box.sh.intel.com (HELO [10.239.159.136]) ([10.239.159.136]) by orsmga002.jf.intel.com with ESMTP; 11 Dec 2019 18:44:31 -0800 Cc: baolu.lu@linux.intel.com, iommu@lists.linux-foundation.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/3] iommu/vt-d bad RMRR workarounds To: Barret Rhoden , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , David Woodhouse , Joerg Roedel , Yian Chen , Sohil Mehta References: <20191211194606.87940-1-brho@google.com> From: Lu Baolu Message-ID: <35f49464-0ce5-9998-12a0-624d9683ea18@linux.intel.com> Date: Thu, 12 Dec 2019 10:43:45 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 In-Reply-To: <20191211194606.87940-1-brho@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 12/12/19 3:46 AM, Barret Rhoden via iommu wrote: > I can imagine a bunch of ways around this. > > One option is to hook in a check for buggy RMRRs in intel-iommu.c. If > the base and end are 0, just ignore the entry. That works for my > specific buggy DMAR entry. There might be other buggy entries out > there. The docs specify some requirements on the base and end (called > limit) addresses. > > Another option is to change the sanity check so that unmapped ranges are > considered OK. That would work for my case, but only because we're > hiding the firmware bug: my DMAR has a bad RMRR that happens to fall into a > reserved or non-existent range. The downside here is that we'd > presumably be setting up an IOMMU mapping for this bad RMRR. But at > least it's not pointing to any RAM we're using. (That's actually what > goes on in the current, non-kexec case for me. Phys page 0 is marked > RESERVED, and I have an RMRR that points to it.) This option also would > cover any buggy firmwares that use an actual RMRR that pointed to memory > that was omitted from the e820 map. > > A third option: whenever the RMRR sanity check fails, just ignore it and > return 0. Don't set up the rmrru. Right now, we completely abort DMAR > processing. If there was an actual device that needed to poke this > memory that failed the sanity check (meaning, not RESERVED, currently), > then we're already in trouble; that device could clobber RAM, right? If > we're going to use the IOMMU, I'd rather the device be behind an IOMMU > with*no* mapping for the region, so it couldn't clobber whatever we > happened to put in that location. > > I actually think all three options are reasonable ideas independently of > one another. This patchset that does all three. Please take at least > one of them. =) (May require a slight revision if you don't take all > of them). The VT-d spec defines the BIOS considerations about RMRR in section 8.4: " BIOS must report the RMRR reported memory addresses as reserved (or as EFI runtime) in the system memory map returned through methods such as INT15, EFI GetMemoryMap etc. " So we should treat it as firmware bug if the RMRR range is not mapped as RESERVED in the system memory map table. As for how should the driver handle this case, ignoring buggy RMRR with a warning message might be a possible choice. Best regards, baolu