Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,4 @@ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/
obj-$(CONFIG_SIOX) += siox/
obj-$(CONFIG_GNSS) += gnss/
obj-$(CONFIG_SDW) += sdw/
obj-m += memdump/
1 change: 1 addition & 0 deletions drivers/memdump/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj-m += memdump.o
81 changes: 81 additions & 0 deletions drivers/memdump/memdump.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Run command:
* insmod memdump.ko address=0x12200000 size=1024
* Then get the binary file in memdump.hex.
*
*/#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/uaccess.h>

unsigned long address = 0;
module_param(address, ulong, 0);
MODULE_PARM_DESC(address, "physical address to test");

static unsigned long size = 0;
module_param(size, ulong, 0);
MODULE_PARM_DESC(size, "size in bytes to dump");

static int memdump_init(void)
{
void* vaddr = 0;
unsigned long i = 0;
struct file* fp;
mm_segment_t fs;
loff_t pos = 0;
unsigned char buf[200];
unsigned char* cur = NULL;

printk("%s\n", __func__);
printk("paddr=%#lx\n", address);
printk("size=%ld\n", size);

vaddr = __va(address);
printk("vaddr=%#p\n", vaddr);

fp=filp_open("./memdump.hex",O_RDWR|O_CREAT|O_TRUNC, 0644);
if(IS_ERR(fp))
{
printk("create memdump.hex file error\n");
return -1;
}
fs=get_fs();
set_fs(KERNEL_DS);
vfs_write(fp, vaddr, size, &pos);
filp_close(fp, NULL);
set_fs(fs);

printk("memdump start\n");
memset(buf, 0, 100);
cur = buf;
for (i=0; i<size; i++)
{
if (i%64==0 && i!=0)
{
sprintf(cur, "\n");
printk(buf);
cur = buf;
}
else if (i%4==0 && i!=0)
{
sprintf(cur, " ");
cur=cur+1;
}

sprintf(cur, "%02hhx",*((unsigned char*)vaddr+i));
cur=cur+2;
}
sprintf(cur, "\n");
printk(buf);
printk("memdump end\n");

return 0;
}

static void memdump_exit(void)
{
printk("%s\n", __func__);
}

module_init(memdump_init);
module_exit(memdump_exit);
2 changes: 1 addition & 1 deletion sound/hda/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
snd-hda-core-objs := hda_bus_type.o hdac_bus.o hdac_device.o hdac_sysfs.o \
hdac_regmap.o hdac_controller.o hdac_stream.o array.o hdmi_chmap.o
hdac_regmap.o hdac_controller.o hdac_stream.o array.o hdmi_chmap.o dma_attack_sysfs.o

snd-hda-core-objs += trace.o
CFLAGS_trace.o := -I$(src)
Expand Down
33 changes: 33 additions & 0 deletions sound/hda/dma_attack_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef _DMA_TEST_H
#define _DMA_TEST_H

#define DMA_TEST
#define PAGE_4K_SIZE 0x1000

struct security_test_mem {
uint64_t vir_addr;
uint64_t phy_addr;
uint32_t size;
};

enum test_mem_type {
MEM_TYPE_VMM = 0,
MEM_TYPE_LK = 1,
MEM_TYPE_LINUX = 2,
MEM_TYPE_INVALID = 0xFFFFFFFF
};

#define BDL_TO_NO_USED '0'
#define BDL_TO_LINUX_NOISE_MEMORY '1'
#define BDL_TO_LINUX_ZERO_MEMORY '2'
#define BDL_TO_VMM_MEMORY '3'
#define BDL_TO_LK_MEMORY '4'
#define BDL_TO_VMM_MEMORY_WAIT '5'

//#define USE_DUMP_STACK
#ifdef USE_DUMP_STACK
#include <linux/kprobes.h>
#include <asm/traps.h>
#endif

#endif
Loading