Skip to content

Commit

Permalink
Add check to confirm IHK and McKernel with the same version are used
Browse files Browse the repository at this point in the history
  • Loading branch information
masamichitakagi committed Jan 23, 2018
1 parent 8313682 commit 5d60a8c
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 6 deletions.
10 changes: 7 additions & 3 deletions config.h.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
/* config.h.in. Generated from configure.ac by autoheader. */

/* Id of IHK.ko maching of which is checked at run-time by reboot script and
mcexec */
#undef BUILDID

/* whether memdump feature is enabled */
#undef ENABLE_MEMDUMP

/* whether rusage is enabled */
#undef ENABLE_RUSAGE

/* whether perf is enabled */
#undef ENABLE_PERF

/* whether rusage is enabled */
#undef ENABLE_RUSAGE

/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

Expand Down
17 changes: 17 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ BINDIR
TARGET
KDIR
ARCH
BUILDID
EGREP
GREP
CPP
Expand Down Expand Up @@ -5069,6 +5070,22 @@ else
$as_echo "$as_me: perf is disabled" >&6;}
fi

ABS_SRCDIR=$( cd $( dirname $0 ); pwd )
IHK_ABS_SRCDIR=${ABS_SRCDIR}/../ihk
{ $as_echo "$as_me:${as_lineno-$LINENO}: IHK_ABS_SRCDIR=$IHK_ABS_SRCDIR" >&5
$as_echo "$as_me: IHK_ABS_SRCDIR=$IHK_ABS_SRCDIR" >&6;}
BUILDID=$( cd $IHK_ABS_SRCDIR; git rev-list -1 HEAD | cut -c1-8 )
{ $as_echo "$as_me:${as_lineno-$LINENO}: BUILDID=$BUILDID" >&5
$as_echo "$as_me: BUILDID=$BUILDID" >&6;}
if test "x$BUILDID" != "x" ; then

cat >>confdefs.h <<_ACEOF
#define BUILDID "$BUILDID"
_ACEOF

fi





Expand Down
11 changes: 10 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ m4_define([IHK_RELEASE_DATE_m4],[2013-11-18])dnl
m4_define([MCKERNEL_RELEASE_DATE_m4],[2013-11-18])dnl
m4_define([DCFA_RELEASE_DATE_m4],[2013-11-18])dnl


AC_INIT([ihk], IHK_VERSION_m4)

IHK_VERSION=IHK_VERSION_m4
Expand Down Expand Up @@ -413,6 +412,16 @@ else
AC_MSG_NOTICE([perf is disabled])
fi

ABS_SRCDIR=$( cd $( dirname $0 ); pwd )
IHK_ABS_SRCDIR=${ABS_SRCDIR}/../ihk
BUILDID=$( cd $IHK_ABS_SRCDIR; git rev-list -1 HEAD | cut -c1-8 )
AC_MSG_NOTICE([BUILDID=$BUILDID])
if test "x$BUILDID" != "x" ; then
AC_DEFINE_UNQUOTED(BUILDID,"$BUILDID",[IHK build-id to confirm IHK and McKernel built at the same time are used])
)
fi
AC_SUBST(BUILDID)

AC_SUBST(CC)
AC_SUBST(XCC)
AC_SUBST(ARCH)
Expand Down
2 changes: 1 addition & 1 deletion linux/core/Makefile.module.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ KMODDIR=@KMODDIR@

obj-m += ihk.o

ccflags-y := -I$(src)/../include -I$(src)/../include/ihk/arch/$(ARCH) -I$(src)/../../ikc/include
ccflags-y := -I$(src)/../include -I$(src)/../include/ihk/arch/$(ARCH) -I$(src)/../../ikc/include -I@abs_builddir@/../../

ihk-y = host_driver.o mem_alloc.o mm.o mikc.o
ihk-y += ../../ikc/linux.o ../../ikc/master.o ../../ikc/queue.o
Expand Down
20 changes: 20 additions & 0 deletions linux/core/host_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <ihk/misc/debug.h>
#include "host_linux.h"
#include "ops_wrappers.h"
#include <config.h>

//#define DEBUG_IKC

Expand Down Expand Up @@ -953,6 +954,7 @@ static int __ihk_os_ioctl_perm(unsigned int request)
case IHK_OS_QUERY_CPU:
case IHK_OS_QUERY_MEM:
case IHK_OS_GET_IKC_MAP:
case IHK_OS_GET_BUILDID:
case IHK_OS_STATUS:
case IHK_OS_GET_USAGE:
case IHK_OS_GET_CPU_USAGE:
Expand Down Expand Up @@ -1045,6 +1047,10 @@ static long ihk_host_os_ioctl(struct file *file, unsigned int request,
ret = __ihk_os_get_ikc_map(data, arg);
break;

case IHK_OS_GET_BUILDID:
ret = __ihk_os_get_buildid(data, arg);
break;

case IHK_OS_QUERY_CPU:
ret = __ihk_os_query_cpu(data, arg);
break;
Expand Down Expand Up @@ -1402,6 +1408,16 @@ static int __ihk_device_create_os_init(struct ihk_host_linux_device_data *data,
return ret;
}

static int __ihk_device_get_buildid(struct ihk_host_linux_device_data *data,
unsigned long arg)
{
char buildid[] = BUILDID;
if (copy_to_user((void*)arg, buildid, sizeof(buildid))) {
return -EFAULT;
}
return 0;
}

/** \brief Create a OS file in the kernel
*
* @return minor number */
Expand Down Expand Up @@ -1672,6 +1688,10 @@ static long ihk_host_device_ioctl(struct file *file, unsigned int request,
data = file->private_data;

switch (request) {
case IHK_DEVICE_GET_BUILDID:
ret = __ihk_device_get_buildid(data, arg);
break;

case IHK_DEVICE_CREATE_OS:
ret = __ihk_device_create_os(data, arg);
break;
Expand Down
6 changes: 6 additions & 0 deletions linux/core/ops_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ IHK_OS_OPS_BEGIN(int, get_ikc_map,
IHK_OPS_BODY(get_ikc_map, arg);
}

IHK_OS_OPS_BEGIN(int, get_buildid,
unsigned long arg)
{
IHK_OPS_BODY(get_buildid, arg);
}

IHK_OS_OPS_BEGIN(int, query_cpu,
unsigned long arg)
{
Expand Down
10 changes: 10 additions & 0 deletions linux/driver/smp/smp-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1862,6 +1862,15 @@ static int smp_ihk_os_get_ikc_map(ihk_os_t ihk_os, void *priv, unsigned long arg
return ret;
}

static int smp_ihk_os_get_buildid(ihk_os_t ihk_os, void *priv, unsigned long arg)
{
char buildid[] = BUILDID;
if (copy_to_user((void*)arg, buildid, sizeof(buildid))) {
return -EFAULT;
}
return 0;
}

static int smp_ihk_parse_mem(char *p, size_t *mem_size, int *numa_id)
{
char *oldp;
Expand Down Expand Up @@ -2341,6 +2350,7 @@ static struct ihk_os_ops smp_ihk_os_ops = {
.release_cpu = smp_ihk_os_release_cpu,
.set_ikc_map = smp_ihk_os_set_ikc_map,
.get_ikc_map = smp_ihk_os_get_ikc_map,
.get_buildid = smp_ihk_os_get_buildid,
.query_cpu = smp_ihk_os_query_cpu,
.assign_mem = smp_ihk_os_assign_mem,
.release_mem = smp_ihk_os_release_mem,
Expand Down
7 changes: 7 additions & 0 deletions linux/include/ihk/ihk_host_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,13 @@ struct ihk_os_ops {
**/
int (*get_ikc_map)(ihk_os_t, void *, unsigned long arg);

/** \brief Get build-id.
*
* \return Success or failure.
* \param pointer to build-id string.
**/
int (*get_buildid)(ihk_os_t, void *, unsigned long arg);

/** \brief Query CPU cores of an OS instance
*
* \return Success or failure.
Expand Down
2 changes: 2 additions & 0 deletions linux/include/ihk/ihk_host_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define IHK_DEVICE_GET_KMSG_BUF 0x112908
#define IHK_DEVICE_READ_KMSG_BUF 0x112909
#define IHK_DEVICE_RELEASE_KMSG_BUF 0x11290a
#define IHK_DEVICE_GET_BUILDID 0x11290b

#define IHK_DEVICE_DEBUG_START 0x122900
#define IHK_DEVICE_DEBUG_END 0x1229ff
Expand Down Expand Up @@ -62,6 +63,7 @@
#define IHK_OS_GET_NUM_NUMA_NODES 0x112a34
#define IHK_OS_NOTIFY_HUNGUP 0x112a35
#define IHK_OS_DETECT_HUNGUP 0x112a36
#define IHK_OS_GET_BUILDID 0x112a37

#define IHK_OS_DEBUG_START 0x122a00
#define IHK_OS_DEBUG_END 0x122aff
Expand Down
32 changes: 31 additions & 1 deletion linux/user/ihkconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*/
#ifdef POSTK_DEBUG_ARCH_DEP_70 /* add config.h include to ihkconfig */
#include <config.h>
#else
#include <config.h>
#endif /* POSTK_DEBUG_ARCH_DEP_70 */
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -69,7 +71,7 @@ static int usage(char **arg)
fprintf(stderr, " release mem\n");
fprintf(stderr, " query cpu|mem\n");
fprintf(stderr, " get os_instances\n");

fprintf(stderr, " get buildid\n");
return 0;
}

Expand Down Expand Up @@ -397,6 +399,32 @@ static int do_get_os_instances(int index)
goto fn_exit;
}

static int do_get_buildid(int index)
{
int ret = 0;
int fd = -1;
char fn[128];
char query_result[sizeof(BUILDID)];

sprintf(fn, "/dev/mcd%d", index);

fd = open(fn, O_RDONLY);
IHKCONFIG_CHKANDJUMP(fd < 0, "open", -1);

ret = ioctl(fd, IHK_DEVICE_GET_BUILDID, query_result);
IHKCONFIG_CHKANDJUMP(ret != 0, "IHK_DEVICE_GET_BUILDID", -1);

printf("%s\n", query_result);

fn_exit:
if (fd != -1) {
close(fd);
}
return ret;
fn_fail:
goto fn_exit;
}

static int do_get(int index)
{
if (__argc < 4) {
Expand All @@ -406,6 +434,8 @@ static int do_get(int index)

if (!strcmp(__argv[3], "os_instances")) {
return do_get_os_instances(index);
} else if (!strcmp(__argv[3], "buildid")) {
return do_get_buildid(index);
} else {
fprintf(stderr, "Unknown target : %s\n", __argv[3]);
usage(__argv);
Expand Down
28 changes: 28 additions & 0 deletions linux/user/ihkosctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,32 @@ static int do_get_ikc_map(int index)
goto fn_exit;
}

static int do_get_buildid(int index)
{
int ret = 0;
int fd = -1;
char fn[128];
char query_result[sizeof(BUILDID)];

sprintf(fn, "/dev/mcos%d", index);

fd = open(fn, O_RDONLY);
IHKOSCTL_CHKANDJUMP(fd < 0, "open", -1);

ret = ioctl(fd, IHK_OS_GET_BUILDID, query_result);
IHKOSCTL_CHKANDJUMP(ret != 0, "IHK_OS_GET_BUILDID", -1);

printf("%s\n", query_result);

fn_exit:
if (fd != -1) {
close(fd);
}
return ret;
fn_fail:
goto fn_exit;
}

static int do_get(int index)
{
if (__argc < 4) {
Expand All @@ -173,6 +199,8 @@ static int do_get(int index)
return do_get_status(index);
} else if (!strcmp(__argv[3], "ikc_map")) {
return do_get_ikc_map(index);
} else if (!strcmp(__argv[3], "buildid")) {
return do_get_buildid(index);
} else {
fprintf(stderr, "Unknown target : %s\n", __argv[3]);
usage(__argv);
Expand Down

0 comments on commit 5d60a8c

Please sign in to comment.