WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH 4/4] kexec/arch/i386: Add get_memory_ranges_xen()

To: Daniel Kiper <dkiper@xxxxxxxxxxxx>
Subject: [Xen-devel] Re: [PATCH 4/4] kexec/arch/i386: Add get_memory_ranges_xen() function
From: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Date: Mon, 22 Aug 2011 00:01:24 -0400
Cc: olaf@xxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxx, ian.campbell@xxxxxxxxxx, kexec@xxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, horms@xxxxxxxxxxxx, vgoyal@xxxxxxxxxx
Delivery-date: Sun, 21 Aug 2011 21:05:32 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20110821135459.GE17323@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Oracle
References: <20110821135459.GE17323@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Reply-to: konrad.wilk@xxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: KMail/1.13.5 (Linux/3.0.0; KDE/4.5.5; i686; ; )
> get_memory_ranges_sysfs() and get_memory_ranges_proc_iomem()
> are unreliable under Xen. Proper machine memory map could be
> obtained under Xen by calling __HYPERVISOR_memory_op hypercall
> with XENMEM_machine_memory_map argument. get_memory_ranges_xen()
> does that. It is implemented using ioctl() or libxenctrl interface.
> This solution is compatible with 3.x and 4.x Xen versions.
> 
> Signed-off-by: Daniel Kiper <dkiper@xxxxxxxxxxxx>
> ---
>  configure.ac                       |    3 +
>  kexec/arch/i386/kexec-x86-common.c |  203 
++++++++++++++++++++++++++++++++++--
>  2 files changed, 197 insertions(+), 9 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 172a52a..0d09bba 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -157,6 +157,9 @@ if test "$with_xen" = yes ; then
>       AC_CHECK_HEADER(xenctrl.h,
>               AC_CHECK_LIB(xenctrl, xc_version, ,
>               AC_MSG_NOTICE([Xen support disabled])))
> +     if test "$ac_cv_lib_xenctrl_xc_version" = yes ; then
> +             AC_CHECK_FUNCS(xc_get_machine_memory_map)
> +     fi
>  fi
>  
>  dnl ---Sanity checks
> diff --git a/kexec/arch/i386/kexec-x86-common.c b/kexec/arch/i386/kexec-x86-
common.c
> index 8f59c6c..609d35d 100644
> --- a/kexec/arch/i386/kexec-x86-common.c
> +++ b/kexec/arch/i386/kexec-x86-common.c
> @@ -17,6 +17,10 @@
>   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>   */
>  
> +#define _XOPEN_SOURCE        600
> +#define _BSD_SOURCE
> +
> +#include <fcntl.h>
>  #include <stddef.h>
>  #include <stdio.h>
>  #include <errno.h>
> @@ -24,12 +28,29 @@
>  #include <string.h>
>  #include <limits.h>
>  #include <stdlib.h>
> +#include <stdio.h>
> +#include <sys/ioctl.h>
> +#include <sys/mman.h>
> +#include <sys/stat.h>
> +#include <unistd.h>
>  #include "../../kexec.h"
>  #include "../../kexec-syscall.h"
>  #include "../../firmware_memmap.h"
>  #include "../../crashdump.h"
>  #include "kexec-x86.h"
>  
> +#ifdef HAVE_LIBXENCTRL
> +#ifdef HAVE_XC_GET_MACHINE_MEMORY_MAP
> +#include <xenctrl.h>
> +#else
> +#define __XEN_TOOLS__        1
> +#include <x86/x86-linux.h>
> +#include <xen/xen.h>
> +#include <xen/memory.h>
> +#include <xen/sys/privcmd.h>
> +#endif /* HAVE_XC_GET_MACHINE_MEMORY_MAP */
> +#endif /* HAVE_LIBXENCTRL */
> +
>  static struct memory_range memory_range[MAX_MEMORY_RANGES];
>  
>  /**
> @@ -129,6 +150,172 @@ static int get_memory_ranges_sysfs(struct memory_range 
**range, int *ranges)
>       return 0;
>  }
>  
> +#ifdef HAVE_LIBXENCTRL
> +static unsigned e820_to_kexec_type(uint32_t type)
> +{
> +     switch (type) {
> +             case E820_RAM:
> +                     return RANGE_RAM;
> +             case E820_ACPI:
> +                     return RANGE_ACPI;
> +             case E820_NVS:
> +                     return RANGE_ACPI_NVS;
> +             case E820_RESERVED:

For E820_UNUSABLE you want to do that too?

> +             default:
> +                     return RANGE_RESERVED;

Or should E820_UNUSABLE returne its own type of RANGE?
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>