iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Charlotte Tan <charlotte@extrahop.com>
To: iommu@lists.linux.dev
Cc: yian.chen@intel.com, dwmw2@infradead.org,
	baolu.lu@linux.intel.com, joro@8bytes.org,
	junichi.nomura@nec.com, atomlin@redhat.com,
	Charlotte Tan <charlotte@extrahop.com>,
	Will Mortensen <will@extrahop.com>
Subject: [PATCH] iommu/vt-d: allow NVS regions in arch_rmrr_sanity_check()
Date: Wed, 28 Sep 2022 21:44:49 -0700	[thread overview]
Message-ID: <20220929044449.32515-1-charlotte@extrahop.com> (raw)

arch_rmrr_sanity_check() warns if the RMRR is not covered by an ACPI Reserved
region, but it seems like it should accept an NVS region as well. The ACPI spec
https://uefi.org/specs/ACPI/6.5/15_System_Address_Map_Interfaces.html
uses similar wording for "Reserved" and "NVS" region types; for NVS regions it
says "This range of addresses is in use or reserved by the system and must
not be used by the operating system."

There is an old comment on this mailing list that also suggests NVS regions should
pass the arch_rmrr_sanity_check() test:

> The warnings come from arch_rmrr_sanity_check() since it checks whether the
> region is E820_TYPE_RESERVED.  However, if the purpose of the check is to
> detect RMRR has regions that may be used by OS as free memory, isn't
> E820_TYPE_NVS safe, too?

https://lore.kernel.org/linux-iommu/64a5843d-850d-e58c-4fc2-0a0eeeb656dc@nec.com/

This patch overlaps with another proposed patch that would add the region
type to the log since sometimes the bug reporter sees this log on the console
but doesn't know to include the kernel log:

https://lore.kernel.org/lkml/20220611204859.234975-3-atomlin@redhat.com/

Here's an example of the "Firmware Bug" apparent false positive:

> DMAR: [Firmware Bug]: No firmware reserved region can cover this RMRR [0x000000006f760000-0x000000006f762fff], contact BIOS vendor for fixes
> DMAR: [Firmware Bug]: Your BIOS is broken; bad RMRR [0x000000006f760000-0x000000006f762fff]

This is the snippet from the e820 table:

> BIOS-e820: [mem 0x0000000068bff000-0x000000006ebfefff] reserved
> BIOS-e820: [mem 0x000000006ebff000-0x000000006f9fefff] ACPI NVS
> BIOS-e820: [mem 0x000000006f9ff000-0x000000006fffefff] ACPI data

There are more details at https://bugzilla.kernel.org/show_bug.cgi?id=216443

Fixes: f036c7fa0ab6 ("iommu/vt-d: Check VT-d RMRR region in BIOS is reported as reserved")
Cc: Will Mortensen <will@extrahop.com>
Link: https://lore.kernel.org/linux-iommu/64a5843d-850d-e58c-4fc2-0a0eeeb656dc@nec.com/
Link: https://bugzilla.kernel.org/show_bug.cgi?id=216443
Signed-off-by: Charlotte Tan <charlotte@extrahop.com>
---
 arch/x86/include/asm/iommu.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
index 0bef44d30a27..0e99cc1aec08 100644
--- a/arch/x86/include/asm/iommu.h
+++ b/arch/x86/include/asm/iommu.h
@@ -25,8 +25,10 @@ arch_rmrr_sanity_check(struct acpi_dmar_reserved_memory *rmrr)
 {
 	u64 start = rmrr->base_address;
 	u64 end = rmrr->end_address + 1;
+	int entry_type;
 
-	if (e820__mapped_all(start, end, E820_TYPE_RESERVED))
+	entry_type = e820__get_entry_type(start, end);
+	if ((entry_type == E820_TYPE_RESERVED) || (entry_type == E820_TYPE_NVS))
 		return 0;
 
 	pr_err(FW_BUG "No firmware reserved region can cover this RMRR [%#018Lx-%#018Lx], contact BIOS vendor for fixes\n",
-- 
2.17.1


             reply	other threads:[~2022-09-29  4:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29  4:44 Charlotte Tan [this message]
2022-09-29  7:53 ` [PATCH] iommu/vt-d: allow NVS regions in arch_rmrr_sanity_check() Aaron Tomlin
2022-10-10 12:03 ` Baolu Lu
2022-10-10 13:28   ` Aaron Tomlin
2022-10-10 13:31     ` Aaron Tomlin
     [not found]       ` <CA+N19e6+Qab5qhQOj_QDGU60Ef_V4eJzCydmM_Qa0LGxn8_JvQ@mail.gmail.com>
2022-10-11 19:41         ` Charlotte Tan
2022-10-19  0:52 ` Baolu Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220929044449.32515-1-charlotte@extrahop.com \
    --to=charlotte@extrahop.com \
    --cc=atomlin@redhat.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=junichi.nomura@nec.com \
    --cc=will@extrahop.com \
    --cc=yian.chen@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).