Skip to content

Commit 292974c

Browse files
committed
Merge tag 'for-linus-4.20a-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen fixes from Juergen Gross: - A revert of a previous commit as it is no longer necessary and has shown to cause problems in some memory hotplug cases. - Some small fixes and a minor cleanup. - A patch for adding better diagnostic data in a very rare failure case. * tag 'for-linus-4.20a-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: pvcalls-front: fixes incorrect error handling Revert "xen/balloon: Mark unallocated host memory as UNUSABLE" xen: xlate_mmu: add missing header to fix 'W=1' warning xen/x86: add diagnostic printout to xen_mc_flush() in case of error x86/xen: cleanup includes in arch/x86/xen/spinlock.c
2 parents a234c73 + 975ef94 commit 292974c

File tree

8 files changed

+37
-164
lines changed

8 files changed

+37
-164
lines changed

arch/x86/xen/enlighten.c

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <xen/xen.h>
1111
#include <xen/features.h>
1212
#include <xen/page.h>
13-
#include <xen/interface/memory.h>
1413

1514
#include <asm/xen/hypercall.h>
1615
#include <asm/xen/hypervisor.h>
@@ -346,80 +345,3 @@ void xen_arch_unregister_cpu(int num)
346345
}
347346
EXPORT_SYMBOL(xen_arch_unregister_cpu);
348347
#endif
349-
350-
#ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
351-
void __init arch_xen_balloon_init(struct resource *hostmem_resource)
352-
{
353-
struct xen_memory_map memmap;
354-
int rc;
355-
unsigned int i, last_guest_ram;
356-
phys_addr_t max_addr = PFN_PHYS(max_pfn);
357-
struct e820_table *xen_e820_table;
358-
const struct e820_entry *entry;
359-
struct resource *res;
360-
361-
if (!xen_initial_domain())
362-
return;
363-
364-
xen_e820_table = kmalloc(sizeof(*xen_e820_table), GFP_KERNEL);
365-
if (!xen_e820_table)
366-
return;
367-
368-
memmap.nr_entries = ARRAY_SIZE(xen_e820_table->entries);
369-
set_xen_guest_handle(memmap.buffer, xen_e820_table->entries);
370-
rc = HYPERVISOR_memory_op(XENMEM_machine_memory_map, &memmap);
371-
if (rc) {
372-
pr_warn("%s: Can't read host e820 (%d)\n", __func__, rc);
373-
goto out;
374-
}
375-
376-
last_guest_ram = 0;
377-
for (i = 0; i < memmap.nr_entries; i++) {
378-
if (xen_e820_table->entries[i].addr >= max_addr)
379-
break;
380-
if (xen_e820_table->entries[i].type == E820_TYPE_RAM)
381-
last_guest_ram = i;
382-
}
383-
384-
entry = &xen_e820_table->entries[last_guest_ram];
385-
if (max_addr >= entry->addr + entry->size)
386-
goto out; /* No unallocated host RAM. */
387-
388-
hostmem_resource->start = max_addr;
389-
hostmem_resource->end = entry->addr + entry->size;
390-
391-
/*
392-
* Mark non-RAM regions between the end of dom0 RAM and end of host RAM
393-
* as unavailable. The rest of that region can be used for hotplug-based
394-
* ballooning.
395-
*/
396-
for (; i < memmap.nr_entries; i++) {
397-
entry = &xen_e820_table->entries[i];
398-
399-
if (entry->type == E820_TYPE_RAM)
400-
continue;
401-
402-
if (entry->addr >= hostmem_resource->end)
403-
break;
404-
405-
res = kzalloc(sizeof(*res), GFP_KERNEL);
406-
if (!res)
407-
goto out;
408-
409-
res->name = "Unavailable host RAM";
410-
res->start = entry->addr;
411-
res->end = (entry->addr + entry->size < hostmem_resource->end) ?
412-
entry->addr + entry->size : hostmem_resource->end;
413-
rc = insert_resource(hostmem_resource, res);
414-
if (rc) {
415-
pr_warn("%s: Can't insert [%llx - %llx) (%d)\n",
416-
__func__, res->start, res->end, rc);
417-
kfree(res);
418-
goto out;
419-
}
420-
}
421-
422-
out:
423-
kfree(xen_e820_table);
424-
}
425-
#endif /* CONFIG_XEN_BALLOON_MEMORY_HOTPLUG */

arch/x86/xen/multicalls.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ void xen_mc_flush(void)
6969

7070
trace_xen_mc_flush(b->mcidx, b->argidx, b->cbidx);
7171

72+
#if MC_DEBUG
73+
memcpy(b->debug, b->entries,
74+
b->mcidx * sizeof(struct multicall_entry));
75+
#endif
76+
7277
switch (b->mcidx) {
7378
case 0:
7479
/* no-op */
@@ -87,32 +92,34 @@ void xen_mc_flush(void)
8792
break;
8893

8994
default:
90-
#if MC_DEBUG
91-
memcpy(b->debug, b->entries,
92-
b->mcidx * sizeof(struct multicall_entry));
93-
#endif
94-
9595
if (HYPERVISOR_multicall(b->entries, b->mcidx) != 0)
9696
BUG();
9797
for (i = 0; i < b->mcidx; i++)
9898
if (b->entries[i].result < 0)
9999
ret++;
100+
}
100101

102+
if (WARN_ON(ret)) {
103+
pr_err("%d of %d multicall(s) failed: cpu %d\n",
104+
ret, b->mcidx, smp_processor_id());
105+
for (i = 0; i < b->mcidx; i++) {
106+
if (b->entries[i].result < 0) {
101107
#if MC_DEBUG
102-
if (ret) {
103-
printk(KERN_ERR "%d multicall(s) failed: cpu %d\n",
104-
ret, smp_processor_id());
105-
dump_stack();
106-
for (i = 0; i < b->mcidx; i++) {
107-
printk(KERN_DEBUG " call %2d/%d: op=%lu arg=[%lx] result=%ld\t%pF\n",
108-
i+1, b->mcidx,
108+
pr_err(" call %2d: op=%lu arg=[%lx] result=%ld\t%pF\n",
109+
i + 1,
109110
b->debug[i].op,
110111
b->debug[i].args[0],
111112
b->entries[i].result,
112113
b->caller[i]);
114+
#else
115+
pr_err(" call %2d: op=%lu arg=[%lx] result=%ld\n",
116+
i + 1,
117+
b->entries[i].op,
118+
b->entries[i].args[0],
119+
b->entries[i].result);
120+
#endif
113121
}
114122
}
115-
#endif
116123
}
117124

118125
b->mcidx = 0;
@@ -126,8 +133,6 @@ void xen_mc_flush(void)
126133
b->cbidx = 0;
127134

128135
local_irq_restore(flags);
129-
130-
WARN_ON(ret);
131136
}
132137

133138
struct multicall_space __xen_mc_entry(size_t args)

arch/x86/xen/setup.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ char * __init xen_memory_setup(void)
808808
addr = xen_e820_table.entries[0].addr;
809809
size = xen_e820_table.entries[0].size;
810810
while (i < xen_e820_table.nr_entries) {
811+
bool discard = false;
811812

812813
chunk_size = size;
813814
type = xen_e820_table.entries[i].type;
@@ -823,10 +824,11 @@ char * __init xen_memory_setup(void)
823824
xen_add_extra_mem(pfn_s, n_pfns);
824825
xen_max_p2m_pfn = pfn_s + n_pfns;
825826
} else
826-
type = E820_TYPE_UNUSABLE;
827+
discard = true;
827828
}
828829

829-
xen_align_and_add_e820_region(addr, chunk_size, type);
830+
if (!discard)
831+
xen_align_and_add_e820_region(addr, chunk_size, type);
830832

831833
addr += chunk_size;
832834
size -= chunk_size;

arch/x86/xen/spinlock.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@
33
* Split spinlock implementation out into its own file, so it can be
44
* compiled in a FTRACE-compatible way.
55
*/
6-
#include <linux/kernel_stat.h>
6+
#include <linux/kernel.h>
77
#include <linux/spinlock.h>
8-
#include <linux/debugfs.h>
9-
#include <linux/log2.h>
10-
#include <linux/gfp.h>
118
#include <linux/slab.h>
129
#include <linux/atomic.h>
1310

1411
#include <asm/paravirt.h>
1512
#include <asm/qspinlock.h>
1613

17-
#include <xen/interface/xen.h>
1814
#include <xen/events.h>
1915

2016
#include "xen-ops.h"
21-
#include "debugfs.h"
2217

2318
static DEFINE_PER_CPU(int, lock_kicker_irq) = -1;
2419
static DEFINE_PER_CPU(char *, irq_name);

drivers/xen/balloon.c

Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -251,25 +251,10 @@ static void release_memory_resource(struct resource *resource)
251251
kfree(resource);
252252
}
253253

254-
/*
255-
* Host memory not allocated to dom0. We can use this range for hotplug-based
256-
* ballooning.
257-
*
258-
* It's a type-less resource. Setting IORESOURCE_MEM will make resource
259-
* management algorithms (arch_remove_reservations()) look into guest e820,
260-
* which we don't want.
261-
*/
262-
static struct resource hostmem_resource = {
263-
.name = "Host RAM",
264-
};
265-
266-
void __attribute__((weak)) __init arch_xen_balloon_init(struct resource *res)
267-
{}
268-
269254
static struct resource *additional_memory_resource(phys_addr_t size)
270255
{
271-
struct resource *res, *res_hostmem;
272-
int ret = -ENOMEM;
256+
struct resource *res;
257+
int ret;
273258

274259
res = kzalloc(sizeof(*res), GFP_KERNEL);
275260
if (!res)
@@ -278,42 +263,13 @@ static struct resource *additional_memory_resource(phys_addr_t size)
278263
res->name = "System RAM";
279264
res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
280265

281-
res_hostmem = kzalloc(sizeof(*res), GFP_KERNEL);
282-
if (res_hostmem) {
283-
/* Try to grab a range from hostmem */
284-
res_hostmem->name = "Host memory";
285-
ret = allocate_resource(&hostmem_resource, res_hostmem,
286-
size, 0, -1,
287-
PAGES_PER_SECTION * PAGE_SIZE, NULL, NULL);
288-
}
289-
290-
if (!ret) {
291-
/*
292-
* Insert this resource into iomem. Because hostmem_resource
293-
* tracks portion of guest e820 marked as UNUSABLE noone else
294-
* should try to use it.
295-
*/
296-
res->start = res_hostmem->start;
297-
res->end = res_hostmem->end;
298-
ret = insert_resource(&iomem_resource, res);
299-
if (ret < 0) {
300-
pr_err("Can't insert iomem_resource [%llx - %llx]\n",
301-
res->start, res->end);
302-
release_memory_resource(res_hostmem);
303-
res_hostmem = NULL;
304-
res->start = res->end = 0;
305-
}
306-
}
307-
308-
if (ret) {
309-
ret = allocate_resource(&iomem_resource, res,
310-
size, 0, -1,
311-
PAGES_PER_SECTION * PAGE_SIZE, NULL, NULL);
312-
if (ret < 0) {
313-
pr_err("Cannot allocate new System RAM resource\n");
314-
kfree(res);
315-
return NULL;
316-
}
266+
ret = allocate_resource(&iomem_resource, res,
267+
size, 0, -1,
268+
PAGES_PER_SECTION * PAGE_SIZE, NULL, NULL);
269+
if (ret < 0) {
270+
pr_err("Cannot allocate new System RAM resource\n");
271+
kfree(res);
272+
return NULL;
317273
}
318274

319275
#ifdef CONFIG_SPARSEMEM
@@ -325,7 +281,6 @@ static struct resource *additional_memory_resource(phys_addr_t size)
325281
pr_err("New System RAM resource outside addressable RAM (%lu > %lu)\n",
326282
pfn, limit);
327283
release_memory_resource(res);
328-
release_memory_resource(res_hostmem);
329284
return NULL;
330285
}
331286
}
@@ -750,8 +705,6 @@ static int __init balloon_init(void)
750705
set_online_page_callback(&xen_online_page);
751706
register_memory_notifier(&xen_memory_nb);
752707
register_sysctl_table(xen_root);
753-
754-
arch_xen_balloon_init(&hostmem_resource);
755708
#endif
756709

757710
#ifdef CONFIG_XEN_PV

drivers/xen/pvcalls-front.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ static int create_active(struct sock_mapping *map, int *evtchn)
385385
out_error:
386386
if (*evtchn >= 0)
387387
xenbus_free_evtchn(pvcalls_front_dev, *evtchn);
388-
kfree(map->active.data.in);
389-
kfree(map->active.ring);
388+
free_pages((unsigned long)map->active.data.in, PVCALLS_RING_ORDER);
389+
free_page((unsigned long)map->active.ring);
390390
return ret;
391391
}
392392

drivers/xen/xlate_mmu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <asm/xen/hypervisor.h>
3737

3838
#include <xen/xen.h>
39+
#include <xen/xen-ops.h>
3940
#include <xen/page.h>
4041
#include <xen/interface/xen.h>
4142
#include <xen/interface/memory.h>

include/xen/balloon.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,3 @@ static inline void xen_balloon_init(void)
4444
{
4545
}
4646
#endif
47-
48-
#ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
49-
struct resource;
50-
void arch_xen_balloon_init(struct resource *hostmem_resource);
51-
#endif

0 commit comments

Comments
 (0)