Skip to content

Commit

Permalink
Merge tag 'for-linus-6.15a-rc2-tag' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/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
  • Loading branch information
Linus Torvalds committed Apr 10, 2025
2 parents e4742a8 + 64a66e2 commit 2eb959e
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 15 deletions.
10 changes: 10 additions & 0 deletions arch/x86/xen/enlighten.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ EXPORT_SYMBOL(xen_start_flags);
*/
struct shared_info *HYPERVISOR_shared_info = &xen_dummy_shared_info;

/* Number of pages released from the initial allocation. */
unsigned long xen_released_pages;

static __ref void xen_get_vendor(void)
{
init_cpu_devs();
Expand Down Expand Up @@ -466,6 +469,13 @@ int __init arch_xen_unpopulated_init(struct resource **res)
xen_free_unpopulated_pages(1, &pg);
}

/*
* Account for the region being in the physmap but unpopulated.
* The value in xen_released_pages is used by the balloon
* driver to know how much of the physmap is unpopulated and
* set an accurate initial memory target.
*/
xen_released_pages += xen_extra_mem[i].n_pfns;
/* Zero so region is not also added to the balloon driver. */
xen_extra_mem[i].n_pfns = 0;
}
Expand Down
19 changes: 18 additions & 1 deletion arch/x86/xen/enlighten_pvh.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/acpi.h>
#include <linux/cpufreq.h>
#include <linux/cpuidle.h>
#include <linux/export.h>
#include <linux/mm.h>

Expand Down Expand Up @@ -123,8 +125,23 @@ static void __init pvh_arch_setup(void)
{
pvh_reserve_extra_memory();

if (xen_initial_domain())
if (xen_initial_domain()) {
xen_add_preferred_consoles();

/*
* Disable usage of CPU idle and frequency drivers: when
* running as hardware domain the exposed native ACPI tables
* causes idle and/or frequency drivers to attach and
* malfunction. It's Xen the entity that controls the idle and
* frequency states.
*
* For unprivileged domains the exposed ACPI tables are
* fabricated and don't contain such data.
*/
disable_cpuidle();
disable_cpufreq();
WARN_ON(xen_set_default_idle());
}
}

void __init xen_pvh_init(struct boot_params *boot_params)
Expand Down
3 changes: 0 additions & 3 deletions arch/x86/xen/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@

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

/* Number of pages released from the initial allocation. */
unsigned long xen_released_pages;

/* Memory map would allow PCI passthrough. */
bool xen_pv_pci_possible;

Expand Down
2 changes: 1 addition & 1 deletion drivers/xen/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ config XEN_PRIVCMD_EVENTFD

config XEN_ACPI_PROCESSOR
tristate "Xen ACPI processor"
depends on XEN && XEN_PV_DOM0 && X86 && ACPI_PROCESSOR && CPU_FREQ
depends on XEN && XEN_DOM0 && X86 && ACPI_PROCESSOR && CPU_FREQ
default m
help
This ACPI processor uploads Power Management information to the Xen
Expand Down
34 changes: 24 additions & 10 deletions drivers/xen/balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ void xen_free_ballooned_pages(unsigned int nr_pages, struct page **pages)
}
EXPORT_SYMBOL(xen_free_ballooned_pages);

static void __init balloon_add_regions(void)
static int __init balloon_add_regions(void)
{
unsigned long start_pfn, pages;
unsigned long pfn, extra_pfn_end;
Expand All @@ -702,26 +702,38 @@ static void __init balloon_add_regions(void)
for (pfn = start_pfn; pfn < extra_pfn_end; pfn++)
balloon_append(pfn_to_page(pfn));

balloon_stats.total_pages += extra_pfn_end - start_pfn;
/*
* Extra regions are accounted for in the physmap, but need
* decreasing from current_pages to balloon down the initial
* allocation, because they are already accounted for in
* total_pages.
*/
if (extra_pfn_end - start_pfn >= balloon_stats.current_pages) {
WARN(1, "Extra pages underflow current target");
return -ERANGE;
}
balloon_stats.current_pages -= extra_pfn_end - start_pfn;
}

return 0;
}

static int __init balloon_init(void)
{
struct task_struct *task;
int rc;

if (!xen_domain())
return -ENODEV;

pr_info("Initialising balloon driver\n");

#ifdef CONFIG_XEN_PV
balloon_stats.current_pages = xen_pv_domain()
? min(xen_start_info->nr_pages - xen_released_pages, max_pfn)
: get_num_physpages();
#else
balloon_stats.current_pages = get_num_physpages();
#endif
if (xen_released_pages >= get_num_physpages()) {
WARN(1, "Released pages underflow current target");
return -ERANGE;
}

balloon_stats.current_pages = get_num_physpages() - xen_released_pages;
balloon_stats.target_pages = balloon_stats.current_pages;
balloon_stats.balloon_low = 0;
balloon_stats.balloon_high = 0;
Expand All @@ -738,7 +750,9 @@ static int __init balloon_init(void)
register_sysctl_init("xen/balloon", balloon_table);
#endif

balloon_add_regions();
rc = balloon_add_regions();
if (rc)
return rc;

task = kthread_run(balloon_thread, NULL, "xen-balloon");
if (IS_ERR(task)) {
Expand Down
1 change: 1 addition & 0 deletions drivers/xen/xenbus/xenbus_probe_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,4 +513,5 @@ static int __init boot_wait_for_devices(void)
late_initcall(boot_wait_for_devices);
#endif

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

0 comments on commit 2eb959e

Please sign in to comment.