Skip to content

Commit 2eb959e

Browse files
committed
Merge tag 'for-linus-6.15a-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen fixes from Juergen Gross: - A simple fix adding the module description of the Xenbus frontend module - A fix correcting the xen-acpi-processor Kconfig dependency for PVH Dom0 support - A fix for the Xen balloon driver when running as Xen Dom0 in PVH mode - A fix for PVH Dom0 in order to avoid problems with CPU idle and frequency drivers conflicting with Xen * tag 'for-linus-6.15a-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: x86/xen: disable CPU idle and frequency drivers for PVH dom0 x86/xen: fix balloon target initialization for PVH dom0 xen: Change xen-acpi-processor dom0 dependency xenbus: add module description
2 parents e4742a8 + 64a66e2 commit 2eb959e

File tree

6 files changed

+54
-15
lines changed

6 files changed

+54
-15
lines changed

arch/x86/xen/enlighten.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ EXPORT_SYMBOL(xen_start_flags);
7070
*/
7171
struct shared_info *HYPERVISOR_shared_info = &xen_dummy_shared_info;
7272

73+
/* Number of pages released from the initial allocation. */
74+
unsigned long xen_released_pages;
75+
7376
static __ref void xen_get_vendor(void)
7477
{
7578
init_cpu_devs();
@@ -466,6 +469,13 @@ int __init arch_xen_unpopulated_init(struct resource **res)
466469
xen_free_unpopulated_pages(1, &pg);
467470
}
468471

472+
/*
473+
* Account for the region being in the physmap but unpopulated.
474+
* The value in xen_released_pages is used by the balloon
475+
* driver to know how much of the physmap is unpopulated and
476+
* set an accurate initial memory target.
477+
*/
478+
xen_released_pages += xen_extra_mem[i].n_pfns;
469479
/* Zero so region is not also added to the balloon driver. */
470480
xen_extra_mem[i].n_pfns = 0;
471481
}

arch/x86/xen/enlighten_pvh.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <linux/acpi.h>
3+
#include <linux/cpufreq.h>
4+
#include <linux/cpuidle.h>
35
#include <linux/export.h>
46
#include <linux/mm.h>
57

@@ -123,8 +125,23 @@ static void __init pvh_arch_setup(void)
123125
{
124126
pvh_reserve_extra_memory();
125127

126-
if (xen_initial_domain())
128+
if (xen_initial_domain()) {
127129
xen_add_preferred_consoles();
130+
131+
/*
132+
* Disable usage of CPU idle and frequency drivers: when
133+
* running as hardware domain the exposed native ACPI tables
134+
* causes idle and/or frequency drivers to attach and
135+
* malfunction. It's Xen the entity that controls the idle and
136+
* frequency states.
137+
*
138+
* For unprivileged domains the exposed ACPI tables are
139+
* fabricated and don't contain such data.
140+
*/
141+
disable_cpuidle();
142+
disable_cpufreq();
143+
WARN_ON(xen_set_default_idle());
144+
}
128145
}
129146

130147
void __init xen_pvh_init(struct boot_params *boot_params)

arch/x86/xen/setup.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@
3737

3838
#define GB(x) ((uint64_t)(x) * 1024 * 1024 * 1024)
3939

40-
/* Number of pages released from the initial allocation. */
41-
unsigned long xen_released_pages;
42-
4340
/* Memory map would allow PCI passthrough. */
4441
bool xen_pv_pci_possible;
4542

drivers/xen/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ config XEN_PRIVCMD_EVENTFD
278278

279279
config XEN_ACPI_PROCESSOR
280280
tristate "Xen ACPI processor"
281-
depends on XEN && XEN_PV_DOM0 && X86 && ACPI_PROCESSOR && CPU_FREQ
281+
depends on XEN && XEN_DOM0 && X86 && ACPI_PROCESSOR && CPU_FREQ
282282
default m
283283
help
284284
This ACPI processor uploads Power Management information to the Xen

drivers/xen/balloon.c

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ void xen_free_ballooned_pages(unsigned int nr_pages, struct page **pages)
679679
}
680680
EXPORT_SYMBOL(xen_free_ballooned_pages);
681681

682-
static void __init balloon_add_regions(void)
682+
static int __init balloon_add_regions(void)
683683
{
684684
unsigned long start_pfn, pages;
685685
unsigned long pfn, extra_pfn_end;
@@ -702,26 +702,38 @@ static void __init balloon_add_regions(void)
702702
for (pfn = start_pfn; pfn < extra_pfn_end; pfn++)
703703
balloon_append(pfn_to_page(pfn));
704704

705-
balloon_stats.total_pages += extra_pfn_end - start_pfn;
705+
/*
706+
* Extra regions are accounted for in the physmap, but need
707+
* decreasing from current_pages to balloon down the initial
708+
* allocation, because they are already accounted for in
709+
* total_pages.
710+
*/
711+
if (extra_pfn_end - start_pfn >= balloon_stats.current_pages) {
712+
WARN(1, "Extra pages underflow current target");
713+
return -ERANGE;
714+
}
715+
balloon_stats.current_pages -= extra_pfn_end - start_pfn;
706716
}
717+
718+
return 0;
707719
}
708720

709721
static int __init balloon_init(void)
710722
{
711723
struct task_struct *task;
724+
int rc;
712725

713726
if (!xen_domain())
714727
return -ENODEV;
715728

716729
pr_info("Initialising balloon driver\n");
717730

718-
#ifdef CONFIG_XEN_PV
719-
balloon_stats.current_pages = xen_pv_domain()
720-
? min(xen_start_info->nr_pages - xen_released_pages, max_pfn)
721-
: get_num_physpages();
722-
#else
723-
balloon_stats.current_pages = get_num_physpages();
724-
#endif
731+
if (xen_released_pages >= get_num_physpages()) {
732+
WARN(1, "Released pages underflow current target");
733+
return -ERANGE;
734+
}
735+
736+
balloon_stats.current_pages = get_num_physpages() - xen_released_pages;
725737
balloon_stats.target_pages = balloon_stats.current_pages;
726738
balloon_stats.balloon_low = 0;
727739
balloon_stats.balloon_high = 0;
@@ -738,7 +750,9 @@ static int __init balloon_init(void)
738750
register_sysctl_init("xen/balloon", balloon_table);
739751
#endif
740752

741-
balloon_add_regions();
753+
rc = balloon_add_regions();
754+
if (rc)
755+
return rc;
742756

743757
task = kthread_run(balloon_thread, NULL, "xen-balloon");
744758
if (IS_ERR(task)) {

drivers/xen/xenbus/xenbus_probe_frontend.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,4 +513,5 @@ static int __init boot_wait_for_devices(void)
513513
late_initcall(boot_wait_for_devices);
514514
#endif
515515

516+
MODULE_DESCRIPTION("Xen PV-device frontend support");
516517
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)