Skip to content

Commit 30d4efb

Browse files
committed
Merge tag 'for-linus-6.18-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen updates from Juergen Gross: - fix the migration of a Xen virq to another cpu plus some related cleanup work - clean up Xen-PV mode specific code, resulting in removing some of that code in the resulting binary in case CONFIG_XEN_PV is not set - fixes and cleanup for suspend handling under Xen * tag 'for-linus-6.18-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen: take system_transition_mutex on suspend xen/manage: Fix suspend error path xen/events: Update virq_to_irq on migration xen/events: Return -EEXIST for bound VIRQs xen/events: Cleanup find_virq() return codes x86/xen: select HIBERNATE_CALLBACKS more directly drivers/xen/gntdev: use xen_pv_domain() instead of cached value xen: replace XENFEAT_auto_translated_physmap with xen_pv_domain() xen: rework xen_pv_domain()
2 parents 4175529 + 9d52b0b commit 30d4efb

File tree

20 files changed

+101
-76
lines changed

20 files changed

+101
-76
lines changed

arch/x86/configs/xen.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ CONFIG_CPU_FREQ=y
1212

1313
# x86 xen specific config options
1414
CONFIG_XEN_PVH=y
15-
CONFIG_XEN_SAVE_RESTORE=y
1615
# CONFIG_XEN_DEBUG_FS is not set
1716
CONFIG_XEN_MCE_LOG=y
1817
CONFIG_XEN_ACPI_PROCESSOR=m

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#include <asm/extable.h>
1313
#include <asm/page.h>
1414

15+
#include <xen/xen.h>
1516
#include <xen/interface/xen.h>
1617
#include <xen/interface/grant_table.h>
17-
#include <xen/features.h>
1818

1919
/* Xen machine address */
2020
typedef struct xmaddr {
@@ -162,7 +162,7 @@ static inline unsigned long pfn_to_mfn(unsigned long pfn)
162162
* pfn_to_mfn. This will have to be removed when we figured
163163
* out which call.
164164
*/
165-
if (xen_feature(XENFEAT_auto_translated_physmap))
165+
if (!xen_pv_domain())
166166
return pfn;
167167

168168
mfn = __pfn_to_mfn(pfn);
@@ -175,7 +175,7 @@ static inline unsigned long pfn_to_mfn(unsigned long pfn)
175175

176176
static inline int phys_to_machine_mapping_valid(unsigned long pfn)
177177
{
178-
if (xen_feature(XENFEAT_auto_translated_physmap))
178+
if (!xen_pv_domain())
179179
return 1;
180180

181181
return __pfn_to_mfn(pfn) != INVALID_P2M_ENTRY;
@@ -210,7 +210,7 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
210210
* gfn_to_pfn. This will have to be removed when we figure
211211
* out which call.
212212
*/
213-
if (xen_feature(XENFEAT_auto_translated_physmap))
213+
if (!xen_pv_domain())
214214
return mfn;
215215

216216
pfn = mfn_to_pfn_no_overrides(mfn);
@@ -242,15 +242,15 @@ static inline xpaddr_t machine_to_phys(xmaddr_t machine)
242242
/* Pseudo-physical <-> Guest conversion */
243243
static inline unsigned long pfn_to_gfn(unsigned long pfn)
244244
{
245-
if (xen_feature(XENFEAT_auto_translated_physmap))
245+
if (!xen_pv_domain())
246246
return pfn;
247247
else
248248
return pfn_to_mfn(pfn);
249249
}
250250

251251
static inline unsigned long gfn_to_pfn(unsigned long gfn)
252252
{
253-
if (xen_feature(XENFEAT_auto_translated_physmap))
253+
if (!xen_pv_domain())
254254
return gfn;
255255
else
256256
return mfn_to_pfn(gfn);
@@ -284,7 +284,7 @@ static inline unsigned long bfn_to_local_pfn(unsigned long mfn)
284284
{
285285
unsigned long pfn;
286286

287-
if (xen_feature(XENFEAT_auto_translated_physmap))
287+
if (!xen_pv_domain())
288288
return mfn;
289289

290290
pfn = mfn_to_pfn(mfn);

arch/x86/xen/Kconfig

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ config XEN
88
depends on PARAVIRT
99
select PARAVIRT_CLOCK
1010
select X86_HV_CALLBACK_VECTOR
11+
select HIBERNATE_CALLBACKS
1112
depends on X86_64 || (X86_32 && X86_PAE)
1213
depends on X86_64 || (X86_GENERIC || MPENTIUM4 || MATOM)
1314
depends on X86_LOCAL_APIC && X86_TSC
@@ -64,12 +65,6 @@ config XEN_PVHVM_GUEST
6465
help
6566
Support running as a Xen PVHVM guest.
6667

67-
config XEN_SAVE_RESTORE
68-
bool
69-
depends on XEN
70-
select HIBERNATE_CALLBACKS
71-
default y
72-
7368
config XEN_DEBUG_FS
7469
bool "Enable Xen debug and tuning parameters in debugfs"
7570
depends on XEN && DEBUG_FS

arch/x86/xen/enlighten_pv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ static bool __init xen_check_xsave(void)
382382

383383
static void __init xen_init_capabilities(void)
384384
{
385-
setup_force_cpu_cap(X86_FEATURE_XENPV);
386385
setup_clear_cpu_cap(X86_FEATURE_DCA);
387386
setup_clear_cpu_cap(X86_FEATURE_APERFMPERF);
388387
setup_clear_cpu_cap(X86_FEATURE_MTRR);
@@ -1402,6 +1401,7 @@ asmlinkage __visible void __init xen_start_kernel(struct start_info *si)
14021401
JMP32_INSN_SIZE);
14031402

14041403
xen_domain_type = XEN_PV_DOMAIN;
1404+
setup_force_cpu_cap(X86_FEATURE_XENPV);
14051405
xen_start_flags = xen_start_info->flags;
14061406
/* Interrupts are guaranteed to be off initially. */
14071407
early_boot_irqs_disabled = true;

arch/x86/xen/mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ EXPORT_SYMBOL_GPL(arbitrary_virt_to_machine);
4141
int xen_unmap_domain_gfn_range(struct vm_area_struct *vma,
4242
int nr, struct page **pages)
4343
{
44-
if (xen_feature(XENFEAT_auto_translated_physmap))
44+
if (!xen_pv_domain())
4545
return xen_xlate_unmap_gfn_range(vma, nr, pages);
4646

4747
if (!pages)

arch/x86/xen/p2m.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
686686
int i, ret = 0;
687687
pte_t *pte;
688688

689-
if (xen_feature(XENFEAT_auto_translated_physmap))
689+
if (!xen_pv_domain())
690690
return 0;
691691

692692
if (kmap_ops) {
@@ -769,7 +769,7 @@ int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
769769
{
770770
int i, ret = 0;
771771

772-
if (xen_feature(XENFEAT_auto_translated_physmap))
772+
if (!xen_pv_domain())
773773
return 0;
774774

775775
for (i = 0; i < count; i++) {

drivers/xen/balloon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ static enum bp_state reserve_additional_memory(void)
302302
* are not restored since this region is now known not to
303303
* conflict with any devices.
304304
*/
305-
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
305+
if (xen_pv_domain()) {
306306
unsigned long pfn, i;
307307

308308
pfn = PFN_DOWN(resource->start);
@@ -626,7 +626,7 @@ int xen_alloc_ballooned_pages(unsigned int nr_pages, struct page **pages)
626626
*/
627627
BUILD_BUG_ON(XEN_PAGE_SIZE != PAGE_SIZE);
628628

629-
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
629+
if (xen_pv_domain()) {
630630
ret = xen_alloc_p2m_entry(page_to_pfn(page));
631631
if (ret < 0)
632632
goto out_undo;

drivers/xen/events/events_base.c

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,27 +1314,34 @@ int bind_interdomain_evtchn_to_irq_lateeoi(struct xenbus_device *dev,
13141314
}
13151315
EXPORT_SYMBOL_GPL(bind_interdomain_evtchn_to_irq_lateeoi);
13161316

1317-
static int find_virq(unsigned int virq, unsigned int cpu, evtchn_port_t *evtchn)
1317+
static int find_virq(unsigned int virq, unsigned int cpu, evtchn_port_t *evtchn,
1318+
bool percpu)
13181319
{
13191320
struct evtchn_status status;
13201321
evtchn_port_t port;
1321-
int rc = -ENOENT;
1322+
bool exists = false;
13221323

13231324
memset(&status, 0, sizeof(status));
13241325
for (port = 0; port < xen_evtchn_max_channels(); port++) {
1326+
int rc;
1327+
13251328
status.dom = DOMID_SELF;
13261329
status.port = port;
13271330
rc = HYPERVISOR_event_channel_op(EVTCHNOP_status, &status);
13281331
if (rc < 0)
13291332
continue;
13301333
if (status.status != EVTCHNSTAT_virq)
13311334
continue;
1332-
if (status.u.virq == virq && status.vcpu == xen_vcpu_nr(cpu)) {
1335+
if (status.u.virq != virq)
1336+
continue;
1337+
if (status.vcpu == xen_vcpu_nr(cpu)) {
13331338
*evtchn = port;
1334-
break;
1339+
return 0;
1340+
} else if (!percpu) {
1341+
exists = true;
13351342
}
13361343
}
1337-
return rc;
1344+
return exists ? -EEXIST : -ENOENT;
13381345
}
13391346

13401347
/**
@@ -1381,8 +1388,11 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu, bool percpu)
13811388
evtchn = bind_virq.port;
13821389
else {
13831390
if (ret == -EEXIST)
1384-
ret = find_virq(virq, cpu, &evtchn);
1385-
BUG_ON(ret < 0);
1391+
ret = find_virq(virq, cpu, &evtchn, percpu);
1392+
if (ret) {
1393+
__unbind_from_irq(info, info->irq);
1394+
goto out;
1395+
}
13861396
}
13871397

13881398
ret = xen_irq_info_virq_setup(info, cpu, evtchn, virq);
@@ -1787,9 +1797,20 @@ static int xen_rebind_evtchn_to_cpu(struct irq_info *info, unsigned int tcpu)
17871797
* virq or IPI channel, which don't actually need to be rebound. Ignore
17881798
* it, but don't do the xenlinux-level rebind in that case.
17891799
*/
1790-
if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0)
1800+
if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0) {
1801+
int old_cpu = info->cpu;
1802+
17911803
bind_evtchn_to_cpu(info, tcpu, false);
17921804

1805+
if (info->type == IRQT_VIRQ) {
1806+
int virq = info->u.virq;
1807+
int irq = per_cpu(virq_to_irq, old_cpu)[virq];
1808+
1809+
per_cpu(virq_to_irq, old_cpu)[virq] = -1;
1810+
per_cpu(virq_to_irq, tcpu)[virq] = irq;
1811+
}
1812+
}
1813+
17931814
do_unmask(info, EVT_MASK_REASON_TEMPORARY);
17941815

17951816
return 0;

drivers/xen/gntdev-dmabuf.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -720,16 +720,15 @@ static void dmabuf_imp_release_all(struct gntdev_dmabuf_priv *priv)
720720

721721
/* DMA buffer IOCTL support. */
722722

723-
long gntdev_ioctl_dmabuf_exp_from_refs(struct gntdev_priv *priv, int use_ptemod,
723+
long gntdev_ioctl_dmabuf_exp_from_refs(struct gntdev_priv *priv,
724724
struct ioctl_gntdev_dmabuf_exp_from_refs __user *u)
725725
{
726726
struct ioctl_gntdev_dmabuf_exp_from_refs op;
727727
u32 *refs;
728728
long ret;
729729

730-
if (use_ptemod) {
731-
pr_debug("Cannot provide dma-buf: use_ptemode %d\n",
732-
use_ptemod);
730+
if (xen_pv_domain()) {
731+
pr_debug("Cannot provide dma-buf in a PV domain\n");
733732
return -EINVAL;
734733
}
735734

drivers/xen/gntdev-dmabuf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct gntdev_dmabuf_priv *gntdev_dmabuf_init(struct file *filp);
1818

1919
void gntdev_dmabuf_fini(struct gntdev_dmabuf_priv *priv);
2020

21-
long gntdev_ioctl_dmabuf_exp_from_refs(struct gntdev_priv *priv, int use_ptemod,
21+
long gntdev_ioctl_dmabuf_exp_from_refs(struct gntdev_priv *priv,
2222
struct ioctl_gntdev_dmabuf_exp_from_refs __user *u);
2323

2424
long gntdev_ioctl_dmabuf_exp_wait_released(struct gntdev_priv *priv,

0 commit comments

Comments
 (0)