qubes-linux-kernel/patches.xen/xen-kzalloc

187 lines
7.3 KiB
Plaintext
Raw Normal View History

From: jbeulich@novell.com
Subject: use kzalloc() in favor of kmalloc()+memset()
Patch-mainline: n/a
Also use clear_page() in favor of memset(, 0, PAGE_SIZE).
2011-04-19 20:09:59 +00:00
--- head-2011-02-17.orig/arch/x86/mm/init_32-xen.c 2011-02-02 15:07:16.000000000 +0100
+++ head-2011-02-17/arch/x86/mm/init_32-xen.c 2011-02-02 15:10:16.000000000 +0100
@@ -724,7 +724,7 @@ unsigned long __init extend_init_mapping
if (pmd_none(*pmd)) {
unsigned long pa = start_pfn++ << PAGE_SHIFT;
- memset(__va(pa), 0, PAGE_SIZE);
+ clear_page(__va(pa));
make_lowmem_page_readonly(__va(pa),
XENFEAT_writable_page_tables);
xen_l2_entry_update(pmd, __pmd(pa | _KERNPG_TABLE));
--- head-2011-02-17.orig/arch/x86/mm/init_64-xen.c 2011-02-02 15:07:16.000000000 +0100
+++ head-2011-02-17/arch/x86/mm/init_64-xen.c 2011-02-02 15:10:16.000000000 +0100
@@ -213,7 +213,7 @@ static __ref void *spp_getpage(void)
else if (e820_table_end < e820_table_top) {
ptr = __va(e820_table_end << PAGE_SHIFT);
e820_table_end++;
- memset(ptr, 0, PAGE_SIZE);
+ clear_page(ptr);
} else
ptr = alloc_bootmem_pages(PAGE_SIZE);
--- head-2011-02-17.orig/drivers/xen/blkback/blkback.c 2011-02-28 14:23:53.000000000 +0100
+++ head-2011-02-17/drivers/xen/blkback/blkback.c 2011-02-28 14:26:29.000000000 +0100
@@ -639,7 +639,7 @@ static int __init blkif_init(void)
mmap_pages = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
- pending_reqs = kmalloc(sizeof(pending_reqs[0]) *
+ pending_reqs = kzalloc(sizeof(pending_reqs[0]) *
blkif_reqs, GFP_KERNEL);
pending_grant_handles = kmalloc(sizeof(pending_grant_handles[0]) *
mmap_pages, GFP_KERNEL);
2011-04-19 20:09:59 +00:00
@@ -656,7 +656,6 @@ static int __init blkif_init(void)
blkif_interface_init();
- memset(pending_reqs, 0, sizeof(pending_reqs));
INIT_LIST_HEAD(&pending_free);
for (i = 0; i < blkif_reqs; i++)
2011-04-19 20:09:59 +00:00
--- head-2011-02-17.orig/drivers/xen/core/gnttab.c 2010-09-23 17:06:35.000000000 +0200
+++ head-2011-02-17/drivers/xen/core/gnttab.c 2011-02-02 15:10:16.000000000 +0100
@@ -546,7 +546,7 @@ int gnttab_copy_grant_page(grant_ref_t r
new_addr = page_address(new_page);
addr = page_address(page);
- memcpy(new_addr, addr, PAGE_SIZE);
+ copy_page(new_addr, addr);
pfn = page_to_pfn(page);
mfn = pfn_to_mfn(pfn);
--- head-2011-02-17.orig/drivers/xen/core/machine_reboot.c 2011-02-02 15:09:52.000000000 +0100
+++ head-2011-02-17/drivers/xen/core/machine_reboot.c 2011-02-02 15:10:16.000000000 +0100
@@ -97,7 +97,7 @@ static void post_suspend(int suspend_can
BUG();
HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
- memset(empty_zero_page, 0, PAGE_SIZE);
+ clear_page(empty_zero_page);
fpp = PAGE_SIZE/sizeof(unsigned long);
for (i = 0, j = 0, k = -1; i < max_pfn; i += fpp, j++) {
2011-04-19 20:09:59 +00:00
--- head-2011-02-17.orig/drivers/xen/core/smpboot.c 2011-02-07 12:28:20.000000000 +0100
+++ head-2011-02-17/drivers/xen/core/smpboot.c 2011-02-02 15:10:16.000000000 +0100
@@ -176,17 +176,12 @@ static void __cpuinit cpu_initialize_con
ctxt.flags = VGCF_IN_KERNEL;
ctxt.user_regs.ds = __USER_DS;
ctxt.user_regs.es = __USER_DS;
- ctxt.user_regs.fs = 0;
- ctxt.user_regs.gs = 0;
ctxt.user_regs.ss = __KERNEL_DS;
ctxt.user_regs.eip = (unsigned long)cpu_bringup_and_idle;
ctxt.user_regs.eflags = X86_EFLAGS_IF | 0x1000; /* IOPL_RING1 */
- memset(&ctxt.fpu_ctxt, 0, sizeof(ctxt.fpu_ctxt));
-
smp_trap_init(ctxt.trap_ctxt);
- ctxt.ldt_ents = 0;
ctxt.gdt_frames[0] = arbitrary_virt_to_mfn(get_cpu_gdt_table(cpu));
ctxt.gdt_ents = GDT_SIZE / 8;
2011-04-19 20:09:59 +00:00
--- head-2011-02-17.orig/drivers/xen/netback/interface.c 2011-02-17 10:34:28.000000000 +0100
+++ head-2011-02-17/drivers/xen/netback/interface.c 2011-02-17 10:36:11.000000000 +0100
@@ -270,7 +270,6 @@ netif_t *netif_alloc(struct device *pare
SET_NETDEV_DEV(dev, parent);
netif = netdev_priv(dev);
- memset(netif, 0, sizeof(*netif));
netif->domid = domid;
netif->group = UINT_MAX;
netif->handle = handle;
2011-04-19 20:09:59 +00:00
--- head-2011-02-17.orig/drivers/xen/scsiback/emulate.c 2011-02-08 10:04:09.000000000 +0100
+++ head-2011-02-17/drivers/xen/scsiback/emulate.c 2011-02-08 10:45:57.000000000 +0100
@@ -243,13 +243,11 @@ static void __report_luns(pending_req_t
alloc_len = sizeof(struct scsi_lun) * alloc_luns
+ VSCSI_REPORT_LUNS_HEADER;
retry:
- if ((buff = kmalloc(alloc_len, GFP_KERNEL)) == NULL) {
+ if ((buff = kzalloc(alloc_len, GFP_KERNEL)) == NULL) {
2011-04-19 20:09:59 +00:00
pr_err("scsiback:%s kmalloc err\n", __FUNCTION__);
goto fail;
}
- memset(buff, 0, alloc_len);
-
one_lun = (struct scsi_lun *) &buff[8];
spin_lock_irqsave(&info->v2p_lock, flags);
list_for_each_entry(entry, head, l) {
2011-04-19 20:09:59 +00:00
--- head-2011-02-17.orig/drivers/xen/scsiback/scsiback.c 2011-02-28 14:51:23.000000000 +0100
+++ head-2011-02-17/drivers/xen/scsiback/scsiback.c 2011-02-28 14:53:21.000000000 +0100
@@ -668,7 +668,7 @@ static int __init scsiback_init(void)
mmap_pages = vscsiif_reqs * VSCSIIF_SG_TABLESIZE;
- pending_reqs = kmalloc(sizeof(pending_reqs[0]) *
+ pending_reqs = kzalloc(sizeof(pending_reqs[0]) *
vscsiif_reqs, GFP_KERNEL);
pending_grant_handles = kmalloc(sizeof(pending_grant_handles[0]) *
mmap_pages, GFP_KERNEL);
2011-04-19 20:09:59 +00:00
@@ -683,7 +683,6 @@ static int __init scsiback_init(void)
if (scsiback_interface_init() < 0)
goto out_of_kmem;
- memset(pending_reqs, 0, sizeof(pending_reqs));
INIT_LIST_HEAD(&pending_free);
for (i = 0; i < vscsiif_reqs; i++)
2011-04-19 20:09:59 +00:00
--- head-2011-02-17.orig/drivers/xen/sfc_netutil/accel_cuckoo_hash.c 2011-02-01 15:03:03.000000000 +0100
+++ head-2011-02-17/drivers/xen/sfc_netutil/accel_cuckoo_hash.c 2011-02-02 15:10:16.000000000 +0100
@@ -77,7 +77,7 @@ int cuckoo_hash_init(cuckoo_hash_table *
BUG_ON(length_bits >= sizeof(unsigned) * 8);
BUG_ON(key_length > sizeof(cuckoo_hash_key));
- table_mem = kmalloc(sizeof(cuckoo_hash_entry) * 2 * length, GFP_KERNEL);
+ table_mem = kzalloc(sizeof(cuckoo_hash_entry) * 2 * length, GFP_KERNEL);
if (table_mem == NULL)
return -ENOMEM;
@@ -93,9 +93,6 @@ int cuckoo_hash_init(cuckoo_hash_table *
set_hash_parameters(hashtab);
- /* Zero the table */
- memset(hashtab->table0, 0, length * 2 * sizeof(cuckoo_hash_entry));
-
return 0;
}
EXPORT_SYMBOL_GPL(cuckoo_hash_init);
2011-04-19 20:09:59 +00:00
--- head-2011-02-17.orig/drivers/xen/tpmback/interface.c 2011-01-31 17:56:27.000000000 +0100
+++ head-2011-02-17/drivers/xen/tpmback/interface.c 2011-02-02 15:10:16.000000000 +0100
@@ -128,7 +128,7 @@ int tpmif_map(tpmif_t *tpmif, unsigned l
}
tpmif->tx = (tpmif_tx_interface_t *)tpmif->tx_area->addr;
- memset(tpmif->tx, 0, PAGE_SIZE);
+ clear_page(tpmif->tx);
err = bind_interdomain_evtchn_to_irqhandler(
tpmif->domid, evtchn, tpmif_be_int, 0, tpmif->devname, tpmif);
2011-04-19 20:09:59 +00:00
--- head-2011-02-17.orig/drivers/xen/usbback/usbback.c 2011-02-01 15:03:10.000000000 +0100
+++ head-2011-02-17/drivers/xen/usbback/usbback.c 2011-02-02 15:10:16.000000000 +0100
@@ -1140,7 +1140,7 @@ static int __init usbback_init(void)
return -ENODEV;
mmap_pages = usbif_reqs * USBIF_MAX_SEGMENTS_PER_REQUEST;
- pending_reqs = kmalloc(sizeof(pending_reqs[0]) *
+ pending_reqs = kzalloc(sizeof(pending_reqs[0]) *
usbif_reqs, GFP_KERNEL);
pending_grant_handles = kmalloc(sizeof(pending_grant_handles[0]) *
mmap_pages, GFP_KERNEL);
2011-04-19 20:09:59 +00:00
@@ -1154,7 +1154,6 @@ static int __init usbback_init(void)
for (i = 0; i < mmap_pages; i++)
pending_grant_handles[i] = USBBACK_INVALID_HANDLE;
- memset(pending_reqs, 0, sizeof(pending_reqs));
INIT_LIST_HEAD(&pending_free);
for (i = 0; i < usbif_reqs; i++)