All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Xenomai] Cobalt Scheduling tasks on a single core
From: Jackson Jones @ 2018-07-23 19:44 UTC (permalink / raw)
  To: xenomai, Philippe Gerum
In-Reply-To: <b16ed60f-31f2-3ef0-f7bc-a35de9629b51@xenomai.org>

We were using processor affinity and assigning the RT tasks to different
cores. The issue we ran into is that the application would lock up (causing
the whole system to freeze) after several hours of being idle
(approximately 8 hours). When we did not use processor affinity, our app
would not lock up (but then all RT task are on one core).

One thing I noticed is that currently we are designating all the CPUs to be
real time (passing xenomai.supported_cpus=0x0000000f). Could this be the
cause of the lockup? Should we leave one cpu out (of the real time group)?

We also discovered over this past weekend that if we enable these options
in the Linux kernel, our app does not lock up:

CONFIG_LOCKUP_DETECTOR=y
# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
CONFIG_DETECT_HUNG_TASK=y
CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120
# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0

These options are not something we want to ship with, but it is interesting
that they seem to prevent the lockup.




On Sat, Jul 21, 2018 at 1:47 AM, Philippe Gerum <rpm@xenomai.org> wrote:

> On 07/21/2018 01:28 AM, Jackson Jones wrote:
> > We are running against xenomai 3.0.7 on a quad core arm (i.mx6).  Xenomai
> > was configured with these arguments:
> >
> > #export CFLAGS=-O2 LIBS=-lposix
> > ./configure \
> >     --with-core=cobalt \
> >     --enable-smp \
> >     --enable-registry \
> >     --enable-pshared \
> >     --enable-dlopen-libs \
> >     --enable-sanity \
> >     --disable-tls \
> >     --enable-valgrind-client \
> >     --disable-assert
> >
> > The main app spawns off several real time tasks. Cobalt is scheduling all
> > the real-time tasks on one core. Is this normal behavior for Cobalt? I
> > would expect it to take advantage of the multiple cores.
>
> Your application has to decide for this, CPU migration is costly in many
> ways, increases latency. For this reason, no Xenomai co-kernel ever has
> implemented any load balancing of any sort. On the contrary, it does pin
> each emerging thread to its current CPU precisely to prevent unexpected
> migration while the threads runs in secondary mode, before entering the
> rt processing loop - this CPU may of course be changed by the
> application afterwards.
>
> What you are seeing here is the default assignment of threads to CPUs:
> the regular kernel picked a base CPU for each newly created thread, then
> Cobalt pinned it there.
>
> The idea is to figure out the best placement of the rt threads among the
> CPUs available for rt processing, moving them accordingly using
> sched_setaffinity() during the init phase. This placement could be
> paired with setting xenomai.supported_cpus for restricting the CPUs
> dedicated to real-time duties to a subset of the available cores.
>
> --
> Philippe.
>

^ permalink raw reply

* Re: [PATCH v2] hwmon: (iio_hwmon) Use devm functions
From: Guenter Roeck @ 2018-07-23 18:42 UTC (permalink / raw)
  To: Maxime Roussin-Bélanger; +Cc: Jean Delvare, linux-hwmon, Jonathan Cameron
In-Reply-To: <20180723033329.28213-1-maxime.roussinbelanger@gmail.com>

On Sun, Jul 22, 2018 at 11:33:29PM -0400, Maxime Roussin-Bélanger wrote:
> Use devm_iio_channel_get_all() to automatically release
> channels.
> 
> Use devm_hwmon_device_register_with_groups() to
> automatically unregister the device.
> 
> Signed-off-by: Maxime Roussin-Bélanger <maxime.roussinbelanger@gmail.com>

Applied, with a couple of additional changes (see below).

Thanks,
Guenter

> ---
> Changes in v2:
> 	- Remove unnecessary {}
> 
> drivers/hwmon/iio_hwmon.c | 63 ++++++++++++---------------------------
>  1 file changed, 19 insertions(+), 44 deletions(-)
> 
> diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
> index a3a1d1cb2f27..44d7dfe9cb46 100644
> --- a/drivers/hwmon/iio_hwmon.c
> +++ b/drivers/hwmon/iio_hwmon.c
> @@ -73,44 +73,38 @@ static int iio_hwmon_probe(struct platform_device *pdev)
>  	if (dev->of_node && dev->of_node->name)
>  		name = dev->of_node->name;
>  
> -	channels = iio_channel_get_all(dev);
> +	channels = devm_iio_channel_get_all(dev);
>  	if (IS_ERR(channels)) {
>  		if (PTR_ERR(channels) == -ENODEV)
>  			return -EPROBE_DEFER;
>  		return PTR_ERR(channels);
>  	}
>  
>  	st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL);
> -	if (st == NULL) {
> -		ret = -ENOMEM;
> -		goto error_release_channels;
> -	}
> +	if (st == NULL)
> +		return -ENOMEM;
>  
>  	st->channels = channels;
>  
>  	/* count how many attributes we have */
>  	while (st->channels[st->num_channels].indio_dev)
>  		st->num_channels++;
>  
>  	st->attrs = devm_kzalloc(dev,
>  				 sizeof(*st->attrs) * (st->num_channels + 1),
>  				 GFP_KERNEL);
> -	if (st->attrs == NULL) {
> -		ret = -ENOMEM;
> -		goto error_release_channels;
> -	}
> +	if (st->attrs == NULL)
> +		return -ENOMEM;
>  
>  	for (i = 0; i < st->num_channels; i++) {
>  		a = devm_kzalloc(dev, sizeof(*a), GFP_KERNEL);
> -		if (a == NULL) {
> -			ret = -ENOMEM;
> -			goto error_release_channels;
> -		}
> +		if (a == NULL)
> +			return -ENOMEM;
>  
>  		sysfs_attr_init(&a->dev_attr.attr);
>  		ret = iio_get_channel_type(&st->channels[i], &type);
>  		if (ret < 0)
> -			goto error_release_channels;
> +			return ret;
>  
>  		switch (type) {
>  		case IIO_VOLTAGE:
> @@ -138,49 +132,31 @@ static int iio_hwmon_probe(struct platform_device *pdev)
>  							       humidity_i++);
>  			break;
>  		default:
> -			ret = -EINVAL;
> -			goto error_release_channels;
> -		}
> -		if (a->dev_attr.attr.name == NULL) {
> -			ret = -ENOMEM;
> -			goto error_release_channels;
> +			return -EINVAL;
>  		}
> +		if (a->dev_attr.attr.name == NULL)
> +			return -ENOMEM;
> +
>  		a->dev_attr.show = iio_hwmon_read_val;
>  		a->dev_attr.attr.mode = S_IRUGO;
>  		a->index = i;
>  		st->attrs[i] = &a->dev_attr.attr;
>  	}
>  
>  	st->attr_group.attrs = st->attrs;
>  	st->groups[0] = &st->attr_group;
>  
>  	sname = devm_kstrdup(dev, name, GFP_KERNEL);
> -	if (!sname) {
> -		ret = -ENOMEM;
> -		goto error_release_channels;
> -	}
> +	if (!sname)
> +		return -ENOMEM;
>  
>  	strreplace(sname, '-', '_');
> -	st->hwmon_dev = hwmon_device_register_with_groups(dev, sname, st,
> -							  st->groups);
> -	if (IS_ERR(st->hwmon_dev)) {
> -		ret = PTR_ERR(st->hwmon_dev);
> -		goto error_release_channels;
> -	}
> -	platform_set_drvdata(pdev, st);
> -	return 0;
> -
> -error_release_channels:
> -	iio_channel_release_all(channels);
> -	return ret;
> -}
> +	st->hwmon_dev = devm_hwmon_device_register_with_groups(dev, sname, st,
> +							       st->groups);

st->hwmon_dev is now unnecessary. Changed to local variable.

> +	if (IS_ERR(st->hwmon_dev))
> +		return PTR_ERR(st->hwmon_dev);
>  
> -static int iio_hwmon_remove(struct platform_device *pdev)
> -{
> -	struct iio_hwmon_state *st = platform_get_drvdata(pdev);
> -
> -	hwmon_device_unregister(st->hwmon_dev);
> -	iio_channel_release_all(st->channels);
> +	platform_set_drvdata(pdev, st);

This is now unnecessary. Dropped. With this, the simplified the code to

	hwmon_dev = devm_hwmon_device_register_with_groups(dev, sname, st,
							   st->groups);
	return PTR_ERR_OR_ZERO(hwmon_dev);

>  
>  	return 0;
>  }
> @@ -197,7 +173,6 @@ static struct platform_driver __refdata iio_hwmon_driver = {
>  		.of_match_table = iio_hwmon_of_match,
>  	},
>  	.probe = iio_hwmon_probe,
> -	.remove = iio_hwmon_remove,
>  };
>  
>  module_platform_driver(iio_hwmon_driver);

^ permalink raw reply

* Re: [PATCH v2 bpf 2/3] bpf: Replace [u]int32_t and [u]int64_t in libbpf
From: Martin KaFai Lau @ 2018-07-23 18:41 UTC (permalink / raw)
  To: Yonghong Song; +Cc: netdev, Alexei Starovoitov, Daniel Borkmann, kernel-team
In-Reply-To: <f9f7ad47-b53b-35c7-d0ab-119d01c2cf41@fb.com>

On Mon, Jul 23, 2018 at 11:04:34AM -0700, Yonghong Song wrote:
> 
> 
> On 7/21/18 11:20 AM, Martin KaFai Lau wrote:
> > This patch replaces [u]int32_t and [u]int64_t usage with
> > __[su]32 and __[su]64.  The same change goes for [u]int16_t
> > and [u]int8_t.
> > 
> > Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf")
> > Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> > ---
> >   tools/lib/bpf/btf.c    | 28 +++++++++++++---------------
> >   tools/lib/bpf/btf.h    |  8 ++++----
> >   tools/lib/bpf/libbpf.c | 12 ++++++------
> >   tools/lib/bpf/libbpf.h |  4 ++--
> >   4 files changed, 25 insertions(+), 27 deletions(-)
> > 
> > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> > index 8c54a4b6f187..ce77b5b57912 100644
> > --- a/tools/lib/bpf/btf.c
> > +++ b/tools/lib/bpf/btf.c
> > @@ -2,7 +2,6 @@
> >   /* Copyright (c) 2018 Facebook */
> >   #include <stdlib.h>
> > -#include <stdint.h>
> >   #include <string.h>
> >   #include <unistd.h>
> >   #include <errno.h>
> > @@ -27,13 +26,13 @@ struct btf {
> >   	struct btf_type **types;
> >   	const char *strings;
> >   	void *nohdr_data;
> > -	uint32_t nr_types;
> > -	uint32_t types_size;
> > -	uint32_t data_size;
> > +	__u32 nr_types;
> > +	__u32 types_size;
> > +	__u32 data_size;
> >   	int fd;
> >   };
> > -static const char *btf_name_by_offset(const struct btf *btf, uint32_t offset)
> > +static const char *btf_name_by_offset(const struct btf *btf, __u32 offset)
> >   {
> >   	if (offset < btf->hdr->str_len)
> >   		return &btf->strings[offset];
> > @@ -151,7 +150,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
> >   	while (next_type < end_type) {
> >   		struct btf_type *t = next_type;
> > -		uint16_t vlen = BTF_INFO_VLEN(t->info);
> > +		__u16 vlen = BTF_INFO_VLEN(t->info);
> >   		int err;
> >   		next_type += sizeof(*t);
> > @@ -191,7 +190,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
> >   }
> >   static const struct btf_type *btf_type_by_id(const struct btf *btf,
> > -					     uint32_t type_id)
> > +					     __u32 type_id)
> >   {
> >   	if (type_id > btf->nr_types)
> >   		return NULL;
> > @@ -226,12 +225,12 @@ static int64_t btf_type_size(const struct btf_type *t)
> 
> Missing this one:
>    static int64_t btf_type_size(const struct btf_type *t)
> 
> There are a couple of instances of using u32 instead of __u32, better to use
> __u32 everywhere in the same file:
>                 u32 expand_by, new_size;
>         u32 meta_left;
Thanks for pointing them out.  Will make the changes.

> 
> 
> >   #define MAX_RESOLVE_DEPTH 32
> > -int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id)
> > +__s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
> >   {
> >   	const struct btf_array *array;
> >   	const struct btf_type *t;
> > -	uint32_t nelems = 1;
> > -	int64_t size = -1;
> > +	__u32 nelems = 1;
> > +	__s64 size = -1;
> >   	int i;
> >   	t = btf_type_by_id(btf, type_id);
> > @@ -271,9 +270,9 @@ int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id)
> >   	return nelems * size;
> >   }
> > -int32_t btf__find_by_name(const struct btf *btf, const char *type_name)
> > +__s32 btf__find_by_name(const struct btf *btf, const char *type_name)
> >   {
> > -	uint32_t i;
> > +	__u32 i;
> >   	if (!strcmp(type_name, "void"))
> >   		return 0;
> > @@ -302,10 +301,9 @@ void btf__free(struct btf *btf)
> >   	free(btf);
> >   }
> > -struct btf *btf__new(uint8_t *data, uint32_t size,
> > -		     btf_print_fn_t err_log)
> > +struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log)
> >   {
> > -	uint32_t log_buf_size = 0;
> > +	__u32 log_buf_size = 0;
> >   	char *log_buf = NULL;
> >   	struct btf *btf;
> >   	int err;
> > diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
> > index 74bb344035bb..ed3a84370ccc 100644
> > --- a/tools/lib/bpf/btf.h
> > +++ b/tools/lib/bpf/btf.h
> > @@ -4,7 +4,7 @@
> >   #ifndef __BPF_BTF_H
> >   #define __BPF_BTF_H
> > -#include <stdint.h>
> > +#include <linux/types.h>
> >   #define BTF_ELF_SEC ".BTF"
> > @@ -14,9 +14,9 @@ typedef int (*btf_print_fn_t)(const char *, ...)
> >   	__attribute__((format(printf, 1, 2)));
> >   void btf__free(struct btf *btf);
> > -struct btf *btf__new(uint8_t *data, uint32_t size, btf_print_fn_t err_log);
> > -int32_t btf__find_by_name(const struct btf *btf, const char *type_name);
> > -int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id);
> > +struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log);
> > +__s32 btf__find_by_name(const struct btf *btf, const char *type_name);
> > +__s64 btf__resolve_size(const struct btf *btf, __u32 type_id);
> >   int btf__fd(const struct btf *btf);
> >   #endif
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index a1e96b5de5ff..6deb4fe4fffe 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -216,8 +216,8 @@ struct bpf_map {
> >   	size_t offset;
> >   	int map_ifindex;
> >   	struct bpf_map_def def;
> > -	uint32_t btf_key_type_id;
> > -	uint32_t btf_value_type_id;
> > +	__u32 btf_key_type_id;
> > +	__u32 btf_value_type_id;
> >   	void *priv;
> >   	bpf_map_clear_priv_t clear_priv;
> >   };
> > @@ -1016,8 +1016,8 @@ static int bpf_map_find_btf_info(struct bpf_map *map, const struct btf *btf)
> >   {
> >   	struct bpf_map_def *def = &map->def;
> >   	const size_t max_name = 256;
> > -	int64_t key_size, value_size;
> > -	int32_t key_id, value_id;
> > +	__s64 key_size, value_size;
> > +	__s32 key_id, value_id;
> >   	char name[max_name];
> >   	/* Find key type by name from BTF */
> > @@ -2089,12 +2089,12 @@ const char *bpf_map__name(struct bpf_map *map)
> >   	return map ? map->name : NULL;
> >   }
> > -uint32_t bpf_map__btf_key_type_id(const struct bpf_map *map)
> > +__u32 bpf_map__btf_key_type_id(const struct bpf_map *map)
> >   {
> >   	return map ? map->btf_key_type_id : 0;
> >   }
> > -uint32_t bpf_map__btf_value_type_id(const struct bpf_map *map)
> > +__u32 bpf_map__btf_value_type_id(const struct bpf_map *map)
> >   {
> >   	return map ? map->btf_value_type_id : 0;
> >   }
> > diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
> > index 09976531aa74..b33ae02f7d0e 100644
> > --- a/tools/lib/bpf/libbpf.h
> > +++ b/tools/lib/bpf/libbpf.h
> > @@ -244,8 +244,8 @@ bpf_map__next(struct bpf_map *map, struct bpf_object *obj);
> >   int bpf_map__fd(struct bpf_map *map);
> >   const struct bpf_map_def *bpf_map__def(struct bpf_map *map);
> >   const char *bpf_map__name(struct bpf_map *map);
> > -uint32_t bpf_map__btf_key_type_id(const struct bpf_map *map);
> > -uint32_t bpf_map__btf_value_type_id(const struct bpf_map *map);
> > +__u32 bpf_map__btf_key_type_id(const struct bpf_map *map);
> > +__u32 bpf_map__btf_value_type_id(const struct bpf_map *map);
> >   typedef void (*bpf_map_clear_priv_t)(struct bpf_map *, void *);
> >   int bpf_map__set_priv(struct bpf_map *map, void *priv,
> > 

^ permalink raw reply

* Re: [PATCH v2 bpf 3/3] bpf: Introduce BPF_ANNOTATE_KV_PAIR
From: Martin KaFai Lau @ 2018-07-23 18:41 UTC (permalink / raw)
  To: Yonghong Song; +Cc: netdev, Alexei Starovoitov, Daniel Borkmann, kernel-team
In-Reply-To: <bd832483-293f-0113-14fa-d7b5fef53f4d@fb.com>

On Mon, Jul 23, 2018 at 11:31:43AM -0700, Yonghong Song wrote:
> 
> 
> On 7/21/18 11:20 AM, Martin KaFai Lau wrote:
> > This patch introduces BPF_ANNOTATE_KV_PAIR to signal the
> > bpf loader about the btf key_type and value_type of a bpf map.
> > Please refer to the changes in test_btf_haskv.c for its usage.
> > Both iproute2 and libbpf loader will then have the same
> > convention to find out the map's btf_key_type_id and
> > btf_value_type_id from a map's name.
> > 
> > Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf")
> > Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
> > Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> > ---
> >   tools/lib/bpf/btf.c                          |  7 +-
> >   tools/lib/bpf/btf.h                          |  2 +
> >   tools/lib/bpf/libbpf.c                       | 75 +++++++++++---------
> >   tools/testing/selftests/bpf/bpf_helpers.h    |  9 +++
> >   tools/testing/selftests/bpf/test_btf_haskv.c |  7 +-
> >   5 files changed, 56 insertions(+), 44 deletions(-)
> > 
> > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> > index ce77b5b57912..321a99e648ed 100644
> > --- a/tools/lib/bpf/btf.c
> > +++ b/tools/lib/bpf/btf.c
> > @@ -189,8 +189,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
> >   	return 0;
> >   }
> > -static const struct btf_type *btf_type_by_id(const struct btf *btf,
> > -					     __u32 type_id)
> > +const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 type_id)
> >   {
> >   	if (type_id > btf->nr_types)
> >   		return NULL;
> > @@ -233,7 +232,7 @@ __s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
> >   	__s64 size = -1;
> >   	int i;
> > -	t = btf_type_by_id(btf, type_id);
> > +	t = btf__type_by_id(btf, type_id);
> >   	for (i = 0; i < MAX_RESOLVE_DEPTH && !btf_type_is_void_or_null(t);
> >   	     i++) {
> >   		size = btf_type_size(t);
> > @@ -258,7 +257,7 @@ __s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
> >   			return -EINVAL;
> >   		}
> > -		t = btf_type_by_id(btf, type_id);
> > +		t = btf__type_by_id(btf, type_id);
> >   	}
> >   	if (size < 0)
> > diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
> > index ed3a84370ccc..e2a09a155f84 100644
> > --- a/tools/lib/bpf/btf.h
> > +++ b/tools/lib/bpf/btf.h
> > @@ -9,6 +9,7 @@
> >   #define BTF_ELF_SEC ".BTF"
> >   struct btf;
> > +struct btf_type;
> >   typedef int (*btf_print_fn_t)(const char *, ...)
> >   	__attribute__((format(printf, 1, 2)));
> > @@ -16,6 +17,7 @@ typedef int (*btf_print_fn_t)(const char *, ...)
> >   void btf__free(struct btf *btf);
> >   struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log);
> >   __s32 btf__find_by_name(const struct btf *btf, const char *type_name);
> > +const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 id);
> >   __s64 btf__resolve_size(const struct btf *btf, __u32 type_id);
> >   int btf__fd(const struct btf *btf);
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index 6deb4fe4fffe..d881d370616c 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -36,6 +36,7 @@
> >   #include <linux/err.h>
> >   #include <linux/kernel.h>
> >   #include <linux/bpf.h>
> > +#include <linux/btf.h>
> >   #include <linux/list.h>
> >   #include <linux/limits.h>
> >   #include <sys/stat.h>
> > @@ -1014,68 +1015,72 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
> >   static int bpf_map_find_btf_info(struct bpf_map *map, const struct btf *btf)
> >   {
> > +	const struct btf_type *container_type;
> > +	const struct btf_member *key, *value;
> >   	struct bpf_map_def *def = &map->def;
> >   	const size_t max_name = 256;
> > +	char container_name[max_name];
> >   	__s64 key_size, value_size;
> > -	__s32 key_id, value_id;
> > -	char name[max_name];
> > +	__s32 container_id;
> > -	/* Find key type by name from BTF */
> > -	if (snprintf(name, max_name, "%s_key", map->name) == max_name) {
> > -		pr_warning("map:%s length of BTF key_type:%s_key is too long\n",
> > +	if (snprintf(container_name, max_name, "____btf_map_%s", map->name) ==
> > +	    max_name) {
> > +		pr_warning("map:%s length of '____btf_map_%s' is too long\n",
> >   			   map->name, map->name);
> >   		return -EINVAL;
> >   	}
> > -	key_id = btf__find_by_name(btf, name);
> > -	if (key_id < 0) {
> > -		pr_debug("map:%s key_type:%s cannot be found in BTF\n",
> > -			 map->name, name);
> > -		return key_id;
> > +	container_id = btf__find_by_name(btf, container_name);
> > +	if (container_id < 0) {
> > +		pr_debug("map:%s container_name:%s cannot be found in BTF. Missing BPF_ANNOTATE_KV_PAIR?\n",
> > +			 map->name, container_name);
> > +		return container_id;
> >   	}
> > -	key_size = btf__resolve_size(btf, key_id);
> > -	if (key_size < 0) {
> > -		pr_warning("map:%s key_type:%s cannot get the BTF type_size\n",
> > -			   map->name, name);
> > -		return key_size;
> > +	container_type = btf__type_by_id(btf, container_id);
> > +	if (!container_type) {
> > +		pr_warning("map:%s cannot find BTF type for container_id:%u\n",
> > +			   map->name, container_id);
> > +		return -EINVAL;
> >   	}
> > -	if (def->key_size != key_size) {
> > -		pr_warning("map:%s key_type:%s has BTF type_size:%u != key_size:%u\n",
> > -			   map->name, name, (unsigned int)key_size, def->key_size);
> > +	if (BTF_INFO_KIND(container_type->info) != BTF_KIND_STRUCT ||
> > +	    BTF_INFO_VLEN(container_type->info) < 2) {
> 
> Should "BTF_INFO_VLEN(container_type->info) < 2" be
> "BTF_INFO_VLEN(container_type->info) != 2"?
I intentionally use "<" in case we may want to extend
BPF_ANNOTATE_KV_PAIR in the future.

> 
> > +		pr_warning("map:%s container_name:%s is an invalid container struct\n",
> > +			   map->name, container_name);
> >   		return -EINVAL;
> >   	}
> > -	/* Find value type from BTF */
> > -	if (snprintf(name, max_name, "%s_value", map->name) == max_name) {
> > -		pr_warning("map:%s length of BTF value_type:%s_value is too long\n",
> > -			  map->name, map->name);
> > -		return -EINVAL;
> > +	key = (struct btf_member *)(container_type + 1);
> > +	value = key + 1;
> > +
> > +	key_size = btf__resolve_size(btf, key->type);
> > +	if (key_size < 0) {
> > +		pr_warning("map:%s invalid BTF key_type_size\n",
> > +			   map->name);
> > +		return key_size;
> >   	}
> > -	value_id = btf__find_by_name(btf, name);
> > -	if (value_id < 0) {
> > -		pr_debug("map:%s value_type:%s cannot be found in BTF\n",
> > -			 map->name, name);
> > -		return value_id;
> > +	if (def->key_size != key_size) {
> > +		pr_warning("map:%s btf_key_type_size:%u != map_def_key_size:%u\n",
> > +			   map->name, (__u32)key_size, def->key_size);
> > +		return -EINVAL;
> >   	}
> > -	value_size = btf__resolve_size(btf, value_id);
> > +	value_size = btf__resolve_size(btf, value->type);
> >   	if (value_size < 0) {
> > -		pr_warning("map:%s value_type:%s cannot get the BTF type_size\n",
> > -			   map->name, name);
> > +		pr_warning("map:%s invalid BTF value_type_size\n", map->name);
> >   		return value_size;
> >   	}
> >   	if (def->value_size != value_size) {
> > -		pr_warning("map:%s value_type:%s has BTF type_size:%u != value_size:%u\n",
> > -			   map->name, name, (unsigned int)value_size, def->value_size);
> > +		pr_warning("map:%s btf_value_type_size:%u != map_def_value_size:%u\n",
> > +			   map->name, (__u32)value_size, def->value_size);
> >   		return -EINVAL;
> >   	}
> > -	map->btf_key_type_id = key_id;
> > -	map->btf_value_type_id = value_id;
> > +	map->btf_key_type_id = key->type;
> > +	map->btf_value_type_id = value->type;
> >   	return 0;
> >   }
> > diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h
> > index f2f28b6c8915..810de20e8e26 100644
> > --- a/tools/testing/selftests/bpf/bpf_helpers.h
> > +++ b/tools/testing/selftests/bpf/bpf_helpers.h
> > @@ -158,6 +158,15 @@ struct bpf_map_def {
> >   	unsigned int numa_node;
> >   };
> > +#define BPF_ANNOTATE_KV_PAIR(name, type_key, type_val)		\
> > +	struct ____btf_map_##name {				\
> > +		type_key key;					\
> > +		type_val value;					\
> > +	};							\
> > +	struct ____btf_map_##name				\
> > +	__attribute__ ((section(".maps." #name), used))		\
> > +		____btf_map_##name = { }
> > +
> >   static int (*bpf_skb_load_bytes)(void *ctx, int off, void *to, int len) =
> >   	(void *) BPF_FUNC_skb_load_bytes;
> >   static int (*bpf_skb_store_bytes)(void *ctx, int off, void *from, int len, int flags) =
> > diff --git a/tools/testing/selftests/bpf/test_btf_haskv.c b/tools/testing/selftests/bpf/test_btf_haskv.c
> > index 8c7ca096ecf2..b21b876f475d 100644
> > --- a/tools/testing/selftests/bpf/test_btf_haskv.c
> > +++ b/tools/testing/selftests/bpf/test_btf_haskv.c
> > @@ -10,11 +10,6 @@ struct ipv_counts {
> >   	unsigned int v6;
> >   };
> > -typedef int btf_map_key;
> > -typedef struct ipv_counts btf_map_value;
> > -btf_map_key dumm_key;
> > -btf_map_value dummy_value;
> > -
> >   struct bpf_map_def SEC("maps") btf_map = {
> >   	.type = BPF_MAP_TYPE_ARRAY,
> >   	.key_size = sizeof(int),
> > @@ -22,6 +17,8 @@ struct bpf_map_def SEC("maps") btf_map = {
> >   	.max_entries = 4,
> >   };
> > +BPF_ANNOTATE_KV_PAIR(btf_map, int, struct ipv_counts);
> > +
> >   struct dummy_tracepoint_args {
> >   	unsigned long long pad;
> >   	struct sock *sock;
> > 

^ permalink raw reply

* Re: [PATCH 1/2] Add sw2_sw4 voltage table to cpcap regulator.
From: Peter Geis @ 2018-07-23 19:43 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Mark Brown, lgirdwood, robh+dt, mark.rutland, linux-kernel,
	devicetree, linux-tegra
In-Reply-To: <3459086.gtf8SULmVS@dimapc>

On 07/23/2018 03:20 PM, Dmitry Osipenko wrote:
> On Monday, 23 July 2018 21:37:50 MSK Peter Geis wrote:
>> On 07/23/2018 02:13 PM, Mark Brown wrote:
>>> On Mon, Jul 23, 2018 at 01:58:26PM -0400, Peter Geis wrote:
>>>> SW2 and SW4 use a shared table to provide voltage to the cpu core and
>>>> devices on Tegra hardware.
>>>> Added this table to the cpcap regulator driver as the first step to
>>>> supporting this device on Tegra.
>>>
>>> This also doesn't apply against current code (though it does now parse
>>> OK), please check and resend - make sure you don't have other out of
>>> tree changes and are using an up to date kernel (ideally my regulator
>>> for-next branch) as a base.
>>
>> Good Afternoon,
>>
>> I thought it was my error in the patches being stripped, unfortunately
>> it seems to be a known Gmail behavior.
>> Any ideas on how to get around it?
> 
> Use the "git send-email" instead of email client.
> 
> You need to create and send out patches using git, that will be something like
> this:
> 
> 1) "git format-patch -v1 -2 ..." to make patches
> 2) "git send-email --smtp-server=smtp.gmail.com --smtp-
> user=pgwipeout@gmail.com --smtp-encryption=tls --smtp-server-port=587 --
> suppress-cc=all --confirm=always --to 'Mark Brown <broonie@kernel.org>' --cc
> 'linux-tegra@vger.kernel.org' --cc 'linux-kernel@vger.kernel.org' ...
> 00*.patch" to send out the patches
> 

As always, thanks Dmitry!
Resent through git this time.

^ permalink raw reply

* Re: [PATCH net] ip: hash fragments consistently
From: David Miller @ 2018-07-23 18:40 UTC (permalink / raw)
  To: pabeni; +Cc: netdev, tom
In-Reply-To: <9b22fd3a35416b3145f1245466167b001925ce1a.1532357173.git.pabeni@redhat.com>

From: Paolo Abeni <pabeni@redhat.com>
Date: Mon, 23 Jul 2018 16:50:48 +0200

> The skb hash for locally generated ip[v6] fragments belonging
> to the same datagram can vary in several circumstances:
> * for connected UDP[v6] sockets, the first fragment get its hash
>   via set_owner_w()/skb_set_hash_from_sk()
> * for unconnected IPv6 UDPv6 sockets, the first fragment can get
>   its hash via ip6_make_flowlabel()/skb_get_hash_flowi6(), if
>   auto_flowlabel is enabled
> 
> For the following frags the hash is usually computed via
> skb_get_hash().
> The above can cause OoO for unconnected IPv6 UDPv6 socket: in that
> scenario the egress tx queue can be selected on a per packet basis
> via the skb hash.
> It may also fool flow-oriented schedulers to place fragments belonging
> to the same datagram in different flows.
> 
> Fix the issue by copying the skb hash from the head frag into
> the others at fragmentation time.
> 
> Before this commit:
> perf probe -a "dev_queue_xmit skb skb->hash skb->l4_hash:b1@0/8 skb->sw_hash:b1@1/8"
> netperf -H $IPV4 -t UDP_STREAM -l 5 -- -m 2000 -n &
> perf record -e probe:dev_queue_xmit -e probe:skb_set_owner_w -a sleep 0.1
> perf script
> probe:dev_queue_xmit: (ffffffff8c6b1b20) hash=3713014309 l4_hash=1 sw_hash=0
> probe:dev_queue_xmit: (ffffffff8c6b1b20) hash=0 l4_hash=0 sw_hash=0
> 
> After this commit:
> probe:dev_queue_xmit: (ffffffff8c6b1b20) hash=2171763177 l4_hash=1 sw_hash=0
> probe:dev_queue_xmit: (ffffffff8c6b1b20) hash=2171763177 l4_hash=1 sw_hash=0
> 
> Fixes: b73c3d0e4f0e ("net: Save TX flow hash in sock and set in skbuf on xmit")
> Fixes: 67800f9b1f4e ("ipv6: Call skb_get_hash_flowi6 to get skb->hash in ip6_make_flowlabel")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Good catch!

Applied and queued up for -stable, thanks!

^ permalink raw reply

* ✓ Fi.CI.IGT: success for drm/i915: Skip repeated calls to i915_gem_set_wedged() (rev2)
From: Patchwork @ 2018-07-23 19:41 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx
In-Reply-To: <20180723145335.24579-1-chris@chris-wilson.co.uk>

== Series Details ==

Series: drm/i915: Skip repeated calls to i915_gem_set_wedged() (rev2)
URL   : https://patchwork.freedesktop.org/series/47067/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4529_full -> Patchwork_9749_full =

== Summary - WARNING ==

  Minor unknown changes coming with Patchwork_9749_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_9749_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  

== Possible new issues ==

  Here are the unknown changes that may have been introduced in Patchwork_9749_full:

  === IGT changes ===

    ==== Warnings ====

    igt@gem_mocs_settings@mocs-rc6-blt:
      shard-kbl:          PASS -> SKIP +1

    igt@gem_mocs_settings@mocs-rc6-vebox:
      shard-kbl:          SKIP -> PASS +2

    
== Known issues ==

  Here are the changes found in Patchwork_9749_full that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_eio@execbuf:
      shard-glk:          PASS -> INCOMPLETE (k.org#198133, fdo#103359) +15

    igt@gem_eio@in-flight-contexts-1us:
      shard-kbl:          PASS -> INCOMPLETE (fdo#103665) +14

    igt@gem_eio@in-flight-contexts-immediate:
      shard-hsw:          PASS -> INCOMPLETE (fdo#103540) +14

    igt@gem_eio@in-flight-immediate:
      shard-apl:          PASS -> INCOMPLETE (fdo#103927) +15

    igt@gem_eio@in-flight-suspend:
      shard-kbl:          PASS -> INCOMPLETE (fdo#106702, fdo#103665)

    igt@gem_eio@throttle:
      shard-snb:          PASS -> INCOMPLETE (fdo#105411) +16

    
  fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
  fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540
  fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
  fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
  fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
  fdo#106702 https://bugs.freedesktop.org/show_bug.cgi?id=106702
  k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133


== Participating hosts (5 -> 5) ==

  No changes in participating hosts


== Build changes ==

    * Linux: CI_DRM_4529 -> Patchwork_9749

  CI_DRM_4529: f44f476c6bb735cb4067af0c4417c49d105bf419 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4571: 65fccc149b85968cdce4737266b056059c1510f3 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_9749: 9b348bfd231b38751c4d528a89d795745484c760 @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9749/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply

* Re: bisected: 4.18-rc* regression: x86-32 troubles (with timers?)
From: Daniel Borkmann @ 2018-07-23 19:41 UTC (permalink / raw)
  To: Arnd Bergmann, Meelis Roos; +Cc: Linux Kernel list, Networking
In-Reply-To: <CAK8P3a19pCbn5Ns0jVqGTiSmGj4AOgjWL0CQtAA-sYRqY4Gvjw@mail.gmail.com>

Hello Meelis, Arnd,

On 07/23/2018 06:03 PM, Arnd Bergmann wrote:
> On Sat, Jul 21, 2018 at 1:01 AM, Meelis Roos <mroos@linux.ee> wrote:
>> Added netdev and Daniel Borkmann - please see
>> https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1724795.html
>> for the original report. It seems to be about BPF instead.
>>
>> Meanwhile I have found more machines with the trouble. Still no clear
>> mark in the config - some x86-32 machines that have
>> CONFIG_BPF=y
>> CONFIG_BPF_SYSCALL=y
>> CONFIG_BPF_JIT_ALWAYS_ON=y
>> are working fine.
>>
>>> The new bisect seems to have also led me to a strange commit. This time
>>> I tried to be careful and tested most on two reboots before classifying
>>> as good.
>>>
>>> However, f4e3ec0d573e was suspicious - it failed to autoload e1000 but
>>> had no other errors. On both boots with this kernel, modprobe e1000 and
>>> ifup -a made the system work so I assumed it was good, while it might
>>> not have been. Will try bisecting with f4e3ec0d573e marked bad.
>>
>> Now this seems more relevant:
>>
>> mroos@rx100s2:~/linux$ nice git bisect good
>> 24dea04767e6e5175f4750770281b0c17ac6a2fb is the first bad commit
>> commit 24dea04767e6e5175f4750770281b0c17ac6a2fb
>> Author: Daniel Borkmann <daniel@iogearbox.net>
>> Date:   Fri May 4 01:08:23 2018 +0200
>>
>>     bpf, x32: remove ld_abs/ld_ind
>>
>>     Since LD_ABS/LD_IND instructions are now removed from the core and
>>     reimplemented through a combination of inlined BPF instructions and
>>     a slow-path helper, we can get rid of the complexity from x32 JIT.
> 
> This does seem much more likely than the previous bisection, given
> that you ended up in an x86-32 specific commit (the subject says x32,
> but that is a mistake). I also checked that systemd indeed does
> call into bpf in a number of places, possibly for the journald socket.
> 
> OTOH, it's still hard to tell how that commit can have ended up
> corrupting the clock read function in systemd. To cross-check,
> could you try reverting that commit on the latest kernel and see
> if it still works?

I would be curious as well about that whether revert would make it
work. What's the value of sysctl net.core.bpf_jit_enable ? Does it
change anything if you set it to 0 (only interpreter) or 1 (JIT
enabled). Seems a bit strange to me that bisect ended at this commit
given the issue you have. The JIT itself was also new in this window
fwiw. In any case some more debug info would be great to have.

Thanks,
Daniel

^ permalink raw reply

* Re: KASAN: use-after-free Read in p9_fd_poll
From: syzbot @ 2018-07-23 19:41 UTC (permalink / raw)
  To: davem, ericvh, linux-kernel, lucho, netdev, rminnich,
	syzkaller-bugs, v9fs-developer
In-Reply-To: <000000000000afbebb0570be9bf3@google.com>

syzbot has found a reproducer for the following crash on:

HEAD commit:    d72e90f33aa4 Linux 4.18-rc6
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=161894c8400000
kernel config:  https://syzkaller.appspot.com/x/.config?x=68af3495408deac5
dashboard link: https://syzkaller.appspot.com/bug?extid=0442e6e2f7e1e33b1037
compiler:       gcc (GCC) 8.0.1 20180413 (experimental)
syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=1569b51c400000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16e7a978400000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+0442e6e2f7e1e33b1037@syzkaller.appspotmail.com

random: sshd: uninitialized urandom read (32 bytes read)
random: sshd: uninitialized urandom read (32 bytes read)
==================================================================
BUG: KASAN: use-after-free in p9_fd_poll+0x280/0x2b0 net/9p/trans_fd.c:238
Read of size 8 at addr ffff8801d6ddf340 by task kworker/0:2/26

CPU: 0 PID: 26 Comm: kworker/0:2 Not tainted 4.18.0-rc6+ #160
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011
Workqueue: events p9_poll_workfn
Call Trace:
  __dump_stack lib/dump_stack.c:77 [inline]
  dump_stack+0x1c9/0x2b4 lib/dump_stack.c:113
  print_address_description+0x6c/0x20b mm/kasan/report.c:256
  kasan_report_error mm/kasan/report.c:354 [inline]
  kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
  __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
  p9_fd_poll+0x280/0x2b0 net/9p/trans_fd.c:238
  p9_poll_mux net/9p/trans_fd.c:617 [inline]
  p9_poll_workfn+0x463/0x6d0 net/9p/trans_fd.c:1107
  process_one_work+0xc73/0x1ba0 kernel/workqueue.c:2153
  worker_thread+0x189/0x13c0 kernel/workqueue.c:2296
  kthread+0x345/0x410 kernel/kthread.c:246
  ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412

Allocated by task 4581:
  save_stack+0x43/0xd0 mm/kasan/kasan.c:448
  set_track mm/kasan/kasan.c:460 [inline]
  kasan_kmalloc+0xc4/0xe0 mm/kasan/kasan.c:553
  kmem_cache_alloc_trace+0x152/0x780 mm/slab.c:3620
  kmalloc include/linux/slab.h:513 [inline]
  kzalloc include/linux/slab.h:707 [inline]
  p9_fd_open net/9p/trans_fd.c:796 [inline]
  p9_fd_create+0x1a7/0x3f0 net/9p/trans_fd.c:1036
  p9_client_create+0x8ed/0x1770 net/9p/client.c:1063
  v9fs_session_init+0x21a/0x1a80 fs/9p/v9fs.c:400
  v9fs_mount+0x7c/0x900 fs/9p/vfs_super.c:135
  mount_fs+0xae/0x328 fs/super.c:1277
  vfs_kern_mount.part.34+0xdc/0x4e0 fs/namespace.c:1037
  vfs_kern_mount fs/namespace.c:1027 [inline]
  do_new_mount fs/namespace.c:2518 [inline]
  do_mount+0x581/0x30e0 fs/namespace.c:2848
  ksys_mount+0x12d/0x140 fs/namespace.c:3064
  __do_sys_mount fs/namespace.c:3078 [inline]
  __se_sys_mount fs/namespace.c:3075 [inline]
  __x64_sys_mount+0xbe/0x150 fs/namespace.c:3075
  do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
  entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 4581:
  save_stack+0x43/0xd0 mm/kasan/kasan.c:448
  set_track mm/kasan/kasan.c:460 [inline]
  __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:521
  kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
  __cache_free mm/slab.c:3498 [inline]
  kfree+0xd9/0x260 mm/slab.c:3813
  p9_fd_close+0x416/0x5b0 net/9p/trans_fd.c:893
  p9_client_create+0xa9a/0x1770 net/9p/client.c:1077
  v9fs_session_init+0x21a/0x1a80 fs/9p/v9fs.c:400
  v9fs_mount+0x7c/0x900 fs/9p/vfs_super.c:135
  mount_fs+0xae/0x328 fs/super.c:1277
  vfs_kern_mount.part.34+0xdc/0x4e0 fs/namespace.c:1037
  vfs_kern_mount fs/namespace.c:1027 [inline]
  do_new_mount fs/namespace.c:2518 [inline]
  do_mount+0x581/0x30e0 fs/namespace.c:2848
  ksys_mount+0x12d/0x140 fs/namespace.c:3064
  __do_sys_mount fs/namespace.c:3078 [inline]
  __se_sys_mount fs/namespace.c:3075 [inline]
  __x64_sys_mount+0xbe/0x150 fs/namespace.c:3075
  do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
  entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8801d6ddf340
  which belongs to the cache kmalloc-512 of size 512
The buggy address is located 0 bytes inside of
  512-byte region [ffff8801d6ddf340, ffff8801d6ddf540)
The buggy address belongs to the page:
page:ffffea00075b77c0 count:1 mapcount:0 mapping:ffff8801da800940 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffffea0007398548 ffffea0006c59188 ffff8801da800940
raw: 0000000000000000 ffff8801d6ddf0c0 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
  ffff8801d6ddf200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
  ffff8801d6ddf280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
> ffff8801d6ddf300: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                            ^
  ffff8801d6ddf380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
  ffff8801d6ddf400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


^ permalink raw reply

* [Buildroot] [PATCH] package/binutils: add binutils version 2.31
From: Max Filippov @ 2018-07-23 19:40 UTC (permalink / raw)
  To: buildroot
In-Reply-To: <20180717130952.5b09ca40@windsurf>

On Tue, Jul 17, 2018 at 4:09 AM, Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
> The update to binutils 2.31 seems to be causing a regression: it cannot
> build uClibc anymore:

Thanks for the report, the issue is now fixed in the binutils
and a patch is posted to the buildroot.

>   LD libthread_db-1.0.30.so
> /opt/xtensa-lx60--uclibc--bleeding-edge-2018.07-1/lib/gcc/xtensa-buildroot-linux-uclibc/8.1.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: BFD (GNU Binutils) 2.31 internal error, aborting at elf32-xtensa.c:3269 in elf_xtensa_finish_dynamic_sections
>
> /opt/xtensa-lx60--uclibc--bleeding-edge-2018.07-1/lib/gcc/xtensa-buildroot-linux-uclibc/8.1.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: Please report this bug.
>
> collect2: error: ld returned 1 exit status
> libpthread/nptl_db/Makefile.in:53: recipe for target 'lib/libthread_db.so' failed
> make[1]: *** [lib/libthread_db.so] Error 1
> make[1]: Leaving directory '/opt/output/build/uclibc-1.0.30'
>
> My previous build of toolchains, which was using binutils 2.30, went
> fine including on Xtensa.
>
> See
> https://gitlab.com/free-electrons/toolchains-builder/-/jobs/82264912
> for the build failure.

-- 
Thanks.
-- Max

^ permalink raw reply

* Re: [PATCH 0/5] Misc Coccinelle-related improvements
From: Junio C Hamano @ 2018-07-23 19:40 UTC (permalink / raw)
  To: SZEDER Gábor
  Cc: git, René Scharfe, Derrick Stolee,
	Nguyễn Thái Ngọc Duy
In-Reply-To: <20180723135100.24288-1-szeder.dev@gmail.com>

SZEDER Gábor <szeder.dev@gmail.com> writes:

> Just a couple of minor Coccinelle-related improvements:
>
>   - The first two patches are small cleanups.
>
>   - The last three could make life perhaps just a tad bit easier for
>     devs running 'make coccicheck'.

Thanks.  All 5 patches make sense.

Queued.

^ permalink raw reply

* [Bug 106441] Totem video playback stuttering and graphical artifacts
From: bugzilla-daemon @ 2018-07-23 19:40 UTC (permalink / raw)
  To: dri-devel
In-Reply-To: <bug-106441-502@http.bugs.freedesktop.org/>


[-- Attachment #1.1: Type: text/plain, Size: 618 bytes --]

https://bugs.freedesktop.org/show_bug.cgi?id=106441

--- Comment #6 from Richard B. Kreckel <kreckel@ginac.de> ---
(In reply to Richard B. Kreckel from comment #5)
> It must be Xorg.
> 
> I've upgradee to Xorg 1.20 (without upgrading anything else) from
> Debian/experimental and this problem has disappeared for good.

...which is not to say that things work, now.
In a way it's worse than before but this seems to be another problem:
<https://gitlab.gnome.org/GNOME/totem/issues/241>.
(I'm posting this here for the record.)

-- 
You are receiving this mail because:
You are the assignee for the bug.

[-- Attachment #1.2: Type: text/html, Size: 1564 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply

* [PATCH] drm/i915: Skip repeated calls to i915_gem_set_wedged()
From: Chris Wilson @ 2018-07-23 19:39 UTC (permalink / raw)
  To: intel-gfx
In-Reply-To: <20180723145335.24579-1-chris@chris-wilson.co.uk>

If we already wedged, i915_gem_set_wedged() becomes a complicated no-op.

v2: Make sure the double set-wedged is synchronous, a parallel call
should not return before the driver is indeed wedged.

References: https://bugs.freedesktop.org/show_bug.cgi?id=107343
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c       | 31 ++++++++++++++++++++++-----
 drivers/gpu/drm/i915/i915_gpu_error.h |  3 ++-
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 8b52cb768a67..832c65734c47 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3298,12 +3298,26 @@ static void nop_complete_submit_request(struct i915_request *request)
 	spin_unlock_irqrestore(&request->engine->timeline.lock, flags);
 }
 
+static void wait_for_wedged(struct i915_gpu_error *error)
+{
+	DEFINE_WAIT_BIT(wq_entry, &error->flags, I915_WEDGED);
+
+	__wait_on_bit(&error->reset_queue,
+		      &wq_entry, bit_wait, TASK_UNINTERRUPTIBLE);
+}
+
 void i915_gem_set_wedged(struct drm_i915_private *i915)
 {
+	struct i915_gpu_error *error = &i915->gpu_error;
 	struct intel_engine_cs *engine;
 	enum intel_engine_id id;
 
-	GEM_TRACE("start\n");
+	if (test_and_set_bit(I915_WEDGE_IN_PROGRESS, &error->flags)) {
+		wait_for_wedged(error);
+		return;
+	}
+	if (test_bit(I915_WEDGED, &error->flags))
+		return;
 
 	if (GEM_SHOW_DEBUG()) {
 		struct drm_printer p = drm_debug_printer(__func__);
@@ -3312,8 +3326,7 @@ void i915_gem_set_wedged(struct drm_i915_private *i915)
 			intel_engine_dump(engine, &p, "%s\n", engine->name);
 	}
 
-	set_bit(I915_WEDGED, &i915->gpu_error.flags);
-	smp_mb__after_atomic();
+	GEM_TRACE("start\n");
 
 	/*
 	 * First, stop submission to hw, but do not yet complete requests by
@@ -3372,17 +3385,25 @@ void i915_gem_set_wedged(struct drm_i915_private *i915)
 		i915_gem_reset_finish_engine(engine);
 	}
 
+	smp_mb__before_atomic();
+	set_bit(I915_WEDGED, &error->flags);
+	clear_bit(I915_WEDGE_IN_PROGRESS, &error->flags);
+
 	GEM_TRACE("end\n");
 
-	wake_up_all(&i915->gpu_error.reset_queue);
+	wake_up_all(&error->reset_queue);
 }
 
 bool i915_gem_unset_wedged(struct drm_i915_private *i915)
 {
+	struct i915_gpu_error *error = &i915->gpu_error;
 	struct i915_timeline *tl;
 
 	lockdep_assert_held(&i915->drm.struct_mutex);
-	if (!test_bit(I915_WEDGED, &i915->gpu_error.flags))
+
+	if (test_bit(I915_WEDGE_IN_PROGRESS, &error->flags))
+		wait_for_wedged(error);
+	if (!test_bit(I915_WEDGED, &error->flags))
 		return true;
 
 	GEM_TRACE("start\n");
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.h b/drivers/gpu/drm/i915/i915_gpu_error.h
index f893a4e8b783..1a78a8f330f2 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.h
+++ b/drivers/gpu/drm/i915/i915_gpu_error.h
@@ -267,8 +267,9 @@ struct i915_gpu_error {
 #define I915_RESET_BACKOFF	0
 #define I915_RESET_HANDOFF	1
 #define I915_RESET_MODESET	2
+#define I915_RESET_ENGINE	3
 #define I915_WEDGED		(BITS_PER_LONG - 1)
-#define I915_RESET_ENGINE	(I915_WEDGED - I915_NUM_ENGINES)
+#define I915_WEDGE_IN_PROGRESS	(I915_WEDGED - 1)
 
 	/** Number of times an engine has been reset */
 	u32 reset_engine_count[I915_NUM_ENGINES];
-- 
2.18.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related

* [PATCH 2/2 v2] Add support for CPCAP regulators on Tegra devices.
From: Peter Geis @ 2018-07-23 19:38 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, robh+dt, linux-kernel, devicetree, linux-tegra,
	Peter Geis
In-Reply-To: <20180723193848.32491-1-pgwipeout@gmail.com>

Added support for the CPCAP power management regulator functions on
Tegra devices.
Added sw2_sw4 value tables, which provide power to the Tegra core and
aux devices.
Added the Tegra init tables and device tree compatibility match.

Signed-off-by: Peter Geis <pgwipeout@gmail.com>
---
 .../bindings/regulator/cpcap-regulator.txt    |  1 +
 drivers/regulator/cpcap-regulator.c           | 80 +++++++++++++++++++
 2 files changed, 81 insertions(+)

diff --git a/Documentation/devicetree/bindings/regulator/cpcap-regulator.txt b/Documentation/devicetree/bindings/regulator/cpcap-regulator.txt
index 675f4437ce92..3e2d33ab1731 100644
--- a/Documentation/devicetree/bindings/regulator/cpcap-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/cpcap-regulator.txt
@@ -4,6 +4,7 @@ Motorola CPCAP PMIC voltage regulators
 Requires node properties:
 - "compatible" value one of:
     "motorola,cpcap-regulator"
+    "motorola,tegra-cpcap-regulator"
     "motorola,mapphone-cpcap-regulator"
 
 Required regulator properties:
diff --git a/drivers/regulator/cpcap-regulator.c b/drivers/regulator/cpcap-regulator.c
index c0b1e04bd90f..cb3774be445d 100644
--- a/drivers/regulator/cpcap-regulator.c
+++ b/drivers/regulator/cpcap-regulator.c
@@ -412,6 +412,82 @@ static struct cpcap_regulator omap4_regulators[] = {
 	{ /* sentinel */ },
 };
 
+static struct cpcap_regulator tegra_regulators[] = {
+	CPCAP_REG(SW1, CPCAP_REG_S1C1, CPCAP_REG_ASSIGN2,
+		  CPCAP_BIT_SW1_SEL, unknown_val_tbl,
+		  0, 0, 0, 0, 0, 0),
+	CPCAP_REG(SW2, CPCAP_REG_S2C1, CPCAP_REG_ASSIGN2,
+		  CPCAP_BIT_SW2_SEL, sw2_sw4_val_tbl,
+		  0xf00, 0x7f, 0, 0x800, 0, 120),
+	CPCAP_REG(SW3, CPCAP_REG_S3C, CPCAP_REG_ASSIGN2,
+		  CPCAP_BIT_SW3_SEL, unknown_val_tbl,
+		  0, 0, 0, 0, 0, 0),
+	CPCAP_REG(SW4, CPCAP_REG_S4C1, CPCAP_REG_ASSIGN2,
+		  CPCAP_BIT_SW4_SEL, sw2_sw4_val_tbl,
+		  0xf00, 0x7f, 0, 0x900, 0, 100),
+	CPCAP_REG(SW5, CPCAP_REG_S5C, CPCAP_REG_ASSIGN2,
+		  CPCAP_BIT_SW5_SEL, sw5_val_tbl,
+		  0x2a, 0, 0, 0x22, 0, 0),
+	CPCAP_REG(SW6, CPCAP_REG_S6C, CPCAP_REG_ASSIGN2,
+		  CPCAP_BIT_SW6_SEL, unknown_val_tbl,
+		  0, 0, 0, 0, 0, 0),
+	CPCAP_REG(VCAM, CPCAP_REG_VCAMC, CPCAP_REG_ASSIGN2,
+		  CPCAP_BIT_VCAM_SEL, vcam_val_tbl,
+		  0x87, 0x30, 4, 0x7, 0, 420),
+	CPCAP_REG(VCSI, CPCAP_REG_VCSIC, CPCAP_REG_ASSIGN3,
+		  CPCAP_BIT_VCSI_SEL, vcsi_val_tbl,
+		  0x47, 0x10, 4, 0x7, 0, 350),
+	CPCAP_REG(VDAC, CPCAP_REG_VDACC, CPCAP_REG_ASSIGN3,
+		  CPCAP_BIT_VDAC_SEL, vdac_val_tbl,
+		  0x87, 0x30, 4, 0x3, 0, 420),
+	CPCAP_REG(VDIG, CPCAP_REG_VDIGC, CPCAP_REG_ASSIGN2,
+		  CPCAP_BIT_VDIG_SEL, vdig_val_tbl,
+		  0x87, 0x30, 4, 0x5, 0, 420),
+	CPCAP_REG(VFUSE, CPCAP_REG_VFUSEC, CPCAP_REG_ASSIGN3,
+		  CPCAP_BIT_VFUSE_SEL, vfuse_val_tbl,
+		  0x80, 0xf, 0, 0x80, 0, 420),
+	CPCAP_REG(VHVIO, CPCAP_REG_VHVIOC, CPCAP_REG_ASSIGN3,
+		  CPCAP_BIT_VHVIO_SEL, vhvio_val_tbl,
+		  0x17, 0, 0, 0x2, 0, 0),
+	CPCAP_REG(VSDIO, CPCAP_REG_VSDIOC, CPCAP_REG_ASSIGN2,
+		  CPCAP_BIT_VSDIO_SEL, vsdio_val_tbl,
+		  0x87, 0x38, 3, 0x2, 0, 420),
+	CPCAP_REG(VPLL, CPCAP_REG_VPLLC, CPCAP_REG_ASSIGN3,
+		  CPCAP_BIT_VPLL_SEL, vpll_val_tbl,
+		  0x43, 0x18, 3, 0x1, 0, 420),
+	CPCAP_REG(VRF1, CPCAP_REG_VRF1C, CPCAP_REG_ASSIGN3,
+		  CPCAP_BIT_VRF1_SEL, vrf1_val_tbl,
+		  0xac, 0x2, 1, 0xc, 0, 10),
+	CPCAP_REG(VRF2, CPCAP_REG_VRF2C, CPCAP_REG_ASSIGN3,
+		  CPCAP_BIT_VRF2_SEL, vrf2_val_tbl,
+		  0x23, 0x8, 3, 0x3, 0, 10),
+	CPCAP_REG(VRFREF, CPCAP_REG_VRFREFC, CPCAP_REG_ASSIGN3,
+		  CPCAP_BIT_VRFREF_SEL, vrfref_val_tbl,
+		  0x23, 0x8, 3, 0x3, 0, 420),
+	CPCAP_REG(VWLAN1, CPCAP_REG_VWLAN1C, CPCAP_REG_ASSIGN3,
+		  CPCAP_BIT_VWLAN1_SEL, vwlan1_val_tbl,
+		  0x47, 0x10, 4, 0x5, 0, 420),
+	CPCAP_REG(VWLAN2, CPCAP_REG_VWLAN2C, CPCAP_REG_ASSIGN3,
+		  CPCAP_BIT_VWLAN2_SEL, vwlan2_val_tbl,
+		  0x20c, 0xc0, 6, 0x8, 0, 420),
+	CPCAP_REG(VSIM, CPCAP_REG_VSIMC, CPCAP_REG_ASSIGN3,
+		  0xffff, vsim_val_tbl,
+		  0x23, 0x8, 3, 0x3, 0, 420),
+	CPCAP_REG(VSIMCARD, CPCAP_REG_VSIMC, CPCAP_REG_ASSIGN3,
+		  0xffff, vsimcard_val_tbl,
+		  0x1e80, 0x8, 3, 0x1e00, 0, 420),
+	CPCAP_REG(VVIB, CPCAP_REG_VVIBC, CPCAP_REG_ASSIGN3,
+		  CPCAP_BIT_VVIB_SEL, vvib_val_tbl,
+		  0x1, 0xc, 2, 0, 0x1, 500),
+	CPCAP_REG(VUSB, CPCAP_REG_VUSBC, CPCAP_REG_ASSIGN3,
+		  CPCAP_BIT_VUSB_SEL, vusb_val_tbl,
+		  0x11c, 0x40, 6, 0xc, 0, 0),
+	CPCAP_REG(VAUDIO, CPCAP_REG_VAUDIOC, CPCAP_REG_ASSIGN4,
+		  CPCAP_BIT_VAUDIO_SEL, vaudio_val_tbl,
+		  0x16, 0x1, 0, 0x4, 0, 0),
+	{ /* sentinel */ },
+};
+
 static const struct of_device_id cpcap_regulator_id_table[] = {
 	{
 		.compatible = "motorola,cpcap-regulator",
@@ -420,6 +496,10 @@ static const struct of_device_id cpcap_regulator_id_table[] = {
 		.compatible = "motorola,mapphone-cpcap-regulator",
 		.data = omap4_regulators,
 	},
+	{
+		.compatible = "motorola,tegra-cpcap-regulator",
+		.data = tegra_regulators,
+	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, cpcap_regulator_id_table);
-- 
2.17.1

^ permalink raw reply related

* [PATCH 1/2 v2] Add sw2_sw4 voltage table to cpcap regulator.
From: Peter Geis @ 2018-07-23 19:38 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, robh+dt, linux-kernel, devicetree, linux-tegra,
	Peter Geis
In-Reply-To: <20180723193848.32491-1-pgwipeout@gmail.com>

SW2 and SW4 use a shared table to provide voltage to the cpu core and
devices on Tegra hardware.
Added this table to the cpcap regulator driver as the first step to
supporting this device on Tegra.

Signed-off-by: Peter Geis <pgwipeout@gmail.com>
---
 drivers/regulator/cpcap-regulator.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/regulator/cpcap-regulator.c b/drivers/regulator/cpcap-regulator.c
index bd910fe123d9..c0b1e04bd90f 100644
--- a/drivers/regulator/cpcap-regulator.c
+++ b/drivers/regulator/cpcap-regulator.c
@@ -271,6 +271,29 @@ static struct regulator_ops cpcap_regulator_ops = {
 };
 
 static const unsigned int unknown_val_tbl[] = { 0, };
+static const unsigned int sw2_sw4_val_tbl[] = { 612500, 625000, 637500,
+						650000, 662500, 675000,
+						687500, 700000, 712500,
+						725000, 737500, 750000,
+						762500, 775000, 787500,
+						800000, 812500, 825000,
+						837500, 850000, 862500,
+						875000, 887500, 900000,
+						912500, 925000, 937500,
+						950000, 962500, 975000,
+						987500, 1000000, 1012500,
+						1025000, 1037500, 1050000,
+						1062500, 1075000, 1087500,
+						1100000, 1112500, 1125000,
+						1137500, 1150000, 1162500,
+						1175000, 1187500, 1200000,
+						1212500, 1225000, 1237500,
+						1250000, 1262500, 1275000,
+						1287500, 1300000, 1312500,
+						1325000, 1337500, 1350000,
+						1362500, 1375000, 1387500,
+						1400000, 1412500, 1425000,
+						1437500, 1450000, 1462500, };
 static const unsigned int sw5_val_tbl[] = { 0, 5050000, };
 static const unsigned int vcam_val_tbl[] = { 2600000, 2700000, 2800000,
 					     2900000, };
-- 
2.17.1

^ permalink raw reply related

* [PATCH 0/2 v2] Add support for cpcap regulators on Tegra devices.
From: Peter Geis @ 2018-07-23 19:38 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, robh+dt, linux-kernel, devicetree, linux-tegra,
	Peter Geis

Good Afternoon,

I am re-sending the whole patch set again.
I have sent this to myself, and confirmed it still patches cleanly.

I apologize once again.

The CPCAP regulator driver can support various devices, but currently only supports Omap4 devices.
Adds the sw2 and sw4 voltage tables, which power the Tegra core, and a DT match for the Tegra device.
Tested on the Motorola Xoom MZ602.

v2:
Stopped reinventing the wheel, using git email now.
Rebased against regulator for-next branch.

v1:
Fix conversion of tabulation to spaces.

Peter Geis (2):
  Add sw2_sw4 voltage table to cpcap regulator.
  Add support for CPCAP regulators on Tegra devices.

 .../bindings/regulator/cpcap-regulator.txt    |   1 +
 drivers/regulator/cpcap-regulator.c           | 103 ++++++++++++++++++
 2 files changed, 104 insertions(+)

-- 
2.17.1

^ permalink raw reply

* [Buildroot] [PATCH] package/binutils: fix xtensa linker relaxation regression in 2.31.1
From: Max Filippov @ 2018-07-23 19:37 UTC (permalink / raw)
  To: buildroot

Fix the following xtensa ld error observed when building uClibc-ng
libthread_db with binutils-2.31:

  BFD (GNU Binutils) 2.31 internal error, aborting at
  elf32-xtensa.c:3269 in elf_xtensa_finish_dynamic_sections

Fixes: https://gitlab.com/free-electrons/toolchains-builder/-/jobs/82264912
Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 ...relaxation-of-undefined-weak-references-i.patch | 48 ++++++++++++
 ...-dynamic-relocations-sections-consistency.patch | 90 ++++++++++++++++++++++
 2 files changed, 138 insertions(+)
 create mode 100644 package/binutils/2.31.1/0010-xtensa-fix-relaxation-of-undefined-weak-references-i.patch
 create mode 100644 package/binutils/2.31.1/0011-xtensa-move-dynamic-relocations-sections-consistency.patch

diff --git a/package/binutils/2.31.1/0010-xtensa-fix-relaxation-of-undefined-weak-references-i.patch b/package/binutils/2.31.1/0010-xtensa-fix-relaxation-of-undefined-weak-references-i.patch
new file mode 100644
index 000000000000..660d30c38925
--- /dev/null
+++ b/package/binutils/2.31.1/0010-xtensa-fix-relaxation-of-undefined-weak-references-i.patch
@@ -0,0 +1,48 @@
+From 5d3a462f05cba5b0c0c96de899b84fb84155c760 Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Sun, 22 Jul 2018 13:52:28 -0700
+Subject: [PATCH] xtensa: fix relaxation of undefined weak references in
+ shared objects
+
+The change c451bb34ae8b ("xtensa: don't emit dynamic relocation for weak
+undefined symbol") didn't properly handle shrinking of relocation
+sections due to coalescing of references to a dynamic undefined weak
+symbol in a shared object, which resulted in the following assertion
+failure in ld when linking uClibc-ng libthread_db for xtensa:
+
+  BFD (GNU Binutils) 2.31 internal error, aborting at elf32-xtensa.c:3269
+  in elf_xtensa_finish_dynamic_sections
+
+Shrink dynamic relocations section for dynamic undefined weak symbols
+when linking a shared object.
+
+bfd/
+2018-07-23  Max Filippov  <jcmvbkbc@gmail.com>
+
+	* elf32-xtensa.c (shrink_dynamic_reloc_sections): Shrink dynamic
+	relocations section for dynamic undefined weak symbols when
+	linking a shared object.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+Backported from: 5d3a462f05cba5b0c0c96de899b84fb84155c760
+---
+ bfd/elf32-xtensa.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
+index f7f569d0c086..a4b046e445f1 100644
+--- a/bfd/elf32-xtensa.c
++++ b/bfd/elf32-xtensa.c
+@@ -10022,7 +10022,8 @@ shrink_dynamic_reloc_sections (struct bfd_link_info *info,
+   if ((r_type == R_XTENSA_32 || r_type == R_XTENSA_PLT)
+       && (input_section->flags & SEC_ALLOC) != 0
+       && (dynamic_symbol || bfd_link_pic (info))
+-      && (!h || h->root.type != bfd_link_hash_undefweak))
++      && (!h || h->root.type != bfd_link_hash_undefweak
++	  || (dynamic_symbol && bfd_link_dll (info))))
+     {
+       asection *srel;
+       bfd_boolean is_plt = FALSE;
+-- 
+2.11.0
+
diff --git a/package/binutils/2.31.1/0011-xtensa-move-dynamic-relocations-sections-consistency.patch b/package/binutils/2.31.1/0011-xtensa-move-dynamic-relocations-sections-consistency.patch
new file mode 100644
index 000000000000..2c12ce3db1d9
--- /dev/null
+++ b/package/binutils/2.31.1/0011-xtensa-move-dynamic-relocations-sections-consistency.patch
@@ -0,0 +1,90 @@
+From f82863d797e461b936dff2b659a3aa65088ee87e Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Sun, 22 Jul 2018 18:59:11 -0700
+Subject: [PATCH] xtensa: move dynamic relocations sections consistency
+ check
+
+The function elf_xtensa_finish_dynamic_sections checks that sizes of
+sections .rela.dyn and .rela.plt match number of corresponding relocation
+records, but the check is only done when .rela.plt is non-empty, so, e.g.
+it is never run for the static PIE.
+Rearrange the test so that .rela.dyn and .rela.plt are checked always.
+
+bfd/
+2018-07-23  Max Filippov  <jcmvbkbc@gmail.com>
+
+	* elf32-xtensa.c (elf_xtensa_finish_dynamic_sections): Move
+	relocation sections consistency check to always check both
+	.rela.dyn and .rela.plt when they exist. Rearrange variable
+	definition and assignment places.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+Backported from: f82863d797e461b936dff2b659a3aa65088ee87e
+---
+ bfd/elf32-xtensa.c | 22 +++++++++++-----------
+ 1 file changed, 11 insertions(+), 11 deletions(-)
+
+diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
+index a4b046e445f1..cf085b7b0751 100644
+--- a/bfd/elf32-xtensa.c
++++ b/bfd/elf32-xtensa.c
+@@ -3156,7 +3156,7 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd,
+ {
+   struct elf_xtensa_link_hash_table *htab;
+   bfd *dynobj;
+-  asection *sdyn, *srelplt, *sgot, *sxtlit, *sgotloc;
++  asection *sdyn, *srelplt, *srelgot, *sgot, *sxtlit, *sgotloc;
+   Elf32_External_Dyn *dyncon, *dynconend;
+   int num_xtlit_entries = 0;
+ 
+@@ -3186,15 +3186,15 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd,
+     }
+ 
+   srelplt = htab->elf.srelplt;
++  srelgot = htab->elf.srelgot;
+   if (srelplt && srelplt->size != 0)
+     {
+-      asection *sgotplt, *srelgot, *spltlittbl;
++      asection *sgotplt, *spltlittbl;
+       int chunk, plt_chunks, plt_entries;
+       Elf_Internal_Rela irela;
+       bfd_byte *loc;
+       unsigned rtld_reloc;
+ 
+-      srelgot = htab->elf.srelgot;
+       spltlittbl = htab->spltlittbl;
+       BFD_ASSERT (srelgot != NULL && spltlittbl != NULL);
+ 
+@@ -3260,14 +3260,6 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd,
+ 		      spltlittbl->contents + (chunk * 8) + 4);
+ 	}
+ 
+-      /* All the dynamic relocations have been emitted at this point.
+-	 Make sure the relocation sections are the correct size.  */
+-      if (srelgot->size != (sizeof (Elf32_External_Rela)
+-			    * srelgot->reloc_count)
+-	  || srelplt->size != (sizeof (Elf32_External_Rela)
+-			       * srelplt->reloc_count))
+-	abort ();
+-
+      /* The .xt.lit.plt section has just been modified.  This must
+ 	happen before the code below which combines adjacent literal
+ 	table entries, and the .xt.lit.plt contents have to be forced to
+@@ -3282,6 +3274,14 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd,
+       spltlittbl->flags &= ~SEC_HAS_CONTENTS;
+     }
+ 
++  /* All the dynamic relocations have been emitted at this point.
++     Make sure the relocation sections are the correct size.  */
++  if ((srelgot && srelgot->size != (sizeof (Elf32_External_Rela)
++				    * srelgot->reloc_count))
++      || (srelplt && srelplt->size != (sizeof (Elf32_External_Rela)
++				       * srelplt->reloc_count)))
++    abort ();
++
+   /* Combine adjacent literal table entries.  */
+   BFD_ASSERT (! bfd_link_relocatable (info));
+   sxtlit = bfd_get_section_by_name (output_bfd, ".xt.lit");
+-- 
+2.11.0
+
-- 
2.11.0

^ permalink raw reply related

* Re: [PATCH 2/5] coccinelle: use $(addsuffix) in 'coccicheck' make target
From: Junio C Hamano @ 2018-07-23 19:37 UTC (permalink / raw)
  To: SZEDER Gábor
  Cc: git, René Scharfe, Derrick Stolee,
	Nguyễn Thái Ngọc Duy
In-Reply-To: <20180723135100.24288-3-szeder.dev@gmail.com>

SZEDER Gábor <szeder.dev@gmail.com> writes:

> The dependencies of the 'coccicheck' make target are listed with the
> help of the $(patsubst) make function, which in this case doesn't do
> any pattern substitution, but only adds the '.patch' suffix.
>
> Use the shorter and more idiomatic $(addsuffix) make function instead.

Makes sense.

>
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 27bfc196dd..8f509576e9 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2683,7 +2683,7 @@ C_SOURCES = $(patsubst %.o,%.c,$(C_OBJ))
>  	then \
>  		echo '    ' SPATCH result: $@; \
>  	fi
> -coccicheck: $(patsubst %.cocci,%.cocci.patch,$(wildcard contrib/coccinelle/*.cocci))
> +coccicheck: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.cocci))
>  
>  .PHONY: coccicheck

^ permalink raw reply

* Re: [RFC PATCH] audit: use current whenever possible
From: Richard Guy Briggs @ 2018-07-23 19:37 UTC (permalink / raw)
  To: Paul Moore; +Cc: linux-audit
In-Reply-To: <153212502997.22712.10176469722588086701.stgit@chester>

On 2018-07-20 18:17, Paul Moore wrote:
> There are many places, notably audit_log_task_info() and
> audit_log_exit(), that take task_struct pointers but in reality they
> are always working on the current task.  This patch eliminates the
> task_struct arguments and uses current directly which allows a number
> of cleanups as well.

I came across and removed a several in the audit task struct cleanup,
but it looks like you've rebased over those and caught a few more.

I'm fine with delaying setting task's context to NULL for
__audit_free().

Why was the context originally taken for __audit_syscall_exit() and
given back once the syscall event records have been issued?  Is there a
possible race with something else?

> Signed-off-by: Paul Moore <paul@paul-moore.com>

Otherwise, this cleanup looks like a good simplification.
Reviewed-by: Richard Guy Briggs <rgb@redhat.com>

> ---
>  drivers/tty/tty_audit.c          |   13 ++--
>  include/linux/audit.h            |    6 +-
>  kernel/audit.c                   |   34 +++++------
>  kernel/audit.h                   |    2 -
>  kernel/auditsc.c                 |  118 +++++++++++++++++---------------------
>  security/integrity/ima/ima_api.c |    2 -
>  6 files changed, 81 insertions(+), 94 deletions(-)
> 
> diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c
> index 50f567b6a66e..28f87fd6a28e 100644
> --- a/drivers/tty/tty_audit.c
> +++ b/drivers/tty/tty_audit.c
> @@ -61,20 +61,19 @@ static void tty_audit_log(const char *description, dev_t dev,
>  			  unsigned char *data, size_t size)
>  {
>  	struct audit_buffer *ab;
> -	struct task_struct *tsk = current;
> -	pid_t pid = task_pid_nr(tsk);
> -	uid_t uid = from_kuid(&init_user_ns, task_uid(tsk));
> -	uid_t loginuid = from_kuid(&init_user_ns, audit_get_loginuid(tsk));
> -	unsigned int sessionid = audit_get_sessionid(tsk);
> +	pid_t pid = task_pid_nr(current);
> +	uid_t uid = from_kuid(&init_user_ns, task_uid(current));
> +	uid_t loginuid = from_kuid(&init_user_ns, audit_get_loginuid(current));
> +	unsigned int sessionid = audit_get_sessionid(current);
>  
>  	ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_TTY);
>  	if (ab) {
> -		char name[sizeof(tsk->comm)];
> +		char name[sizeof(current->comm)];
>  
>  		audit_log_format(ab, "%s pid=%u uid=%u auid=%u ses=%u major=%d"
>  				 " minor=%d comm=", description, pid, uid,
>  				 loginuid, sessionid, MAJOR(dev), MINOR(dev));
> -		get_task_comm(name, tsk);
> +		get_task_comm(name, current);
>  		audit_log_untrustedstring(ab, name);
>  		audit_log_format(ab, " data=");
>  		audit_log_n_hex(ab, data, size);
> diff --git a/include/linux/audit.h b/include/linux/audit.h
> index 9334fbef7bae..108dd9706a30 100644
> --- a/include/linux/audit.h
> +++ b/include/linux/audit.h
> @@ -153,8 +153,7 @@ extern void		    audit_log_link_denied(const char *operation);
>  extern void		    audit_log_lost(const char *message);
>  
>  extern int audit_log_task_context(struct audit_buffer *ab);
> -extern void audit_log_task_info(struct audit_buffer *ab,
> -				struct task_struct *tsk);
> +extern void audit_log_task_info(struct audit_buffer *ab);
>  
>  extern int		    audit_update_lsm_rules(void);
>  
> @@ -202,8 +201,7 @@ static inline int audit_log_task_context(struct audit_buffer *ab)
>  {
>  	return 0;
>  }
> -static inline void audit_log_task_info(struct audit_buffer *ab,
> -				       struct task_struct *tsk)
> +static inline void audit_log_task_info(struct audit_buffer *ab)
>  { }
>  #define audit_enabled AUDIT_OFF
>  #endif /* CONFIG_AUDIT */
> diff --git a/kernel/audit.c b/kernel/audit.c
> index 2a8058764aa6..160144f7e5f9 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -1096,10 +1096,11 @@ static void audit_log_feature_change(int which, u32 old_feature, u32 new_feature
>  
>  	if (audit_enabled == AUDIT_OFF)
>  		return;
> +
>  	ab = audit_log_start(audit_context(), GFP_KERNEL, AUDIT_FEATURE_CHANGE);
>  	if (!ab)
>  		return;
> -	audit_log_task_info(ab, current);
> +	audit_log_task_info(ab);
>  	audit_log_format(ab, " feature=%s old=%u new=%u old_lock=%u new_lock=%u res=%d",
>  			 audit_feature_names[which], !!old_feature, !!new_feature,
>  			 !!old_lock, !!new_lock, res);
> @@ -2247,15 +2248,15 @@ void audit_log_d_path_exe(struct audit_buffer *ab,
>  	audit_log_format(ab, " exe=(null)");
>  }
>  
> -struct tty_struct *audit_get_tty(struct task_struct *tsk)
> +struct tty_struct *audit_get_tty(void)
>  {
>  	struct tty_struct *tty = NULL;
>  	unsigned long flags;
>  
> -	spin_lock_irqsave(&tsk->sighand->siglock, flags);
> -	if (tsk->signal)
> -		tty = tty_kref_get(tsk->signal->tty);
> -	spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
> +	spin_lock_irqsave(&current->sighand->siglock, flags);
> +	if (current->signal)
> +		tty = tty_kref_get(current->signal->tty);
> +	spin_unlock_irqrestore(&current->sighand->siglock, flags);
>  	return tty;
>  }
>  
> @@ -2264,25 +2265,24 @@ void audit_put_tty(struct tty_struct *tty)
>  	tty_kref_put(tty);
>  }
>  
> -void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
> +void audit_log_task_info(struct audit_buffer *ab)
>  {
>  	const struct cred *cred;
> -	char comm[sizeof(tsk->comm)];
> +	char comm[sizeof(current->comm)];
>  	struct tty_struct *tty;
>  
>  	if (!ab)
>  		return;
>  
> -	/* tsk == current */
>  	cred = current_cred();
> -	tty = audit_get_tty(tsk);
> +	tty = audit_get_tty();
>  	audit_log_format(ab,
>  			 " ppid=%d pid=%d auid=%u uid=%u gid=%u"
>  			 " euid=%u suid=%u fsuid=%u"
>  			 " egid=%u sgid=%u fsgid=%u tty=%s ses=%u",
> -			 task_ppid_nr(tsk),
> -			 task_tgid_nr(tsk),
> -			 from_kuid(&init_user_ns, audit_get_loginuid(tsk)),
> +			 task_ppid_nr(current),
> +			 task_tgid_nr(current),
> +			 from_kuid(&init_user_ns, audit_get_loginuid(current)),
>  			 from_kuid(&init_user_ns, cred->uid),
>  			 from_kgid(&init_user_ns, cred->gid),
>  			 from_kuid(&init_user_ns, cred->euid),
> @@ -2292,11 +2292,11 @@ void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
>  			 from_kgid(&init_user_ns, cred->sgid),
>  			 from_kgid(&init_user_ns, cred->fsgid),
>  			 tty ? tty_name(tty) : "(none)",
> -			 audit_get_sessionid(tsk));
> +			 audit_get_sessionid(current));
>  	audit_put_tty(tty);
>  	audit_log_format(ab, " comm=");
> -	audit_log_untrustedstring(ab, get_task_comm(comm, tsk));
> -	audit_log_d_path_exe(ab, tsk->mm);
> +	audit_log_untrustedstring(ab, get_task_comm(comm, current));
> +	audit_log_d_path_exe(ab, current->mm);
>  	audit_log_task_context(ab);
>  }
>  EXPORT_SYMBOL(audit_log_task_info);
> @@ -2317,7 +2317,7 @@ void audit_log_link_denied(const char *operation)
>  	if (!ab)
>  		return;
>  	audit_log_format(ab, "op=%s", operation);
> -	audit_log_task_info(ab, current);
> +	audit_log_task_info(ab);
>  	audit_log_format(ab, " res=0");
>  	audit_log_end(ab);
>  }
> diff --git a/kernel/audit.h b/kernel/audit.h
> index 214e14948370..9c76b7a6e956 100644
> --- a/kernel/audit.h
> +++ b/kernel/audit.h
> @@ -262,7 +262,7 @@ extern struct audit_entry *audit_dupe_rule(struct audit_krule *old);
>  extern void audit_log_d_path_exe(struct audit_buffer *ab,
>  				 struct mm_struct *mm);
>  
> -extern struct tty_struct *audit_get_tty(struct task_struct *tsk);
> +extern struct tty_struct *audit_get_tty(void);
>  extern void audit_put_tty(struct tty_struct *tty);
>  
>  /* audit watch functions */
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index fb207466e99b..8b12e525306e 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -836,44 +836,6 @@ void audit_filter_inodes(struct task_struct *tsk, struct audit_context *ctx)
>  	rcu_read_unlock();
>  }
>  
> -/* Transfer the audit context pointer to the caller, clearing it in the tsk's struct */
> -static inline struct audit_context *audit_take_context(struct task_struct *tsk,
> -						      int return_valid,
> -						      long return_code)
> -{
> -	struct audit_context *context = tsk->audit_context;
> -
> -	if (!context)
> -		return NULL;
> -	context->return_valid = return_valid;
> -
> -	/*
> -	 * we need to fix up the return code in the audit logs if the actual
> -	 * return codes are later going to be fixed up by the arch specific
> -	 * signal handlers
> -	 *
> -	 * This is actually a test for:
> -	 * (rc == ERESTARTSYS ) || (rc == ERESTARTNOINTR) ||
> -	 * (rc == ERESTARTNOHAND) || (rc == ERESTART_RESTARTBLOCK)
> -	 *
> -	 * but is faster than a bunch of ||
> -	 */
> -	if (unlikely(return_code <= -ERESTARTSYS) &&
> -	    (return_code >= -ERESTART_RESTARTBLOCK) &&
> -	    (return_code != -ENOIOCTLCMD))
> -		context->return_code = -EINTR;
> -	else
> -		context->return_code  = return_code;
> -
> -	if (context->in_syscall && !context->dummy) {
> -		audit_filter_syscall(tsk, context, &audit_filter_list[AUDIT_FILTER_EXIT]);
> -		audit_filter_inodes(tsk, context);
> -	}
> -
> -	audit_set_context(tsk, NULL);
> -	return context;
> -}
> -
>  static inline void audit_proctitle_free(struct audit_context *context)
>  {
>  	kfree(context->proctitle.value);
> @@ -1298,15 +1260,18 @@ static inline int audit_proctitle_rtrim(char *proctitle, int len)
>  	return len;
>  }
>  
> -static void audit_log_proctitle(struct task_struct *tsk,
> -			 struct audit_context *context)
> +static void audit_log_proctitle(void)
>  {
>  	int res;
>  	char *buf;
>  	char *msg = "(null)";
>  	int len = strlen(msg);
> +	struct audit_context *context = audit_context();
>  	struct audit_buffer *ab;
>  
> +	if (!context)
> +		return;
> +
>  	ab = audit_log_start(context, GFP_KERNEL, AUDIT_PROCTITLE);
>  	if (!ab)
>  		return;	/* audit_panic or being filtered */
> @@ -1319,7 +1284,7 @@ static void audit_log_proctitle(struct task_struct *tsk,
>  		if (!buf)
>  			goto out;
>  		/* Historically called this from procfs naming */
> -		res = get_cmdline(tsk, buf, MAX_PROCTITLE_AUDIT_LEN);
> +		res = get_cmdline(current, buf, MAX_PROCTITLE_AUDIT_LEN);
>  		if (res == 0) {
>  			kfree(buf);
>  			goto out;
> @@ -1339,15 +1304,39 @@ static void audit_log_proctitle(struct task_struct *tsk,
>  	audit_log_end(ab);
>  }
>  
> -static void audit_log_exit(struct audit_context *context, struct task_struct *tsk)
> +static void audit_log_exit(int ret_valid, long ret_code)
>  {
>  	int i, call_panic = 0;
> +	struct audit_context *context = audit_context();
>  	struct audit_buffer *ab;
>  	struct audit_aux_data *aux;
>  	struct audit_names *n;
>  
> -	/* tsk == current */
> -	context->personality = tsk->personality;
> +	context->personality = current->personality;
> +	context->return_valid = ret_valid;
> +
> +	/*
> +	 * we need to fix up the return code in the audit logs if the actual
> +	 * return codes are later going to be fixed up by the arch specific
> +	 * signal handlers
> +	 *
> +	 * This is actually a test for:
> +	 * (rc == ERESTARTSYS ) || (rc == ERESTARTNOINTR) ||
> +	 * (rc == ERESTARTNOHAND) || (rc == ERESTART_RESTARTBLOCK)
> +	 *
> +	 * but is faster than a bunch of ||
> +	 */
> +	if (unlikely(ret_code <= -ERESTARTSYS) &&
> +	    (ret_code >= -ERESTART_RESTARTBLOCK) &&
> +	    (ret_code != -ENOIOCTLCMD))
> +		ret_code = -EINTR;
> +	context->return_code = ret_code;
> +
> +	if (context->in_syscall && !context->dummy) {
> +		audit_filter_syscall(current, context,
> +				     &audit_filter_list[AUDIT_FILTER_EXIT]);
> +		audit_filter_inodes(current, context);
> +	}
>  
>  	ab = audit_log_start(context, GFP_KERNEL, AUDIT_SYSCALL);
>  	if (!ab)
> @@ -1356,10 +1345,10 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
>  			 context->arch, context->major);
>  	if (context->personality != PER_LINUX)
>  		audit_log_format(ab, " per=%lx", context->personality);
> -	if (context->return_valid)
> +	if (ret_valid)
>  		audit_log_format(ab, " success=%s exit=%ld",
> -				 (context->return_valid==AUDITSC_SUCCESS)?"yes":"no",
> -				 context->return_code);
> +				 (ret_valid == AUDITSC_SUCCESS) ? "yes" : "no",
> +				 ret_code);
>  
>  	audit_log_format(ab,
>  			 " a0=%lx a1=%lx a2=%lx a3=%lx items=%d",
> @@ -1369,7 +1358,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
>  			 context->argv[3],
>  			 context->name_count);
>  
> -	audit_log_task_info(ab, tsk);
> +	audit_log_task_info(ab);
>  	audit_log_key(ab, context->filterkey);
>  	audit_log_end(ab);
>  
> @@ -1458,7 +1447,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
>  		audit_log_name(context, n, NULL, i++, &call_panic);
>  	}
>  
> -	audit_log_proctitle(tsk, context);
> +	audit_log_proctitle();
>  
>  	/* Send end of event record to help user space know we are finished */
>  	ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE);
> @@ -1478,20 +1467,23 @@ void __audit_free(struct task_struct *tsk)
>  {
>  	struct audit_context *context;
>  
> -	context = audit_take_context(tsk, 0, 0);
> +	context = tsk->audit_context;
>  	if (!context)
>  		return;
>  
> -	/* Check for system calls that do not go through the exit
> -	 * function (e.g., exit_group), then free context block.
> -	 * We use GFP_ATOMIC here because we might be doing this
> -	 * in the context of the idle thread */
> -	/* that can happen only if we are called from do_exit() */
> -	if (context->in_syscall && context->current_state == AUDIT_RECORD_CONTEXT)
> -		audit_log_exit(context, tsk);
> +	/* We are called either by do_exit() or the fork() error handling code;
> +	 * in the former case tsk == current and in the latter tsk is a
> +	 * random task_struct that doesn't doesn't have any meaningful data we
> +	 * need to log via audit_log_exit(). */
> +	if (tsk == current &&
> +	    context->in_syscall &&
> +	    context->current_state == AUDIT_RECORD_CONTEXT)
> +		audit_log_exit(0, 0);
> +
>  	if (!list_empty(&context->killed_trees))
>  		audit_kill_trees(&context->killed_trees);
>  
> +	audit_set_context(tsk, NULL);
>  	audit_free_context(context);
>  }
>  
> @@ -1566,12 +1558,12 @@ void __audit_syscall_exit(int success, long return_code)
>  	else
>  		success = AUDITSC_FAILURE;
>  
> -	context = audit_take_context(current, success, return_code);
> +	context = audit_context();
>  	if (!context)
>  		return;
>  
>  	if (context->in_syscall && context->current_state == AUDIT_RECORD_CONTEXT)
> -		audit_log_exit(context, current);
> +		audit_log_exit(success, return_code);
>  
>  	context->in_syscall = 0;
>  	context->prio = context->state == AUDIT_RECORD_CONTEXT ? ~0ULL : 0;
> @@ -1593,7 +1585,6 @@ void __audit_syscall_exit(int success, long return_code)
>  		kfree(context->filterkey);
>  		context->filterkey = NULL;
>  	}
> -	audit_set_context(current, context);
>  }
>  
>  static inline void handle_one(const struct inode *inode)
> @@ -2031,7 +2022,7 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, kuid_t kloginuid,
>  	uid = from_kuid(&init_user_ns, task_uid(current));
>  	oldloginuid = from_kuid(&init_user_ns, koldloginuid);
>  	loginuid = from_kuid(&init_user_ns, kloginuid),
> -	tty = audit_get_tty(current);
> +	tty = audit_get_tty();
>  
>  	audit_log_format(ab, "pid=%d uid=%u", task_tgid_nr(current), uid);
>  	audit_log_task_context(ab);
> @@ -2052,7 +2043,6 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, kuid_t kloginuid,
>   */
>  int audit_set_loginuid(kuid_t loginuid)
>  {
> -	struct task_struct *task = current;
>  	unsigned int oldsessionid, sessionid = AUDIT_SID_UNSET;
>  	kuid_t oldloginuid;
>  	int rc;
> @@ -2071,8 +2061,8 @@ int audit_set_loginuid(kuid_t loginuid)
>  			sessionid = (unsigned int)atomic_inc_return(&session_id);
>  	}
>  
> -	task->sessionid = sessionid;
> -	task->loginuid = loginuid;
> +	current->sessionid = sessionid;
> +	current->loginuid = loginuid;
>  out:
>  	audit_log_set_loginuid(oldloginuid, loginuid, oldsessionid, sessionid, rc);
>  	return rc;
> diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
> index a02c5acfd403..30999169c0a8 100644
> --- a/security/integrity/ima/ima_api.c
> +++ b/security/integrity/ima/ima_api.c
> @@ -335,7 +335,7 @@ void ima_audit_measurement(struct integrity_iint_cache *iint,
>  	audit_log_untrustedstring(ab, filename);
>  	audit_log_format(ab, " hash=\"%s:%s\"", algo_name, hash);
>  
> -	audit_log_task_info(ab, current);
> +	audit_log_task_info(ab);
>  	audit_log_end(ab);
>  
>  	iint->flags |= IMA_AUDITED;
> 
> --
> Linux-audit mailing list
> Linux-audit@redhat.com
> https://www.redhat.com/mailman/listinfo/linux-audit

- RGB

--
Richard Guy Briggs <rgb@redhat.com>
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635

^ permalink raw reply

* Re: [PATCH 1/5] coccinelle: mark the 'coccicheck' make target as .PHONY
From: Junio C Hamano @ 2018-07-23 19:37 UTC (permalink / raw)
  To: SZEDER Gábor
  Cc: git, René Scharfe, Derrick Stolee,
	Nguyễn Thái Ngọc Duy
In-Reply-To: <20180723135100.24288-2-szeder.dev@gmail.com>

SZEDER Gábor <szeder.dev@gmail.com> writes:

> The 'coccicheck' target doesn't create a file with the same name, so
> mark it as .PHONY.
>
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---

Good.  It is customary to do so immediately before the target, not
after a blank line, though.

>  Makefile | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index e4b503d259..27bfc196dd 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2685,6 +2685,8 @@ C_SOURCES = $(patsubst %.o,%.c,$(C_OBJ))
>  	fi
>  coccicheck: $(patsubst %.cocci,%.cocci.patch,$(wildcard contrib/coccinelle/*.cocci))
>  
> +.PHONY: coccicheck
> +
>  ### Installation rules
>  
>  ifneq ($(filter /%,$(firstword $(template_dir))),)

^ permalink raw reply

* [Qemu-devel] [PATCH v2 for-3.0] tests/libqtest: Improve kill_qemu()
From: Eric Blake @ 2018-07-23 19:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, mst, rth, alex.bennee, f4bug

In kill_qemu() we have an assert that checks that the QEMU process
didn't dump core:
            assert(!WCOREDUMP(wstatus));

Unfortunately the WCOREDUMP macro here means the resulting message
is not very easy to comprehend on at least some systems:

ahci-test: tests/libqtest.c:113: kill_qemu: Assertion `!(((__extension__ (((union { __typeof(wstatus) __in; int __i; }) { .__in = (wstatus) }).__i))) & 0x80)' failed.

and it doesn't identify what signal the process took.

Furthermore, we are NOT detecting EINTR (while EINTR shouldn't be
happening if we didn't install signal handlers, it's still better
to always be robust), and also want to log unexpected non-zero status
that was not accompanied by a core dump.

Instead of using a raw assert, print the information in an
easier to understand way:

/i386/ahci/sanity: tests/libqtest.c:119: kill_qemu() detected QEMU death with core dump from signal 11 (Segmentation fault)
Aborted (core dumped)

(Of course, the really useful information would be why the QEMU
process dumped core in the first place, but we don't have that
by the time the test program has picked up the exit status.)

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Eric Blake <eblake@redhat.com>
---

I've taken the ideas from Peter's patch:
https://lists.gnu.org/archive/html/qemu-devel/2018-07/msg04430.html
as well as fixing a related issue brought up last time this was touched:
https://lists.gnu.org/archive/html/qemu-devel/2018-05/msg05710.html

 tests/libqtest.c | 39 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index 098af6aec44..f3dabfadd78 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -105,12 +105,47 @@ static void kill_qemu(QTestState *s)
     if (s->qemu_pid != -1) {
         int wstatus = 0;
         pid_t pid;
+        bool die = false;

         kill(s->qemu_pid, SIGTERM);
+    retry:
         pid = waitpid(s->qemu_pid, &wstatus, 0);
+        if (pid == -1 && errno == EINTR) {
+            goto retry;
+        }

-        if (pid == s->qemu_pid && WIFSIGNALED(wstatus)) {
-            assert(!WCOREDUMP(wstatus));
+        assert(pid == s->qemu_pid);
+        /*
+         * We expect qemu to exit with status 0; anything else is
+         * fishy and should be logged.  Abort except when death by
+         * signal is not accompanied by a coredump (as that's the only
+         * time it was likely that the user is trying to kill the
+         * testsuite early).
+         */
+        if (wstatus) {
+            die = true;
+            if (WIFEXITED(wstatus)) {
+                fprintf(stderr, "%s:%d: kill_qemu() tried to terminate QEMU "
+                        "process but encountered exit status %d\n",
+                        __FILE__, __LINE__, WEXITSTATUS(wstatus));
+            } else if (WIFSIGNALED(wstatus)) {
+                int sig = WTERMSIG(wstatus);
+                const char *signame = strsignal(sig) ?: "unknown ???";
+
+                if (!WCOREDUMP(wstatus)) {
+                    die = false;
+                    fprintf(stderr, "%s:%d: kill_qemu() ignoring QEMU death "
+                            "by signal %d (%s)\n",
+                            __FILE__, __LINE__, sig, signame);
+                } else {
+                    fprintf(stderr, "%s:%d: kill_qemu() detected QEMU death "
+                            "with core dump from signal %d (%s)\n",
+                            __FILE__, __LINE__, sig, signame);
+                }
+            }
+        }
+        if (die) {
+            abort();
         }
     }
 }
-- 
2.14.4

^ permalink raw reply related

* Re: [PATCH v2 bpf 3/3] bpf: Introduce BPF_ANNOTATE_KV_PAIR
From: Yonghong Song @ 2018-07-23 18:31 UTC (permalink / raw)
  To: Martin KaFai Lau, netdev; +Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team
In-Reply-To: <20180721182043.1401089-4-kafai@fb.com>



On 7/21/18 11:20 AM, Martin KaFai Lau wrote:
> This patch introduces BPF_ANNOTATE_KV_PAIR to signal the
> bpf loader about the btf key_type and value_type of a bpf map.
> Please refer to the changes in test_btf_haskv.c for its usage.
> Both iproute2 and libbpf loader will then have the same
> convention to find out the map's btf_key_type_id and
> btf_value_type_id from a map's name.
> 
> Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf")
> Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> ---
>   tools/lib/bpf/btf.c                          |  7 +-
>   tools/lib/bpf/btf.h                          |  2 +
>   tools/lib/bpf/libbpf.c                       | 75 +++++++++++---------
>   tools/testing/selftests/bpf/bpf_helpers.h    |  9 +++
>   tools/testing/selftests/bpf/test_btf_haskv.c |  7 +-
>   5 files changed, 56 insertions(+), 44 deletions(-)
> 
> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index ce77b5b57912..321a99e648ed 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
> @@ -189,8 +189,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
>   	return 0;
>   }
>   
> -static const struct btf_type *btf_type_by_id(const struct btf *btf,
> -					     __u32 type_id)
> +const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 type_id)
>   {
>   	if (type_id > btf->nr_types)
>   		return NULL;
> @@ -233,7 +232,7 @@ __s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
>   	__s64 size = -1;
>   	int i;
>   
> -	t = btf_type_by_id(btf, type_id);
> +	t = btf__type_by_id(btf, type_id);
>   	for (i = 0; i < MAX_RESOLVE_DEPTH && !btf_type_is_void_or_null(t);
>   	     i++) {
>   		size = btf_type_size(t);
> @@ -258,7 +257,7 @@ __s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
>   			return -EINVAL;
>   		}
>   
> -		t = btf_type_by_id(btf, type_id);
> +		t = btf__type_by_id(btf, type_id);
>   	}
>   
>   	if (size < 0)
> diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
> index ed3a84370ccc..e2a09a155f84 100644
> --- a/tools/lib/bpf/btf.h
> +++ b/tools/lib/bpf/btf.h
> @@ -9,6 +9,7 @@
>   #define BTF_ELF_SEC ".BTF"
>   
>   struct btf;
> +struct btf_type;
>   
>   typedef int (*btf_print_fn_t)(const char *, ...)
>   	__attribute__((format(printf, 1, 2)));
> @@ -16,6 +17,7 @@ typedef int (*btf_print_fn_t)(const char *, ...)
>   void btf__free(struct btf *btf);
>   struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log);
>   __s32 btf__find_by_name(const struct btf *btf, const char *type_name);
> +const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 id);
>   __s64 btf__resolve_size(const struct btf *btf, __u32 type_id);
>   int btf__fd(const struct btf *btf);
>   
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 6deb4fe4fffe..d881d370616c 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -36,6 +36,7 @@
>   #include <linux/err.h>
>   #include <linux/kernel.h>
>   #include <linux/bpf.h>
> +#include <linux/btf.h>
>   #include <linux/list.h>
>   #include <linux/limits.h>
>   #include <sys/stat.h>
> @@ -1014,68 +1015,72 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
>   
>   static int bpf_map_find_btf_info(struct bpf_map *map, const struct btf *btf)
>   {
> +	const struct btf_type *container_type;
> +	const struct btf_member *key, *value;
>   	struct bpf_map_def *def = &map->def;
>   	const size_t max_name = 256;
> +	char container_name[max_name];
>   	__s64 key_size, value_size;
> -	__s32 key_id, value_id;
> -	char name[max_name];
> +	__s32 container_id;
>   
> -	/* Find key type by name from BTF */
> -	if (snprintf(name, max_name, "%s_key", map->name) == max_name) {
> -		pr_warning("map:%s length of BTF key_type:%s_key is too long\n",
> +	if (snprintf(container_name, max_name, "____btf_map_%s", map->name) ==
> +	    max_name) {
> +		pr_warning("map:%s length of '____btf_map_%s' is too long\n",
>   			   map->name, map->name);
>   		return -EINVAL;
>   	}
>   
> -	key_id = btf__find_by_name(btf, name);
> -	if (key_id < 0) {
> -		pr_debug("map:%s key_type:%s cannot be found in BTF\n",
> -			 map->name, name);
> -		return key_id;
> +	container_id = btf__find_by_name(btf, container_name);
> +	if (container_id < 0) {
> +		pr_debug("map:%s container_name:%s cannot be found in BTF. Missing BPF_ANNOTATE_KV_PAIR?\n",
> +			 map->name, container_name);
> +		return container_id;
>   	}
>   
> -	key_size = btf__resolve_size(btf, key_id);
> -	if (key_size < 0) {
> -		pr_warning("map:%s key_type:%s cannot get the BTF type_size\n",
> -			   map->name, name);
> -		return key_size;
> +	container_type = btf__type_by_id(btf, container_id);
> +	if (!container_type) {
> +		pr_warning("map:%s cannot find BTF type for container_id:%u\n",
> +			   map->name, container_id);
> +		return -EINVAL;
>   	}
>   
> -	if (def->key_size != key_size) {
> -		pr_warning("map:%s key_type:%s has BTF type_size:%u != key_size:%u\n",
> -			   map->name, name, (unsigned int)key_size, def->key_size);
> +	if (BTF_INFO_KIND(container_type->info) != BTF_KIND_STRUCT ||
> +	    BTF_INFO_VLEN(container_type->info) < 2) {

Should "BTF_INFO_VLEN(container_type->info) < 2" be
"BTF_INFO_VLEN(container_type->info) != 2"?

> +		pr_warning("map:%s container_name:%s is an invalid container struct\n",
> +			   map->name, container_name);
>   		return -EINVAL;
>   	}
>   
> -	/* Find value type from BTF */
> -	if (snprintf(name, max_name, "%s_value", map->name) == max_name) {
> -		pr_warning("map:%s length of BTF value_type:%s_value is too long\n",
> -			  map->name, map->name);
> -		return -EINVAL;
> +	key = (struct btf_member *)(container_type + 1);
> +	value = key + 1;
> +
> +	key_size = btf__resolve_size(btf, key->type);
> +	if (key_size < 0) {
> +		pr_warning("map:%s invalid BTF key_type_size\n",
> +			   map->name);
> +		return key_size;
>   	}
>   
> -	value_id = btf__find_by_name(btf, name);
> -	if (value_id < 0) {
> -		pr_debug("map:%s value_type:%s cannot be found in BTF\n",
> -			 map->name, name);
> -		return value_id;
> +	if (def->key_size != key_size) {
> +		pr_warning("map:%s btf_key_type_size:%u != map_def_key_size:%u\n",
> +			   map->name, (__u32)key_size, def->key_size);
> +		return -EINVAL;
>   	}
>   
> -	value_size = btf__resolve_size(btf, value_id);
> +	value_size = btf__resolve_size(btf, value->type);
>   	if (value_size < 0) {
> -		pr_warning("map:%s value_type:%s cannot get the BTF type_size\n",
> -			   map->name, name);
> +		pr_warning("map:%s invalid BTF value_type_size\n", map->name);
>   		return value_size;
>   	}
>   
>   	if (def->value_size != value_size) {
> -		pr_warning("map:%s value_type:%s has BTF type_size:%u != value_size:%u\n",
> -			   map->name, name, (unsigned int)value_size, def->value_size);
> +		pr_warning("map:%s btf_value_type_size:%u != map_def_value_size:%u\n",
> +			   map->name, (__u32)value_size, def->value_size);
>   		return -EINVAL;
>   	}
>   
> -	map->btf_key_type_id = key_id;
> -	map->btf_value_type_id = value_id;
> +	map->btf_key_type_id = key->type;
> +	map->btf_value_type_id = value->type;
>   
>   	return 0;
>   }
> diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h
> index f2f28b6c8915..810de20e8e26 100644
> --- a/tools/testing/selftests/bpf/bpf_helpers.h
> +++ b/tools/testing/selftests/bpf/bpf_helpers.h
> @@ -158,6 +158,15 @@ struct bpf_map_def {
>   	unsigned int numa_node;
>   };
>   
> +#define BPF_ANNOTATE_KV_PAIR(name, type_key, type_val)		\
> +	struct ____btf_map_##name {				\
> +		type_key key;					\
> +		type_val value;					\
> +	};							\
> +	struct ____btf_map_##name				\
> +	__attribute__ ((section(".maps." #name), used))		\
> +		____btf_map_##name = { }
> +
>   static int (*bpf_skb_load_bytes)(void *ctx, int off, void *to, int len) =
>   	(void *) BPF_FUNC_skb_load_bytes;
>   static int (*bpf_skb_store_bytes)(void *ctx, int off, void *from, int len, int flags) =
> diff --git a/tools/testing/selftests/bpf/test_btf_haskv.c b/tools/testing/selftests/bpf/test_btf_haskv.c
> index 8c7ca096ecf2..b21b876f475d 100644
> --- a/tools/testing/selftests/bpf/test_btf_haskv.c
> +++ b/tools/testing/selftests/bpf/test_btf_haskv.c
> @@ -10,11 +10,6 @@ struct ipv_counts {
>   	unsigned int v6;
>   };
>   
> -typedef int btf_map_key;
> -typedef struct ipv_counts btf_map_value;
> -btf_map_key dumm_key;
> -btf_map_value dummy_value;
> -
>   struct bpf_map_def SEC("maps") btf_map = {
>   	.type = BPF_MAP_TYPE_ARRAY,
>   	.key_size = sizeof(int),
> @@ -22,6 +17,8 @@ struct bpf_map_def SEC("maps") btf_map = {
>   	.max_entries = 4,
>   };
>   
> +BPF_ANNOTATE_KV_PAIR(btf_map, int, struct ipv_counts);
> +
>   struct dummy_tracepoint_args {
>   	unsigned long long pad;
>   	struct sock *sock;
> 

^ permalink raw reply

* Re: [PATCH] drm/rockchip: Replace drm_dev_unref with drm_dev_put
From: Heiko Stuebner @ 2018-07-23 19:32 UTC (permalink / raw)
  To: Thomas Zimmermann; +Cc: dri-devel
In-Reply-To: <20180717110927.30776-1-tzimmermann@suse.de>

Hi Thomas,

Am Dienstag, 17. Juli 2018, 13:09:27 CEST schrieb Thomas Zimmermann:
> This patch unifies the naming of DRM functions for reference counting
> of struct drm_device. The resulting code is more aligned with the rest
> of the Linux kernel interfaces.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>

applied to drm-misc-next

Thanks
Heiko


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply

* Re: [PATCH 03/14] format-patch: teach --interdiff to respect -v/--reroll-count
From: Eric Sunshine @ 2018-07-23 19:32 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy
  Cc: Git List, Johannes Schindelin,
	Ævar Arnfjörð Bjarmason, Stefan Beller
In-Reply-To: <CACsJy8AGwbrEFU2bTynXyQi1DmEYtwHrtmefMz+jD13GQs=9HQ@mail.gmail.com>

On Mon, Jul 23, 2018 at 12:12 PM Duy Nguyen <pclouds@gmail.com> wrote:
> On Sun, Jul 22, 2018 at 11:57 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
> > @@ -215,6 +215,7 @@ struct rev_info {
> >         /* interdiff */
> >         const struct object_id *idiff_oid1;
> >         const struct object_id *idiff_oid2;
> > +       const char *idiff_title;
>
> I feel we're abusing struct rev_info a bit for this since this
> interdiff thing is very builtin/log.c's business and not at all
> related to rev walk. Is it possible (and easy) to just pass
> idfff_title from cmd_format_patch to make_cover_letter()? If it's a
> lot of code, then I guess we can just leave it here.

As originally implemented, this information was passed directly to
make_cover_letter(), however, as you discovered in your review of
patch 6/14[1], which makes it possible to embed an interdiff in the
commentary section of a lone patch, 'struct rev_info' is the only way
to pass this information down that deeply in the patch-generation
process. So, yes, this pretty much needs to use 'struct rev_info',
even if that need doesn't exist at this early step in the series.

[1]: https://public-inbox.org/git/CACsJy8Aw6R8-3kDfhCqunXziajCg9O_1WrEYc4rfKa+-=m1D5g@mail.gmail.com/

^ permalink raw reply

* [Qemu-devel] [PATCH for-3.1 2/2] acpi: Decouple ACPI hotplug callbacks from HotplugHandler
From: Eduardo Habkost @ 2018-07-23 19:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marcel Apfelbaum, Igor Mammedov, Xiao Guangrong, Ben Warren,
	Michael S. Tsirkin
In-Reply-To: <20180723193145.24705-1-ehabkost@redhat.com>

The ACPI hotplug callbacks get a HotplugHandler object as
argument.  This has two problems:

1) The functions require a TYPE_ACPI_DEVICE_IF object, but the
   function prototype doesn't indicate that.  It's possible to
   pass an object that would make the function crash.
2) The function does not require the object to implement
   TYPE_HOTPLUG_HANDLER at all, but the function prototype
   imposes that for no reason.

Change the argument type to AcpiDeviceIf instead of
HotplugHandler.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/hw/acpi/cpu.h            |  5 ++---
 include/hw/acpi/cpu_hotplug.h    |  2 +-
 include/hw/acpi/memory_hotplug.h |  4 ++--
 include/hw/acpi/pcihp.h          |  4 ++--
 include/hw/mem/nvdimm.h          |  3 ++-
 hw/acpi/cpu.c                    |  8 ++++----
 hw/acpi/cpu_hotplug.c            |  4 ++--
 hw/acpi/ich9.c                   | 14 ++++++++------
 hw/acpi/memory_hotplug.c         |  8 ++++----
 hw/acpi/nvdimm.c                 |  4 ++--
 hw/acpi/pcihp.c                  |  8 ++++----
 hw/acpi/piix4.c                  | 18 ++++++++++--------
 12 files changed, 43 insertions(+), 39 deletions(-)

diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h
index 89ce172941..3ae6504c24 100644
--- a/include/hw/acpi/cpu.h
+++ b/include/hw/acpi/cpu.h
@@ -15,7 +15,6 @@
 #include "hw/qdev-core.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/aml-build.h"
-#include "hw/hotplug.h"
 
 typedef struct AcpiCpuStatus {
     struct CPUState *cpu;
@@ -34,10 +33,10 @@ typedef struct CPUHotplugState {
     AcpiCpuStatus *devs;
 } CPUHotplugState;
 
-void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
+void acpi_cpu_plug_cb(AcpiDeviceIf *acpi_dev,
                       CPUHotplugState *cpu_st, DeviceState *dev, Error **errp);
 
-void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
+void acpi_cpu_unplug_request_cb(AcpiDeviceIf *acpi_dev,
                                 CPUHotplugState *cpu_st,
                                 DeviceState *dev, Error **errp);
 
diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h
index 3b932abbbb..8e663b0606 100644
--- a/include/hw/acpi/cpu_hotplug.h
+++ b/include/hw/acpi/cpu_hotplug.h
@@ -25,7 +25,7 @@ typedef struct AcpiCpuHotplug {
     uint8_t sts[ACPI_GPE_PROC_LEN];
 } AcpiCpuHotplug;
 
-void legacy_acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
+void legacy_acpi_cpu_plug_cb(AcpiDeviceIf *acpi_dev,
                              AcpiCpuHotplug *g, DeviceState *dev, Error **errp);
 
 void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,
diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index 77c65765d6..ebd97093dd 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -31,9 +31,9 @@ typedef struct MemHotplugState {
 void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
                               MemHotplugState *state, uint16_t io_base);
 
-void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st,
+void acpi_memory_plug_cb(AcpiDeviceIf *acpi_dev, MemHotplugState *mem_st,
                          DeviceState *dev, Error **errp);
-void acpi_memory_unplug_request_cb(HotplugHandler *hotplug_dev,
+void acpi_memory_unplug_request_cb(AcpiDeviceIf *acpi_dev,
                                    MemHotplugState *mem_st,
                                    DeviceState *dev, Error **errp);
 void acpi_memory_unplug_cb(MemHotplugState *mem_st,
diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index 8a65f99fc8..bba37b81dc 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -56,9 +56,9 @@ typedef struct AcpiPciHpState {
 void acpi_pcihp_init(Object *owner, AcpiPciHpState *, PCIBus *root,
                      MemoryRegion *address_space_io, bool bridges_enabled);
 
-void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
+void acpi_pcihp_device_plug_cb(AcpiDeviceIf *acpi_dev, AcpiPciHpState *s,
                                DeviceState *dev, Error **errp);
-void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
+void acpi_pcihp_device_unplug_cb(AcpiDeviceIf *acpi_dev, AcpiPciHpState *s,
                                  DeviceState *dev, Error **errp);
 
 /* Called on reset */
diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h
index c5c9b3c7f8..0d80497efe 100644
--- a/include/hw/mem/nvdimm.h
+++ b/include/hw/mem/nvdimm.h
@@ -25,6 +25,7 @@
 
 #include "hw/mem/pc-dimm.h"
 #include "hw/acpi/bios-linker-loader.h"
+#include "hw/acpi/acpi_dev_interface.h"
 
 #define NVDIMM_DEBUG 0
 #define nvdimm_debug(fmt, ...)                                \
@@ -149,5 +150,5 @@ void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data,
                        BIOSLinker *linker, AcpiNVDIMMState *state,
                        uint32_t ram_slots);
 void nvdimm_plug(AcpiNVDIMMState *state);
-void nvdimm_acpi_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev);
+void nvdimm_acpi_plug_cb(AcpiDeviceIf *acpi_dev, DeviceState *dev);
 #endif
diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c
index 2eb9b5a032..71aec1d655 100644
--- a/hw/acpi/cpu.c
+++ b/hw/acpi/cpu.c
@@ -220,7 +220,7 @@ static AcpiCpuStatus *get_cpu_status(CPUHotplugState *cpu_st, DeviceState *dev)
     return NULL;
 }
 
-void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
+void acpi_cpu_plug_cb(AcpiDeviceIf *acpi_dev,
                       CPUHotplugState *cpu_st, DeviceState *dev, Error **errp)
 {
     AcpiCpuStatus *cdev;
@@ -233,11 +233,11 @@ void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
     cdev->cpu = CPU(dev);
     if (dev->hotplugged) {
         cdev->is_inserting = true;
-        acpi_send_event(ACPI_DEVICE_IF(hotplug_dev), ACPI_CPU_HOTPLUG_STATUS);
+        acpi_send_event(acpi_dev, ACPI_CPU_HOTPLUG_STATUS);
     }
 }
 
-void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
+void acpi_cpu_unplug_request_cb(AcpiDeviceIf *acpi_dev,
                                 CPUHotplugState *cpu_st,
                                 DeviceState *dev, Error **errp)
 {
@@ -249,7 +249,7 @@ void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
     }
 
     cdev->is_removing = true;
-    acpi_send_event(ACPI_DEVICE_IF(hotplug_dev), ACPI_CPU_HOTPLUG_STATUS);
+    acpi_send_event(acpi_dev, ACPI_CPU_HOTPLUG_STATUS);
 }
 
 void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st,
diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
index 5a1599796b..d9277e27de 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -72,14 +72,14 @@ static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu,
     g->sts[cpu_id / 8] |= (1 << (cpu_id % 8));
 }
 
-void legacy_acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
+void legacy_acpi_cpu_plug_cb(AcpiDeviceIf *acpi_dev,
                              AcpiCpuHotplug *g, DeviceState *dev, Error **errp)
 {
     acpi_set_cpu_present_bit(g, CPU(dev), errp);
     if (*errp != NULL) {
         return;
     }
-    acpi_send_event(ACPI_DEVICE_IF(hotplug_dev), ACPI_CPU_HOTPLUG_STATUS);
+    acpi_send_event(acpi_dev, ACPI_CPU_HOTPLUG_STATUS);
 }
 
 void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index c5d8646abc..c53b8bb508 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -487,20 +487,21 @@ void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
                             Error **errp)
 {
     ICH9LPCState *lpc = ICH9_LPC_DEVICE(hotplug_dev);
+    AcpiDeviceIf *acpi_dev = ACPI_DEVICE_IF(hotplug_dev);
 
     if (lpc->pm.acpi_memory_hotplug.is_enabled &&
         object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
         if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
-            nvdimm_acpi_plug_cb(hotplug_dev, dev);
+            nvdimm_acpi_plug_cb(acpi_dev, dev);
         } else {
-            acpi_memory_plug_cb(hotplug_dev, &lpc->pm.acpi_memory_hotplug,
+            acpi_memory_plug_cb(acpi_dev, &lpc->pm.acpi_memory_hotplug,
                                 dev, errp);
         }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
         if (lpc->pm.cpu_hotplug_legacy) {
-            legacy_acpi_cpu_plug_cb(hotplug_dev, &lpc->pm.gpe_cpu, dev, errp);
+            legacy_acpi_cpu_plug_cb(acpi_dev, &lpc->pm.gpe_cpu, dev, errp);
         } else {
-            acpi_cpu_plug_cb(hotplug_dev, &lpc->pm.cpuhp_state, dev, errp);
+            acpi_cpu_plug_cb(acpi_dev, &lpc->pm.cpuhp_state, dev, errp);
         }
     } else {
         error_setg(errp, "acpi: device plug request for not supported device"
@@ -512,15 +513,16 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev,
                                       DeviceState *dev, Error **errp)
 {
     ICH9LPCState *lpc = ICH9_LPC_DEVICE(hotplug_dev);
+    AcpiDeviceIf *acpi_dev = ACPI_DEVICE_IF(hotplug_dev);
 
     if (lpc->pm.acpi_memory_hotplug.is_enabled &&
         object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
-        acpi_memory_unplug_request_cb(hotplug_dev,
+        acpi_memory_unplug_request_cb(acpi_dev,
                                       &lpc->pm.acpi_memory_hotplug, dev,
                                       errp);
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) &&
                !lpc->pm.cpu_hotplug_legacy) {
-        acpi_cpu_unplug_request_cb(hotplug_dev, &lpc->pm.cpuhp_state,
+        acpi_cpu_unplug_request_cb(acpi_dev, &lpc->pm.cpuhp_state,
                                    dev, errp);
     } else {
         error_setg(errp, "acpi: device unplug request for not supported device"
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 24b2aa0301..c0a4c39432 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -261,7 +261,7 @@ acpi_memory_slot_status(MemHotplugState *mem_st,
     return &mem_st->devs[slot];
 }
 
-void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st,
+void acpi_memory_plug_cb(AcpiDeviceIf *acpi_dev, MemHotplugState *mem_st,
                          DeviceState *dev, Error **errp)
 {
     MemStatus *mdev;
@@ -280,11 +280,11 @@ void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st,
     mdev->is_enabled = true;
     if (dev->hotplugged) {
         mdev->is_inserting = true;
-        acpi_send_event(ACPI_DEVICE_IF(hotplug_dev), ACPI_MEMORY_HOTPLUG_STATUS);
+        acpi_send_event(acpi_dev, ACPI_MEMORY_HOTPLUG_STATUS);
     }
 }
 
-void acpi_memory_unplug_request_cb(HotplugHandler *hotplug_dev,
+void acpi_memory_unplug_request_cb(AcpiDeviceIf *acpi_dev,
                                    MemHotplugState *mem_st,
                                    DeviceState *dev, Error **errp)
 {
@@ -296,7 +296,7 @@ void acpi_memory_unplug_request_cb(HotplugHandler *hotplug_dev,
     }
 
     mdev->is_removing = true;
-    acpi_send_event(ACPI_DEVICE_IF(hotplug_dev), ACPI_MEMORY_HOTPLUG_STATUS);
+    acpi_send_event(acpi_dev, ACPI_MEMORY_HOTPLUG_STATUS);
 }
 
 void acpi_memory_unplug_cb(MemHotplugState *mem_st,
diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
index bdc373696d..b4708dc746 100644
--- a/hw/acpi/nvdimm.c
+++ b/hw/acpi/nvdimm.c
@@ -918,10 +918,10 @@ static const MemoryRegionOps nvdimm_dsm_ops = {
     },
 };
 
-void nvdimm_acpi_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev)
+void nvdimm_acpi_plug_cb(AcpiDeviceIf *acpi_dev, DeviceState *dev)
 {
     if (dev->hotplugged) {
-        acpi_send_event(ACPI_DEVICE_IF(hotplug_dev), ACPI_NVDIMM_HOTPLUG_STATUS);
+        acpi_send_event(acpi_dev, ACPI_NVDIMM_HOTPLUG_STATUS);
     }
 }
 
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index b3bb11dac5..c094d86de3 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -217,7 +217,7 @@ void acpi_pcihp_reset(AcpiPciHpState *s)
     acpi_pcihp_update(s);
 }
 
-void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
+void acpi_pcihp_device_plug_cb(AcpiDeviceIf *acpi_dev, AcpiPciHpState *s,
                                DeviceState *dev, Error **errp)
 {
     PCIDevice *pdev = PCI_DEVICE(dev);
@@ -237,10 +237,10 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
     }
 
     s->acpi_pcihp_pci_status[bsel].up |= (1U << slot);
-    acpi_send_event(ACPI_DEVICE_IF(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS);
+    acpi_send_event(acpi_dev, ACPI_PCI_HOTPLUG_STATUS);
 }
 
-void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
+void acpi_pcihp_device_unplug_cb(AcpiDeviceIf *acpi_dev, AcpiPciHpState *s,
                                  DeviceState *dev, Error **errp)
 {
     PCIDevice *pdev = PCI_DEVICE(dev);
@@ -253,7 +253,7 @@ void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
     }
 
     s->acpi_pcihp_pci_status[bsel].down |= (1U << slot);
-    acpi_send_event(ACPI_DEVICE_IF(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS);
+    acpi_send_event(acpi_dev, ACPI_PCI_HOTPLUG_STATUS);
 }
 
 static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size)
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 6404af5f33..c26c66242f 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -374,22 +374,23 @@ static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,
                                  DeviceState *dev, Error **errp)
 {
     PIIX4PMState *s = PIIX4_PM(hotplug_dev);
+    AcpiDeviceIf *acpi_dev = ACPI_DEVICE_IF(hotplug_dev);
 
     if (s->acpi_memory_hotplug.is_enabled &&
         object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
         if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
-            nvdimm_acpi_plug_cb(hotplug_dev, dev);
+            nvdimm_acpi_plug_cb(acpi_dev, dev);
         } else {
-            acpi_memory_plug_cb(hotplug_dev, &s->acpi_memory_hotplug,
+            acpi_memory_plug_cb(acpi_dev, &s->acpi_memory_hotplug,
                                 dev, errp);
         }
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
-        acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, errp);
+        acpi_pcihp_device_plug_cb(acpi_dev, &s->acpi_pci_hotplug, dev, errp);
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
         if (s->cpu_hotplug_legacy) {
-            legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp);
+            legacy_acpi_cpu_plug_cb(acpi_dev, &s->gpe_cpu, dev, errp);
         } else {
-            acpi_cpu_plug_cb(hotplug_dev, &s->cpuhp_state, dev, errp);
+            acpi_cpu_plug_cb(acpi_dev, &s->cpuhp_state, dev, errp);
         }
     } else {
         error_setg(errp, "acpi: device plug request for not supported device"
@@ -401,17 +402,18 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,
                                            DeviceState *dev, Error **errp)
 {
     PIIX4PMState *s = PIIX4_PM(hotplug_dev);
+    AcpiDeviceIf *acpi_dev = ACPI_DEVICE_IF(hotplug_dev);
 
     if (s->acpi_memory_hotplug.is_enabled &&
         object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
-        acpi_memory_unplug_request_cb(hotplug_dev, &s->acpi_memory_hotplug,
+        acpi_memory_unplug_request_cb(acpi_dev, &s->acpi_memory_hotplug,
                                       dev, errp);
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
-        acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
+        acpi_pcihp_device_unplug_cb(acpi_dev, &s->acpi_pci_hotplug, dev,
                                     errp);
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) &&
                !s->cpu_hotplug_legacy) {
-        acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp);
+        acpi_cpu_unplug_request_cb(acpi_dev, &s->cpuhp_state, dev, errp);
     } else {
         error_setg(errp, "acpi: device unplug request for not supported device"
                    " type: %s", object_get_typename(OBJECT(dev)));
-- 
2.18.0.rc1.1.g3f1ff2140

^ permalink raw reply related


This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.