Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cf_axi_tdd] Typo in the cf_axi_tdd driver #345

Closed
tg-m opened this issue Apr 4, 2019 · 4 comments
Closed

[cf_axi_tdd] Typo in the cf_axi_tdd driver #345

tg-m opened this issue Apr 4, 2019 · 4 comments

Comments

@tg-m
Copy link

tg-m commented Apr 4, 2019

There's a typo in the cf_axi_tdd driver:

drivers/iio/adc/cf_axi_tdd.c:354:  static IIO_CONST_ATTR(enable_mode_available, "rx_tx rx_only tx_onlx");
drivers/iio/adc/cf_axi_tdd.c:361:  static IIO_CONST_ATTR(dma_gateing_mode_available, "none rx_only tx_onlx rx_tx");

Should be tx_only, while it is tx_onlx.

dbogdan added a commit that referenced this issue Apr 4, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
@dbogdan
Copy link
Contributor

dbogdan commented Apr 4, 2019

Thanks for reporting this. A pull request has been already made: #346

commodo pushed a commit that referenced this issue Apr 5, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
@commodo
Copy link
Contributor

commodo commented Apr 5, 2019

Closed via #346

@commodo commodo closed this as completed Apr 5, 2019
@tg-m
Copy link
Author

tg-m commented Apr 5, 2019

Well... I expected something more. For example, creating char const* const TX_ONLY_STR = "tx_only"; and changing all occurrences of this string in the source to such a constant. Similarly for "rx_only" and "rx_tx". That would be nice. Otherwise, similar typos may occur in the future.

commodo pushed a commit that referenced this issue Apr 5, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Apr 5, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
@dbogdan
Copy link
Contributor

dbogdan commented Apr 5, 2019

We are open for suggestions and patches. Anyone can create pull requests - we are happy to review them. Can you do it for the mentioned changes?

commodo pushed a commit that referenced this issue May 28, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue May 30, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue May 31, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Jun 4, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Jul 11, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Jul 16, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Jul 16, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Sep 5, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Oct 2, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Oct 2, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Oct 3, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Oct 16, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Oct 16, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Oct 17, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Oct 18, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Nov 21, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Nov 25, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Nov 29, 2019
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Jan 21, 2020
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Jan 21, 2020
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Jan 22, 2020
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
commodo pushed a commit that referenced this issue Feb 20, 2020
The issue was reported here:
#345

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
(cherry picked from commit 3baa4d9)
threexc pushed a commit to threexc/linux that referenced this issue Apr 22, 2024
A64_LDRSW() takes three registers: Xt, Xn, Xm as arguments and it loads
and sign extends the value at address Xn + Xm into register Xt.

Currently, the offset is being directly used in place of the tmp
register which has the offset already loaded by the last emitted
instruction.

This will cause JIT failures. The easiest way to reproduce this is to
test the following code through test_bpf module:

{
	"BPF_LDX_MEMSX | BPF_W",
	.u.insns_int = {
		BPF_LD_IMM64(R1, 0x00000000deadbeefULL),
		BPF_LD_IMM64(R2, 0xffffffffdeadbeefULL),
		BPF_STX_MEM(BPF_DW, R10, R1, -7),
		BPF_LDX_MEMSX(BPF_W, R0, R10, -7),
		BPF_JMP_REG(BPF_JNE, R0, R2, 1),
		BPF_ALU64_IMM(BPF_MOV, R0, 0),
		BPF_EXIT_INSN(),
	},
	INTERNAL,
	{ },
	{ { 0, 0 } },
	.stack_depth = 7,
},

We need to use the offset as -7 to trigger this code path, there could
be other valid ways to trigger this from proper BPF programs as well.

This code is rejected by the JIT because -7 is passed to A64_LDRSW() but
it expects a valid register (0 - 31).

 roott@pjy:~# modprobe test_bpf test_name="BPF_LDX_MEMSX | BPF_W"
 [11300.490371] test_bpf: test_bpf: set 'test_bpf' as the default test_suite.
 [11300.491750] test_bpf: analogdevicesinc#345 BPF_LDX_MEMSX | BPF_W
 [11300.493179] aarch64_insn_encode_register: unknown register encoding -7
 [11300.494133] aarch64_insn_encode_register: unknown register encoding -7
 [11300.495292] FAIL to select_runtime err=-524
 [11300.496804] test_bpf: Summary: 0 PASSED, 1 FAILED, [0/0 JIT'ed]
 modprobe: ERROR: could not insert 'test_bpf': Invalid argument

Applying this patch fixes the issue.

 root@pjy:~# modprobe test_bpf test_name="BPF_LDX_MEMSX | BPF_W"
 [  292.837436] test_bpf: test_bpf: set 'test_bpf' as the default test_suite.
 [  292.839416] test_bpf: analogdevicesinc#345 BPF_LDX_MEMSX | BPF_W jited:1 156 PASS
 [  292.844794] test_bpf: Summary: 1 PASSED, 0 FAILED, [1/1 JIT'ed]

Fixes: cc88f54 ("bpf, arm64: Support sign-extension load instructions")
Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
Message-ID: <20240312235917.103626-1-puranjay12@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants