Skip to content

Commit 239451e

Browse files
committed
Merge tag 'for-linus-6.3-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen updates from Juergen Gross: - help deprecate the /proc/xen files by making the related information available via sysfs - mark the Xen variants of play_dead "noreturn" - support a shared Xen platform interrupt - several small cleanups and fixes * tag 'for-linus-6.3-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen: sysfs: make kobj_type structure constant x86/Xen: drop leftover VM-assist uses xen: Replace one-element array with flexible-array member xen/grant-dma-iommu: Implement a dummy probe_device() callback xen/pvcalls-back: fix permanently masked event channel xen: Allow platform PCI interrupt to be shared x86/xen/time: prefer tsc as clocksource when it is invariant x86/xen: mark xen_pv_play_dead() as __noreturn x86/xen: don't let xen_pv_play_dead() return drivers/xen/hypervisor: Expose Xen SIF flags to userspace
2 parents b8878e5 + 4ecc96c commit 239451e

File tree

14 files changed

+151
-34
lines changed

14 files changed

+151
-34
lines changed

Documentation/ABI/stable/sysfs-hypervisor-xen

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,16 @@ Contact: [email protected]
120120
Description: If running under Xen:
121121
The Xen version is in the format <major>.<minor><extra>
122122
This is the <minor> part of it.
123+
124+
What: /sys/hypervisor/start_flags/*
125+
Date: March 2023
126+
KernelVersion: 6.3.0
127+
128+
Description: If running under Xen:
129+
All bits in Xen's start-flags are represented as
130+
boolean files, returning '1' if set, '0' otherwise.
131+
This takes the place of the defunct /proc/xen/capabilities,
132+
which would contain "control_d" on dom0, and be empty
133+
otherwise. This flag is now exposed as "initdomain" in
134+
addition to the "privileged" flag; all other possible flags
135+
are accessible as "unknownXX".

arch/x86/xen/setup.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -934,12 +934,8 @@ void xen_enable_syscall(void)
934934

935935
static void __init xen_pvmmu_arch_setup(void)
936936
{
937-
HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
938937
HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
939938

940-
HYPERVISOR_vm_assist(VMASST_CMD_enable,
941-
VMASST_TYPE_pae_extended_cr3);
942-
943939
if (register_callback(CALLBACKTYPE_event,
944940
xen_asm_exc_xen_hypervisor_callback) ||
945941
register_callback(CALLBACKTYPE_failsafe, xen_failsafe_callback))

arch/x86/xen/smp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ void xen_smp_send_reschedule(int cpu);
2121
void xen_smp_send_call_function_ipi(const struct cpumask *mask);
2222
void xen_smp_send_call_function_single_ipi(int cpu);
2323

24+
void __noreturn xen_cpu_bringup_again(unsigned long stack);
25+
2426
struct xen_common_irq {
2527
int irq;
2628
char *name;

arch/x86/xen/smp_pv.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -381,21 +381,12 @@ static void xen_pv_cpu_die(unsigned int cpu)
381381
}
382382
}
383383

384-
static void xen_pv_play_dead(void) /* used only with HOTPLUG_CPU */
384+
static void __noreturn xen_pv_play_dead(void) /* used only with HOTPLUG_CPU */
385385
{
386386
play_dead_common();
387387
HYPERVISOR_vcpu_op(VCPUOP_down, xen_vcpu_nr(smp_processor_id()), NULL);
388-
cpu_bringup();
389-
/*
390-
* commit 4b0c0f294 (tick: Cleanup NOHZ per cpu data on cpu down)
391-
* clears certain data that the cpu_idle loop (which called us
392-
* and that we return from) expects. The only way to get that
393-
* data back is to call:
394-
*/
395-
tick_nohz_idle_enter();
396-
tick_nohz_idle_stop_tick_protected();
397-
398-
cpuhp_online_idle(CPUHP_AP_ONLINE_IDLE);
388+
xen_cpu_bringup_again((unsigned long)task_pt_regs(current));
389+
BUG();
399390
}
400391

401392
#else /* !CONFIG_HOTPLUG_CPU */
@@ -409,7 +400,7 @@ static void xen_pv_cpu_die(unsigned int cpu)
409400
BUG();
410401
}
411402

412-
static void xen_pv_play_dead(void)
403+
static void __noreturn xen_pv_play_dead(void)
413404
{
414405
BUG();
415406
}

arch/x86/xen/time.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,15 +482,51 @@ static void xen_setup_vsyscall_time_info(void)
482482
xen_clocksource.vdso_clock_mode = VDSO_CLOCKMODE_PVCLOCK;
483483
}
484484

485+
/*
486+
* Check if it is possible to safely use the tsc as a clocksource. This is
487+
* only true if the hypervisor notifies the guest that its tsc is invariant,
488+
* the tsc is stable, and the tsc instruction will never be emulated.
489+
*/
490+
static int __init xen_tsc_safe_clocksource(void)
491+
{
492+
u32 eax, ebx, ecx, edx;
493+
494+
if (!(boot_cpu_has(X86_FEATURE_CONSTANT_TSC)))
495+
return 0;
496+
497+
if (!(boot_cpu_has(X86_FEATURE_NONSTOP_TSC)))
498+
return 0;
499+
500+
if (check_tsc_unstable())
501+
return 0;
502+
503+
/* Leaf 4, sub-leaf 0 (0x40000x03) */
504+
cpuid_count(xen_cpuid_base() + 3, 0, &eax, &ebx, &ecx, &edx);
505+
506+
/* tsc_mode = no_emulate (2) */
507+
if (ebx != 2)
508+
return 0;
509+
510+
return 1;
511+
}
512+
485513
static void __init xen_time_init(void)
486514
{
487515
struct pvclock_vcpu_time_info *pvti;
488516
int cpu = smp_processor_id();
489517
struct timespec64 tp;
490518

491-
/* As Dom0 is never moved, no penalty on using TSC there */
519+
/*
520+
* As Dom0 is never moved, no penalty on using TSC there.
521+
*
522+
* If it is possible for the guest to determine that the tsc is a safe
523+
* clocksource, then set xen_clocksource rating below that of the tsc
524+
* so that the system prefers tsc instead.
525+
*/
492526
if (xen_initial_domain())
493527
xen_clocksource.rating = 275;
528+
else if (xen_tsc_safe_clocksource())
529+
xen_clocksource.rating = 299;
494530

495531
clocksource_register_hz(&xen_clocksource, NSEC_PER_SEC);
496532

arch/x86/xen/xen-head.S

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ SYM_CODE_START(asm_cpu_bringup_and_idle)
7676

7777
call cpu_bringup_and_idle
7878
SYM_CODE_END(asm_cpu_bringup_and_idle)
79+
80+
SYM_CODE_START(xen_cpu_bringup_again)
81+
UNWIND_HINT_FUNC
82+
mov %rdi, %rsp
83+
UNWIND_HINT_REGS
84+
call cpu_bringup_and_idle
85+
SYM_CODE_END(xen_cpu_bringup_again)
7986
.popsection
8087
#endif
8188
#endif

drivers/xen/events/events_base.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,9 +1710,10 @@ void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl)
17101710
generic_handle_irq(irq);
17111711
}
17121712

1713-
static void __xen_evtchn_do_upcall(void)
1713+
static int __xen_evtchn_do_upcall(void)
17141714
{
17151715
struct vcpu_info *vcpu_info = __this_cpu_read(xen_vcpu);
1716+
int ret = vcpu_info->evtchn_upcall_pending ? IRQ_HANDLED : IRQ_NONE;
17161717
int cpu = smp_processor_id();
17171718
struct evtchn_loop_ctrl ctrl = { 0 };
17181719

@@ -1737,6 +1738,8 @@ static void __xen_evtchn_do_upcall(void)
17371738
* above.
17381739
*/
17391740
__this_cpu_inc(irq_epoch);
1741+
1742+
return ret;
17401743
}
17411744

17421745
void xen_evtchn_do_upcall(struct pt_regs *regs)
@@ -1751,9 +1754,9 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)
17511754
set_irq_regs(old_regs);
17521755
}
17531756

1754-
void xen_hvm_evtchn_do_upcall(void)
1757+
int xen_hvm_evtchn_do_upcall(void)
17551758
{
1756-
__xen_evtchn_do_upcall();
1759+
return __xen_evtchn_do_upcall();
17571760
}
17581761
EXPORT_SYMBOL_GPL(xen_hvm_evtchn_do_upcall);
17591762

drivers/xen/grant-dma-iommu.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@ struct grant_dma_iommu_device {
1616
struct iommu_device iommu;
1717
};
1818

19-
/* Nothing is really needed here */
20-
static const struct iommu_ops grant_dma_iommu_ops;
19+
static struct iommu_device *grant_dma_iommu_probe_device(struct device *dev)
20+
{
21+
return ERR_PTR(-ENODEV);
22+
}
23+
24+
/* Nothing is really needed here except a dummy probe_device callback */
25+
static const struct iommu_ops grant_dma_iommu_ops = {
26+
.probe_device = grant_dma_iommu_probe_device,
27+
};
2128

2229
static const struct of_device_id grant_dma_iommu_of_match[] = {
2330
{ .compatible = "xen,grant-dma" },

drivers/xen/platform-pci.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,13 @@ static uint64_t get_callback_via(struct pci_dev *pdev)
6464

6565
static irqreturn_t do_hvm_evtchn_intr(int irq, void *dev_id)
6666
{
67-
xen_hvm_evtchn_do_upcall();
68-
return IRQ_HANDLED;
67+
return xen_hvm_evtchn_do_upcall();
6968
}
7069

7170
static int xen_allocate_irq(struct pci_dev *pdev)
7271
{
7372
return request_irq(pdev->irq, do_hvm_evtchn_intr,
74-
IRQF_NOBALANCING | IRQF_TRIGGER_RISING,
73+
IRQF_NOBALANCING | IRQF_SHARED,
7574
"xen-platform-pci", pdev);
7675
}
7776

drivers/xen/pvcalls-back.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ static bool pvcalls_conn_back_write(struct sock_mapping *map)
173173
RING_IDX cons, prod, size, array_size;
174174
int ret;
175175

176+
atomic_set(&map->write, 0);
177+
176178
cons = intf->out_cons;
177179
prod = intf->out_prod;
178180
/* read the indexes before dealing with the data */
@@ -197,7 +199,6 @@ static bool pvcalls_conn_back_write(struct sock_mapping *map)
197199
iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, vec, 2, size);
198200
}
199201

200-
atomic_set(&map->write, 0);
201202
ret = inet_sendmsg(map->sock, &msg, size);
202203
if (ret == -EAGAIN) {
203204
atomic_inc(&map->write);

0 commit comments

Comments
 (0)