Skip to contentSkip to conversation

x86: Don't increase ApicIdCoreSize past 7

RFC PATCH In review George Dunlap 4 participants 5 messages Nov 25, 2019 – Nov 26, 2019

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 x86: Don't increase ApicIdCoreSize past 7

Changeset ca2eee92df44 ("x86, hvm: Expose host core/HT topology to HVM guests") attempted to "fake up" a topology which would induce guest operating systems to not treat vcpus as sibling hyperthreads. This involved actually reporting hyperthreading as available, but giving vcpus every other ApicId; which in turn led to doubling the ApicIds per core by bumping the ApicIdCoreSize by one. In particular, Ryzen 3xxx series processors, and reportedly EPYC "Rome" cpus -- have an ApicIdCoreSize of 7; the "fake" topology increases this to 8.

Unfortunately, Windows running on modern AMD hardware -- including Ryzen 3xxx series processors, and reportedly EPYC "Rome" cpus -- doesn't seem to cope with this value being higher than 7. (Linux guests have so far continued to cope.)

A "proper" fix is complicated and it's too late to fix it either for 4.13, or to backport to supported branches. As a short-term fix, limit this value to 7.

This does mean that a Linux guest, booted on such a system without this change, and then migrating to a system with this change, with more than 64 vcpus, would see an apparent topology change. This is a low enough risk in practice that enabling this limit unilaterally, to allow other guests to boot without manual intervention, is worth it.

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Juergen Gross <[email protected]>

---
 tools/libxc/xc_cpuid_x86.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/libxc/xc_cpuid_x86.c +6 -1
index 312c481f1e..519d6d8bd0 100644
@@ -616,10 +616,15 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid,
              * - going out of sync with leaf 1 EBX[23:16],
              * - incrementing ApicIdCoreSize when it's zero (which changes the
              *   meaning of bits 7:0).
+             *
+             * UPDATE: I addition to avoiding overflow, some
+             * proprietary operating systems have trouble with
+             * apic_id_size values greater than 7.  Limit the value to
+             * 7 for now.
              */
             if ( p->extd.nc < 0x7f )
             {
-                if ( p->extd.apic_id_size != 0 && p->extd.apic_id_size != 0xf )
+                if ( p->extd.apic_id_size != 0 && p->extd.apic_id_size < 0x7 )
                     p->extd.apic_id_size++;
 
                 p->extd.nc = (p->extd.nc << 1) | 1;
Signature · 7 lines
2.24.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 24 lines · George Dunlap

Changeset ca2eee92df44 ("x86, hvm: Expose host core/HT topology to HVM guests") attempted to "fake up" a topology which would induce guest operating systems to not treat vcpus as sibling hyperthreads. This involved actually reporting hyperthreading as available, but giving vcpus every other ApicId; which in turn led to doubling the ApicIds per core by bumping the ApicIdCoreSize by one. In particular, Ryzen 3xxx series processors, and reportedly EPYC "Rome" cpus -- have an ApicIdCoreSize of 7; the "fake" topology increases this to 8.

Unfortunately, Windows running on modern AMD hardware -- including Ryzen 3xxx series processors, and reportedly EPYC "Rome" cpus -- doesn't seem to cope with this value being higher than 7. (Linux guests have so far continued to cope.)

A "proper" fix is complicated and it's too late to fix it either for 4.13, or to backport to supported branches. As a short-term fix, limit this value to 7.

This does mean that a Linux guest, booted on such a system without this change, and then migrating to a system with this change, with more than 64 vcpus, would see an apparent topology change. This is a low enough risk in practice that enabling this limit unilaterally, to allow other guests to boot without manual intervention, is worth it.

Quoted 3 lines

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v1 1/1
#2 lore raw
In reply to George Dunlap
Quoted 24 lines · George Dunlap

Changeset ca2eee92df44 ("x86, hvm: Expose host core/HT topology to HVM guests") attempted to "fake up" a topology which would induce guest operating systems to not treat vcpus as sibling hyperthreads. This involved actually reporting hyperthreading as available, but giving vcpus every other ApicId; which in turn led to doubling the ApicIds per core by bumping the ApicIdCoreSize by one. In particular, Ryzen 3xxx series processors, and reportedly EPYC "Rome" cpus -- have an ApicIdCoreSize of 7; the "fake" topology increases this to 8.

Unfortunately, Windows running on modern AMD hardware -- including Ryzen 3xxx series processors, and reportedly EPYC "Rome" cpus -- doesn't seem to cope with this value being higher than 7. (Linux guests have so far continued to cope.)

A "proper" fix is complicated and it's too late to fix it either for 4.13, or to backport to supported branches. As a short-term fix, limit this value to 7.

This does mean that a Linux guest, booted on such a system without this change, and then migrating to a system with this change, with more than 64 vcpus, would see an apparent topology change. This is a low enough risk in practice that enabling this limit unilaterally, to allow other guests to boot without manual intervention, is worth it.

Quoted 3 lines

with ...

tools/libxc/xc_cpuid_x86.c int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, · line 620

Quoted 8 lines
tools/libxc/xc_cpuid_x86.c +2 -0
@@ -616,10 +616,15 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid,
              * - going out of sync with leaf 1 EBX[23:16],
              * - incrementing ApicIdCoreSize when it's zero (which changes the
              *   meaning of bits 7:0).
+             *
+             * UPDATE: I addition to avoiding overflow, some

... this becoming "UPDATE: In ...".

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 32 lines · Jan Beulich
Quoted 24 lines · George Dunlap

Changeset ca2eee92df44 ("x86, hvm: Expose host core/HT topology to HVM guests") attempted to "fake up" a topology which would induce guest operating systems to not treat vcpus as sibling hyperthreads. This involved actually reporting hyperthreading as available, but giving vcpus every other ApicId; which in turn led to doubling the ApicIds per core by bumping the ApicIdCoreSize by one. In particular, Ryzen 3xxx series processors, and reportedly EPYC "Rome" cpus -- have an ApicIdCoreSize of 7; the "fake" topology increases this to 8.

Unfortunately, Windows running on modern AMD hardware -- including Ryzen 3xxx series processors, and reportedly EPYC "Rome" cpus -- doesn't seem to cope with this value being higher than 7. (Linux guests have so far continued to cope.)

A "proper" fix is complicated and it's too late to fix it either for 4.13, or to backport to supported branches. As a short-term fix, limit this value to 7.

This does mean that a Linux guest, booted on such a system without this change, and then migrating to a system with this change, with more than 64 vcpus, would see an apparent topology change. This is a low enough risk in practice that enabling this limit unilaterally, to allow other guests to boot without manual intervention, is worth it.

Quoted 3 lines

with ...

Quoted 10 lines

tools/libxc/xc_cpuid_x86.c int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, · line 620

Quoted 8 lines
tools/libxc/xc_cpuid_x86.c +2 -0
@@ -616,10 +616,15 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid,
              * - going out of sync with leaf 1 EBX[23:16],
              * - incrementing ApicIdCoreSize when it's zero (which changes the
              *   meaning of bits 7:0).
+             *
+             * UPDATE: I addition to avoiding overflow, some

... this becoming "UPDATE: In ...".

Gah... Sorry, meant to apply this change on check-in, but screwed it up (accidentally edited the wrong buffer). Let me know if you want a follow-up patch to fix it.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
In reply to George Dunlap
Quoted 27 lines · George Dunlap

Changeset ca2eee92df44 ("x86, hvm: Expose host core/HT topology to HVM guests") attempted to "fake up" a topology which would induce guest operating systems to not treat vcpus as sibling hyperthreads. This involved actually reporting hyperthreading as available, but giving vcpus every other ApicId; which in turn led to doubling the ApicIds per core by bumping the ApicIdCoreSize by one. In particular, Ryzen 3xxx series processors, and reportedly EPYC "Rome" cpus -- have an ApicIdCoreSize of 7; the "fake" topology increases this to 8.

Unfortunately, Windows running on modern AMD hardware -- including Ryzen 3xxx series processors, and reportedly EPYC "Rome" cpus -- doesn't seem to cope with this value being higher than 7. (Linux guests have so far continued to cope.)

A "proper" fix is complicated and it's too late to fix it either for 4.13, or to backport to supported branches. As a short-term fix, limit this value to 7.

This does mean that a Linux guest, booted on such a system without this change, and then migrating to a system with this change, with more than 64 vcpus, would see an apparent topology change. This is a low enough risk in practice that enabling this limit unilaterally, to allow other guests to boot without manual intervention, is worth it.

Quoted 8 lines

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Juergen Gross <[email protected]>

---
 tools/libxc/xc_cpuid_x86.c | 7 ++++++-

I will defer this to x86 maintainers.

Seeing that you already have an Ack from Jan, feel free to add mine if necessary.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel