| 0/0 |
2026/05/21 22:16 |
flow |
patching |
1h23m
Error:
|
| 1/1 |
2026/05/21 22:16 |
action |
base-commit-picker |
0m
Results: map[KernelBranch:master KernelCommit:5200f5f493f79f14bbdc349e402a40dfb32f23c8 KernelRepo:git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git]
|
| 2/1 |
2026/05/21 22:16 |
action |
syz-repro-to-c-repro |
0m
Results: map[SimplifiedCRepro:// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <setjmp.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/loop.h>
#ifndef __NR_memfd_create
#define __NR_memfd_create 319
#endif
static unsigned long long procid;
//% This code is derived from puff.{c,h}, found in the zlib development. The
//% original files come with the following copyright notice:
//% Copyright (C) 2002-2013 Mark Adler, all rights reserved
//% version 2.3, 21 Jan 2013
//% This software is provided 'as-is', without any express or implied
//% warranty. In no event will the author be held liable for any damages
//% arising from the use of this software.
//% Permission is granted to anyone to use this software for any purpose,
//% including commercial applications, and to alter it and redistribute it
//% freely, subject to the following restrictions:
//% 1. The origin of this software must not be misrepresented; you must not
//% claim that you wrote the original software. If you use this software
//% in a product, an acknowledgment in the product documentation would be
//% appreciated but is not required.
//% 2. Altered source versions must be plainly marked as such, and must not be
//% misrepresented as being the original software.
//% 3. This notice may not be removed or altered from any source distribution.
//% Mark Adler madler@alumni.caltech.edu
//% BEGIN CODE DERIVED FROM puff.{c,h}
#define MAXBITS 15
#define MAXLCODES 286
#define MAXDCODES 30
#define MAXCODES (MAXLCODES + MAXDCODES)
#define FIXLCODES 288
struct puff_state {
unsigned char* out;
unsigned long outlen;
unsigned long outcnt;
const unsigned char* in;
unsigned long inlen;
unsigned long incnt;
int bitbuf;
int bitcnt;
jmp_buf env;
};
static int puff_bits(struct puff_state* s, int need)
{
long val = s->bitbuf;
while (s->bitcnt < need) {
if (s->incnt == s->inlen)
longjmp(s->env, 1);
val |= (long)(s->in[s->incnt++]) << s->bitcnt;
s->bitcnt += 8;
}
s->bitbuf = (int)(val >> need);
s->bitcnt -= need;
return (int)(val & ((1L << need) - 1));
}
static int puff_stored(struct puff_state* s)
{
s->bitbuf = 0;
s->bitcnt = 0;
if (s->incnt + 4 > s->inlen)
return 2;
unsigned len = s->in[s->incnt++];
len |= s->in[s->incnt++] << 8;
if (s->in[s->incnt++] != (~len & 0xff) ||
s->in[s->incnt++] != ((~len >> 8) & 0xff))
return -2;
if (s->incnt + len > s->inlen)
return 2;
if (s->outcnt + len > s->outlen)
return 1;
for (; len--; s->outcnt++, s->incnt++) {
if (s->in[s->incnt])
s->out[s->outcnt] = s->in[s->incnt];
}
return 0;
}
struct puff_huffman {
short* count;
short* symbol;
};
static int puff_decode(struct puff_state* s, const struct puff_huffman* h)
{
int first = 0;
int index = 0;
int bitbuf = s->bitbuf;
int left = s->bitcnt;
int code = first = index = 0;
int len = 1;
short* next = h->count + 1;
while (1) {
while (left--) {
code |= bitbuf & 1;
bitbuf >>= 1;
int count = *next++;
if (code - count < first) {
s->bitbuf = bitbuf;
s->bitcnt = (s->bitcnt - len) & 7;
return h->symbol[index + (code - first)];
}
index += count;
first += count;
first <<= 1;
code <<= 1;
len++;
}
left = (MAXBITS + 1) - len;
if (left == 0)
break;
if (s->incnt == s->inlen)
longjmp(s->env, 1);
bitbuf = s->in[s->incnt++];
if (left > 8)
left = 8;
}
return -10;
}
static int puff_construct(struct puff_huffman* h, const short* length, int n)
{
int len;
for (len = 0; len <= MAXBITS; len++)
h->count[len] = 0;
int symbol;
for (symbol = 0; symbol < n; symbol++)
(h->count[length[symbol]])++;
if (h->count[0] == n)
return 0;
int left = 1;
for (len = 1; len <= MAXBITS; len++) {
left <<= 1;
left -= h->count[len];
if (left < 0)
return left;
}
short offs[MAXBITS + 1];
offs[1] = 0;
for (len = 1; len < MAXBITS; len++)
offs[len + 1] = offs[len] + h->count[len];
for (symbol = 0; symbol < n; symbol++)
if (length[symbol] != 0)
h->symbol[offs[length[symbol]]++] = symbol;
return left;
}
static int puff_codes(struct puff_state* s,
const struct puff_huffman* lencode,
const struct puff_huffman* distcode)
{
static const short lens[29] = {
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258};
static const short lext[29] = {
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0};
static const short dists[30] = {
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577};
static const short dext[30] = {
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
12, 12, 13, 13};
int symbol;
do {
symbol = puff_decode(s, lencode);
if (symbol < 0)
return symbol;
if (symbol < 256) {
if (s->outcnt == s->outlen)
return 1;
if (symbol)
s->out[s->outcnt] = symbol;
s->outcnt++;
} else if (symbol > 256) {
symbol -= 257;
if (symbol >= 29)
return -10;
int len = lens[symbol] + puff_bits(s, lext[symbol]);
symbol = puff_decode(s, distcode);
if (symbol < 0)
return symbol;
unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]);
if (dist > s->outcnt)
return -11;
if (s->outcnt + len > s->outlen)
return 1;
while (len--) {
if (dist <= s->outcnt && s->out[s->outcnt - dist])
s->out[s->outcnt] = s->out[s->outcnt - dist];
s->outcnt++;
}
}
} while (symbol != 256);
return 0;
}
static int puff_fixed(struct puff_state* s)
{
static int virgin = 1;
static short lencnt[MAXBITS + 1], lensym[FIXLCODES];
static short distcnt[MAXBITS + 1], distsym[MAXDCODES];
static struct puff_huffman lencode, distcode;
if (virgin) {
lencode.count = lencnt;
lencode.symbol = lensym;
distcode.count = distcnt;
distcode.symbol = distsym;
short lengths[FIXLCODES];
int symbol;
for (symbol = 0; symbol < 144; symbol++)
lengths[symbol] = 8;
for (; symbol < 256; symbol++)
lengths[symbol] = 9;
for (; symbol < 280; symbol++)
lengths[symbol] = 7;
for (; symbol < FIXLCODES; symbol++)
lengths[symbol] = 8;
puff_construct(&lencode, lengths, FIXLCODES);
for (symbol = 0; symbol < MAXDCODES; symbol++)
lengths[symbol] = 5;
puff_construct(&distcode, lengths, MAXDCODES);
virgin = 0;
}
return puff_codes(s, &lencode, &distcode);
}
static int puff_dynamic(struct puff_state* s)
{
static const short order[19] =
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
int nlen = puff_bits(s, 5) + 257;
int ndist = puff_bits(s, 5) + 1;
int ncode = puff_bits(s, 4) + 4;
if (nlen > MAXLCODES || ndist > MAXDCODES)
return -3;
short lengths[MAXCODES];
int index;
for (index = 0; index < ncode; index++)
lengths[order[index]] = puff_bits(s, 3);
for (; index < 19; index++)
lengths[order[index]] = 0;
short lencnt[MAXBITS + 1], lensym[MAXLCODES];
struct puff_huffman lencode = {lencnt, lensym};
int err = puff_construct(&lencode, lengths, 19);
if (err != 0)
return -4;
index = 0;
while (index < nlen + ndist) {
int symbol;
int len;
symbol = puff_decode(s, &lencode);
if (symbol < 0)
return symbol;
if (symbol < 16)
lengths[index++] = symbol;
else {
len = 0;
if (symbol == 16) {
if (index == 0)
return -5;
len = lengths[index - 1];
symbol = 3 + puff_bits(s, 2);
} else if (symbol == 17)
symbol = 3 + puff_bits(s, 3);
else
symbol = 11 + puff_bits(s, 7);
if (index + symbol > nlen + ndist)
return -6;
while (symbol--)
lengths[index++] = len;
}
}
if (lengths[256] == 0)
return -9;
err = puff_construct(&lencode, lengths, nlen);
if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1]))
return -7;
short distcnt[MAXBITS + 1], distsym[MAXDCODES];
struct puff_huffman distcode = {distcnt, distsym};
err = puff_construct(&distcode, lengths + nlen, ndist);
if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1]))
return -8;
return puff_codes(s, &lencode, &distcode);
}
static int puff(
unsigned char* dest,
unsigned long* destlen,
const unsigned char* source,
unsigned long sourcelen)
{
struct puff_state s = {
.out = dest,
.outlen = *destlen,
.outcnt = 0,
.in = source,
.inlen = sourcelen,
.incnt = 0,
.bitbuf = 0,
.bitcnt = 0,
};
int err;
if (setjmp(s.env) != 0)
err = 2;
else {
int last;
do {
last = puff_bits(&s, 1);
int type = puff_bits(&s, 2);
err = type == 0 ? puff_stored(&s) : (type == 1 ? puff_fixed(&s) : (type == 2 ? puff_dynamic(&s) : -1));
if (err != 0)
break;
} while (!last);
}
*destlen = s.outcnt;
return err;
}
//% END CODE DERIVED FROM puff.{c,h}
#define ZLIB_HEADER_WIDTH 2
static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcelen, int dest_fd)
{
if (sourcelen < ZLIB_HEADER_WIDTH)
return 0;
source += ZLIB_HEADER_WIDTH;
sourcelen -= ZLIB_HEADER_WIDTH;
const unsigned long max_destlen = 132 << 20;
void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0);
if (ret == MAP_FAILED)
return -1;
unsigned char* dest = (unsigned char*)ret;
unsigned long destlen = max_destlen;
int err = puff(dest, &destlen, source, sourcelen);
if (err) {
munmap(dest, max_destlen);
errno = -err;
return -1;
}
if (write(dest_fd, dest, destlen) != (ssize_t)destlen) {
munmap(dest, max_destlen);
return -1;
}
return munmap(dest, max_destlen);
}
static int setup_loop_device(unsigned char* data, unsigned long size, const char* loopname, int* loopfd_p)
{
int err = 0, loopfd = -1;
int memfd = syscall(__NR_memfd_create, "syzkaller", 0);
if (memfd == -1) {
err = errno;
goto error;
}
if (puff_zlib_to_file(data, size, memfd)) {
err = errno;
goto error_close_memfd;
}
loopfd = open(loopname, O_RDWR);
if (loopfd == -1) {
err = errno;
goto error_close_memfd;
}
if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
if (errno != EBUSY) {
err = errno;
goto error_close_loop;
}
ioctl(loopfd, LOOP_CLR_FD, 0);
usleep(1000);
if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
err = errno;
goto error_close_loop;
}
}
close(memfd);
*loopfd_p = loopfd;
return 0;
error_close_loop:
close(loopfd);
error_close_memfd:
close(memfd);
error:
errno = err;
return -1;
}
static void reset_loop_device(const char* loopname)
{
int loopfd = open(loopname, O_RDWR);
if (loopfd == -1) {
return;
}
if (ioctl(loopfd, LOOP_CLR_FD, 0)) {
}
close(loopfd);
}
static long syz_mount_image(
volatile long fsarg,
volatile long dir,
volatile long flags,
volatile long optsarg,
volatile long change_dir,
volatile unsigned long size,
volatile long image)
{
unsigned char* data = (unsigned char*)image;
int res = -1, err = 0, need_loop_device = !!size;
char* mount_opts = (char*)optsarg;
char* target = (char*)dir;
char* fs = (char*)fsarg;
char* source = NULL;
char loopname[64];
if (need_loop_device) {
int loopfd;
memset(loopname, 0, sizeof(loopname));
snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid);
if (setup_loop_device(data, size, loopname, &loopfd) == -1)
return -1;
close(loopfd);
source = loopname;
}
mkdir(target, 0777);
char opts[256];
memset(opts, 0, sizeof(opts));
if (strlen(mount_opts) > (sizeof(opts) - 32)) {
}
strncpy(opts, mount_opts, sizeof(opts) - 32);
if (strcmp(fs, "iso9660") == 0) {
flags |= MS_RDONLY;
} else if (strncmp(fs, "ext", 3) == 0) {
bool has_remount_ro = false;
char* remount_ro_start = strstr(opts, "errors=remount-ro");
if (remount_ro_start != NULL) {
char after = *(remount_ro_start + strlen("errors=remount-ro"));
char before = remount_ro_start == opts ? '\0' : *(remount_ro_start - 1);
has_remount_ro = ((before == '\0' || before == ',') && (after == '\0' || after == ','));
}
if (strstr(opts, "errors=panic") || !has_remount_ro)
strcat(opts, ",errors=continue");
} else if (strcmp(fs, "xfs") == 0) {
strcat(opts, ",nouuid");
} else if (strncmp(fs, "gfs2", 4) == 0 && (strstr(opts, "errors=panic") || strstr(opts, "debug"))) {
strcat(opts, ",errors=withdraw");
}
res = mount(source, target, fs, flags, opts);
if (res == -1) {
err = errno;
goto error_clear_loop;
}
res = open(target, O_RDONLY | O_DIRECTORY);
if (res == -1) {
err = errno;
goto error_clear_loop;
}
if (change_dir) {
res = chdir(target);
if (res == -1) {
err = errno;
}
}
error_clear_loop:
if (need_loop_device)
reset_loop_device(loopname);
errno = err;
return res;
}
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_mount_image$befs arguments: [
// fs: ptr[in, buffer] {
// buffer: {62 65 66 73 00} (length 0x5)
// }
// dir: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8)
// }
// flags: mount_flags = 0x800001 (8 bytes)
// opts: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// }
// }
// chdir: int8 = 0x0 (1 bytes)
// size: len = 0x9e17 (8 bytes)
// img: ptr[in, buffer] {
// buffer: (compressed buffer with length 0x9e18)
// }
// ]
// returns fd_dir
memcpy((void*)0x200000000040, "befs\000", 5);
memcpy((void*)0x200000000000, "./file0\000", 8);
memcpy((void*)0x2000000000c0, "... [truncated large byte array] ...", 40472);
syz_mount_image(/*fs=*/0x200000000040, /*dir=*/0x200000000000, /*flags=MS_I_VERSION|MS_RDONLY*/0x800001, /*opts=*/0x200000000080, /*chdir=*/0, /*size=*/0x9e17, /*img=*/0x2000000000c0);
return 0;
}
]
|
| 3/1 |
2026/05/21 22:16 |
action |
kernel-checkouter |
0m
Results: map[KernelSrc:/app/workdir/cache/src/d5a02ed91a4f019017141f71e695c75b27c3612e]
|
| 4/1 |
2026/05/21 22:16 |
action |
kernel-builder |
13m
Results: map[KernelObj:/app/workdir/cache/build/de4e112907db359f1160041c5d3b501139869ced]
|
| 5/1 |
2026/05/21 22:30 |
action |
crash-reproducer |
3m
Results: map[OtherCrashReports:<nil> ReproducedBugTitle:UBSAN: shift-out-of-bounds in befs_check_sb ReproducedCrashReport:loop0: detected capacity change from 0 to 128
------------[ cut here ]------------
UBSAN: shift-out-of-bounds in /app/workdir/cache/src/d5a02ed91a4f019017141f71e695c75b27c3612e/fs/befs/super.c:96:9
shift exponent 2066842816 is too large for 32-bit type 'int'
CPU: 0 UID: 0 PID: 6217 Comm: syz.0.17 Not tainted syzkaller #1 PREEMPT_{RT,(full)}
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
ubsan_epilogue+0xa/0x30 lib/ubsan.c:233
__ubsan_handle_shift_out_of_bounds+0x385/0x410 lib/ubsan.c:494
befs_check_sb+0x421/0x4c0 fs/befs/super.c:96
befs_fill_super+0x49b/[ 166.533846][ T6217] befs_fill_super+0x49b/0xa70 fs/befs/linuxvfs.c:843
get_tree_bdev_flags+0x431/0x4f0 fs/super.c:1694
vfs_get_tree+0x92/0x2a0 fs/super.c:1754
fc_mount fs/namespace.c:1193 [inline]
do_new_mount_fc fs/namespace.c:3758 [inline]
do_new_mount+0x341/0xd30 fs/namespace.c:3834
do_mount fs/namespace.c:4167 [inline]
__do_sys_mount fs/namespace.c:4383 [inline]
__se_sys_mount+0x31d/0x420 fs/namespace.c:4360
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5c83a6e0ca
Code: 48 c7 c2 e8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f5c830cde58 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f5c830cdee0 RCX: 00007f5c83a6e0ca
RDX: 0000200000000040 RSI: 0000200000000000 RDI: 00007f5c830cdea0
RBP: 0000200000000040 R08: 00007f5c830cdee0 R09: 0000000000800001
R10: 0000000000800001 R11: 0000000000000246 R12: 0000200000000000
R13: 00007f5c830cdea0 R14: 0000000000009e17 R15: 0000200000000080
</TASK>
---[ end trace ]---
ReproducedFaultInjection:]
|
| 6/1 |
2026/05/21 22:33 |
action |
codesearch-prepare |
18m
Results: map[Index:codesearch-index]
|
| 7/1 |
2026/05/21 22:52 |
agent |
debugger |
2m
Model:
Instruction:
You are an experienced Linux kernel developer tasked with debugging a kernel crash root cause.
You need to provide a detailed explanation of the root cause for another developer to be
able to write a fix for the bug based on your explanation. Include all relevant details
into the response: function/struct/field/etc names, code snippets, line numbers,
macro/enum values, etc.
Prefer calling several tools at the same time to save round-trips.
Prompt:
The crash is:
loop0: detected capacity change from 0 to 128
------------[ cut here ]------------
UBSAN: shift-out-of-bounds in /app/workdir/cache/src/d5a02ed91a4f019017141f71e695c75b27c3612e/fs/befs/super.c:96:9
shift exponent 2066842816 is too large for 32-bit type 'int'
CPU: 0 UID: 0 PID: 6217 Comm: syz.0.17 Not tainted syzkaller #1 PREEMPT_{RT,(full)}
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
ubsan_epilogue+0xa/0x30 lib/ubsan.c:233
__ubsan_handle_shift_out_of_bounds+0x385/0x410 lib/ubsan.c:494
befs_check_sb+0x421/0x4c0 fs/befs/super.c:96
befs_fill_super+0x49b/[ 166.533846][ T6217] befs_fill_super+0x49b/0xa70 fs/befs/linuxvfs.c:843
get_tree_bdev_flags+0x431/0x4f0 fs/super.c:1694
vfs_get_tree+0x92/0x2a0 fs/super.c:1754
fc_mount fs/namespace.c:1193 [inline]
do_new_mount_fc fs/namespace.c:3758 [inline]
do_new_mount+0x341/0xd30 fs/namespace.c:3834
do_mount fs/namespace.c:4167 [inline]
__do_sys_mount fs/namespace.c:4383 [inline]
__se_sys_mount+0x31d/0x420 fs/namespace.c:4360
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5c83a6e0ca
Code: 48 c7 c2 e8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f5c830cde58 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f5c830cdee0 RCX: 00007f5c83a6e0ca
RDX: 0000200000000040 RSI: 0000200000000000 RDI: 00007f5c830cdea0
RBP: 0000200000000040 R08: 00007f5c830cdee0 R09: 0000000000800001
R10: 0000000000800001 R11: 0000000000000246 R12: 0000200000000000
R13: 00007f5c830cdea0 R14: 0000000000009e17 R15: 0000200000000080
</TASK>
---[ end trace ]---
The following C code is a draft of the vulnerable syscall sequence. Keep in mind that
it may lack the precise threading, sandboxing, and some arguments of a working reproducer:
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <setjmp.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/loop.h>
#ifndef __NR_memfd_create
#define __NR_memfd_create 319
#endif
static unsigned long long procid;
//% This code is derived from puff.{c,h}, found in the zlib development. The
//% original files come with the following copyright notice:
//% Copyright (C) 2002-2013 Mark Adler, all rights reserved
//% version 2.3, 21 Jan 2013
//% This software is provided 'as-is', without any express or implied
//% warranty. In no event will the author be held liable for any damages
//% arising from the use of this software.
//% Permission is granted to anyone to use this software for any purpose,
//% including commercial applications, and to alter it and redistribute it
//% freely, subject to the following restrictions:
//% 1. The origin of this software must not be misrepresented; you must not
//% claim that you wrote the original software. If you use this software
//% in a product, an acknowledgment in the product documentation would be
//% appreciated but is not required.
//% 2. Altered source versions must be plainly marked as such, and must not be
//% misrepresented as being the original software.
//% 3. This notice may not be removed or altered from any source distribution.
//% Mark Adler madler@alumni.caltech.edu
//% BEGIN CODE DERIVED FROM puff.{c,h}
#define MAXBITS 15
#define MAXLCODES 286
#define MAXDCODES 30
#define MAXCODES (MAXLCODES + MAXDCODES)
#define FIXLCODES 288
struct puff_state {
unsigned char* out;
unsigned long outlen;
unsigned long outcnt;
const unsigned char* in;
unsigned long inlen;
unsigned long incnt;
int bitbuf;
int bitcnt;
jmp_buf env;
};
static int puff_bits(struct puff_state* s, int need)
{
long val = s->bitbuf;
while (s->bitcnt < need) {
if (s->incnt == s->inlen)
longjmp(s->env, 1);
val |= (long)(s->in[s->incnt++]) << s->bitcnt;
s->bitcnt += 8;
}
s->bitbuf = (int)(val >> need);
s->bitcnt -= need;
return (int)(val & ((1L << need) - 1));
}
static int puff_stored(struct puff_state* s)
{
s->bitbuf = 0;
s->bitcnt = 0;
if (s->incnt + 4 > s->inlen)
return 2;
unsigned len = s->in[s->incnt++];
len |= s->in[s->incnt++] << 8;
if (s->in[s->incnt++] != (~len & 0xff) ||
s->in[s->incnt++] != ((~len >> 8) & 0xff))
return -2;
if (s->incnt + len > s->inlen)
return 2;
if (s->outcnt + len > s->outlen)
return 1;
for (; len--; s->outcnt++, s->incnt++) {
if (s->in[s->incnt])
s->out[s->outcnt] = s->in[s->incnt];
}
return 0;
}
struct puff_huffman {
short* count;
short* symbol;
};
static int puff_decode(struct puff_state* s, const struct puff_huffman* h)
{
int first = 0;
int index = 0;
int bitbuf = s->bitbuf;
int left = s->bitcnt;
int code = first = index = 0;
int len = 1;
short* next = h->count + 1;
while (1) {
while (left--) {
code |= bitbuf & 1;
bitbuf >>= 1;
int count = *next++;
if (code - count < first) {
s->bitbuf = bitbuf;
s->bitcnt = (s->bitcnt - len) & 7;
return h->symbol[index + (code - first)];
}
index += count;
first += count;
first <<= 1;
code <<= 1;
len++;
}
left = (MAXBITS + 1) - len;
if (left == 0)
break;
if (s->incnt == s->inlen)
longjmp(s->env, 1);
bitbuf = s->in[s->incnt++];
if (left > 8)
left = 8;
}
return -10;
}
static int puff_construct(struct puff_huffman* h, const short* length, int n)
{
int len;
for (len = 0; len <= MAXBITS; len++)
h->count[len] = 0;
int symbol;
for (symbol = 0; symbol < n; symbol++)
(h->count[length[symbol]])++;
if (h->count[0] == n)
return 0;
int left = 1;
for (len = 1; len <= MAXBITS; len++) {
left <<= 1;
left -= h->count[len];
if (left < 0)
return left;
}
short offs[MAXBITS + 1];
offs[1] = 0;
for (len = 1; len < MAXBITS; len++)
offs[len + 1] = offs[len] + h->count[len];
for (symbol = 0; symbol < n; symbol++)
if (length[symbol] != 0)
h->symbol[offs[length[symbol]]++] = symbol;
return left;
}
static int puff_codes(struct puff_state* s,
const struct puff_huffman* lencode,
const struct puff_huffman* distcode)
{
static const short lens[29] = {
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258};
static const short lext[29] = {
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0};
static const short dists[30] = {
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577};
static const short dext[30] = {
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
12, 12, 13, 13};
int symbol;
do {
symbol = puff_decode(s, lencode);
if (symbol < 0)
return symbol;
if (symbol < 256) {
if (s->outcnt == s->outlen)
return 1;
if (symbol)
s->out[s->outcnt] = symbol;
s->outcnt++;
} else if (symbol > 256) {
symbol -= 257;
if (symbol >= 29)
return -10;
int len = lens[symbol] + puff_bits(s, lext[symbol]);
symbol = puff_decode(s, distcode);
if (symbol < 0)
return symbol;
unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]);
if (dist > s->outcnt)
return -11;
if (s->outcnt + len > s->outlen)
return 1;
while (len--) {
if (dist <= s->outcnt && s->out[s->outcnt - dist])
s->out[s->outcnt] = s->out[s->outcnt - dist];
s->outcnt++;
}
}
} while (symbol != 256);
return 0;
}
static int puff_fixed(struct puff_state* s)
{
static int virgin = 1;
static short lencnt[MAXBITS + 1], lensym[FIXLCODES];
static short distcnt[MAXBITS + 1], distsym[MAXDCODES];
static struct puff_huffman lencode, distcode;
if (virgin) {
lencode.count = lencnt;
lencode.symbol = lensym;
distcode.count = distcnt;
distcode.symbol = distsym;
short lengths[FIXLCODES];
int symbol;
for (symbol = 0; symbol < 144; symbol++)
lengths[symbol] = 8;
for (; symbol < 256; symbol++)
lengths[symbol] = 9;
for (; symbol < 280; symbol++)
lengths[symbol] = 7;
for (; symbol < FIXLCODES; symbol++)
lengths[symbol] = 8;
puff_construct(&lencode, lengths, FIXLCODES);
for (symbol = 0; symbol < MAXDCODES; symbol++)
lengths[symbol] = 5;
puff_construct(&distcode, lengths, MAXDCODES);
virgin = 0;
}
return puff_codes(s, &lencode, &distcode);
}
static int puff_dynamic(struct puff_state* s)
{
static const short order[19] =
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
int nlen = puff_bits(s, 5) + 257;
int ndist = puff_bits(s, 5) + 1;
int ncode = puff_bits(s, 4) + 4;
if (nlen > MAXLCODES || ndist > MAXDCODES)
return -3;
short lengths[MAXCODES];
int index;
for (index = 0; index < ncode; index++)
lengths[order[index]] = puff_bits(s, 3);
for (; index < 19; index++)
lengths[order[index]] = 0;
short lencnt[MAXBITS + 1], lensym[MAXLCODES];
struct puff_huffman lencode = {lencnt, lensym};
int err = puff_construct(&lencode, lengths, 19);
if (err != 0)
return -4;
index = 0;
while (index < nlen + ndist) {
int symbol;
int len;
symbol = puff_decode(s, &lencode);
if (symbol < 0)
return symbol;
if (symbol < 16)
lengths[index++] = symbol;
else {
len = 0;
if (symbol == 16) {
if (index == 0)
return -5;
len = lengths[index - 1];
symbol = 3 + puff_bits(s, 2);
} else if (symbol == 17)
symbol = 3 + puff_bits(s, 3);
else
symbol = 11 + puff_bits(s, 7);
if (index + symbol > nlen + ndist)
return -6;
while (symbol--)
lengths[index++] = len;
}
}
if (lengths[256] == 0)
return -9;
err = puff_construct(&lencode, lengths, nlen);
if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1]))
return -7;
short distcnt[MAXBITS + 1], distsym[MAXDCODES];
struct puff_huffman distcode = {distcnt, distsym};
err = puff_construct(&distcode, lengths + nlen, ndist);
if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1]))
return -8;
return puff_codes(s, &lencode, &distcode);
}
static int puff(
unsigned char* dest,
unsigned long* destlen,
const unsigned char* source,
unsigned long sourcelen)
{
struct puff_state s = {
.out = dest,
.outlen = *destlen,
.outcnt = 0,
.in = source,
.inlen = sourcelen,
.incnt = 0,
.bitbuf = 0,
.bitcnt = 0,
};
int err;
if (setjmp(s.env) != 0)
err = 2;
else {
int last;
do {
last = puff_bits(&s, 1);
int type = puff_bits(&s, 2);
err = type == 0 ? puff_stored(&s) : (type == 1 ? puff_fixed(&s) : (type == 2 ? puff_dynamic(&s) : -1));
if (err != 0)
break;
} while (!last);
}
*destlen = s.outcnt;
return err;
}
//% END CODE DERIVED FROM puff.{c,h}
#define ZLIB_HEADER_WIDTH 2
static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcelen, int dest_fd)
{
if (sourcelen < ZLIB_HEADER_WIDTH)
return 0;
source += ZLIB_HEADER_WIDTH;
sourcelen -= ZLIB_HEADER_WIDTH;
const unsigned long max_destlen = 132 << 20;
void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0);
if (ret == MAP_FAILED)
return -1;
unsigned char* dest = (unsigned char*)ret;
unsigned long destlen = max_destlen;
int err = puff(dest, &destlen, source, sourcelen);
if (err) {
munmap(dest, max_destlen);
errno = -err;
return -1;
}
if (write(dest_fd, dest, destlen) != (ssize_t)destlen) {
munmap(dest, max_destlen);
return -1;
}
return munmap(dest, max_destlen);
}
static int setup_loop_device(unsigned char* data, unsigned long size, const char* loopname, int* loopfd_p)
{
int err = 0, loopfd = -1;
int memfd = syscall(__NR_memfd_create, "syzkaller", 0);
if (memfd == -1) {
err = errno;
goto error;
}
if (puff_zlib_to_file(data, size, memfd)) {
err = errno;
goto error_close_memfd;
}
loopfd = open(loopname, O_RDWR);
if (loopfd == -1) {
err = errno;
goto error_close_memfd;
}
if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
if (errno != EBUSY) {
err = errno;
goto error_close_loop;
}
ioctl(loopfd, LOOP_CLR_FD, 0);
usleep(1000);
if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
err = errno;
goto error_close_loop;
}
}
close(memfd);
*loopfd_p = loopfd;
return 0;
error_close_loop:
close(loopfd);
error_close_memfd:
close(memfd);
error:
errno = err;
return -1;
}
static void reset_loop_device(const char* loopname)
{
int loopfd = open(loopname, O_RDWR);
if (loopfd == -1) {
return;
}
if (ioctl(loopfd, LOOP_CLR_FD, 0)) {
}
close(loopfd);
}
static long syz_mount_image(
volatile long fsarg,
volatile long dir,
volatile long flags,
volatile long optsarg,
volatile long change_dir,
volatile unsigned long size,
volatile long image)
{
unsigned char* data = (unsigned char*)image;
int res = -1, err = 0, need_loop_device = !!size;
char* mount_opts = (char*)optsarg;
char* target = (char*)dir;
char* fs = (char*)fsarg;
char* source = NULL;
char loopname[64];
if (need_loop_device) {
int loopfd;
memset(loopname, 0, sizeof(loopname));
snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid);
if (setup_loop_device(data, size, loopname, &loopfd) == -1)
return -1;
close(loopfd);
source = loopname;
}
mkdir(target, 0777);
char opts[256];
memset(opts, 0, sizeof(opts));
if (strlen(mount_opts) > (sizeof(opts) - 32)) {
}
strncpy(opts, mount_opts, sizeof(opts) - 32);
if (strcmp(fs, "iso9660") == 0) {
flags |= MS_RDONLY;
} else if (strncmp(fs, "ext", 3) == 0) {
bool has_remount_ro = false;
char* remount_ro_start = strstr(opts, "errors=remount-ro");
if (remount_ro_start != NULL) {
char after = *(remount_ro_start + strlen("errors=remount-ro"));
char before = remount_ro_start == opts ? '\0' : *(remount_ro_start - 1);
has_remount_ro = ((before == '\0' || before == ',') && (after == '\0' || after == ','));
}
if (strstr(opts, "errors=panic") || !has_remount_ro)
strcat(opts, ",errors=continue");
} else if (strcmp(fs, "xfs") == 0) {
strcat(opts, ",nouuid");
} else if (strncmp(fs, "gfs2", 4) == 0 && (strstr(opts, "errors=panic") || strstr(opts, "debug"))) {
strcat(opts, ",errors=withdraw");
}
res = mount(source, target, fs, flags, opts);
if (res == -1) {
err = errno;
goto error_clear_loop;
}
res = open(target, O_RDONLY | O_DIRECTORY);
if (res == -1) {
err = errno;
goto error_clear_loop;
}
if (change_dir) {
res = chdir(target);
if (res == -1) {
err = errno;
}
}
error_clear_loop:
if (need_loop_device)
reset_loop_device(loopname);
errno = err;
return res;
}
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_mount_image$befs arguments: [
// fs: ptr[in, buffer] {
// buffer: {62 65 66 73 00} (length 0x5)
// }
// dir: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8)
// }
// flags: mount_flags = 0x800001 (8 bytes)
// opts: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// }
// }
// chdir: int8 = 0x0 (1 bytes)
// size: len = 0x9e17 (8 bytes)
// img: ptr[in, buffer] {
// buffer: (compressed buffer with length 0x9e18)
// }
// ]
// returns fd_dir
memcpy((void*)0x200000000040, "befs\000", 5);
memcpy((void*)0x200000000000, "./file0\000", 8);
memcpy((void*)0x2000000000c0, "... [truncated large byte array] ...", 40472);
syz_mount_image(/*fs=*/0x200000000040, /*dir=*/0x200000000000, /*flags=MS_I_VERSION|MS_RDONLY*/0x800001, /*opts=*/0x200000000080, /*chdir=*/0, /*size=*/0x9e17, /*img=*/0x2000000000c0);
return 0;
}
Reply: An analysis of the crash report and the source code reveals the following root cause and the corresponding fix.
### Root Cause
The crash is caused by a shift-out-of-bounds (Undefined Behavior) in `fs/befs/super.c` inside the `befs_check_sb()` function.
When mounting a BEFS filesystem, the kernel reads the superblock fields `block_shift` and `ag_shift` directly from the disk and uses them as shift exponents to validate consistency with `block_size` and `blocks_per_ag`:
```c
if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
// ...
}
if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
// ...
```
Because `befs_sb->block_shift` and `befs_sb->ag_shift` are controlled by the filesystem image and are not validated before the shift operation, a maliciously crafted image can provide a huge value (e.g., `2066842816` as seen in the syzkaller log). Shifting a 32-bit integer `1` by an exponent $\ge 32$ triggers a UBSAN shift-out-of-bounds panic.
### Fix
To fix this, we should avoid using the unvalidated `block_shift` and `ag_shift` as shift exponents. Instead, we can use the `ilog2()` and `is_power_of_2()` macros from `<linux/log2.h>` to compute the expected shift values from `block_size` and `blocks_per_ag`, and compare them against the provided shift values.
1. **For `block_shift`**:
`befs_sb->block_size` is already strictly validated earlier in `befs_check_sb()` to be exactly 1024, 2048, 4096, or 8192. Since it is guaranteed to be a valid power of two, we can safely use `ilog2(befs_sb->block_size)` to get the expected `block_shift`.
2. **For `ag_shift`**:
`befs_sb->blocks_per_ag` is not validated to be a power of two. The original check `(1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag` inherently requires `blocks_per_ag` to be a power of two (otherwise they can never be equal). We can explicitly check if `blocks_per_ag` is a power of two using `is_power_of_2()`, and if so, compare `ilog2(befs_sb->blocks_per_ag)` with `befs_sb->ag_shift`.
Here is how the patched code in `fs/befs/super.c` should look:
```c
#include <linux/log2.h>
// ...
int befs_check_sb(struct super_block *sb)
{
struct befs_sb_info *befs_sb = BEFS_SB(sb);
// ... [magic and block_size checks] ...
/*
* block_shift and block_size encode the same information
* in different ways as a consistency check.
*/
if (befs_sb->block_shift != ilog2(befs_sb->block_size)) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
/* ag_shift also encodes the same information as blocks_per_ag in a
* different way, non-fatal consistency check
*/
if (!is_power_of_2(befs_sb->blocks_per_ag) ||
befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
// ...
}
```
This completely eliminates the undefined behavior while preserving the exact same validation logic.
|
| 8/2 |
2026/05/21 22:52 |
llm |
debugger |
0m
Model:
Tokens:
input: 10965
output: 23
thoughts: 463
Thoughts: **Analyzing a Syzkaller Crash Report**
Okay, here's what I'm seeing: A syzkaller crash report has come in. The core of it flags a "shift-out-of-bounds" error, and the trace points us directly to `fs/befs/super.c:96` within the `befs_check_sb` function. That's our starting point. The message clearly indicates an integer shift operation where the shift exponent is excessively large, exceeding the bounds of a 32-bit integer. This screams potential integer overflow or some mishandling of bitwise operations within the BEFS filesystem code. Now, my immediate thought is to dive into `fs/befs/super.c` and meticulously examine line 96 within `befs_check_sb`. This is going to involve understanding the exact data structures being used, the bit-shifting operations performed, and what potential values could lead to such an out-of-bounds condition. We need to understand how the superblock is being validated and how those shift operations are used during that validation.
|
| 9/2 |
2026/05/21 22:52 |
tool |
read-file |
0m
Args: map[File:fs/befs/super.c]
Results: map[Contents:/*
* super.c
*
* Copyright (C) 2001-2002 Will Dyson <will_dyson@pobox.com>
*
* Licensed under the GNU GPL. See the file COPYING for details.
*
*/
#include <linux/fs.h>
#include <asm/page.h> /* for PAGE_SIZE */
#include "befs.h"
#include "super.h"
/*
* befs_load_sb -- Read from disk and properly byteswap all the fields
* of the befs superblock
*/
int
befs_load_sb(struct super_block *sb, befs_super_block *disk_sb)
{
struct befs_sb_info *befs_sb = BEFS_SB(sb);
/* Check the byte order of the filesystem */
if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_LE)
befs_sb->byte_order = BEFS_BYTESEX_LE;
else if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_BE)
befs_sb->byte_order = BEFS_BYTESEX_BE;
befs_sb->magic1 = fs32_to_cpu(sb, disk_sb->magic1);
befs_sb->magic2 = fs32_to_cpu(sb, disk_sb->magic2);
befs_sb->magic3 = fs32_to_cpu(sb, disk_sb->magic3);
befs_sb->block_size = fs32_to_cpu(sb, disk_sb->block_size);
befs_sb->block_shift = fs32_to_cpu(sb, disk_sb->block_shift);
befs_sb->num_blocks = fs64_to_cpu(sb, disk_sb->num_blocks);
befs_sb->used_blocks = fs64_to_cpu(sb, disk_sb->used_blocks);
befs_sb->inode_size = fs32_to_cpu(sb, disk_sb->inode_size);
befs_sb->blocks_per_ag = fs32_to_cpu(sb, disk_sb->blocks_per_ag);
befs_sb->ag_shift = fs32_to_cpu(sb, disk_sb->ag_shift);
befs_sb->num_ags = fs32_to_cpu(sb, disk_sb->num_ags);
befs_sb->flags = fs32_to_cpu(sb, disk_sb->flags);
befs_sb->log_blocks = fsrun_to_cpu(sb, disk_sb->log_blocks);
befs_sb->log_start = fs64_to_cpu(sb, disk_sb->log_start);
befs_sb->log_end = fs64_to_cpu(sb, disk_sb->log_end);
befs_sb->root_dir = fsrun_to_cpu(sb, disk_sb->root_dir);
befs_sb->indices = fsrun_to_cpu(sb, disk_sb->indices);
befs_sb->nls = NULL;
return BEFS_OK;
}
int
befs_check_sb(struct super_block *sb)
{
struct befs_sb_info *befs_sb = BEFS_SB(sb);
/* Check magic headers of super block */
if ((befs_sb->magic1 != BEFS_SUPER_MAGIC1)
|| (befs_sb->magic2 != BEFS_SUPER_MAGIC2)
|| (befs_sb->magic3 != BEFS_SUPER_MAGIC3)) {
befs_error(sb, "invalid magic header");
return BEFS_ERR;
}
/*
* Check blocksize of BEFS.
*
* Blocksize of BEFS is 1024, 2048, 4096 or 8192.
*/
if ((befs_sb->block_size != 1024)
&& (befs_sb->block_size != 2048)
&& (befs_sb->block_size != 4096)
&& (befs_sb->block_size != 8192)) {
befs_error(sb, "invalid blocksize: %u", befs_sb->block_size);
return BEFS_ERR;
}
if (befs_sb->block_size > PAGE_SIZE) {
befs_error(sb, "blocksize(%u) cannot be larger "
"than system pagesize(%lu)", befs_sb->block_size,
PAGE_SIZE);
return BEFS_ERR;
}
/*
* block_shift and block_size encode the same information
* in different ways as a consistency check.
*/
if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
/* ag_shift also encodes the same information as blocks_per_ag in a
* different way, non-fatal consistency check
*/
if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
if (befs_sb->log_start != befs_sb->log_end ||
befs_sb->flags == BEFS_DIRTY) {
befs_error(sb, "Filesystem not clean! There are blocks in the "
"journal. You must boot into BeOS and mount this "
"volume to make it clean.");
return BEFS_ERR;
}
return BEFS_OK;
}
]
|
| 10/2 |
2026/05/21 22:52 |
llm |
debugger |
0m
Model:
Tokens:
input: 13146
output: 17
thoughts: 570
Thoughts: **Analyzing a Potential Integer Overflow Vulnerability in the BEFS Filesystem**
Okay, so I'm looking at this crash at line 96, specifically this problematic line of code:
```c
if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
```
The error is arising because `befs_sb->block_shift` is an enormous number, 2066842816 to be exact, which is completely messing up the left shift operation. The problem, as I see it, is that we're shifting `1` which is a 32-bit `int`, by a value that is likely out of range (more than 31 bits), resulting in undefined behavior.
I need to trace the origin of this potentially invalid `befs_sb->block_shift` value. It appears this value is loaded from `disk_sb->block_shift` within `befs_load_sb` via:
```c
befs_sb->block_shift = fs32_to_cpu(sb, disk_sb->block_shift);
```
So, this is a 32-bit integer that's being loaded from disk.
The core issue is that `befs_sb->block_shift` isn't being validated *before* its use in the left shift. The intention of that `if` statement seems to be checking consistency between `block_shift` and `block_size`. However, as it currently stands, with `block_shift` being potentially >= 32 this will lead to an undefined behavior and a crash.
Wait a second⦠`befs_sb->block_size` *is* validated. It's constrained to be either 1024, 2048, 4096, or 8192. So that implies that `block_shift` should be limited to 10, 11, 12, or 13. Given this constraint, it should be possible to perform a simple range check for `befs_sb->block_shift` to validate the sanity of its value, or we could also use `ilog2(befs_sb->block_size) == befs_sb->block_shift` to perform this sanity check.
Now, let me check for other locations where this left shift issue could pop up, I should check `befs_sb->ag_shift`.
```c
if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
```
Ah yes, `befs_sb->ag_shift` can also cause this problem, leading to a shift-out-of-bounds error. I'll need to go back and verify the related source code in `fs/befs/super.c`.
|
| 11/2 |
2026/05/21 22:52 |
tool |
grepper |
0m
Args:
Results: map[Output:arch/arm64/include/asm/memory.h=263=static inline bool kaslr_enabled(void) { return false; }
--
arch/arm64/include/asm/memory.h-296-#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS)
arch/arm64/include/asm/memory.h:297:#define __tag_shifted(tag) ((u64)(tag) << 56)
arch/arm64/include/asm/memory.h-298-#define __tag_reset(addr) __untagged_addr(addr)
--
arch/arm64/include/asm/memory.h-300-#else
arch/arm64/include/asm/memory.h:301:#define __tag_shifted(tag) 0UL
arch/arm64/include/asm/memory.h-302-#define __tag_reset(addr) (addr)
--
arch/arm64/include/asm/memory.h=306=static inline const void *__tag_set(const void *addr, u8 tag)
arch/arm64/include/asm/memory.h-307-{
arch/arm64/include/asm/memory.h:308: u64 __addr = (u64)addr & ~__tag_shifted(0xff);
arch/arm64/include/asm/memory.h:309: return (const void *)(__addr | __tag_shifted(tag));
arch/arm64/include/asm/memory.h-310-}
--
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c=49=void __cvmx_helper_errata_qlm_disable_2nd_order_cdr(int qlm)
--
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c-60- */
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c:61: cvmx_helper_qlm_jtag_shift_zeros(qlm, 63 - 0 + 1);
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c-62- /* cfg_cdr_incx<67:64>=3 */
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c:63: cvmx_helper_qlm_jtag_shift(qlm, 67 - 64 + 1, 3);
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c-64- /* Zeros for bits <76:68> */
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c:65: cvmx_helper_qlm_jtag_shift_zeros(qlm, 76 - 68 + 1);
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c-66- /* cfg_cdr_secord<77>=1 */
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c:67: cvmx_helper_qlm_jtag_shift(qlm, 77 - 77 + 1, 1);
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c-68- /* Zeros for bits <267:78> */
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c:69: cvmx_helper_qlm_jtag_shift_zeros(qlm, 267 - 78 + 1);
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c-70- }
--
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c=46=void cvmx_helper_qlm_jtag_init(void)
--
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-86- */
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c:87:uint32_t cvmx_helper_qlm_jtag_shift(int qlm, int bits, uint32_t data)
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-88-{
--
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-106- * chain. This function is a convenience wrapper around
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c:107: * cvmx_helper_qlm_jtag_shift() to shift more than 32 bits of
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-108- * zeros at a time.
--
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-112- */
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c:113:void cvmx_helper_qlm_jtag_shift_zeros(int qlm, int bits)
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-114-{
--
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-118- n = 32;
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c:119: cvmx_helper_qlm_jtag_shift(qlm, n, 0);
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-120- bits -= n;
--
arch/mips/include/asm/octeon/cvmx-helper-jtag.h=38=extern void cvmx_helper_qlm_jtag_init(void);
arch/mips/include/asm/octeon/cvmx-helper-jtag.h:39:extern uint32_t cvmx_helper_qlm_jtag_shift(int qlm, int bits, uint32_t data);
arch/mips/include/asm/octeon/cvmx-helper-jtag.h:40:extern void cvmx_helper_qlm_jtag_shift_zeros(int qlm, int bits);
arch/mips/include/asm/octeon/cvmx-helper-jtag.h-41-extern void cvmx_helper_qlm_jtag_update(int qlm);
--
arch/mips/pci/pcie-octeon.c=1153=static int __cvmx_pcie_rc_initialize_gen2(int pcie_port)
--
arch/mips/pci/pcie-octeon.c-1220- cvmx_helper_qlm_jtag_init();
arch/mips/pci/pcie-octeon.c:1221: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 85);
arch/mips/pci/pcie-octeon.c:1222: cvmx_helper_qlm_jtag_shift(pcie_port, 1, 1);
arch/mips/pci/pcie-octeon.c:1223: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 300-86);
arch/mips/pci/pcie-octeon.c:1224: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 85);
arch/mips/pci/pcie-octeon.c:1225: cvmx_helper_qlm_jtag_shift(pcie_port, 1, 1);
arch/mips/pci/pcie-octeon.c:1226: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 300-86);
arch/mips/pci/pcie-octeon.c:1227: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 85);
arch/mips/pci/pcie-octeon.c:1228: cvmx_helper_qlm_jtag_shift(pcie_port, 1, 1);
arch/mips/pci/pcie-octeon.c:1229: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 300-86);
arch/mips/pci/pcie-octeon.c:1230: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 85);
arch/mips/pci/pcie-octeon.c:1231: cvmx_helper_qlm_jtag_shift(pcie_port, 1, 1);
arch/mips/pci/pcie-octeon.c:1232: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 300-86);
arch/mips/pci/pcie-octeon.c-1233- cvmx_helper_qlm_jtag_update(pcie_port);
--
drivers/infiniband/hw/bng_re/bng_res.h=53=enum bng_re_db_info_flags_mask {
--
drivers/infiniband/hw/bng_re/bng_res.h-59-
drivers/infiniband/hw/bng_re/bng_res.h:60:enum bng_re_db_epoch_flag_shift {
drivers/infiniband/hw/bng_re/bng_res.h-61- BNG_RE_DB_EPOCH_CONS_SHIFT = BNG_RE_DBR_EPOCH_SHIFT,
--
drivers/infiniband/hw/bnxt_re/qplib_res.h=217=enum bnxt_qplib_db_info_flags_mask {
--
drivers/infiniband/hw/bnxt_re/qplib_res.h-223-
drivers/infiniband/hw/bnxt_re/qplib_res.h:224:enum bnxt_qplib_db_epoch_flag_shift {
drivers/infiniband/hw/bnxt_re/qplib_res.h-225- BNXT_QPLIB_DB_EPOCH_CONS_SHIFT = BNXT_QPLIB_DBR_EPOCH_SHIFT,
--
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h=348=struct tp_params {
--
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h-385- int matchtype_shift;
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h:386: int frag_shift;
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h-387-
--
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c=1151=bool is_filter_exact_match(struct adapter *adap,
--
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c-1226-
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c:1227: if (tp->frag_shift >= 0)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c:1228: ntuple_mask |= (u64)fs->mask.frag << tp->frag_shift;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c-1229-
--
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c=1236=static u64 hash_filter_ntuple(struct ch_filter_specification *fs,
--
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c-1286-
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c:1287: if (tp->frag_shift >= 0 && fs->mask.frag)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c:1288: ntuple |= (u64)(fs->val.frag) << tp->frag_shift;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c-1289-
--
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c=9409=int t4_init_tp_params(struct adapter *adap, bool sleep_ok)
--
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c-9491- MPSHITTYPE_F);
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:9492: adap->params.tp.frag_shift = t4_filter_field_shift(adap,
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c-9493- FRAGMENTATION_F);
--
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c=9817=static int hclge_set_vlan_tx_offload_cfg(struct hclge_vport *vport)
--
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c-9843- hnae3_set_bit(req->vport_vlan_cfg, HCLGE_TAG_SHIFT_MODE_EN_B,
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c:9844: vcfg->tag_shift_mode_en ? 1 : 0);
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c-9845- hnae3_set_bit(req->vport_vlan_cfg, HCLGE_CFG_NIC_ROCE_SEL_B, 0);
--
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c=9902=static int hclge_vlan_offload_cfg(struct hclge_vport *vport,
--
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c-9931- vport->txvlan_cfg.default_tag2 = 0;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c:9932: vport->txvlan_cfg.tag_shift_mode_en = true;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c-9933-
--
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h=992=struct hclge_tx_vtag_cfg {
--
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h-1000- u16 default_tag2; /* The default outer vlan tag to insert */
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h:1001: bool tag_shift_mode_en;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h-1002-};
--
fs/befs/befs.h=32=struct befs_sb_info {
--
fs/befs/befs.h-43- u32 blocks_per_ag;
fs/befs/befs.h:44: u32 ag_shift;
fs/befs/befs.h-45- u32 num_ags;
--
fs/befs/befs.h=123=iaddr2blockno(struct super_block *sb, const befs_inode_addr *iaddr)
fs/befs/befs.h-124-{
fs/befs/befs.h:125: return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
fs/befs/befs.h-126- iaddr->start);
--
fs/befs/befs.h=130=blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
--
fs/befs/befs.h-133-
fs/befs/befs.h:134: iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
fs/befs/befs.h-135- iaddr.start =
fs/befs/befs.h:136: blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
fs/befs/befs.h-137- iaddr.len = 1;
--
fs/befs/befs_fs_types.h=113=typedef struct {
--
fs/befs/befs_fs_types.h-127- fs32 blocks_per_ag;
fs/befs/befs_fs_types.h:128: fs32 ag_shift;
fs/befs/befs_fs_types.h-129- fs32 num_ags;
--
fs/befs/debug.c=156=befs_dump_super_block(const struct super_block *sb, befs_super_block *sup)
--
fs/befs/debug.c-178- fs32_to_cpu(sb, sup->blocks_per_ag));
fs/befs/debug.c:179: befs_debug(sb, " ag_shift %u", fs32_to_cpu(sb, sup->ag_shift));
fs/befs/debug.c-180- befs_debug(sb, " num_ags %u", fs32_to_cpu(sb, sup->num_ags));
--
fs/befs/super.c=21=befs_load_sb(struct super_block *sb, befs_super_block *disk_sb)
--
fs/befs/super.c-40- befs_sb->blocks_per_ag = fs32_to_cpu(sb, disk_sb->blocks_per_ag);
fs/befs/super.c:41: befs_sb->ag_shift = fs32_to_cpu(sb, disk_sb->ag_shift);
fs/befs/super.c-42- befs_sb->num_ags = fs32_to_cpu(sb, disk_sb->num_ags);
--
fs/befs/super.c=58=befs_check_sb(struct super_block *sb)
--
fs/befs/super.c-102-
fs/befs/super.c:103: /* ag_shift also encodes the same information as blocks_per_ag in a
fs/befs/super.c-104- * different way, non-fatal consistency check
fs/befs/super.c-105- */
fs/befs/super.c:106: if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
fs/befs/super.c:107: befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
fs/befs/super.c-108-
--
sound/soc/mediatek/common/mtk-afe-fe-dai.c=456=int mtk_memif_set_channel(struct mtk_base_afe *afe,
--
sound/soc/mediatek/common/mtk-afe-fe-dai.c-482- 1, mono,
sound/soc/mediatek/common/mtk-afe-fe-dai.c:483: memif->data->int_odd_flag_shift);
sound/soc/mediatek/common/mtk-afe-fe-dai.c-484-
--
sound/soc/mediatek/common/mtk-base-afe.h=33=struct mtk_base_memif_data {
--
sound/soc/mediatek/common/mtk-base-afe.h-51- int int_odd_flag_reg;
sound/soc/mediatek/common/mtk-base-afe.h:52: int int_odd_flag_shift;
sound/soc/mediatek/common/mtk-base-afe.h-53- int enable_reg;
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c=1924=static const struct mtk_base_memif_data memif_data[MT8188_AFE_MEMIF_NUM] = {
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-1936- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:1937: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-1938- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-1963- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:1964: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-1965- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-1990- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:1991: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-1992- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2017- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2018: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2019- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2044- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2045: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2046- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2071- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2072: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2073- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2098- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2099: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2100- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2125- .int_odd_flag_reg = AFE_UL1_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2126: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2127- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2152- .int_odd_flag_reg = AFE_UL2_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2153: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2154- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2179- .int_odd_flag_reg = AFE_UL3_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2180: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2181- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2206- .int_odd_flag_reg = AFE_UL4_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2207: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2208- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2233- .int_odd_flag_reg = AFE_UL5_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2234: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2235- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2260- .int_odd_flag_reg = AFE_UL6_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2261: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2262- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2287- .int_odd_flag_reg = AFE_UL8_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2288: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2289- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2314- .int_odd_flag_reg = AFE_UL9_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2315: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2316- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2341- .int_odd_flag_reg = AFE_UL10_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2342: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2343- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c=1796=static const struct mtk_base_memif_data memif_data[MT8195_AFE_MEMIF_NUM] = {
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1808- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1809: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1810- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1835- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1836: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1837- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1862- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1863: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1864- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1889- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1890: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1891- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1916- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1917: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1918- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1943- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1944: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1945- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1970- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1971: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1972- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1997- .int_odd_flag_reg = AFE_UL1_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1998: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1999- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2024- .int_odd_flag_reg = AFE_UL2_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2025: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2026- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2051- .int_odd_flag_reg = AFE_UL3_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2052: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2053- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2078- .int_odd_flag_reg = AFE_UL4_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2079: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2080- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2105- .int_odd_flag_reg = AFE_UL5_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2106: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2107- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2132- .int_odd_flag_reg = AFE_UL6_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2133: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2134- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2159- .int_odd_flag_reg = AFE_UL8_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2160: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2161- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2186- .int_odd_flag_reg = AFE_UL9_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2187: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2188- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2213- .int_odd_flag_reg = AFE_UL10_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2214: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2215- .enable_reg = AFE_DAC_CON0,
]
|
| 12/2 |
2026/05/21 22:52 |
llm |
debugger |
0m
Model:
Tokens:
input: 24382
output: 43
thoughts: 1676
Thoughts: **Refining the BEFS Superblock Checks**
Okay, so I'm looking at these checks in the BEFS superblock validation, specifically `befs_check_sb`. The current code has some potential issues with bit shifts. First, the `ag_shift` check:
```c
if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
```
If `befs_sb->ag_shift` is 32 or greater, this is going to lead to a shift-out-of-bounds, undefined behavior. The `block_shift` check also uses a similar bit-shift:
```c
if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
```
Let's break this down. For `block_shift`, the existing code checks for consistency with `block_size`. Since `block_size` is constrained to be one of 1024, 2048, 4096, or 8192, we're safe to assume the shift is within an acceptable range because we can validate it by checking if `befs_sb->block_shift == ilog2(befs_sb->block_size)`. I can use `ilog2` for this. Since `block_size` has already been validated, and we know `ilog2` is in `<linux/log2.h>`, this looks like a cleaner approach.
Now for `ag_shift`, we need to address the possibility of shift-out-of-bounds. We know `blocks_per_ag` is a 32-bit integer, which should mean `ag_shift` should be `< 32`. A simple check would be to see if `befs_sb->ag_shift >= 32` before the shift. However, if we're using a single-bit shift, we must use the unsigned equivalent.
After further consideration, to avoid the undefined behavior, the safest approach seems to be using an unsigned left-shift and checking for out-of-bounds. This simplifies the consistency check and handles the corner cases safely.
So I think a good fix would be:
```c
if (befs_sb->block_shift != ilog2(befs_sb->block_size)) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
if (befs_sb->ag_shift >= 32 || (1U << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
```
This ensures we avoid integer overflow and undefined behavior from shifting.
Wait, I need to consider `blocks_per_ag` can be zero, which might cause a problem with `ilog2`. So that should be dealt with. Let's make sure it's read from disk. Yes, it is. The unsigned shift also resolves this problem, so we're good to go.
|
| 13/2 |
2026/05/21 22:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/befs/super.c IncludeLines:true Name:befs_check_sb]
Results: map[SourceCode: 57: int
58: befs_check_sb(struct super_block *sb)
59: {
60: struct befs_sb_info *befs_sb = BEFS_SB(sb);
61:
62: /* Check magic headers of super block */
63: if ((befs_sb->magic1 != BEFS_SUPER_MAGIC1)
64: || (befs_sb->magic2 != BEFS_SUPER_MAGIC2)
65: || (befs_sb->magic3 != BEFS_SUPER_MAGIC3)) {
66: befs_error(sb, "invalid magic header");
67: return BEFS_ERR;
68: }
69:
70: /*
71: * Check blocksize of BEFS.
72: *
73: * Blocksize of BEFS is 1024, 2048, 4096 or 8192.
74: */
75:
76: if ((befs_sb->block_size != 1024)
77: && (befs_sb->block_size != 2048)
78: && (befs_sb->block_size != 4096)
79: && (befs_sb->block_size != 8192)) {
80: befs_error(sb, "invalid blocksize: %u", befs_sb->block_size);
81: return BEFS_ERR;
82: }
83:
84: if (befs_sb->block_size > PAGE_SIZE) {
85: befs_error(sb, "blocksize(%u) cannot be larger "
86: "than system pagesize(%lu)", befs_sb->block_size,
87: PAGE_SIZE);
88: return BEFS_ERR;
89: }
90:
91: /*
92: * block_shift and block_size encode the same information
93: * in different ways as a consistency check.
94: */
95:
96: if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
97: befs_error(sb, "block_shift disagrees with block_size. "
98: "Corruption likely.");
99: return BEFS_ERR;
100: }
101:
102:
103: /* ag_shift also encodes the same information as blocks_per_ag in a
104: * different way, non-fatal consistency check
105: */
106: if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
107: befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
108:
109: if (befs_sb->log_start != befs_sb->log_end ||
110: befs_sb->flags == BEFS_DIRTY) {
111: befs_error(sb, "Filesystem not clean! There are blocks in the "
112: "journal. You must boot into BeOS and mount this "
113: "volume to make it clean.");
114: return BEFS_ERR;
115: }
116:
117: return BEFS_OK;
118: }
SourceFile:fs/befs/super.c]
|
| 14/2 |
2026/05/21 22:53 |
llm |
debugger |
0m
Model:
Tokens:
input: 27845
output: 23
thoughts: 75
Thoughts: Okay, let me think this through.
**Fixing the `block_shift` Issue in BEFS**
Right, so it looks like the core of this BEFS problem stems from the `block_shift` value. The proposed fix, as I understand it, centers around ensuring that the base-2 logarithm of the block size (`ilog2(befs_sb->block_size)`) actually matches what's stored in the superblock (`befs_sb->block_shift`). Simple enough in principle. However, I need to make absolutely sure the code handles the `ilog2` function correctly.
Now, my immediate concern is, is `ilog2` even defined and available in this context? I seem to recall it being one of those handy utilities in the kernel. Let me double check β it should be in `linux/log2.h`, right? I'd better confirm that's included somewhere.
Okay, let me quickly navigate over to `fs/befs/super.c`. I need to verify that `linux/log2.h` (or some other header that defines `ilog2`) is being properly included there. This is a pretty straightforward check, but it's crucial to the entire logic working correctly. Gotta be precise here. No point in the fix if the function isn't available.
|
| 15/2 |
2026/05/21 22:53 |
tool |
read-file |
0m
Args: map[File:fs/befs/super.c]
Results: map[Contents:/*
* super.c
*
* Copyright (C) 2001-2002 Will Dyson <will_dyson@pobox.com>
*
* Licensed under the GNU GPL. See the file COPYING for details.
*
*/
#include <linux/fs.h>
#include <asm/page.h> /* for PAGE_SIZE */
#include "befs.h"
#include "super.h"
/*
* befs_load_sb -- Read from disk and properly byteswap all the fields
* of the befs superblock
*/
int
befs_load_sb(struct super_block *sb, befs_super_block *disk_sb)
{
struct befs_sb_info *befs_sb = BEFS_SB(sb);
/* Check the byte order of the filesystem */
if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_LE)
befs_sb->byte_order = BEFS_BYTESEX_LE;
else if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_BE)
befs_sb->byte_order = BEFS_BYTESEX_BE;
befs_sb->magic1 = fs32_to_cpu(sb, disk_sb->magic1);
befs_sb->magic2 = fs32_to_cpu(sb, disk_sb->magic2);
befs_sb->magic3 = fs32_to_cpu(sb, disk_sb->magic3);
befs_sb->block_size = fs32_to_cpu(sb, disk_sb->block_size);
befs_sb->block_shift = fs32_to_cpu(sb, disk_sb->block_shift);
befs_sb->num_blocks = fs64_to_cpu(sb, disk_sb->num_blocks);
befs_sb->used_blocks = fs64_to_cpu(sb, disk_sb->used_blocks);
befs_sb->inode_size = fs32_to_cpu(sb, disk_sb->inode_size);
befs_sb->blocks_per_ag = fs32_to_cpu(sb, disk_sb->blocks_per_ag);
befs_sb->ag_shift = fs32_to_cpu(sb, disk_sb->ag_shift);
befs_sb->num_ags = fs32_to_cpu(sb, disk_sb->num_ags);
befs_sb->flags = fs32_to_cpu(sb, disk_sb->flags);
befs_sb->log_blocks = fsrun_to_cpu(sb, disk_sb->log_blocks);
befs_sb->log_start = fs64_to_cpu(sb, disk_sb->log_start);
befs_sb->log_end = fs64_to_cpu(sb, disk_sb->log_end);
befs_sb->root_dir = fsrun_to_cpu(sb, disk_sb->root_dir);
befs_sb->indices = fsrun_to_cpu(sb, disk_sb->indices);
befs_sb->nls = NULL;
return BEFS_OK;
}
int
befs_check_sb(struct super_block *sb)
{
struct befs_sb_info *befs_sb = BEFS_SB(sb);
/* Check magic headers of super block */
if ((befs_sb->magic1 != BEFS_SUPER_MAGIC1)
|| (befs_sb->magic2 != BEFS_SUPER_MAGIC2)
|| (befs_sb->magic3 != BEFS_SUPER_MAGIC3)) {
befs_error(sb, "invalid magic header");
return BEFS_ERR;
}
/*
* Check blocksize of BEFS.
*
* Blocksize of BEFS is 1024, 2048, 4096 or 8192.
*/
if ((befs_sb->block_size != 1024)
&& (befs_sb->block_size != 2048)
&& (befs_sb->block_size != 4096)
&& (befs_sb->block_size != 8192)) {
befs_error(sb, "invalid blocksize: %u", befs_sb->block_size);
return BEFS_ERR;
}
if (befs_sb->block_size > PAGE_SIZE) {
befs_error(sb, "blocksize(%u) cannot be larger "
"than system pagesize(%lu)", befs_sb->block_size,
PAGE_SIZE);
return BEFS_ERR;
}
/*
* block_shift and block_size encode the same information
* in different ways as a consistency check.
*/
if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
/* ag_shift also encodes the same information as blocks_per_ag in a
* different way, non-fatal consistency check
*/
if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
if (befs_sb->log_start != befs_sb->log_end ||
befs_sb->flags == BEFS_DIRTY) {
befs_error(sb, "Filesystem not clean! There are blocks in the "
"journal. You must boot into BeOS and mount this "
"volume to make it clean.");
return BEFS_ERR;
}
return BEFS_OK;
}
]
|
| 16/2 |
2026/05/21 22:53 |
llm |
debugger |
0m
Model:
Tokens:
input: 29688
output: 16
thoughts: 62
Thoughts: **Investigating `ilog2` in the BeFS Filesystem**
Okay, so I'm looking at this `linux/log2.h` header. It's normally pulled in indirectly through `linux/fs.h`, which is pretty standard. But, hang on, there's `ilog2` available. Thatβs interesting. I'm curious about the specific use cases within the `fs/befs/` directory. I'm going to quickly check how and where `ilog2` is actually being utilized within this subsystem. Let's see if we're making the most of it or if there are any areas for potential optimization or modernization.
|
| 17/2 |
2026/05/21 22:53 |
tool |
grepper |
0m
Args:
Results: map[Output:
Full output is too long, showing 500 out of 7425 lines.
Use more precise expression if possible.
[arch/alpha/kernel/setup.c=1162=external_cache_probe(int minsize, int width)
--
arch/alpha/kernel/setup.c-1168- if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
arch/alpha/kernel/setup.c:1169: maxsize = 1 << (ilog2(max_low_pfn + 1) + PAGE_SHIFT);
arch/alpha/kernel/setup.c-1170-
--
arch/arm/include/asm/cpufeature.h-25-#define MAX_CPU_FEATURES 64
arch/arm/include/asm/cpufeature.h:26:#define __hwcap_feature(x) ilog2(HWCAP_ ## x)
arch/arm/include/asm/cpufeature.h:27:#define __hwcap2_feature(x) (32 + ilog2(HWCAP2_ ## x))
arch/arm/include/asm/cpufeature.h-28-#define cpu_feature(x) __hwcap2_feature(x)
--
arch/arm/mach-davinci/sram.c=49=static int __init sram_init(void)
--
arch/arm/mach-davinci/sram.c-57- len = min_t(unsigned, len, SRAM_SIZE);
arch/arm/mach-davinci/sram.c:58: sram_pool = gen_pool_create(ilog2(SRAM_GRANULARITY), -1);
arch/arm/mach-davinci/sram.c-59- if (!sram_pool)
--
arch/arm/mm/cache-l2x0.c=943=static int __init l2x0_cache_size_of_parse(const struct device_node *np,
--
arch/arm/mm/cache-l2x0.c-1009- */
arch/arm/mm/cache-l2x0.c:1010: way_size_bits = ilog2(way_size >> 10) - 3;
arch/arm/mm/cache-l2x0.c-1011- if (way_size_bits < 1 || way_size_bits > 6) {
--
arch/arm/mm/pmsa-v7.c=420=void __init pmsav7_setup(void)
--
arch/arm/mm/pmsa-v7.c-445-
arch/arm/mm/pmsa-v7.c:446: err |= mpu_setup_region(region++, xip[i].base, ilog2(xip[i].size),
arch/arm/mm/pmsa-v7.c-447- PMSAv7_AP_PL1RO_PL0NA | PMSAv7_RGN_NORMAL,
--
arch/arm/mm/pmsa-v7.c-456-
arch/arm/mm/pmsa-v7.c:457: err |= mpu_setup_region(region++, mem[i].base, ilog2(mem[i].size),
arch/arm/mm/pmsa-v7.c-458- PMSAv7_AP_PL1RW_PL0RW | PMSAv7_RGN_NORMAL,
--
arch/arm/mm/pmsa-v7.c-463-#ifndef CONFIG_CPU_V7M
arch/arm/mm/pmsa-v7.c:464: err |= mpu_setup_region(region++, vectors_base, ilog2(2 * PAGE_SIZE),
arch/arm/mm/pmsa-v7.c-465- PMSAv7_AP_PL1RW_PL0NA | PMSAv7_RGN_NORMAL,
--
arch/arm64/include/asm/hwcap.h-61- */
arch/arm64/include/asm/hwcap.h:62:#define __khwcap_feature(x) const_ilog2(HWCAP_ ## x)
arch/arm64/include/asm/hwcap.h:63:#define __khwcap2_feature(x) (const_ilog2(HWCAP2_ ## x) + 64)
arch/arm64/include/asm/hwcap.h:64:#define __khwcap3_feature(x) (const_ilog2(HWCAP3_ ## x) + 128)
arch/arm64/include/asm/hwcap.h-65-
--
arch/arm64/include/asm/pgtable.h=1574=static inline void update_mmu_cache_range(struct vm_fault *vmf,
--
arch/arm64/include/asm/pgtable.h-1618- */
arch/arm64/include/asm/pgtable.h:1619:#define exec_folio_order() ilog2(SZ_64K >> PAGE_SHIFT)
arch/arm64/include/asm/pgtable.h-1620-
--
arch/arm64/kernel/cpuinfo.c=50=static const char *const hwcap_str[] = {
--
arch/arm64/kernel/cpuinfo.c-169-#ifdef CONFIG_COMPAT
arch/arm64/kernel/cpuinfo.c:170:#define COMPAT_KERNEL_HWCAP(x) const_ilog2(COMPAT_HWCAP_ ## x)
arch/arm64/kernel/cpuinfo.c-171-static const char *const compat_hwcap_str[] = {
--
arch/arm64/kernel/cpuinfo.c-201-
arch/arm64/kernel/cpuinfo.c:202:#define COMPAT_KERNEL_HWCAP2(x) const_ilog2(COMPAT_HWCAP2_ ## x)
arch/arm64/kernel/cpuinfo.c-203-static const char *const compat_hwcap2_str[] = {
--
arch/arm64/kvm/vgic/vgic-mmio.h=37=extern const struct kvm_io_device_ops kvm_io_gic_ops;
--
arch/arm64/kvm/vgic/vgic-mmio.h-58-#define VGIC_ADDR_TO_INTID(addr, bits) (((addr) & VGIC_ADDR_IRQ_MASK(bits)) * \
arch/arm64/kvm/vgic/vgic-mmio.h:59: 8 >> ilog2(bits))
arch/arm64/kvm/vgic/vgic-mmio.h-60-
--
arch/csky/mm/asid.c=168=int asid_allocator_init(struct asid_info *info,
--
arch/csky/mm/asid.c-172- info->bits = bits;
arch/csky/mm/asid.c:173: info->ctxt_shift = ilog2(asid_per_ctxt);
arch/csky/mm/asid.c-174- info->flush_cpu_ctxt_cb = flush_cpu_ctxt_cb;
--
arch/loongarch/include/asm/cpufeature.h-16-
arch/loongarch/include/asm/cpufeature.h:17:#define cpu_feature(x) ilog2(HWCAP_ ## x)
arch/loongarch/include/asm/cpufeature.h-18-
--
arch/loongarch/include/asm/thread_info.h=54=register unsigned long current_stack_pointer __asm__("$sp");
--
arch/loongarch/include/asm/thread_info.h-60-#define THREAD_MASK (THREAD_SIZE - 1UL)
arch/loongarch/include/asm/thread_info.h:61:#define THREAD_SIZE_ORDER ilog2(THREAD_SIZE / PAGE_SIZE)
arch/loongarch/include/asm/thread_info.h-62-/*
--
arch/loongarch/kernel/dma.c=8=void acpi_arch_dma_setup(struct device *dev)
--
arch/loongarch/kernel/dma.c-17-
arch/loongarch/kernel/dma.c:18: mask = DMA_BIT_MASK(ilog2(end) + 1);
arch/loongarch/kernel/dma.c-19- dev->bus_dma_limit = end;
--
arch/loongarch/kernel/traps.c=436=static inline void setup_vint_size(unsigned int size)
--
arch/loongarch/kernel/traps.c-439-
arch/loongarch/kernel/traps.c:440: vs = ilog2(size/4);
arch/loongarch/kernel/traps.c-441-
--
arch/loongarch/lib/dump_tlb.c=28=static void dump_tlb(int first, int last)
--
arch/loongarch/lib/dump_tlb.c-37- int vwidth = 16;
arch/loongarch/lib/dump_tlb.c:38: int asidwidth = DIV_ROUND_UP(ilog2(asidmask) + 1, 4);
arch/loongarch/lib/dump_tlb.c-39-
--
arch/mips/bcm63xx/cs.c=35=int bcm63xx_set_cs_base(unsigned int cs, u32 base, unsigned int size)
--
arch/mips/bcm63xx/cs.c-51- /* 8k => 0 - 256M => 15 */
arch/mips/bcm63xx/cs.c:52: val |= (ilog2(size) - ilog2(8 * 1024)) << MPI_CSBASE_SIZE_SHIFT;
arch/mips/bcm63xx/cs.c-53-
--
arch/mips/include/asm/cpufeature.h-14-
arch/mips/include/asm/cpufeature.h:15:#define cpu_feature(x) ilog2(HWCAP_ ## x)
arch/mips/include/asm/cpufeature.h-16-
--
arch/mips/kvm/entry.c=233=static void *kvm_mips_build_enter_guest(void *addr)
--
arch/mips/kvm/entry.c-314- /* index the ASID array */
arch/mips/kvm/entry.c:315: uasm_i_sll(&p, GPR_T2, GPR_T2, ilog2(sizeof(long)));
arch/mips/kvm/entry.c-316- UASM_i_ADDU(&p, GPR_T3, GPR_T1, GPR_T2);
--
arch/mips/lib/dump_tlb.c=66=static void dump_tlb(int first, int last)
--
arch/mips/lib/dump_tlb.c-72- unsigned long asidmask = cpu_asid_mask(¤t_cpu_data);
arch/mips/lib/dump_tlb.c:73: int asidwidth = DIV_ROUND_UP(ilog2(asidmask) + 1, 4);
arch/mips/lib/dump_tlb.c-74- unsigned long s_mmid;
--
arch/mips/mm/tlb-r4k.c=586=static void __ref r4k_tlb_uniquify_read(struct tlbent *tlb_vpns, int tlbsize)
--
arch/mips/mm/tlb-r4k.c-610- vpn = (entryhi & vpn_mask & ~mask) >> VPN2_SHIFT;
arch/mips/mm/tlb-r4k.c:611: pagesz = ilog2((mask >> VPN2_SHIFT) + 1);
arch/mips/mm/tlb-r4k.c-612-
--
arch/mips/mm/tlb-r4k.c=642=static void __ref r4k_tlb_uniquify_write(struct tlbent *tlb_vpns, int tlbsize)
--
arch/mips/mm/tlb-r4k.c-647- vpn_size = 1ULL << (current_cpu_data.vmbits - VPN2_SHIFT);
arch/mips/mm/tlb-r4k.c:648: pagesz = ilog2((PM_4K >> VPN2_SHIFT) + 1);
arch/mips/mm/tlb-r4k.c-649-
--
arch/mips/mm/tlbex.c=333=static struct work_registers build_get_work_registers(u32 **p)
--
arch/mips/mm/tlbex.c-351- /* handler_reg_save index in GPR_K0 */
arch/mips/mm/tlbex.c:352: UASM_i_SLL(p, GPR_K0, GPR_K0, ilog2(sizeof(struct tlb_reg_save)));
arch/mips/mm/tlbex.c-353-
--
arch/mips/mm/tlbex.c=583=static __maybe_unused void build_convert_pte_to_entrylo(u32 **p,
--
arch/mips/mm/tlbex.c-592- if (fill_includes_sw_bits) {
arch/mips/mm/tlbex.c:593: UASM_i_ROTR(p, reg, reg, ilog2(_PAGE_GLOBAL));
arch/mips/mm/tlbex.c-594- } else {
arch/mips/mm/tlbex.c:595: UASM_i_SRL(p, reg, reg, ilog2(_PAGE_NO_EXEC));
arch/mips/mm/tlbex.c-596- UASM_i_ROTR(p, reg, reg,
arch/mips/mm/tlbex.c:597: ilog2(_PAGE_GLOBAL) - ilog2(_PAGE_NO_EXEC));
arch/mips/mm/tlbex.c-598- }
--
arch/mips/mm/tlbex.c-600-#ifdef CONFIG_PHYS_ADDR_T_64BIT
arch/mips/mm/tlbex.c:601: uasm_i_dsrl_safe(p, reg, reg, ilog2(_PAGE_GLOBAL));
arch/mips/mm/tlbex.c-602-#else
arch/mips/mm/tlbex.c:603: UASM_i_SRL(p, reg, reg, ilog2(_PAGE_GLOBAL));
arch/mips/mm/tlbex.c-604-#endif
--
arch/mips/mm/tlbex.c=678=build_is_huge_pte(u32 **p, struct uasm_reloc **r, unsigned int tmp,
--
arch/mips/mm/tlbex.c-682- if (use_bbit_insns()) {
arch/mips/mm/tlbex.c:683: uasm_il_bbit1(p, r, tmp, ilog2(_PAGE_HUGE), lid);
arch/mips/mm/tlbex.c-684- } else {
--
arch/mips/mm/tlbex.c=991=void build_update_entries(u32 **p, unsigned int tmp, unsigned int ptep)
--
arch/mips/mm/tlbex.c-1003- uasm_i_lw(p, tmp, pte_off_even, ptep); /* even pte */
arch/mips/mm/tlbex.c:1004: UASM_i_ROTR(p, tmp, tmp, ilog2(_PAGE_GLOBAL));
arch/mips/mm/tlbex.c-1005- UASM_i_MTC0(p, tmp, C0_ENTRYLO0);
--
arch/mips/mm/tlbex.c-1013- uasm_i_lw(p, tmp, pte_off_odd, ptep); /* odd pte */
arch/mips/mm/tlbex.c:1014: UASM_i_ROTR(p, tmp, tmp, ilog2(_PAGE_GLOBAL));
arch/mips/mm/tlbex.c-1015- UASM_i_MTC0(p, tmp, C0_ENTRYLO1);
--
arch/mips/mm/tlbex.c=1049=build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l,
--
arch/mips/mm/tlbex.c-1177-#ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT
arch/mips/mm/tlbex.c:1178: uasm_il_bbit1(p, r, scratch, ilog2(_PAGE_HUGE), label_tlb_huge_update);
arch/mips/mm/tlbex.c-1179- /*
--
arch/mips/mm/tlbex.c-1203- if (cpu_has_rixi) {
arch/mips/mm/tlbex.c:1204: uasm_i_drotr(p, even, even, ilog2(_PAGE_GLOBAL));
arch/mips/mm/tlbex.c-1205- UASM_i_MTC0(p, even, C0_ENTRYLO0); /* load it */
arch/mips/mm/tlbex.c:1206: uasm_i_drotr(p, odd, odd, ilog2(_PAGE_GLOBAL));
arch/mips/mm/tlbex.c-1207- } else {
arch/mips/mm/tlbex.c:1208: uasm_i_dsrl_safe(p, even, even, ilog2(_PAGE_GLOBAL));
arch/mips/mm/tlbex.c-1209- UASM_i_MTC0(p, even, C0_ENTRYLO0); /* load it */
arch/mips/mm/tlbex.c:1210: uasm_i_dsrl_safe(p, odd, odd, ilog2(_PAGE_GLOBAL));
arch/mips/mm/tlbex.c-1211- }
--
arch/mips/mm/tlbex.c=1426=static void setup_pw(void)
--
arch/mips/mm/tlbex.c-1437-
arch/mips/mm/tlbex.c:1438: psn = ilog2(_PAGE_HUGE); /* bit used to indicate huge page */
arch/mips/mm/tlbex.c-1439-#endif
--
arch/mips/mm/tlbex.c-1452-
arch/mips/mm/tlbex.c:1453: pte_i = ilog2(_PAGE_GLOBAL);
arch/mips/mm/tlbex.c-1454- pte_w = 0;
--
arch/mips/mm/tlbex.c=1703=build_pte_present(u32 **p, struct uasm_reloc **r,
--
arch/mips/mm/tlbex.c-1710- if (use_bbit_insns()) {
arch/mips/mm/tlbex.c:1711: uasm_il_bbit0(p, r, pte, ilog2(_PAGE_PRESENT), lid);
arch/mips/mm/tlbex.c-1712- uasm_i_nop(p);
--
arch/mips/mm/tlbex.c=1795=build_pte_modifiable(u32 **p, struct uasm_reloc **r,
--
arch/mips/mm/tlbex.c-1799- if (use_bbit_insns()) {
arch/mips/mm/tlbex.c:1800: uasm_il_bbit0(p, r, pte, ilog2(_PAGE_WRITE), lid);
arch/mips/mm/tlbex.c-1801- uasm_i_nop(p);
--
arch/mips/mm/tlbex.c=2054=static void build_r4000_tlb_load_handler(void)
--
arch/mips/mm/tlbex.c-2089- if (use_bbit_insns()) {
arch/mips/mm/tlbex.c:2090: uasm_il_bbit0(&p, &r, wr.r1, ilog2(_PAGE_VALID),
arch/mips/mm/tlbex.c-2091- label_tlbl_goaround1);
--
arch/mips/mm/tlbex.c-2112- if (use_bbit_insns()) {
arch/mips/mm/tlbex.c:2113: uasm_i_bbit0(&p, wr.r2, ilog2(sizeof(pte_t)), 8);
arch/mips/mm/tlbex.c-2114- } else {
--
arch/mips/mm/tlbex.c-2155- if (use_bbit_insns()) {
arch/mips/mm/tlbex.c:2156: uasm_il_bbit0(&p, &r, wr.r1, ilog2(_PAGE_VALID),
arch/mips/mm/tlbex.c-2157- label_tlbl_goaround2);
--
arch/mips/mm/tlbex.c-2178- if (use_bbit_insns()) {
arch/mips/mm/tlbex.c:2179: uasm_i_bbit0(&p, wr.r2, ilog2(sizeof(pte_t)), 8);
arch/mips/mm/tlbex.c-2180- } else {
--
arch/mips/mm/tlbex.c=2398=static void config_htw_params(void)
--
arch/mips/mm/tlbex.c-2441-
arch/mips/mm/tlbex.c:2442: pwsize = ilog2(PTRS_PER_PGD) << MIPS_PWSIZE_GDW_SHIFT;
arch/mips/mm/tlbex.c:2443: pwsize |= ilog2(PTRS_PER_PTE) << MIPS_PWSIZE_PTW_SHIFT;
arch/mips/mm/tlbex.c-2444- if (CONFIG_PGTABLE_LEVELS >= 3)
arch/mips/mm/tlbex.c:2445: pwsize |= ilog2(PTRS_PER_PMD) << MIPS_PWSIZE_MDW_SHIFT;
arch/mips/mm/tlbex.c-2446-
--
arch/mips/mm/tlbex.c=2494=static void check_pabits(void)
--
arch/mips/mm/tlbex.c-2522-
arch/mips/mm/tlbex.c:2523: if (fillbits >= ilog2(_PAGE_NO_EXEC))
arch/mips/mm/tlbex.c-2524- fill_includes_sw_bits = true;
--
arch/mips/net/bpf_jit_comp.c=247=bool rewrite_alu_i(u8 op, s32 imm, u8 *alu, s32 *val)
--
arch/mips/net/bpf_jit_comp.c-271- op = BPF_LSH;
arch/mips/net/bpf_jit_comp.c:272: imm = ilog2(abs(imm));
arch/mips/net/bpf_jit_comp.c-273- }
--
arch/mips/net/bpf_jit_comp.c-281- op = BPF_RSH;
arch/mips/net/bpf_jit_comp.c:282: imm = ilog2(imm);
arch/mips/net/bpf_jit_comp.c-283- }
--
arch/nios2/kernel/cpuinfo.c=31=void __init setup_cpuinfo(void)
--
arch/nios2/kernel/cpuinfo.c-98- cpuinfo.tlb_pid_num_bits = fcpu(cpu, "altr,pid-num-bits");
arch/nios2/kernel/cpuinfo.c:99: cpuinfo.tlb_num_ways_log2 = ilog2(cpuinfo.tlb_num_ways);
arch/nios2/kernel/cpuinfo.c-100- cpuinfo.tlb_num_entries = fcpu(cpu, "altr,tlb-num-entries");
--
arch/powerpc/boot/cuboot-pq2.c=120=static void fixup_pci(void)
--
arch/powerpc/boot/cuboot-pq2.c-206-
arch/powerpc/boot/cuboot-pq2.c:207: mem_pow2 = 1 << (__ilog2_u32(bd.bi_memsize - 1) + 1);
arch/powerpc/boot/cuboot-pq2.c-208- mem_mask = ~(mem_pow2 - 1) >> 12;
--
arch/powerpc/boot/ops.h=248=static inline __attribute__((const))
arch/powerpc/boot/ops.h:249:int __ilog2_u32(u32 n)
arch/powerpc/boot/ops.h-250-{
--
arch/powerpc/include/asm/bitops.h=257=static inline void arch___clear_bit_unlock(int nr, volatile unsigned long *addr)
--
arch/powerpc/include/asm/bitops.h-266- */
arch/powerpc/include/asm/bitops.h:267:#define __ilog2(x) ilog2(x)
arch/powerpc/include/asm/bitops.h-268-
--
arch/powerpc/include/asm/cpufeature.h-20- *
arch/powerpc/include/asm/cpufeature.h:21: * #define PPC_MODULE_FEATURE_32 (ilog2(PPC_FEATURE_32))
arch/powerpc/include/asm/cpufeature.h-22- */
arch/powerpc/include/asm/cpufeature.h-23-
arch/powerpc/include/asm/cpufeature.h:24:#define PPC_MODULE_FEATURE_VEC_CRYPTO (32 + ilog2(PPC_FEATURE2_VEC_CRYPTO))
arch/powerpc/include/asm/cpufeature.h:25:#define PPC_MODULE_FEATURE_P10 (32 + ilog2(PPC_FEATURE2_ARCH_3_1))
arch/powerpc/include/asm/cpufeature.h-26-
--
arch/powerpc/include/asm/iommu.h=129=int get_iommu_order(unsigned long size, struct iommu_table *tbl)
arch/powerpc/include/asm/iommu.h-130-{
arch/powerpc/include/asm/iommu.h:131: return __ilog2((size - 1) >> tbl->it_page_shift) + 1;
arch/powerpc/include/asm/iommu.h-132-}
--
arch/powerpc/kernel/setup-common.c=391=static void __init cpu_init_thread_core_maps(int tpc)
--
arch/powerpc/kernel/setup-common.c-401- */
arch/powerpc/kernel/setup-common.c:402: threads_shift = ilog2(tpc);
arch/powerpc/kernel/setup-common.c-403- BUG_ON(tpc != (1 << threads_shift));
--
arch/powerpc/kernel/setup_64.c=547=static void __init init_cache_info(struct ppc_cache_info *info, u32 size, u32 lsize,
--
arch/powerpc/kernel/setup_64.c-553- info->block_size = bsize;
arch/powerpc/kernel/setup_64.c:554: info->log_block_size = __ilog2(bsize);
arch/powerpc/kernel/setup_64.c-555- if (bsize)
--
arch/powerpc/kernel/sysfs.c=243=static unsigned int get_idle_ticks_bit(u64 ns)
--
arch/powerpc/kernel/sysfs.c-254-
arch/powerpc/kernel/sysfs.c:255: return ilog2(cycle);
arch/powerpc/kernel/sysfs.c-256-}
--
arch/powerpc/kvm/book3s_hv.c=5469=static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
--
arch/powerpc/kvm/book3s_hv.c-5526- psize = 0x1000;
arch/powerpc/kvm/book3s_hv.c:5527: porder = __ilog2(psize);
arch/powerpc/kvm/book3s_hv.c-5528-
--
arch/powerpc/kvm/e500_mmu.c=731=int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu,
--
arch/powerpc/kvm/e500_mmu.c-762-
arch/powerpc/kvm/e500_mmu.c:763: sets = params.tlb_sizes[0] >> ilog2(params.tlb_ways[0]);
arch/powerpc/kvm/e500_mmu.c-764- if (!is_power_of_2(sets))
--
arch/powerpc/kvm/e500_mmu_host.c=187=void inval_gtlbe_on_host(struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel,
--
arch/powerpc/kvm/e500_mmu_host.c-207- while (tmp) {
arch/powerpc/kvm/e500_mmu_host.c:208: hw_tlb_indx = __ilog2_u64(tmp & -tmp);
arch/powerpc/kvm/e500_mmu_host.c-209- mtspr(SPRN_MAS0,
--
arch/powerpc/mm/book3s32/mmu.c=346=void __init MMU_init_hw(void)
--
arch/powerpc/mm/book3s32/mmu.c-366- n_hpteg = MIN_N_HPTEG;
arch/powerpc/mm/book3s32/mmu.c:367: lg_n_hpteg = __ilog2(n_hpteg);
arch/powerpc/mm/book3s32/mmu.c-368- if (n_hpteg & (n_hpteg - 1)) {
--
arch/powerpc/mm/book3s64/hash_utils.c=1176=unsigned htab_shift_for_mem_size(unsigned long mem_size)
arch/powerpc/mm/book3s64/hash_utils.c-1177-{
arch/powerpc/mm/book3s64/hash_utils.c:1178: unsigned memshift = __ilog2(mem_size);
arch/powerpc/mm/book3s64/hash_utils.c-1179- unsigned pshift = mmu_psize_defs[mmu_virtual_psize].shift;
--
arch/powerpc/mm/book3s64/hash_utils.c=1278=static void __init hash_init_partition_table(phys_addr_t hash_table,
--
arch/powerpc/mm/book3s64/hash_utils.c-1286- */
arch/powerpc/mm/book3s64/hash_utils.c:1287: htab_size = __ilog2(htab_size) - 18;
arch/powerpc/mm/book3s64/hash_utils.c-1288- mmu_partition_table_set_entry(0, hash_table | htab_size, 0, false);
--
arch/powerpc/mm/book3s64/hash_utils.c=1309=static void __init htab_initialize(void)
--
arch/powerpc/mm/book3s64/hash_utils.c-1388- /* htab absolute addr + encoded htabsize */
arch/powerpc/mm/book3s64/hash_utils.c:1389: _SDR1 = table + __ilog2(htab_size_bytes) - 18;
arch/powerpc/mm/book3s64/hash_utils.c-1390-
--
arch/powerpc/mm/nohash/e500.c=97=static void settlbcam(int index, unsigned long virt, phys_addr_t phys,
--
arch/powerpc/mm/nohash/e500.c-101-
arch/powerpc/mm/nohash/e500.c:102: tsize = __ilog2(size) - 10;
arch/powerpc/mm/nohash/e500.c-103-
--
arch/powerpc/mm/nohash/e500.c=138=static unsigned long calc_cam_sz(unsigned long ram, unsigned long virt,
--
arch/powerpc/mm/nohash/e500.c-140-{
arch/powerpc/mm/nohash/e500.c:141: unsigned int camsize = __ilog2(ram);
arch/powerpc/mm/nohash/e500.c-142- unsigned int align = __ffs(virt | phys);
--
arch/powerpc/mm/nohash/e500.c-151- /* Convert (2^max) kB to (2^max) bytes */
arch/powerpc/mm/nohash/e500.c:152: max_cam = __ilog2(mfspr(SPRN_TLB1PS)) + 10;
arch/powerpc/mm/nohash/e500.c-153- }
--
arch/powerpc/mm/nohash/e500_hugetlbpage.c=119=book3e_hugetlb_preload(struct vm_area_struct *vma, unsigned long ea, pte_t pte)
--
arch/powerpc/mm/nohash/e500_hugetlbpage.c-133- psize = vma_mmu_pagesize(vma);
arch/powerpc/mm/nohash/e500_hugetlbpage.c:134: shift = __ilog2(psize);
arch/powerpc/mm/nohash/e500_hugetlbpage.c-135- tsize = shift - 10;
--
arch/powerpc/net/bpf_jit_comp32.c=322=int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct codegen_context *ctx,
--
arch/powerpc/net/bpf_jit_comp32.c-456- } else if (is_power_of_2((u32)imm)) {
arch/powerpc/net/bpf_jit_comp32.c:457: EMIT(PPC_RAW_SLWI(dst_reg, src2_reg, ilog2(imm)));
arch/powerpc/net/bpf_jit_comp32.c-458- } else if (imm >= -32768 && imm < 32768) {
--
arch/powerpc/net/bpf_jit_comp32.c-475- } else if (imm > 0 && is_power_of_2(imm)) {
arch/powerpc/net/bpf_jit_comp32.c:476: imm = ilog2(imm);
arch/powerpc/net/bpf_jit_comp32.c-477- EMIT(PPC_RAW_RLWINM(dst_reg_h, src2_reg_h, imm, 0, 31 - imm));
--
arch/powerpc/net/bpf_jit_comp32.c-515- if (off)
arch/powerpc/net/bpf_jit_comp32.c:516: EMIT(PPC_RAW_SRAWI(dst_reg, src2_reg, ilog2(imm)));
arch/powerpc/net/bpf_jit_comp32.c-517- else
arch/powerpc/net/bpf_jit_comp32.c:518: EMIT(PPC_RAW_SRWI(dst_reg, src2_reg, ilog2(imm)));
arch/powerpc/net/bpf_jit_comp32.c-519- } else {
--
arch/powerpc/net/bpf_jit_comp32.c-542- } else if (off) {
arch/powerpc/net/bpf_jit_comp32.c:543: EMIT(PPC_RAW_SRAWI(_R0, src2_reg, ilog2(imm)));
arch/powerpc/net/bpf_jit_comp32.c-544- EMIT(PPC_RAW_ADDZE(_R0, _R0));
arch/powerpc/net/bpf_jit_comp32.c:545: EMIT(PPC_RAW_SLWI(_R0, _R0, ilog2(imm)));
arch/powerpc/net/bpf_jit_comp32.c-546- EMIT(PPC_RAW_SUB(dst_reg, src2_reg, _R0));
arch/powerpc/net/bpf_jit_comp32.c-547- } else {
arch/powerpc/net/bpf_jit_comp32.c:548: imm = ilog2((u32)imm);
arch/powerpc/net/bpf_jit_comp32.c-549- EMIT(PPC_RAW_RLWINM(dst_reg, src2_reg, 0, 32 - imm, 31));
--
arch/powerpc/net/bpf_jit_comp32.c-565- EMIT(PPC_RAW_SUBFC(dst_reg, dst_reg_h, dst_reg));
arch/powerpc/net/bpf_jit_comp32.c:566: EMIT(PPC_RAW_RLWINM(dst_reg, dst_reg, 0, 32 - ilog2(imm), 31));
arch/powerpc/net/bpf_jit_comp32.c-567- EMIT(PPC_RAW_XOR(dst_reg, dst_reg, dst_reg_h));
--
arch/powerpc/net/bpf_jit_comp32.c-570- } else {
arch/powerpc/net/bpf_jit_comp32.c:571: EMIT(PPC_RAW_RLWINM(dst_reg, src2_reg, 0, 32 - ilog2(imm), 31));
arch/powerpc/net/bpf_jit_comp32.c-572- EMIT(PPC_RAW_LI(dst_reg_h, 0));
--
arch/powerpc/net/bpf_jit_comp32.c-590- } else {
arch/powerpc/net/bpf_jit_comp32.c:591: imm = ilog2(imm);
arch/powerpc/net/bpf_jit_comp32.c-592- EMIT(PPC_RAW_RLWINM(dst_reg, src2_reg, 32 - imm, imm, 31));
--
arch/powerpc/platforms/44x/pci.c=201=static int __init ppc4xx_setup_one_pci_PMM(struct pci_controller *hose,
--
arch/powerpc/platforms/44x/pci.c-232- }
arch/powerpc/platforms/44x/pci.c:233: ma = (0xffffffffu << ilog2(size)) | 1;
arch/powerpc/platforms/44x/pci.c-234- if (flags & IORESOURCE_PREFETCH)
--
arch/powerpc/platforms/44x/pci.c=291=static void __init ppc4xx_configure_pci_PTMs(struct pci_controller *hose,
--
arch/powerpc/platforms/44x/pci.c-298- /* Calculate window size */
arch/powerpc/platforms/44x/pci.c:299: sa = (0xffffffffu << ilog2(size)) | 1;
arch/powerpc/platforms/44x/pci.c-300- sa |= 0x1;
--
arch/powerpc/platforms/44x/pci.c=405=static int __init ppc4xx_setup_one_pcix_POM(struct pci_controller *hose,
--
arch/powerpc/platforms/44x/pci.c-426- pcial = RES_TO_U32_LOW(pci_addr);
arch/powerpc/platforms/44x/pci.c:427: sa = (0xffffffffu << ilog2(size)) | 0x1;
arch/powerpc/platforms/44x/pci.c-428-
--
arch/powerpc/platforms/44x/pci.c=490=static void __init ppc4xx_configure_pcix_PIMs(struct pci_controller *hose,
--
arch/powerpc/platforms/44x/pci.c-503- /* Calculate window size */
arch/powerpc/platforms/44x/pci.c:504: sa = (0xffffffffu << ilog2(size)) | 1;
arch/powerpc/platforms/44x/pci.c-505- sa |= 0x1;
--
arch/powerpc/platforms/44x/pci.c=1600=static int __init ppc4xx_setup_one_pciex_POM(struct ppc4xx_pciex_port *port,
--
arch/powerpc/platforms/44x/pci.c-1623- pcial = RES_TO_U32_LOW(pci_addr);
arch/powerpc/platforms/44x/pci.c:1624: sa = (0xffffffffu << ilog2(size)) | 0x1;
arch/powerpc/platforms/44x/pci.c-1625-
--
arch/powerpc/platforms/44x/pci.c=1730=static void __init ppc4xx_configure_pciex_PIMs(struct ppc4xx_pciex_port *port,
--
arch/powerpc/platforms/44x/pci.c-1747- /* Calculate window size */
arch/powerpc/platforms/44x/pci.c:1748: sa = (0xffffffffffffffffull << ilog2(ep_size));
arch/powerpc/platforms/44x/pci.c-1749-
--
arch/powerpc/platforms/44x/pci.c-1766- /* Calculate window size */
arch/powerpc/platforms/44x/pci.c:1767: sa = (0xffffffffffffffffull << ilog2(size));
arch/powerpc/platforms/44x/pci.c-1768- if (res->flags & IORESOURCE_PREFETCH)
--
arch/powerpc/platforms/powermac/pic.c=203=static irqreturn_t gatwick_action(int cpl, void *dev_id)
--
arch/powerpc/platforms/powermac/pic.c-216- continue;
arch/powerpc/platforms/powermac/pic.c:217: irq += __ilog2(bits);
arch/powerpc/platforms/powermac/pic.c-218- raw_spin_unlock_irqrestore(&pmac_pic_lock, flags);
--
arch/powerpc/platforms/powermac/pic.c=227=static unsigned int pmac_pic_get_irq(void)
--
arch/powerpc/platforms/powermac/pic.c-246- continue;
arch/powerpc/platforms/powermac/pic.c:247: irq += __ilog2(bits);
arch/powerpc/platforms/powermac/pic.c-248- break;
--
arch/powerpc/platforms/powernv/eeh-powernv.c=172=int pnv_eeh_post_init(void)
--
arch/powerpc/platforms/powernv/eeh-powernv.c-180- /* Register OPAL event notifier */
arch/powerpc/platforms/powernv/eeh-powernv.c:181: eeh_event_irq = opal_event_request(ilog2(OPAL_EVENT_PCI_ERROR));
arch/powerpc/platforms/powernv/eeh-powernv.c-182- if (eeh_event_irq < 0) {
--
arch/powerpc/platforms/powernv/opal-dump.c=418=void __init opal_platform_dump_init(void)
--
arch/powerpc/platforms/powernv/opal-dump.c-440-
arch/powerpc/platforms/powernv/opal-dump.c:441: dump_irq = opal_event_request(ilog2(OPAL_EVENT_DUMP_AVAIL));
arch/powerpc/platforms/powernv/opal-dump.c-442- if (!dump_irq) {
--
arch/powerpc/platforms/powernv/opal-elog.c=306=int __init opal_elog_init(void)
--
arch/powerpc/platforms/powernv/opal-elog.c-319-
arch/powerpc/platforms/powernv/opal-elog.c:320: irq = opal_event_request(ilog2(OPAL_EVENT_ERROR_LOG_AVAIL));
arch/powerpc/platforms/powernv/opal-elog.c-321- if (!irq) {
--
arch/powerpc/platforms/powernv/opal.c=385=static int __init opal_message_init(struct device_node *opal_node)
--
arch/powerpc/platforms/powernv/opal.c-405-
arch/powerpc/platforms/powernv/opal.c:406: irq = opal_event_request(ilog2(OPAL_EVENT_MSG_PENDING));
arch/powerpc/platforms/powernv/opal.c-407- if (!irq) {
--
arch/powerpc/platforms/powernv/pci-ioda-tce.c=83=static __be64 *pnv_tce(struct iommu_table *tbl, bool user, long idx, bool alloc)
--
arch/powerpc/platforms/powernv/pci-ioda-tce.c-86- int level = tbl->it_indirect_levels;
arch/powerpc/platforms/powernv/pci-ioda-tce.c:87: const long shift = ilog2(tbl->it_level_size);
arch/powerpc/platforms/powernv/pci-ioda-tce.c-88- unsigned long mask = (tbl->it_level_size - 1) << (level * shift);
--
arch/powerpc/platforms/powernv/pci-ioda-tce.c-100- tmp2 = pnv_alloc_tce_level(tbl->it_nid,
arch/powerpc/platforms/powernv/pci-ioda-tce.c:101: ilog2(tbl->it_level_size) + 3);
arch/powerpc/platforms/powernv/pci-ioda-tce.c-102- if (!tmp2)
--
arch/powerpc/platforms/powernv/pci-ioda-tce.c-109- pnv_pci_ioda2_table_do_free_pages(tmp2,
arch/powerpc/platforms/powernv/pci-ioda-tce.c:110: ilog2(tbl->it_level_size) + 3, 1);
arch/powerpc/platforms/powernv/pci-ioda-tce.c-111- tce = oldtce;
--
arch/powerpc/platforms/powernv/pci-ioda-tce.c=290=long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,
--
arch/powerpc/platforms/powernv/pci-ioda-tce.c-296- unsigned long total_allocated_uas = 0;
arch/powerpc/platforms/powernv/pci-ioda-tce.c:297: const unsigned int window_shift = ilog2(window_size);
arch/powerpc/platforms/powernv/pci-ioda-tce.c-298- unsigned int entries_shift = window_shift - page_shift;
]
]
|
| 18/2 |
2026/05/21 22:53 |
llm |
debugger |
0m
Model:
Tokens:
input: 42795
output: 21
thoughts: 1418
Thoughts: **Refining the Block and AG Shift Validation**
Okay, so I'm looking at how `block_shift` and `ag_shift` are handled in this BEFS superblock code. I've got `ilog2` in mind β it's generally available, and I can just include `<linux/log2.h>`.
First, the `block_size` check. The code validates that `befs_sb->block_size` is one of the standard sizes: 1024, 2048, 4096, or 8192. So, taking the `ilog2` of it seems safe and clean. No need for any risky bit shifts. This is the simplest and best solution.
```c
if (befs_sb->block_shift != ilog2(befs_sb->block_size)) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
```
Now, onto `ag_shift`. The original code has a potentially dangerous bit shift with `1 << befs_sb->ag_shift`. If `ag_shift` is 32 or greater, this is undefined behavior for 32-bit `int`s. This means that this line has to be evaluated in a different way.
I could use `ilog2` here, too. I'd need to add a check for if `blocks_per_ag` is zero. Then, I remembered that `is_power_of_2` is also defined in `<linux/log2.h>`. This is the perfect solution.
```c
if (!is_power_of_2(befs_sb->blocks_per_ag) ||
befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
```
This ensures `blocks_per_ag` is a power of 2, and then verifies the shift. Also, it properly handles the case where `blocks_per_ag` is zero. This is a significant improvement because it's both correct and readable. This is very clean.
|
| 19/2 |
2026/05/21 22:53 |
tool |
grepper |
0m
Args: map[Expression:is_power_of_2]
Results: map[Output:
Full output is too long, showing 500 out of 2998 lines.
Use more precise expression if possible.
[arch/arc/mm/cache.c=933=static noinline void __init arc_ioc_setup(void)
--
arch/arc/mm/cache.c-964-
arch/arc/mm/cache.c:965: if (!is_power_of_2(mem_sz) || mem_sz < 4096)
arch/arc/mm/cache.c-966- panic("IOC Aperture size must be power of 2 larger than 4KB");
--
arch/arm/mm/cache-uniphier.c=315=static int __init __uniphier_cache_init(struct device_node *np,
--
arch/arm/mm/cache-uniphier.c-349- if (of_property_read_u32(np, "cache-line-size", &data->line_size) ||
arch/arm/mm/cache-uniphier.c:350: !is_power_of_2(data->line_size)) {
arch/arm/mm/cache-uniphier.c-351- pr_err("L%d: cache-line-size is unspecified or invalid\n",
--
arch/arm/mm/cache-uniphier.c-357- if (of_property_read_u32(np, "cache-sets", &data->nsets) ||
arch/arm/mm/cache-uniphier.c:358: !is_power_of_2(data->nsets)) {
arch/arm/mm/cache-uniphier.c-359- pr_err("L%d: cache-sets is unspecified or invalid\n",
--
arch/microblaze/mm/pgtable.c=166=void __init mapin_ram(void)
--
arch/microblaze/mm/pgtable.c-187-/* is x a power of 2? */
arch/microblaze/mm/pgtable.c:188:#define is_power_of_2(x) ((x) != 0 && (((x) & ((x) - 1)) == 0))
arch/microblaze/mm/pgtable.c-189-
--
arch/mips/net/bpf_jit_comp.c=211=bool valid_alu_i(u8 op, s32 imm)
--
arch/mips/net/bpf_jit_comp.c-236- /* imm must be zero or a positive power of two */
arch/mips/net/bpf_jit_comp.c:237: return imm == 0 || (imm > 0 && is_power_of_2(imm));
arch/mips/net/bpf_jit_comp.c-238- case BPF_DIV:
--
arch/mips/net/bpf_jit_comp.c-240- /* imm must be an 17-bit power of two */
arch/mips/net/bpf_jit_comp.c:241: return (u32)imm <= 0x10000 && is_power_of_2((u32)imm);
arch/mips/net/bpf_jit_comp.c-242- }
--
arch/powerpc/kvm/book3s.c=934=int kvmppc_h_logical_ci_load(struct kvm_vcpu *vcpu)
--
arch/powerpc/kvm/book3s.c-941-
arch/powerpc/kvm/book3s.c:942: if (!is_power_of_2(size) || (size > sizeof(buf)))
arch/powerpc/kvm/book3s.c-943- return H_TOO_HARD;
--
arch/powerpc/kvm/book3s_hv.c=3095=static int kvmhv_set_smt_mode(struct kvm *kvm, unsigned long smt_mode,
--
arch/powerpc/kvm/book3s_hv.c-3102- return -EINVAL;
arch/powerpc/kvm/book3s_hv.c:3103: if (smt_mode > MAX_SMT_THREADS || !is_power_of_2(smt_mode))
arch/powerpc/kvm/book3s_hv.c-3104- return -EINVAL;
--
arch/powerpc/kvm/e500_mmu.c=731=int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu,
--
arch/powerpc/kvm/e500_mmu.c-759-
arch/powerpc/kvm/e500_mmu.c:760: if (!is_power_of_2(params.tlb_ways[0]))
arch/powerpc/kvm/e500_mmu.c-761- return -EINVAL;
--
arch/powerpc/kvm/e500_mmu.c-763- sets = params.tlb_sizes[0] >> ilog2(params.tlb_ways[0]);
arch/powerpc/kvm/e500_mmu.c:764: if (!is_power_of_2(sets))
arch/powerpc/kvm/e500_mmu.c-765- return -EINVAL;
--
arch/powerpc/kvm/e500_mmu_host.c=711=int e500_mmu_host_init(struct kvmppc_vcpu_e500 *vcpu_e500)
--
arch/powerpc/kvm/e500_mmu_host.c-730-
arch/powerpc/kvm/e500_mmu_host.c:731: if (!is_power_of_2(host_tlb_params[0].entries) ||
arch/powerpc/kvm/e500_mmu_host.c:732: !is_power_of_2(host_tlb_params[0].ways) ||
arch/powerpc/kvm/e500_mmu_host.c-733- host_tlb_params[0].entries < host_tlb_params[0].ways ||
--
arch/powerpc/mm/hugetlbpage.c=137=bool __init arch_hugetlb_valid_size(unsigned long size)
--
arch/powerpc/mm/hugetlbpage.c-143- * that it fits within pagetable and slice limits. */
arch/powerpc/mm/hugetlbpage.c:144: if (size <= PAGE_SIZE || !is_power_of_2(size))
arch/powerpc/mm/hugetlbpage.c-145- return false;
--
arch/powerpc/mm/init-common.c=118=void pgtable_cache_add(unsigned int shift)
--
arch/powerpc/mm/init-common.c-131- /* It would be nice if this was a BUILD_BUG_ON(), but at the
arch/powerpc/mm/init-common.c:132: * moment, gcc doesn't seem to recognize is_power_of_2 as a
arch/powerpc/mm/init-common.c-133- * constant expression, so so much for that. */
arch/powerpc/mm/init-common.c:134: BUG_ON(!is_power_of_2(minalign));
arch/powerpc/mm/init-common.c-135- BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE);
--
arch/powerpc/net/bpf_jit_comp32.c=322=int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct codegen_context *ctx,
--
arch/powerpc/net/bpf_jit_comp32.c-455- EMIT(PPC_RAW_SUBFIC(dst_reg, src2_reg, 0));
arch/powerpc/net/bpf_jit_comp32.c:456: } else if (is_power_of_2((u32)imm)) {
arch/powerpc/net/bpf_jit_comp32.c-457- EMIT(PPC_RAW_SLWI(dst_reg, src2_reg, ilog2(imm)));
--
arch/powerpc/net/bpf_jit_comp32.c-474- EMIT(PPC_RAW_SUBFZE(dst_reg_h, src2_reg_h));
arch/powerpc/net/bpf_jit_comp32.c:475: } else if (imm > 0 && is_power_of_2(imm)) {
arch/powerpc/net/bpf_jit_comp32.c-476- imm = ilog2(imm);
--
arch/powerpc/net/bpf_jit_comp32.c-513- EMIT(PPC_RAW_MR(dst_reg, src2_reg));
arch/powerpc/net/bpf_jit_comp32.c:514: } else if (is_power_of_2((u32)imm)) {
arch/powerpc/net/bpf_jit_comp32.c-515- if (off)
--
arch/powerpc/net/bpf_jit_comp32.c-530-
arch/powerpc/net/bpf_jit_comp32.c:531: if (!is_power_of_2((u32)imm)) {
arch/powerpc/net/bpf_jit_comp32.c-532- bpf_set_seen_register(ctx, tmp_reg);
--
arch/powerpc/net/bpf_jit_comp32.c-556- imm = -imm;
arch/powerpc/net/bpf_jit_comp32.c:557: if (!is_power_of_2(imm))
arch/powerpc/net/bpf_jit_comp32.c-558- return -EOPNOTSUPP;
--
arch/powerpc/net/bpf_jit_comp32.c-577- return -EINVAL;
arch/powerpc/net/bpf_jit_comp32.c:578: if (!is_power_of_2(abs(imm)))
arch/powerpc/net/bpf_jit_comp32.c-579- return -EOPNOTSUPP;
--
arch/powerpc/platforms/44x/pci.c=201=static int __init ppc4xx_setup_one_pci_PMM(struct pci_controller *hose,
--
arch/powerpc/platforms/44x/pci.c-227- */
arch/powerpc/platforms/44x/pci.c:228: if ((plb_addr + size) > 0xffffffffull || !is_power_of_2(size) ||
arch/powerpc/platforms/44x/pci.c-229- size < 0x1000 || (plb_addr & (size - 1)) != 0) {
--
arch/powerpc/platforms/44x/pci.c=405=static int __init ppc4xx_setup_one_pcix_POM(struct pci_controller *hose,
--
arch/powerpc/platforms/44x/pci.c-414-
arch/powerpc/platforms/44x/pci.c:415: if (!is_power_of_2(size) || size < 0x1000 ||
arch/powerpc/platforms/44x/pci.c-416- (plb_addr & (size - 1)) != 0) {
--
arch/powerpc/platforms/44x/pci.c=1600=static int __init ppc4xx_setup_one_pciex_POM(struct ppc4xx_pciex_port *port,
--
arch/powerpc/platforms/44x/pci.c-1610-
arch/powerpc/platforms/44x/pci.c:1611: if (!is_power_of_2(size) ||
arch/powerpc/platforms/44x/pci.c-1612- (index < 2 && size < 0x100000) ||
--
arch/powerpc/platforms/powernv/pci-ioda-tce.c=290=long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,
--
arch/powerpc/platforms/powernv/pci-ioda-tce.c-305-
arch/powerpc/platforms/powernv/pci-ioda-tce.c:306: if (!is_power_of_2(window_size))
arch/powerpc/platforms/powernv/pci-ioda-tce.c-307- return -EINVAL;
--
arch/powerpc/platforms/powernv/pci-ioda.c=1468=unsigned long pnv_pci_ioda2_get_table_size(__u32 page_shift,
--
arch/powerpc/platforms/powernv/pci-ioda.c-1478- if (!levels || (levels > POWERNV_IOMMU_MAX_LEVELS) ||
arch/powerpc/platforms/powernv/pci-ioda.c:1479: !is_power_of_2(window_size))
arch/powerpc/platforms/powernv/pci-ioda.c-1480- return 0;
--
arch/powerpc/platforms/pseries/iommu.c=2056=static long spapr_tce_create_table(struct iommu_table_group *table_group, int num,
--
arch/powerpc/platforms/pseries/iommu.c-2077-
arch/powerpc/platforms/pseries/iommu.c:2078: if (!is_power_of_2(window_size) || levels > 1)
arch/powerpc/platforms/pseries/iommu.c-2079- return -EINVAL;
--
arch/powerpc/sysdev/fsl_rmu.c=660=fsl_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox,
--
arch/powerpc/sysdev/fsl_rmu.c-689- /* Set transfer size aligned to next power of 2 (in double words) */
arch/powerpc/sysdev/fsl_rmu.c:690: desc->dwcnt = is_power_of_2(len) ? len : 1 << get_bitmask_order(len);
arch/powerpc/sysdev/fsl_rmu.c-691-
--
arch/powerpc/sysdev/fsl_rmu.c=720=fsl_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
--
arch/powerpc/sysdev/fsl_rmu.c-726- if ((entries < RIO_MIN_TX_RING_SIZE) ||
arch/powerpc/sysdev/fsl_rmu.c:727: (entries > RIO_MAX_TX_RING_SIZE) || (!is_power_of_2(entries))) {
arch/powerpc/sysdev/fsl_rmu.c-728- rc = -EINVAL;
--
arch/powerpc/sysdev/fsl_rmu.c=852=fsl_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
--
arch/powerpc/sysdev/fsl_rmu.c-858- if ((entries < RIO_MIN_RX_RING_SIZE) ||
arch/powerpc/sysdev/fsl_rmu.c:859: (entries > RIO_MAX_RX_RING_SIZE) || (!is_power_of_2(entries))) {
arch/powerpc/sysdev/fsl_rmu.c-860- rc = -EINVAL;
--
arch/riscv/kernel/cpufeature.c=93=static int riscv_ext_zicbom_validate(const struct riscv_isa_ext_data *data,
--
arch/riscv/kernel/cpufeature.c-99- }
arch/riscv/kernel/cpufeature.c:100: if (!is_power_of_2(riscv_cbom_block_size)) {
arch/riscv/kernel/cpufeature.c-101- pr_err("Zicbom disabled as cbom-block-size present, but is not a power-of-2\n");
--
arch/riscv/kernel/cpufeature.c=109=static int riscv_ext_zicboz_validate(const struct riscv_isa_ext_data *data,
--
arch/riscv/kernel/cpufeature.c-115- }
arch/riscv/kernel/cpufeature.c:116: if (!is_power_of_2(riscv_cboz_block_size)) {
arch/riscv/kernel/cpufeature.c-117- pr_err("Zicboz disabled as cboz-block-size present, but is not a power-of-2\n");
--
arch/riscv/kernel/cpufeature.c=124=static int riscv_ext_zicbop_validate(const struct riscv_isa_ext_data *data,
--
arch/riscv/kernel/cpufeature.c-130- }
arch/riscv/kernel/cpufeature.c:131: if (!is_power_of_2(riscv_cbop_block_size)) {
arch/riscv/kernel/cpufeature.c-132- pr_err("Zicbop disabled as cbop-block-size present, but is not a power-of-2\n");
--
arch/s390/kernel/irq.c=308=static inline int ext_hash(u16 code)
arch/s390/kernel/irq.c-309-{
arch/s390/kernel/irq.c:310: BUILD_BUG_ON(!is_power_of_2(ARRAY_SIZE(ext_int_hash)));
arch/s390/kernel/irq.c-311-
--
arch/s390/pci/pci.c=1065=static int zpci_mem_init(void)
arch/s390/pci/pci.c-1066-{
arch/s390/pci/pci.c:1067: BUILD_BUG_ON(!is_power_of_2(__alignof__(struct zpci_fmb)) ||
arch/s390/pci/pci.c-1068- __alignof__(struct zpci_fmb) < sizeof(struct zpci_fmb));
--
arch/sparc/mm/srmmu.c=191=void srmmu_free_nocache(void *addr, int size)
--
arch/sparc/mm/srmmu.c-206- }
arch/sparc/mm/srmmu.c:207: if (!is_power_of_2(size)) {
arch/sparc/mm/srmmu.c-208- printk("Size 0x%x is not a power of 2\n", size);
--
arch/um/kernel/um_arch.c=276=static void __init parse_cache_line(char *line)
--
arch/um/kernel/um_arch.c-284- }
arch/um/kernel/um_arch.c:285: if (kstrtoul(to_parse, 10, &res) == 0 && is_power_of_2(res))
arch/um/kernel/um_arch.c-286- boot_cpu_data.cache_alignment = res;
--
arch/x86/include/asm/div64.h-25- __base = (base); \
arch/x86/include/asm/div64.h:26: if (__builtin_constant_p(__base) && is_power_of_2(__base)) { \
arch/x86/include/asm/div64.h-27- __mod = n & (__base - 1); \
--
arch/x86/kernel/cpu/sgx/ioctl.c=58=static int sgx_encl_create(struct sgx_encl *encl, struct sgx_secs *secs)
--
arch/x86/kernel/cpu/sgx/ioctl.c-71- */
arch/x86/kernel/cpu/sgx/ioctl.c:72: if (!is_power_of_2(secs->size))
arch/x86/kernel/cpu/sgx/ioctl.c-73- return -EINVAL;
--
arch/x86/kernel/hw_breakpoint.c=324=static int arch_build_bp_info(struct perf_event *bp,
--
arch/x86/kernel/hw_breakpoint.c-397- /* AMD range breakpoint */
arch/x86/kernel/hw_breakpoint.c:398: if (!is_power_of_2(attr->bp_len))
arch/x86/kernel/hw_breakpoint.c-399- return -EINVAL;
--
arch/x86/kvm/kvm_cache_regs.h=178=static __always_inline bool kvm_is_cr0_bit_set(struct kvm_vcpu *vcpu,
--
arch/x86/kvm/kvm_cache_regs.h-180-{
arch/x86/kvm/kvm_cache_regs.h:181: BUILD_BUG_ON(!is_power_of_2(cr0_bit));
arch/x86/kvm/kvm_cache_regs.h-182-
--
arch/x86/kvm/kvm_cache_regs.h=200=static __always_inline bool kvm_is_cr4_bit_set(struct kvm_vcpu *vcpu,
--
arch/x86/kvm/kvm_cache_regs.h-202-{
arch/x86/kvm/kvm_cache_regs.h:203: BUILD_BUG_ON(!is_power_of_2(cr4_bit));
arch/x86/kvm/kvm_cache_regs.h-204-
--
arch/x86/kvm/lapic.c=327=static void kvm_recalculate_logical_map(struct kvm_apic_map *new,
--
arch/x86/kvm/lapic.c-386- ldr = ffs(mask) - 1;
arch/x86/kvm/lapic.c:387: if (!is_power_of_2(mask) || cluster[ldr])
arch/x86/kvm/lapic.c-388- new->logical_mode = KVM_APIC_MODE_MAP_DISABLED;
--
arch/x86/kvm/svm/avic.c=679=static u32 *avic_get_logical_id_entry(struct kvm_vcpu *vcpu, u32 ldr, bool flat)
--
arch/x86/kvm/svm/avic.c-693- }
arch/x86/kvm/svm/avic.c:694: if (!ldr || !is_power_of_2(ldr))
arch/x86/kvm/svm/avic.c-695- return NULL;
--
arch/x86/kvm/x86.c=13922=static inline u32 kvm_async_pf_hash_fn(gfn_t gfn)
arch/x86/kvm/x86.c-13923-{
arch/x86/kvm/x86.c:13924: BUILD_BUG_ON(!is_power_of_2(ASYNC_PF_PER_VCPU));
arch/x86/kvm/x86.c-13925-
--
arch/xtensa/kernel/hw_breakpoint.c=51=int hw_breakpoint_arch_parse(struct perf_event *bp,
--
arch/xtensa/kernel/hw_breakpoint.c-74- hw->len = attr->bp_len;
arch/xtensa/kernel/hw_breakpoint.c:75: if (hw->len < 1 || hw->len > 64 || !is_power_of_2(hw->len))
arch/xtensa/kernel/hw_breakpoint.c-76- return -EINVAL;
--
block/blk-crypto.c=307=int blk_crypto_init_key(struct blk_crypto_key *blk_key,
--
block/blk-crypto.c-338-
block/blk-crypto.c:339: if (!is_power_of_2(data_unit_size))
block/blk-crypto.c-340- return -EINVAL;
--
block/blk-settings.c=270=static void blk_validate_atomic_write_limits(struct queue_limits *lim)
--
block/blk-settings.c-285-
block/blk-settings.c:286: if (WARN_ON_ONCE(!is_power_of_2(lim->atomic_write_hw_unit_min)))
block/blk-settings.c-287- goto unsupported;
block/blk-settings.c-288-
block/blk-settings.c:289: if (WARN_ON_ONCE(!is_power_of_2(lim->atomic_write_hw_unit_max)))
block/blk-settings.c-290- goto unsupported;
--
block/blk-settings.c-321- */
block/blk-settings.c:322: if (!is_power_of_2(boundary_sectors))
block/blk-settings.c-323- goto unsupported;
--
block/blk-settings.c=340=int blk_validate_limits(struct queue_limits *lim)
--
block/blk-settings.c-358- lim->physical_block_size = lim->logical_block_size;
block/blk-settings.c:359: } else if (!is_power_of_2(lim->physical_block_size)) {
block/blk-settings.c-360- pr_warn("Invalid physical block size (%d)\n", lim->physical_block_size);
--
block/blk-zoned.c=2331=int blk_revalidate_disk_zones(struct gendisk *disk)
--
block/blk-zoned.c-2353- */
block/blk-zoned.c:2354: if (!zone_sectors || !is_power_of_2(zone_sectors)) {
block/blk-zoned.c-2355- pr_warn("%s: Invalid non power of two zone size (%llu)\n",
--
block/partitions/mac.c=33=int mac_partition(struct parsed_partitions *state)
--
block/partitions/mac.c-63- */
block/partitions/mac.c:64: if (!is_power_of_2(secsize))
block/partitions/mac.c-65- return -1;
--
crypto/cbc.c=138=static int crypto_cbc_create(struct crypto_template *tmpl, struct rtattr **tb)
--
crypto/cbc.c-147- err = -EINVAL;
crypto/cbc.c:148: if (!is_power_of_2(inst->alg.co.base.cra_blocksize))
crypto/cbc.c-149- goto out_free_inst;
--
drivers/accel/amdxdna/amdxdna_gem.c=789=amdxdna_drm_create_dev_heap_bo(struct drm_device *dev,
--
drivers/accel/amdxdna/amdxdna_gem.c-796-
drivers/accel/amdxdna/amdxdna_gem.c:797: WARN_ON(!is_power_of_2(xdna->dev_info->dev_mem_size));
drivers/accel/amdxdna/amdxdna_gem.c-798- XDNA_DBG(xdna, "Requested dev heap size 0x%llx", args->size);
--
drivers/accel/amdxdna/amdxdna_mailbox.c=493=xdna_mailbox_start_channel(struct mailbox_channel *mb_chann,
--
drivers/accel/amdxdna/amdxdna_mailbox.c-500-
drivers/accel/amdxdna/amdxdna_mailbox.c:501: if (!is_power_of_2(x2i->rb_size) || !is_power_of_2(i2x->rb_size)) {
drivers/accel/amdxdna/amdxdna_mailbox.c-502- pr_err("Ring buf size must be power of 2\n");
--
drivers/accel/habanalabs/common/command_submission.c=1347=static int hl_cs_sanity_checks(struct hl_fpriv *hpriv, union hl_cs_args *args)
--
drivers/accel/habanalabs/common/command_submission.c-1373-
drivers/accel/habanalabs/common/command_submission.c:1374: if (unlikely(cs_type_flags && !is_power_of_2(cs_type_flags))) {
drivers/accel/habanalabs/common/command_submission.c-1375- dev_err(hdev->dev,
--
drivers/accel/habanalabs/common/device.c=51=static u64 hl_set_dram_bar(struct hl_device *hdev, u64 addr, struct pci_mem_region *region,
--
drivers/accel/habanalabs/common/device.c-56-
drivers/accel/habanalabs/common/device.c:57: if (is_power_of_2(prop->dram_pci_bar_size))
drivers/accel/habanalabs/common/device.c-58- bar_base_addr = addr & ~(prop->dram_pci_bar_size - 0x1ull);
--
drivers/accel/habanalabs/common/memory.c=29=static int set_alloc_page_size(struct hl_device *hdev, struct hl_mem_in *args, u32 *page_size)
--
drivers/accel/habanalabs/common/memory.c-40-
drivers/accel/habanalabs/common/memory.c:41: if (!is_power_of_2(psize)) {
drivers/accel/habanalabs/common/memory.c-42- dev_err(hdev->dev, "user page size (%#llx) is not power of 2\n", psize);
--
drivers/accel/habanalabs/common/memory.c=87=static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args,
--
drivers/accel/habanalabs/common/memory.c-114- if (contiguous) {
drivers/accel/habanalabs/common/memory.c:115: if (is_power_of_2(page_size))
drivers/accel/habanalabs/common/memory.c-116- paddr = (uintptr_t) gen_pool_dma_alloc_align(vm->dram_pg_pool,
--
drivers/accel/habanalabs/common/memory.c-152- for (i = 0 ; i < num_pgs ; i++) {
drivers/accel/habanalabs/common/memory.c:153: if (is_power_of_2(page_size))
drivers/accel/habanalabs/common/memory.c-154- phys_pg_pack->pages[i] =
--
drivers/accel/habanalabs/common/memory.c=593=static u64 get_va_block(struct hl_device *hdev,
--
drivers/accel/habanalabs/common/memory.c-604- bool add_prev = false;
drivers/accel/habanalabs/common/memory.c:605: bool is_align_pow_2 = is_power_of_2(va_range->page_size);
drivers/accel/habanalabs/common/memory.c-606- bool is_hint_dram_addr = hl_is_dram_va(hdev, hint_addr);
--
drivers/accel/habanalabs/common/memory.c=1272=static int unmap_device_va(struct hl_ctx *ctx, struct hl_mem_in *args,
--
drivers/accel/habanalabs/common/memory.c-1343-
drivers/accel/habanalabs/common/memory.c:1344: if (!is_userptr && !is_power_of_2(phys_pg_pack->page_size))
drivers/accel/habanalabs/common/memory.c-1345- vaddr = prop->dram_base_address +
--
drivers/accel/habanalabs/common/memory.c=2514=static int va_range_init(struct hl_device *hdev, struct hl_va_range **va_ranges,
--
drivers/accel/habanalabs/common/memory.c-2528-
drivers/accel/habanalabs/common/memory.c:2529: if (is_power_of_2(page_size)) {
drivers/accel/habanalabs/common/memory.c-2530- start = round_up(start, page_size);
--
drivers/accel/habanalabs/common/memory.c=2833=int hl_vm_init(struct hl_device *hdev)
--
drivers/accel/habanalabs/common/memory.c-2838-
drivers/accel/habanalabs/common/memory.c:2839: if (is_power_of_2(prop->dram_page_size))
drivers/accel/habanalabs/common/memory.c-2840- vm->dram_pg_pool =
--
drivers/accel/habanalabs/common/mmu/mmu.c=476=static void hl_mmu_pa_page_with_offset(struct hl_ctx *ctx, u64 virt_addr,
--
drivers/accel/habanalabs/common/mmu/mmu.c-497- if ((hops->range_type == HL_VA_RANGE_TYPE_DRAM) &&
drivers/accel/habanalabs/common/mmu/mmu.c:498: !is_power_of_2(prop->dram_page_size)) {
drivers/accel/habanalabs/common/mmu/mmu.c-499- u64 dram_page_size, dram_base, abs_phys_addr, abs_virt_addr,
--
drivers/accel/habanalabs/goya/goya.c=5082=int goya_cpucp_info_get(struct hl_device *hdev)
--
drivers/accel/habanalabs/goya/goya.c-5099- if (dram_size) {
drivers/accel/habanalabs/goya/goya.c:5100: if ((!is_power_of_2(dram_size)) ||
drivers/accel/habanalabs/goya/goya.c-5101- (dram_size < DRAM_PHYS_DEFAULT_SIZE)) {
--
drivers/ata/libata-core.c=2938=int ata_dev_configure(struct ata_device *dev)
--
drivers/ata/libata-core.c-3057- /* only recognize/allow powers of two here */
drivers/ata/libata-core.c:3058: if (is_power_of_2(max) && is_power_of_2(cnt))
drivers/ata/libata-core.c-3059- if (cnt <= max)
--
drivers/base/memory.c=120=int __init memory_block_advise_max_size(unsigned long size)
drivers/base/memory.c-121-{
drivers/base/memory.c:122: if (!size || !is_power_of_2(size))
drivers/base/memory.c-123- return -EINVAL;
--
drivers/base/memory.c=952=void __init memory_dev_init(void)
--
drivers/base/memory.c-958- block_sz = memory_block_size_bytes();
drivers/base/memory.c:959: if (!is_power_of_2(block_sz) || block_sz < MIN_MEMORY_BLOCK_SIZE)
drivers/base/memory.c-960- panic("Memory block size not suitable: 0x%lx\n", block_sz);
--
drivers/base/memory.c=1143=int memory_group_register_dynamic(int nid, unsigned long unit_pages)
--
drivers/base/memory.c-1152-
drivers/base/memory.c:1153: if (!unit_pages || !is_power_of_2(unit_pages) ||
drivers/base/memory.c-1154- unit_pages < PHYS_PFN(memory_block_size_bytes()))
--
drivers/base/regmap/regmap.c=677=struct regmap *__regmap_init(struct device *dev,
--
drivers/base/regmap/regmap.c-784- map->reg_stride = 1;
drivers/base/regmap/regmap.c:785: if (is_power_of_2(map->reg_stride))
drivers/base/regmap/regmap.c-786- map->reg_stride_order = ilog2(map->reg_stride);
--
drivers/base/swnode.c=171=static int property_entry_read_int_array(const struct property_entry *props,
--
drivers/base/swnode.c-182-
drivers/base/swnode.c:183: if (!is_power_of_2(elem_size) || elem_size > sizeof(u64))
drivers/base/swnode.c-184- return -ENXIO;
--
drivers/block/null_blk/main.c=1885=static int null_validate_conf(struct nullb_device *dev)
--
drivers/block/null_blk/main.c-1919- if (dev->zoned &&
drivers/block/null_blk/main.c:1920: (!dev->zone_size || !is_power_of_2(dev->zone_size))) {
drivers/block/null_blk/main.c-1921- pr_err("zone_size must be power-of-two\n");
--
drivers/block/null_blk/zoned.c=51=int null_init_zoned_dev(struct nullb_device *dev,
--
drivers/block/null_blk/zoned.c-58-
drivers/block/null_blk/zoned.c:59: if (!is_power_of_2(dev->zone_size)) {
drivers/block/null_blk/zoned.c-60- pr_err("zone_size must be power-of-two\n");
--
drivers/block/rbd.c=6259=static int rbd_parse_param(struct fs_parameter *param,
--
drivers/block/rbd.c-6288- goto out_of_range;
drivers/block/rbd.c:6289: if (!is_power_of_2(result.uint_32))
drivers/block/rbd.c-6290- return inval_plog(&log, "alloc_size must be a power of 2");
--
drivers/block/ublk_drv.c=894=static int ublk_validate_params(const struct ublk_device *ub)
--
drivers/block/ublk_drv.c-956-
drivers/block/ublk_drv.c:957: if (!is_power_of_2(p->alignment + 1))
drivers/block/ublk_drv.c-958- return -EINVAL;
--
drivers/block/ublk_drv.c-963-
drivers/block/ublk_drv.c:964: if (!is_power_of_2(p->seg_boundary_mask + 1))
drivers/block/ublk_drv.c-965- return -EINVAL;
--
drivers/block/virtio_blk.c=718=static int virtblk_read_zoned_limits(struct virtio_blk *vblk,
--
drivers/block/virtio_blk.c-754- &vblk->zone_sectors);
drivers/block/virtio_blk.c:755: if (vblk->zone_sectors == 0 || !is_power_of_2(vblk->zone_sectors)) {
drivers/block/virtio_blk.c-756- dev_err(&vdev->dev,
--
drivers/block/zloop.c=1451=static int zloop_parse_options(struct zloop_options *opts, const char *buf)
--
drivers/block/zloop.c-1514- if (!token || token > ZLOOP_MAX_ZONE_SIZE_MB ||
drivers/block/zloop.c:1515: !is_power_of_2(token)) {
drivers/block/zloop.c-1516- pr_err("Invalid zone size %u\n", token);
--
drivers/bus/mvebu-mbus.c=325=static int mvebu_mbus_setup_window(struct mvebu_mbus_state *mbus,
--
drivers/bus/mvebu-mbus.c-333-
drivers/bus/mvebu-mbus.c:334: if (!is_power_of_2(size)) {
drivers/bus/mvebu-mbus.c-335- WARN(true, "Invalid MBus window size: 0x%zx\n", size);
--
drivers/bus/mvebu-mbus.c=471=static int mvebu_devs_debug_show(struct seq_file *seq, void *v)
--
drivers/bus/mvebu-mbus.c-494-
drivers/bus/mvebu-mbus.c:495: if (!is_power_of_2(wsize) ||
drivers/bus/mvebu-mbus.c-496- ((wbase & (u64)(wsize - 1)) != 0))
--
drivers/clk/clk-divider.c=179=static bool _is_valid_div(const struct clk_div_table *table, unsigned int div,
--
drivers/clk/clk-divider.c-182- if (flags & CLK_DIVIDER_POWER_OF_TWO)
drivers/clk/clk-divider.c:183: return is_power_of_2(div);
drivers/clk/clk-divider.c-184- if (table)
--
drivers/clk/ti/divider.c=130=static bool _is_valid_div(struct clk_omap_divider *divider, unsigned int div)
--
drivers/clk/ti/divider.c-132- if (divider->flags & CLK_DIVIDER_POWER_OF_TWO)
drivers/clk/ti/divider.c:133: return is_power_of_2(div);
drivers/clk/ti/divider.c-134- if (divider->table)
--
drivers/clocksource/timer-cadence-ttc.c=237=static int ttc_rate_change_clocksource_cb(struct notifier_block *nb,
--
drivers/clocksource/timer-cadence-ttc.c-262-
drivers/clocksource/timer-cadence-ttc.c:263: if (!is_power_of_2(factor))
drivers/clocksource/timer-cadence-ttc.c-264- return NOTIFY_BAD;
--
drivers/crypto/talitos.c=3407=static int talitos_probe(struct platform_device *ofdev)
--
drivers/crypto/talitos.c-3444-
drivers/crypto/talitos.c:3445: if (!is_power_of_2(priv->num_channels) || !priv->chfifo_len ||
drivers/crypto/talitos.c-3446- !priv->exec_units || !priv->desc_types) {
--
drivers/cxl/acpi.c=95=static int cxl_parse_cxims(union acpi_subtable_headers *header, void *arg,
--
drivers/cxl/acpi.c-115- /* IW 1,3 do not use xormaps and skip this parsing entirely */
drivers/cxl/acpi.c:116: if (is_power_of_2(cxld->interleave_ways))
drivers/cxl/acpi.c-117- /* 2, 4, 8, 16 way */
--
drivers/cxl/core/region.c=488=static int set_interleave_ways(struct cxl_region *cxlr, int val)
--
drivers/cxl/core/region.c-503- */
drivers/cxl/core/region.c:504: if (!is_power_of_2(val / cxld->interleave_ways) ||
drivers/cxl/core/region.c-505- (val % cxld->interleave_ways)) {
--
drivers/cxl/core/region.c=1426=static int cxl_port_setup_targets(struct cxl_port *port,
--
drivers/cxl/core/region.c-1446- */
drivers/cxl/core/region.c:1447: if (!is_power_of_2(cxl_rr->nr_targets)) {
drivers/cxl/core/region.c-1448- dev_dbg(&cxlr->dev, "%s:%s: invalid target count %d\n",
--
drivers/cxl/core/region.c-1500- */
drivers/cxl/core/region.c:1501: if (!is_power_of_2(parent_iw))
drivers/cxl/core/region.c-1502- parent_iw /= 3;
--
drivers/cxl/core/region.c=3296=static bool region_is_unaligned_mod3(struct cxl_region *cxlr)
--
]
]
|
| 20/2 |
2026/05/21 22:53 |
llm |
debugger |
0m
Model:
Tokens:
input: 56854
output: 22
thoughts: 43
Thoughts: **Checking for Power of Two Functionality**
Okay, so I'm thinking about the most efficient way to determine if a number is a power of two. The `is_power_of_2` function is definitely something I've come across before, and it's quite prevalent in various contexts. The next logical step is to see if it's already defined within the standard Linux headers, specifically within `<linux/log2.h>`. Given the frequent need for this kind of bitwise operation in kernel development, it wouldn't surprise me at all to find it there. It would save me the effort of reinventing the wheel and ensure consistency with the existing codebase. So, let's go check `<linux/log2.h>`.
|
| 21/2 |
2026/05/21 22:53 |
tool |
grepper |
0m
Args: map[Expression:define is_power_of_2]
Results: map[Output:arch/microblaze/mm/pgtable.c=166=void __init mapin_ram(void)
--
arch/microblaze/mm/pgtable.c-187-/* is x a power of 2? */
arch/microblaze/mm/pgtable.c:188:#define is_power_of_2(x) ((x) != 0 && (((x) & ((x) - 1)) == 0))
arch/microblaze/mm/pgtable.c-189-
--
tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c-24- */
tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c:25:#define is_power_of_2(n) (n != 0 && ((n & (n - 1)) == 0))
tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c-26-
]
|
| 22/2 |
2026/05/21 22:53 |
llm |
debugger |
0m
Model:
Tokens:
input: 57334
output: 23
thoughts: 25
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Considering the `is_power_of_2` Implementation**
Okay, so I'm looking at this code and something's just clicked. The `is_power_of_2` check... hold on a second. Isn't that defined as an *inline* function, likely within `<linux/log2.h>`? I need to double-check that, because if it *is* inlined, that has significant implications for optimization and how the compiler will handle the instruction stream. It suggests that a bitwise operation is most likely, and thus a very cheap computation. I need to keep the inline nature in mind when analyzing this section, as it's not a function call as such, but actual code insertion, so the typical call overhead I'd be looking for is not there. Therefore, this check is most likely essentially free, making it unlikely the bottleneck.
|
| 23/2 |
2026/05/21 22:53 |
tool |
grepper |
0m
Args: map[Expression:inline.*is_power_of_2]
Results: map[Output:drivers/gpu/drm/i915/i915_utils.h=39=struct drm_i915_private;
--
drivers/gpu/drm/i915/i915_utils.h-77-
drivers/gpu/drm/i915/i915_utils.h:78:static inline bool is_power_of_2_u64(u64 n)
drivers/gpu/drm/i915/i915_utils.h-79-{
]
|
| 24/2 |
2026/05/21 22:53 |
llm |
debugger |
0m
Model:
Tokens:
input: 57725
output: 23
thoughts: 14
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Diving into `include/linux/log2.h`**
Alright, let's take a look at `include/linux/log2.h`. I'm curious to see how the kernel handles the log base 2 calculations. Given its fundamental nature, I'd expect to see some clever bitwise tricks to optimize this β especially for architectures where floating-point operations would be costly. I'm hoping to find elegant solutions, perhaps leveraging hardware instructions if available, for speed and efficiency, since `log2` is such a commonly used operation in many aspects of a kernel. This file usually has some interesting insights into low-level optimization strategies, so I am looking forward to seeing what it has to offer. My expectation is that the kernel would want to do some sort of table lookup, combined with bit-shifting.
|
| 25/2 |
2026/05/21 22:53 |
tool |
read-file |
0m
Args: map[File:include/linux/log2.h]
Results: map[Contents:/* SPDX-License-Identifier: GPL-2.0-or-later */
/* Integer base 2 logarithm calculation
*
* Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
* Written by David Howells (dhowells@redhat.com)
*/
#ifndef _LINUX_LOG2_H
#define _LINUX_LOG2_H
#include <linux/types.h>
#include <linux/bitops.h>
/*
* non-constant log of base 2 calculators
* - the arch may override these in asm/bitops.h if they can be implemented
* more efficiently than using fls() and fls64()
* - the arch is not required to handle n==0 if implementing the fallback
*/
#ifndef CONFIG_ARCH_HAS_ILOG2_U32
static __always_inline __attribute__((const))
int __ilog2_u32(u32 n)
{
return fls(n) - 1;
}
#endif
#ifndef CONFIG_ARCH_HAS_ILOG2_U64
static __always_inline __attribute__((const))
int __ilog2_u64(u64 n)
{
return fls64(n) - 1;
}
#endif
/**
* is_power_of_2() - check if a value is a power of two
* @n: the value to check
*
* Determine whether some value is a power of two, where zero is
* *not* considered a power of two.
* Return: true if @n is a power of 2, otherwise false.
*/
static __always_inline __attribute__((const))
bool is_power_of_2(unsigned long n)
{
return n - 1 < (n ^ (n - 1));
}
/**
* __roundup_pow_of_two() - round up to nearest power of two
* @n: value to round up
*/
static inline __attribute__((const))
unsigned long __roundup_pow_of_two(unsigned long n)
{
return 1UL << fls_long(n - 1);
}
/**
* __rounddown_pow_of_two() - round down to nearest power of two
* @n: value to round down
*/
static inline __attribute__((const))
unsigned long __rounddown_pow_of_two(unsigned long n)
{
return 1UL << (fls_long(n) - 1);
}
/**
* const_ilog2 - log base 2 of 32-bit or a 64-bit constant unsigned value
* @n: parameter
*
* Use this where sparse expects a true constant expression, e.g. for array
* indices.
*/
#define const_ilog2(n) \
( \
__builtin_constant_p(n) ? ( \
(n) < 2 ? 0 : \
(n) & (1ULL << 63) ? 63 : \
(n) & (1ULL << 62) ? 62 : \
(n) & (1ULL << 61) ? 61 : \
(n) & (1ULL << 60) ? 60 : \
(n) & (1ULL << 59) ? 59 : \
(n) & (1ULL << 58) ? 58 : \
(n) & (1ULL << 57) ? 57 : \
(n) & (1ULL << 56) ? 56 : \
(n) & (1ULL << 55) ? 55 : \
(n) & (1ULL << 54) ? 54 : \
(n) & (1ULL << 53) ? 53 : \
(n) & (1ULL << 52) ? 52 : \
(n) & (1ULL << 51) ? 51 : \
(n) & (1ULL << 50) ? 50 : \
(n) & (1ULL << 49) ? 49 : \
(n) & (1ULL << 48) ? 48 : \
(n) & (1ULL << 47) ? 47 : \
(n) & (1ULL << 46) ? 46 : \
(n) & (1ULL << 45) ? 45 : \
(n) & (1ULL << 44) ? 44 : \
(n) & (1ULL << 43) ? 43 : \
(n) & (1ULL << 42) ? 42 : \
(n) & (1ULL << 41) ? 41 : \
(n) & (1ULL << 40) ? 40 : \
(n) & (1ULL << 39) ? 39 : \
(n) & (1ULL << 38) ? 38 : \
(n) & (1ULL << 37) ? 37 : \
(n) & (1ULL << 36) ? 36 : \
(n) & (1ULL << 35) ? 35 : \
(n) & (1ULL << 34) ? 34 : \
(n) & (1ULL << 33) ? 33 : \
(n) & (1ULL << 32) ? 32 : \
(n) & (1ULL << 31) ? 31 : \
(n) & (1ULL << 30) ? 30 : \
(n) & (1ULL << 29) ? 29 : \
(n) & (1ULL << 28) ? 28 : \
(n) & (1ULL << 27) ? 27 : \
(n) & (1ULL << 26) ? 26 : \
(n) & (1ULL << 25) ? 25 : \
(n) & (1ULL << 24) ? 24 : \
(n) & (1ULL << 23) ? 23 : \
(n) & (1ULL << 22) ? 22 : \
(n) & (1ULL << 21) ? 21 : \
(n) & (1ULL << 20) ? 20 : \
(n) & (1ULL << 19) ? 19 : \
(n) & (1ULL << 18) ? 18 : \
(n) & (1ULL << 17) ? 17 : \
(n) & (1ULL << 16) ? 16 : \
(n) & (1ULL << 15) ? 15 : \
(n) & (1ULL << 14) ? 14 : \
(n) & (1ULL << 13) ? 13 : \
(n) & (1ULL << 12) ? 12 : \
(n) & (1ULL << 11) ? 11 : \
(n) & (1ULL << 10) ? 10 : \
(n) & (1ULL << 9) ? 9 : \
(n) & (1ULL << 8) ? 8 : \
(n) & (1ULL << 7) ? 7 : \
(n) & (1ULL << 6) ? 6 : \
(n) & (1ULL << 5) ? 5 : \
(n) & (1ULL << 4) ? 4 : \
(n) & (1ULL << 3) ? 3 : \
(n) & (1ULL << 2) ? 2 : \
1) : \
-1)
/**
* ilog2 - log base 2 of 32-bit or a 64-bit unsigned value
* @n: parameter
*
* constant-capable log of base 2 calculation
* - this can be used to initialise global variables from constant data, hence
* the massive ternary operator construction
*
* selects the appropriately-sized optimised version depending on sizeof(n)
*/
#define ilog2(n) \
( \
__builtin_constant_p(n) ? \
((n) < 2 ? 0 : \
63 - __builtin_clzll(n)) : \
(sizeof(n) <= 4) ? \
__ilog2_u32(n) : \
__ilog2_u64(n) \
)
/**
* roundup_pow_of_two - round the given value up to nearest power of two
* @n: parameter
*
* round the given value up to the nearest power of two
* - the result is undefined when n == 0
* - this can be used to initialise global variables from constant data
*/
#define roundup_pow_of_two(n) \
( \
__builtin_constant_p(n) ? ( \
((n) == 1) ? 1 : \
(1UL << (ilog2((n) - 1) + 1)) \
) : \
__roundup_pow_of_two(n) \
)
/**
* rounddown_pow_of_two - round the given value down to nearest power of two
* @n: parameter
*
* round the given value down to the nearest power of two
* - the result is undefined when n == 0
* - this can be used to initialise global variables from constant data
*/
#define rounddown_pow_of_two(n) \
( \
__builtin_constant_p(n) ? ( \
(1UL << ilog2(n))) : \
__rounddown_pow_of_two(n) \
)
static inline __attribute_const__
int __order_base_2(unsigned long n)
{
return n > 1 ? ilog2(n - 1) + 1 : 0;
}
/**
* order_base_2 - calculate the (rounded up) base 2 order of the argument
* @n: parameter
*
* The first few values calculated by this routine:
* ob2(0) = 0
* ob2(1) = 0
* ob2(2) = 1
* ob2(3) = 2
* ob2(4) = 2
* ob2(5) = 3
* ... and so on.
*/
#define order_base_2(n) \
( \
__builtin_constant_p(n) ? ( \
((n) == 0 || (n) == 1) ? 0 : \
ilog2((n) - 1) + 1) : \
__order_base_2(n) \
)
static inline __attribute__((const))
int __bits_per(unsigned long n)
{
if (n < 2)
return 1;
if (is_power_of_2(n))
return order_base_2(n) + 1;
return order_base_2(n);
}
/**
* bits_per - calculate the number of bits required for the argument
* @n: parameter
*
* This is constant-capable and can be used for compile time
* initializations, e.g bitfields.
*
* The first few values calculated by this routine:
* bf(0) = 1
* bf(1) = 1
* bf(2) = 2
* bf(3) = 2
* bf(4) = 3
* ... and so on.
*/
#define bits_per(n) \
( \
__builtin_constant_p(n) ? ( \
((n) == 0 || (n) == 1) \
? 1 : ilog2(n) + 1 \
) : \
__bits_per(n) \
)
/**
* max_pow_of_two_factor - return highest power-of-2 factor
* @n: parameter
*
* find highest power-of-2 which is evenly divisible into n.
* 0 is returned for n == 0 or 1.
*/
static inline __attribute__((const))
unsigned int max_pow_of_two_factor(unsigned int n)
{
return n & -n;
}
#endif /* _LINUX_LOG2_H */
]
|
| 26/2 |
2026/05/21 22:53 |
llm |
debugger |
0m
Model:
Tokens:
input: 61109
output: 18
thoughts: 1079
Thoughts: **Refining the BEFS Superblock Checks**
Okay, so I'm looking at improving the superblock checks in the BEFS filesystem code. My initial thought was to use `ilog2` in place of the bit-shift operations, but I need to be careful. I know that `is_power_of_2` and `ilog2` are available since they're in `<linux/log2.h>`, and that header is transitively included by `<linux/fs.h>`, which `fs/befs/super.c` already includes. So, the function's availability isn't a problem.
Now, reviewing the existing code, it has these checks:
```c
if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
```
My first instinct was to replace those with:
```c
if (befs_sb->block_shift != ilog2(befs_sb->block_size)) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
if (befs_sb->blocks_per_ag == 0 ||
befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
```
But, hold on. I need to be *absolutely* sure this won't break anything. The `blocks_per_ag` check is the tricky one. If `blocks_per_ag` is *not* a power of 2, `ilog2` will return the position of the most significant bit. For example, if `blocks_per_ag` is 3, `ilog2(3)` would return 1. Now, if `ag_shift` is also 1, then the new condition would be satisfied (1 == 1) and *no* error would be reported. However, the original code would have detected an error because `(1 << ag_shift)` would be 2, which is *not* equal to `blocks_per_ag`. The crucial observation is that the original check *implicitly* requires `blocks_per_ag` to be a power of 2, because `1 << befs_sb->ag_shift` will *always* result in a power of 2. Thus, the original code is working as it is!
Therefore, I need to explicitly check if `blocks_per_ag` is a power of 2 before using `ilog2`.
```c
if (!is_power_of_2(befs_sb->blocks_per_ag) ||
befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
```
This ensures we retain the same behavior and error conditions. And it also addresses the case where `blocks_per_ag` is zero. `is_power_of_2(0)` returns false, so the error would be reported in that case, too, which is correct behavior. This is good.
Now, concerning the `block_size` check. The code already verifies that `block_size` is one of 1024, 2048, 4096, or 8192, all powers of 2. So, using `ilog2(befs_sb->block_size)` is perfectly safe here.
I also double checked the `fs/befs/super.c` file to see how `<linux/log2.h>` is being included, since I don't want to make assumptions. It currently includes `<linux/fs.h>` and `<asm/page.h>`. It looks like `<linux/log2.h>` isn't included directly, but is available through the transitive include. To be absolutely safe and clear, I *could* explicitly add `#include <linux/log2.h>`, but it's likely redundant because it's included transitively. However, it is explicitly included in other files, so I'll probably
|
| 27/2 |
2026/05/21 22:53 |
tool |
grepper |
0m
Args: map[Expression:include.*log2]
Results: map[Output:
Full output is too long, showing 500 out of 1369 lines.
Use more precise expression if possible.
[Documentation/core-api/kernel-api.rst=155=Base 2 log and power Functions
--
Documentation/core-api/kernel-api.rst-157-
Documentation/core-api/kernel-api.rst:158:.. kernel-doc:: include/linux/log2.h
Documentation/core-api/kernel-api.rst-159- :internal:
--
Documentation/translations/zh_CN/core-api/kernel-api.rst=150=lib/crc-itu-t.c
--
Documentation/translations/zh_CN/core-api/kernel-api.rst-156-
Documentation/translations/zh_CN/core-api/kernel-api.rst:157:include/linux/log2.h
Documentation/translations/zh_CN/core-api/kernel-api.rst-158-
--
arch/alpha/kernel/pci_iommu.c-12-#include <linux/scatterlist.h>
arch/alpha/kernel/pci_iommu.c:13:#include <linux/log2.h>
arch/alpha/kernel/pci_iommu.c-14-#include <linux/dma-map-ops.h>
--
arch/alpha/kernel/setup.c-46-#include <asm/io.h>
arch/alpha/kernel/setup.c:47:#include <linux/log2.h>
arch/alpha/kernel/setup.c-48-#include <linux/export.h>
--
arch/arc/include/asm/pgalloc.h-32-#include <linux/mm.h>
arch/arc/include/asm/pgalloc.h:33:#include <linux/log2.h>
arch/arc/include/asm/pgalloc.h-34-#include <asm-generic/pgalloc.h>
--
arch/arm/include/asm/cpufeature.h-8-
arch/arm/include/asm/cpufeature.h:9:#include <linux/log2.h>
arch/arm/include/asm/cpufeature.h-10-#include <asm/hwcap.h>
--
arch/arm/mm/cache-l2x0.c-11-#include <linux/spinlock.h>
arch/arm/mm/cache-l2x0.c:12:#include <linux/log2.h>
arch/arm/mm/cache-l2x0.c-13-#include <linux/io.h>
--
arch/arm/mm/cache-uniphier.c-11-#include <linux/io.h>
arch/arm/mm/cache-uniphier.c:12:#include <linux/log2.h>
arch/arm/mm/cache-uniphier.c-13-#include <linux/of_address.h>
--
arch/arm64/include/asm/hwcap.h-49-#ifndef __ASSEMBLER__
arch/arm64/include/asm/hwcap.h:50:#include <linux/log2.h>
arch/arm64/include/asm/hwcap.h-51-
--
arch/mips/bcm63xx/cs.c-12-#include <linux/spinlock.h>
arch/mips/bcm63xx/cs.c:13:#include <linux/log2.h>
arch/mips/bcm63xx/cs.c-14-#include <bcm63xx_cpu.h>
--
arch/mips/kvm/entry.c-14-#include <linux/kvm_host.h>
arch/mips/kvm/entry.c:15:#include <linux/log2.h>
arch/mips/kvm/entry.c-16-#include <asm/mipsregs.h>
--
arch/powerpc/kvm/book3s_hv_rm_mmu.c-12-#include <linux/module.h>
arch/powerpc/kvm/book3s_hv_rm_mmu.c:13:#include <linux/log2.h>
arch/powerpc/kvm/book3s_hv_rm_mmu.c-14-#include <linux/sizes.h>
--
arch/powerpc/kvm/e500_mmu.c-22-#include <linux/highmem.h>
arch/powerpc/kvm/e500_mmu.c:23:#include <linux/log2.h>
arch/powerpc/kvm/e500_mmu.c-24-#include <linux/uaccess.h>
--
arch/powerpc/kvm/e500_mmu_host.c-22-#include <linux/highmem.h>
arch/powerpc/kvm/e500_mmu_host.c:23:#include <linux/log2.h>
arch/powerpc/kvm/e500_mmu_host.c-24-#include <linux/uaccess.h>
--
arch/powerpc/kvm/guest-state-buffer.c-3-#include "asm/hvcall.h"
arch/powerpc/kvm/guest-state-buffer.c:4:#include <linux/log2.h>
arch/powerpc/kvm/guest-state-buffer.c-5-#include <asm/pgalloc.h>
--
arch/powerpc/kvm/test-guest-state-buffer.c-3-#include <linux/init.h>
arch/powerpc/kvm/test-guest-state-buffer.c:4:#include <linux/log2.h>
arch/powerpc/kvm/test-guest-state-buffer.c-5-#include <kunit/test.h>
--
arch/powerpc/platforms/powernv/vas-window.c-11-#include <linux/io.h>
arch/powerpc/platforms/powernv/vas-window.c:12:#include <linux/log2.h>
arch/powerpc/platforms/powernv/vas-window.c-13-#include <linux/rcupdate.h>
--
arch/powerpc/platforms/pseries/rtas-work-area.c-5-#include <linux/genalloc.h>
arch/powerpc/platforms/pseries/rtas-work-area.c:6:#include <linux/log2.h>
arch/powerpc/platforms/pseries/rtas-work-area.c-7-#include <linux/kernel.h>
--
arch/powerpc/sysdev/fsl_pci.c-23-#include <linux/memblock.h>
arch/powerpc/sysdev/fsl_pci.c:24:#include <linux/log2.h>
arch/powerpc/sysdev/fsl_pci.c-25-#include <linux/of_address.h>
--
arch/riscv/kernel/cpufeature.c-13-#include <linux/ctype.h>
arch/riscv/kernel/cpufeature.c:14:#include <linux/log2.h>
arch/riscv/kernel/cpufeature.c-15-#include <linux/memory.h>
--
arch/riscv/kernel/module.c-11-#include <linux/kernel.h>
arch/riscv/kernel/module.c:12:#include <linux/log2.h>
arch/riscv/kernel/module.c-13-#include <linux/moduleloader.h>
--
arch/s390/kernel/nmi.c-17-#include <linux/hardirq.h>
arch/s390/kernel/nmi.c:18:#include <linux/log2.h>
arch/s390/kernel/nmi.c-19-#include <linux/kprobes.h>
--
arch/sh/drivers/pci/pci-sh7780.c-15-#include <linux/delay.h>
arch/sh/drivers/pci/pci-sh7780.c:16:#include <linux/log2.h>
arch/sh/drivers/pci/pci-sh7780.c-17-#include "pci-sh4.h"
--
arch/sh/kernel/cpu/init.c-12-#include <linux/mm.h>
arch/sh/kernel/cpu/init.c:13:#include <linux/log2.h>
arch/sh/kernel/cpu/init.c-14-#include <asm/mmu_context.h>
--
arch/sparc/include/asm/vio.h-11-#include <linux/list.h>
arch/sparc/include/asm/vio.h:12:#include <linux/log2.h>
arch/sparc/include/asm/vio.h-13-
--
arch/sparc/kernel/mdesc.c-7-#include <linux/types.h>
arch/sparc/kernel/mdesc.c:8:#include <linux/log2.h>
arch/sparc/kernel/mdesc.c-9-#include <linux/list.h>
--
arch/sparc/kernel/pci_sun4v.c-16-#include <linux/export.h>
arch/sparc/kernel/pci_sun4v.c:17:#include <linux/log2.h>
arch/sparc/kernel/pci_sun4v.c-18-#include <linux/of.h>
--
arch/sparc/mm/srmmu.c-20-#include <linux/init.h>
arch/sparc/mm/srmmu.c:21:#include <linux/log2.h>
arch/sparc/mm/srmmu.c-22-#include <linux/gfp.h>
--
arch/x86/hyperv/mmu.c-2-
arch/x86/hyperv/mmu.c:3:#include <linux/log2.h>
arch/x86/hyperv/mmu.c-4-#include <linux/slab.h>
--
arch/x86/include/asm/div64.h-7-#include <linux/types.h>
arch/x86/include/asm/div64.h:8:#include <linux/log2.h>
arch/x86/include/asm/div64.h-9-
--
arch/x86/include/asm/pgtable.h=919=static inline pgd_t pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd)
--
arch/x86/include/asm/pgtable.h-936-#include <linux/mmdebug.h>
arch/x86/include/asm/pgtable.h:937:#include <linux/log2.h>
arch/x86/include/asm/pgtable.h-938-#include <asm/fixmap.h>
--
arch/x86/virt/vmx/tdx/tdx.c-27-#include <linux/sort.h>
arch/x86/virt/vmx/tdx/tdx.c:28:#include <linux/log2.h>
arch/x86/virt/vmx/tdx/tdx.c-29-#include <linux/acpi.h>
--
arch/xtensa/kernel/hw_breakpoint.c-11-#include <linux/hw_breakpoint.h>
arch/xtensa/kernel/hw_breakpoint.c:12:#include <linux/log2.h>
arch/xtensa/kernel/hw_breakpoint.c-13-#include <linux/percpu.h>
--
block/genhd.c-23-#include <linux/idr.h>
block/genhd.c:24:#include <linux/log2.h>
block/genhd.c-25-#include <linux/pm_runtime.h>
--
crypto/cbc.c-11-#include <linux/kernel.h>
crypto/cbc.c:12:#include <linux/log2.h>
crypto/cbc.c-13-#include <linux/module.h>
--
crypto/cts.c-47-#include <linux/kernel.h>
crypto/cts.c:48:#include <linux/log2.h>
crypto/cts.c-49-#include <linux/module.h>
--
drivers/ata/ahci_dwc.c-14-#include <linux/libata.h>
drivers/ata/ahci_dwc.c:15:#include <linux/log2.h>
drivers/ata/ahci_dwc.c-16-#include <linux/module.h>
--
drivers/ata/libata-core.c-44-#include <linux/io.h>
drivers/ata/libata-core.c:45:#include <linux/log2.h>
drivers/ata/libata-core.c-46-#include <linux/slab.h>
--
drivers/base/regmap/regmap.c-17-#include <linux/delay.h>
drivers/base/regmap/regmap.c:18:#include <linux/log2.h>
drivers/base/regmap/regmap.c-19-#include <linux/hwspinlock.h>
--
drivers/bus/intel-ixp4xx-eb.c-12-#include <linux/init.h>
drivers/bus/intel-ixp4xx-eb.c:13:#include <linux/log2.h>
drivers/bus/intel-ixp4xx-eb.c-14-#include <linux/mfd/syscon.h>
--
drivers/bus/mvebu-mbus.c-55-#include <linux/debugfs.h>
drivers/bus/mvebu-mbus.c:56:#include <linux/log2.h>
drivers/bus/mvebu-mbus.c-57-#include <linux/memblock.h>
--
drivers/bus/uniphier-system-bus.c-6-#include <linux/io.h>
drivers/bus/uniphier-system-bus.c:7:#include <linux/log2.h>
drivers/bus/uniphier-system-bus.c-8-#include <linux/module.h>
--
drivers/cdx/controller/mcdi.c-22-#include <net/netevent.h>
drivers/cdx/controller/mcdi.c:23:#include <linux/log2.h>
drivers/cdx/controller/mcdi.c-24-#include <linux/net_tstamp.h>
--
drivers/char/agp/parisc-agp.c-16-#include <linux/agp_backend.h>
drivers/char/agp/parisc-agp.c:17:#include <linux/log2.h>
drivers/char/agp/parisc-agp.c-18-#include <linux/slab.h>
--
drivers/clk/analogbits/wrpll-cln28hpc.c-26-#include <linux/limits.h>
drivers/clk/analogbits/wrpll-cln28hpc.c:27:#include <linux/log2.h>
drivers/clk/analogbits/wrpll-cln28hpc.c-28-#include <linux/math64.h>
--
drivers/clk/clk-divider.c-16-#include <linux/string.h>
drivers/clk/clk-divider.c:17:#include <linux/log2.h>
drivers/clk/clk-divider.c-18-
--
drivers/clk/qcom/clk-spmi-pmic-div.c-10-#include <linux/err.h>
drivers/clk/qcom/clk-spmi-pmic-div.c:11:#include <linux/log2.h>
drivers/clk/qcom/clk-spmi-pmic-div.c-12-#include <linux/module.h>
--
drivers/clk/sunxi/clk-sun9i-core.c-11-#include <linux/of_address.h>
drivers/clk/sunxi/clk-sun9i-core.c:12:#include <linux/log2.h>
drivers/clk/sunxi/clk-sun9i-core.c-13-
--
drivers/clk/sunxi/clk-sunxi.c-16-#include <linux/spinlock.h>
drivers/clk/sunxi/clk-sunxi.c:17:#include <linux/log2.h>
drivers/clk/sunxi/clk-sunxi.c-18-
--
drivers/clk/ti/apll.c-16-#include <linux/string.h>
drivers/clk/ti/apll.c:17:#include <linux/log2.h>
drivers/clk/ti/apll.c-18-#include <linux/of.h>
--
drivers/comedi/drivers/mite.c-39-#include <linux/slab.h>
drivers/comedi/drivers/mite.c:40:#include <linux/log2.h>
drivers/comedi/drivers/mite.c-41-#include <linux/comedi/comedi_pci.h>
--
drivers/crypto/hisilicon/qm.c-9-#include <linux/irqreturn.h>
drivers/crypto/hisilicon/qm.c:10:#include <linux/log2.h>
drivers/crypto/hisilicon/qm.c-11-#include <linux/pm_runtime.h>
--
drivers/cxl/cxl.h-10-#include <linux/bitops.h>
drivers/cxl/cxl.h:11:#include <linux/log2.h>
drivers/cxl/cxl.h-12-#include <linux/node.h>
--
drivers/dma/dw/core.c-18-#include <linux/io.h>
drivers/dma/dw/core.c:19:#include <linux/log2.h>
drivers/dma/dw/core.c-20-#include <linux/mm.h>
--
drivers/dma/nbpfaxi.c-14-#include <linux/io.h>
drivers/dma/nbpfaxi.c:15:#include <linux/log2.h>
drivers/dma/nbpfaxi.c-16-#include <linux/module.h>
--
drivers/dma/ste_dma40.c-16-#include <linux/delay.h>
drivers/dma/ste_dma40.c:17:#include <linux/log2.h>
drivers/dma/ste_dma40.c-18-#include <linux/pm.h>
--
drivers/dma/stm32/stm32-mdma.c-23-#include <linux/list.h>
drivers/dma/stm32/stm32-mdma.c:24:#include <linux/log2.h>
drivers/dma/stm32/stm32-mdma.c-25-#include <linux/module.h>
--
drivers/firmware/arm_scmi/perf.c-12-#include <linux/io.h>
drivers/firmware/arm_scmi/perf.c:13:#include <linux/log2.h>
drivers/firmware/arm_scmi/perf.c-14-#include <linux/module.h>
--
drivers/firmware/efi/libstub/randomalloc.c-6-#include <linux/efi.h>
drivers/firmware/efi/libstub/randomalloc.c:7:#include <linux/log2.h>
drivers/firmware/efi/libstub/randomalloc.c-8-#include <asm/efi.h>
--
drivers/gpio/gpio-mmio.c=17=o ` ~~~~\___/~~~~ ` controller in FPGA is ,.`
--
drivers/gpio/gpio-mmio.c-48-#include <linux/limits.h>
drivers/gpio/gpio-mmio.c:49:#include <linux/log2.h>
drivers/gpio/gpio-mmio.c-50-#include <linux/mod_devicetable.h>
--
drivers/gpu/drm/amd/amdkfd/kfd_process.c-24-#include <linux/mutex.h>
drivers/gpu/drm/amd/amdkfd/kfd_process.c:25:#include <linux/log2.h>
drivers/gpu/drm/amd/amdkfd/kfd_process.c-26-#include <linux/sched.h>
--
drivers/gpu/drm/amd/amdkfd/kfd_topology.c-30-#include <linux/cpufreq.h>
drivers/gpu/drm/amd/amdkfd/kfd_topology.c:31:#include <linux/log2.h>
drivers/gpu/drm/amd/amdkfd/kfd_topology.c-32-#include <linux/dmi.h>
--
drivers/gpu/drm/i915/display/intel_cx0_phy.c-5-
drivers/gpu/drm/i915/display/intel_cx0_phy.c:6:#include <linux/log2.h>
drivers/gpu/drm/i915/display/intel_cx0_phy.c-7-#include <linux/math64.h>
--
drivers/gpu/drm/i915/display/intel_dp.c-30-#include <linux/iopoll.h>
drivers/gpu/drm/i915/display/intel_dp.c:31:#include <linux/log2.h>
drivers/gpu/drm/i915/display/intel_dp.c-32-#include <linux/math.h>
--
drivers/gpu/drm/i915/display/intel_dp_mst.c-25-
drivers/gpu/drm/i915/display/intel_dp_mst.c:26:#include <linux/log2.h>
drivers/gpu/drm/i915/display/intel_dp_mst.c-27-#include <linux/math.h>
--
drivers/gpu/drm/i915/gem/i915_gem_context.c-66-#include <linux/highmem.h>
drivers/gpu/drm/i915/gem/i915_gem_context.c:67:#include <linux/log2.h>
drivers/gpu/drm/i915/gem/i915_gem_context.c-68-#include <linux/nospec.h>
--
drivers/gpu/drm/i915/gt/gen6_ppgtt.c-5-
drivers/gpu/drm/i915/gt/gen6_ppgtt.c:6:#include <linux/log2.h>
drivers/gpu/drm/i915/gt/gen6_ppgtt.c-7-
--
drivers/gpu/drm/i915/gt/gen8_ppgtt.c-5-
drivers/gpu/drm/i915/gt/gen8_ppgtt.c:6:#include <linux/log2.h>
drivers/gpu/drm/i915/gt/gen8_ppgtt.c-7-
--
drivers/gpu/drm/i915/i915_gem_gtt.c-9-#include <linux/fault-inject.h>
drivers/gpu/drm/i915/i915_gem_gtt.c:10:#include <linux/log2.h>
drivers/gpu/drm/i915/i915_gem_gtt.c-11-#include <linux/random.h>
--
drivers/gpu/drm/imagination/pvr_gem.c-18-#include <linux/iosys-map.h>
drivers/gpu/drm/imagination/pvr_gem.c:19:#include <linux/log2.h>
drivers/gpu/drm/imagination/pvr_gem.c-20-#include <linux/mutex.h>
--
drivers/gpu/drm/nouveau/include/nvif/os.h-22-#include <linux/interrupt.h>
drivers/gpu/drm/nouveau/include/nvif/os.h:23:#include <linux/log2.h>
drivers/gpu/drm/nouveau/include/nvif/os.h-24-#include <linux/pm_runtime.h>
--
drivers/gpu/drm/rockchip/rockchip_drm_vop.c-11-#include <linux/kernel.h>
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:12:#include <linux/log2.h>
drivers/gpu/drm/rockchip/rockchip_drm_vop.c-13-#include <linux/module.h>
--
drivers/gpu/drm/xe/regs/xe_reg_defs.h-12-#include <linux/build_bug.h>
drivers/gpu/drm/xe/regs/xe_reg_defs.h:13:#include <linux/log2.h>
drivers/gpu/drm/xe/regs/xe_reg_defs.h-14-#include <linux/sizes.h>
--
drivers/gpu/drm/xe/xe_lmtt_2l.c-7-#include <linux/bitfield.h>
drivers/gpu/drm/xe/xe_lmtt_2l.c:8:#include <linux/log2.h>
drivers/gpu/drm/xe/xe_lmtt_2l.c-9-#include <linux/sizes.h>
--
drivers/gpu/drm/xe/xe_lmtt_ml.c-7-#include <linux/bitfield.h>
drivers/gpu/drm/xe/xe_lmtt_ml.c:8:#include <linux/log2.h>
drivers/gpu/drm/xe/xe_lmtt_ml.c-9-#include <linux/sizes.h>
--
drivers/hwmon/adt7462.c-15-#include <linux/mutex.h>
drivers/hwmon/adt7462.c:16:#include <linux/log2.h>
drivers/hwmon/adt7462.c-17-#include <linux/slab.h>
--
drivers/hwmon/adt7470.c-18-#include <linux/delay.h>
drivers/hwmon/adt7470.c:19:#include <linux/log2.h>
drivers/hwmon/adt7470.c-20-#include <linux/kthread.h>
--
drivers/hwmon/i5k_amb.c-14-#include <linux/mutex.h>
drivers/hwmon/i5k_amb.c:15:#include <linux/log2.h>
drivers/hwmon/i5k_amb.c-16-#include <linux/pci.h>
--
drivers/hwmon/pmbus/adm1275.c-17-#include <linux/bitfield.h>
drivers/hwmon/pmbus/adm1275.c:18:#include <linux/log2.h>
drivers/hwmon/pmbus/adm1275.c-19-#include "pmbus.h"
--
drivers/hwmon/pmbus/lm25066.c-15-#include <linux/i2c.h>
drivers/hwmon/pmbus/lm25066.c:16:#include <linux/log2.h>
drivers/hwmon/pmbus/lm25066.c-17-#include <linux/of.h>
--
drivers/i2c/busses/i2c-ocores.c-24-#include <linux/io.h>
drivers/i2c/busses/i2c-ocores.c:25:#include <linux/log2.h>
drivers/i2c/busses/i2c-ocores.c-26-#include <linux/spinlock.h>
--
drivers/iio/adc/ad4030.c-20-#include <linux/limits.h>
drivers/iio/adc/ad4030.c:21:#include <linux/log2.h>
drivers/iio/adc/ad4030.c-22-#include <linux/math64.h>
--
drivers/iio/adc/nau7802.c-14-#include <linux/wait.h>
drivers/iio/adc/nau7802.c:15:#include <linux/log2.h>
drivers/iio/adc/nau7802.c-16-
--
drivers/iio/adc/qcom-spmi-adc5.c-13-#include <linux/kernel.h>
drivers/iio/adc/qcom-spmi-adc5.c:14:#include <linux/log2.h>
drivers/iio/adc/qcom-spmi-adc5.c-15-#include <linux/math64.h>
--
drivers/iio/adc/qcom-spmi-vadc.c-20-#include <linux/slab.h>
drivers/iio/adc/qcom-spmi-vadc.c:21:#include <linux/log2.h>
drivers/iio/adc/qcom-spmi-vadc.c-22-
--
drivers/iio/adc/qcom-vadc-common.c-7-#include <linux/math64.h>
drivers/iio/adc/qcom-vadc-common.c:8:#include <linux/log2.h>
drivers/iio/adc/qcom-vadc-common.c-9-#include <linux/err.h>
--
drivers/iio/adc/ti-ads1298.c-12-#include <linux/gpio/consumer.h>
drivers/iio/adc/ti-ads1298.c:13:#include <linux/log2.h>
drivers/iio/adc/ti-ads1298.c-14-#include <linux/math.h>
--
drivers/iio/chemical/bme680_core.c-14-#include <linux/device.h>
drivers/iio/chemical/bme680_core.c:15:#include <linux/log2.h>
drivers/iio/chemical/bme680_core.c-16-#include <linux/module.h>
--
drivers/iio/pressure/icp10100.c-18-#include <linux/delay.h>
drivers/iio/pressure/icp10100.c:19:#include <linux/log2.h>
drivers/iio/pressure/icp10100.c-20-#include <linux/math64.h>
--
drivers/iio/proximity/sx9310.c-17-#include <linux/kernel.h>
drivers/iio/proximity/sx9310.c:18:#include <linux/log2.h>
drivers/iio/proximity/sx9310.c-19-#include <linux/mod_devicetable.h>
--
drivers/iio/proximity/sx9324.c-16-#include <linux/kernel.h>
drivers/iio/proximity/sx9324.c:17:#include <linux/log2.h>
drivers/iio/proximity/sx9324.c-18-#include <linux/mod_devicetable.h>
--
drivers/iio/proximity/sx9360.c-15-#include <linux/kernel.h>
drivers/iio/proximity/sx9360.c:16:#include <linux/log2.h>
drivers/iio/proximity/sx9360.c-17-#include <linux/mod_devicetable.h>
--
drivers/infiniband/hw/efa/efa_com.c-5-
drivers/infiniband/hw/efa/efa_com.c:6:#include <linux/log2.h>
drivers/infiniband/hw/efa/efa_com.c-7-
--
drivers/infiniband/hw/efa/efa_verbs.c-8-#include <linux/vmalloc.h>
drivers/infiniband/hw/efa/efa_verbs.c:9:#include <linux/log2.h>
drivers/infiniband/hw/efa/efa_verbs.c-10-
--
drivers/infiniband/hw/hfi1/ipoib_tx.c-10-
drivers/infiniband/hw/hfi1/ipoib_tx.c:11:#include <linux/log2.h>
drivers/infiniband/hw/hfi1/ipoib_tx.c-12-#include <linux/circ_buf.h>
--
drivers/infiniband/hw/mlx4/qp.c-33-
drivers/infiniband/hw/mlx4/qp.c:34:#include <linux/log2.h>
drivers/infiniband/hw/mlx4/qp.c-35-#include <linux/etherdevice.h>
--
drivers/infiniband/hw/mlx5/main.c-15-#include <linux/bitmap.h>
drivers/infiniband/hw/mlx5/main.c:16:#include <linux/log2.h>
drivers/infiniband/hw/mlx5/main.c-17-#include <linux/sched.h>
--
drivers/infiniband/hw/ocrdma/ocrdma_hw.c-44-#include <linux/interrupt.h>
drivers/infiniband/hw/ocrdma/ocrdma_hw.c:45:#include <linux/log2.h>
drivers/infiniband/hw/ocrdma/ocrdma_hw.c-46-#include <linux/dma-mapping.h>
--
drivers/input/keyboard/qt1050.c-16-#include <linux/kernel.h>
drivers/input/keyboard/qt1050.c:17:#include <linux/log2.h>
drivers/input/keyboard/qt1050.c-18-#include <linux/module.h>
--
drivers/input/misc/pm8941-pwrkey.c-12-#include <linux/ktime.h>
drivers/input/misc/pm8941-pwrkey.c:13:#include <linux/log2.h>
drivers/input/misc/pm8941-pwrkey.c-14-#include <linux/module.h>
--
drivers/input/misc/pmic8xxx-pwrkey.c-12-#include <linux/regmap.h>
drivers/input/misc/pmic8xxx-pwrkey.c:13:#include <linux/log2.h>
drivers/input/misc/pmic8xxx-pwrkey.c-14-#include <linux/of.h>
--
drivers/input/touchscreen/imx6ul_tsc.c-20-#include <linux/io.h>
drivers/input/touchscreen/imx6ul_tsc.c:21:#include <linux/log2.h>
drivers/input/touchscreen/imx6ul_tsc.c-22-
--
drivers/iommu/generic_pt/fmt/riscv.h-29-#include <linux/container_of.h>
drivers/iommu/generic_pt/fmt/riscv.h:30:#include <linux/log2.h>
drivers/iommu/generic_pt/fmt/riscv.h-31-#include <linux/sizes.h>
--
drivers/iommu/generic_pt/fmt/vtdss.h-28-#include <linux/container_of.h>
drivers/iommu/generic_pt/fmt/vtdss.h:29:#include <linux/log2.h>
drivers/iommu/generic_pt/fmt/vtdss.h-30-
--
drivers/iommu/generic_pt/fmt/x86_64.h-41-#include <linux/container_of.h>
drivers/iommu/generic_pt/fmt/x86_64.h:42:#include <linux/log2.h>
drivers/iommu/generic_pt/fmt/x86_64.h-43-#include <linux/mem_encrypt.h>
--
drivers/iommu/generic_pt/pt_defs.h-21-#include <linux/kconfig.h>
drivers/iommu/generic_pt/pt_defs.h:22:#include "pt_log2.h"
drivers/iommu/generic_pt/pt_defs.h-23-
--
drivers/iommu/generic_pt/pt_fmt_defaults.h-10-#include "pt_defs.h"
drivers/iommu/generic_pt/pt_fmt_defaults.h:11:#include <linux/log2.h>
drivers/iommu/generic_pt/pt_fmt_defaults.h-12-
--
drivers/iommu/sun50i-iommu.c-16-#include <linux/ioport.h>
drivers/iommu/sun50i-iommu.c:17:#include <linux/log2.h>
drivers/iommu/sun50i-iommu.c-18-#include <linux/module.h>
--
drivers/irqchip/irq-gic-v3-its.c-20-#include <linux/list.h>
drivers/irqchip/irq-gic-v3-its.c:21:#include <linux/log2.h>
drivers/irqchip/irq-gic-v3-its.c-22-#include <linux/mem_encrypt.h>
--
drivers/irqchip/irq-gic-v5-irs.c-9-#include <linux/kmemleak.h>
drivers/irqchip/irq-gic-v5-irs.c:10:#include <linux/log2.h>
drivers/irqchip/irq-gic-v5-irs.c-11-#include <linux/of.h>
--
drivers/leds/leds-lm3692x.c-8-#include <linux/leds.h>
drivers/leds/leds-lm3692x.c:9:#include <linux/log2.h>
drivers/leds/leds-lm3692x.c-10-#include <linux/mod_devicetable.h>
--
drivers/mailbox/pcc.c-54-#include <linux/list.h>
drivers/mailbox/pcc.c:55:#include <linux/log2.h>
drivers/mailbox/pcc.c-56-#include <linux/platform_device.h>
--
drivers/md/dm-clone-target.c-10-#include <linux/list.h>
drivers/md/dm-clone-target.c:11:#include <linux/log2.h>
drivers/md/dm-clone-target.c-12-#include <linux/init.h>
--
drivers/md/dm-snap.c-19-#include <linux/vmalloc.h>
drivers/md/dm-snap.c:20:#include <linux/log2.h>
drivers/md/dm-snap.c-21-#include <linux/dm-kcopyd.h>
--
drivers/md/dm-stripe.c-16-#include <linux/slab.h>
drivers/md/dm-stripe.c:17:#include <linux/log2.h>
drivers/md/dm-stripe.c-18-
--
drivers/md/dm-thin.c-15-#include <linux/jiffies.h>
drivers/md/dm-thin.c:16:#include <linux/log2.h>
drivers/md/dm-thin.c-17-#include <linux/list.h>
--
drivers/md/dm-vdo/dm-vdo-target.c-11-#include <linux/err.h>
drivers/md/dm-vdo/dm-vdo-target.c:12:#include <linux/log2.h>
drivers/md/dm-vdo/dm-vdo-target.c-13-#include <linux/module.h>
--
drivers/md/dm-vdo/encodings.c-7-
drivers/md/dm-vdo/encodings.c:8:#include <linux/log2.h>
drivers/md/dm-vdo/encodings.c-9-
--
drivers/md/dm-vdo/indexer/delta-index.c-10-#include <linux/limits.h>
drivers/md/dm-vdo/indexer/delta-index.c:11:#include <linux/log2.h>
drivers/md/dm-vdo/indexer/delta-index.c-12-
--
drivers/md/dm-vdo/indexer/geometry.c-8-#include <linux/compiler.h>
drivers/md/dm-vdo/indexer/geometry.c:9:#include <linux/log2.h>
drivers/md/dm-vdo/indexer/geometry.c-10-
--
drivers/md/dm-vdo/indexer/open-chapter.c-7-
drivers/md/dm-vdo/indexer/open-chapter.c:8:#include <linux/log2.h>
drivers/md/dm-vdo/indexer/open-chapter.c-9-
--
drivers/md/dm-vdo/indexer/volume-index.c-10-#include <linux/compiler.h>
drivers/md/dm-vdo/indexer/volume-index.c:11:#include <linux/log2.h>
drivers/md/dm-vdo/indexer/volume-index.c-12-
--
drivers/md/dm-vdo/priority-table.c-7-
drivers/md/dm-vdo/priority-table.c:8:#include <linux/log2.h>
drivers/md/dm-vdo/priority-table.c-9-
--
]
]
|
| 28/2 |
2026/05/21 22:53 |
llm |
debugger |
0m
Model:
Tokens:
input: 73728
output: 44
thoughts: 1580
Thoughts: **Analyzing and Fixing a Potential Shift-Out-of-Bounds Vulnerability in the BEFS Filesystem Code**
Okay, so I'm looking at this crash report from syzkaller, and it seems like there's a potential vulnerability in the BEFS filesystem code, specifically related to how superblock fields are handled. Initially, I thought about adding an include for `<linux/log2.h>` in `fs/befs/super.c`, but on further review, that's unnecessary because it's pulled in transitively. I need to get to the root of the problem.
It's clear that the issue lies within the `befs_check_sb()` function where `block_shift` and `ag_shift` are validated. The code directly reads these values from the disk superblock without proper bounds checking. The subsequent bitwise left-shift operation `1 << befs_sb->block_shift` or `1 << befs_sb->ag_shift` can cause a shift-out-of-bounds error if these values are excessively large (e.g., >= 32), which can lead to undefined behavior in C. The syzkaller report explicitly confirms this with the message "shift exponent 2066842816 is too large for 32-bit type 'int'".
To resolve this, the key is to prevent the shift operation from using unvalidated exponents. Since `befs_sb->block_size` is already validated to have a reasonable value (1024, 2048, 4096, or 8192), I can safely use `ilog2(befs_sb->block_size)` to check against `befs_sb->block_shift`. This avoids the potential shift-out-of-bounds issue.
For `ag_shift`, it's a bit more nuanced. The original code implicitly requires that `blocks_per_ag` be a power of two because it compares `1 << befs_sb->ag_shift` with `befs_sb->blocks_per_ag`. Now I can explicitly check if `blocks_per_ag` is a power of two using the `is_power_of_2()` macro from `<linux/log2.h>`. Then, I'll compare `ilog2(befs_sb->blocks_per_ag)` with `befs_sb->ag_shift`.
The corrected `befs_check_sb()` function will look like:
```c
#include <linux/log2.h> // Ensure this is included
...
/*
* block_shift and block_size encode the same information
* in different ways as a consistency check.
*/
if (befs_sb->block_shift != ilog2(befs_sb->block_size)) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
/* ag_shift also encodes the same information as blocks_per_ag in a
* different way, non-fatal consistency check
*/
if (!is_power_of_2(befs_sb->blocks_per_ag) ||
befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
```
I considered the edge case where `blocks_per_ag` might be zero, but I confirmed that the behavior of the original code, as well as the corrected version, is consistent.
Next, I needed to check if `block_shift` or `ag_shift` are used in other places without validation. I went through the code and saw that in `befs_load_sb` these values are assigned:
```c
befs_sb->block_shift = fs32_to_cpu(sb, disk_sb->block_shift);
befs_sb->ag_shift = fs32_to_cpu(sb, disk_sb->ag_shift);
```
Then in `fs/befs/befs.h` there were uses of `ag_shift` in these functions:
```c
static inline befs_blocknr_t
iaddr2blockno(struct super_block *sb, const befs_inode_addr *iaddr)
{
return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
iaddr->start);
}
static inline void
blockno2iaddr(
|
| 29/2 |
2026/05/21 22:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/befs/befs.h IncludeLines:true Name:befs_inode_addr]
Results: map[SourceCode: 108: typedef befs_block_run befs_inode_addr;
SourceFile:fs/befs/befs_fs_types.h]
|
| 30/2 |
2026/05/21 22:54 |
llm |
debugger |
0m
Model:
Tokens:
input: 76434
output: 48
thoughts: 12
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to a fellow expert:
**Debugging Workflow: `befs_block_run` Check**
Alright, time to get my hands dirty. My initial thought process is always a methodical one. First, I need to zero in on what's potentially causing an issue. Instead of jumping to conclusions, I'm thinking, "Let's check `befs_block_run`." That name alone suggests a critical piece of the puzzle, likely related to [Insert relevant knowledge here, e.g., the block execution within the BEFS system, the job scheduling aspect, the specific data block execution]. Iβm immediately going to mentally go through the usual suspects for problems related to this function: data dependencies, resource allocation, potential race conditions, input validation, or if there's a problem with the process being executed. The specifics of how I'm going to check will depend on the system. This likely involves diving into logs, examining its parameters and tracing execution if possible.
|
| 31/2 |
2026/05/21 22:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/befs/befs_fs_types.h IncludeLines:true Name:befs_block_run]
Results: map[SourceCode: 101: typedef struct {
102: u32 allocation_group;
103: u16 start;
104: u16 len;
105: } PACKED befs_block_run;
SourceFile:fs/befs/befs_fs_types.h]
|
| 32/2 |
2026/05/21 22:54 |
llm |
debugger |
0m
Model:
Tokens:
input: 76818
output: 49
thoughts: 97
Thoughts: Okay, let me think this through.
**Analyzing the Data Type Compatibility in this BEFS Calculation**
Alright, so `allocation_group` is confirmed as an `u32`. Good. That's the starting point. Now, I see the core calculation is `iaddr->allocation_group << BEFS_SB(sb)->ag_shift`. That's essentially a bitwise left shift: an unsigned 32-bit integer shifted by another unsigned 32-bit integer. The critical point is the value of `ag_shift`. If `ag_shift` is no more than 31, then the shift is valid and won't cause any undefined behavior or overflow in the resulting 32-bit value.
Hang on a second⦠The function `iaddr2blockno` is involved here, and that returns `befs_blocknr_t`. Hmm, I need to double-check: is that `befs_blocknr_t` defined as a `u64` or a `u32`? That distinction matters because it dictates the potential size of the shifted value and how `iaddr2blockno` is handling it. I need to make sure the shift operation's result fits within the expected range of a `befs_blocknr_t`.
|
| 33/2 |
2026/05/21 22:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/befs/befs_fs_types.h IncludeLines:true Name:befs_blocknr_t]
Results: map[SourceCode: 18: typedef u64 befs_blocknr_t;
SourceFile:fs/befs/befs.h]
|
| 34/2 |
2026/05/21 22:54 |
llm |
debugger |
0m
Model:
Tokens:
input: 77290
output: 43
thoughts: 75
Thoughts: Okay, let's break this down.
**Potential Integer Overflow Concerns in Block Number Calculation**
Hmm, so if `befs_blocknr_t` is defined as an unsigned 64-bit integer (`u64`), I need to be careful with how I'm handling the block number calculation within the `iaddr2blockno` function. Specifically, that line: `iaddr->allocation_group << BEFS_SB(sb)->ag_shift`. If `iaddr->allocation_group` is large enough, and then shifted left by `BEFS_SB(sb)->ag_shift`, which I assume is some shift amount related to the allocation group size, I could easily overflow a 32-bit integer if I'm not careful. That result would be incorrect, obviously. This is the kind of subtle bug that could lead to really nasty data corruption down the line.
Therefore, I need to make sure that the multiplication is performed using 64-bit arithmetic to avoid this overflow. Looks like I will need to verify the code again and make sure that this is handled correctly. Let's revisit `iaddr2blockno` and make sure it's doing what I expect.
|
| 35/2 |
2026/05/21 22:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/befs/befs.h IncludeLines:true Name:iaddr2blockno]
Results: map[SourceCode: 122: static inline befs_blocknr_t
123: iaddr2blockno(struct super_block *sb, const befs_inode_addr *iaddr)
124: {
125: return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
126: iaddr->start);
127: }
SourceFile:fs/befs/befs.h]
|
| 36/2 |
2026/05/21 22:54 |
llm |
debugger |
0m
Model:
Tokens:
input: 77799
output: 17
thoughts: 625
Thoughts: **Analyzing the BEFS Filesystem Consistency Check**
Okay, so I'm looking at this code and trying to figure out what's going on. First, I noticed something about `iaddr->allocation_group` being a `u32`, and the potential for overflow if `ag_shift` is large. However, that feels like a separate, pre-existing issue. It's not directly related to the specific crash. My primary concern right now is that this shift exponent is too large. It's failing specifically in `befs_check_sb`, saying the shift amount is excessive for a 32-bit `int`.
Let's dissect the current fix. It checks for consistency between `block_shift` and `block_size`, which is good. Then it moves on to `ag_shift` and `blocks_per_ag`. I'm comparing the old code:
```c
if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
```
...with the new code:
```c
if (!is_power_of_2(befs_sb->blocks_per_ag) ||
befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
```
Hold on, the new code is functionally equivalent to the old code. It's just a more robust way to check that the `blocks_per_ag` is a power of 2 and consistent with `ag_shift`. Both just print an error. They don't return `BEFS_ERR`.
But wait, if `blocks_per_ag` isn't a power of 2, or if `ag_shift` is wildly incorrect, should we be more aggressive? The comment says this is a "non-fatal consistency check". I'm thinking, should we *not* return an error? The code's comment guides us. No, we shouldn't.
Now, a more crucial question: if we *continue* with an invalid `ag_shift`, we're likely to hit the shift-out-of-bounds issue when it's used later in `iaddr2blockno`, during the `iaddr->allocation_group << BEFS_SB(sb)->ag_shift` calculation. That's a ticking time bomb! I need to trace where `ag_shift` is actually used beyond this check. I need to make sure we're not just kicking the can down the road.
|
| 37/2 |
2026/05/21 22:54 |
tool |
grepper |
0m
Args:
Results: map[Output:arch/arm64/include/asm/memory.h=263=static inline bool kaslr_enabled(void) { return false; }
--
arch/arm64/include/asm/memory.h-296-#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS)
arch/arm64/include/asm/memory.h:297:#define __tag_shifted(tag) ((u64)(tag) << 56)
arch/arm64/include/asm/memory.h-298-#define __tag_reset(addr) __untagged_addr(addr)
--
arch/arm64/include/asm/memory.h-300-#else
arch/arm64/include/asm/memory.h:301:#define __tag_shifted(tag) 0UL
arch/arm64/include/asm/memory.h-302-#define __tag_reset(addr) (addr)
--
arch/arm64/include/asm/memory.h=306=static inline const void *__tag_set(const void *addr, u8 tag)
arch/arm64/include/asm/memory.h-307-{
arch/arm64/include/asm/memory.h:308: u64 __addr = (u64)addr & ~__tag_shifted(0xff);
arch/arm64/include/asm/memory.h:309: return (const void *)(__addr | __tag_shifted(tag));
arch/arm64/include/asm/memory.h-310-}
--
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c=49=void __cvmx_helper_errata_qlm_disable_2nd_order_cdr(int qlm)
--
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c-60- */
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c:61: cvmx_helper_qlm_jtag_shift_zeros(qlm, 63 - 0 + 1);
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c-62- /* cfg_cdr_incx<67:64>=3 */
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c:63: cvmx_helper_qlm_jtag_shift(qlm, 67 - 64 + 1, 3);
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c-64- /* Zeros for bits <76:68> */
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c:65: cvmx_helper_qlm_jtag_shift_zeros(qlm, 76 - 68 + 1);
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c-66- /* cfg_cdr_secord<77>=1 */
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c:67: cvmx_helper_qlm_jtag_shift(qlm, 77 - 77 + 1, 1);
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c-68- /* Zeros for bits <267:78> */
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c:69: cvmx_helper_qlm_jtag_shift_zeros(qlm, 267 - 78 + 1);
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c-70- }
--
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c=46=void cvmx_helper_qlm_jtag_init(void)
--
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-86- */
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c:87:uint32_t cvmx_helper_qlm_jtag_shift(int qlm, int bits, uint32_t data)
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-88-{
--
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-106- * chain. This function is a convenience wrapper around
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c:107: * cvmx_helper_qlm_jtag_shift() to shift more than 32 bits of
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-108- * zeros at a time.
--
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-112- */
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c:113:void cvmx_helper_qlm_jtag_shift_zeros(int qlm, int bits)
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-114-{
--
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-118- n = 32;
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c:119: cvmx_helper_qlm_jtag_shift(qlm, n, 0);
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c-120- bits -= n;
--
arch/mips/include/asm/octeon/cvmx-helper-jtag.h=38=extern void cvmx_helper_qlm_jtag_init(void);
arch/mips/include/asm/octeon/cvmx-helper-jtag.h:39:extern uint32_t cvmx_helper_qlm_jtag_shift(int qlm, int bits, uint32_t data);
arch/mips/include/asm/octeon/cvmx-helper-jtag.h:40:extern void cvmx_helper_qlm_jtag_shift_zeros(int qlm, int bits);
arch/mips/include/asm/octeon/cvmx-helper-jtag.h-41-extern void cvmx_helper_qlm_jtag_update(int qlm);
--
arch/mips/pci/pcie-octeon.c=1153=static int __cvmx_pcie_rc_initialize_gen2(int pcie_port)
--
arch/mips/pci/pcie-octeon.c-1220- cvmx_helper_qlm_jtag_init();
arch/mips/pci/pcie-octeon.c:1221: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 85);
arch/mips/pci/pcie-octeon.c:1222: cvmx_helper_qlm_jtag_shift(pcie_port, 1, 1);
arch/mips/pci/pcie-octeon.c:1223: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 300-86);
arch/mips/pci/pcie-octeon.c:1224: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 85);
arch/mips/pci/pcie-octeon.c:1225: cvmx_helper_qlm_jtag_shift(pcie_port, 1, 1);
arch/mips/pci/pcie-octeon.c:1226: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 300-86);
arch/mips/pci/pcie-octeon.c:1227: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 85);
arch/mips/pci/pcie-octeon.c:1228: cvmx_helper_qlm_jtag_shift(pcie_port, 1, 1);
arch/mips/pci/pcie-octeon.c:1229: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 300-86);
arch/mips/pci/pcie-octeon.c:1230: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 85);
arch/mips/pci/pcie-octeon.c:1231: cvmx_helper_qlm_jtag_shift(pcie_port, 1, 1);
arch/mips/pci/pcie-octeon.c:1232: cvmx_helper_qlm_jtag_shift_zeros(pcie_port, 300-86);
arch/mips/pci/pcie-octeon.c-1233- cvmx_helper_qlm_jtag_update(pcie_port);
--
drivers/infiniband/hw/bng_re/bng_res.h=53=enum bng_re_db_info_flags_mask {
--
drivers/infiniband/hw/bng_re/bng_res.h-59-
drivers/infiniband/hw/bng_re/bng_res.h:60:enum bng_re_db_epoch_flag_shift {
drivers/infiniband/hw/bng_re/bng_res.h-61- BNG_RE_DB_EPOCH_CONS_SHIFT = BNG_RE_DBR_EPOCH_SHIFT,
--
drivers/infiniband/hw/bnxt_re/qplib_res.h=217=enum bnxt_qplib_db_info_flags_mask {
--
drivers/infiniband/hw/bnxt_re/qplib_res.h-223-
drivers/infiniband/hw/bnxt_re/qplib_res.h:224:enum bnxt_qplib_db_epoch_flag_shift {
drivers/infiniband/hw/bnxt_re/qplib_res.h-225- BNXT_QPLIB_DB_EPOCH_CONS_SHIFT = BNXT_QPLIB_DBR_EPOCH_SHIFT,
--
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h=348=struct tp_params {
--
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h-385- int matchtype_shift;
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h:386: int frag_shift;
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h-387-
--
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c=1151=bool is_filter_exact_match(struct adapter *adap,
--
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c-1226-
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c:1227: if (tp->frag_shift >= 0)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c:1228: ntuple_mask |= (u64)fs->mask.frag << tp->frag_shift;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c-1229-
--
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c=1236=static u64 hash_filter_ntuple(struct ch_filter_specification *fs,
--
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c-1286-
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c:1287: if (tp->frag_shift >= 0 && fs->mask.frag)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c:1288: ntuple |= (u64)(fs->val.frag) << tp->frag_shift;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c-1289-
--
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c=9409=int t4_init_tp_params(struct adapter *adap, bool sleep_ok)
--
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c-9491- MPSHITTYPE_F);
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:9492: adap->params.tp.frag_shift = t4_filter_field_shift(adap,
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c-9493- FRAGMENTATION_F);
--
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c=9817=static int hclge_set_vlan_tx_offload_cfg(struct hclge_vport *vport)
--
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c-9843- hnae3_set_bit(req->vport_vlan_cfg, HCLGE_TAG_SHIFT_MODE_EN_B,
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c:9844: vcfg->tag_shift_mode_en ? 1 : 0);
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c-9845- hnae3_set_bit(req->vport_vlan_cfg, HCLGE_CFG_NIC_ROCE_SEL_B, 0);
--
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c=9902=static int hclge_vlan_offload_cfg(struct hclge_vport *vport,
--
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c-9931- vport->txvlan_cfg.default_tag2 = 0;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c:9932: vport->txvlan_cfg.tag_shift_mode_en = true;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c-9933-
--
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h=992=struct hclge_tx_vtag_cfg {
--
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h-1000- u16 default_tag2; /* The default outer vlan tag to insert */
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h:1001: bool tag_shift_mode_en;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h-1002-};
--
fs/befs/befs.h=32=struct befs_sb_info {
--
fs/befs/befs.h-43- u32 blocks_per_ag;
fs/befs/befs.h:44: u32 ag_shift;
fs/befs/befs.h-45- u32 num_ags;
--
fs/befs/befs.h=123=iaddr2blockno(struct super_block *sb, const befs_inode_addr *iaddr)
fs/befs/befs.h-124-{
fs/befs/befs.h:125: return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
fs/befs/befs.h-126- iaddr->start);
--
fs/befs/befs.h=130=blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
--
fs/befs/befs.h-133-
fs/befs/befs.h:134: iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
fs/befs/befs.h-135- iaddr.start =
fs/befs/befs.h:136: blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
fs/befs/befs.h-137- iaddr.len = 1;
--
fs/befs/befs_fs_types.h=113=typedef struct {
--
fs/befs/befs_fs_types.h-127- fs32 blocks_per_ag;
fs/befs/befs_fs_types.h:128: fs32 ag_shift;
fs/befs/befs_fs_types.h-129- fs32 num_ags;
--
fs/befs/debug.c=156=befs_dump_super_block(const struct super_block *sb, befs_super_block *sup)
--
fs/befs/debug.c-178- fs32_to_cpu(sb, sup->blocks_per_ag));
fs/befs/debug.c:179: befs_debug(sb, " ag_shift %u", fs32_to_cpu(sb, sup->ag_shift));
fs/befs/debug.c-180- befs_debug(sb, " num_ags %u", fs32_to_cpu(sb, sup->num_ags));
--
fs/befs/super.c=21=befs_load_sb(struct super_block *sb, befs_super_block *disk_sb)
--
fs/befs/super.c-40- befs_sb->blocks_per_ag = fs32_to_cpu(sb, disk_sb->blocks_per_ag);
fs/befs/super.c:41: befs_sb->ag_shift = fs32_to_cpu(sb, disk_sb->ag_shift);
fs/befs/super.c-42- befs_sb->num_ags = fs32_to_cpu(sb, disk_sb->num_ags);
--
fs/befs/super.c=58=befs_check_sb(struct super_block *sb)
--
fs/befs/super.c-102-
fs/befs/super.c:103: /* ag_shift also encodes the same information as blocks_per_ag in a
fs/befs/super.c-104- * different way, non-fatal consistency check
fs/befs/super.c-105- */
fs/befs/super.c:106: if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
fs/befs/super.c:107: befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
fs/befs/super.c-108-
--
sound/soc/mediatek/common/mtk-afe-fe-dai.c=456=int mtk_memif_set_channel(struct mtk_base_afe *afe,
--
sound/soc/mediatek/common/mtk-afe-fe-dai.c-482- 1, mono,
sound/soc/mediatek/common/mtk-afe-fe-dai.c:483: memif->data->int_odd_flag_shift);
sound/soc/mediatek/common/mtk-afe-fe-dai.c-484-
--
sound/soc/mediatek/common/mtk-base-afe.h=33=struct mtk_base_memif_data {
--
sound/soc/mediatek/common/mtk-base-afe.h-51- int int_odd_flag_reg;
sound/soc/mediatek/common/mtk-base-afe.h:52: int int_odd_flag_shift;
sound/soc/mediatek/common/mtk-base-afe.h-53- int enable_reg;
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c=1924=static const struct mtk_base_memif_data memif_data[MT8188_AFE_MEMIF_NUM] = {
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-1936- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:1937: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-1938- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-1963- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:1964: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-1965- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-1990- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:1991: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-1992- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2017- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2018: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2019- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2044- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2045: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2046- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2071- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2072: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2073- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2098- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2099: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2100- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2125- .int_odd_flag_reg = AFE_UL1_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2126: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2127- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2152- .int_odd_flag_reg = AFE_UL2_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2153: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2154- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2179- .int_odd_flag_reg = AFE_UL3_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2180: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2181- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2206- .int_odd_flag_reg = AFE_UL4_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2207: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2208- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2233- .int_odd_flag_reg = AFE_UL5_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2234: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2235- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2260- .int_odd_flag_reg = AFE_UL6_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2261: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2262- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2287- .int_odd_flag_reg = AFE_UL8_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2288: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2289- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2314- .int_odd_flag_reg = AFE_UL9_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2315: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2316- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2341- .int_odd_flag_reg = AFE_UL10_CON0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c:2342: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c-2343- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c=1796=static const struct mtk_base_memif_data memif_data[MT8195_AFE_MEMIF_NUM] = {
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1808- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1809: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1810- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1835- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1836: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1837- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1862- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1863: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1864- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1889- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1890: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1891- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1916- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1917: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1918- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1943- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1944: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1945- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1970- .int_odd_flag_reg = -1,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1971: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1972- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1997- .int_odd_flag_reg = AFE_UL1_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:1998: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-1999- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2024- .int_odd_flag_reg = AFE_UL2_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2025: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2026- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2051- .int_odd_flag_reg = AFE_UL3_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2052: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2053- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2078- .int_odd_flag_reg = AFE_UL4_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2079: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2080- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2105- .int_odd_flag_reg = AFE_UL5_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2106: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2107- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2132- .int_odd_flag_reg = AFE_UL6_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2133: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2134- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2159- .int_odd_flag_reg = AFE_UL8_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2160: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2161- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2186- .int_odd_flag_reg = AFE_UL9_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2187: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2188- .enable_reg = AFE_DAC_CON0,
--
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2213- .int_odd_flag_reg = AFE_UL10_CON0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2214: .int_odd_flag_shift = 0,
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c-2215- .enable_reg = AFE_DAC_CON0,
]
|
| 38/2 |
2026/05/21 22:54 |
llm |
debugger |
0m
Model:
Tokens:
input: 89031
output: 948
thoughts: 1214
Thoughts: **Analysis of the BEFS Superblock Validation Crash**
Okay, so here's what I've got. The core of the problem seems to be in `befs_check_sb()` within the BEFS filesystem code, specifically related to how it handles `block_shift` and `ag_shift` values read from the superblock. I noticed the crash report clearly points to an out-of-bounds shift error. The critical part is this:
```c
if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
...
if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
```
The code directly uses `befs_sb->block_shift` and `befs_sb->ag_shift` as shift exponents in the bitwise left-shift operator `<<` without validation. If a malicious or corrupted filesystem provides a large value for either of these fieldsβlike the example with `block_shift` = 2066842816 reported in the crashβthe expression `1 << befs_sb->block_shift` results in undefined behavior. This shift-out-of-bounds leads to the crash.
I quickly checked the code and saw that `ag_shift` is used in `iaddr2blockno`, but it's okay because the shift only uses `u32` which is valid. It's a bug but not the one that crashed.
**My Proposed Fix**
The fix is straightforward: avoid using these unvalidated values directly as shift exponents. Instead, I need to compute the expected shift values and compare them against those read from the superblock. I'll leverage the `ilog2()` and `is_power_of_2()` macros from `<linux/log2.h>`, which are designed for precisely this purpose.
For `block_shift`, the fix is simple: I'll use `ilog2(befs_sb->block_size)`. This is safe because `befs_sb->block_size` has already been validated in the code to be one of a small set of powers of two (1024, 2048, 4096, or 8192).
For `ag_shift`, it's slightly more involved. The original check, `(1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag`, implicitly requires that `blocks_per_ag` is a power of two. But, I'll add an explicit check using `is_power_of_2(befs_sb->blocks_per_ag)` before proceeding. If `blocks_per_ag` is a power of two, I will then compare `ilog2(befs_sb->blocks_per_ag)` with `befs_sb->ag_shift`.
Here's how I envision the revised code in `fs/befs/super.c`:
```c
#include <linux/log2.h>
...
int befs_check_sb(struct super_block *sb)
{
...
/*
* block_shift and block_size encode the same information
* in different ways as a consistency check.
*/
if (befs_sb->block_shift != ilog2(befs_sb->block_size)) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
/* ag_shift also encodes the same information as blocks_per_ag in a
* different way, non-fatal consistency check
*/
if (!is_power_of_2(befs_sb->blocks_per_ag) ||
befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
...
}
```
This ensures the shift exponents are always valid while maintaining the same validation logic. It directly addresses the shift-out-of-bounds vulnerability and should resolve the reported crash.
|
| 39/1 |
2026/05/21 22:54 |
action |
kernel-scratch-checkouter |
0m
Results: map[KernelScratchSrc:/app/workdir/cache/tmp/tmp1245896397]
|
| 40/1 |
2026/05/21 22:55 |
loop |
|
33m
|
| 41/2 |
2026/05/21 22:55 |
iteration |
0 |
33m
|
| 42/3 |
2026/05/21 22:55 |
agent |
patch-generator |
2m
Model:
Instruction:
You are an experienced Linux kernel developer tasked with creating a fix for a kernel bug.
You will be given a crash report, and an initial explanation of the root cause done by another
kernel expert.
Use the codeeditor tool to do code edits.
Note: you will not see your changes when looking at the code using codesearch tools.
Use the patch-diff tool to review the modifications you applied.
Your final reply should contain explanation of what you did in the patch and why
(details not present in the initial explanation of the bug).
Your fix must not just prevent the given crash, but also be the best fix for the underlying
root cause from the software engineering point of view. There can be several ways to fix the
same bug. Consider alternatives, and pick the best one. For example, additional checks may be
added at different locations/functions, it's usually better to place them earlier in the
execution to avoid multiple checks at various locations later.
Frequently the same coding mistake is done in several locations in the source code.
Check if your fix should be extended/applied to similar cases around to fix other similar bugs.
But don't go too wide, don't try to fix problems kernel-wide, fix similar issues
in the same file only.
If you are changing post-conditions of a function, consider all callers of the functions,
and if they need to be updated to handle new post-conditions. For example, if you make
a function that previously never returned a NULL, return NULL, consider if callers
need to be updated to handle NULL return value.
Prefer calling several tools at the same time to save round-trips.
Prompt:
The crash that corresponds to the bug is:
loop0: detected capacity change from 0 to 128
------------[ cut here ]------------
UBSAN: shift-out-of-bounds in /app/workdir/cache/src/d5a02ed91a4f019017141f71e695c75b27c3612e/fs/befs/super.c:96:9
shift exponent 2066842816 is too large for 32-bit type 'int'
CPU: 0 UID: 0 PID: 6217 Comm: syz.0.17 Not tainted syzkaller #1 PREEMPT_{RT,(full)}
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
ubsan_epilogue+0xa/0x30 lib/ubsan.c:233
__ubsan_handle_shift_out_of_bounds+0x385/0x410 lib/ubsan.c:494
befs_check_sb+0x421/0x4c0 fs/befs/super.c:96
befs_fill_super+0x49b/[ 166.533846][ T6217] befs_fill_super+0x49b/0xa70 fs/befs/linuxvfs.c:843
get_tree_bdev_flags+0x431/0x4f0 fs/super.c:1694
vfs_get_tree+0x92/0x2a0 fs/super.c:1754
fc_mount fs/namespace.c:1193 [inline]
do_new_mount_fc fs/namespace.c:3758 [inline]
do_new_mount+0x341/0xd30 fs/namespace.c:3834
do_mount fs/namespace.c:4167 [inline]
__do_sys_mount fs/namespace.c:4383 [inline]
__se_sys_mount+0x31d/0x420 fs/namespace.c:4360
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5c83a6e0ca
Code: 48 c7 c2 e8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f5c830cde58 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f5c830cdee0 RCX: 00007f5c83a6e0ca
RDX: 0000200000000040 RSI: 0000200000000000 RDI: 00007f5c830cdea0
RBP: 0000200000000040 R08: 00007f5c830cdee0 R09: 0000000000800001
R10: 0000000000800001 R11: 0000000000000246 R12: 0000200000000000
R13: 00007f5c830cdea0 R14: 0000000000009e17 R15: 0000200000000080
</TASK>
---[ end trace ]---
The explanation of the root cause of the bug is:
An analysis of the crash report and the source code reveals the following root cause and the corresponding fix.
### Root Cause
The crash is caused by a shift-out-of-bounds (Undefined Behavior) in `fs/befs/super.c` inside the `befs_check_sb()` function.
When mounting a BEFS filesystem, the kernel reads the superblock fields `block_shift` and `ag_shift` directly from the disk and uses them as shift exponents to validate consistency with `block_size` and `blocks_per_ag`:
```c
if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
// ...
}
if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
// ...
```
Because `befs_sb->block_shift` and `befs_sb->ag_shift` are controlled by the filesystem image and are not validated before the shift operation, a maliciously crafted image can provide a huge value (e.g., `2066842816` as seen in the syzkaller log). Shifting a 32-bit integer `1` by an exponent $\ge 32$ triggers a UBSAN shift-out-of-bounds panic.
### Fix
To fix this, we should avoid using the unvalidated `block_shift` and `ag_shift` as shift exponents. Instead, we can use the `ilog2()` and `is_power_of_2()` macros from `<linux/log2.h>` to compute the expected shift values from `block_size` and `blocks_per_ag`, and compare them against the provided shift values.
1. **For `block_shift`**:
`befs_sb->block_size` is already strictly validated earlier in `befs_check_sb()` to be exactly 1024, 2048, 4096, or 8192. Since it is guaranteed to be a valid power of two, we can safely use `ilog2(befs_sb->block_size)` to get the expected `block_shift`.
2. **For `ag_shift`**:
`befs_sb->blocks_per_ag` is not validated to be a power of two. The original check `(1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag` inherently requires `blocks_per_ag` to be a power of two (otherwise they can never be equal). We can explicitly check if `blocks_per_ag` is a power of two using `is_power_of_2()`, and if so, compare `ilog2(befs_sb->blocks_per_ag)` with `befs_sb->ag_shift`.
Here is how the patched code in `fs/befs/super.c` should look:
```c
#include <linux/log2.h>
// ...
int befs_check_sb(struct super_block *sb)
{
struct befs_sb_info *befs_sb = BEFS_SB(sb);
// ... [magic and block_size checks] ...
/*
* block_shift and block_size encode the same information
* in different ways as a consistency check.
*/
if (befs_sb->block_shift != ilog2(befs_sb->block_size)) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
/* ag_shift also encodes the same information as blocks_per_ag in a
* different way, non-fatal consistency check
*/
if (!is_power_of_2(befs_sb->blocks_per_ag) ||
befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
// ...
}
```
This completely eliminates the undefined behavior while preserving the exact same validation logic.
Reply: I have applied the fix as proposed.
### Explanation of the fix
The crash occurs because the kernel reads `block_shift` and `ag_shift` directly from the filesystem image and uses them as shift exponents without validation. If a maliciously crafted image provides a large value for these fields (e.g., `2066842816`), the expression `1 << befs_sb->block_shift` or `1 << befs_sb->ag_shift` triggers a shift-out-of-bounds undefined behavior, which results in a kernel panic when UBSAN is enabled.
To fix this, we can avoid using the unvalidated shift values as shift exponents. Instead, we can compute the expected shift values from `block_size` and `blocks_per_ag` using `ilog2()` and compare them against the provided shift values:
1. **For `block_shift`**: `befs_sb->block_size` is already strictly validated earlier in `befs_check_sb()` to be exactly 1024, 2048, 4096, or 8192. Since it is guaranteed to be a valid power of two, we can safely use `ilog2(befs_sb->block_size)` to get the expected `block_shift`.
2. **For `ag_shift`**: `befs_sb->blocks_per_ag` is not validated to be a power of two. The original check `(1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag` inherently requires `blocks_per_ag` to be a power of two (otherwise they can never be equal). We can explicitly check if `blocks_per_ag` is a power of two using `is_power_of_2()`, and if so, compare `ilog2(befs_sb->blocks_per_ag)` with `befs_sb->ag_shift`. If `blocks_per_ag` is not a power of two, the check will fail as expected.
I have updated `fs/befs/super.c` to include `<linux/log2.h>` and replaced the unsafe shift operations with the safe `ilog2()` and `is_power_of_2()` checks. This completely eliminates the undefined behavior while preserving the exact same validation logic.
|
| 43/4 |
2026/05/21 22:55 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 6233
output: 27
thoughts: 115
Thoughts: **Analyzing a Shift-Out-of-Bounds Vulnerability in BEFS Filesystem**
Okay, so I'm digging into this bug report, and it looks like we've got a classic shift-out-of-bounds issue, specifically within the BEFS filesystem code, in `fs/befs/super.c` at line 96. My immediate thought is, "Ah, yes, memory safety, the never-ending battle!"
The core problem, as I understand it, stems from the fact that `befs_sb->block_shift` and `befs_sb->ag_shift` are being directly pulled from the disk. Essentially, these values, which determine shift exponents, are read without any validation whatsoever before being used. That's a textbook recipe for disaster. If a malicious or corrupted filesystem sets these values incorrectly, we're looking at potential memory corruption when the code tries to calculate offsets or sizes using these shifts.
The proposed fix, which seems quite sensible, involves validating these values using `ilog2()` and `is_power_of_2()`. That makes perfect sense; `ilog2()` gives you the integer logarithm base 2, confirming the value is a valid power of 2, and then we're double-checking with `is_power_of_2()` to be absolutely sure. This will ensure that these shift values are not only valid but also adhere to the fundamental requirements for shifting operations, preventing out-of-bounds reads or writes. I'll need to review this code closely, paying particular attention to how these validated shift values are subsequently used in calculations. Let's start by looking at `fs/befs/super.c`.
|
| 44/4 |
2026/05/21 22:55 |
tool |
codesearch-file-index |
0m
Args: map[SourceFile:fs/befs/super.c]
Results: map[Entities:[map[Kind:function Name:befs_check_sb] map[Kind:function Name:befs_load_sb]]]
|
| 45/4 |
2026/05/21 22:55 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 6779
output: 23
thoughts: 14
Thoughts: Here's a first-person summary, keeping in mind the audience is an expert:
**Diving into BEFS Superblock Implementation**
Alright, time to crack open `fs/befs/super.c`. Let's get down to the nitty-gritty of the BeFS superblock. I'm going to start by refreshing my memory on how this filesystem structures its metadata, specifically how it handles the fundamental block management, and how that interacts with the overall filesystem operations. I want to see how the code represents and protects the critical information that describes the filesystem itself, such as block size, the number of inodes, the location of the root directory, and free space maps. I'll pay close attention to any locking mechanisms or synchronization primitives employed to ensure consistency, especially in a multi-threaded environment. I expect to see some interesting design choices reflecting the filesystem's evolution and performance considerations. I'm looking for the 'aha!' moments, the elegant solutions, or maybe even areas where optimization could be explored. Let's see how well it's all put together.
|
| 46/4 |
2026/05/21 22:55 |
tool |
read-file |
0m
Args: map[File:fs/befs/super.c]
Results: map[Contents:/*
* super.c
*
* Copyright (C) 2001-2002 Will Dyson <will_dyson@pobox.com>
*
* Licensed under the GNU GPL. See the file COPYING for details.
*
*/
#include <linux/fs.h>
#include <asm/page.h> /* for PAGE_SIZE */
#include "befs.h"
#include "super.h"
/*
* befs_load_sb -- Read from disk and properly byteswap all the fields
* of the befs superblock
*/
int
befs_load_sb(struct super_block *sb, befs_super_block *disk_sb)
{
struct befs_sb_info *befs_sb = BEFS_SB(sb);
/* Check the byte order of the filesystem */
if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_LE)
befs_sb->byte_order = BEFS_BYTESEX_LE;
else if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_BE)
befs_sb->byte_order = BEFS_BYTESEX_BE;
befs_sb->magic1 = fs32_to_cpu(sb, disk_sb->magic1);
befs_sb->magic2 = fs32_to_cpu(sb, disk_sb->magic2);
befs_sb->magic3 = fs32_to_cpu(sb, disk_sb->magic3);
befs_sb->block_size = fs32_to_cpu(sb, disk_sb->block_size);
befs_sb->block_shift = fs32_to_cpu(sb, disk_sb->block_shift);
befs_sb->num_blocks = fs64_to_cpu(sb, disk_sb->num_blocks);
befs_sb->used_blocks = fs64_to_cpu(sb, disk_sb->used_blocks);
befs_sb->inode_size = fs32_to_cpu(sb, disk_sb->inode_size);
befs_sb->blocks_per_ag = fs32_to_cpu(sb, disk_sb->blocks_per_ag);
befs_sb->ag_shift = fs32_to_cpu(sb, disk_sb->ag_shift);
befs_sb->num_ags = fs32_to_cpu(sb, disk_sb->num_ags);
befs_sb->flags = fs32_to_cpu(sb, disk_sb->flags);
befs_sb->log_blocks = fsrun_to_cpu(sb, disk_sb->log_blocks);
befs_sb->log_start = fs64_to_cpu(sb, disk_sb->log_start);
befs_sb->log_end = fs64_to_cpu(sb, disk_sb->log_end);
befs_sb->root_dir = fsrun_to_cpu(sb, disk_sb->root_dir);
befs_sb->indices = fsrun_to_cpu(sb, disk_sb->indices);
befs_sb->nls = NULL;
return BEFS_OK;
}
int
befs_check_sb(struct super_block *sb)
{
struct befs_sb_info *befs_sb = BEFS_SB(sb);
/* Check magic headers of super block */
if ((befs_sb->magic1 != BEFS_SUPER_MAGIC1)
|| (befs_sb->magic2 != BEFS_SUPER_MAGIC2)
|| (befs_sb->magic3 != BEFS_SUPER_MAGIC3)) {
befs_error(sb, "invalid magic header");
return BEFS_ERR;
}
/*
* Check blocksize of BEFS.
*
* Blocksize of BEFS is 1024, 2048, 4096 or 8192.
*/
if ((befs_sb->block_size != 1024)
&& (befs_sb->block_size != 2048)
&& (befs_sb->block_size != 4096)
&& (befs_sb->block_size != 8192)) {
befs_error(sb, "invalid blocksize: %u", befs_sb->block_size);
return BEFS_ERR;
}
if (befs_sb->block_size > PAGE_SIZE) {
befs_error(sb, "blocksize(%u) cannot be larger "
"than system pagesize(%lu)", befs_sb->block_size,
PAGE_SIZE);
return BEFS_ERR;
}
/*
* block_shift and block_size encode the same information
* in different ways as a consistency check.
*/
if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
/* ag_shift also encodes the same information as blocks_per_ag in a
* different way, non-fatal consistency check
*/
if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
if (befs_sb->log_start != befs_sb->log_end ||
befs_sb->flags == BEFS_DIRTY) {
befs_error(sb, "Filesystem not clean! There are blocks in the "
"journal. You must boot into BeOS and mount this "
"volume to make it clean.");
return BEFS_ERR;
}
return BEFS_OK;
}
]
|
| 47/4 |
2026/05/21 22:55 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 8507
output: 410
thoughts: 78
Thoughts: Okay, here's my thought process regarding this code, from my perspective as an expert:
**Addressing a Potential Missing Header**
Right, let's just make sure `<linux/log2.h>` is properly included in `fs/befs/super.c`. Hmm, a quick search... nope, it's not present. Okay, that's straightforward. I need to add an `#include <linux/log2.h>` statement to that file. We often forget these.
Now, let me just quickly glance over lines 89-106 of `fs/befs/super.c`. Just to be safe, I like to be sure the function where it is going to be used is actually present. I do not see the specific usage here, so this seems like a fine and independent inclusion.
|
| 48/4 |
2026/05/21 22:55 |
tool |
codeeditor |
0m
Args: map[CurrentCode: /*
* block_shift and block_size encode the same information
* in different ways as a consistency check.
*/
if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
/* ag_shift also encodes the same information as blocks_per_ag in a
* different way, non-fatal consistency check
*/
if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
befs_error(sb, "ag_shift disagrees with blocks_per_ag."); NewCode: /*
* block_shift and block_size encode the same information
* in different ways as a consistency check.
*/
if (befs_sb->block_shift != ilog2(befs_sb->block_size)) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
/* ag_shift also encodes the same information as blocks_per_ag in a
* different way, non-fatal consistency check
*/
if (!is_power_of_2(befs_sb->blocks_per_ag) ||
befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
befs_error(sb, "ag_shift disagrees with blocks_per_ag."); SourceFile:fs/befs/super.c]
Results:
|
| 49/4 |
2026/05/21 22:55 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 9177
output: 114
thoughts: 26
Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue:
**Adding a Necessary Header**
Right, so I'm diving into `fs/befs/super.c`. Looks like I need to incorporate the `#include <linux/log2.h>` directive here. No surprises, really. Considering the operations I'm implementing or debugging within that file, it's pretty clear that I'm going to need the `log2` functionality at some point. It's likely involved in bitwise operations related to block size calculations, inode allocation, or potentially even some metadata structure handling, given the context of a BEFS superblock file. Makes sense. Better to get it in now before I start writing code that depends on it and have to go back. Always good to anticipate these kinds of dependencies and proactively include them. Efficient.
|
| 50/4 |
2026/05/21 22:55 |
tool |
codeeditor |
0m
Args: map[CurrentCode:#include <linux/fs.h>
#include <asm/page.h> /* for PAGE_SIZE */
#include "befs.h" NewCode:#include <linux/fs.h>
#include <linux/log2.h>
#include <asm/page.h> /* for PAGE_SIZE */
#include "befs.h" SourceFile:fs/befs/super.c]
Results:
|
| 51/4 |
2026/05/21 22:55 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 9506
output: 23
thoughts: 7
Thoughts: Okay, I'm ready to delve into this text and formulate a summary from a first-person perspective, as an expert would. Here we go.
**Reviewing the Revisions: A Thoughtful Examination**
Alright, let's get down to brass tacks. I need to meticulously review these changes. *Where* did they occur? *Why* were they implemented? I'm not just looking for a simple list of modifications; I'm after the *reasoning* behind each alteration, the impact of these revisions on the overall integrity of the work, and the extent to which they align with the original goals, the established methodologies, and prevailing best practices within the field. My assessment will require a critical eye and an understanding of the subtle nuances, the potential pitfalls, and the possible unexpected outcomes of each adjustment. I need to be sure these edits are well considered and add value, and do not inadvertently compromise the work. This review demands a thorough, almost forensic, approach. Time to dig in.
|
| 52/4 |
2026/05/21 22:55 |
tool |
patch-diff |
0m
Args: map[File:fs/befs/super.c]
Results: map[Output:diff --git a/fs/befs/super.c b/fs/befs/super.c
index 7c50025c9..51cf57ad6 100644
--- a/fs/befs/super.c
+++ b/fs/befs/super.c
@@ -1,20 +1,21 @@
/*
* super.c
*
* Copyright (C) 2001-2002 Will Dyson <will_dyson@pobox.com>
*
* Licensed under the GNU GPL. See the file COPYING for details.
*
*/
#include <linux/fs.h>
+#include <linux/log2.h>
#include <asm/page.h> /* for PAGE_SIZE */
#include "befs.h"
#include "super.h"
/*
* befs_load_sb -- Read from disk and properly byteswap all the fields
* of the befs superblock
*/
int
@@ -58,61 +59,62 @@ int
befs_check_sb(struct super_block *sb)
{
struct befs_sb_info *befs_sb = BEFS_SB(sb);
/* Check magic headers of super block */
if ((befs_sb->magic1 != BEFS_SUPER_MAGIC1)
|| (befs_sb->magic2 != BEFS_SUPER_MAGIC2)
|| (befs_sb->magic3 != BEFS_SUPER_MAGIC3)) {
befs_error(sb, "invalid magic header");
return BEFS_ERR;
}
/*
* Check blocksize of BEFS.
*
* Blocksize of BEFS is 1024, 2048, 4096 or 8192.
*/
if ((befs_sb->block_size != 1024)
&& (befs_sb->block_size != 2048)
&& (befs_sb->block_size != 4096)
&& (befs_sb->block_size != 8192)) {
befs_error(sb, "invalid blocksize: %u", befs_sb->block_size);
return BEFS_ERR;
}
if (befs_sb->block_size > PAGE_SIZE) {
befs_error(sb, "blocksize(%u) cannot be larger "
"than system pagesize(%lu)", befs_sb->block_size,
PAGE_SIZE);
return BEFS_ERR;
}
/*
* block_shift and block_size encode the same information
* in different ways as a consistency check.
*/
- if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
+ if (befs_sb->block_shift != ilog2(befs_sb->block_size)) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
/* ag_shift also encodes the same information as blocks_per_ag in a
* different way, non-fatal consistency check
*/
- if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
+ if (!is_power_of_2(befs_sb->blocks_per_ag) ||
+ befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
if (befs_sb->log_start != befs_sb->log_end ||
befs_sb->flags == BEFS_DIRTY) {
befs_error(sb, "Filesystem not clean! There are blocks in the "
"journal. You must boot into BeOS and mount this "
"volume to make it clean.");
return BEFS_ERR;
}
return BEFS_OK;
}
]
|
| 53/4 |
2026/05/21 22:55 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 10837
output: 30
thoughts: 34
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Patch Verification and Broader Context**
Alright, that patch looks solid. It's spot-on, exactly addressing the issue described in the proposed fix. No complaints there. Before I sign off on this, though, I need to do a quick sweep. It's not enough to fix *this* specific instance; I want to ensure we're not seeing this pattern, or a variation of it, cropping up elsewhere. I'll need to dig into the `fs/befs/` directory first, given the fix is for this file system, but it's crucial to expand the scope beyond that. I'll need to think about other potentially vulnerable code paths, and other areas where this type of error could manifest. A few minutes invested now in looking for similar problems could save a huge headache down the road. Let's see if we can find any other lurking time-bombs.
|
| 54/4 |
2026/05/21 22:56 |
tool |
grepper |
0m
Args: map[Expression:1 << [a-zA-Z0-9_>.-]*shift]
Results: map[Output:
Full output is too long, showing 500 out of 2822 lines.
Use more precise expression if possible.
[arch/arm/mach-omap1/clock.c=63=static void omap1_clk_allow_idle(struct omap1_clk *clk)
--
arch/arm/mach-omap1/clock.c-70- if (iclk->no_idle_count > 0 && !(--iclk->no_idle_count))
arch/arm/mach-omap1/clock.c:71: arm_idlect1_mask |= 1 << iclk->idlect_shift;
arch/arm/mach-omap1/clock.c-72-}
--
arch/arm/mach-omap1/clock.c=74=static void omap1_clk_deny_idle(struct omap1_clk *clk)
--
arch/arm/mach-omap1/clock.c-81- if (iclk->no_idle_count++ == 0)
arch/arm/mach-omap1/clock.c:82: arm_idlect1_mask &= ~(1 << iclk->idlect_shift);
arch/arm/mach-omap1/clock.c-83-}
--
arch/arm/mach-omap2/cm2xxx.c=148=static int omap2xxx_cm_wait_module_ready(u8 part, s16 prcm_mod, u16 idlest_id,
--
arch/arm/mach-omap2/cm2xxx.c-159-
arch/arm/mach-omap2/cm2xxx.c:160: mask = 1 << idlest_shift;
arch/arm/mach-omap2/cm2xxx.c-161- ena = mask;
--
arch/arm/mach-omap2/cm3xxx.c=88=static int omap3xxx_cm_wait_module_ready(u8 part, s16 prcm_mod, u16 idlest_id,
--
arch/arm/mach-omap2/cm3xxx.c-99-
arch/arm/mach-omap2/cm3xxx.c:100: mask = 1 << idlest_shift;
arch/arm/mach-omap2/cm3xxx.c-101- ena = 0;
--
arch/arm/mach-omap2/omap_hwmod.c=431=static int _set_softreset(struct omap_hwmod *oh, u32 *v)
--
arch/arm/mach-omap2/omap_hwmod.c-443-
arch/arm/mach-omap2/omap_hwmod.c:444: softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift);
arch/arm/mach-omap2/omap_hwmod.c-445-
--
arch/arm/mach-omap2/omap_hwmod.c=459=static int _clear_softreset(struct omap_hwmod *oh, u32 *v)
--
arch/arm/mach-omap2/omap_hwmod.c-473-
arch/arm/mach-omap2/omap_hwmod.c:474: softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift);
arch/arm/mach-omap2/omap_hwmod.c-475-
--
arch/arm/mach-omap2/omap_hwmod.c=491=static int _wait_softreset_complete(struct omap_hwmod *oh)
--
arch/arm/mach-omap2/omap_hwmod.c-503- else if (sysc->sysc_flags & SYSC_HAS_RESET_STATUS) {
arch/arm/mach-omap2/omap_hwmod.c:504: softrst_mask = (0x1 << sysc->sysc_fields->srst_shift);
arch/arm/mach-omap2/omap_hwmod.c-505- omap_test_timeout(!(omap_hwmod_read(oh, sysc->sysc_offs)
--
arch/arm/mach-omap2/omap_hwmod.c=525=static int _set_dmadisable(struct omap_hwmod *oh)
--
arch/arm/mach-omap2/omap_hwmod.c-548- dmadisable_mask =
arch/arm/mach-omap2/omap_hwmod.c:549: (0x1 << oh->class->sysc->sysc_fields->dmadisable_shift);
arch/arm/mach-omap2/omap_hwmod.c-550- v |= dmadisable_mask;
--
arch/arm/mach-omap2/omap_hwmod.c=569=static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle,
--
arch/arm/mach-omap2/omap_hwmod.c-584- autoidle_shift = oh->class->sysc->sysc_fields->autoidle_shift;
arch/arm/mach-omap2/omap_hwmod.c:585: autoidle_mask = (0x1 << autoidle_shift);
arch/arm/mach-omap2/omap_hwmod.c-586-
--
arch/arm/mach-omap2/omap_hwmod.c=600=static int _enable_wakeup(struct omap_hwmod *oh, u32 *v)
--
arch/arm/mach-omap2/omap_hwmod.c-613- if (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)
arch/arm/mach-omap2/omap_hwmod.c:614: *v |= 0x1 << oh->class->sysc->sysc_fields->enwkup_shift;
arch/arm/mach-omap2/omap_hwmod.c-615-
--
arch/arm/mach-omap2/prm2xxx.c=54=static u32 omap2xxx_prm_read_reset_sources(void)
--
arch/arm/mach-omap2/prm2xxx.c-63- while (p->reg_shift >= 0 && p->std_shift >= 0) {
arch/arm/mach-omap2/prm2xxx.c:64: if (v & (1 << p->reg_shift))
arch/arm/mach-omap2/prm2xxx.c:65: r |= 1 << p->std_shift;
arch/arm/mach-omap2/prm2xxx.c-66- p++;
--
arch/arm/mach-omap2/prm2xxx_3xxx.c=33=int omap2_prm_is_hardreset_asserted(u8 shift, u8 part, s16 prm_mod, u16 offset)
--
arch/arm/mach-omap2/prm2xxx_3xxx.c-35- return omap2_prm_read_mod_bits_shift(prm_mod, OMAP2_RM_RSTCTRL,
arch/arm/mach-omap2/prm2xxx_3xxx.c:36: (1 << shift));
arch/arm/mach-omap2/prm2xxx_3xxx.c-37-}
--
arch/arm/mach-omap2/prm2xxx_3xxx.c=53=int omap2_prm_assert_hardreset(u8 shift, u8 part, s16 prm_mod, u16 offset)
--
arch/arm/mach-omap2/prm2xxx_3xxx.c-56-
arch/arm/mach-omap2/prm2xxx_3xxx.c:57: mask = 1 << shift;
arch/arm/mach-omap2/prm2xxx_3xxx.c-58- omap2_prm_rmw_mod_reg_bits(mask, mask, prm_mod, OMAP2_RM_RSTCTRL);
--
arch/arm/mach-omap2/prm2xxx_3xxx.c=82=int omap2_prm_deassert_hardreset(u8 rst_shift, u8 st_shift, u8 part,
--
arch/arm/mach-omap2/prm2xxx_3xxx.c-87-
arch/arm/mach-omap2/prm2xxx_3xxx.c:88: rst = 1 << rst_shift;
arch/arm/mach-omap2/prm2xxx_3xxx.c:89: st = 1 << st_shift;
arch/arm/mach-omap2/prm2xxx_3xxx.c-90-
--
arch/arm/mach-omap2/prm33xx.c=56=static int am33xx_prm_is_hardreset_asserted(u8 shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prm33xx.c-61- v = am33xx_prm_read_reg(inst, rstctrl_offs);
arch/arm/mach-omap2/prm33xx.c:62: v &= 1 << shift;
arch/arm/mach-omap2/prm33xx.c-63- v >>= shift;
--
arch/arm/mach-omap2/prm33xx.c=82=static int am33xx_prm_assert_hardreset(u8 shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prm33xx.c-84-{
arch/arm/mach-omap2/prm33xx.c:85: u32 mask = 1 << shift;
arch/arm/mach-omap2/prm33xx.c-86-
--
arch/arm/mach-omap2/prm33xx.c=111=static int am33xx_prm_deassert_hardreset(u8 shift, u8 st_shift, u8 part,
--
arch/arm/mach-omap2/prm33xx.c-115- int c;
arch/arm/mach-omap2/prm33xx.c:116: u32 mask = 1 << st_shift;
arch/arm/mach-omap2/prm33xx.c-117-
--
arch/arm/mach-omap2/prm33xx.c-125- /* de-assert the reset control line */
arch/arm/mach-omap2/prm33xx.c:126: mask = 1 << shift;
arch/arm/mach-omap2/prm33xx.c-127-
--
arch/arm/mach-omap2/prm3xxx.c=447=static u32 omap3xxx_prm_read_reset_sources(void)
--
arch/arm/mach-omap2/prm3xxx.c-456- while (p->reg_shift >= 0 && p->std_shift >= 0) {
arch/arm/mach-omap2/prm3xxx.c:457: if (v & (1 << p->reg_shift))
arch/arm/mach-omap2/prm3xxx.c:458: r |= 1 << p->std_shift;
arch/arm/mach-omap2/prm3xxx.c-459- p++;
--
arch/arm/mach-omap2/prm44xx.c=370=static u32 omap44xx_prm_read_reset_sources(void)
--
arch/arm/mach-omap2/prm44xx.c-385- while (p->reg_shift >= 0 && p->std_shift >= 0) {
arch/arm/mach-omap2/prm44xx.c:386: if (v & (1 << p->reg_shift))
arch/arm/mach-omap2/prm44xx.c:387: r |= 1 << p->std_shift;
arch/arm/mach-omap2/prm44xx.c-388- p++;
--
arch/arm/mach-omap2/prminst44xx.c=99=int omap4_prminst_is_hardreset_asserted(u8 shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prminst44xx.c-104- v = omap4_prminst_read_inst_reg(part, inst, rstctrl_offs);
arch/arm/mach-omap2/prminst44xx.c:105: v &= 1 << shift;
arch/arm/mach-omap2/prminst44xx.c-106- v >>= shift;
--
arch/arm/mach-omap2/prminst44xx.c=123=int omap4_prminst_assert_hardreset(u8 shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prminst44xx.c-125-{
arch/arm/mach-omap2/prminst44xx.c:126: u32 mask = 1 << shift;
arch/arm/mach-omap2/prminst44xx.c-127-
--
arch/arm/mach-omap2/prminst44xx.c=152=int omap4_prminst_deassert_hardreset(u8 shift, u8 st_shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prminst44xx.c-155- int c;
arch/arm/mach-omap2/prminst44xx.c:156: u32 mask = 1 << shift;
arch/arm/mach-omap2/prminst44xx.c:157: u32 st_mask = 1 << st_shift;
arch/arm/mach-omap2/prminst44xx.c-158-
--
arch/arm/mach-s3c/gpio-samsung.c=326=static int samsung_gpiolib_4bit_output(struct gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-335- con &= ~(0xf << con_4bit_shift(offset));
arch/arm/mach-s3c/gpio-samsung.c:336: con |= 0x1 << con_4bit_shift(offset);
arch/arm/mach-s3c/gpio-samsung.c-337-
--
arch/arm/mach-s3c/gpio-samsung.c=398=static int samsung_gpiolib_4bit2_output(struct gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-414- con &= ~(0xf << con_4bit_shift(con_offset));
arch/arm/mach-s3c/gpio-samsung.c:415: con |= 0x1 << con_4bit_shift(con_offset);
arch/arm/mach-s3c/gpio-samsung.c-416-
--
arch/arm64/kvm/pauth.c=125=static u64 corrupt_addr(struct kvm_vcpu *vcpu, u64 ptr)
--
arch/arm64/kvm/pauth.c-141- else
arch/arm64/kvm/pauth.c:142: error_code = 1 << shift;
arch/arm64/kvm/pauth.c-143-
--
arch/loongarch/pci/acpi.c=99=static struct pci_config_window *arch_pci_ecam_create(struct device *dev,
--
arch/loongarch/pci/acpi.c-119-
arch/loongarch/pci/acpi.c:120: bsz = 1 << ops->bus_shift;
arch/loongarch/pci/acpi.c-121-
--
arch/mips/alchemy/common/clock.c=529=static int alchemy_clk_fgv1_setp(struct clk_hw *hw, u8 index)
--
arch/mips/alchemy/common/clock.c-536- if (index)
arch/mips/alchemy/common/clock.c:537: v |= (1 << c->shift);
arch/mips/alchemy/common/clock.c-538- else
arch/mips/alchemy/common/clock.c:539: v &= ~(1 << c->shift);
arch/mips/alchemy/common/clock.c-540- alchemy_wrsys(v, c->reg);
--
arch/mips/cavium-octeon/executive/cvmx-l2c.c=314=int cvmx_l2c_lock_line(uint64_t addr)
--
arch/mips/cavium-octeon/executive/cvmx-l2c.c-380- int alias_shift = CVMX_L2C_IDX_ADDR_SHIFT + 2 * CVMX_L2_SET_BITS - 1;
arch/mips/cavium-octeon/executive/cvmx-l2c.c:381: uint64_t addr_tmp = addr ^ (addr & ((1 << alias_shift) - 1)) >> CVMX_L2_SET_BITS;
arch/mips/cavium-octeon/executive/cvmx-l2c.c-382-
--
arch/powerpc/kernel/iommu.c=912=void *iommu_alloc_coherent(struct device *dev, struct iommu_table *tbl,
--
arch/powerpc/kernel/iommu.c-920- struct page *page;
arch/powerpc/kernel/iommu.c:921: int tcesize = (1 << tbl->it_page_shift);
arch/powerpc/kernel/iommu.c-922-
--
arch/powerpc/kernel/legacy_serial.c=326=static void __init setup_legacy_serial_console(int console)
--
arch/powerpc/kernel/legacy_serial.c-331-
arch/powerpc/kernel/legacy_serial.c:332: stride = 1 << port->regshift;
arch/powerpc/kernel/legacy_serial.c-333-
--
arch/powerpc/kernel/legacy_serial.c=357=static int __init ioremap_legacy_serial_console(void)
--
arch/powerpc/kernel/legacy_serial.c-375-
arch/powerpc/kernel/legacy_serial.c:376: udbg_uart_init_mmio(vaddr, 1 << port->regshift);
arch/powerpc/kernel/legacy_serial.c-377- early_iounmap(info->early_addr, 0x1000);
--
arch/powerpc/kernel/setup-common.c=391=static void __init cpu_init_thread_core_maps(int tpc)
--
arch/powerpc/kernel/setup-common.c-402- threads_shift = ilog2(tpc);
arch/powerpc/kernel/setup-common.c:403: BUG_ON(tpc != (1 << threads_shift));
arch/powerpc/kernel/setup-common.c-404-
--
arch/powerpc/kernel/syscalls.c=39=static long do_mmap2(unsigned long addr, size_t len,
--
arch/powerpc/kernel/syscalls.c-45-
arch/powerpc/kernel/syscalls.c:46: if (!IS_ALIGNED(off, 1 << shift))
arch/powerpc/kernel/syscalls.c-47- return -EINVAL;
--
arch/powerpc/mm/book3s64/hash_pgtable.c=524=static bool hash__change_memory_range(unsigned long start, unsigned long end,
--
arch/powerpc/mm/book3s64/hash_pgtable.c-529- shift = mmu_psize_defs[mmu_linear_psize].shift;
arch/powerpc/mm/book3s64/hash_pgtable.c:530: step = 1 << shift;
arch/powerpc/mm/book3s64/hash_pgtable.c-531-
--
arch/powerpc/mm/book3s64/hash_utils.c=621=int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
--
arch/powerpc/mm/book3s64/hash_utils.c-629- shift = mmu_psize_defs[psize].shift;
arch/powerpc/mm/book3s64/hash_utils.c:630: step = 1 << shift;
arch/powerpc/mm/book3s64/hash_utils.c-631-
--
arch/powerpc/mm/book3s64/hash_utils.c=707=int htab_remove_mapping(unsigned long vstart, unsigned long vend,
--
arch/powerpc/mm/book3s64/hash_utils.c-715- shift = mmu_psize_defs[psize].shift;
arch/powerpc/mm/book3s64/hash_utils.c:716: step = 1 << shift;
arch/powerpc/mm/book3s64/hash_utils.c-717-
--
arch/powerpc/mm/book3s64/hash_utils.c=1050=static void __init init_hpte_page_sizes(void)
--
arch/powerpc/mm/book3s64/hash_utils.c-1071- hpte_page_sizes[penc] = (ap << 4) | bp;
arch/powerpc/mm/book3s64/hash_utils.c:1072: penc += 1 << shift;
arch/powerpc/mm/book3s64/hash_utils.c-1073- }
--
arch/powerpc/platforms/pseries/lpar.c=1481=void __init pseries_lpar_read_hblkrm_characteristics(void)
--
arch/powerpc/platforms/pseries/lpar.c-1506-
arch/powerpc/platforms/pseries/lpar.c:1507: block_size = 1 << block_shift;
arch/powerpc/platforms/pseries/lpar.c-1508-
--
arch/powerpc/sysdev/mpic.c=1216=struct mpic * __init mpic_alloc(struct device_node *node,
--
arch/powerpc/sysdev/mpic.c-1484- mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1);
arch/powerpc/sysdev/mpic.c:1485: mpic->isu_mask = (1 << mpic->isu_shift) - 1;
arch/powerpc/sysdev/mpic.c-1486-
--
arch/powerpc/sysdev/xive/common.c=1679=__be32 *xive_queue_page_alloc(unsigned int cpu, u32 queue_shift)
--
arch/powerpc/sysdev/xive/common.c-1689- qpage = (__be32 *)page_address(pages);
arch/powerpc/sysdev/xive/common.c:1690: memset(qpage, 0, 1 << queue_shift);
arch/powerpc/sysdev/xive/common.c-1691-
--
arch/riscv/mm/hugetlbpage.c=218=static int num_contig_ptes_from_size(unsigned long sz, size_t *pgsize)
--
arch/riscv/mm/hugetlbpage.c-232-
arch/riscv/mm/hugetlbpage.c:233: *pgsize = 1 << hugepage_shift;
arch/riscv/mm/hugetlbpage.c-234-
--
arch/sh/kernel/dwarf.c=180=static inline unsigned long dwarf_read_leb128(char *addr, int *ret)
--
arch/sh/kernel/dwarf.c-205- if ((shift < num_bits) && (byte & 0x40))
arch/sh/kernel/dwarf.c:206: result |= (-1 << shift);
arch/sh/kernel/dwarf.c-207-
--
arch/sh/mm/cache-sh4.c=159=static void flush_dcache_all(void)
--
arch/sh/mm/cache-sh4.c-167-
arch/sh/mm/cache-sh4.c:168: entry_offset = 1 << current_cpu_data.dcache.entry_shift;
arch/sh/mm/cache-sh4.c-169-
--
arch/x86/kernel/apic/x2apic_uv_x.c=244=static void __init early_get_apic_socketid_shift(void)
--
arch/x86/kernel/apic/x2apic_uv_x.c-252- uv_cpuid.apicid_shift = 0;
arch/x86/kernel/apic/x2apic_uv_x.c:253: uv_cpuid.apicid_mask = (~(-1 << sid_shift));
arch/x86/kernel/apic/x2apic_uv_x.c-254- uv_cpuid.socketid_shift = sid_shift;
--
arch/x86/kernel/apic/x2apic_uv_x.c=1188=static void __init uv_init_hub_info(struct uv_hub_info_s *hi)
--
arch/x86/kernel/apic/x2apic_uv_x.c-1214- uv_cpuid.gnode_shift = max_t(unsigned int, uv_cpuid.gnode_shift, mn.n_val);
arch/x86/kernel/apic/x2apic_uv_x.c:1215: hi->gnode_extra = (uv_node_id & ~((1 << uv_cpuid.gnode_shift) - 1)) >> 1;
arch/x86/kernel/apic/x2apic_uv_x.c-1216- if (mn.m_val)
--
arch/x86/kernel/vsmp_64.c=95=static void __init vsmp_cap_cpus(void)
--
arch/x86/kernel/vsmp_64.c-119- node_shift = 8;
arch/x86/kernel/vsmp_64.c:120: maxcpus = (topology & ((1 << node_shift) - 1)) + 1;
arch/x86/kernel/vsmp_64.c-121-
--
arch/x86/platform/efi/efi.c=784=static void __init __efi_enter_virtual_mode(void)
--
arch/x86/platform/efi/efi.c-821-
arch/x86/platform/efi/efi.c:822: if (efi_setup_page_tables(pa, 1 << pg_shift))
arch/x86/platform/efi/efi.c-823- goto err;
--
block/badblocks.c=839=static bool _badblocks_set(struct badblocks *bb, sector_t s, sector_t sectors,
--
block/badblocks.c-859-
block/badblocks.c:860: rounddown(s, 1 << bb->shift);
block/badblocks.c:861: roundup(next, 1 << bb->shift);
block/badblocks.c-862- sectors = next - s;
--
block/badblocks.c=1049=static bool _badblocks_clear(struct badblocks *bb, sector_t s, sector_t sectors)
--
block/badblocks.c-1073- target = s + sectors;
block/badblocks.c:1074: roundup(s, 1 << bb->shift);
block/badblocks.c:1075: rounddown(target, 1 << bb->shift);
block/badblocks.c-1076- sectors = target - s;
--
block/badblocks.c=1298=int badblocks_check(struct badblocks *bb, sector_t s, sector_t sectors,
--
block/badblocks.c-1309-
block/badblocks.c:1310: rounddown(s, 1 << bb->shift);
block/badblocks.c:1311: roundup(target, 1 << bb->shift);
block/badblocks.c-1312- sectors = target - s;
--
drivers/accel/habanalabs/common/mmu/mmu_v2_hr.c=190=static int hl_mmu_v2_get_last_hop(struct hl_mmu_properties *mmu_prop, u32 page_size)
--
drivers/accel/habanalabs/common/mmu/mmu_v2_hr.c-197-
drivers/accel/habanalabs/common/mmu/mmu_v2_hr.c:198: if (page_size <= (1 << mmu_prop->hop_shifts[hop]))
drivers/accel/habanalabs/common/mmu/mmu_v2_hr.c-199- break;
--
drivers/ata/libata-core.c=950=unsigned int ata_xfer_mode2mask(u8 xfer_mode)
--
drivers/ata/libata-core.c-956- return ((2 << (ent->shift + xfer_mode - ent->base)) - 1)
drivers/ata/libata-core.c:957: & ~((1 << ent->shift) - 1);
drivers/ata/libata-core.c-958- return 0;
--
drivers/ata/pata_falcon.c=124=static int pata_falcon_init_one(struct platform_device *pdev)
--
drivers/ata/pata_falcon.c-185-
drivers/ata/pata_falcon.c:186: ap->ioaddr.error_addr = base + io_offset + (1 << reg_shift);
drivers/ata/pata_falcon.c:187: ap->ioaddr.feature_addr = base + io_offset + (1 << reg_shift);
drivers/ata/pata_falcon.c-188- ap->ioaddr.nsect_addr = base + io_offset + (2 << reg_shift);
--
drivers/ata/pata_sil680.c=103=static void sil680_set_piomode(struct ata_port *ap, struct ata_device *adev)
--
drivers/ata/pata_sil680.c-137- reg |= 0x0200; /* Enable IORDY */
drivers/ata/pata_sil680.c:138: mode |= 1 << port_shift;
drivers/ata/pata_sil680.c-139- }
--
drivers/block/loop.c=1999=static int loop_add(int i)
--
drivers/block/loop.c-2083- disk->first_minor = i << part_shift;
drivers/block/loop.c:2084: disk->minors = 1 << part_shift;
drivers/block/loop.c-2085- disk->fops = &lo_fops;
--
drivers/block/nbd.c=1907=static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
--
drivers/block/nbd.c-1979- disk->first_minor = index << part_shift;
drivers/block/nbd.c:1980: disk->minors = 1 << part_shift;
drivers/block/nbd.c-1981- disk->fops = &nbd_fops;
--
drivers/block/ublk_drv.c=4413=static int ublk_ctrl_start_dev(struct ublk_device *ub,
--
drivers/block/ublk_drv.c-4418- struct queue_limits lim = {
drivers/block/ublk_drv.c:4419: .logical_block_size = 1 << p->logical_bs_shift,
drivers/block/ublk_drv.c:4420: .physical_block_size = 1 << p->physical_bs_shift,
drivers/block/ublk_drv.c:4421: .io_min = 1 << p->io_min_shift,
drivers/block/ublk_drv.c:4422: .io_opt = 1 << p->io_opt_shift,
drivers/block/ublk_drv.c-4423- .max_hw_sectors = p->max_sectors,
--
drivers/bus/ti-sysc.c=1001=static int sysc_enable_module(struct device *dev)
--
drivers/bus/ti-sysc.c-1108- ddata->cfg.sysc_val & BIT(regbits->autoidle_shift)) {
drivers/bus/ti-sysc.c:1109: reg |= 1 << regbits->autoidle_shift;
drivers/bus/ti-sysc.c-1110- sysc_write_sysconfig(ddata, reg);
--
drivers/bus/ti-sysc.c=1140=static int sysc_disable_module(struct device *dev)
--
drivers/bus/ti-sysc.c-1205- ddata->cfg.sysc_val & BIT(regbits->autoidle_shift))
drivers/bus/ti-sysc.c:1206: reg |= 1 << regbits->autoidle_shift;
drivers/bus/ti-sysc.c-1207- sysc_write_sysconfig(ddata, reg);
--
drivers/char/agp/parisc-agp.c=252=agp_ioc_init(void __iomem *ioc_regs)
--
drivers/char/agp/parisc-agp.c-275- }
drivers/char/agp/parisc-agp.c:276: info->io_page_size = 1 << io_tlb_shift;
drivers/char/agp/parisc-agp.c-277- info->io_pages_per_kpage = PAGE_SIZE / info->io_page_size;
--
drivers/clk/at91/clk-programmable.c=148=static int clk_programmable_set_rate(struct clk_hw *hw, unsigned long rate,
--
drivers/clk/at91/clk-programmable.c-166-
drivers/clk/at91/clk-programmable.c:167: if (div != (1 << shift))
drivers/clk/at91/clk-programmable.c-168- return -EINVAL;
--
drivers/clk/at91/clk-sam9x60-pll.c=346=static void sam9x60_div_pll_set_div(struct sam9x60_pll_core *core, u32 div,
--
drivers/clk/at91/clk-sam9x60-pll.c-350- u32 ena_msk = enable ? core->layout->endiv_mask : 0;
drivers/clk/at91/clk-sam9x60-pll.c:351: u32 ena_val = enable ? (1 << core->layout->endiv_shift) : 0;
drivers/clk/at91/clk-sam9x60-pll.c-352-
--
drivers/clk/bcm/clk-iproc-asiu.c=36=static int iproc_asiu_clk_enable(struct clk_hw *hw)
--
drivers/clk/bcm/clk-iproc-asiu.c-46- val = readl(asiu->gate_base + clk->gate.offset);
drivers/clk/bcm/clk-iproc-asiu.c:47: val |= (1 << clk->gate.en_shift);
drivers/clk/bcm/clk-iproc-asiu.c-48- writel(val, asiu->gate_base + clk->gate.offset);
--
drivers/clk/bcm/clk-iproc-asiu.c=53=static void iproc_asiu_clk_disable(struct clk_hw *hw)
--
drivers/clk/bcm/clk-iproc-asiu.c-63- val = readl(asiu->gate_base + clk->gate.offset);
drivers/clk/bcm/clk-iproc-asiu.c:64: val &= ~(1 << clk->gate.en_shift);
drivers/clk/bcm/clk-iproc-asiu.c-65- writel(val, asiu->gate_base + clk->gate.offset);
--
drivers/clk/bcm/clk-iproc-asiu.c=68=static unsigned long iproc_asiu_clk_recalc_rate(struct clk_hw *hw,
--
drivers/clk/bcm/clk-iproc-asiu.c-82- val = readl(asiu->div_base + clk->div.offset);
drivers/clk/bcm/clk-iproc-asiu.c:83: if ((val & (1 << clk->div.en_shift)) == 0) {
drivers/clk/bcm/clk-iproc-asiu.c-84- clk->rate = parent_rate;
--
drivers/clk/bcm/clk-iproc-asiu.c=124=static int iproc_asiu_clk_set_rate(struct clk_hw *hw, unsigned long rate,
--
drivers/clk/bcm/clk-iproc-asiu.c-137- val = readl(asiu->div_base + clk->div.offset);
drivers/clk/bcm/clk-iproc-asiu.c:138: val &= ~(1 << clk->div.en_shift);
drivers/clk/bcm/clk-iproc-asiu.c-139- writel(val, asiu->div_base + clk->div.offset);
--
drivers/clk/bcm/clk-iproc-asiu.c-151- val = readl(asiu->div_base + clk->div.offset);
drivers/clk/bcm/clk-iproc-asiu.c:152: val |= 1 << clk->div.en_shift;
drivers/clk/bcm/clk-iproc-asiu.c-153- if (div_h) {
--
drivers/clk/bcm/clk-iproc-pll.c=147=static int pll_wait_for_lock(struct iproc_pll *pll)
--
drivers/clk/bcm/clk-iproc-pll.c-154-
drivers/clk/bcm/clk-iproc-pll.c:155: if (val & (1 << ctrl->status.shift))
drivers/clk/bcm/clk-iproc-pll.c-156- return 0;
--
drivers/clk/bcm/clk-iproc-pll.c=175=static void __pll_disable(struct iproc_pll *pll)
--
drivers/clk/bcm/clk-iproc-pll.c-181- val = readl(pll->asiu_base + ctrl->asiu.offset);
drivers/clk/bcm/clk-iproc-pll.c:182: val &= ~(1 << ctrl->asiu.en_shift);
drivers/clk/bcm/clk-iproc-pll.c-183- iproc_pll_write(pll, pll->asiu_base, ctrl->asiu.offset, val);
--
drivers/clk/bcm/clk-iproc-pll.c-194- val = readl(pll->pwr_base + ctrl->aon.offset);
drivers/clk/bcm/clk-iproc-pll.c:195: val |= 1 << ctrl->aon.iso_shift;
drivers/clk/bcm/clk-iproc-pll.c-196- iproc_pll_write(pll, pll->pwr_base, ctrl->aon.offset, val);
--
drivers/clk/bcm/clk-iproc-pll.c=204=static int __pll_enable(struct iproc_pll *pll)
--
drivers/clk/bcm/clk-iproc-pll.c-218- val |= bit_mask(ctrl->aon.pwr_width) << ctrl->aon.pwr_shift;
drivers/clk/bcm/clk-iproc-pll.c:219: val &= ~(1 << ctrl->aon.iso_shift);
drivers/clk/bcm/clk-iproc-pll.c-220- iproc_pll_write(pll, pll->pwr_base, ctrl->aon.offset, val);
--
drivers/clk/bcm/clk-iproc-pll.c-225- val = readl(pll->asiu_base + ctrl->asiu.offset);
drivers/clk/bcm/clk-iproc-pll.c:226: val |= (1 << ctrl->asiu.en_shift);
drivers/clk/bcm/clk-iproc-pll.c-227- iproc_pll_write(pll, pll->asiu_base, ctrl->asiu.offset, val);
--
drivers/clk/bcm/clk-iproc-pll.c=276=static bool pll_fractional_change_only(struct iproc_pll *pll,
--
drivers/clk/bcm/clk-iproc-pll.c-285- val = readl(pll->status_base + ctrl->status.offset);
drivers/clk/bcm/clk-iproc-pll.c:286: if ((val & (1 << ctrl->status.shift)) == 0)
drivers/clk/bcm/clk-iproc-pll.c-287- return false;
--
drivers/clk/bcm/clk-iproc-pll.c=447=static unsigned long iproc_pll_recalc_rate(struct clk_hw *hw,
--
drivers/clk/bcm/clk-iproc-pll.c-462- val = readl(pll->status_base + ctrl->status.offset);
drivers/clk/bcm/clk-iproc-pll.c:463: if ((val & (1 << ctrl->status.shift)) == 0)
drivers/clk/bcm/clk-iproc-pll.c-464- return 0;
--
drivers/clk/bcm/clk-iproc-pll.c=575=static int iproc_clk_enable(struct clk_hw *hw)
--
drivers/clk/bcm/clk-iproc-pll.c-583- val = readl(pll->control_base + ctrl->enable.offset);
drivers/clk/bcm/clk-iproc-pll.c:584: val &= ~(1 << ctrl->enable.enable_shift);
drivers/clk/bcm/clk-iproc-pll.c-585- iproc_pll_write(pll, pll->control_base, ctrl->enable.offset, val);
--
drivers/clk/bcm/clk-iproc-pll.c-588- val = readl(pll->control_base + ctrl->enable.offset);
drivers/clk/bcm/clk-iproc-pll.c:589: val &= ~(1 << ctrl->enable.hold_shift);
drivers/clk/bcm/clk-iproc-pll.c-590- iproc_pll_write(pll, pll->control_base, ctrl->enable.offset, val);
--
drivers/clk/bcm/clk-iproc-pll.c=595=static void iproc_clk_disable(struct clk_hw *hw)
--
drivers/clk/bcm/clk-iproc-pll.c-605- val = readl(pll->control_base + ctrl->enable.offset);
drivers/clk/bcm/clk-iproc-pll.c:606: val |= 1 << ctrl->enable.enable_shift;
drivers/clk/bcm/clk-iproc-pll.c-607- iproc_pll_write(pll, pll->control_base, ctrl->enable.offset, val);
--
drivers/clk/berlin/berlin2-div.c=176=static unsigned long berlin2_div_recalc_rate(struct clk_hw *hw,
--
drivers/clk/berlin/berlin2-div.c-186- divsw = readl_relaxed(div->base + map->div_switch_offs) &
drivers/clk/berlin/berlin2-div.c:187: (1 << map->div_switch_shift);
drivers/clk/berlin/berlin2-div.c-188- div3sw = readl_relaxed(div->base + map->div3_switch_offs) &
drivers/clk/berlin/berlin2-div.c:189: (1 << map->div3_switch_shift);
drivers/clk/berlin/berlin2-div.c-190-
--
drivers/clk/imx/clk-busy.c=16=static int clk_busy_wait(void __iomem *reg, u8 shift)
--
drivers/clk/imx/clk-busy.c-19-
drivers/clk/imx/clk-busy.c:20: while (readl_relaxed(reg) & (1 << shift))
drivers/clk/imx/clk-busy.c-21- if (time_after(jiffies, timeout))
--
drivers/clk/mxs/clk.c=14=int mxs_clk_wait(void __iomem *reg, u8 shift)
--
drivers/clk/mxs/clk.c-17-
drivers/clk/mxs/clk.c:18: while (readl_relaxed(reg) & (1 << shift))
drivers/clk/mxs/clk.c-19- if (time_after(jiffies, timeout))
--
drivers/clk/socfpga/clk-gate-s10.c=51=static u8 socfpga_gate_get_parent(struct clk_hw *hwclk)
--
drivers/clk/socfpga/clk-gate-s10.c-58- if (socfpgaclk->bypass_reg) {
drivers/clk/socfpga/clk-gate-s10.c:59: mask = (0x1 << socfpgaclk->bypass_shift);
drivers/clk/socfpga/clk-gate-s10.c-60- parent = ((readl(socfpgaclk->bypass_reg) & mask) >>
--
drivers/clk/socfpga/clk-gate-s10.c=81=static u8 socfpga_agilex_gate_get_parent(struct clk_hw *hwclk)
--
]
]
|
| 55/4 |
2026/05/21 22:56 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 23448
output: 17
thoughts: 115
Thoughts: **Analyzing Potential Vulnerabilities in BEFS Filesystem Code**
Okay, so I've been looking over some `grep` output and it's pointing me towards some interesting areas. It seems like the expression `1 << shift` is used fairly frequently, but usually, `shift` is either a constant hardcoded into a driver or comes from a hardware definition, which means it's generally safe. However, I've got my eye on `fs/befs/super.c`, specifically. I see that `block_shift` and `ag_shift` are read directly from the disk image. That's a red flag! Values from disk are essentially user-supplied, and that makes them untrusted and potentially massive. I need to dig deeper. My immediate thought is to check the rest of the `fs/befs/` directory for any other occurrences of `1 << shift` or similar expressions, just to be thorough and see if there are other places these values are used. I need to understand the full context of these shift operations to determine the real impact here.
|
| 56/4 |
2026/05/21 22:56 |
tool |
grepper |
0m
Args: map[Expression:<<.*shift]
Results: map[Output:
Full output is too long, showing 500 out of 34283 lines.
Use more precise expression if possible.
[Documentation/admin-guide/kdump/gdbmacros.txt=289=define dmesg
--
Documentation/admin-guide/kdump/gdbmacros.txt-294- set var $desc_flags_shift = $desc_sv_bits - 2
Documentation/admin-guide/kdump/gdbmacros.txt:295: set var $desc_flags_mask = 3 << $desc_flags_shift
Documentation/admin-guide/kdump/gdbmacros.txt-296- set var $id_mask = ~$desc_flags_mask
--
Documentation/mm/physical_memory.rst=545=Compaction control
--
Documentation/mm/physical_memory.rst-577- The number of compactions skipped before trying again is
Documentation/mm/physical_memory.rst:578: ``1<<compact_defer_shift``. It is increased by 1 in ``defer_compaction()``.
Documentation/mm/physical_memory.rst-579- It is reset in ``compaction_defer_reset()`` when a direct compaction results
--
Documentation/virt/kvm/x86/msr.rst=62=data:
--
Documentation/virt/kvm/x86/msr.rst-118- if (tsc_shift >= 0)
Documentation/virt/kvm/x86/msr.rst:119: time <<= tsc_shift;
Documentation/virt/kvm/x86/msr.rst-120- else
--
arch/alpha/kernel/perf_event.c=233=static inline void alpha_write_pmc(int idx, unsigned long val)
--
arch/alpha/kernel/perf_event.c-235- val &= alpha_pmu->pmc_count_mask[idx];
arch/alpha/kernel/perf_event.c:236: val <<= alpha_pmu->pmc_count_shift[idx];
arch/alpha/kernel/perf_event.c-237- val |= (1<<idx);
--
arch/arc/kernel/unwind.c=449=static uleb128_t get_uleb128(const u8 **pcur, const u8 *end)
--
arch/arc/kernel/unwind.c-456- if (shift + 7 > 8 * sizeof(value)
arch/arc/kernel/unwind.c:457: && (*cur & 0x7fU) >= (1U << (8 * sizeof(value) - shift))) {
arch/arc/kernel/unwind.c-458- cur = end + 1;
--
arch/arc/kernel/unwind.c-460- }
arch/arc/kernel/unwind.c:461: value |= (uleb128_t) (*cur & 0x7f) << shift;
arch/arc/kernel/unwind.c-462- if (!(*cur++ & 0x80))
--
arch/arc/kernel/unwind.c=470=static sleb128_t get_sleb128(const u8 **pcur, const u8 *end)
--
arch/arc/kernel/unwind.c-477- if (shift + 7 > 8 * sizeof(value)
arch/arc/kernel/unwind.c:478: && (*cur & 0x7fU) >= (1U << (8 * sizeof(value) - shift))) {
arch/arc/kernel/unwind.c-479- cur = end + 1;
--
arch/arc/kernel/unwind.c-481- }
arch/arc/kernel/unwind.c:482: value |= (sleb128_t) (*cur & 0x7f) << shift;
arch/arc/kernel/unwind.c-483- if (!(*cur & 0x80)) {
arch/arc/kernel/unwind.c:484: value |= -(*cur++ & 0x40) << shift;
arch/arc/kernel/unwind.c-485- break;
--
arch/arm/mach-omap1/clock.c=63=static void omap1_clk_allow_idle(struct omap1_clk *clk)
--
arch/arm/mach-omap1/clock.c-70- if (iclk->no_idle_count > 0 && !(--iclk->no_idle_count))
arch/arm/mach-omap1/clock.c:71: arm_idlect1_mask |= 1 << iclk->idlect_shift;
arch/arm/mach-omap1/clock.c-72-}
--
arch/arm/mach-omap1/clock.c=74=static void omap1_clk_deny_idle(struct omap1_clk *clk)
--
arch/arm/mach-omap1/clock.c-81- if (iclk->no_idle_count++ == 0)
arch/arm/mach-omap1/clock.c:82: arm_idlect1_mask &= ~(1 << iclk->idlect_shift);
arch/arm/mach-omap1/clock.c-83-}
--
arch/arm/mach-omap1/omap-dma.c=77=static inline void set_gdma_dev(int req, int dev)
--
arch/arm/mach-omap1/omap-dma.c-83- l = omap_readl(reg);
arch/arm/mach-omap1/omap-dma.c:84: l &= ~(0x3f << shift);
arch/arm/mach-omap1/omap-dma.c:85: l |= (dev - 1) << shift;
arch/arm/mach-omap1/omap-dma.c-86- omap_writel(l, reg);
--
arch/arm/mach-omap1/serial.c=33=static inline unsigned int omap_serial_in(struct plat_serial8250_port *up,
--
arch/arm/mach-omap1/serial.c-35-{
arch/arm/mach-omap1/serial.c:36: offset <<= up->regshift;
arch/arm/mach-omap1/serial.c-37- return (unsigned int)__raw_readb(up->membase + offset);
--
arch/arm/mach-omap1/serial.c=40=static inline void omap_serial_outp(struct plat_serial8250_port *p, int offset,
--
arch/arm/mach-omap1/serial.c-42-{
arch/arm/mach-omap1/serial.c:43: offset <<= p->regshift;
arch/arm/mach-omap1/serial.c-44- __raw_writeb(value, p->membase + offset);
--
arch/arm/mach-omap2/cm2xxx.c=148=static int omap2xxx_cm_wait_module_ready(u8 part, s16 prcm_mod, u16 idlest_id,
--
arch/arm/mach-omap2/cm2xxx.c-159-
arch/arm/mach-omap2/cm2xxx.c:160: mask = 1 << idlest_shift;
arch/arm/mach-omap2/cm2xxx.c-161- ena = mask;
--
arch/arm/mach-omap2/cm3xxx.c=88=static int omap3xxx_cm_wait_module_ready(u8 part, s16 prcm_mod, u16 idlest_id,
--
arch/arm/mach-omap2/cm3xxx.c-99-
arch/arm/mach-omap2/cm3xxx.c:100: mask = 1 << idlest_shift;
arch/arm/mach-omap2/cm3xxx.c-101- ena = 0;
--
arch/arm/mach-omap2/display.c=73=static int omap4_dsi_mux_pads(int dsi_id, unsigned lanes)
--
arch/arm/mach-omap2/display.c-102-
arch/arm/mach-omap2/display.c:103: reg |= (lanes << enable_shift) & enable_mask;
arch/arm/mach-omap2/display.c:104: reg |= (lanes << pipd_shift) & pipd_mask;
arch/arm/mach-omap2/display.c-105-
--
arch/arm/mach-omap2/omap_hwmod.c=332=static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode,
--
arch/arm/mach-omap2/omap_hwmod.c-347- mstandby_shift = oh->class->sysc->sysc_fields->midle_shift;
arch/arm/mach-omap2/omap_hwmod.c:348: mstandby_mask = (0x3 << mstandby_shift);
arch/arm/mach-omap2/omap_hwmod.c-349-
arch/arm/mach-omap2/omap_hwmod.c-350- *v &= ~mstandby_mask;
arch/arm/mach-omap2/omap_hwmod.c:351: *v |= __ffs(standbymode) << mstandby_shift;
arch/arm/mach-omap2/omap_hwmod.c-352-
--
arch/arm/mach-omap2/omap_hwmod.c=366=static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v)
--
arch/arm/mach-omap2/omap_hwmod.c-380- sidle_shift = oh->class->sysc->sysc_fields->sidle_shift;
arch/arm/mach-omap2/omap_hwmod.c:381: sidle_mask = (0x3 << sidle_shift);
arch/arm/mach-omap2/omap_hwmod.c-382-
arch/arm/mach-omap2/omap_hwmod.c-383- *v &= ~sidle_mask;
arch/arm/mach-omap2/omap_hwmod.c:384: *v |= __ffs(idlemode) << sidle_shift;
arch/arm/mach-omap2/omap_hwmod.c-385-
--
arch/arm/mach-omap2/omap_hwmod.c=400=static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v)
--
arch/arm/mach-omap2/omap_hwmod.c-414- clkact_shift = oh->class->sysc->sysc_fields->clkact_shift;
arch/arm/mach-omap2/omap_hwmod.c:415: clkact_mask = (0x3 << clkact_shift);
arch/arm/mach-omap2/omap_hwmod.c-416-
arch/arm/mach-omap2/omap_hwmod.c-417- *v &= ~clkact_mask;
arch/arm/mach-omap2/omap_hwmod.c:418: *v |= clockact << clkact_shift;
arch/arm/mach-omap2/omap_hwmod.c-419-
--
arch/arm/mach-omap2/omap_hwmod.c=431=static int _set_softreset(struct omap_hwmod *oh, u32 *v)
--
arch/arm/mach-omap2/omap_hwmod.c-443-
arch/arm/mach-omap2/omap_hwmod.c:444: softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift);
arch/arm/mach-omap2/omap_hwmod.c-445-
--
arch/arm/mach-omap2/omap_hwmod.c=459=static int _clear_softreset(struct omap_hwmod *oh, u32 *v)
--
arch/arm/mach-omap2/omap_hwmod.c-473-
arch/arm/mach-omap2/omap_hwmod.c:474: softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift);
arch/arm/mach-omap2/omap_hwmod.c-475-
--
arch/arm/mach-omap2/omap_hwmod.c=491=static int _wait_softreset_complete(struct omap_hwmod *oh)
--
arch/arm/mach-omap2/omap_hwmod.c-503- else if (sysc->sysc_flags & SYSC_HAS_RESET_STATUS) {
arch/arm/mach-omap2/omap_hwmod.c:504: softrst_mask = (0x1 << sysc->sysc_fields->srst_shift);
arch/arm/mach-omap2/omap_hwmod.c-505- omap_test_timeout(!(omap_hwmod_read(oh, sysc->sysc_offs)
--
arch/arm/mach-omap2/omap_hwmod.c=525=static int _set_dmadisable(struct omap_hwmod *oh)
--
arch/arm/mach-omap2/omap_hwmod.c-548- dmadisable_mask =
arch/arm/mach-omap2/omap_hwmod.c:549: (0x1 << oh->class->sysc->sysc_fields->dmadisable_shift);
arch/arm/mach-omap2/omap_hwmod.c-550- v |= dmadisable_mask;
--
arch/arm/mach-omap2/omap_hwmod.c=569=static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle,
--
arch/arm/mach-omap2/omap_hwmod.c-584- autoidle_shift = oh->class->sysc->sysc_fields->autoidle_shift;
arch/arm/mach-omap2/omap_hwmod.c:585: autoidle_mask = (0x1 << autoidle_shift);
arch/arm/mach-omap2/omap_hwmod.c-586-
arch/arm/mach-omap2/omap_hwmod.c-587- *v &= ~autoidle_mask;
arch/arm/mach-omap2/omap_hwmod.c:588: *v |= autoidle << autoidle_shift;
arch/arm/mach-omap2/omap_hwmod.c-589-
--
arch/arm/mach-omap2/omap_hwmod.c=600=static int _enable_wakeup(struct omap_hwmod *oh, u32 *v)
--
arch/arm/mach-omap2/omap_hwmod.c-613- if (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)
arch/arm/mach-omap2/omap_hwmod.c:614: *v |= 0x1 << oh->class->sysc->sysc_fields->enwkup_shift;
arch/arm/mach-omap2/omap_hwmod.c-615-
--
arch/arm/mach-omap2/prm2xxx.c=54=static u32 omap2xxx_prm_read_reset_sources(void)
--
arch/arm/mach-omap2/prm2xxx.c-63- while (p->reg_shift >= 0 && p->std_shift >= 0) {
arch/arm/mach-omap2/prm2xxx.c:64: if (v & (1 << p->reg_shift))
arch/arm/mach-omap2/prm2xxx.c:65: r |= 1 << p->std_shift;
arch/arm/mach-omap2/prm2xxx.c-66- p++;
--
arch/arm/mach-omap2/prm2xxx_3xxx.c=33=int omap2_prm_is_hardreset_asserted(u8 shift, u8 part, s16 prm_mod, u16 offset)
--
arch/arm/mach-omap2/prm2xxx_3xxx.c-35- return omap2_prm_read_mod_bits_shift(prm_mod, OMAP2_RM_RSTCTRL,
arch/arm/mach-omap2/prm2xxx_3xxx.c:36: (1 << shift));
arch/arm/mach-omap2/prm2xxx_3xxx.c-37-}
--
arch/arm/mach-omap2/prm2xxx_3xxx.c=53=int omap2_prm_assert_hardreset(u8 shift, u8 part, s16 prm_mod, u16 offset)
--
arch/arm/mach-omap2/prm2xxx_3xxx.c-56-
arch/arm/mach-omap2/prm2xxx_3xxx.c:57: mask = 1 << shift;
arch/arm/mach-omap2/prm2xxx_3xxx.c-58- omap2_prm_rmw_mod_reg_bits(mask, mask, prm_mod, OMAP2_RM_RSTCTRL);
--
arch/arm/mach-omap2/prm2xxx_3xxx.c=82=int omap2_prm_deassert_hardreset(u8 rst_shift, u8 st_shift, u8 part,
--
arch/arm/mach-omap2/prm2xxx_3xxx.c-87-
arch/arm/mach-omap2/prm2xxx_3xxx.c:88: rst = 1 << rst_shift;
arch/arm/mach-omap2/prm2xxx_3xxx.c:89: st = 1 << st_shift;
arch/arm/mach-omap2/prm2xxx_3xxx.c-90-
--
arch/arm/mach-omap2/prm33xx.c=56=static int am33xx_prm_is_hardreset_asserted(u8 shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prm33xx.c-61- v = am33xx_prm_read_reg(inst, rstctrl_offs);
arch/arm/mach-omap2/prm33xx.c:62: v &= 1 << shift;
arch/arm/mach-omap2/prm33xx.c-63- v >>= shift;
--
arch/arm/mach-omap2/prm33xx.c=82=static int am33xx_prm_assert_hardreset(u8 shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prm33xx.c-84-{
arch/arm/mach-omap2/prm33xx.c:85: u32 mask = 1 << shift;
arch/arm/mach-omap2/prm33xx.c-86-
--
arch/arm/mach-omap2/prm33xx.c=111=static int am33xx_prm_deassert_hardreset(u8 shift, u8 st_shift, u8 part,
--
arch/arm/mach-omap2/prm33xx.c-115- int c;
arch/arm/mach-omap2/prm33xx.c:116: u32 mask = 1 << st_shift;
arch/arm/mach-omap2/prm33xx.c-117-
--
arch/arm/mach-omap2/prm33xx.c-125- /* de-assert the reset control line */
arch/arm/mach-omap2/prm33xx.c:126: mask = 1 << shift;
arch/arm/mach-omap2/prm33xx.c-127-
--
arch/arm/mach-omap2/prm3xxx.c=447=static u32 omap3xxx_prm_read_reset_sources(void)
--
arch/arm/mach-omap2/prm3xxx.c-456- while (p->reg_shift >= 0 && p->std_shift >= 0) {
arch/arm/mach-omap2/prm3xxx.c:457: if (v & (1 << p->reg_shift))
arch/arm/mach-omap2/prm3xxx.c:458: r |= 1 << p->std_shift;
arch/arm/mach-omap2/prm3xxx.c-459- p++;
--
arch/arm/mach-omap2/prm44xx.c=370=static u32 omap44xx_prm_read_reset_sources(void)
--
arch/arm/mach-omap2/prm44xx.c-385- while (p->reg_shift >= 0 && p->std_shift >= 0) {
arch/arm/mach-omap2/prm44xx.c:386: if (v & (1 << p->reg_shift))
arch/arm/mach-omap2/prm44xx.c:387: r |= 1 << p->std_shift;
arch/arm/mach-omap2/prm44xx.c-388- p++;
--
arch/arm/mach-omap2/prminst44xx.c=99=int omap4_prminst_is_hardreset_asserted(u8 shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prminst44xx.c-104- v = omap4_prminst_read_inst_reg(part, inst, rstctrl_offs);
arch/arm/mach-omap2/prminst44xx.c:105: v &= 1 << shift;
arch/arm/mach-omap2/prminst44xx.c-106- v >>= shift;
--
arch/arm/mach-omap2/prminst44xx.c=123=int omap4_prminst_assert_hardreset(u8 shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prminst44xx.c-125-{
arch/arm/mach-omap2/prminst44xx.c:126: u32 mask = 1 << shift;
arch/arm/mach-omap2/prminst44xx.c-127-
--
arch/arm/mach-omap2/prminst44xx.c=152=int omap4_prminst_deassert_hardreset(u8 shift, u8 st_shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prminst44xx.c-155- int c;
arch/arm/mach-omap2/prminst44xx.c:156: u32 mask = 1 << shift;
arch/arm/mach-omap2/prminst44xx.c:157: u32 st_mask = 1 << st_shift;
arch/arm/mach-omap2/prminst44xx.c-158-
--
arch/arm/mach-omap2/vc.c=116=static int omap_vc_config_channel(struct voltagedomain *voltdm)
--
arch/arm/mach-omap2/vc.c-126-
arch/arm/mach-omap2/vc.c:127: voltdm->rmw(CFG_CHANNEL_MASK << vc->cfg_channel_sa_shift,
arch/arm/mach-omap2/vc.c:128: vc->cfg_channel << vc->cfg_channel_sa_shift,
arch/arm/mach-omap2/vc.c-129- vc->cfg_channel_reg);
--
arch/arm/mach-omap2/vc.c=135=int omap_vc_pre_scale(struct voltagedomain *voltdm,
--
arch/arm/mach-omap2/vc.c-166- vc_cmdval &= ~vc->common->cmd_on_mask;
arch/arm/mach-omap2/vc.c:167: vc_cmdval |= (*target_vsel << vc->common->cmd_on_shift);
arch/arm/mach-omap2/vc.c-168- voltdm->write(vc_cmdval, vc->cmdval_reg);
--
arch/arm/mach-omap2/vc.c=191=int omap_vc_bypass_scale(struct voltagedomain *voltdm,
--
arch/arm/mach-omap2/vc.c-205- vc_bypass_val_reg = vc->common->bypass_val_reg;
arch/arm/mach-omap2/vc.c:206: vc_bypass_value = (target_vsel << vc->common->data_shift) |
arch/arm/mach-omap2/vc.c:207: (vc->volt_reg_addr << vc->common->regaddr_shift) |
arch/arm/mach-omap2/vc.c:208: (vc->i2c_slave_addr << vc->common->slaveaddr_shift);
arch/arm/mach-omap2/vc.c-209-
--
arch/arm/mach-omap2/vc.c=529=static u32 omap4_usec_to_val_scrm(u32 usec, int shift, u32 mask)
--
arch/arm/mach-omap2/vc.c-532-
arch/arm/mach-omap2/vc.c:533: val = omap_usec_to_32k(usec) << shift;
arch/arm/mach-omap2/vc.c-534-
--
arch/arm/mach-omap2/vc.c=805=void __init omap_vc_init_channel(struct voltagedomain *voltdm)
--
arch/arm/mach-omap2/vc.c-862-
arch/arm/mach-omap2/vc.c:863: val = ((on_vsel << vc->common->cmd_on_shift) |
arch/arm/mach-omap2/vc.c:864: (onlp_vsel << vc->common->cmd_onlp_shift) |
arch/arm/mach-omap2/vc.c:865: (ret_vsel << vc->common->cmd_ret_shift) |
arch/arm/mach-omap2/vc.c:866: (off_vsel << vc->common->cmd_off_shift));
arch/arm/mach-omap2/vc.c-867- voltdm->write(val, vc->cmdval_reg);
--
arch/arm/mach-omap2/vp.c=39=void __init omap_vp_init(struct voltagedomain *voltdm)
--
arch/arm/mach-omap2/vp.c-81- /* VSTEPMIN */
arch/arm/mach-omap2/vp.c:82: val = (waittime << vp->common->vstepmin_smpswaittimemin_shift) |
arch/arm/mach-omap2/vp.c:83: (vstepmin << vp->common->vstepmin_stepmin_shift);
arch/arm/mach-omap2/vp.c-84- voltdm->write(val, vp->vstepmin);
--
arch/arm/mach-omap2/vp.c-86- /* VSTEPMAX */
arch/arm/mach-omap2/vp.c:87: val = (vstepmax << vp->common->vstepmax_stepmax_shift) |
arch/arm/mach-omap2/vp.c:88: (waittime << vp->common->vstepmax_smpswaittimemax_shift);
arch/arm/mach-omap2/vp.c-89- voltdm->write(val, vp->vstepmax);
--
arch/arm/mach-omap2/vp.c-91- /* VLIMITTO */
arch/arm/mach-omap2/vp.c:92: val = (vddmax << vp->common->vlimitto_vddmax_shift) |
arch/arm/mach-omap2/vp.c:93: (vddmin << vp->common->vlimitto_vddmin_shift) |
arch/arm/mach-omap2/vp.c:94: (timeout << vp->common->vlimitto_timeout_shift);
arch/arm/mach-omap2/vp.c-95- voltdm->write(val, vp->vlimitto);
--
arch/arm/mach-s3c/gpio-samsung.c=40=static int samsung_gpio_setpull_updown(struct samsung_gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-47- pup = __raw_readl(reg);
arch/arm/mach-s3c/gpio-samsung.c:48: pup &= ~(3 << shift);
arch/arm/mach-s3c/gpio-samsung.c:49: pup |= pull << shift;
arch/arm/mach-s3c/gpio-samsung.c-50- __raw_writel(pup, reg);
--
arch/arm/mach-s3c/gpio-samsung.c=68=static int samsung_gpio_setcfg_2bit(struct samsung_gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-79-
arch/arm/mach-s3c/gpio-samsung.c:80: cfg <<= shift;
arch/arm/mach-s3c/gpio-samsung.c-81- }
--
arch/arm/mach-s3c/gpio-samsung.c-83- con = __raw_readl(reg);
arch/arm/mach-s3c/gpio-samsung.c:84: con &= ~(0x3 << shift);
arch/arm/mach-s3c/gpio-samsung.c-85- con |= cfg;
--
arch/arm/mach-s3c/gpio-samsung.c=131=static int samsung_gpio_setcfg_4bit(struct samsung_gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-142- cfg &= 0xf;
arch/arm/mach-s3c/gpio-samsung.c:143: cfg <<= shift;
arch/arm/mach-s3c/gpio-samsung.c-144- }
--
arch/arm/mach-s3c/gpio-samsung.c-146- con = __raw_readl(reg);
arch/arm/mach-s3c/gpio-samsung.c:147: con &= ~(0xf << shift);
arch/arm/mach-s3c/gpio-samsung.c-148- con |= cfg;
--
arch/arm/mach-s3c/gpio-samsung.c=307=static int samsung_gpiolib_4bit_input(struct gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-315- if (ourchip->bitmap_gpio_int & BIT(offset))
arch/arm/mach-s3c/gpio-samsung.c:316: con |= 0xf << con_4bit_shift(offset);
arch/arm/mach-s3c/gpio-samsung.c-317- else
arch/arm/mach-s3c/gpio-samsung.c:318: con &= ~(0xf << con_4bit_shift(offset));
arch/arm/mach-s3c/gpio-samsung.c-319- __raw_writel(con, base + GPIOCON_OFF);
--
arch/arm/mach-s3c/gpio-samsung.c=326=static int samsung_gpiolib_4bit_output(struct gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-334- con = __raw_readl(base + GPIOCON_OFF);
arch/arm/mach-s3c/gpio-samsung.c:335: con &= ~(0xf << con_4bit_shift(offset));
arch/arm/mach-s3c/gpio-samsung.c:336: con |= 0x1 << con_4bit_shift(offset);
arch/arm/mach-s3c/gpio-samsung.c-337-
--
arch/arm/mach-s3c/gpio-samsung.c=376=static int samsung_gpiolib_4bit2_input(struct gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-389- con = __raw_readl(regcon);
arch/arm/mach-s3c/gpio-samsung.c:390: con &= ~(0xf << con_4bit_shift(offset));
arch/arm/mach-s3c/gpio-samsung.c-391- __raw_writel(con, regcon);
--
arch/arm/mach-s3c/gpio-samsung.c=398=static int samsung_gpiolib_4bit2_output(struct gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-413- con = __raw_readl(regcon);
arch/arm/mach-s3c/gpio-samsung.c:414: con &= ~(0xf << con_4bit_shift(con_offset));
arch/arm/mach-s3c/gpio-samsung.c:415: con |= 0x1 << con_4bit_shift(con_offset);
arch/arm/mach-s3c/gpio-samsung.c-416-
--
arch/arm/mach-s3c/s3c64xx.c=269=static int s3c_irq_eint_set_type(struct irq_data *data, unsigned int type)
--
arch/arm/mach-s3c/s3c64xx.c-319- shift = ((offs - 16) / 2) * 4;
arch/arm/mach-s3c/s3c64xx.c:320: mask = 0x7 << shift;
arch/arm/mach-s3c/s3c64xx.c-321-
--
arch/arm/mach-s3c/s3c64xx.c-323- ctrl &= ~mask;
arch/arm/mach-s3c/s3c64xx.c:324: ctrl |= newvalue << shift;
arch/arm/mach-s3c/s3c64xx.c-325- __raw_writel(ctrl, reg);
--
arch/arm/mm/alignment.c=801=do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
--
arch/arm/mm/alignment.c-890- case SHIFT_LSL:
arch/arm/mm/alignment.c:891: offset.un <<= shiftval;
arch/arm/mm/alignment.c-892- break;
--
arch/arm/mm/alignment.c-908- offset.un = offset.un >> shiftval |
arch/arm/mm/alignment.c:909: offset.un << (32 - shiftval);
arch/arm/mm/alignment.c-910- break;
--
arch/arm/nwfpe/softfloat.c=154=static void
--
arch/arm/nwfpe/softfloat.c-159- shiftCount = countLeadingZeros32( aSig ) - 8;
arch/arm/nwfpe/softfloat.c:160: *zSigPtr = aSig<<shiftCount;
arch/arm/nwfpe/softfloat.c-161- *zExpPtr = 1 - shiftCount;
--
arch/arm/nwfpe/softfloat.c=279=static float32
--
arch/arm/nwfpe/softfloat.c-284- shiftCount = countLeadingZeros32( zSig ) - 1;
arch/arm/nwfpe/softfloat.c:285: return roundAndPackFloat32( roundData, zSign, zExp - shiftCount, zSig<<shiftCount );
arch/arm/nwfpe/softfloat.c-286-
--
arch/arm/nwfpe/softfloat.c=335=static void
--
arch/arm/nwfpe/softfloat.c-340- shiftCount = countLeadingZeros64( aSig ) - 11;
arch/arm/nwfpe/softfloat.c:341: *zSigPtr = aSig<<shiftCount;
arch/arm/nwfpe/softfloat.c-342- *zExpPtr = 1 - shiftCount;
--
arch/arm/nwfpe/softfloat.c=452=static float64
--
arch/arm/nwfpe/softfloat.c-457- shiftCount = countLeadingZeros64( zSig ) - 1;
arch/arm/nwfpe/softfloat.c:458: return roundAndPackFloat64( roundData, zSign, zExp - shiftCount, zSig<<shiftCount );
arch/arm/nwfpe/softfloat.c-459-
--
arch/arm/nwfpe/softfloat.c=511=static void
--
arch/arm/nwfpe/softfloat.c-516- shiftCount = countLeadingZeros64( aSig );
arch/arm/nwfpe/softfloat.c:517: *zSigPtr = aSig<<shiftCount;
arch/arm/nwfpe/softfloat.c-518- *zExpPtr = 1 - shiftCount;
--
arch/arm/nwfpe/softfloat.c=780=float64 int32_to_float64( int32 a )
--
arch/arm/nwfpe/softfloat.c-791- zSig = absA;
arch/arm/nwfpe/softfloat.c:792: return packFloat64( aSign, 0x432 - shiftCount, zSig<<shiftCount );
arch/arm/nwfpe/softfloat.c-793-
--
arch/arm/nwfpe/softfloat.c=806=floatx80 int32_to_floatx80( int32 a )
--
arch/arm/nwfpe/softfloat.c-817- zSig = absA;
arch/arm/nwfpe/softfloat.c:818: return packFloatx80( zSign, 0x403E - shiftCount, zSig<<shiftCount );
arch/arm/nwfpe/softfloat.c-819-
--
arch/arm/nwfpe/softfloat.c=866=int32 float32_to_int32_round_to_zero( float32 a )
--
arch/arm/nwfpe/softfloat.c-888- z = aSig>>( - shiftCount );
arch/arm/nwfpe/softfloat.c:889: if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) {
arch/arm/nwfpe/softfloat.c-890- float_raise( float_flag_inexact );
--
arch/arm/nwfpe/softfloat.c=1680=int32 float64_to_int32_round_to_zero( float64 a )
--
arch/arm/nwfpe/softfloat.c-1708- }
arch/arm/nwfpe/softfloat.c:1709: if ( ( aSig<<shiftCount ) != savedASig ) {
arch/arm/nwfpe/softfloat.c-1710- float_raise( float_flag_inexact );
--
arch/arm/nwfpe/softfloat.c=1753=int32 float64_to_uint32_round_to_zero( float64 a )
--
arch/arm/nwfpe/softfloat.c-1781- }
arch/arm/nwfpe/softfloat.c:1782: if ( ( aSig<<shiftCount ) != savedASig ) {
arch/arm/nwfpe/softfloat.c-1783- float_raise( float_flag_inexact );
--
arch/arm/nwfpe/softfloat.c=2569=int32 floatx80_to_int32_round_to_zero( floatx80 a )
--
arch/arm/nwfpe/softfloat.c-2596- }
arch/arm/nwfpe/softfloat.c:2597: if ( ( aSig<<shiftCount ) != savedASig ) {
arch/arm/nwfpe/softfloat.c-2598- float_raise( float_flag_inexact );
--
arch/arm/plat-orion/mpp.c=27=void __init orion_mpp_conf(unsigned int *mpp_list, unsigned int variant_mask,
--
arch/arm/plat-orion/mpp.c-63- shift = (num & 7) << 2;
arch/arm/plat-orion/mpp.c:64: mpp_ctrl[num / 8] &= ~(0xf << shift);
arch/arm/plat-orion/mpp.c:65: mpp_ctrl[num / 8] |= sel << shift;
arch/arm/plat-orion/mpp.c-66-
--
arch/arm/vfp/vfp.h=9=static inline u32 vfp_shiftright32jamming(u32 val, unsigned int shift)
--
arch/arm/vfp/vfp.h-12- if (shift < 32)
arch/arm/vfp/vfp.h:13: val = val >> shift | ((val << (32 - shift)) != 0);
arch/arm/vfp/vfp.h-14- else
--
arch/arm/vfp/vfp.h=20=static inline u64 vfp_shiftright64jamming(u64 val, unsigned int shift)
--
arch/arm/vfp/vfp.h-23- if (shift < 64)
arch/arm/vfp/vfp.h:24: val = val >> shift | ((val << (64 - shift)) != 0);
arch/arm/vfp/vfp.h-25- else
--
arch/arm/vfp/vfpdouble.c=70=u32 vfp_double_normaliseround(int dd, struct vfp_double *vd, u32 fpscr, u32 exceptions, const char *func)
--
arch/arm/vfp/vfpdouble.c-99- exponent -= shift;
arch/arm/vfp/vfpdouble.c:100: significand <<= shift;
arch/arm/vfp/vfpdouble.c-101- }
--
arch/arm/vfp/vfpdouble.c=506=static u32 vfp_double_ftoui(int sd, int unused, int dm, u32 fpscr)
--
arch/arm/vfp/vfpdouble.c-534- */
arch/arm/vfp/vfpdouble.c:535: d = (vdm.significand << 1) >> shift;
arch/arm/vfp/vfpdouble.c:536: rem = vdm.significand << (65 - shift);
arch/arm/vfp/vfpdouble.c-537-
--
arch/arm/vfp/vfpdouble.c=585=static u32 vfp_double_ftosi(int sd, int unused, int dm, u32 fpscr)
--
arch/arm/vfp/vfpdouble.c-613-
arch/arm/vfp/vfpdouble.c:614: d = (vdm.significand << 1) >> shift;
arch/arm/vfp/vfpdouble.c:615: rem = vdm.significand << (65 - shift);
arch/arm/vfp/vfpdouble.c-616-
--
arch/arm/vfp/vfpsingle.c=72=u32 vfp_single_normaliseround(int sd, struct vfp_single *vs, u32 fpscr, u32 exceptions, const char *func)
--
arch/arm/vfp/vfpsingle.c-104- exponent -= shift;
arch/arm/vfp/vfpsingle.c:105: significand <<= shift;
arch/arm/vfp/vfpsingle.c-106- }
--
arch/arm/vfp/vfpsingle.c=547=static u32 vfp_single_ftoui(int sd, int unused, s32 m, u32 fpscr)
--
arch/arm/vfp/vfpsingle.c-576- */
arch/arm/vfp/vfpsingle.c:577: d = (vsm.significand << 1) >> shift;
arch/arm/vfp/vfpsingle.c:578: rem = vsm.significand << (33 - shift);
arch/arm/vfp/vfpsingle.c-579-
--
arch/arm/vfp/vfpsingle.c=627=static u32 vfp_single_ftosi(int sd, int unused, s32 m, u32 fpscr)
--
arch/arm/vfp/vfpsingle.c-659- /* 2^0 <= m <= 2^31-2^7 */
arch/arm/vfp/vfpsingle.c:660: d = (vsm.significand << 1) >> shift;
arch/arm/vfp/vfpsingle.c:661: rem = vsm.significand << (33 - shift);
arch/arm/vfp/vfpsingle.c-662-
--
arch/arm64/include/asm/kvm_mmu.h=143=extern u32 __hyp_va_bits;
--
arch/arm64/include/asm/kvm_mmu.h-151-#define kvm_phys_shift(mmu) VTCR_EL2_IPA((mmu)->vtcr)
]
]
|
| 57/4 |
2026/05/21 22:56 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 35977
output: 17
thoughts: 13
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Diving into the BEFS Filesystem**
Alright, time to zero in. We've got a system, and we need to investigate. While a broad overview is always good as a starting point, it's inefficient to keep chasing shadows. Considering the context, I think a more focused approach is needed. Let's make sure we're not missing anything obvious in the `fs/befs/` directory first. I'm going to want to examine the BEFS filesystem implementation directly. Hopefully, this specific area will provide the clues we need. It's a targeted check, but it's crucial to rule out the most likely suspects before we get bogged down in something tangential. Time to put the magnifying glass on `fs/befs/`.
|
| 58/4 |
2026/05/21 22:56 |
tool |
grepper |
0m
Args: map[Expression:<<.*shift]
Results: map[Output:
Full output is too long, showing 500 out of 34283 lines.
Use more precise expression if possible.
[Documentation/admin-guide/kdump/gdbmacros.txt=289=define dmesg
--
Documentation/admin-guide/kdump/gdbmacros.txt-294- set var $desc_flags_shift = $desc_sv_bits - 2
Documentation/admin-guide/kdump/gdbmacros.txt:295: set var $desc_flags_mask = 3 << $desc_flags_shift
Documentation/admin-guide/kdump/gdbmacros.txt-296- set var $id_mask = ~$desc_flags_mask
--
Documentation/mm/physical_memory.rst=545=Compaction control
--
Documentation/mm/physical_memory.rst-577- The number of compactions skipped before trying again is
Documentation/mm/physical_memory.rst:578: ``1<<compact_defer_shift``. It is increased by 1 in ``defer_compaction()``.
Documentation/mm/physical_memory.rst-579- It is reset in ``compaction_defer_reset()`` when a direct compaction results
--
Documentation/virt/kvm/x86/msr.rst=62=data:
--
Documentation/virt/kvm/x86/msr.rst-118- if (tsc_shift >= 0)
Documentation/virt/kvm/x86/msr.rst:119: time <<= tsc_shift;
Documentation/virt/kvm/x86/msr.rst-120- else
--
arch/alpha/kernel/perf_event.c=233=static inline void alpha_write_pmc(int idx, unsigned long val)
--
arch/alpha/kernel/perf_event.c-235- val &= alpha_pmu->pmc_count_mask[idx];
arch/alpha/kernel/perf_event.c:236: val <<= alpha_pmu->pmc_count_shift[idx];
arch/alpha/kernel/perf_event.c-237- val |= (1<<idx);
--
arch/arc/kernel/unwind.c=449=static uleb128_t get_uleb128(const u8 **pcur, const u8 *end)
--
arch/arc/kernel/unwind.c-456- if (shift + 7 > 8 * sizeof(value)
arch/arc/kernel/unwind.c:457: && (*cur & 0x7fU) >= (1U << (8 * sizeof(value) - shift))) {
arch/arc/kernel/unwind.c-458- cur = end + 1;
--
arch/arc/kernel/unwind.c-460- }
arch/arc/kernel/unwind.c:461: value |= (uleb128_t) (*cur & 0x7f) << shift;
arch/arc/kernel/unwind.c-462- if (!(*cur++ & 0x80))
--
arch/arc/kernel/unwind.c=470=static sleb128_t get_sleb128(const u8 **pcur, const u8 *end)
--
arch/arc/kernel/unwind.c-477- if (shift + 7 > 8 * sizeof(value)
arch/arc/kernel/unwind.c:478: && (*cur & 0x7fU) >= (1U << (8 * sizeof(value) - shift))) {
arch/arc/kernel/unwind.c-479- cur = end + 1;
--
arch/arc/kernel/unwind.c-481- }
arch/arc/kernel/unwind.c:482: value |= (sleb128_t) (*cur & 0x7f) << shift;
arch/arc/kernel/unwind.c-483- if (!(*cur & 0x80)) {
arch/arc/kernel/unwind.c:484: value |= -(*cur++ & 0x40) << shift;
arch/arc/kernel/unwind.c-485- break;
--
arch/arm/mach-omap1/clock.c=63=static void omap1_clk_allow_idle(struct omap1_clk *clk)
--
arch/arm/mach-omap1/clock.c-70- if (iclk->no_idle_count > 0 && !(--iclk->no_idle_count))
arch/arm/mach-omap1/clock.c:71: arm_idlect1_mask |= 1 << iclk->idlect_shift;
arch/arm/mach-omap1/clock.c-72-}
--
arch/arm/mach-omap1/clock.c=74=static void omap1_clk_deny_idle(struct omap1_clk *clk)
--
arch/arm/mach-omap1/clock.c-81- if (iclk->no_idle_count++ == 0)
arch/arm/mach-omap1/clock.c:82: arm_idlect1_mask &= ~(1 << iclk->idlect_shift);
arch/arm/mach-omap1/clock.c-83-}
--
arch/arm/mach-omap1/omap-dma.c=77=static inline void set_gdma_dev(int req, int dev)
--
arch/arm/mach-omap1/omap-dma.c-83- l = omap_readl(reg);
arch/arm/mach-omap1/omap-dma.c:84: l &= ~(0x3f << shift);
arch/arm/mach-omap1/omap-dma.c:85: l |= (dev - 1) << shift;
arch/arm/mach-omap1/omap-dma.c-86- omap_writel(l, reg);
--
arch/arm/mach-omap1/serial.c=33=static inline unsigned int omap_serial_in(struct plat_serial8250_port *up,
--
arch/arm/mach-omap1/serial.c-35-{
arch/arm/mach-omap1/serial.c:36: offset <<= up->regshift;
arch/arm/mach-omap1/serial.c-37- return (unsigned int)__raw_readb(up->membase + offset);
--
arch/arm/mach-omap1/serial.c=40=static inline void omap_serial_outp(struct plat_serial8250_port *p, int offset,
--
arch/arm/mach-omap1/serial.c-42-{
arch/arm/mach-omap1/serial.c:43: offset <<= p->regshift;
arch/arm/mach-omap1/serial.c-44- __raw_writeb(value, p->membase + offset);
--
arch/arm/mach-omap2/cm2xxx.c=148=static int omap2xxx_cm_wait_module_ready(u8 part, s16 prcm_mod, u16 idlest_id,
--
arch/arm/mach-omap2/cm2xxx.c-159-
arch/arm/mach-omap2/cm2xxx.c:160: mask = 1 << idlest_shift;
arch/arm/mach-omap2/cm2xxx.c-161- ena = mask;
--
arch/arm/mach-omap2/cm3xxx.c=88=static int omap3xxx_cm_wait_module_ready(u8 part, s16 prcm_mod, u16 idlest_id,
--
arch/arm/mach-omap2/cm3xxx.c-99-
arch/arm/mach-omap2/cm3xxx.c:100: mask = 1 << idlest_shift;
arch/arm/mach-omap2/cm3xxx.c-101- ena = 0;
--
arch/arm/mach-omap2/display.c=73=static int omap4_dsi_mux_pads(int dsi_id, unsigned lanes)
--
arch/arm/mach-omap2/display.c-102-
arch/arm/mach-omap2/display.c:103: reg |= (lanes << enable_shift) & enable_mask;
arch/arm/mach-omap2/display.c:104: reg |= (lanes << pipd_shift) & pipd_mask;
arch/arm/mach-omap2/display.c-105-
--
arch/arm/mach-omap2/omap_hwmod.c=332=static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode,
--
arch/arm/mach-omap2/omap_hwmod.c-347- mstandby_shift = oh->class->sysc->sysc_fields->midle_shift;
arch/arm/mach-omap2/omap_hwmod.c:348: mstandby_mask = (0x3 << mstandby_shift);
arch/arm/mach-omap2/omap_hwmod.c-349-
arch/arm/mach-omap2/omap_hwmod.c-350- *v &= ~mstandby_mask;
arch/arm/mach-omap2/omap_hwmod.c:351: *v |= __ffs(standbymode) << mstandby_shift;
arch/arm/mach-omap2/omap_hwmod.c-352-
--
arch/arm/mach-omap2/omap_hwmod.c=366=static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v)
--
arch/arm/mach-omap2/omap_hwmod.c-380- sidle_shift = oh->class->sysc->sysc_fields->sidle_shift;
arch/arm/mach-omap2/omap_hwmod.c:381: sidle_mask = (0x3 << sidle_shift);
arch/arm/mach-omap2/omap_hwmod.c-382-
arch/arm/mach-omap2/omap_hwmod.c-383- *v &= ~sidle_mask;
arch/arm/mach-omap2/omap_hwmod.c:384: *v |= __ffs(idlemode) << sidle_shift;
arch/arm/mach-omap2/omap_hwmod.c-385-
--
arch/arm/mach-omap2/omap_hwmod.c=400=static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v)
--
arch/arm/mach-omap2/omap_hwmod.c-414- clkact_shift = oh->class->sysc->sysc_fields->clkact_shift;
arch/arm/mach-omap2/omap_hwmod.c:415: clkact_mask = (0x3 << clkact_shift);
arch/arm/mach-omap2/omap_hwmod.c-416-
arch/arm/mach-omap2/omap_hwmod.c-417- *v &= ~clkact_mask;
arch/arm/mach-omap2/omap_hwmod.c:418: *v |= clockact << clkact_shift;
arch/arm/mach-omap2/omap_hwmod.c-419-
--
arch/arm/mach-omap2/omap_hwmod.c=431=static int _set_softreset(struct omap_hwmod *oh, u32 *v)
--
arch/arm/mach-omap2/omap_hwmod.c-443-
arch/arm/mach-omap2/omap_hwmod.c:444: softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift);
arch/arm/mach-omap2/omap_hwmod.c-445-
--
arch/arm/mach-omap2/omap_hwmod.c=459=static int _clear_softreset(struct omap_hwmod *oh, u32 *v)
--
arch/arm/mach-omap2/omap_hwmod.c-473-
arch/arm/mach-omap2/omap_hwmod.c:474: softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift);
arch/arm/mach-omap2/omap_hwmod.c-475-
--
arch/arm/mach-omap2/omap_hwmod.c=491=static int _wait_softreset_complete(struct omap_hwmod *oh)
--
arch/arm/mach-omap2/omap_hwmod.c-503- else if (sysc->sysc_flags & SYSC_HAS_RESET_STATUS) {
arch/arm/mach-omap2/omap_hwmod.c:504: softrst_mask = (0x1 << sysc->sysc_fields->srst_shift);
arch/arm/mach-omap2/omap_hwmod.c-505- omap_test_timeout(!(omap_hwmod_read(oh, sysc->sysc_offs)
--
arch/arm/mach-omap2/omap_hwmod.c=525=static int _set_dmadisable(struct omap_hwmod *oh)
--
arch/arm/mach-omap2/omap_hwmod.c-548- dmadisable_mask =
arch/arm/mach-omap2/omap_hwmod.c:549: (0x1 << oh->class->sysc->sysc_fields->dmadisable_shift);
arch/arm/mach-omap2/omap_hwmod.c-550- v |= dmadisable_mask;
--
arch/arm/mach-omap2/omap_hwmod.c=569=static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle,
--
arch/arm/mach-omap2/omap_hwmod.c-584- autoidle_shift = oh->class->sysc->sysc_fields->autoidle_shift;
arch/arm/mach-omap2/omap_hwmod.c:585: autoidle_mask = (0x1 << autoidle_shift);
arch/arm/mach-omap2/omap_hwmod.c-586-
arch/arm/mach-omap2/omap_hwmod.c-587- *v &= ~autoidle_mask;
arch/arm/mach-omap2/omap_hwmod.c:588: *v |= autoidle << autoidle_shift;
arch/arm/mach-omap2/omap_hwmod.c-589-
--
arch/arm/mach-omap2/omap_hwmod.c=600=static int _enable_wakeup(struct omap_hwmod *oh, u32 *v)
--
arch/arm/mach-omap2/omap_hwmod.c-613- if (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)
arch/arm/mach-omap2/omap_hwmod.c:614: *v |= 0x1 << oh->class->sysc->sysc_fields->enwkup_shift;
arch/arm/mach-omap2/omap_hwmod.c-615-
--
arch/arm/mach-omap2/prm2xxx.c=54=static u32 omap2xxx_prm_read_reset_sources(void)
--
arch/arm/mach-omap2/prm2xxx.c-63- while (p->reg_shift >= 0 && p->std_shift >= 0) {
arch/arm/mach-omap2/prm2xxx.c:64: if (v & (1 << p->reg_shift))
arch/arm/mach-omap2/prm2xxx.c:65: r |= 1 << p->std_shift;
arch/arm/mach-omap2/prm2xxx.c-66- p++;
--
arch/arm/mach-omap2/prm2xxx_3xxx.c=33=int omap2_prm_is_hardreset_asserted(u8 shift, u8 part, s16 prm_mod, u16 offset)
--
arch/arm/mach-omap2/prm2xxx_3xxx.c-35- return omap2_prm_read_mod_bits_shift(prm_mod, OMAP2_RM_RSTCTRL,
arch/arm/mach-omap2/prm2xxx_3xxx.c:36: (1 << shift));
arch/arm/mach-omap2/prm2xxx_3xxx.c-37-}
--
arch/arm/mach-omap2/prm2xxx_3xxx.c=53=int omap2_prm_assert_hardreset(u8 shift, u8 part, s16 prm_mod, u16 offset)
--
arch/arm/mach-omap2/prm2xxx_3xxx.c-56-
arch/arm/mach-omap2/prm2xxx_3xxx.c:57: mask = 1 << shift;
arch/arm/mach-omap2/prm2xxx_3xxx.c-58- omap2_prm_rmw_mod_reg_bits(mask, mask, prm_mod, OMAP2_RM_RSTCTRL);
--
arch/arm/mach-omap2/prm2xxx_3xxx.c=82=int omap2_prm_deassert_hardreset(u8 rst_shift, u8 st_shift, u8 part,
--
arch/arm/mach-omap2/prm2xxx_3xxx.c-87-
arch/arm/mach-omap2/prm2xxx_3xxx.c:88: rst = 1 << rst_shift;
arch/arm/mach-omap2/prm2xxx_3xxx.c:89: st = 1 << st_shift;
arch/arm/mach-omap2/prm2xxx_3xxx.c-90-
--
arch/arm/mach-omap2/prm33xx.c=56=static int am33xx_prm_is_hardreset_asserted(u8 shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prm33xx.c-61- v = am33xx_prm_read_reg(inst, rstctrl_offs);
arch/arm/mach-omap2/prm33xx.c:62: v &= 1 << shift;
arch/arm/mach-omap2/prm33xx.c-63- v >>= shift;
--
arch/arm/mach-omap2/prm33xx.c=82=static int am33xx_prm_assert_hardreset(u8 shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prm33xx.c-84-{
arch/arm/mach-omap2/prm33xx.c:85: u32 mask = 1 << shift;
arch/arm/mach-omap2/prm33xx.c-86-
--
arch/arm/mach-omap2/prm33xx.c=111=static int am33xx_prm_deassert_hardreset(u8 shift, u8 st_shift, u8 part,
--
arch/arm/mach-omap2/prm33xx.c-115- int c;
arch/arm/mach-omap2/prm33xx.c:116: u32 mask = 1 << st_shift;
arch/arm/mach-omap2/prm33xx.c-117-
--
arch/arm/mach-omap2/prm33xx.c-125- /* de-assert the reset control line */
arch/arm/mach-omap2/prm33xx.c:126: mask = 1 << shift;
arch/arm/mach-omap2/prm33xx.c-127-
--
arch/arm/mach-omap2/prm3xxx.c=447=static u32 omap3xxx_prm_read_reset_sources(void)
--
arch/arm/mach-omap2/prm3xxx.c-456- while (p->reg_shift >= 0 && p->std_shift >= 0) {
arch/arm/mach-omap2/prm3xxx.c:457: if (v & (1 << p->reg_shift))
arch/arm/mach-omap2/prm3xxx.c:458: r |= 1 << p->std_shift;
arch/arm/mach-omap2/prm3xxx.c-459- p++;
--
arch/arm/mach-omap2/prm44xx.c=370=static u32 omap44xx_prm_read_reset_sources(void)
--
arch/arm/mach-omap2/prm44xx.c-385- while (p->reg_shift >= 0 && p->std_shift >= 0) {
arch/arm/mach-omap2/prm44xx.c:386: if (v & (1 << p->reg_shift))
arch/arm/mach-omap2/prm44xx.c:387: r |= 1 << p->std_shift;
arch/arm/mach-omap2/prm44xx.c-388- p++;
--
arch/arm/mach-omap2/prminst44xx.c=99=int omap4_prminst_is_hardreset_asserted(u8 shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prminst44xx.c-104- v = omap4_prminst_read_inst_reg(part, inst, rstctrl_offs);
arch/arm/mach-omap2/prminst44xx.c:105: v &= 1 << shift;
arch/arm/mach-omap2/prminst44xx.c-106- v >>= shift;
--
arch/arm/mach-omap2/prminst44xx.c=123=int omap4_prminst_assert_hardreset(u8 shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prminst44xx.c-125-{
arch/arm/mach-omap2/prminst44xx.c:126: u32 mask = 1 << shift;
arch/arm/mach-omap2/prminst44xx.c-127-
--
arch/arm/mach-omap2/prminst44xx.c=152=int omap4_prminst_deassert_hardreset(u8 shift, u8 st_shift, u8 part, s16 inst,
--
arch/arm/mach-omap2/prminst44xx.c-155- int c;
arch/arm/mach-omap2/prminst44xx.c:156: u32 mask = 1 << shift;
arch/arm/mach-omap2/prminst44xx.c:157: u32 st_mask = 1 << st_shift;
arch/arm/mach-omap2/prminst44xx.c-158-
--
arch/arm/mach-omap2/vc.c=116=static int omap_vc_config_channel(struct voltagedomain *voltdm)
--
arch/arm/mach-omap2/vc.c-126-
arch/arm/mach-omap2/vc.c:127: voltdm->rmw(CFG_CHANNEL_MASK << vc->cfg_channel_sa_shift,
arch/arm/mach-omap2/vc.c:128: vc->cfg_channel << vc->cfg_channel_sa_shift,
arch/arm/mach-omap2/vc.c-129- vc->cfg_channel_reg);
--
arch/arm/mach-omap2/vc.c=135=int omap_vc_pre_scale(struct voltagedomain *voltdm,
--
arch/arm/mach-omap2/vc.c-166- vc_cmdval &= ~vc->common->cmd_on_mask;
arch/arm/mach-omap2/vc.c:167: vc_cmdval |= (*target_vsel << vc->common->cmd_on_shift);
arch/arm/mach-omap2/vc.c-168- voltdm->write(vc_cmdval, vc->cmdval_reg);
--
arch/arm/mach-omap2/vc.c=191=int omap_vc_bypass_scale(struct voltagedomain *voltdm,
--
arch/arm/mach-omap2/vc.c-205- vc_bypass_val_reg = vc->common->bypass_val_reg;
arch/arm/mach-omap2/vc.c:206: vc_bypass_value = (target_vsel << vc->common->data_shift) |
arch/arm/mach-omap2/vc.c:207: (vc->volt_reg_addr << vc->common->regaddr_shift) |
arch/arm/mach-omap2/vc.c:208: (vc->i2c_slave_addr << vc->common->slaveaddr_shift);
arch/arm/mach-omap2/vc.c-209-
--
arch/arm/mach-omap2/vc.c=529=static u32 omap4_usec_to_val_scrm(u32 usec, int shift, u32 mask)
--
arch/arm/mach-omap2/vc.c-532-
arch/arm/mach-omap2/vc.c:533: val = omap_usec_to_32k(usec) << shift;
arch/arm/mach-omap2/vc.c-534-
--
arch/arm/mach-omap2/vc.c=805=void __init omap_vc_init_channel(struct voltagedomain *voltdm)
--
arch/arm/mach-omap2/vc.c-862-
arch/arm/mach-omap2/vc.c:863: val = ((on_vsel << vc->common->cmd_on_shift) |
arch/arm/mach-omap2/vc.c:864: (onlp_vsel << vc->common->cmd_onlp_shift) |
arch/arm/mach-omap2/vc.c:865: (ret_vsel << vc->common->cmd_ret_shift) |
arch/arm/mach-omap2/vc.c:866: (off_vsel << vc->common->cmd_off_shift));
arch/arm/mach-omap2/vc.c-867- voltdm->write(val, vc->cmdval_reg);
--
arch/arm/mach-omap2/vp.c=39=void __init omap_vp_init(struct voltagedomain *voltdm)
--
arch/arm/mach-omap2/vp.c-81- /* VSTEPMIN */
arch/arm/mach-omap2/vp.c:82: val = (waittime << vp->common->vstepmin_smpswaittimemin_shift) |
arch/arm/mach-omap2/vp.c:83: (vstepmin << vp->common->vstepmin_stepmin_shift);
arch/arm/mach-omap2/vp.c-84- voltdm->write(val, vp->vstepmin);
--
arch/arm/mach-omap2/vp.c-86- /* VSTEPMAX */
arch/arm/mach-omap2/vp.c:87: val = (vstepmax << vp->common->vstepmax_stepmax_shift) |
arch/arm/mach-omap2/vp.c:88: (waittime << vp->common->vstepmax_smpswaittimemax_shift);
arch/arm/mach-omap2/vp.c-89- voltdm->write(val, vp->vstepmax);
--
arch/arm/mach-omap2/vp.c-91- /* VLIMITTO */
arch/arm/mach-omap2/vp.c:92: val = (vddmax << vp->common->vlimitto_vddmax_shift) |
arch/arm/mach-omap2/vp.c:93: (vddmin << vp->common->vlimitto_vddmin_shift) |
arch/arm/mach-omap2/vp.c:94: (timeout << vp->common->vlimitto_timeout_shift);
arch/arm/mach-omap2/vp.c-95- voltdm->write(val, vp->vlimitto);
--
arch/arm/mach-s3c/gpio-samsung.c=40=static int samsung_gpio_setpull_updown(struct samsung_gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-47- pup = __raw_readl(reg);
arch/arm/mach-s3c/gpio-samsung.c:48: pup &= ~(3 << shift);
arch/arm/mach-s3c/gpio-samsung.c:49: pup |= pull << shift;
arch/arm/mach-s3c/gpio-samsung.c-50- __raw_writel(pup, reg);
--
arch/arm/mach-s3c/gpio-samsung.c=68=static int samsung_gpio_setcfg_2bit(struct samsung_gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-79-
arch/arm/mach-s3c/gpio-samsung.c:80: cfg <<= shift;
arch/arm/mach-s3c/gpio-samsung.c-81- }
--
arch/arm/mach-s3c/gpio-samsung.c-83- con = __raw_readl(reg);
arch/arm/mach-s3c/gpio-samsung.c:84: con &= ~(0x3 << shift);
arch/arm/mach-s3c/gpio-samsung.c-85- con |= cfg;
--
arch/arm/mach-s3c/gpio-samsung.c=131=static int samsung_gpio_setcfg_4bit(struct samsung_gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-142- cfg &= 0xf;
arch/arm/mach-s3c/gpio-samsung.c:143: cfg <<= shift;
arch/arm/mach-s3c/gpio-samsung.c-144- }
--
arch/arm/mach-s3c/gpio-samsung.c-146- con = __raw_readl(reg);
arch/arm/mach-s3c/gpio-samsung.c:147: con &= ~(0xf << shift);
arch/arm/mach-s3c/gpio-samsung.c-148- con |= cfg;
--
arch/arm/mach-s3c/gpio-samsung.c=307=static int samsung_gpiolib_4bit_input(struct gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-315- if (ourchip->bitmap_gpio_int & BIT(offset))
arch/arm/mach-s3c/gpio-samsung.c:316: con |= 0xf << con_4bit_shift(offset);
arch/arm/mach-s3c/gpio-samsung.c-317- else
arch/arm/mach-s3c/gpio-samsung.c:318: con &= ~(0xf << con_4bit_shift(offset));
arch/arm/mach-s3c/gpio-samsung.c-319- __raw_writel(con, base + GPIOCON_OFF);
--
arch/arm/mach-s3c/gpio-samsung.c=326=static int samsung_gpiolib_4bit_output(struct gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-334- con = __raw_readl(base + GPIOCON_OFF);
arch/arm/mach-s3c/gpio-samsung.c:335: con &= ~(0xf << con_4bit_shift(offset));
arch/arm/mach-s3c/gpio-samsung.c:336: con |= 0x1 << con_4bit_shift(offset);
arch/arm/mach-s3c/gpio-samsung.c-337-
--
arch/arm/mach-s3c/gpio-samsung.c=376=static int samsung_gpiolib_4bit2_input(struct gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-389- con = __raw_readl(regcon);
arch/arm/mach-s3c/gpio-samsung.c:390: con &= ~(0xf << con_4bit_shift(offset));
arch/arm/mach-s3c/gpio-samsung.c-391- __raw_writel(con, regcon);
--
arch/arm/mach-s3c/gpio-samsung.c=398=static int samsung_gpiolib_4bit2_output(struct gpio_chip *chip,
--
arch/arm/mach-s3c/gpio-samsung.c-413- con = __raw_readl(regcon);
arch/arm/mach-s3c/gpio-samsung.c:414: con &= ~(0xf << con_4bit_shift(con_offset));
arch/arm/mach-s3c/gpio-samsung.c:415: con |= 0x1 << con_4bit_shift(con_offset);
arch/arm/mach-s3c/gpio-samsung.c-416-
--
arch/arm/mach-s3c/s3c64xx.c=269=static int s3c_irq_eint_set_type(struct irq_data *data, unsigned int type)
--
arch/arm/mach-s3c/s3c64xx.c-319- shift = ((offs - 16) / 2) * 4;
arch/arm/mach-s3c/s3c64xx.c:320: mask = 0x7 << shift;
arch/arm/mach-s3c/s3c64xx.c-321-
--
arch/arm/mach-s3c/s3c64xx.c-323- ctrl &= ~mask;
arch/arm/mach-s3c/s3c64xx.c:324: ctrl |= newvalue << shift;
arch/arm/mach-s3c/s3c64xx.c-325- __raw_writel(ctrl, reg);
--
arch/arm/mm/alignment.c=801=do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
--
arch/arm/mm/alignment.c-890- case SHIFT_LSL:
arch/arm/mm/alignment.c:891: offset.un <<= shiftval;
arch/arm/mm/alignment.c-892- break;
--
arch/arm/mm/alignment.c-908- offset.un = offset.un >> shiftval |
arch/arm/mm/alignment.c:909: offset.un << (32 - shiftval);
arch/arm/mm/alignment.c-910- break;
--
arch/arm/nwfpe/softfloat.c=154=static void
--
arch/arm/nwfpe/softfloat.c-159- shiftCount = countLeadingZeros32( aSig ) - 8;
arch/arm/nwfpe/softfloat.c:160: *zSigPtr = aSig<<shiftCount;
arch/arm/nwfpe/softfloat.c-161- *zExpPtr = 1 - shiftCount;
--
arch/arm/nwfpe/softfloat.c=279=static float32
--
arch/arm/nwfpe/softfloat.c-284- shiftCount = countLeadingZeros32( zSig ) - 1;
arch/arm/nwfpe/softfloat.c:285: return roundAndPackFloat32( roundData, zSign, zExp - shiftCount, zSig<<shiftCount );
arch/arm/nwfpe/softfloat.c-286-
--
arch/arm/nwfpe/softfloat.c=335=static void
--
arch/arm/nwfpe/softfloat.c-340- shiftCount = countLeadingZeros64( aSig ) - 11;
arch/arm/nwfpe/softfloat.c:341: *zSigPtr = aSig<<shiftCount;
arch/arm/nwfpe/softfloat.c-342- *zExpPtr = 1 - shiftCount;
--
arch/arm/nwfpe/softfloat.c=452=static float64
--
arch/arm/nwfpe/softfloat.c-457- shiftCount = countLeadingZeros64( zSig ) - 1;
arch/arm/nwfpe/softfloat.c:458: return roundAndPackFloat64( roundData, zSign, zExp - shiftCount, zSig<<shiftCount );
arch/arm/nwfpe/softfloat.c-459-
--
arch/arm/nwfpe/softfloat.c=511=static void
--
arch/arm/nwfpe/softfloat.c-516- shiftCount = countLeadingZeros64( aSig );
arch/arm/nwfpe/softfloat.c:517: *zSigPtr = aSig<<shiftCount;
arch/arm/nwfpe/softfloat.c-518- *zExpPtr = 1 - shiftCount;
--
arch/arm/nwfpe/softfloat.c=780=float64 int32_to_float64( int32 a )
--
arch/arm/nwfpe/softfloat.c-791- zSig = absA;
arch/arm/nwfpe/softfloat.c:792: return packFloat64( aSign, 0x432 - shiftCount, zSig<<shiftCount );
arch/arm/nwfpe/softfloat.c-793-
--
arch/arm/nwfpe/softfloat.c=806=floatx80 int32_to_floatx80( int32 a )
--
arch/arm/nwfpe/softfloat.c-817- zSig = absA;
arch/arm/nwfpe/softfloat.c:818: return packFloatx80( zSign, 0x403E - shiftCount, zSig<<shiftCount );
arch/arm/nwfpe/softfloat.c-819-
--
arch/arm/nwfpe/softfloat.c=866=int32 float32_to_int32_round_to_zero( float32 a )
--
arch/arm/nwfpe/softfloat.c-888- z = aSig>>( - shiftCount );
arch/arm/nwfpe/softfloat.c:889: if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) {
arch/arm/nwfpe/softfloat.c-890- float_raise( float_flag_inexact );
--
arch/arm/nwfpe/softfloat.c=1680=int32 float64_to_int32_round_to_zero( float64 a )
--
arch/arm/nwfpe/softfloat.c-1708- }
arch/arm/nwfpe/softfloat.c:1709: if ( ( aSig<<shiftCount ) != savedASig ) {
arch/arm/nwfpe/softfloat.c-1710- float_raise( float_flag_inexact );
--
arch/arm/nwfpe/softfloat.c=1753=int32 float64_to_uint32_round_to_zero( float64 a )
--
arch/arm/nwfpe/softfloat.c-1781- }
arch/arm/nwfpe/softfloat.c:1782: if ( ( aSig<<shiftCount ) != savedASig ) {
arch/arm/nwfpe/softfloat.c-1783- float_raise( float_flag_inexact );
--
arch/arm/nwfpe/softfloat.c=2569=int32 floatx80_to_int32_round_to_zero( floatx80 a )
--
arch/arm/nwfpe/softfloat.c-2596- }
arch/arm/nwfpe/softfloat.c:2597: if ( ( aSig<<shiftCount ) != savedASig ) {
arch/arm/nwfpe/softfloat.c-2598- float_raise( float_flag_inexact );
--
arch/arm/plat-orion/mpp.c=27=void __init orion_mpp_conf(unsigned int *mpp_list, unsigned int variant_mask,
--
arch/arm/plat-orion/mpp.c-63- shift = (num & 7) << 2;
arch/arm/plat-orion/mpp.c:64: mpp_ctrl[num / 8] &= ~(0xf << shift);
arch/arm/plat-orion/mpp.c:65: mpp_ctrl[num / 8] |= sel << shift;
arch/arm/plat-orion/mpp.c-66-
--
arch/arm/vfp/vfp.h=9=static inline u32 vfp_shiftright32jamming(u32 val, unsigned int shift)
--
arch/arm/vfp/vfp.h-12- if (shift < 32)
arch/arm/vfp/vfp.h:13: val = val >> shift | ((val << (32 - shift)) != 0);
arch/arm/vfp/vfp.h-14- else
--
arch/arm/vfp/vfp.h=20=static inline u64 vfp_shiftright64jamming(u64 val, unsigned int shift)
--
arch/arm/vfp/vfp.h-23- if (shift < 64)
arch/arm/vfp/vfp.h:24: val = val >> shift | ((val << (64 - shift)) != 0);
arch/arm/vfp/vfp.h-25- else
--
arch/arm/vfp/vfpdouble.c=70=u32 vfp_double_normaliseround(int dd, struct vfp_double *vd, u32 fpscr, u32 exceptions, const char *func)
--
arch/arm/vfp/vfpdouble.c-99- exponent -= shift;
arch/arm/vfp/vfpdouble.c:100: significand <<= shift;
arch/arm/vfp/vfpdouble.c-101- }
--
arch/arm/vfp/vfpdouble.c=506=static u32 vfp_double_ftoui(int sd, int unused, int dm, u32 fpscr)
--
arch/arm/vfp/vfpdouble.c-534- */
arch/arm/vfp/vfpdouble.c:535: d = (vdm.significand << 1) >> shift;
arch/arm/vfp/vfpdouble.c:536: rem = vdm.significand << (65 - shift);
arch/arm/vfp/vfpdouble.c-537-
--
arch/arm/vfp/vfpdouble.c=585=static u32 vfp_double_ftosi(int sd, int unused, int dm, u32 fpscr)
--
arch/arm/vfp/vfpdouble.c-613-
arch/arm/vfp/vfpdouble.c:614: d = (vdm.significand << 1) >> shift;
arch/arm/vfp/vfpdouble.c:615: rem = vdm.significand << (65 - shift);
arch/arm/vfp/vfpdouble.c-616-
--
arch/arm/vfp/vfpsingle.c=72=u32 vfp_single_normaliseround(int sd, struct vfp_single *vs, u32 fpscr, u32 exceptions, const char *func)
--
arch/arm/vfp/vfpsingle.c-104- exponent -= shift;
arch/arm/vfp/vfpsingle.c:105: significand <<= shift;
arch/arm/vfp/vfpsingle.c-106- }
--
arch/arm/vfp/vfpsingle.c=547=static u32 vfp_single_ftoui(int sd, int unused, s32 m, u32 fpscr)
--
arch/arm/vfp/vfpsingle.c-576- */
arch/arm/vfp/vfpsingle.c:577: d = (vsm.significand << 1) >> shift;
arch/arm/vfp/vfpsingle.c:578: rem = vsm.significand << (33 - shift);
arch/arm/vfp/vfpsingle.c-579-
--
arch/arm/vfp/vfpsingle.c=627=static u32 vfp_single_ftosi(int sd, int unused, s32 m, u32 fpscr)
--
arch/arm/vfp/vfpsingle.c-659- /* 2^0 <= m <= 2^31-2^7 */
arch/arm/vfp/vfpsingle.c:660: d = (vsm.significand << 1) >> shift;
arch/arm/vfp/vfpsingle.c:661: rem = vsm.significand << (33 - shift);
arch/arm/vfp/vfpsingle.c-662-
--
arch/arm64/include/asm/kvm_mmu.h=143=extern u32 __hyp_va_bits;
--
arch/arm64/include/asm/kvm_mmu.h-151-#define kvm_phys_shift(mmu) VTCR_EL2_IPA((mmu)->vtcr)
]
]
|
| 59/4 |
2026/05/21 22:56 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 48356
output: 15
thoughts: 16
Thoughts: Here's my thought process, summarized as you requested:
**Navigating the Filesystem for a Specific Term**
Okay, so I need to find something, and the term I'm looking for is "shift." My first instinct is to think about where this kind of functionality might reside within the kernel's filesystem structure. Given my experience, the filesystem area is a good starting point. I recall that the BeFS filesystem has specific code, and the path `/fs/befs/` seems like the likely place for the specific code that I am looking for. Let's start the search there! Iβll start by digging around in `/fs/befs/` and see what I can turn up.
|
| 60/4 |
2026/05/21 22:56 |
tool |
grepper |
0m
Args:
Results: map[Output:
Full output is too long, showing 500 out of 190050 lines.
Use more precise expression if possible.
[Documentation/ABI/obsolete/sysfs-bus-iio=79=Description:
--
Documentation/ABI/obsolete/sysfs-bus-iio-81- and hence the form in which it is read from user-space.
Documentation/ABI/obsolete/sysfs-bus-iio:82: Form is [be|le]:[s|u]bits/storagebits[>>shift].
Documentation/ABI/obsolete/sysfs-bus-iio-83- be or le specifies big or little endian. s or u specifies if
--
Documentation/ABI/obsolete/sysfs-bus-iio-85- of data and storagebits is the space (after padding) that it
Documentation/ABI/obsolete/sysfs-bus-iio:86: occupies in the buffer. shift if specified, is the shift that
Documentation/ABI/obsolete/sysfs-bus-iio-87- needs to be applied prior to masking out unused bits. Some
--
Documentation/ABI/obsolete/sysfs-bus-iio-94- signed 48 bit integer stored in a 64 bit location aligned to
Documentation/ABI/obsolete/sysfs-bus-iio:95: a 64 bit boundary. To obtain the clean value, shift right 2
Documentation/ABI/obsolete/sysfs-bus-iio-96- and apply a mask to zero the top 16 bits of the result.
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-isku=139=Contact: Stefan Achatz <erazor_de@users.sourceforge.net>
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-isku:140:Description: When written, this file lets one trigger easyshift functionality
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-isku-141- from the host.
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus=27=Description: When read, this file returns the raw integer version number of the
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus-29- further usage in other programs. To receive the real version
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus:30: number the decimal point has to be shifted 2 positions to the
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus-31- left. E.g. a returned value of 121 means 1.21
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-kovaplus=45=Description: When read, this file returns the raw integer version number of the
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-kovaplus-47- further usage in other programs. To receive the real version
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-kovaplus:48: number the decimal point has to be shifted 2 positions to the
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-kovaplus-49- left. E.g. a returned value of 121 means 1.21
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-pyra=34=Description: When read, this file returns the raw integer version number of the
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-pyra-36- further usage in other programs. To receive the real version
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-pyra:37: number the decimal point has to be shifted 2 positions to the
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-pyra-38- left. E.g. a returned value of 138 means 1.38
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-ryos=132=Contact: Stefan Achatz <erazor_de@users.sourceforge.net>
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-ryos:133:Description: When written, this file lets one trigger easyshift functionality
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-ryos-134- from the host.
--
Documentation/ABI/stable/sysfs-driver-speakup=139=Contact: speakup@linux-speakup.org
Documentation/ABI/stable/sysfs-driver-speakup:140:Description: If set to one, speakup speaks shift, alt and control when those
Documentation/ABI/stable/sysfs-driver-speakup:141: keys are pressed. If say_control is set to zero, shift, ctrl,
Documentation/ABI/stable/sysfs-driver-speakup-142- and alt are not spoken when they are pressed.
--
Documentation/ABI/testing/debugfs-moxtet=4=Contact: Marek BehΓΊn <kabel@kernel.org>
Documentation/ABI/testing/debugfs-moxtet:5:Description: (Read) Read input from the shift registers, in hexadecimal.
Documentation/ABI/testing/debugfs-moxtet-6- Returns N+1 bytes, where N is the number of Moxtet connected
--
Documentation/ABI/testing/debugfs-moxtet=22=Contact: Marek BehΓΊn <kabel@kernel.org>
Documentation/ABI/testing/debugfs-moxtet:23:Description: (RW) Read last written value to the shift registers, in
Documentation/ABI/testing/debugfs-moxtet:24: hexadecimal, or write values to the shift registers, also
Documentation/ABI/testing/debugfs-moxtet-25- in hexadecimal.
--
Documentation/ABI/testing/debugfs-moxtet-32- 01 01 was last written, or is to be written, to the
Documentation/ABI/testing/debugfs-moxtet:33: first module's shift register
Documentation/ABI/testing/debugfs-moxtet-34- 02 the same for second module
--
Documentation/ABI/testing/sysfs-bus-iio=1510=Description:
--
Documentation/ABI/testing/sysfs-bus-iio-1512- and hence the form in which it is read from user-space.
Documentation/ABI/testing/sysfs-bus-iio:1513: Form is [be|le]:[s|u]bits/storagebits[>>shift].
Documentation/ABI/testing/sysfs-bus-iio-1514- be or le specifies big or little endian. s or u specifies if
--
Documentation/ABI/testing/sysfs-bus-iio-1516- of data and storagebits is the space (after padding) that it
Documentation/ABI/testing/sysfs-bus-iio:1517: occupies in the buffer. shift if specified, is the shift that
Documentation/ABI/testing/sysfs-bus-iio-1518- needs to be applied prior to masking out unused bits. Some
--
Documentation/ABI/testing/sysfs-bus-iio-1525- signed 48 bit integer stored in a 64 bit location aligned to
Documentation/ABI/testing/sysfs-bus-iio:1526: a 64 bit boundary. To obtain the clean value, shift right 2
Documentation/ABI/testing/sysfs-bus-iio-1527- and apply a mask to zero the top 16 bits of the result.
--
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1013=4=Description:
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1013:5: Read/write unscaled value for the Local Oscillatior path quadrature I phase shift.
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1013-6-
--
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1013=10=Description:
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1013:11: Read/write unscaled value for the Local Oscillatior path quadrature Q phase shift.
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1013-12-
--
Documentation/ABI/testing/sysfs-bus-siox=17=Description:
--
Documentation/ABI/testing/sysfs-bus-siox-23- to a driver (similar to the platform bus). <inbytes> and <outbytes> define
Documentation/ABI/testing/sysfs-bus-siox:24: the length of the input and output shift register in bytes respectively.
Documentation/ABI/testing/sysfs-bus-siox-25-
--
Documentation/ABI/testing/sysfs-driver-hid-prodikeys=24=Description:
Documentation/ABI/testing/sysfs-driver-hid-prodikeys:25: Controls the octave shift modifier in the pc-midi driver.
Documentation/ABI/testing/sysfs-driver-hid-prodikeys:26: The octave can be shifted via software up/down 2 octaves.
Documentation/ABI/testing/sysfs-driver-hid-prodikeys:27: 0 means the no ocatve shift.
Documentation/ABI/testing/sysfs-driver-hid-prodikeys-28- Range: -2..2 (minus 2 to plus 2)
--
Documentation/ABI/testing/sysfs-driver-hid-roccat-kone=36=Description: When read, this file returns the raw integer version number of the
--
Documentation/ABI/testing/sysfs-driver-hid-roccat-kone-38- further usage in other programs. To receive the real version
Documentation/ABI/testing/sysfs-driver-hid-roccat-kone:39: number the decimal point has to be shifted 2 positions to the
Documentation/ABI/testing/sysfs-driver-hid-roccat-kone-40- left. E.g. a returned value of 138 means 1.38
--
Documentation/ABI/testing/sysfs-firmware-opal-psr=4=Description: Power-Shift-Ratio directory for Powernv P9 servers
--
Documentation/ABI/testing/sysfs-firmware-opal-psr-6- Power-Shift-Ratio allows to provide hints the firmware
Documentation/ABI/testing/sysfs-firmware-opal-psr:7: to shift/throttle power between different entities in
Documentation/ABI/testing/sysfs-firmware-opal-psr-8- the system. Each attribute in this directory indicates
--
Documentation/ABI/testing/sysfs-tty=129=Description:
--
Documentation/ABI/testing/sysfs-tty-134-
Documentation/ABI/testing/sysfs-tty:135:What: /sys/class/tty/ttyS<x>/iomem_reg_shift
Documentation/ABI/testing/sysfs-tty-136-Date: October 2012
--
Documentation/ABI/testing/sysfs-tty=138=Description:
Documentation/ABI/testing/sysfs-tty:139: Show the register shift indicating the spacing to be used
Documentation/ABI/testing/sysfs-tty-140- for accesses on this iomem address.
--
Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst=324=sequence number is already recorded, blocks on ``->exp_wq[1]``.
--
Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst-337-| whether or not a grace period is currently in progress. It is |
Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst:338:| therefore necessary to shift the sequence number right one bit |
Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst-339-| position to obtain the number of the grace period. This results in |
--
Documentation/admin-guide/acpi/ssdt-overlays.rst=127=variable with the content from a given file::
--
Documentation/admin-guide/acpi/ssdt-overlays.rst-132- case "$1" in
Documentation/admin-guide/acpi/ssdt-overlays.rst:133: "-f") filename="$2"; shift;;
Documentation/admin-guide/acpi/ssdt-overlays.rst:134: "-g") guid="$2"; shift;;
Documentation/admin-guide/acpi/ssdt-overlays.rst-135- *) name="$1";;
Documentation/admin-guide/acpi/ssdt-overlays.rst-136- esac
Documentation/admin-guide/acpi/ssdt-overlays.rst:137: shift
Documentation/admin-guide/acpi/ssdt-overlays.rst-138- done
--
Documentation/admin-guide/java.rst=69=Javawrapper shell script:
--
Documentation/admin-guide/java.rst-156-
Documentation/admin-guide/java.rst:157: shift
Documentation/admin-guide/java.rst-158- /usr/bin/java $FQCLASS "$@"
--
Documentation/admin-guide/kdump/gdbmacros.txt=289=define dmesg
--
Documentation/admin-guide/kdump/gdbmacros.txt-293- set var $desc_sv_bits = sizeof(long) * 8
Documentation/admin-guide/kdump/gdbmacros.txt:294: set var $desc_flags_shift = $desc_sv_bits - 2
Documentation/admin-guide/kdump/gdbmacros.txt:295: set var $desc_flags_mask = 3 << $desc_flags_shift
Documentation/admin-guide/kdump/gdbmacros.txt-296- set var $id_mask = ~$desc_flags_mask
--
Documentation/admin-guide/kdump/gdbmacros.txt-308- # skip non-committed record
Documentation/admin-guide/kdump/gdbmacros.txt:309: set var $state = 3 & ($desc->state_var.counter >> $desc_flags_shift)
Documentation/admin-guide/kdump/gdbmacros.txt-310- if ($state == $desc_committed || $state == $desc_finalized)
--
Documentation/admin-guide/kdump/vmcoreinfo.rst=77=Physical addresses are translated to struct pages by treating them as
Documentation/admin-guide/kdump/vmcoreinfo.rst:78:an index into the mem_map array. Right-shifting a physical address
Documentation/admin-guide/kdump/vmcoreinfo.rst-79-PAGE_SHIFT bits converts it into a page frame number which is an index
--
Documentation/admin-guide/kdump/vmcoreinfo.rst=540=when computing the count of vmemmap regions.
Documentation/admin-guide/kdump/vmcoreinfo.rst-541-
Documentation/admin-guide/kdump/vmcoreinfo.rst:542:mmu_psize_def|(mmu_psize_def, shift)
Documentation/admin-guide/kdump/vmcoreinfo.rst-543-------------------------------------
--
Documentation/admin-guide/kernel-parameters.txt=97=Kernel parameters
--
Documentation/admin-guide/kernel-parameters.txt-5770- rcutree.rcu_divisor= [KNL]
Documentation/admin-guide/kernel-parameters.txt:5771: Set the shift-right count to use to compute
Documentation/admin-guide/kernel-parameters.txt-5772- the callback-invocation batch limit bl from
--
Documentation/admin-guide/kernel-parameters.txt-6795-
Documentation/admin-guide/kernel-parameters.txt:6796: sched_thermal_decay_shift=
Documentation/admin-guide/kernel-parameters.txt-6797- [Deprecated]
Documentation/admin-guide/kernel-parameters.txt:6798: [KNL, SMP] Set a decay shift for scheduler thermal
Documentation/admin-guide/kernel-parameters.txt-6799- pressure signal. Thermal pressure signal follows the
--
Documentation/admin-guide/kernel-parameters.txt-6801- signals(usually 32 ms but configurable). Setting
Documentation/admin-guide/kernel-parameters.txt:6802: sched_thermal_decay_shift will left shift the decay
Documentation/admin-guide/kernel-parameters.txt:6803: period for the thermal pressure signal by the shift
Documentation/admin-guide/kernel-parameters.txt-6804- value.
Documentation/admin-guide/kernel-parameters.txt-6805- i.e. with the default pelt decay period of 32 ms
Documentation/admin-guide/kernel-parameters.txt:6806: sched_thermal_decay_shift thermal pressure decay pr
Documentation/admin-guide/kernel-parameters.txt-6807- 1 64 ms
--
Documentation/admin-guide/kernel-per-CPU-kthreads.rst=318=To reduce its OS jitter, do at least one of the following:
--
Documentation/admin-guide/kernel-per-CPU-kthreads.rst-324- note that this will not eliminate OS jitter, but will instead
Documentation/admin-guide/kernel-per-CPU-kthreads.rst:325: shift it to RCU_SOFTIRQ.
--
Documentation/admin-guide/md.rst=462=If bitmap_type is llbitmap, then the md device will also contain:
--
Documentation/admin-guide/md.rst-468- llbitmap/metadata
Documentation/admin-guide/md.rst:469: This is read-only, show bitmap metadata, include chunksize, chunkshift,
Documentation/admin-guide/md.rst-470- chunks, offset and daemon_sleep.
--
Documentation/admin-guide/media/cec.rst=230=adapters can support this. An example is the Odroid-U3 SBC that has a
Documentation/admin-guide/media/cec.rst:231:level-shifter that is powered off when the HPD signal is low, thus
Documentation/admin-guide/media/cec.rst-232-blocking the CEC pin. Even though the SoC can use CEC without a HPD,
Documentation/admin-guide/media/cec.rst:233:the level-shifter will prevent this from functioning.
Documentation/admin-guide/media/cec.rst-234-
--
Documentation/admin-guide/media/cec.rst=328=If you want to monitor the HPD and/or 5V lines as well, then you need one of
Documentation/admin-guide/media/cec.rst:329:these 5V to 3.3V level shifters:
Documentation/admin-guide/media/cec.rst-330-
--
Documentation/admin-guide/media/cec.rst=340=GPIO 6 and GPIO 7. The optional HPD pin of the HDMI connector should
Documentation/admin-guide/media/cec.rst:341:be connected via the level shifter to these pins: GPIO 23 and GPIO 12.
Documentation/admin-guide/media/cec.rst-342-The optional 5V pin of the HDMI connector should be connected via the
Documentation/admin-guide/media/cec.rst:343:level shifter to these pins: GPIO 25 and GPIO 22. Monitoring the HPD and
Documentation/admin-guide/media/cec.rst-344-5V lines is not necessary, but it is helpful.
--
Documentation/admin-guide/media/vivid.rst=680=The Test Pattern Controls are all specific to video capture.
--
Documentation/admin-guide/media/vivid.rst-737- Receivers that will just keep skipping Video Guard Band values will
Documentation/admin-guide/media/vivid.rst:738: now fail and either loose sync or these video lines will shift.
Documentation/admin-guide/media/vivid.rst-739-
--
Documentation/admin-guide/mm/pagemap.rst=221=into the file), or if the size of the read is not a multiple of 8 bytes.
Documentation/admin-guide/mm/pagemap.rst-222-
Documentation/admin-guide/mm/pagemap.rst:223:Before Linux 3.11 pagemap bits 55-60 were used for "page-shift" (which is
Documentation/admin-guide/mm/pagemap.rst-224-always 12 at most architectures). Since Linux 3.11 their meaning changes
--
Documentation/admin-guide/pm/amd-pstate.rst=329=When dynamic EPP is enabled, writes to energy_performance_preference are blocked
Documentation/admin-guide/pm/amd-pstate.rst:330:even when EPP feature is enabled by platform firmware. Lower epp values shift the bias
Documentation/admin-guide/pm/amd-pstate.rst:331:towards improved performance while a higher epp value shifts the bias towards
Documentation/admin-guide/pm/amd-pstate.rst-332-power-savings. The exact impact can change from one platform to the other.
--
Documentation/admin-guide/spkguide.txt=187=as the speakup key. Instead of pressing and releasing this key, as you
Documentation/admin-guide/spkguide.txt:188:do under DOS or Windows, you hold it like a shift key, and press other
Documentation/admin-guide/spkguide.txt-189-keys in combination with it. For example, repeatedly holding keypad
--
Documentation/admin-guide/spkguide.txt=244=beyond the scope of this manual. To use the caps lock for its normal
Documentation/admin-guide/spkguide.txt:245:purpose, hold the shift key while toggling the caps lock on and off. We
Documentation/admin-guide/spkguide.txt-246-should note here, that holding the caps lock key and pressing the z key
--
Documentation/admin-guide/spkguide.txt=280=spk key_f8 = edit_repeat
Documentation/admin-guide/spkguide.txt:281:shift spk key_f9 = edit_exnum
Documentation/admin-guide/spkguide.txt-282- key_kp7 = say_prev_line
--
Documentation/admin-guide/spkguide.txt=325=spk key_minus = speakup_parked
Documentation/admin-guide/spkguide.txt:326:shift spk key_minus = say_char_num
Documentation/admin-guide/spkguide.txt-327-spk key_j = say_prev_word
--
Documentation/admin-guide/spkguide.txt=349=spk key_8 = speakup_paste
Documentation/admin-guide/spkguide.txt:350:shift spk key_m = say_first_char
Documentation/admin-guide/spkguide.txt-351- ctrl spk key_semicolon = say_last_char
--
Documentation/admin-guide/sysctl/kernel.rst=89=This gives the bootloader type number as indicated by the bootloader,
Documentation/admin-guide/sysctl/kernel.rst:90:shifted left by 4, and OR'd with the low four bits of the bootloader
Documentation/admin-guide/sysctl/kernel.rst-91-version. The reason for this encoding is that this used to match the
--
Documentation/admin-guide/sysctl/net.rst=537=The max value is set to CONN_OVERLOAD_LIMIT, and the default and min values
Documentation/admin-guide/sysctl/net.rst:538:are scaled (shifted) versions of that same value. Note that the min value
Documentation/admin-guide/sysctl/net.rst-539-is not at this point in time used in any meaningful way, but the triplet is
--
Documentation/admin-guide/sysrq.rst=223=Sometimes SysRq seems to get 'stuck' after using it, what can I do?
--
Documentation/admin-guide/sysrq.rst-225-
Documentation/admin-guide/sysrq.rst:226:When this happens, try tapping shift, alt and control on both sides of the
Documentation/admin-guide/sysrq.rst-227-keyboard, and hitting an invalid sysrq sequence again. (i.e., something like
--
Documentation/arch/arm/nwfpe/todo.rst=32=Coordinate Rotation Digital Computer, and is a method of computing
Documentation/arch/arm/nwfpe/todo.rst:33:transcendental functions using mostly shifts and adds and a few
Documentation/arch/arm/nwfpe/todo.rst:34:multiplications and divisions. The ARM excels at shifts and adds,
Documentation/arch/arm/nwfpe/todo.rst-35-so such a method could be promising, but requires more research to
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk=30=function find_length(f)
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-47-
Documentation/arch/arm/samsung/clksrc-change-registers.awk:48:function find_shift(s)
Documentation/arch/arm/samsung/clksrc-change-registers.awk-49-{
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-51- if (id <= 0) {
Documentation/arch/arm/samsung/clksrc-change-registers.awk:52: printf "cannot find shift " s "\n" > "/dev/stderr"
Documentation/arch/arm/samsung/clksrc-change-registers.awk-53- exit
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk=60=BEGIN {
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-76- dmask[name,0] = find_length(fields[1])
Documentation/arch/arm/samsung/clksrc-change-registers.awk:77: dmask[name,1] = find_shift(fields[1])
Documentation/arch/arm/samsung/clksrc-change-registers.awk-78- if (0)
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-87-/clksrc_clk.*=.*{/ {
Documentation/arch/arm/samsung/clksrc-change-registers.awk:88: shift=""
Documentation/arch/arm/samsung/clksrc-change-registers.awk-89- mask=""
Documentation/arch/arm/samsung/clksrc-change-registers.awk:90: divshift=""
Documentation/arch/arm/samsung/clksrc-change-registers.awk-91- reg_div=""
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-102-
Documentation/arch/arm/samsung/clksrc-change-registers.awk:103: if (line ~ /\.shift/) {
Documentation/arch/arm/samsung/clksrc-change-registers.awk:104: shift = extract_value(line)
Documentation/arch/arm/samsung/clksrc-change-registers.awk-105- } else if (line ~ /\.mask/) {
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-110- reg_src = extract_value(line)
Documentation/arch/arm/samsung/clksrc-change-registers.awk:111: } else if (line ~ /\.divider_shift/) {
Documentation/arch/arm/samsung/clksrc-change-registers.awk:112: divshift = extract_value(line)
Documentation/arch/arm/samsung/clksrc-change-registers.awk-113- } else if (line ~ /{/) {
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-120- if (0) {
Documentation/arch/arm/samsung/clksrc-change-registers.awk:121: printf "shift '" shift "' ='" dmask[shift,0] "'\n" > "/dev/stderr"
Documentation/arch/arm/samsung/clksrc-change-registers.awk-122- printf "mask '" mask "'\n" > "/dev/stderr"
Documentation/arch/arm/samsung/clksrc-change-registers.awk:123: printf "dshft '" divshift "'\n" > "/dev/stderr"
Documentation/arch/arm/samsung/clksrc-change-registers.awk-124- printf "rdiv '" reg_div "'\n" > "/dev/stderr"
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-133- printf "/* rdiv " reg_div " */\n"
Documentation/arch/arm/samsung/clksrc-change-registers.awk:134: printf "/* shift " shift " */\n"
Documentation/arch/arm/samsung/clksrc-change-registers.awk-135- printf "/* mask " mask " */\n"
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-141- printf ".reg = " reg_div ", "
Documentation/arch/arm/samsung/clksrc-change-registers.awk:142: printf ".shift = " dmask[generated,1] ", "
Documentation/arch/arm/samsung/clksrc-change-registers.awk-143- printf ".size = " dmask[generated,0] ", "
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-148- printf ".reg = " reg_src ", "
Documentation/arch/arm/samsung/clksrc-change-registers.awk:149: printf ".shift = " dmask[mask,1] ", "
Documentation/arch/arm/samsung/clksrc-change-registers.awk-150- printf ".size = " dmask[mask,0] ", "
--
Documentation/arch/loongarch/introduction.rst=232=For brevity, only instruction names (mnemonics) are listed here; please see the
--
Documentation/arch/loongarch/introduction.rst-245-
Documentation/arch/loongarch/introduction.rst:246:2. Bit-shift Instructions::
Documentation/arch/loongarch/introduction.rst-247-
--
Documentation/arch/m68k/buddha-driver.rst=135=to 1 by definition.
Documentation/arch/m68k/buddha-driver.rst-136-
Documentation/arch/m68k/buddha-driver.rst:137:The values in this table have to be shifted 5 bits to the
Documentation/arch/m68k/buddha-driver.rst-138-left and or'd with $1f (this sets the lower 5 bits).
--
Documentation/arch/m68k/kernel-options.rst=513=panning or blanking.
--
Documentation/arch/m68k/kernel-options.rst-517-
Documentation/arch/m68k/kernel-options.rst:518:The external pixel clock attached to the Falcon VIDEL shifter. This
Documentation/arch/m68k/kernel-options.rst-519-currently works only with the ScreenWonder!
--
Documentation/arch/x86/amd-memory-encryption.rst=225=an RMP segment::
--
Documentation/arch/x86/amd-memory-encryption.rst-231- Bits[51:20] segment physical address
Documentation/arch/x86/amd-memory-encryption.rst:232: This address is left shift 20-bits (or just masked when
Documentation/arch/x86/amd-memory-encryption.rst-233- read) to form the physical address of the segment (1MB
--
Documentation/arch/x86/topology.rst=152=follows:
--
Documentation/arch/x86/topology.rst-169- The kernel uses the `CoreMaskWidth` from `EAX[4:0]` to discover the
Documentation/arch/x86/topology.rst:170: number of bits that need to be right-shifted from `ExtendedLocalApicId`
Documentation/arch/x86/topology.rst-171- in `EDX[31:0]` in order to get a unique Topology ID for the topology
--
Documentation/arch/x86/topology.rst-193- The kernel uses the `CoreMaskWidth` from `EAX[4:0]` to discover the
Documentation/arch/x86/topology.rst:194: number of bits that need to be right-shifted from the `ExtendedLocalApicId`
Documentation/arch/x86/topology.rst-195- in `EDX[31:0]` to get a unique Topology ID for that topology level. CPUs
--
Documentation/arch/x86/topology.rst-209-
Documentation/arch/x86/topology.rst:210: The shifts from the APIC ID for the Socket ID is calculated from the
Documentation/arch/x86/topology.rst-211- `ApicIdSize` field in `ECX[15:12]` if it is non-zero.
Documentation/arch/x86/topology.rst-212-
Documentation/arch/x86/topology.rst:213: If `ApicIdSize` is reported to be zero, the shift is calculated as the
Documentation/arch/x86/topology.rst-214- order of the `number of threads` calculated from `NC` field in
--
Documentation/arch/x86/topology.rst-237- On processors of Family 0x17 and above that do not support CPUID leaf
Documentation/arch/x86/topology.rst:238: 0x80000026 or CPUID leaf 0xB, the shifts from the APIC ID for the Core
Documentation/arch/x86/topology.rst-239- ID is calculated using the order of `number of threads per core`
--
Documentation/arch/x86/topology.rst-275- The kernel uses the value from `EAX[4:0]` to discover the number of
Documentation/arch/x86/topology.rst:276: bits that need to be right shifted from the `x2APIC ID` in `EDX[31:0]`
Documentation/arch/x86/topology.rst-277- to get a unique Topology ID for the topology level. CPUs with the same
--
Documentation/arch/x86/topology.rst-301- On Intel processors that support neither CPUID leaf 0x1F, nor CPUID leaf
Documentation/arch/x86/topology.rst:302: 0xB, the shifts for the SMT domains is calculated using the number of
Documentation/arch/x86/topology.rst-303- CPUs sharing the L1 cache.
--
Documentation/arch/x86/topology.rst-309- sharing this cache` from `EAX[25:14]` of level-0 of CPUID 0x4 provides
Documentation/arch/x86/topology.rst:310: the shifts from the APIC ID required to compute the Core ID.
Documentation/arch/x86/topology.rst-311-
--
Documentation/arch/x86/topology.rst-317-
Documentation/arch/x86/topology.rst:318: The mask and shifts to derive the Physical Package (socket) ID is
Documentation/arch/x86/topology.rst-319- computed using the `Maximum number of addressable IDs for logical
--
Documentation/arch/x86/x86_64/mm.rst=87=Complete virtual memory map with 5-level page tables
--
Documentation/arch/x86/x86_64/mm.rst-92- - With 56-bit addresses, user-space memory gets expanded by a factor of 512x,
Documentation/arch/x86/x86_64/mm.rst:93: from 0.125 PB to 64 PB. All kernel mappings shift down to the -64 PB starting
Documentation/arch/x86/x86_64/mm.rst-94- offset and many of the regions expand to support the much larger physical
--
Documentation/bpf/classic_vs_extended.rst=289=If BPF_CLASS(code) == BPF_ALU or BPF_ALU64 [ in eBPF ], BPF_OP(code) is one of::
--
Documentation/bpf/classic_vs_extended.rst-302- BPF_MOV 0xb0 /* eBPF only: mov reg to reg */
Documentation/bpf/classic_vs_extended.rst:303: BPF_ARSH 0xc0 /* eBPF only: sign extending shift right */
Documentation/bpf/classic_vs_extended.rst-304- BPF_END 0xd0 /* eBPF only: endianness conversion */
--
Documentation/bpf/libbpf/libbpf_overview.rst=196=about the field that should be relocated on the target kernel. i.e, if the
Documentation/bpf/libbpf/libbpf_overview.rst:197:``parent`` field gets shifted to a different offset within
Documentation/bpf/libbpf/libbpf_overview.rst-198-``struct task_struct`` due to some new field added in front of it, libbpf will
--
Documentation/bpf/llvm_reloc.rst=284=The complete list of relocation kinds is represented by the following enum:
--
Documentation/bpf/llvm_reloc.rst-292- BPF_CORE_FIELD_SIGNED = 3, /* field signedness (0 - unsigned, 1 - signed) */
Documentation/bpf/llvm_reloc.rst:293: BPF_CORE_FIELD_LSHIFT_U64 = 4, /* bitfield-specific left bitshift */
Documentation/bpf/llvm_reloc.rst:294: BPF_CORE_FIELD_RSHIFT_U64 = 5, /* bitfield-specific right bitshift */
Documentation/bpf/llvm_reloc.rst-295- BPF_CORE_TYPE_ID_LOCAL = 6, /* type ID in local BPF object */
--
Documentation/bpf/llvm_reloc.rst=465=E.g. field-based relocations:
--
Documentation/bpf/llvm_reloc.rst-473- *g = __builtin_preserve_field_info(s->b, 3 /* field signedness */);
Documentation/bpf/llvm_reloc.rst:474: *g = __builtin_preserve_field_info(s->c, 4 /* bitfield left shift */);
Documentation/bpf/llvm_reloc.rst:475: *g = __builtin_preserve_field_info(s->c, 5 /* bitfield right shift */);
Documentation/bpf/llvm_reloc.rst-476- }
--
Documentation/bpf/llvm_reloc.rst-491- 12: r1 = 0x31
Documentation/bpf/llvm_reloc.rst:492: 60: CO-RE <lshift_u64> [2] struct foo::c (0:2)
Documentation/bpf/llvm_reloc.rst-493- 13: *(u64 *)(r2 + 0x0) = r1
Documentation/bpf/llvm_reloc.rst-494- 14: r1 = 0x31
Documentation/bpf/llvm_reloc.rst:495: 70: CO-RE <rshift_u64> [2] struct foo::c (0:2)
Documentation/bpf/llvm_reloc.rst-496- 15: *(u64 *)(r2 + 0x0) = r1
--
Documentation/bpf/verifier.rst=275=bit will be zero as 14 is even. Similarly ``r2 >>= 48`` will make
Documentation/bpf/verifier.rst:276:R2=inv(id=0,umax_value=65535,var_off=(0x0; 0xffff)), since the shift is not sign
Documentation/bpf/verifier.rst-277-extending. This logic is implemented in adjust_reg_min_max_vals() function,
--
Documentation/core-api/cachetlb.rst=139=Here are the routines, one by one:
--
Documentation/core-api/cachetlb.rst-188-
Documentation/core-api/cachetlb.rst:189: The 'pfn' indicates the physical page frame (shift this value
Documentation/core-api/cachetlb.rst-190- left by PAGE_SHIFT to get the physical address) that 'addr'
--
Documentation/core-api/kernel-api.rst=362=instances may be used to manage for example a 96 MHz signal that is used
Documentation/core-api/kernel-api.rst:363:to shift bits into and out of peripherals or busses, or otherwise
Documentation/core-api/kernel-api.rst-364-trigger synchronous state machine transitions in system hardware.
--
Documentation/core-api/packing.rst=20=A more robust alternative to struct field definitions would be to extract the
Documentation/core-api/packing.rst:21:required fields by shifting the appropriate number of bits. But this would
Documentation/core-api/packing.rst-22-still not protect from endianness mismatches, except if all memory accesses
Documentation/core-api/packing.rst=23=were performed byte-by-byte. Also the code can easily get cluttered, and the
Documentation/core-api/packing.rst:24:high-level idea might get lost among the many bit shifts required.
Documentation/core-api/packing.rst:25:Many drivers take the bit-shifting approach and then attempt to reduce the
Documentation/core-api/packing.rst-26-clutter with tailored macros, but more often than not these macros take
--
Documentation/core-api/real-time/differences.rst=42=Interrupt handling in a PREEMPT_RT system is invoked in process context through
Documentation/core-api/real-time/differences.rst:43:the use of threaded interrupts. Other parts of the kernel also shift their
Documentation/core-api/real-time/differences.rst-44-execution into threaded context by different mechanisms. The goal is to keep
--
Documentation/core-api/swiotlb.rst=178=IO_TLB_SIZE, IO_TLB_SEGSIZE, and the number of areas must all be powers of 2 as
Documentation/core-api/swiotlb.rst:179:the code uses shifting and bit masking to do many of the calculations. The
Documentation/core-api/swiotlb.rst-180-number of areas is rounded up to a power of 2 if necessary to meet this
--
Documentation/core-api/watch_queue.rst=71=or destroyed and the second indicates that some messages have been lost.
--
Documentation/core-api/watch_queue.rst-75- * The length of the message in bytes, including the header (mask with
Documentation/core-api/watch_queue.rst:76: WATCH_INFO_LENGTH and shift by WATCH_INFO_LENGTH__SHIFT). This indicates
Documentation/core-api/watch_queue.rst-77- the size of the record, which may be between 8 and 127 bytes.
Documentation/core-api/watch_queue.rst-78-
Documentation/core-api/watch_queue.rst:79: * The watch ID (mask with WATCH_INFO_ID and shift by WATCH_INFO_ID__SHIFT).
Documentation/core-api/watch_queue.rst-80- This indicates that caller's ID of the watch, which may be between 0
--
Documentation/core-api/watch_queue.rst=160=The ``info_id`` value should be an 8-bit number obtained from userspace and
Documentation/core-api/watch_queue.rst:161:shifted by WATCH_INFO_ID__SHIFT. This is OR'd into the WATCH_INFO_ID field of
Documentation/core-api/watch_queue.rst-162-struct watch_notification::info when and if the notification is written into
--
Documentation/crypto/descore-readme.rst=250=be able to get performance equal to assembly-coding, except that:
--
Documentation/crypto/descore-readme.rst-252-1) with the lack of a bit rotate operator in C, rotates have to be synthesized
Documentation/crypto/descore-readme.rst:253: from shifts. so access to ``asm`` will speed things up if your machine
Documentation/crypto/descore-readme.rst-254- has rotates, as explained above in (3) (not necessary if you use gcc).
--
Documentation/crypto/descore-readme.rst=282=a) additionally, i have tried to put the larger constants in registers.
--
Documentation/crypto/descore-readme.rst-286- - greater than 127 in value (can't use movq or byte immediate on CISC)
Documentation/crypto/descore-readme.rst:287: - 9-127 (may not be able to use CISC shift immediate or add/sub quick),
Documentation/crypto/descore-readme.rst-288- - 1-8 were never registered, being the cheapest constants.
--
Documentation/crypto/descore-readme.rst=301=for the 68000, the ``two registers and small offset`` form is used sparingly.
Documentation/crypto/descore-readme.rst:302:all index scaling is done explicitly - no hidden shifts by log2(sizeof).
Documentation/crypto/descore-readme.rst-303-
--
Documentation/dev-tools/ubsan.rst=16=Report example
--
Documentation/dev-tools/ubsan.rst-22- UBSAN: Undefined behaviour in ../include/linux/bitops.h:110:33
Documentation/dev-tools/ubsan.rst:23: shift exponent 32 is to large for 32-bit type 'unsigned int'
Documentation/dev-tools/ubsan.rst-24- CPU: 0 PID: 0 Comm: swapper Not tainted 4.4.0-rc1+ #26
--
Documentation/dev-tools/ubsan.rst-30- [<ffffffff8163a5ed>] ubsan_epilogue+0xd/0x40
Documentation/dev-tools/ubsan.rst:31: [<ffffffff8163ac2b>] __ubsan_handle_shift_out_of_bounds+0xeb/0x130
Documentation/dev-tools/ubsan.rst-32- [<ffffffff815f0001>] ? radix_tree_gang_lookup_slot+0x51/0x150
--
Documentation/devicetree/bindings/arm/altera/socfpga-clk-manager.yaml=101=$defs:
--
Documentation/devicetree/bindings/arm/altera/socfpga-clk-manager.yaml-119- - description: divider register offset
Documentation/devicetree/bindings/arm/altera/socfpga-clk-manager.yaml:120: - description: bit shift
Documentation/devicetree/bindings/arm/altera/socfpga-clk-manager.yaml-121- - description: bit width
--
Documentation/devicetree/bindings/arm/omap/ctrl.txt=39=scm: scm@2000 {
--
Documentation/devicetree/bindings/arm/omap/ctrl.txt-78- clocks = <&core_96m_fck>, <&mcbsp_clks>;
Documentation/devicetree/bindings/arm/omap/ctrl.txt:79: ti,bit-shift = <4>;
Documentation/devicetree/bindings/arm/omap/ctrl.txt-80- reg = <0x02d8>;
--
Documentation/devicetree/bindings/arm/qcom.yaml=18=properties:
--
Documentation/devicetree/bindings/arm/qcom.yaml-394- - radxa,dragon-q6a
Documentation/devicetree/bindings/arm/qcom.yaml:395: - shift,otter
Documentation/devicetree/bindings/arm/qcom.yaml-396- - thundercomm,minipc-g1iot
--
Documentation/devicetree/bindings/arm/qcom.yaml-967- - qcom,sdm845-mtp
Documentation/devicetree/bindings/arm/qcom.yaml:968: - shift,axolotl
Documentation/devicetree/bindings/arm/qcom.yaml-969- - samsung,starqltechn
--
Documentation/devicetree/bindings/ata/ata-generic.yaml=15=properties:
--
Documentation/devicetree/bindings/ata/ata-generic.yaml-27-
Documentation/devicetree/bindings/ata/ata-generic.yaml:28: reg-shift:
]
]
|
| 61/4 |
2026/05/21 22:56 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 60942
output: 20
thoughts: 13
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Diving into the Filesystem: BEFS Specifics**
Alright, time to get laser-focused. While a broad overview is always good, I need to get down to brass tacks. Let's not waste any cycles; let's drill down directly into `fs/befs/`. I'm thinking, this is where the real meat of the BEFS implementation resides. We need to dissect the BEFS code and architecture. Let's start with the fundamental BEFS structures, the critical data paths, and the key locking mechanisms, to get a handle on what the original devs were doing in BEFS. I'm especially keen to see how they're handling concurrency. What's the allocation strategy? Block sizes? Metadata organization? Performance considerations should be obvious from the implementation. This is where the magic happens, or doesn't, depending on how robust and well-designed it all is.
|
| 62/4 |
2026/05/21 22:56 |
tool |
grepper |
0m
Error:
Args: map[Expression:shift.*fs/befs]
Results:
|
| 63/4 |
2026/05/21 22:56 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 61197
output: 16
thoughts: 31
Thoughts: Here's your summary:
**Thinking Through the Problem**
Okay, so I need to find something. The command to use is definitely `shift`. And, if I remember correctly, I can specify a directory to search within, right? Ah, but hold on a second... a more direct approach might be better. Instead of the potentially clunky `shift` with directory filtering, I can just use `git grep` and specify the directory right away. So, that would be `git grep shift fs/befs/`. Much cleaner and probably faster. I'll stick with that.
|
| 64/4 |
2026/05/21 22:56 |
tool |
grepper |
0m
Args:
Results: map[Output:
Full output is too long, showing 500 out of 190050 lines.
Use more precise expression if possible.
[Documentation/ABI/obsolete/sysfs-bus-iio=79=Description:
--
Documentation/ABI/obsolete/sysfs-bus-iio-81- and hence the form in which it is read from user-space.
Documentation/ABI/obsolete/sysfs-bus-iio:82: Form is [be|le]:[s|u]bits/storagebits[>>shift].
Documentation/ABI/obsolete/sysfs-bus-iio-83- be or le specifies big or little endian. s or u specifies if
--
Documentation/ABI/obsolete/sysfs-bus-iio-85- of data and storagebits is the space (after padding) that it
Documentation/ABI/obsolete/sysfs-bus-iio:86: occupies in the buffer. shift if specified, is the shift that
Documentation/ABI/obsolete/sysfs-bus-iio-87- needs to be applied prior to masking out unused bits. Some
--
Documentation/ABI/obsolete/sysfs-bus-iio-94- signed 48 bit integer stored in a 64 bit location aligned to
Documentation/ABI/obsolete/sysfs-bus-iio:95: a 64 bit boundary. To obtain the clean value, shift right 2
Documentation/ABI/obsolete/sysfs-bus-iio-96- and apply a mask to zero the top 16 bits of the result.
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-isku=139=Contact: Stefan Achatz <erazor_de@users.sourceforge.net>
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-isku:140:Description: When written, this file lets one trigger easyshift functionality
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-isku-141- from the host.
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus=27=Description: When read, this file returns the raw integer version number of the
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus-29- further usage in other programs. To receive the real version
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus:30: number the decimal point has to be shifted 2 positions to the
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-koneplus-31- left. E.g. a returned value of 121 means 1.21
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-kovaplus=45=Description: When read, this file returns the raw integer version number of the
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-kovaplus-47- further usage in other programs. To receive the real version
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-kovaplus:48: number the decimal point has to be shifted 2 positions to the
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-kovaplus-49- left. E.g. a returned value of 121 means 1.21
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-pyra=34=Description: When read, this file returns the raw integer version number of the
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-pyra-36- further usage in other programs. To receive the real version
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-pyra:37: number the decimal point has to be shifted 2 positions to the
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-pyra-38- left. E.g. a returned value of 138 means 1.38
--
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-ryos=132=Contact: Stefan Achatz <erazor_de@users.sourceforge.net>
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-ryos:133:Description: When written, this file lets one trigger easyshift functionality
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-ryos-134- from the host.
--
Documentation/ABI/stable/sysfs-driver-speakup=139=Contact: speakup@linux-speakup.org
Documentation/ABI/stable/sysfs-driver-speakup:140:Description: If set to one, speakup speaks shift, alt and control when those
Documentation/ABI/stable/sysfs-driver-speakup:141: keys are pressed. If say_control is set to zero, shift, ctrl,
Documentation/ABI/stable/sysfs-driver-speakup-142- and alt are not spoken when they are pressed.
--
Documentation/ABI/testing/debugfs-moxtet=4=Contact: Marek BehΓΊn <kabel@kernel.org>
Documentation/ABI/testing/debugfs-moxtet:5:Description: (Read) Read input from the shift registers, in hexadecimal.
Documentation/ABI/testing/debugfs-moxtet-6- Returns N+1 bytes, where N is the number of Moxtet connected
--
Documentation/ABI/testing/debugfs-moxtet=22=Contact: Marek BehΓΊn <kabel@kernel.org>
Documentation/ABI/testing/debugfs-moxtet:23:Description: (RW) Read last written value to the shift registers, in
Documentation/ABI/testing/debugfs-moxtet:24: hexadecimal, or write values to the shift registers, also
Documentation/ABI/testing/debugfs-moxtet-25- in hexadecimal.
--
Documentation/ABI/testing/debugfs-moxtet-32- 01 01 was last written, or is to be written, to the
Documentation/ABI/testing/debugfs-moxtet:33: first module's shift register
Documentation/ABI/testing/debugfs-moxtet-34- 02 the same for second module
--
Documentation/ABI/testing/sysfs-bus-iio=1510=Description:
--
Documentation/ABI/testing/sysfs-bus-iio-1512- and hence the form in which it is read from user-space.
Documentation/ABI/testing/sysfs-bus-iio:1513: Form is [be|le]:[s|u]bits/storagebits[>>shift].
Documentation/ABI/testing/sysfs-bus-iio-1514- be or le specifies big or little endian. s or u specifies if
--
Documentation/ABI/testing/sysfs-bus-iio-1516- of data and storagebits is the space (after padding) that it
Documentation/ABI/testing/sysfs-bus-iio:1517: occupies in the buffer. shift if specified, is the shift that
Documentation/ABI/testing/sysfs-bus-iio-1518- needs to be applied prior to masking out unused bits. Some
--
Documentation/ABI/testing/sysfs-bus-iio-1525- signed 48 bit integer stored in a 64 bit location aligned to
Documentation/ABI/testing/sysfs-bus-iio:1526: a 64 bit boundary. To obtain the clean value, shift right 2
Documentation/ABI/testing/sysfs-bus-iio-1527- and apply a mask to zero the top 16 bits of the result.
--
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1013=4=Description:
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1013:5: Read/write unscaled value for the Local Oscillatior path quadrature I phase shift.
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1013-6-
--
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1013=10=Description:
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1013:11: Read/write unscaled value for the Local Oscillatior path quadrature Q phase shift.
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1013-12-
--
Documentation/ABI/testing/sysfs-bus-siox=17=Description:
--
Documentation/ABI/testing/sysfs-bus-siox-23- to a driver (similar to the platform bus). <inbytes> and <outbytes> define
Documentation/ABI/testing/sysfs-bus-siox:24: the length of the input and output shift register in bytes respectively.
Documentation/ABI/testing/sysfs-bus-siox-25-
--
Documentation/ABI/testing/sysfs-driver-hid-prodikeys=24=Description:
Documentation/ABI/testing/sysfs-driver-hid-prodikeys:25: Controls the octave shift modifier in the pc-midi driver.
Documentation/ABI/testing/sysfs-driver-hid-prodikeys:26: The octave can be shifted via software up/down 2 octaves.
Documentation/ABI/testing/sysfs-driver-hid-prodikeys:27: 0 means the no ocatve shift.
Documentation/ABI/testing/sysfs-driver-hid-prodikeys-28- Range: -2..2 (minus 2 to plus 2)
--
Documentation/ABI/testing/sysfs-driver-hid-roccat-kone=36=Description: When read, this file returns the raw integer version number of the
--
Documentation/ABI/testing/sysfs-driver-hid-roccat-kone-38- further usage in other programs. To receive the real version
Documentation/ABI/testing/sysfs-driver-hid-roccat-kone:39: number the decimal point has to be shifted 2 positions to the
Documentation/ABI/testing/sysfs-driver-hid-roccat-kone-40- left. E.g. a returned value of 138 means 1.38
--
Documentation/ABI/testing/sysfs-firmware-opal-psr=4=Description: Power-Shift-Ratio directory for Powernv P9 servers
--
Documentation/ABI/testing/sysfs-firmware-opal-psr-6- Power-Shift-Ratio allows to provide hints the firmware
Documentation/ABI/testing/sysfs-firmware-opal-psr:7: to shift/throttle power between different entities in
Documentation/ABI/testing/sysfs-firmware-opal-psr-8- the system. Each attribute in this directory indicates
--
Documentation/ABI/testing/sysfs-tty=129=Description:
--
Documentation/ABI/testing/sysfs-tty-134-
Documentation/ABI/testing/sysfs-tty:135:What: /sys/class/tty/ttyS<x>/iomem_reg_shift
Documentation/ABI/testing/sysfs-tty-136-Date: October 2012
--
Documentation/ABI/testing/sysfs-tty=138=Description:
Documentation/ABI/testing/sysfs-tty:139: Show the register shift indicating the spacing to be used
Documentation/ABI/testing/sysfs-tty-140- for accesses on this iomem address.
--
Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst=324=sequence number is already recorded, blocks on ``->exp_wq[1]``.
--
Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst-337-| whether or not a grace period is currently in progress. It is |
Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst:338:| therefore necessary to shift the sequence number right one bit |
Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst-339-| position to obtain the number of the grace period. This results in |
--
Documentation/admin-guide/acpi/ssdt-overlays.rst=127=variable with the content from a given file::
--
Documentation/admin-guide/acpi/ssdt-overlays.rst-132- case "$1" in
Documentation/admin-guide/acpi/ssdt-overlays.rst:133: "-f") filename="$2"; shift;;
Documentation/admin-guide/acpi/ssdt-overlays.rst:134: "-g") guid="$2"; shift;;
Documentation/admin-guide/acpi/ssdt-overlays.rst-135- *) name="$1";;
Documentation/admin-guide/acpi/ssdt-overlays.rst-136- esac
Documentation/admin-guide/acpi/ssdt-overlays.rst:137: shift
Documentation/admin-guide/acpi/ssdt-overlays.rst-138- done
--
Documentation/admin-guide/java.rst=69=Javawrapper shell script:
--
Documentation/admin-guide/java.rst-156-
Documentation/admin-guide/java.rst:157: shift
Documentation/admin-guide/java.rst-158- /usr/bin/java $FQCLASS "$@"
--
Documentation/admin-guide/kdump/gdbmacros.txt=289=define dmesg
--
Documentation/admin-guide/kdump/gdbmacros.txt-293- set var $desc_sv_bits = sizeof(long) * 8
Documentation/admin-guide/kdump/gdbmacros.txt:294: set var $desc_flags_shift = $desc_sv_bits - 2
Documentation/admin-guide/kdump/gdbmacros.txt:295: set var $desc_flags_mask = 3 << $desc_flags_shift
Documentation/admin-guide/kdump/gdbmacros.txt-296- set var $id_mask = ~$desc_flags_mask
--
Documentation/admin-guide/kdump/gdbmacros.txt-308- # skip non-committed record
Documentation/admin-guide/kdump/gdbmacros.txt:309: set var $state = 3 & ($desc->state_var.counter >> $desc_flags_shift)
Documentation/admin-guide/kdump/gdbmacros.txt-310- if ($state == $desc_committed || $state == $desc_finalized)
--
Documentation/admin-guide/kdump/vmcoreinfo.rst=77=Physical addresses are translated to struct pages by treating them as
Documentation/admin-guide/kdump/vmcoreinfo.rst:78:an index into the mem_map array. Right-shifting a physical address
Documentation/admin-guide/kdump/vmcoreinfo.rst-79-PAGE_SHIFT bits converts it into a page frame number which is an index
--
Documentation/admin-guide/kdump/vmcoreinfo.rst=540=when computing the count of vmemmap regions.
Documentation/admin-guide/kdump/vmcoreinfo.rst-541-
Documentation/admin-guide/kdump/vmcoreinfo.rst:542:mmu_psize_def|(mmu_psize_def, shift)
Documentation/admin-guide/kdump/vmcoreinfo.rst-543-------------------------------------
--
Documentation/admin-guide/kernel-parameters.txt=97=Kernel parameters
--
Documentation/admin-guide/kernel-parameters.txt-5770- rcutree.rcu_divisor= [KNL]
Documentation/admin-guide/kernel-parameters.txt:5771: Set the shift-right count to use to compute
Documentation/admin-guide/kernel-parameters.txt-5772- the callback-invocation batch limit bl from
--
Documentation/admin-guide/kernel-parameters.txt-6795-
Documentation/admin-guide/kernel-parameters.txt:6796: sched_thermal_decay_shift=
Documentation/admin-guide/kernel-parameters.txt-6797- [Deprecated]
Documentation/admin-guide/kernel-parameters.txt:6798: [KNL, SMP] Set a decay shift for scheduler thermal
Documentation/admin-guide/kernel-parameters.txt-6799- pressure signal. Thermal pressure signal follows the
--
Documentation/admin-guide/kernel-parameters.txt-6801- signals(usually 32 ms but configurable). Setting
Documentation/admin-guide/kernel-parameters.txt:6802: sched_thermal_decay_shift will left shift the decay
Documentation/admin-guide/kernel-parameters.txt:6803: period for the thermal pressure signal by the shift
Documentation/admin-guide/kernel-parameters.txt-6804- value.
Documentation/admin-guide/kernel-parameters.txt-6805- i.e. with the default pelt decay period of 32 ms
Documentation/admin-guide/kernel-parameters.txt:6806: sched_thermal_decay_shift thermal pressure decay pr
Documentation/admin-guide/kernel-parameters.txt-6807- 1 64 ms
--
Documentation/admin-guide/kernel-per-CPU-kthreads.rst=318=To reduce its OS jitter, do at least one of the following:
--
Documentation/admin-guide/kernel-per-CPU-kthreads.rst-324- note that this will not eliminate OS jitter, but will instead
Documentation/admin-guide/kernel-per-CPU-kthreads.rst:325: shift it to RCU_SOFTIRQ.
--
Documentation/admin-guide/md.rst=462=If bitmap_type is llbitmap, then the md device will also contain:
--
Documentation/admin-guide/md.rst-468- llbitmap/metadata
Documentation/admin-guide/md.rst:469: This is read-only, show bitmap metadata, include chunksize, chunkshift,
Documentation/admin-guide/md.rst-470- chunks, offset and daemon_sleep.
--
Documentation/admin-guide/media/cec.rst=230=adapters can support this. An example is the Odroid-U3 SBC that has a
Documentation/admin-guide/media/cec.rst:231:level-shifter that is powered off when the HPD signal is low, thus
Documentation/admin-guide/media/cec.rst-232-blocking the CEC pin. Even though the SoC can use CEC without a HPD,
Documentation/admin-guide/media/cec.rst:233:the level-shifter will prevent this from functioning.
Documentation/admin-guide/media/cec.rst-234-
--
Documentation/admin-guide/media/cec.rst=328=If you want to monitor the HPD and/or 5V lines as well, then you need one of
Documentation/admin-guide/media/cec.rst:329:these 5V to 3.3V level shifters:
Documentation/admin-guide/media/cec.rst-330-
--
Documentation/admin-guide/media/cec.rst=340=GPIO 6 and GPIO 7. The optional HPD pin of the HDMI connector should
Documentation/admin-guide/media/cec.rst:341:be connected via the level shifter to these pins: GPIO 23 and GPIO 12.
Documentation/admin-guide/media/cec.rst-342-The optional 5V pin of the HDMI connector should be connected via the
Documentation/admin-guide/media/cec.rst:343:level shifter to these pins: GPIO 25 and GPIO 22. Monitoring the HPD and
Documentation/admin-guide/media/cec.rst-344-5V lines is not necessary, but it is helpful.
--
Documentation/admin-guide/media/vivid.rst=680=The Test Pattern Controls are all specific to video capture.
--
Documentation/admin-guide/media/vivid.rst-737- Receivers that will just keep skipping Video Guard Band values will
Documentation/admin-guide/media/vivid.rst:738: now fail and either loose sync or these video lines will shift.
Documentation/admin-guide/media/vivid.rst-739-
--
Documentation/admin-guide/mm/pagemap.rst=221=into the file), or if the size of the read is not a multiple of 8 bytes.
Documentation/admin-guide/mm/pagemap.rst-222-
Documentation/admin-guide/mm/pagemap.rst:223:Before Linux 3.11 pagemap bits 55-60 were used for "page-shift" (which is
Documentation/admin-guide/mm/pagemap.rst-224-always 12 at most architectures). Since Linux 3.11 their meaning changes
--
Documentation/admin-guide/pm/amd-pstate.rst=329=When dynamic EPP is enabled, writes to energy_performance_preference are blocked
Documentation/admin-guide/pm/amd-pstate.rst:330:even when EPP feature is enabled by platform firmware. Lower epp values shift the bias
Documentation/admin-guide/pm/amd-pstate.rst:331:towards improved performance while a higher epp value shifts the bias towards
Documentation/admin-guide/pm/amd-pstate.rst-332-power-savings. The exact impact can change from one platform to the other.
--
Documentation/admin-guide/spkguide.txt=187=as the speakup key. Instead of pressing and releasing this key, as you
Documentation/admin-guide/spkguide.txt:188:do under DOS or Windows, you hold it like a shift key, and press other
Documentation/admin-guide/spkguide.txt-189-keys in combination with it. For example, repeatedly holding keypad
--
Documentation/admin-guide/spkguide.txt=244=beyond the scope of this manual. To use the caps lock for its normal
Documentation/admin-guide/spkguide.txt:245:purpose, hold the shift key while toggling the caps lock on and off. We
Documentation/admin-guide/spkguide.txt-246-should note here, that holding the caps lock key and pressing the z key
--
Documentation/admin-guide/spkguide.txt=280=spk key_f8 = edit_repeat
Documentation/admin-guide/spkguide.txt:281:shift spk key_f9 = edit_exnum
Documentation/admin-guide/spkguide.txt-282- key_kp7 = say_prev_line
--
Documentation/admin-guide/spkguide.txt=325=spk key_minus = speakup_parked
Documentation/admin-guide/spkguide.txt:326:shift spk key_minus = say_char_num
Documentation/admin-guide/spkguide.txt-327-spk key_j = say_prev_word
--
Documentation/admin-guide/spkguide.txt=349=spk key_8 = speakup_paste
Documentation/admin-guide/spkguide.txt:350:shift spk key_m = say_first_char
Documentation/admin-guide/spkguide.txt-351- ctrl spk key_semicolon = say_last_char
--
Documentation/admin-guide/sysctl/kernel.rst=89=This gives the bootloader type number as indicated by the bootloader,
Documentation/admin-guide/sysctl/kernel.rst:90:shifted left by 4, and OR'd with the low four bits of the bootloader
Documentation/admin-guide/sysctl/kernel.rst-91-version. The reason for this encoding is that this used to match the
--
Documentation/admin-guide/sysctl/net.rst=537=The max value is set to CONN_OVERLOAD_LIMIT, and the default and min values
Documentation/admin-guide/sysctl/net.rst:538:are scaled (shifted) versions of that same value. Note that the min value
Documentation/admin-guide/sysctl/net.rst-539-is not at this point in time used in any meaningful way, but the triplet is
--
Documentation/admin-guide/sysrq.rst=223=Sometimes SysRq seems to get 'stuck' after using it, what can I do?
--
Documentation/admin-guide/sysrq.rst-225-
Documentation/admin-guide/sysrq.rst:226:When this happens, try tapping shift, alt and control on both sides of the
Documentation/admin-guide/sysrq.rst-227-keyboard, and hitting an invalid sysrq sequence again. (i.e., something like
--
Documentation/arch/arm/nwfpe/todo.rst=32=Coordinate Rotation Digital Computer, and is a method of computing
Documentation/arch/arm/nwfpe/todo.rst:33:transcendental functions using mostly shifts and adds and a few
Documentation/arch/arm/nwfpe/todo.rst:34:multiplications and divisions. The ARM excels at shifts and adds,
Documentation/arch/arm/nwfpe/todo.rst-35-so such a method could be promising, but requires more research to
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk=30=function find_length(f)
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-47-
Documentation/arch/arm/samsung/clksrc-change-registers.awk:48:function find_shift(s)
Documentation/arch/arm/samsung/clksrc-change-registers.awk-49-{
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-51- if (id <= 0) {
Documentation/arch/arm/samsung/clksrc-change-registers.awk:52: printf "cannot find shift " s "\n" > "/dev/stderr"
Documentation/arch/arm/samsung/clksrc-change-registers.awk-53- exit
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk=60=BEGIN {
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-76- dmask[name,0] = find_length(fields[1])
Documentation/arch/arm/samsung/clksrc-change-registers.awk:77: dmask[name,1] = find_shift(fields[1])
Documentation/arch/arm/samsung/clksrc-change-registers.awk-78- if (0)
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-87-/clksrc_clk.*=.*{/ {
Documentation/arch/arm/samsung/clksrc-change-registers.awk:88: shift=""
Documentation/arch/arm/samsung/clksrc-change-registers.awk-89- mask=""
Documentation/arch/arm/samsung/clksrc-change-registers.awk:90: divshift=""
Documentation/arch/arm/samsung/clksrc-change-registers.awk-91- reg_div=""
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-102-
Documentation/arch/arm/samsung/clksrc-change-registers.awk:103: if (line ~ /\.shift/) {
Documentation/arch/arm/samsung/clksrc-change-registers.awk:104: shift = extract_value(line)
Documentation/arch/arm/samsung/clksrc-change-registers.awk-105- } else if (line ~ /\.mask/) {
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-110- reg_src = extract_value(line)
Documentation/arch/arm/samsung/clksrc-change-registers.awk:111: } else if (line ~ /\.divider_shift/) {
Documentation/arch/arm/samsung/clksrc-change-registers.awk:112: divshift = extract_value(line)
Documentation/arch/arm/samsung/clksrc-change-registers.awk-113- } else if (line ~ /{/) {
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-120- if (0) {
Documentation/arch/arm/samsung/clksrc-change-registers.awk:121: printf "shift '" shift "' ='" dmask[shift,0] "'\n" > "/dev/stderr"
Documentation/arch/arm/samsung/clksrc-change-registers.awk-122- printf "mask '" mask "'\n" > "/dev/stderr"
Documentation/arch/arm/samsung/clksrc-change-registers.awk:123: printf "dshft '" divshift "'\n" > "/dev/stderr"
Documentation/arch/arm/samsung/clksrc-change-registers.awk-124- printf "rdiv '" reg_div "'\n" > "/dev/stderr"
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-133- printf "/* rdiv " reg_div " */\n"
Documentation/arch/arm/samsung/clksrc-change-registers.awk:134: printf "/* shift " shift " */\n"
Documentation/arch/arm/samsung/clksrc-change-registers.awk-135- printf "/* mask " mask " */\n"
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-141- printf ".reg = " reg_div ", "
Documentation/arch/arm/samsung/clksrc-change-registers.awk:142: printf ".shift = " dmask[generated,1] ", "
Documentation/arch/arm/samsung/clksrc-change-registers.awk-143- printf ".size = " dmask[generated,0] ", "
--
Documentation/arch/arm/samsung/clksrc-change-registers.awk-148- printf ".reg = " reg_src ", "
Documentation/arch/arm/samsung/clksrc-change-registers.awk:149: printf ".shift = " dmask[mask,1] ", "
Documentation/arch/arm/samsung/clksrc-change-registers.awk-150- printf ".size = " dmask[mask,0] ", "
--
Documentation/arch/loongarch/introduction.rst=232=For brevity, only instruction names (mnemonics) are listed here; please see the
--
Documentation/arch/loongarch/introduction.rst-245-
Documentation/arch/loongarch/introduction.rst:246:2. Bit-shift Instructions::
Documentation/arch/loongarch/introduction.rst-247-
--
Documentation/arch/m68k/buddha-driver.rst=135=to 1 by definition.
Documentation/arch/m68k/buddha-driver.rst-136-
Documentation/arch/m68k/buddha-driver.rst:137:The values in this table have to be shifted 5 bits to the
Documentation/arch/m68k/buddha-driver.rst-138-left and or'd with $1f (this sets the lower 5 bits).
--
Documentation/arch/m68k/kernel-options.rst=513=panning or blanking.
--
Documentation/arch/m68k/kernel-options.rst-517-
Documentation/arch/m68k/kernel-options.rst:518:The external pixel clock attached to the Falcon VIDEL shifter. This
Documentation/arch/m68k/kernel-options.rst-519-currently works only with the ScreenWonder!
--
Documentation/arch/x86/amd-memory-encryption.rst=225=an RMP segment::
--
Documentation/arch/x86/amd-memory-encryption.rst-231- Bits[51:20] segment physical address
Documentation/arch/x86/amd-memory-encryption.rst:232: This address is left shift 20-bits (or just masked when
Documentation/arch/x86/amd-memory-encryption.rst-233- read) to form the physical address of the segment (1MB
--
Documentation/arch/x86/topology.rst=152=follows:
--
Documentation/arch/x86/topology.rst-169- The kernel uses the `CoreMaskWidth` from `EAX[4:0]` to discover the
Documentation/arch/x86/topology.rst:170: number of bits that need to be right-shifted from `ExtendedLocalApicId`
Documentation/arch/x86/topology.rst-171- in `EDX[31:0]` in order to get a unique Topology ID for the topology
--
Documentation/arch/x86/topology.rst-193- The kernel uses the `CoreMaskWidth` from `EAX[4:0]` to discover the
Documentation/arch/x86/topology.rst:194: number of bits that need to be right-shifted from the `ExtendedLocalApicId`
Documentation/arch/x86/topology.rst-195- in `EDX[31:0]` to get a unique Topology ID for that topology level. CPUs
--
Documentation/arch/x86/topology.rst-209-
Documentation/arch/x86/topology.rst:210: The shifts from the APIC ID for the Socket ID is calculated from the
Documentation/arch/x86/topology.rst-211- `ApicIdSize` field in `ECX[15:12]` if it is non-zero.
Documentation/arch/x86/topology.rst-212-
Documentation/arch/x86/topology.rst:213: If `ApicIdSize` is reported to be zero, the shift is calculated as the
Documentation/arch/x86/topology.rst-214- order of the `number of threads` calculated from `NC` field in
--
Documentation/arch/x86/topology.rst-237- On processors of Family 0x17 and above that do not support CPUID leaf
Documentation/arch/x86/topology.rst:238: 0x80000026 or CPUID leaf 0xB, the shifts from the APIC ID for the Core
Documentation/arch/x86/topology.rst-239- ID is calculated using the order of `number of threads per core`
--
Documentation/arch/x86/topology.rst-275- The kernel uses the value from `EAX[4:0]` to discover the number of
Documentation/arch/x86/topology.rst:276: bits that need to be right shifted from the `x2APIC ID` in `EDX[31:0]`
Documentation/arch/x86/topology.rst-277- to get a unique Topology ID for the topology level. CPUs with the same
--
Documentation/arch/x86/topology.rst-301- On Intel processors that support neither CPUID leaf 0x1F, nor CPUID leaf
Documentation/arch/x86/topology.rst:302: 0xB, the shifts for the SMT domains is calculated using the number of
Documentation/arch/x86/topology.rst-303- CPUs sharing the L1 cache.
--
Documentation/arch/x86/topology.rst-309- sharing this cache` from `EAX[25:14]` of level-0 of CPUID 0x4 provides
Documentation/arch/x86/topology.rst:310: the shifts from the APIC ID required to compute the Core ID.
Documentation/arch/x86/topology.rst-311-
--
Documentation/arch/x86/topology.rst-317-
Documentation/arch/x86/topology.rst:318: The mask and shifts to derive the Physical Package (socket) ID is
Documentation/arch/x86/topology.rst-319- computed using the `Maximum number of addressable IDs for logical
--
Documentation/arch/x86/x86_64/mm.rst=87=Complete virtual memory map with 5-level page tables
--
Documentation/arch/x86/x86_64/mm.rst-92- - With 56-bit addresses, user-space memory gets expanded by a factor of 512x,
Documentation/arch/x86/x86_64/mm.rst:93: from 0.125 PB to 64 PB. All kernel mappings shift down to the -64 PB starting
Documentation/arch/x86/x86_64/mm.rst-94- offset and many of the regions expand to support the much larger physical
--
Documentation/bpf/classic_vs_extended.rst=289=If BPF_CLASS(code) == BPF_ALU or BPF_ALU64 [ in eBPF ], BPF_OP(code) is one of::
--
Documentation/bpf/classic_vs_extended.rst-302- BPF_MOV 0xb0 /* eBPF only: mov reg to reg */
Documentation/bpf/classic_vs_extended.rst:303: BPF_ARSH 0xc0 /* eBPF only: sign extending shift right */
Documentation/bpf/classic_vs_extended.rst-304- BPF_END 0xd0 /* eBPF only: endianness conversion */
--
Documentation/bpf/libbpf/libbpf_overview.rst=196=about the field that should be relocated on the target kernel. i.e, if the
Documentation/bpf/libbpf/libbpf_overview.rst:197:``parent`` field gets shifted to a different offset within
Documentation/bpf/libbpf/libbpf_overview.rst-198-``struct task_struct`` due to some new field added in front of it, libbpf will
--
Documentation/bpf/llvm_reloc.rst=284=The complete list of relocation kinds is represented by the following enum:
--
Documentation/bpf/llvm_reloc.rst-292- BPF_CORE_FIELD_SIGNED = 3, /* field signedness (0 - unsigned, 1 - signed) */
Documentation/bpf/llvm_reloc.rst:293: BPF_CORE_FIELD_LSHIFT_U64 = 4, /* bitfield-specific left bitshift */
Documentation/bpf/llvm_reloc.rst:294: BPF_CORE_FIELD_RSHIFT_U64 = 5, /* bitfield-specific right bitshift */
Documentation/bpf/llvm_reloc.rst-295- BPF_CORE_TYPE_ID_LOCAL = 6, /* type ID in local BPF object */
--
Documentation/bpf/llvm_reloc.rst=465=E.g. field-based relocations:
--
Documentation/bpf/llvm_reloc.rst-473- *g = __builtin_preserve_field_info(s->b, 3 /* field signedness */);
Documentation/bpf/llvm_reloc.rst:474: *g = __builtin_preserve_field_info(s->c, 4 /* bitfield left shift */);
Documentation/bpf/llvm_reloc.rst:475: *g = __builtin_preserve_field_info(s->c, 5 /* bitfield right shift */);
Documentation/bpf/llvm_reloc.rst-476- }
--
Documentation/bpf/llvm_reloc.rst-491- 12: r1 = 0x31
Documentation/bpf/llvm_reloc.rst:492: 60: CO-RE <lshift_u64> [2] struct foo::c (0:2)
Documentation/bpf/llvm_reloc.rst-493- 13: *(u64 *)(r2 + 0x0) = r1
Documentation/bpf/llvm_reloc.rst-494- 14: r1 = 0x31
Documentation/bpf/llvm_reloc.rst:495: 70: CO-RE <rshift_u64> [2] struct foo::c (0:2)
Documentation/bpf/llvm_reloc.rst-496- 15: *(u64 *)(r2 + 0x0) = r1
--
Documentation/bpf/verifier.rst=275=bit will be zero as 14 is even. Similarly ``r2 >>= 48`` will make
Documentation/bpf/verifier.rst:276:R2=inv(id=0,umax_value=65535,var_off=(0x0; 0xffff)), since the shift is not sign
Documentation/bpf/verifier.rst-277-extending. This logic is implemented in adjust_reg_min_max_vals() function,
--
Documentation/core-api/cachetlb.rst=139=Here are the routines, one by one:
--
Documentation/core-api/cachetlb.rst-188-
Documentation/core-api/cachetlb.rst:189: The 'pfn' indicates the physical page frame (shift this value
Documentation/core-api/cachetlb.rst-190- left by PAGE_SHIFT to get the physical address) that 'addr'
--
Documentation/core-api/kernel-api.rst=362=instances may be used to manage for example a 96 MHz signal that is used
Documentation/core-api/kernel-api.rst:363:to shift bits into and out of peripherals or busses, or otherwise
Documentation/core-api/kernel-api.rst-364-trigger synchronous state machine transitions in system hardware.
--
Documentation/core-api/packing.rst=20=A more robust alternative to struct field definitions would be to extract the
Documentation/core-api/packing.rst:21:required fields by shifting the appropriate number of bits. But this would
Documentation/core-api/packing.rst-22-still not protect from endianness mismatches, except if all memory accesses
Documentation/core-api/packing.rst=23=were performed byte-by-byte. Also the code can easily get cluttered, and the
Documentation/core-api/packing.rst:24:high-level idea might get lost among the many bit shifts required.
Documentation/core-api/packing.rst:25:Many drivers take the bit-shifting approach and then attempt to reduce the
Documentation/core-api/packing.rst-26-clutter with tailored macros, but more often than not these macros take
--
Documentation/core-api/real-time/differences.rst=42=Interrupt handling in a PREEMPT_RT system is invoked in process context through
Documentation/core-api/real-time/differences.rst:43:the use of threaded interrupts. Other parts of the kernel also shift their
Documentation/core-api/real-time/differences.rst-44-execution into threaded context by different mechanisms. The goal is to keep
--
Documentation/core-api/swiotlb.rst=178=IO_TLB_SIZE, IO_TLB_SEGSIZE, and the number of areas must all be powers of 2 as
Documentation/core-api/swiotlb.rst:179:the code uses shifting and bit masking to do many of the calculations. The
Documentation/core-api/swiotlb.rst-180-number of areas is rounded up to a power of 2 if necessary to meet this
--
Documentation/core-api/watch_queue.rst=71=or destroyed and the second indicates that some messages have been lost.
--
Documentation/core-api/watch_queue.rst-75- * The length of the message in bytes, including the header (mask with
Documentation/core-api/watch_queue.rst:76: WATCH_INFO_LENGTH and shift by WATCH_INFO_LENGTH__SHIFT). This indicates
Documentation/core-api/watch_queue.rst-77- the size of the record, which may be between 8 and 127 bytes.
Documentation/core-api/watch_queue.rst-78-
Documentation/core-api/watch_queue.rst:79: * The watch ID (mask with WATCH_INFO_ID and shift by WATCH_INFO_ID__SHIFT).
Documentation/core-api/watch_queue.rst-80- This indicates that caller's ID of the watch, which may be between 0
--
Documentation/core-api/watch_queue.rst=160=The ``info_id`` value should be an 8-bit number obtained from userspace and
Documentation/core-api/watch_queue.rst:161:shifted by WATCH_INFO_ID__SHIFT. This is OR'd into the WATCH_INFO_ID field of
Documentation/core-api/watch_queue.rst-162-struct watch_notification::info when and if the notification is written into
--
Documentation/crypto/descore-readme.rst=250=be able to get performance equal to assembly-coding, except that:
--
Documentation/crypto/descore-readme.rst-252-1) with the lack of a bit rotate operator in C, rotates have to be synthesized
Documentation/crypto/descore-readme.rst:253: from shifts. so access to ``asm`` will speed things up if your machine
Documentation/crypto/descore-readme.rst-254- has rotates, as explained above in (3) (not necessary if you use gcc).
--
Documentation/crypto/descore-readme.rst=282=a) additionally, i have tried to put the larger constants in registers.
--
Documentation/crypto/descore-readme.rst-286- - greater than 127 in value (can't use movq or byte immediate on CISC)
Documentation/crypto/descore-readme.rst:287: - 9-127 (may not be able to use CISC shift immediate or add/sub quick),
Documentation/crypto/descore-readme.rst-288- - 1-8 were never registered, being the cheapest constants.
--
Documentation/crypto/descore-readme.rst=301=for the 68000, the ``two registers and small offset`` form is used sparingly.
Documentation/crypto/descore-readme.rst:302:all index scaling is done explicitly - no hidden shifts by log2(sizeof).
Documentation/crypto/descore-readme.rst-303-
--
Documentation/dev-tools/ubsan.rst=16=Report example
--
Documentation/dev-tools/ubsan.rst-22- UBSAN: Undefined behaviour in ../include/linux/bitops.h:110:33
Documentation/dev-tools/ubsan.rst:23: shift exponent 32 is to large for 32-bit type 'unsigned int'
Documentation/dev-tools/ubsan.rst-24- CPU: 0 PID: 0 Comm: swapper Not tainted 4.4.0-rc1+ #26
--
Documentation/dev-tools/ubsan.rst-30- [<ffffffff8163a5ed>] ubsan_epilogue+0xd/0x40
Documentation/dev-tools/ubsan.rst:31: [<ffffffff8163ac2b>] __ubsan_handle_shift_out_of_bounds+0xeb/0x130
Documentation/dev-tools/ubsan.rst-32- [<ffffffff815f0001>] ? radix_tree_gang_lookup_slot+0x51/0x150
--
Documentation/devicetree/bindings/arm/altera/socfpga-clk-manager.yaml=101=$defs:
--
Documentation/devicetree/bindings/arm/altera/socfpga-clk-manager.yaml-119- - description: divider register offset
Documentation/devicetree/bindings/arm/altera/socfpga-clk-manager.yaml:120: - description: bit shift
Documentation/devicetree/bindings/arm/altera/socfpga-clk-manager.yaml-121- - description: bit width
--
Documentation/devicetree/bindings/arm/omap/ctrl.txt=39=scm: scm@2000 {
--
Documentation/devicetree/bindings/arm/omap/ctrl.txt-78- clocks = <&core_96m_fck>, <&mcbsp_clks>;
Documentation/devicetree/bindings/arm/omap/ctrl.txt:79: ti,bit-shift = <4>;
Documentation/devicetree/bindings/arm/omap/ctrl.txt-80- reg = <0x02d8>;
--
Documentation/devicetree/bindings/arm/qcom.yaml=18=properties:
--
Documentation/devicetree/bindings/arm/qcom.yaml-394- - radxa,dragon-q6a
Documentation/devicetree/bindings/arm/qcom.yaml:395: - shift,otter
Documentation/devicetree/bindings/arm/qcom.yaml-396- - thundercomm,minipc-g1iot
--
Documentation/devicetree/bindings/arm/qcom.yaml-967- - qcom,sdm845-mtp
Documentation/devicetree/bindings/arm/qcom.yaml:968: - shift,axolotl
Documentation/devicetree/bindings/arm/qcom.yaml-969- - samsung,starqltechn
--
Documentation/devicetree/bindings/ata/ata-generic.yaml=15=properties:
--
Documentation/devicetree/bindings/ata/ata-generic.yaml-27-
Documentation/devicetree/bindings/ata/ata-generic.yaml:28: reg-shift:
]
]
|
| 65/4 |
2026/05/21 22:56 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 73773
output: 22
thoughts: 13
Thoughts: Here's my take on those thoughts:
**Manual File System Inspection - BEFS**
Okay, so I need to get hands-on with this. Forget any automated scripts for the moment. Let's not make assumptions. I'm going to navigate to `fs/befs/` manually. This might seem a bit basic, but sometimes the simplest approach is the most revealing, especially when debugging. I want to *see* what's there, observe the metadata directly, and build a clearer mental model before I start throwing sophisticated tools at it. There could be something obvious jumping out that a program would gloss over. I want to assess the integrity, the directory structure, the file attributesβ¦the works. Time to get down and dirty with the file system.
|
| 66/4 |
2026/05/21 22:57 |
tool |
codesearch-dir-index |
0m
Args:
Results: map[Files:[befs.h befs_fs_types.h btree.c btree.h datastream.c datastream.h debug.c endian.h inode.c inode.h io.c io.h linuxvfs.c super.c super.h] Subdirs:<nil>]
|
| 67/4 |
2026/05/21 22:57 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 74081
output: 24
thoughts: 15
Thoughts: Okay, let's dive in. Here's my thought process summarized for you:
**Diving into the BEFS Header**
Alright, time to get started. My initial instinct is to go straight to the core of the BEFS implementation. The logical place to start is the header file, specifically `fs/befs/befs.h`. I need to understand the fundamental data structures, macros, and function prototypes that define the BEFS filesystem. This header file should give me a solid foundation and overview of how things are put together before I delve into the more detailed implementation code. It's a key first step for any in-depth exploration.
|
| 68/4 |
2026/05/21 22:57 |
tool |
read-file |
0m
Args:
Results: map[Contents:/* SPDX-License-Identifier: GPL-2.0 */
/*
* befs.h
*
* Copyright (C) 2001-2002 Will Dyson <will_dyson@pobox.com>
* Copyright (C) 1999 Makoto Kato (m_kato@ga2.so-net.ne.jp)
*/
#ifndef _LINUX_BEFS_H
#define _LINUX_BEFS_H
#include "befs_fs_types.h"
/* used in debug.c */
#define BEFS_VERSION "0.9.3"
typedef u64 befs_blocknr_t;
/*
* BeFS in memory structures
*/
struct befs_mount_options {
kgid_t gid;
kuid_t uid;
int use_gid;
int use_uid;
int debug;
char *iocharset;
};
struct befs_sb_info {
u32 magic1;
u32 block_size;
u32 block_shift;
int byte_order;
befs_off_t num_blocks;
befs_off_t used_blocks;
u32 inode_size;
u32 magic2;
/* Allocation group information */
u32 blocks_per_ag;
u32 ag_shift;
u32 num_ags;
/* State of the superblock */
u32 flags;
/* Journal log entry */
befs_block_run log_blocks;
befs_off_t log_start;
befs_off_t log_end;
befs_inode_addr root_dir;
befs_inode_addr indices;
u32 magic3;
struct befs_mount_options mount_opts;
struct nls_table *nls;
};
struct befs_inode_info {
u32 i_flags;
u32 i_type;
befs_inode_addr i_inode_num;
befs_inode_addr i_parent;
befs_inode_addr i_attribute;
union {
befs_data_stream ds;
char symlink[BEFS_SYMLINK_LEN];
} i_data;
struct inode vfs_inode;
};
enum befs_err {
BEFS_OK,
BEFS_ERR,
BEFS_BAD_INODE,
BEFS_BT_END,
BEFS_BT_EMPTY,
BEFS_BT_MATCH,
BEFS_BT_OVERFLOW,
BEFS_BT_NOT_FOUND
};
/****************************/
/* debug.c */
__printf(2, 3)
void befs_error(const struct super_block *sb, const char *fmt, ...);
__printf(2, 3)
void befs_warning(const struct super_block *sb, const char *fmt, ...);
__printf(2, 3)
void befs_debug(const struct super_block *sb, const char *fmt, ...);
void befs_dump_super_block(const struct super_block *sb, befs_super_block *);
void befs_dump_inode(const struct super_block *sb, befs_inode *);
void befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super *);
void befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *);
/****************************/
/* Gets a pointer to the private portion of the super_block
* structure from the public part
*/
static inline struct befs_sb_info *
BEFS_SB(const struct super_block *super)
{
return (struct befs_sb_info *) super->s_fs_info;
}
static inline struct befs_inode_info *
BEFS_I(const struct inode *inode)
{
return container_of(inode, struct befs_inode_info, vfs_inode);
}
static inline befs_blocknr_t
iaddr2blockno(struct super_block *sb, const befs_inode_addr *iaddr)
{
return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
iaddr->start);
}
static inline befs_inode_addr
blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
{
befs_inode_addr iaddr;
iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
iaddr.start =
blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
iaddr.len = 1;
return iaddr;
}
static inline unsigned int
befs_iaddrs_per_block(struct super_block *sb)
{
return BEFS_SB(sb)->block_size / sizeof(befs_disk_inode_addr);
}
#include "endian.h"
#endif /* _LINUX_BEFS_H */
]
|
| 69/4 |
2026/05/21 22:57 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 75509
output: 28
thoughts: 352
Thoughts: **My Analysis of BEFS Block Number Conversion**
Okay, let's break down these BEFS block number conversions. Looking at `iaddr2blockno` and `blockno2iaddr`, it's all about translating between inode addresses and block numbers. The core of this is clearly the use of `ag_shift`. I remember, from `befs_check_sb`, we've validated `ag_shift`. That validation is critical because it ensures the integrity of these calculations.
Right, `ag_shift` is the base-2 logarithm of `blocks_per_ag`. Now, `blocks_per_ag` is a 32-bit integer, meaning `ilog2(blocks_per_ag)` can't be more than 31. This is important to note as it constrains the size of the allocation group shift, making sure that it does not exceed the valid range. The shift operation is used to efficiently calculate the block number from the allocation group and the start block within that group. Likewise, to go the other way, from block number to inode address, we divide to get the allocation group, and then subtract to find the start block. And the `iaddr.len` is set to 1, indicating a single block.
However, I need to confirm something: the type of `iaddr->allocation_group`. Gotta double-check that `befs_inode_addr` structure definition in `befs_fs_types.h` to be sure that `iaddr->allocation_group` is a `u32`. This confirms the bit-wise operations.
|
| 70/4 |
2026/05/21 22:57 |
tool |
read-file |
0m
Args: map[File:fs/befs/befs_fs_types.h]
Results: map[Contents:/* SPDX-License-Identifier: GPL-2.0 */
/*
* fs/befs/befs_fs_types.h
*
* Copyright (C) 2001 Will Dyson (will@cs.earlham.edu)
*
*
*
* from linux/include/linux/befs_fs.h
*
* Copyright (C) 1999 Makoto Kato (m_kato@ga2.so-net.ne.jp)
*
*/
#ifndef _LINUX_BEFS_FS_TYPES
#define _LINUX_BEFS_FS_TYPES
#ifdef __KERNEL__
#include <linux/types.h>
#endif /*__KERNEL__*/
#define PACKED __attribute__ ((__packed__))
/*
* Max name lengths of BFS
*/
#define BEFS_NAME_LEN 255
#define BEFS_SYMLINK_LEN 144
#define BEFS_NUM_DIRECT_BLOCKS 12
#define B_OS_NAME_LENGTH 32
/* The datastream blocks mapped by the double-indirect
* block are always 4 fs blocks long.
* This eliminates the need for linear searches among
* the potentially huge number of indirect blocks
*
* Err. Should that be 4 fs blocks or 4k???
* It matters on large blocksize volumes
*/
#define BEFS_DBLINDIR_BRUN_LEN 4
/*
* Flags of superblock
*/
enum super_flags {
BEFS_BYTESEX_BE,
BEFS_BYTESEX_LE,
BEFS_CLEAN = 0x434c454e,
BEFS_DIRTY = 0x44495254,
BEFS_SUPER_MAGIC1 = 0x42465331, /* BFS1 */
BEFS_SUPER_MAGIC2 = 0xdd121031,
BEFS_SUPER_MAGIC3 = 0x15b6830e,
};
#define BEFS_BYTEORDER_NATIVE 0x42494745
#define BEFS_BYTEORDER_NATIVE_LE ((__force fs32)cpu_to_le32(BEFS_BYTEORDER_NATIVE))
#define BEFS_BYTEORDER_NATIVE_BE ((__force fs32)cpu_to_be32(BEFS_BYTEORDER_NATIVE))
#define BEFS_SUPER_MAGIC BEFS_SUPER_MAGIC1
#define BEFS_SUPER_MAGIC1_LE ((__force fs32)cpu_to_le32(BEFS_SUPER_MAGIC1))
#define BEFS_SUPER_MAGIC1_BE ((__force fs32)cpu_to_be32(BEFS_SUPER_MAGIC1))
/*
* Flags of inode
*/
#define BEFS_INODE_MAGIC1 0x3bbe0ad9
enum inode_flags {
BEFS_INODE_IN_USE = 0x00000001,
BEFS_ATTR_INODE = 0x00000004,
BEFS_INODE_LOGGED = 0x00000008,
BEFS_INODE_DELETED = 0x00000010,
BEFS_LONG_SYMLINK = 0x00000040,
BEFS_PERMANENT_FLAG = 0x0000ffff,
BEFS_INODE_NO_CREATE = 0x00010000,
BEFS_INODE_WAS_WRITTEN = 0x00020000,
BEFS_NO_TRANSACTION = 0x00040000,
};
/*
* On-Disk datastructures of BeFS
*/
typedef u64 __bitwise fs64;
typedef u32 __bitwise fs32;
typedef u16 __bitwise fs16;
typedef u64 befs_off_t;
typedef fs64 befs_time_t;
/* Block runs */
typedef struct {
fs32 allocation_group;
fs16 start;
fs16 len;
} PACKED befs_disk_block_run;
typedef struct {
u32 allocation_group;
u16 start;
u16 len;
} PACKED befs_block_run;
typedef befs_disk_block_run befs_disk_inode_addr;
typedef befs_block_run befs_inode_addr;
/*
* The Superblock Structure
*/
typedef struct {
char name[B_OS_NAME_LENGTH];
fs32 magic1;
fs32 fs_byte_order;
fs32 block_size;
fs32 block_shift;
fs64 num_blocks;
fs64 used_blocks;
fs32 inode_size;
fs32 magic2;
fs32 blocks_per_ag;
fs32 ag_shift;
fs32 num_ags;
fs32 flags;
befs_disk_block_run log_blocks;
fs64 log_start;
fs64 log_end;
fs32 magic3;
befs_disk_inode_addr root_dir;
befs_disk_inode_addr indices;
} PACKED befs_super_block;
/*
* Note: the indirect and dbl_indir block_runs may
* be longer than one block!
*/
typedef struct {
befs_disk_block_run direct[BEFS_NUM_DIRECT_BLOCKS];
fs64 max_direct_range;
befs_disk_block_run indirect;
fs64 max_indirect_range;
befs_disk_block_run double_indirect;
fs64 max_double_indirect_range;
fs64 size;
} PACKED befs_disk_data_stream;
typedef struct {
befs_block_run direct[BEFS_NUM_DIRECT_BLOCKS];
befs_off_t max_direct_range;
befs_block_run indirect;
befs_off_t max_indirect_range;
befs_block_run double_indirect;
befs_off_t max_double_indirect_range;
befs_off_t size;
} PACKED befs_data_stream;
/* Attribute */
typedef struct {
fs32 type;
fs16 name_size;
fs16 data_size;
char name[1];
} PACKED befs_small_data;
/* Inode structure */
typedef struct {
fs32 magic1;
befs_disk_inode_addr inode_num;
fs32 uid;
fs32 gid;
fs32 mode;
fs32 flags;
befs_time_t create_time;
befs_time_t last_modified_time;
befs_disk_inode_addr parent;
befs_disk_inode_addr attributes;
fs32 type;
fs32 inode_size;
fs32 etc; /* not use */
union {
befs_disk_data_stream datastream;
char symlink[BEFS_SYMLINK_LEN];
} data;
fs32 pad[4]; /* not use */
befs_small_data small_data[1];
} PACKED befs_inode;
/*
* B+tree superblock
*/
#define BEFS_BTREE_MAGIC 0x69f6c2e8
enum btree_types {
BTREE_STRING_TYPE = 0,
BTREE_INT32_TYPE = 1,
BTREE_UINT32_TYPE = 2,
BTREE_INT64_TYPE = 3,
BTREE_UINT64_TYPE = 4,
BTREE_FLOAT_TYPE = 5,
BTREE_DOUBLE_TYPE = 6
};
typedef struct {
fs32 magic;
fs32 node_size;
fs32 max_depth;
fs32 data_type;
fs64 root_node_ptr;
fs64 free_node_ptr;
fs64 max_size;
} PACKED befs_disk_btree_super;
typedef struct {
u32 magic;
u32 node_size;
u32 max_depth;
u32 data_type;
befs_off_t root_node_ptr;
befs_off_t free_node_ptr;
befs_off_t max_size;
} PACKED befs_btree_super;
/*
* Header structure of each btree node
*/
typedef struct {
fs64 left;
fs64 right;
fs64 overflow;
fs16 all_key_count;
fs16 all_key_length;
} PACKED befs_btree_nodehead;
typedef struct {
befs_off_t left;
befs_off_t right;
befs_off_t overflow;
u16 all_key_count;
u16 all_key_length;
} PACKED befs_host_btree_nodehead;
#endif /* _LINUX_BEFS_FS_TYPES */
]
|
| 71/4 |
2026/05/21 22:57 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 78515
output: 15
thoughts: 633
Thoughts: **Analyzing Bit Shifts in BEFS Filesystem Code**
Okay, so I'm looking at this BEFS code and specifically these `befs_block_run` and `befs_inode_addr` structs. They're defined as having an `allocation_group` field, which is a `u32`, and then there's this shift operation: `iaddr->allocation_group << BEFS_SB(sb)->ag_shift`. My initial thought was, "Hmm, what about potential overflow?" With an unsigned 32-bit integer, overflow isn't *undefined behavior* like it is with signed integers, but it can still lead to unexpected results if the `allocation_group` is very large.
Then I realized, wait, the `ag_shift` value is going to be determined by the `blocks_per_ag` parameter. Looking at the `befs_check_sb` function, it validates that `blocks_per_ag` *must* be a power of 2, and that `ag_shift` is equal to the base-2 logarithm of `blocks_per_ag` (calculated using `ilog2`). Now, a power of 2 can't be zero, as it's at least 1, and so the maximum value for `ag_shift` is going to be 31. The special case to avoid a shift of 32 (leading to undefined behaviour) is already taken care of. So, the shift operation on `allocation_group` is actually perfectly safe from overflow, as `ag_shift` is guaranteed to be within the valid range for unsigned integer shifts.
Next, I need to check the `block_shift` value. That one is related to the `block_size` of the filesystem. The code validates that `block_size` can be 1024, 2048, 4096, or 8192, and `block_shift` is equal to the base-2 logarithm of this `block_size`. That means `block_shift` can only be 10, 11, 12, or 13. And that's also perfectly safe.
I should probably double-check the rest of the BEFS code in this directory, though, to make sure there aren't any other shift operations I'm missing, but so far, so good.
|
| 72/4 |
2026/05/21 22:57 |
tool |
grepper |
0m
Args:
Results: map[Output:
Full output is too long, showing 500 out of 730354 lines.
Use more precise expression if possible.
[Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro=4=Description:
--
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro-40- +-----------------+------------+----------+----------------+----------------------------------------+
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro:41: | MCU (mem) | 1 | 1 | ERR1 | MCU # \| SLOT << 11 |
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro-42- +-----------------+------------+----------+----------------+----------------------------------------+
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro:43: | MCU (mem) | 1 | 2 | ERR2 | MCU # \| SLOT << 11 |
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro-44- +-----------------+------------+----------+----------------+----------------------------------------+
--
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro-54- +-----------------+------------+----------+----------------+----------------------------------------+
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro:55: | Mesh (other) | 2 | 0 | Cross Point | X \| (Y << 5) \| NS <<11 |
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro-56- +-----------------+------------+----------+----------------+----------------------------------------+
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro:57: | Mesh (other) | 2 | 1 | Home Node(IO) | X \| (Y << 5) \| NS <<11 |
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro-58- +-----------------+------------+----------+----------------+----------------------------------------+
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro:59: | Mesh (other) | 2 | 2 | Home Node(Mem) | X \| (Y << 5) \| NS <<11 \| device<<12 |
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro-60- +-----------------+------------+----------+----------------+----------------------------------------+
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro:61: | Mesh (other) | 2 | 4 | CCIX Node | X \| (Y << 5) \| NS <<11 |
Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro-62- +-----------------+------------+----------+----------------+----------------------------------------+
--
Documentation/admin-guide/blockdev/zram.rst=412=like below::
--
Documentation/admin-guide/blockdev/zram.rst-415- $ 4K_SHIFT=12
Documentation/admin-guide/blockdev/zram.rst:416: $ echo $((400<<MB_SHIFT>>4K_SHIFT)) > \
Documentation/admin-guide/blockdev/zram.rst-417- /sys/block/zram0/writeback_limit.
--
Documentation/admin-guide/blockdev/zram.rst=421=they could do it like below::
Documentation/admin-guide/blockdev/zram.rst-422-
Documentation/admin-guide/blockdev/zram.rst:423: $ echo $((400<<MB_SHIFT>>4K_SHIFT)) > \
Documentation/admin-guide/blockdev/zram.rst-424- /sys/block/zram0/writeback_limit
--
Documentation/admin-guide/dynamic-debug-howto.rst=88=Multiple commands can be written together, separated by ``;`` or ``\n``::
--
Documentation/admin-guide/dynamic-debug-howto.rst-90- :#> ddcmd "func pnpacpi_get_resources +p; func pnp_assign_mem +p"
Documentation/admin-guide/dynamic-debug-howto.rst:91: :#> ddcmd <<"EOC"
Documentation/admin-guide/dynamic-debug-howto.rst-92- func pnpacpi_get_resources +p
--
Documentation/admin-guide/java.rst=160=javaclassname.c:
--
Documentation/admin-guide/java.rst-243- eof_error();
Documentation/admin-guide/java.rst:244: return (u_int16_t)((b1 << 8) | b2);
Documentation/admin-guide/java.rst-245- }
--
Documentation/admin-guide/java.rst-349- {
Documentation/admin-guide/java.rst:350: int c = ((x & 0x1f) << 6) + (y & 0x3f);
Documentation/admin-guide/java.rst-351- if(c) putchar(c);
--
Documentation/admin-guide/kdump/gdbmacros.txt=173=define dump_record
--
Documentation/admin-guide/kdump/gdbmacros.txt-184-
Documentation/admin-guide/kdump/gdbmacros.txt:185: set var $begin = $desc->text_blk_lpos.begin % (1U << prb->text_data_ring.size_bits)
Documentation/admin-guide/kdump/gdbmacros.txt:186: set var $next = $desc->text_blk_lpos.next % (1U << prb->text_data_ring.size_bits)
Documentation/admin-guide/kdump/gdbmacros.txt-187-
--
Documentation/admin-guide/kdump/gdbmacros.txt=289=define dmesg
--
Documentation/admin-guide/kdump/gdbmacros.txt-294- set var $desc_flags_shift = $desc_sv_bits - 2
Documentation/admin-guide/kdump/gdbmacros.txt:295: set var $desc_flags_mask = 3 << $desc_flags_shift
Documentation/admin-guide/kdump/gdbmacros.txt-296- set var $id_mask = ~$desc_flags_mask
Documentation/admin-guide/kdump/gdbmacros.txt-297-
Documentation/admin-guide/kdump/gdbmacros.txt:298: set var $desc_count = 1U << prb->desc_ring.count_bits
Documentation/admin-guide/kdump/gdbmacros.txt-299- set var $prev_flags = 0
--
Documentation/admin-guide/kernel-parameters.txt=97=Kernel parameters
--
Documentation/admin-guide/kernel-parameters.txt-2618- Allocate an own aperture over RAM with size
Documentation/admin-guide/kernel-parameters.txt:2619: 32MB<<order. (default: order=1, i.e. 64MB)
Documentation/admin-guide/kernel-parameters.txt-2620-
--
Documentation/admin-guide/md.rst=53=other modes are only supported with persistent super blocks
--
Documentation/admin-guide/md.rst-59-
Documentation/admin-guide/md.rst:60:Set the chunk size as 4k << n.
Documentation/admin-guide/md.rst-61-
--
Documentation/admin-guide/nfs/pnfs-block-server.rst=27=how to translate the device into a serial number from SCSI EVPD 0x80::
Documentation/admin-guide/nfs/pnfs-block-server.rst-28-
Documentation/admin-guide/nfs/pnfs-block-server.rst:29: cat > /sbin/nfsd-recall-failed << EOF
Documentation/admin-guide/nfs/pnfs-block-server.rst-30-
--
Documentation/admin-guide/perf/hns3-pmu.rst=107=PF/VF, its conversion formula::
Documentation/admin-guide/perf/hns3-pmu.rst-108-
Documentation/admin-guide/perf/hns3-pmu.rst:109: func = (bus << 8) + (device << 3) + (function)
Documentation/admin-guide/perf/hns3-pmu.rst-110-
--
Documentation/admin-guide/perf/nvidia-tegra410-pmu.rst=163=The list of event filters:
--
Documentation/admin-guide/perf/nvidia-tegra410-pmu.rst-171- * src_bdf: the BDF that will be monitored. This is a 16-bit value that
Documentation/admin-guide/perf/nvidia-tegra410-pmu.rst:172: follows formula: (bus << 8) + (device << 3) + (function). For example, the
Documentation/admin-guide/perf/nvidia-tegra410-pmu.rst-173- value of BDF 27:01.1 is 0x2781.
--
Documentation/arch/arm64/kasan-offsets.sh=6=print_kasan_offset () {
Documentation/arch/arm64/kasan-offsets.sh-7- printf "%02d\t" $1
Documentation/arch/arm64/kasan-offsets.sh:8: printf "0x%08x00000000\n" $(( (0xffffffff & (-1 << ($1 - 1 - 32))) \
Documentation/arch/arm64/kasan-offsets.sh:9: - (1 << (64 - 32 - $2)) ))
Documentation/arch/arm64/kasan-offsets.sh-10-}
--
Documentation/arch/arm64/memory-tagging-extension.rst=250=Example of correct usage
--
Documentation/arch/arm64/memory-tagging-extension.rst-271- */
Documentation/arch/arm64/memory-tagging-extension.rst:272: #define HWCAP2_MTE (1 << 18)
Documentation/arch/arm64/memory-tagging-extension.rst-273-
--
Documentation/arch/arm64/memory-tagging-extension.rst-283- #define PR_GET_TAGGED_ADDR_CTRL 56
Documentation/arch/arm64/memory-tagging-extension.rst:284: # define PR_TAGGED_ADDR_ENABLE (1UL << 0)
Documentation/arch/arm64/memory-tagging-extension.rst-285- # define PR_MTE_TCF_SHIFT 1
Documentation/arch/arm64/memory-tagging-extension.rst:286: # define PR_MTE_TCF_NONE (0UL << PR_MTE_TCF_SHIFT)
Documentation/arch/arm64/memory-tagging-extension.rst:287: # define PR_MTE_TCF_SYNC (1UL << PR_MTE_TCF_SHIFT)
Documentation/arch/arm64/memory-tagging-extension.rst:288: # define PR_MTE_TCF_ASYNC (2UL << PR_MTE_TCF_SHIFT)
Documentation/arch/arm64/memory-tagging-extension.rst:289: # define PR_MTE_TCF_MASK (3UL << PR_MTE_TCF_SHIFT)
Documentation/arch/arm64/memory-tagging-extension.rst-290- # define PR_MTE_TAG_SHIFT 3
Documentation/arch/arm64/memory-tagging-extension.rst:291: # define PR_MTE_TAG_MASK (0xffffUL << PR_MTE_TAG_SHIFT)
Documentation/arch/arm64/memory-tagging-extension.rst-292-
--
Documentation/arch/arm64/memory-tagging-extension.rst-325- PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_SYNC | PR_MTE_TCF_ASYNC |
Documentation/arch/arm64/memory-tagging-extension.rst:326: (0xfffe << PR_MTE_TAG_SHIFT),
Documentation/arch/arm64/memory-tagging-extension.rst-327- 0, 0, 0)) {
--
Documentation/arch/arm64/tagged-address-abi.rst=134=failure.
--
Documentation/arch/arm64/tagged-address-abi.rst-146- #define PR_SET_TAGGED_ADDR_CTRL 55
Documentation/arch/arm64/tagged-address-abi.rst:147: #define PR_TAGGED_ADDR_ENABLE (1UL << 0)
Documentation/arch/arm64/tagged-address-abi.rst-148-
--
Documentation/arch/arm64/tagged-address-abi.rst-169- tag = rand() & 0xff;
Documentation/arch/arm64/tagged-address-abi.rst:170: ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
Documentation/arch/arm64/tagged-address-abi.rst-171-
--
Documentation/arch/powerpc/elfnote.rst=16=bitmap as "descriptor" field. Each bit is described below:
--
Documentation/arch/powerpc/elfnote.rst-21-
Documentation/arch/powerpc/elfnote.rst:22: #define PPCCAP_ULTRAVISOR_BIT (1 << 0)
Documentation/arch/powerpc/elfnote.rst-23-
--
Documentation/arch/powerpc/ptrace.rst=53=Sets a hardware breakpoint or watchpoint, according to the provided structure::
--
Documentation/arch/powerpc/ptrace.rst-73- #define PPC_BREAKPOINT_CONDITION_BE_ALL 0x00ff0000 /* byte enable bits */
Documentation/arch/powerpc/ptrace.rst:74: #define PPC_BREAKPOINT_CONDITION_BE(n) (1<<((n)+16))
Documentation/arch/powerpc/ptrace.rst-75- uint32_t condition_mode; /* break/watchpoint condition flags */
--
Documentation/arch/powerpc/transactional_memory.rst=127=Example signal handler::
--
Documentation/arch/powerpc/transactional_memory.rst-137- #ifndef __powerpc64__
Documentation/arch/powerpc/transactional_memory.rst:138: msr |= ((u64)transactional_ucp->uc_mcontext.regs->msr) << 32;
Documentation/arch/powerpc/transactional_memory.rst-139- #endif
--
Documentation/arch/s390/vfio-ccw.rst=250=from userspace::
Documentation/arch/s390/vfio-ccw.rst-251-
Documentation/arch/s390/vfio-ccw.rst:252: #define VFIO_CCW_ASYNC_CMD_HSCH (1 << 0)
Documentation/arch/s390/vfio-ccw.rst:253: #define VFIO_CCW_ASYNC_CMD_CSCH (1 << 1)
Documentation/arch/s390/vfio-ccw.rst-254- struct ccw_cmd_region {
--
Documentation/arch/sparc/adi.rst=160=functionality::
--
Documentation/arch/sparc/adi.rst-247- */
Documentation/arch/sparc/adi.rst:248: tmp_addr = (void *) ((unsigned long)shmaddr << adi_nbits);
Documentation/arch/sparc/adi.rst-249- tmp_addr = (void *) ((unsigned long)tmp_addr >> adi_nbits);
Documentation/arch/sparc/adi.rst:250: veraddr = (void *) (((unsigned long)version << (64-adi_nbits))
Documentation/arch/sparc/adi.rst-251- | (unsigned long)tmp_addr);
--
Documentation/arch/sparc/oradax/oracle-dax.rst=305=describes the Scan command in detail::
--
Documentation/arch/sparc/oradax/oracle-dax.rst-307- ccb->control = /* Table 36.1, CCB Header Format */
Documentation/arch/sparc/oradax/oracle-dax.rst:308: (2L << 48) /* command = Scan Value */
Documentation/arch/sparc/oradax/oracle-dax.rst:309: | (3L << 40) /* output address type = primary virtual */
Documentation/arch/sparc/oradax/oracle-dax.rst:310: | (3L << 34) /* primary input address type = primary virtual */
Documentation/arch/sparc/oradax/oracle-dax.rst-311- /* Section 36.2.1, Query CCB Command Formats */
Documentation/arch/sparc/oradax/oracle-dax.rst:312: | (1 << 28) /* 36.2.1.1.1 primary input format = fixed width bit packed */
Documentation/arch/sparc/oradax/oracle-dax.rst:313: | (0 << 23) /* 36.2.1.1.2 primary input element size = 0 (1 bit) */
Documentation/arch/sparc/oradax/oracle-dax.rst:314: | (8 << 10) /* 36.2.1.1.6 output format = bit vector */
Documentation/arch/sparc/oradax/oracle-dax.rst:315: | (0 << 5) /* 36.2.1.3 First scan criteria size = 0 (1 byte) */
Documentation/arch/sparc/oradax/oracle-dax.rst:316: | (31 << 0); /* 36.2.1.3 Disable second scan criteria */
Documentation/arch/sparc/oradax/oracle-dax.rst-317-
--
Documentation/arch/sparc/oradax/oracle-dax.rst-322- ccb->access = /* Section 36.2.1.2, Data Access Control */
Documentation/arch/sparc/oradax/oracle-dax.rst:323: (2 << 24) /* Primary input length format = bits */
Documentation/arch/sparc/oradax/oracle-dax.rst-324- | (nbits - 1); /* number of bits in primary input stream, minus 1 */
--
Documentation/arch/sparc/oradax/oracle-dax.rst=392=type must be given in the CCB::
--
Documentation/arch/sparc/oradax/oracle-dax.rst-394- ccb->control |= /* Table 36.1, CCB Header Format */
Documentation/arch/sparc/oradax/oracle-dax.rst:395: (3L << 32); /* completion area address type = primary virtual */
Documentation/arch/sparc/oradax/oracle-dax.rst-396-
--
Documentation/arch/x86/amd-memory-encryption.rst=216=the RMP segment coverage value is 0x24 => 36, meaning the size of memory
Documentation/arch/x86/amd-memory-encryption.rst:217:covered by an RMP segment is 64GB (1 << 36). So the first RMP segment
Documentation/arch/x86/amd-memory-encryption.rst-218-covers physical addresses from 0 to 0xF_FFFF_FFFF, the second RMP segment
--
Documentation/arch/x86/boot.rst=365=Protocol: 2.00+
--
Documentation/arch/x86/boot.rst-367-
Documentation/arch/x86/boot.rst:368: Contains the boot protocol version, in (major << 8) + minor format,
Documentation/arch/x86/boot.rst-369- e.g. 0x0204 for version 2.04, and 0x0a11 for a hypothetical version
--
Documentation/arch/x86/boot.rst=587=Protocol: 2.02+
--
Documentation/arch/x86/boot.rst-591- type_of_loader field. The total version number is considered to be
Documentation/arch/x86/boot.rst:592: (type_of_loader & 0x0f) + (ext_loader_ver << 4).
Documentation/arch/x86/boot.rst-593-
--
Documentation/arch/x86/boot.rst=681=Protocol: 2.10+
--
Documentation/arch/x86/boot.rst-688-
Documentation/arch/x86/boot.rst:689: kernel_alignment = 1 << min_alignment;
Documentation/arch/x86/boot.rst-690-
--
Documentation/arch/x86/boot.rst=1215=conflict with actual kernel options now or in the future.
--
Documentation/arch/x86/boot.rst-1226- <size> is an integer in C notation optionally followed by
Documentation/arch/x86/boot.rst:1227: (case insensitive) K, M, G, T, P or E (meaning << 10, << 20,
Documentation/arch/x86/boot.rst:1228: << 30, << 40, << 50 or << 60). This specifies the end of
Documentation/arch/x86/boot.rst-1229- memory to the kernel. This affects the possible placement of
--
Documentation/arch/x86/x86_64/fsgs.rst=90=FSGSBASE instructions enablement
--
Documentation/arch/x86/x86_64/fsgs.rst-114- #ifndef HWCAP2_FSGSBASE
Documentation/arch/x86/x86_64/fsgs.rst:115: #define HWCAP2_FSGSBASE (1 << 1)
Documentation/arch/x86/x86_64/fsgs.rst-116- #endif
--
Documentation/arch/x86/xstate.rst=87=TILE_DATA dynamically:
--
Documentation/arch/x86/xstate.rst-108-
Documentation/arch/x86/xstate.rst:109: #define MASK_XCOMP_TILE ((1 << ARCH_XCOMP_TILECFG) | \
Documentation/arch/x86/xstate.rst:110: (1 << ARCH_XCOMP_TILEDATA))
Documentation/arch/x86/xstate.rst-111-
--
Documentation/block/ioprio.rst=60=ionice.c tool::
--
Documentation/block/ioprio.rst-164- } else {
Documentation/block/ioprio.rst:165: if (ioprio_set(IOPRIO_WHO_PROCESS, pid, ioprio | ioprio_class << IOPRIO_CLASS_SHIFT) == -1) {
Documentation/block/ioprio.rst-166- perror("ioprio_set");
--
Documentation/bpf/btf.rst=142=The ``BTF_INT_ENCODING`` has the following attributes::
Documentation/bpf/btf.rst-143-
Documentation/bpf/btf.rst:144: #define BTF_INT_SIGNED (1 << 0)
Documentation/bpf/btf.rst:145: #define BTF_INT_CHAR (1 << 1)
Documentation/bpf/btf.rst:146: #define BTF_INT_BOOL (1 << 2)
Documentation/bpf/btf.rst-147-
--
Documentation/bpf/llvm_reloc.rst=304=Notes:
--
Documentation/bpf/llvm_reloc.rst-319- v = *({s|u}<sz> *)((void *)s + off)
Documentation/bpf/llvm_reloc.rst:320: v <<= l
Documentation/bpf/llvm_reloc.rst-321- v >>= r
--
Documentation/bpf/standardization/instruction-set.rst=323=register.
--
Documentation/bpf/standardization/instruction-set.rst-336- AND 0x5 0 dst &= src
Documentation/bpf/standardization/instruction-set.rst:337: LSH 0x6 0 dst <<= (src & mask)
Documentation/bpf/standardization/instruction-set.rst-338- RSH 0x7 0 dst >>= (src & mask)
--
Documentation/bpf/standardization/instruction-set.rst=733=defined further below:
--
Documentation/bpf/standardization/instruction-set.rst-739- ======= ========================================= =========== ==============
Documentation/bpf/standardization/instruction-set.rst:740: 0x0 dst = (next_imm << 32) | imm integer integer
Documentation/bpf/standardization/instruction-set.rst-741- 0x1 dst = map_by_fd(imm) map fd map
--
Documentation/bpf/verifier.rst=235=More complex packet access may look like::
--
Documentation/bpf/verifier.rst-244- 11: r2 = r1
Documentation/bpf/verifier.rst:245: 12: r2 <<= 48
Documentation/bpf/verifier.rst-246- 13: r2 >>= 48
--
Documentation/crypto/descore-readme.rst=33=Author's address: how@isl.stanford.edu
--
Documentation/crypto/descore-readme.rst-36-
Documentation/crypto/descore-readme.rst:37:==>> To compile after untarring/unsharring, just ``make`` <<==
Documentation/crypto/descore-readme.rst-38-
--
Documentation/dev-tools/checkpatch.rst=639=Indentation and Line Breaks
--
Documentation/dev-tools/checkpatch.rst-664- case 'g':
Documentation/dev-tools/checkpatch.rst:665: mem <<= 30;
Documentation/dev-tools/checkpatch.rst-666- break;
--
Documentation/dev-tools/checkpatch.rst-668- case 'm':
Documentation/dev-tools/checkpatch.rst:669: mem <<= 20;
Documentation/dev-tools/checkpatch.rst-670- break;
--
Documentation/dev-tools/checkpatch.rst-672- case 'k':
Documentation/dev-tools/checkpatch.rst:673: mem <<= 10;
Documentation/dev-tools/checkpatch.rst-674- fallthrough;
--
Documentation/dev-tools/checkpatch.rst=753=Macros, Attributes and Symbols
--
Documentation/dev-tools/checkpatch.rst-781- **BIT_MACRO**
Documentation/dev-tools/checkpatch.rst:782: Defines like: 1 << <digit> could be BIT(digit).
Documentation/dev-tools/checkpatch.rst-783- The BIT() macro is defined via include/linux/bits.h::
Documentation/dev-tools/checkpatch.rst-784-
Documentation/dev-tools/checkpatch.rst:785: #define BIT(nr) (1UL << (nr))
Documentation/dev-tools/checkpatch.rst-786-
--
Documentation/dev-tools/checkuapi.rst=54=won't break userspace::
Documentation/dev-tools/checkuapi.rst-55-
Documentation/dev-tools/checkuapi.rst:56: cat << 'EOF' | patch -l -p1
Documentation/dev-tools/checkuapi.rst-57- --- a/include/uapi/linux/acct.h
--
Documentation/dev-tools/checkuapi.rst=81=Let's add another change that *might* break userspace::
Documentation/dev-tools/checkuapi.rst-82-
Documentation/dev-tools/checkuapi.rst:83: cat << 'EOF' | patch -l -p1
Documentation/dev-tools/checkuapi.rst-84- --- a/include/uapi/linux/bpf.h
--
Documentation/dev-tools/checkuapi.rst=129=Now, let's make a similar change that *will* break userspace::
Documentation/dev-tools/checkuapi.rst-130-
Documentation/dev-tools/checkuapi.rst:131: cat << 'EOF' | patch -l -p1
Documentation/dev-tools/checkuapi.rst-132- --- a/include/uapi/linux/bpf.h
--
Documentation/dev-tools/checkuapi.rst=207=Consider this change::
Documentation/dev-tools/checkuapi.rst-208-
Documentation/dev-tools/checkuapi.rst:209: cat << 'EOF' | patch -l -p1
Documentation/dev-tools/checkuapi.rst-210- --- a/arch/arm64/include/uapi/asm/sigcontext.h
--
Documentation/dev-tools/checkuapi.rst=264=Consider this change::
Documentation/dev-tools/checkuapi.rst-265-
Documentation/dev-tools/checkuapi.rst:266: cat << 'EOF' | patch -l -p1
Documentation/dev-tools/checkuapi.rst-267- --- a/include/uapi/linux/types.h
--
Documentation/dev-tools/checkuapi.rst=310=Consider this change::
Documentation/dev-tools/checkuapi.rst-311-
Documentation/dev-tools/checkuapi.rst:312: cat << 'EOF' | patch -l -p1
Documentation/dev-tools/checkuapi.rst-313- diff --git a/include/uapi/asm-generic/Kbuild b/include/uapi/asm-generic/Kbuild
--
Documentation/dev-tools/coccinelle.rst=375=will execute the following part of the SmPL script::
--
Documentation/dev-tools/coccinelle.rst-385- @script:python depends on report@
Documentation/dev-tools/coccinelle.rst:386: p << r.p;
Documentation/dev-tools/coccinelle.rst:387: x << r.x;
Documentation/dev-tools/coccinelle.rst-388- @@
--
Documentation/dev-tools/coccinelle.rst=498=will execute the following part of the SmPL script::
--
Documentation/dev-tools/coccinelle.rst-508- @script:python depends on org@
Documentation/dev-tools/coccinelle.rst:509: p << r.p;
Documentation/dev-tools/coccinelle.rst:510: x << r.x;
Documentation/dev-tools/coccinelle.rst-511- @@
--
Documentation/dev-tools/kcov.rst=47=single syscall from within a test program:
--
Documentation/dev-tools/kcov.rst-65- #define KCOV_DISABLE _IO('c', 101)
Documentation/dev-tools/kcov.rst:66: #define COVER_SIZE (64<<10)
Documentation/dev-tools/kcov.rst-67-
--
Documentation/dev-tools/kcov.rst=143=Comparison operands collection is similar to coverage collection:
--
Documentation/dev-tools/kcov.rst-158-
Documentation/dev-tools/kcov.rst:159: #define KCOV_CMP_CONST (1 << 0)
Documentation/dev-tools/kcov.rst:160: #define KCOV_CMP_SIZE(n) ((n) << 1)
Documentation/dev-tools/kcov.rst-161- #define KCOV_CMP_MASK KCOV_CMP_SIZE(3)
--
Documentation/dev-tools/kcov.rst-198- /* size of the operands. */
Documentation/dev-tools/kcov.rst:199: size = 1 << ((type & KCOV_CMP_MASK) >> 1);
Documentation/dev-tools/kcov.rst-200- /* is_const - true if either operand is a compile-time constant.*/
--
Documentation/dev-tools/kcov.rst=288=local tasks spawned by the process and the global task that handles USB bus #1:
--
Documentation/dev-tools/kcov.rst-305-
Documentation/dev-tools/kcov.rst:306: #define COVER_SIZE (64 << 10)
Documentation/dev-tools/kcov.rst-307-
--
Documentation/dev-tools/kcov.rst-309-
Documentation/dev-tools/kcov.rst:310: #define KCOV_SUBSYSTEM_COMMON (0x00ull << 56)
Documentation/dev-tools/kcov.rst:311: #define KCOV_SUBSYSTEM_USB (0x01ull << 56)
Documentation/dev-tools/kcov.rst-312-
Documentation/dev-tools/kcov.rst:313: #define KCOV_SUBSYSTEM_MASK (0xffull << 56)
Documentation/dev-tools/kcov.rst-314- #define KCOV_INSTANCE_MASK (0xffffffffull)
--
Documentation/dev-tools/kunit/usage.rst=613=Custom Parameter Generator Function:
--
Documentation/dev-tools/kunit/usage.rst-645- if (prev)
Documentation/dev-tools/kunit/usage.rst:646: next_buffer_size = prev_buffer_size << 1;
Documentation/dev-tools/kunit/usage.rst-647-
--
Documentation/devicetree/bindings/bus/mvebu-mbus.txt=145=a special macro that can be use to simplify the translation entries:
Documentation/devicetree/bindings/bus/mvebu-mbus.txt-146-
Documentation/devicetree/bindings/bus/mvebu-mbus.txt:147:#define MBUS_ID(target,attributes) (((target) << 24) | ((attributes) << 16))
Documentation/devicetree/bindings/bus/mvebu-mbus.txt-148-
--
Documentation/devicetree/bindings/cache/marvell,tauros2-cache.yaml=13=properties:
--
Documentation/devicetree/bindings/cache/marvell,tauros2-cache.yaml-20-
Documentation/devicetree/bindings/cache/marvell,tauros2-cache.yaml:21: - CACHE_TAUROS2_PREFETCH_ON (1 << 0)
Documentation/devicetree/bindings/cache/marvell,tauros2-cache.yaml:22: - CACHE_TAUROS2_LINEFILL_BURST8 (1 << 1)
Documentation/devicetree/bindings/cache/marvell,tauros2-cache.yaml-23-
--
Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml=21=properties:
--
Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml-42- encodes the row/column as:
Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml:43: (((row) & 0xFF) << 24) | (((column) & 0xFF) << 16)
Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml-44- where the lower 16 bits are reserved. This property is specified only
--
Documentation/devicetree/bindings/input/matrix-keymap.yaml=22=properties:
--
Documentation/devicetree/bindings/input/matrix-keymap.yaml-27- column and linux key-code. The 32-bit big endian cell is packed as:
Documentation/devicetree/bindings/input/matrix-keymap.yaml:28: row << 24 | column << 16 | key-code
Documentation/devicetree/bindings/input/matrix-keymap.yaml-29-
--
Documentation/devicetree/bindings/mfd/hi6421.txt=18=Example:
--
Documentation/devicetree/bindings/mfd/hi6421.txt-20- compatible = "hisilicon,hi6421-pmic";
Documentation/devicetree/bindings/mfd/hi6421.txt:21: reg = <0xfcc00000 0x0180>; /* 0x60 << 2 */
Documentation/devicetree/bindings/mfd/hi6421.txt-22-
--
Documentation/devicetree/bindings/net/marvell,dfx-server.yaml=46=examples:
--
Documentation/devicetree/bindings/net/marvell,dfx-server.yaml-48-
Documentation/devicetree/bindings/net/marvell,dfx-server.yaml:49: #define MBUS_ID(target,attributes) (((target) << 24) | ((attributes) << 16))
Documentation/devicetree/bindings/net/marvell,dfx-server.yaml-50- bus@0 {
--
Documentation/devicetree/bindings/net/mctp-i2c-controller.yaml=22=properties:
--
Documentation/devicetree/bindings/net/mctp-i2c-controller.yaml-30- 7 bit I2C address of the local endpoint.
Documentation/devicetree/bindings/net/mctp-i2c-controller.yaml:31: I2C_OWN_SLAVE_ADDRESS (1<<30) flag must be set.
Documentation/devicetree/bindings/net/mctp-i2c-controller.yaml-32-
--
Documentation/devicetree/bindings/pci/host-generic-pci.yaml=12=description: |
--
Documentation/devicetree/bindings/pci/host-generic-pci.yaml-28- cfg_offset(bus, device, function, register) =
Documentation/devicetree/bindings/pci/host-generic-pci.yaml:29: bus << 16 | device << 11 | function << 8 | register
Documentation/devicetree/bindings/pci/host-generic-pci.yaml-30-
--
Documentation/devicetree/bindings/pci/host-generic-pci.yaml-33- cfg_offset(bus, device, function, register) =
Documentation/devicetree/bindings/pci/host-generic-pci.yaml:34: bus << 20 | device << 15 | function << 12 | register
Documentation/devicetree/bindings/pci/host-generic-pci.yaml-35-
--
Documentation/devicetree/bindings/pci/marvell,kirkwood-pcie.yaml=120=examples:
Documentation/devicetree/bindings/pci/marvell,kirkwood-pcie.yaml-121- - |
Documentation/devicetree/bindings/pci/marvell,kirkwood-pcie.yaml:122: #define MBUS_ID(target,attributes) (((target) << 24) | ((attributes) << 16))
Documentation/devicetree/bindings/pci/marvell,kirkwood-pcie.yaml-123-
--
Documentation/devicetree/bindings/pci/pci-ep.yaml=16=properties:
--
Documentation/devicetree/bindings/pci/pci-ep.yaml-78-
Documentation/devicetree/bindings/pci/pci-ep.yaml:79: (func & 0x7) | (vfunc << 3)
Documentation/devicetree/bindings/pci/pci-ep.yaml-80-
--
Documentation/devicetree/bindings/pinctrl/atmel,at91rm9200-pinctrl.yaml=19=properties:
--
Documentation/devicetree/bindings/pinctrl/atmel,at91rm9200-pinctrl.yaml-66- For each peripheral/bank we will describe in a u32 if a pin can be
Documentation/devicetree/bindings/pinctrl/atmel,at91rm9200-pinctrl.yaml:67: configured in it by putting 1 to the pin bit (1 << pin)
Documentation/devicetree/bindings/pinctrl/atmel,at91rm9200-pinctrl.yaml-68-
--
Documentation/devicetree/bindings/pinctrl/cix,sky1-pinctrl.yaml=77=examples:
Documentation/devicetree/bindings/pinctrl/cix,sky1-pinctrl.yaml-78- - |
Documentation/devicetree/bindings/pinctrl/cix,sky1-pinctrl.yaml:79: #define CIX_PAD_GPIO012_FUNC_GPIO012 (11 << 8 | 0x0)
Documentation/devicetree/bindings/pinctrl/cix,sky1-pinctrl.yaml-80- pinctrl@4170000 {
--
Documentation/devicetree/bindings/pinctrl/fsl,imx-pinctrl.txt=32=Bits used for CONFIG:
Documentation/devicetree/bindings/pinctrl/fsl,imx-pinctrl.txt:33:NO_PAD_CTL(1 << 31): indicate this pin does not need config.
Documentation/devicetree/bindings/pinctrl/fsl,imx-pinctrl.txt-34-
Documentation/devicetree/bindings/pinctrl/fsl,imx-pinctrl.txt:35:SION(1 << 30): Software Input On Field.
Documentation/devicetree/bindings/pinctrl/fsl,imx-pinctrl.txt-36-Force the selected mux mode input path no matter of MUX_MODE functionality.
--
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt=6=CONFIG bits definition:
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt:7:PAD_CTL_HYS (1 << 8)
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt:8:PAD_CTL_PKE (1 << 7)
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt:9:PAD_CTL_PUE (1 << 6)
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt:10:PAD_CTL_PUS_100K_DOWN (0 << 4)
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt:11:PAD_CTL_PUS_47K_UP (1 << 4)
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt:12:PAD_CTL_PUS_100K_UP (2 << 4)
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt:13:PAD_CTL_PUS_22K_UP (3 << 4)
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt:14:PAD_CTL_ODE_CMOS (0 << 3)
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt:15:PAD_CTL_ODE_OPENDRAIN (1 << 3)
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt:16:PAD_CTL_DSE_NOMINAL (0 << 1)
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt:17:PAD_CTL_DSE_HIGH (1 << 1)
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt:18:PAD_CTL_DSE_MAX (2 << 1)
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt:19:PAD_CTL_SRE_FAST (1 << 0)
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt:20:PAD_CTL_SRE_SLOW (0 << 0)
Documentation/devicetree/bindings/pinctrl/fsl,imx25-pinctrl.txt-21-
--
Documentation/devicetree/bindings/pinctrl/fsl,imx27-iomuxc.yaml=33=patternProperties:
--
Documentation/devicetree/bindings/pinctrl/fsl,imx27-iomuxc.yaml-57- - description: |
Documentation/devicetree/bindings/pinctrl/fsl,imx27-iomuxc.yaml:58: MUX_ID is function + (direction << 2) + (gpio_oconf << 4)
Documentation/devicetree/bindings/pinctrl/fsl,imx27-iomuxc.yaml:59: + (gpio_iconfa << 8) + (gpio_iconfb << 10)
Documentation/devicetree/bindings/pinctrl/fsl,imx27-iomuxc.yaml-60-
--
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml=42=patternProperties:
--
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml-73- Common i.MX35
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:74: PAD_CTL_DRIVE_VOLAGAGE_18 (1 << 13)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:75: PAD_CTL_DRIVE_VOLAGAGE_33 (0 << 13)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:76: PAD_CTL_HYS (1 << 8)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:77: PAD_CTL_PKE (1 << 7)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:78: PAD_CTL_PUE (1 << 6)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:79: PAD_CTL_PUS_100K_DOWN (0 << 4)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:80: PAD_CTL_PUS_47K_UP (1 << 4)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:81: PAD_CTL_PUS_100K_UP (2 << 4)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:82: PAD_CTL_PUS_22K_UP (3 << 4)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:83: PAD_CTL_ODE_CMOS (0 << 3)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:84: PAD_CTL_ODE_OPENDRAIN (1 << 3)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:85: PAD_CTL_DSE_NOMINAL (0 << 1)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:86: PAD_CTL_DSE_HIGH (1 << 1)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:87: PAD_CTL_DSE_MAX (2 << 1)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:88: PAD_CTL_SRE_FAST (1 << 0)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:89: PAD_CTL_SRE_SLOW (0 << 0)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml-90- Common i.MX50/i.MX51/i.MX53 bits
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:91: PAD_CTL_HVE (1 << 13)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:92: PAD_CTL_HYS (1 << 8)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:93: PAD_CTL_PKE (1 << 7)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:94: PAD_CTL_PUE (1 << 6)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:95: PAD_CTL_PUS_100K_DOWN (0 << 4)
Documentation/devicetree/bindings/pinctrl/fsl,imx35-pinctrl.yaml:96: PAD_CTL_PUS_47K_UP (1 << 4)
]
]
|
| 73/4 |
2026/05/21 22:57 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 92658
output: 20
thoughts: 17
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Checking `fs/befs/` for `<<` β Revisited**
Alright, let's circle back to that `fs/befs/` directory and see what's what. I need to re-examine that location with a fresh perspective. I'm specifically looking for any instances of the `<<` operator. We've seen it before, but given the nuances of this system, it's worth a second, more focused look. I suspect we missed something, or perhaps the context has shifted since our last analysis. My goal here is to either confirm its previous meaning or identify any new functionality or potential side effects it might now be exhibiting. A quick, targeted sweep of that directory should refresh my memory and highlight any changes. I'm expecting this to be a quick hit, but I'm prepared to dig deeper if the initial scan raises any flags. This is likely a key piece of the puzzle.
|
| 74/4 |
2026/05/21 22:57 |
tool |
grepper |
0m
Error:
Args: map[Expression:<<.*fs/befs]
Results:
|
| 75/4 |
2026/05/21 22:57 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 92919
output: 25
thoughts: 130
Thoughts: **Navigating the Code Search Landscape**
Okay, so I'm trying to efficiently find something within this codebase. Right, `git grep` - that regex is the search *expression*, the directory is just an *argument*. Got it. Now, this `grepper` tool... seems like it doesn't do the directory filtering itself. Can I somehow leverage `git grep` *through* `grepper`? Hmm, no, `grepper` just seems to expect a bare expression.
Alright, think bigger picture. What are my alternatives? I could use `codesearch-find-references`, or maybe the `codesearch-file-index` function... or, I could just, you know, manually read the relevant files directly. I've already scanned `fs/befs/super.c` and `fs/befs/befs.h` - they didn't hold the key. Okay, let's now check `fs/befs/linuxvfs.c`. Let's see what's in there.
|
| 76/4 |
2026/05/21 22:57 |
tool |
read-file |
0m
Args: map[File:fs/befs/linuxvfs.c]
Results: map[Contents:// SPDX-License-Identifier: GPL-2.0-only
/*
* linux/fs/befs/linuxvfs.c
*
* Copyright (C) 2001 Will Dyson <will_dyson@pobox.com
*
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/fs_context.h>
#include <linux/fs_parser.h>
#include <linux/errno.h>
#include <linux/filelock.h>
#include <linux/stat.h>
#include <linux/nls.h>
#include <linux/buffer_head.h>
#include <linux/vfs.h>
#include <linux/namei.h>
#include <linux/sched.h>
#include <linux/cred.h>
#include <linux/exportfs.h>
#include <linux/seq_file.h>
#include <linux/blkdev.h>
#include "befs.h"
#include "btree.h"
#include "inode.h"
#include "datastream.h"
#include "super.h"
#include "io.h"
MODULE_DESCRIPTION("BeOS File System (BeFS) driver");
MODULE_AUTHOR("Will Dyson");
MODULE_LICENSE("GPL");
/* The units the vfs expects inode->i_blocks to be in */
#define VFS_BLOCK_SIZE 512
static int befs_readdir(struct file *, struct dir_context *);
static int befs_get_block(struct inode *, sector_t, struct buffer_head *, int);
static int befs_read_folio(struct file *file, struct folio *folio);
static sector_t befs_bmap(struct address_space *mapping, sector_t block);
static struct dentry *befs_lookup(struct inode *, struct dentry *,
unsigned int);
static struct inode *befs_iget(struct super_block *, unsigned long);
static struct inode *befs_alloc_inode(struct super_block *sb);
static void befs_free_inode(struct inode *inode);
static void befs_destroy_inodecache(void);
static int befs_symlink_read_folio(struct file *, struct folio *);
static int befs_utf2nls(struct super_block *sb, const char *in, int in_len,
char **out, int *out_len);
static int befs_nls2utf(struct super_block *sb, const char *in, int in_len,
char **out, int *out_len);
static void befs_put_super(struct super_block *);
static int befs_statfs(struct dentry *, struct kstatfs *);
static int befs_show_options(struct seq_file *, struct dentry *);
static struct dentry *befs_fh_to_dentry(struct super_block *sb,
struct fid *fid, int fh_len, int fh_type);
static struct dentry *befs_fh_to_parent(struct super_block *sb,
struct fid *fid, int fh_len, int fh_type);
static struct dentry *befs_get_parent(struct dentry *child);
static void befs_free_fc(struct fs_context *fc);
static const struct super_operations befs_sops = {
.alloc_inode = befs_alloc_inode, /* allocate a new inode */
.free_inode = befs_free_inode, /* deallocate an inode */
.put_super = befs_put_super, /* uninit super */
.statfs = befs_statfs, /* statfs */
.show_options = befs_show_options,
};
/* slab cache for befs_inode_info objects */
static struct kmem_cache *befs_inode_cachep;
static const struct file_operations befs_dir_operations = {
.read = generic_read_dir,
.iterate_shared = befs_readdir,
.llseek = generic_file_llseek,
.setlease = generic_setlease,
};
static const struct inode_operations befs_dir_inode_operations = {
.lookup = befs_lookup,
};
static const struct address_space_operations befs_aops = {
.read_folio = befs_read_folio,
.bmap = befs_bmap,
};
static const struct address_space_operations befs_symlink_aops = {
.read_folio = befs_symlink_read_folio,
};
static const struct export_operations befs_export_operations = {
.encode_fh = generic_encode_ino32_fh,
.fh_to_dentry = befs_fh_to_dentry,
.fh_to_parent = befs_fh_to_parent,
.get_parent = befs_get_parent,
};
/*
* Called by generic_file_read() to read a folio of data
*
* In turn, simply calls a generic block read function and
* passes it the address of befs_get_block, for mapping file
* positions to disk blocks.
*/
static int befs_read_folio(struct file *file, struct folio *folio)
{
return block_read_full_folio(folio, befs_get_block);
}
static sector_t
befs_bmap(struct address_space *mapping, sector_t block)
{
return generic_block_bmap(mapping, block, befs_get_block);
}
/*
* Generic function to map a file position (block) to a
* disk offset (passed back in bh_result).
*
* Used by many higher level functions.
*
* Calls befs_fblock2brun() in datastream.c to do the real work.
*/
static int
befs_get_block(struct inode *inode, sector_t block,
struct buffer_head *bh_result, int create)
{
struct super_block *sb = inode->i_sb;
befs_data_stream *ds = &BEFS_I(inode)->i_data.ds;
befs_block_run run = BAD_IADDR;
int res;
ulong disk_off;
befs_debug(sb, "---> befs_get_block() for inode %llu, block %ld",
inode->i_ino, (long)block);
if (create) {
befs_error(sb, "befs_get_block() was asked to write to "
"block %ld in inode %llu", (long)block,
inode->i_ino);
return -EPERM;
}
res = befs_fblock2brun(sb, ds, block, &run);
if (res != BEFS_OK) {
befs_error(sb,
"<--- %s for inode %llu, block %ld ERROR",
__func__, inode->i_ino,
(long)block);
return -EFBIG;
}
disk_off = (ulong) iaddr2blockno(sb, &run);
map_bh(bh_result, inode->i_sb, disk_off);
befs_debug(sb, "<--- %s for inode %llu, block %ld, disk address %lu",
__func__, inode->i_ino, (long)block,
(unsigned long)disk_off);
return 0;
}
static struct dentry *
befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
{
struct inode *inode;
struct super_block *sb = dir->i_sb;
const befs_data_stream *ds = &BEFS_I(dir)->i_data.ds;
befs_off_t offset;
int ret;
int utfnamelen;
char *utfname;
const char *name = dentry->d_name.name;
befs_debug(sb, "---> %s name %pd inode %llu", __func__,
dentry, dir->i_ino);
/* Convert to UTF-8 */
if (BEFS_SB(sb)->nls) {
ret =
befs_nls2utf(sb, name, strlen(name), &utfname, &utfnamelen);
if (ret < 0) {
befs_debug(sb, "<--- %s ERROR", __func__);
return ERR_PTR(ret);
}
ret = befs_btree_find(sb, ds, utfname, &offset);
kfree(utfname);
} else {
ret = befs_btree_find(sb, ds, name, &offset);
}
if (ret == BEFS_BT_NOT_FOUND) {
befs_debug(sb, "<--- %s %pd not found", __func__, dentry);
inode = NULL;
} else if (ret != BEFS_OK || offset == 0) {
befs_error(sb, "<--- %s Error", __func__);
inode = ERR_PTR(-ENODATA);
} else {
inode = befs_iget(dir->i_sb, (ino_t) offset);
}
befs_debug(sb, "<--- %s", __func__);
return d_splice_alias(inode, dentry);
}
static int
befs_readdir(struct file *file, struct dir_context *ctx)
{
struct inode *inode = file_inode(file);
struct super_block *sb = inode->i_sb;
const befs_data_stream *ds = &BEFS_I(inode)->i_data.ds;
befs_off_t value;
int result;
size_t keysize;
char keybuf[BEFS_NAME_LEN + 1];
befs_debug(sb, "---> %s name %pD, inode %llu, ctx->pos %lld",
__func__, file, inode->i_ino, ctx->pos);
while (1) {
result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1,
keybuf, &keysize, &value);
if (result == BEFS_ERR) {
befs_debug(sb, "<--- %s ERROR", __func__);
befs_error(sb, "IO error reading %pD (inode %llu)",
file, inode->i_ino);
return -EIO;
} else if (result == BEFS_BT_END) {
befs_debug(sb, "<--- %s END", __func__);
return 0;
} else if (result == BEFS_BT_EMPTY) {
befs_debug(sb, "<--- %s Empty directory", __func__);
return 0;
}
/* Convert to NLS */
if (BEFS_SB(sb)->nls) {
char *nlsname;
int nlsnamelen;
result =
befs_utf2nls(sb, keybuf, keysize, &nlsname,
&nlsnamelen);
if (result < 0) {
befs_debug(sb, "<--- %s ERROR", __func__);
return result;
}
if (!dir_emit(ctx, nlsname, nlsnamelen,
(ino_t) value, DT_UNKNOWN)) {
kfree(nlsname);
return 0;
}
kfree(nlsname);
} else {
if (!dir_emit(ctx, keybuf, keysize,
(ino_t) value, DT_UNKNOWN))
return 0;
}
ctx->pos++;
}
}
static struct inode *
befs_alloc_inode(struct super_block *sb)
{
struct befs_inode_info *bi;
bi = alloc_inode_sb(sb, befs_inode_cachep, GFP_KERNEL);
if (!bi)
return NULL;
return &bi->vfs_inode;
}
static void befs_free_inode(struct inode *inode)
{
kmem_cache_free(befs_inode_cachep, BEFS_I(inode));
}
static void init_once(void *foo)
{
struct befs_inode_info *bi = (struct befs_inode_info *) foo;
inode_init_once(&bi->vfs_inode);
}
static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
{
struct buffer_head *bh;
befs_inode *raw_inode;
struct befs_sb_info *befs_sb = BEFS_SB(sb);
struct befs_inode_info *befs_ino;
struct inode *inode;
befs_debug(sb, "---> %s inode = %lu", __func__, ino);
inode = iget_locked(sb, ino);
if (!inode)
return ERR_PTR(-ENOMEM);
if (!(inode_state_read_once(inode) & I_NEW))
return inode;
befs_ino = BEFS_I(inode);
/* convert from vfs's inode number to befs's inode number */
befs_ino->i_inode_num = blockno2iaddr(sb, inode->i_ino);
befs_debug(sb, " real inode number [%u, %hu, %hu]",
befs_ino->i_inode_num.allocation_group,
befs_ino->i_inode_num.start, befs_ino->i_inode_num.len);
bh = sb_bread(sb, inode->i_ino);
if (!bh) {
befs_error(sb, "unable to read inode block - "
"inode = %llu", inode->i_ino);
goto unacquire_none;
}
raw_inode = (befs_inode *) bh->b_data;
befs_dump_inode(sb, raw_inode);
if (befs_check_inode(sb, raw_inode, inode->i_ino) != BEFS_OK) {
befs_error(sb, "Bad inode: %llu", inode->i_ino);
goto unacquire_bh;
}
inode->i_mode = (umode_t) fs32_to_cpu(sb, raw_inode->mode);
/*
* set uid and gid. But since current BeOS is single user OS, so
* you can change by "uid" or "gid" options.
*/
inode->i_uid = befs_sb->mount_opts.use_uid ?
befs_sb->mount_opts.uid :
make_kuid(&init_user_ns, fs32_to_cpu(sb, raw_inode->uid));
inode->i_gid = befs_sb->mount_opts.use_gid ?
befs_sb->mount_opts.gid :
make_kgid(&init_user_ns, fs32_to_cpu(sb, raw_inode->gid));
set_nlink(inode, 1);
/*
* BEFS's time is 64 bits, but current VFS is 32 bits...
* BEFS don't have access time. Nor inode change time. VFS
* doesn't have creation time.
* Also, the lower 16 bits of the last_modified_time and
* create_time are just a counter to help ensure uniqueness
* for indexing purposes. (PFD, page 54)
*/
inode_set_mtime(inode,
fs64_to_cpu(sb, raw_inode->last_modified_time) >> 16,
0);/* lower 16 bits are not a time */
inode_set_ctime_to_ts(inode, inode_get_mtime(inode));
inode_set_atime_to_ts(inode, inode_get_mtime(inode));
befs_ino->i_inode_num = fsrun_to_cpu(sb, raw_inode->inode_num);
befs_ino->i_parent = fsrun_to_cpu(sb, raw_inode->parent);
befs_ino->i_attribute = fsrun_to_cpu(sb, raw_inode->attributes);
befs_ino->i_flags = fs32_to_cpu(sb, raw_inode->flags);
if (S_ISLNK(inode->i_mode) && !(befs_ino->i_flags & BEFS_LONG_SYMLINK)){
inode->i_size = 0;
inode->i_blocks = befs_sb->block_size / VFS_BLOCK_SIZE;
strscpy(befs_ino->i_data.symlink, raw_inode->data.symlink,
BEFS_SYMLINK_LEN);
} else {
int num_blks;
befs_ino->i_data.ds =
fsds_to_cpu(sb, &raw_inode->data.datastream);
num_blks = befs_count_blocks(sb, &befs_ino->i_data.ds);
inode->i_blocks =
num_blks * (befs_sb->block_size / VFS_BLOCK_SIZE);
inode->i_size = befs_ino->i_data.ds.size;
}
inode->i_mapping->a_ops = &befs_aops;
if (S_ISREG(inode->i_mode)) {
inode->i_fop = &generic_ro_fops;
} else if (S_ISDIR(inode->i_mode)) {
inode->i_op = &befs_dir_inode_operations;
inode->i_fop = &befs_dir_operations;
} else if (S_ISLNK(inode->i_mode)) {
if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
inode->i_op = &page_symlink_inode_operations;
inode_nohighmem(inode);
inode->i_mapping->a_ops = &befs_symlink_aops;
} else {
inode->i_link = befs_ino->i_data.symlink;
inode->i_op = &simple_symlink_inode_operations;
}
} else {
befs_error(sb, "Inode %llu is not a regular file, "
"directory or symlink. THAT IS WRONG! BeFS has no "
"on disk special files", inode->i_ino);
goto unacquire_bh;
}
brelse(bh);
befs_debug(sb, "<--- %s", __func__);
unlock_new_inode(inode);
return inode;
unacquire_bh:
brelse(bh);
unacquire_none:
iget_failed(inode);
befs_debug(sb, "<--- %s - Bad inode", __func__);
return ERR_PTR(-EIO);
}
/* Initialize the inode cache. Called at fs setup.
*
* Taken from NFS implementation by Al Viro.
*/
static int __init
befs_init_inodecache(void)
{
befs_inode_cachep = kmem_cache_create_usercopy("befs_inode_cache",
sizeof(struct befs_inode_info), 0,
SLAB_RECLAIM_ACCOUNT | SLAB_ACCOUNT,
offsetof(struct befs_inode_info,
i_data.symlink),
sizeof_field(struct befs_inode_info,
i_data.symlink),
init_once);
if (befs_inode_cachep == NULL)
return -ENOMEM;
return 0;
}
/* Called at fs teardown.
*
* Taken from NFS implementation by Al Viro.
*/
static void
befs_destroy_inodecache(void)
{
/*
* Make sure all delayed rcu free inodes are flushed before we
* destroy cache.
*/
rcu_barrier();
kmem_cache_destroy(befs_inode_cachep);
}
/*
* The inode of symbolic link is different to data stream.
* The data stream become link name. Unless the LONG_SYMLINK
* flag is set.
*/
static int befs_symlink_read_folio(struct file *unused, struct folio *folio)
{
struct inode *inode = folio->mapping->host;
struct super_block *sb = inode->i_sb;
struct befs_inode_info *befs_ino = BEFS_I(inode);
befs_data_stream *data = &befs_ino->i_data.ds;
befs_off_t len = data->size;
char *link = folio_address(folio);
int err = -EIO;
if (len == 0 || len > PAGE_SIZE) {
befs_error(sb, "Long symlink with illegal length");
goto fail;
}
befs_debug(sb, "Follow long symlink");
if (befs_read_lsymlink(sb, data, link, len) != len) {
befs_error(sb, "Failed to read entire long symlink");
goto fail;
}
link[len - 1] = '\0';
err = 0;
fail:
folio_end_read(folio, err == 0);
return err;
}
/*
* UTF-8 to NLS charset convert routine
*
* Uses uni2char() / char2uni() rather than the nls tables directly
*/
static int
befs_utf2nls(struct super_block *sb, const char *in,
int in_len, char **out, int *out_len)
{
struct nls_table *nls = BEFS_SB(sb)->nls;
int i, o;
unicode_t uni;
int unilen, utflen;
char *result;
/* The utf8->nls conversion won't make the final nls string bigger
* than the utf one, but if the string is pure ascii they'll have the
* same width and an extra char is needed to save the additional \0
*/
int maxlen = in_len + 1;
befs_debug(sb, "---> %s", __func__);
if (!nls) {
befs_error(sb, "%s called with no NLS table loaded", __func__);
return -EINVAL;
}
*out = result = kmalloc(maxlen, GFP_NOFS);
if (!*out)
return -ENOMEM;
for (i = o = 0; i < in_len; i += utflen, o += unilen) {
/* convert from UTF-8 to Unicode */
utflen = utf8_to_utf32(&in[i], in_len - i, &uni);
if (utflen < 0)
goto conv_err;
/* convert from Unicode to nls */
if (uni > MAX_WCHAR_T)
goto conv_err;
unilen = nls->uni2char(uni, &result[o], in_len - o);
if (unilen < 0)
goto conv_err;
}
result[o] = '\0';
*out_len = o;
befs_debug(sb, "<--- %s", __func__);
return o;
conv_err:
befs_error(sb, "Name using character set %s contains a character that "
"cannot be converted to unicode.", nls->charset);
befs_debug(sb, "<--- %s", __func__);
kfree(result);
return -EILSEQ;
}
/**
* befs_nls2utf - Convert NLS string to utf8 encodeing
* @sb: Superblock
* @in: Input string buffer in NLS format
* @in_len: Length of input string in bytes
* @out: The output string in UTF-8 format
* @out_len: Length of the output buffer
*
* Converts input string @in, which is in the format of the loaded NLS map,
* into a utf8 string.
*
* The destination string @out is allocated by this function and the caller is
* responsible for freeing it with kfree()
*
* On return, *@out_len is the length of @out in bytes.
*
* On success, the return value is the number of utf8 characters written to
* the output buffer @out.
*
* On Failure, a negative number coresponding to the error code is returned.
*/
static int
befs_nls2utf(struct super_block *sb, const char *in,
int in_len, char **out, int *out_len)
{
struct nls_table *nls = BEFS_SB(sb)->nls;
int i, o;
wchar_t uni;
int unilen, utflen;
char *result;
/*
* There are nls characters that will translate to 3-chars-wide UTF-8
* characters, an additional byte is needed to save the final \0
* in special cases
*/
int maxlen = (3 * in_len) + 1;
befs_debug(sb, "---> %s\n", __func__);
if (!nls) {
befs_error(sb, "%s called with no NLS table loaded.",
__func__);
return -EINVAL;
}
*out = result = kmalloc(maxlen, GFP_NOFS);
if (!*out) {
*out_len = 0;
return -ENOMEM;
}
for (i = o = 0; i < in_len; i += unilen, o += utflen) {
/* convert from nls to unicode */
unilen = nls->char2uni(&in[i], in_len - i, &uni);
if (unilen < 0)
goto conv_err;
/* convert from unicode to UTF-8 */
utflen = utf32_to_utf8(uni, &result[o], 3);
if (utflen <= 0)
goto conv_err;
}
result[o] = '\0';
*out_len = o;
befs_debug(sb, "<--- %s", __func__);
return i;
conv_err:
befs_error(sb, "Name using character set %s contains a character that "
"cannot be converted to unicode.", nls->charset);
befs_debug(sb, "<--- %s", __func__);
kfree(result);
return -EILSEQ;
}
static struct inode *befs_nfs_get_inode(struct super_block *sb, uint64_t ino,
uint32_t generation)
{
/* No need to handle i_generation */
return befs_iget(sb, ino);
}
/*
* Map a NFS file handle to a corresponding dentry
*/
static struct dentry *befs_fh_to_dentry(struct super_block *sb,
struct fid *fid, int fh_len, int fh_type)
{
return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
befs_nfs_get_inode);
}
/*
* Find the parent for a file specified by NFS handle
*/
static struct dentry *befs_fh_to_parent(struct super_block *sb,
struct fid *fid, int fh_len, int fh_type)
{
return generic_fh_to_parent(sb, fid, fh_len, fh_type,
befs_nfs_get_inode);
}
static struct dentry *befs_get_parent(struct dentry *child)
{
struct inode *parent;
struct befs_inode_info *befs_ino = BEFS_I(d_inode(child));
parent = befs_iget(child->d_sb,
(unsigned long)befs_ino->i_parent.start);
return d_obtain_alias(parent);
}
enum {
Opt_uid, Opt_gid, Opt_charset, Opt_debug,
};
static const struct fs_parameter_spec befs_param_spec[] = {
fsparam_uid ("uid", Opt_uid),
fsparam_gid ("gid", Opt_gid),
fsparam_string ("iocharset", Opt_charset),
fsparam_flag ("debug", Opt_debug),
{}
};
static int
befs_parse_param(struct fs_context *fc, struct fs_parameter *param)
{
struct befs_mount_options *opts = fc->fs_private;
int token;
struct fs_parse_result result;
/* befs ignores all options on remount */
if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE)
return 0;
token = fs_parse(fc, befs_param_spec, param, &result);
if (token < 0)
return token;
switch (token) {
case Opt_uid:
opts->uid = result.uid;
opts->use_uid = 1;
break;
case Opt_gid:
opts->gid = result.gid;
opts->use_gid = 1;
break;
case Opt_charset:
kfree(opts->iocharset);
opts->iocharset = param->string;
param->string = NULL;
break;
case Opt_debug:
opts->debug = 1;
break;
default:
return -EINVAL;
}
return 0;
}
static int befs_show_options(struct seq_file *m, struct dentry *root)
{
struct befs_sb_info *befs_sb = BEFS_SB(root->d_sb);
struct befs_mount_options *opts = &befs_sb->mount_opts;
if (!uid_eq(opts->uid, GLOBAL_ROOT_UID))
seq_printf(m, ",uid=%u",
from_kuid_munged(&init_user_ns, opts->uid));
if (!gid_eq(opts->gid, GLOBAL_ROOT_GID))
seq_printf(m, ",gid=%u",
from_kgid_munged(&init_user_ns, opts->gid));
if (opts->iocharset)
seq_printf(m, ",charset=%s", opts->iocharset);
if (opts->debug)
seq_puts(m, ",debug");
return 0;
}
/* This function has the responsibiltiy of getting the
* filesystem ready for unmounting.
* Basically, we free everything that we allocated in
* befs_read_inode
*/
static void
befs_put_super(struct super_block *sb)
{
kfree(BEFS_SB(sb)->mount_opts.iocharset);
BEFS_SB(sb)->mount_opts.iocharset = NULL;
unload_nls(BEFS_SB(sb)->nls);
kfree(sb->s_fs_info);
sb->s_fs_info = NULL;
}
/*
* Copy the parsed options into the sbi mount_options member
*/
static void
befs_set_options(struct befs_sb_info *sbi, struct befs_mount_options *opts)
{
sbi->mount_opts.uid = opts->uid;
sbi->mount_opts.gid = opts->gid;
sbi->mount_opts.use_uid = opts->use_uid;
sbi->mount_opts.use_gid = opts->use_gid;
sbi->mount_opts.debug = opts->debug;
sbi->mount_opts.iocharset = opts->iocharset;
opts->iocharset = NULL;
}
/* Allocate private field of the superblock, fill it.
*
* Finish filling the public superblock fields
* Make the root directory
* Load a set of NLS translations if needed.
*/
static int
befs_fill_super(struct super_block *sb, struct fs_context *fc)
{
struct buffer_head *bh;
struct befs_sb_info *befs_sb;
befs_super_block *disk_sb;
struct inode *root;
long ret = -EINVAL;
const unsigned long sb_block = 0;
const off_t x86_sb_off = 512;
int blocksize;
struct befs_mount_options *parsed_opts = fc->fs_private;
int silent = fc->sb_flags & SB_SILENT;
sb->s_fs_info = kzalloc_obj(*befs_sb);
if (sb->s_fs_info == NULL)
goto unacquire_none;
befs_sb = BEFS_SB(sb);
befs_set_options(befs_sb, parsed_opts);
befs_debug(sb, "---> %s", __func__);
if (!sb_rdonly(sb)) {
befs_warning(sb,
"No write support. Marking filesystem read-only");
sb->s_flags |= SB_RDONLY;
}
/*
* Set dummy blocksize to read super block.
* Will be set to real fs blocksize later.
*
* Linux 2.4.10 and later refuse to read blocks smaller than
* the logical block size for the device. But we also need to read at
* least 1k to get the second 512 bytes of the volume.
*/
blocksize = sb_min_blocksize(sb, 1024);
if (!blocksize) {
if (!silent)
befs_error(sb, "unable to set blocksize");
goto unacquire_priv_sbp;
}
bh = sb_bread(sb, sb_block);
if (!bh) {
if (!silent)
befs_error(sb, "unable to read superblock");
goto unacquire_priv_sbp;
}
/* account for offset of super block on x86 */
disk_sb = (befs_super_block *) bh->b_data;
if ((disk_sb->magic1 == BEFS_SUPER_MAGIC1_LE) ||
(disk_sb->magic1 == BEFS_SUPER_MAGIC1_BE)) {
befs_debug(sb, "Using PPC superblock location");
} else {
befs_debug(sb, "Using x86 superblock location");
disk_sb =
(befs_super_block *) ((void *) bh->b_data + x86_sb_off);
}
if ((befs_load_sb(sb, disk_sb) != BEFS_OK) ||
(befs_check_sb(sb) != BEFS_OK))
goto unacquire_bh;
befs_dump_super_block(sb, disk_sb);
brelse(bh);
if (befs_sb->num_blocks > ~((sector_t)0)) {
if (!silent)
befs_error(sb, "blocks count: %llu is larger than the host can use",
befs_sb->num_blocks);
goto unacquire_priv_sbp;
}
/*
* set up enough so that it can read an inode
* Fill in kernel superblock fields from private sb
*/
sb->s_magic = BEFS_SUPER_MAGIC;
/* Set real blocksize of fs */
sb_set_blocksize(sb, (ulong) befs_sb->block_size);
sb->s_op = &befs_sops;
sb->s_export_op = &befs_export_operations;
sb->s_time_min = 0;
sb->s_time_max = 0xffffffffffffll;
root = befs_iget(sb, iaddr2blockno(sb, &(befs_sb->root_dir)));
if (IS_ERR(root)) {
ret = PTR_ERR(root);
goto unacquire_priv_sbp;
}
sb->s_root = d_make_root(root);
if (!sb->s_root) {
if (!silent)
befs_error(sb, "get root inode failed");
goto unacquire_priv_sbp;
}
/* load nls library */
if (befs_sb->mount_opts.iocharset) {
befs_debug(sb, "Loading nls: %s",
befs_sb->mount_opts.iocharset);
befs_sb->nls = load_nls(befs_sb->mount_opts.iocharset);
if (!befs_sb->nls) {
befs_warning(sb, "Cannot load nls %s"
" loading default nls",
befs_sb->mount_opts.iocharset);
befs_sb->nls = load_nls_default();
}
/* load default nls if none is specified in mount options */
} else {
befs_debug(sb, "Loading default nls");
befs_sb->nls = load_nls_default();
}
return 0;
unacquire_bh:
brelse(bh);
unacquire_priv_sbp:
kfree(befs_sb->mount_opts.iocharset);
kfree(sb->s_fs_info);
sb->s_fs_info = NULL;
unacquire_none:
return ret;
}
static int
befs_reconfigure(struct fs_context *fc)
{
sync_filesystem(fc->root->d_sb);
if (!(fc->sb_flags & SB_RDONLY))
return -EINVAL;
return 0;
}
static int
befs_statfs(struct dentry *dentry, struct kstatfs *buf)
{
struct super_block *sb = dentry->d_sb;
u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
befs_debug(sb, "---> %s", __func__);
buf->f_type = BEFS_SUPER_MAGIC;
buf->f_bsize = sb->s_blocksize;
buf->f_blocks = BEFS_SB(sb)->num_blocks;
buf->f_bfree = BEFS_SB(sb)->num_blocks - BEFS_SB(sb)->used_blocks;
buf->f_bavail = buf->f_bfree;
buf->f_files = 0; /* UNKNOWN */
buf->f_ffree = 0; /* UNKNOWN */
buf->f_fsid = u64_to_fsid(id);
buf->f_namelen = BEFS_NAME_LEN;
befs_debug(sb, "<--- %s", __func__);
return 0;
}
static int befs_get_tree(struct fs_context *fc)
{
return get_tree_bdev(fc, befs_fill_super);
}
static const struct fs_context_operations befs_context_ops = {
.parse_param = befs_parse_param,
.get_tree = befs_get_tree,
.reconfigure = befs_reconfigure,
.free = befs_free_fc,
};
static int befs_init_fs_context(struct fs_context *fc)
{
struct befs_mount_options *opts;
opts = kzalloc_obj(*opts);
if (!opts)
return -ENOMEM;
/* Initialize options */
opts->uid = GLOBAL_ROOT_UID;
opts->gid = GLOBAL_ROOT_GID;
fc->fs_private = opts;
fc->ops = &befs_context_ops;
return 0;
}
static void befs_free_fc(struct fs_context *fc)
{
struct befs_mount_options *opts = fc->fs_private;
kfree(opts->iocharset);
kfree(fc->fs_private);
}
static struct file_system_type befs_fs_type = {
.owner = THIS_MODULE,
.name = "befs",
.kill_sb = kill_block_super,
.fs_flags = FS_REQUIRES_DEV,
.init_fs_context = befs_init_fs_context,
.parameters = befs_param_spec,
};
MODULE_ALIAS_FS("befs");
static int __init
init_befs_fs(void)
{
int err;
pr_info("version: %s\n", BEFS_VERSION);
err = befs_init_inodecache();
if (err)
goto unacquire_none;
err = register_filesystem(&befs_fs_type);
if (err)
goto unacquire_inodecache;
return 0;
unacquire_inodecache:
befs_destroy_inodecache();
unacquire_none:
return err;
}
static void __exit
exit_befs_fs(void)
{
befs_destroy_inodecache();
unregister_filesystem(&befs_fs_type);
}
/*
* Macros that typecheck the init and exit functions,
* ensures that they are called at init and cleanup,
* and eliminates warnings about unused functions.
*/
module_init(init_befs_fs)
module_exit(exit_befs_fs)
]
|
| 77/4 |
2026/05/21 22:57 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 103617
output: 23
thoughts: 15
Thoughts: Here's my take on the situation:
**Initial Assessment and Verification Steps**
Okay, the initial glance at this patch is promising; it seems well-structured and doesn't immediately raise any red flags. However, we all know that first impressions can be deceiving, especially in this field. I'm going to take a moment to carefully scrutinize the patch diff. I need to make sure I understand the full scope of the changes and that everything aligns with the expected behavior and design principles. Time to dive deeper and verify my initial positive impression. Let's see if this patch stands up to thorough inspection.
|
| 78/4 |
2026/05/21 22:58 |
tool |
patch-diff |
0m
Args: map[File:fs/befs/super.c]
Results: map[Output:diff --git a/fs/befs/super.c b/fs/befs/super.c
index 7c50025c9..51cf57ad6 100644
--- a/fs/befs/super.c
+++ b/fs/befs/super.c
@@ -1,20 +1,21 @@
/*
* super.c
*
* Copyright (C) 2001-2002 Will Dyson <will_dyson@pobox.com>
*
* Licensed under the GNU GPL. See the file COPYING for details.
*
*/
#include <linux/fs.h>
+#include <linux/log2.h>
#include <asm/page.h> /* for PAGE_SIZE */
#include "befs.h"
#include "super.h"
/*
* befs_load_sb -- Read from disk and properly byteswap all the fields
* of the befs superblock
*/
int
@@ -58,61 +59,62 @@ int
befs_check_sb(struct super_block *sb)
{
struct befs_sb_info *befs_sb = BEFS_SB(sb);
/* Check magic headers of super block */
if ((befs_sb->magic1 != BEFS_SUPER_MAGIC1)
|| (befs_sb->magic2 != BEFS_SUPER_MAGIC2)
|| (befs_sb->magic3 != BEFS_SUPER_MAGIC3)) {
befs_error(sb, "invalid magic header");
return BEFS_ERR;
}
/*
* Check blocksize of BEFS.
*
* Blocksize of BEFS is 1024, 2048, 4096 or 8192.
*/
if ((befs_sb->block_size != 1024)
&& (befs_sb->block_size != 2048)
&& (befs_sb->block_size != 4096)
&& (befs_sb->block_size != 8192)) {
befs_error(sb, "invalid blocksize: %u", befs_sb->block_size);
return BEFS_ERR;
}
if (befs_sb->block_size > PAGE_SIZE) {
befs_error(sb, "blocksize(%u) cannot be larger "
"than system pagesize(%lu)", befs_sb->block_size,
PAGE_SIZE);
return BEFS_ERR;
}
/*
* block_shift and block_size encode the same information
* in different ways as a consistency check.
*/
- if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
+ if (befs_sb->block_shift != ilog2(befs_sb->block_size)) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
/* ag_shift also encodes the same information as blocks_per_ag in a
* different way, non-fatal consistency check
*/
- if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
+ if (!is_power_of_2(befs_sb->blocks_per_ag) ||
+ befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
if (befs_sb->log_start != befs_sb->log_end ||
befs_sb->flags == BEFS_DIRTY) {
befs_error(sb, "Filesystem not clean! There are blocks in the "
"journal. You must boot into BeOS and mount this "
"volume to make it clean.");
return BEFS_ERR;
}
return BEFS_OK;
}
]
|
| 79/4 |
2026/05/21 22:58 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 104874
output: 511
thoughts: 168
Thoughts: **My Analysis of the Fix**
Okay, so the solution is precisely as we discussed. Brilliant! Instead of blindly shifting `1` by potentially garbage values, it now cleverly validates the shift values against what we *know* they should be, calculated safely with `ilog2()`. This neatly sidesteps the undefined behavior issue we were worried about.
Specifically, `block_size` is already limited to acceptable values: 1024, 2048, 4096, or 8192. So, taking the log base 2 of `block_size` is perfectly safe and will produce the correct results. For `blocks_per_ag`, the code validates it *is* a power of 2 using `is_power_of_2()` before computing the shift value using `ilog2()`.
This is robust; it's exactly what we wanted! Itβll handle even maliciously crafted filesystem images with ridiculous shift values gracefully. Now, I can confidently write the final reply explaining this fix in detail.
|
| 80/3 |
2026/05/21 22:58 |
action |
test-patch |
30m
Results: map[PatchDiff:diff --git a/fs/befs/super.c b/fs/befs/super.c
index 7c50025c9..256de36f8 100644
--- a/fs/befs/super.c
+++ b/fs/befs/super.c
@@ -8,6 +8,7 @@
*/
#include <linux/fs.h>
+#include <linux/log2.h>
#include <asm/page.h> /* for PAGE_SIZE */
#include "befs.h"
@@ -93,17 +94,17 @@ befs_check_sb(struct super_block *sb)
* in different ways as a consistency check.
*/
- if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
+ if (befs_sb->block_shift != ilog2(befs_sb->block_size)) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
-
/* ag_shift also encodes the same information as blocks_per_ag in a
* different way, non-fatal consistency check
*/
- if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
+ if (!is_power_of_2(befs_sb->blocks_per_ag) ||
+ befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
if (befs_sb->log_start != befs_sb->log_end ||
TestError:]
|
| 81/1 |
2026/05/21 23:28 |
agent |
fixes-finder |
10m
Model:
Error:
Instruction:
You are an experienced Linux kernel developer tasked with identifying the commit
that introduced the bug being fixed. Identifying the correct buggy commit is crucial
for proper kernel maintenance (backporting to stable trees, etc.).
Your investigation strategy:
1. Examine the patch that fixes the bug. Use git tools (like git-log or git-blame)
to trace the history of the lines or functions modified by the patch.
2. Analyze the stack trace in the crash report. Identify the key files and functions
involved in the crash and investigate their history to see when the problematic
logic was introduced.
3. Compare the bug explanation with the commit history to find the point where
the described logic error first appeared.
A bug is typically introduced when a piece of code is first written, or when
a refactoring changed its logic in a way that introduced the bug.
Trace the history of relevant symbols or find when specific code patterns were introduced/removed.
You must provide exactly one bug-introducing commit hash.
If you are unable to confidently determine the bug-introducing commit after investigation,
return an empty string rather than guessing.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The crash is:
loop0: detected capacity change from 0 to 128
------------[ cut here ]------------
UBSAN: shift-out-of-bounds in /app/workdir/cache/src/d5a02ed91a4f019017141f71e695c75b27c3612e/fs/befs/super.c:96:9
shift exponent 2066842816 is too large for 32-bit type 'int'
CPU: 0 UID: 0 PID: 6217 Comm: syz.0.17 Not tainted syzkaller #1 PREEMPT_{RT,(full)}
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
ubsan_epilogue+0xa/0x30 lib/ubsan.c:233
__ubsan_handle_shift_out_of_bounds+0x385/0x410 lib/ubsan.c:494
befs_check_sb+0x421/0x4c0 fs/befs/super.c:96
befs_fill_super+0x49b/[ 166.533846][ T6217] befs_fill_super+0x49b/0xa70 fs/befs/linuxvfs.c:843
get_tree_bdev_flags+0x431/0x4f0 fs/super.c:1694
vfs_get_tree+0x92/0x2a0 fs/super.c:1754
fc_mount fs/namespace.c:1193 [inline]
do_new_mount_fc fs/namespace.c:3758 [inline]
do_new_mount+0x341/0xd30 fs/namespace.c:3834
do_mount fs/namespace.c:4167 [inline]
__do_sys_mount fs/namespace.c:4383 [inline]
__se_sys_mount+0x31d/0x420 fs/namespace.c:4360
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5c83a6e0ca
Code: 48 c7 c2 e8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f5c830cde58 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f5c830cdee0 RCX: 00007f5c83a6e0ca
RDX: 0000200000000040 RSI: 0000200000000000 RDI: 00007f5c830cdea0
RBP: 0000200000000040 R08: 00007f5c830cdee0 R09: 0000000000800001
R10: 0000000000800001 R11: 0000000000000246 R12: 0000200000000000
R13: 00007f5c830cdea0 R14: 0000000000009e17 R15: 0000200000000080
</TASK>
---[ end trace ]---
The explanation of the root cause is:
An analysis of the crash report and the source code reveals the following root cause and the corresponding fix.
### Root Cause
The crash is caused by a shift-out-of-bounds (Undefined Behavior) in `fs/befs/super.c` inside the `befs_check_sb()` function.
When mounting a BEFS filesystem, the kernel reads the superblock fields `block_shift` and `ag_shift` directly from the disk and uses them as shift exponents to validate consistency with `block_size` and `blocks_per_ag`:
```c
if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
// ...
}
if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
// ...
```
Because `befs_sb->block_shift` and `befs_sb->ag_shift` are controlled by the filesystem image and are not validated before the shift operation, a maliciously crafted image can provide a huge value (e.g., `2066842816` as seen in the syzkaller log). Shifting a 32-bit integer `1` by an exponent $\ge 32$ triggers a UBSAN shift-out-of-bounds panic.
### Fix
To fix this, we should avoid using the unvalidated `block_shift` and `ag_shift` as shift exponents. Instead, we can use the `ilog2()` and `is_power_of_2()` macros from `<linux/log2.h>` to compute the expected shift values from `block_size` and `blocks_per_ag`, and compare them against the provided shift values.
1. **For `block_shift`**:
`befs_sb->block_size` is already strictly validated earlier in `befs_check_sb()` to be exactly 1024, 2048, 4096, or 8192. Since it is guaranteed to be a valid power of two, we can safely use `ilog2(befs_sb->block_size)` to get the expected `block_shift`.
2. **For `ag_shift`**:
`befs_sb->blocks_per_ag` is not validated to be a power of two. The original check `(1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag` inherently requires `blocks_per_ag` to be a power of two (otherwise they can never be equal). We can explicitly check if `blocks_per_ag` is a power of two using `is_power_of_2()`, and if so, compare `ilog2(befs_sb->blocks_per_ag)` with `befs_sb->ag_shift`.
Here is how the patched code in `fs/befs/super.c` should look:
```c
#include <linux/log2.h>
// ...
int befs_check_sb(struct super_block *sb)
{
struct befs_sb_info *befs_sb = BEFS_SB(sb);
// ... [magic and block_size checks] ...
/*
* block_shift and block_size encode the same information
* in different ways as a consistency check.
*/
if (befs_sb->block_shift != ilog2(befs_sb->block_size)) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
/* ag_shift also encodes the same information as blocks_per_ag in a
* different way, non-fatal consistency check
*/
if (!is_power_of_2(befs_sb->blocks_per_ag) ||
befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
// ...
}
```
This completely eliminates the undefined behavior while preserving the exact same validation logic.
The patch that fixes the bug is:
diff --git a/fs/befs/super.c b/fs/befs/super.c
index 7c50025c9..256de36f8 100644
--- a/fs/befs/super.c
+++ b/fs/befs/super.c
@@ -8,6 +8,7 @@
*/
#include <linux/fs.h>
+#include <linux/log2.h>
#include <asm/page.h> /* for PAGE_SIZE */
#include "befs.h"
@@ -93,17 +94,17 @@ befs_check_sb(struct super_block *sb)
* in different ways as a consistency check.
*/
- if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
+ if (befs_sb->block_shift != ilog2(befs_sb->block_size)) {
befs_error(sb, "block_shift disagrees with block_size. "
"Corruption likely.");
return BEFS_ERR;
}
-
/* ag_shift also encodes the same information as blocks_per_ag in a
* different way, non-fatal consistency check
*/
- if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
+ if (!is_power_of_2(befs_sb->blocks_per_ag) ||
+ befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
if (befs_sb->log_start != befs_sb->log_end ||
Search for the commit(s) that introduced this bug.
|
| 82/2 |
2026/05/21 23:28 |
llm |
fixes-finder |
0m
Model:
Tokens:
input: 6376
output: 41
thoughts: 150
Thoughts: **Debugging a Bizarre BEFS Bug**
Okay, so I've got this bug, and it's looking pretty nasty. It seems to be a shift-out-of-bounds error in the `befs_check_sb()` function within `fs/befs/super.c`. The code in question is these two lines:
```c
if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
```
and
```c
if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
```
My initial thought is to figure out *when* this code was actually introduced. I need to understand the history to get a better grasp on the intent and potential context of this logic. Time to fire up `git-log` or `git-blame` on `fs/befs/super.c`. Knowing the commit history here will be critical to understanding what was supposed to happen and how it might be going wrong. Let's dig in and see what we can find.
|
| 83/2 |
2026/05/21 23:28 |
tool |
git-log |
10m
Error:
Args: map[CodeRegexp:1 << befs_sb->block_shift SourcePath:fs/befs/super.c]
Results:
|
| 84/2 |
2026/05/21 23:38 |
llm |
fixes-finder |
0m
Model:
Tokens:
input: 6840
output: 41
thoughts: 9
Thoughts: Okay, here's the summary, formatted as requested:
**Navigating the Router Configuration**
Alright, let's see... looking at this configuration, it's immediately apparent that I need to ensure proper routing. I should definitely be setting a `PathPrefix`. Without it, I'm just asking for trouble and potentially exposing internal services unintentionally. It would be a silly oversight, given the complexity I am working with. I should have it as an imperative to make it functional.
|
| 85/2 |
2026/05/21 23:38 |
tool |
git-log |
0m
Args: map[CodeRegexp:1 << befs_sb->block_shift PathPrefix:fs/befs/super.c]
Results: map[Output:1da177e4c3f4 Linux-2.6.12-rc2
]
|
| 86/2 |
2026/05/21 23:38 |
llm |
fixes-finder |
0m
Model:
Tokens:
input: 7027
output: 41
thoughts: 58
Thoughts: Okay, here's my summary, presented as a stream of thought:
**Initial Code Commit Investigation**
Alright, based on what I'm seeing, my initial hunch is that this particular code snippet appears to have been introduced back in the first commit, specifically `1da177e4c3f4`. Before I dig any deeper, I should probably verify this assertion. The most direct approach is likely to use `git-blame` on the `fs/befs/super.c` file. That should pinpoint the exact commit responsible for adding this particular chunk of code, or at least its introduction. Alternatively, a quick glance at the file history using other git commands should provide the same information. Let's start with `git-blame`; it tends to be the fastest method for this kind of investigation. I can get a pretty clear picture in very short order.
|
| 87/2 |
2026/05/21 23:38 |
tool |
git-log |
0m
Args: map[CodeRegexp:1 << befs_sb->ag_shift PathPrefix:fs/befs/super.c]
Results: map[Output:bbe1bd0b6bba befs: add check for ag_shift in superblock
]
|
| 88/2 |
2026/05/21 23:39 |
llm |
fixes-finder |
0m
Model:
Tokens:
input: 7344
output: 23
thoughts: 45
Thoughts: Okay, here's my take on those thoughts, framed as my own:
**Investigating a Suspect Shift**
Right, so I've stumbled across `1 << befs_sb->ag_shift`. That bitwise left shift looks a little suspicious, and I have a nagging feeling it was introduced fairly recently. Let me just confirm that. Ah, yes, confirmed: it was introduced in the commit `bbe1bd0b6bba`. Okay, time to dive in. I need to understand the context. What was the motivation for this change? What problem were they trying to solve? Or, more importantly, what problems did they create? Knowing the change itself is only the starting point. I need to understand the *why* to really grasp the implications and potential side effects within this filesystem. Let's see what that commit message has to say.
|
| 89/2 |
2026/05/21 23:39 |
tool |
git-show |
0m
Args:
Results: map[Output:commit bbe1bd0b6bba138eaf441c6c964bde9866da8808
Author: Luis de Bethencourt <luisbg@osg.samsung.com>
Date: Tue Aug 9 22:23:36 2016 +0100
befs: add check for ag_shift in superblock
ag_shift and blocks_per_ag contain the same information in different ways,
same as block_shift and block_size do. It is worth checking this two are
consistent, but since blocks_per_ag isn't documented as mandatory to use
some implementations of befs don't enforce this, so making it non-fatal if
they don't match and just having it as a warning.
Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
Signed-off-by: Salah Triki <salah.triki@gmail.com>
diff --git a/fs/befs/super.c b/fs/befs/super.c
index dc13df8de3e8..c36745d2b45f 100644
--- a/fs/befs/super.c
+++ b/fs/befs/super.c
@@ -103,6 +103,13 @@ befs_check_sb(struct super_block *sb)
return BEFS_ERR;
}
+
+ /* ag_shift also encodes the same information as blocks_per_ag in a
+ * different way, non-fatal consistency check
+ */
+ if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
+ befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
+
if (befs_sb->log_start != befs_sb->log_end || befs_sb->flags == BEFS_DIRTY) {
befs_error(sb, "Filesystem not clean! There are blocks in the "
"journal. You must boot into BeOS and mount this volume "
]
|
| 90/2 |
2026/05/21 23:39 |
llm |
fixes-finder |
0m
Model:
Tokens:
input: 8139
output: 41
thoughts: 551
Thoughts: **Analyzing a Shift-Out-of-Bounds Error in the BEFS Filesystem**
Okay, so I'm digging into this crash report, and it looks like a shift-out-of-bounds error in the BEFS filesystem. Specifically, the error involves a right bit shift, where the exponent is too large for an integer. The crash report points me to a specific line in `super.c`: `if ((1 << befs_sb->block_shift) != befs_sb->block_size)`.
My initial thought was to see when this code was introduced. I tracked it back to the original commit for `block_shift`: `1da177e4c3f41524e38d5ce812c16628619d62b6`. If this is the correct commit, and the code was there from the beginning, then this bug is as old as the repository itself, which seems... unlikely. I'd better double-check that commit. I also need to verify that `1 << befs_sb->block_shift` was the exact code introduced.
Looking at the patch, the code was updated:
```c
- if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
+ if (befs_sb->block_shift != ilog2(befs_sb->block_size)) {
```
and
```c
- if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
+ if (!is_power_of_2(befs_sb->blocks_per_ag) ||
+ befs_sb->ag_shift != ilog2(befs_sb->blocks_per_ag))
```
So, it's clear the original code was vulnerable. The `1 << befs_sb->block_shift` calculation is problematic because, as the error states, if `befs_sb->block_shift` is large enough, the shift operation overflows the integer. The updated code, using `ilog2`, avoids this by checking the actual value and using a different function. The second change ensures that `blocks_per_ag` is a power of 2, and that the computed `ag_shift` is also correct.
|
| 91/2 |
2026/05/21 23:39 |
tool |
git-log |
0m
Args: map[CodeRegexp:1 << befs_sb->block_shift PathPrefix:fs/befs/super.c]
Results: map[Output:1da177e4c3f4 Linux-2.6.12-rc2
]
|
| 92/2 |
2026/05/21 23:39 |
llm |
fixes-finder |
0m
Model:
Tokens:
input: 9282
output: 39
thoughts: 156
Thoughts: **Debugging a Tricky Kernel Crash**
Okay, so I've got this crash, and the commit ID associated with the code in question is `1da177e4c3f41524e38d5ce812c16628619d62b6`. That's where I need to start. The crash is happening specifically on line 96, which I recognize as the bit shift operation using `befs_sb->block_shift`: `1 << befs_sb->block_shift`. My initial thought is, this likely means the bug *was* introduced by that particular commit. I need to delve into it.
However, I've seen things like this before. It's possible that `1da177e4c3f41524e38d5ce812c16628619d62b6` just *exposed* a latent issue. The problem might have always been there, and something in this commit is what caused it to trigger. What's nagging at me is whether some validation around `block_shift` might have been removed *prior* to this commit. Could a prior change have quietly created the conditions, and this subsequent commit just became the tipping point? Time to start looking at the history and see if there are any suspicious removals of checks around that `block_shift` variable. Let's dig deeper.
|
| 93/2 |
2026/05/21 23:39 |
tool |
git-log |
0m
Args: map[CodeRegexp:befs_sb->block_shift PathPrefix:fs/befs/super.c]
Results: map[Output:1da177e4c3f4 Linux-2.6.12-rc2
]
|
| 94/2 |
2026/05/21 23:39 |
llm |
fixes-finder |
0m
Model:
Tokens:
input: 9825
output: 29
thoughts: 17
Thoughts: Here's my take on the thought process, as if it were my own:
**Diving into the Befs Superblock Implementation**
Alright, time to get my hands dirty. Let's start by digging into the `fs/befs/super.c` file. This is where the core of the Be File System (BeFS) superblock implementation lives. I need to understand how this code handles the very foundation of the filesystem. I want to see how the metadata is structured, how the superblock is initialized and managed, and how it interacts with the rest of the file system. Knowing the history of this code is key to understanding its current state. I'll be looking for any significant changes, optimizations, or bug fixes over time that give me insight into the evolution of BeFS's architecture and design choices. What are the key revision commits? What were the driving forces behind those changes? I'll be hunting for the context behind the current implementation by reading the commit messages and changesets.
|
| 95/2 |
2026/05/21 23:39 |
tool |
git-log |
0m
Args: map[Count:10 PathPrefix:fs/befs/super.c]
Results: map[Output:103c0fb3400b befs: fix style issues in super.c
11674239f927 befs: fix comment style
bbe1bd0b6bba befs: add check for ag_shift in superblock
6ea4558f9b37 befs: add flags field to validate superblock state
10145d611632 befs: fix function name in documentation
038428fcf7f0 befs: replace typedef befs_sb_info by structure
2b3fffefea99 befs: fix build on parisc
152b95a1ed49 befs: annotate fs32 on tests for superblock endianness
af10b0084dff [PATCH] befs: prepare to sanitizing headers
1da177e4c3f4 Linux-2.6.12-rc2
]
|
| 96/2 |
2026/05/21 23:39 |
llm |
fixes-finder |
0m
Model:
Tokens:
input: 10308
output: 62
thoughts: 196
Thoughts: Okay, let me think this through.
**Analyzing a Potential Kernel Bug in the BEFS Filesystem Driver**
Alright, I'm looking at a bug related to `befs_check_sb()`. It looks like there's a shift-out-of-bounds error in that function. My initial thought is the issue stems from the fact that `befs_sb->block_shift` isn't being properly validated. I remember seeing this kind of thing before.
Ah, I recall now! This variable, `befs_sb->block_shift`, gets read directly from disk in the superblock. And, crucially, it's used in a bit-shift operation: `1 << befs_sb->block_shift`. This is a classic vulnerability if that value isn't constrained. It's a textbook shift-out-of-bounds situation. So the shift-out-of-bounds occurred because that variable was read and used without validation.
Okay, so where is `befs_sb->block_shift` populated? It's read from the superblock. I need to trace back and see *where* it's populated. My hunch is that `befs_fill_super` or `befs_check_sb` are the culprit. The commit I'm looking at, `1da177e4c3f41524e38d5ce812c16628619d62b6`, is likely where this became an issue. I'll focus my investigation on those two functions within that commit.
|
| 97/2 |
2026/05/21 23:39 |
tool |
git-show |
0m
Error:
Args: map[Commit:1da177e4c3f41524e38d5ce812c16628619d62b6:fs/befs/super.c]
Results:
|