Re: [net-next v3 3/6] net: marvell: prestera: Add basic devlink support

2020-07-26 Thread Jiri Pirko
Sat, Jul 25, 2020 at 05:06:48PM CEST, vadym.koc...@plvision.eu wrote:
>Add very basic support for devlink interface:
>
>- driver name
>- fw version
>- devlink ports
>
>Signed-off-by: Vadym Kochan 

Reviewed-by: Jiri Pirko 


Re: [PATCH 12/19] perf metric: Add events for the current list

2020-07-26 Thread kajoljain



On 7/20/20 4:04 AM, Ian Rogers wrote:
> On Sun, Jul 19, 2020 at 11:14 AM Jiri Olsa  wrote:
>>
>> There's no need to iterate the whole list of groups,
>> when adding new events. The currently created groups
>> are the ones we want to add.
>>
>> Signed-off-by: Jiri Olsa 
> 
> Acked-by: Ian Rogers 
> 

Reviewed-By : Kajol Jain

Thanks,
Kajol Jain
> Thanks,
> Ian
> 
>> ---
>>  tools/perf/util/metricgroup.c | 9 ++---
>>  1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
>> index bb5757b9419d..332414d93f7a 100644
>> --- a/tools/perf/util/metricgroup.c
>> +++ b/tools/perf/util/metricgroup.c
>> @@ -813,6 +813,7 @@ static int metricgroup__add_metric(const char *metric, 
>> bool metric_no_group,
>>  {
>> struct pmu_event *pe;
>> struct egroup *eg;
>> +   LIST_HEAD(list);
>> int i, ret;
>> bool has_match = false;
>>
>> @@ -820,7 +821,7 @@ static int metricgroup__add_metric(const char *metric, 
>> bool metric_no_group,
>> has_match = true;
>> eg = NULL;
>>
>> -   ret = add_metric(group_list, pe, metric_no_group, );
>> +   ret = add_metric(, pe, metric_no_group, );
>> if (ret)
>> return ret;
>>
>> @@ -829,7 +830,7 @@ static int metricgroup__add_metric(const char *metric, 
>> bool metric_no_group,
>>  * included in the expression.
>>  */
>> ret = resolve_metric(eg, metric_no_group,
>> -group_list, map);
>> +, map);
>> if (ret)
>> return ret;
>> }
>> @@ -838,7 +839,7 @@ static int metricgroup__add_metric(const char *metric, 
>> bool metric_no_group,
>> if (!has_match)
>> return -EINVAL;
>>
>> -   list_for_each_entry(eg, group_list, nd) {
>> +   list_for_each_entry(eg, , nd) {
>> if (events->len > 0)
>> strbuf_addf(events, ",");
>>
>> @@ -850,6 +851,8 @@ static int metricgroup__add_metric(const char *metric, 
>> bool metric_no_group,
>>>pctx);
>> }
>> }
>> +
>> +   list_splice(, group_list);
>> return 0;
>>  }
>>
>> --
>> 2.25.4
>>


Re: [PATCH 11/19] perf metric: Compute referenced metrics

2020-07-26 Thread kajoljain



On 7/19/20 11:43 PM, Jiri Olsa wrote:
> Adding computation (expr__parse call) of referenced metric at
> the point when it needs to be resolved during the parent metric
> computation.
> 
> Once the inner metric is computed, the result is stored and
> used if there's another usage of that metric.
> 
> Acked-by: Ian Rogers 
> Signed-off-by: Jiri Olsa 

Reviewed-By : Kajol Jain

Thanks,
Kajol Jain
> ---
>  tools/perf/util/expr.c | 31 +++
>  tools/perf/util/expr.h |  3 +++
>  tools/perf/util/expr.y |  4 ++--
>  3 files changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
> index d3997c2b4a90..a346ca590513 100644
> --- a/tools/perf/util/expr.c
> +++ b/tools/perf/util/expr.c
> @@ -112,6 +112,7 @@ int expr__add_ref(struct expr_parse_ctx *ctx, struct 
> metric_ref *ref)
>*/
>   data_ptr->ref.metric_name = ref->metric_name;
>   data_ptr->ref.metric_expr = ref->metric_expr;
> + data_ptr->ref.counted = false;
>   data_ptr->is_ref = true;
>  
>   ret = hashmap__set(>ids, name, data_ptr,
> @@ -133,6 +134,34 @@ int expr__get_id(struct expr_parse_ctx *ctx, const char 
> *id,
>   return hashmap__find(>ids, id, (void **)data) ? 0 : -1;
>  }
>  
> +int expr__resolve_id(struct expr_parse_ctx *ctx, const char *id,
> +  struct expr_id_data **datap)
> +{
> + struct expr_id_data *data;
> +
> + if (expr__get_id(ctx, id, datap) || !*datap) {
> + pr_debug("%s not found\n", id);
> + return -1;
> + }
> +
> + data = *datap;
> +
> + pr_debug2("lookup: is_ref %d, counted %d, val %f: %s\n",
> +   data->is_ref, data->ref.counted, data->val, id);
> +
> + if (data->is_ref && !data->ref.counted) {
> + data->ref.counted = true;
> + pr_debug("processing metric: %s ENTRY\n", id);
> + if (expr__parse(>val, ctx, data->ref.metric_expr, 1)) {
> + pr_debug("%s failed to count\n", id);
> + return -1;
> + }
> + pr_debug("processing metric: %s EXIT: %f\n", id, data->val);
> + }
> +
> + return 0;
> +}
> +
>  void expr__del_id(struct expr_parse_ctx *ctx, const char *id)
>  {
>   struct expr_id_data *old_val = NULL;
> @@ -173,6 +202,8 @@ __expr__parse(double *val, struct expr_parse_ctx *ctx, 
> const char *expr,
>   void *scanner;
>   int ret;
>  
> + pr_debug2("parsing metric: %s\n", expr);
> +
>   ret = expr_lex_init_extra(_ctx, );
>   if (ret)
>   return ret;
> diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h
> index 81d04ff7f857..9ed208d93418 100644
> --- a/tools/perf/util/expr.h
> +++ b/tools/perf/util/expr.h
> @@ -23,6 +23,7 @@ struct expr_id_data {
>   struct {
>   const char *metric_name;
>   const char *metric_expr;
> + bool counted;
>   } ref;
>   };
>  
> @@ -42,6 +43,8 @@ int expr__add_id_val(struct expr_parse_ctx *ctx, const char 
> *id, double val);
>  int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref);
>  int expr__get_id(struct expr_parse_ctx *ctx, const char *id,
>struct expr_id_data **data);
> +int expr__resolve_id(struct expr_parse_ctx *ctx, const char *id,
> +  struct expr_id_data **datap);
>  int expr__parse(double *final_val, struct expr_parse_ctx *ctx,
>   const char *expr, int runtime);
>  int expr__find_other(const char *expr, const char *one,
> diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y
> index 0d4f5d324be7..d34b370391c6 100644
> --- a/tools/perf/util/expr.y
> +++ b/tools/perf/util/expr.y
> @@ -88,11 +88,11 @@ expr:   NUMBER
>   | ID{
>   struct expr_id_data *data;
>  
> - if (expr__get_id(ctx, $1, ) || 
> !data) {
> - pr_debug("%s not found\n", $1);
> + if (expr__resolve_id(ctx, $1, )) {
>   free($1);
>   YYABORT;
>   }
> +
>   $$ = data->val;
>   free($1);
>   }
> 


Re: [PATCH 13/19] perf metric: Add cache_miss_cycles to metric parse test

2020-07-26 Thread kajoljain



On 7/19/20 11:43 PM, Jiri Olsa wrote:
> Adding test that compute metric with other metrics in it.
> 
>   cache_miss_cycles = metric:dcache_miss_cpi + metric:icache_miss_cycles
> 
> Acked-by: Ian Rogers 
> Signed-off-by: Jiri Olsa 

Reviewed-By : Kajol Jain

Thanks,
Kajol Jain
> ---
>  tools/perf/tests/parse-metric.c | 33 +
>  1 file changed, 33 insertions(+)
> 
> diff --git a/tools/perf/tests/parse-metric.c b/tools/perf/tests/parse-metric.c
> index 8c48251425e1..28f33893338b 100644
> --- a/tools/perf/tests/parse-metric.c
> +++ b/tools/perf/tests/parse-metric.c
> @@ -11,6 +11,8 @@
>  #include "debug.h"
>  #include "expr.h"
>  #include "stat.h"
> +#include 
> +#include 
>  
>  static struct pmu_event pme_test[] = {
>  {
> @@ -22,6 +24,18 @@ static struct pmu_event pme_test[] = {
> "( 1 + cpu_clk_unhalted.one_thread_active / 
> cpu_clk_unhalted.ref_xclk ) )))",
>   .metric_name= "Frontend_Bound_SMT",
>  },
> +{
> + .metric_expr= "l1d\\-loads\\-misses / inst_retired.any",
> + .metric_name= "dcache_miss_cpi",
> +},
> +{
> + .metric_expr= "l1i\\-loads\\-misses / inst_retired.any",
> + .metric_name= "icache_miss_cycles",
> +},
> +{
> + .metric_expr= "(dcache_miss_cpi + icache_miss_cycles)",
> + .metric_name= "cache_miss_cycles",
> +},
>  };
>  
>  static struct pmu_events_map map = {
> @@ -162,9 +176,28 @@ static int test_frontend(void)
>   return 0;
>  }
>  
> +static int test_cache_miss_cycles(void)
> +{
> + double ratio;
> + struct value vals[] = {
> + { .event = "l1d-loads-misses",  .val = 300 },
> + { .event = "l1i-loads-misses",  .val = 200 },
> + { .event = "inst_retired.any",  .val = 400 },
> + { 0 },
> + };
> +
> + TEST_ASSERT_VAL("failed to compute metric",
> + compute_metric("cache_miss_cycles", vals, ) == 0);
> +
> + TEST_ASSERT_VAL("cache_miss_cycles failed, wrong ratio",
> + ratio == 1.25);
> + return 0;
> +}
> +
>  int test__parse_metric(struct test *test __maybe_unused, int subtest 
> __maybe_unused)
>  {
>   TEST_ASSERT_VAL("IPC failed", test_ipc() == 0);
>   TEST_ASSERT_VAL("frontend failed", test_frontend() == 0);
> + TEST_ASSERT_VAL("cache_miss_cycles failed", test_cache_miss_cycles() == 
> 0);
>   return 0;
>  }
> 


Re: [PATCH 14/19] perf metric: Add DCache_L2 to metric parse test

2020-07-26 Thread kajoljain



On 7/19/20 11:43 PM, Jiri Olsa wrote:
> Adding test that compute DCache_L2 metrics with other related metrics in it.
> 
> Acked-by: Ian Rogers 
> Signed-off-by: Jiri Olsa 

Reviewed-By : Kajol Jain

Thanks,
Kajol Jain
> ---
>  tools/perf/tests/parse-metric.c | 71 +
>  1 file changed, 71 insertions(+)
> 
> diff --git a/tools/perf/tests/parse-metric.c b/tools/perf/tests/parse-metric.c
> index 28f33893338b..aa4d5a9f09a8 100644
> --- a/tools/perf/tests/parse-metric.c
> +++ b/tools/perf/tests/parse-metric.c
> @@ -36,6 +36,27 @@ static struct pmu_event pme_test[] = {
>   .metric_expr= "(dcache_miss_cpi + icache_miss_cycles)",
>   .metric_name= "cache_miss_cycles",
>  },
> +{
> + .metric_expr= "l2_rqsts.demand_data_rd_hit + l2_rqsts.pf_hit + 
> l2_rqsts.rfo_hit",
> + .metric_name= "DCache_L2_All_Hits",
> +},
> +{
> + .metric_expr= "max(l2_rqsts.all_demand_data_rd - 
> l2_rqsts.demand_data_rd_hit, 0) + "
> +   "l2_rqsts.pf_miss + l2_rqsts.rfo_miss",
> + .metric_name= "DCache_L2_All_Miss",
> +},
> +{
> + .metric_expr= "dcache_l2_all_hits + dcache_l2_all_miss",
> + .metric_name= "DCache_L2_All",
> +},
> +{
> + .metric_expr= "d_ratio(dcache_l2_all_hits, dcache_l2_all)",
> + .metric_name= "DCache_L2_Hits",
> +},
> +{
> + .metric_expr= "d_ratio(dcache_l2_all_miss, dcache_l2_all)",
> + .metric_name= "DCache_L2_Misses",
> +},
>  };
>  
>  static struct pmu_events_map map = {
> @@ -194,10 +215,60 @@ static int test_cache_miss_cycles(void)
>   return 0;
>  }
>  
> +
> +/*
> + * DCache_L2_All_Hits = l2_rqsts.demand_data_rd_hit + l2_rqsts.pf_hit + 
> l2_rqsts.rfo_hi
> + * DCache_L2_All_Miss = max(l2_rqsts.all_demand_data_rd - 
> l2_rqsts.demand_data_rd_hit, 0) +
> + *  l2_rqsts.pf_miss + l2_rqsts.rfo_miss
> + * DCache_L2_All  = dcache_l2_all_hits + dcache_l2_all_miss
> + * DCache_L2_Hits = d_ratio(dcache_l2_all_hits, dcache_l2_all)
> + * DCache_L2_Misses   = d_ratio(dcache_l2_all_miss, dcache_l2_all)
> + *
> + * l2_rqsts.demand_data_rd_hit = 100
> + * l2_rqsts.pf_hit = 200
> + * l2_rqsts.rfo_hi = 300
> + * l2_rqsts.all_demand_data_rd = 400
> + * l2_rqsts.pf_miss= 500
> + * l2_rqsts.rfo_miss   = 600
> + *
> + * DCache_L2_All_Hits = 600
> + * DCache_L2_All_Miss = MAX(400 - 100, 0) + 500 + 600 = 1400
> + * DCache_L2_All  = 600 + 1400  = 2000
> + * DCache_L2_Hits = 600 / 2000  = 0.3
> + * DCache_L2_Misses   = 1400 / 2000 = 0.7
> + */
> +static int test_dcache_l2(void)
> +{
> + double ratio;
> + struct value vals[] = {
> + { .event = "l2_rqsts.demand_data_rd_hit", .val = 100 },
> + { .event = "l2_rqsts.pf_hit", .val = 200 },
> + { .event = "l2_rqsts.rfo_hit",.val = 300 },
> + { .event = "l2_rqsts.all_demand_data_rd", .val = 400 },
> + { .event = "l2_rqsts.pf_miss",.val = 500 },
> + { .event = "l2_rqsts.rfo_miss",   .val = 600 },
> + { 0 },
> + };
> +
> + TEST_ASSERT_VAL("failed to compute metric",
> + compute_metric("DCache_L2_Hits", vals, ) == 0);
> +
> + TEST_ASSERT_VAL("DCache_L2_Hits failed, wrong ratio",
> + ratio == 0.3);
> +
> + TEST_ASSERT_VAL("failed to compute metric",
> + compute_metric("DCache_L2_Misses", vals, ) == 0);
> +
> + TEST_ASSERT_VAL("DCache_L2_Misses failed, wrong ratio",
> + ratio == 0.7);
> + return 0;
> +}
> +
>  int test__parse_metric(struct test *test __maybe_unused, int subtest 
> __maybe_unused)
>  {
>   TEST_ASSERT_VAL("IPC failed", test_ipc() == 0);
>   TEST_ASSERT_VAL("frontend failed", test_frontend() == 0);
>   TEST_ASSERT_VAL("cache_miss_cycles failed", test_cache_miss_cycles() == 
> 0);
> + TEST_ASSERT_VAL("DCache_L2 failed", test_dcache_l2() == 0);
>   return 0;
>  }
> 


Re: [PATCH 10/19] perf metric: Add referenced metrics to hash data

2020-07-26 Thread kajoljain



On 7/20/20 4:02 AM, Ian Rogers wrote:
> On Sun, Jul 19, 2020 at 11:14 AM Jiri Olsa  wrote:
>>
>> Adding referenced metrics to the parsing context so they
>> can be resolved during the metric processing.
>>
>> Adding expr__add_ref function to store referenced metrics
>> into parse context.
>>
>> Signed-off-by: Jiri Olsa 
> 
> Acked-by: Ian Rogers 

Reviewed-By : Kajol Jain

Thanks,
Kajol Jain
> 
> Thanks,
> Ian
> 
>> ---
>>  tools/perf/util/expr.c| 54 +++
>>  tools/perf/util/expr.h| 13 -
>>  tools/perf/util/stat-shadow.c | 20 +
>>  3 files changed, 80 insertions(+), 7 deletions(-)
>>
>> diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
>> index f726211f49d4..d3997c2b4a90 100644
>> --- a/tools/perf/util/expr.c
>> +++ b/tools/perf/util/expr.c
>> @@ -4,10 +4,14 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include "metricgroup.h"
>> +#include "debug.h"
>>  #include "expr.h"
>>  #include "expr-bison.h"
>>  #include "expr-flex.h"
>>  #include 
>> +#include 
>> +#include 
>>
>>  #ifdef PARSER_DEBUG
>>  extern int expr_debug;
>> @@ -63,6 +67,7 @@ int expr__add_id_val(struct expr_parse_ctx *ctx, const 
>> char *id, double val)
>> if (!data_ptr)
>> return -ENOMEM;
>> data_ptr->val = val;
>> +   data_ptr->is_ref = false;
>>
>> ret = hashmap__set(>ids, id, data_ptr,
>>(const void **)_key, (void **)_data);
>> @@ -73,6 +78,55 @@ int expr__add_id_val(struct expr_parse_ctx *ctx, const 
>> char *id, double val)
>> return ret;
>>  }
>>
>> +int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref)
>> +{
>> +   struct expr_id_data *data_ptr = NULL, *old_data = NULL;
>> +   char *old_key = NULL;
>> +   char *name, *p;
>> +   int ret;
>> +
>> +   data_ptr = zalloc(sizeof(*data_ptr));
>> +   if (!data_ptr)
>> +   return -ENOMEM;
>> +
>> +   name = strdup(ref->metric_name);
>> +   if (!name) {
>> +   free(data_ptr);
>> +   return -ENOMEM;
>> +   }
>> +
>> +   /*
>> +* The jevents tool converts all metric expressions
>> +* to lowercase, including metric references, hence
>> +* we need to add lowercase name for metric, so it's
>> +* properly found.
>> +*/
>> +   for (p = name; *p; p++)
>> +   *p = tolower(*p);
>> +
>> +   /*
>> +* Intentionally passing just const char pointers,
>> +* originally from 'struct pmu_event' object.
>> +* We don't need to change them, so there's no
>> +* need to create our own copy.
>> +*/
>> +   data_ptr->ref.metric_name = ref->metric_name;
>> +   data_ptr->ref.metric_expr = ref->metric_expr;
>> +   data_ptr->is_ref = true;
>> +
>> +   ret = hashmap__set(>ids, name, data_ptr,
>> +  (const void **)_key, (void **)_data);
>> +   if (ret)
>> +   free(data_ptr);
>> +
>> +   pr_debug2("adding ref metric %s: %s\n",
>> + ref->metric_name, ref->metric_expr);
>> +
>> +   free(old_key);
>> +   free(old_data);
>> +   return ret;
>> +}
>> +
>>  int expr__get_id(struct expr_parse_ctx *ctx, const char *id,
>>  struct expr_id_data **data)
>>  {
>> diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h
>> index 2462abd0ac65..81d04ff7f857 100644
>> --- a/tools/perf/util/expr.h
>> +++ b/tools/perf/util/expr.h
>> @@ -11,12 +11,22 @@
>>  #include "util/hashmap.h"
>>  //#endif
>>
>> +struct metric_ref;
>> +
>>  struct expr_parse_ctx {
>> struct hashmap ids;
>>  };
>>
>>  struct expr_id_data {
>> -   double  val;
>> +   union {
>> +   double val;
>> +   struct {
>> +   const char *metric_name;
>> +   const char *metric_expr;
>> +   } ref;
>> +   };
>> +
>> +   bool is_ref;
>>  };
>>
>>  struct expr_scanner_ctx {
>> @@ -29,6 +39,7 @@ void expr__ctx_clear(struct expr_parse_ctx *ctx);
>>  void expr__del_id(struct expr_parse_ctx *ctx, const char *id);
>>  int expr__add_id(struct expr_parse_ctx *ctx, const char *id);
>>  int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double 
>> val);
>> +int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref);
>>  int expr__get_id(struct expr_parse_ctx *ctx, const char *id,
>>  struct expr_id_data **data);
>>  int expr__parse(double *final_val, struct expr_parse_ctx *ctx,
>> diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
>> index fc9ac4b4218e..e1ba6c1b916a 100644
>> --- a/tools/perf/util/stat-shadow.c
>> +++ b/tools/perf/util/stat-shadow.c
>> @@ -731,13 +731,14 @@ static void print_smi_cost(struct perf_stat_config 
>> *config,
>>  }
>>
>>  static int prepare_metric(struct evsel **metric_events,
>> + struct metric_ref *metric_refs,
>>  

Re: [PATCH 07/19] perf metric: Rename __metricgroup__add_metric to __add_metric

2020-07-26 Thread kajoljain



On 7/19/20 11:43 PM, Jiri Olsa wrote:
> Renaming __metricgroup__add_metric to __add_metric
> to fit in the current function names.
> 
> Acked-by: Ian Rogers 
> Signed-off-by: Jiri Olsa 

Reviewed-By : Kajol Jain

Thanks,
Kajol Jain
> ---
>  tools/perf/util/metricgroup.c | 17 ++---
>  1 file changed, 6 insertions(+), 11 deletions(-)
> 
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index 4096be7a7a9e..ccd80538a6ae 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -571,10 +571,10 @@ int __weak arch_get_runtimeparam(void)
>   return 1;
>  }
>  
> -static int __metricgroup__add_metric(struct list_head *group_list,
> -  struct pmu_event *pe,
> -  bool metric_no_group,
> -  int runtime)
> +static int __add_metric(struct list_head *group_list,
> + struct pmu_event *pe,
> + bool metric_no_group,
> + int runtime)
>  {
>   struct egroup *eg;
>  
> @@ -634,10 +634,7 @@ static int add_metric(struct list_head *group_list,
>   pr_debug("metric expr %s for %s\n", pe->metric_expr, pe->metric_name);
>  
>   if (!strstr(pe->metric_expr, "?")) {
> - ret = __metricgroup__add_metric(group_list,
> - pe,
> - metric_no_group,
> - 1);
> + ret = __add_metric(group_list, pe, metric_no_group, 1);
>   } else {
>   int j, count;
>  
> @@ -649,9 +646,7 @@ static int add_metric(struct list_head *group_list,
>*/
>  
>   for (j = 0; j < count && !ret; j++) {
> - ret = __metricgroup__add_metric(
> - group_list, pe,
> - metric_no_group, j);
> + ret = __add_metric(group_list, pe, metric_no_group, j);
>   }
>   }
>  
> 


Re: [PATCH v3 1/4] staging: media: atomisp: fix style of block comments

2020-07-26 Thread Rohit K Bharadwaj
On 26/07/20 2:42 pm, Greg KH wrote:
> On Sun, Jul 26, 2020 at 02:35:10PM +0530, Rohit K Bharadwaj wrote:
>> this patch fixes the coding style of block comments.
>>
>> Signed-off-by: Rohit K Bharadwaj 
>> ---
>> v3: change patch subject prefix
>> v2: split patch into sequence of patches 
>> v1: fix all coding style issues in single patch
>>
>>  .../media/atomisp/pci/sh_css_firmware.c   | 28 +--
>>  1 file changed, 19 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c 
>> b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
>> index d4ab15b6d1ac..2907aead98b7 100644
>> --- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c
>> +++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
>> @@ -51,9 +51,12 @@ struct fw_param {
>>  
>>  static struct firmware_header *firmware_header;
>>  
>> -/* The string STR is a place holder
>> +/*
>> + * The string STR is a place holder
>>   * which will be replaced with the actual RELEASE_VERSION
>> - * during package generation. Please do not modify  */
>> + * during package generation. Please do not modify
>> + */
>> +
> 
> Why the blank line?
> 
Sir, I thought that it would improve the readability of the code and would help 
easily distinguish comments from the variable declaration part, and also since 
there was a blank line between the start of comment and the static struct 
firmware_header variable, I thought of putting a blank line after the comment 
end as well to maintain symmetry. 


Re: [PATCH 08/19] perf metric: Collect referenced metrics in struct metric_ref_node

2020-07-26 Thread kajoljain



On 7/20/20 3:48 AM, Ian Rogers wrote:
> On Sun, Jul 19, 2020 at 11:13 AM Jiri Olsa  wrote:
>>
>> Collecting referenced metrics in struct metric_ref_node object,
>> so we can process them later on.
>>
>> The change will parse nested metric names out of expression and
>> 'resolve' them.
>>
>> All referenced metrics are dissolved into one context, meaning all
>> nested metrics events and added to the parent context.
>>
>> Signed-off-by: Jiri Olsa 
> 
> Acked-by: Ian Rogers 
> 
> Thanks,
> Ian

Reviewed-By : Kajol Jain

Thanks,
Kajol Jain
> 
>> ---
>>  tools/perf/util/metricgroup.c | 170 +++---
>>  1 file changed, 156 insertions(+), 14 deletions(-)
>>
>> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
>> index ccd80538a6ae..d1b2c1aa436f 100644
>> --- a/tools/perf/util/metricgroup.c
>> +++ b/tools/perf/util/metricgroup.c
>> @@ -102,12 +102,25 @@ void metricgroup__rblist_exit(struct rblist 
>> *metric_events)
>> rblist__exit(metric_events);
>>  }
>>
>> +/*
>> + * A node in the list of referenced metrics. metric_expr
>> + * is held as a convenience to avoid a search through the
>> + * metric list.
>> + */
>> +struct metric_ref_node {
>> +   const char *metric_name;
>> +   const char *metric_expr;
>> +   struct list_head list;
>> +};
>> +
>>  struct egroup {
>> struct list_head nd;
>> struct expr_parse_ctx pctx;
>> const char *metric_name;
>> const char *metric_expr;
>> const char *metric_unit;
>> +   struct list_head metric_refs;
>> +   int metric_refs_cnt;
>> int runtime;
>> bool has_constraint;
>>  };
>> @@ -574,27 +587,72 @@ int __weak arch_get_runtimeparam(void)
>>  static int __add_metric(struct list_head *group_list,
>> struct pmu_event *pe,
>> bool metric_no_group,
>> -   int runtime)
>> +   int runtime,
>> +   struct egroup **egp)
>>  {
>> +   struct metric_ref_node *ref;
>> struct egroup *eg;
>>
>> -   eg = malloc(sizeof(*eg));
>> -   if (!eg)
>> -   return -ENOMEM;
>> +   if (*egp == NULL) {
>> +   /*
>> +* We got in here for the parent group,
>> +* allocate it and put it on the list.
>> +*/
>> +   eg = malloc(sizeof(*eg));
>> +   if (!eg)
>> +   return -ENOMEM;
>> +
>> +   expr__ctx_init(>pctx);
>> +   eg->metric_name = pe->metric_name;
>> +   eg->metric_expr = pe->metric_expr;
>> +   eg->metric_unit = pe->unit;
>> +   eg->runtime = runtime;
>> +   eg->has_constraint = metric_no_group || 
>> metricgroup__has_constraint(pe);
>> +   INIT_LIST_HEAD(>metric_refs);
>> +   eg->metric_refs_cnt = 0;
>> +   *egp = eg;
>> +   } else {
>> +   /*
>> +* We got here for the referenced metric, via the
>> +* recursive metricgroup__add_metric call, add
>> +* it to the parent group.
>> +*/
>> +   eg = *egp;
>> +
>> +   ref = malloc(sizeof(*ref));
>> +   if (!ref)
>> +   return -ENOMEM;
>> +
>> +   /*
>> +* Intentionally passing just const char pointers,
>> +* from 'pe' object, so they never go away. We don't
>> +* need to change them, so there's no need to create
>> +* our own copy.
>> +*/
>> +   ref->metric_name = pe->metric_name;
>> +   ref->metric_expr = pe->metric_expr;
>>
>> -   expr__ctx_init(>pctx);
>> -   eg->metric_name = pe->metric_name;
>> -   eg->metric_expr = pe->metric_expr;
>> -   eg->metric_unit = pe->unit;
>> -   eg->runtime = runtime;
>> -   eg->has_constraint = metric_no_group || 
>> metricgroup__has_constraint(pe);
>> +   list_add(>list, >metric_refs);
>> +   eg->metric_refs_cnt++;
>> +   }
>>
>> +   /*
>> +* For both the parent and referenced metrics, we parse
>> +* all the metric's IDs and add it to the parent context.
>> +*/
>> if (expr__find_other(pe->metric_expr, NULL, >pctx, runtime) < 0) 
>> {
>> expr__ctx_clear(>pctx);
>> free(eg);
>> return -EINVAL;
>> }
>>
>> +   /*
>> +* We add new group only in the 'parent' call,
>> +* so bail out for referenced metric case.
>> +*/
>> +   if (eg->metric_refs_cnt)
>> +   return 0;
>> +
>> if (list_empty(group_list))
>> list_add(>nd, group_list);
>> else {
>> @@ -625,16 +683,78 @@ static int __add_metric(struct list_head *group_list,
>> (match_metric(__pe->metric_group, __metric) ||

Re: [PATCH v6 08/13] hwmon: add support for the sl28cpld hardware monitoring controller

2020-07-26 Thread Andy Shevchenko
On Sun, Jul 26, 2020 at 01:18:29AM +0200, Michael Walle wrote:
> Add support for the hardware monitoring controller of the sl28cpld board
> management controller. This driver is part of a multi-function device.

FWIW,
Reviewed-by: Andy Shevchenko 

> Signed-off-by: Michael Walle 
> Acked-by: Guenter Roeck 
> ---
> Changes since v5:
>  - none
> 
> Changes since v4:
>  - update copyright year
>  - remove #include , suggested by Andy.
>  - use PTR_ERR_OR_ZERO(), suggested by Andy.
>  - remove the platform device table
>  - don't use KBUID_MODNAME
> 
> Changes since v3:
>  - see cover letter
> 
>  Documentation/hwmon/index.rst|   1 +
>  Documentation/hwmon/sl28cpld.rst |  36 
>  drivers/hwmon/Kconfig|  10 +++
>  drivers/hwmon/Makefile   |   1 +
>  drivers/hwmon/sl28cpld-hwmon.c   | 142 +++
>  5 files changed, 190 insertions(+)
>  create mode 100644 Documentation/hwmon/sl28cpld.rst
>  create mode 100644 drivers/hwmon/sl28cpld-hwmon.c
> 
> diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
> index 750d3a975d82..d90c43c82936 100644
> --- a/Documentation/hwmon/index.rst
> +++ b/Documentation/hwmon/index.rst
> @@ -154,6 +154,7 @@ Hardware Monitoring Kernel Drivers
> sht3x
> shtc1
> sis5595
> +   sl28cpld
> smm665
> smsc47b397
> smsc47m192
> diff --git a/Documentation/hwmon/sl28cpld.rst 
> b/Documentation/hwmon/sl28cpld.rst
> new file mode 100644
> index ..7ed65f78250c
> --- /dev/null
> +++ b/Documentation/hwmon/sl28cpld.rst
> @@ -0,0 +1,36 @@
> +.. SPDX-License-Identifier: GPL-2.0-only
> +
> +Kernel driver sl28cpld
> +==
> +
> +Supported chips:
> +
> +   * Kontron sl28cpld
> +
> + Prefix: 'sl28cpld'
> +
> + Datasheet: not available
> +
> +Authors: Michael Walle 
> +
> +Description
> +---
> +
> +The sl28cpld is a board management controller which also exposes a hardware
> +monitoring controller. At the moment this controller supports a single fan
> +supervisor. In the future there might be other flavours and additional
> +hardware monitoring might be supported.
> +
> +The fan supervisor has a 7 bit counter register and a counter period of 1
> +second. If the 7 bit counter overflows, the supervisor will automatically
> +switch to x8 mode to support a wider input range at the loss of
> +granularity.
> +
> +Sysfs entries
> +-
> +
> +The following attributes are supported.
> +
> +=== 
> 
> +fan1_input   Fan RPM. Assuming 2 pulses per revolution.
> +=== 
> 
> diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
> index 8dc28b26916e..a02829ec7386 100644
> --- a/drivers/hwmon/Kconfig
> +++ b/drivers/hwmon/Kconfig
> @@ -1479,6 +1479,16 @@ config SENSORS_RASPBERRYPI_HWMON
> This driver can also be built as a module. If so, the module
> will be called raspberrypi-hwmon.
>  
> +config SENSORS_SL28CPLD
> + tristate "Kontron sl28cpld hardware monitoring driver"
> + select MFD_SIMPLE_MFD_I2C
> + help
> +   If you say yes here you get support for the fan supervisor of the
> +   sl28cpld board management controller.
> +
> +   This driver can also be built as a module.  If so, the module
> +   will be called sl28cpld-hwmon.
> +
>  config SENSORS_SHT15
>   tristate "Sensiron humidity and temperature sensors. SHT15 and compat."
>   depends on GPIOLIB || COMPILE_TEST
> diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
> index a8f4b35b136b..dee8511f9348 100644
> --- a/drivers/hwmon/Makefile
> +++ b/drivers/hwmon/Makefile
> @@ -159,6 +159,7 @@ obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o
>  obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o
>  obj-$(CONFIG_SENSORS_SCH5627)+= sch5627.o
>  obj-$(CONFIG_SENSORS_SCH5636)+= sch5636.o
> +obj-$(CONFIG_SENSORS_SL28CPLD)   += sl28cpld-hwmon.o
>  obj-$(CONFIG_SENSORS_SHT15)  += sht15.o
>  obj-$(CONFIG_SENSORS_SHT21)  += sht21.o
>  obj-$(CONFIG_SENSORS_SHT3x)  += sht3x.o
> diff --git a/drivers/hwmon/sl28cpld-hwmon.c b/drivers/hwmon/sl28cpld-hwmon.c
> new file mode 100644
> index ..e48f58ec5b9c
> --- /dev/null
> +++ b/drivers/hwmon/sl28cpld-hwmon.c
> @@ -0,0 +1,142 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * sl28cpld hardware monitoring driver
> + *
> + * Copyright 2020 Kontron Europe GmbH
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define FAN_INPUT0x00
> +#define   FAN_SCALE_X8   BIT(7)
> +#define   FAN_VALUE_MASK GENMASK(6, 0)
> +
> +struct sl28cpld_hwmon {
> + struct regmap *regmap;
> + u32 offset;
> +};
> +
> +static umode_t sl28cpld_hwmon_is_visible(const void *data,
> +  enum hwmon_sensor_types type,
> + 

Re: [PATCH 06/19] perf metric: Add add_metric function

2020-07-26 Thread kajoljain



On 7/19/20 11:43 PM, Jiri Olsa wrote:
> Decouple metric adding logging into add_metric function,
> so it can be used from other places in following changes.
> 
> Acked-by: Ian Rogers 
> Signed-off-by: Jiri Olsa 
> ---

Reviewed-By : Kajol Jain

Thanks,
Kajol Jain
>  tools/perf/util/metricgroup.c | 62 ---
>  1 file changed, 36 insertions(+), 26 deletions(-)
> 
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index b37008fc253c..4096be7a7a9e 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -625,6 +625,39 @@ static int __metricgroup__add_metric(struct list_head 
> *group_list,
>   (match_metric(__pe->metric_group, __metric) ||  \
>match_metric(__pe->metric_name, __metric)))
>  
> +static int add_metric(struct list_head *group_list,
> +   struct pmu_event *pe,
> +   bool metric_no_group)
> +{
> + int ret = 0;
> +
> + pr_debug("metric expr %s for %s\n", pe->metric_expr, pe->metric_name);
> +
> + if (!strstr(pe->metric_expr, "?")) {
> + ret = __metricgroup__add_metric(group_list,
> + pe,
> + metric_no_group,
> + 1);
> + } else {
> + int j, count;
> +
> + count = arch_get_runtimeparam();
> +
> + /* This loop is added to create multiple
> +  * events depend on count value and add
> +  * those events to group_list.
> +  */
> +
> + for (j = 0; j < count && !ret; j++) {
> + ret = __metricgroup__add_metric(
> + group_list, pe,
> + metric_no_group, j);
> + }
> + }
> +
> + return ret;
> +}
> +
>  static int metricgroup__add_metric(const char *metric, bool metric_no_group,
>  struct strbuf *events,
>  struct list_head *group_list,
> @@ -636,34 +669,11 @@ static int metricgroup__add_metric(const char *metric, 
> bool metric_no_group,
>   bool has_match = false;
>  
>   map_for_each_metric(pe, i, map, metric) {
> - pr_debug("metric expr %s for %s\n", pe->metric_expr, 
> pe->metric_name);
>   has_match = true;
>  
> - if (!strstr(pe->metric_expr, "?")) {
> - ret = __metricgroup__add_metric(group_list,
> - pe,
> - metric_no_group,
> - 1);
> - if (ret)
> - return ret;
> - } else {
> - int j, count;
> -
> - count = arch_get_runtimeparam();
> -
> - /* This loop is added to create multiple
> -  * events depend on count value and add
> -  * those events to group_list.
> -  */
> -
> - for (j = 0; j < count; j++) {
> - ret = __metricgroup__add_metric(
> - group_list, pe,
> - metric_no_group, j);
> - if (ret)
> - return ret;
> - }
> - }
> + ret = add_metric(group_list, pe, metric_no_group);
> + if (ret)
> + return ret;
>   }
>  
>   /* End of pmu events. */
> 


Re: [PATCH 09/19] perf metric: Collect referenced metrics in struct metric_expr

2020-07-26 Thread kajoljain



On 7/19/20 11:43 PM, Jiri Olsa wrote:
> Add referenced metrics into struct metric_expr object,
> so they are accessible when computing the metric.
> 
> Storing just name and expression itself, so the metric
> can be resolved and computed.
> 
> Acked-by: Ian Rogers 
> Signed-off-by: Jiri Olsa 

Reviewed-By : Kajol Jain

Thanks,
Kajol Jain
> ---
>  tools/perf/util/metricgroup.c | 32 
>  tools/perf/util/metricgroup.h |  6 ++
>  2 files changed, 38 insertions(+)
> 
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index d1b2c1aa436f..bb5757b9419d 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -83,6 +83,7 @@ static void metric_event_delete(struct rblist *rblist 
> __maybe_unused,
>   struct metric_expr *expr, *tmp;
>  
>   list_for_each_entry_safe(expr, tmp, >head, nd) {
> + free(expr->metric_refs);
>   free(expr);
>   }
>  
> @@ -248,6 +249,7 @@ static int metricgroup__setup_events(struct list_head 
> *groups,
>  
>   list_for_each_entry (eg, groups, nd) {
>   struct evsel **metric_events;
> + struct metric_ref *metric_refs = NULL;
>  
>   metric_events = calloc(sizeof(void *),
>   hashmap__size(>pctx.ids) + 1);
> @@ -279,6 +281,36 @@ static int metricgroup__setup_events(struct list_head 
> *groups,
>   free(metric_events);
>   break;
>   }
> +
> + /*
> +  * Collect and store collected nested expressions
> +  * for metric processing.
> +  */
> + if (eg->metric_refs_cnt) {
> + struct metric_ref_node *ref;
> +
> + metric_refs = zalloc(sizeof(struct metric_ref) * 
> (eg->metric_refs_cnt + 1));
> + if (!metric_refs) {
> + ret = -ENOMEM;
> + free(metric_events);
> + break;
> + }
> +
> + i = 0;
> + list_for_each_entry(ref, >metric_refs, list) {
> + /*
> +  * Intentionally passing just const char 
> pointers,
> +  * originally from 'struct pmu_event' object.
> +  * We don't need to change them, so there's no
> +  * need to create our own copy.
> +  */
> + metric_refs[i].metric_name = ref->metric_name;
> + metric_refs[i].metric_expr = ref->metric_expr;
> + i++;
> + }
> + };
> +
> + expr->metric_refs = metric_refs;
>   expr->metric_expr = eg->metric_expr;
>   expr->metric_name = eg->metric_name;
>   expr->metric_unit = eg->metric_unit;
> diff --git a/tools/perf/util/metricgroup.h b/tools/perf/util/metricgroup.h
> index 8315bd1a7da4..62623a39cbec 100644
> --- a/tools/perf/util/metricgroup.h
> +++ b/tools/perf/util/metricgroup.h
> @@ -18,12 +18,18 @@ struct metric_event {
>   struct list_head head; /* list of metric_expr */
>  };
>  
> +struct metric_ref {
> + const char *metric_name;
> + const char *metric_expr;
> +};
> +
>  struct metric_expr {
>   struct list_head nd;
>   const char *metric_expr;
>   const char *metric_name;
>   const char *metric_unit;
>   struct evsel **metric_events;
> + struct metric_ref *metric_refs;
>   int runtime;
>  };
>  
> 


Re: [PATCH 05/19] perf metric: Add macros for iterating map events

2020-07-26 Thread kajoljain



On 7/19/20 11:43 PM, Jiri Olsa wrote:
> Adding following macros to iterate events and metric:
>   map_for_each_event(__pe, __idx, __map)
> - iterates over all pmu_events_map events
>   map_for_each_metric(__pe, __idx, __map, __metric)
> - iterates over all metrics that match __metric argument
> 
> and use it in metricgroup__add_metric function. Macros
> will be be used from other places in following changes.
> 
> Signed-off-by: Jiri Olsa 

Reviewed-By : Kajol Jain

Thanks,
Kajol Jain

> ---
>  tools/perf/util/metricgroup.c | 77 ++-
>  1 file changed, 40 insertions(+), 37 deletions(-)
> 
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index df0356ec120d..b37008fc253c 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -614,6 +614,17 @@ static int __metricgroup__add_metric(struct list_head 
> *group_list,
>   return 0;
>  }
>  
> +#define map_for_each_event(__pe, __idx, __map)   
> \
> + for (__idx = 0, __pe = &__map->table[__idx];\
> +  __pe->name || __pe->metric_group || __pe->metric_name; \
> +  __pe = &__map->table[++__idx])
> +
> +#define map_for_each_metric(__pe, __idx, __map, __metric)\
> + map_for_each_event(__pe, __idx, __map)  \
> + if (__pe->metric_expr &&\
> + (match_metric(__pe->metric_group, __metric) ||  \
> +  match_metric(__pe->metric_name, __metric)))
> +
>  static int metricgroup__add_metric(const char *metric, bool metric_no_group,
>  struct strbuf *events,
>  struct list_head *group_list,
> @@ -624,49 +635,41 @@ static int metricgroup__add_metric(const char *metric, 
> bool metric_no_group,
>   int i, ret;
>   bool has_match = false;
>  
> - for (i = 0; ; i++) {
> - pe = >table[i];
> -
> - if (!pe->name && !pe->metric_group && !pe->metric_name) {
> - /* End of pmu events. */
> - if (!has_match)
> - return -EINVAL;
> - break;
> - }
> - if (!pe->metric_expr)
> - continue;
> - if (match_metric(pe->metric_group, metric) ||
> - match_metric(pe->metric_name, metric)) {
> - has_match = true;
> - pr_debug("metric expr %s for %s\n", pe->metric_expr, 
> pe->metric_name);
> -
> - if (!strstr(pe->metric_expr, "?")) {
> - ret = __metricgroup__add_metric(group_list,
> - pe,
> - metric_no_group,
> - 1);
> - if (ret)
> - return ret;
> - } else {
> - int j, count;
> + map_for_each_metric(pe, i, map, metric) {
> + pr_debug("metric expr %s for %s\n", pe->metric_expr, 
> pe->metric_name);
> + has_match = true;
> +
> + if (!strstr(pe->metric_expr, "?")) {
> + ret = __metricgroup__add_metric(group_list,
> + pe,
> + metric_no_group,
> + 1);
> + if (ret)
> + return ret;
> + } else {
> + int j, count;
>  
> - count = arch_get_runtimeparam();
> + count = arch_get_runtimeparam();
>  
> - /* This loop is added to create multiple
> -  * events depend on count value and add
> -  * those events to group_list.
> -  */
> + /* This loop is added to create multiple
> +  * events depend on count value and add
> +  * those events to group_list.
> +  */
>  
> - for (j = 0; j < count; j++) {
> - ret = __metricgroup__add_metric(
> - group_list, pe,
> - metric_no_group, j);
> - if (ret)
> - return ret;
> - }
> + for (j = 0; j < count; j++) {
> + ret = __metricgroup__add_metric(
> + group_list, pe,
> + 

Re: [PATCH 04/19] perf metric: Add expr__del_id function

2020-07-26 Thread kajoljain



On 7/19/20 11:43 PM, Jiri Olsa wrote:
> Adding expr__del_id function to remove ID from hashmap.
> It will save us few lines in following changes.
> 
> Acked-by: Ian Rogers 
> Signed-off-by: Jiri Olsa 

Reviewed-By : Kajol Jain

Thanks,
Kajol Jain

> ---
>  tools/perf/util/expr.c | 21 +
>  tools/perf/util/expr.h |  1 +
>  2 files changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
> index 4e5a6533dfce..f726211f49d4 100644
> --- a/tools/perf/util/expr.c
> +++ b/tools/perf/util/expr.c
> @@ -79,6 +79,17 @@ int expr__get_id(struct expr_parse_ctx *ctx, const char 
> *id,
>   return hashmap__find(>ids, id, (void **)data) ? 0 : -1;
>  }
>  
> +void expr__del_id(struct expr_parse_ctx *ctx, const char *id)
> +{
> + struct expr_id_data *old_val = NULL;
> + char *old_key = NULL;
> +
> + hashmap__delete(>ids, id,
> + (const void **)_key, (void **)_val);
> + free(old_key);
> + free(old_val);
> +}
> +
>  void expr__ctx_init(struct expr_parse_ctx *ctx)
>  {
>   hashmap__init(>ids, key_hash, key_equal, NULL);
> @@ -136,16 +147,10 @@ int expr__parse(double *final_val, struct 
> expr_parse_ctx *ctx,
>  int expr__find_other(const char *expr, const char *one,
>struct expr_parse_ctx *ctx, int runtime)
>  {
> - struct expr_id_data *old_val = NULL;
> - char *old_key = NULL;
>   int ret = __expr__parse(NULL, ctx, expr, EXPR_OTHER, runtime);
>  
> - if (one) {
> - hashmap__delete(>ids, one,
> - (const void **)_key, (void **)_val);
> - free(old_key);
> - free(old_val);
> - }
> + if (one)
> + expr__del_id(ctx, one);
>  
>   return ret;
>  }
> diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h
> index f38292fdab19..2462abd0ac65 100644
> --- a/tools/perf/util/expr.h
> +++ b/tools/perf/util/expr.h
> @@ -26,6 +26,7 @@ struct expr_scanner_ctx {
>  
>  void expr__ctx_init(struct expr_parse_ctx *ctx);
>  void expr__ctx_clear(struct expr_parse_ctx *ctx);
> +void expr__del_id(struct expr_parse_ctx *ctx, const char *id);
>  int expr__add_id(struct expr_parse_ctx *ctx, const char *id);
>  int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double val);
>  int expr__get_id(struct expr_parse_ctx *ctx, const char *id,
> 


Re: [PATCH 02/19] perf metric: Add expr__add_id function

2020-07-26 Thread kajoljain



On 7/19/20 11:43 PM, Jiri Olsa wrote:
> Adding expr__add_id function to data for ID
> with zero value, which is used when scanning
> the expression for IDs.
> 

Reviewed-By : Kajol Jain

Thanks,
Kajol Jain

> Acked-by: Ian Rogers 
> Signed-off-by: Jiri Olsa 
> ---
>  tools/perf/util/expr.c | 31 +--
>  tools/perf/util/expr.h |  1 +
>  tools/perf/util/expr.y |  2 +-
>  3 files changed, 27 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
> index 578a173d4873..9228f60e2a20 100644
> --- a/tools/perf/util/expr.c
> +++ b/tools/perf/util/expr.c
> @@ -32,6 +32,26 @@ static bool key_equal(const void *key1, const void *key2,
>   return !strcmp((const char *)key1, (const char *)key2);
>  }
>  
> +/* Caller must make sure id is allocated */
> +int expr__add_id(struct expr_parse_ctx *ctx, const char *id)
> +{
> + struct expr_id_data *data_ptr = NULL, *old_data = NULL;
> + char *old_key = NULL;
> + int ret;
> +
> + data_ptr = malloc(sizeof(*data_ptr));
> + if (!data_ptr)
> + return -ENOMEM;
> +
> + ret = hashmap__set(>ids, id, data_ptr,
> +(const void **)_key, (void **)_data);
> + if (ret)
> + free(data_ptr);
> + free(old_key);
> + free(old_data);
> + return ret;
> +}
> +
>  /* Caller must make sure id is allocated */
>  int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double val)
>  {
> @@ -39,12 +59,11 @@ int expr__add_id_val(struct expr_parse_ctx *ctx, const 
> char *id, double val)
>   char *old_key = NULL;
>   int ret;
>  
> - if (val != 0.0) {
> - data_ptr = malloc(sizeof(*data_ptr));
> - if (!data_ptr)
> - return -ENOMEM;
> - data_ptr->val = val;
> - }
> + data_ptr = malloc(sizeof(*data_ptr));
> + if (!data_ptr)
> + return -ENOMEM;
> + data_ptr->val = val;
> +
>   ret = hashmap__set(>ids, id, data_ptr,
>  (const void **)_key, (void **)_data);
>   if (ret)
> diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h
> index 21fe5bd85718..ac32cda42006 100644
> --- a/tools/perf/util/expr.h
> +++ b/tools/perf/util/expr.h
> @@ -26,6 +26,7 @@ struct expr_scanner_ctx {
>  
>  void expr__ctx_init(struct expr_parse_ctx *ctx);
>  void expr__ctx_clear(struct expr_parse_ctx *ctx);
> +int expr__add_id(struct expr_parse_ctx *ctx, const char *id);
>  int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double val);
>  int expr__get_id(struct expr_parse_ctx *ctx, const char *id, double 
> *val_ptr);
>  int expr__parse(double *final_val, struct expr_parse_ctx *ctx,
> diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y
> index b2b3420ea6ec..8befe4a46f87 100644
> --- a/tools/perf/util/expr.y
> +++ b/tools/perf/util/expr.y
> @@ -69,7 +69,7 @@ all_other: all_other other
>  
>  other: ID
>  {
> - expr__add_id_val(ctx, $1, 0.0);
> + expr__add_id(ctx, $1);
>  }
>  |
>  MIN | MAX | IF | ELSE | SMT_ON | NUMBER | '|' | '^' | '&' | '-' | '+' | '*' 
> | '/' | '%' | '(' | ')' | ','
> 


Re: [PATCH 03/19] perf metric: Change expr__get_id to return struct expr_id_data

2020-07-26 Thread kajoljain



On 7/19/20 11:43 PM, Jiri Olsa wrote:
> Changing expr__get_id to use and return struct expr_id_data
> pointer as value for the ID. This way we can access data other
> than value for given ID in following changes.
> 
> Acked-by: Ian Rogers 
> Signed-off-by: Jiri Olsa 
> ---

Reviewed-By : Kajol Jain

Thanks,
Kajol Jain

>  tools/perf/util/expr.c | 10 +++---
>  tools/perf/util/expr.h |  3 ++-
>  tools/perf/util/expr.y | 14 +-
>  3 files changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
> index 9228f60e2a20..4e5a6533dfce 100644
> --- a/tools/perf/util/expr.c
> +++ b/tools/perf/util/expr.c
> @@ -73,14 +73,10 @@ int expr__add_id_val(struct expr_parse_ctx *ctx, const 
> char *id, double val)
>   return ret;
>  }
>  
> -int expr__get_id(struct expr_parse_ctx *ctx, const char *id, double *val_ptr)
> +int expr__get_id(struct expr_parse_ctx *ctx, const char *id,
> +  struct expr_id_data **data)
>  {
> - struct expr_id_data *data;
> -
> - if (!hashmap__find(>ids, id, (void **)))
> - return -1;
> - *val_ptr = (data == NULL) ?  0.0 : data->val;
> - return 0;
> + return hashmap__find(>ids, id, (void **)data) ? 0 : -1;
>  }
>  
>  void expr__ctx_init(struct expr_parse_ctx *ctx)
> diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h
> index ac32cda42006..f38292fdab19 100644
> --- a/tools/perf/util/expr.h
> +++ b/tools/perf/util/expr.h
> @@ -28,7 +28,8 @@ void expr__ctx_init(struct expr_parse_ctx *ctx);
>  void expr__ctx_clear(struct expr_parse_ctx *ctx);
>  int expr__add_id(struct expr_parse_ctx *ctx, const char *id);
>  int expr__add_id_val(struct expr_parse_ctx *ctx, const char *id, double val);
> -int expr__get_id(struct expr_parse_ctx *ctx, const char *id, double 
> *val_ptr);
> +int expr__get_id(struct expr_parse_ctx *ctx, const char *id,
> +  struct expr_id_data **data);
>  int expr__parse(double *final_val, struct expr_parse_ctx *ctx,
>   const char *expr, int runtime);
>  int expr__find_other(const char *expr, const char *one,
> diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y
> index 8befe4a46f87..0d4f5d324be7 100644
> --- a/tools/perf/util/expr.y
> +++ b/tools/perf/util/expr.y
> @@ -85,12 +85,16 @@ if_expr:
>   ;
>  
>  expr:  NUMBER
> - | ID{ if (expr__get_id(ctx, $1, &$$)) {
> - pr_debug("%s not found\n", $1);
> + | ID{
> + struct expr_id_data *data;
> +
> + if (expr__get_id(ctx, $1, ) || 
> !data) {
> + pr_debug("%s not found\n", $1);
> + free($1);
> + YYABORT;
> + }
> + $$ = data->val;
>   free($1);
> - YYABORT;
> -   }
> -   free($1);
>   }
>   | expr '|' expr { $$ = (long)$1 | (long)$3; }
>   | expr '&' expr { $$ = (long)$1 & (long)$3; }
> 


Re: [PATCH v6 07/13] gpio: add support for the sl28cpld GPIO controller

2020-07-26 Thread Andy Shevchenko
On Sun, Jul 26, 2020 at 01:18:28AM +0200, Michael Walle wrote:
> Add support for the GPIO controller of the sl28 board management
> controller. This driver is part of a multi-function device.
> 
> A controller has 8 lines. There are three different flavors:
> full-featured GPIO with interrupt support, input-only and output-only.

FWIW,
Reviewed-by: Andy Shevchenko 

> Signed-off-by: Michael Walle 
> Reviewed-by: Linus Walleij 
> ---
> Changes since v5:
>  - added "select REGMAP_IRQ"
> 
> Changes since v4:
>  - update copyright year
>  - remove #include , suggested by Andy.
>  - use device_get_match_data(), suggested by Andy.
>  - drop the irq_support variable, instead call _init_irq() directly,
>suggested by Andy.
>  - also move the irq code a bit around to make it look nicer
>  - drop "struct sl28cpld_gpio". We don't need to actually store the
>irq_chip and irq_chip_data, everything is device resource managed.
>  - use 100 chars line limit, suggested by Andy.
>  - remove the platform device table
>  - don't use KBUID_MODNAME
> 
> Changes since v3:
>  - see cover letter
> 
>  drivers/gpio/Kconfig |  12 +++
>  drivers/gpio/Makefile|   1 +
>  drivers/gpio/gpio-sl28cpld.c | 161 +++
>  3 files changed, 174 insertions(+)
>  create mode 100644 drivers/gpio/gpio-sl28cpld.c
> 
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index 8030fd91a3cc..f6a547b76432 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -1223,6 +1223,18 @@ config GPIO_RC5T583
> This driver provides the support for driving/reading the gpio pins
> of RC5T583 device through standard gpio library.
>  
> +config GPIO_SL28CPLD
> + tristate "Kontron sl28cpld GPIO support"
> + select MFD_SIMPLE_MFD_I2C
> + select GPIO_REGMAP
> + select GPIOLIB_IRQCHIP
> + select REGMAP_IRQ
> + help
> +   This enables support for the GPIOs found on the Kontron sl28 CPLD.
> +
> +   This driver can also be built as a module. If so, the module will be
> +   called gpio-sl28cpld.
> +
>  config GPIO_STMPE
>   bool "STMPE GPIOs"
>   depends on MFD_STMPE
> diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
> index 4f9abff4f2dc..c3a4e7c94a91 100644
> --- a/drivers/gpio/Makefile
> +++ b/drivers/gpio/Makefile
> @@ -132,6 +132,7 @@ obj-$(CONFIG_GPIO_SCH311X)+= 
> gpio-sch311x.o
>  obj-$(CONFIG_GPIO_SCH)   += gpio-sch.o
>  obj-$(CONFIG_GPIO_SIFIVE)+= gpio-sifive.o
>  obj-$(CONFIG_GPIO_SIOX)  += gpio-siox.o
> +obj-$(CONFIG_GPIO_SL28CPLD)  += gpio-sl28cpld.o
>  obj-$(CONFIG_GPIO_SODAVILLE) += gpio-sodaville.o
>  obj-$(CONFIG_GPIO_SPEAR_SPICS)   += gpio-spear-spics.o
>  obj-$(CONFIG_GPIO_SPRD)  += gpio-sprd.o
> diff --git a/drivers/gpio/gpio-sl28cpld.c b/drivers/gpio/gpio-sl28cpld.c
> new file mode 100644
> index ..889b8f5622c2
> --- /dev/null
> +++ b/drivers/gpio/gpio-sl28cpld.c
> @@ -0,0 +1,161 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * sl28cpld GPIO driver
> + *
> + * Copyright 2020 Michael Walle 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/* GPIO flavor */
> +#define GPIO_REG_DIR 0x00
> +#define GPIO_REG_OUT 0x01
> +#define GPIO_REG_IN  0x02
> +#define GPIO_REG_IE  0x03
> +#define GPIO_REG_IP  0x04
> +
> +/* input-only flavor */
> +#define GPI_REG_IN   0x00
> +
> +/* output-only flavor */
> +#define GPO_REG_OUT  0x00
> +
> +enum sl28cpld_gpio_type {
> + SL28CPLD_GPIO = 1,
> + SL28CPLD_GPI,
> + SL28CPLD_GPO,
> +};
> +
> +static const struct regmap_irq sl28cpld_gpio_irqs[] = {
> + REGMAP_IRQ_REG_LINE(0, 8),
> + REGMAP_IRQ_REG_LINE(1, 8),
> + REGMAP_IRQ_REG_LINE(2, 8),
> + REGMAP_IRQ_REG_LINE(3, 8),
> + REGMAP_IRQ_REG_LINE(4, 8),
> + REGMAP_IRQ_REG_LINE(5, 8),
> + REGMAP_IRQ_REG_LINE(6, 8),
> + REGMAP_IRQ_REG_LINE(7, 8),
> +};
> +
> +static int sl28cpld_gpio_irq_init(struct platform_device *pdev,
> +   unsigned int base,
> +   struct gpio_regmap_config *config)
> +{
> + struct regmap_irq_chip_data *irq_data;
> + struct regmap_irq_chip *irq_chip;
> + struct device *dev = >dev;
> + int irq, ret;
> +
> + if (!device_property_read_bool(dev, "interrupt-controller"))
> + return 0;
> +
> + irq = platform_get_irq(pdev, 0);
> + if (irq < 0)
> + return irq;
> +
> + irq_chip = devm_kzalloc(dev, sizeof(*irq_chip), GFP_KERNEL);
> + if (!irq_chip)
> + return -ENOMEM;
> +
> + irq_chip->name = "sl28cpld-gpio-irq",
> + irq_chip->irqs = sl28cpld_gpio_irqs;
> + irq_chip->num_irqs = ARRAY_SIZE(sl28cpld_gpio_irqs);
> + irq_chip->num_regs = 1;
> + irq_chip->status_base = base + GPIO_REG_IP;
> + irq_chip->mask_base = base + 

[PATCH v3 4/4] staging: media: atomisp: fix line length exceeds

2020-07-26 Thread Rohit K Bharadwaj
this patch fixes the line length exceeded error from checkpatch.pl

Signed-off-by: Rohit K Bharadwaj 
---
v3: change patch subject prefix
v2: split patch into sequence of patches 
v1: fix all coding style issues in single patch

 drivers/staging/media/atomisp/pci/sh_css_firmware.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
index 2208453cbef0..6e8f45e38804 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
@@ -243,7 +243,8 @@ sh_css_load_firmware(struct device *dev, const char 
*fw_data,
firmware_header = (struct firmware_header *)fw_data;
file_header = _header->file_header;
binaries = _header->binary_header;
-   strscpy(FW_rel_ver_name, file_header->version, 
min(sizeof(FW_rel_ver_name), sizeof(file_header->version)));
+   strscpy(FW_rel_ver_name, file_header->version,
+   min(sizeof(FW_rel_ver_name), sizeof(file_header->version)));
ret = sh_css_check_firmware_version(dev, fw_data);
if (ret) {
IA_CSS_ERROR("CSS code version (%s) and firmware version (%s) 
mismatch!",
-- 
2.25.1



Re: [PATCHv3 00/19] perf metric: Add support to reuse metric

2020-07-26 Thread kajoljain



On 7/25/20 5:21 PM, Jiri Olsa wrote:
> On Fri, Jul 24, 2020 at 11:22:28AM +0530, kajoljain wrote:
> 
> SNIP
> 
>>
>> Hi Jiri,
>>The change looks good to me. I tried with adding this patch on top of 
>> your perf/metric branch. It did resolve the issue of not printing
>> all chips data. And now I can see proper values for hv-24x7 metric events.
>>
>> I was also trying by adding new metric using the feature added in this 
>> patchset with something like this:
>>
>> diff --git a/tools/perf/pmu-events/arch/powerpc/power9/nest_metrics.json 
>> b/tools/perf/pmu-events/arch/powerpc/power9/nest_metrics.json
>> index 8383a37647ad..dfe4bd63b587 100644
>> --- a/tools/perf/pmu-events/arch/powerpc/power9/nest_metrics.json
>> +++ b/tools/perf/pmu-events/arch/powerpc/power9/nest_metrics.json
>> @@ -16,6 +16,11 @@
>>  "MetricName": "PowerBUS_Frequency",
>>  "ScaleUnit": "2.5e-7GHz"
>>  },
>> +{
>> +   "MetricExpr": "Memory_WR_BW_Chip + Memory_RD_BW_Chip",
>> +"MetricName": "Total_Memory_BW",
>> +"ScaleUnit": "1.6e-2MB"
>> +},
> 
> hum, we'll need special case this.. because Memory_WR_BW_Chip will
> unwind to Memory_WR_BW_Chip_[01] and Total_Memory_BW is not aware of
> that.. what's the expected behaviour in here?
> 
> have Total_Memory_BW_[01] for each runtime arg?

Hi Jiri,
Yes right. So we want Total_Memory_BW to show sum results of both chip 0 
and 1 seperately, which is missing here.
> 
> I think this will need to come on top of this changes,
> it's already too big
> 

Yes make sense. We can send separate patches on top of this patch set for this 
use case. 

Other then that the whole patchset looks good to me with the change to rectify 
Paul A. Clarke concern.

Tested/Reviewed-By : Kajol Jain

Thanks,
Kajol Jain
> thanks,
> jirka
> 
>>
>> I guess as we have dependency on '?' symbol, I am not able to see all chips 
>> data for Total_Memory_BW.
>> I am not sure if Its expected behavior?
>>
>> This is what I am getting:
>>
>> [root@ltc-zz189-lp4 perf]# ./perf stat --metric-only -M 
>> Total_Memory_BW,Memory_WR_BW_Chip,Memory_RD_BW_Chip -I 1000 -C 0
>> #   time  MB  Total_Memory_BW MB  Memory_RD_BW_Chip_1 MB  
>> Memory_WR_BW_Chip_1 MB  Memory_WR_BW_Chip_0 MB  Memory_RD_BW_Chip_0 
>>  1.67388 36.4  0.2   
>>   36.3 65.0 72.1 
>>  2.000374276 36.2  0.3   
>>   35.9 65.4 77.9 
>>  3.000543202 36.3  0.3   
>>   36.0 68.7 81.2 
>>  4.000702855 36.3  0.3   
>>   36.0 70.9 93.3 
>>  5.000856837 36.0  0.2   
>>   35.8 67.4 81.5 
>> ^C 5.367865273 13.2  0.1 
>> 13.1 23.5 28.3 
>>  Performance counter stats for 'CPU(s) 0':
>>194.4  1.3193.1   
>>  361.0434.3 
>>5.368039176 seconds time elapsed
>>
>> We can only get single chip data's sum in Total_Memory_BW. Please let me 
>> know if I am missing something.
> 
> SNIP
> 


[PATCH v3 3/4] staging: media: atomisp: fix trailing statement of if

2020-07-26 Thread Rohit K Bharadwaj
this patch fixes the error from checkpatch.pl which says that trailing 
statements after if keyword to be on next line

Signed-off-by: Rohit K Bharadwaj 
---
v3: change patch subject prefix
v2: split patch into sequence of patches 
v1: fix all coding style issues in single patch

 drivers/staging/media/atomisp/pci/sh_css_firmware.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
index 988785ab6c95..2208453cbef0 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
@@ -115,7 +115,8 @@ sh_css_load_blob_info(const char *fw, const struct 
ia_css_fw_info *bi,
return -EINVAL;
 
/* Special case: only one binary in fw */
-   if (!bi) bi = (const struct ia_css_fw_info *)fw;
+   if (!bi)
+   bi = (const struct ia_css_fw_info *)fw;
 
name = fw + bi->blob.prog_name_offset;
blob = (const unsigned char *)fw + bi->blob.offset;
-- 
2.25.1



Re: [PATCH RFC 2/6] pwm: core: Add option to config PWM duty/period with u64 data length

2020-07-26 Thread Martin Botka
> And all divisions go mad on 32-bit CPU, right?
> Please, if you thought about it carefully, update a commit message to
> clarify that.

Hello,
This patch will be dropped in V2 since another series already made these u64.
See a9d887dc1c60ed67f2271d66560cdcf864c4a578 in linux-next.
I have not tested compiling that commit in linux-next on 32 bit arch
but if it fails i can replace this commit with fix for that.

Also  I'm not the author of this commit.
Konrad Dybcio fast forwarded it to 5.8 from 4.14.
Fenglin Wu is the author and also created that commit message.

Thank you.

Best regards
Martin


Re: [PATCH v3 1/4] staging: media: atomisp: fix style of block comments

2020-07-26 Thread Greg KH
On Sun, Jul 26, 2020 at 02:35:10PM +0530, Rohit K Bharadwaj wrote:
> this patch fixes the coding style of block comments.
> 
> Signed-off-by: Rohit K Bharadwaj 
> ---
> v3: change patch subject prefix
> v2: split patch into sequence of patches 
> v1: fix all coding style issues in single patch
> 
>  .../media/atomisp/pci/sh_css_firmware.c   | 28 +--
>  1 file changed, 19 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c 
> b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
> index d4ab15b6d1ac..2907aead98b7 100644
> --- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c
> +++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
> @@ -51,9 +51,12 @@ struct fw_param {
>  
>  static struct firmware_header *firmware_header;
>  
> -/* The string STR is a place holder
> +/*
> + * The string STR is a place holder
>   * which will be replaced with the actual RELEASE_VERSION
> - * during package generation. Please do not modify  */
> + * during package generation. Please do not modify
> + */
> +

Why the blank line?


Re: [PATCH v1 0/5] irqdomain: clean up, add irq_domain_create_legacy()

2020-07-26 Thread Andy Shevchenko
On Wed, Jul 08, 2020 at 07:21:30PM +0300, Andy Shevchenko wrote:
> In order to make users OF independent provide irq_domain_create_legacy() API.
> Last patch is an example of such user. First three patches are little 
> cleanups.
> 
> Since regmap patch is dependent to what is now in regmap tree, I suggest to
> create an immutable branch in IRQ domain tree and Mark can pull it and apply
> the last one.

Marc, are you okay with the IRQ domain patches?

> Andy Shevchenko (5):
>   irqdomain: Remove unused of_device_id forward declaration
>   irqdomain: Add forward declaration of fwnode_handle
>   irqdomain: Replace open coded of_node_to_fwnode()
>   irqdomain: Introduce irq_domain_create_legacy() API
>   regmap: irq: Convert to use fwnode directly
> 
>  Documentation/core-api/irq/irq-domain.rst |  6 ++
>  drivers/base/regmap/regmap-irq.c  | 11 +--
>  include/linux/irqdomain.h |  8 +++-
>  kernel/irq/irqdomain.c| 19 +++
>  4 files changed, 33 insertions(+), 11 deletions(-)
> 
> -- 
> 2.27.0
> 

-- 
With Best Regards,
Andy Shevchenko




[PATCH] iomap: Ensure iop->uptodate matches PageUptodate

2020-07-26 Thread Matthew Wilcox (Oracle)
If the filesystem has block size < page size and we end up calling
iomap_page_create() in iomap_page_mkwrite_actor(), the uptodate bits
would be zero, which causes us to skip writeback of blocks which are
!uptodate in iomap_writepage_map().  This can lead to user data loss.

Found using generic/127 with the THP patches.  I don't think this can be
reproduced on mainline using that test (the THP code causes iomap_pages
to be discarded more frequently), but inspection shows it can happen
with an appropriate series of operations.

Fixes: 9dc55f1389f9 ("iomap: add support for sub-pagesize buffered I/O without 
buffer heads")
Signed-off-by: Matthew Wilcox (Oracle) 
---
 fs/iomap/buffered-io.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index a2b3b5455219..f0c5027bf33f 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -53,7 +53,10 @@ iomap_page_create(struct inode *inode, struct page *page)
atomic_set(>read_count, 0);
atomic_set(>write_count, 0);
spin_lock_init(>uptodate_lock);
-   bitmap_zero(iop->uptodate, PAGE_SIZE / SECTOR_SIZE);
+   if (PageUptodate(page))
+   bitmap_fill(iop->uptodate, PAGE_SIZE / SECTOR_SIZE);
+   else
+   bitmap_zero(iop->uptodate, PAGE_SIZE / SECTOR_SIZE);
 
/*
 * migrate_page_move_mapping() assumes that pages with private data have
@@ -72,6 +75,8 @@ iomap_page_release(struct page *page)
return;
WARN_ON_ONCE(atomic_read(>read_count));
WARN_ON_ONCE(atomic_read(>write_count));
+   WARN_ON_ONCE(bitmap_full(iop->uptodate, PAGE_SIZE / SECTOR_SIZE) !=
+   PageUptodate(page));
kfree(iop);
 }
 
-- 
2.27.0



[PATCH v3 2/4] staging: media: atomisp: fix style of open brace

2020-07-26 Thread Rohit K Bharadwaj
this patch fixes style of open brace after functions and if statements

Signed-off-by: Rohit K Bharadwaj 
---
v3: change patch subject prefix
v2: split patch into sequence of patches 
v1: fix all coding style issues in single patch

 .../media/atomisp/pci/sh_css_firmware.c   | 29 +--
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
index 2907aead98b7..988785ab6c95 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
@@ -81,7 +81,8 @@ char *sh_css_get_fw_version(void)
 /* Setup sp/sp1 binary */
 static int
 setup_binary(struct ia_css_fw_info *fw, const char *fw_data,
-struct ia_css_fw_info *sh_css_fw, unsigned int binary_id) {
+struct ia_css_fw_info *sh_css_fw, unsigned int binary_id)
+{
const char *blob_data;
 
if ((!fw) || (!fw_data))
@@ -105,7 +106,8 @@ setup_binary(struct ia_css_fw_info *fw, const char *fw_data,
 int
 sh_css_load_blob_info(const char *fw, const struct ia_css_fw_info *bi,
  struct ia_css_blob_descr *bd,
- unsigned int index) {
+ unsigned int index)
+{
const char *name;
const unsigned char *blob;
 
@@ -119,8 +121,9 @@ sh_css_load_blob_info(const char *fw, const struct 
ia_css_fw_info *bi,
blob = (const unsigned char *)fw + bi->blob.offset;
 
/* sanity check */
-   if (bi->blob.size != bi->blob.text_size + bi->blob.icache_size + 
bi->blob.data_size + bi->blob.padding_size)
-   {
+   if (bi->blob.size !=
+   bi->blob.text_size + bi->blob.icache_size +
+   bi->blob.data_size + bi->blob.padding_size) {
/* sanity check, note the padding bytes added for section to 
DDR alignment */
return -EINVAL;
}
@@ -131,21 +134,18 @@ sh_css_load_blob_info(const char *fw, const struct 
ia_css_fw_info *bi,
bd->blob = blob;
bd->header = *bi;
 
-   if (bi->type == ia_css_isp_firmware || bi->type == ia_css_sp_firmware)
-   {
+   if (bi->type == ia_css_isp_firmware || bi->type == ia_css_sp_firmware) {
char *namebuffer;
 
namebuffer = kstrdup(name, GFP_KERNEL);
if (!namebuffer)
return -ENOMEM;
bd->name = fw_minibuffer[index].name = namebuffer;
-   } else
-   {
+   } else {
bd->name = name;
}
 
-   if (bi->type == ia_css_isp_firmware)
-   {
+   if (bi->type == ia_css_isp_firmware) {
size_t paramstruct_size = sizeof(struct ia_css_memory_offsets);
size_t configstruct_size = sizeof(struct 
ia_css_config_memory_offsets);
size_t statestruct_size = sizeof(struct 
ia_css_state_memory_offsets);
@@ -226,7 +226,8 @@ static const char * const fw_acc_type_name[] = {
 
 int
 sh_css_load_firmware(struct device *dev, const char *fw_data,
-unsigned int fw_size) {
+unsigned int fw_size)
+{
unsigned int i;
struct ia_css_fw_info *binaries;
struct sh_css_fw_bi_file_h *file_header;
@@ -260,8 +261,7 @@ sh_css_load_firmware(struct device *dev, const char 
*fw_data,
 
sh_css_num_binaries = file_header->binary_nr;
/* Only allocate memory for ISP blob info */
-   if (sh_css_num_binaries > NUM_OF_SPS)
-   {
+   if (sh_css_num_binaries > NUM_OF_SPS) {
sh_css_blob_info = kmalloc(
(sh_css_num_binaries - NUM_OF_SPS) *
sizeof(*sh_css_blob_info), GFP_KERNEL);
@@ -276,8 +276,7 @@ sh_css_load_firmware(struct device *dev, const char 
*fw_data,
if (!fw_minibuffer)
return -ENOMEM;
 
-   for (i = 0; i < sh_css_num_binaries; i++)
-   {
+   for (i = 0; i < sh_css_num_binaries; i++) {
struct ia_css_fw_info *bi = [i];
/*
 * note: the var below is made static as it is quite large;
-- 
2.25.1



[PATCH v3 1/4] staging: media: atomisp: fix style of block comments

2020-07-26 Thread Rohit K Bharadwaj
this patch fixes the coding style of block comments.

Signed-off-by: Rohit K Bharadwaj 
---
v3: change patch subject prefix
v2: split patch into sequence of patches 
v1: fix all coding style issues in single patch

 .../media/atomisp/pci/sh_css_firmware.c   | 28 +--
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
index d4ab15b6d1ac..2907aead98b7 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
@@ -51,9 +51,12 @@ struct fw_param {
 
 static struct firmware_header *firmware_header;
 
-/* The string STR is a place holder
+/*
+ * The string STR is a place holder
  * which will be replaced with the actual RELEASE_VERSION
- * during package generation. Please do not modify  */
+ * during package generation. Please do not modify
+ */
+
 static const char *isp2400_release_version = 
STR(irci_stable_candrpv_0415_20150521_0458);
 static const char *isp2401_release_version = STR(irci_ecr - 
master_20150911_0724);
 
@@ -276,10 +279,11 @@ sh_css_load_firmware(struct device *dev, const char 
*fw_data,
for (i = 0; i < sh_css_num_binaries; i++)
{
struct ia_css_fw_info *bi = [i];
-   /* note: the var below is made static as it is quite large;
-  if it is not static it ends up on the stack which could
-  cause issues for drivers
-   */
+   /*
+* note: the var below is made static as it is quite large;
+* if it is not static it ends up on the stack which could
+* cause issues for drivers
+*/
static struct ia_css_blob_descr bd;
int err;
 
@@ -333,7 +337,11 @@ sh_css_load_firmware(struct device *dev, const char 
*fw_data,
return err;
 
} else {
-   /* All subsequent binaries (including bootloaders) 
(i>NUM_OF_SPS) are ISP firmware */
+   /*
+* All subsequent binaries
+* (including bootloaders) (i>NUM_OF_SPS)
+* are ISP firmware
+*/
if (i < NUM_OF_SPS)
return -EINVAL;
 
@@ -374,8 +382,10 @@ ia_css_ptr
 sh_css_load_blob(const unsigned char *blob, unsigned int size)
 {
ia_css_ptr target_addr = hmm_alloc(size, HMM_BO_PRIVATE, 0, NULL, 0);
-   /* this will allocate memory aligned to a DDR word boundary which
-  is required for the CSS DMA to read the instructions. */
+   /*
+* this will allocate memory aligned to a DDR word boundary which
+* is required for the CSS DMA to read the instructions.
+*/
 
assert(blob);
if (target_addr)
-- 
2.25.1



Re: [PATCH] fork: fix pid refcount leaks when destroying file

2020-07-26 Thread Christian Brauner
On Sun, Jul 26, 2020 at 12:49:59PM +0800, Xin Xiong wrote:
> When clone_flags & CLONE_PIDFD is true,the function creates a new file
> object called pidfile,and invokes get_pid(),which increases the refcnt
> of pid for pidfile to hold.
> 
> The reference counting issues take place in the error handling paths.
> When error occurs after the construction of pidfile, the function only
> invokes fput() to destroy pidfile, in which the increased refcount
> won't be decreased, resulting in a refcount leak.
> 
> Fix this issue by adding put_pid() in the error handling path
> bad_fork_put_pidfd.
> 
> Signed-off-by: Xiyu Yang 
> Signed-off-by: Xin Tan 
> Signed-off-by: Xin Xiong 
> ---
>  kernel/fork.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 142b23645d82..7cbfb2c4fce3 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -2319,6 +2319,7 @@ static __latent_entropy struct task_struct 
> *copy_process(
>  bad_fork_put_pidfd:
>   if (clone_flags & CLONE_PIDFD) {
>   fput(pidfile);
> + put_pid(pid);
>   put_unused_fd(pidfd);

Thanks for the patch but this is actually wrong. If you look further up
where pidfile is allocated you'll see the comment

get_pid(pid);   /* held by pidfile now */

which I added to inidicate that the additional reference to struct pid
has now been transferred to the pidfile and is released when the file is
released. So the last fput(pidfile) will cause the vfs to call the
files' ->release() method which in this case is

static int pidfd_release(struct inode *inode, struct file *file)
{
struct pid *pid = file->private_data;

file->private_data = NULL;
put_pid(pid);
return 0;
}

Since fput(pidfile) in the bad_fork_put_pidfd error path is the only
reference to the pidfile the struct pid reference count will be
decremented.

Your additional put_pid() will cause a UAF which you should've seen
during testing if you injected an error by setting CLONE_PIDFD e.g. by
providing NULL as the args->pidfd argument to clone3() or NULL to the
parent_tidptr argument of clone() or by placing the parent into a cgroup
whos current pid_max limit doesn't allow it to fork.

Thanks!
Christian


[PATCH] ASoC: SOF: imx: use resource_size

2020-07-26 Thread Julia Lawall
Use resource_size rather than a verbose computation on
the end and start fields.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)


@@ struct resource ptr; @@
- (ptr.end - ptr.start + 1)
+ resource_size()


Signed-off-by: Julia Lawall 

---
 sound/soc/sof/imx/imx8m.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -u -p a/sound/soc/sof/imx/imx8m.c b/sound/soc/sof/imx/imx8m.c
--- a/sound/soc/sof/imx/imx8m.c
+++ b/sound/soc/sof/imx/imx8m.c
@@ -188,8 +188,7 @@ static int imx8m_probe(struct snd_sof_de
}
 
sdev->bar[SOF_FW_BLK_TYPE_SRAM] = devm_ioremap_wc(sdev->dev, res.start,
- res.end - res.start +
- 1);
+ resource_size());
if (!sdev->bar[SOF_FW_BLK_TYPE_SRAM]) {
dev_err(sdev->dev, "failed to ioremap mem 0x%x size 0x%x\n",
base, size);



Re: [PATCH RFC 2/6] pwm: core: Add option to config PWM duty/period with u64 data length

2020-07-26 Thread Andy Shevchenko
On Sat, Jul 25, 2020 at 12:40 AM Martin Botka  wrote:
>
> From: Fenglin Wu 
>
> Currently, PWM core driver provides interfaces for configuring PWM
> period and duty length in nanoseconds with an integer data type, so
> the max period can be only set to ~2.147 seconds. Add interfaces which
> can set PWM period and duty with u64 data type to remove this
> limitation.

And all divisions go mad on 32-bit CPU, right?
Please, if you thought about it carefully, update a commit message to
clarify that.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 09/14] bdi: remove BDI_CAP_CGROUP_WRITEBACK

2020-07-26 Thread Wols Lists
On 22/07/20 08:45, Johannes Thumshirn wrote:
> On 22/07/2020 08:27, Christoph Hellwig wrote:
>> it is know to support cgroup writeback, or the bdi comes from the block
> knwon  ~^
> 
Whoops - "known"

> Apart from that,
> Reviewed-by: Johannes Thumshirn 
> 
Cheers,
Wol


Re: [PATCH] io: Fix return type of _inb and _inl

2020-07-26 Thread Andy Shevchenko
On Sun, Jul 26, 2020 at 6:14 AM Stafford Horne  wrote:
>
> The return type of functions _inb, _inw and _inl are all u16 which looks
> wrong.  This patch makes them u8, u16 and u32 respectively.
>
> The original commit text for these does not indicate that these should
> be all forced to u16.

Is it in alight with all architectures? that support this interface natively?

(Return value is arch-dependent AFAIU, so it might actually return
16-bit for byte read, but I agree that this is weird for 32-bit value.
I think you have elaborate more in the commit message)

-- 
With Best Regards,
Andy Shevchenko


Re: [RFC 0/7] Add support to process rx packets in thread

2020-07-26 Thread Felix Fietkau
On 2020-07-26 10:32, Hillf Danton wrote:
> 
> On Sun, 26 Jul 2020 10:10:15 +0200 Felix Fietkau wrote:
>> On 2020-07-26 03:22, Hillf Danton wrote:
>> > 
>> > Feel free to do that. Is it likely for me to select a Cc?
>> > 
>> Shall I use Signed-off-by: Hillf Danton ?
> 
> s/Signed-off-by/Cc/
> 
>> What Cc do you want me to add?
> 
> I prefer Cc over other tags.
Ah, okay. I was planning on adding you as the author of the patch, since
you did most of the work on it. If you want to be attributed as author
(or in Co-developed-by), I'd need your Signed-off-by.

If you don't want that, I can submit it under my name and leave you in
as Cc only.

- Felix


Re: [PATCH] [video/fbdev] fb_flashcursor: Remove redundant null check

2020-07-26 Thread Andy Shevchenko
On Sun, Jul 26, 2020 at 8:17 AM Gaurav Singh  wrote:
>
> ops cannot be NULL as its being accessed later without

it's

> checks. Remove the redundant NULL check.

Commit message doesn't clarify why your fix is the correct one.
Maybe it's the other way around, missed check in the rest of the code there?

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v2 1/4] fix style of block comments

2020-07-26 Thread Rohit K Bharadwaj
On 26/07/20 2:18 pm, Rohit K Bharadwaj wrote:
> this patch fixes the coding style of block comments.
> 
> Signed-off-by: Rohit K Bharadwaj 
> ---
> v2: split patch into sequence of patches 
> v1: fix all coding style issues in single patch
> 
>  .../media/atomisp/pci/sh_css_firmware.c   | 28 +--
>  1 file changed, 19 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c 
> b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
> index d4ab15b6d1ac..2907aead98b7 100644
> --- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c
> +++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
> @@ -51,9 +51,12 @@ struct fw_param {
>  
>  static struct firmware_header *firmware_header;
>  
> -/* The string STR is a place holder
> +/*
> + * The string STR is a place holder
>   * which will be replaced with the actual RELEASE_VERSION
> - * during package generation. Please do not modify  */
> + * during package generation. Please do not modify
> + */
> +
>  static const char *isp2400_release_version = 
> STR(irci_stable_candrpv_0415_20150521_0458);
>  static const char *isp2401_release_version = STR(irci_ecr - 
> master_20150911_0724);
>  
> @@ -276,10 +279,11 @@ sh_css_load_firmware(struct device *dev, const char 
> *fw_data,
>   for (i = 0; i < sh_css_num_binaries; i++)
>   {
>   struct ia_css_fw_info *bi = [i];
> - /* note: the var below is made static as it is quite large;
> -if it is not static it ends up on the stack which could
> -cause issues for drivers
> - */
> + /*
> +  * note: the var below is made static as it is quite large;
> +  * if it is not static it ends up on the stack which could
> +  * cause issues for drivers
> +  */
>   static struct ia_css_blob_descr bd;
>   int err;
>  
> @@ -333,7 +337,11 @@ sh_css_load_firmware(struct device *dev, const char 
> *fw_data,
>   return err;
>  
>   } else {
> - /* All subsequent binaries (including bootloaders) 
> (i>NUM_OF_SPS) are ISP firmware */
> + /*
> +  * All subsequent binaries
> +  * (including bootloaders) (i>NUM_OF_SPS)
> +  * are ISP firmware
> +  */
>   if (i < NUM_OF_SPS)
>   return -EINVAL;
>  
> @@ -374,8 +382,10 @@ ia_css_ptr
>  sh_css_load_blob(const unsigned char *blob, unsigned int size)
>  {
>   ia_css_ptr target_addr = hmm_alloc(size, HMM_BO_PRIVATE, 0, NULL, 0);
> - /* this will allocate memory aligned to a DDR word boundary which
> -is required for the CSS DMA to read the instructions. */
> + /*
> +  * this will allocate memory aligned to a DDR word boundary which
> +  * is required for the CSS DMA to read the instructions.
> +  */
>  
>   assert(blob);
>   if (target_addr)
> 
I'm really sorry for the spam, please excuse me, I realized that I didn't 
change the subject prefix so will send another version, apologies for any 
inconvenience caused.


Re: [PATCH] [video/fbdev] mbxfb_remove: fix null pointer dereference

2020-07-26 Thread Andy Shevchenko
On Sun, Jul 26, 2020 at 8:26 AM Gaurav Singh  wrote:
>
> Function mbxfb_debugfs_remove() accesses fbi->par without NULL check,
> hence do the NULL check in the caller mbxfb_remove().

...

> @@ -1012,11 +1012,10 @@ static int mbxfb_remove(struct platform_device *dev)
>
> write_reg_dly(SYSRST_RST, SYSRST);
>
> -   mbxfb_debugfs_remove(fbi);
> -

> if (fbi) {

Can you explain how this is NULL on ->remove()?

I bet this check is simply redundant. But you have to check and update
commit message accordingly.

> struct mbxfb_info *mfbi = fbi->par;
>
> +   mbxfb_debugfs_remove(fbi);
> unregister_framebuffer(fbi);
> if (mfbi) {
> if (mfbi->platform_remove)


-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] tty: fix pid refcount leak in tty_signal_session_leader

2020-07-26 Thread Andy Shevchenko
On Sun, Jul 26, 2020 at 8:30 AM Xin Xiong  wrote:
>
> In the loop, every time when p->signal->leader is true, the function
> tty_signal_session_leader() will invoke get_pid() and return a
> reference of tty->pgrp with increased refcount to the local variable
> tty_pgrp or return NULL if it fails. After finishing the loop, the
> function invokes put_pid() for only once, decreasing the refcount that
> tty_pgrp keeps.
>
> Refcount leaks may occur when the scenario that p->signal->leader is
> true happens more than once. In this assumption, if the above scenario
> happens n times in the loop, the function forgets to decrease the
> refcount for n-1 times, which causes refcount leaks.
>
> Fix the issue by decreasing the current refcount of the local variable
> tty_pgrp before assigning new objects to it.
>
> Signed-off-by: Xiyu Yang 
> Signed-off-by: Xin Tan 
> Signed-off-by: Xin Xiong 

This SoB chain is out of order. If you are the author, your SoB should
go first, if you are a commiter, the From line should correspond to
the first SoB (not yours), if it's a group of authors (funny for
one-/twoliner) then you consider to use Co-developed-by. Please, read
Submitting Patches document.

...

> put_pid(p->signal->tty_old_pgrp);  /* A noop */
> spin_lock(>ctrl_lock);
> +   if (tty_pgrp)
> +   put_pid(tty_pgrp);
> tty_pgrp = get_pid(tty->pgrp);
> if (tty->pgrp)
> p->signal->tty_old_pgrp = get_pid(tty->pgrp);

I guess this patch wasn't thought thru. You see the get_pid for it
happens twice in a row. Perhaps you have to get the logic behind all
these first?

P.S. ...on top of what Greg said.

-- 
With Best Regards,
Andy Shevchenko


[PATCH v2 1/4] fix style of block comments

2020-07-26 Thread Rohit K Bharadwaj
this patch fixes the coding style of block comments.

Signed-off-by: Rohit K Bharadwaj 
---
v2: split patch into sequence of patches 
v1: fix all coding style issues in single patch

 .../media/atomisp/pci/sh_css_firmware.c   | 28 +--
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
index d4ab15b6d1ac..2907aead98b7 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
@@ -51,9 +51,12 @@ struct fw_param {
 
 static struct firmware_header *firmware_header;
 
-/* The string STR is a place holder
+/*
+ * The string STR is a place holder
  * which will be replaced with the actual RELEASE_VERSION
- * during package generation. Please do not modify  */
+ * during package generation. Please do not modify
+ */
+
 static const char *isp2400_release_version = 
STR(irci_stable_candrpv_0415_20150521_0458);
 static const char *isp2401_release_version = STR(irci_ecr - 
master_20150911_0724);
 
@@ -276,10 +279,11 @@ sh_css_load_firmware(struct device *dev, const char 
*fw_data,
for (i = 0; i < sh_css_num_binaries; i++)
{
struct ia_css_fw_info *bi = [i];
-   /* note: the var below is made static as it is quite large;
-  if it is not static it ends up on the stack which could
-  cause issues for drivers
-   */
+   /*
+* note: the var below is made static as it is quite large;
+* if it is not static it ends up on the stack which could
+* cause issues for drivers
+*/
static struct ia_css_blob_descr bd;
int err;
 
@@ -333,7 +337,11 @@ sh_css_load_firmware(struct device *dev, const char 
*fw_data,
return err;
 
} else {
-   /* All subsequent binaries (including bootloaders) 
(i>NUM_OF_SPS) are ISP firmware */
+   /*
+* All subsequent binaries
+* (including bootloaders) (i>NUM_OF_SPS)
+* are ISP firmware
+*/
if (i < NUM_OF_SPS)
return -EINVAL;
 
@@ -374,8 +382,10 @@ ia_css_ptr
 sh_css_load_blob(const unsigned char *blob, unsigned int size)
 {
ia_css_ptr target_addr = hmm_alloc(size, HMM_BO_PRIVATE, 0, NULL, 0);
-   /* this will allocate memory aligned to a DDR word boundary which
-  is required for the CSS DMA to read the instructions. */
+   /*
+* this will allocate memory aligned to a DDR word boundary which
+* is required for the CSS DMA to read the instructions.
+*/
 
assert(blob);
if (target_addr)
-- 
2.25.1



Re: [blk] 6e6fcbc27e: ltp.fs_fill.fail

2020-07-26 Thread Ming Lei
On Sun, Jul 26, 2020 at 03:55:11PM +0800, kernel test robot wrote:
> Greeting,
> 
> FYI, we noticed the following commit (built with gcc-9):
> 
> commit: 6e6fcbc27e7788af54139c53537395d95560f2ef ("blk-mq: support batching 
> dispatch in case of io")
> https://git.kernel.org/cgit/linux/kernel/git/axboe/linux-block.git 
> for-5.9/drivers
> 
> 
> in testcase: ltp
> with following parameters:
> 
>   disk: 1HDD
>   fs: ext4
>   test: fs-03
> 
> test-description: The LTP testsuite contains a collection of tools for 
> testing the Linux kernel and related features.
> test-url: http://linux-test-project.github.io/
> 
> 
> on test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 16G
> 
> caused below changes (please refer to attached dmesg/kmsg for entire 
> log/backtrace):
> 
> 
> 
> 
> If you fix the issue, kindly add following tag
> Reported-by: kernel test robot 
> 
> 
> 
> <<>>
> tag=fs_fill stime=1595659069
> cmdline="fs_fill"
> contacts=""
> analysis=exit
> <<>>
> tst_device.c:89: INFO: Found free device 0 '/dev/loop0'
> tst_supported_fs_types.c:60: INFO: Kernel supports ext2
> tst_supported_fs_types.c:44: INFO: mkfs.ext2 does exist
> tst_supported_fs_types.c:60: INFO: Kernel supports ext3
> tst_supported_fs_types.c:44: INFO: mkfs.ext3 does exist
> tst_supported_fs_types.c:60: INFO: Kernel supports ext4
> tst_supported_fs_types.c:44: INFO: mkfs.ext4 does exist
> tst_supported_fs_types.c:60: INFO: Kernel supports xfs
> tst_supported_fs_types.c:44: INFO: mkfs.xfs does exist
> tst_supported_fs_types.c:60: INFO: Kernel supports btrfs
> tst_supported_fs_types.c:44: INFO: mkfs.btrfs does exist
> tst_supported_fs_types.c:60: INFO: Kernel supports vfat
> tst_supported_fs_types.c:44: INFO: mkfs.vfat does exist
> tst_supported_fs_types.c:83: INFO: Filesystem exfat is not supported
> tst_supported_fs_types.c:92: INFO: FUSE does support ntfs
> tst_supported_fs_types.c:44: INFO: mkfs.ntfs does exist
> tst_test.c:1308: INFO: Testing on ext2
> tst_mkfs.c:90: INFO: Formatting /dev/loop0 with ext2 opts='' extra opts=''
> mke2fs 1.44.5 (15-Dec-2018)
> tst_test.c:1247: INFO: Timeout per run is 0h 05m 00s
> fs_fill.c:103: INFO: Running 10 writer threads
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread4/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread10/file0
> fs_fill.c:53: INFO: Unlinking mntpoint/thread8/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread6/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread2/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread7/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread5/file0
> fs_fill.c:53: INFO: Unlinking mntpoint/thread1/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread9/file0
> fs_fill.c:53: INFO: Unlinking mntpoint/thread3/file0
> fs_fill.c:87: PASS: Got 10 ENOSPC runtime 1194ms
> tst_test.c:1308: INFO: Testing on ext3
> tst_mkfs.c:90: INFO: Formatting /dev/loop0 with ext3 opts='' extra opts=''
> mke2fs 1.44.5 (15-Dec-2018)
> tst_test.c:1247: INFO: Timeout per run is 0h 05m 00s
> fs_fill.c:103: INFO: Running 10 writer threads
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread9/file0
> fs_fill.c:53: INFO: Unlinking mntpoint/thread10/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread4/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread9/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread2/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread3/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread7/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread3/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread7/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread9/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread4/file0
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread8/file4
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread5/file4
> tst_fill_fs.c:59: INFO: write(): ENOSPC (28)
> fs_fill.c:53: INFO: Unlinking mntpoint/thread10/file4
> tst_fill_fs.c:59: INFO: write(): ENOSPC 

Re: [PATCH v2 3/4] dt-bindings: usb: Add Microchip USB47xx/USB49xx support

2020-07-26 Thread Greg Kroah-Hartman
On Thu, Jul 23, 2020 at 09:29:01PM +0200, Christian Eggers wrote:
> Add DT bindings for Microchip USB47xx/USB49xx driver.
> 
> Signed-off-by: Christian Eggers 
> ---
> > My bot found errors running 'make dt_binding_check' on your patch:
> 
> > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/usb49xx.example.dt.yaml:
> >  usb4916i@2d: 'ocs-min-width-ms' does not match any of the regexes: 
> > 'pinctrl-[0-9]+'
> > If you already ran 'make dt_binding_check' and didn't see the above
> > error(s), then make sure dt-schema is up to date:
> The mistake was sitting in front of the computer. I simply overlooked this 
> message.
> 
> Changes in v2:
> - added property description for ocs-min-width-ms
> - fixed property description for oc-delay-ns

Please resend the whole series, not just a single patch, as it makes it
very difficult to pick the "correct" patches to be applied...

thanks,

greg k-h


Re: [RESEND PATCH] usb: common: usb-conn-gpio: Register optional charger

2020-07-26 Thread Greg Kroah-Hartman
On Sat, Jul 25, 2020 at 07:51:14PM +0200, Paul Cercueil wrote:
> Hi Greg,
> 
> Le mar. 21 juil. 2020 à 13:41, Greg Kroah-Hartman
>  a écrit :
> > On Mon, Jun 22, 2020 at 12:48:07AM +0200, Paul Cercueil wrote:
> > >  Register a power supply charger, if the Kconfig option
> > >  USB_CONN_GPIO_CHARGER is set, whose online state depends on whether
> > >  the USB role is set to device or not.
> > > 
> > >  This is useful when the USB role is the only way to know if the
> > > device
> > >  is charging from USB. The API is the standard power supply charger
> > > API,
> > >  you get a /sys/class/power_supply/xxx/online node which tells you
> > > the
> > >  state of the charger.
> > > 
> > >  The sole purpose of this is to give userspace applications a way to
> > >  know whether or not the charger is plugged.
> > > 
> > >  Signed-off-by: Paul Cercueil 
> > >  ---
> > >   drivers/usb/common/Kconfig | 11 +++
> > >   drivers/usb/common/usb-conn-gpio.c | 47
> > > ++
> > >   2 files changed, 58 insertions(+)
> > > 
> > >  diff --git a/drivers/usb/common/Kconfig b/drivers/usb/common/Kconfig
> > >  index d611477aae41..5405ae96c68f 100644
> > >  --- a/drivers/usb/common/Kconfig
> > >  +++ b/drivers/usb/common/Kconfig
> > >  @@ -49,3 +49,14 @@ config USB_CONN_GPIO
> > > 
> > > To compile the driver as a module, choose M here: the module
> > > will
> > > be called usb-conn-gpio.ko
> > >  +
> > >  +if USB_CONN_GPIO
> > >  +
> > >  +config USB_CONN_GPIO_CHARGER
> > >  +bool "USB charger support"
> > >  +select POWER_SUPPLY
> > >  +help
> > >  +  Register a charger with the power supply subsystem. This will
> > > allow
> > >  +  userspace to know whether or not the device is charging from
> > > USB.
> > 
> > Why make this an option at all?  Why wouldn't we always want this here?
> > 
> > As this is a charger, exporting that information to userspace should
> > probably always happen, right?
> 
> I wanted to avoid the hardcoded dependency on CONFIG_POWER_SUPPLY.
> 
> I can very well make that non-optional.

As the whole reason for this driver is to be a power supply, make it
depend on the power supply core please.

thanks,

greg k-h


Re: [net-next v3 1/6] net: marvell: prestera: Add driver for Prestera family ASIC devices

2020-07-26 Thread Jiri Pirko
Sat, Jul 25, 2020 at 05:06:46PM CEST, vadym.koc...@plvision.eu wrote:
>Marvell Prestera 98DX326x integrates up to 24 ports of 1GbE with 8
>ports of 10GbE uplinks or 2 ports of 40Gbps stacking for a largely
>wireless SMB deployment.
>
>The current implementation supports only boards designed for the Marvell
>Switchdev solution and requires special firmware.
>
>The core Prestera switching logic is implemented in prestera_main.c,
>there is an intermediate hw layer between core logic and firmware. It is
>implemented in prestera_hw.c, the purpose of it is to encapsulate hw
>related logic, in future there is a plan to support more devices with
>different HW related configurations.
>
>This patch contains only basic switch initialization and RX/TX support
>over SDMA mechanism.
>
>Currently supported devices have DMA access range <= 32bit and require
>ZONE_DMA to be enabled, for such cases SDMA driver checks if the skb
>allocated in proper range supported by the Prestera device.
>
>Also meanwhile there is no TX interrupt support in current firmware
>version so recycling work is scheduled on each xmit.
>
>Port's mac address is generated from the switch base mac which may be
>provided via device-tree (static one or as nvme cell), or randomly
>generated.
>
>Signed-off-by: Andrii Savka 
>Signed-off-by: Oleksandr Mazur 
>Signed-off-by: Serhiy Boiko 
>Signed-off-by: Serhiy Pshyk 
>Signed-off-by: Taras Chornyi 
>Signed-off-by: Volodymyr Mytnyk 
>Signed-off-by: Vadym Kochan 
>---

[...]


>+static const struct net_device_ops netdev_ops = {

Prefix, please:
prestera_netdev_ops.



>+  .ndo_open = prestera_port_open,
>+  .ndo_stop = prestera_port_close,
>+  .ndo_start_xmit = prestera_port_xmit,
>+  .ndo_change_mtu = prestera_port_change_mtu,
>+  .ndo_get_stats64 = prestera_port_get_stats64,
>+  .ndo_set_mac_address = prestera_port_set_mac_address,
>+};

[...]


Re: [net-next v3 5/6] net: marvell: prestera: Add Switchdev driver implementation

2020-07-26 Thread Jiri Pirko
Sat, Jul 25, 2020 at 05:06:50PM CEST, vadym.koc...@plvision.eu wrote:
>The following features are supported:
>
>- VLAN-aware bridge offloading
>- VLAN-unaware bridge offloading
>- FDB offloading (learning, ageing)
>- Switchport configuration
>
>Currently there are some limitations like:
>
>- Only 1 VLAN-aware bridge instance supported
>- FDB ageing timeout parameter is set globally per device
>
>Signed-off-by: Serhiy Boiko 
>Signed-off-by: Serhiy Pshyk 
>Signed-off-by: Taras Chornyi 
>Signed-off-by: Vadym Kochan 
>---

[...]


>+static void prestera_fdb_event_work(struct work_struct *work)
>+{
>+  struct switchdev_notifier_fdb_info *fdb_info;
>+  struct prestera_fdb_event_work *swdev_work;
>+  struct prestera_port *port;
>+  struct net_device *dev;
>+  int err = 0;
>+
>+  swdev_work = container_of(work, struct prestera_fdb_event_work, work);
>+  dev = swdev_work->dev;
>+
>+  rtnl_lock();
>+
>+  port = prestera_port_dev_lower_find(dev);
>+  if (!port)
>+  goto out;
>+
>+  switch (swdev_work->event) {
>+  case SWITCHDEV_FDB_ADD_TO_DEVICE:
>+  fdb_info = _work->fdb_info;
>+  if (!fdb_info->added_by_user)
>+  break;
>+
>+  err = prestera_port_fdb_set(port, fdb_info, true);
>+  if (err)
>+  break;
>+
>+  prestera_fdb_offload_notify(port, fdb_info);
>+  break;
>+
>+  case SWITCHDEV_FDB_DEL_TO_DEVICE:
>+  fdb_info = _work->fdb_info;
>+  prestera_port_fdb_set(port, fdb_info, false);
>+  break;
>+  }
>+
>+out:
>+  rtnl_unlock();
>+
>+  kfree(swdev_work->fdb_info.addr);
>+  kfree(swdev_work);
>+  dev_put(dev);
>+}
>+
>+static int prestera_switchdev_event(struct notifier_block *unused,
>+  unsigned long event, void *ptr)
>+{
>+  struct net_device *dev = switchdev_notifier_info_to_dev(ptr);
>+  struct switchdev_notifier_fdb_info *fdb_info;
>+  struct switchdev_notifier_info *info = ptr;
>+  struct prestera_fdb_event_work *swdev_work;
>+  struct net_device *upper;
>+  int err = 0;
>+
>+  if (event == SWITCHDEV_PORT_ATTR_SET) {
>+  err = switchdev_handle_port_attr_set(dev, ptr,
>+   prestera_netdev_check,
>+   
>prestera_port_obj_attr_set);
>+  return notifier_from_errno(err);
>+  }
>+
>+  upper = netdev_master_upper_dev_get_rcu(dev);
>+  if (!upper)
>+  return NOTIFY_DONE;
>+
>+  if (!netif_is_bridge_master(upper))
>+  return NOTIFY_DONE;

Okay, you support upper bridge. Of which interface? I believe you should
put prestera_netdev_check(dev) check here and avoid the lookup in the
work. Otherwise any chain of intermediate lower devices would be
supported, which is wrong.


>+
>+  swdev_work = kzalloc(sizeof(*swdev_work), GFP_ATOMIC);
>+  if (!swdev_work)
>+  return NOTIFY_BAD;
>+
>+  swdev_work->event = event;
>+  swdev_work->dev = dev;
>+
>+  switch (event) {
>+  case SWITCHDEV_FDB_ADD_TO_DEVICE:
>+  case SWITCHDEV_FDB_DEL_TO_DEVICE:
>+  fdb_info = container_of(info,
>+  struct switchdev_notifier_fdb_info,
>+  info);
>+
>+  INIT_WORK(_work->work, prestera_fdb_event_work);
>+  memcpy(_work->fdb_info, ptr,
>+ sizeof(swdev_work->fdb_info));
>+
>+  swdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC);
>+  if (!swdev_work->fdb_info.addr)
>+  goto out;
>+
>+  ether_addr_copy((u8 *)swdev_work->fdb_info.addr,
>+  fdb_info->addr);
>+  dev_hold(dev);
>+
>+  break;
>+
>+  default:
>+  kfree(swdev_work);
>+  return NOTIFY_DONE;
>+  }
>+
>+  queue_work(swdev_wq, _work->work);
>+  return NOTIFY_DONE;
>+out:
>+  kfree(swdev_work);
>+  return NOTIFY_BAD;
>+}

[...]


Re: [PATCH 0/6] mips: delete duplicated words

2020-07-26 Thread Thomas Bogendoerfer
On Sat, Jul 25, 2020 at 05:34:23PM -0700, Randy Dunlap wrote:
> Delete duplicated words in arch/mips/ header files.
> 
> Cc: Thomas Bogendoerfer 
> Cc: linux-m...@vger.kernel.org
> 
>  arch/mips/include/asm/io.h  |2 +-
>  arch/mips/include/asm/octeon/cvmx-l2c.h |2 +-
>  arch/mips/include/asm/octeon/cvmx-pip.h |2 +-
>  arch/mips/include/asm/octeon/cvmx-pko.h |7 +++
>  arch/mips/include/asm/octeon/cvmx-pow.h |8 
>  arch/mips/include/asm/octeon/octeon.h   |2 +-
>  6 files changed, 11 insertions(+), 12 deletions(-)

series applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.[ RFC1925, 2.3 ]


Re: [PATCH v2 1/2] MIPS: Set page access bit with pgprot on platforms with RIXI

2020-07-26 Thread Thomas Bogendoerfer
On Sat, Jun 06, 2020 at 12:02:48PM +0800, Bibo Mao wrote:
> @@ -158,23 +158,23 @@ void __update_cache(unsigned long address, pte_t pte)
>  static inline void setup_protection_map(void)
>  {
>   if (cpu_has_rixi) {
> - protection_map[0]  = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ);
> - protection_map[1]  = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT | _PAGE_NO_EXEC);
> - protection_map[2]  = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ);
> - protection_map[3]  = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT | _PAGE_NO_EXEC);
> - protection_map[4]  = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT);
> - protection_map[5]  = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT);
> - protection_map[6]  = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT);
> - protection_map[7]  = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT);
> -
> - protection_map[8]  = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ);
> - protection_map[9]  = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT | _PAGE_NO_EXEC);
> - protection_map[10] = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE | _PAGE_NO_READ);
> - protection_map[11] = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE);
> - protection_map[12] = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT);
> - protection_map[13] = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT);
> - protection_map[14] = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT | _PAGE_WRITE);
> - protection_map[15] = __pgprot(_page_cachable_default | 
> _PAGE_PRESENT | _PAGE_WRITE);
> + protection_map[0]  = __pgprot(__PC | __PP | __NX | __NR);
> + protection_map[1]  = __pgprot(__PC | __PP | __NX | ___R);
> + protection_map[2]  = __pgprot(__PC | __PP | __NX | __NR);
> + protection_map[3]  = __pgprot(__PC | __PP | __NX | ___R);
> + protection_map[4]  = __pgprot(__PC | __PP | ___R);
> + protection_map[5]  = __pgprot(__PC | __PP | ___R);
> + protection_map[6]  = __pgprot(__PC | __PP | ___R);
> + protection_map[7]  = __pgprot(__PC | __PP | ___R);
> +
> + protection_map[8]  = __pgprot(__PC | __PP | __NX | __NR);
> + protection_map[9]  = __pgprot(__PC | __PP | __NX | ___R);
> + protection_map[10] = __pgprot(__PC | __PP | __NX | ___W | __NR);
> + protection_map[11] = __pgprot(__PC | __PP | __NX | ___W | ___R);
> + protection_map[12] = __pgprot(__PC | __PP | ___R);
> + protection_map[13] = __pgprot(__PC | __PP | ___R);
> + protection_map[14] = __pgprot(__PC | __PP | ___W | ___R);
> + protection_map[15] = __pgprot(__PC | __PP | ___W | ___R);

you are doing two steps in one go, so it's not obvious you are not only
using some macros, but also changing semantics. And while there are already
really long lines, please leave it that way and only do the access bit
change.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.[ RFC1925, 2.3 ]


Re: [PATCH] MIPS: ingenic: JZ4725B: Add IPU node

2020-07-26 Thread Thomas Bogendoerfer
On Sat, Jul 25, 2020 at 07:43:07PM +0200, Paul Cercueil wrote:
> Add a devicetree node for the Image Processing Unit (IPU) found in the
> JZ4725B. Connect it with graph nodes to the LCD node. The LCD driver
> will expect the IPU node to be accessed through graph port #8, as stated
> in the bindings documentation.
> 
> Signed-off-by: Paul Cercueil 
> ---
> 
> Notes:
> Binding documentation was merged in the DRM tree (drm-misc-next branch).
> See 
> https://cgit.freedesktop.org/drm/drm-misc/plain/Documentation/devicetree/bindings/display/ingenic,ipu.yaml
> 
>  arch/mips/boot/dts/ingenic/jz4725b.dtsi | 30 +
>  arch/mips/boot/dts/ingenic/rs90.dts |  6 -
>  2 files changed, 35 insertions(+), 1 deletion(-)

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.[ RFC1925, 2.3 ]


Re: [PATCH] devices.txt: document rfkill allocation

2020-07-26 Thread Greg KH
On Sun, Jul 26, 2020 at 09:53:27AM +0200, Pavel Machek wrote:
> Document rfkill allocation.
> 
> Signed-off-by: Pavel Machek (CIP) 
> 
> diff --git a/Documentation/admin-guide/devices.txt 
> b/Documentation/admin-guide/devices.txt
> index 2a97aaec8b12..763fedd94d7d 100644
> --- a/Documentation/admin-guide/devices.txt
> +++ b/Documentation/admin-guide/devices.txt
> @@ -375,8 +375,9 @@
>   239 = /dev/uhid User-space I/O driver support for HID 
> subsystem
>   240 = /dev/userio   Serio driver testing device
>   241 = /dev/vhost-vsock  Host kernel driver for virtio vsock
> + 242 = /dev/rfkill   Turning off radio transmissions (rfkill)
>  
> - 242-254 Reserved for local use
> + 243-254 Reserved for local use

Ugh, really?  Another "let's test this locally" value got merged into
the tree without anyone noticing?

bah...

greg k-h


Re: [PATCH] staging: rtl8723bs: include: Fix coding style errors

2020-07-26 Thread Greg KH
On Sun, Jul 26, 2020 at 01:32:15PM +0530, Aditya Jain wrote:
> Fixing ERROR: "foo *  bar" should be "foo *bar" in hal_phy_cfg.h
> as reported by checkpatch.pl
> 
> Signed-off-by: Aditya Jain 
> ---
>  .../staging/rtl8723bs/include/hal_phy_cfg.h| 18 +-
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/include/hal_phy_cfg.h 
> b/drivers/staging/rtl8723bs/include/hal_phy_cfg.h
> index 419ddb0733aa..fd5f377bad4f 100644
> --- a/drivers/staging/rtl8723bs/include/hal_phy_cfg.h
> +++ b/drivers/staging/rtl8723bs/include/hal_phy_cfg.h
> @@ -42,7 +42,7 @@ u32 Data
>  
>  u32
>  PHY_QueryRFReg_8723B(
> -struct adapter * Adapter,
> +struct adapter   *Adapter,
>  u8   eRFPath,
>  u32  RegAddr,
>  u32  BitMask

Ick, these are all horrid.  How about just making these all on a single
line like most functions have them instead of this one cleanup?

Same for the other changes you made in this file.

thanks,

greg k-h


Re: [PATCHv8 0/6] n_gsm serdev support and GNSS driver for droid4

2020-07-26 Thread Pavel Machek
Hi!

> > Here's the updated set of these patches fixed up for Johan's and
> > Pavel's earlier comments.
> > 
> > This series does the following:
> > 
> > 1. Adds functions to n_gsm.c for serdev-ngsm.c driver to use
> > 
> > 2. Adds a generic serdev-ngsm.c driver that brings up the TS 27.010
> >TTY ports configured in devicetree with help of n_gsm.c
> > 
> > 3. Allows the use of standard Linux device drivers for dedicated
> >TS 27.010 channels for devices like GNSS and ALSA found on some
> >modems for example
> 
> Unfortunately that does not seem to be the case just yet. Your gnss
> driver is still aware that it's using n_gsm for the transport and calls
> into the "parent" serdev-ngsm driver instead of using the serdev
> interface (e.g. as if this was still and MFD driver).
> 
> If you model this right, the GNSS driver should work equally well
> regardless of whether you use the serial interface (with n_gsm) or USB
> (e.g. cdc-acm or usb-serial).

We are not going to see that protocol anywhere else, so why is that
a good goal?

Anyway, Tony, is there newer version of this patchset? It would be
good to get something in...

Can I help somehow?

Best regards,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH 04/21] devtmpfs: refactor devtmpfsd()

2020-07-26 Thread Christoph Hellwig
On Sun, Jul 26, 2020 at 09:43:06AM +0200, Greg Kroah-Hartman wrote:
> On Sun, Jul 26, 2020 at 09:13:39AM +0200, Christoph Hellwig wrote:
> > Split the main worker loop into a separate function.  This allows
> > devtmpfsd itself and devtmpfsd_setup to be marked __init, which will
> > allows us to call __init routines for the setup work.
> > 
> > Signed-off-by: Christoph Hellwig 
> > ---
> >  drivers/base/devtmpfs.c | 47 +++--
> >  1 file changed, 26 insertions(+), 21 deletions(-)
> 
> Nice cleanup, thanks for doing this:

This was actualy Als idea, I should have probably mentioned that.


Re: [PATCH v5 5/6] kprobes: Use text_alloc() and text_free()

2020-07-26 Thread Mike Rapoport
On Sat, Jul 25, 2020 at 06:16:48AM +0300, Jarkko Sakkinen wrote:
> On Fri, Jul 24, 2020 at 11:27:46AM +0200, Ingo Molnar wrote:
> > 
> > * Jarkko Sakkinen  wrote:
> > 
> > > Use text_alloc() and text_free() instead of module_alloc() and
> > > module_memfree() when an arch provides them.
> > > 
> > > Cc: linux...@kvack.org
> > > Cc: Andi Kleen 
> > > Cc: Masami Hiramatsu 
> > > Cc: Peter Zijlstra 
> > > Signed-off-by: Jarkko Sakkinen 
> > > ---
> > >  kernel/kprobes.c | 9 +
> > >  1 file changed, 9 insertions(+)
> > > 
> > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> > > index 4e46d96d4e16..611fcda9f6bf 100644
> > > --- a/kernel/kprobes.c
> > > +++ b/kernel/kprobes.c
> > > @@ -40,6 +40,7 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >  
> > >  #define KPROBE_HASH_BITS 6
> > >  #define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS)
> > > @@ -111,12 +112,20 @@ enum kprobe_slot_state {
> > >  
> > >  void __weak *alloc_insn_page(void)
> > >  {
> > > +#ifdef CONFIG_ARCH_HAS_TEXT_ALLOC
> > > + return text_alloc(PAGE_SIZE);
> > > +#else
> > >   return module_alloc(PAGE_SIZE);
> > > +#endif
> > >  }
> > >  
> > >  void __weak free_insn_page(void *page)
> > >  {
> > > +#ifdef CONFIG_ARCH_HAS_TEXT_ALLOC
> > > + text_free(page);
> > > +#else
> > >   module_memfree(page);
> > > +#endif
> > >  }
> > 
> > I've read the observations in the other threads, but this #ifdef 
> > jungle is silly, it's a de-facto open coded text_alloc() with a 
> > module_alloc() fallback...
> 
> In the previous version I had:
> 
>   
> https://lore.kernel.org/lkml/20200717030422.679972-4-jarkko.sakki...@linux.intel.com/
> 
> and I had just calls to text_alloc() and text_free() in corresponding
> snippet to the above.
> 
> I got this feedback from Mike:
> 
>   https://lore.kernel.org/lkml/20200718162359.ga2919...@kernel.org/
> 
> I'm not still sure that I fully understand this feedback as I don't see
> any inherent and obvious difference to the v4. In that version fallbacks
> are to module_alloc() and module_memfree() and text_alloc() and
> text_memfree() can be overridden by arch.

Let me try to elaborate.

There are several subsystems that need to allocate memory for executable
text. As it happens, they use module_alloc() with some abilities for
architectures to override this behaviour.

For many architectures, it would be enough to rename modules_alloc() to
text_alloc(), make it built-in and this way allow removing dependency on
MODULES.

Yet, some architectures have different restrictions for code allocation
for different subsystems so it would make sense to have more than one
variant of text_alloc() and a single config option ARCH_HAS_TEXT_ALLOC
won't be sufficient.

I liked Mark's suggestion to have text_alloc_() and proposed
a way to introduce text_alloc_kprobes() along with
HAVE_KPROBES_TEXT_ALLOC to enable arch overrides of this function.

The major difference between your v4 and my suggestion is that I'm not
trying to impose a single ARCH_HAS_TEXT_ALLOC as an alternative to
MODULES but rather to use per subsystem config option, e.g.
HAVE_KPROBES_TEXT_ALLOC.

Another thing, which might be worth doing regardless of the outcome of
this discussion is to rename alloc_insn_pages() to text_alloc_kprobes()
because the former is way too generic and does not emphasize that the 
instruction page is actually used by kprobes only.

> /Jarkko
> 

-- 
Sincerely yours,
Mike.


Re: [PATCH] iio: sx9310: Fixes dropped on initial commit

2020-07-26 Thread Andy Shevchenko
On Sat, Jul 25, 2020 at 3:41 AM Daniel Campello  wrote:
>
> This patch brings back fixes on v9 of initial patch that got dropped
> when v8 was taken instead.
>   - Updated Copyright
>   - Updated macro definitions
>   - Simplified return condition checks
>   - Removed ACPI and of table macros

Please, split to a series of patches.
I see at least ~4-5 by the changes below.

-- 
With Best Regards,
Andy Shevchenko


Re: [RFC 0/7] Add support to process rx packets in thread

2020-07-26 Thread Felix Fietkau
On 2020-07-26 03:22, Hillf Danton wrote:
>> - add a state bit for threaded NAPI
>> - make netif_threaded_napi_add inline
>> - run queue_work outside of local_irq_save/restore (it does that
>> internally already)
>>
>> If you don't mind, I'd like to propose this to netdev soon. Can I have
>> your Signed-off-by for that?
> 
> Feel free to do that. Is it likely for me to select a Cc?
Shall I use Signed-off-by: Hillf Danton ?
What Cc do you want me to add?

>> ---
>> --- a/include/linux/netdevice.h
>> +++ b/include/linux/netdevice.h
>> @@ -347,6 +347,7 @@ struct napi_struct {
>>  struct list_headdev_list;
>>  struct hlist_node   napi_hash_node;
>>  unsigned intnapi_id;
>> +struct work_struct  work;
>>  };
>>  
>>  enum {
>> @@ -357,6 +358,7 @@ enum {
>>  NAPI_STATE_HASHED,  /* In NAPI hash (busy polling possible) */
>>  NAPI_STATE_NO_BUSY_POLL,/* Do not add in napi_hash, no busy polling */
>>  NAPI_STATE_IN_BUSY_POLL,/* sk_busy_loop() owns this NAPI */
>> +NAPI_STATE_THREADED,/* Use threaded NAPI */
>>  };
>>  
>>  enum {
>> @@ -367,6 +369,7 @@ enum {
>>  NAPIF_STATE_HASHED   = BIT(NAPI_STATE_HASHED),
>>  NAPIF_STATE_NO_BUSY_POLL = BIT(NAPI_STATE_NO_BUSY_POLL),
>>  NAPIF_STATE_IN_BUSY_POLL = BIT(NAPI_STATE_IN_BUSY_POLL),
>> +NAPIF_STATE_THREADED = BIT(NAPI_STATE_THREADED),
>>  };
>>  
>>  enum gro_result {
>> @@ -2315,6 +2318,26 @@ static inline void *netdev_priv(const struct 
>> net_device *dev)
>>  void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
>>  int (*poll)(struct napi_struct *, int), int weight);
>>  
>> +/**
>> + *  netif_threaded_napi_add - initialize a NAPI context
>> + *  @dev:  network device
>> + *  @napi: NAPI context
>> + *  @poll: polling function
>> + *  @weight: default weight
>> + *
>> + * This variant of netif_napi_add() should be used from drivers using NAPI
>> + * with CPU intensive poll functions.
>> + * This will schedule polling from a high priority workqueue that
>> + */
>> +static inline void netif_threaded_napi_add(struct net_device *dev,
>> +   struct napi_struct *napi,
>> +   int (*poll)(struct napi_struct *, 
>> int),
>> +   int weight)
>> +{
>> +set_bit(NAPI_STATE_THREADED, >state);
>> +netif_napi_add(dev, napi, poll, weight);
>> +}
>> +
>>  /**
>>   *  netif_tx_napi_add - initialize a NAPI context
>>   *  @dev:  network device
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -158,6 +158,7 @@ static DEFINE_SPINLOCK(offload_lock);
>>  struct list_head ptype_base[PTYPE_HASH_SIZE] __read_mostly;
>>  struct list_head ptype_all __read_mostly;   /* Taps */
>>  static struct list_head offload_base __read_mostly;
>> +static struct workqueue_struct *napi_workq;
> 
> Is __read_mostly missing?
Yes, thanks. I will add that before sending the patch.

- Felix


[PATCH 2/2] mm, util: account_locked_vm() does not hold mmap_lock

2020-07-26 Thread Pengfei Li
Since mm->locked_vm is already an atomic counter, account_locked_vm()
does not need to hold mmap_lock.

Signed-off-by: Pengfei Li 
---
 drivers/vfio/vfio_iommu_type1.c |  8 ++--
 mm/util.c   | 15 +++
 2 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 78013be07fe7..53818fce78a6 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -376,12 +376,8 @@ static int vfio_lock_acct(struct vfio_dma *dma, long 
npage, bool async)
if (!mm)
return -ESRCH; /* process exited */
 
-   ret = mmap_write_lock_killable(mm);
-   if (!ret) {
-   ret = __account_locked_vm(mm, abs(npage), npage > 0, dma->task,
- dma->lock_cap);
-   mmap_write_unlock(mm);
-   }
+   ret = __account_locked_vm(mm, abs(npage), npage > 0,
+   dma->task, dma->lock_cap);
 
if (async)
mmput(mm);
diff --git a/mm/util.c b/mm/util.c
index 473add0dc275..320fdd537aea 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -424,8 +424,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct 
rlimit *rlim_stack)
  * @task:task used to check RLIMIT_MEMLOCK
  * @bypass_rlim: %true if checking RLIMIT_MEMLOCK should be skipped
  *
- * Assumes @task and @mm are valid (i.e. at least one reference on each), and
- * that mmap_lock is held as writer.
+ * Assumes @task and @mm are valid (i.e. at least one reference on each).
  *
  * Return:
  * * 0   on success
@@ -437,8 +436,6 @@ int __account_locked_vm(struct mm_struct *mm, unsigned long 
pages, bool inc,
unsigned long locked_vm, limit;
int ret = 0;
 
-   mmap_assert_write_locked(mm);
-
locked_vm = atomic64_read(>locked_vm);
if (inc) {
if (!bypass_rlim) {
@@ -476,17 +473,11 @@ EXPORT_SYMBOL_GPL(__account_locked_vm);
  */
 int account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc)
 {
-   int ret;
-
if (pages == 0 || !mm)
return 0;
 
-   mmap_write_lock(mm);
-   ret = __account_locked_vm(mm, pages, inc, current,
- capable(CAP_IPC_LOCK));
-   mmap_write_unlock(mm);
-
-   return ret;
+   return __account_locked_vm(mm, pages, inc,
+   current, capable(CAP_IPC_LOCK));
 }
 EXPORT_SYMBOL_GPL(account_locked_vm);
 
-- 
2.26.2



Re: [v3 1/2] iio: gyro: Add driver support for ADXRS290

2020-07-26 Thread Andy Shevchenko
On Fri, Jul 24, 2020 at 2:02 PM Nishant Malpani
 wrote:
>
> ADXRS290 is a high performance MEMS pitch and roll (dual-axis in-plane)
> angular rate sensor (gyroscope) designed for use in stabilization
> applications. It also features an internal temperature sensor and
> programmable high-pass and low-pass filters.
>
> Add support for ADXRS290 in direct-access mode for now.

Thanks for an update!
My nits below, after addressing them
Reviewed-by: Andy Shevchenko 

> Datasheet: 
> https://www.analog.com/media/en/technical-documentation/data-sheets/ADXRS290.pdf
> Signed-off-by: Nishant Malpani 
> ---
>
> Changes in v3:
>   - drop "Link" tag & extra line in commit message
>   - rename cut-off frequencies tables to
> 'adxrs290_{lpf, hpf}_3db_freq_hz_table' to be more descriptive
>   - fix unsigned type errors
>   - add comments on how to scale raw angular velocity and temperature
> values to appropriate units mentioned in the ABI
>   - re-order declarations in reversed spruce tree order
>   - remove 'indio_dev->dev.parent = >dev' as the iio core handles it
> during iio_device_alloc()
>   - use plain msleep() instead of the interruptible variant
>   - remove extra terminal comma
>
> Changes in v2:
>   - append copyright tag with author's info
>   - remove asm/unaligned.h header
>   - remove unnecessary comments about the registers' description
>   - rephrase comment on the usage of mutex_lock
>   - discard the usage of local tx, rx buffers; use DMA-safe buffers
> provided by the SPI core instead
>   - utilize spi_w8r16 provided by the SPI core instead of writing a
> wrapper over spi_sync_transfer which semantically does the same
>   - equip spi_write_then_read instead of plain spi_write since the
> latter requires a DMA-safe buffer
>   - implement exact matching of filter 3db frequencies instead of
> finding the "closest" match; rounding complexity is left to the
> userspace
>   - include 'info_mask_shared_by_type_available' when initialising
> iio_chan_spec instead of explicitly exposing attributes
> signifying available filter 3db frequencies; with this we can
> utilize read_avail core callback
> ---
>  MAINTAINERS |   6 +
>  drivers/iio/gyro/Kconfig|  10 +
>  drivers/iio/gyro/Makefile   |   1 +
>  drivers/iio/gyro/adxrs290.c | 446 
>  4 files changed, 463 insertions(+)
>  create mode 100644 drivers/iio/gyro/adxrs290.c
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 9077411c9890..71ae9b184179 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1098,6 +1098,12 @@ L:   linux-me...@vger.kernel.org
>  S: Maintained
>  F: drivers/media/i2c/adv7842*
>
> +ANALOG DEVICES INC ADXRS290 DRIVER
> +M: Nishant Malpani 
> +L: linux-...@vger.kernel.org
> +S: Supported
> +F: drivers/iio/gyro/adxrs290.c
> +
>  ANALOG DEVICES INC ASOC CODEC DRIVERS
>  M: Lars-Peter Clausen 
>  M: Nuno Sá 
> diff --git a/drivers/iio/gyro/Kconfig b/drivers/iio/gyro/Kconfig
> index 6daeddf37f60..024a34139875 100644
> --- a/drivers/iio/gyro/Kconfig
> +++ b/drivers/iio/gyro/Kconfig
> @@ -41,6 +41,16 @@ config ADIS16260
>   This driver can also be built as a module.  If so, the module
>   will be called adis16260.
>
> +config ADXRS290
> +   tristate "Analog Devices ADXRS290 Dual-Axis MEMS Gyroscope SPI driver"
> +   depends on SPI
> +   help
> + Say yes here to build support for Analog Devices ADXRS290 
> programmable
> + digital output gyroscope.
> +
> + This driver can also be built as a module. If so, the module will be
> + called adxrs290.
> +
>  config ADXRS450
> tristate "Analog Devices ADXRS450/3 Digital Output Gyroscope SPI 
> driver"
> depends on SPI
> diff --git a/drivers/iio/gyro/Makefile b/drivers/iio/gyro/Makefile
> index 45cbd5dc644e..0319b397dc3f 100644
> --- a/drivers/iio/gyro/Makefile
> +++ b/drivers/iio/gyro/Makefile
> @@ -8,6 +8,7 @@ obj-$(CONFIG_ADIS16080) += adis16080.o
>  obj-$(CONFIG_ADIS16130) += adis16130.o
>  obj-$(CONFIG_ADIS16136) += adis16136.o
>  obj-$(CONFIG_ADIS16260) += adis16260.o
> +obj-$(CONFIG_ADXRS290) += adxrs290.o
>  obj-$(CONFIG_ADXRS450) += adxrs450.o
>  obj-$(CONFIG_BMG160) += bmg160_core.o
>  obj-$(CONFIG_BMG160_I2C) += bmg160_i2c.o
> diff --git a/drivers/iio/gyro/adxrs290.c b/drivers/iio/gyro/adxrs290.c
> new file mode 100644
> index ..cff1af9211bc
> --- /dev/null
> +++ b/drivers/iio/gyro/adxrs290.c
> @@ -0,0 +1,446 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * ADXRS290 SPI Gyroscope Driver
> + *
> + * Copyright (C) 2020 Nishant Malpani 
> + * Copyright (C) 2020 Analog Devices, Inc.
> + */
> +
> +#include 

> +#include 
> +#include 

Keep it ordered?

> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +
> +#define ADXRS290_ADI_ID0xAD
> +#define ADXRS290_MEMS_ID   0x1D
> +#define ADXRS290_DEV_ID0x92
> +
> +#define 

BUG: unable to handle kernel NULL pointer dereference in do_syscall_32_irqs_on

2020-07-26 Thread syzbot
Hello,

syzbot found the following issue on:

HEAD commit:23ee3e4e Merge tag 'pci-v5.8-fixes-2' of git://git.kernel...
git tree:   upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=14a4c7d890
kernel config:  https://syzkaller.appspot.com/x/.config?x=f87a5e4232fdb267
dashboard link: https://syzkaller.appspot.com/bug?extid=0e3a50ab9ac2fdf9ffc6
compiler:   gcc (GCC) 10.1.0-syz 20200507
userspace arch: i386
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=168fe3a090

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+0e3a50ab9ac2fdf9f...@syzkaller.appspotmail.com

BUG: kernel NULL pointer dereference, address: 
#PF: supervisor write access in kernel mode
#PF: error_code(0x0002) - not-present page
PGD 94d49067 P4D 94d49067 PUD a1c93067 PMD 0 
Oops: 0002 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 6854 Comm: syz-executor.3 Not tainted 5.8.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
RIP: 0010:do_syscall_32_irqs_on+0x3f/0x60 arch/x86/entry/common.c:428
Code: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <00> 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00
RSP: 0018:c900017b7f28 EFLAGS: 00010296
RAX:  RBX: c900017b7f58 RCX: 1920002f6fd2
RDX: 888098bb4240 RSI: 81c214b2 RDI: 0005
RBP: c900017b7f58 R08: 0001 R09: 888098bb4b08
R10: ff8c R11:  R12: 0001
R13:  R14:  R15: 
FS:  () GS:8880ae60(0063) knlGS:0a292900
CS:  0010 DS: 002b ES: 002b CR0: 80050033
CR2:  CR3: a1b88000 CR4: 001406f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 __do_fast_syscall_32 arch/x86/entry/common.c:475 [inline]
 do_fast_syscall_32+0x7f/0x120 arch/x86/entry/common.c:503
 entry_SYSENTER_compat_after_hwframe+0x4d/0x5c
BUG: kernel NULL pointer dereference, address: 
#PF: supervisor write access in kernel mode
#PF: error_code(0x0002) - not-present page
PGD 94d49067 P4D 94d49067 PUD a1c93067 PMD 0 
Oops: 0002 [#2] PREEMPT SMP KASAN
CPU: 0 PID: 6854 Comm: syz-executor.3 Not tainted 5.8.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
RIP: 0010:in_gate_area_no_mm+0x0/0x6a arch/x86/entry/vsyscall/vsyscall_64.c:343
Code: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <00> 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00
RSP: 0018:c900017b7440 EFLAGS: 00010093
RAX:  RBX: c900017b74e0 RCX: 816a62f0
RDX: 888098bb4240 RSI: 816a631b RDI: f7f83569
RBP: f7f83569 R08: c900017b75f0 R09: 8c8d7109
R10: f7f83569 R11:  R12: c900017b75f0
R13: 0001 R14: f7f83569 R15: c900017b7500
FS:  () GS:8880ae60(0063) knlGS:0a292900
CS:  0010 DS: 002b ES: 002b CR0: 80050033
CR2:  CR3: a1b88000 CR4: 001406f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 is_kernel include/linux/kallsyms.h:44 [inline]
 is_ksym_addr include/linux/kallsyms.h:50 [inline]
 kallsyms_lookup+0xc3/0x2e0 kernel/kallsyms.c:290
 __sprint_symbol+0x9c/0x1c0 kernel/kallsyms.c:363
 symbol_string+0x14c/0x370 lib/vsprintf.c:969
 pointer+0x185/0x970 lib/vsprintf.c:2226
 vsnprintf+0x5b2/0x14f0 lib/vsprintf.c:2624
 vscnprintf+0x29/0x80 lib/vsprintf.c:2723
 vprintk_store+0x44/0x4a0 kernel/printk/printk.c:1942
 vprintk_emit+0x139/0x770 kernel/printk/printk.c:2003
 vprintk_func+0x8f/0x1a6 kernel/printk/printk_safe.c:393
 printk+0xba/0xed kernel/printk/printk.c:2070
 show_ip+0x22/0x30 arch/x86/kernel/dumpstack.c:124
 show_iret_regs+0x10/0x32 arch/x86/kernel/dumpstack.c:131
 __show_regs+0x18/0x50 arch/x86/kernel/process_64.c:72
 show_trace_log_lvl+0x255/0x2b4 arch/x86/kernel/dumpstack.c:274
 show_regs arch/x86/kernel/dumpstack.c:447 [inline]
 __die_body arch/x86/kernel/dumpstack.c:393 [inline]
 __die+0x51/0x90 arch/x86/kernel/dumpstack.c:407
 no_context+0x56b/0x9f0 arch/x86/mm/fault.c:695
 __bad_area_nosemaphore+0xa9/0x480 arch/x86/mm/fault.c:789
 do_user_addr_fault+0x8ce/0xd00 arch/x86/mm/fault.c:1258
 handle_page_fault arch/x86/mm/fault.c:1365 [inline]
 exc_page_fault+0xab/0x170 arch/x86/mm/fault.c:1418
 asm_exc_page_fault+0x1e/0x30 arch/x86/include/asm/idtentry.h:542
RIP: 0010:do_syscall_32_irqs_on+0x3f/0x60 arch/x86/entry/common.c:428
Code: 00 00 00 00 00 00 00 00 00 00 

[PATCH 1/2] mm: make mm->locked_vm an atomic64 counter

2020-07-26 Thread Pengfei Li
Like commit 70f8a3ca68d3 ("mm: make mm->pinned_vm an atomic64 counter").

By making mm->locked_vm an atomic64 counter, we can safely modify it
without holding mmap_lock.

The reason for using atomic64 instead of atomic_long is to keep the same
as mm->pinned_vm, and there is no need to worry about overflow.

Signed-off-by: Pengfei Li 
---
 drivers/infiniband/sw/siw/siw_verbs.c | 12 +++-
 drivers/vfio/vfio_iommu_type1.c   |  6 --
 fs/io_uring.c |  4 ++--
 fs/proc/task_mmu.c|  2 +-
 include/linux/mm_types.h  |  4 ++--
 kernel/fork.c |  2 +-
 mm/debug.c|  5 +++--
 mm/mlock.c|  4 ++--
 mm/mmap.c | 18 +-
 mm/mremap.c   |  6 +++---
 mm/util.c |  6 +++---
 11 files changed, 37 insertions(+), 32 deletions(-)

diff --git a/drivers/infiniband/sw/siw/siw_verbs.c 
b/drivers/infiniband/sw/siw/siw_verbs.c
index adafa1b8bebe..bf78d7988442 100644
--- a/drivers/infiniband/sw/siw/siw_verbs.c
+++ b/drivers/infiniband/sw/siw/siw_verbs.c
@@ -1293,14 +1293,16 @@ struct ib_mr *siw_reg_user_mr(struct ib_pd *pd, u64 
start, u64 len,
goto err_out;
}
if (mem_limit != RLIM_INFINITY) {
-   unsigned long num_pages =
-   (PAGE_ALIGN(len + (start & ~PAGE_MASK))) >> PAGE_SHIFT;
+   unsigned long num_pages, locked_pages;
+
+   num_pages = (PAGE_ALIGN(len + (start & ~PAGE_MASK)))
+   >> PAGE_SHIFT;
+   locked_pages = atomic64_read(>mm->locked_vm);
mem_limit >>= PAGE_SHIFT;
 
-   if (num_pages > mem_limit - current->mm->locked_vm) {
+   if (num_pages > mem_limit - locked_pages) {
siw_dbg_pd(pd, "pages req %lu, max %lu, lock %lu\n",
-  num_pages, mem_limit,
-  current->mm->locked_vm);
+  num_pages, mem_limit, locked_pages);
rv = -ENOMEM;
goto err_out;
}
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 9d41105bfd01..78013be07fe7 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -509,7 +509,8 @@ static long vfio_pin_pages_remote(struct vfio_dma *dma, 
unsigned long vaddr,
 * pages are already counted against the user.
 */
if (!rsvd && !vfio_find_vpfn(dma, iova)) {
-   if (!dma->lock_cap && current->mm->locked_vm + 1 > limit) {
+   if (!dma->lock_cap &&
+   atomic64_read(>mm->locked_vm) + 1 > limit) {
put_pfn(*pfn_base, dma->prot);
pr_warn("%s: RLIMIT_MEMLOCK (%ld) exceeded\n", __func__,
limit << PAGE_SHIFT);
@@ -536,7 +537,8 @@ static long vfio_pin_pages_remote(struct vfio_dma *dma, 
unsigned long vaddr,
 
if (!rsvd && !vfio_find_vpfn(dma, iova)) {
if (!dma->lock_cap &&
-   current->mm->locked_vm + lock_acct + 1 > limit) {
+   atomic64_read(>mm->locked_vm) +
+   lock_acct + 1 > limit) {
put_pfn(pfn, dma->prot);
pr_warn("%s: RLIMIT_MEMLOCK (%ld) exceeded\n",
__func__, limit << PAGE_SHIFT);
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 7cf2f295fba7..f1241c6314e6 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7371,7 +7371,7 @@ static void io_unaccount_mem(struct io_ring_ctx *ctx, 
unsigned long nr_pages,
 
if (ctx->sqo_mm) {
if (acct == ACCT_LOCKED)
-   ctx->sqo_mm->locked_vm -= nr_pages;
+   atomic64_sub(nr_pages, >sqo_mm->locked_vm);
else if (acct == ACCT_PINNED)
atomic64_sub(nr_pages, >sqo_mm->pinned_vm);
}
@@ -7390,7 +7390,7 @@ static int io_account_mem(struct io_ring_ctx *ctx, 
unsigned long nr_pages,
 
if (ctx->sqo_mm) {
if (acct == ACCT_LOCKED)
-   ctx->sqo_mm->locked_vm += nr_pages;
+   atomic64_add(nr_pages, >sqo_mm->locked_vm);
else if (acct == ACCT_PINNED)
atomic64_add(nr_pages, >sqo_mm->pinned_vm);
}
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index df2f0f05f5ba..2af56e68766e 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -58,7 +58,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
swap = get_mm_counter(mm, MM_SWAPENTS);
SEQ_PUT_DEC("VmPeak:\t", hiwater_vm);
SEQ_PUT_DEC(" kB\nVmSize:\t", total_vm);
-   SEQ_PUT_DEC(" kB\nVmLck:\t", 

[PATCH] staging: rtl8723bs: include: Fix coding style errors

2020-07-26 Thread Aditya Jain
Fixing ERROR: "foo *bar" should be "foo *bar" in hal_phy_cfg.h
as reported by checkpatch.pl

Signed-off-by: Aditya Jain 
---
 .../staging/rtl8723bs/include/hal_phy_cfg.h| 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/hal_phy_cfg.h 
b/drivers/staging/rtl8723bs/include/hal_phy_cfg.h
index 419ddb0733aa..fd5f377bad4f 100644
--- a/drivers/staging/rtl8723bs/include/hal_phy_cfg.h
+++ b/drivers/staging/rtl8723bs/include/hal_phy_cfg.h
@@ -42,7 +42,7 @@ u32   Data
 
 u32
 PHY_QueryRFReg_8723B(
-struct adapter *   Adapter,
+struct adapter *Adapter,
 u8 eRFPath,
 u32RegAddr,
 u32BitMask
@@ -50,7 +50,7 @@ u32   BitMask
 
 void
 PHY_SetRFReg_8723B(
-struct adapter *   Adapter,
+struct adapter *Adapter,
 u8 eRFPath,
 u32RegAddr,
 u32BitMask,
@@ -66,7 +66,7 @@ s32 PHY_MACConfig8723B(struct adapter *padapter);
 
 void
 PHY_SetTxPowerIndex(
-struct adapter *   Adapter,
+struct adapter *Adapter,
 u32PowerIndex,
 u8 RFPath,
 u8 Rate
@@ -74,7 +74,7 @@ u8Rate
 
 u8
 PHY_GetTxPowerIndex(
-struct adapter *   padapter,
+struct adapter *padapter,
 u8 RFPath,
 u8 Rate,
 enum CHANNEL_WIDTH BandWidth,
@@ -83,19 +83,19 @@ u8  Channel
 
 void
 PHY_GetTxPowerLevel8723B(
-struct adapter *   Adapter,
-   s32*powerlevel
+struct adapter *Adapter,
+   s32 *powerlevel
);
 
 void
 PHY_SetTxPowerLevel8723B(
-struct adapter *   Adapter,
+struct adapter *Adapter,
 u8 channel
);
 
 void
 PHY_SetBWMode8723B(
-struct adapter *   Adapter,
+struct adapter *Adapter,
 enum CHANNEL_WIDTH Bandwidth,  /*  20M or 40M */
 unsigned char  Offset  /*  Upper, Lower, or Don't care 
*/
 );
@@ -108,7 +108,7 @@ u8 channel
 
 void
 PHY_SetSwChnlBWMode8723B(
-struct adapter *   Adapter,
+struct adapter *Adapter,
 u8 channel,
 enum CHANNEL_WIDTH Bandwidth,
 u8 Offset40,
-- 
2.25.1



Poor windows VFIO performance, GPU stalls (bisected)

2020-07-26 Thread Geoffrey McRae

Hi All,

The commit 22540ca3d00d2990a4148a13b92209c3dc5422db causes a Windows KVM 
guest running under QEMU with a VFIO passthrough GPU to randomly stall 
when using the GPU leading to the guest assuming that the driver has 
hung. Reverting this commit resolves the problem.


The host system is configured with the following kernel arguments which 
may be related:

  isolcpus=0-5,24-29,6-11,30-35 rcu_nocbs=0-5,24-29,6-11,30-35

The system is an AMD Threadripper 2970WX on a Gigabyte x399 AORUS Gaming 
7 board.
It has two GPUs each being passed through to two separate KVM guests, 
one is an AMD Radeon 7 in a Linux guest, the other is a GeForce 1080Ti 
in a Windows guest.
The cores used for these two guests are isolated from the host for 
performance reasons.


Any insight as to why this is occurring would be appreciated. If you 
need any more information or would like to test patches please let me 
know.


Kind Regards,
Geoffrey McRae
HostFission

https://hostfission.com


[PATCH] udf: use common error code for unclean filesystem

2020-07-26 Thread Pavel Machek

Use common error code for unclean filesystem, and warn when
incosistency is detected.

Signed-off-by: Pavel Machek (CIP) 

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index adaba8e8b326..8e74c7b5b8d0 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1395,7 +1395,10 @@ static int udf_read_inode(struct inode *inode, bool 
hidden_inode)
if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_SHORT &&
iinfo->i_alloc_type != ICBTAG_FLAG_AD_LONG &&
iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
-   ret = -EIO;
+   ret = -EUCLEAN;
+   udf_err(inode->i_sb, "invalid allocation type: %u\n",
+   iinfo->i_alloc_type);
+
goto out;
}
iinfo->i_unique = 0;

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: PGP signature


Re: [PATCH] net: ipv6: fix slab-out-of-bounds Read in __xfrm6_tunnel_spi_check

2020-07-26 Thread kernel test robot
Hi K,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ipsec/master]
[also build test WARNING on ipsec-next/master net-next/master net/master 
v5.8-rc6 next-20200724]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/B-K-Karthik/net-ipv6-fix-slab-out-of-bounds-Read-in-__xfrm6_tunnel_spi_check/20200725-213142
base:   https://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec.git 
master
config: x86_64-randconfig-r032-20200726 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 
8bf4c1f4fb257774f66c8cda07adc6c5e8668326)
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> net/ipv6/xfrm6_tunnel.c:106:43: warning: incompatible integer to pointer 
>> conversion passing 'u32' (aka 'unsigned int') to parameter of type 'const 
>> xfrm_address_t *' [-Wint-conversion]
   int index = xfrm6_tunnel_spi_hash_byaddr(spi);
^~~
   net/ipv6/xfrm6_tunnel.c:57:79: note: passing argument to parameter 'addr' 
here
   static inline unsigned int xfrm6_tunnel_spi_hash_byaddr(const xfrm_address_t 
*addr)

 ^
   net/ipv6/xfrm6_tunnel.c:69:28: warning: unused function 
'xfrm6_tunnel_spi_hash_byspi' [-Wunused-function]
   static inline unsigned int xfrm6_tunnel_spi_hash_byspi(u32 spi)
  ^
   2 warnings generated.

vim +106 net/ipv6/xfrm6_tunnel.c

   101  
   102  static int __xfrm6_tunnel_spi_check(struct net *net, u32 spi)
   103  {
   104  struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net);
   105  struct xfrm6_tunnel_spi *x6spi;
 > 106  int index = xfrm6_tunnel_spi_hash_byaddr(spi);
   107  
   108  hlist_for_each_entry(x6spi,
   109   _tn->spi_byaddr[index],
   110   list_byspi) {
   111  if (x6spi->spi == spi)
   112  return -1;
   113  }
   114  return index;
   115  }
   116  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


[PATCH] devices.txt: document rfkill allocation

2020-07-26 Thread Pavel Machek
Document rfkill allocation.

Signed-off-by: Pavel Machek (CIP) 

diff --git a/Documentation/admin-guide/devices.txt 
b/Documentation/admin-guide/devices.txt
index 2a97aaec8b12..763fedd94d7d 100644
--- a/Documentation/admin-guide/devices.txt
+++ b/Documentation/admin-guide/devices.txt
@@ -375,8 +375,9 @@
239 = /dev/uhid User-space I/O driver support for HID 
subsystem
240 = /dev/userio   Serio driver testing device
241 = /dev/vhost-vsock  Host kernel driver for virtio vsock
+   242 = /dev/rfkill   Turning off radio transmissions (rfkill)
 
-   242-254 Reserved for local use
+   243-254 Reserved for local use
255 Reserved for MISC_DYNAMIC_MINOR
 
   11 char  Raw keyboard device (Linux/SPARC only)

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: PGP signature


[PATCHv2 2/2] perf tools: Fix term parsing for raw syntax

2020-07-26 Thread Jiri Olsa
Jin Yao reported issue with possible conflict between raw
events and term values in pmu event syntax.

Currently following syntax is resolved as raw event with
0xead value:
  uncore_imc_free_running/read/

instead of using 'read' term from uncore_imc_free_running pmu,
because 'read' is correct raw event syntax with 0xead value.

To solve this issue we do following:
  - check existing terms during r syntax processing
and make them priority in case of conflict
  - allow pmu/r0x1234/ syntax to be able to specify conflicting
raw event (implemented in previous patch)

Also adding automated tests for this and perf_pmu__parse_cleanup
call to parse_events_terms, so the test gets properly cleaned up.

Reported-by: Jin Yao 
Signed-off-by: Jiri Olsa 
---
v2 changes:
 - added comment to perf_pmu__test_parse_init

 tools/perf/tests/parse-events.c | 37 -
 tools/perf/util/parse-events.c  | 28 +
 tools/perf/util/parse-events.h  |  2 ++
 tools/perf/util/parse-events.l  | 19 ++---
 4 files changed, 77 insertions(+), 9 deletions(-)

diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 5aaddcb0058a..7f9f87a470c3 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -631,6 +631,34 @@ static int test__checkterms_simple(struct list_head *terms)
TEST_ASSERT_VAL("wrong val", term->val.num == 1);
TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask"));
 
+   /*
+* read
+*
+* The perf_pmu__test_parse_init injects 'read' term into
+* perf_pmu_events_list, so 'read' is evaluated as read term
+* and not as raw event with 'ead' hex value.
+*/
+   term = list_entry(term->list.next, struct parse_events_term, list);
+   TEST_ASSERT_VAL("wrong type term",
+   term->type_term == PARSE_EVENTS__TERM_TYPE_USER);
+   TEST_ASSERT_VAL("wrong type val",
+   term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
+   TEST_ASSERT_VAL("wrong val", term->val.num == 1);
+   TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "read"));
+
+   /*
+* r0xead
+*
+* To be still able to pass 'ead' value with 'r' syntax,
+* we added support to parse 'r0xHEX' event.
+*/
+   term = list_entry(term->list.next, struct parse_events_term, list);
+   TEST_ASSERT_VAL("wrong type term",
+   term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG);
+   TEST_ASSERT_VAL("wrong type val",
+   term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
+   TEST_ASSERT_VAL("wrong val", term->val.num == 0xead);
+   TEST_ASSERT_VAL("wrong config", !term->config);
return 0;
 }
 
@@ -1781,7 +1809,7 @@ struct terms_test {
 
 static struct terms_test test__terms[] = {
[0] = {
-   .str   = "config=10,config1,config2=3,umask=1",
+   .str   = "config=10,config1,config2=3,umask=1,read,r0xead",
.check = test__checkterms_simple,
},
 };
@@ -1841,6 +1869,13 @@ static int test_term(struct terms_test *t)
 
INIT_LIST_HEAD();
 
+   /*
+* The perf_pmu__test_parse_init prepares perf_pmu_events_list
+* which gets freed in parse_events_terms.
+*/
+   if (perf_pmu__test_parse_init())
+   return -1;
+
ret = parse_events_terms(, t->str);
if (ret) {
pr_debug("failed to parse terms '%s', err %d\n",
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index e88e4c7a2a9a..9f7260e69113 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -2019,6 +2019,32 @@ static void perf_pmu__parse_init(void)
perf_pmu__parse_cleanup();
 }
 
+/*
+ * This function injects special term in
+ * perf_pmu_events_list so the test code
+ * can check on this functionality.
+ */
+int perf_pmu__test_parse_init(void)
+{
+   struct perf_pmu_event_symbol *list;
+
+   list = malloc(sizeof(*list) * 1);
+   if (!list)
+   return -ENOMEM;
+
+   list->type   = PMU_EVENT_SYMBOL;
+   list->symbol = strdup("read");
+
+   if (!list->symbol) {
+   free(list);
+   return -ENOMEM;
+   }
+
+   perf_pmu_events_list = list;
+   perf_pmu_events_list_num = 1;
+   return 0;
+}
+
 enum perf_pmu_event_symbol_type
 perf_pmu__parse_check(const char *name)
 {
@@ -2080,6 +2106,8 @@ int parse_events_terms(struct list_head *terms, const 
char *str)
int ret;
 
ret = parse_events__scanner(str, _state);
+   perf_pmu__parse_cleanup();
+
if (!ret) {
list_splice(parse_state.terms, terms);
zfree(_state.terms);
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index f0010095fc8c..00cde7d2e30c 100644
--- a/tools/perf/util/parse-events.h
+++ 

[PATCHv2 1/2] perf tools: Allow r0x event syntax

2020-07-26 Thread Jiri Olsa
Adding support to specify raw event with 'r0' syntax within
pmu term syntax like:

  -e cpu/r0xdead/

It will be used to specify raw events in cases where they conflict
with real pmu terms, like 'read', which is valid raw event syntax,
but also a possible pmu term name as reported by Jin Yao.

Reported-by: Jin Yao 
Acked-by: Ian Rogers 
Signed-off-by: Jiri Olsa 
---
 tools/perf/Documentation/perf-list.txt | 1 +
 tools/perf/tests/parse-events.c| 5 +
 tools/perf/util/parse-events.l | 1 +
 3 files changed, 7 insertions(+)

diff --git a/tools/perf/Documentation/perf-list.txt 
b/tools/perf/Documentation/perf-list.txt
index 376a50b3452d..10ed539a8859 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -119,6 +119,7 @@ It's also possible to use pmu syntax:
 
  perf record -e r1a8 -a sleep 1
  perf record -e cpu/r1a8/ ...
+ perf record -e cpu/r0x1a8/ ...
 
 You should refer to the processor specific documentation for getting these
 details. Some of them are referenced in the SEE ALSO section below.
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 895188b63f96..5aaddcb0058a 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1766,6 +1766,11 @@ static struct evlist_test test__events_pmu[] = {
.check = test__checkevent_raw_pmu,
.id= 4,
},
+   {
+   .name  = "software/r0x1a/",
+   .check = test__checkevent_raw_pmu,
+   .id= 4,
+   },
 };
 
 struct terms_test {
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index 56912c9641f5..44c85fea5d00 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -293,6 +293,7 @@ percore { return term(yyscanner, 
PARSE_EVENTS__TERM_TYPE_PERCORE); }
 aux-output { return term(yyscanner, 
PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT); }
 aux-sample-size{ return term(yyscanner, 
PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE); }
 r{num_raw_hex} { return raw(yyscanner); }
+r0x{num_raw_hex}   { return raw(yyscanner); }
 ,  { return ','; }
 "/"{ BEGIN(INITIAL); return '/'; }
 {name_minus}   { return str(yyscanner, PE_NAME); }
-- 
2.25.4



Re: [PATCH 2/2] perf tools: Fix term parsing for raw syntax

2020-07-26 Thread Jiri Olsa
On Sat, Jul 25, 2020 at 09:58:13AM -0700, Ian Rogers wrote:

SNIP

> > ret = parse_events_terms(, t->str);
> > if (ret) {
> > pr_debug("failed to parse terms '%s', err %d\n",
> > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> > index e88e4c7a2a9a..254f02a7fb0d 100644
> > --- a/tools/perf/util/parse-events.c
> > +++ b/tools/perf/util/parse-events.c
> > @@ -2019,6 +2019,27 @@ static void perf_pmu__parse_init(void)
> > perf_pmu__parse_cleanup();
> >  }
> >
> > +int perf_pmu__test_parse_init(void)
> > +{
> > +   struct perf_pmu_event_symbol *list;
> > +
> > +   list = malloc(sizeof(*list) * 1);
> > +   if (!list)
> > +   return -ENOMEM;
> > +
> > +   list->type   = PMU_EVENT_SYMBOL;
> > +   list->symbol = strdup("read");
> > +
> > +   if (!list->symbol) {
> > +   free(list);
> > +   return -ENOMEM;
> > +   }
> > +
> > +   perf_pmu_events_list = list;
> > +   perf_pmu_events_list_num = 1;
> > +   return 0;
> > +}
> 
> nit: It's easy to see in the test code why this is necessary, could
> the function be moved there? If not perhaps add a function comment?
> The test in the function name is quite load bearing.

both perf_pmu_events_list/cnt are static and I'd like to keep it that
way, so the function needs to be in here.. I'll add comment explaining
this

jirka



Re: get rid of the address_space override in setsockopt v2

2020-07-26 Thread David Miller
From: Christoph Hellwig 
Date: Sun, 26 Jul 2020 09:03:11 +0200

> On Fri, Jul 24, 2020 at 03:43:42PM -0700, David Miller wrote:
>> > Changes since v1:
>> >  - check that users don't pass in kernel addresses
>> >  - more bpfilter cleanups
>> >  - cosmetic mptcp tweak
>> 
>> Series applied to net-next, I'm build testing and will push this out when
>> that is done.
> 
> The buildbot found one warning with the isdn debug code after a few
> days, here is what I think is the best fix:

I already fixed this in net-next.


Re: Re: Re: Re: checkpatch: support deprecated terms checking

2020-07-26 Thread SeongJae Park
On Sun, 26 Jul 2020 00:29:05 -0700 Joe Perches  wrote:

> On Sun, 2020-07-26 at 09:18 +0200, SeongJae Park wrote:
> > On Sat, 25 Jul 2020 21:27:07 -0700 Joe Perches  wrote:
> > 
> > > On Sun, 2020-07-26 at 01:35 +0200, SeongJae Park wrote:
> > > > On Sat, 25 Jul 2020 10:29:23 -0700 Joe Perches  wrote:
> > > > 
> > > > > On Sat, 2020-07-25 at 15:02 +0200, Michał Mirosław wrote:
> > > > > > Hello,
> > > > > > 
> > > > > > I see that this patch went into next and is already inciting people 
> > > > > > to
> > > > > > do wrong things [1]. Can you please fix it to require '--subjective'
> > > > > > switch or otherwise mark it clearly as suggestion-only?
> > > > > > 
> > > > > > The coding-style as in Linus' master says about *NEW* uses of the 
> > > > > > words
> > > > > > listed (those introductions I expect to be actually rare) and not 
> > > > > > about
> > > > > > existing use in the code or industry. Making a noise about all uses
> > > > > > found surely will generate a lot more irrelevant patches.
> > > > > > 
> > > > > > [1] https://www.spinics.net/lists/linux-tegra/msg51849.html
> > > > > 
> > > > > And if not reverted, perhaps do not check existing files
> > > > > at all but only check patches and change the message to
> > > > > show only suggestions not from a specification.
> > > > 
> > > > Agreed for this case.  However, excluding existing file check doesn't 
> > > > fully
> > > > avoid this problem.  Also, more terms having different deprecation 
> > > > rules might
> > > > be added in future.  How about allowing file check but show reference 
> > > > in the
> > > > suggestion message as below?
> > > 
> > > The general problem is that drivers/staging, net/ and drivers/net
> > > all have --strict on by default.
> > > 
> > > Emitting these deprecated terms messages with -f --file uses for
> > > files in those directories isn't a great idea.
> > 
> > Thank you for kindly explaining your concenrs in detail.  However, I think 
> > it's
> > ok to do this check even without '--strict' for files if we explicitly says
> > it's suggestion only, as Michal said.  My patch does so.
> > 
> > > > diff --git a/scripts/deprecated_terms.txt b/scripts/deprecated_terms.txt
> > > []
> > > > @@ -3,8 +3,10 @@
> > > >  # The format of each line is:
> > > >  # deprecated||suggested
> > > >  #
> > > > +# If special rules are applied on the terms, please comment those.
> > > 
> > > Disagree.  Comments about these existing uses aren't helpful.
> > 
> > Sorry, I don't understand your point here.  Why do you think it's not 
> > helpful?
> > If 'checkpatch' finds the deprecated terms, it will ask people to read this
> > file, which explains special rules for each of the deprecations if exists.  
> > The
> > rule is, in the case of 'slave', 'applies to new uses only'.  Therefore, 
> > people
> > could stop sending the noisy unnecessary patches to the maintainers.
> 
> Because it will describe this for _every_ instance
> of any deprecated word in the file.

Thank you for kindly explaining your concern.  I personally thought the verbose
warning is not a real problem.  Anyway, how about below patch, then?  It will
show only one warning or check for each of the terms.

= >8 ==

>From 6c606c62ea25933db8bb0afec083b5b4b8b3f11f Mon Sep 17 00:00:00 2001
From: SeongJae Park 
Date: Sun, 26 Jul 2020 01:14:48 +0200
Subject: [PATCH] scripts/deprecatd_terms: provide references

Deprecation of terms could have special rules.  For example, 'slave' is
ok for existing usages.  Same to 'master', but it's also ok unless it's
used with 'slave'.  This commit provides the references for such rules.

Also, because the report became more verbose a little, this commit makes
the report to be made for only one instance of each deprecated term.

Signed-off-by: SeongJae Park 
---
 scripts/checkpatch.pl| 6 +-
 scripts/deprecated_terms.txt | 6 --
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e9fde28eb0de..227e088bfe56 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -721,6 +721,7 @@ sub read_word_corrections {
 my %deprecated_terms_fix;
 read_word_corrections($deprecated_terms_file, \%deprecated_terms_fix);
 my $deprecated_terms = join("|", sort keys %deprecated_terms_fix) if keys 
%deprecated_terms_fix;
+my %deprecated_terms_reported = map { $_ => 1 }
 
 # Load common spelling mistakes and build regular expression list.
 my $misspellings;
@@ -2975,13 +2976,16 @@ sub process {
($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
while ($rawline =~ 
/(?:^|[^a-z@])($deprecated_terms)(?:\b|$|[^a-z@])/gi) {
my $deprecated_term = $1;
+   last if 
(exists($deprecated_terms_reported{$deprecated_term}));
+   $deprecated_terms_reported{$deprecated_term} = 
1;
+
 

Re: [PATCH 04/21] devtmpfs: refactor devtmpfsd()

2020-07-26 Thread Greg Kroah-Hartman
On Sun, Jul 26, 2020 at 09:13:39AM +0200, Christoph Hellwig wrote:
> Split the main worker loop into a separate function.  This allows
> devtmpfsd itself and devtmpfsd_setup to be marked __init, which will
> allows us to call __init routines for the setup work.
> 
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/base/devtmpfs.c | 47 +++--
>  1 file changed, 26 insertions(+), 21 deletions(-)

Nice cleanup, thanks for doing this:

Reviewed-by: Greg Kroah-Hartman 


Re: [PATCH 1/2] lockdep: improve current->(hard|soft)irqs_enabled synchronisation with actual irq state

2020-07-26 Thread Alexey Kardashevskiy



On 24/07/2020 15:59, Nicholas Piggin wrote:
> Excerpts from Alexey Kardashevskiy's message of July 24, 2020 2:16 pm:
>>
>>
>> On 23/07/2020 23:11, Nicholas Piggin wrote:
>>> Excerpts from Peter Zijlstra's message of July 23, 2020 9:40 pm:
 On Thu, Jul 23, 2020 at 08:56:14PM +1000, Nicholas Piggin wrote:

> diff --git a/arch/powerpc/include/asm/hw_irq.h 
> b/arch/powerpc/include/asm/hw_irq.h
> index 3a0db7b0b46e..35060be09073 100644
> --- a/arch/powerpc/include/asm/hw_irq.h
> +++ b/arch/powerpc/include/asm/hw_irq.h
> @@ -200,17 +200,14 @@ static inline bool arch_irqs_disabled(void)
>  #define powerpc_local_irq_pmu_save(flags)\
>do {   \
>   raw_local_irq_pmu_save(flags);  \
> - trace_hardirqs_off();   \
> + if (!raw_irqs_disabled_flags(flags))\
> + trace_hardirqs_off();   \
>   } while(0)
>  #define powerpc_local_irq_pmu_restore(flags) \
>   do {\
> - if (raw_irqs_disabled_flags(flags)) {   \
> - raw_local_irq_pmu_restore(flags);   \
> - trace_hardirqs_off();   \
> - } else {\
> + if (!raw_irqs_disabled_flags(flags))\
>   trace_hardirqs_on();\
> - raw_local_irq_pmu_restore(flags);   \
> - }   \
> + raw_local_irq_pmu_restore(flags);   \
>   } while(0)

 You shouldn't be calling lockdep from NMI context!
>>>
>>> After this patch it doesn't.
>>>
>>> trace_hardirqs_on/off implementation appears to expect to be called in NMI 
>>> context though, for some reason.
>>>
 That is, I recently
 added suport for that on x86:

   https://lkml.kernel.org/r/20200623083721.155449...@infradead.org
   https://lkml.kernel.org/r/20200623083721.216740...@infradead.org

 But you need to be very careful on how you order things, as you can see
 the above relies on preempt_count() already having been incremented with
 NMI_MASK.
>>>
>>> Hmm. My patch seems simpler.
>>
>> And your patches fix my error while Peter's do not:
>>
>>
>> IRQs not enabled as expected
>> WARNING: CPU: 0 PID: 1377 at /home/aik/p/kernel/kernel/softirq.c:169
>> __local_bh_enable_ip+0x118/0x190
> 
> I think they would have needed some powerpc bits as well. 

True, there is quite a lot to repeat of what x86 does, I was in a hurry
and did not think it through :)

> But I don't
> see a reason we can't merge my patches, at least they fix this case and
> don't seem to make things worse in any way.

True. Or we could keep these lockdep_stats::redundant_softirqs_on/etc
and make powerpc_local_irq_pmu_restore()/local_irq_restore() call
trace_hardirqs_on() always and let lockdep do reference counting, may be?


-- 
Alexey


Re: [PATCH v2] net: ipv6: fix use-after-free Read in __xfrm6_tunnel_spi_lookup

2020-07-26 Thread kernel test robot
Hi K,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ipsec/master]
[also build test WARNING on ipsec-next/master sparc-next/master net-next/master 
net/master v5.8-rc6 next-20200724]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/B-K-Karthik/net-ipv6-fix-use-after-free-Read-in-__xfrm6_tunnel_spi_lookup/20200726-111019
base:   https://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec.git 
master
config: alpha-allyesconfig (attached as .config)
compiler: alpha-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross 
ARCH=alpha 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

   net/ipv6/xfrm6_tunnel.c: In function '__xfrm6_tunnel_spi_check':
>> net/ipv6/xfrm6_tunnel.c:106:43: warning: cast to pointer from integer of 
>> different size [-Wint-to-pointer-cast]
 106 |  int index = xfrm6_tunnel_spi_hash_byaddr((const xfrm_address_t 
*)spi);
 |   ^

vim +106 net/ipv6/xfrm6_tunnel.c

   101  
   102  static int __xfrm6_tunnel_spi_check(struct net *net, u32 spi)
   103  {
   104  struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net);
   105  struct xfrm6_tunnel_spi *x6spi;
 > 106  int index = xfrm6_tunnel_spi_hash_byaddr((const xfrm_address_t 
 > *)spi);
   107  
   108  hlist_for_each_entry(x6spi,
   109   _tn->spi_byaddr[index],
   110   list_byspi) {
   111  if (x6spi->spi == spi)
   112  return -1;
   113  }
   114  return index;
   115  }
   116  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


Re: Re: Re: checkpatch: support deprecated terms checking

2020-07-26 Thread Joe Perches
On Sun, 2020-07-26 at 09:18 +0200, SeongJae Park wrote:
> On Sat, 25 Jul 2020 21:27:07 -0700 Joe Perches  wrote:
> 
> > On Sun, 2020-07-26 at 01:35 +0200, SeongJae Park wrote:
> > > On Sat, 25 Jul 2020 10:29:23 -0700 Joe Perches  wrote:
> > > 
> > > > On Sat, 2020-07-25 at 15:02 +0200, Michał Mirosław wrote:
> > > > > Hello,
> > > > > 
> > > > > I see that this patch went into next and is already inciting people to
> > > > > do wrong things [1]. Can you please fix it to require '--subjective'
> > > > > switch or otherwise mark it clearly as suggestion-only?
> > > > > 
> > > > > The coding-style as in Linus' master says about *NEW* uses of the 
> > > > > words
> > > > > listed (those introductions I expect to be actually rare) and not 
> > > > > about
> > > > > existing use in the code or industry. Making a noise about all uses
> > > > > found surely will generate a lot more irrelevant patches.
> > > > > 
> > > > > [1] https://www.spinics.net/lists/linux-tegra/msg51849.html
> > > > 
> > > > And if not reverted, perhaps do not check existing files
> > > > at all but only check patches and change the message to
> > > > show only suggestions not from a specification.
> > > 
> > > Agreed for this case.  However, excluding existing file check doesn't 
> > > fully
> > > avoid this problem.  Also, more terms having different deprecation rules 
> > > might
> > > be added in future.  How about allowing file check but show reference in 
> > > the
> > > suggestion message as below?
> > 
> > The general problem is that drivers/staging, net/ and drivers/net
> > all have --strict on by default.
> > 
> > Emitting these deprecated terms messages with -f --file uses for
> > files in those directories isn't a great idea.
> 
> Thank you for kindly explaining your concenrs in detail.  However, I think 
> it's
> ok to do this check even without '--strict' for files if we explicitly says
> it's suggestion only, as Michal said.  My patch does so.
> 
> > > diff --git a/scripts/deprecated_terms.txt b/scripts/deprecated_terms.txt
> > []
> > > @@ -3,8 +3,10 @@
> > >  # The format of each line is:
> > >  # deprecated||suggested
> > >  #
> > > +# If special rules are applied on the terms, please comment those.
> > 
> > Disagree.  Comments about these existing uses aren't helpful.
> 
> Sorry, I don't understand your point here.  Why do you think it's not helpful?
> If 'checkpatch' finds the deprecated terms, it will ask people to read this
> file, which explains special rules for each of the deprecations if exists.  
> The
> rule is, in the case of 'slave', 'applies to new uses only'.  Therefore, 
> people
> could stop sending the noisy unnecessary patches to the maintainers.

Because it will describe this for _every_ instance
of any deprecated word in the file.




Re: Re: Re: checkpatch: support deprecated terms checking

2020-07-26 Thread SeongJae Park
On Sat, 25 Jul 2020 21:27:07 -0700 Joe Perches  wrote:

> On Sun, 2020-07-26 at 01:35 +0200, SeongJae Park wrote:
> > On Sat, 25 Jul 2020 10:29:23 -0700 Joe Perches  wrote:
> > 
> > > On Sat, 2020-07-25 at 15:02 +0200, Michał Mirosław wrote:
> > > > Hello,
> > > > 
> > > > I see that this patch went into next and is already inciting people to
> > > > do wrong things [1]. Can you please fix it to require '--subjective'
> > > > switch or otherwise mark it clearly as suggestion-only?
> > > > 
> > > > The coding-style as in Linus' master says about *NEW* uses of the words
> > > > listed (those introductions I expect to be actually rare) and not about
> > > > existing use in the code or industry. Making a noise about all uses
> > > > found surely will generate a lot more irrelevant patches.
> > > > 
> > > > [1] https://www.spinics.net/lists/linux-tegra/msg51849.html
> > > 
> > > And if not reverted, perhaps do not check existing files
> > > at all but only check patches and change the message to
> > > show only suggestions not from a specification.
> > 
> > Agreed for this case.  However, excluding existing file check doesn't fully
> > avoid this problem.  Also, more terms having different deprecation rules 
> > might
> > be added in future.  How about allowing file check but show reference in the
> > suggestion message as below?
> 
> The general problem is that drivers/staging, net/ and drivers/net
> all have --strict on by default.
> 
> Emitting these deprecated terms messages with -f --file uses for
> files in those directories isn't a great idea.

Thank you for kindly explaining your concenrs in detail.  However, I think it's
ok to do this check even without '--strict' for files if we explicitly says
it's suggestion only, as Michal said.  My patch does so.

> 
> > diff --git a/scripts/deprecated_terms.txt b/scripts/deprecated_terms.txt
> []
> > @@ -3,8 +3,10 @@
> >  # The format of each line is:
> >  # deprecated||suggested
> >  #
> > +# If special rules are applied on the terms, please comment those.
> 
> Disagree.  Comments about these existing uses aren't helpful.

Sorry, I don't understand your point here.  Why do you think it's not helpful?
If 'checkpatch' finds the deprecated terms, it will ask people to read this
file, which explains special rules for each of the deprecations if exists.  The
rule is, in the case of 'slave', 'applies to new uses only'.  Therefore, people
could stop sending the noisy unnecessary patches to the maintainers.


Thanks,
SeongJae Park

> 
> > +#
> > +# Refer to "4) Naming" section of Documentation/process/coding-style.rst 
> > for
> > +# below three terms.
> >  blacklist||(denylist|blocklist)
> > -# For other alternatives of 'slave', Please refer to
> > -# Documentation/process/coding-style.rst
> >  slave||(secondary|target|...)
> >  whitelist||(allowlist|passlist)
> 


Re: [PATCH] Module argument to control whether intel-spi-pci attempts to turn the SPI flash chip writeable

2020-07-26 Thread Greg Kroah-Hartman
On Sat, Jul 25, 2020 at 02:20:03PM -0300, Daniel Gutson wrote:
> El sáb., 25 jul. 2020 2:56 a. m., Greg Kroah-Hartman <
> gre...@linuxfoundation.org> escribió:
> 
> > On Fri, Jul 24, 2020 at 06:28:53PM -0300, Daniel Gutson wrote:
> > > Currently, intel-spi has a module argument that controls whether the
> > driver
> > > attempts to turn the SPI flash chip writeable. The default value
> > > is FALSE (don't try to make it writeable).
> > > However, this flag applies only for a number of devices, coming from the
> > > platform driver, whereas the devices detected through the PCI driver
> > > (intel-spi-pci) are not subject to this check since the configuration
> > > takes place in intel-spi-pci which doesn't have an argument.
> > >
> > > That's why I propose this patch to add such argument to intel-spi-pci,
> > > so the user can control whether the driver tries to make the chip
> > > writeable or not, being the default FALSE as is the argument of
> > > intel-spi.
> > >
> > > Signed-off-by: Daniel Gutson 
> > > ---
> > >  drivers/mtd/spi-nor/controllers/intel-spi-pci.c | 16 +++-
> > >  1 file changed, 11 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/mtd/spi-nor/controllers/intel-spi-pci.c
> > b/drivers/mtd/spi-nor/controllers/intel-spi-pci.c
> > > index 81329f680bec..77e57450f166 100644
> > > --- a/drivers/mtd/spi-nor/controllers/intel-spi-pci.c
> > > +++ b/drivers/mtd/spi-nor/controllers/intel-spi-pci.c
> > > @@ -24,6 +24,10 @@ static const struct intel_spi_boardinfo cnl_info = {
> > >   .type = INTEL_SPI_CNL,
> > >  };
> > >
> > > +static bool writeable;
> > > +module_param(writeable, bool, 0);
> > > +MODULE_PARM_DESC(writeable, "Enable write access to SPI flash chip
> > (default=0)");
> >
> > Ick, this isn't the 1990's, please do not add new module parameters,
> > they are a major pain to work with and only work on a global basis, not
> > on a per-device basis.
> >
> > No user will remember how to use this, as it isn't documented anywhere
> > either.  Can you make this a sysfs attribute or something, or better
> > yet, make it "just work" depending on the device type?
> >
> 
> 1) I just did the same that intel-spi.c does.

No need to copy bad examples :)

> You need to understand that there's a set of DIDs coming from the
> lpc_ich (and then the platform) driver, and another set from
> intel-spi-pci. The first set is subject to the check, the second
> doesn't. So there is no "just work" as I understand it.

I have no idea what "DID" is here, sorry.

But why do you want to write it?

> 2) this is an initialization argument, I could make it always NOT attempt
> to make the chip writable, and a system attribute to turn it writable
> post-initialization but the behavior is not the same. In any ways, as I
> mentioned before, some DIDs will be covered by the existing argument of
> intel-spi and other DIDs by this sysfs attribute, becoming IMHO
> inconsistent from the user POV.

What sysfs attribute?  This is a module parameter :(

totally confused,

greg k-h


[PATCH 01/21] fs: refactor do_mount

2020-07-26 Thread Christoph Hellwig
Factor out a path_mount helper that takes a struct path * instead of the
actual file name.  This will allow to convert the init and devtmpfs code
to properly mount based on a kernel pointer instead of relying on the
implicit set_fs(KERNEL_DS) during early init.

Signed-off-by: Christoph Hellwig 
---
 fs/namespace.c | 67 ++
 1 file changed, 35 insertions(+), 32 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index f30ed401cc6d7a..6f8234f74bed90 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3115,12 +3115,11 @@ char *copy_mount_string(const void __user *data)
  * Therefore, if this magic number is present, it carries no information
  * and must be discarded.
  */
-long do_mount(const char *dev_name, const char __user *dir_name,
+static int path_mount(const char *dev_name, struct path *path,
const char *type_page, unsigned long flags, void *data_page)
 {
-   struct path path;
unsigned int mnt_flags = 0, sb_flags;
-   int retval = 0;
+   int ret;
 
/* Discard magic */
if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
@@ -3133,19 +3132,13 @@ long do_mount(const char *dev_name, const char __user 
*dir_name,
if (flags & MS_NOUSER)
return -EINVAL;
 
-   /* ... and get the mountpoint */
-   retval = user_path_at(AT_FDCWD, dir_name, LOOKUP_FOLLOW, );
-   if (retval)
-   return retval;
-
-   retval = security_sb_mount(dev_name, ,
-  type_page, flags, data_page);
-   if (!retval && !may_mount())
-   retval = -EPERM;
-   if (!retval && (flags & SB_MANDLOCK) && !may_mandlock())
-   retval = -EPERM;
-   if (retval)
-   goto dput_out;
+   ret = security_sb_mount(dev_name, path, type_page, flags, data_page);
+   if (ret)
+   return ret;
+   if (!may_mount())
+   return -EPERM;
+   if ((flags & SB_MANDLOCK) && !may_mandlock())
+   return -EPERM;
 
/* Default to relatime unless overriden */
if (!(flags & MS_NOATIME))
@@ -3172,7 +3165,7 @@ long do_mount(const char *dev_name, const char __user 
*dir_name,
((flags & (MS_NOATIME | MS_NODIRATIME | MS_RELATIME |
   MS_STRICTATIME)) == 0)) {
mnt_flags &= ~MNT_ATIME_MASK;
-   mnt_flags |= path.mnt->mnt_flags & MNT_ATIME_MASK;
+   mnt_flags |= path->mnt->mnt_flags & MNT_ATIME_MASK;
}
 
sb_flags = flags & (SB_RDONLY |
@@ -3185,22 +3178,32 @@ long do_mount(const char *dev_name, const char __user 
*dir_name,
SB_I_VERSION);
 
if ((flags & (MS_REMOUNT | MS_BIND)) == (MS_REMOUNT | MS_BIND))
-   retval = do_reconfigure_mnt(, mnt_flags);
-   else if (flags & MS_REMOUNT)
-   retval = do_remount(, flags, sb_flags, mnt_flags,
-   data_page);
-   else if (flags & MS_BIND)
-   retval = do_loopback(, dev_name, flags & MS_REC);
-   else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
-   retval = do_change_type(, flags);
-   else if (flags & MS_MOVE)
-   retval = do_move_mount_old(, dev_name);
-   else
-   retval = do_new_mount(, type_page, sb_flags, mnt_flags,
- dev_name, data_page);
-dput_out:
+   return do_reconfigure_mnt(path, mnt_flags);
+   if (flags & MS_REMOUNT)
+   return do_remount(path, flags, sb_flags, mnt_flags, data_page);
+   if (flags & MS_BIND)
+   return do_loopback(path, dev_name, flags & MS_REC);
+   if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
+   return do_change_type(path, flags);
+   if (flags & MS_MOVE)
+   return do_move_mount_old(path, dev_name);
+
+   return do_new_mount(path, type_page, sb_flags, mnt_flags, dev_name,
+   data_page);
+}
+
+long do_mount(const char *dev_name, const char __user *dir_name,
+   const char *type_page, unsigned long flags, void *data_page)
+{
+   struct path path;
+   int ret;
+
+   ret = user_path_at(AT_FDCWD, dir_name, LOOKUP_FOLLOW, );
+   if (ret)
+   return ret;
+   ret = path_mount(dev_name, , type_page, flags, data_page);
path_put();
-   return retval;
+   return ret;
 }
 
 static struct ucounts *inc_mnt_namespaces(struct user_namespace *ns)
-- 
2.27.0



[PATCH 05/21] init: initialize ramdisk_execute_command at compile time

2020-07-26 Thread Christoph Hellwig
Set ramdisk_execute_command to "/init" at compile time.  The command
line can still override it, but this saves a few instructions and
removes a NULL check.

Signed-off-by: Christoph Hellwig 
---
 init/main.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/init/main.c b/init/main.c
index db0621dfbb0468..c2c9143db96795 100644
--- a/init/main.c
+++ b/init/main.c
@@ -154,7 +154,7 @@ static bool initargs_found;
 #endif
 
 static char *execute_command;
-static char *ramdisk_execute_command;
+static char *ramdisk_execute_command = "/init";
 
 /*
  * Used to generate warnings if static_key manipulation functions are used
@@ -1514,10 +1514,6 @@ static noinline void __init kernel_init_freeable(void)
 * check if there is an early userspace init.  If yes, let it do all
 * the work
 */
-
-   if (!ramdisk_execute_command)
-   ramdisk_execute_command = "/init";
-
if (ksys_access((const char __user *)
ramdisk_execute_command, 0) != 0) {
ramdisk_execute_command = NULL;
-- 
2.27.0



[PATCH 17/21] init: add an init_symlink helper

2020-07-26 Thread Christoph Hellwig
Add a simple helper to symlink with a kernel space file name and switch
the early init code over to it.  Remove the now unused ksys_symlink.

Signed-off-by: Christoph Hellwig 
---
 fs/for_init.c | 16 
 fs/internal.h |  2 --
 fs/namei.c|  2 +-
 include/linux/init_syscalls.h |  1 +
 include/linux/syscalls.h  |  9 -
 init/initramfs.c  |  2 +-
 6 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/fs/for_init.c b/fs/for_init.c
index 339ac1a52ca150..082ff1004f06b3 100644
--- a/fs/for_init.c
+++ b/fs/for_init.c
@@ -151,6 +151,22 @@ int __init init_link(const char *oldname, const char 
*newname)
return error;
 }
 
+int __init init_symlink(const char *oldname, const char *newname)
+{
+   struct dentry *dentry;
+   struct path path;
+   int error;
+
+   dentry = kern_path_create(AT_FDCWD, newname, , 0);
+   if (IS_ERR(dentry))
+   return PTR_ERR(dentry);
+   error = security_path_symlink(, dentry, oldname);
+   if (!error)
+   error = vfs_symlink(path.dentry->d_inode, dentry, oldname);
+   done_path_create(, dentry);
+   return error;
+}
+
 int __init init_unlink(const char *pathname)
 {
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
diff --git a/fs/internal.h b/fs/internal.h
index 58451b033d2698..40b50a222d7a22 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -67,8 +67,6 @@ long do_mknodat(int dfd, const char __user *filename, umode_t 
mode,
 long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
 long do_rmdir(int dfd, struct filename *name);
 long do_unlinkat(int dfd, struct filename *name);
-long do_symlinkat(const char __user *oldname, int newdfd,
- const char __user *newname);
 int may_linkat(struct path *link);
 
 /*
diff --git a/fs/namei.c b/fs/namei.c
index 13de64c6be7640..2f6fa53eb3da28 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3955,7 +3955,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, 
const char *oldname)
 }
 EXPORT_SYMBOL(vfs_symlink);
 
-long do_symlinkat(const char __user *oldname, int newdfd,
+static long do_symlinkat(const char __user *oldname, int newdfd,
  const char __user *newname)
 {
int error;
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index 5ca15a5b55b7d7..125f55ae3f80b8 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -9,5 +9,6 @@ int __init init_chown(const char *filename, uid_t user, gid_t 
group, int flags);
 int __init init_chmod(const char *filename, umode_t mode);
 int __init init_eaccess(const char *filename);
 int __init init_link(const char *oldname, const char *newname);
+int __init init_symlink(const char *oldname, const char *newname);
 int __init init_unlink(const char *pathname);
 int __init init_rmdir(const char *pathname);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 4b18b91ce46573..7cdc0d749a049f 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1277,15 +1277,6 @@ static inline long ksys_mkdir(const char __user 
*pathname, umode_t mode)
return do_mkdirat(AT_FDCWD, pathname, mode);
 }
 
-extern long do_symlinkat(const char __user *oldname, int newdfd,
-const char __user *newname);
-
-static inline long ksys_symlink(const char __user *oldname,
-   const char __user *newname)
-{
-   return do_symlinkat(oldname, AT_FDCWD, newname);
-}
-
 extern long do_mknodat(int dfd, const char __user *filename, umode_t mode,
   unsigned int dev);
 
diff --git a/init/initramfs.c b/init/initramfs.c
index 48c137142fed7f..889c470b0c2aba 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -390,7 +390,7 @@ static int __init do_symlink(void)
 {
collected[N_ALIGN(name_len) + body_len] = '\0';
clean_path(collected, 0);
-   ksys_symlink(collected + N_ALIGN(name_len), collected);
+   init_symlink(collected + N_ALIGN(name_len), collected);
init_chown(collected, uid, gid, AT_SYMLINK_NOFOLLOW);
do_utime(collected, mtime);
state = SkipIt;
-- 
2.27.0



[PATCH 21/21] init: add an init_utimes helper

2020-07-26 Thread Christoph Hellwig
Add a simple helper to set timestamps with a kernel space file name and
switch the early init code over to it.

Signed-off-by: Christoph Hellwig 
---
 fs/for_init.c | 13 +
 include/linux/init_syscalls.h |  1 +
 init/initramfs.c  |  3 +--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/fs/for_init.c b/fs/for_init.c
index 919a50130a5919..4eee11ad63ffce 100644
--- a/fs/for_init.c
+++ b/fs/for_init.c
@@ -234,3 +234,16 @@ int __init init_rmdir(const char *pathname)
 {
return do_rmdir(AT_FDCWD, getname_kernel(pathname));
 }
+
+int __init init_utimes(char *filename, struct timespec64 *ts)
+{
+   struct path path;
+   int error;
+
+   error = kern_path(filename, 0, );
+   if (error)
+   return error;
+   error = vfs_utimes(, ts);
+   path_put();
+   return error;
+}
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index b2fda50daca6c5..3654b525ac0b17 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -15,3 +15,4 @@ int __init init_symlink(const char *oldname, const char 
*newname);
 int __init init_unlink(const char *pathname);
 int __init init_mkdir(const char *pathname, umode_t mode);
 int __init init_rmdir(const char *pathname);
+int __init init_utimes(char *filename, struct timespec64 *ts);
diff --git a/init/initramfs.c b/init/initramfs.c
index b1be3ada3ce4b3..b9dfc941a4c3e4 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -110,8 +110,7 @@ static long __init do_utime(char *filename, time64_t mtime)
t[0].tv_nsec = 0;
t[1].tv_sec = mtime;
t[1].tv_nsec = 0;
-
-   return do_utimes(AT_FDCWD, filename, t, AT_SYMLINK_NOFOLLOW);
+   return init_utimes(filename, t);
 }
 
 static __initdata LIST_HEAD(dir_list);
-- 
2.27.0



[PATCH 14/21] init: add an init_chmod helper

2020-07-26 Thread Christoph Hellwig
Add a simple helper to chmod with a kernel space file name and switch
the early init code over to it.

Signed-off-by: Christoph Hellwig 
---
 fs/for_init.c | 13 +
 fs/internal.h |  2 +-
 fs/open.c |  4 ++--
 include/linux/init_syscalls.h |  1 +
 include/linux/syscalls.h  |  7 ---
 init/initramfs.c  |  4 ++--
 6 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/fs/for_init.c b/fs/for_init.c
index 0541851d86f42e..098e9b69c32ef6 100644
--- a/fs/for_init.c
+++ b/fs/for_init.c
@@ -92,6 +92,19 @@ int __init init_chown(const char *filename, uid_t user, 
gid_t group, int flags)
return error;
 }
 
+int __init init_chmod(const char *filename, umode_t mode)
+{
+   struct path path;
+   int error;
+
+   error = kern_path(filename, LOOKUP_FOLLOW, );
+   if (error)
+   return error;
+   error = chmod_common(, mode);
+   path_put();
+   return error;
+}
+
 int __init init_unlink(const char *pathname)
 {
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
diff --git a/fs/internal.h b/fs/internal.h
index e81b9e23c3ea3f..6d82681c7d8372 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -131,7 +131,7 @@ extern struct open_how build_open_how(int flags, umode_t 
mode);
 extern int build_open_flags(const struct open_how *how, struct open_flags *op);
 
 long do_sys_ftruncate(unsigned int fd, loff_t length, int small);
-int do_fchmodat(int dfd, const char __user *filename, umode_t mode);
+int chmod_common(const struct path *path, umode_t mode);
 int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group,
int flag);
 int chown_common(const struct path *path, uid_t user, gid_t group);
diff --git a/fs/open.c b/fs/open.c
index 49960a1248f14b..7ba89eae46c560 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -563,7 +563,7 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename)
return error;
 }
 
-static int chmod_common(const struct path *path, umode_t mode)
+int chmod_common(const struct path *path, umode_t mode)
 {
struct inode *inode = path->dentry->d_inode;
struct inode *delegated_inode = NULL;
@@ -610,7 +610,7 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
return err;
 }
 
-int do_fchmodat(int dfd, const char __user *filename, umode_t mode)
+static int do_fchmodat(int dfd, const char __user *filename, umode_t mode)
 {
struct path path;
int error;
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index 0da59d76133e17..2b1b4dc586825f 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -6,5 +6,6 @@ int __init init_umount(const char *name, int flags);
 int __init init_chdir(const char *filename);
 int __init init_chroot(const char *filename);
 int __init init_chown(const char *filename, uid_t user, gid_t group, int 
flags);
+int __init init_chmod(const char *filename, umode_t mode);
 int __init init_unlink(const char *pathname);
 int __init init_rmdir(const char *pathname);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index e89d62e944dc0e..8b71fa321ca20c 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1304,13 +1304,6 @@ static inline long ksys_link(const char __user *oldname,
return do_linkat(AT_FDCWD, oldname, AT_FDCWD, newname, 0);
 }
 
-extern int do_fchmodat(int dfd, const char __user *filename, umode_t mode);
-
-static inline int ksys_chmod(const char __user *filename, umode_t mode)
-{
-   return do_fchmodat(AT_FDCWD, filename, mode);
-}
-
 long do_faccessat(int dfd, const char __user *filename, int mode, int flags);
 
 static inline long ksys_access(const char __user *filename, int mode)
diff --git a/init/initramfs.c b/init/initramfs.c
index 919b40fb07bada..f2ec2f024f9e67 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -347,14 +347,14 @@ static int __init do_name(void)
} else if (S_ISDIR(mode)) {
ksys_mkdir(collected, mode);
init_chown(collected, uid, gid, 0);
-   ksys_chmod(collected, mode);
+   init_chmod(collected, mode);
dir_add(collected, mtime);
} else if (S_ISBLK(mode) || S_ISCHR(mode) ||
   S_ISFIFO(mode) || S_ISSOCK(mode)) {
if (maybe_link() == 0) {
ksys_mknod(collected, mode, rdev);
init_chown(collected, uid, gid, 0);
-   ksys_chmod(collected, mode);
+   init_chmod(collected, mode);
do_utime(collected, mtime);
}
}
-- 
2.27.0



[PATCH 08/21] init: add an init_umount helper

2020-07-26 Thread Christoph Hellwig
Like ksys_umount, but takes a kernel pointer for the destination path.
Switch over the umount in the init code, which just happen to work due to
the implicit set_fs(KERNEL_DS) during early init right now.

Signed-off-by: Christoph Hellwig 
---
 fs/for_init.c | 14 ++
 fs/internal.h |  1 +
 fs/namespace.c|  4 ++--
 include/linux/init_syscalls.h |  1 +
 include/linux/syscalls.h  |  1 -
 init/do_mounts_initrd.c   |  2 +-
 6 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/fs/for_init.c b/fs/for_init.c
index 6a04cc8d8557c4..7a039b6d107c92 100644
--- a/fs/for_init.c
+++ b/fs/for_init.c
@@ -19,3 +19,17 @@ int __init init_mount(const char *dev_name, const char 
*dir_name,
path_put();
return ret;
 }
+
+int __init init_umount(const char *name, int flags)
+{
+   int lookup_flags = LOOKUP_MOUNTPOINT;
+   struct path path;
+   int ret;
+
+   if (!(flags & UMOUNT_NOFOLLOW))
+   lookup_flags |= LOOKUP_FOLLOW;
+   ret = kern_path(name, lookup_flags, );
+   if (ret)
+   return ret;
+   return path_umount(, flags);
+}
diff --git a/fs/internal.h b/fs/internal.h
index 72ea0b6f7435a4..491d1e63809b37 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -92,6 +92,7 @@ extern void dissolve_on_fput(struct vfsmount *);
 
 int path_mount(const char *dev_name, struct path *path,
const char *type_page, unsigned long flags, void *data_page);
+int path_umount(struct path *path, int flags);
 
 /*
  * fs_struct.c
diff --git a/fs/namespace.c b/fs/namespace.c
index 2c4d7592097485..a7301790abb211 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1706,7 +1706,7 @@ static inline bool may_mandlock(void)
 }
 #endif
 
-static int path_umount(struct path *path, int flags)
+int path_umount(struct path *path, int flags)
 {
struct mount *mnt;
int retval;
@@ -1736,7 +1736,7 @@ static int path_umount(struct path *path, int flags)
return retval;
 }
 
-int ksys_umount(char __user *name, int flags)
+static int ksys_umount(char __user *name, int flags)
 {
int lookup_flags = LOOKUP_MOUNTPOINT;
struct path path;
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index af9ea88a60e0bd..a5a2e7f1991691 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -2,3 +2,4 @@
 
 int __init init_mount(const char *dev_name, const char *dir_name,
const char *type_page, unsigned long flags, void *data_page);
+int __init init_umount(const char *name, int flags);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index e43816198e6001..1a4f5d8ee7044b 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1236,7 +1236,6 @@ asmlinkage long sys_ni_syscall(void);
  * the ksys_xyzyyz() functions prototyped below.
  */
 
-int ksys_umount(char __user *name, int flags);
 int ksys_chroot(const char __user *filename);
 ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count);
 int ksys_chdir(const char __user *filename);
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index 1f9336209ad9cc..6b020a06990251 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -122,7 +122,7 @@ static void __init handle_initrd(void)
else
printk("failed\n");
printk(KERN_NOTICE "Unmounting old root\n");
-   ksys_umount("/old", MNT_DETACH);
+   init_umount("/old", MNT_DETACH);
}
 }
 
-- 
2.27.0



[PATCH 10/21] init: add an init_rmdir helper

2020-07-26 Thread Christoph Hellwig
Add a simple helper to rmdir with a kernel space file name and switch
the early init code over to it.  Remove the now unused ksys_rmdir.

Signed-off-by: Christoph Hellwig 
---
 fs/for_init.c | 5 +
 include/linux/init_syscalls.h | 1 +
 include/linux/syscalls.h  | 7 ---
 init/initramfs.c  | 2 +-
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/fs/for_init.c b/fs/for_init.c
index 32472206d64136..1f10ebe78c1ba1 100644
--- a/fs/for_init.c
+++ b/fs/for_init.c
@@ -38,3 +38,8 @@ int __init init_unlink(const char *pathname)
 {
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
 }
+
+int __init init_rmdir(const char *pathname)
+{
+   return do_rmdir(AT_FDCWD, getname_kernel(pathname));
+}
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index 00d597249549ee..abf3af563c0b3a 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -4,3 +4,4 @@ int __init init_mount(const char *dev_name, const char 
*dir_name,
const char *type_page, unsigned long flags, void *data_page);
 int __init init_umount(const char *name, int flags);
 int __init init_unlink(const char *pathname);
+int __init init_rmdir(const char *pathname);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 26f9738e5ab861..a7b14258d245e2 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1273,13 +1273,6 @@ int compat_ksys_ipc(u32 call, int first, int second,
  * The following kernel syscall equivalents are just wrappers to fs-internal
  * functions. Therefore, provide stubs to be inlined at the callsites.
  */
-long do_rmdir(int dfd, struct filename *name);
-
-static inline long ksys_rmdir(const char __user *pathname)
-{
-   return do_rmdir(AT_FDCWD, getname(pathname));
-}
-
 extern long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
 
 static inline long ksys_mkdir(const char __user *pathname, umode_t mode)
diff --git a/init/initramfs.c b/init/initramfs.c
index 574ab3755203da..1ceba88cfcc052 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -299,7 +299,7 @@ static void __init clean_path(char *path, umode_t fmode)
 
if (!vfs_lstat(path, ) && (st.mode ^ fmode) & S_IFMT) {
if (S_ISDIR(st.mode))
-   ksys_rmdir(path);
+   init_rmdir(path);
else
init_unlink(path);
}
-- 
2.27.0



[PATCH 15/21] init: add an init_eaccess helper

2020-07-26 Thread Christoph Hellwig
Add a simple helper to check if a file exists based on kernel space file
name and switch the early init code over to it.  Note that this
theoretically changes behavior as it always is based on the effective
permissions.  But during early init that doesn't make a difference.

Signed-off-by: Christoph Hellwig 
---
 fs/for_init.c | 13 +
 fs/open.c |  2 +-
 include/linux/init_syscalls.h |  1 +
 include/linux/syscalls.h  |  7 ---
 init/main.c   |  4 ++--
 5 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/fs/for_init.c b/fs/for_init.c
index 098e9b69c32ef6..abc152f41e648b 100644
--- a/fs/for_init.c
+++ b/fs/for_init.c
@@ -105,6 +105,19 @@ int __init init_chmod(const char *filename, umode_t mode)
return error;
 }
 
+int __init init_eaccess(const char *filename)
+{
+   struct path path;
+   int error;
+
+   error = kern_path(filename, LOOKUP_FOLLOW, );
+   if (error)
+   return error;
+   error = inode_permission(d_inode(path.dentry), MAY_ACCESS);
+   path_put();
+   return error;
+}
+
 int __init init_unlink(const char *pathname)
 {
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
diff --git a/fs/open.c b/fs/open.c
index 7ba89eae46c560..aafecd1f7ba1a5 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -394,7 +394,7 @@ static const struct cred *access_override_creds(void)
return old_cred;
 }
 
-long do_faccessat(int dfd, const char __user *filename, int mode, int flags)
+static long do_faccessat(int dfd, const char __user *filename, int mode, int 
flags)
 {
struct path path;
struct inode *inode;
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index 2b1b4dc586825f..7031c0934bee9f 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -7,5 +7,6 @@ int __init init_chdir(const char *filename);
 int __init init_chroot(const char *filename);
 int __init init_chown(const char *filename, uid_t user, gid_t group, int 
flags);
 int __init init_chmod(const char *filename, umode_t mode);
+int __init init_eaccess(const char *filename);
 int __init init_unlink(const char *pathname);
 int __init init_rmdir(const char *pathname);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 8b71fa321ca20c..a2779638e41445 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1304,13 +1304,6 @@ static inline long ksys_link(const char __user *oldname,
return do_linkat(AT_FDCWD, oldname, AT_FDCWD, newname, 0);
 }
 
-long do_faccessat(int dfd, const char __user *filename, int mode, int flags);
-
-static inline long ksys_access(const char __user *filename, int mode)
-{
-   return do_faccessat(AT_FDCWD, filename, mode, 0);
-}
-
 extern int do_fchownat(int dfd, const char __user *filename, uid_t user,
   gid_t group, int flag);
 
diff --git a/init/main.c b/init/main.c
index c2c9143db96795..6e2a4a078b78c4 100644
--- a/init/main.c
+++ b/init/main.c
@@ -96,6 +96,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1514,8 +1515,7 @@ static noinline void __init kernel_init_freeable(void)
 * check if there is an early userspace init.  If yes, let it do all
 * the work
 */
-   if (ksys_access((const char __user *)
-   ramdisk_execute_command, 0) != 0) {
+   if (init_eaccess(ramdisk_execute_command) != 0) {
ramdisk_execute_command = NULL;
prepare_namespace();
}
-- 
2.27.0



[PATCH 02/21] fs: refactor ksys_umount

2020-07-26 Thread Christoph Hellwig
Factor out a path_umount helper that takes a struct path * instead of the
actual file name.  This will allow to convert the init and devtmpfs code
to properly mount based on a kernel pointer instead of relying on the
implicit set_fs(KERNEL_DS) during early init.

Signed-off-by: Christoph Hellwig 
---
 fs/namespace.c | 40 ++--
 1 file changed, 18 insertions(+), 22 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 6f8234f74bed90..43834b59eff6c3 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1706,36 +1706,19 @@ static inline bool may_mandlock(void)
 }
 #endif
 
-/*
- * Now umount can handle mount points as well as block devices.
- * This is important for filesystems which use unnamed block devices.
- *
- * We now support a flag for forced unmount like the other 'big iron'
- * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
- */
-
-int ksys_umount(char __user *name, int flags)
+static int path_umount(struct path *path, int flags)
 {
-   struct path path;
struct mount *mnt;
int retval;
-   int lookup_flags = LOOKUP_MOUNTPOINT;
 
if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW))
return -EINVAL;
-
if (!may_mount())
return -EPERM;
 
-   if (!(flags & UMOUNT_NOFOLLOW))
-   lookup_flags |= LOOKUP_FOLLOW;
-
-   retval = user_path_at(AT_FDCWD, name, lookup_flags, );
-   if (retval)
-   goto out;
-   mnt = real_mount(path.mnt);
+   mnt = real_mount(path->mnt);
retval = -EINVAL;
-   if (path.dentry != path.mnt->mnt_root)
+   if (path->dentry != path->mnt->mnt_root)
goto dput_and_out;
if (!check_mnt(mnt))
goto dput_and_out;
@@ -1748,12 +1731,25 @@ int ksys_umount(char __user *name, int flags)
retval = do_umount(mnt, flags);
 dput_and_out:
/* we mustn't call path_put() as that would clear mnt_expiry_mark */
-   dput(path.dentry);
+   dput(path->dentry);
mntput_no_expire(mnt);
-out:
return retval;
 }
 
+int ksys_umount(char __user *name, int flags)
+{
+   int lookup_flags = LOOKUP_MOUNTPOINT;
+   struct path path;
+   int ret;
+
+   if (!(flags & UMOUNT_NOFOLLOW))
+   lookup_flags |= LOOKUP_FOLLOW;
+   ret = user_path_at(AT_FDCWD, name, lookup_flags, );
+   if (ret)
+   return ret;
+   return path_umount(, flags);
+}
+
 SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
 {
return ksys_umount(name, flags);
-- 
2.27.0



[PATCH 13/21] init: add an init_chown helper

2020-07-26 Thread Christoph Hellwig
Add a simple helper to chown with a kernel space file name and switch
the early init code over to it.

Signed-off-by: Christoph Hellwig 
---
 fs/for_init.c | 18 ++
 fs/internal.h |  2 +-
 fs/open.c |  2 +-
 include/linux/init_syscalls.h |  1 +
 init/initramfs.c  |  6 +++---
 5 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/fs/for_init.c b/fs/for_init.c
index 2d5428b7dc1420..0541851d86f42e 100644
--- a/fs/for_init.c
+++ b/fs/for_init.c
@@ -74,6 +74,24 @@ int __init init_chroot(const char *filename)
return error;
 }
 
+int __init init_chown(const char *filename, uid_t user, gid_t group, int flags)
+{
+   int lookup_flags = (flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
+   struct path path;
+   int error;
+
+   error = kern_path(filename, lookup_flags, );
+   if (error)
+   return error;
+   error = mnt_want_write(path.mnt);
+   if (!error) {
+   error = chown_common(, user, group);
+   mnt_drop_write(path.mnt);
+   }
+   path_put();
+   return error;
+}
+
 int __init init_unlink(const char *pathname)
 {
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
diff --git a/fs/internal.h b/fs/internal.h
index 491d1e63809b37..e81b9e23c3ea3f 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -134,7 +134,7 @@ long do_sys_ftruncate(unsigned int fd, loff_t length, int 
small);
 int do_fchmodat(int dfd, const char __user *filename, umode_t mode);
 int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group,
int flag);
-
+int chown_common(const struct path *path, uid_t user, gid_t group);
 extern int vfs_open(const struct path *, struct file *);
 
 /*
diff --git a/fs/open.c b/fs/open.c
index f62f4752bb436d..49960a1248f14b 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -639,7 +639,7 @@ SYSCALL_DEFINE2(chmod, const char __user *, filename, 
umode_t, mode)
return do_fchmodat(AT_FDCWD, filename, mode);
 }
 
-static int chown_common(const struct path *path, uid_t user, gid_t group)
+int chown_common(const struct path *path, uid_t user, gid_t group)
 {
struct inode *inode = path->dentry->d_inode;
struct inode *delegated_inode = NULL;
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index e07099a14b91db..0da59d76133e17 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -5,5 +5,6 @@ int __init init_mount(const char *dev_name, const char 
*dir_name,
 int __init init_umount(const char *name, int flags);
 int __init init_chdir(const char *filename);
 int __init init_chroot(const char *filename);
+int __init init_chown(const char *filename, uid_t user, gid_t group, int 
flags);
 int __init init_unlink(const char *pathname);
 int __init init_rmdir(const char *pathname);
diff --git a/init/initramfs.c b/init/initramfs.c
index 1ceba88cfcc052..919b40fb07bada 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -346,14 +346,14 @@ static int __init do_name(void)
}
} else if (S_ISDIR(mode)) {
ksys_mkdir(collected, mode);
-   ksys_chown(collected, uid, gid);
+   init_chown(collected, uid, gid, 0);
ksys_chmod(collected, mode);
dir_add(collected, mtime);
} else if (S_ISBLK(mode) || S_ISCHR(mode) ||
   S_ISFIFO(mode) || S_ISSOCK(mode)) {
if (maybe_link() == 0) {
ksys_mknod(collected, mode, rdev);
-   ksys_chown(collected, uid, gid);
+   init_chown(collected, uid, gid, 0);
ksys_chmod(collected, mode);
do_utime(collected, mtime);
}
@@ -391,7 +391,7 @@ static int __init do_symlink(void)
collected[N_ALIGN(name_len) + body_len] = '\0';
clean_path(collected, 0);
ksys_symlink(collected + N_ALIGN(name_len), collected);
-   ksys_lchown(collected, uid, gid);
+   init_chown(collected, uid, gid, AT_SYMLINK_NOFOLLOW);
do_utime(collected, mtime);
state = SkipIt;
next_state = Reset;
-- 
2.27.0



[PATCH 20/21] init: add an init_stat helper

2020-07-26 Thread Christoph Hellwig
Add a simple helper to stat with a kernel space file name and switch
the early init code over to it.

Signed-off-by: Christoph Hellwig 
---
 drivers/md/md-autodetect.c|  3 ++-
 fs/for_init.c | 15 +++
 include/linux/init_syscalls.h |  1 +
 init/initramfs.c  |  3 ++-
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/md/md-autodetect.c b/drivers/md/md-autodetect.c
index 14b6e86814c061..6bbec89976a748 100644
--- a/drivers/md/md-autodetect.c
+++ b/drivers/md/md-autodetect.c
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -151,7 +152,7 @@ static void __init md_setup_drive(struct md_setup_args 
*args)
if (strncmp(devname, "/dev/", 5) == 0)
devname += 5;
snprintf(comp_name, 63, "/dev/%s", devname);
-   if (vfs_stat(comp_name, ) == 0 && S_ISBLK(stat.mode))
+   if (init_stat(comp_name, , 0) == 0 && S_ISBLK(stat.mode))
dev = new_decode_dev(stat.rdev);
if (!dev) {
pr_warn("md: Unknown device name: %s\n", devname);
diff --git a/fs/for_init.c b/fs/for_init.c
index 50813d2913b57b..919a50130a5919 100644
--- a/fs/for_init.c
+++ b/fs/for_init.c
@@ -118,6 +118,21 @@ int __init init_eaccess(const char *filename)
return error;
 }
 
+int __init init_stat(const char *filename, struct kstat *stat, int flags)
+{
+   int lookup_flags = (flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
+   struct path path;
+   int error;
+
+   error = kern_path(filename, lookup_flags, );
+   if (error)
+   return error;
+   error = vfs_getattr(, stat, STATX_BASIC_STATS,
+   flags | AT_NO_AUTOMOUNT);
+   path_put();
+   return error;
+}
+
 int __init init_mknod(const char *filename, umode_t mode, unsigned int dev)
 {
struct dentry *dentry;
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index fa1fe7a877795f..b2fda50daca6c5 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -8,6 +8,7 @@ int __init init_chroot(const char *filename);
 int __init init_chown(const char *filename, uid_t user, gid_t group, int 
flags);
 int __init init_chmod(const char *filename, umode_t mode);
 int __init init_eaccess(const char *filename);
+int __init init_stat(const char *filename, struct kstat *stat, int flags);
 int __init init_mknod(const char *filename, umode_t mode, unsigned int dev);
 int __init init_link(const char *oldname, const char *newname);
 int __init init_symlink(const char *oldname, const char *newname);
diff --git a/init/initramfs.c b/init/initramfs.c
index 9b2d93a2eb5e4b..b1be3ada3ce4b3 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -297,7 +297,8 @@ static void __init clean_path(char *path, umode_t fmode)
 {
struct kstat st;
 
-   if (!vfs_lstat(path, ) && (st.mode ^ fmode) & S_IFMT) {
+   if (init_stat(path, , AT_SYMLINK_NOFOLLOW) &&
+   (st.mode ^ fmode) & S_IFMT) {
if (S_ISDIR(st.mode))
init_rmdir(path);
else
-- 
2.27.0



[PATCH 04/21] devtmpfs: refactor devtmpfsd()

2020-07-26 Thread Christoph Hellwig
Split the main worker loop into a separate function.  This allows
devtmpfsd itself and devtmpfsd_setup to be marked __init, which will
allows us to call __init routines for the setup work.

Signed-off-by: Christoph Hellwig 
---
 drivers/base/devtmpfs.c | 47 +++--
 1 file changed, 26 insertions(+), 21 deletions(-)

diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index c9017e0584c003..a103ee7e229930 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -378,7 +378,30 @@ static int handle(const char *name, umode_t mode, kuid_t 
uid, kgid_t gid,
return handle_remove(name, dev);
 }
 
-static int devtmpfs_setup(void *p)
+static void __noreturn devtmpfs_work_loop(void)
+{
+   while (1) {
+   spin_lock(_lock);
+   while (requests) {
+   struct req *req = requests;
+   requests = NULL;
+   spin_unlock(_lock);
+   while (req) {
+   struct req *next = req->next;
+   req->err = handle(req->name, req->mode,
+ req->uid, req->gid, req->dev);
+   complete(>done);
+   req = next;
+   }
+   spin_lock(_lock);
+   }
+   __set_current_state(TASK_INTERRUPTIBLE);
+   spin_unlock(_lock);
+   schedule();
+   }
+}
+
+static int __init devtmpfs_setup(void *p)
 {
int err;
 
@@ -396,31 +419,13 @@ static int devtmpfs_setup(void *p)
return err;
 }
 
-static int devtmpfsd(void *p)
+static int __init devtmpfsd(void *p)
 {
int err = devtmpfs_setup(p);
 
if (err)
return err;
-   while (1) {
-   spin_lock(_lock);
-   while (requests) {
-   struct req *req = requests;
-   requests = NULL;
-   spin_unlock(_lock);
-   while (req) {
-   struct req *next = req->next;
-   req->err = handle(req->name, req->mode,
- req->uid, req->gid, req->dev);
-   complete(>done);
-   req = next;
-   }
-   spin_lock(_lock);
-   }
-   __set_current_state(TASK_INTERRUPTIBLE);
-   spin_unlock(_lock);
-   schedule();
-   }
+   devtmpfs_work_loop();
return 0;
 }
 
-- 
2.27.0



[PATCH 03/21] fs: push the getname from do_rmdir into the callers

2020-07-26 Thread Christoph Hellwig
This mirrors do_unlinkat and will make life a little easier for
the init code to reuse the whole function with a kernel filename.

Signed-off-by: Christoph Hellwig 
---
 fs/internal.h|  2 +-
 fs/namei.c   | 10 --
 include/linux/syscalls.h |  4 ++--
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/fs/internal.h b/fs/internal.h
index 9b863a7bd70892..e903d5aae139a2 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -65,7 +65,7 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
 long do_mknodat(int dfd, const char __user *filename, umode_t mode,
unsigned int dev);
 long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
-long do_rmdir(int dfd, const char __user *pathname);
+long do_rmdir(int dfd, struct filename *name);
 long do_unlinkat(int dfd, struct filename *name);
 long do_symlinkat(const char __user *oldname, int newdfd,
  const char __user *newname);
diff --git a/fs/namei.c b/fs/namei.c
index 72d4219c93acb7..d75a6039ae3966 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3720,17 +3720,16 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
 }
 EXPORT_SYMBOL(vfs_rmdir);
 
-long do_rmdir(int dfd, const char __user *pathname)
+long do_rmdir(int dfd, struct filename *name)
 {
int error = 0;
-   struct filename *name;
struct dentry *dentry;
struct path path;
struct qstr last;
int type;
unsigned int lookup_flags = 0;
 retry:
-   name = filename_parentat(dfd, getname(pathname), lookup_flags,
+   name = filename_parentat(dfd, name, lookup_flags,
, , );
if (IS_ERR(name))
return PTR_ERR(name);
@@ -3781,7 +3780,7 @@ long do_rmdir(int dfd, const char __user *pathname)
 
 SYSCALL_DEFINE1(rmdir, const char __user *, pathname)
 {
-   return do_rmdir(AT_FDCWD, pathname);
+   return do_rmdir(AT_FDCWD, getname(pathname));
 }
 
 /**
@@ -3926,8 +3925,7 @@ SYSCALL_DEFINE3(unlinkat, int, dfd, const char __user *, 
pathname, int, flag)
return -EINVAL;
 
if (flag & AT_REMOVEDIR)
-   return do_rmdir(dfd, pathname);
-
+   return do_rmdir(dfd, getname(pathname));
return do_unlinkat(dfd, getname(pathname));
 }
 
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 5b0f1fca4cfb9d..e43816198e6001 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1281,11 +1281,11 @@ static inline long ksys_unlink(const char __user 
*pathname)
return do_unlinkat(AT_FDCWD, getname(pathname));
 }
 
-extern long do_rmdir(int dfd, const char __user *pathname);
+long do_rmdir(int dfd, struct filename *name);
 
 static inline long ksys_rmdir(const char __user *pathname)
 {
-   return do_rmdir(AT_FDCWD, pathname);
+   return do_rmdir(AT_FDCWD, getname(pathname));
 }
 
 extern long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
-- 
2.27.0



[PATCH 18/21] init: add an init_mkdir helper

2020-07-26 Thread Christoph Hellwig
Add a simple helper to mkdir with a kernel space file name and switch
the early init code over to it.  Remove the now unused ksys_mkdir.

Signed-off-by: Christoph Hellwig 
---
 fs/for_init.c | 18 ++
 fs/internal.h |  1 -
 fs/namei.c|  2 +-
 include/linux/init_syscalls.h |  1 +
 include/linux/syscalls.h  |  7 ---
 init/do_mounts_initrd.c   |  2 +-
 init/initramfs.c  |  2 +-
 init/noinitramfs.c|  5 +++--
 8 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/fs/for_init.c b/fs/for_init.c
index 082ff1004f06b3..6ae3305bece1eb 100644
--- a/fs/for_init.c
+++ b/fs/for_init.c
@@ -172,6 +172,24 @@ int __init init_unlink(const char *pathname)
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
 }
 
+int __init init_mkdir(const char *pathname, umode_t mode)
+{
+   struct dentry *dentry;
+   struct path path;
+   int error;
+
+   dentry = kern_path_create(AT_FDCWD, pathname, , LOOKUP_DIRECTORY);
+   if (IS_ERR(dentry))
+   return PTR_ERR(dentry);
+   if (!IS_POSIXACL(path.dentry->d_inode))
+   mode &= ~current_umask();
+   error = security_path_mkdir(, dentry, mode);
+   if (!error)
+   error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
+   done_path_create(, dentry);
+   return error;
+}
+
 int __init init_rmdir(const char *pathname)
 {
return do_rmdir(AT_FDCWD, getname_kernel(pathname));
diff --git a/fs/internal.h b/fs/internal.h
index 40b50a222d7a22..4741e591e923bf 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -64,7 +64,6 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
   const char *, unsigned int, struct path *);
 long do_mknodat(int dfd, const char __user *filename, umode_t mode,
unsigned int dev);
-long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
 long do_rmdir(int dfd, struct filename *name);
 long do_unlinkat(int dfd, struct filename *name);
 int may_linkat(struct path *link);
diff --git a/fs/namei.c b/fs/namei.c
index 2f6fa53eb3da28..d6b25dd32f4d50 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3645,7 +3645,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, 
umode_t mode)
 }
 EXPORT_SYMBOL(vfs_mkdir);
 
-long do_mkdirat(int dfd, const char __user *pathname, umode_t mode)
+static long do_mkdirat(int dfd, const char __user *pathname, umode_t mode)
 {
struct dentry *dentry;
struct path path;
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index 125f55ae3f80b8..d808985231f8f8 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -11,4 +11,5 @@ int __init init_eaccess(const char *filename);
 int __init init_link(const char *oldname, const char *newname);
 int __init init_symlink(const char *oldname, const char *newname);
 int __init init_unlink(const char *pathname);
+int __init init_mkdir(const char *pathname, umode_t mode);
 int __init init_rmdir(const char *pathname);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 7cdc0d749a049f..5ef77a91382aa5 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1270,13 +1270,6 @@ int compat_ksys_ipc(u32 call, int first, int second,
  * The following kernel syscall equivalents are just wrappers to fs-internal
  * functions. Therefore, provide stubs to be inlined at the callsites.
  */
-extern long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
-
-static inline long ksys_mkdir(const char __user *pathname, umode_t mode)
-{
-   return do_mkdirat(AT_FDCWD, pathname, mode);
-}
-
 extern long do_mknodat(int dfd, const char __user *filename, umode_t mode,
   unsigned int dev);
 
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index a6b447b191dbc8..3f5ac81913dde4 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -81,7 +81,7 @@ static void __init handle_initrd(void)
create_dev("/dev/root.old", Root_RAM0);
/* mount initrd on rootfs' /root */
mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
-   ksys_mkdir("/old", 0700);
+   init_mkdir("/old", 0700);
init_chdir("/old");
 
/*
diff --git a/init/initramfs.c b/init/initramfs.c
index 889c470b0c2aba..076e66f11bda8d 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -345,7 +345,7 @@ static int __init do_name(void)
state = CopyFile;
}
} else if (S_ISDIR(mode)) {
-   ksys_mkdir(collected, mode);
+   init_mkdir(collected, mode);
init_chown(collected, uid, gid, 0);
init_chmod(collected, mode);
dir_add(collected, mtime);
diff --git a/init/noinitramfs.c b/init/noinitramfs.c
index fa9cdfa7101d3c..94cc4df74b11f2 100644
--- a/init/noinitramfs.c
+++ b/init/noinitramfs.c
@@ -9,6 

[PATCH 16/21] init: add an init_link helper

2020-07-26 Thread Christoph Hellwig
Add a simple helper to link with a kernel space file name and switch
the early init code over to it.  Remove the now unused ksys_link.

Signed-off-by: Christoph Hellwig 
---
 fs/for_init.c | 33 +
 fs/internal.h |  3 +--
 fs/namei.c|  4 ++--
 include/linux/init_syscalls.h |  1 +
 include/linux/syscalls.h  |  9 -
 init/initramfs.c  |  2 +-
 6 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/fs/for_init.c b/fs/for_init.c
index abc152f41e648b..339ac1a52ca150 100644
--- a/fs/for_init.c
+++ b/fs/for_init.c
@@ -118,6 +118,39 @@ int __init init_eaccess(const char *filename)
return error;
 }
 
+int __init init_link(const char *oldname, const char *newname)
+{
+   struct dentry *new_dentry;
+   struct path old_path, new_path;
+   int error;
+
+   error = kern_path(oldname, 0, _path);
+   if (error)
+   return error;
+
+   new_dentry = kern_path_create(AT_FDCWD, newname, _path, 0);
+   error = PTR_ERR(new_dentry);
+   if (IS_ERR(new_dentry))
+   goto out;
+
+   error = -EXDEV;
+   if (old_path.mnt != new_path.mnt)
+   goto out_dput;
+   error = may_linkat(_path);
+   if (unlikely(error))
+   goto out_dput;
+   error = security_path_link(old_path.dentry, _path, new_dentry);
+   if (error)
+   goto out_dput;
+   error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry,
+NULL);
+out_dput:
+   done_path_create(_path, new_dentry);
+out:
+   path_put(_path);
+   return error;
+}
+
 int __init init_unlink(const char *pathname)
 {
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
diff --git a/fs/internal.h b/fs/internal.h
index 6d82681c7d8372..58451b033d2698 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -69,8 +69,7 @@ long do_rmdir(int dfd, struct filename *name);
 long do_unlinkat(int dfd, struct filename *name);
 long do_symlinkat(const char __user *oldname, int newdfd,
  const char __user *newname);
-int do_linkat(int olddfd, const char __user *oldname, int newdfd,
- const char __user *newname, int flags);
+int may_linkat(struct path *link);
 
 /*
  * namespace.c
diff --git a/fs/namei.c b/fs/namei.c
index d75a6039ae3966..13de64c6be7640 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1024,7 +1024,7 @@ static bool safe_hardlink_source(struct inode *inode)
  *
  * Returns 0 if successful, -ve on error.
  */
-static int may_linkat(struct path *link)
+int may_linkat(struct path *link)
 {
struct inode *inode = link->dentry->d_inode;
 
@@ -4086,7 +4086,7 @@ EXPORT_SYMBOL(vfs_link);
  * with linux 2.0, and to avoid hard-linking to directories
  * and other special files.  --ADM
  */
-int do_linkat(int olddfd, const char __user *oldname, int newdfd,
+static int do_linkat(int olddfd, const char __user *oldname, int newdfd,
  const char __user *newname, int flags)
 {
struct dentry *new_dentry;
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index 7031c0934bee9f..5ca15a5b55b7d7 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -8,5 +8,6 @@ int __init init_chroot(const char *filename);
 int __init init_chown(const char *filename, uid_t user, gid_t group, int 
flags);
 int __init init_chmod(const char *filename, umode_t mode);
 int __init init_eaccess(const char *filename);
+int __init init_link(const char *oldname, const char *newname);
 int __init init_unlink(const char *pathname);
 int __init init_rmdir(const char *pathname);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index a2779638e41445..4b18b91ce46573 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1295,15 +1295,6 @@ static inline long ksys_mknod(const char __user 
*filename, umode_t mode,
return do_mknodat(AT_FDCWD, filename, mode, dev);
 }
 
-extern int do_linkat(int olddfd, const char __user *oldname, int newdfd,
-const char __user *newname, int flags);
-
-static inline long ksys_link(const char __user *oldname,
-const char __user *newname)
-{
-   return do_linkat(AT_FDCWD, oldname, AT_FDCWD, newname, 0);
-}
-
 extern int do_fchownat(int dfd, const char __user *filename, uid_t user,
   gid_t group, int flag);
 
diff --git a/init/initramfs.c b/init/initramfs.c
index f2ec2f024f9e67..48c137142fed7f 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -311,7 +311,7 @@ static int __init maybe_link(void)
char *old = find_link(major, minor, ino, mode, collected);
if (old) {
clean_path(collected, 0);
-   return (ksys_link(old, collected) < 0) ? -1 : 1;
+   return (init_link(old, collected) < 0) ? -1 : 1;
}
}

[PATCH 19/21] init: add an init_mknod helper

2020-07-26 Thread Christoph Hellwig
Add a simple helper to mknod with a kernel space file name and switch
the early init code over to it.  Remove the now unused ksys_mknod.

Signed-off-by: Christoph Hellwig 
---
 fs/for_init.c | 25 +
 fs/internal.h |  2 --
 fs/namei.c|  2 +-
 include/linux/init_syscalls.h |  1 +
 include/linux/syscalls.h  |  9 -
 init/do_mounts.h  |  2 +-
 init/initramfs.c  |  2 +-
 init/noinitramfs.c|  3 +--
 8 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/fs/for_init.c b/fs/for_init.c
index 6ae3305bece1eb..50813d2913b57b 100644
--- a/fs/for_init.c
+++ b/fs/for_init.c
@@ -118,6 +118,31 @@ int __init init_eaccess(const char *filename)
return error;
 }
 
+int __init init_mknod(const char *filename, umode_t mode, unsigned int dev)
+{
+   struct dentry *dentry;
+   struct path path;
+   int error;
+
+   if (S_ISFIFO(mode) || S_ISSOCK(mode))
+   dev = 0;
+   else if (!(S_ISBLK(mode) || S_ISCHR(mode)))
+   return -EINVAL;
+
+   dentry = kern_path_create(AT_FDCWD, filename, , 0);
+   if (IS_ERR(dentry))
+   return PTR_ERR(dentry);
+
+   if (!IS_POSIXACL(path.dentry->d_inode))
+   mode &= ~current_umask();
+   error = security_path_mknod(, dentry, mode, dev);
+   if (!error)
+   error = vfs_mknod(path.dentry->d_inode, dentry, mode,
+ new_decode_dev(dev));
+   done_path_create(, dentry);
+   return error;
+}
+
 int __init init_link(const char *oldname, const char *newname)
 {
struct dentry *new_dentry;
diff --git a/fs/internal.h b/fs/internal.h
index 4741e591e923bf..07e145b2f88c4a 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -62,8 +62,6 @@ extern int filename_lookup(int dfd, struct filename *name, 
unsigned flags,
   struct path *path, struct path *root);
 extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
   const char *, unsigned int, struct path *);
-long do_mknodat(int dfd, const char __user *filename, umode_t mode,
-   unsigned int dev);
 long do_rmdir(int dfd, struct filename *name);
 long do_unlinkat(int dfd, struct filename *name);
 int may_linkat(struct path *link);
diff --git a/fs/namei.c b/fs/namei.c
index d6b25dd32f4d50..fde8fe086c090d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3564,7 +3564,7 @@ static int may_mknod(umode_t mode)
}
 }
 
-long do_mknodat(int dfd, const char __user *filename, umode_t mode,
+static long do_mknodat(int dfd, const char __user *filename, umode_t mode,
unsigned int dev)
 {
struct dentry *dentry;
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index d808985231f8f8..fa1fe7a877795f 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -8,6 +8,7 @@ int __init init_chroot(const char *filename);
 int __init init_chown(const char *filename, uid_t user, gid_t group, int 
flags);
 int __init init_chmod(const char *filename, umode_t mode);
 int __init init_eaccess(const char *filename);
+int __init init_mknod(const char *filename, umode_t mode, unsigned int dev);
 int __init init_link(const char *oldname, const char *newname);
 int __init init_symlink(const char *oldname, const char *newname);
 int __init init_unlink(const char *pathname);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 5ef77a91382aa5..63046c5e9fc5d4 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1270,15 +1270,6 @@ int compat_ksys_ipc(u32 call, int first, int second,
  * The following kernel syscall equivalents are just wrappers to fs-internal
  * functions. Therefore, provide stubs to be inlined at the callsites.
  */
-extern long do_mknodat(int dfd, const char __user *filename, umode_t mode,
-  unsigned int dev);
-
-static inline long ksys_mknod(const char __user *filename, umode_t mode,
- unsigned int dev)
-{
-   return do_mknodat(AT_FDCWD, filename, mode, dev);
-}
-
 extern int do_fchownat(int dfd, const char __user *filename, uid_t user,
   gid_t group, int flag);
 
diff --git a/init/do_mounts.h b/init/do_mounts.h
index 104d8431725aeb..7a29ac3e427bab 100644
--- a/init/do_mounts.h
+++ b/init/do_mounts.h
@@ -17,7 +17,7 @@ extern int root_mountflags;
 static inline __init int create_dev(char *name, dev_t dev)
 {
init_unlink(name);
-   return ksys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
+   return init_mknod(name, S_IFBLK | 0600, new_encode_dev(dev));
 }
 
 #ifdef CONFIG_BLK_DEV_RAM
diff --git a/init/initramfs.c b/init/initramfs.c
index 076e66f11bda8d..9b2d93a2eb5e4b 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -352,7 +352,7 @@ static int __init do_name(void)
} else if (S_ISBLK(mode) || S_ISCHR(mode) ||
  

[PATCH 12/21] init: add an init_chroot helper

2020-07-26 Thread Christoph Hellwig
Add a simple helper to chroot with a kernel space file name and switch
the early init code over to it.  Remove the now unused ksys_chroot.

Signed-off-by: Christoph Hellwig 
---
 drivers/base/devtmpfs.c   |  2 +-
 fs/for_init.c | 24 
 fs/open.c |  7 +--
 include/linux/init_syscalls.h |  1 +
 include/linux/syscalls.h  |  2 --
 init/do_mounts.c  |  2 +-
 init/do_mounts_initrd.c   |  4 ++--
 7 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index bc2cfe10018cd5..36e81b52368650 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -413,7 +413,7 @@ static int __init devtmpfs_setup(void *p)
if (err)
goto out;
init_chdir("/.."); /* will traverse into overmounted root */
-   ksys_chroot(".");
+   init_chroot(".");
 out:
*(int *)p = err;
complete(_done);
diff --git a/fs/for_init.c b/fs/for_init.c
index e5d907d4b98aac..2d5428b7dc1420 100644
--- a/fs/for_init.c
+++ b/fs/for_init.c
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "internal.h"
 
 int __init init_mount(const char *dev_name, const char *dir_name,
@@ -50,6 +51,29 @@ int __init init_chdir(const char *filename)
return error;
 }
 
+int __init init_chroot(const char *filename)
+{
+   struct path path;
+   int error;
+
+   error = kern_path(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, );
+   if (error)
+   return error;
+   error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
+   if (error)
+   goto dput_and_out;
+   error = -EPERM;
+   if (!ns_capable(current_user_ns(), CAP_SYS_CHROOT))
+   goto dput_and_out;
+   error = security_path_chroot();
+   if (error)
+   goto dput_and_out;
+   set_fs_root(current->fs, );
+dput_and_out:
+   path_put();
+   return error;
+}
+
 int __init init_unlink(const char *pathname)
 {
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
diff --git a/fs/open.c b/fs/open.c
index 723e0ac898935e..f62f4752bb436d 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -530,7 +530,7 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
return error;
 }
 
-int ksys_chroot(const char __user *filename)
+SYSCALL_DEFINE1(chroot, const char __user *, filename)
 {
struct path path;
int error;
@@ -563,11 +563,6 @@ int ksys_chroot(const char __user *filename)
return error;
 }
 
-SYSCALL_DEFINE1(chroot, const char __user *, filename)
-{
-   return ksys_chroot(filename);
-}
-
 static int chmod_common(const struct path *path, umode_t mode)
 {
struct inode *inode = path->dentry->d_inode;
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index 1e845910ae56e9..e07099a14b91db 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -4,5 +4,6 @@ int __init init_mount(const char *dev_name, const char 
*dir_name,
const char *type_page, unsigned long flags, void *data_page);
 int __init init_umount(const char *name, int flags);
 int __init init_chdir(const char *filename);
+int __init init_chroot(const char *filename);
 int __init init_unlink(const char *pathname);
 int __init init_rmdir(const char *pathname);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 31fa67fb9894b3..e89d62e944dc0e 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1235,8 +1235,6 @@ asmlinkage long sys_ni_syscall(void);
  * Instead, use one of the functions which work equivalently, such as
  * the ksys_xyzyyz() functions prototyped below.
  */
-
-int ksys_chroot(const char __user *filename);
 ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count);
 int ksys_fchown(unsigned int fd, uid_t user, gid_t group);
 ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count);
diff --git a/init/do_mounts.c b/init/do_mounts.c
index cc08ed7b44e764..c8ccdc80ffcdd5 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -629,7 +629,7 @@ void __init prepare_namespace(void)
 out:
devtmpfs_mount();
init_mount(".", "/", NULL, MS_MOVE, NULL);
-   ksys_chroot(".");
+   init_chroot(".");
 }
 
 static bool is_tmpfs;
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index 04627fd22a921f..a6b447b191dbc8 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -63,7 +63,7 @@ static int __init init_linuxrc(struct subprocess_info *info, 
struct cred *new)
/* move initrd over / and chdir/chroot in initrd root */
init_chdir("/root");
init_mount(".", "/", NULL, MS_MOVE, NULL);
-   ksys_chroot(".");
+   init_chroot(".");
ksys_setsid();
return 0;
 }
@@ -101,7 +101,7 @@ static void __init handle_initrd(void)
/* move initrd to rootfs' /old */
init_mount("..", ".", NULL, 

[PATCH 09/21] init: add an init_unlink helper

2020-07-26 Thread Christoph Hellwig
Add a simple helper to unlink with a kernel space file name and switch
the early init code over to it.  Remove the now unused ksys_unlink.

Signed-off-by: Christoph Hellwig 
---
 fs/for_init.c | 5 +
 include/linux/init_syscalls.h | 1 +
 include/linux/syscalls.h  | 7 ---
 init/do_mounts.h  | 2 +-
 init/do_mounts_initrd.c   | 4 ++--
 init/do_mounts_rd.c   | 2 +-
 init/initramfs.c  | 3 ++-
 7 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/fs/for_init.c b/fs/for_init.c
index 7a039b6d107c92..32472206d64136 100644
--- a/fs/for_init.c
+++ b/fs/for_init.c
@@ -33,3 +33,8 @@ int __init init_umount(const char *name, int flags)
return ret;
return path_umount(, flags);
 }
+
+int __init init_unlink(const char *pathname)
+{
+   return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
+}
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index a5a2e7f1991691..00d597249549ee 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -3,3 +3,4 @@
 int __init init_mount(const char *dev_name, const char *dir_name,
const char *type_page, unsigned long flags, void *data_page);
 int __init init_umount(const char *name, int flags);
+int __init init_unlink(const char *pathname);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 1a4f5d8ee7044b..26f9738e5ab861 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1273,13 +1273,6 @@ int compat_ksys_ipc(u32 call, int first, int second,
  * The following kernel syscall equivalents are just wrappers to fs-internal
  * functions. Therefore, provide stubs to be inlined at the callsites.
  */
-extern long do_unlinkat(int dfd, struct filename *name);
-
-static inline long ksys_unlink(const char __user *pathname)
-{
-   return do_unlinkat(AT_FDCWD, getname(pathname));
-}
-
 long do_rmdir(int dfd, struct filename *name);
 
 static inline long ksys_rmdir(const char __user *pathname)
diff --git a/init/do_mounts.h b/init/do_mounts.h
index 20e7fec8cb499e..104d8431725aeb 100644
--- a/init/do_mounts.h
+++ b/init/do_mounts.h
@@ -16,7 +16,7 @@ extern int root_mountflags;
 
 static inline __init int create_dev(char *name, dev_t dev)
 {
-   ksys_unlink(name);
+   init_unlink(name);
return ksys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
 }
 
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index 6b020a06990251..8b44dd017842a8 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -137,11 +137,11 @@ bool __init initrd_load(void)
 * mounted in the normal path.
 */
if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
-   ksys_unlink("/initrd.image");
+   init_unlink("/initrd.image");
handle_initrd();
return true;
}
}
-   ksys_unlink("/initrd.image");
+   init_unlink("/initrd.image");
return false;
 }
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index 7b64390c075043..b062f8b028ce7c 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -271,7 +271,7 @@ int __init rd_load_image(char *from)
fput(out_file);
 out:
kfree(buf);
-   ksys_unlink("/dev/ram");
+   init_unlink("/dev/ram");
return res;
 }
 
diff --git a/init/initramfs.c b/init/initramfs.c
index 3823d15e5d2619..574ab3755203da 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static ssize_t __init xwrite(struct file *file, const char *p, size_t count)
 {
@@ -300,7 +301,7 @@ static void __init clean_path(char *path, umode_t fmode)
if (S_ISDIR(st.mode))
ksys_rmdir(path);
else
-   ksys_unlink(path);
+   init_unlink(path);
}
 }
 
-- 
2.27.0



[PATCH 11/21] init: add an init_chdir helper

2020-07-26 Thread Christoph Hellwig
Add a simple helper to chdir with a kernel space file name and switch
the early init code over to it.  Remove the now unused ksys_chdir.

Signed-off-by: Christoph Hellwig 
---
 drivers/base/devtmpfs.c   |  2 +-
 fs/for_init.c | 16 
 fs/open.c |  7 +--
 include/linux/init_syscalls.h |  1 +
 include/linux/syscalls.h  |  1 -
 init/do_mounts.c  |  2 +-
 init/do_mounts_initrd.c   |  8 
 7 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index 03051e8c12bdc9..bc2cfe10018cd5 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -412,7 +412,7 @@ static int __init devtmpfs_setup(void *p)
err = init_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, NULL);
if (err)
goto out;
-   ksys_chdir("/.."); /* will traverse into overmounted root */
+   init_chdir("/.."); /* will traverse into overmounted root */
ksys_chroot(".");
 out:
*(int *)p = err;
diff --git a/fs/for_init.c b/fs/for_init.c
index 1f10ebe78c1ba1..e5d907d4b98aac 100644
--- a/fs/for_init.c
+++ b/fs/for_init.c
@@ -3,6 +3,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "internal.h"
 
@@ -34,6 +35,21 @@ int __init init_umount(const char *name, int flags)
return path_umount(, flags);
 }
 
+int __init init_chdir(const char *filename)
+{
+   struct path path;
+   int error;
+
+   error = kern_path(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, );
+   if (error)
+   return error;
+   error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
+   if (!error)
+   set_fs_pwd(current->fs, );
+   path_put();
+   return error;
+}
+
 int __init init_unlink(const char *pathname)
 {
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
diff --git a/fs/open.c b/fs/open.c
index b316dd6a86a8b9..723e0ac898935e 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -482,7 +482,7 @@ SYSCALL_DEFINE2(access, const char __user *, filename, int, 
mode)
return do_faccessat(AT_FDCWD, filename, mode, 0);
 }
 
-int ksys_chdir(const char __user *filename)
+SYSCALL_DEFINE1(chdir, const char __user *, filename)
 {
struct path path;
int error;
@@ -508,11 +508,6 @@ int ksys_chdir(const char __user *filename)
return error;
 }
 
-SYSCALL_DEFINE1(chdir, const char __user *, filename)
-{
-   return ksys_chdir(filename);
-}
-
 SYSCALL_DEFINE1(fchdir, unsigned int, fd)
 {
struct fd f = fdget_raw(fd);
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index abf3af563c0b3a..1e845910ae56e9 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -3,5 +3,6 @@
 int __init init_mount(const char *dev_name, const char *dir_name,
const char *type_page, unsigned long flags, void *data_page);
 int __init init_umount(const char *name, int flags);
+int __init init_chdir(const char *filename);
 int __init init_unlink(const char *pathname);
 int __init init_rmdir(const char *pathname);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index a7b14258d245e2..31fa67fb9894b3 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1238,7 +1238,6 @@ asmlinkage long sys_ni_syscall(void);
 
 int ksys_chroot(const char __user *filename);
 ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count);
-int ksys_chdir(const char __user *filename);
 int ksys_fchown(unsigned int fd, uid_t user, gid_t group);
 ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count);
 void ksys_sync(void);
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 4812e21d149cab..cc08ed7b44e764 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -408,7 +408,7 @@ static int __init do_mount_root(const char *name, const 
char *fs,
if (ret)
goto out;
 
-   ksys_chdir("/root");
+   init_chdir("/root");
s = current->fs->pwd.dentry->d_sb;
ROOT_DEV = s->s_dev;
printk(KERN_INFO
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index 8b44dd017842a8..04627fd22a921f 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -61,7 +61,7 @@ static int __init init_linuxrc(struct subprocess_info *info, 
struct cred *new)
ksys_unshare(CLONE_FS | CLONE_FILES);
console_on_rootfs();
/* move initrd over / and chdir/chroot in initrd root */
-   ksys_chdir("/root");
+   init_chdir("/root");
init_mount(".", "/", NULL, MS_MOVE, NULL);
ksys_chroot(".");
ksys_setsid();
@@ -82,7 +82,7 @@ static void __init handle_initrd(void)
/* mount initrd on rootfs' /root */
mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
ksys_mkdir("/old", 0700);
-   ksys_chdir("/old");
+   init_chdir("/old");
 
/*
 * In case that a 

[PATCH 07/21] init: add an init_mount helper

2020-07-26 Thread Christoph Hellwig
Like do_mount, but takes a kernel pointer for the destination path.
Switch over the mounts in the init code and devtmpfs to it, which
just happen to work due to the implicit set_fs(KERNEL_DS) during early
init right now.

Signed-off-by: Christoph Hellwig 
---
 drivers/base/devtmpfs.c   |  5 +++--
 fs/Makefile   |  2 +-
 fs/for_init.c | 21 +
 fs/internal.h |  4 
 fs/namespace.c|  2 +-
 include/linux/init_syscalls.h |  4 
 init/do_mounts.c  |  8 
 init/do_mounts.h  |  1 +
 init/do_mounts_initrd.c   |  6 +++---
 9 files changed, 42 insertions(+), 11 deletions(-)
 create mode 100644 fs/for_init.c
 create mode 100644 include/linux/init_syscalls.h

diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index a103ee7e229930..03051e8c12bdc9 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "base.h"
 
@@ -359,7 +360,7 @@ int __init devtmpfs_mount(void)
if (!thread)
return 0;
 
-   err = do_mount("devtmpfs", "dev", "devtmpfs", MS_SILENT, NULL);
+   err = init_mount("devtmpfs", "dev", "devtmpfs", MS_SILENT, NULL);
if (err)
printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
else
@@ -408,7 +409,7 @@ static int __init devtmpfs_setup(void *p)
err = ksys_unshare(CLONE_NEWNS);
if (err)
goto out;
-   err = do_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, NULL);
+   err = init_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, NULL);
if (err)
goto out;
ksys_chdir("/.."); /* will traverse into overmounted root */
diff --git a/fs/Makefile b/fs/Makefile
index 2ce5112b02c867..837512ff387ccd 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -13,7 +13,7 @@ obj-y :=  open.o read_write.o file_table.o super.o \
seq_file.o xattr.o libfs.o fs-writeback.o \
pnode.o splice.o sync.o utimes.o d_path.o \
stack.o fs_struct.o statfs.o fs_pin.o nsfs.o \
-   fs_types.o fs_context.o fs_parser.o fsopen.o
+   fs_types.o fs_context.o fs_parser.o fsopen.o for_init.o
 
 ifeq ($(CONFIG_BLOCK),y)
 obj-y +=   buffer.o block_dev.o direct-io.o mpage.o
diff --git a/fs/for_init.c b/fs/for_init.c
new file mode 100644
index 00..6a04cc8d8557c4
--- /dev/null
+++ b/fs/for_init.c
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "internal.h"
+
+int __init init_mount(const char *dev_name, const char *dir_name,
+   const char *type_page, unsigned long flags, void *data_page)
+{
+   struct path path;
+   int ret;
+
+   ret = kern_path(dir_name, LOOKUP_FOLLOW, );
+   if (ret)
+   return ret;
+   ret = path_mount(dev_name, , type_page, flags, data_page);
+   path_put();
+   return ret;
+}
diff --git a/fs/internal.h b/fs/internal.h
index e903d5aae139a2..72ea0b6f7435a4 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -89,6 +89,10 @@ extern int __mnt_want_write_file(struct file *);
 extern void __mnt_drop_write_file(struct file *);
 
 extern void dissolve_on_fput(struct vfsmount *);
+
+int path_mount(const char *dev_name, struct path *path,
+   const char *type_page, unsigned long flags, void *data_page);
+
 /*
  * fs_struct.c
  */
diff --git a/fs/namespace.c b/fs/namespace.c
index 43834b59eff6c3..2c4d7592097485 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3111,7 +3111,7 @@ char *copy_mount_string(const void __user *data)
  * Therefore, if this magic number is present, it carries no information
  * and must be discarded.
  */
-static int path_mount(const char *dev_name, struct path *path,
+int path_mount(const char *dev_name, struct path *path,
const char *type_page, unsigned long flags, void *data_page)
 {
unsigned int mnt_flags = 0, sb_flags;
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
new file mode 100644
index 00..af9ea88a60e0bd
--- /dev/null
+++ b/include/linux/init_syscalls.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+int __init init_mount(const char *dev_name, const char *dir_name,
+   const char *type_page, unsigned long flags, void *data_page);
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 4f4ceb35805503..4812e21d149cab 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -395,16 +395,16 @@ static int __init do_mount_root(const char *name, const 
char *fs,
int ret;
 
if (data) {
-   /* do_mount() requires a full page as fifth argument */
+   /* init_mount() requires a full page as fifth argument */
p = alloc_page(GFP_KERNEL);
if (!p)
return -ENOMEM;

[PATCH 06/21] init: mark create_dev as __init

2020-07-26 Thread Christoph Hellwig
The helper is only used for the early init code.

Signed-off-by: Christoph Hellwig 
---
 init/do_mounts.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init/do_mounts.h b/init/do_mounts.h
index c855b3f0e06d19..021e2f60223e25 100644
--- a/init/do_mounts.h
+++ b/init/do_mounts.h
@@ -13,7 +13,7 @@ void  mount_block_root(char *name, int flags);
 void  mount_root(void);
 extern int root_mountflags;
 
-static inline int create_dev(char *name, dev_t dev)
+static inline __init int create_dev(char *name, dev_t dev)
 {
ksys_unlink(name);
return ksys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
-- 
2.27.0



add file system helpers that take kernel pointers for the init code v3

2020-07-26 Thread Christoph Hellwig
Hi Al and Linus,

currently a lot of the file system calls in the early in code (and the
devtmpfs kthread) rely on the implicit set_fs(KERNEL_DS) during boot.
This is one of the few last remaining places we need to deal with to kill
off set_fs entirely, so this series adds new helpers that take kernel
pointers.  These helpers are in init/ and marked __init and thus will
be discarded after bootup.  A few also need to be duplicated in devtmpfs,
though unfortunately.

The series sits on top of my previous

  "decruft the early init / initrd / initramfs code v2"

series.


Git tree:

git://git.infradead.org/users/hch/misc.git init_path

Gitweb:

http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/init_path


Changes since v2:
 - move to fs/for-init.c
 - reuse the init routines in devtmpfs after refactoring devtmpfsd
   (and thus the broken error handling in the previous version)
 - actually use kern_path in a place where user_path_at sneaked back in

Changes since v1:
 - avoid most core VFS changes
 - renamed the functions and move them to init/ and devtmpfs
 - drop a bunch of cleanups that can be submitted independently now


Diffstat:
 drivers/base/devtmpfs.c   |   54 +
 drivers/md/md-autodetect.c|3 
 fs/Makefile   |2 
 fs/for_init.c |  249 ++
 fs/internal.h |   19 +--
 fs/namei.c|   20 +--
 fs/namespace.c|  107 --
 fs/open.c |   22 +--
 include/linux/init_syscalls.h |   18 +++
 include/linux/syscalls.h  |   66 ---
 init/do_mounts.c  |   12 +-
 init/do_mounts.h  |7 -
 init/do_mounts_initrd.c   |   26 ++--
 init/do_mounts_rd.c   |2 
 init/initramfs.c  |   29 ++--
 init/main.c   |   10 -
 init/noinitramfs.c|8 -
 17 files changed, 423 insertions(+), 231 deletions(-)


Re: [PATCH v2 04/20] unify generic instances of csum_partial_copy_nocheck()

2020-07-26 Thread Christoph Hellwig
On Fri, Jul 24, 2020 at 01:30:40PM +0100, Al Viro wrote:
> > Sorry, I meant csum_and_copy_from_nocheck, just as in this patch.
> > 
> > Merging your branch into the net-next tree thus will conflict in
> > the nios2 and asm-geneeric/checksum.h as well as lib/checksum.c.
> 
> Noted, but that asm-generic/checksum.h conflict will be "massage
> in net-next/outright removal in this branch"; the same goes for
> lib/checksum.c and nios2.  It's c6x that is unpleasant in that respect...

What about just rebasing your branch on the net-next tree?


Re: WARNING in ipvlan_l3s_unregister

2020-07-26 Thread syzbot
syzbot has found a reproducer for the following issue on:

HEAD commit:23ee3e4e Merge tag 'pci-v5.8-fixes-2' of git://git.kernel...
git tree:   upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17a1e4c490
kernel config:  https://syzkaller.appspot.com/x/.config?x=f3bc31881f1ae8a7
dashboard link: https://syzkaller.appspot.com/bug?extid=bb3d7a24f705078b1286
compiler:   clang version 10.0.0 (https://github.com/llvm/llvm-project/ 
c2443155a0fb245c8f17f2c1c72b6ea391e86e81)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=151a031710

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

[ cut here ]
WARNING: CPU: 0 PID: 7576 at drivers/net/ipvlan/ipvlan_l3s.c:148 
ipvlan_unregister_nf_hook drivers/net/ipvlan/ipvlan_l3s.c:148 [inline]
WARNING: CPU: 0 PID: 7576 at drivers/net/ipvlan/ipvlan_l3s.c:148 
ipvlan_l3s_unregister+0x145/0x1d0 drivers/net/ipvlan/ipvlan_l3s.c:221
Kernel panic - not syncing: panic_on_warn set ...
CPU: 0 PID: 7576 Comm: syz-executor.0 Not tainted 5.8.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1f0/0x31e lib/dump_stack.c:118
 panic+0x264/0x7a0 kernel/panic.c:231
 __warn+0x227/0x250 kernel/panic.c:600
 report_bug+0x1b1/0x2e0 lib/bug.c:198
 handle_bug+0x42/0x80 arch/x86/kernel/traps.c:235
 exc_invalid_op+0x16/0x40 arch/x86/kernel/traps.c:255
 asm_exc_invalid_op+0x12/0x20 arch/x86/include/asm/idtentry.h:540
RIP: 0010:ipvlan_unregister_nf_hook drivers/net/ipvlan/ipvlan_l3s.c:148 [inline]
RIP: 0010:ipvlan_l3s_unregister+0x145/0x1d0 drivers/net/ipvlan/ipvlan_l3s.c:221
Code: 48 c1 e8 03 42 80 3c 20 00 74 08 4c 89 f7 e8 12 59 dc fc 49 c7 06 00 00 
00 00 5b 41 5c 41 5d 41 5e 41 5f 5d c3 e8 0b 4a 9d fc <0f> 0b eb c8 e8 02 4a 9d 
fc c6 05 4b e5 b1 04 01 48 c7 c7 ec f3 09
RSP: 0018:c9000268f308 EFLAGS: 00010293
RAX: 84d747f5 RBX: 1110137b3c38 RCX: 8880a7732400
RDX:  RSI:  RDI: 
RBP:  R08: 84d7477e R09: fbfff131a7ee
R10: fbfff131a7ee R11:  R12: dc00
R13: 88809bd9e1c0 R14: 8880914ae000 R15: 888097498040
 ipvlan_set_port_mode+0x33e/0x420 drivers/net/ipvlan/ipvlan_main.c:37
 ipvlan_link_new+0x733/0xab0 drivers/net/ipvlan/ipvlan_main.c:611
 __rtnl_newlink net/core/rtnetlink.c:3339 [inline]
 rtnl_newlink+0x143e/0x1bf0 net/core/rtnetlink.c:3397
 rtnetlink_rcv_msg+0x889/0xd40 net/core/rtnetlink.c:5460
 netlink_rcv_skb+0x190/0x3a0 net/netlink/af_netlink.c:2469
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x786/0x940 net/netlink/af_netlink.c:1329
 netlink_sendmsg+0xa57/0xd70 net/netlink/af_netlink.c:1918
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg net/socket.c:672 [inline]
 sys_sendmsg+0x519/0x800 net/socket.c:2352
 ___sys_sendmsg net/socket.c:2406 [inline]
 __sys_sendmsg+0x2b1/0x360 net/socket.c:2439
 do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:384
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x45c369
Code: Bad RIP value.
RSP: 002b:7fff12787788 EFLAGS: 0246 ORIG_RAX: 002e
RAX: ffda RBX: 0002b740 RCX: 0045c369
RDX:  RSI: 2080 RDI: 0005
RBP: 0078bf40 R08:  R09: 
R10:  R11: 0246 R12: 00790730
R13:  R14: 0add R15: 0078bf0c
Kernel Offset: disabled
Rebooting in 86400 seconds..



Re: [PATCH v3] usb: dwc3: Add support for VBUS power control

2020-07-26 Thread Mike Looijmans



Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert


TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands

T: +31 (0) 499 33 69 69
E: mike.looijm...@topicproducts.com
W: www.topicproducts.com

Please consider the environment before printing this e-mail
On 23-07-2020 13:05, Mark Brown wrote:

On Thu, Jul 23, 2020 at 09:56:14AM +0200, Vincent Whitchurch wrote:

On Fri, Jun 19, 2020 at 04:25:12PM +0200, Mike Looijmans wrote:

+void dwc3_set_vbus(struct dwc3 *dwc, bool enable)
+{
+   int ret;
+
+   if (enable != dwc->vbus_reg_enabled) {
+   if (enable)
+   ret = regulator_enable(dwc->vbus_reg);
+   else
+   ret = regulator_disable(dwc->vbus_reg);
  

dwc->vbus_reg is set to NULL when the regulator is not present.  These
regulator_* functions expect a non-NULL pointer so a NULL check is
required before calling them.

Does the device actually support running without power so that's a thing
that can happen?  _get_optional() should only ever be used for supplies
that may be physically absent.


It's the 5V VBUS power for the USB "plug" that's being controlled here. 
It must turned on when the controller is in "host" mode. Some boards 
arrange this in hardware through the PHY, and some just don't have any 
control at all and have it permanently on or off. On a board where the 
5V is controlled using a GPIO line or an I2C chip, this patch is 
required to make it work.



--
Mike Looijmans



Re: get rid of the address_space override in setsockopt v2

2020-07-26 Thread Andreas Schwab
On Jul 26 2020, Christoph Hellwig wrote:

> From 6601732f7a54db5f04efba08f7e9224e5b757112 Mon Sep 17 00:00:00 2001
> From: Christoph Hellwig 
> Date: Sun, 26 Jul 2020 09:00:09 +0200
> Subject: mISDN: remove a debug printk in data_sock_setsockopt
>
> The %p won't work with the new sockptr_t type.  But in the times of
> ftrace, bpftrace and co these kinds of debug printks are pretty anyway,

I think there is a word missing after pretty.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


Re: [PATCH] tty: fix pid refcount leak in tty_signal_session_leader

2020-07-26 Thread Greg Kroah-Hartman
On Sun, Jul 26, 2020 at 01:28:04PM +0800, Xin Xiong wrote:
> In the loop, every time when p->signal->leader is true, the function
> tty_signal_session_leader() will invoke get_pid() and return a
> reference of tty->pgrp with increased refcount to the local variable
> tty_pgrp or return NULL if it fails. After finishing the loop, the
> function invokes put_pid() for only once, decreasing the refcount that
> tty_pgrp keeps.
> 
> Refcount leaks may occur when the scenario that p->signal->leader is
> true happens more than once. In this assumption, if the above scenario
> happens n times in the loop, the function forgets to decrease the
> refcount for n-1 times, which causes refcount leaks.
> 
> Fix the issue by decreasing the current refcount of the local variable
> tty_pgrp before assigning new objects to it.
> 
> Signed-off-by: Xiyu Yang 
> Signed-off-by: Xin Tan 
> Signed-off-by: Xin Xiong 
> ---
>  drivers/tty/tty_jobctrl.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c
> index f8ed50a16848..9e6bf693ade1 100644
> --- a/drivers/tty/tty_jobctrl.c
> +++ b/drivers/tty/tty_jobctrl.c
> @@ -212,6 +212,8 @@ int tty_signal_session_leader(struct tty_struct *tty, int 
> exit_session)
>   __group_send_sig_info(SIGCONT, SEND_SIG_PRIV, p);
>   put_pid(p->signal->tty_old_pgrp);  /* A noop */
>   spin_lock(>ctrl_lock);
> + if (tty_pgrp)
> + put_pid(tty_pgrp);

No need to check this before calling it.

But, the real question is why is this needed now?  Nothing has changed
in this area of the kernel for a very long time, so how did things get
broken here?

How are you triggering this and what is the result when we have that
additional reference?

thanks,

greg k-h


net/ipv6/ip6mr.c:1772:21: sparse: sparse: incorrect type in argument 1 (different address spaces)

2020-07-26 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   04300d66f0a06d572d9f2ad6768c38cabde22179
commit: 670d0a4b10704667765f7d18f7592993d02783aa sparse: use identifiers to 
define address spaces
date:   5 weeks ago
config: sh-randconfig-s031-20200726 (attached as .config)
compiler: sh4-linux-gcc (GCC) 9.3.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-93-g4c6cbe55-dirty
git checkout 670d0a4b10704667765f7d18f7592993d02783aa
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=sh 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


sparse warnings: (new ones prefixed by >>)

   net/ipv6/ip6mr.c:1721:21: sparse: sparse: incorrect type in initializer 
(different address spaces) @@ expected int const *__gu_addr @@ got int 
[noderef] __user * @@
   net/ipv6/ip6mr.c:1721:21: sparse: expected int const *__gu_addr
   net/ipv6/ip6mr.c:1721:21: sparse: got int [noderef] __user *
   net/ipv6/ip6mr.c:1721:21: sparse: sparse: incorrect type in argument 1 
(different address spaces) @@ expected void const volatile [noderef] __user 
* @@ got int const *__gu_addr @@
   net/ipv6/ip6mr.c:1721:21: sparse: expected void const volatile [noderef] 
__user *
   net/ipv6/ip6mr.c:1721:21: sparse: got int const *__gu_addr
   net/ipv6/ip6mr.c:1738:21: sparse: sparse: incorrect type in initializer 
(different address spaces) @@ expected int const *__gu_addr @@ got int 
[noderef] __user * @@
   net/ipv6/ip6mr.c:1738:21: sparse: expected int const *__gu_addr
   net/ipv6/ip6mr.c:1738:21: sparse: got int [noderef] __user *
   net/ipv6/ip6mr.c:1738:21: sparse: sparse: incorrect type in argument 1 
(different address spaces) @@ expected void const volatile [noderef] __user 
* @@ got int const *__gu_addr @@
   net/ipv6/ip6mr.c:1738:21: sparse: expected void const volatile [noderef] 
__user *
   net/ipv6/ip6mr.c:1738:21: sparse: got int const *__gu_addr
   net/ipv6/ip6mr.c:1751:21: sparse: sparse: incorrect type in initializer 
(different address spaces) @@ expected int const *__gu_addr @@ got int 
[noderef] __user * @@
   net/ipv6/ip6mr.c:1751:21: sparse: expected int const *__gu_addr
   net/ipv6/ip6mr.c:1751:21: sparse: got int [noderef] __user *
   net/ipv6/ip6mr.c:1751:21: sparse: sparse: incorrect type in argument 1 
(different address spaces) @@ expected void const volatile [noderef] __user 
* @@ got int const *__gu_addr @@
   net/ipv6/ip6mr.c:1751:21: sparse: expected void const volatile [noderef] 
__user *
   net/ipv6/ip6mr.c:1751:21: sparse: got int const *__gu_addr
   net/ipv6/ip6mr.c:1772:21: sparse: sparse: incorrect type in initializer 
(different address spaces) @@ expected unsigned int const *__gu_addr @@ 
got unsigned int [noderef] [usertype] __user * @@
   net/ipv6/ip6mr.c:1772:21: sparse: expected unsigned int const *__gu_addr
   net/ipv6/ip6mr.c:1772:21: sparse: got unsigned int [noderef] [usertype] 
__user *
>> net/ipv6/ip6mr.c:1772:21: sparse: sparse: incorrect type in argument 1 
>> (different address spaces) @@ expected void const volatile [noderef] 
>> __user * @@ got unsigned int const *__gu_addr @@
   net/ipv6/ip6mr.c:1772:21: sparse: expected void const volatile [noderef] 
__user *
   net/ipv6/ip6mr.c:1772:21: sparse: got unsigned int const *__gu_addr
   net/ipv6/ip6mr.c:1836:13: sparse: sparse: incorrect type in initializer 
(different address spaces) @@ expected int const *__gu_addr @@ got int 
[noderef] __user *optlen @@
   net/ipv6/ip6mr.c:1836:13: sparse: expected int const *__gu_addr
   net/ipv6/ip6mr.c:1836:13: sparse: got int [noderef] __user *optlen
   net/ipv6/ip6mr.c:1836:13: sparse: sparse: incorrect type in argument 1 
(different address spaces) @@ expected void const volatile [noderef] __user 
* @@ got int const *__gu_addr @@
   net/ipv6/ip6mr.c:1836:13: sparse: expected void const volatile [noderef] 
__user *
   net/ipv6/ip6mr.c:1836:13: sparse: got int const *__gu_addr
   net/ipv6/ip6mr.c:405:13: sparse: sparse: context imbalance in 
'ip6mr_vif_seq_start' - different lock contexts for basic block
   net/ipv6/ip6mr.c: note: in included file (through include/linux/mroute6.h):
   include/linux/mroute_base.h:427:31: sparse: sparse: context imbalance in 
'mr_mfc_seq_stop' - unexpected unlock
--
   net/netrom/af_netrom.c:309:13: sparse: sparse: incorrect type in initializer 
(different address spaces) @@ expected unsigned int const *__gu_addr @@ 
got unsigned int [noderef] __user * @@
   net/netrom/af_netrom.c:309:13: sparse: exp

<    1   2   3   4   5   6   7   >