mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bjorn.helgaas@hp.com>
To: David Mosberger <davidm@hpl.hp.com>
Cc: linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC] prevent "dd if=/dev/mem" crash
Date: Thu, 23 Oct 2003 15:05:34 -0600	[thread overview]
Message-ID: <200310231505.34320.bjorn.helgaas@hp.com> (raw)
In-Reply-To: <200310201142.26676.bjorn.helgaas@hp.com>

The drivers/char/mem.c change was accepted, so here's the
ia64-specific part.

===== arch/ia64/kernel/efi.c 1.26 vs edited =====
--- 1.26/arch/ia64/kernel/efi.c	Tue Oct 21 18:52:48 2003
+++ edited/arch/ia64/kernel/efi.c	Thu Oct 23 14:35:08 2003
@@ -711,6 +711,32 @@
 	return 0;
 }
 
+int
+valid_phys_addr_range (unsigned long phys_addr, unsigned long *size)
+{
+	void *efi_map_start, *efi_map_end, *p;
+	efi_memory_desc_t *md;
+	u64 efi_desc_size;
+
+	efi_map_start = __va(ia64_boot_param->efi_memmap);
+	efi_map_end   = efi_map_start + ia64_boot_param->efi_memmap_size;
+	efi_desc_size = ia64_boot_param->efi_memdesc_size;
+
+	for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
+		md = p;
+
+		if (phys_addr - md->phys_addr < (md->num_pages << EFI_PAGE_SHIFT)) {
+			if (!(md->attribute & EFI_MEMORY_WB))
+				return 0;
+
+			if (*size > md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - phys_addr)
+				*size = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - phys_addr;
+			return 1;
+		}
+	}
+	return 0;
+}
+
 static void __exit
 efivars_exit (void)
 {
===== include/asm-ia64/io.h 1.17 vs edited =====
--- 1.17/include/asm-ia64/io.h	Wed Aug 20 00:13:39 2003
+++ edited/include/asm-ia64/io.h	Thu Oct 23 14:32:42 2003
@@ -72,6 +72,9 @@
 	return (void *) (address + PAGE_OFFSET);
 }
 
+#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
+extern int valid_phys_addr_range (unsigned long addr, size_t *count); /* efi.c */
+
 /*
  * The following two macros are deprecated and scheduled for removal.
  * Please use the PCI-DMA interface defined in <asm/pci.h> instead.


  reply	other threads:[~2003-10-23 21:12 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-17 22:10 Bjorn Helgaas
2003-10-17 22:23 ` Matt Mackall
2003-10-17 22:50 ` Andrew Morton
2003-10-17 23:25   ` Bjorn Helgaas
2003-10-17 23:55     ` Andrew Morton
2003-10-18  0:15       ` William Lee Irwin III
2003-10-18  0:21       ` David Mosberger
2003-10-18  0:49         ` Andrew Morton
2003-10-18  1:31           ` Matt Chapman
2003-10-18  1:41             ` Andrew Morton
2003-10-18  1:48           ` David Mosberger
2003-10-18  2:01             ` Andrew Morton
2003-10-18  2:01             ` Matt Chapman
2003-10-19 11:25           ` Eric W. Biederman
2003-10-19 19:01             ` William Lee Irwin III
2003-10-20 15:17         ` Bjorn Helgaas
2003-10-20 18:48           ` David Mosberger
2003-10-20 15:58         ` fielding PCI bus timeouts - was: " Rich Altmaier
2003-10-20 17:42       ` [RFC] " Bjorn Helgaas
2003-10-23 21:05         ` Bjorn Helgaas [this message]
2003-10-19 18:17   ` Pavel Machek
2003-10-23  8:33     ` Martin Pool
2003-10-23  9:31       ` Zoltan Menyhart
2003-10-17 22:19 Luck, Tony
2003-10-17 22:40 ` Andreas Schwab

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=200310231505.34320.bjorn.helgaas@hp.com \
    --to=bjorn.helgaas@hp.com \
    --cc=davidm@hpl.hp.com \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®