Skip to content

Commit

Permalink
Linux Kernel 3.10.31 compiles and runs (.rej cleaned up)
Browse files Browse the repository at this point in the history
Applied:
/LineageOS/android/kernel/sony/msm8994$ patch -p1 -R <
/home/dj/Downloads/linuxkernelpatches/patch-3.10.31-32

Change-Id: Id20343f99833fa1b16e9ac6b478e3b406b7ea188
  • Loading branch information
djStolen committed Dec 24, 2023
1 parent 40f58a6 commit 14b681f
Show file tree
Hide file tree
Showing 70 changed files with 254 additions and 480 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION = 3
PATCHLEVEL = 10
SUBLEVEL = 32
SUBLEVEL = 31
EXTRAVERSION =
NAME = TOSSUG Baby Fish

Expand Down
7 changes: 2 additions & 5 deletions arch/s390/kernel/head64.S
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,20 @@ ENTRY(startup_continue)
.quad 0 # cr12: tracing off
.quad 0 # cr13: home space segment table
.quad 0xc0000000 # cr14: machine check handling off
.quad .Llinkage_stack # cr15: linkage stack operations
.quad 0 # cr15: linkage stack operations
.Lpcmsk:.quad 0x0000000180000000
.L4malign:.quad 0xffffffffffc00000
.Lscan2g:.quad 0x80000000 + 0x20000 - 8 # 2GB + 128K - 8
.Lnop: .long 0x07000700
.Lparmaddr:
.quad PARMAREA
.align 64
.Lduct: .long 0,.Laste,.Laste,0,.Lduald,0,0,0
.Lduct: .long 0,0,0,0,.Lduald,0,0,0
.long 0,0,0,0,0,0,0,0
.Laste: .quad 0,0xffffffffffffffff,0,0,0,0,0,0
.align 128
.Lduald:.rept 8
.long 0x80000000,0,0,0 # invalid access-list entries
.endr
.Llinkage_stack:
.long 0,0,0x89000000,0,0,0,0x8a000000,0

ENTRY(_ehead)

Expand Down
10 changes: 0 additions & 10 deletions arch/s390/mm/page-states.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include <linux/mm.h>
#include <linux/gfp.h>
#include <linux/init.h>
#include <asm/setup.h>
#include <asm/ipl.h>

#define ESSA_SET_STABLE 1
#define ESSA_SET_UNUSED 2
Expand Down Expand Up @@ -43,14 +41,6 @@ void __init cmma_init(void)

if (!cmma_flag)
return;
/*
* Disable CMM for dump, otherwise the tprot based memory
* detection can fail because of unstable pages.
*/
if (OLDMEM_BASE || ipl_info.type == IPL_TYPE_FCP_DUMP) {
cmma_flag = 0;
return;
}
asm volatile(
" .insn rrf,0xb9ab0000,%1,%1,0,0\n"
"0: la %0,0\n"
Expand Down
31 changes: 11 additions & 20 deletions arch/x86/include/asm/xen/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,38 +79,30 @@ static inline int phys_to_machine_mapping_valid(unsigned long pfn)
return get_phys_to_machine(pfn) != INVALID_P2M_ENTRY;
}

static inline unsigned long mfn_to_pfn_no_overrides(unsigned long mfn)
static inline unsigned long mfn_to_pfn(unsigned long mfn)
{
unsigned long pfn;
int ret;
int ret = 0;

if (xen_feature(XENFEAT_auto_translated_physmap))
return mfn;

if (unlikely(mfn >= machine_to_phys_nr))
return ~0;

if (unlikely(mfn >= machine_to_phys_nr)) {
pfn = ~0;
goto try_override;
}
pfn = 0;
/*
* The array access can fail (e.g., device space beyond end of RAM).
* In such cases it doesn't matter what we return (we return garbage),
* but we must handle the fault without crashing!
*/
ret = __get_user(pfn, &machine_to_phys_mapping[mfn]);
try_override:
/* ret might be < 0 if there are no entries in the m2p for mfn */
if (ret < 0)
return ~0;

return pfn;
}

static inline unsigned long mfn_to_pfn(unsigned long mfn)
{
unsigned long pfn;

if (xen_feature(XENFEAT_auto_translated_physmap))
return mfn;

pfn = mfn_to_pfn_no_overrides(mfn);
if (get_phys_to_machine(pfn) != mfn) {
pfn = ~0;
else if (get_phys_to_machine(pfn) != mfn)
/*
* If this appears to be a foreign mfn (because the pfn
* doesn't map back to the mfn), then check the local override
Expand All @@ -119,7 +111,6 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
* m2p_find_override_pfn returns ~0 if it doesn't find anything.
*/
pfn = m2p_find_override_pfn(mfn, ~0);
}

/*
* pfn is ~0 if there are no entries in the m2p for mfn or if the
Expand Down
7 changes: 1 addition & 6 deletions arch/x86/kernel/cpu/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,8 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
raw_local_save_flags(eflags);
BUG_ON(eflags & X86_EFLAGS_AC);

if (cpu_has(c, X86_FEATURE_SMAP)) {
#ifdef CONFIG_X86_SMAP
if (cpu_has(c, X86_FEATURE_SMAP))
set_in_cr4(X86_CR4_SMAP);
#else
clear_in_cr4(X86_CR4_SMAP);
#endif
}
}

/*
Expand Down
83 changes: 36 additions & 47 deletions arch/x86/kernel/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ within(unsigned long addr, unsigned long start, unsigned long end)
return addr >= start && addr < end;
}

static unsigned long text_ip_addr(unsigned long ip)
static int
do_ftrace_mod_code(unsigned long ip, const void *new_code)
{
/*
* On x86_64, kernel text mappings are mapped read-only with
Expand All @@ -90,7 +91,7 @@ static unsigned long text_ip_addr(unsigned long ip)
if (within(ip, (unsigned long)_text, (unsigned long)_etext))
ip = (unsigned long)__va(__pa_symbol(ip));

return ip;
return probe_kernel_write((void *)ip, new_code, MCOUNT_INSN_SIZE);
}

static const unsigned char *ftrace_nop_replace(void)
Expand Down Expand Up @@ -122,10 +123,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0)
return -EINVAL;

ip = text_ip_addr(ip);

/* replace the text with the new text */
if (probe_kernel_write((void *)ip, new_code, MCOUNT_INSN_SIZE))
if (do_ftrace_mod_code(ip, new_code))
return -EPERM;

sync_core();
Expand Down Expand Up @@ -222,51 +221,37 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
return -EINVAL;
}

static unsigned long ftrace_update_func;

static int update_ftrace_func(unsigned long ip, void *new)
int ftrace_update_ftrace_func(ftrace_func_t func)
{
unsigned char old[MCOUNT_INSN_SIZE];
unsigned long ip = (unsigned long)(&ftrace_call);
unsigned char old[MCOUNT_INSN_SIZE], *new;
int ret;

memcpy(old, (void *)ip, MCOUNT_INSN_SIZE);

ftrace_update_func = ip;
/* Make sure the breakpoints see the ftrace_update_func update */
smp_wmb();
memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
new = ftrace_call_replace(ip, (unsigned long)func);

/* See comment above by declaration of modifying_ftrace_code */
atomic_inc(&modifying_ftrace_code);

ret = ftrace_modify_code(ip, old, new);

atomic_dec(&modifying_ftrace_code);

return ret;
}

int ftrace_update_ftrace_func(ftrace_func_t func)
{
unsigned long ip = (unsigned long)(&ftrace_call);
unsigned char *new;
int ret;

new = ftrace_call_replace(ip, (unsigned long)func);
ret = update_ftrace_func(ip, new);

/* Also update the regs callback function */
if (!ret) {
ip = (unsigned long)(&ftrace_regs_call);
memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
new = ftrace_call_replace(ip, (unsigned long)func);
ret = update_ftrace_func(ip, new);
ret = ftrace_modify_code(ip, old, new);
}

atomic_dec(&modifying_ftrace_code);

return ret;
}

static int is_ftrace_caller(unsigned long ip)
{
if (ip == ftrace_update_func)
if (ip == (unsigned long)(&ftrace_call) ||
ip == (unsigned long)(&ftrace_regs_call))
return 1;

return 0;
Expand Down Expand Up @@ -692,41 +677,45 @@ int __init ftrace_dyn_arch_init(void *data)
#ifdef CONFIG_DYNAMIC_FTRACE
extern void ftrace_graph_call(void);

static unsigned char *ftrace_jmp_replace(unsigned long ip, unsigned long addr)
static int ftrace_mod_jmp(unsigned long ip,
int old_offset, int new_offset)
{
static union ftrace_code_union calc;
unsigned char code[MCOUNT_INSN_SIZE];

/* Jmp not a call (ignore the .e8) */
calc.e8 = 0xe9;
calc.offset = ftrace_calc_offset(ip + MCOUNT_INSN_SIZE, addr);
if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
return -EFAULT;

/*
* ftrace external locks synchronize the access to the static variable.
*/
return calc.code;
}
if (code[0] != 0xe9 || old_offset != *(int *)(&code[1]))
return -EINVAL;

static int ftrace_mod_jmp(unsigned long ip, void *func)
{
unsigned char *new;
*(int *)(&code[1]) = new_offset;

new = ftrace_jmp_replace(ip, (unsigned long)func);
if (do_ftrace_mod_code(ip, &code))
return -EPERM;

return update_ftrace_func(ip, new);
return 0;
}

int ftrace_enable_ftrace_graph_caller(void)
{
unsigned long ip = (unsigned long)(&ftrace_graph_call);
int old_offset, new_offset;

return ftrace_mod_jmp(ip, &ftrace_graph_caller);
old_offset = (unsigned long)(&ftrace_stub) - (ip + MCOUNT_INSN_SIZE);
new_offset = (unsigned long)(&ftrace_graph_caller) - (ip + MCOUNT_INSN_SIZE);

return ftrace_mod_jmp(ip, old_offset, new_offset);
}

int ftrace_disable_ftrace_graph_caller(void)
{
unsigned long ip = (unsigned long)(&ftrace_graph_call);
int old_offset, new_offset;

old_offset = (unsigned long)(&ftrace_graph_caller) - (ip + MCOUNT_INSN_SIZE);
new_offset = (unsigned long)(&ftrace_stub) - (ip + MCOUNT_INSN_SIZE);

return ftrace_mod_jmp(ip, &ftrace_stub);
return ftrace_mod_jmp(ip, old_offset, new_offset);
}

#endif /* !CONFIG_DYNAMIC_FTRACE */
Expand Down
14 changes: 5 additions & 9 deletions arch/x86/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -989,12 +989,6 @@ static int fault_in_kernel_space(unsigned long address)

static inline bool smap_violation(int error_code, struct pt_regs *regs)
{
if (!IS_ENABLED(CONFIG_X86_SMAP))
return false;

if (!static_cpu_has(X86_FEATURE_SMAP))
return false;

if (error_code & PF_USER)
return false;

Expand Down Expand Up @@ -1097,9 +1091,11 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
if (unlikely(error_code & PF_RSVD))
pgtable_bad(regs, error_code, address);

if (unlikely(smap_violation(error_code, regs))) {
bad_area_nosemaphore(regs, error_code, address);
return;
if (static_cpu_has(X86_FEATURE_SMAP)) {
if (unlikely(smap_violation(error_code, regs))) {
bad_area_nosemaphore(regs, error_code, address);
return;
}
}

perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
Expand Down
10 changes: 6 additions & 4 deletions arch/x86/xen/p2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ int m2p_add_override(unsigned long mfn, struct page *page,
unsigned long uninitialized_var(address);
unsigned level;
pte_t *ptep = NULL;
int ret = 0;

pfn = page_to_pfn(page);
if (!PageHighMem(page)) {
Expand Down Expand Up @@ -924,8 +925,8 @@ int m2p_add_override(unsigned long mfn, struct page *page,
* frontend pages while they are being shared with the backend,
* because mfn_to_pfn (that ends up being called by GUPF) will
* return the backend pfn rather than the frontend pfn. */
pfn = mfn_to_pfn_no_overrides(mfn);
if (get_phys_to_machine(pfn) == mfn)
ret = __get_user(pfn, &machine_to_phys_mapping[mfn]);
if (ret == 0 && get_phys_to_machine(pfn) == mfn)
set_phys_to_machine(pfn, FOREIGN_FRAME(mfn));

return 0;
Expand All @@ -940,6 +941,7 @@ int m2p_remove_override(struct page *page,
unsigned long uninitialized_var(address);
unsigned level;
pte_t *ptep = NULL;
int ret = 0;

pfn = page_to_pfn(page);
mfn = get_phys_to_machine(pfn);
Expand Down Expand Up @@ -1017,8 +1019,8 @@ int m2p_remove_override(struct page *page,
* the original pfn causes mfn_to_pfn(mfn) to return the frontend
* pfn again. */
mfn &= ~FOREIGN_FRAME_BIT;
pfn = mfn_to_pfn_no_overrides(mfn);
if (get_phys_to_machine(pfn) == FOREIGN_FRAME(mfn) &&
ret = __get_user(pfn, &machine_to_phys_mapping[mfn]);
if (ret == 0 && get_phys_to_machine(pfn) == FOREIGN_FRAME(mfn) &&
m2p_find_override(mfn) == NULL)
set_phys_to_machine(pfn, mfn);

Expand Down
9 changes: 0 additions & 9 deletions arch/x86/xen/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
old memory can be recycled */
make_lowmem_page_readwrite(xen_initial_gdt);

#ifdef CONFIG_X86_32
/*
* Xen starts us with XEN_FLAT_RING1_DS, but linux code
* expects __USER_DS
*/
loadsegment(ds, __USER_DS);
loadsegment(es, __USER_DS);
#endif

xen_filter_cpu_maps();
xen_setup_vcpu_info_placement();
}
Expand Down
8 changes: 0 additions & 8 deletions block/blk-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,6 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,

atomic_inc(&bb.done);
submit_bio(type, bio);

/*
* We can loop for a long time in here, if someone does
* full device discards (like mkfs). Be nice and allow
* us to schedule out to avoid softlocking if preempt
* is disabled.
*/
cond_resched();
}
blk_finish_plug(&plug);

Expand Down
2 changes: 1 addition & 1 deletion block/blk.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static inline struct request *__elv_next_request(struct request_queue *q)
q->flush_queue_delayed = 1;
return NULL;
}
if (unlikely(blk_queue_bypass(q)) ||
if (unlikely(blk_queue_dying(q)) ||
!q->elevator->type->ops.elevator_dispatch_fn(q, 0))
return NULL;
}
Expand Down
Loading

0 comments on commit 14b681f

Please sign in to comment.