Exemplo n.º 1
0
static int __jump_label_mod_text_reserved(void *start, void *end)
{
	struct module *mod;

	mod = __module_text_address((unsigned long)start);
	if (!mod)
		return 0;

	WARN_ON_ONCE(__module_text_address((unsigned long)end) != mod);

	return __jump_label_text_reserved(mod->jump_entries,
				mod->jump_entries + mod->num_jump_entries,
				start, end);
}
Exemplo n.º 2
0
/*
 * __strom_lookup_extra_symbol - lookup extra symbol and grab module if any
 */
static inline int
__strom_lookup_extra_symbol(const char *symbol_name,
							void **symbol_addr,
							struct module **symbol_mod,
							bool is_optional)
{
	unsigned long	addr;
	struct module  *mod;

	addr = kallsyms_lookup_name(symbol_name);
	if (!addr)
	{
		prError("could not solve %s kernel symbol: %s",
				is_optional ? "an optional" : "a required",
				symbol_name);
		return -ENOENT;
	}

	mod = __module_text_address(addr);
	if (mod)
	{
		__module_get(mod);
		prNotice("extra symbol \"%s\" found at %p of module \"%s\"",
				 symbol_name, (void *)addr, mod->name);
	}
	else
	{
		prNotice("extra symbol \"%s\" found at %p (core kernel)\n",
				 symbol_name, (void *)addr);
	}
	*symbol_addr = (void *) addr;
	*symbol_mod  = mod;

	return 0;
}
Exemplo n.º 3
0
/** Prints an address based on the _STP_SYM flags.
 * @param address The address to lookup.
 * @param task The address to lookup (if NULL lookup kernel/module address).
 * @note Symbolic lookups should not normally be done within
 * a probe because it is too time-consuming. Use at module exit time. */
static int _stp_snprint_addr(char *str, size_t len, unsigned long address,
			     int flags, struct task_struct *task)
{
  const char *modname = NULL;
  const char *name = NULL;
  unsigned long offset = 0, size = 0;
  char *exstr, *poststr, *prestr;

  prestr = (flags & _STP_SYM_PRE_SPACE) ? " " : "";
  exstr = (((flags & _STP_SYM_INEXACT) && (flags & _STP_SYM_SYMBOL))
	   ? " (inexact)" : "");
  if (flags & _STP_SYM_POST_SPACE)
    poststr = " ";
  else if (flags & _STP_SYM_NEWLINE)
    poststr = "\n";
  else
    poststr = "";

  if (flags & (_STP_SYM_SYMBOL | _STP_SYM_MODULE)) {
    name = _stp_kallsyms_lookup(address, &size, &offset, &modname, task);
    if (name && name[0] == '.')
      name++;
  }

  if (modname && (flags & _STP_SYM_MODULE_BASENAME)) {
     char *slash = strrchr (modname, '/');
     if (slash)
        modname = slash+1;
  }

  if (name && (flags & _STP_SYM_SYMBOL)) {
    if ((flags & _STP_SYM_MODULE) && modname && *modname) {
      if (flags & _STP_SYM_OFFSET) {
	if (flags & _STP_SYM_SIZE) {
	  /* symbol, module, offset and size. */
	  if (flags & _STP_SYM_HEX_SYMBOL)
	    return _stp_snprintf(str, len, "%s%p : %s+%#lx/%#lx [%s]%s%s",
				 prestr, (int64_t) address,
				 name, offset, size, modname,
				 exstr, poststr);
	  else
	    return _stp_snprintf(str, len, "%s%s+%#lx/%#lx [%s]%s%s",
				 prestr, name, offset, size,
				 modname, exstr, poststr);
	} else {
	  /* symbol, module, offset. */
	  if (flags & _STP_SYM_HEX_SYMBOL)
	    return _stp_snprintf(str, len, "%s%p : %s+%#lx [%s]%s%s",
				 prestr, (int64_t) address,
				 name, offset, modname,
				 exstr, poststr);
	  else
	    return _stp_snprintf(str, len, "%s%s+%#lx [%s]%s%s",
				 prestr, name, offset,
				 modname, exstr, poststr);
	}
      } else {
	/* symbol plus module */
	if (flags & _STP_SYM_HEX_SYMBOL)
	  return _stp_snprintf(str, len, "%s%p : %s [%s]%s%s", prestr,
			       (int64_t) address, name, modname,
			       exstr, poststr);
	else
	  return _stp_snprintf(str, len, "%s%s [%s]%s%s", prestr, name,
			       modname, exstr, poststr);
      }
    } else if (flags & _STP_SYM_OFFSET) {
      if (flags & _STP_SYM_SIZE) {
	/* symbol name, offset + size, no module name */
	if (flags & _STP_SYM_HEX_SYMBOL)
	  return _stp_snprintf(str, len, "%s%p : %s+%#lx/%#lx%s%s", prestr,
			       (int64_t) address, name, offset,
			       size, exstr, poststr);
	else
	  return _stp_snprintf(str, len, "%s%s+%#lx/%#lx%s%s", prestr, name,
			       offset, size, exstr, poststr);
      } else {
	/* symbol name, offset, no module name */
	if (flags & _STP_SYM_HEX_SYMBOL)
	  return _stp_snprintf(str, len, "%s%p : %s+%#lx%s%s", prestr,
			       (int64_t) address, name, offset,
			       exstr, poststr);
	else
	  return _stp_snprintf(str, len, "%s%s+%#lx%s%s", prestr, name,
			       offset, exstr, poststr);
      }
    } else {
      /* symbol name only */
      if (flags & _STP_SYM_HEX_SYMBOL)
	return _stp_snprintf(str, len, "%s%p : %s%s%s", prestr,
			     (int64_t) address, name, exstr, poststr);
      else
	return _stp_snprintf(str, len, "%s%s%s%s", prestr, name,
			     exstr, poststr);
    }
  } else {
    /* no symbol name */
    if (modname && *modname && (flags & _STP_SYM_MODULE)) {
      if (flags & _STP_SYM_OFFSET) {
        if (flags & _STP_SYM_SIZE) {
          /* hex address, module name, offset + size */
          return _stp_snprintf(str, len, "%s%p [%s+%#lx/%#lx]%s%s", prestr,
			       (int64_t) address, modname, offset,
			       size, exstr, poststr);
        } else {
          /* hex address, module name, offset */
	  return _stp_snprintf(str, len, "%s%p [%s+%#lx]%s%s", prestr,
			       (int64_t) address, modname, offset,
			       exstr, poststr);
        }
      } else {
	/* hex address, module name */
        return _stp_snprintf(str, len, "%s%p [%s]%s%s", prestr,
			     (int64_t) address, modname, exstr, poststr);
      }
#ifdef STAPCONF_MODULE_TEXT_ADDRESS
    } if ((flags & _STP_SYM_MODULE) && ! task) {
      /* No symbol, nor module name, but user really wants one, do one
	 last try. */
      struct module *ko;
      preempt_disable();
      ko = __module_text_address (address);
      if (ko && ko->name)
	{
	  /* hex address, module name */
	  int ret = _stp_snprintf(str, len, "%s%p [%s]%s%s", prestr,
				  (int64_t) address, ko->name, exstr, poststr);
	  preempt_enable_no_resched();
	  return ret;
        }
      preempt_enable_no_resched();
      /* no names, hex only */
      return _stp_snprintf(str, len, "%s%p%s%s", prestr,
			   (int64_t) address, exstr, poststr);
#endif
    } else {
      /* no names, hex only */
      return _stp_snprintf(str, len, "%s%p%s%s", prestr,
			   (int64_t) address, exstr, poststr);
    }
  }
}
Exemplo n.º 4
0
__notrace_funcgraph int __kernel_text_address(unsigned long addr)
{
	if (core_kernel_text(addr))
		return 1;
	return __module_text_address(addr) != NULL;
}