Skip to content

Commit 3946b46

Browse files
committed
Merge tag 'for-linus-5.15b-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen fixes from Juergen Gross: - fix two minor issues in the Xen privcmd driver plus a cleanup patch for that driver - fix multiple issues related to running as PVH guest and some related earlyprintk fixes for other Xen guest types - fix an issue introduced in 5.15 the Xen balloon driver * tag 'for-linus-5.15b-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen/balloon: fix cancelled balloon action xen/x86: adjust data placement x86/PVH: adjust function/data placement xen/x86: hook up xen_banner() also for PVH xen/x86: generalize preferred console model from PV to PVH Dom0 xen/x86: make "earlyprintk=xen" work for HVM/PVH DomU xen/x86: allow "earlyprintk=xen" to work for PV Dom0 xen/x86: make "earlyprintk=xen" work better for PVH Dom0 xen/x86: allow PVH Dom0 without XEN_PV=y xen/x86: prevent PVH type from getting clobbered xen/privcmd: drop "pages" parameter from xen_remap_pfn() xen/privcmd: fix error handling in mmap-resource processing xen/privcmd: replace kcalloc() by kvcalloc() when allocating empty pages
2 parents 0dcf60d + 319933a commit 3946b46

File tree

16 files changed

+135
-103
lines changed

16 files changed

+135
-103
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@
12661266
The VGA and EFI output is eventually overwritten by
12671267
the real console.
12681268

1269-
The xen output can only be used by Xen PV guests.
1269+
The xen option can only be used in Xen domains.
12701270

12711271
The sclp output can only be used on s390.
12721272

arch/x86/include/asm/xen/pci.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ static inline int pci_xen_hvm_init(void)
1414
return -1;
1515
}
1616
#endif
17-
#if defined(CONFIG_XEN_DOM0)
17+
#ifdef CONFIG_XEN_PV_DOM0
1818
int __init pci_xen_initial_domain(void);
19-
int xen_find_device_domain_owner(struct pci_dev *dev);
20-
int xen_register_device_domain_owner(struct pci_dev *dev, uint16_t domain);
21-
int xen_unregister_device_domain_owner(struct pci_dev *dev);
2219
#else
2320
static inline int __init pci_xen_initial_domain(void)
2421
{
2522
return -1;
2623
}
24+
#endif
25+
#ifdef CONFIG_XEN_DOM0
26+
int xen_find_device_domain_owner(struct pci_dev *dev);
27+
int xen_register_device_domain_owner(struct pci_dev *dev, uint16_t domain);
28+
int xen_unregister_device_domain_owner(struct pci_dev *dev);
29+
#else
2730
static inline int xen_find_device_domain_owner(struct pci_dev *dev)
2831
{
2932
return -1;

arch/x86/pci/xen.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi,
113113
false /* no mapping of GSI to PIRQ */);
114114
}
115115

116-
#ifdef CONFIG_XEN_DOM0
116+
#ifdef CONFIG_XEN_PV_DOM0
117117
static int xen_register_gsi(u32 gsi, int triggering, int polarity)
118118
{
119119
int rc, irq;
@@ -261,7 +261,7 @@ static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
261261
return irq;
262262
}
263263

264-
#ifdef CONFIG_XEN_DOM0
264+
#ifdef CONFIG_XEN_PV_DOM0
265265
static bool __read_mostly pci_seg_supported = true;
266266

267267
static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
@@ -375,10 +375,10 @@ static void xen_initdom_restore_msi_irqs(struct pci_dev *dev)
375375
WARN(ret && ret != -ENOSYS, "restore_msi -> %d\n", ret);
376376
}
377377
}
378-
#else /* CONFIG_XEN_DOM0 */
378+
#else /* CONFIG_XEN_PV_DOM0 */
379379
#define xen_initdom_setup_msi_irqs NULL
380380
#define xen_initdom_restore_msi_irqs NULL
381-
#endif /* !CONFIG_XEN_DOM0 */
381+
#endif /* !CONFIG_XEN_PV_DOM0 */
382382

383383
static void xen_teardown_msi_irqs(struct pci_dev *dev)
384384
{
@@ -555,7 +555,7 @@ int __init pci_xen_hvm_init(void)
555555
return 0;
556556
}
557557

558-
#ifdef CONFIG_XEN_DOM0
558+
#ifdef CONFIG_XEN_PV_DOM0
559559
int __init pci_xen_initial_domain(void)
560560
{
561561
int irq;
@@ -583,6 +583,9 @@ int __init pci_xen_initial_domain(void)
583583
}
584584
return 0;
585585
}
586+
#endif
587+
588+
#ifdef CONFIG_XEN_DOM0
586589

587590
struct xen_device_domain_owner {
588591
domid_t domain;
@@ -656,4 +659,4 @@ int xen_unregister_device_domain_owner(struct pci_dev *dev)
656659
return 0;
657660
}
658661
EXPORT_SYMBOL_GPL(xen_unregister_device_domain_owner);
659-
#endif
662+
#endif /* CONFIG_XEN_DOM0 */

arch/x86/platform/pvh/enlighten.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
/*
1717
* PVH variables.
1818
*
19-
* pvh_bootparams and pvh_start_info need to live in the data segment since
19+
* pvh_bootparams and pvh_start_info need to live in a data segment since
2020
* they are used after startup_{32|64}, which clear .bss, are invoked.
2121
*/
22-
struct boot_params pvh_bootparams __section(".data");
23-
struct hvm_start_info pvh_start_info __section(".data");
22+
struct boot_params __initdata pvh_bootparams;
23+
struct hvm_start_info __initdata pvh_start_info;
2424

25-
unsigned int pvh_start_info_sz = sizeof(pvh_start_info);
25+
const unsigned int __initconst pvh_start_info_sz = sizeof(pvh_start_info);
2626

27-
static u64 pvh_get_root_pointer(void)
27+
static u64 __init pvh_get_root_pointer(void)
2828
{
2929
return pvh_start_info.rsdp_paddr;
3030
}
@@ -107,7 +107,7 @@ void __init __weak xen_pvh_init(struct boot_params *boot_params)
107107
BUG();
108108
}
109109

110-
static void hypervisor_specific_init(bool xen_guest)
110+
static void __init hypervisor_specific_init(bool xen_guest)
111111
{
112112
if (xen_guest)
113113
xen_pvh_init(&pvh_bootparams);

arch/x86/xen/Kconfig

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,9 @@ config XEN_PV_SMP
4343
def_bool y
4444
depends on XEN_PV && SMP
4545

46-
config XEN_DOM0
47-
bool "Xen PV Dom0 support"
48-
default y
49-
depends on XEN_PV && PCI_XEN && SWIOTLB_XEN
50-
depends on X86_IO_APIC && ACPI && PCI
51-
help
52-
Support running as a Xen PV Dom0 guest.
46+
config XEN_PV_DOM0
47+
def_bool y
48+
depends on XEN_PV && XEN_DOM0
5349

5450
config XEN_PVHVM
5551
def_bool y
@@ -86,3 +82,12 @@ config XEN_PVH
8682
def_bool n
8783
help
8884
Support for running as a Xen PVH guest.
85+
86+
config XEN_DOM0
87+
bool "Xen Dom0 support"
88+
default XEN_PV
89+
depends on (XEN_PV && SWIOTLB_XEN) || (XEN_PVH && X86_64)
90+
depends on X86_IO_APIC && ACPI && PCI
91+
select X86_X2APIC if XEN_PVH && X86_64
92+
help
93+
Support running as a Xen Dom0 guest.

arch/x86/xen/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= spinlock.o
4545

4646
obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o
4747

48-
obj-$(CONFIG_XEN_DOM0) += vga.o
48+
obj-$(CONFIG_XEN_PV_DOM0) += vga.o
4949

5050
obj-$(CONFIG_SWIOTLB_XEN) += pci-swiotlb-xen.o
5151

arch/x86/xen/enlighten.c

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@
33
#ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
44
#include <linux/memblock.h>
55
#endif
6+
#include <linux/console.h>
67
#include <linux/cpu.h>
78
#include <linux/kexec.h>
89
#include <linux/slab.h>
910
#include <linux/panic_notifier.h>
1011

1112
#include <xen/xen.h>
1213
#include <xen/features.h>
14+
#include <xen/interface/sched.h>
15+
#include <xen/interface/version.h>
1316
#include <xen/page.h>
1417

1518
#include <asm/xen/hypercall.h>
1619
#include <asm/xen/hypervisor.h>
1720
#include <asm/cpu.h>
1821
#include <asm/e820/api.h>
22+
#include <asm/setup.h>
1923

2024
#include "xen-ops.h"
2125
#include "smp.h"
@@ -52,9 +56,6 @@ DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info);
5256
DEFINE_PER_CPU(uint32_t, xen_vcpu_id);
5357
EXPORT_PER_CPU_SYMBOL(xen_vcpu_id);
5458

55-
enum xen_domain_type xen_domain_type = XEN_NATIVE;
56-
EXPORT_SYMBOL_GPL(xen_domain_type);
57-
5859
unsigned long *machine_to_phys_mapping = (void *)MACH2PHYS_VIRT_START;
5960
EXPORT_SYMBOL(machine_to_phys_mapping);
6061
unsigned long machine_to_phys_nr;
@@ -69,10 +70,12 @@ __read_mostly int xen_have_vector_callback;
6970
EXPORT_SYMBOL_GPL(xen_have_vector_callback);
7071

7172
/*
72-
* NB: needs to live in .data because it's used by xen_prepare_pvh which runs
73-
* before clearing the bss.
73+
* NB: These need to live in .data or alike because they're used by
74+
* xen_prepare_pvh() which runs before clearing the bss.
7475
*/
75-
uint32_t xen_start_flags __section(".data") = 0;
76+
enum xen_domain_type __ro_after_init xen_domain_type = XEN_NATIVE;
77+
EXPORT_SYMBOL_GPL(xen_domain_type);
78+
uint32_t __ro_after_init xen_start_flags;
7679
EXPORT_SYMBOL(xen_start_flags);
7780

7881
/*
@@ -258,6 +261,45 @@ int xen_vcpu_setup(int cpu)
258261
return ((per_cpu(xen_vcpu, cpu) == NULL) ? -ENODEV : 0);
259262
}
260263

264+
void __init xen_banner(void)
265+
{
266+
unsigned version = HYPERVISOR_xen_version(XENVER_version, NULL);
267+
struct xen_extraversion extra;
268+
269+
HYPERVISOR_xen_version(XENVER_extraversion, &extra);
270+
271+
pr_info("Booting kernel on %s\n", pv_info.name);
272+
pr_info("Xen version: %u.%u%s%s\n",
273+
version >> 16, version & 0xffff, extra.extraversion,
274+
xen_feature(XENFEAT_mmu_pt_update_preserve_ad)
275+
? " (preserve-AD)" : "");
276+
}
277+
278+
/* Check if running on Xen version (major, minor) or later */
279+
bool xen_running_on_version_or_later(unsigned int major, unsigned int minor)
280+
{
281+
unsigned int version;
282+
283+
if (!xen_domain())
284+
return false;
285+
286+
version = HYPERVISOR_xen_version(XENVER_version, NULL);
287+
if ((((version >> 16) == major) && ((version & 0xffff) >= minor)) ||
288+
((version >> 16) > major))
289+
return true;
290+
return false;
291+
}
292+
293+
void __init xen_add_preferred_consoles(void)
294+
{
295+
add_preferred_console("xenboot", 0, NULL);
296+
if (!boot_params.screen_info.orig_video_isVGA)
297+
add_preferred_console("tty", 0, NULL);
298+
add_preferred_console("hvc", 0, NULL);
299+
if (boot_params.screen_info.orig_video_isVGA)
300+
add_preferred_console("tty", 0, NULL);
301+
}
302+
261303
void xen_reboot(int reason)
262304
{
263305
struct sched_shutdown r = { .reason = reason };

arch/x86/xen/enlighten_pv.c

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <linux/mm.h>
2929
#include <linux/page-flags.h>
3030
#include <linux/highmem.h>
31-
#include <linux/console.h>
3231
#include <linux/pci.h>
3332
#include <linux/gfp.h>
3433
#include <linux/edd.h>
@@ -109,17 +108,6 @@ struct tls_descs {
109108
*/
110109
static DEFINE_PER_CPU(struct tls_descs, shadow_tls_desc);
111110

112-
static void __init xen_banner(void)
113-
{
114-
unsigned version = HYPERVISOR_xen_version(XENVER_version, NULL);
115-
struct xen_extraversion extra;
116-
HYPERVISOR_xen_version(XENVER_extraversion, &extra);
117-
118-
pr_info("Booting paravirtualized kernel on %s\n", pv_info.name);
119-
pr_info("Xen version: %d.%d%s (preserve-AD)\n",
120-
version >> 16, version & 0xffff, extra.extraversion);
121-
}
122-
123111
static void __init xen_pv_init_platform(void)
124112
{
125113
populate_extra_pte(fix_to_virt(FIX_PARAVIRT_BOOTMAP));
@@ -142,22 +130,6 @@ static void __init xen_pv_guest_late_init(void)
142130
#endif
143131
}
144132

145-
/* Check if running on Xen version (major, minor) or later */
146-
bool
147-
xen_running_on_version_or_later(unsigned int major, unsigned int minor)
148-
{
149-
unsigned int version;
150-
151-
if (!xen_domain())
152-
return false;
153-
154-
version = HYPERVISOR_xen_version(XENVER_version, NULL);
155-
if ((((version >> 16) == major) && ((version & 0xffff) >= minor)) ||
156-
((version >> 16) > major))
157-
return true;
158-
return false;
159-
}
160-
161133
static __read_mostly unsigned int cpuid_leaf5_ecx_val;
162134
static __read_mostly unsigned int cpuid_leaf5_edx_val;
163135

@@ -1364,7 +1336,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
13641336
boot_params.hdr.hardware_subarch = X86_SUBARCH_XEN;
13651337

13661338
if (!xen_initial_domain()) {
1367-
add_preferred_console("xenboot", 0, NULL);
13681339
if (pci_xen)
13691340
x86_init.pci.arch_init = pci_xen_init;
13701341
x86_platform.set_legacy_features =
@@ -1409,11 +1380,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
14091380
#endif
14101381
}
14111382

1412-
if (!boot_params.screen_info.orig_video_isVGA)
1413-
add_preferred_console("tty", 0, NULL);
1414-
add_preferred_console("hvc", 0, NULL);
1415-
if (boot_params.screen_info.orig_video_isVGA)
1416-
add_preferred_console("tty", 0, NULL);
1383+
xen_add_preferred_consoles();
14171384

14181385
#ifdef CONFIG_PCI
14191386
/* PCI BIOS service won't work from a PV guest. */

arch/x86/xen/enlighten_pvh.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <linux/acpi.h>
3+
#include <linux/export.h>
34

45
#include <xen/hvc-console.h>
56

@@ -18,10 +19,11 @@
1819
/*
1920
* PVH variables.
2021
*
21-
* The variable xen_pvh needs to live in the data segment since it is used
22+
* The variable xen_pvh needs to live in a data segment since it is used
2223
* after startup_{32|64} is invoked, which will clear the .bss segment.
2324
*/
24-
bool xen_pvh __section(".data") = 0;
25+
bool __ro_after_init xen_pvh;
26+
EXPORT_SYMBOL_GPL(xen_pvh);
2527

2628
void __init xen_pvh_init(struct boot_params *boot_params)
2729
{
@@ -36,6 +38,10 @@ void __init xen_pvh_init(struct boot_params *boot_params)
3638
pfn = __pa(hypercall_page);
3739
wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32));
3840

41+
if (xen_initial_domain())
42+
x86_init.oem.arch_setup = xen_add_preferred_consoles;
43+
x86_init.oem.banner = xen_banner;
44+
3945
xen_efi_init(boot_params);
4046
}
4147

arch/x86/xen/mmu_pv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2398,7 +2398,7 @@ static int remap_area_pfn_pte_fn(pte_t *ptep, unsigned long addr, void *data)
23982398

23992399
int xen_remap_pfn(struct vm_area_struct *vma, unsigned long addr,
24002400
xen_pfn_t *pfn, int nr, int *err_ptr, pgprot_t prot,
2401-
unsigned int domid, bool no_translate, struct page **pages)
2401+
unsigned int domid, bool no_translate)
24022402
{
24032403
int err = 0;
24042404
struct remap_data rmd;

0 commit comments

Comments
 (0)