提交 a94f0fb1 编写于 作者: S Sebastian Ott 提交者: Martin Schwidefsky

s390/appldata_mem: do not use static data

Using static data for fields which are accessed by HW will fail if
the driver is build as a module (since this would be vmalloc'ed
memory). This Bug was revealed via
"s390: remove virt_to_phys implementation" - the old virt_to_phys
implementation would have translated the address but it was not
guaranteed that the memory was contiguous.
Signed-off-by: NSebastian Ott <sebott@linux.vnet.ibm.com>
Reviewed-by: NGerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
上级 739737ef
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* book: * book:
* http://oss.software.ibm.com/developerworks/opensource/linux390/index.shtml * http://oss.software.ibm.com/developerworks/opensource/linux390/index.shtml
*/ */
static struct appldata_mem_data { struct appldata_mem_data {
u64 timestamp; u64 timestamp;
u32 sync_count_1; /* after VM collected the record data, */ u32 sync_count_1; /* after VM collected the record data, */
u32 sync_count_2; /* sync_count_1 and sync_count_2 should be the u32 sync_count_2; /* sync_count_1 and sync_count_2 should be the
...@@ -63,7 +63,7 @@ static struct appldata_mem_data { ...@@ -63,7 +63,7 @@ static struct appldata_mem_data {
u64 pgmajfault; /* page faults (major only) */ u64 pgmajfault; /* page faults (major only) */
// <-- New in 2.6 // <-- New in 2.6
} __attribute__((packed)) appldata_mem_data; } __packed;
/* /*
...@@ -118,7 +118,6 @@ static struct appldata_ops ops = { ...@@ -118,7 +118,6 @@ static struct appldata_ops ops = {
.record_nr = APPLDATA_RECORD_MEM_ID, .record_nr = APPLDATA_RECORD_MEM_ID,
.size = sizeof(struct appldata_mem_data), .size = sizeof(struct appldata_mem_data),
.callback = &appldata_get_mem_data, .callback = &appldata_get_mem_data,
.data = &appldata_mem_data,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.mod_lvl = {0xF0, 0xF0}, /* EBCDIC "00" */ .mod_lvl = {0xF0, 0xF0}, /* EBCDIC "00" */
}; };
...@@ -131,7 +130,17 @@ static struct appldata_ops ops = { ...@@ -131,7 +130,17 @@ static struct appldata_ops ops = {
*/ */
static int __init appldata_mem_init(void) static int __init appldata_mem_init(void)
{ {
return appldata_register_ops(&ops); int ret;
ops.data = kzalloc(sizeof(struct appldata_mem_data), GFP_KERNEL);
if (!ops.data)
return -ENOMEM;
ret = appldata_register_ops(&ops);
if (ret)
kfree(ops.data);
return ret;
} }
/* /*
...@@ -142,6 +151,7 @@ static int __init appldata_mem_init(void) ...@@ -142,6 +151,7 @@ static int __init appldata_mem_init(void)
static void __exit appldata_mem_exit(void) static void __exit appldata_mem_exit(void)
{ {
appldata_unregister_ops(&ops); appldata_unregister_ops(&ops);
kfree(ops.data);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册