The stock 73.1.A.2.74 kernel is Google's GKI build ab15926011 of 202a62288cb6, but the common kernel in Sony's open source archive is an older snapshot: it lacks, among others, CONFIG_ARM64_ERRATUM_4118414 and CONFIG_ARM64_ERRATUM_4193714, which the stock kernel enables, and a kernel built from it does not boot on pdx267. Use the exact stock source instead (kernel/common tag android16-6.12-2026-03_r59). Co-Authored-By: Claude Opus 5.5 <[email protected]>
104 lines
2.6 KiB
C
104 lines
2.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_PAGE_SIZE_MIGRATION_H
|
|
#define _LINUX_PAGE_SIZE_MIGRATION_H
|
|
|
|
/*
|
|
* Page Size Migration
|
|
*
|
|
* Copyright (c) 2024, Google LLC.
|
|
* Author: Kalesh Singh <[email protected]>
|
|
*
|
|
* This file contains the APIs for mitigations to ensure
|
|
* app compatibility during the transition from 4kB to 16kB
|
|
* page size in Android.
|
|
*/
|
|
|
|
#include <linux/elf.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/pgsize_migration_inline.h>
|
|
#include <linux/printk.h>
|
|
#include <linux/seq_file.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/sched.h>
|
|
|
|
#define pgmigration_err(fmt, ...) \
|
|
pr_err("page size migration: [%i (%s)] %s:%d: " fmt, \
|
|
task_pid_nr(current), current->comm, __func__, __LINE__, ## __VA_ARGS__)
|
|
|
|
#if PAGE_SIZE == SZ_4K && defined(CONFIG_64BIT)
|
|
extern void vma_set_pad_pages(struct vm_area_struct *vma,
|
|
unsigned long nr_pages);
|
|
|
|
extern unsigned long vma_pad_pages(struct vm_area_struct *vma);
|
|
|
|
extern void madvise_vma_pad_pages(struct vm_area_struct *vma,
|
|
unsigned long start, unsigned long end);
|
|
|
|
extern void show_map_pad_vma(struct vm_area_struct *vma,
|
|
struct seq_file *m, void *func, bool smaps);
|
|
|
|
extern void split_pad_vma(struct vm_area_struct *vma, struct vm_area_struct *new,
|
|
unsigned long addr, int new_below);
|
|
|
|
extern bool is_mergable_pad_vma(struct vm_area_struct *vma,
|
|
unsigned long vm_flags);
|
|
|
|
extern unsigned long vma_data_pages(struct vm_area_struct *vma);
|
|
#else /* PAGE_SIZE != SZ_4K || !defined(CONFIG_64BIT) */
|
|
static inline void vma_set_pad_pages(struct vm_area_struct *vma,
|
|
unsigned long nr_pages)
|
|
{
|
|
}
|
|
|
|
static inline unsigned long vma_pad_pages(struct vm_area_struct *vma)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void madvise_vma_pad_pages(struct vm_area_struct *vma,
|
|
unsigned long start, unsigned long end)
|
|
{
|
|
}
|
|
|
|
static inline void show_map_pad_vma(struct vm_area_struct *vma,
|
|
struct seq_file *m, void *func, bool smaps)
|
|
{
|
|
}
|
|
|
|
static inline void split_pad_vma(struct vm_area_struct *vma, struct vm_area_struct *new,
|
|
unsigned long addr, int new_below)
|
|
{
|
|
}
|
|
|
|
static inline bool is_mergable_pad_vma(struct vm_area_struct *vma,
|
|
unsigned long vm_flags)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
static inline unsigned long vma_data_pages(struct vm_area_struct *vma)
|
|
{
|
|
return vma_pages(vma);
|
|
}
|
|
#endif /* PAGE_SIZE == SZ_4K && defined(CONFIG_64BIT) */
|
|
|
|
static inline bool is_elf_file(struct file *file)
|
|
{
|
|
char buf[SELFMAG];
|
|
loff_t pos = 0;
|
|
|
|
if (!file)
|
|
return false;
|
|
|
|
/*
|
|
* Read the first SELFMAG bytes of the file to check for the
|
|
* ELF magic number.
|
|
*/
|
|
if (kernel_read(file, buf, SELFMAG, &pos) != SELFMAG)
|
|
return false;
|
|
|
|
return !memcmp(buf, ELFMAG, SELFMAG);
|
|
}
|
|
|
|
#endif /* _LINUX_PAGE_SIZE_MIGRATION_H */
|