All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/xen: disable nosmt in Xen guests
@ 2019-06-12 10:12 ` Juergen Gross
  0 siblings, 0 replies; 10+ messages in thread
From: Juergen Gross @ 2019-06-12 10:12 UTC (permalink / raw)
  To: xen-devel, x86, linux-kernel
  Cc: Juergen Gross, Boris Ostrovsky, Stefano Stabellini,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin

When running as a Xen guest selecting "nosmt" either via command line
or implicitly via default settings makes no sense, as the guest has no
clue about the real system topology it is running on. With Xen it is
the hypervisor's job to ensure the proper bug mitigations are active
regarding smt settings.

So when running as a Xen guest set cpu_smt_control to "not supported"
in order to avoid disabling random vcpus.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/xen/enlighten.c     | 8 ++++++++
 arch/x86/xen/enlighten_hvm.c | 2 ++
 arch/x86/xen/enlighten_pv.c  | 2 ++
 arch/x86/xen/xen-ops.h       | 2 ++
 4 files changed, 14 insertions(+)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 750f46ad018a..312b73698d0c 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -345,3 +345,11 @@ void xen_arch_unregister_cpu(int num)
 }
 EXPORT_SYMBOL(xen_arch_unregister_cpu);
 #endif
+
+void __init xen_disable_nosmt(void)
+{
+#ifdef CONFIG_HOTPLUG_SMT
+	/* Don't allow SMT disabling in Xen guests. */
+	cpu_smt_control = CPU_SMT_NOT_SUPPORTED;
+#endif
+}
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
index 0e75642d42a3..7c62662cd2ca 100644
--- a/arch/x86/xen/enlighten_hvm.c
+++ b/arch/x86/xen/enlighten_hvm.c
@@ -116,6 +116,8 @@ static void __init init_hvm_pv_info(void)
 		this_cpu_write(xen_vcpu_id, ebx);
 	else
 		this_cpu_write(xen_vcpu_id, smp_processor_id());
+
+	xen_disable_nosmt();
 }
 
 #ifdef CONFIG_KEXEC_CORE
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 4722ba2966ac..dcfec65bca60 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -131,6 +131,8 @@ static void __init xen_pv_init_platform(void)
 
 	/* pvclock is in shared info area */
 	xen_init_time_ops();
+
+	xen_disable_nosmt();
 }
 
 static void __init xen_pv_guest_late_init(void)
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 2f111f47ba98..63a31b9d7217 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -161,4 +161,6 @@ void xen_hvm_post_suspend(int suspend_cancelled);
 static inline void xen_hvm_post_suspend(int suspend_cancelled) {}
 #endif
 
+void __init xen_disable_nosmt(void);
+
 #endif /* XEN_OPS_H */
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Xen-devel] [PATCH] x86/xen: disable nosmt in Xen guests
@ 2019-06-12 10:12 ` Juergen Gross
  0 siblings, 0 replies; 10+ messages in thread
From: Juergen Gross @ 2019-06-12 10:12 UTC (permalink / raw)
  To: xen-devel, x86, linux-kernel
  Cc: Juergen Gross, Stefano Stabellini, Ingo Molnar, Borislav Petkov,
	H. Peter Anvin, Boris Ostrovsky, Thomas Gleixner

When running as a Xen guest selecting "nosmt" either via command line
or implicitly via default settings makes no sense, as the guest has no
clue about the real system topology it is running on. With Xen it is
the hypervisor's job to ensure the proper bug mitigations are active
regarding smt settings.

So when running as a Xen guest set cpu_smt_control to "not supported"
in order to avoid disabling random vcpus.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/xen/enlighten.c     | 8 ++++++++
 arch/x86/xen/enlighten_hvm.c | 2 ++
 arch/x86/xen/enlighten_pv.c  | 2 ++
 arch/x86/xen/xen-ops.h       | 2 ++
 4 files changed, 14 insertions(+)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 750f46ad018a..312b73698d0c 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -345,3 +345,11 @@ void xen_arch_unregister_cpu(int num)
 }
 EXPORT_SYMBOL(xen_arch_unregister_cpu);
 #endif
+
+void __init xen_disable_nosmt(void)
+{
+#ifdef CONFIG_HOTPLUG_SMT
+	/* Don't allow SMT disabling in Xen guests. */
+	cpu_smt_control = CPU_SMT_NOT_SUPPORTED;
+#endif
+}
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
index 0e75642d42a3..7c62662cd2ca 100644
--- a/arch/x86/xen/enlighten_hvm.c
+++ b/arch/x86/xen/enlighten_hvm.c
@@ -116,6 +116,8 @@ static void __init init_hvm_pv_info(void)
 		this_cpu_write(xen_vcpu_id, ebx);
 	else
 		this_cpu_write(xen_vcpu_id, smp_processor_id());
+
+	xen_disable_nosmt();
 }
 
 #ifdef CONFIG_KEXEC_CORE
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 4722ba2966ac..dcfec65bca60 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -131,6 +131,8 @@ static void __init xen_pv_init_platform(void)
 
 	/* pvclock is in shared info area */
 	xen_init_time_ops();
+
+	xen_disable_nosmt();
 }
 
 static void __init xen_pv_guest_late_init(void)
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 2f111f47ba98..63a31b9d7217 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -161,4 +161,6 @@ void xen_hvm_post_suspend(int suspend_cancelled);
 static inline void xen_hvm_post_suspend(int suspend_cancelled) {}
 #endif
 
+void __init xen_disable_nosmt(void);
+
 #endif /* XEN_OPS_H */
-- 
2.16.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Xen-devel] [PATCH] x86/xen: disable nosmt in Xen guests
  2019-06-12 10:12 ` [Xen-devel] " Juergen Gross
@ 2019-06-12 10:19   ` Jan Beulich
  -1 siblings, 0 replies; 10+ messages in thread
From: Jan Beulich @ 2019-06-12 10:19 UTC (permalink / raw)
  To: Juergen Gross
  Cc: Borislav Petkov, Stefano Stabellini, the arch/x86 maintainers,
	tglx, xen-devel, Boris Ostrovsky, mingo, linux-kernel, hpa

>>> On 12.06.19 at 12:12, <jgross@suse.com> wrote:
> When running as a Xen guest selecting "nosmt" either via command line
> or implicitly via default settings makes no sense, as the guest has no
> clue about the real system topology it is running on. With Xen it is
> the hypervisor's job to ensure the proper bug mitigations are active
> regarding smt settings.

I don't agree with the second sentence: It is in principle fine for the
hypervisor to expose HT (i.e. not disable it as bug mitigation), and
leave it to the guest kernels to protect themselves. We're just not
at the point yet where Xen offers sufficient / reliable data to guest
kernels to do so, so _for the time being_ what you say is correct.

Jan



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Xen-devel] [PATCH] x86/xen: disable nosmt in Xen guests
@ 2019-06-12 10:19   ` Jan Beulich
  0 siblings, 0 replies; 10+ messages in thread
From: Jan Beulich @ 2019-06-12 10:19 UTC (permalink / raw)
  To: Juergen Gross
  Cc: Stefano Stabellini, the arch/x86 maintainers, linux-kernel,
	mingo, Borislav Petkov, hpa, xen-devel, Boris Ostrovsky, tglx

>>> On 12.06.19 at 12:12, <jgross@suse.com> wrote:
> When running as a Xen guest selecting "nosmt" either via command line
> or implicitly via default settings makes no sense, as the guest has no
> clue about the real system topology it is running on. With Xen it is
> the hypervisor's job to ensure the proper bug mitigations are active
> regarding smt settings.

I don't agree with the second sentence: It is in principle fine for the
hypervisor to expose HT (i.e. not disable it as bug mitigation), and
leave it to the guest kernels to protect themselves. We're just not
at the point yet where Xen offers sufficient / reliable data to guest
kernels to do so, so _for the time being_ what you say is correct.

Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Xen-devel] [PATCH] x86/xen: disable nosmt in Xen guests
  2019-06-12 10:19   ` Jan Beulich
@ 2019-06-12 10:36     ` Juergen Gross
  -1 siblings, 0 replies; 10+ messages in thread
From: Juergen Gross @ 2019-06-12 10:36 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Borislav Petkov, Stefano Stabellini, the arch/x86 maintainers,
	tglx, xen-devel, Boris Ostrovsky, mingo, linux-kernel, hpa

On 12.06.19 12:19, Jan Beulich wrote:
>>>> On 12.06.19 at 12:12, <jgross@suse.com> wrote:
>> When running as a Xen guest selecting "nosmt" either via command line
>> or implicitly via default settings makes no sense, as the guest has no
>> clue about the real system topology it is running on. With Xen it is
>> the hypervisor's job to ensure the proper bug mitigations are active
>> regarding smt settings.
> 
> I don't agree with the second sentence: It is in principle fine for the
> hypervisor to expose HT (i.e. not disable it as bug mitigation), and
> leave it to the guest kernels to protect themselves. We're just not
> at the point yet where Xen offers sufficient / reliable data to guest
> kernels to do so, so _for the time being_ what you say is correct.

Okay, I'll add something like:

This is true as long Xen doesn't support core scheduling together with
exposing the (then) correct sibling information to the guest and
indicating that case via a sutable interface.


Juergen


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Xen-devel] [PATCH] x86/xen: disable nosmt in Xen guests
@ 2019-06-12 10:36     ` Juergen Gross
  0 siblings, 0 replies; 10+ messages in thread
From: Juergen Gross @ 2019-06-12 10:36 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Stefano Stabellini, the arch/x86 maintainers, linux-kernel,
	mingo, Borislav Petkov, hpa, xen-devel, Boris Ostrovsky, tglx

On 12.06.19 12:19, Jan Beulich wrote:
>>>> On 12.06.19 at 12:12, <jgross@suse.com> wrote:
>> When running as a Xen guest selecting "nosmt" either via command line
>> or implicitly via default settings makes no sense, as the guest has no
>> clue about the real system topology it is running on. With Xen it is
>> the hypervisor's job to ensure the proper bug mitigations are active
>> regarding smt settings.
> 
> I don't agree with the second sentence: It is in principle fine for the
> hypervisor to expose HT (i.e. not disable it as bug mitigation), and
> leave it to the guest kernels to protect themselves. We're just not
> at the point yet where Xen offers sufficient / reliable data to guest
> kernels to do so, so _for the time being_ what you say is correct.

Okay, I'll add something like:

This is true as long Xen doesn't support core scheduling together with
exposing the (then) correct sibling information to the guest and
indicating that case via a sutable interface.


Juergen


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/xen: disable nosmt in Xen guests
  2019-06-12 10:12 ` [Xen-devel] " Juergen Gross
@ 2019-06-12 11:48   ` Peter Zijlstra
  -1 siblings, 0 replies; 10+ messages in thread
From: Peter Zijlstra @ 2019-06-12 11:48 UTC (permalink / raw)
  To: Juergen Gross
  Cc: xen-devel, x86, linux-kernel, Boris Ostrovsky,
	Stefano Stabellini, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H. Peter Anvin

On Wed, Jun 12, 2019 at 12:12:28PM +0200, Juergen Gross wrote:
> When running as a Xen guest selecting "nosmt" either via command line
> or implicitly via default settings makes no sense, as the guest has no
> clue about the real system topology it is running on. With Xen it is
> the hypervisor's job to ensure the proper bug mitigations are active
> regarding smt settings.
> 
> So when running as a Xen guest set cpu_smt_control to "not supported"
> in order to avoid disabling random vcpus.

If it doesn't make sense; then the topology should not expose SMT
threads and the knob will not have any effect.

If you expose SMT topology info to the guest, then you get what you ask
for.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Xen-devel] [PATCH] x86/xen: disable nosmt in Xen guests
@ 2019-06-12 11:48   ` Peter Zijlstra
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Zijlstra @ 2019-06-12 11:48 UTC (permalink / raw)
  To: Juergen Gross
  Cc: Stefano Stabellini, x86, linux-kernel, Ingo Molnar,
	Borislav Petkov, H. Peter Anvin, xen-devel, Boris Ostrovsky,
	Thomas Gleixner

On Wed, Jun 12, 2019 at 12:12:28PM +0200, Juergen Gross wrote:
> When running as a Xen guest selecting "nosmt" either via command line
> or implicitly via default settings makes no sense, as the guest has no
> clue about the real system topology it is running on. With Xen it is
> the hypervisor's job to ensure the proper bug mitigations are active
> regarding smt settings.
> 
> So when running as a Xen guest set cpu_smt_control to "not supported"
> in order to avoid disabling random vcpus.

If it doesn't make sense; then the topology should not expose SMT
threads and the knob will not have any effect.

If you expose SMT topology info to the guest, then you get what you ask
for.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/xen: disable nosmt in Xen guests
  2019-06-12 11:48   ` [Xen-devel] " Peter Zijlstra
@ 2019-06-12 14:59     ` Juergen Gross
  -1 siblings, 0 replies; 10+ messages in thread
From: Juergen Gross @ 2019-06-12 14:59 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: xen-devel, x86, linux-kernel, Boris Ostrovsky,
	Stefano Stabellini, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H. Peter Anvin

On 12.06.19 13:48, Peter Zijlstra wrote:
> On Wed, Jun 12, 2019 at 12:12:28PM +0200, Juergen Gross wrote:
>> When running as a Xen guest selecting "nosmt" either via command line
>> or implicitly via default settings makes no sense, as the guest has no
>> clue about the real system topology it is running on. With Xen it is
>> the hypervisor's job to ensure the proper bug mitigations are active
>> regarding smt settings.
>>
>> So when running as a Xen guest set cpu_smt_control to "not supported"
>> in order to avoid disabling random vcpus.
> 
> If it doesn't make sense; then the topology should not expose SMT
> threads and the knob will not have any effect.

Yes, that's the theory.

I agree completely, but this is ongoing work which will need some more
time. It probably would have been ready for some time now, but some
recent processor bugs required a shift in priorities what to do first.

In order to run a new kernel on existing Xen we need that patch to avoid
disabling random cpus.


Juergen

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Xen-devel] [PATCH] x86/xen: disable nosmt in Xen guests
@ 2019-06-12 14:59     ` Juergen Gross
  0 siblings, 0 replies; 10+ messages in thread
From: Juergen Gross @ 2019-06-12 14:59 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Stefano Stabellini, x86, linux-kernel, Ingo Molnar,
	Borislav Petkov, H. Peter Anvin, xen-devel, Boris Ostrovsky,
	Thomas Gleixner

On 12.06.19 13:48, Peter Zijlstra wrote:
> On Wed, Jun 12, 2019 at 12:12:28PM +0200, Juergen Gross wrote:
>> When running as a Xen guest selecting "nosmt" either via command line
>> or implicitly via default settings makes no sense, as the guest has no
>> clue about the real system topology it is running on. With Xen it is
>> the hypervisor's job to ensure the proper bug mitigations are active
>> regarding smt settings.
>>
>> So when running as a Xen guest set cpu_smt_control to "not supported"
>> in order to avoid disabling random vcpus.
> 
> If it doesn't make sense; then the topology should not expose SMT
> threads and the knob will not have any effect.

Yes, that's the theory.

I agree completely, but this is ongoing work which will need some more
time. It probably would have been ready for some time now, but some
recent processor bugs required a shift in priorities what to do first.

In order to run a new kernel on existing Xen we need that patch to avoid
disabling random cpus.


Juergen

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-06-12 14:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-12 10:12 [PATCH] x86/xen: disable nosmt in Xen guests Juergen Gross
2019-06-12 10:12 ` [Xen-devel] " Juergen Gross
2019-06-12 10:19 ` Jan Beulich
2019-06-12 10:19   ` Jan Beulich
2019-06-12 10:36   ` Juergen Gross
2019-06-12 10:36     ` Juergen Gross
2019-06-12 11:48 ` Peter Zijlstra
2019-06-12 11:48   ` [Xen-devel] " Peter Zijlstra
2019-06-12 14:59   ` Juergen Gross
2019-06-12 14:59     ` [Xen-devel] " Juergen Gross

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.