Re: [PATCH] firewire: nosy: Fix a use-after-free bug in nosy_ioctl()
On Sat, Apr 03, 2021 at 06:58:36AM +, Zheyu Ma wrote: > For each device, the nosy driver allocates a pcilynx structure. > A use-after-free might happen in the following scenario: > > 1. Open nosy device for the first time and call ioctl with command > NOSY_IOC_START, then a new client A will be malloced and added > to doubly linked list. > 2. Open nosy device for the second time and call ioctl with command > NOSY_IOC_START, then a new client B will be malloced and added > to doubly linked list. > 3. Call ioctl with command NOSY_IOC_START for client A, then client A > will be readded to the doubly linked list. Now the doubly linked > list is messed up. > 4. Close the first nosy device and nosy_release will be called. > In nosy_release, client A will be unlinked and freed. > 5. Close the second nosy device, and client A will be referenced, > resulting in UAF. > > The root cause of this bug is that the element in the doubly linked list > is reentered into the list. > Fix this bug by adding a check before inserting a client. If a client > is already in the linked list, don't insert it. > > The following KASAN report reveals it: > > [ 14.672676 ] BUG: KASAN: use-after-free in nosy_release+0x1ea/0x210 > [ 14.673113 ] Write of size 8 at addr 888102ad7360 by task poc > [ 14.673609 ] CPU: 3 PID: 337 Comm: poc Not tainted 5.12.0-rc5+ #6 > [ 14.673988 ] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), > BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014 > [ 14.674686 ] Call Trace: > [ 14.674843 ] dump_stack+0x8a/0xb5 > [ 14.675061 ] print_address_description.constprop.0+0x18/0x130 > [ 14.675428 ] ? nosy_release+0x1ea/0x210 > [ 14.675676 ] ? nosy_release+0x1ea/0x210 > [ 14.675916 ] kasan_report.cold+0x7f/0x111 > [ 14.676169 ] ? nosy_release+0x1ea/0x210 > [ 14.676409 ] nosy_release+0x1ea/0x210 > [ 14.676642 ] __fput+0x1e2/0x840 > [ 14.676844 ] task_work_run+0xe8/0x180 > [ 14.677083 ] exit_to_user_mode_prepare+0x114/0x120 > [ 14.677388 ] syscall_exit_to_user_mode+0x1d/0x40 > [ 14.677678 ] entry_SYSCALL_64_after_hwframe+0x44/0xae > [ 14.677995 ] RIP: 0033:0x7fc5a8666f30 > [ 14.678229 ] Code: 00 64 c7 00 0d 00 00 00 b8 ff ff ff ff eb 90 > b8 ff ff ff ff eb 89 0f 1f 40 00 83 3d d9 27 2c 00 00 75 10 b8 03 > 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e84 > [ 14.679385 ] RSP: 002b:7ffe9e94cd68 EFLAGS: 0246 > ORIG_RAX: 0003 > [ 14.679862 ] RAX: RBX: > RCX: 7fc5a8666f30 > [ 14.680301 ] RDX: 7ffe9e94ce78 RSI: 2601 > RDI: 0004 > [ 14.680743 ] RBP: 7ffe9e94cd80 R08: 564727400850 > R09: 7fc5a8939ba0 > [ 14.681180 ] R10: 0692 R11: 0246 > R12: 564727400610 > [ 14.681624 ] R13: 7ffe9e94ce60 R14: > R15: > [ 14.682072 ] > [ 14.682168 ] Allocated by task 337: > [ 14.682387 ] kasan_save_stack+0x1b/0x40 > [ 14.682633 ] __kasan_kmalloc+0x7a/0x90 > [ 14.682868 ] nosy_open+0x154/0x4d0 > [ 14.683089 ] misc_open+0x2ec/0x410 > [ 14.683313 ] chrdev_open+0x20d/0x5a0 > [ 14.683541 ] do_dentry_open+0x40f/0xe80 > [ 14.683787 ] path_openat+0x1cf9/0x37b0 > [ 14.684025 ] do_filp_open+0x16d/0x390 > [ 14.684253 ] do_sys_openat2+0x11d/0x360 > [ 14.684497 ] __x64_sys_open+0xfd/0x1a0 > [ 14.684736 ] do_syscall_64+0x33/0x40 > [ 14.684964 ] entry_SYSCALL_64_after_hwframe+0x44/0xae > [ 14.685283 ] > [ 14.685384 ] Freed by task 337: > [ 14.685580 ] kasan_save_stack+0x1b/0x40 > [ 14.685822 ] kasan_set_track+0x1c/0x30 > [ 14.686062 ] kasan_set_free_info+0x20/0x30 > [ 14.686324 ] __kasan_slab_free+0xe5/0x110 > [ 14.686581 ] kfree+0x8f/0x210 > [ 14.686775 ] nosy_release+0x158/0x210 > [ 14.687011 ] __fput+0x1e2/0x840 > [ 14.687213 ] task_work_run+0xe8/0x180 > [ 14.687449 ] exit_to_user_mode_prepare+0x114/0x120 > [ 14.687750 ] syscall_exit_to_user_mode+0x1d/0x40 > [ 14.688040 ] entry_SYSCALL_64_after_hwframe+0x44/0xae > [ 14.688356 ] > [ 14.688454 ] The buggy address belongs to the object at > 888102ad7300 > [ 14.688454 ] which belongs to the cache kmalloc-128 of size 128 > [ 14.689232 ] The buggy address is located 96 bytes inside of > [ 14.689232 ] 128-byte region [888102ad7300, 888102ad7380) > [ 14.689955 ] The buggy address belongs to the page: > [ 14.690258 ] page:46ca3dc1 refcount:1 mapcount:0 > mapping: index:0x888102ad7100 pfn:0x102ad6 > [ 14.690917 ] head:46ca3dc1 order:1 compound_mapcount:0 > [ 14.691278 ] flags: 0x2010200(slab|head)
Re: [PATCH 2/4] KVM: MIPS: rework flush_shadow_* callbacks into one that prepares the flush
On 03/04/21 04:31, Huacai Chen wrote: Hi, Paolo, TE mode has been removed in the MIPS tree, can we also remove it in KVM tree before this rework? Fortunately I can pull the exact commit that was applied to the MIPS tree, as it was the first patch that was applied to the tree, but next time please send KVM changes through the KVM tree. Paolo
[PATCH v2 1/7] perf arm-spe: Remove unused enum value ARM_SPE_PER_CPU_MMAPS
The enum value 'ARM_SPE_PER_CPU_MMAPS' is never used so remove it. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.h | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/perf/util/arm-spe.h b/tools/perf/util/arm-spe.h index 98d3235781c3..105ce0ea0a01 100644 --- a/tools/perf/util/arm-spe.h +++ b/tools/perf/util/arm-spe.h @@ -11,7 +11,6 @@ enum { ARM_SPE_PMU_TYPE, - ARM_SPE_PER_CPU_MMAPS, ARM_SPE_AUXTRACE_PRIV_MAX, }; -- 2.25.1
[PATCH v2 0/7] perf arm-spe: Enable timestamp
As we know, the timestamp is important for AUX trace; it's mainly used to correlate between perf events and AUX trace, allows to generate events with time ordered manner. There have several good examples of enabling timestamp for AUX trace (like Intel-pt, Intel-bts, etc). Since the conversion between TSC and kernel timestamp has been supported on Arm64, TSC is a naming convention from x86, but perf now has reused it to support Arm arch timer counter. This patch set is to enable timestamp for Arm SPE trace. It reads out TSC parameters from mmap page and stores into auxtrace info structure; the TSC parameters are used for conversion between timer counter and kernel time and which is applied for Arm SPE samples. This patch set can be clearly applied on perf/core branch with: commit 6859bc0e78c6 ("perf stat: Improve readability of shadow stats") Ths patch series has been tested on Hisilicon D06 platform. After: # perf script -F comm,time,cpu,pid,dso,ip,sym perf 2408 [032] 168.680297: bd1253690a3c perf_event_exec ([kernel.kallsyms]) perf 2408 [032] 168.680297: bd1253690a3c perf_event_exec ([kernel.kallsyms]) false_sharing.e 2408 [032] 168.680317: bd1253683f50 perf_iterate_ctx.constprop.0 ([kernel.kallsyms]) false_sharing.e 2408 [032] 168.680317: bd1253683f50 perf_iterate_ctx.constprop.0 ([kernel.kallsyms]) false_sharing.e 2408 [032] 168.680319: bd1253683f70 perf_iterate_ctx.constprop.0 ([kernel.kallsyms]) false_sharing.e 2408 [032] 168.680319: bd1253683f70 perf_iterate_ctx.constprop.0 ([kernel.kallsyms]) false_sharing.e 2408 [032] 168.680367: bd12539b03ec __arch_clear_user ([kernel.kallsyms]) false_sharing.e 2408 [032] 168.680375: bd1253721440 kmem_cache_alloc ([kernel.kallsyms]) false_sharing.e 2408 [032] 168.680375: bd1253721440 kmem_cache_alloc ([kernel.kallsyms]) false_sharing.e 2408 [032] 168.680375: bd1253721440 kmem_cache_alloc ([kernel.kallsyms]) false_sharing.e 2408 [032] 168.680375: bd1253721440 kmem_cache_alloc ([kernel.kallsyms]) false_sharing.e 2408 [032] 168.680376: bd1253683f70 perf_iterate_ctx.constprop.0 ([kernel.kallsyms]) false_sharing.e 2408 [032] 168.680376: bd1253683f70 perf_iterate_ctx.constprop.0 ([kernel.kallsyms]) false_sharing.e 2408 [032] 168.680376: bd1253683f70 perf_iterate_ctx.constprop.0 ([kernel.kallsyms]) Changes from v1: * Rebased patch series on the latest perf/core branch; * Fixed the patch for dumping TSC parameters to support both the older and new auxtrace info format. Leo Yan (7): perf arm-spe: Remove unused enum value ARM_SPE_PER_CPU_MMAPS perf arm-spe: Store TSC parameters in auxtrace info perf arm-spe: Dump TSC parameters perf arm-spe: Convert event kernel time to counter value perf arm-spe: Assign kernel time to synthesized event perf arm-spe: Bail out if the trace is later than perf event perf arm-spe: Don't wait for PERF_RECORD_EXIT event tools/perf/arch/arm64/util/arm-spe.c | 23 +++ tools/perf/util/arm-spe.c| 89 +++- tools/perf/util/arm-spe.h| 7 ++- 3 files changed, 103 insertions(+), 16 deletions(-) -- 2.25.1
[PATCH v2 2/7] perf arm-spe: Store TSC parameters in auxtrace info
The TSC parameters are used for conversion between arch timer counter and kernel timestamp, this patch stores the parameters into the struct perf_record_auxtrace_info, and it is saved in perf data file. Signed-off-by: Leo Yan --- tools/perf/arch/arm64/util/arm-spe.c | 23 +++ tools/perf/util/arm-spe.h| 6 ++ 2 files changed, 29 insertions(+) diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c index 414c8a5584b1..dd940cf16f49 100644 --- a/tools/perf/arch/arm64/util/arm-spe.c +++ b/tools/perf/arch/arm64/util/arm-spe.c @@ -15,7 +15,9 @@ #include "../../../util/event.h" #include "../../../util/evsel.h" #include "../../../util/evlist.h" +#include "../../../util/mmap.h" #include "../../../util/session.h" +#include "../../../util/tsc.h" #include // page_size #include "../../../util/pmu.h" #include "../../../util/debug.h" @@ -47,6 +49,9 @@ static int arm_spe_info_fill(struct auxtrace_record *itr, struct arm_spe_recording *sper = container_of(itr, struct arm_spe_recording, itr); struct perf_pmu *arm_spe_pmu = sper->arm_spe_pmu; + struct perf_event_mmap_page *pc; + struct perf_tsc_conversion tc = { .time_mult = 0, }; + int err; if (priv_size != ARM_SPE_AUXTRACE_PRIV_SIZE) return -EINVAL; @@ -54,8 +59,26 @@ static int arm_spe_info_fill(struct auxtrace_record *itr, if (!session->evlist->core.nr_mmaps) return -EINVAL; + pc = session->evlist->mmap[0].core.base; + if (pc) { + err = perf_read_tsc_conversion(pc, &tc); + if (err) { + if (err != -EOPNOTSUPP) + return err; + } + + if (!tc.time_mult) + ui__warning("Arm SPE: arch timer not available\n"); + } + auxtrace_info->type = PERF_AUXTRACE_ARM_SPE; auxtrace_info->priv[ARM_SPE_PMU_TYPE] = arm_spe_pmu->type; + auxtrace_info->priv[ARM_SPE_TIME_SHIFT] = tc.time_shift; + auxtrace_info->priv[ARM_SPE_TIME_MULT] = tc.time_mult; + auxtrace_info->priv[ARM_SPE_TIME_ZERO] = tc.time_zero; + auxtrace_info->priv[ARM_SPE_TIME_CYCLES] = tc.time_cycles; + auxtrace_info->priv[ARM_SPE_TIME_MASK] = tc.time_mask; + auxtrace_info->priv[ARM_SPE_CAP_USER_TIME_SHORT] = tc.cap_user_time_short; return 0; } diff --git a/tools/perf/util/arm-spe.h b/tools/perf/util/arm-spe.h index 105ce0ea0a01..5bf3e838d226 100644 --- a/tools/perf/util/arm-spe.h +++ b/tools/perf/util/arm-spe.h @@ -11,6 +11,12 @@ enum { ARM_SPE_PMU_TYPE, + ARM_SPE_TIME_SHIFT, + ARM_SPE_TIME_MULT, + ARM_SPE_TIME_ZERO, + ARM_SPE_TIME_CYCLES, + ARM_SPE_TIME_MASK, + ARM_SPE_CAP_USER_TIME_SHORT, ARM_SPE_AUXTRACE_PRIV_MAX, }; -- 2.25.1
[PATCH v2 3/7] perf arm-spe: Dump TSC parameters
The TSC parameters are stored in auxtrace info, this patch dumps these parameters for reporting the raw data. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.c | 42 ++- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 2539d4baec44..69ce3483d1af 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -26,6 +26,7 @@ #include "symbol.h" #include "thread.h" #include "thread-stack.h" +#include "tsc.h" #include "tool.h" #include "util/synthetic-events.h" @@ -45,6 +46,8 @@ struct arm_spe { struct machine *machine; u32 pmu_type; + struct perf_tsc_conversion tc; + u8 timeless_decoding; u8 data_queued; @@ -803,14 +806,23 @@ static bool arm_spe_evsel_is_auxtrace(struct perf_session *session, static const char * const arm_spe_info_fmts[] = { [ARM_SPE_PMU_TYPE] = " PMU Type %"PRId64"\n", + [ARM_SPE_TIME_SHIFT]= " Time Shift %"PRIu64"\n", + [ARM_SPE_TIME_MULT] = " Time Muliplier %"PRIu64"\n", + [ARM_SPE_TIME_ZERO] = " Time Zero %"PRIu64"\n", + [ARM_SPE_TIME_CYCLES] = " Time Cycles%"PRIu64"\n", + [ARM_SPE_TIME_MASK] = " Time Mask %#"PRIx64"\n", + [ARM_SPE_CAP_USER_TIME_SHORT] = " Cap Time Short %"PRId64"\n", }; -static void arm_spe_print_info(__u64 *arr) +static void arm_spe_print_info(__u64 *arr, int start, int finish) { + int i; + if (!dump_trace) return; - fprintf(stdout, arm_spe_info_fmts[ARM_SPE_PMU_TYPE], arr[ARM_SPE_PMU_TYPE]); + for (i = start; i <= finish; i++) + fprintf(stdout, arm_spe_info_fmts[i], arr[i]); } struct arm_spe_synth { @@ -1001,11 +1013,19 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) return 0; } +static bool arm_spe_has(struct perf_record_auxtrace_info *auxtrace_info, + int pos) +{ + return auxtrace_info->header.size >= + (sizeof(struct perf_record_auxtrace_info) + +(sizeof(u64) * (pos + 1))); +} + int arm_spe_process_auxtrace_info(union perf_event *event, struct perf_session *session) { struct perf_record_auxtrace_info *auxtrace_info = &event->auxtrace_info; - size_t min_sz = sizeof(u64) * ARM_SPE_AUXTRACE_PRIV_MAX; + size_t min_sz = sizeof(u64) * ARM_SPE_TIME_SHIFT; struct arm_spe *spe; int err; @@ -1025,6 +1045,20 @@ int arm_spe_process_auxtrace_info(union perf_event *event, spe->machine = &session->machines.host; /* No kvm support */ spe->auxtrace_type = auxtrace_info->type; spe->pmu_type = auxtrace_info->priv[ARM_SPE_PMU_TYPE]; + arm_spe_print_info(&auxtrace_info->priv[0], ARM_SPE_PMU_TYPE, + ARM_SPE_PMU_TYPE); + + if (arm_spe_has(auxtrace_info, ARM_SPE_CAP_USER_TIME_SHORT)) { + spe->tc.time_shift = auxtrace_info->priv[ARM_SPE_TIME_SHIFT]; + spe->tc.time_mult = auxtrace_info->priv[ARM_SPE_TIME_MULT]; + spe->tc.time_zero = auxtrace_info->priv[ARM_SPE_TIME_ZERO]; + spe->tc.time_cycles = auxtrace_info->priv[ARM_SPE_TIME_CYCLES]; + spe->tc.time_mask = auxtrace_info->priv[ARM_SPE_TIME_MASK]; + spe->tc.cap_user_time_short = + auxtrace_info->priv[ARM_SPE_CAP_USER_TIME_SHORT]; + arm_spe_print_info(&auxtrace_info->priv[0], ARM_SPE_TIME_SHIFT, + ARM_SPE_CAP_USER_TIME_SHORT); + } spe->timeless_decoding = arm_spe__is_timeless_decoding(spe); spe->auxtrace.process_event = arm_spe_process_event; @@ -1035,8 +1069,6 @@ int arm_spe_process_auxtrace_info(union perf_event *event, spe->auxtrace.evsel_is_auxtrace = arm_spe_evsel_is_auxtrace; session->auxtrace = &spe->auxtrace; - arm_spe_print_info(&auxtrace_info->priv[0]); - if (dump_trace) return 0; -- 2.25.1
[PATCH v2 4/7] perf arm-spe: Convert event kernel time to counter value
When handle a perf event, Arm SPE decoder needs to decide if this perf event is earlier or later than the samples from Arm SPE trace data; to do comparision, it needs to use the same unit for the time. This patch converts the event kernel time to arch timer's counter value, thus it can be used to compare with counter value contained in Arm SPE Timestamp packet. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 69ce3483d1af..4cf558b0218a 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -669,7 +669,7 @@ static int arm_spe_process_event(struct perf_session *session, } if (sample->time && (sample->time != (u64) -1)) - timestamp = sample->time; + timestamp = perf_time_to_tsc(sample->time, &spe->tc); else timestamp = 0; -- 2.25.1
[PATCH v2 5/7] perf arm-spe: Assign kernel time to synthesized event
In current code, it assigns the arch timer counter to the synthesized samples Arm SPE trace, thus the samples don't contain the kernel time but only contain the raw counter value. To fix the issue, this patch converts the timer counter to kernel time and assigns it to sample timestamp. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 4cf558b0218a..80f5659e7f7e 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -234,7 +234,7 @@ static void arm_spe_prep_sample(struct arm_spe *spe, struct arm_spe_record *record = &speq->decoder->record; if (!spe->timeless_decoding) - sample->time = speq->timestamp; + sample->time = tsc_to_perf_time(record->timestamp, &spe->tc); sample->ip = record->from_ip; sample->cpumode = arm_spe_cpumode(spe, sample->ip); -- 2.25.1
[PATCH v2 6/7] perf arm-spe: Bail out if the trace is later than perf event
It's possible that record in Arm SPE trace is later than perf event and vice versa. This asks to correlate the perf events and Arm SPE synthesized events to be processed in the manner of correct timing. To achieve the time ordering, this patch reverses the flow, it firstly calls arm_spe_sample() and then calls arm_spe_decode(). By comparing the timestamp value and detect the perf event is coming earlier than Arm SPE trace data, it bails out from the decoding loop, the last record is pushed into auxtrace stack and is deferred to generate sample. To track the timestamp, everytime it updates timestamp for the latest record. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.c | 37 ++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 80f5659e7f7e..99a394c366e0 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -434,12 +434,36 @@ static int arm_spe_sample(struct arm_spe_queue *speq) static int arm_spe_run_decoder(struct arm_spe_queue *speq, u64 *timestamp) { struct arm_spe *spe = speq->spe; + struct arm_spe_record *record; int ret; if (!spe->kernel_start) spe->kernel_start = machine__kernel_start(spe->machine); while (1) { + /* +* The usual logic is firstly to decode the packets, and then +* based the record to synthesize sample; but here the flow is +* reversed: it calls arm_spe_sample() for synthesizing samples +* prior to arm_spe_decode(). +* +* Two reasons for this code logic: +* 1. Firstly, when setup queue in arm_spe__setup_queue(), it +* has decoded trace data and generated a record, but the record +* is left to generate sample until run to here, so it's correct +* to synthesize sample for the left record. +* 2. After decoding trace data, it needs to compare the record +* timestamp with the coming perf event, if the record timestamp +* is later than the perf event, it needs bail out and pushs the +* record into auxtrace heap, thus the record can be deferred to +* synthesize sample until run to here at the next time; so this +* can correlate samples between Arm SPE trace data and other +* perf events with correct time ordering. +*/ + ret = arm_spe_sample(speq); + if (ret) + return ret; + ret = arm_spe_decode(speq->decoder); if (!ret) { pr_debug("No data or all data has been processed.\n"); @@ -453,10 +477,17 @@ static int arm_spe_run_decoder(struct arm_spe_queue *speq, u64 *timestamp) if (ret < 0) continue; - ret = arm_spe_sample(speq); - if (ret) - return ret; + record = &speq->decoder->record; + /* Update timestamp for the last record */ + if (record->timestamp > speq->timestamp) + speq->timestamp = record->timestamp; + + /* +* If the timestamp of the queue is later than timestamp of the +* coming perf event, bail out so can allow the perf event to +* be processed ahead. +*/ if (!spe->timeless_decoding && speq->timestamp >= *timestamp) { *timestamp = speq->timestamp; return 0; -- 2.25.1
[PATCH v2 7/7] perf arm-spe: Don't wait for PERF_RECORD_EXIT event
When decode Arm SPE trace, it waits for PERF_RECORD_EXIT event (the last perf event) for processing trace data, which is needless and even might cause logic error, e.g. it might fail to correlate perf events with Arm SPE events correctly. So this patch removes the condition checking for PERF_RECORD_EXIT event. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 99a394c366e0..17dcad99912a 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -717,11 +717,7 @@ static int arm_spe_process_event(struct perf_session *session, sample->time); } } else if (timestamp) { - if (event->header.type == PERF_RECORD_EXIT) { - err = arm_spe_process_queues(spe, timestamp); - if (err) - return err; - } + err = arm_spe_process_queues(spe, timestamp); } return err; -- 2.25.1
Re: [PATCH 14/16] staging: rtl8723bs: remove all RT_TRACE logs in core/rtw_wlan_util.c
On Fri, Apr 02, 2021 at 11:37:17AM -0700, Joe Perches wrote: > On Fri, 2021-04-02 at 19:40 +0200, Fabio Aiuto wrote: > > On Fri, Apr 02, 2021 at 08:20:17AM -0700, Joe Perches wrote: > > > On Fri, 2021-04-02 at 14:51 +0200, Fabio Aiuto wrote: > > > > On Fri, Apr 02, 2021 at 03:37:57AM -0700, Joe Perches wrote: > > > > > On Fri, 2021-04-02 at 12:01 +0200, Fabio Aiuto wrote: > > > > > > remove all RT_TRACE logs > > > > > > > > > > > > fix patch-related checkpatch issues > [] > > > > > Lastly, another suggestion would be to just submit a single patch > > > > > removing _ALL_ the RT_TRACE uses not intermixing various other > > > > > cleanups > > > > > with the series and then do those other cleanups. > > > > > > > > > > Using a coccinelle script like: > > > > > > > > > > $ cat RT_TRACE.cocci > > > > > @@ > > > > > expression a, b, c; > > > > > @@ > > > > > > > > > > - RT_TRACE(a, b, (c)); > > > > > > > > > > $ spatch -sp-file RT_TRACE.cocci drivers/staging/rtl8723bs/ > > > > > > > > > > And then clean up the various bits you think are inappropriately done. > [] > > > > thank you Joe, I tried with (RT_TRACE.cocci in parent folder) > > > > > > > > user@host:~/src/git/kernels/staging$ spatch -sp-file ../RT_TRACE.cocci > > > > drivers/staging/rtl8723bs/ > > > > init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h > > > > 0 files match > > > > > > Likely you are running the script on the tree after you have > > > applied all your patches. > > > > > > Try running the cocci script on a fresh copy of -next. > > > > > > Using the script and adding the script in the commit message helps > > > others to verify that the changes you make do not have any other effect. > > > > > > $ cat RT_TRACE.cocci > > > @@ > > > expression a, b, c; > > > @@ > > > > > > - RT_TRACE(a, b, (c)); > > > > > > $ git checkout next-20210401 > > > $ spatch -sp-file RT_TRACE.cocci --in-place --no-show-diff --very-quiet > > > drivers/staging/rtl8723bs/ > > > 31 files match > > > $ git diff --stat -p > > > drivers/staging/rtl8723bs/core/rtw_cmd.c | 34 +-- > [] > > > 28 files changed, 19 insertions(+), 935 deletions(-) > [] > > thank you Joe, this mail is so precious ;) > > I'm not quite sure what you mean by that but you quoted > nearly 200k of the previous email. you gave me good advice > > Please remember to trim your replies. > > got it, thank you regards, fabio
Re: [PATCH] platform/chrome: Update cros_ec sysfs attributes on sensors discovery
Hi Gwendal, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on chrome-platform-linux/for-next] [also build test WARNING on linux/master linus/master v5.12-rc5 next-20210401] [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/Gwendal-Grignou/platform-chrome-Update-cros_ec-sysfs-attributes-on-sensors-discovery/20210403-142205 base: https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next config: xtensa-allyesconfig (attached as .config) compiler: xtensa-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 # https://github.com/0day-ci/linux/commit/f4bc64b0efbd2fb964478a0a2aab4ba2fc827447 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Gwendal-Grignou/platform-chrome-Update-cros_ec-sysfs-attributes-on-sensors-discovery/20210403-142205 git checkout f4bc64b0efbd2fb964478a0a2aab4ba2fc827447 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=xtensa If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All warnings (new ones prefixed by >>): drivers/platform/chrome/cros_ec_sysfs.c: In function 'cros_ec_sysfs_probe': >> drivers/platform/chrome/cros_ec_sysfs.c:348:17: warning: assignment discards >> 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 348 | ec_dev->group = &cros_ec_attr_group; | ^ vim +/const +348 drivers/platform/chrome/cros_ec_sysfs.c 337 338 static int cros_ec_sysfs_probe(struct platform_device *pd) 339 { 340 struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent); 341 struct device *dev = &pd->dev; 342 int ret; 343 344 ret = sysfs_create_group(&ec_dev->class_dev.kobj, &cros_ec_attr_group); 345 if (ret < 0) 346 dev_err(dev, "failed to create attributes. err=%d\n", ret); 347 else > 348 ec_dev->group = &cros_ec_attr_group; 349 350 return ret; 351 } 352 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org .config.gz Description: application/gzip
Re: [PATCH v2 01/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_xmit.c
On Fri, Apr 02, 2021 at 07:29:43PM +0200, Fabio Aiuto wrote: > remove all RT_TRACE logs > I don't mean to be a pain, but this changelog text needs some work. This says _what_ it does, but not _why_ you are doing this. The kernel documentation has a section on how to write a good changelog text, you might want to look at that. For this type of series, this could be as simple as: Remove all of the RT_TRACE_LOGs in the rtx_xmit.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged, so just remove them as they are unused. Or something like that. Most of the time, writing the changelog can take more work than the actual code change itself, but it's important as we need to know what is happening both for the reviewers, as well as people in the future who might have to look back and try to understand the reason for specific changes. Can you fix up this series based on this and resend? thanks, greg k-h
Re: [PATCH] platform/chrome: Update cros_ec sysfs attributes on sensors discovery
Hi Gwendal, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on chrome-platform-linux/for-next] [also build test WARNING on linux/master linus/master v5.12-rc5 next-20210401] [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/Gwendal-Grignou/platform-chrome-Update-cros_ec-sysfs-attributes-on-sensors-discovery/20210403-142205 base: https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next config: riscv-randconfig-s032-20210403 (attached as .config) compiler: riscv64-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.3-279-g6d5d9b42-dirty # https://github.com/0day-ci/linux/commit/f4bc64b0efbd2fb964478a0a2aab4ba2fc827447 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Gwendal-Grignou/platform-chrome-Update-cros_ec-sysfs-attributes-on-sensors-discovery/20210403-142205 git checkout f4bc64b0efbd2fb964478a0a2aab4ba2fc827447 # 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=riscv If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot sparse warnings: (new ones prefixed by >>) >> drivers/platform/chrome/cros_ec_sysfs.c:348:31: sparse: sparse: incorrect >> type in assignment (different modifiers) @@ expected struct >> attribute_group *group @@ got struct attribute_group const * @@ drivers/platform/chrome/cros_ec_sysfs.c:348:31: sparse: expected struct attribute_group *group drivers/platform/chrome/cros_ec_sysfs.c:348:31: sparse: got struct attribute_group const * vim +348 drivers/platform/chrome/cros_ec_sysfs.c 337 338 static int cros_ec_sysfs_probe(struct platform_device *pd) 339 { 340 struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent); 341 struct device *dev = &pd->dev; 342 int ret; 343 344 ret = sysfs_create_group(&ec_dev->class_dev.kobj, &cros_ec_attr_group); 345 if (ret < 0) 346 dev_err(dev, "failed to create attributes. err=%d\n", ret); 347 else > 348 ec_dev->group = &cros_ec_attr_group; 349 350 return ret; 351 } 352 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org .config.gz Description: application/gzip
Re: [PATCH v2 01/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_xmit.c
On Sat, Apr 03, 2021 at 09:40:08AM +0200, Greg KH wrote: > On Fri, Apr 02, 2021 at 07:29:43PM +0200, Fabio Aiuto wrote: > > remove all RT_TRACE logs > > > > I don't mean to be a pain, but this changelog text needs some work. > > This says _what_ it does, but not _why_ you are doing this. The kernel > documentation has a section on how to write a good changelog text, you > might want to look at that. you are right, I spent time writing the cover, but not the changelog which will remain in kernel history > > For this type of series, this could be as simple as: > Remove all of the RT_TRACE_LOGs in the rtx_xmit.c file as they > currently do nothing as they require the code to be modified by > hand in order to be turned on. This obviously has not happened > since the code was merged, so just remove them as they are > unused. > > > Or something like that. > > Most of the time, writing the changelog can take more work than the > actual code change itself, but it's important as we need to know what is > happening both for the reviewers, as well as people in the future who > might have to look back and try to understand the reason for specific > changes. > > Can you fix up this series based on this and resend? > > thanks, > > greg k-h Thank you Greg, I will do and resend it. fabio
[PATCH] ia64: module: fix symbolizer crash on fdescr
Noticed failure as a crash on ia64 when tried to symbolize all backtraces collected by page_owner=on: $ cat /sys/kernel/debug/page_owner CPU: 1 PID: 2074 Comm: cat Not tainted 5.12.0-rc4 #226 Hardware name: hp server rx3600, BIOS 04.03 04/08/2008 ip is at dereference_module_function_descriptor+0x41/0x100 Crash happens at dereference_module_function_descriptor() due to use-after-free when dereferencing ".opd" section header. All section headers are already freed after module is laoded successfully. To keep symbolizer working the change stores ".opd" address and size after module is relocated to a new place and before section headers are discarded. To make similar errors less obscure module_finalize() now zeroes out all variables relevant to module loading only. CC: Andrew Morton CC: linux-i...@vger.kernel.org Signed-off-by: Sergei Trofimovich --- arch/ia64/include/asm/module.h | 6 +- arch/ia64/kernel/module.c | 29 + 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/arch/ia64/include/asm/module.h b/arch/ia64/include/asm/module.h index 5a29652e6def..7271b9c5fc76 100644 --- a/arch/ia64/include/asm/module.h +++ b/arch/ia64/include/asm/module.h @@ -14,16 +14,20 @@ struct elf64_shdr; /* forward declration */ struct mod_arch_specific { + /* Used only at module load time. */ struct elf64_shdr *core_plt;/* core PLT section */ struct elf64_shdr *init_plt;/* init PLT section */ struct elf64_shdr *got; /* global offset table */ struct elf64_shdr *opd; /* official procedure descriptors */ struct elf64_shdr *unwind; /* unwind-table section */ unsigned long gp; /* global-pointer for module */ + unsigned int next_got_entry;/* index of next available got entry */ + /* Used at module run and cleanup time. */ void *core_unw_table; /* core unwind-table cookie returned by unwinder */ void *init_unw_table; /* init unwind-table cookie returned by unwinder */ - unsigned int next_got_entry;/* index of next available got entry */ + void *opd_addr; /* symbolize uses .opd to get to actual function */ + unsigned long opd_size; }; #define ARCH_SHF_SMALL SHF_IA_64_SHORT diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c index 00a496cb346f..f3385fe6e37e 100644 --- a/arch/ia64/kernel/module.c +++ b/arch/ia64/kernel/module.c @@ -905,9 +905,31 @@ register_unwind_table (struct module *mod) int module_finalize (const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, struct module *mod) { + struct mod_arch_specific *mas = &mod->arch; + DEBUGP("%s: init: entry=%p\n", __func__, mod->init); - if (mod->arch.unwind) + if (mas->unwind) register_unwind_table(mod); + + /* +* ".opd" was already relocated to the final destination. Store +* it's address for use in symbolizer. +*/ + mas->opd_addr = (void *)mas->opd->sh_addr; + mas->opd_size = mas->opd->sh_size; + + /* +* Module relocation was already done at this point. Section +* headers are about to be deleted. Wipe out load-time context. +*/ + mas->core_plt = NULL; + mas->init_plt = NULL; + mas->got = NULL; + mas->opd = NULL; + mas->unwind = NULL; + mas->gp = 0; + mas->next_got_entry = 0; + return 0; } @@ -926,10 +948,9 @@ module_arch_cleanup (struct module *mod) void *dereference_module_function_descriptor(struct module *mod, void *ptr) { - Elf64_Shdr *opd = mod->arch.opd; + struct mod_arch_specific *mas = &mod->arch; - if (ptr < (void *)opd->sh_addr || - ptr >= (void *)(opd->sh_addr + opd->sh_size)) + if (ptr < mas->opd_addr || ptr >= mas->opd_addr + mas->opd_size) return ptr; return dereference_function_descriptor(ptr); -- 2.31.1
Re: [PATCH v2 01/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_xmit.c
On Sat, Apr 03, 2021 at 09:48:06AM +0200, Fabio Aiuto wrote: > On Sat, Apr 03, 2021 at 09:40:08AM +0200, Greg KH wrote: > > On Fri, Apr 02, 2021 at 07:29:43PM +0200, Fabio Aiuto wrote: > > > remove all RT_TRACE logs > > > > > > > I don't mean to be a pain, but this changelog text needs some work. > > > > This says _what_ it does, but not _why_ you are doing this. The kernel > > documentation has a section on how to write a good changelog text, you > > might want to look at that. > > you are right, I spent time writing the cover, but not the changelog which > will remain in kernel history Take portions of what you write in the cover letter, into the changelog for the patches. Or the other way around is also good, depending on which you write first :) thanks, greg k-h
Re: [PATCH] platform/chrome: Update cros_ec sysfs attributes on sensors discovery
On Fri, Apr 02, 2021 at 11:20:31PM -0700, Gwendal Grignou wrote: > When cros_ec_sysfs probe is called before cros_ec_sensorhub probe > routine, the |kb_wake_angle| attribute will not be displayed, even if > there are two accelerometers in the chromebook. > > Call sysfs_update_group() when accelerometers are enumerated if the > cros_ec sysfs attributes group has already been created. > > Fixes: d60ac88a62df ("mfd / platform / iio: cros_ec: Register sensor through > sensorhub") > Cc: sta...@vger.kernel.org > Signed-off-by: Gwendal Grignou > --- > drivers/platform/chrome/cros_ec_sensorhub.c | 5 - > drivers/platform/chrome/cros_ec_sysfs.c | 2 ++ > include/linux/platform_data/cros_ec_proto.h | 2 ++ > 3 files changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/platform/chrome/cros_ec_sensorhub.c > b/drivers/platform/chrome/cros_ec_sensorhub.c > index 9c4af76a9956e..78085ad362ca8 100644 > --- a/drivers/platform/chrome/cros_ec_sensorhub.c > +++ b/drivers/platform/chrome/cros_ec_sensorhub.c > @@ -106,8 +106,11 @@ static int cros_ec_sensorhub_register(struct device *dev, > sensor_type[sensorhub->resp->info.type]++; > } > > - if (sensor_type[MOTIONSENSE_TYPE_ACCEL] >= 2) > + if (sensor_type[MOTIONSENSE_TYPE_ACCEL] >= 2) { > ec->has_kb_wake_angle = true; > + if (ec->group) > + sysfs_update_group(&ec->class_dev.kobj, ec->group); > + } > > if (cros_ec_check_features(ec, > EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS)) { > diff --git a/drivers/platform/chrome/cros_ec_sysfs.c > b/drivers/platform/chrome/cros_ec_sysfs.c > index f07eabcf9494c..3838d5f51aadc 100644 > --- a/drivers/platform/chrome/cros_ec_sysfs.c > +++ b/drivers/platform/chrome/cros_ec_sysfs.c > @@ -344,6 +344,8 @@ static int cros_ec_sysfs_probe(struct platform_device *pd) > ret = sysfs_create_group(&ec_dev->class_dev.kobj, &cros_ec_attr_group); This is odd, the platform/driver core should be creating these files, you should never have to do this "by hand". If you do it this way, you are racing with userspace and loosing. Please set the dev_groups field in the driver structure to be this group and then all will be fine automatically. > if (ret < 0) > dev_err(dev, "failed to create attributes. err=%d\n", ret); > + else > + ec_dev->group = &cros_ec_attr_group; > > return ret; > } > diff --git a/include/linux/platform_data/cros_ec_proto.h > b/include/linux/platform_data/cros_ec_proto.h > index 02599687770c5..4cd06f68bc536 100644 > --- a/include/linux/platform_data/cros_ec_proto.h > +++ b/include/linux/platform_data/cros_ec_proto.h > @@ -191,6 +191,7 @@ struct cros_ec_platform { > /** > * struct cros_ec_dev - ChromeOS EC device entry point. > * @class_dev: Device structure used in sysfs. > + * @group: sysfs attributes group for this EC. > * @ec_dev: cros_ec_device structure to talk to the physical device. > * @dev: Pointer to the platform device. > * @debug_info: cros_ec_debugfs structure for debugging information. > @@ -200,6 +201,7 @@ struct cros_ec_platform { > */ > struct cros_ec_dev { > struct device class_dev; > + struct attribute_group *group; This should not be needed. thanks, greg k-h
Re: [PATCH] platform/chrome: Update cros_ec sysfs attributes on sensors discovery
Hi Gwendal, Thank you for the patch! Yet something to improve: [auto build test ERROR on chrome-platform-linux/for-next] [also build test ERROR on linux/master linus/master v5.12-rc5 next-20210401] [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/Gwendal-Grignou/platform-chrome-Update-cros_ec-sysfs-attributes-on-sensors-discovery/20210403-142205 base: https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next config: arm-randconfig-r015-20210403 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 0fe8af94688aa03c01913c2001d6a1a911f42ce6) 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 arm cross compiling tool for clang build # apt-get install binutils-arm-linux-gnueabi # https://github.com/0day-ci/linux/commit/f4bc64b0efbd2fb964478a0a2aab4ba2fc827447 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Gwendal-Grignou/platform-chrome-Update-cros_ec-sysfs-attributes-on-sensors-discovery/20210403-142205 git checkout f4bc64b0efbd2fb964478a0a2aab4ba2fc827447 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): >> drivers/platform/chrome/cros_ec_sysfs.c:348:17: error: assigning to 'struct >> attribute_group *' from 'const struct attribute_group *' discards qualifiers >> [-Werror,-Wincompatible-pointer-types-discards-qualifiers] ec_dev->group = &cros_ec_attr_group; ^ ~~~ 1 error generated. vim +348 drivers/platform/chrome/cros_ec_sysfs.c 337 338 static int cros_ec_sysfs_probe(struct platform_device *pd) 339 { 340 struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent); 341 struct device *dev = &pd->dev; 342 int ret; 343 344 ret = sysfs_create_group(&ec_dev->class_dev.kobj, &cros_ec_attr_group); 345 if (ret < 0) 346 dev_err(dev, "failed to create attributes. err=%d\n", ret); 347 else > 348 ec_dev->group = &cros_ec_attr_group; 349 350 return ret; 351 } 352 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org .config.gz Description: application/gzip
Re: [PATCH 1/2] block: shutdown blktrace in case of fatal signal pending
On Fri, Apr 02, 2021 at 07:27:30PM +0200, Christoph Hellwig wrote: > On Wed, Mar 31, 2021 at 08:16:50AM +0800, Ming Lei wrote: > > On Tue, Mar 30, 2021 at 06:53:30PM +0200, Christoph Hellwig wrote: > > > On Tue, Mar 23, 2021 at 04:14:39PM +0800, Ming Lei wrote: > > > > blktrace may allocate lots of memory, if the process is terminated > > > > by user or OOM, we need to provide one chance to remove the trace > > > > buffer, otherwise memory leak may be caused. > > > > > > > > Fix the issue by shutdown blktrace in case of task exiting in > > > > blkdev_close(). > > > > > > > > Signed-off-by: Ming Lei > > > > > > This just seems weird. blktrace has no relationship to open > > > block device instances. > > > > blktrace still needs to open one blkdev, then send its own ioctl > > commands to block layer. In case of OOM, the allocated memory in > > these ioctl commands won't be released. > > > > Or any other suggestion? > > Not much we can do there I think. If we want to autorelease memory > it needs to be an API that ties the memory allocation to an FD. We still may shutdown blktrace if current is the last opener, otherwise new blktrace can't be started and memory should be leaked forever, and what do you think of the revised version? >From de33ec85ee1ce2865aa04f2639e480ea4db4eebf Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Tue, 23 Mar 2021 10:32:23 +0800 Subject: [PATCH] block: shutdown blktrace in case of task exiting blktrace may allocate lots of memory, if the process is terminated by user or OOM, we need to provide one chance to remove the trace buffer, otherwise memory leak may be caused. Also new blktrace instance can't be started too. Fix the issue by shutdown blktrace in case of task exiting in blkdev_close() when it is the last opener. Signed-off-by: Ming Lei --- fs/block_dev.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/fs/block_dev.c b/fs/block_dev.c index 92ed7d5df677..8fa59cecce72 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "internal.h" struct bdev_inode { @@ -1646,6 +1647,11 @@ EXPORT_SYMBOL(blkdev_put); static int blkdev_close(struct inode * inode, struct file * filp) { struct block_device *bdev = I_BDEV(bdev_file_inode(filp)); + + /* shutdown blktrace in case of exiting which may be from OOM */ + if ((current->flags & PF_EXITING) && (bdev->bd_openers == 1)) + blk_trace_shutdown(bdev->bd_disk->queue); + blkdev_put(bdev, filp->f_mode); return 0; } -- 2.29.2 -- Ming
[syzbot] WARNING: suspicious RCU usage in __schedule
Hello, syzbot found the following issue on: HEAD commit:1e43c377 Merge tag 'xtensa-20210329' of git://github.com/j.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1432bd1ad0 kernel config: https://syzkaller.appspot.com/x/.config?x=78a83786814e7724 dashboard link: https://syzkaller.appspot.com/bug?extid=be81a058b10931003a4a userspace arch: arm Unfortunately, I don't have any reproducer for this issue yet. IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+be81a058b10931003...@syzkaller.appspotmail.com = WARNING: suspicious RCU usage 5.12.0-rc5-syzkaller-3-g1e43c377a79f #0 Not tainted - kernel/sched/core.c:4841 Illegal context switch in RCU-sched read-side critical section! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 0 no locks held by migration/1/17. stack backtrace: CPU: 1 PID: 17 Comm: migration/1 Not tainted 5.12.0-rc5-syzkaller-3-g1e43c377a79f #0 Hardware name: linux,dummy-virt (DT) Stopper: 0x0 <- 0x0 Call trace: dump_backtrace+0x0/0x3e0 arch/arm64/include/asm/pointer_auth.h:76 show_stack+0x18/0x24 arch/arm64/kernel/stacktrace.c:191 __dump_stack lib/dump_stack.c:79 [inline] dump_stack+0x120/0x1a8 lib/dump_stack.c:120 lockdep_rcu_suspicious+0x130/0x148 kernel/locking/lockdep.c:6428 schedule_debug kernel/sched/core.c:4841 [inline] __schedule+0x1244/0x1bc4 kernel/sched/core.c:4967 schedule+0xac/0x22c kernel/sched/core.c:5152 smpboot_thread_fn+0x278/0x7f4 kernel/smpboot.c:161 kthread+0x320/0x3bc kernel/kthread.c:292 ret_from_fork+0x10/0x3c arch/arm64/kernel/entry.S:958 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkal...@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
Re: [PATCH v3] nvme: disallow passthru cmd from targeting a nsid != nsid of the block dev
So it turns out that while git-am complained it did apply the patch just fine and it didn't look whitespace mangled. No idea what went on there, but the patch is in nvme-5.13 now.
Re: [PATCH] drm/amdgpu: Fix a potential sdma invalid access
Hi Qu, Am 03.04.21 um 07:08 schrieb Qu Huang: Hi Christian, On 2021/4/3 0:25, Christian König wrote: Hi Qu, Am 02.04.21 um 05:18 schrieb Qu Huang: Before dma_resv_lock(bo->base.resv, NULL) in amdgpu_bo_release_notify(), the bo->base.resv lock may be held by ttm_mem_evict_first(), That can't happen since when bo_release_notify is called the BO has not more references and is therefore deleted. And we never evict a deleted BO, we just wait for it to become idle. Yes, the bo reference counter return to zero will enter ttm_bo_release(),but notify bo release (call amdgpu_bo_release_notify()) first happen, and then test if a reservation object's fences have been signaled, and then mark bo as deleted and remove bo from the LRU list. When ttm_bo_release() and ttm_mem_evict_first() is concurrent, the Bo has not been removed from the LRU list and is not marked as deleted, this will happen. Not sure on which code base you are, but I don't see how this can happen. ttm_mem_evict_first() calls ttm_bo_get_unless_zero() and ttm_bo_release() is only called when the BO reference count becomes zero. So ttm_mem_evict_first() will see that this BO is about to be destroyed and skips it. As a test, when we use CPU memset instead of SDMA fill in amdgpu_bo_release_notify(), the result is page fault: PID: 5490 TASK: 8e8136e04100 CPU: 4 COMMAND: "gemmPerf" #0 [8e79eaa17970] machine_kexec at b2863784 #1 [8e79eaa179d0] __crash_kexec at b291ce92 #2 [8e79eaa17aa0] crash_kexec at b291cf80 #3 [8e79eaa17ab8] oops_end at b2f6c768 #4 [8e79eaa17ae0] no_context at b2f5aaa6 #5 [8e79eaa17b30] __bad_area_nosemaphore at b2f5ab3d #6 [8e79eaa17b80] bad_area_nosemaphore at b2f5acae #7 [8e79eaa17b90] __do_page_fault at b2f6f6c0 #8 [8e79eaa17c00] do_page_fault at b2f6f925 #9 [8e79eaa17c30] page_fault at b2f6b758 [exception RIP: memset+31] RIP: b2b8668f RSP: 8e79eaa17ce8 RFLAGS: 00010a17 RAX: bebebebebebebebe RBX: 8e747bff10c0 RCX: 060b0020 RDX: RSI: 00be RDI: ab807f00 RBP: 8e79eaa17d10 R8: 8e79eaa14000 R9: ab7c8000 R10: bcba R11: 01ba R12: 8e79ebaa4050 R13: ab7c8000 R14: 00022600 R15: 8e8136e04100 ORIG_RAX: CS: 0010 SS: 0018 #10 [8e79eaa17ce8] amdgpu_bo_release_notify at c092f2d1 [amdgpu] #11 [8e79eaa17d18] ttm_bo_release at c08f39dd [amdttm] #12 [8e79eaa17d58] amdttm_bo_put at c08f3c8c [amdttm] #13 [8e79eaa17d68] amdttm_bo_vm_close at c08f7ac9 [amdttm] #14 [8e79eaa17d80] remove_vma at b29ef115 #15 [8e79eaa17da0] exit_mmap at b29f2c64 #16 [8e79eaa17e58] mmput at b28940c7 #17 [8e79eaa17e78] do_exit at b289dc95 #18 [8e79eaa17f10] do_group_exit at b289e4cf #19 [8e79eaa17f40] sys_exit_group at b289e544 #20 [8e79eaa17f50] system_call_fastpath at b2f74ddb Well that might be perfectly expected. VRAM is not necessarily CPU accessible. Regards, Christian. Regards, Qu. Regards, Christian. and the VRAM mem will be evicted, mem region was replaced by Gtt mem region. amdgpu_bo_release_notify() will then hold the bo->base.resv lock, and SDMA will get an invalid address in amdgpu_fill_buffer(), resulting in a VMFAULT or memory corruption. To avoid it, we have to hold bo->base.resv lock first, and check whether the mem.mem_type is TTM_PL_VRAM. Signed-off-by: Qu Huang --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 4b29b82..8018574 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -1300,12 +1300,16 @@ void amdgpu_bo_release_notify(struct ttm_buffer_object *bo) if (bo->base.resv == &bo->base._resv) amdgpu_amdkfd_remove_fence_on_pt_pd_bos(abo); - if (bo->mem.mem_type != TTM_PL_VRAM || !bo->mem.mm_node || - !(abo->flags & AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE)) + if (!(abo->flags & AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE)) return; dma_resv_lock(bo->base.resv, NULL); + if (bo->mem.mem_type != TTM_PL_VRAM || !bo->mem.mm_node) { + dma_resv_unlock(bo->base.resv); + return; + } + r = amdgpu_fill_buffer(abo, AMDGPU_POISON, bo->base.resv, &fence); if (!WARN_ON(r)) { amdgpu_bo_fence(abo, fence, false); -- 1.8.3.1
Re: [PATCH 1/2] block: shutdown blktrace in case of fatal signal pending
On Sat, Apr 03, 2021 at 04:10:16PM +0800, Ming Lei wrote: > On Fri, Apr 02, 2021 at 07:27:30PM +0200, Christoph Hellwig wrote: > > On Wed, Mar 31, 2021 at 08:16:50AM +0800, Ming Lei wrote: > > > On Tue, Mar 30, 2021 at 06:53:30PM +0200, Christoph Hellwig wrote: > > > > On Tue, Mar 23, 2021 at 04:14:39PM +0800, Ming Lei wrote: > > > > > blktrace may allocate lots of memory, if the process is terminated > > > > > by user or OOM, we need to provide one chance to remove the trace > > > > > buffer, otherwise memory leak may be caused. > > > > > > > > > > Fix the issue by shutdown blktrace in case of task exiting in > > > > > blkdev_close(). > > > > > > > > > > Signed-off-by: Ming Lei > > > > > > > > This just seems weird. blktrace has no relationship to open > > > > block device instances. > > > > > > blktrace still needs to open one blkdev, then send its own ioctl > > > commands to block layer. In case of OOM, the allocated memory in > > > these ioctl commands won't be released. > > > > > > Or any other suggestion? > > > > Not much we can do there I think. If we want to autorelease memory > > it needs to be an API that ties the memory allocation to an FD. > > We still may shutdown blktrace if current is the last opener, otherwise > new blktrace can't be started and memory should be leaked forever, and > what do you think of the revised version? This way seems not good enough, another better one is to use file->private_data for such purpose since blkdev fs doesn't use file->privete_data, then we can shutdown blktrace just for the blktrace FD: >From 191dff30abfd48c38a78dec78e011a39a3b606ca Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Tue, 23 Mar 2021 10:32:23 +0800 Subject: [PATCH] block: shutdown blktrace in case of task exiting blktrace may allocate lots of memory, if the process is terminated by user or OOM, we need to provide one chance to remove the trace buffer, otherwise memory leak may be caused. Also new blktrace instance can't be started too. Fix the issue by shutdown blktrace in bdev_close() if blktrace was setup on this FD. Signed-off-by: Ming Lei --- block/ioctl.c| 2 ++ fs/block_dev.c | 12 include/linux/blktrace_api.h | 11 +++ 3 files changed, 25 insertions(+) diff --git a/block/ioctl.c b/block/ioctl.c index ff241e663c01..7dad4a546db3 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -611,6 +611,8 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg) else mode &= ~FMODE_NDELAY; + blkdev_mark_blktrace(file, cmd); + switch (cmd) { /* These need separate implementations for the data structure */ case HDIO_GETGEO: diff --git a/fs/block_dev.c b/fs/block_dev.c index 92ed7d5df677..aaa7d7d1e5a4 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "internal.h" struct bdev_inode { @@ -1646,6 +1647,15 @@ EXPORT_SYMBOL(blkdev_put); static int blkdev_close(struct inode * inode, struct file * filp) { struct block_device *bdev = I_BDEV(bdev_file_inode(filp)); + + /* +* The task running blktrace is supposed to shutdown blktrace +* by ioctl. If they forget to shutdown or can't do it because +* of OOM or sort of situation, we shutdown for them. +*/ + if (blkdev_has_run_blktrace(filp)) + blk_trace_shutdown(bdev->bd_disk->queue); + blkdev_put(bdev, filp->f_mode); return 0; } @@ -1664,6 +1674,8 @@ static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg) else mode &= ~FMODE_NDELAY; + blkdev_mark_blktrace(file, cmd); + return blkdev_ioctl(bdev, mode, cmd, arg); } diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h index a083e15df608..754058c1965c 100644 --- a/include/linux/blktrace_api.h +++ b/include/linux/blktrace_api.h @@ -135,4 +135,15 @@ static inline unsigned int blk_rq_trace_nr_sectors(struct request *rq) return blk_rq_is_passthrough(rq) ? 0 : blk_rq_sectors(rq); } +static inline void blkdev_mark_blktrace(struct file *file, unsigned int cmd) +{ + if (cmd == BLKTRACESETUP) + file->private_data = (void *)-1; +} + +static inline bool blkdev_has_run_blktrace(struct file *file) +{ + return file->private_data == (void *)-1; +} + #endif -- 2.29.2 -- Ming
[PATCH v3 00/30] staging: rtl8723bs: remove RT_TRACE logs in core/*
This patchset removes all RT_TRACE usages in core/ files. This is the first of a series aimed at removing RT_TRACE macro. The whole private tracing system is not tied to a configuration symbol and the default behaviour is _trace nothing_. It's verbose and relies on a private log level tracing doomed to be removed. --- Changes in v3: - written better changelog in single patches Changes in v2: - isolate checkpatch fixes in separate patches - removed two if conditions in core/rtw_wlan_util.c Fabio Aiuto (30): staging: rtl8723bs: remove RT_TRACE logs in core/rtw_xmit.c staging: rtl8723bs: fix condition in if statement in core/rtw_xmit.c staging: rtl8723bs: remove RT_TRACE logs in core/rtw_security.c staging: rtl8723bs: fix line exceed warning in core/rtw_security.c staging: rtl8723bs: fix spaces around operator issues in core/rtw_security.c staging: rtl8723bs: remove all RT_TRACE logs in core/rtw_eeprom.c staging: rtl8723bs: fix error prone if conditions in core/rtw_eeprom.c staging: rtl8723bs: remove all RT_TRACE logs in core/rtw_pwrctrl.c staging: rtl8723bs: fix logical continuation issue in core/rtw_pwrctrl.c staging: rtl8723bs: remove unnecessary parentheses in if-condition in core/rtw_pwrctrl.c staging: rtl8723bs: remove RT_TRACE logs in core/rtw_cmd.c staging: rtl8723bs: fix null check conditions in core/rtw_cmd.c staging: rtl8723bs: remove unnecessary parentheses in if condition in core/rtw_cmd.c staging: rtl8723bs: remove commented RT_TRACE calls in core/rtw_mlme.c staging: rtl8723bs: remove RT_TRACE logs in core/rtw_mlme.c staging: rtl8723bs: tidy up some error handling in core/rtw_mlme.c staging: rtl8723bs: remove RT_TRACE logs in core/rtw_mlme_ext.c staging: rtl8723bs: remove commented RT_TRACE calls in core/rtw_recv.c staging: rtl8723bs: remove RT_TRACE logs in core/rtw_recv.c staging: rtl8723bs: added spaces around operator in core/rtw_recv.c staging: rtl8723bs: split long line in core/rtw_recv.c staging: rtl8723bs: remove unnecessary parentheses in core/rtw_recv.c staging: rtl8723bs: fix comparison in if condition in core/rtw_recv.c staging: rtl8723bs: remove commented RT_TRACE call in core/rtw_ioctl_set.c staging: rtl8723bs: remove RT_TRACE logs in core/rtw_ioctl_set.c staging: rtl8723bs: place constant on the right side of the test in core/rtw_ioctl_set.c staging: rtl8723bs: remove all RT_TRACE logs in core/rtw_wlan_util.c staging: rtl8723bs: remove RT_TRACE logs in core/rtw_sta_mgt.c staging: rtl8723bs: remove RT_TRACE logs in core/rtw_ieee80211.c staging: rtl8723bs: add spaces around operators in core/rtw_ieee80211.c drivers/staging/rtl8723bs/core/rtw_cmd.c | 53 +-- drivers/staging/rtl8723bs/core/rtw_eeprom.c | 56 +++ .../staging/rtl8723bs/core/rtw_ieee80211.c| 90 ++- .../staging/rtl8723bs/core/rtw_ioctl_set.c| 79 +- drivers/staging/rtl8723bs/core/rtw_mlme.c | 124 +++ drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 39 + drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 56 +-- drivers/staging/rtl8723bs/core/rtw_recv.c | 147 +- drivers/staging/rtl8723bs/core/rtw_security.c | 41 + drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 25 --- .../staging/rtl8723bs/core/rtw_wlan_util.c| 24 +-- drivers/staging/rtl8723bs/core/rtw_xmit.c | 82 +- 12 files changed, 101 insertions(+), 715 deletions(-) -- 2.20.1
[PATCH v3 02/30] staging: rtl8723bs: fix condition in if statement in core/rtw_xmit.c
fix post-commit hook checkpatch issue: CHECK: Using comparison to true is error prone 71: FILE: drivers/staging/rtl8723bs/core/rtw_xmit.c:565: + ((padapter->securitypriv.sw_encrypt == true) || (psecuritypriv->hw_decrypted == false))) Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index beee87db85a5..957d7e3a4d4a 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -562,7 +562,7 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p memcpy(pattrib->dot118021x_UncstKey.skey, psta->dot118021x_UncstKey.skey, 16); if (pattrib->encrypt && - ((padapter->securitypriv.sw_encrypt == true) || (psecuritypriv->hw_decrypted == false))) + ((padapter->securitypriv.sw_encrypt) || (!psecuritypriv->hw_decrypted))) pattrib->bswenc = true; else pattrib->bswenc = false; -- 2.20.1
[PATCH v3 03/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_security.c
Remove all of the RT_TRACE logs in the core/rtw_security.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_security.c | 40 +-- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 8a447e149438..689419a76d94 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -236,16 +236,6 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) /* calculate icv and compare the icv */ *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4)); - if (crc[3] != payload[length-1] || crc[2] != payload[length-2] || crc[1] != payload[length-3] || crc[0] != payload[length-4]) { - RT_TRACE(_module_rtl871x_security_c_, -_drv_err_, -("%s:icv error crc[3](%x)!=payload[length-1](%x) || crc[2](%x)!=payload[length-2](%x) || crc[1](%x)!=payload[length-3](%x) || crc[0](%x)!=payload[length-4](%x)\n", - __func__, - crc[3], payload[length - 1], - crc[2], payload[length - 2], - crc[1], payload[length - 3], - crc[0], payload[length - 4])); - } } } @@ -609,8 +599,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) if (pattrib->encrypt == _TKIP_) { { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); - if (IS_MCAST(pattrib->ra)) prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; else @@ -631,7 +619,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; - RT_TRACE(_module_rtl871x_security_c_, _drv_info_, ("pattrib->iv_len =%x, pattrib->icv_len =%x\n", pattrib->iv_len, pattrib->icv_len)); *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ arcfour_init(&mycontext, rc4key, 16); @@ -739,18 +726,9 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4)); - if (crc[3] != payload[length-1] || crc[2] != payload[length-2] || crc[1] != payload[length-3] || crc[0] != payload[length-4]) { - RT_TRACE(_module_rtl871x_security_c_, -_drv_err_, -("rtw_wep_decrypt:icv error crc[3](%x)!=payload[length-1](%x) || crc[2](%x)!=payload[length-2](%x) || crc[1](%x)!=payload[length-3](%x) || crc[0](%x)!=payload[length-4](%x)\n", - crc[3], payload[length - 1], - crc[2], payload[length - 2], - crc[1], payload[length - 3], - crc[0], payload[length - 4])); + if (crc[3] != payload[length-1] || crc[2] != payload[length-2] || crc[1] != payload[length-3] || crc[0] != payload[length-4]) res = _FAIL; - } } else { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo == NULL!!!\n", __func__)); res = _FAIL; } } @@ -1380,8 +1358,6 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) /* 4 start to encrypt each fragment */ if (pattrib->encrypt == _AES_) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); - if (IS_MCAST(pattrib->ra)) prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; else @@ -1611,13 +1587,6 @@ static signed int aes_decipher(u8 *key, uint hdrlen, /* compare the mic */ for (i = 0; i < 8; i++) { if (pframe[hdrlen+8+plen-8+i] != messa
[PATCH v3 01/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_xmit.c
Remove all of the RT_TRACE logs in the core/rtw_xmit.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 82 ++- 1 file changed, 7 insertions(+), 75 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 3fc4ea02bf15..beee87db85a5 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -69,7 +69,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) if (!pxmitpriv->pallocated_frame_buf) { pxmitpriv->pxmit_frame_buf = NULL; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_frame fail!\n")); res = _FAIL; goto exit; } @@ -105,7 +104,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); if (!pxmitpriv->pallocated_xmitbuf) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_buf fail!\n")); res = _FAIL; goto exit; } @@ -155,7 +153,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) if (!pxmitpriv->xframe_ext_alloc_addr) { pxmitpriv->xframe_ext = NULL; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xframe_ext fail!\n")); res = _FAIL; goto exit; } @@ -188,7 +185,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->pallocated_xmit_extbuf = vzalloc(NR_XMIT_EXTBUFF * sizeof(struct xmit_buf) + 4); if (!pxmitpriv->pallocated_xmit_extbuf) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); res = _FAIL; goto exit; } @@ -481,12 +477,9 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p pattrib->mac_id = psta->mac_id; if (psta->ieee8021x_blocked == true) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\n psta->ieee8021x_blocked == true\n")); - pattrib->encrypt = 0; if ((pattrib->ether_type != 0x888e) && (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false)) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\npsta->ieee8021x_blocked == true, pattrib->ether_type(%.4x) != 0x888e\n", pattrib->ether_type)); #ifdef DBG_TX_DROP_FRAME DBG_871X("DBG_TX_DROP_FRAME %s psta->ieee8021x_blocked == true, pattrib->ether_type(%04x) != 0x888e\n", __func__, pattrib->ether_type); #endif @@ -568,20 +561,11 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p if (pattrib->encrypt > 0) memcpy(pattrib->dot118021x_UncstKey.skey, psta->dot118021x_UncstKey.skey, 16); - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, - ("update_attrib: encrypt =%d securitypriv.sw_encrypt =%d\n", - pattrib->encrypt, padapter->securitypriv.sw_encrypt)); - if (pattrib->encrypt && - ((padapter->securitypriv.sw_encrypt == true) || (psecuritypriv->hw_decrypted == false))) { + ((padapter->securitypriv.sw_encrypt == true) || (psecuritypriv->hw_decrypted == false))) pattrib->bswenc = true; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, - ("update_attrib: encrypt =%d securitypriv.hw_decrypted =%d bswenc =true\n", - pattrib->encrypt, padapter->securitypriv.sw_encrypt)); - } else { + else pattrib->bswenc = false; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("update_attrib: bswenc =false\n")); - } exit: @@ -685,7 +669,6 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p ((tmp[21] == 67) && (tmp[23] == 68))) { /* 68 : UDP BOOTP client */ /* 67 : UDP BOOTP server */ - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("==update_attrib: get DHCP Packet\n")); pattrib->dhcp_pkt = 1; } } @@ -720,7 +703,6 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p
[PATCH v3 04/30] staging: rtl8723bs: fix line exceed warning in core/rtw_security.c
fix the following post-commit hook checkpatch issue: WARNING: line length of 149 exceeds 100 columns 61: FILE: drivers/staging/rtl8723bs/core/rtw_security.c:729: + if (crc[3] != payload[length-1] || crc[2] != payload[length-2] || crc[1] != payload[length-3] || crc[0] != payload[length-4]) Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_security.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 689419a76d94..663a8ea199ee 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -726,7 +726,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4)); - if (crc[3] != payload[length-1] || crc[2] != payload[length-2] || crc[1] != payload[length-3] || crc[0] != payload[length-4]) + if (crc[3] != payload[length-1] || crc[2] != payload[length-2] || + crc[1] != payload[length-3] || crc[0] != payload[length-4]) res = _FAIL; } else { res = _FAIL; -- 2.20.1
[PATCH v3 05/30] staging: rtl8723bs: fix spaces around operator issues in core/rtw_security.c
fix the following post commit hook checkpatch issues: CHECK: spaces preferred around that '-' (ctx:VxV) 25: FILE: drivers/staging/rtl8723bs/core/rtw_security.c:729: + if (crc[3] != payload[length-1] || crc[2] != payload[length-2] || ^ CHECK: spaces preferred around that '-' (ctx:VxV) 25: FILE: drivers/staging/rtl8723bs/core/rtw_security.c:729: + if (crc[3] != payload[length-1] || crc[2] != payload[length-2] || ^ CHECK: spaces preferred around that '-' (ctx:VxV) 26: FILE: drivers/staging/rtl8723bs/core/rtw_security.c:730: + crc[1] != payload[length-3] || crc[0] != payload[length-4]) ^ CHECK: spaces preferred around that '-' (ctx:VxV) 26: FILE: drivers/staging/rtl8723bs/core/rtw_security.c:730: + crc[1] != payload[length-3] || crc[0] != payload[length-4]) ^ Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_security.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 663a8ea199ee..6c74c0444abc 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -726,8 +726,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4)); - if (crc[3] != payload[length-1] || crc[2] != payload[length-2] || - crc[1] != payload[length-3] || crc[0] != payload[length-4]) + if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] || + crc[1] != payload[length - 3] || crc[0] != payload[length - 4]) res = _FAIL; } else { res = _FAIL; -- 2.20.1
[PATCH v3 06/30] staging: rtl8723bs: remove all RT_TRACE logs in core/rtw_eeprom.c
Remove all of the RT_TRACE logs in the core/rtw_eeprom.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_eeprom.c | 56 - 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_eeprom.c b/drivers/staging/rtl8723bs/core/rtw_eeprom.c index 3cbd65dee741..32d5e5b23337 100644 --- a/drivers/staging/rtl8723bs/core/rtw_eeprom.c +++ b/drivers/staging/rtl8723bs/core/rtw_eeprom.c @@ -35,10 +35,9 @@ void shift_out_bits(_adapter *padapter, u16 data, u16 count) u16 x, mask; _func_enter_; - if (padapter->bSurpriseRemoved == true) { - RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + if (padapter->bSurpriseRemoved == true) goto out; - } + mask = 0x01 << (count - 1); x = rtw_read8(padapter, EE_9346CR); @@ -48,20 +47,18 @@ _func_enter_; x &= ~_EEDI; if (data & mask) x |= _EEDI; - if (padapter->bSurpriseRemoved == true) { - RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); - goto out; - } + if (padapter->bSurpriseRemoved == true) + goto out; + rtw_write8(padapter, EE_9346CR, (u8)x); udelay(CLOCK_RATE); up_clk(padapter, &x); down_clk(padapter, &x); mask = mask >> 1; } while (mask); - if (padapter->bSurpriseRemoved == true) { - RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + if (padapter->bSurpriseRemoved == true) goto out; - } + x &= ~_EEDI; rtw_write8(padapter, EE_9346CR, (u8)x); out: @@ -72,10 +69,9 @@ u16 shift_in_bits(_adapter *padapter) { u16 x, d = 0, i; _func_enter_; - if (padapter->bSurpriseRemoved == true) { - RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + if (padapter->bSurpriseRemoved == true) goto out; - } + x = rtw_read8(padapter, EE_9346CR); x &= ~(_EEDO | _EEDI); @@ -84,10 +80,9 @@ _func_enter_; for (i = 0; i < 16; i++) { d = d << 1; up_clk(padapter, &x); - if (padapter->bSurpriseRemoved == true) { - RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + if (padapter->bSurpriseRemoved == true) goto out; - } + x = rtw_read8(padapter, EE_9346CR); x &= ~(_EEDI); @@ -122,26 +117,22 @@ void eeprom_clean(_adapter *padapter) { u16 x; _func_enter_; - if (padapter->bSurpriseRemoved == true) { - RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + if (padapter->bSurpriseRemoved == true) goto out; - } + x = rtw_read8(padapter, EE_9346CR); - if (padapter->bSurpriseRemoved == true) { - RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + if (padapter->bSurpriseRemoved == true) goto out; - } + x &= ~(_EECS | _EEDI); rtw_write8(padapter, EE_9346CR, (u8)x); - if (padapter->bSurpriseRemoved == true) { - RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + if (padapter->bSurpriseRemoved == true) goto out; - } + up_clk(padapter, &x); - if (padapter->bSurpriseRemoved == true) { - RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + if (padapter->bSurpriseRemoved == true) goto out; - } + down_clk(padapter, &x); out: _func_exit_; @@ -155,17 +146,14 @@ u16 eeprom_read16(_adapter *padapter, u16 reg) /*ReadEEprom*/ _func_enter_; - if (padapter->bSurpriseRemoved == true) { - RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + if (padapter->bSurpriseRemoved == true) goto out; - } + /* select EEPROM, reset bits, set _EECS*/ x = rtw_read8(padapter, EE_9346CR); - if (padapter->bSurpriseRemoved == true) { - RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + if (padapter->bSurpriseRemoved == true) goto out; - }
[PATCH v3 07/30] staging: rtl8723bs: fix error prone if conditions in core/rtw_eeprom.c
fix the following post-commit hook checkpatch issues: CHECK: Using comparison to true is error prone 21: FILE: drivers/staging/rtl8723bs/core/rtw_eeprom.c:38: + if (padapter->bSurpriseRemoved == true) CHECK: Using comparison to true is error prone 36: FILE: drivers/staging/rtl8723bs/core/rtw_eeprom.c:50: + if (padapter->bSurpriseRemoved == true) CHECK: Using comparison to true is error prone 47: FILE: drivers/staging/rtl8723bs/core/rtw_eeprom.c:59: + if (padapter->bSurpriseRemoved == true) CHECK: Using comparison to true is error prone 60: FILE: drivers/staging/rtl8723bs/core/rtw_eeprom.c:72: + if (padapter->bSurpriseRemoved == true) CHECK: Using comparison to true is error prone 73: FILE: drivers/staging/rtl8723bs/core/rtw_eeprom.c:83: + if (padapter->bSurpriseRemoved == true) CHECK: Using comparison to true is error prone 86: FILE: drivers/staging/rtl8723bs/core/rtw_eeprom.c:120: + if (padapter->bSurpriseRemoved == true) CHECK: Using comparison to true is error prone 93: FILE: drivers/staging/rtl8723bs/core/rtw_eeprom.c:124: + if (padapter->bSurpriseRemoved == true) CHECK: Using comparison to true is error prone 101: FILE: drivers/staging/rtl8723bs/core/rtw_eeprom.c:129: + if (padapter->bSurpriseRemoved == true) CHECK: Using comparison to true is error prone 108: FILE: drivers/staging/rtl8723bs/core/rtw_eeprom.c:133: + if (padapter->bSurpriseRemoved == true) CHECK: Using comparison to true is error prone 121: FILE: drivers/staging/rtl8723bs/core/rtw_eeprom.c:149: + if (padapter->bSurpriseRemoved == true) CHECK: Using comparison to true is error prone 130: FILE: drivers/staging/rtl8723bs/core/rtw_eeprom.c:155: + if (padapter->bSurpriseRemoved == true) Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_eeprom.c | 22 ++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_eeprom.c b/drivers/staging/rtl8723bs/core/rtw_eeprom.c index 32d5e5b23337..be0eda1604d0 100644 --- a/drivers/staging/rtl8723bs/core/rtw_eeprom.c +++ b/drivers/staging/rtl8723bs/core/rtw_eeprom.c @@ -35,7 +35,7 @@ void shift_out_bits(_adapter *padapter, u16 data, u16 count) u16 x, mask; _func_enter_; - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; mask = 0x01 << (count - 1); @@ -47,7 +47,7 @@ _func_enter_; x &= ~_EEDI; if (data & mask) x |= _EEDI; - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; rtw_write8(padapter, EE_9346CR, (u8)x); @@ -56,7 +56,7 @@ _func_enter_; down_clk(padapter, &x); mask = mask >> 1; } while (mask); - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; x &= ~_EEDI; @@ -69,7 +69,7 @@ u16 shift_in_bits(_adapter *padapter) { u16 x, d = 0, i; _func_enter_; - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; x = rtw_read8(padapter, EE_9346CR); @@ -80,7 +80,7 @@ _func_enter_; for (i = 0; i < 16; i++) { d = d << 1; up_clk(padapter, &x); - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; x = rtw_read8(padapter, EE_9346CR); @@ -117,20 +117,20 @@ void eeprom_clean(_adapter *padapter) { u16 x; _func_enter_; - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; x = rtw_read8(padapter, EE_9346CR); - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; x &= ~(_EECS | _EEDI); rtw_write8(padapter, EE_9346CR, (u8)x); - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; up_clk(padapter, &x); - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; down_clk(padapter, &x); @@ -146,13 +146,13 @@ u16 eeprom_read16(_adapter *padapter, u16 reg) /*ReadEEprom*/ _func_enter_; - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; /* select EEPROM, reset bits, set _EECS*/ x = rtw_read8(padapter, EE_9346CR); - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto out; x &= ~(_EEDI | _EEDO | _EESK | _EEM0); -- 2.20.1
[PATCH v3 08/30] staging: rtl8723bs: remove all RT_TRACE logs in core/rtw_pwrctrl.c
Remove all of the RT_TRACE logs in the core/rtw_pwrctrl.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 54 ++-- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index 8bf80e6f4a11..cc1b0d1a5a7b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -267,40 +267,26 @@ void rtw_set_rpwm(struct adapter *padapter, u8 pslv) DBG_871X("%s: RPWM timeout, force to set RPWM(0x%02X) again!\n", __func__, pslv); } else { if ((pwrpriv->rpwm == pslv) - || ((pwrpriv->rpwm >= PS_STATE_S2) && (pslv >= PS_STATE_S2))) { - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, - ("%s: Already set rpwm[0x%02X], new = 0x%02X!\n", __func__, pwrpriv->rpwm, pslv)); + || ((pwrpriv->rpwm >= PS_STATE_S2) && (pslv >= PS_STATE_S2))) return; - } + } if ((padapter->bSurpriseRemoved) || !(padapter->hw_init_completed)) { - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, -("%s: SurpriseRemoved(%d) hw_init_completed(%d)\n", - __func__, padapter->bSurpriseRemoved, padapter->hw_init_completed)); - pwrpriv->cpwm = PS_STATE_S4; return; } if (padapter->bDriverStopped) { - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, -("%s: change power state(0x%02X) when DriverStopped\n", __func__, pslv)); - - if (pslv < PS_STATE_S2) { - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, -("%s: Reject to enter PS_STATE(0x%02X) lower than S2 when DriverStopped!!\n", __func__, pslv)); + if (pslv < PS_STATE_S2) return; - } } rpwm = pslv | pwrpriv->tog; /* only when from PS_STATE S0/S1 to S2 and higher needs ACK */ if ((pwrpriv->cpwm < PS_STATE_S2) && (pslv >= PS_STATE_S2)) rpwm |= PS_ACK; - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, -("rtw_set_rpwm: rpwm = 0x%02x cpwm = 0x%02x\n", rpwm, pwrpriv->cpwm)); pwrpriv->rpwm = pslv; @@ -382,14 +368,8 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a { struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, -("%s: PowerMode =%d Smart_PS =%d\n", - __func__, ps_mode, smart_ps)); - - if (ps_mode > PM_Card_Disable) { - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, ("ps_mode:%d error\n", ps_mode)); + if (ps_mode > PM_Card_Disable) return; - } if (pwrpriv->pwr_mode == ps_mode) if (PS_MODE_ACTIVE == ps_mode) @@ -701,8 +681,6 @@ void cpwm_int_hdl(struct adapter *padapter, struct reportpwrstate_parm *preportp exit: mutex_unlock(&pwrpriv->lock); - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, -("cpwm_int_hdl: cpwm = 0x%02x\n", pwrpriv->cpwm)); } static void cpwm_event_callback(struct work_struct *work) @@ -817,10 +795,6 @@ s32 rtw_register_task_alive(struct adapter *padapter, u32 task) register_task_alive(pwrctrl, task); if (pwrctrl->bFwCurrentInPSMode) { - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, -("%s: task = 0x%x cpwm = 0x%02x alives = 0x%08x\n", - __func__, task, pwrctrl->cpwm, pwrctrl->alives)); - if (pwrctrl->cpwm < pslv) { if (pwrctrl->cpwm < PS_STATE_S2) res = _FAIL; @@ -869,10 +843,6 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task) unregister_task_alive(pwrctrl, task); if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) && pwrctrl->bFwCurrentInPSMode) { - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, -("%s: cpwm = 0x%02x alives = 0x%08x\n", - __func__, pwrctrl->cpwm, pwrctrl->alives)); - if (pwrctrl->cpwm > pslv) if ((pslv >= PS_STATE_S2) || (pwrctrl->alives == 0)) rtw_set_rpwm(padapte
[PATCH v3 09/30] staging: rtl8723bs: fix logical continuation issue in core/rtw_pwrctrl.c
fix following post-commit hook checkpatch issue: CHECK: Logical continuations should be on the previous line 22: FILE: drivers/staging/rtl8723bs/core/rtw_pwrctrl.c:270: if ((pwrpriv->rpwm == pslv) + || ((pwrpriv->rpwm >= PS_STATE_S2) && (pslv >= PS_STATE_S2))) Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index cc1b0d1a5a7b..fa06144337ce 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -266,8 +266,8 @@ void rtw_set_rpwm(struct adapter *padapter, u8 pslv) if (pwrpriv->brpwmtimeout) { DBG_871X("%s: RPWM timeout, force to set RPWM(0x%02X) again!\n", __func__, pslv); } else { - if ((pwrpriv->rpwm == pslv) - || ((pwrpriv->rpwm >= PS_STATE_S2) && (pslv >= PS_STATE_S2))) + if ((pwrpriv->rpwm == pslv) || + ((pwrpriv->rpwm >= PS_STATE_S2) && (pslv >= PS_STATE_S2))) return; } -- 2.20.1
[PATCH v3 10/30] staging: rtl8723bs: remove unnecessary parentheses in if-condition in core/rtw_pwrctrl.c
fix following post-commit hook checkpatch issues: CHECK: Unnecessary parentheses around 'pwrpriv->rpwm == pslv' 26: FILE: drivers/staging/rtl8723bs/core/rtw_pwrctrl.c:269: + if ((pwrpriv->rpwm == pslv) || + ((pwrpriv->rpwm >= PS_STATE_S2) && (pslv >= PS_STATE_S2))) CHECK: Unnecessary parentheses around 'pwrpriv->rpwm >= PS_STATE_S2' 26: FILE: drivers/staging/rtl8723bs/core/rtw_pwrctrl.c:269: + if ((pwrpriv->rpwm == pslv) || + ((pwrpriv->rpwm >= PS_STATE_S2) && (pslv >= PS_STATE_S2))) CHECK: Unnecessary parentheses around 'pslv >= PS_STATE_S2' 26: FILE: drivers/staging/rtl8723bs/core/rtw_pwrctrl.c:269: + if ((pwrpriv->rpwm == pslv) || + ((pwrpriv->rpwm >= PS_STATE_S2) && (pslv >= PS_STATE_S2))) Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index fa06144337ce..09bf25940e92 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -266,8 +266,8 @@ void rtw_set_rpwm(struct adapter *padapter, u8 pslv) if (pwrpriv->brpwmtimeout) { DBG_871X("%s: RPWM timeout, force to set RPWM(0x%02X) again!\n", __func__, pslv); } else { - if ((pwrpriv->rpwm == pslv) || - ((pwrpriv->rpwm >= PS_STATE_S2) && (pslv >= PS_STATE_S2))) + if (pwrpriv->rpwm == pslv || + (pwrpriv->rpwm >= PS_STATE_S2 && pslv >= PS_STATE_S2)) return; } -- 2.20.1
[PATCH v3 11/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_cmd.c
Remove all of the RT_TRACE logs in the core/rtw_cmd.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. removed a variable, left unused after RT_TRACE removal Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_cmd.c | 53 +++- 1 file changed, 6 insertions(+), 47 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 2aaf25b48f96..2086df056c44 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -221,8 +221,6 @@ int rtw_init_evt_priv(struct evt_priv *pevtpriv) void _rtw_free_evt_priv(struct evt_priv *pevtpriv) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+_rtw_free_evt_priv\n")); - _cancel_workitem_sync(&pevtpriv->c2h_wk); while (pevtpriv->c2h_wk_alive) msleep(10); @@ -233,8 +231,6 @@ void _rtw_free_evt_priv(struct evt_priv *pevtpriv) kfree(c2h); } kfree(pevtpriv->c2h_queue); - - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("-_rtw_free_evt_priv\n")); } void _rtw_free_cmd_priv(struct cmd_priv *pcmdpriv) @@ -299,13 +295,11 @@ structcmd_obj *_rtw_dequeue_cmd(struct __queue *queue) void rtw_free_evt_priv(struct evt_priv *pevtpriv) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_free_evt_priv\n")); _rtw_free_evt_priv(pevtpriv); } void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_free_cmd_priv\n")); _rtw_free_cmd_priv(pcmdpriv); } @@ -415,8 +409,6 @@ int rtw_cmd_thread(void *context) atomic_set(&(pcmdpriv->cmdthd_running), true); complete(&pcmdpriv->terminate_cmdthread_comp); - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread \n")); - while (1) { if (wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp)) { DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp) return != 0, break\n", FUNC_ADPT_ARG(padapter)); @@ -439,11 +431,8 @@ int rtw_cmd_thread(void *context) continue; } - if (rtw_register_cmd_alive(padapter) != _SUCCESS) { - RT_TRACE(_module_hal_xmit_c_, _drv_notice_, -("%s: wait to leave LPS_LCLK\n", __func__)); + if (rtw_register_cmd_alive(padapter) != _SUCCESS) continue; - } _next: if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) { @@ -512,14 +501,12 @@ int rtw_cmd_thread(void *context) if (pcmd->cmdcode < ARRAY_SIZE(rtw_cmd_callback)) { pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback; if (pcmd_callback == NULL) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("mlme_cmd_hdl(): pcmd_callback = 0x%p, cmdcode = 0x%x\n", pcmd_callback, pcmd->cmdcode)); rtw_free_cmd_obj(pcmd); } else { /* todo: !!! fill rsp_buf to pcmd->rsp if (pcmd->rsp!= NULL) */ pcmd_callback(pcmd->padapter, pcmd);/* need consider that free cmd_obj in rtw_cmd_callback */ } } else { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("%s: cmdcode = 0x%x callback not defined!\n", __func__, pcmd->cmdcode)); rtw_free_cmd_obj(pcmd); } @@ -583,8 +570,6 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, rtw_free_network_queue(padapter, false); - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("%s: flush network queue\n", __func__)); - init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey)); /* psurveyPara->bsslimit = 48; */ @@ -672,15 +657,9 @@ u8 rtw_createbss_cmd(struct adapter *padapter) { struct cmd_obj *pcmd; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct mlme_priv*pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex*pdev_network = &padapter->registrypriv.dev_network; u8 res = _SUCCESS; - if (pmlmepriv->assoc_ssid.SsidLength == 0) - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for Any SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); - else - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss
[PATCH v3 12/30] staging: rtl8723bs: fix null check conditions in core/rtw_cmd.c
fix post-commit hook checkpatch issues: CHECK: Comparison to NULL could be written "!psta" 178: FILE: drivers/staging/rtl8723bs/core/rtw_cmd.c:2012: + if (psta == NULL) CHECK: Comparison to NULL could be written "!psta" 198: FILE: drivers/staging/rtl8723bs/core/rtw_cmd.c:2066: + if (psta == NULL) CHECK: Comparison to NULL could be written "!psta" 211: FILE: drivers/staging/rtl8723bs/core/rtw_cmd.c:2081: + if (psta == NULL) Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_cmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 2086df056c44..840b9da9f2d9 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -2009,7 +2009,7 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) psta = rtw_get_stainfo(&padapter->stapriv, pnetwork->MacAddress); if (!psta) { psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->MacAddress); - if (psta == NULL) + if (!psta) goto createbss_cmd_fail; } @@ -2063,7 +2063,7 @@ void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pc struct set_stakey_rsp *psetstakey_rsp = (struct set_stakey_rsp *) (pcmd->rsp); struct sta_info *psta = rtw_get_stainfo(pstapriv, psetstakey_rsp->addr); - if (psta == NULL) + if (!psta) goto exit; exit: @@ -2078,7 +2078,7 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj * struct set_assocsta_rsp *passocsta_rsp = (struct set_assocsta_rsp *) (pcmd->rsp); struct sta_info *psta = rtw_get_stainfo(pstapriv, passocsta_parm->addr); - if (psta == NULL) + if (!psta) goto exit; psta->aid = passocsta_rsp->cam_id; -- 2.20.1
[PATCH v3 13/30] staging: rtl8723bs: remove unnecessary parentheses in if condition in core/rtw_cmd.c
fix post-commit hook checkpatch issue: WARNING: Unnecessary parentheses 166: FILE: drivers/staging/rtl8723bs/core/rtw_cmd.c:2000: + if ((pcmd->res != H2C_SUCCESS)) Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 840b9da9f2d9..77c583c60343 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -1997,7 +1997,7 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) if (pcmd->parmbuf == NULL) goto exit; - if ((pcmd->res != H2C_SUCCESS)) + if (pcmd->res != H2C_SUCCESS) _set_timer(&pmlmepriv->assoc_timer, 1); del_timer_sync(&pmlmepriv->assoc_timer); -- 2.20.1
[PATCH v3 14/30] staging: rtl8723bs: remove commented RT_TRACE calls in core/rtw_mlme.c
Remove commented RT_TRACE calls in core/rtw_mlme.c Remove all of the RT_TRACE logs in the core/rtw_mlme.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 29d4b7493784..4289bf40aa73 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -356,7 +356,6 @@ static struct wlan_network *rtw_dequeue_network(struct __queue *queue) void rtw_free_network_nolock(struct adapter *padapter, struct wlan_network *pnetwork); void rtw_free_network_nolock(struct adapter *padapter, struct wlan_network *pnetwork) { - /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_network ==> ssid = %s\n\n" , pnetwork->network.Ssid.Ssid)); */ _rtw_free_network_nolock(&(padapter->mlmepriv), pnetwork); rtw_cfg80211_unlink_bss(padapter, pnetwork); } @@ -393,8 +392,6 @@ int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork) inline int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b) { - /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("(%s,%d)(%s,%d)\n", */ - /* a->Ssid.Ssid, a->Ssid.SsidLength, b->Ssid.Ssid, b->Ssid.SsidLength)); */ return (a->Ssid.SsidLength == b->Ssid.SsidLength) && !memcmp(a->Ssid.Ssid, b->Ssid.Ssid, a->Ssid.SsidLength); } @@ -551,8 +548,6 @@ static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex &(pmlmepriv->cur_network.network)); if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && (is_same_network(&(pmlmepriv->cur_network.network), pnetwork, 0))) { - /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,"Same Network\n"); */ - /* if (pmlmepriv->cur_network.network.IELength<= pnetwork->IELength) */ { update_network(&(pmlmepriv->cur_network.network), pnetwork, adapter, true); @@ -778,7 +773,6 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) /* update IBSS_network 's timestamp */ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) { - /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,"rtw_survey_event_callback : WIFI_ADHOC_MASTER_STATE\n\n"); */ if (!memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) { struct wlan_network *ibss_wlan = NULL; -- 2.20.1
[PATCH v3 15/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_mlme.c
Remove all of the RT_TRACE logs in the core/rtw_mlme.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 105 -- 1 file changed, 15 insertions(+), 90 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 4289bf40aa73..e8a39519fed8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -155,8 +155,6 @@ struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) list_del_init(&pnetwork->list); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, -("rtw_alloc_network: ptr =%p\n", plist)); pnetwork->network_type = 0; pnetwork->fixed = false; pnetwork->last_scanned = jiffies; @@ -298,11 +296,11 @@ signed int rtw_if_up(struct adapter *padapter) signed int res; if (padapter->bDriverStopped || padapter->bSurpriseRemoved || - (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_if_up:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved)); + (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false)) res = false; - } else + else res = true; + return res; } @@ -339,7 +337,6 @@ u8 *rtw_get_beacon_interval_from_ie(u8 *ie) void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_mlme_priv\n")); _rtw_free_mlme_priv(pmlmepriv); } @@ -607,10 +604,9 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t /* If there are no more slots, expire the oldest */ /* list_del_init(&oldest->list); */ pnetwork = oldest; - if (!pnetwork) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n")); + if (!pnetwork) goto exit; - } + memcpy(&(pnetwork->network), target, get_wlan_bssid_ex_sz(target)); /* variable initialize */ pnetwork->fixed = false; @@ -628,10 +624,8 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t pnetwork = rtw_alloc_network(pmlmepriv); /* will update scan_time */ - if (!pnetwork) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n")); + if (!pnetwork) goto exit; - } bssid_ex_sz = get_wlan_bssid_ex_sz(target); target->Length = bssid_ex_sz; @@ -750,7 +744,6 @@ int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwor /* TODO: Perry : For Power Management */ void rtw_atimdone_event_callback(struct adapter*adapter, u8 *pbuf) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive atimdone_event\n")); } void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) @@ -761,13 +754,9 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) pnetwork = (struct wlan_bssid_ex *)pbuf; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_survey_event_callback, ssid =%s\n", pnetwork->Ssid.Ssid)); - len = get_wlan_bssid_ex_sz(pnetwork); - if (len > (sizeof(struct wlan_bssid_ex))) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n rtw_survey_event_callback: return a wrong bss ***\n")); + if (len > (sizeof(struct wlan_bssid_ex))) return; - } spin_lock_bh(&pmlmepriv->lock); @@ -811,14 +800,9 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) pmlmepriv->wps_probe_req_ie = NULL; } - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_surveydone_event_callback: fw_state:%x\n\n", get_fwstate(pmlmepriv))); - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { del_timer_sync(&pmlmepriv->scan_to_timer); _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); - } else { - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("nic status =%x, survey done event comes too late!\n", get_fwstate(pmlmepriv))); } rtw_set_signal_stat_timer(&adapter
[PATCH v3 16/30] staging: rtl8723bs: tidy up some error handling in core/rtw_mlme.c
the RT_TRACE() output is not useful so we want to delete it. In this case there is no cleanup for rtw_cleanbss_cmd() required or even possible. I've deleted the RT_TRACE() output and added a goto unlock to show that we can't continue if rtw_createbss_cmd() fails. Suggested-by: David Carpenter Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 17 +++-- 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index e8a39519fed8..e6bced0269b1 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -815,6 +815,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) if (rtw_select_and_join_from_scanned_queue(pmlmepriv) == _SUCCESS) { _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); } else { + u8 ret = _SUCCESS; struct wlan_bssid_ex*pdev_network = &(adapter->registrypriv.dev_network); u8 *pibss = adapter->registrypriv.dev_network.MacAddress; @@ -828,10 +829,11 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; - if (rtw_createbss_cmd(adapter) != _SUCCESS) - ; - pmlmepriv->to_join = false; + + ret = rtw_createbss_cmd(adapter); + if (ret != _SUCCESS) + goto unlock; } } } else { @@ -877,7 +879,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) } /* DBG_871X("scan complete in %dms\n", jiffies_to_msecs(jiffies - pmlmepriv->scan_start_time)); */ - +unlock: spin_unlock_bh(&pmlmepriv->lock); rtw_os_xmit_schedule(adapter); @@ -1564,6 +1566,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) rtw_free_stainfo(adapter, psta); if (adapter->stapriv.asoc_sta_count == 1) {/* a sta + bc/mc_stainfo (not Ibss_stainfo) */ + u8 ret = _SUCCESS; /* rtw_indicate_disconnect(adapter);removed@20091105 */ spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); /* free old ibss network */ @@ -1591,12 +1594,14 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) _clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE); } - if (rtw_createbss_cmd(adapter) != _SUCCESS) - ; + ret = rtw_createbss_cmd(adapter); + if (ret != _SUCCESS) + goto unlock; } } +unlock: spin_unlock_bh(&pmlmepriv->lock); } -- 2.20.1
[PATCH v3 17/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_mlme_ext.c
Remove all of the RT_TRACE logs in the core/rtw_mlme_ext.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 39 +++ 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 8aadcf72a7ba..9855a77a5188 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -526,14 +526,8 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) struct dvobj_priv *psdpriv = padapter->dvobj; struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, -("+mgt_dispatcher: type(0x%x) subtype(0x%x)\n", - GetFrameType(pframe), GetFrameSubType(pframe))); - - if (GetFrameType(pframe) != WIFI_MGT_TYPE) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("mgt_dispatcher: type(0x%x) error!\n", GetFrameType(pframe))); + if (GetFrameType(pframe) != WIFI_MGT_TYPE) return; - } /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && @@ -545,10 +539,9 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) index = GetFrameSubType(pframe) >> 4; - if (index >= ARRAY_SIZE(mlme_sta_tbl)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Currently we do not support reserved sub-fr-type =%d\n", index)); + if (index >= ARRAY_SIZE(mlme_sta_tbl)) return; - } + ptable += index; if (psta) { @@ -2675,8 +2668,6 @@ static int _issue_probereq(struct adapter *padapter, int bssrate_len = 0; u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+issue_probereq\n")); - pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) goto exit; @@ -2743,8 +2734,6 @@ static int _issue_probereq(struct adapter *padapter, pattrib->last_txcmdsz = pattrib->pktlen; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("issuing probe_req, tx_len =%d\n", pattrib->last_txcmdsz)); - if (wait_ack) { ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); } else { @@ -4441,8 +4430,6 @@ void start_create_ibss(struct adapter *padapter) /* issue beacon */ if (send_beacon(padapter) == _FAIL) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("issuing beacon frame fail\n")); - report_join_res(padapter, -1); pmlmeinfo->state = WIFI_FW_NULL_STATE; } else { @@ -4622,8 +4609,6 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid memset(country, 0, 4); memcpy(country, p, 3); p += 3; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, - ("%s: 802.11d country =%s\n", __func__, country)); i = 0; while ((ie - p) >= 3) { @@ -4813,9 +4798,6 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid break; chplan_new[i].ScanType = SCAN_ACTIVE; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, -("%s: change channel %d scan type from passive to active\n", - __func__, channel)); } break; } @@ -6332,10 +6314,6 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) #ifdef CHECK_EVENT_SEQ /* checking event sequence... */ if (evt_seq != (atomic_read(&pevt_priv->event_seq) & 0x7f)) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, -("Event Seq Error! %d vs %d\n", (evt_seq & 0x7f), - (atomic_read(&pevt_priv->event_seq) & 0x7f))); - pevt_priv->event_seq = (evt_seq+1)&0x7f; goto _abort_event_; @@ -6343,21 +6321,14 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) #endif /* checking if event code is valid */ - if (evt_code >= MAX_C2HEVT) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nEvent Code(%d) mismatch!\n"
[PATCH v3 18/30] staging: rtl8723bs: remove commented RT_TRACE calls in core/rtw_recv.c
Remove commented RT_TRACE calls Remove all of the RT_TRACE logs in the core/rtw_recv.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_recv.c | 12 1 file changed, 12 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 608a59286505..189f686a1f29 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -588,13 +588,11 @@ static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *pre prtnframe = precv_frame; /* check is the EAPOL frame or not (Rekey) */ /* if (ether_type == eapol_type) { */ - /* RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("portctrl:ether_type == 0x888e\n")); */ /* check Rekey */ /* prtnframe =precv_frame; */ /* */ /* else { */ - /* RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:ether_type = 0x%04x\n", ether_type)); */ /* */ } } else @@ -1693,7 +1691,6 @@ static signed int validate_recv_frame(struct adapter *adapter, union recv_frame retval = validate_recv_data_frame(adapter, precv_frame); if (retval == _FAIL) { struct recv_priv *precvpriv = &adapter->recvpriv; - /* RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail\n")); */ precvpriv->rx_drop++; } else if (retval == _SUCCESS) { #ifdef DBG_RX_DUMP_EAP @@ -1889,7 +1886,6 @@ static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_n /* Drop out the packet which SeqNum is smaller than WinStart */ if (SN_LESS(seq_num, preorder_ctrl->indicate_seq)) { - /* RT_TRACE(COMP_RX_REORDER, DBG_LOUD, ("CheckRxTsIndicateSeq(): Packet Drop! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, NewSeqNum)); */ /* DbgPrint("CheckRxTsIndicateSeq(): Packet Drop! IndicateSeq: %d, NewSeq: %d\n", precvpriv->indicate_seq, seq_num); */ #ifdef DBG_RX_DROP_FRAME @@ -1914,7 +1910,6 @@ static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_n preorder_ctrl->indicate_seq, seq_num); #endif } else if (SN_LESS(wend, seq_num)) { - /* RT_TRACE(COMP_RX_REORDER, DBG_LOUD, ("CheckRxTsIndicateSeq(): Window Shift! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, NewSeqNum)); */ /* DbgPrint("CheckRxTsIndicateSeq(): Window Shift! IndicateSeq: %d, NewSeq: %d\n", precvpriv->indicate_seq, seq_num); */ /* boundary situation, when seq_num cross 0xFFF */ @@ -1959,7 +1954,6 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, un plist = get_next(plist); else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num)) /* Duplicate entry is found!! Do not insert current entry. */ - /* RT_TRACE(COMP_RX_REORDER, DBG_TRACE, ("InsertRxReorderList(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum)); */ /* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */ return false; else @@ -1980,8 +1974,6 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, un /* spin_unlock(&ppending_recvframe_queue->lock); */ /* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */ - - /* RT_TRACE(COMP_RX_REORDER, DBG_TRACE, ("InsertRxReorderList(): Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum)); */ return true; } @@ -2437,8 +2429,6 @@ s32 rtw_recv_entry(union recv_frame *precvframe) struct recv_priv *precvpriv; s32 ret = _SUCCESS; - /* RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("+rtw_recv_entry\n")); */ - padapter = precvframe->u.hdr.adapter; precvpriv = &padapter->recvpriv; @@ -2456,8 +2446,6 @@ s32 rtw_recv_entry(union recv_frame *precvframe) _recv_entry_drop: - /* RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("_recv_entry_drop\n")); */ - return ret; } -- 2.20.1
[PATCH v3 19/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_recv.c
Remove all of the RT_TRACE logs in the core/rtw_recv.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_recv.c | 134 +- 1 file changed, 6 insertions(+), 128 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 189f686a1f29..2d749341d47b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -325,10 +325,6 @@ static signed int recvframe_chkmic(struct adapter *adapter, union recv_frame *p stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]); if (prxattrib->encrypt == _TKIP_) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:prxattrib->encrypt == _TKIP_\n")); - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:da = 0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", - prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2], prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5])); - /* calculate mic code */ if (stainfo) { if (IS_MCAST(prxattrib->ra)) { @@ -337,28 +333,22 @@ static signed int recvframe_chkmic(struct adapter *adapter, union recv_frame *p /* rxdata_key_idx =(((iv[3])>>6)&0x3) ; */ mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n")); /* DBG_871X("\n recvframe_chkmic: bcmc key psecuritypriv->dot118021XGrpKeyid(%d), pmlmeinfo->key_index(%d) , recv key_id(%d)\n", */ /* psecuritypriv->dot118021XGrpKeyid, pmlmeinfo->key_index, rxdata_key_idx); */ if (psecuritypriv->binstallGrpkey == false) { res = _FAIL; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic:didn't install group key!!\n")); DBG_871X("\n recvframe_chkmic:didn't install group key!!\n"); goto exit; } } else { mickey = &stainfo->dot11tkiprxmickey.skey[0]; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic: unicast key\n")); } datalen = precvframe->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len-prxattrib->icv_len-8;/* icv_len included the mic code */ pframe = precvframe->u.hdr.rx_data; payload = pframe+prxattrib->hdrlen+prxattrib->iv_len; - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n prxattrib->iv_len =%d prxattrib->icv_len =%d\n", prxattrib->iv_len, prxattrib->icv_len)); - - rtw_seccalctkipmic(mickey, pframe, payload, datalen, &miccode[0], (unsigned char)prxattrib->priority); /* care the length of the data */ pframemic = payload+datalen; @@ -366,38 +356,12 @@ static signed int recvframe_chkmic(struct adapter *adapter, union recv_frame *p bmic_err = false; for (i = 0; i < 8; i++) { - if (miccode[i] != *(pframemic+i)) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic:miccode[%d](%02x) != *(pframemic+%d)(%02x) ", i, miccode[i], i, *(pframemic+i))); + if (miccode[i] != *(pframemic+i)) bmic_err = true; - } } if (bmic_err == true) { - - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n *(pframemic-8)-*(pframemic-1) = 0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", - *(pframemic-8), *(pframemic-7), *(pframemic-6), *(pframemic-5), *(pframemic-4), *(pframemic-3), *(pframemic-2), *(pframemic-1))); - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n *(pframemic-16)-*(pframemic-9) = 0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", - *(pframemic-16), *(pframemic-15), *(pframemic-14), *(pframemic-13), *(pframemic-12), *(pframemic-11), *(pframemic-10), *(pframemic-9))); -
[PATCH v3 20/30] staging: rtl8723bs: added spaces around operator in core/rtw_recv.c
fix post-commit hook checkpatch issue: CHECK: spaces preferred around that '+' (ctx:VxV) 60: FILE: drivers/staging/rtl8723bs/core/rtw_recv.c:359: + if (miccode[i] != *(pframemic+i)) ^ Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 2d749341d47b..953351f896c3 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -356,7 +356,7 @@ static signed int recvframe_chkmic(struct adapter *adapter, union recv_frame *p bmic_err = false; for (i = 0; i < 8; i++) { - if (miccode[i] != *(pframemic+i)) + if (miccode[i] != *(pframemic + i)) bmic_err = true; } -- 2.20.1
[PATCH v3 21/30] staging: rtl8723bs: split long line in core/rtw_recv.c
fix post-commit hook checkpatch issue: WARNING: line length of 113 exceeds 100 columns 110: FILE: drivers/staging/rtl8723bs/core/rtw_recv.c:381: + if ((psecuritypriv->bcheck_grpkey == false) && (IS_MCAST(prxattrib->ra) == true)) Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_recv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 953351f896c3..c8a13d733c98 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -378,7 +378,8 @@ static signed int recvframe_chkmic(struct adapter *adapter, union recv_frame *p } else { /* mic checked ok */ - if ((psecuritypriv->bcheck_grpkey == false) && (IS_MCAST(prxattrib->ra) == true)) + if ((psecuritypriv->bcheck_grpkey == false) && + (IS_MCAST(prxattrib->ra) == true)) psecuritypriv->bcheck_grpkey = true; } } -- 2.20.1
[PATCH v3 22/30] staging: rtl8723bs: remove unnecessary parentheses in core/rtw_recv.c
fix post-commit checkpatch issue: CHECK: Unnecessary parentheses around 'psecuritypriv->bcheck_grpkey == false' 24: FILE: drivers/staging/rtl8723bs/core/rtw_recv.c:381: + if ((psecuritypriv-> bcheck_grpkey == false) && + (IS_MCAST(prxattrib->ra) == true)) Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index c8a13d733c98..cd4324a93275 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -378,7 +378,7 @@ static signed int recvframe_chkmic(struct adapter *adapter, union recv_frame *p } else { /* mic checked ok */ - if ((psecuritypriv->bcheck_grpkey == false) && + if (psecuritypriv->bcheck_grpkey == false && (IS_MCAST(prxattrib->ra) == true)) psecuritypriv->bcheck_grpkey = true; } -- 2.20.1
[PATCH v3 23/30] staging: rtl8723bs: fix comparison in if condition in core/rtw_recv.c
fix post-commit checkpatch issue: CHECK: Using comparison to false is error prone 27: FILE: drivers/staging/rtl8723bs/core/rtw_recv.c:381: + if (psecuritypriv-> bcheck_grpkey == false && Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index cd4324a93275..21949925ec77 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -378,7 +378,7 @@ static signed int recvframe_chkmic(struct adapter *adapter, union recv_frame *p } else { /* mic checked ok */ - if (psecuritypriv->bcheck_grpkey == false && + if (!psecuritypriv->bcheck_grpkey && (IS_MCAST(prxattrib->ra) == true)) psecuritypriv->bcheck_grpkey = true; } -- 2.20.1
[PATCH v3 24/30] staging: rtl8723bs: remove commented RT_TRACE call in core/rtw_ioctl_set.c
Remove commented RT_TRACE call in core/rtw_ioctl_set.c Remove all of the RT_TRACE logs in the core/rtw_ioctl_set.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_ioctl_set.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index 7d858cae2395..14eb01df69b0 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -451,9 +451,6 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, /* SecClearAllKeys(adapter); */ - /* RT_TRACE(COMP_OID_SET, DBG_LOUD, ("set_infrastructure: fw_state:%x after changing mode\n", */ - /* get_fwstate(pmlmepriv))); */ - spin_unlock_bh(&pmlmepriv->lock); } return true; -- 2.20.1
[PATCH v3 25/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_ioctl_set.c
Remove all of the RT_TRACE logs in the core/rtw_ioctl_set.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Signed-off-by: Fabio Aiuto --- .../staging/rtl8723bs/core/rtw_ioctl_set.c| 76 +-- 1 file changed, 4 insertions(+), 72 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index 14eb01df69b0..d4920d7d2452 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -28,7 +28,6 @@ u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid) u8 ret = true; if (ssid->SsidLength > 32) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid length >32\n")); ret = false; goto exit; } @@ -49,8 +48,6 @@ u8 rtw_do_join(struct adapter *padapter) phead = get_list_head(queue); plist = get_next(phead); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("\n rtw_do_join: phead = %p; plist = %p\n\n\n", phead, plist)); - pmlmepriv->cur_network.join_res = -2; set_fwstate(pmlmepriv, _FW_UNDER_LINKING); @@ -69,13 +66,11 @@ u8 rtw_do_join(struct adapter *padapter) if (pmlmepriv->LinkDetectInfo.bBusyTraffic == false || rtw_to_roam(padapter) > 0 ) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_do_join(): site survey if scanned_queue is empty\n.")); /* submit site_survey_cmd */ ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); - if (_SUCCESS != ret) { + if (_SUCCESS != ret) pmlmepriv->to_join = false; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_do_join(): site survey return error\n.")); - } + } else { pmlmepriv->to_join = false; ret = _FAIL; @@ -107,15 +102,12 @@ u8 rtw_do_join(struct adapter *padapter) rtw_generate_random_ibss(pibss); if (rtw_createbss_cmd(padapter) != _SUCCESS) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error =>do_goin: rtw_createbss_cmd status FAIL***\n ")); ret = false; goto exit; } pmlmepriv->to_join = false; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("***Error => rtw_select_and_join_from_scanned_queue FAIL under STA_Mode***\n ")); - } else { /* can't associate ; reset under-linking */ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); @@ -127,10 +119,9 @@ u8 rtw_do_join(struct adapter *padapter) ) { /* DBG_871X("rtw_do_join() when no desired bss in scanning queue\n"); */ ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); - if (_SUCCESS != ret) { + if (_SUCCESS != ret) pmlmepriv->to_join = false; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("do_join(): site survey return error\n.")); - } + } else { ret = _FAIL; pmlmepriv->to_join = false; @@ -169,16 +160,10 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) goto release_mlme_lock; if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); - if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false) goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ } else { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set BSSID not the same bssid\n")); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _d
[PATCH v3 27/30] staging: rtl8723bs: remove all RT_TRACE logs in core/rtw_wlan_util.c
Remove all of the RT_TRACE logs in the core/rtw_wlan_util.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Signed-off-by: Fabio Aiuto --- .../staging/rtl8723bs/core/rtw_wlan_util.c| 24 --- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 760b0ea4e9bd..f6a7993005ab 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1334,11 +1334,6 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) memcpy(bssid->Ssid.Ssid, (p + 2), ssid_len); bssid->Ssid.SsidLength = ssid_len; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s bssid.Ssid.Ssid:%s bssid.Ssid.SsidLength:%d " - "cur_network->network.Ssid.Ssid:%s len:%d\n", __func__, bssid->Ssid.Ssid, - bssid->Ssid.SsidLength, cur_network->network.Ssid.Ssid, - cur_network->network.Ssid.SsidLength)); - if (memcmp(bssid->Ssid.Ssid, cur_network->network.Ssid.Ssid, 32) || bssid->Ssid.SsidLength != cur_network->network.Ssid.SsidLength) { if (bssid->Ssid.Ssid[0] != '\0' && bssid->Ssid.SsidLength != 0) { /* not hidden ssid */ @@ -1355,9 +1350,6 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) else bssid->Privacy = 0; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("%s(): cur_network->network.Privacy is %d, bssid.Privacy is %d\n", -__func__, cur_network->network.Privacy, bssid->Privacy)); if (cur_network->network.Privacy != bssid->Privacy) { DBG_871X("%s(), privacy is not match\n", __func__); goto _mismatch; @@ -1382,25 +1374,17 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) { pbuf = rtw_get_wpa_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); if (pbuf && (wpa_ielen > 0)) { - if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("%s pnetwork->pairwise_cipher: %d, group_cipher is %d, is_8021x is %d\n", __func__, -pairwise_cipher, group_cipher, is_8021x)); - } + rtw_parse_wpa_ie(pbuf, wpa_ielen + 2, &group_cipher, +&pairwise_cipher, &is_8021x); } else { pbuf = rtw_get_wpa2_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); if (pbuf && (wpa_ielen > 0)) { - if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("%s pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_802x is %d\n", -__func__, pairwise_cipher, group_cipher, is_8021x)); - } + rtw_parse_wpa2_ie(pbuf, wpa_ielen + 2, &group_cipher, + &pairwise_cipher, &is_8021x); } } - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("%s cur_network->group_cipher is %d: %d\n", __func__, cur_network->BcnInfo.group_cipher, group_cipher)); if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || group_cipher != cur_network->BcnInfo.group_cipher) { DBG_871X("%s pairwise_cipher(%x:%x) or group_cipher(%x:%x) is not match\n", __func__, pairwise_cipher, cur_network->BcnInfo.pairwise_cipher, -- 2.20.1
[PATCH v3 26/30] staging: rtl8723bs: place constant on the right side of the test in core/rtw_ioctl_set.c
fix posst-commit hook checkpatch issues: WARNING: Comparisons should place the constant on the right side of the test 40: FILE: drivers/staging/rtl8723bs/core/rtw_ioctl_set.c:71: + if (_SUCCESS != ret) WARNING: Comparisons should place the constant on the right side of the test 69: FILE: drivers/staging/rtl8723bs/core/rtw_ioctl_set.c:122: + if (_SUCCESS != ret) Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_ioctl_set.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index d4920d7d2452..f8c7dcb7ab7d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -68,7 +68,7 @@ u8 rtw_do_join(struct adapter *padapter) ) { /* submit site_survey_cmd */ ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); - if (_SUCCESS != ret) + if (ret != _SUCCESS) pmlmepriv->to_join = false; } else { @@ -119,7 +119,7 @@ u8 rtw_do_join(struct adapter *padapter) ) { /* DBG_871X("rtw_do_join() when no desired bss in scanning queue\n"); */ ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); - if (_SUCCESS != ret) + if (ret != _SUCCESS) pmlmepriv->to_join = false; } else { -- 2.20.1
[PATCH v3 28/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_sta_mgt.c
Remove all of the RT_TRACE logs in the core/rtw_sta_mgt.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 25 1 file changed, 25 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c index f96dd0b40e04..7dcac4dd9de2 100644 --- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c @@ -216,10 +216,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) index = wifi_mac_hash(hwaddr); - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, ("rtw_alloc_stainfo: index = %x", index)); - if (index >= NUM_STA) { - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("ERROR => rtw_alloc_stainfo: index >= NUM_STA")); spin_unlock_bh(&(pstapriv->sta_hash_lock)); psta = NULL; goto exit; @@ -242,17 +239,6 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) for (i = 0; i < 16; i++) memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], &wRxSeqInitialValue, 2); - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, -("alloc number_%d stainfo with hwaddr = %x %x %x %x %x %x \n", - pstapriv->asoc_sta_count, - hwaddr[0], - hwaddr[1], - hwaddr[2], - hwaddr[3], - hwaddr[4], - hwaddr[5]) - ); - init_addba_retry_timer(pstapriv->padapter, psta); /* for A-MPDU Rx reordering buffer control */ @@ -363,16 +349,6 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) spin_unlock_bh(&pxmitpriv->lock); list_del_init(&psta->hash_list); - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, -("\n free number_%d stainfo with hwaddr = 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x \n", - pstapriv->asoc_sta_count, - psta->hwaddr[0], - psta->hwaddr[1], - psta->hwaddr[2], - psta->hwaddr[3], - psta->hwaddr[4], - psta->hwaddr[5]) - ); pstapriv->asoc_sta_count--; /* re-init sta_info; 20061114 will be init in alloc_stainfo */ @@ -543,7 +519,6 @@ u32 rtw_init_bcmc_stainfo(struct adapter *padapter) if (!psta) { res = _FAIL; - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("rtw_alloc_stainfo fail")); goto exit; } -- 2.20.1
[PATCH v3 29/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_ieee80211.c
Remove all of the RT_TRACE logs in the core/rtw_ieee80211.c file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Signed-off-by: Fabio Aiuto --- .../staging/rtl8723bs/core/rtw_ieee80211.c| 90 --- 1 file changed, 15 insertions(+), 75 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index e931afc3ba22..eb2058f2d139 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -488,11 +488,8 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis pos += WPA_SELECTOR_LEN; left -= WPA_SELECTOR_LEN; - } else if (left > 0) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie length mismatch, %u too much", __func__, left)); - + } else if (left > 0) return _FAIL; - } /* pairwise_cipher */ if (left >= 2) { @@ -501,11 +498,8 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis pos += 2; left -= 2; - if (count == 0 || left < count * WPA_SELECTOR_LEN) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie count botch (pairwise), " - "count %u left %u", __func__, count, left)); + if (count == 0 || left < count * WPA_SELECTOR_LEN) return _FAIL; - } for (i = 0; i < count; i++) { *pairwise_cipher |= rtw_get_wpa_cipher_suite(pos); @@ -514,16 +508,13 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis left -= WPA_SELECTOR_LEN; } - } else if (left == 1) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short (for key mgmt)", __func__)); + } else if (left == 1) return _FAIL; - } if (is_8021x) { if (left >= 6) { pos += 2; if (!memcmp(pos, SUITE_1X, 4)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s : there has 802.1x auth\n", __func__)); *is_8021x = 1; } } @@ -559,10 +550,8 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi pos += RSN_SELECTOR_LEN; left -= RSN_SELECTOR_LEN; - } else if (left > 0) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie length mismatch, %u too much", __func__, left)); + } else if (left > 0) return _FAIL; - } /* pairwise_cipher */ if (left >= 2) { @@ -571,11 +560,8 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi pos += 2; left -= 2; - if (count == 0 || left < count * RSN_SELECTOR_LEN) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie count botch (pairwise), " -"count %u left %u", __func__, count, left)); + if (count == 0 || left < count * RSN_SELECTOR_LEN) return _FAIL; - } for (i = 0; i < count; i++) { *pairwise_cipher |= rtw_get_wpa2_cipher_suite(pos); @@ -584,19 +570,14 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi left -= RSN_SELECTOR_LEN; } - } else if (left == 1) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short (for key mgmt)", __func__)); - + } else if (left == 1) return _FAIL; - } if (is_8021x) { if (left >= 6) { pos += 2; - if (!memcmp(pos, SUITE_1X, 4)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s (): there has 802.1x auth\n", __func__)); + if (!memcmp(pos, SUITE_1X, 4)) *is_8021x = 1; - } } } @@ -607,7 +588,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len) { int len = 0; - u8 authmode, i; + u8 authmode; uintcnt; u8 wapi_oui1[4] = {0x0, 0x14, 0x72, 0x01}; u8 wapi_oui2[4] = {0x0, 0x14, 0x72, 0x0
[PATCH v3 30/30] staging: rtl8723bs: add spaces around operators in core/rtw_ieee80211.c
fix post-commit hook checkpatch issues: CHECK: spaces preferred around that '+' (ctx:VxV) 161: FILE: drivers/staging/rtl8723bs/core/rtw_ieee80211.c:648: + *wpa_len = in_ie[cnt+1]+2; ^ CHECK: spaces preferred around that '+' (ctx:VxV) 161: FILE: drivers/staging/rtl8723bs/core/rtw_ieee80211.c:648: + *wpa_len = in_ie[cnt+1]+2; ^ CHECK: spaces preferred around that '+' (ctx:VxV) 162: FILE: drivers/staging/rtl8723bs/core/rtw_ieee80211.c:649: + cnt += in_ie[cnt+1]+2; /* get next */ ^ CHECK: spaces preferred around that '+' (ctx:VxV) 162: FILE: drivers/staging/rtl8723bs/core/rtw_ieee80211.c:649: + cnt += in_ie[cnt+1]+2; /* get next */ ^ Signed-off-by: Fabio Aiuto --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index eb2058f2d139..a0d664e254a8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -645,8 +645,8 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie if (wpa_ie) memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt+1]+2); - *wpa_len = in_ie[cnt+1]+2; - cnt += in_ie[cnt+1]+2; /* get next */ + *wpa_len = in_ie[cnt + 1] + 2; + cnt += in_ie[cnt + 1] + 2; /* get next */ } else { if (authmode == WLAN_EID_RSN) { if (rsn_ie) -- 2.20.1
[PATCH] tools/kvm_stat: fix out of date aarch64 kvm_exit reason definations
Aarch64 kvm exit reason defination is out of date for some time, so in this patch: 1. Sync some newly introduced or missing EC definations. 2. Change the WFI to WFx. 3. Fix the comment. Not all the definations are used or usable for aarch64 kvm, but it's better to keep align across the whole kernel. Signed-off-by: Zeng Tao --- tools/kvm/kvm_stat/kvm_stat | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat index b0bf56c..63d87fd 100755 --- a/tools/kvm/kvm_stat/kvm_stat +++ b/tools/kvm/kvm_stat/kvm_stat @@ -154,17 +154,19 @@ SVM_EXIT_REASONS = { 'NPF':0x400, } -# EC definition of HSR (from arch/arm64/include/asm/kvm_arm.h) +# EC definition of HSR (from arch/arm64/include/asm/esr.h) AARCH64_EXIT_REASONS = { 'UNKNOWN': 0x00, -'WFI': 0x01, +'WFx': 0x01, 'CP15_32': 0x03, 'CP15_64': 0x04, 'CP14_MR': 0x05, 'CP14_LS': 0x06, 'FP_ASIMD': 0x07, 'CP10_ID': 0x08, +'PAC': 0x09, 'CP14_64': 0x0C, +'BTI': 0x0D, 'ILL_ISS': 0x0E, 'SVC32':0x11, 'HVC32':0x12, @@ -173,6 +175,10 @@ AARCH64_EXIT_REASONS = { 'HVC64':0x16, 'SMC64':0x17, 'SYS64':0x18, +'SVE': 0x19, +'ERET': 0x1a, +'FPAC': 0x1c, +'IMP_DEF': 0x1f, 'IABT': 0x20, 'IABT_HYP': 0x21, 'PC_ALIGN': 0x22, -- 2.8.1
Fair Pay can be generalized as a Non-Synesthesia project.
Summarizing my posts on LKML, Fair Pay can be generalized as a Non-Synesthesia project, compatible with the muslim Maruf not Munkar principles (translated best in Cursive), and Alla'. We support all instances of such things. My media project always actually was this: https://www.youtube.com/channel/UCBzmdh-pG3_OEqNRz5Owtmw Serenity, Ywe Cærlyn
Re: [PATCH v3 16/30] staging: rtl8723bs: tidy up some error handling in core/rtw_mlme.c
On Sat, Apr 03, 2021 at 11:13:38AM +0200, Fabio Aiuto wrote: > the RT_TRACE() output is not useful so we want to delete it. In this case > there is no cleanup for rtw_cleanbss_cmd() required or even possible. I've > deleted the RT_TRACE() output and added a goto unlock to show > that we can't continue if rtw_createbss_cmd() fails. > > Suggested-by: David Carpenter > Signed-off-by: Fabio Aiuto > --- > drivers/staging/rtl8723bs/core/rtw_mlme.c | 17 +++-- > 1 file changed, 11 insertions(+), 6 deletions(-) Hi Dan, I put a Suggested-by tag on one patch in v3 patchset. But reading the docs on submitting patches I relaized later that maybe it requires your permission before. It' written about Reviewed-by but not about Suggested-by, should I have asked you before, should I? I'm sorry if I should have. thank you, fabio
Re: [PATCH v3 16/30] staging: rtl8723bs: tidy up some error handling in core/rtw_mlme.c
On Sat, Apr 03, 2021 at 11:42:47AM +0200, Fabio Aiuto wrote: > On Sat, Apr 03, 2021 at 11:13:38AM +0200, Fabio Aiuto wrote: > > the RT_TRACE() output is not useful so we want to delete it. In this case > > there is no cleanup for rtw_cleanbss_cmd() required or even possible. I've > > deleted the RT_TRACE() output and added a goto unlock to show > > that we can't continue if rtw_createbss_cmd() fails. > > > > Suggested-by: David Carpenter > > Signed-off-by: Fabio Aiuto > > --- > > drivers/staging/rtl8723bs/core/rtw_mlme.c | 17 +++-- > > 1 file changed, 11 insertions(+), 6 deletions(-) > > Hi Dan, > > I put a Suggested-by tag on one patch in v3 patchset. But reading the docs > on submitting patches I relaized later that maybe it requires your permission > before. > > It' written about Reviewed-by but not about Suggested-by, should I have asked > you before, should I? > > I'm sorry if I should have. Found it, I'm really sorry A Suggested-by: tag indicates that the patch idea is suggested by the person named and ensures credit to the person for the idea. Please note that this tag should not be added without the reporter's permission, especially if the idea was not posted in a public forum. That said, if we diligently credit our idea reporters, they will, hopefully, be inspired to help us again in the future. I wonder if in the case of this patch was needed this tag.. > > thank you, > > fabio regards, fabio
Re: [PATCH v6] RISC-V: enable XIP
Hi Vitaly, Le 4/1/21 à 7:10 AM, Alex Ghiti a écrit : Le 4/1/21 à 4:52 AM, Vitaly Wool a écrit : Hi Alex, On Thu, Apr 1, 2021 at 10:11 AM Alex Ghiti wrote: Hi, Le 3/30/21 à 4:04 PM, Alex Ghiti a écrit : Le 3/30/21 à 3:33 PM, Palmer Dabbelt a écrit : On Tue, 30 Mar 2021 11:39:10 PDT (-0700), a...@ghiti.fr wrote: Le 3/30/21 à 2:26 AM, Vitaly Wool a écrit : On Tue, Mar 30, 2021 at 8:23 AM Palmer Dabbelt wrote: On Sun, 21 Mar 2021 17:12:15 PDT (-0700), vitaly.w...@konsulko.com wrote: Introduce XIP (eXecute In Place) support for RISC-V platforms. It allows code to be executed directly from non-volatile storage directly addressable by the CPU, such as QSPI NOR flash which can be found on many RISC-V platforms. This makes way for significant optimization of RAM footprint. The XIP kernel is not compressed since it has to run directly from flash, so it will occupy more space on the non-volatile storage. The physical flash address used to link the kernel object files and for storing it has to be known at compile time and is represented by a Kconfig option. XIP on RISC-V will for the time being only work on MMU-enabled kernels. Signed-off-by: Vitaly Wool --- Changes in v2: - dedicated macro for XIP address fixup when MMU is not enabled yet o both for 32-bit and 64-bit RISC-V - SP is explicitly set to a safe place in RAM before __copy_data call - removed redundant alignment requirements in vmlinux-xip.lds.S - changed long -> uintptr_t typecast in __XIP_FIXUP macro. Changes in v3: - rebased against latest for-next - XIP address fixup macro now takes an argument - SMP related fixes Changes in v4: - rebased against the current for-next - less #ifdef's in C/ASM code - dedicated XIP_FIXUP_OFFSET assembler macro in head.S - C-specific definitions moved into #ifndef __ASSEMBLY__ - Fixed multi-core boot Changes in v5: - fixed build error for non-XIP kernels Changes in v6: - XIP_PHYS_RAM_BASE config option renamed to PHYS_RAM_BASE - added PHYS_RAM_BASE_FIXED config flag to allow usage of PHYS_RAM_BASE in non-XIP configurations if needed - XIP_FIXUP macro rewritten with a tempoarary variable to avoid side effects - fixed crash for non-XIP kernels that don't use built-in DTB So v5 landed on for-next, which generally means it's best to avoid re-spinning the patch and instead send along fixups. That said, the v5 is causing some testing failures for me. I'm going to drop the v5 for now as I don't have time to test this tonight. I'll try and take a look soon, as it will conflict with Alex's patches. I can come up with the incremental patch instead pretty much straight away if that works better. ~Vitaly arch/riscv/Kconfig | 49 ++- arch/riscv/Makefile | 8 +- arch/riscv/boot/Makefile | 13 +++ arch/riscv/include/asm/pgtable.h | 65 -- arch/riscv/kernel/cpu_ops_sbi.c | 11 ++- arch/riscv/kernel/head.S | 49 ++- arch/riscv/kernel/head.h | 3 + arch/riscv/kernel/setup.c | 8 +- arch/riscv/kernel/vmlinux-xip.lds.S | 132 arch/riscv/kernel/vmlinux.lds.S | 6 ++ arch/riscv/mm/init.c | 100 +++-- 11 files changed, 426 insertions(+), 18 deletions(-) create mode 100644 arch/riscv/kernel/vmlinux-xip.lds.S diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 8ea60a0a19ae..bd6f82240c34 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -441,7 +441,7 @@ config EFI_STUB config EFI bool "UEFI runtime support" - depends on OF + depends on OF && !XIP_KERNEL select LIBFDT select UCS2_STRING select EFI_PARAMS_FROM_FDT @@ -465,11 +465,56 @@ config STACKPROTECTOR_PER_TASK def_bool y depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS +config PHYS_RAM_BASE_FIXED + bool "Explicitly specified physical RAM address" + default n + +config PHYS_RAM_BASE + hex "Platform Physical RAM address" + depends on PHYS_RAM_BASE_FIXED + default "0x8000" + help + This is the physical address of RAM in the system. It has to be + explicitly specified to run early relocations of read-write data + from flash to RAM. + +config XIP_KERNEL + bool "Kernel Execute-In-Place from ROM" + depends on MMU + select PHYS_RAM_BASE_FIXED + help + Execute-In-Place allows the kernel to run from non-volatile storage + directly addressable by the CPU, such as NOR flash. This saves RAM + space since the text section of the kernel is not loaded from flash + to RAM. Read-write sections, such as the data section and stack, + are still copied to RAM. The XIP kernel is not compressed since + it has to run directly from flash, so it will take more space to + store it. The flash address used to link the kernel object files, + and for storing it, is c
Re: [PATCH] kfence: unpoison pool region before use
On Sat, 3 Apr 2021 at 07:13, Peter Collingbourne wrote: > If the memory region allocated by KFENCE had previously been poisoned, > any validity checks done using kasan_byte_accessible() will fail. Fix > it by unpoisoning the memory before using it as the pool region. > > Link: > https://linux-review.googlesource.com/id/I0af99e9f1c25eaf7e1ec295836b5d148d76940c5 > Signed-off-by: Peter Collingbourne Thanks, at a high level this seems reasonable, because we always want to ensure that KFENCE memory remains unpoisoned with KASAN on. FWIW I subjected a config with KFENCE+KASAN (generic, SW_TAGS, and HW_TAGS) to syzkaller testing and ran kfence_test: Tested-by: Marco Elver However, it is unclear to me under which circumstances we actually need this, i.e. something would grab some memblock memory, somehow poison it, and then release the memory back during early boot (note, kfence_alloc_pool() is called before slab setup). If we can somehow understand what actually did this, perhaps it'd help tell us if this actually needs fixing in KFENCE or it's the other thing that needs a fix. Given all this is happening during really early boot, I'd expect no or very few calls to kasan_poison() until kfence_alloc_pool() is called. We can probably debug it more by having kasan_poison() do a "if (!__kfence_pool) dump_stack();" somewhere. Can you try this on the system where you can repro the problem? I tried this just now on the latest mainline kernel, and saw 0 calls until kfence_alloc_pool(). Thanks, -- Marco > --- > mm/kfence/core.c | 12 +--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/mm/kfence/core.c b/mm/kfence/core.c > index d53c91f881a4..bb22b0cf77aa 100644 > --- a/mm/kfence/core.c > +++ b/mm/kfence/core.c > @@ -633,13 +633,19 @@ static DECLARE_DELAYED_WORK(kfence_timer, > toggle_allocation_gate); > > void __init kfence_alloc_pool(void) > { > + void *pool; > + > if (!kfence_sample_interval) > return; > > - __kfence_pool = memblock_alloc(KFENCE_POOL_SIZE, PAGE_SIZE); > - > - if (!__kfence_pool) > + pool = memblock_alloc(KFENCE_POOL_SIZE, PAGE_SIZE); > + if (!pool) { > pr_err("failed to allocate pool\n"); > + return; > + } > + > + kasan_unpoison_range(pool, KFENCE_POOL_SIZE); > + __kfence_pool = pool; > } > > void __init kfence_init(void) > -- > 2.31.0.208.g409f899ff0-goog >
Re: [PATCH v3 16/30] staging: rtl8723bs: tidy up some error handling in core/rtw_mlme.c
On Sat, Apr 03, 2021 at 11:50:30AM +0200, Fabio Aiuto wrote: > On Sat, Apr 03, 2021 at 11:42:47AM +0200, Fabio Aiuto wrote: > > On Sat, Apr 03, 2021 at 11:13:38AM +0200, Fabio Aiuto wrote: > > > the RT_TRACE() output is not useful so we want to delete it. In this case > > > there is no cleanup for rtw_cleanbss_cmd() required or even possible. I've > > > deleted the RT_TRACE() output and added a goto unlock to show > > > that we can't continue if rtw_createbss_cmd() fails. > > > > > > Suggested-by: David Carpenter > > > Signed-off-by: Fabio Aiuto > > > --- > > > drivers/staging/rtl8723bs/core/rtw_mlme.c | 17 +++-- > > > 1 file changed, 11 insertions(+), 6 deletions(-) > > > > Hi Dan, > > > > I put a Suggested-by tag on one patch in v3 patchset. But reading the docs > > on submitting patches I relaized later that maybe it requires your > > permission before. > > > > It' written about Reviewed-by but not about Suggested-by, should I have > > asked you before, should I? > > > > I'm sorry if I should have. > > Found it, I'm really sorry > > A Suggested-by: tag indicates that the patch idea is suggested by the person > named and ensures credit to the person for the idea. Please note that this > tag should not be added without the reporter's permission, especially if the > idea was not posted in a public forum. That said, if we diligently credit our > idea reporters, they will, hopefully, be inspired to help us again in the > future. > > I wonder if in the case of this patch was needed this tag.. Yeah, it's fine. It's all on a public list so it's not a secret. regards, dan carpenter
[PATCH] printk: Make multiple inclusion of kernel/printk/internal.h safe
kernel test robot reported that kernel/printk/internal.h is not ready to be #include'd for multiple times, and that vprintk_func() for CONFIG_PRINTK=n should be marked as "static inline". Since "tty: use printk_safe context at tty_msg()" will make kernel/printk/internal.h be #include'd for multiple times, let's fix this problem first. Reported-by: kernel test robot Signed-off-by: Tetsuo Handa Fixes: 099f1c84c0052ec1 ("printk: introduce per-cpu safe_print seq buffer") Cc: # 4.11+ --- kernel/printk/internal.h | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h index 3a8fd491758c..2119c546cba2 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -2,6 +2,10 @@ /* * internal.h - printk internal definitions */ + +#ifndef _KERNEL_PRINTK_INTERNAL_H +#define _KERNEL_PRINTK_INTERNAL_H + #include #ifdef CONFIG_PRINTK @@ -56,7 +60,7 @@ void defer_console_output(void); #else -__printf(1, 0) int vprintk_func(const char *fmt, va_list args) { return 0; } +static inline __printf(1, 0) int vprintk_func(const char *fmt, va_list args) { return 0; } /* * In !PRINTK builds we still export logbuf_lock spin_lock, console_sem @@ -72,3 +76,5 @@ __printf(1, 0) int vprintk_func(const char *fmt, va_list args) { return 0; } static inline void printk_safe_init(void) { } static inline bool printk_percpu_data_ready(void) { return false; } #endif /* CONFIG_PRINTK */ + +#endif -- 2.18.4
WE OFFER INVESTMENT FUNDING
We introduce ourselves as mandated capital providers. We are interested in having your company represents us exclusively in your jurisdiction for the placement of loan and investment financing. Being direct financiers we offer financing for businesses for expansion, working capital, construction projects, factoring, energy, manufacturing, telecommunications and the real estate sector to name a few. Our pool of funds is provided by high net worth individuals, trust funds, family office funds as well as corporate and institutional funds. We act as the direct custodian of these funds provided by our clients who request that we operate with the utmost of privacy and discretion. As a result we normally fund individual projects starting from USD3 million well into the 100 to 200 million dollar range. Sincerely Rix Anthony FM Consultant New Zealand
Re: allmodconfig not working with dummy-tools
Hello, thanks for the fix. On Fri, Apr 02, 2021 at 01:26:38AM +0900, Masahiro Yamada wrote: > On Thu, Apr 1, 2021 at 9:39 PM Michal Suchánek wrote: > I squashed the following. Please wait for tomorrow's linux-next. > diff --git a/scripts/dummy-tools/gcc b/scripts/dummy-tools/gcc > index 39e65fee59bd..f6d543725f1e 100755 > --- a/scripts/dummy-tools/gcc > +++ b/scripts/dummy-tools/gcc > @@ -67,6 +67,12 @@ if arg_contain -E "$@"; then > fi > fi > > +# To set CONFIG_AS_IS_GNU > +if arg_contain -Wa,--version "$@"; then > + echo "GNU assembler (scripts/dummy-tools) 2.50" > + exit 0 > +fi > + > if arg_contain -S "$@"; then > # For scripts/gcc-x86-*-has-stack-protector.sh > if arg_contain -fstack-protector "$@"; then Looks like this did not make it to linux-next (0104 does not have it, 0204 does not exist). Nonetheless, applying the fixup resolves the problem. Thanks Michal
Re: [PATCH 2/4] KVM: MIPS: rework flush_shadow_* callbacks into one that prepares the flush
On 03/04/21 04:31, Huacai Chen wrote: Hi, Paolo, TE mode has been removed in the MIPS tree, can we also remove it in KVM tree before this rework? I tried the merge and it will be enough for Linus to remove arch/mips/kvm/trap_emul.c. So I will leave it as is, but next time I'd prefer KVM MIPS changes to go through either my tree or a common topic branch. Paolo
arch/powerpc/kvm/book3s_hv_nested.c:264:6: error: stack frame size of 2304 bytes in function 'kvmhv_enter_nested_guest'
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: d93a0d43e3d0ba9e19387be4dae4a8d5b175a8d7 commit: 97e4910232fa1f81e806aa60c25a0450276d99a2 linux/compiler-clang.h: define HAVE_BUILTIN_BSWAP* date: 3 weeks ago config: powerpc64-randconfig-r006-20210403 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 0fe8af94688aa03c01913c2001d6a1a911f42ce6) 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 powerpc64 cross compiling tool for clang build # apt-get install binutils-powerpc64-linux-gnu # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=97e4910232fa1f81e806aa60c25a0450276d99a2 git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git fetch --no-tags linus master git checkout 97e4910232fa1f81e806aa60c25a0450276d99a2 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): >> arch/powerpc/kvm/book3s_hv_nested.c:264:6: error: stack frame size of 2304 >> bytes in function 'kvmhv_enter_nested_guest' [-Werror,-Wframe-larger-than=] long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu) ^ 1 error generated. vim +/kvmhv_enter_nested_guest +264 arch/powerpc/kvm/book3s_hv_nested.c afe75049303f75 Ravi Bangoria2020-12-16 263 360cae313702cd Paul Mackerras 2018-10-08 @264 long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu) 360cae313702cd Paul Mackerras 2018-10-08 265 { 360cae313702cd Paul Mackerras 2018-10-08 266 long int err, r; 360cae313702cd Paul Mackerras 2018-10-08 267 struct kvm_nested_guest *l2; 360cae313702cd Paul Mackerras 2018-10-08 268 struct pt_regs l2_regs, saved_l1_regs; afe75049303f75 Ravi Bangoria2020-12-16 269 struct hv_guest_state l2_hv = {0}, saved_l1_hv; 360cae313702cd Paul Mackerras 2018-10-08 270 struct kvmppc_vcore *vc = vcpu->arch.vcore; 360cae313702cd Paul Mackerras 2018-10-08 271 u64 hv_ptr, regs_ptr; 360cae313702cd Paul Mackerras 2018-10-08 272 u64 hdec_exp; 360cae313702cd Paul Mackerras 2018-10-08 273 s64 delta_purr, delta_spurr, delta_ic, delta_vtb; 360cae313702cd Paul Mackerras 2018-10-08 274 u64 mask; 360cae313702cd Paul Mackerras 2018-10-08 275 unsigned long lpcr; 360cae313702cd Paul Mackerras 2018-10-08 276 360cae313702cd Paul Mackerras 2018-10-08 277 if (vcpu->kvm->arch.l1_ptcr == 0) 360cae313702cd Paul Mackerras 2018-10-08 278 return H_NOT_AVAILABLE; 360cae313702cd Paul Mackerras 2018-10-08 279 360cae313702cd Paul Mackerras 2018-10-08 280 /* copy parameters in */ 360cae313702cd Paul Mackerras 2018-10-08 281 hv_ptr = kvmppc_get_gpr(vcpu, 4); 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 282 regs_ptr = kvmppc_get_gpr(vcpu, 5); 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 283 vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); afe75049303f75 Ravi Bangoria2020-12-16 284 err = kvmhv_read_guest_state_and_regs(vcpu, &l2_hv, &l2_regs, afe75049303f75 Ravi Bangoria2020-12-16 285 hv_ptr, regs_ptr); 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 286 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); 360cae313702cd Paul Mackerras 2018-10-08 287 if (err) 360cae313702cd Paul Mackerras 2018-10-08 288 return H_PARAMETER; 1508c22f112ce1 Alexey Kardashevskiy 2020-06-09 289 10b5022db7861a Suraj Jitindar Singh 2018-10-08 290 if (kvmppc_need_byteswap(vcpu)) 10b5022db7861a Suraj Jitindar Singh 2018-10-08 291 byteswap_hv_regs(&l2_hv); afe75049303f75 Ravi Bangoria2020-12-16 292 if (l2_hv.version > HV_GUEST_STATE_VERSION) 360cae313702cd Paul Mackerras 2018-10-08 293 return H_P2; 360cae313702cd Paul Mackerras 2018-10-08 294 10b5022db7861a Suraj Jitindar Singh 2018-10-08 295 if (kvmppc_need_byteswap(vcpu)) 10b5022db7861a Suraj Jitindar Singh 2018-10-08 296 byteswap_pt_regs(&l2_regs); 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 297 if (l2_hv.vcpu_token >= NR_CPUS) 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 298 return H_PARAMETER; 9d0b048da788c1 Suraj Jitindar Singh 2018-10-08 299 360cae313702cd Paul Mackerras 2018-10-08 300 /* translate lpid */ 360cae313702cd Paul Mackerras 2018-10-08 301 l2 = kvmhv_get_nes
[GIT PULL] Serial driver fix for 5.12-rc6
The following changes since commit 1e28eed17697bcf343c6743f0028cc3b5dd88bf0: Linux 5.12-rc3 (2021-03-14 14:41:02 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tags/tty-5.12-rc6 for you to fetch changes up to 29d96eb261345c8d888e248ae79484e681be2faa: soc: qcom-geni-se: Cleanup the code to remove proxy votes (2021-03-26 15:16:05 +0100) Serial driver fix for 5.12-rc6 Here is a single serial driver fix for 5.12-rc6. Is is a revert of a change that showed up in 5.9 that has been reported to cause problems. It has been in linux-next for a while with no reported issues. Signed-off-by: Greg Kroah-Hartman Roja Rani Yarubandi (1): soc: qcom-geni-se: Cleanup the code to remove proxy votes drivers/soc/qcom/qcom-geni-se.c | 74 --- drivers/tty/serial/qcom_geni_serial.c | 7 include/linux/qcom-geni-se.h | 2 - 3 files changed, 83 deletions(-)
[GIT PULL] USB driver fixes for 5.12-rc6
The following changes since commit 0d02ec6b3136c73c09e7859f0d0e4e2c4c07b49b: Linux 5.12-rc4 (2021-03-21 14:56:43 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git tags/usb-5.12-rc6 for you to fetch changes up to 93f672804bf2d7a49ef3fd96827ea6290ca1841e: usb: dwc2: Prevent core suspend when port connection flag is 0 (2021-03-26 14:51:34 +0100) USB fixes for 5.12-rc6 Here are a few small USB driver fixes for 5.12-rc6 to resolve reported problems. They include: - a number of cdc-acm fixes for reported problems. It seems more people are using this driver lately... - dwc3 driver fixes for reported problems, and fixes for the fixes :) - dwc2 driver fixes for reported issues. - musb driver fix. - new USB quirk additions. All of these have been in linux-next for a while with no reported issues. Signed-off-by: Greg Kroah-Hartman Andy Shevchenko (1): usb: dwc3: pci: Enable dis_uX_susphy_quirk for Intel Merrifield Artur Petrosyan (2): usb: dwc2: Fix HPRT0.PrtSusp bit setting for HiKey 960 board. usb: dwc2: Prevent core suspend when port connection flag is 0 Chunfeng Yun (1): usb: xhci-mtk: fix broken streams issue on 0.96 xHCI Johan Hovold (8): USB: cdc-acm: fix double free on probe failure USB: cdc-acm: fix use-after-free after probe failure USB: cdc-acm: drop redundant driver-data assignment USB: cdc-acm: drop redundant driver-data reset USB: cdc-acm: clean up probe error labels USB: cdc-acm: use negation for NULL checks USB: cdc-acm: always claim data interface USB: cdc-acm: do not log successful probe on later errors Oliver Neukum (3): cdc-acm: fix BREAK rx code path adding necessary calls USB: cdc-acm: untangle a circular dependency between callback and softint USB: cdc-acm: downgrade message to debug Shawn Guo (1): usb: dwc3: qcom: skip interconnect init for ACPI probe Shuah Khan (1): usbip: vhci_hcd fix shift out-of-bounds in vhci_hub_control() Thinh Nguyen (2): usb: dwc3: gadget: Set gadget_max_speed when set ssp_rate usb: dwc3: gadget: Use max speed if unspecified Tong Zhang (1): usb: gadget: udc: amd5536udc_pci fix null-ptr-dereference Tony Lindgren (1): usb: musb: Fix suspend with devices connected for a64 Vincent Palatin (1): USB: quirks: ignore remote wake-up on Fibocom L850-GL LTE modem Wesley Cheng (1): usb: dwc3: gadget: Clear DEP flags after stop transfers in ep disable drivers/usb/class/cdc-acm.c | 120 +++- drivers/usb/core/quirks.c | 4 ++ drivers/usb/dwc2/hcd.c | 5 +- drivers/usb/dwc3/dwc3-pci.c | 2 + drivers/usb/dwc3/dwc3-qcom.c| 3 + drivers/usb/dwc3/gadget.c | 11 +-- drivers/usb/gadget/udc/amd5536udc_pci.c | 10 +-- drivers/usb/host/xhci-mtk.c | 10 ++- drivers/usb/musb/musb_core.c| 12 ++-- drivers/usb/usbip/vhci_hcd.c| 2 + 10 files changed, 112 insertions(+), 67 deletions(-)
[GIT PULL] Staging driver fix for 5.12-rc6
The following changes since commit 0d02ec6b3136c73c09e7859f0d0e4e2c4c07b49b: Linux 5.12-rc4 (2021-03-21 14:56:43 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git tags/staging-5.12-rc6 for you to fetch changes up to e78836ae76d20f38eed8c8c67f21db97529949da: staging: rtl8192e: Change state information from u16 to u8 (2021-03-23 13:32:40 +0100) Staging driver fixes for 5.12-rc6 Here are 2 rtl8192e staging driver fixes for reported problems. Both of these have been in linux-next for a while with no reported issues. Signed-off-by: Greg Kroah-Hartman Atul Gopinathan (2): staging: rtl8192e: Fix incorrect source in memcpy() staging: rtl8192e: Change state information from u16 to u8 drivers/staging/rtl8192e/rtllib.h| 2 +- drivers/staging/rtl8192e/rtllib_rx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
[GIT PULL] Char/Misc driver fixes for 5.12-rc6
The following changes since commit 1e28eed17697bcf343c6743f0028cc3b5dd88bf0: Linux 5.12-rc3 (2021-03-14 14:41:02 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git tags/char-misc-5.12-rc6 for you to fetch changes up to 3756b6578709c55819742f6ba0c18f93e8901397: Merge tag 'icc-5.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/djakov/icc into char-misc-linus (2021-03-27 12:39:18 +0100) Char/Misc driver fixes for 5.12-rc6 Here are a few small driver char/misc changes for 5.12-rc6. Nothing major here, a few fixes for reported issues: - interconnect fixes for problems found - fbcon syzbot-found fix - extcon fixes - firmware stratix10 bugfix - MAINTAINERS file update. All of these have been in linux-next for a while with no reported issues. Signed-off-by: Greg Kroah-Hartman Benjamin Li (1): interconnect: qcom: msm8939: remove rpm-ids from non-RPM nodes Dinghao Liu (1): extcon: Fix error handling in extcon_dev_register Du Cheng (1): drivers: video: fbcon: fix NULL dereference in fbcon_cursor() Georgi Djakov (1): interconnect: Fix kerneldoc warning Greg Kroah-Hartman (3): Merge tag 'extcon-fixes-for-5.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-next Merge tag 'fpga-fixes-for-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/mdf/linux-fpga into char-misc-linus Merge tag 'icc-5.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/djakov/icc into char-misc-linus Jia-Ju Bai (1): interconnect: core: fix error return code of icc_link_destroy() Krzysztof Kozlowski (1): extcon: Add stubs for extcon_register_notifier_all() functions Richard Gong (1): firmware: stratix10-svc: reset COMMAND_RECONFIG_FLAG_PARTIAL to 0 Tomas Winkler (1): mei: allow map and unmap of client dma buffer only for disconnected client Vinod Koul (1): MAINTAINERS: Add linux-phy list and patchwork MAINTAINERS| 3 ++- drivers/extcon/extcon.c| 1 + drivers/interconnect/bulk.c| 2 +- drivers/interconnect/core.c| 2 ++ drivers/interconnect/qcom/msm8939.c| 16 +++ drivers/misc/mei/client.c | 17 +++- drivers/video/fbdev/core/fbcon.c | 3 +++ include/linux/extcon.h | 23 ++ .../linux/firmware/intel/stratix10-svc-client.h| 2 +- 9 files changed, 48 insertions(+), 21 deletions(-)
[GIT PULL] Driver core fix for 5.12-rc6
The following changes since commit 0d02ec6b3136c73c09e7859f0d0e4e2c4c07b49b: Linux 5.12-rc4 (2021-03-21 14:56:43 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git tags/driver-core-5.12-rc6 for you to fetch changes up to f0acf637d60ffcef3ccb6e279f743e587b3c7359: driver core: clear deferred probe reason on probe retry (2021-03-23 15:13:43 +0100) Driver core fix for 5.12-rc6 Here is a single driver core fix for a reported problem with differed probing. It has been in linux-next for a while with no reported problems. Signed-off-by: Greg Kroah-Hartman Ahmad Fatoum (1): driver core: clear deferred probe reason on probe retry drivers/base/dd.c | 3 +++ 1 file changed, 3 insertions(+)
[PATCH] ARM: dts: qcom: msm8974-hammerhead: add mount matrix for IMU
Configure the mount matrix to account for the sensor placement on the board. Signed-off-by: Luca Weiss --- arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts | 4 1 file changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts index e344007cf93f..924b0bd744b9 100644 --- a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts +++ b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts @@ -567,6 +567,10 @@ mpu6515@68 { pinctrl-names = "default"; pinctrl-0 = <&mpu6515_pin>; + mount-matrix = "0", "-1", "0", + "-1", "0", "0", + "0", "0", "1"; + i2c-gate { #address-cells = <1>; #size-cells = <0>; -- 2.31.1
[tip: x86/core] objtool: Skip magical retpoline .altinstr_replacement
The following commit has been merged into the x86/core branch of tip: Commit-ID: 50e7b4a1a1b264fc7df0698f2defb93cadf19a7b Gitweb: https://git.kernel.org/tip/50e7b4a1a1b264fc7df0698f2defb93cadf19a7b Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:14 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:46:57 +02:00 objtool: Skip magical retpoline .altinstr_replacement When the .altinstr_replacement is a retpoline, skip the alternative. We already special case retpolines anyway. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151300.259429...@infradead.org --- tools/objtool/special.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/objtool/special.c b/tools/objtool/special.c index 2c7fbda..07b21cf 100644 --- a/tools/objtool/special.c +++ b/tools/objtool/special.c @@ -106,6 +106,14 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry, return -1; } + /* +* Skip retpoline .altinstr_replacement... we already rewrite the +* instructions for retpolines anyway, see arch_is_retpoline() +* usage in add_{call,jump}_destinations(). +*/ + if (arch_is_retpoline(new_reloc->sym)) + return 1; + alt->new_sec = new_reloc->sym->sec; alt->new_off = (unsigned int)new_reloc->addend; @@ -154,7 +162,9 @@ int special_get_alts(struct elf *elf, struct list_head *alts) memset(alt, 0, sizeof(*alt)); ret = get_alt_entry(elf, entry, sec, idx, alt); - if (ret) + if (ret > 0) + continue; + if (ret < 0) return ret; list_add_tail(&alt->list, alts);
[tip: x86/core] objtool: Add elf_create_undef_symbol()
The following commit has been merged into the x86/core branch of tip: Commit-ID: 2f2f7e47f0525cbaad5dd9675fd9d8aa8da12046 Gitweb: https://git.kernel.org/tip/2f2f7e47f0525cbaad5dd9675fd9d8aa8da12046 Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:11 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:45:05 +02:00 objtool: Add elf_create_undef_symbol() Allow objtool to create undefined symbols; this allows creating relocations to symbols not currently in the symbol table. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151300.064743...@infradead.org --- tools/objtool/elf.c | 60 - tools/objtool/include/objtool/elf.h | 1 +- 2 files changed, 61 insertions(+) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 8457218..d08f5f3 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -715,6 +715,66 @@ static int elf_add_string(struct elf *elf, struct section *strtab, char *str) return len; } +struct symbol *elf_create_undef_symbol(struct elf *elf, const char *name) +{ + struct section *symtab; + struct symbol *sym; + Elf_Data *data; + Elf_Scn *s; + + sym = malloc(sizeof(*sym)); + if (!sym) { + perror("malloc"); + return NULL; + } + memset(sym, 0, sizeof(*sym)); + + sym->name = strdup(name); + + sym->sym.st_name = elf_add_string(elf, NULL, sym->name); + if (sym->sym.st_name == -1) + return NULL; + + sym->sym.st_info = GELF_ST_INFO(STB_GLOBAL, STT_NOTYPE); + // st_other 0 + // st_shndx 0 + // st_value 0 + // st_size 0 + + symtab = find_section_by_name(elf, ".symtab"); + if (!symtab) { + WARN("can't find .symtab"); + return NULL; + } + + s = elf_getscn(elf->elf, symtab->idx); + if (!s) { + WARN_ELF("elf_getscn"); + return NULL; + } + + data = elf_newdata(s); + if (!data) { + WARN_ELF("elf_newdata"); + return NULL; + } + + data->d_buf = &sym->sym; + data->d_size = sizeof(sym->sym); + data->d_align = 1; + + sym->idx = symtab->len / sizeof(sym->sym); + + symtab->len += data->d_size; + symtab->changed = true; + + sym->sec = find_section_by_index(elf, 0); + + elf_add_symbol(elf, sym); + + return sym; +} + struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr) { diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h index 463f329..45e5ede 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -133,6 +133,7 @@ int elf_write_insn(struct elf *elf, struct section *sec, unsigned long offset, unsigned int len, const char *insn); int elf_write_reloc(struct elf *elf, struct reloc *reloc); +struct symbol *elf_create_undef_symbol(struct elf *elf, const char *name); int elf_write(struct elf *elf); void elf_close(struct elf *elf);
[tip: x86/core] objtool: Cache instruction relocs
The following commit has been merged into the x86/core branch of tip: Commit-ID: 7bd2a600f3e9d27286bbf23c83d599e9cc7cf245 Gitweb: https://git.kernel.org/tip/7bd2a600f3e9d27286bbf23c83d599e9cc7cf245 Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:13 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:46:15 +02:00 objtool: Cache instruction relocs Track the reloc of instructions in the new instruction->reloc field to avoid having to look them up again later. ( Technically x86 instructions can have two relocations, but not jumps and calls, for which we're using this. ) Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151300.195441...@infradead.org --- tools/objtool/check.c | 28 -- tools/objtool/include/objtool/check.h | 1 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 77074db..1f4154f 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -797,6 +797,25 @@ __weak bool arch_is_retpoline(struct symbol *sym) return false; } +#define NEGATIVE_RELOC ((void *)-1L) + +static struct reloc *insn_reloc(struct objtool_file *file, struct instruction *insn) +{ + if (insn->reloc == NEGATIVE_RELOC) + return NULL; + + if (!insn->reloc) { + insn->reloc = find_reloc_by_dest_range(file->elf, insn->sec, + insn->offset, insn->len); + if (!insn->reloc) { + insn->reloc = NEGATIVE_RELOC; + return NULL; + } + } + + return insn->reloc; +} + /* * Find the destination instructions for all jumps. */ @@ -811,8 +830,7 @@ static int add_jump_destinations(struct objtool_file *file) if (!is_static_jump(insn)) continue; - reloc = find_reloc_by_dest_range(file->elf, insn->sec, -insn->offset, insn->len); + reloc = insn_reloc(file, insn); if (!reloc) { dest_sec = insn->sec; dest_off = arch_jump_destination(insn); @@ -944,8 +962,7 @@ static int add_call_destinations(struct objtool_file *file) if (insn->type != INSN_CALL) continue; - reloc = find_reloc_by_dest_range(file->elf, insn->sec, - insn->offset, insn->len); + reloc = insn_reloc(file, insn); if (!reloc) { dest_off = arch_jump_destination(insn); insn->call_dest = find_call_destination(insn->sec, dest_off); @@ -1144,8 +1161,7 @@ static int handle_group_alt(struct objtool_file *file, * alternatives code can adjust the relative offsets * accordingly. */ - alt_reloc = find_reloc_by_dest_range(file->elf, insn->sec, - insn->offset, insn->len); + alt_reloc = insn_reloc(file, insn); if (alt_reloc && !arch_support_alt_relocation(special_alt, insn, alt_reloc)) { diff --git a/tools/objtool/include/objtool/check.h b/tools/objtool/include/objtool/check.h index e5528ce..56d50bc 100644 --- a/tools/objtool/include/objtool/check.h +++ b/tools/objtool/include/objtool/check.h @@ -56,6 +56,7 @@ struct instruction { struct instruction *jump_dest; struct instruction *first_jump_src; struct reloc *jump_table; + struct reloc *reloc; struct list_head alts; struct symbol *func; struct list_head stack_ops;
[tip: x86/core] objtool: Keep track of retpoline call sites
The following commit has been merged into the x86/core branch of tip: Commit-ID: 43d5430ad74ef5156353af7aec352426ec7a8e57 Gitweb: https://git.kernel.org/tip/43d5430ad74ef5156353af7aec352426ec7a8e57 Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:12 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:45:27 +02:00 objtool: Keep track of retpoline call sites Provide infrastructure for architectures to rewrite/augment compiler generated retpoline calls. Similar to what we do for static_call()s, keep track of the instructions that are retpoline calls. Use the same list_head, since a retpoline call cannot also be a static_call. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151300.130805...@infradead.org --- tools/objtool/check.c | 34 tools/objtool/include/objtool/arch.h| 2 +- tools/objtool/include/objtool/check.h | 2 +- tools/objtool/include/objtool/objtool.h | 1 +- tools/objtool/objtool.c | 1 +- 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 600fa67..77074db 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -451,7 +451,7 @@ static int create_static_call_sections(struct objtool_file *file) return 0; idx = 0; - list_for_each_entry(insn, &file->static_call_list, static_call_node) + list_for_each_entry(insn, &file->static_call_list, call_node) idx++; sec = elf_create_section(file->elf, ".static_call_sites", SHF_WRITE, @@ -460,7 +460,7 @@ static int create_static_call_sections(struct objtool_file *file) return -1; idx = 0; - list_for_each_entry(insn, &file->static_call_list, static_call_node) { + list_for_each_entry(insn, &file->static_call_list, call_node) { site = (struct static_call_site *)sec->data->d_buf + idx; memset(site, 0, sizeof(struct static_call_site)); @@ -829,13 +829,16 @@ static int add_jump_destinations(struct objtool_file *file) else insn->type = INSN_JUMP_DYNAMIC_CONDITIONAL; + list_add_tail(&insn->call_node, + &file->retpoline_call_list); + insn->retpoline_safe = true; continue; } else if (insn->func) { /* internal or external sibling call (with reloc) */ insn->call_dest = reloc->sym; if (insn->call_dest->static_call_tramp) { - list_add_tail(&insn->static_call_node, + list_add_tail(&insn->call_node, &file->static_call_list); } continue; @@ -897,7 +900,7 @@ static int add_jump_destinations(struct objtool_file *file) /* internal sibling call (without reloc) */ insn->call_dest = insn->jump_dest->func; if (insn->call_dest->static_call_tramp) { - list_add_tail(&insn->static_call_node, + list_add_tail(&insn->call_node, &file->static_call_list); } } @@ -981,6 +984,9 @@ static int add_call_destinations(struct objtool_file *file) insn->type = INSN_CALL_DYNAMIC; insn->retpoline_safe = true; + list_add_tail(&insn->call_node, + &file->retpoline_call_list); + remove_insn_ops(insn); continue; @@ -988,7 +994,7 @@ static int add_call_destinations(struct objtool_file *file) insn->call_dest = reloc->sym; if (insn->call_dest && insn->call_dest->static_call_tramp) { - list_add_tail(&insn->static_call_node, + list_add_tail(&insn->call_node, &file->static_call_list); } @@ -1714,6 +1720,11 @@ static void mark_rodata(struct objtool_file *file) file->rodata = found; } +__weak int arch_rewrite_retpolines(struct objtool_file *file) +{ + return 0; +} + static int decode_sections(struct objtool_file *file) { int ret; @@ -1742,6 +1753,10 @@ static int decode_sections(struct objtool_file *file) if (ret) return ret; + /* +* Must be before add_special_section_alts() as that depends on +* jump_dest being set. +*/
[tip: x86/core] objtool/x86: Rewrite retpoline thunk calls
The following commit has been merged into the x86/core branch of tip: Commit-ID: 9bc0bb50727c8ac69fbb33fb937431cf3518ff37 Gitweb: https://git.kernel.org/tip/9bc0bb50727c8ac69fbb33fb937431cf3518ff37 Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:15 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:47:28 +02:00 objtool/x86: Rewrite retpoline thunk calls When the compiler emits: "CALL __x86_indirect_thunk_\reg" for an indirect call, have objtool rewrite it to: ALTERNATIVE "call __x86_indirect_thunk_\reg", "call *%reg", ALT_NOT(X86_FEATURE_RETPOLINE) Additionally, in order to not emit endless identical .altinst_replacement chunks, use a global symbol for them, see __x86_indirect_alt_*. This also avoids objtool from having to do code generation. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151300.320177...@infradead.org --- arch/x86/include/asm/asm-prototypes.h | 12 ++- arch/x86/lib/retpoline.S | 41 - tools/objtool/arch/x86/decode.c | 117 +- 3 files changed, 167 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/asm-prototypes.h b/arch/x86/include/asm/asm-prototypes.h index 0545b07..4cb726c 100644 --- a/arch/x86/include/asm/asm-prototypes.h +++ b/arch/x86/include/asm/asm-prototypes.h @@ -19,11 +19,19 @@ extern void cmpxchg8b_emu(void); #ifdef CONFIG_RETPOLINE -#define DECL_INDIRECT_THUNK(reg) \ +#undef GEN +#define GEN(reg) \ extern asmlinkage void __x86_indirect_thunk_ ## reg (void); +#include + +#undef GEN +#define GEN(reg) \ + extern asmlinkage void __x86_indirect_alt_call_ ## reg (void); +#include #undef GEN -#define GEN(reg) DECL_INDIRECT_THUNK(reg) +#define GEN(reg) \ + extern asmlinkage void __x86_indirect_alt_jmp_ ## reg (void); #include #endif /* CONFIG_RETPOLINE */ diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S index d2c0d14..4d32cb0 100644 --- a/arch/x86/lib/retpoline.S +++ b/arch/x86/lib/retpoline.S @@ -10,6 +10,8 @@ #include #include + .section .text.__x86.indirect_thunk + .macro RETPOLINE reg ANNOTATE_INTRA_FUNCTION_CALL call.Ldo_rop_\@ @@ -25,9 +27,9 @@ .endm .macro THUNK reg - .section .text.__x86.indirect_thunk .align 32 + SYM_FUNC_START(__x86_indirect_thunk_\reg) ALTERNATIVE_2 __stringify(ANNOTATE_RETPOLINE_SAFE; jmp *%\reg), \ @@ -39,6 +41,32 @@ SYM_FUNC_END(__x86_indirect_thunk_\reg) .endm /* + * This generates .altinstr_replacement symbols for use by objtool. They, + * however, must not actually live in .altinstr_replacement since that will be + * discarded after init, but module alternatives will also reference these + * symbols. + * + * Their names matches the "__x86_indirect_" prefix to mark them as retpolines. + */ +.macro ALT_THUNK reg + + .align 1 + +SYM_FUNC_START_NOALIGN(__x86_indirect_alt_call_\reg) + ANNOTATE_RETPOLINE_SAFE +1: call*%\reg +2: .skip 5-(2b-1b), 0x90 +SYM_FUNC_END(__x86_indirect_alt_call_\reg) + +SYM_FUNC_START_NOALIGN(__x86_indirect_alt_jmp_\reg) + ANNOTATE_RETPOLINE_SAFE +1: jmp *%\reg +2: .skip 5-(2b-1b), 0x90 +SYM_FUNC_END(__x86_indirect_alt_jmp_\reg) + +.endm + +/* * Despite being an assembler file we can't just use .irp here * because __KSYM_DEPS__ only uses the C preprocessor and would * only see one instance of "__x86_indirect_thunk_\reg" rather @@ -61,3 +89,14 @@ SYM_FUNC_END(__x86_indirect_thunk_\reg) #define GEN(reg) EXPORT_THUNK(reg) #include +#undef GEN +#define GEN(reg) ALT_THUNK reg +#include + +#undef GEN +#define GEN(reg) __EXPORT_THUNK(__x86_indirect_alt_call_ ## reg) +#include + +#undef GEN +#define GEN(reg) __EXPORT_THUNK(__x86_indirect_alt_jmp_ ## reg) +#include diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index 782894e..7e8b5be 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -19,6 +19,7 @@ #include #include #include +#include static unsigned char op_to_cfi_reg[][2] = { {CFI_AX, CFI_R8}, @@ -613,6 +614,122 @@ const char *arch_nop_insn(int len) return nops[len-1]; } +/* asm/alternative.h ? */ + +#define ALTINSTR_FLAG_INV (1 << 15) +#define ALT_NOT(feat) ((feat) | ALTINSTR_FLAG_INV) + +struct alt_instr { + s32 instr_offset; /* original instruction */ + s32 repl_offset;/* offset to replacement instruction */ + u16 cpuid; /* cpuid bit set for replacement */ + u8 instrlen; /* length of original instruction */ + u8 replacementlen; /* length of new instruction */ +} __packed; + +static int elf_add_alternative(struct elf *elf, + struct instruction *orig, struct symbol *sym, +
[tip: x86/core] objtool: Extract elf_strtab_concat()
The following commit has been merged into the x86/core branch of tip: Commit-ID: 417a4dc91e559f92404c2544f785b02ce75784c3 Gitweb: https://git.kernel.org/tip/417a4dc91e559f92404c2544f785b02ce75784c3 Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:09 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:44:56 +02:00 objtool: Extract elf_strtab_concat() Create a common helper to append strings to a strtab. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151259.941474...@infradead.org --- tools/objtool/elf.c | 60 +++- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 7b65ae3..c278a04 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -673,13 +673,48 @@ err: return NULL; } +static int elf_add_string(struct elf *elf, struct section *strtab, char *str) +{ + Elf_Data *data; + Elf_Scn *s; + int len; + + if (!strtab) + strtab = find_section_by_name(elf, ".strtab"); + if (!strtab) { + WARN("can't find .strtab section"); + return -1; + } + + s = elf_getscn(elf->elf, strtab->idx); + if (!s) { + WARN_ELF("elf_getscn"); + return -1; + } + + data = elf_newdata(s); + if (!data) { + WARN_ELF("elf_newdata"); + return -1; + } + + data->d_buf = str; + data->d_size = strlen(str) + 1; + data->d_align = 1; + + len = strtab->len; + strtab->len += data->d_size; + strtab->changed = true; + + return len; +} + struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr) { struct section *sec, *shstrtab; size_t size = entsize * nr; Elf_Scn *s; - Elf_Data *data; sec = malloc(sizeof(*sec)); if (!sec) { @@ -736,7 +771,6 @@ struct section *elf_create_section(struct elf *elf, const char *name, sec->sh.sh_addralign = 1; sec->sh.sh_flags = SHF_ALLOC | sh_flags; - /* Add section name to .shstrtab (or .strtab for Clang) */ shstrtab = find_section_by_name(elf, ".shstrtab"); if (!shstrtab) @@ -745,27 +779,9 @@ struct section *elf_create_section(struct elf *elf, const char *name, WARN("can't find .shstrtab or .strtab section"); return NULL; } - - s = elf_getscn(elf->elf, shstrtab->idx); - if (!s) { - WARN_ELF("elf_getscn"); + sec->sh.sh_name = elf_add_string(elf, shstrtab, sec->name); + if (sec->sh.sh_name == -1) return NULL; - } - - data = elf_newdata(s); - if (!data) { - WARN_ELF("elf_newdata"); - return NULL; - } - - data->d_buf = sec->name; - data->d_size = strlen(name) + 1; - data->d_align = 1; - - sec->sh.sh_name = shstrtab->len; - - shstrtab->len += strlen(name) + 1; - shstrtab->changed = true; list_add_tail(&sec->list, &elf->sections); elf_hash_add(elf->section_hash, &sec->hash, sec->idx);
[tip: x86/core] objtool: Extract elf_symbol_add()
The following commit has been merged into the x86/core branch of tip: Commit-ID: 9a7827b7789c630c1efdb121daa42c6e77dce97f Gitweb: https://git.kernel.org/tip/9a7827b7789c630c1efdb121daa42c6e77dce97f Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:10 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:45:01 +02:00 objtool: Extract elf_symbol_add() Create a common helper to add symbols. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151300.003468...@infradead.org --- tools/objtool/elf.c | 56 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index c278a04..8457218 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -290,12 +290,39 @@ static int read_sections(struct elf *elf) return 0; } +static void elf_add_symbol(struct elf *elf, struct symbol *sym) +{ + struct list_head *entry; + struct rb_node *pnode; + + sym->type = GELF_ST_TYPE(sym->sym.st_info); + sym->bind = GELF_ST_BIND(sym->sym.st_info); + + sym->offset = sym->sym.st_value; + sym->len = sym->sym.st_size; + + rb_add(&sym->node, &sym->sec->symbol_tree, symbol_to_offset); + pnode = rb_prev(&sym->node); + if (pnode) + entry = &rb_entry(pnode, struct symbol, node)->list; + else + entry = &sym->sec->symbol_list; + list_add(&sym->list, entry); + elf_hash_add(elf->symbol_hash, &sym->hash, sym->idx); + elf_hash_add(elf->symbol_name_hash, &sym->name_hash, str_hash(sym->name)); + + /* +* Don't store empty STT_NOTYPE symbols in the rbtree. They +* can exist within a function, confusing the sorting. +*/ + if (!sym->len) + rb_erase(&sym->node, &sym->sec->symbol_tree); +} + static int read_symbols(struct elf *elf) { struct section *symtab, *symtab_shndx, *sec; struct symbol *sym, *pfunc; - struct list_head *entry; - struct rb_node *pnode; int symbols_nr, i; char *coldstr; Elf_Data *shndx_data = NULL; @@ -340,9 +367,6 @@ static int read_symbols(struct elf *elf) goto err; } - sym->type = GELF_ST_TYPE(sym->sym.st_info); - sym->bind = GELF_ST_BIND(sym->sym.st_info); - if ((sym->sym.st_shndx > SHN_UNDEF && sym->sym.st_shndx < SHN_LORESERVE) || (shndx_data && sym->sym.st_shndx == SHN_XINDEX)) { @@ -355,32 +379,14 @@ static int read_symbols(struct elf *elf) sym->name); goto err; } - if (sym->type == STT_SECTION) { + if (GELF_ST_TYPE(sym->sym.st_info) == STT_SECTION) { sym->name = sym->sec->name; sym->sec->sym = sym; } } else sym->sec = find_section_by_index(elf, 0); - sym->offset = sym->sym.st_value; - sym->len = sym->sym.st_size; - - rb_add(&sym->node, &sym->sec->symbol_tree, symbol_to_offset); - pnode = rb_prev(&sym->node); - if (pnode) - entry = &rb_entry(pnode, struct symbol, node)->list; - else - entry = &sym->sec->symbol_list; - list_add(&sym->list, entry); - elf_hash_add(elf->symbol_hash, &sym->hash, sym->idx); - elf_hash_add(elf->symbol_name_hash, &sym->name_hash, str_hash(sym->name)); - - /* -* Don't store empty STT_NOTYPE symbols in the rbtree. They -* can exist within a function, confusing the sorting. -*/ - if (!sym->len) - rb_erase(&sym->node, &sym->sec->symbol_tree); + elf_add_symbol(elf, sym); } if (stats)
[tip: x86/core] objtool: Add elf_create_reloc() helper
The following commit has been merged into the x86/core branch of tip: Commit-ID: ef47cc01cb4abcd760d8ac66b9361d6ade4d0846 Gitweb: https://git.kernel.org/tip/ef47cc01cb4abcd760d8ac66b9361d6ade4d0846 Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:07 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:44:18 +02:00 objtool: Add elf_create_reloc() helper We have 4 instances of adding a relocation. Create a common helper to avoid growing even more. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151259.817438...@infradead.org --- tools/objtool/check.c | 78 + tools/objtool/elf.c | 86 ++-- tools/objtool/include/objtool/elf.h | 10 ++- tools/objtool/orc_gen.c | 30 ++ 4 files changed, 85 insertions(+), 119 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 1d0415b..61fe29a 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -433,8 +433,7 @@ reachable: static int create_static_call_sections(struct objtool_file *file) { - struct section *sec, *reloc_sec; - struct reloc *reloc; + struct section *sec; struct static_call_site *site; struct instruction *insn; struct symbol *key_sym; @@ -460,8 +459,7 @@ static int create_static_call_sections(struct objtool_file *file) if (!sec) return -1; - reloc_sec = elf_create_reloc_section(file->elf, sec, SHT_RELA); - if (!reloc_sec) + if (!elf_create_reloc_section(file->elf, sec, SHT_RELA)) return -1; idx = 0; @@ -471,25 +469,11 @@ static int create_static_call_sections(struct objtool_file *file) memset(site, 0, sizeof(struct static_call_site)); /* populate reloc for 'addr' */ - reloc = malloc(sizeof(*reloc)); - - if (!reloc) { - perror("malloc"); - return -1; - } - memset(reloc, 0, sizeof(*reloc)); - - insn_to_reloc_sym_addend(insn->sec, insn->offset, reloc); - if (!reloc->sym) { - WARN_FUNC("static call tramp: missing containing symbol", - insn->sec, insn->offset); + if (elf_add_reloc_to_insn(file->elf, sec, + idx * sizeof(struct static_call_site), + R_X86_64_PC32, + insn->sec, insn->offset)) return -1; - } - - reloc->type = R_X86_64_PC32; - reloc->offset = idx * sizeof(struct static_call_site); - reloc->sec = reloc_sec; - elf_add_reloc(file->elf, reloc); /* find key symbol */ key_name = strdup(insn->call_dest->name); @@ -526,18 +510,11 @@ static int create_static_call_sections(struct objtool_file *file) free(key_name); /* populate reloc for 'key' */ - reloc = malloc(sizeof(*reloc)); - if (!reloc) { - perror("malloc"); + if (elf_add_reloc(file->elf, sec, + idx * sizeof(struct static_call_site) + 4, + R_X86_64_PC32, key_sym, + is_sibling_call(insn) * STATIC_CALL_SITE_TAIL)) return -1; - } - memset(reloc, 0, sizeof(*reloc)); - reloc->sym = key_sym; - reloc->addend = is_sibling_call(insn) ? STATIC_CALL_SITE_TAIL : 0; - reloc->type = R_X86_64_PC32; - reloc->offset = idx * sizeof(struct static_call_site) + 4; - reloc->sec = reloc_sec; - elf_add_reloc(file->elf, reloc); idx++; } @@ -547,8 +524,7 @@ static int create_static_call_sections(struct objtool_file *file) static int create_mcount_loc_sections(struct objtool_file *file) { - struct section *sec, *reloc_sec; - struct reloc *reloc; + struct section *sec; unsigned long *loc; struct instruction *insn; int idx; @@ -571,8 +547,7 @@ static int create_mcount_loc_sections(struct objtool_file *file) if (!sec) return -1; - reloc_sec = elf_create_reloc_section(file->elf, sec, SHT_RELA); - if (!reloc_sec) + if (!elf_create_reloc_section(file->elf, sec, SHT_RELA)) return -1; idx = 0; @@ -581,32 +556,11 @@ static int create_mcount_loc_sections(struct objtool_file *file) loc = (unsigned long *)sec->data->d_buf + idx; memset(loc, 0, sizeof(unsigned l
[tip: x86/core] objtool: Create reloc sections implicitly
The following commit has been merged into the x86/core branch of tip: Commit-ID: d0c5c4cc73da0b05b0d9e5f833f2d859e1b45f8e Gitweb: https://git.kernel.org/tip/d0c5c4cc73da0b05b0d9e5f833f2d859e1b45f8e Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:08 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:44:37 +02:00 objtool: Create reloc sections implicitly Have elf_add_reloc() create the relocation section implicitly. Suggested-by: Josh Poimboeuf Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151259.880174...@infradead.org --- tools/objtool/check.c | 6 -- tools/objtool/elf.c | 9 - tools/objtool/include/objtool/elf.h | 1 - tools/objtool/orc_gen.c | 2 -- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 61fe29a..600fa67 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -459,9 +459,6 @@ static int create_static_call_sections(struct objtool_file *file) if (!sec) return -1; - if (!elf_create_reloc_section(file->elf, sec, SHT_RELA)) - return -1; - idx = 0; list_for_each_entry(insn, &file->static_call_list, static_call_node) { @@ -547,9 +544,6 @@ static int create_mcount_loc_sections(struct objtool_file *file) if (!sec) return -1; - if (!elf_create_reloc_section(file->elf, sec, SHT_RELA)) - return -1; - idx = 0; list_for_each_entry(insn, &file->mcount_loc_list, mcount_loc_node) { diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 0ab52ac..7b65ae3 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -447,11 +447,18 @@ err: return -1; } +static struct section *elf_create_reloc_section(struct elf *elf, + struct section *base, + int reltype); + int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset, unsigned int type, struct symbol *sym, int addend) { struct reloc *reloc; + if (!sec->reloc && !elf_create_reloc_section(elf, sec, SHT_RELA)) + return -1; + reloc = malloc(sizeof(*reloc)); if (!reloc) { perror("malloc"); @@ -829,7 +836,7 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec return sec; } -struct section *elf_create_reloc_section(struct elf *elf, +static struct section *elf_create_reloc_section(struct elf *elf, struct section *base, int reltype) { diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h index 825ad32..463f329 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -122,7 +122,6 @@ static inline u32 reloc_hash(struct reloc *reloc) struct elf *elf_open_read(const char *name, int flags); struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr); -struct section *elf_create_reloc_section(struct elf *elf, struct section *base, int reltype); int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset, unsigned int type, struct symbol *sym, int addend); diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c index 1b57be6..dc9b7dd 100644 --- a/tools/objtool/orc_gen.c +++ b/tools/objtool/orc_gen.c @@ -225,8 +225,6 @@ int orc_create(struct objtool_file *file) sec = elf_create_section(file->elf, ".orc_unwind_ip", 0, sizeof(int), nr); if (!sec) return -1; - if (!elf_create_reloc_section(file->elf, sec, SHT_RELA)) - return -1; /* Write ORC entries to sections: */ list_for_each_entry(entry, &orc_list, list) {
[tip: x86/core] objtool: Fix static_call list generation
The following commit has been merged into the x86/core branch of tip: Commit-ID: a958c4fea768d2c378c89032ab41d38da2a24422 Gitweb: https://git.kernel.org/tip/a958c4fea768d2c378c89032ab41d38da2a24422 Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:05 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:43:19 +02:00 objtool: Fix static_call list generation Currently, objtool generates tail call entries in add_jump_destination() but waits until validate_branch() to generate the regular call entries. Move these to add_call_destination() for consistency. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151259.691529...@infradead.org --- tools/objtool/check.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 6fbc001..8618d03 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1045,6 +1045,11 @@ static int add_call_destinations(struct objtool_file *file) } else insn->call_dest = reloc->sym; + if (insn->call_dest && insn->call_dest->static_call_tramp) { + list_add_tail(&insn->static_call_node, + &file->static_call_list); + } + /* * Many compilers cannot disable KCOV with a function attribute * so they need a little help, NOP out any KCOV calls from noinstr @@ -1788,6 +1793,9 @@ static int decode_sections(struct objtool_file *file) if (ret) return ret; + /* +* Must be before add_{jump_call}_destination. +*/ ret = read_static_call_tramps(file); if (ret) return ret; @@ -1800,6 +1808,10 @@ static int decode_sections(struct objtool_file *file) if (ret) return ret; + /* +* Must be before add_call_destination(); it changes INSN_CALL to +* INSN_JUMP. +*/ ret = read_intra_function_calls(file); if (ret) return ret; @@ -2762,11 +2774,6 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, if (dead_end_function(file, insn->call_dest)) return 0; - if (insn->type == INSN_CALL && insn->call_dest->static_call_tramp) { - list_add_tail(&insn->static_call_node, - &file->static_call_list); - } - break; case INSN_JUMP_CONDITIONAL:
[tip: x86/core] objtool: Correctly handle retpoline thunk calls
The following commit has been merged into the x86/core branch of tip: Commit-ID: bcb1b6ff39da7e8a6a986eb08126fba2b5e13c32 Gitweb: https://git.kernel.org/tip/bcb1b6ff39da7e8a6a986eb08126fba2b5e13c32 Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:03 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:42:54 +02:00 objtool: Correctly handle retpoline thunk calls Just like JMP handling, convert a direct CALL to a retpoline thunk into a retpoline safe indirect CALL. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151259.567568...@infradead.org --- tools/objtool/check.c | 12 1 file changed, 12 insertions(+) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index d45f018..519af4b 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1025,6 +1025,18 @@ static int add_call_destinations(struct objtool_file *file) dest_off); return -1; } + + } else if (!strncmp(reloc->sym->name, "__x86_indirect_thunk_", 21)) { + /* +* Retpoline calls are really dynamic calls in +* disguise, so convert them accordingly. +*/ + insn->type = INSN_CALL_DYNAMIC; + insn->retpoline_safe = true; + + remove_insn_ops(insn); + continue; + } else insn->call_dest = reloc->sym;
[tip: x86/core] objtool: Handle per arch retpoline naming
The following commit has been merged into the x86/core branch of tip: Commit-ID: 530b4ddd9dd92b263081f5c7786d39a8129c8b2d Gitweb: https://git.kernel.org/tip/530b4ddd9dd92b263081f5c7786d39a8129c8b2d Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:04 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:43:02 +02:00 objtool: Handle per arch retpoline naming The __x86_indirect_ naming is obviously not generic. Shorten to allow matching some additional magic names later. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151259.630296...@infradead.org --- tools/objtool/arch/x86/decode.c | 5 + tools/objtool/check.c| 9 +++-- tools/objtool/include/objtool/arch.h | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index ba9ebff..782894e 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -648,3 +648,8 @@ int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg) return 0; } + +bool arch_is_retpoline(struct symbol *sym) +{ + return !strncmp(sym->name, "__x86_indirect_", 15); +} diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 519af4b..6fbc001 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -850,6 +850,11 @@ static int add_ignore_alternatives(struct objtool_file *file) return 0; } +__weak bool arch_is_retpoline(struct symbol *sym) +{ + return false; +} + /* * Find the destination instructions for all jumps. */ @@ -872,7 +877,7 @@ static int add_jump_destinations(struct objtool_file *file) } else if (reloc->sym->type == STT_SECTION) { dest_sec = reloc->sym->sec; dest_off = arch_dest_reloc_offset(reloc->addend); - } else if (!strncmp(reloc->sym->name, "__x86_indirect_thunk_", 21)) { + } else if (arch_is_retpoline(reloc->sym)) { /* * Retpoline jumps are really dynamic jumps in * disguise, so convert them accordingly. @@ -1026,7 +1031,7 @@ static int add_call_destinations(struct objtool_file *file) return -1; } - } else if (!strncmp(reloc->sym->name, "__x86_indirect_thunk_", 21)) { + } else if (arch_is_retpoline(reloc->sym)) { /* * Retpoline calls are really dynamic calls in * disguise, so convert them accordingly. diff --git a/tools/objtool/include/objtool/arch.h b/tools/objtool/include/objtool/arch.h index 6ff0685..bb30993 100644 --- a/tools/objtool/include/objtool/arch.h +++ b/tools/objtool/include/objtool/arch.h @@ -86,4 +86,6 @@ const char *arch_nop_insn(int len); int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg); +bool arch_is_retpoline(struct symbol *sym); + #endif /* _ARCH_H */
[tip: x86/core] x86/retpoline: Simplify retpolines
The following commit has been merged into the x86/core branch of tip: Commit-ID: 119251855f9adf9421cb5eb409933092141ab2c7 Gitweb: https://git.kernel.org/tip/119251855f9adf9421cb5eb409933092141ab2c7 Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:02 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:42:04 +02:00 x86/retpoline: Simplify retpolines Due to: c9c324dc22aa ("objtool: Support stack layout changes in alternatives") it is now possible to simplify the retpolines. Currently our retpolines consist of 2 symbols: - __x86_indirect_thunk_\reg: the compiler target - __x86_retpoline_\reg: the actual retpoline. Both are consecutive in code and aligned such that for any one register they both live in the same cacheline: <__x86_indirect_thunk_rax>: 0: ff e0 jmpq *%rax 2: 90 nop 3: 90 nop 4: 90 nop 0005 <__x86_retpoline_rax>: 5: e8 07 00 00 00 callq 11 <__x86_retpoline_rax+0xc> a: f3 90 pause c: 0f ae e8lfence f: eb f9 jmpa <__x86_retpoline_rax+0x5> 11: 48 89 04 24 mov%rax,(%rsp) 15: c3 retq 16: 66 2e 0f 1f 84 00 00 00 00 00 nopw %cs:0x0(%rax,%rax,1) The thunk is an alternative_2, where one option is a JMP to the retpoline. This was done so that objtool didn't need to deal with alternatives with stack ops. But that problem has been solved, so now it is possible to fold the entire retpoline into the alternative to simplify and consolidate unused bytes: <__x86_indirect_thunk_rax>: 0: ff e0 jmpq *%rax 2: 90 nop 3: 90 nop 4: 90 nop 5: 90 nop 6: 90 nop 7: 90 nop 8: 90 nop 9: 90 nop a: 90 nop b: 90 nop c: 90 nop d: 90 nop e: 90 nop f: 90 nop 10: 90 nop 11: 66 66 2e 0f 1f 84 00 00 00 00 00data16 nopw %cs:0x0(%rax,%rax,1) 1c: 0f 1f 40 00 nopl 0x0(%rax) Notice that since the longest alternative sequence is now: 0: e8 07 00 00 00 callq c <.altinstr_replacement+0xc> 5: f3 90 pause 7: 0f ae e8lfence a: eb f9 jmp5 <.altinstr_replacement+0x5> c: 48 89 04 24 mov%rax,(%rsp) 10: c3 retq 17 bytes, we have 15 bytes NOP at the end of our 32 byte slot. (IOW, if we can shrink the retpoline by 1 byte we can pack it more densely). [ bp: Massage commit message. ] Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Link: https://lkml.kernel.org/r/20210326151259.506071...@infradead.org --- arch/x86/include/asm/asm-prototypes.h | 7 +- arch/x86/include/asm/nospec-branch.h | 6 ++--- arch/x86/lib/retpoline.S | 34 +- tools/objtool/check.c | 3 +-- 4 files changed, 21 insertions(+), 29 deletions(-) diff --git a/arch/x86/include/asm/asm-prototypes.h b/arch/x86/include/asm/asm-prototypes.h index 51e2bf2..0545b07 100644 --- a/arch/x86/include/asm/asm-prototypes.h +++ b/arch/x86/include/asm/asm-prototypes.h @@ -22,15 +22,8 @@ extern void cmpxchg8b_emu(void); #define DECL_INDIRECT_THUNK(reg) \ extern asmlinkage void __x86_indirect_thunk_ ## reg (void); -#define DECL_RETPOLINE(reg) \ - extern asmlinkage void __x86_retpoline_ ## reg (void); - #undef GEN #define GEN(reg) DECL_INDIRECT_THUNK(reg) #include -#undef GEN -#define GEN(reg) DECL_RETPOLINE(reg) -#include - #endif /* CONFIG_RETPOLINE */ diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index 529f8e9..664be73 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -80,7 +80,7 @@ .macro JMP_NOSPEC reg:req #ifdef CONFIG_RETPOLINE ALTERNATIVE_2 __stringify(ANNOTATE_RETPOLINE_SAFE; jmp *%\reg), \ - __stringify(jmp __x86_retpoline_\reg), X86_FEATURE_RETPOLINE, \ + __stringify(jmp __x86_indirect_thunk_\reg), X86_FEATURE_RETPOLINE, \ __stringify(lfence; ANNOTATE_RETPOLINE_SAFE; jmp *%\reg), X86_FEATURE_RETPOLINE_AMD #else jmp *%\reg @@ -90,7 +90,7 @@ .macro CALL_NOSPEC reg:req #ifdef CONFIG_RETPOLINE ALTERNATIVE_2 __stringify(ANNOTATE_RETPOLINE_SAFE; call *%\reg), \ - __stringify(call __x86_retpoline_\reg), X86_FEATURE_RETPOLINE, \ +
[tip: x86/core] x86/alternatives: Optimize optimize_nops()
The following commit has been merged into the x86/core branch of tip: Commit-ID: 23c1ad538f4f371bdb67d8a112314842d5db7e5a Gitweb: https://git.kernel.org/tip/23c1ad538f4f371bdb67d8a112314842d5db7e5a Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:01 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:41:17 +02:00 x86/alternatives: Optimize optimize_nops() Currently, optimize_nops() scans to see if the alternative starts with NOPs. However, the emit pattern is: 141: \oldinstr 142: .skip (len-(142b-141b)), 0x90 That is, when 'oldinstr' is short, the tail is padded with NOPs. This case never gets optimized. Rewrite optimize_nops() to replace any trailing string of NOPs inside the alternative to larger NOPs. Also run it irrespective of patching, replacing NOPs in both the original and replaced code. A direct consequence is that 'padlen' becomes superfluous, so remove it. [ bp: - Adjust commit message - remove a stale comment about needing to pad - add a comment in optimize_nops() - exit early if the NOP verif. loop catches a mismatch - function should not not add NOPs in that case - fix the "optimized NOPs" offsets output ] Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Link: https://lkml.kernel.org/r/20210326151259.442992...@infradead.org --- arch/x86/include/asm/alternative.h| 17 +- arch/x86/kernel/alternative.c | 49 +++--- tools/objtool/arch/x86/include/arch/special.h | 2 +- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 17b3609..a3c2315 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -65,7 +65,6 @@ struct alt_instr { u16 cpuid; /* cpuid bit set for replacement */ u8 instrlen; /* length of original instruction */ u8 replacementlen; /* length of new instruction */ - u8 padlen; /* length of build-time padding */ } __packed; /* @@ -104,7 +103,6 @@ static inline int alternatives_text_reserved(void *start, void *end) #define alt_end_marker "663" #define alt_slen "662b-661b" -#define alt_pad_lenalt_end_marker"b-662b" #define alt_total_slen alt_end_marker"b-661b" #define alt_rlen(num) e_replacement(num)"f-"b_replacement(num)"f" @@ -151,8 +149,7 @@ static inline int alternatives_text_reserved(void *start, void *end) " .long " b_replacement(num)"f - .\n" /* new instruction */ \ " .word " __stringify(feature) "\n" /* feature bit */ \ " .byte " alt_total_slen "\n" /* source len */ \ - " .byte " alt_rlen(num) "\n"/* replacement len */ \ - " .byte " alt_pad_len "\n" /* pad len */ + " .byte " alt_rlen(num) "\n"/* replacement len */ #define ALTINSTR_REPLACEMENT(newinstr, num)/* replacement */ \ "# ALT: replacement " #num "\n" \ @@ -224,9 +221,6 @@ static inline int alternatives_text_reserved(void *start, void *end) * Peculiarities: * No memory clobber here. * Argument numbers start with 1. - * Best is to use constraints that are fixed size (like (%1) ... "r") - * If you use variable sized constraints like "m" or "g" in the - * replacement make sure to pad to the worst case length. * Leaving an unused argument 0 to keep API compatibility. */ #define alternative_input(oldinstr, newinstr, feature, input...) \ @@ -315,13 +309,12 @@ static inline int alternatives_text_reserved(void *start, void *end) * enough information for the alternatives patching code to patch an * instruction. See apply_alternatives(). */ -.macro altinstruction_entry orig alt feature orig_len alt_len pad_len +.macro altinstruction_entry orig alt feature orig_len alt_len .long \orig - . .long \alt - . .word \feature .byte \orig_len .byte \alt_len - .byte \pad_len .endm /* @@ -338,7 +331,7 @@ static inline int alternatives_text_reserved(void *start, void *end) 142: .pushsection .altinstructions,"a" - altinstruction_entry 140b,143f,\feature,142b-140b,144f-143f,142b-141b + altinstruction_entry 140b,143f,\feature,142b-140b,144f-143f .popsection .pushsection .altinstr_replacement,"ax" @@ -375,8 +368,8 @@ static inline int alternatives_text_reserved(void *start, void *end) 142: .pushsection .altinstructions,"a" - altinstruction_entry 140b,143f,\feature1,142b-140b,144f-143f,142b-141b - altinstruction_entry 140b,144f,\feature2,142b-140b,145f-144f,142b-141b + altinstruction_entry 140b,143f,\feature1,142b-140b,144f-143f + altinstruction_entr
[tip: x86/core] objtool: Rework the elf_rebuild_reloc_section() logic
The following commit has been merged into the x86/core branch of tip: Commit-ID: 3a647607b57ad8346e659ddd3b951ac292c83690 Gitweb: https://git.kernel.org/tip/3a647607b57ad8346e659ddd3b951ac292c83690 Author:Peter Zijlstra AuthorDate:Fri, 26 Mar 2021 16:12:06 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 02 Apr 2021 12:43:32 +02:00 objtool: Rework the elf_rebuild_reloc_section() logic Instead of manually calling elf_rebuild_reloc_section() on sections we've called elf_add_reloc() on, have elf_write() DTRT. This makes it easier to add random relocations in places without carefully tracking when we're done and need to flush what section. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Signed-off-by: Ingo Molnar Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151259.754213...@infradead.org --- tools/objtool/check.c | 6 -- tools/objtool/elf.c | 20 ++-- tools/objtool/include/objtool/elf.h | 1 - tools/objtool/orc_gen.c | 3 --- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 8618d03..1d0415b 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -542,9 +542,6 @@ static int create_static_call_sections(struct objtool_file *file) idx++; } - if (elf_rebuild_reloc_section(file->elf, reloc_sec)) - return -1; - return 0; } @@ -614,9 +611,6 @@ static int create_mcount_loc_sections(struct objtool_file *file) idx++; } - if (elf_rebuild_reloc_section(file->elf, reloc_sec)) - return -1; - return 0; } diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 93fa833..374813e 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -479,6 +479,8 @@ void elf_add_reloc(struct elf *elf, struct reloc *reloc) list_add_tail(&reloc->list, &sec->reloc_list); elf_hash_add(elf->reloc_hash, &reloc->hash, reloc_hash(reloc)); + + sec->changed = true; } static int read_rel_reloc(struct section *sec, int i, struct reloc *reloc, unsigned int *symndx) @@ -558,7 +560,9 @@ static int read_relocs(struct elf *elf) return -1; } - elf_add_reloc(elf, reloc); + list_add_tail(&reloc->list, &sec->reloc_list); + elf_hash_add(elf->reloc_hash, &reloc->hash, reloc_hash(reloc)); + nr_reloc++; } max_reloc = max(max_reloc, nr_reloc); @@ -873,14 +877,11 @@ static int elf_rebuild_rela_reloc_section(struct section *sec, int nr) return 0; } -int elf_rebuild_reloc_section(struct elf *elf, struct section *sec) +static int elf_rebuild_reloc_section(struct elf *elf, struct section *sec) { struct reloc *reloc; int nr; - sec->changed = true; - elf->changed = true; - nr = 0; list_for_each_entry(reloc, &sec->reloc_list, list) nr++; @@ -944,9 +945,15 @@ int elf_write(struct elf *elf) struct section *sec; Elf_Scn *s; - /* Update section headers for changed sections: */ + /* Update changed relocation sections and section headers: */ list_for_each_entry(sec, &elf->sections, list) { if (sec->changed) { + if (sec->base && + elf_rebuild_reloc_section(elf, sec)) { + WARN("elf_rebuild_reloc_section"); + return -1; + } + s = elf_getscn(elf->elf, sec->idx); if (!s) { WARN_ELF("elf_getscn"); @@ -958,6 +965,7 @@ int elf_write(struct elf *elf) } sec->changed = false; + elf->changed = true; } } diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h index e6890cc..fc576ed 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -142,7 +142,6 @@ struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *se struct symbol *find_func_containing(struct section *sec, unsigned long offset); void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset, struct reloc *reloc); -int elf_rebuild_reloc_section(struct elf *elf, struct section *sec); #define for_each_sec(file, sec) \ list_for_each_entry(sec, &file->elf->sections, list) diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c index 738aa50..f534708 100644 --- a/tools/objtool/orc_gen.c +++ b/tools/objtool/orc_gen.c @@ -254,8 +254,5 @@ int orc_create(struct objto
[syzbot] WARNING: suspicious RCU usage in remove_vma (2)
Hello, syzbot found the following issue on: HEAD commit:1e43c377 Merge tag 'xtensa-20210329' of git://github.com/j.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1052e1d6d0 kernel config: https://syzkaller.appspot.com/x/.config?x=d1a3d65a48dbd1bc dashboard link: https://syzkaller.appspot.com/bug?extid=26ad5e106ca477175819 Unfortunately, I don't have any reproducer for this issue yet. IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+26ad5e106ca477175...@syzkaller.appspotmail.com = WARNING: suspicious RCU usage 5.12.0-rc5-syzkaller #0 Not tainted - kernel/sched/core.c:8294 Illegal context switch in RCU-bh read-side critical section! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 0 no locks held by syz-executor.0/29105. stack backtrace: CPU: 0 PID: 29105 Comm: syz-executor.0 Not tainted 5.12.0-rc5-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:79 [inline] dump_stack+0x141/0x1d7 lib/dump_stack.c:120 ___might_sleep+0x229/0x2c0 kernel/sched/core.c:8294 remove_vma+0x44/0x170 mm/mmap.c:178 exit_mmap+0x33f/0x590 mm/mmap.c:3229 __mmput+0x122/0x470 kernel/fork.c:1090 mmput+0x58/0x60 kernel/fork.c: exit_mm kernel/exit.c:501 [inline] do_exit+0xb0a/0x2a60 kernel/exit.c:812 do_group_exit+0x125/0x310 kernel/exit.c:922 get_signal+0x47f/0x2150 kernel/signal.c:2781 arch_do_signal_or_restart+0x2a8/0x1eb0 arch/x86/kernel/signal.c:789 handle_signal_work kernel/entry/common.c:147 [inline] exit_to_user_mode_loop kernel/entry/common.c:171 [inline] exit_to_user_mode_prepare+0x148/0x250 kernel/entry/common.c:208 __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline] syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x466459 Code: Unable to access opcode bytes at RIP 0x46642f. RSP: 002b:7fdfaa117218 EFLAGS: 0246 ORIG_RAX: 00ca RAX: RBX: 0056bf68 RCX: 00466459 RDX: RSI: 0080 RDI: 0056bf68 RBP: 0056bf60 R08: R09: R10: R11: 0246 R12: 0056bf6c R13: 7fff64c569cf R14: 7fdfaa117300 R15: 00022000 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkal...@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
[GIT PULL] Please pull powerpc/linux.git powerpc-5.12-5 tag
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Hi Linus, Please pull some more powerpc fixes for 5.12: The following changes since commit cc7a0bb058b85ea03db87169c60c7cfdd5d34678: PCI: rpadlpar: Fix potential drc_name corruption in store functions (2021-03-17 13:48:07 +1100) are available in the git repository at: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git tags/powerpc-5.12-5 for you to fetch changes up to 53f1d31708f6240e4615b0927df31f182e389e2f: powerpc/mm/book3s64: Use the correct storage key value when calling H_PROTECT (2021-03-26 22:19:39 +1100) - -- powerpc fixes for 5.12 #5 Fix a bug on pseries where spurious wakeups from H_PROD would prevent partition migration from succeeding. Fix oopses seen in pcpu_alloc(), caused by parallel faults of the percpu mapping causing us to corrupt the protection key used for the mapping, and cause a fatal key fault. Thanks to Aneesh Kumar K.V, Murilo Opsfelder Araujo, Nathan Lynch. - -- Aneesh Kumar K.V (1): powerpc/mm/book3s64: Use the correct storage key value when calling H_PROTECT Nathan Lynch (2): powerpc/pseries/mobility: use struct for shared state powerpc/pseries/mobility: handle premature return from H_JOIN arch/powerpc/platforms/pseries/lpar.c | 3 +- arch/powerpc/platforms/pseries/mobility.c | 48 ++-- 2 files changed, 46 insertions(+), 5 deletions(-) -BEGIN PGP SIGNATURE- iQIzBAEBCAAdFiEEJFGtCPCthwEv2Y/bUevqPMjhpYAFAmBoVTsACgkQUevqPMjh pYDlFxAAkkiy2RiHbaAlWHpVekXVQN1/oRISHQ+9jRco3BQUAEq8wHJNrlArnab6 N7C/ig2SiugagpLelRsXeXWyM54U3syIQnX3NRg82PgUBxU/LGJmIcyWCgDIf9x0 /xbMrWcRMuzY1x916rX7MPuSVc8LcyVu9nByBrbFWNE6IqUrJ0ngrBNNsEyWbEf/ NBHYqUzpurXYv/OHEPOQu9GIOWej5SR8oOKGn3/aJ66cg3WoC7iC56seBjSIrcLe zwhUenwRYM6YQ6boX0OBKs/NaPSeT9qy4JyZOe0Sqeo0Yvhj4VJs9W0napIYQde5 y6ieoyHk33xPawUWiTEtkLmvH2nZPVRXCfGOQmh5B4mvuS/rrv6hTeFkdLFZ74yJ Fuan/ljnXSPTkT+xRITrOO/irZyTaRXJ4j0Ck3LrtluUFib9psf+OqtoIiqqy11w u+E8T1GChRZTuy2iMZy1jiyvmKwa/S5v67YUU2xUXNYeRI8j3g3cPo/W9Skn3TS2 LiO5+/6Ws1ABn7TohGV2R7sTPu5AnJP7jyHVJuDbtf/Z79U1SMiNAOb8jA/8WNbW 0NtLSQsy1PHonsqUIJgJntmstA46Xnsr1ruA2wR7GEuaaBrjSynw9cG55KlA4Lug 16kaOFPBnJhvkgjTDI7Xl7+ktr4yuR5EriDI0wJMqbhxn+IJ5VM= =9cfb -END PGP SIGNATURE-
[PATCH net-next v1 1/9] net: dsa: add rcv_post call back
Some switches (for example ar9331) do not provide enough information about forwarded packets. If the switch decision was made based on IPv4 or IPv6 header, we need to analyze it and set proper flag. Potentially we can do it in existing rcv path, on other hand we can avoid part of duplicated work and let the dsa framework set skb header pointers and then use preprocessed skb one step later withing the rcv_post call back. This patch is needed for ar9331 switch. Signed-off-by: Oleksij Rempel --- include/net/dsa.h | 2 ++ net/dsa/dsa.c | 4 net/dsa/port.c| 1 + 3 files changed, 7 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index 57b2c49f72f4..f1a7aa4303a7 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -84,6 +84,7 @@ struct dsa_device_ops { struct sk_buff *(*xmit)(struct sk_buff *skb, struct net_device *dev); struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt); + void (*rcv_post)(struct sk_buff *skb); void (*flow_dissect)(const struct sk_buff *skb, __be16 *proto, int *offset); /* Used to determine which traffic should match the DSA filter in @@ -247,6 +248,7 @@ struct dsa_port { struct dsa_switch_tree *dst; struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt); + void (*rcv_post)(struct sk_buff *skb); bool (*filter)(const struct sk_buff *skb, struct net_device *dev); enum { diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 84cad1be9ce4..fa3e7201e760 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -249,6 +249,10 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev, skb->pkt_type = PACKET_HOST; skb->protocol = eth_type_trans(skb, skb->dev); + + if (cpu_dp->rcv_post) + cpu_dp->rcv_post(skb); + if (unlikely(!dsa_slave_dev_check(skb->dev))) { /* Packet is to be injected directly on an upper * device, e.g. a team/bond, so skip all DSA-port diff --git a/net/dsa/port.c b/net/dsa/port.c index 01e30264b25b..859957688c62 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -720,6 +720,7 @@ void dsa_port_set_tag_protocol(struct dsa_port *cpu_dp, { cpu_dp->filter = tag_ops->filter; cpu_dp->rcv = tag_ops->rcv; + cpu_dp->rcv_post = tag_ops->rcv_post; cpu_dp->tag_ops = tag_ops; } -- 2.29.2
[PATCH net-next v1 4/9] net: dsa: qca: ar9331: make proper initial port defaults
Make sure that all external port are actually isolated from each other, so no packets are leaked. Signed-off-by: Oleksij Rempel --- drivers/net/dsa/qca/ar9331.c | 145 ++- 1 file changed, 143 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c index 9a5035b2f0ff..a3de3598fbf5 100644 --- a/drivers/net/dsa/qca/ar9331.c +++ b/drivers/net/dsa/qca/ar9331.c @@ -60,10 +60,19 @@ #define AR9331_SW_REG_FLOOD_MASK 0x2c #define AR9331_SW_FLOOD_MASK_BROAD_TO_CPU BIT(26) +#define AR9331_SW_FLOOD_MASK_MULTI_FLOOD_DPGENMASK(20, 16) +#define AR9331_SW_FLOOD_MASK_UNI_FLOOD_DP GENMASK(4, 0) #define AR9331_SW_REG_GLOBAL_CTRL 0x30 #define AR9331_SW_GLOBAL_CTRL_MFS_MGENMASK(13, 0) +#define AR9331_SW_REG_ADDR_TABLE_CTRL 0x5c +#define AR9331_SW_AT_ARP_ENBIT(20) +#define AR9331_SW_AT_LEARN_CHANGE_EN BIT(18) +#define AR9331_SW_AT_AGE_ENBIT(17) +#define AR9331_SW_AT_AGE_TIME GENMASK(15, 0) +#define AR9331_SW_AT_AGE_TIME_COEF 6900 /* Not documented */ + #define AR9331_SW_REG_MDIO_CTRL0x98 #define AR9331_SW_MDIO_CTRL_BUSY BIT(31) #define AR9331_SW_MDIO_CTRL_MASTER_EN BIT(30) @@ -101,6 +110,46 @@ AR9331_SW_PORT_STATUS_RX_FLOW_EN | AR9331_SW_PORT_STATUS_TX_FLOW_EN | \ AR9331_SW_PORT_STATUS_SPEED_M) +#define AR9331_SW_REG_PORT_CTRL(_port) (0x104 + (_port) * 0x100) +#define AR9331_SW_PORT_CTRL_ING_MIRROR_EN BIT(17) +#define AR9331_SW_PORT_CTRL_EG_MIRROR_EN BIT(16) +#define AR9331_SW_PORT_CTRL_DOUBLE_TAG_VLANBIT(15) +#define AR9331_SW_PORT_CTRL_LEARN_EN BIT(14) +#define AR9331_SW_PORT_CTRL_SINGLE_VLAN_EN BIT(13) +#define AR9331_SW_PORT_CTRL_MAC_LOOP_BACK BIT(12) +#define AR9331_SW_PORT_CTRL_HEAD_ENBIT(11) +#define AR9331_SW_PORT_CTRL_IGMP_MLD_ENBIT(10) +#define AR9331_SW_PORT_CTRL_EG_VLAN_MODE GENMASK(9, 8) +#define AR9331_SW_PORT_CTRL_EG_VLAN_MODE_KEEP 0 +#define AR9331_SW_PORT_CTRL_EG_VLAN_MODE_STRIP 1 +#define AR9331_SW_PORT_CTRL_EG_VLAN_MODE_ADD 2 +#define AR9331_SW_PORT_CTRL_EG_VLAN_MODE_DOUBLE3 +#define AR9331_SW_PORT_CTRL_LEARN_ONE_LOCK BIT(7) +#define AR9331_SW_PORT_CTRL_PORT_LOCK_EN BIT(6) +#define AR9331_SW_PORT_CTRL_LOCK_DROP_EN BIT(5) +#define AR9331_SW_PORT_CTRL_PORT_STATE GENMASK(2, 0) +#define AR9331_SW_PORT_CTRL_PORT_STATE_DISABLED0 +#define AR9331_SW_PORT_CTRL_PORT_STATE_BLOCKING1 +#define AR9331_SW_PORT_CTRL_PORT_STATE_LISTENING 2 +#define AR9331_SW_PORT_CTRL_PORT_STATE_LEARNING3 +#define AR9331_SW_PORT_CTRL_PORT_STATE_FORWARD 4 + +#define AR9331_SW_REG_PORT_VLAN(_port) (0x108 + (_port) * 0x100) +#define AR9331_SW_PORT_VLAN_8021Q_MODE GENMASK(31, 30) +#define AR9331_SW_8021Q_MODE_SECURE3 +#define AR9331_SW_8021Q_MODE_CHECK 2 +#define AR9331_SW_8021Q_MODE_FALLBACK 1 +#define AR9331_SW_8021Q_MODE_NONE 0 +#define AR9331_SW_PORT_VLAN_ING_PORT_PRI GENMASK(29, 27) +#define AR9331_SW_PORT_VLAN_FORCE_PORT_VLAN_EN BIT(26) +#define AR9331_SW_PORT_VLAN_PORT_VID_MEMBERGENMASK(25, 16) +#define AR9331_SW_PORT_VLAN_ARP_LEAKY_EN BIT(15) +#define AR9331_SW_PORT_VLAN_UNI_LEAKY_EN BIT(14) +#define AR9331_SW_PORT_VLAN_MULTI_LEAKY_EN BIT(13) +#define AR9331_SW_PORT_VLAN_FORCE_DEFALUT_VID_EN BIT(12) +#define AR9331_SW_PORT_VLAN_PORT_VID GENMASK(11, 0) +#define AR9331_SW_PORT_VLAN_PORT_VID_DEF 1 + /* MIB registers */ #define AR9331_MIB_COUNTER(x) (0x2 + ((x) * 0x100)) @@ -229,6 +278,7 @@ struct ar9331_sw_priv { struct regmap *regmap; struct reset_control *sw_reset; struct ar9331_sw_port port[AR9331_SW_PORTS]; + int cpu_port; }; static struct ar9331_sw_priv *ar9331_sw_port_to_priv(struct ar9331_sw_port *port) @@ -371,12 +421,72 @@ static int ar9331_sw_mbus_init(struct ar9331_sw_priv *priv) return 0; } -static int ar9331_sw_setup(struct dsa_switch *ds) +static int ar9331_sw_setup_port(struct dsa_switch *ds, int port) { struct ar9331_sw_priv *priv = (struct ar9331_sw_priv *)ds->priv; struct regmap *regmap = priv->regmap; + u32 port_mask, port_ctrl, val; int ret; + /* Generate default port settings */ + port_ctrl = FIELD_PREP(AR9331_SW_PORT_CTRL_PORT_STATE, + AR9331_SW_PORT_CTRL_PORT_STATE_DISABLED); + + if (dsa_is_cpu_port(ds, port)) { + /* +
[PATCH net-next v1 0/9] ar9331: mainline some parts of switch functionality
Till now the ar9331 switch was supporting only port multiplexing mode. With this patch set we should be able to bridging, VLAN and STP Oleksij Rempel (9): net: dsa: add rcv_post call back net: dsa: tag_ar9331: detect IGMP and MLD packets net: dsa: qca: ar9331: reorder MDIO write sequence net: dsa: qca: ar9331: make proper initial port defaults net: dsa: qca: ar9331: add forwarding database support net: dsa: qca: ar9331: add ageing time support net: dsa: qca: ar9331: add bridge support net: dsa: qca: ar9331: add STP support net: dsa: qca: ar9331: add vlan support drivers/net/dsa/qca/ar9331.c | 927 ++- include/net/dsa.h| 2 + net/dsa/dsa.c| 4 + net/dsa/port.c | 1 + net/dsa/tag_ar9331.c | 130 + 5 files changed, 1059 insertions(+), 5 deletions(-) -- 2.29.2
[PATCH net-next v1 9/9] net: dsa: qca: ar9331: add vlan support
This switch provides simple VLAN resolution database for 16 entries (VLANs). With this database we can cover typical functionalities as port based VLANs, untagged and tagged egress. Port based ingress filtering. The VLAN database is working on top of forwarding database. So, potentially, we can have multiple VLANs on top of multiple bridges. Hawing one VLAN on top of multiple bridges will fail on different levels, most probably DSA framework should warn if some one wont to make something likes this. Signed-off-by: Oleksij Rempel --- drivers/net/dsa/qca/ar9331.c | 255 +++ 1 file changed, 255 insertions(+) diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c index 83b59e771a5f..40062388d4a7 100644 --- a/drivers/net/dsa/qca/ar9331.c +++ b/drivers/net/dsa/qca/ar9331.c @@ -67,6 +67,27 @@ #define AR9331_SW_REG_GLOBAL_CTRL 0x30 #define AR9331_SW_GLOBAL_CTRL_MFS_MGENMASK(13, 0) +#define AR9331_SW_NUM_VLAN_RECORDS 16 + +#define AR9331_SW_REG_VLAN_TABLE_FUNCTION0 0x40 +#define AR9331_SW_VT0_PRI_EN BIT(31) +#define AR9331_SW_VT0_PRI GENMASK(30, 28) +#define AR9331_SW_VT0_VID GENMASK(27, 16) +#define AR9331_SW_VT0_PORT_NUM GENMASK(11, 8) +#define AR9331_SW_VT0_FULL_VIO BIT(4) +#define AR9331_SW_VT0_BUSY BIT(3) +#define AR9331_SW_VT0_FUNC GENMASK(2, 0) +#define AR9331_SW_VT0_FUNC_NOP 0 +#define AR9331_SW_VT0_FUNC_FLUSH_ALL 1 +#define AR9331_SW_VT0_FUNC_LOAD_ENTRY 2 +#define AR9331_SW_VT0_FUNC_PURGE_ENTRY 3 +#define AR9331_SW_VT0_FUNC_DEL_PORT4 +#define AR9331_SW_VT0_FUNC_GET_NEXT5 + +#define AR9331_SW_REG_VLAN_TABLE_FUNCTION1 0x44 +#define AR9331_SW_VT1_VALIDBIT(11) +#define AR9331_SW_VT1_VID_MEM GENMASK(9, 0) + /* Size of the address resolution table (ARL) */ #define AR9331_SW_NUM_ARL_RECORDS 1024 @@ -308,6 +329,11 @@ struct ar9331_sw_port { struct spinlock stats_lock; }; +struct ar9331_sw_vlan_db { + u16 vid; + u8 port_mask; +}; + struct ar9331_sw_fdb { u8 port_mask; u8 aging; @@ -328,6 +354,7 @@ struct ar9331_sw_priv { struct ar9331_sw_port port[AR9331_SW_PORTS]; int cpu_port; u32 isolated_ports; + struct ar9331_sw_vlan_db vdb[AR9331_SW_NUM_VLAN_RECORDS]; }; static struct ar9331_sw_priv *ar9331_sw_port_to_priv(struct ar9331_sw_port *port) @@ -1273,6 +1300,231 @@ static void ar9331_sw_port_stp_state_set(struct dsa_switch *ds, int port, dev_err_ratelimited(priv->dev, "%s: error: %i\n", __func__, ret); } +static int ar9331_port_vlan_filtering(struct dsa_switch *ds, int port, + bool vlan_filtering, + struct netlink_ext_ack *extack) +{ + struct ar9331_sw_priv *priv = (struct ar9331_sw_priv *)ds->priv; + struct regmap *regmap = priv->regmap; + u32 mode; + int ret; + + if (vlan_filtering) + mode = AR9331_SW_8021Q_MODE_SECURE; + else + mode = AR9331_SW_8021Q_MODE_NONE; + + ret = regmap_update_bits(regmap, AR9331_SW_REG_PORT_VLAN(port), +AR9331_SW_PORT_VLAN_8021Q_MODE, +FIELD_PREP(AR9331_SW_PORT_VLAN_8021Q_MODE, + mode)); + if (ret) + dev_err_ratelimited(priv->dev, "%s: error: %pe\n", + __func__, ERR_PTR(ret)); + + return ret; +} + +static int ar9331_sw_vt_wait(struct ar9331_sw_priv *priv, u32 *f0) +{ + struct regmap *regmap = priv->regmap; + + return regmap_read_poll_timeout(regmap, + AR9331_SW_REG_VLAN_TABLE_FUNCTION0, + *f0, !(*f0 & AR9331_SW_VT0_BUSY), + 100, 2000); +} + +static int ar9331_sw_port_vt_rmw(struct ar9331_sw_priv *priv, u16 vid, +u8 port_mask_set, u8 port_mask_clr) +{ + struct regmap *regmap = priv->regmap; + u32 f0, f1, port_mask = 0, port_mask_new, func; + struct ar9331_sw_vlan_db *vdb = NULL; + int ret, i; + + if (!vid) + return 0; + + ret = ar9331_sw_vt_wait(priv, &f0); + if (ret) + return ret; + + ret = regmap_write(regmap, AR9331_SW_REG_VLAN_TABLE_FUNCTION0, 0); + if (ret) + goto error; + + ret = regmap_write(regmap, AR9331_SW_REG_VLAN_TABLE_FUNCTION1, 0); + if (ret) + goto error; + + for (i = 0; i < ARRAY_SIZE(priv->vdb); i++) { + if (priv->vdb[i].vid == vid) { + vdb = &priv->vdb[i]; + break; + } + } + +
[PATCH net-next v1 8/9] net: dsa: qca: ar9331: add STP support
According to the datasheet, this switch has configurable STP port states. Suddenly LISTENING and BLOCKING states didn't forwarded packets to the CPU and linux bridge continuously re enabled ports even if a loop was detected. To make it work, I reused bridge functionality to isolate port in LISTENING and BLOCKING states. Signed-off-by: Oleksij Rempel --- drivers/net/dsa/qca/ar9331.c | 69 1 file changed, 69 insertions(+) diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c index bf9588574205..83b59e771a5f 100644 --- a/drivers/net/dsa/qca/ar9331.c +++ b/drivers/net/dsa/qca/ar9331.c @@ -327,6 +327,7 @@ struct ar9331_sw_priv { struct reset_control *sw_reset; struct ar9331_sw_port port[AR9331_SW_PORTS]; int cpu_port; + u32 isolated_ports; }; static struct ar9331_sw_priv *ar9331_sw_port_to_priv(struct ar9331_sw_port *port) @@ -1151,6 +1152,10 @@ static int ar9331_sw_port_bridge_join(struct dsa_switch *ds, int port, if (!dsa_is_user_port(ds, port)) continue; + /* part of the bridge but should be isolated for now */ + if (priv->isolated_ports & BIT(i)) + continue; + val = FIELD_PREP(AR9331_SW_PORT_VLAN_PORT_VID_MEMBER, BIT(port)); ret = regmap_set_bits(regmap, AR9331_SW_REG_PORT_VLAN(i), val); if (ret) @@ -1205,6 +1210,69 @@ static void ar9331_sw_port_bridge_leave(struct dsa_switch *ds, int port, dev_err_ratelimited(priv->dev, "%s: error: %i\n", __func__, ret); } +static void ar9331_sw_port_stp_state_set(struct dsa_switch *ds, int port, +u8 state) +{ + struct ar9331_sw_priv *priv = (struct ar9331_sw_priv *)ds->priv; + struct net_device *br = dsa_to_port(ds, port)->bridge_dev; + struct regmap *regmap = priv->regmap; + u32 port_ctrl = 0, port_state = 0; + bool join = false; + int ret; + + /* +* STP hw support is buggy or I didn't understood it. So, it seems to +* be easier to make hand crafted implementation by using bridge +* functionality. Similar implementation can be found on ksz9477 switch +* and may be we need some generic code to so for all related devices +*/ + switch (state) { + case BR_STATE_FORWARDING: + join = true; + fallthrough; + case BR_STATE_LEARNING: + port_ctrl = AR9331_SW_PORT_CTRL_LEARN_EN; + fallthrough; + case BR_STATE_LISTENING: + case BR_STATE_BLOCKING: + port_state = AR9331_SW_PORT_CTRL_PORT_STATE_FORWARD; + break; + case BR_STATE_DISABLED: + default: + port_state = AR9331_SW_PORT_CTRL_PORT_STATE_DISABLED; + break; + } + + port_ctrl |= FIELD_PREP(AR9331_SW_PORT_CTRL_PORT_STATE, port_state); + + ret = regmap_update_bits(regmap, AR9331_SW_REG_PORT_CTRL(port), +AR9331_SW_PORT_CTRL_LEARN_EN | +AR9331_SW_PORT_CTRL_PORT_STATE, port_ctrl); + if (ret) + goto error; + + if (!dsa_is_user_port(ds, port)) + return; + + /* +* here we care only about user ports. CPU port do not need this +* configuration +*/ + if (join) { + priv->isolated_ports &= ~BIT(port); + if (br) + ar9331_sw_port_bridge_join(ds, port, br); + } else { + priv->isolated_ports |= BIT(port); + if (br) + ar9331_sw_port_bridge_leave(ds, port, br); + } + + return; +error: + dev_err_ratelimited(priv->dev, "%s: error: %i\n", __func__, ret); +} + static const struct dsa_switch_ops ar9331_sw_ops = { .get_tag_protocol = ar9331_sw_get_tag_protocol, .setup = ar9331_sw_setup, @@ -1223,6 +1291,7 @@ static const struct dsa_switch_ops ar9331_sw_ops = { .set_ageing_time= ar9331_sw_set_ageing_time, .port_bridge_join = ar9331_sw_port_bridge_join, .port_bridge_leave = ar9331_sw_port_bridge_leave, + .port_stp_state_set = ar9331_sw_port_stp_state_set, }; static irqreturn_t ar9331_sw_irq(int irq, void *data) -- 2.29.2
[PATCH net-next v1 6/9] net: dsa: qca: ar9331: add ageing time support
This switch provides global ageing time configuration, so let DSA use it. Signed-off-by: Oleksij Rempel --- drivers/net/dsa/qca/ar9331.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c index 4a98f14f31f4..b2c22ba924f0 100644 --- a/drivers/net/dsa/qca/ar9331.c +++ b/drivers/net/dsa/qca/ar9331.c @@ -1115,6 +1115,25 @@ static void ar9331_sw_port_fast_age(struct dsa_switch *ds, int port) dev_err_ratelimited(priv->dev, "%s: error: %i\n", __func__, ret); } +static int ar9331_sw_set_ageing_time(struct dsa_switch *ds, +unsigned int ageing_time) +{ + struct ar9331_sw_priv *priv = (struct ar9331_sw_priv *)ds->priv; + struct regmap *regmap = priv->regmap; + u32 time, val; + + time = DIV_ROUND_UP(ageing_time, AR9331_SW_AT_AGE_TIME_COEF); + if (!time) + time = 1; + else if (time > U16_MAX) + time = U16_MAX; + + val = FIELD_PREP(AR9331_SW_AT_AGE_TIME, time) | AR9331_SW_AT_AGE_EN; + return regmap_update_bits(regmap, AR9331_SW_REG_ADDR_TABLE_CTRL, + AR9331_SW_AT_AGE_EN | AR9331_SW_AT_AGE_TIME, + val); +} + static const struct dsa_switch_ops ar9331_sw_ops = { .get_tag_protocol = ar9331_sw_get_tag_protocol, .setup = ar9331_sw_setup, @@ -1130,6 +1149,7 @@ static const struct dsa_switch_ops ar9331_sw_ops = { .port_fdb_dump = ar9331_sw_port_fdb_dump, .port_mdb_add = ar9331_sw_port_mdb_add, .port_mdb_del = ar9331_sw_port_mdb_del, + .set_ageing_time= ar9331_sw_set_ageing_time, }; static irqreturn_t ar9331_sw_irq(int irq, void *data) @@ -1476,6 +1496,8 @@ static int ar9331_sw_probe(struct mdio_device *mdiodev) priv->ops = ar9331_sw_ops; ds->ops = &priv->ops; dev_set_drvdata(&mdiodev->dev, priv); + ds->ageing_time_min = AR9331_SW_AT_AGE_TIME_COEF; + ds->ageing_time_max = AR9331_SW_AT_AGE_TIME_COEF * U16_MAX; for (i = 0; i < ARRAY_SIZE(priv->port); i++) { struct ar9331_sw_port *port = &priv->port[i]; -- 2.29.2
[PATCH net-next v1 7/9] net: dsa: qca: ar9331: add bridge support
This switch is providing forwarding matrix, with it we can configure individual bridges. Potentially we can configure more then one not VLAN based bridge on this HW. Signed-off-by: Oleksij Rempel --- drivers/net/dsa/qca/ar9331.c | 73 1 file changed, 73 insertions(+) diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c index b2c22ba924f0..bf9588574205 100644 --- a/drivers/net/dsa/qca/ar9331.c +++ b/drivers/net/dsa/qca/ar9331.c @@ -40,6 +40,7 @@ */ #include +#include #include #include #include @@ -1134,6 +1135,76 @@ static int ar9331_sw_set_ageing_time(struct dsa_switch *ds, val); } +static int ar9331_sw_port_bridge_join(struct dsa_switch *ds, int port, + struct net_device *br) +{ + struct ar9331_sw_priv *priv = (struct ar9331_sw_priv *)ds->priv; + struct regmap *regmap = priv->regmap; + int port_mask = BIT(priv->cpu_port); + int i, ret; + u32 val; + + for (i = 0; i < ds->num_ports; i++) { + if (dsa_to_port(ds, i)->bridge_dev != br) + continue; + + if (!dsa_is_user_port(ds, port)) + continue; + + val = FIELD_PREP(AR9331_SW_PORT_VLAN_PORT_VID_MEMBER, BIT(port)); + ret = regmap_set_bits(regmap, AR9331_SW_REG_PORT_VLAN(i), val); + if (ret) + goto error; + + if (i != port) + port_mask |= BIT(i); + } + + val = FIELD_PREP(AR9331_SW_PORT_VLAN_PORT_VID_MEMBER, port_mask); + ret = regmap_update_bits(regmap, AR9331_SW_REG_PORT_VLAN(port), +AR9331_SW_PORT_VLAN_PORT_VID_MEMBER, val); + if (ret) + goto error; + + return 0; +error: + dev_err_ratelimited(priv->dev, "%s: error: %i\n", __func__, ret); + + return ret; +} + +static void ar9331_sw_port_bridge_leave(struct dsa_switch *ds, int port, + struct net_device *br) +{ + struct ar9331_sw_priv *priv = (struct ar9331_sw_priv *)ds->priv; + struct regmap *regmap = priv->regmap; + int i, ret; + u32 val; + + for (i = 0; i < ds->num_ports; i++) { + if (dsa_to_port(ds, i)->bridge_dev != br) + continue; + + if (!dsa_is_user_port(ds, port)) + continue; + + val = FIELD_PREP(AR9331_SW_PORT_VLAN_PORT_VID_MEMBER, BIT(port)); + ret = regmap_clear_bits(regmap, AR9331_SW_REG_PORT_VLAN(i), val); + if (ret) + goto error; + } + + val = FIELD_PREP(AR9331_SW_PORT_VLAN_PORT_VID_MEMBER, BIT(priv->cpu_port)); + ret = regmap_update_bits(regmap, AR9331_SW_REG_PORT_VLAN(port), +AR9331_SW_PORT_VLAN_PORT_VID_MEMBER, val); + if (ret) + goto error; + + return; +error: + dev_err_ratelimited(priv->dev, "%s: error: %i\n", __func__, ret); +} + static const struct dsa_switch_ops ar9331_sw_ops = { .get_tag_protocol = ar9331_sw_get_tag_protocol, .setup = ar9331_sw_setup, @@ -1150,6 +1221,8 @@ static const struct dsa_switch_ops ar9331_sw_ops = { .port_mdb_add = ar9331_sw_port_mdb_add, .port_mdb_del = ar9331_sw_port_mdb_del, .set_ageing_time= ar9331_sw_set_ageing_time, + .port_bridge_join = ar9331_sw_port_bridge_join, + .port_bridge_leave = ar9331_sw_port_bridge_leave, }; static irqreturn_t ar9331_sw_irq(int irq, void *data) -- 2.29.2
[PATCH net-next v1 3/9] net: dsa: qca: ar9331: reorder MDIO write sequence
In case of this switch we work with 32bit registers on top of 16bit bus. Some registers (for example access to forwarding database) have trigger bit on the first 16bit half of request and the result + configuration of request in the second half. Without this this patch, we would trigger database operation and overwrite result in one run. To make it work properly, we should do the second part of transfer before the first one is done. So far, this rule seems to work for all registers on this switch. Signed-off-by: Oleksij Rempel --- drivers/net/dsa/qca/ar9331.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c index ca2ad77b71f1..9a5035b2f0ff 100644 --- a/drivers/net/dsa/qca/ar9331.c +++ b/drivers/net/dsa/qca/ar9331.c @@ -837,16 +837,17 @@ static int ar9331_mdio_write(void *ctx, u32 reg, u32 val) return 0; } - ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg, val); + ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg + 2, + val >> 16); if (ret < 0) goto error; - ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg + 2, - val >> 16); + ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg, val); if (ret < 0) goto error; return 0; + error: dev_err_ratelimited(&sbus->dev, "Bus error. Failed to write register.\n"); return ret; -- 2.29.2
[PATCH net-next v1 5/9] net: dsa: qca: ar9331: add forwarding database support
This switch provides simple address resolution table, without VLAN or multicast specific information. With this patch we are able now to read, modify unicast and mulicast addresses. Signed-off-by: Oleksij Rempel --- drivers/net/dsa/qca/ar9331.c | 356 +++ 1 file changed, 356 insertions(+) diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c index a3de3598fbf5..4a98f14f31f4 100644 --- a/drivers/net/dsa/qca/ar9331.c +++ b/drivers/net/dsa/qca/ar9331.c @@ -66,6 +66,47 @@ #define AR9331_SW_REG_GLOBAL_CTRL 0x30 #define AR9331_SW_GLOBAL_CTRL_MFS_MGENMASK(13, 0) +/* Size of the address resolution table (ARL) */ +#define AR9331_SW_NUM_ARL_RECORDS 1024 + +#define AR9331_SW_REG_ADDR_TABLE_FUNCTION0 0x50 +#define AR9331_SW_AT_ADDR_BYTES4 GENMASK(31, 24) +#define AR9331_SW_AT_ADDR_BYTES5 GENMASK(23, 16) +#define AR9331_SW_AT_FULL_VIO BIT(12) +#define AR9331_SW_AT_PORT_NUM GENMASK(11, 8) +#define AR9331_SW_AT_FLUSH_STATIC_EN BIT(4) +#define AR9331_SW_AT_BUSY BIT(3) +#define AR9331_SW_AT_FUNC GENMASK(2, 0) +#define AR9331_SW_AT_FUNC_NOP 0 +#define AR9331_SW_AT_FUNC_FLUSH_ALL1 +#define AR9331_SW_AT_FUNC_LOAD_ENTRY 2 +#define AR9331_SW_AT_FUNC_PURGE_ENTRY 3 +#define AR9331_SW_AT_FUNC_FLUSH_ALL_UNLOCKED 4 +#define AR9331_SW_AT_FUNC_FLUSH_PORT 5 +#define AR9331_SW_AT_FUNC_GET_NEXT 6 +#define AR9331_SW_AT_FUNC_FIND_MAC 7 + +#define AR9331_SW_REG_ADDR_TABLE_FUNCTION1 0x54 +#define AR9331_SW_AT_ADDR_BYTES0 GENMASK(31, 24) +#define AR9331_SW_AT_ADDR_BYTES1 GENMASK(23, 16) +#define AR9331_SW_AT_ADDR_BYTES2 GENMASK(15, 8) +#define AR9331_SW_AT_ADDR_BYTES3 GENMASK(7, 0) + +#define AR9331_SW_REG_ADDR_TABLE_FUNCTION2 0x58 +#define AR9331_SW_AT_COPY_TO_CPU BIT(26) +#define AR9331_SW_AT_REDIRECT_TOCPUBIT(25) +#define AR9331_SW_AT_LEAKY_EN BIT(24) +#define AR9331_SW_AT_STATUSGENMASK(19, 16) +#define AR9331_SW_AT_STATUS_EMPTY 0 +/* STATUS values from 7 to 1 are different aging levels */ +#define AR9331_SW_AT_STATUS_STATIC 0xf + +#define AR9331_SW_AT_SA_DROP_ENBIT(14) +#define AR9331_SW_AT_MIRROR_EN BIT(13) +#define AR9331_SW_AT_PRIORITY_EN BIT(12) +#define AR9331_SW_AT_PRIORITY GENMASK(11, 10) +#define AR9331_SW_AT_DES_PORT GENMASK(5, 0) + #define AR9331_SW_REG_ADDR_TABLE_CTRL 0x5c #define AR9331_SW_AT_ARP_ENBIT(20) #define AR9331_SW_AT_LEARN_CHANGE_EN BIT(18) @@ -266,6 +307,12 @@ struct ar9331_sw_port { struct spinlock stats_lock; }; +struct ar9331_sw_fdb { + u8 port_mask; + u8 aging; + u8 mac[ETH_ALEN]; +}; + struct ar9331_sw_priv { struct device *dev; struct dsa_switch ds; @@ -765,6 +812,309 @@ static void ar9331_get_stats64(struct dsa_switch *ds, int port, spin_unlock(&p->stats_lock); } +static int ar9331_sw_fdb_wait(struct ar9331_sw_priv *priv, u32 *f0) +{ + struct regmap *regmap = priv->regmap; + + return regmap_read_poll_timeout(regmap, + AR9331_SW_REG_ADDR_TABLE_FUNCTION0, + *f0, !(*f0 & AR9331_SW_AT_BUSY), + 10, 2000); +} + +static int ar9331_sw_port_fdb_write(struct ar9331_sw_priv *priv, + u32 f0, u32 f1, u32 f2) +{ + struct regmap *regmap = priv->regmap; + int ret; + + ret = regmap_write(regmap, AR9331_SW_REG_ADDR_TABLE_FUNCTION2, f2); + if (ret) + return ret; + + ret = regmap_write(regmap, AR9331_SW_REG_ADDR_TABLE_FUNCTION1, f1); + if (ret) + return ret; + + return regmap_write(regmap, AR9331_SW_REG_ADDR_TABLE_FUNCTION0, f0); +} + +static int ar9331_sw_fdb_next(struct ar9331_sw_priv *priv, + struct ar9331_sw_fdb *fdb, int port) +{ + struct regmap *regmap = priv->regmap; + unsigned int status, ports; + u32 f0, f1, f2; + int ret; + + /* Keep AT_ADDR_BYTES4/5 to search next entry after current */ + ret = regmap_update_bits(regmap, AR9331_SW_REG_ADDR_TABLE_FUNCTION0, +AR9331_SW_AT_FUNC | AR9331_SW_AT_BUSY, +AR9331_SW_AT_BUSY | +FIELD_PREP(AR9331_SW_AT_FUNC, + AR9331_SW_AT_FUNC_GET_NEXT)); + if (ret) + return ret; + + ret = ar9331_sw_fdb_wait(priv, &f0); + if (ret) + return ret; + + ret = regmap_read(regmap, AR9331_SW_REG_ADDR_T
[PATCH net-next v1 2/9] net: dsa: tag_ar9331: detect IGMP and MLD packets
The ar9331 switch is not forwarding IGMP and MLD packets if IGMP snooping is enabled. This patch is trying to mimic the HW heuristic to take same decisions as this switch would do to be able to tell the linux bridge if some packet was prabably forwarded or not. Signed-off-by: Oleksij Rempel --- net/dsa/tag_ar9331.c | 130 +++ 1 file changed, 130 insertions(+) diff --git a/net/dsa/tag_ar9331.c b/net/dsa/tag_ar9331.c index 002cf7f952e2..0ba90e0f91bb 100644 --- a/net/dsa/tag_ar9331.c +++ b/net/dsa/tag_ar9331.c @@ -6,6 +6,8 @@ #include #include +#include +#include #include "dsa_priv.h" @@ -24,6 +26,69 @@ #define AR9331_HDR_RESERVED_MASK GENMASK(5, 4) #define AR9331_HDR_PORT_NUM_MASK GENMASK(3, 0) +/* + * This code replicated MLD detection more or less in the same way as the + * switch is doing it + */ +static int ipv6_mc_check_ip6hdr(struct sk_buff *skb) +{ + const struct ipv6hdr *ip6h; + unsigned int offset; + + offset = skb_network_offset(skb) + sizeof(*ip6h); + + if (!pskb_may_pull(skb, offset)) + return -EINVAL; + + ip6h = ipv6_hdr(skb); + + if (ip6h->version != 6) + return -EINVAL; + + skb_set_transport_header(skb, offset); + + return 0; +} + +static int ipv6_mc_check_exthdrs(struct sk_buff *skb) +{ + const struct ipv6hdr *ip6h; + int offset; + u8 nexthdr; + __be16 frag_off; + + ip6h = ipv6_hdr(skb); + + if (ip6h->nexthdr != IPPROTO_HOPOPTS) + return -ENOMSG; + + nexthdr = ip6h->nexthdr; + offset = skb_network_offset(skb) + sizeof(*ip6h); + offset = ipv6_skip_exthdr(skb, offset, &nexthdr, &frag_off); + + if (offset < 0) + return -EINVAL; + + if (nexthdr != IPPROTO_ICMPV6) + return -ENOMSG; + + skb_set_transport_header(skb, offset); + + return 0; +} + +static int my_ipv6_mc_check_mld(struct sk_buff *skb) +{ + int ret; + + ret = ipv6_mc_check_ip6hdr(skb); + if (ret < 0) + return ret; + + return ipv6_mc_check_exthdrs(skb); +} + + static struct sk_buff *ar9331_tag_xmit(struct sk_buff *skb, struct net_device *dev) { @@ -31,6 +96,13 @@ static struct sk_buff *ar9331_tag_xmit(struct sk_buff *skb, __le16 *phdr; u16 hdr; + if (dp->stp_state == BR_STATE_BLOCKING) { + /* TODO: should we reflect it in the stats? */ + netdev_warn_once(dev, "%s:%i dropping blocking packet\n", +__func__, __LINE__); + return NULL; + } + phdr = skb_push(skb, AR9331_HDR_LEN); hdr = FIELD_PREP(AR9331_HDR_VERSION_MASK, AR9331_HDR_VERSION); @@ -80,11 +152,69 @@ static struct sk_buff *ar9331_tag_rcv(struct sk_buff *skb, return skb; } +static void ar9331_tag_rcv_post(struct sk_buff *skb) +{ + const struct iphdr *iph; + unsigned char *dest; + int ret; + + /* +* Since the switch do not tell us which packets was offloaded we assume +* that all of them did. Except: +* - port is not configured for forwarding to any other ports +* - igmp/mld snooping is enabled +* - unicast or multicast flood is disabled on some of bridged ports +* - if we have two port bridge and one is not in forwarding state. +* - packet was dropped on the output port.. +* - any other reasons? +*/ + skb->offload_fwd_mark = true; + + dest = eth_hdr(skb)->h_dest; + /* +* Complete not multicast traffic seems to be forwarded automatically, +* as long as multicast and unicast flood are enabled +*/ + if (!(is_multicast_ether_addr(dest) && !is_broadcast_ether_addr(dest))) + return; + + + /* +* Documentation do not providing any usable information on how the +* igmp/mld snooping is implemented on this switch. Following +* implementation is based on testing, by sending correct and malformed +* packets to the switch. +* It is not trying to find sane and properly formated packets. Instead +* it is trying to be as close to the switch behavior as possible. +*/ + skb_reset_network_header(skb); + switch (ntohs(skb->protocol)) { + case ETH_P_IP: + + if (!pskb_network_may_pull(skb, sizeof(*iph))) + break; + + iph = ip_hdr(skb); + if (iph->protocol == IPPROTO_IGMP) + skb->offload_fwd_mark = false; + + break; + case ETH_P_IPV6: + ret = my_ipv6_mc_check_mld(skb); + if (!ret) + skb->offload_fwd_mark = false; + + break; + } +} + + static const struct dsa_device_ops ar9331_netdev_ops = { .name = "ar9331", .p