Linux-NVDIMM Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 14/16] x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search
       [not found] <1451081365-15190-1-git-send-email-toshi.kani@hpe.com>
@ 2015-12-25 22:09 ` Toshi Kani
  2015-12-26 10:38   ` Borislav Petkov
  2015-12-25 22:09 ` [PATCH v2 16/16] ACPI/EINJ: Allow memory error injection to NVDIMM Toshi Kani
  1 sibling, 1 reply; 4+ messages in thread
From: Toshi Kani @ 2015-12-25 22:09 UTC (permalink / raw)
  To: akpm, bp
  Cc: linux-arch, linux-mm, linux-kernel, Dan Williams, Dave Young, x86,
	linux-nvdimm, Toshi Kani

Change to call walk_iomem_res_desc() for searching resource entries
with the following names:
 "ACPI Tables"
 "ACPI Non-volatile Storage"
 "Persistent Memory (legacy)"
 "Crash kernel"

Note, the caller of walk_iomem_res() with "GART" is left unchanged
because this entry may be initialized by out-of-tree drivers, which
do not have 'desc' set to IORES_DESC_GART.

Cc: Borislav Petkov <bp@alien8.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: x86@kernel.org
Cc: linux-nvdimm@lists.01.org
Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
---
 arch/x86/kernel/crash.c |    4 ++--
 arch/x86/kernel/pmem.c  |    4 ++--
 drivers/nvdimm/e820.c   |    2 +-
 kernel/kexec_file.c     |    8 ++++----
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index 2c1910f..082373b 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -588,12 +588,12 @@ int crash_setup_memmap_entries(struct kimage *image, struct boot_params *params)
 	/* Add ACPI tables */
 	cmd.type = E820_ACPI;
 	flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-	walk_iomem_res("ACPI Tables", flags, 0, -1, &cmd,
+	walk_iomem_res_desc(IORES_DESC_ACPI_TABLES, flags, 0, -1, &cmd,
 		       memmap_entry_callback);
 
 	/* Add ACPI Non-volatile Storage */
 	cmd.type = E820_NVS;
-	walk_iomem_res("ACPI Non-volatile Storage", flags, 0, -1, &cmd,
+	walk_iomem_res_desc(IORES_DESC_ACPI_NV_STORAGE, flags, 0, -1, &cmd,
 			memmap_entry_callback);
 
 	/* Add crashk_low_res region */
diff --git a/arch/x86/kernel/pmem.c b/arch/x86/kernel/pmem.c
index 14415af..92f7014 100644
--- a/arch/x86/kernel/pmem.c
+++ b/arch/x86/kernel/pmem.c
@@ -13,11 +13,11 @@ static int found(u64 start, u64 end, void *data)
 
 static __init int register_e820_pmem(void)
 {
-	char *pmem = "Persistent Memory (legacy)";
 	struct platform_device *pdev;
 	int rc;
 
-	rc = walk_iomem_res(pmem, IORESOURCE_MEM, 0, -1, NULL, found);
+	rc = walk_iomem_res_desc(IORES_DESC_PERSISTENT_MEMORY_LEGACY,
+				 IORESOURCE_MEM, 0, -1, NULL, found);
 	if (rc <= 0)
 		return 0;
 
diff --git a/drivers/nvdimm/e820.c b/drivers/nvdimm/e820.c
index b0045a5..95825b3 100644
--- a/drivers/nvdimm/e820.c
+++ b/drivers/nvdimm/e820.c
@@ -55,7 +55,7 @@ static int e820_pmem_probe(struct platform_device *pdev)
 	for (p = iomem_resource.child; p ; p = p->sibling) {
 		struct nd_region_desc ndr_desc;
 
-		if (strncmp(p->name, "Persistent Memory (legacy)", 26) != 0)
+		if (p->desc != IORES_DESC_PERSISTENT_MEMORY_LEGACY)
 			continue;
 
 		memset(&ndr_desc, 0, sizeof(ndr_desc));
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index c245085..e2bd737 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -522,10 +522,10 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz,
 
 	/* Walk the RAM ranges and allocate a suitable range for the buffer */
 	if (image->type == KEXEC_TYPE_CRASH)
-		ret = walk_iomem_res("Crash kernel",
-				     IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY,
-				     crashk_res.start, crashk_res.end, kbuf,
-				     locate_mem_hole_callback);
+		ret = walk_iomem_res_desc(IORES_DESC_CRASH_KERNEL,
+				IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY,
+				crashk_res.start, crashk_res.end, kbuf,
+				locate_mem_hole_callback);
 	else
 		ret = walk_system_ram_res(0, -1, kbuf,
 					  locate_mem_hole_callback);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 16/16] ACPI/EINJ: Allow memory error injection to NVDIMM
       [not found] <1451081365-15190-1-git-send-email-toshi.kani@hpe.com>
  2015-12-25 22:09 ` [PATCH v2 14/16] x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search Toshi Kani
@ 2015-12-25 22:09 ` Toshi Kani
  1 sibling, 0 replies; 4+ messages in thread
From: Toshi Kani @ 2015-12-25 22:09 UTC (permalink / raw)
  To: akpm, bp
  Cc: linux-arch, linux-mm, linux-kernel, Rafael J. Wysocki,
	Vishal Verma, Tony Luck, Dan Williams, linux-nvdimm, linux-acpi,
	Toshi Kani

In the case of memory error injection, einj_error_inject() checks
if a target address is System RAM.  Change this check to allow
injecting a memory error to NVDIMM by calling region_intersects()
with IORES_DESC_PERSISTENT_MEMORY.  This enables memory error
testing on both System RAM and NVDIMM.

In addition, page_is_ram() is replaced with region_intersects()
with IORESOURCE_SYSTEM_RAM, so that it can verify a target address
range with the requested size.

Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: linux-nvdimm@lists.01.org
Cc: linux-acpi@vger.kernel.org
Acked-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
---
 drivers/acpi/apei/einj.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index 0431883..16cae66 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -519,7 +519,7 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
 			     u64 param3, u64 param4)
 {
 	int rc;
-	unsigned long pfn;
+	u64 base_addr, size;
 
 	/* If user manually set "flags", make sure it is legal */
 	if (flags && (flags &
@@ -545,10 +545,17 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
 	/*
 	 * Disallow crazy address masks that give BIOS leeway to pick
 	 * injection address almost anywhere. Insist on page or
-	 * better granularity and that target address is normal RAM.
+	 * better granularity and that target address is normal RAM or
+	 * NVDIMM.
 	 */
-	pfn = PFN_DOWN(param1 & param2);
-	if (!page_is_ram(pfn) || ((param2 & PAGE_MASK) != PAGE_MASK))
+	base_addr = param1 & param2;
+	size = ~param2 + 1;
+
+	if (((param2 & PAGE_MASK) != PAGE_MASK) ||
+	    ((region_intersects(base_addr, size, IORESOURCE_SYSTEM_RAM,
+			IORES_DESC_NONE) != REGION_INTERSECTS) &&
+	     (region_intersects(base_addr, size, IORESOURCE_MEM,
+			IORES_DESC_PERSISTENT_MEMORY) != REGION_INTERSECTS)))
 		return -EINVAL;
 
 inject:

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 14/16] x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search
  2015-12-25 22:09 ` [PATCH v2 14/16] x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search Toshi Kani
@ 2015-12-26 10:38   ` Borislav Petkov
  2015-12-27  0:31     ` Toshi Kani
  0 siblings, 1 reply; 4+ messages in thread
From: Borislav Petkov @ 2015-12-26 10:38 UTC (permalink / raw)
  To: Toshi Kani
  Cc: akpm, linux-arch, linux-mm, linux-kernel, Dan Williams,
	Dave Young, x86, linux-nvdimm

On Fri, Dec 25, 2015 at 03:09:23PM -0700, Toshi Kani wrote:
> Change to call walk_iomem_res_desc() for searching resource entries
> with the following names:
>  "ACPI Tables"
>  "ACPI Non-volatile Storage"
>  "Persistent Memory (legacy)"
>  "Crash kernel"
> 
> Note, the caller of walk_iomem_res() with "GART" is left unchanged
> because this entry may be initialized by out-of-tree drivers, which
> do not have 'desc' set to IORES_DESC_GART.

There's this out-of-tree bogus argument again. :\

Why do we care about out-of-tree drivers?

You can just as well fix the "GART" case too and kill walk_iomem_res()
altogether...

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 14/16] x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search
  2015-12-26 10:38   ` Borislav Petkov
@ 2015-12-27  0:31     ` Toshi Kani
  0 siblings, 0 replies; 4+ messages in thread
From: Toshi Kani @ 2015-12-27  0:31 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: akpm, linux-arch, kexec, linux-mm, linux-kernel, Dan Williams,
	Dave Young, x86, linux-nvdimm

+ cc: kexec list

On 12/26/2015 3:38 AM, Borislav Petkov wrote:
> On Fri, Dec 25, 2015 at 03:09:23PM -0700, Toshi Kani wrote:
>> Change to call walk_iomem_res_desc() for searching resource entries
>> with the following names:
>>   "ACPI Tables"
>>   "ACPI Non-volatile Storage"
>>   "Persistent Memory (legacy)"
>>   "Crash kernel"
>>
>> Note, the caller of walk_iomem_res() with "GART" is left unchanged
>> because this entry may be initialized by out-of-tree drivers, which
>> do not have 'desc' set to IORES_DESC_GART.
>
> There's this out-of-tree bogus argument again. :\
>
> Why do we care about out-of-tree drivers?
>
> You can just as well fix the "GART" case too and kill walk_iomem_res()
> altogether...

Right, but I do not see any "GART" case in the upstream code, so I 
cannot change it...

Thanks,
-Toshi

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-27  0:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1451081365-15190-1-git-send-email-toshi.kani@hpe.com>
2015-12-25 22:09 ` [PATCH v2 14/16] x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search Toshi Kani
2015-12-26 10:38   ` Borislav Petkov
2015-12-27  0:31     ` Toshi Kani
2015-12-25 22:09 ` [PATCH v2 16/16] ACPI/EINJ: Allow memory error injection to NVDIMM Toshi Kani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox