Skip to content

Commit 566c2dc

Browse files
author
bmax
committed
Revert "fix: 6.12 kernel support and disable SIMD"
This reverts commit f306a2a.
1 parent f306a2a commit 566c2dc

File tree

11 files changed

+56
-52
lines changed

11 files changed

+56
-52
lines changed

kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LD = $(TARGET_COMPILE)ld
99
AS = $(TARGET_COMPILE)as
1010
OBJCOPY = $(TARGET_COMPILE)objcopy
1111

12-
CFLAGS += -Wall -fno-builtin -std=gnu11 -nostdinc -mgeneral-regs-only
12+
CFLAGS += -Wall -fno-builtin -std=gnu11 -nostdinc
1313
CFLAGS += -g
1414

1515
ifdef DEBUG

kernel/base/baselib.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,3 @@ char *lib_strstr(const char *haystack, const char *needle)
345345
{
346346
return (char *)lib_memmem(haystack, lib_strlen(haystack), needle, lib_strlen(needle));
347347
}
348-
349-
void *memset(void *dst, int c, size_t n)
350-
{
351-
return lib_memset(dst, c, n);
352-
}

kernel/base/map.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ static void flush_icache_all(void)
6666
asm volatile("isb" : : : "memory");
6767
}
6868

69-
static void mem_proc(map_data_t *data)
69+
static map_data_t *mem_proc()
7070
{
71-
*data = *get_data();
71+
map_data_t *data = get_data();
7272
uint64_t kernel_va = get_kva();
7373

7474
// relocation
@@ -105,6 +105,8 @@ static void mem_proc(map_data_t *data)
105105
uint64_t detect_virt = (uint64_t)((memblock_virt_alloc_try_nid_f)data->map_symbol.memblock_virt_alloc_relo)(
106106
0, 0x10, detect_phys, detect_phys, NUMA_NO_NODE);
107107
data->linear_voffset = detect_virt - detect_phys;
108+
109+
return data;
108110
}
109111

110112
// todo: 52-bits pa
@@ -173,10 +175,7 @@ static uint64_t __noinline get_or_create_pte(map_data_t *data, uint64_t va, uint
173175
// todo: bti
174176
void __noinline _paging_init()
175177
{
176-
map_data_t buf;
177-
map_data_t *data = &buf;
178-
mem_proc(data);
179-
178+
map_data_t *data = mem_proc();
180179
#ifdef MAP_DEBUG
181180
printk_f printk = (printk_f)(data->printk_relo);
182181
#define map_debug(idx, val) printk(data->str_fmt_px, idx, val)
@@ -203,7 +202,10 @@ void __noinline _paging_init()
203202
((memblock_mark_nomap_f)(data->map_symbol.memblock_mark_nomap_relo))(start_pa, all_size);
204203

205204
// paging_init
206-
((paging_init_f)(data->paging_init_relo))();
205+
uint64_t paging_init_va = data->paging_init_relo;
206+
*(uint32_t *)(paging_init_va) = data->paging_init_backup;
207+
flush_icache_all();
208+
((paging_init_f)(paging_init_va))();
207209
// can't write data below
208210

209211
// AttrIndx[2:0] encoding
@@ -241,7 +243,7 @@ void __noinline _paging_init()
241243
}
242244

243245
flush_icache_all();
244-
246+
245247
// free old start
246248
((memblock_free_f)data->map_symbol.memblock_free_relo)(old_start_pa, reserve_size);
247249

kernel/base/setup.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
typedef struct
2626
{
2727
// preset
28+
uint32_t paging_init_backup;
29+
uint32_t __;
2830
int64_t map_offset;
2931
int64_t start_offset;
3032
int64_t start_size;
@@ -47,7 +49,8 @@ typedef struct
4749
uint64_t linear_voffset;
4850
} map_data_t;
4951
#else
50-
#define map_map_offset_offset 0
52+
#define map_paging_init_backup_offset 0
53+
#define map_map_offset_offset (map_paging_init_backup_offset + 8)
5154
#define map_start_offset_offset (map_map_offset_offset + 8)
5255
#define map_start_size_offset (map_start_offset_offset + 8)
5356
#define map_start_img_size_offset (map_start_size_offset + 8)

kernel/base/setup1.S

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,7 @@ map_prepare:
182182
// map_data.paging_init_relo = setup_preset.paging_init_offset;
183183
ldr x11, [x10, #setup_paging_init_offset_offset]
184184
str x11, [x9, #map_paging_init_relo_offset]
185-
186-
ldr x15, [x10, #setup_paging_init_bl_offset_offset]
187-
// uint64_t paging_init_bl_pa = paging_init_bl_offset + kernel_pa;
188-
add x13, x15, x19
185+
mov x15, x11
189186

190187
// map_data.map_symbol = setup_preset.map_symbol
191188
add x0, x9, #map_map_symbol_offset
@@ -221,6 +218,37 @@ map_prepare:
221218
add x11, x11, #MEMORY_RW_SIZE
222219
str x11, [x9, #map_alloc_size_offset]
223220

221+
// backup and hook paging_init
222+
// uint64_t paging_init_pa = paging_init_offset + kernel_pa;
223+
add x13, x15, x19
224+
// map_data.paging_init_backup = *(uint32_t *)(paging_init_pa);
225+
ldr w12, [x13]
226+
227+
mov w3, #0x201F
228+
movk w3, #0xD503, lsl#16
229+
orr w1, w3, #0x100
230+
mov w2, #0xFFFFFD1F
231+
and w0, w12, w2
232+
// if ((map_data.paging_init_backup & 0xFFFFFD1F) == 0xD503211F)
233+
cmp w0, w1
234+
b.ne .backup
235+
// map_data.paging_init_backup = NOP
236+
mov w12, w3
237+
// uint32_t *p = (uint32_t *)paging_init_pa + 1;
238+
add x11, x13, #4
239+
.cmp_auti:
240+
// while ((*p & 0xFFFFFD1F) != 0xD503211F) ++p;
241+
ldr w0, [x11], #4
242+
and w0, w0, w2
243+
cmp w0, w1
244+
b.ne .cmp_auti
245+
// *p = NOP
246+
stur w3, [x11, #-4]
247+
248+
.backup:
249+
str w12, [x9, #map_paging_init_backup_offset]
250+
dsb ish
251+
224252
// uint64_t replace_offset = (uint64_t)(_paging_init - _map_start) + map_offset;
225253
adrp x11, _paging_init
226254
add x11, x11, :lo12:_paging_init
@@ -229,11 +257,11 @@ map_prepare:
229257
sub x11, x11, x12
230258
add x11, x11, x14
231259

232-
// *(uint32_t *)paging_init_bl_pa = B_REL(paging_init_bl_offset, replace_offset);
233-
// #define BL_REL(src, dst) (0x94000000u | (((dst - src) & 0x0FFFFFFFu) >> 2u))
260+
// *(uint32_t *)paging_init_pa = B_REL(paging_init_offset, replace_offset);
261+
// #define B_REL(src, dst) (0x14000000u | (((dst - src) & 0x0FFFFFFFu) >> 2u))
234262
sub x15, x11, x15
235263
ubfx w15, w15, #2, #26
236-
mov w12, #0x94000000
264+
mov w12, #0x14000000
237265
orr w15, w15, w12
238266
str w15, [x13]
239267

kernel/include/preset.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ typedef struct _setup_preset_t
236236
int64_t map_max_size;
237237
int64_t kallsyms_lookup_name_offset;
238238
int64_t paging_init_offset;
239-
int64_t paging_init_bl_offset;
240239
int64_t printk_offset;
241240
map_symbol_t map_symbol;
242241
uint8_t header_backup[HDR_BACKUP_SIZE];
@@ -259,8 +258,7 @@ typedef struct _setup_preset_t
259258
#define setup_map_max_size_offset (setup_map_offset_offset + 8)
260259
#define setup_kallsyms_lookup_name_offset_offset (setup_map_max_size_offset + 8)
261260
#define setup_paging_init_offset_offset (setup_kallsyms_lookup_name_offset_offset + 8)
262-
#define setup_paging_init_bl_offset_offset (setup_paging_init_offset_offset + 8)
263-
#define setup_printk_offset_offset (setup_paging_init_bl_offset_offset + 8)
261+
#define setup_printk_offset_offset (setup_paging_init_offset_offset + 8)
264262
#define setup_map_symbol_offset (setup_printk_offset_offset + 8)
265263
#define setup_header_backup_offset (setup_map_symbol_offset + MAP_SYMBOL_SIZE)
266264
#define setup_superkey_offset (setup_header_backup_offset + HDR_BACKUP_SIZE)

kernel/linux/include/linux/vmalloc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ extern void *kfunc_def(vm_map_ram)(struct page **pages, unsigned int count, int
6464
extern void kfunc_def(vm_unmap_aliases)(void);
6565

6666
extern void *kfunc_def(vmalloc)(unsigned long size);
67-
extern void *kfunc_def(vmalloc_noprof)(unsigned long size);
6867
extern void *kfunc_def(vzalloc)(unsigned long size);
6968
extern void *kfunc_def(vmalloc_user)(unsigned long size);
7069
extern void *kfunc_def(vmalloc_node)(unsigned long size, int node);
@@ -122,7 +121,6 @@ static inline void vm_unmap_aliases(void)
122121
static inline void *vmalloc(unsigned long size)
123122
{
124123
kfunc_call(vmalloc, size);
125-
kfunc_call(vmalloc_noprof, size);
126124
kfunc_not_found();
127125
return 0;
128126
}

kernel/patch/common/utils.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ int __must_check compat_copy_to_user(void __user *to, const void *from, int n)
7575
{
7676
int cplen = 0;
7777

78-
if (kfunc(xt_data_to_user)) {
78+
if (kfunc(seq_buf_to_user)) {
79+
cplen = seq_buf_copy_to_user(to, from, n);
80+
} else if (kfunc(xt_data_to_user)) {
7981
// xt_data_to_user, xt_obj_to_user
8082
cplen = compat_xt_data_copy_to_user(to, from, n);
8183
if (!cplen) cplen = n;
8284
} else if (kfunc(bits_to_user)) {
8385
// bits_to_user, str_to_user
8486
cplen = compat_bits_copy_to_user(to, from, n);
85-
} else if (kfunc(seq_buf_to_user)) {
86-
cplen = seq_buf_copy_to_user(to, from, n);
8787
} else if (kfunc(trace_seq_to_user)) {
8888
cplen = trace_seq_copy_to_user(to, from, n);
8989
} else {

kernel/patch/ksyms/misc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ void *kfunc_def(vm_map_ram)(struct page **pages, unsigned int count, int node) =
336336
void kfunc_def(vm_unmap_aliases)(void) = 0;
337337

338338
void *kfunc_def(vmalloc)(unsigned long size) = 0;
339-
void *kfunc_def(vmalloc_noprof)(unsigned long size) = 0;
340339
void *kfunc_def(vzalloc)(unsigned long size) = 0;
341340
void *kfunc_def(vmalloc_user)(unsigned long size) = 0;
342341
void *kfunc_def(vmalloc_node)(unsigned long size, int node) = 0;
@@ -384,7 +383,6 @@ static void _linux_mm_vmalloc_sym_match(const char *name, unsigned long addr)
384383
// kfunc_match(vm_unmap_aliases, name, addr);
385384

386385
kfunc_match(vmalloc, name, addr);
387-
kfunc_match(vmalloc_noprof, name, addr);
388386
kfunc_match(vzalloc, name, addr);
389387
// kfunc_match(vmalloc_user, name, addr);
390388
// kfunc_match(vmalloc_node, name, addr);

tools/common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ extern bool log_enable;
4444
#define align_ceil(x, align) (((uint64_t)(x) + (uint64_t)(align)-1) & ~((uint64_t)(align)-1))
4545

4646
#define INSN_IS_B(inst) (((inst) & 0xFC000000) == 0x14000000)
47-
#define INSN_IS_BL(inst) (((inst) & 0xFC000000) == 0x94000000)
4847

4948
#define bits32(n, high, low) ((uint32_t)((n) << (31u - (high))) >> (31u - (high) + (low)))
5049

0 commit comments

Comments
 (0)