RK3288 7.1 内存作假,cpu频率扩大

有时候我们客户需要我们在内存和cpu做手脚,但是又不能只是在Settings里面修改,因为那样会被安兔兔检查出来,

我们可以在内核里面修改,安兔兔最终测试的途径也是测试内核生成的一些特定节点,以下是补丁,基于rk3288 7.1的版本,其他

的版本可以参考修改,原理都是相同的。

 

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 875f22f..d54426c 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -668,11 +668,23 @@ static ssize_t show_##file_name                \
     return sprintf(buf, "%u\n", policy->object);    \
 }
 
+
+static ssize_t show_scaling_max_freq(struct cpufreq_policy *policy, char *buf)        
+{                            
+    printk("hxl policy->object == \n"); 
+    return sprintf(buf, "%u\n", 1800000);
+}
+
+static ssize_t show_cpuinfo_max_freq(struct cpufreq_policy *policy, char *buf)        
+{                            
+    printk("hxl cpuinfo_max_freq == \n"); 
+    return sprintf(buf, "%u\n", 1800000);
+}
 show_one(cpuinfo_min_freq, cpuinfo.min_freq);
-show_one(cpuinfo_max_freq, cpuinfo.max_freq);
+//show_one(cpuinfo_max_freq, cpuinfo.max_freq);
 show_one(cpuinfo_transition_latency, cpuinfo.transition_latency);
 show_one(scaling_min_freq, min);
-show_one(scaling_max_freq, max);
+//show_one(scaling_max_freq, max);
 
 static ssize_t show_scaling_cur_freq(struct cpufreq_policy *policy, char *buf)
 {
@@ -1276,6 +1288,7 @@ static int cpufreq_online(unsigned int cpu)
      */
     cpumask_and(policy->cpus, policy->cpus, cpu_online_mask);
 
+     
     if (new_policy) {
         policy->user_policy.min = policy->min;
         policy->user_policy.max = policy->max;
@@ -1959,7 +1972,10 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
 
     /* Make sure that target_freq is within supported range */
     if (target_freq > policy->max)
+    {
+        printk("target_freq ==== %d\n",target_freq);
         target_freq = policy->max;
+    }
     if (target_freq < policy->min)
         target_freq = policy->min;
 
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index a8f1daf..8d1bb87 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -257,6 +257,7 @@ static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf,
 
         count += sprintf(&buf[count], "%d ", pos->frequency);
     }
+    count += sprintf(&buf[count], "%d ", 1800000000);
     count += sprintf(&buf[count], "\n");
 
     return count;
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index df4661a..6116081 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -23,6 +23,13 @@ void __attribute__((weak)) arch_report_meminfo(struct seq_file *m)
 {
 }
 
+#define FAKE_RAM_SIZE 4194304000
+
+#define SHIFT 10
+__kernel_ulong_t size;
+__kernel_ulong_t ratio;
+
+
 static int meminfo_proc_show(struct seq_file *m, void *v)
 {
     struct sysinfo i;
@@ -51,6 +58,9 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
     for (lru = LRU_BASE; lru < NR_LRU_LISTS; lru++)
         pages[lru] = global_page_state(NR_LRU_BASE + lru);
 
+    size = FAKE_RAM_SIZE >> PAGE_SHIFT;
+    ratio = (size << SHIFT) / i.totalram;
+
     for_each_zone(zone)
         wmark_low += zone->watermark[WMARK_LOW];
 
@@ -140,8 +150,10 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
         "CmaFree:        %8lu kB\n"
 #endif
         ,
-        K(i.totalram),
-        K(i.freeram),
+        //K(i.totalram),
+        //K(i.freeram),
+        K(size),
+        K((i.freeram * ratio) >> SHIFT),
         K(available),
         K(i.bufferram),
         K(cached),
@@ -155,10 +167,14 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
         K(pages[LRU_UNEVICTABLE]),
         K(global_page_state(NR_MLOCK)),
 #ifdef CONFIG_HIGHMEM
-        K(i.totalhigh),
-        K(i.freehigh),
-        K(i.totalram-i.totalhigh),
-        K(i.freeram-i.freehigh),
+        //K(i.totalhigh),
+        //K(i.freehigh),
+        //K(i.totalram-i.totalhigh),
+        //K(i.freeram-i.freehigh),
+        K((i.totalhigh * ratio) >> SHIFT),
+        K((i.freehigh * ratio) >> SHIFT),
+        K(size - ((i.totalhigh * ratio) >> SHIFT)),
+        K((i.freeram - i.freehigh) * ratio >> SHIFT),
 #endif
 #ifndef CONFIG_MMU
         K((unsigned long) atomic_long_read(&mmap_pages_allocated)),
 

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值