Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
25% Recurring Discount on NVMe VPS
Try EnsoVPN - Reliable VPN - 1-Day Free Trial
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
CloudLinux
Try EnsoVPN - Fast & Private VPN - 1-Day Free Trial
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Re-enabling AES-NI on VPSes that don't pass the feature through

2

Comments

  • Nope, still returns OPENSSL_ia32cap=0x80202001478bfffd:0x0000000000000000:0x0000000000000000:0x0000000000000000:0x0000000000000000

  • forestforest Member
    edited July 6

    @JohnFilch123 said:
    Nope, still returns OPENSSL_ia32cap=0x80202001478bfffd:0x0000000000000000:0x0000000000000000:0x0000000000000000:0x0000000000000000

    Okay that means it's working fine, you just have an old CPU so only LV0 is set. Notice how now it's 0x80202001478bfffd but before it was 0x82202001478bfffd. That means, after that reboot, it's successfully enabled AES-NI.

    Restart the shell or source /etc/environment to get the modified value back and try openssl speed -evp aes-256-ctr again and you should see substantial improvements compared to before the reboot.

  • @forest said: substantial

    Doing AES-256-CTR ops for 3s on 16 size blocks: 9029090 AES-256-CTR ops in 2.32s
    Doing AES-256-CTR ops for 3s on 64 size blocks: 2195362 AES-256-CTR ops in 2.26s
    Doing AES-256-CTR ops for 3s on 256 size blocks: 547776 AES-256-CTR ops in 2.22s
    Doing AES-256-CTR ops for 3s on 1024 size blocks: 143612 AES-256-CTR ops in 2.41s
    Doing AES-256-CTR ops for 3s on 8192 size blocks: 18325 AES-256-CTR ops in 2.17s
    Doing AES-256-CTR ops for 3s on 16384 size blocks: 9236 AES-256-CTR ops in 2.22s
    version: 3.5.6
    built on: Sat Jun  6 19:55:35 2026 UTC
    options: bn(64,64)
    compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -fzero-call-used-regs=used-gpr -Wa,--noexecstack -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/openssl-3.5.6=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_BUILDING_OPENSSL -DZLIB -DZSTD -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2
    CPUINFO: OPENSSL_ia32cap=0x80202001478bfffd:0x0000000000000000:0x0000000000000000:0x0000000000000000:0x0000000000000000
    The 'numbers' are in 1000s of bytes per second processed.
    type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
    AES-256-CTR      62269.59k    62169.54k    63166.96k    61020.20k    69178.99k    68163.34k
    

    It was more or less the same, cannot really say there is a substantial improvement but if it worked. I wonder if upgrading the kernel will help (I am on 6.12 currently) and doing setcpuid=153.

  • MurvMurv Member, Megathread Squad

    @JohnFilch123 said: CPUINFO: OPENSSL_ia32cap=0x80202001478bfffd:0x0000000000000000:0x0000000000000000:0x0000000000000000:0x0000000000000000

    I think in your case openssl is not seeing the OPENSSL_ia32cap environment variable at all.

    It'll let you know whenever it's overriding the cpuid flags, a snippet from my own tests:

    CPUINFO: OPENSSL_ia32cap=0x82382203478bfffd:0x0000000000000000:0x0000000000000000:0x0000000000000000:0x0000000000000000 env:0x82382203478bfffd
    

    (See the env:0x82382203478bfffd at the end.)

    Also in my Gcore VM it's significantly faster:

    type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
    AES-256-CTR     317686.02k   855453.25k  2190144.00k  3186075.65k  4041329.32k  3692068.86k
    
    Thanked by 1JohnFilch123
  • forestforest Member
    edited July 6

    @Murv said: I think in your case openssl is not seeing the OPENSSL_ia32cap environment variable at all.

    No, it is. It showed a different output after he unset the variable.

    The output with the variable intact:

    OPENSSL_ia32cap=0x82202001478bfffd:0x0000000000000000:0x0000000000000000:0x0000000000000000:0x0000000000000000
    

    The output after he unset it (note the 0x822... became 0x802...):

    OPENSSL_ia32cap=0x80202001478bfffd:0x0000000000000000:0x0000000000000000:0x0000000000000000:0x0000000000000000
    

    So it definitely sees it, but if nothing is actually happening performance-wise, there must be another reason.

    Thanked by 1Murv
  • Ya something is not working on my VM.

  • MurvMurv Member, Megathread Squad

    @forest said: No, it is. It showed a different output after he unset the variable.

    Ahhh, me weeb-brain misread that.

    Ya something is not working on my VM.

    Can you try OPENSSL_ia32cap=0x82382203478bfffd openssl speed -elapsed -evp aes-256-ctr

  • @Murv said: OPENSSL_ia32cap=0x82382203478bfffd openssl speed -elapsed -evp aes-256-ctr

    You have chosen to measure elapsed time instead of user CPU time.
    Doing AES-256-CTR ops for 3s on 16 size blocks: 56341443 AES-256-CTR ops in 3.00s
    Doing AES-256-CTR ops for 3s on 64 size blocks: 40769437 AES-256-CTR ops in 3.00s
    Doing AES-256-CTR ops for 3s on 256 size blocks: 22920127 AES-256-CTR ops in 3.00s
    Doing AES-256-CTR ops for 3s on 1024 size blocks: 10144178 AES-256-CTR ops in 3.00s
    Doing AES-256-CTR ops for 3s on 8192 size blocks: 1228916 AES-256-CTR ops in 3.00s
    Doing AES-256-CTR ops for 3s on 16384 size blocks: 593197 AES-256-CTR ops in 3.00s
    version: 3.5.6
    built on: Sat Jun  6 19:55:35 2026 UTC
    options: bn(64,64)
    compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -fzero-call-used-regs=used-gpr -Wa,--noexecstack -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/openssl-3.5.6=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_BUILDING_OPENSSL -DZLIB -DZSTD -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2
    CPUINFO: OPENSSL_ia32cap=0x82382203478bfffd:0x0000000000000000:0x0000000000000000:0x0000000000000000:0x0000000000000000 env:0x82382203478bfffd
    The 'numbers' are in 1000s of bytes per second processed.
    type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
    AES-256-CTR     300487.70k   869747.99k  1955850.84k  3462546.09k  3355759.96k  3239646.55k
    
  • MurvMurv Member, Megathread Squad

    @JohnFilch123 said:
    type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
    AES-256-CTR 300487.70k 869747.99k 1955850.84k 3462546.09k 3355759.96k 3239646.55k

    Looks like my value works for you?
    68163.34k vs 3239646.55k

  • @Murv said: Looks like my value works for you?

    Ah, seems like it did the trick, even though I still get zeros everywhere in the output of openssl info -cpusettings

  • forestforest Member
    edited July 6

    @JohnFilch123 said: even though I still get zeros everywhere in the output of openssl info -cpusettings

    That's normal for your CPU, given that you got that even after you did that unset command.

    I thought it was weird at first, but apparently the CPU is just old.

    Thanked by 1JohnFilch123
  • @forest said: CPU is just old

    Yep, welcome to Armenia but well...it is what it is, hopefully it will give my tor relay a boost.

    Thanked by 1forest
  • forestforest Member
    edited July 6

    @JohnFilch123 said: Yep, welcome to Armenia but well...it is what it is, hopefully it will give my tor relay a boost.

    If you don't have much RAM, another thing that'll give it a nice boost is this:

    apt install jemalloc2 && systemctl edit --stdin [email protected] << EOF
    [Service]
    Environment="LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2"
    EOF
    

    That'll reduce RAM usage by ~70%, which can improve performance significantly on low-memory systems. It replaces the default Glibc memory allocator, ptmalloc3, with one called jemalloc2 which is much better at resisting memory fragmentation.

  • @rm_ said:

    @Nekopara said: tempted to run this on a GCORE vps which shows QEMU virtual cpu with nothing enabled

    It's a bit pointless, unless you know why you need it. Modern SSH, HTTPS and VPN (Wireguard) have moved on from AES to ChaCha20, and that doesn't rely on any hardware acceleration.

    Simply incorrect not sure where you people are educated.

    Yes ChaCha20 has seen wide mass adoption especially in VPN space, but AES and other original forms of encryption have had plenty of there own developments are are still heavy more implemented overall.

    AES-GCM, AES-GCM-SIV are actively modern competitors that still take use of hardware acceleration.

    Let’s not forget AES-XTS for other applications outside of general web traffic, data encryption king.

  • @forest said: If you don't have much RAM, another thing that'll give it a nice boost is this:

    1Gb, fix applied, many thanks.

    Thanked by 1forest
  • MurvMurv Member, Megathread Squad

    Also if anyone else is gooning in AES-GCM like me, enabling PCLMULQDQ alongside AES-NI will speed up AES-GCM even further.

    Just had to use 's/(0x[0-9a-f]{16})/sprintf("0x%016x", hex($1) | (1 << 57) | (1 << 33))/e' as the perl argument.

  • WilliamWilliam Member

    Are there even any CPUs wit VT that do not have AES? Atom maybe?

  • MurvMurv Member, Megathread Squad

    @William said:
    Are there even any CPUs wit VT that do not have AES? Atom maybe?

    This is for when the host CPU does support AES-NI but the flag is not set on the VM's CPU.
    For instance Gcore's basic VMs don't have AES-NI flag set but the host CPU does in fact support it.

  • forestforest Member

    @Murv said:
    Also if anyone else is gooning in AES-GCM like me, enabling PCLMULQDQ alongside AES-NI will speed up AES-GCM even further.

    Just had to use 's/(0x[0-9a-f]{16})/sprintf("0x%016x", hex($1) | (1 << 57) | (1 << 33))/e' as the perl argument.

    I didn't even think about whether or not the QEMU virtual CPU would use PCLMULQDQ, I just assumed it would. Wow, if it's not enabled in there then that's even worse, and (1 << 57) | (1 << 33) is definitely a good idea!

    Thanked by 1Murv
  • raindog308raindog308 Administrator, Veteran

    @forest said: Because all QEMU does is change the effect of the CPUID instruction to stop advertising AES-NI support. But the AES-NI instructions can't be trapped, so they'll always work if the guest attempts to issue them and the hardware supports them.

    That's wild. Thanks for posting this.

    What is the motivation for a host to not pass through aes support? I would think it would actually reduce CPU usage overall. And if you do have someone who pounds the CPU because you have AES passed through, they'd be easy to spot and discipline.

  • SaragoldfarbSaragoldfarb Member, Megathread Squad

    Nice. Thanks @forest !

    Thanked by 2forest whynotlearn
  • forestforest Member
    edited July 6

    @raindog308 said:

    @forest said: Because all QEMU does is change the effect of the CPUID instruction to stop advertising AES-NI support. But the AES-NI instructions can't be trapped, so they'll always work if the guest attempts to issue them and the hardware supports them.

    That's wild. Thanks for posting this.

    What is the motivation for a host to not pass through aes support? I would think it would actually reduce CPU usage overall. And if you do have someone who pounds the CPU because you have AES passed through, they'd be easy to spot and discipline.

    If you try to do a live migration when the whole CPU is passed through, things can break if you migrate to different hardware that lacks a feature that is currently being used, so hosts will often set the advertised CPU model to be the lowest common denominator in their fleet (e.g. Broadwell if that's what their oldest node is running). Then they might be missing out on a bit of performance by not advertising some existing and very modern optimizations, but not too much.

    Unfortunately some hosts are lazy or not very experienced and will just use the default qemu64 "CPU model" which is intended to be compatible with anything that is possibly running today, all the way down to a system running the original SLS Linux. It doesn't even advertise SSE4 which is from 20 years ago!

    Each CPU model is basically just an alias for a collection of supported flags, so -cpu IvyBridge is the equivalent of setting -cpu base,+foo,+bar,+baz,... where foo, bar, and baz represent the list of features that a genuine Intel Xeon E3-12xx v2 supports. So if it's actually running on a Xeon E5-2695 v4, you could live migrate it to a real Xeon E3-12xx v2.

    QEMU CPU models and recognized flags (click to expand)

    $ qemu-system-x86_64 -cpu help
    Available CPUs:
      486                   (alias configured by machine type)
      486-v1
      Broadwell             (alias configured by machine type)
      Broadwell-IBRS        (alias of Broadwell-v3)
      Broadwell-noTSX       (alias of Broadwell-v2)
      Broadwell-noTSX-IBRS  (alias of Broadwell-v4)
      Broadwell-v1          Intel Core Processor (Broadwell)
      Broadwell-v2          Intel Core Processor (Broadwell, no TSX)
      Broadwell-v3          Intel Core Processor (Broadwell, IBRS)
      Broadwell-v4          Intel Core Processor (Broadwell, no TSX, IBRS)
      Cascadelake-Server    (alias configured by machine type)
      Cascadelake-Server-noTSX  (alias of Cascadelake-Server-v3)
      Cascadelake-Server-v1  Intel Xeon Processor (Cascadelake)
      Cascadelake-Server-v2  Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES]
      Cascadelake-Server-v3  Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES, no TSX]
      Cascadelake-Server-v4  Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES, EPT switching, no TSX]
      Cascadelake-Server-v5  Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES, EPT switching, XSAVES, no TSX]
      ClearwaterForest      (alias configured by machine type)
      ClearwaterForest-v1   Intel Xeon Processor (ClearwaterForest)
      Conroe                (alias configured by machine type)
      Conroe-v1             Intel Celeron_4x0 (Conroe/Merom Class Core 2)
      Cooperlake            (alias configured by machine type)
      Cooperlake-v1         Intel Xeon Processor (Cooperlake)
      Cooperlake-v2         Intel Xeon Processor (Cooperlake) [XSAVES]
      Denverton             (alias configured by machine type)
      Denverton-v1          Intel Atom Processor (Denverton)
      Denverton-v2          Intel Atom Processor (Denverton) [no MPX, no MONITOR]
      Denverton-v3          Intel Atom Processor (Denverton) [XSAVES, no MPX, no MONITOR]
      Dhyana                (alias configured by machine type)
      Dhyana-v1             Hygon Dhyana Processor
      Dhyana-v2             Hygon Dhyana Processor [XSAVES]
      EPYC                  (alias configured by machine type)
      EPYC-Genoa            (alias configured by machine type)
      EPYC-Genoa-v1         AMD EPYC-Genoa Processor
      EPYC-IBPB             (alias of EPYC-v2)
      EPYC-Milan            (alias configured by machine type)
      EPYC-Milan-v1         AMD EPYC-Milan Processor
      EPYC-Milan-v2         AMD EPYC-Milan-v2 Processor
      EPYC-Rome             (alias configured by machine type)
      EPYC-Rome-v1          AMD EPYC-Rome Processor
      EPYC-Rome-v2          AMD EPYC-Rome Processor
      EPYC-Rome-v3          AMD EPYC-Rome-v3 Processor
      EPYC-Rome-v4          AMD EPYC-Rome-v4 Processor (no XSAVES)
      EPYC-v1               AMD EPYC Processor
      EPYC-v2               AMD EPYC Processor (with IBPB)
      EPYC-v3               AMD EPYC Processor
      EPYC-v4               AMD EPYC-v4 Processor
      GraniteRapids         (alias configured by machine type)
      GraniteRapids-v1      Intel Xeon Processor (GraniteRapids)
      GraniteRapids-v2      Intel Xeon Processor (GraniteRapids)
      Haswell               (alias configured by machine type)
      Haswell-IBRS          (alias of Haswell-v3)
      Haswell-noTSX         (alias of Haswell-v2)
      Haswell-noTSX-IBRS    (alias of Haswell-v4)
      Haswell-v1            Intel Core Processor (Haswell)
      Haswell-v2            Intel Core Processor (Haswell, no TSX)
      Haswell-v3            Intel Core Processor (Haswell, IBRS)
      Haswell-v4            Intel Core Processor (Haswell, no TSX, IBRS)
      Icelake-Server        (alias configured by machine type)
      Icelake-Server-noTSX  (alias of Icelake-Server-v2)
      Icelake-Server-v1     Intel Xeon Processor (Icelake)
      Icelake-Server-v2     Intel Xeon Processor (Icelake) [no TSX]
      Icelake-Server-v3     Intel Xeon Processor (Icelake)
      Icelake-Server-v4     Intel Xeon Processor (Icelake)
      Icelake-Server-v5     Intel Xeon Processor (Icelake) [XSAVES]
      Icelake-Server-v6     Intel Xeon Processor (Icelake) [5-level EPT]
      Icelake-Server-v7     Intel Xeon Processor (Icelake) [TSX, taa-no]
      IvyBridge             (alias configured by machine type)
      IvyBridge-IBRS        (alias of IvyBridge-v2)
      IvyBridge-v1          Intel Xeon E3-12xx v2 (Ivy Bridge)
      IvyBridge-v2          Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)
      KnightsMill           (alias configured by machine type)
      KnightsMill-v1        Intel Xeon Phi Processor (Knights Mill)
      Nehalem               (alias configured by machine type)
      Nehalem-IBRS          (alias of Nehalem-v2)
      Nehalem-v1            Intel Core i7 9xx (Nehalem Class Core i7)
      Nehalem-v2            Intel Core i7 9xx (Nehalem Core i7, IBRS update)
      Opteron_G1            (alias configured by machine type)
      Opteron_G1-v1         AMD Opteron 240 (Gen 1 Class Opteron)
      Opteron_G2            (alias configured by machine type)
      Opteron_G2-v1         AMD Opteron 22xx (Gen 2 Class Opteron)
      Opteron_G3            (alias configured by machine type)
      Opteron_G3-v1         AMD Opteron 23xx (Gen 3 Class Opteron)
      Opteron_G4            (alias configured by machine type)
      Opteron_G4-v1         AMD Opteron 62xx class CPU
      Opteron_G5            (alias configured by machine type)
      Opteron_G5-v1         AMD Opteron 63xx class CPU
      Penryn                (alias configured by machine type)
      Penryn-v1             Intel Core 2 Duo P9xxx (Penryn Class Core 2)
      SandyBridge           (alias configured by machine type)
      SandyBridge-IBRS      (alias of SandyBridge-v2)
      SandyBridge-v1        Intel Xeon E312xx (Sandy Bridge)
      SandyBridge-v2        Intel Xeon E312xx (Sandy Bridge, IBRS update)
      SapphireRapids        (alias configured by machine type)
      SapphireRapids-v1     Intel Xeon Processor (SapphireRapids)
      SapphireRapids-v2     Intel Xeon Processor (SapphireRapids)
      SapphireRapids-v3     Intel Xeon Processor (SapphireRapids)
      SierraForest          (alias configured by machine type)
      SierraForest-v1       Intel Xeon Processor (SierraForest)
      SierraForest-v2       Intel Xeon Processor (SierraForest)
      Skylake-Client        (alias configured by machine type)
      Skylake-Client-IBRS   (alias of Skylake-Client-v2)
      Skylake-Client-noTSX-IBRS  (alias of Skylake-Client-v3)
      Skylake-Client-v1     Intel Core Processor (Skylake)
      Skylake-Client-v2     Intel Core Processor (Skylake, IBRS)
      Skylake-Client-v3     Intel Core Processor (Skylake, IBRS, no TSX)
      Skylake-Client-v4     Intel Core Processor (Skylake, IBRS, no TSX) [IBRS, XSAVES, no TSX]
      Skylake-Server        (alias configured by machine type)
      Skylake-Server-IBRS   (alias of Skylake-Server-v2)
      Skylake-Server-noTSX-IBRS  (alias of Skylake-Server-v3)
      Skylake-Server-v1     Intel Xeon Processor (Skylake)
      Skylake-Server-v2     Intel Xeon Processor (Skylake, IBRS)
      Skylake-Server-v3     Intel Xeon Processor (Skylake, IBRS, no TSX)
      Skylake-Server-v4     Intel Xeon Processor (Skylake, IBRS, no TSX) [IBRS, EPT switching, no TSX]
      Skylake-Server-v5     Intel Xeon Processor (Skylake, IBRS, no TSX) [IBRS, XSAVES, EPT switching, no TSX]
      Snowridge             (alias configured by machine type)
      Snowridge-v1          Intel Atom Processor (SnowRidge)
      Snowridge-v2          Intel Atom Processor (Snowridge, no MPX)
      Snowridge-v3          Intel Atom Processor (Snowridge, no MPX) [XSAVES, no MPX]
      Snowridge-v4          Intel Atom Processor (Snowridge, no MPX) [no split lock detect, no core-capability]
      Westmere              (alias configured by machine type)
      Westmere-IBRS         (alias of Westmere-v2)
      Westmere-v1           Westmere E56xx/L56xx/X56xx (Nehalem-C)
      Westmere-v2           Westmere E56xx/L56xx/X56xx (IBRS update)
      YongFeng              (alias configured by machine type)
      YongFeng-v1           Zhaoxin YongFeng Processor
      YongFeng-v2           Zhaoxin YongFeng Processor [with the correct model number]
      athlon                (alias configured by machine type)
      athlon-v1             QEMU Virtual CPU version 2.5+
      core2duo              (alias configured by machine type)
      core2duo-v1           Intel(R) Core(TM)2 Duo CPU     T7700  @ 2.40GHz
      coreduo               (alias configured by machine type)
      coreduo-v1            Genuine Intel(R) CPU           T2600  @ 2.16GHz
      kvm32                 (alias configured by machine type)
      kvm32-v1              Common 32-bit KVM processor
      kvm64                 (alias configured by machine type)
      kvm64-v1              Common KVM processor
      n270                  (alias configured by machine type)
      n270-v1               Intel(R) Atom(TM) CPU N270   @ 1.60GHz
      pentium               (alias configured by machine type)
      pentium-v1
      pentium2              (alias configured by machine type)
      pentium2-v1
      pentium3              (alias configured by machine type)
      pentium3-v1
      phenom                (alias configured by machine type)
      phenom-v1             AMD Phenom(tm) 9550 Quad-Core Processor
      qemu32                (alias configured by machine type)
      qemu32-v1             QEMU Virtual CPU version 2.5+
      qemu64                (alias configured by machine type)
      qemu64-v1             QEMU Virtual CPU version 2.5+
      base                  base CPU model type with no features enabled
      host                  processor with all supported host features
      max                   Enables all features supported by the accelerator in the current host
    
    Recognized CPUID flags:
      3dnow 3dnowext 3dnowprefetch abm ace2 ace2-en acpi adx aes amd-no-ssb
      amd-psfd amd-ssbd amd-stibp amx-bf16 amx-complex amx-fp16 amx-int8
      amx-tile apic arat arch-capabilities arch-lbr auto-ibrs avic avx avx-ifma
      avx-ne-convert avx-vnni avx-vnni-int16 avx-vnni-int8 avx10 avx10-128
      avx10-256 avx10-512 avx2 avx512-4fmaps avx512-4vnniw avx512-bf16
      avx512-fp16 avx512-vp2intersect avx512-vpopcntdq avx512bitalg avx512bw
      avx512cd avx512dq avx512er avx512f avx512ifma avx512pf avx512vbmi
      avx512vbmi2 avx512vl avx512vnni bhi-ctrl bhi-no bmi1 bmi2 bus-lock-detect
      cid cldemote clflush clflushopt clwb clzero cmov cmp-legacy cmpccxadd
      core-capability cr8legacy cx16 cx8 dca ddpd-u de decodeassists ds ds-cpl
      dtes64 eraps erms est extapic f16c fb-clear fbsdp-no fdp-excptn-only
      flush-l1d flushbyasid fma fma4 fpu fred fsgsbase fsrc fsrm fsrs
      full-width-write fxsr fxsr-opt fzrm gds-no gfni hle ht hypervisor ia64
      ibpb ibpb-brtype ibrs ibrs-all ibs intel-psfd intel-pt intel-pt-lip
      invpcid invtsc ipred-ctrl kvm-asyncpf kvm-asyncpf-int kvm-asyncpf-vmexit
      kvm-hint-dedicated kvm-mmu kvm-msi-ext-dest-id kvm-nopiodelay
      kvm-poll-control kvm-pv-eoi kvm-pv-ipi kvm-pv-sched-yield
      kvm-pv-tlb-flush kvm-pv-unhalt kvm-steal-time kvmclock kvmclock
      kvmclock-stable-bit la57 lahf-lm lam lbrv lfence-always-serializing lkgs
      lm lwp mca mcdt-no mce md-clear mds-no misalignsse mmx mmxext monitor
      movbe movdir64b movdiri mpx msr mtrr no-nested-data-bp nodeid-msr npt
      nrip-save null-sel-clr-base nx osvw overflow-recov pae pat pause-filter
      pbe pbrsb-no pcid pclmulqdq pcommit pdcm pdpe1gb perfctr-core perfctr-nb
      perfmon-v2 pfthreshold pge phe phe-en pks pku pmm pmm-en pn pni popcnt
      prefetchiti pschange-mc-no psdp-no pse pse36 rdctl-no rdpid rdrand rdseed
      rdtscp rfds-clear rfds-no rrsba-ctrl rsba rtm sbdr-ssdp-no sbpb sep
      serialize sgx sgx-aex-notify sgx-debug sgx-edeccssa sgx-exinfo sgx-kss
      sgx-mode64 sgx-provisionkey sgx-tokenkey sgx1 sgx2 sgxlc sha-ni sha512
      skinit skip-l1dfl-vmentry sm3 sm4 smap smep smx spec-ctrl
      split-lock-detect srso-no srso-user-kernel-no ss ssb-no ssbd sse sse2
      sse4.1 sse4.2 sse4a ssse3 stibp stibp-always-on succor svm svm-lock
      svme-addr-chk syscall taa-no tbm tce tm tm2 topoext tsc tsc-adjust
      tsc-deadline tsc-scale tsx-ctrl tsx-ldtrk umip v-vmsave-vmload vaes vgif
      virt-ssbd vmcb-clean vme vmx vmx-activity-hlt vmx-activity-shutdown
      vmx-activity-wait-sipi vmx-any-errcode vmx-apicv-register vmx-apicv-vid
      vmx-apicv-x2apic vmx-apicv-xapic vmx-cr3-load-noexit vmx-cr3-store-noexit
      vmx-cr8-load-exit vmx-cr8-store-exit vmx-desc-exit
      vmx-enable-user-wait-pause vmx-encls-exit vmx-entry-ia32e-mode
      vmx-entry-load-bndcfgs vmx-entry-load-efer vmx-entry-load-fred
      vmx-entry-load-pat vmx-entry-load-perf-global-ctrl vmx-entry-load-pkrs
      vmx-entry-load-rtit-ctl vmx-entry-noload-debugctl vmx-ept vmx-ept-1gb
      vmx-ept-2mb vmx-ept-advanced-exitinfo vmx-ept-execonly vmx-eptad
      vmx-eptp-switching vmx-exit-ack-intr vmx-exit-clear-bndcfgs
      vmx-exit-clear-rtit-ctl vmx-exit-load-efer vmx-exit-load-pat
      vmx-exit-load-perf-global-ctrl vmx-exit-load-pkrs
      vmx-exit-nosave-debugctl vmx-exit-save-efer vmx-exit-save-pat
      vmx-exit-save-preemption-timer vmx-exit-secondary-ctls vmx-flexpriority
      vmx-hlt-exit vmx-ins-outs vmx-intr-exit vmx-invept vmx-invept-all-context
      vmx-invept-single-context vmx-invept-single-context
      vmx-invept-single-context-noglobals vmx-invlpg-exit vmx-invpcid-exit
      vmx-invvpid vmx-invvpid-all-context vmx-invvpid-single-addr vmx-io-bitmap
      vmx-io-exit vmx-monitor-exit vmx-movdr-exit vmx-msr-bitmap vmx-mtf
      vmx-mwait-exit vmx-nested-exception vmx-nmi-exit vmx-page-walk-4
      vmx-page-walk-5 vmx-pause-exit vmx-ple vmx-pml vmx-posted-intr
      vmx-preemption-timer vmx-rdpmc-exit vmx-rdrand-exit vmx-rdseed-exit
      vmx-rdtsc-exit vmx-rdtscp-exit vmx-secondary-ctls vmx-shadow-vmcs
      vmx-store-lma vmx-true-ctls vmx-tsc-offset vmx-tsc-scaling
      vmx-unrestricted-guest vmx-vintr-pending vmx-vmfunc
      vmx-vmwrite-vmexit-fields vmx-vnmi vmx-vnmi-pending vmx-vpid
      vmx-wbinvd-exit vmx-xsaves vmx-zero-len-inject vnmi vpclmulqdq waitpkg
      wbnoinvd wdt wrmsrns x2apic xcrypt xcrypt-en xfd xgetbv1 xop xsave xsavec
      xsaveerptr xsaveopt xsaves xstore xstore-en xtpr zero-fcs-fds
    

    Thanked by 2whynotlearn Murv
  • @forest said:

    @raindog308 said:

    @forest said: Because all QEMU does is change the effect of the CPUID instruction to stop advertising AES-NI support. But the AES-NI instructions can't be trapped, so they'll always work if the guest attempts to issue them and the hardware supports them.

    That's wild. Thanks for posting this.

    What is the motivation for a host to not pass through aes support? I would think it would actually reduce CPU usage overall. And if you do have someone who pounds the CPU because you have AES passed through, they'd be easy to spot and discipline.

    If you try to do a live migration when the whole CPU is passed through, things can break if you migrate to different hardware that lacks a feature that is currently being used, so hosts will often set the advertised CPU model to be the lowest common denominator in their fleet (e.g. Broadwell if that's what their oldest node is running). Then they might be missing out on a bit of performance by not advertising some existing and very modern optimizations, but not too much.

    Unfortunately some hosts are lazy or not very experienced and will just use the default qemu64 "CPU model" which is intended to be compatible with anything that is possibly running today, all the way down to a system running the original SLS Linux. It doesn't even advertise SSE4 which is from 20 years ago!

    QEMU CPU models and recognized flags

    $ qemu-system-x86_64 -cpu help
    Available CPUs:
      486                   (alias configured by machine type)
      486-v1
      Broadwell             (alias configured by machine type)
      Broadwell-IBRS        (alias of Broadwell-v3)
      Broadwell-noTSX       (alias of Broadwell-v2)
      Broadwell-noTSX-IBRS  (alias of Broadwell-v4)
      Broadwell-v1          Intel Core Processor (Broadwell)
      Broadwell-v2          Intel Core Processor (Broadwell, no TSX)
      Broadwell-v3          Intel Core Processor (Broadwell, IBRS)
      Broadwell-v4          Intel Core Processor (Broadwell, no TSX, IBRS)
      Cascadelake-Server    (alias configured by machine type)
      Cascadelake-Server-noTSX  (alias of Cascadelake-Server-v3)
      Cascadelake-Server-v1  Intel Xeon Processor (Cascadelake)
      Cascadelake-Server-v2  Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES]
      Cascadelake-Server-v3  Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES, no TSX]
      Cascadelake-Server-v4  Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES, EPT switching, no TSX]
      Cascadelake-Server-v5  Intel Xeon Processor (Cascadelake) [ARCH_CAPABILITIES, EPT switching, XSAVES, no TSX]
      ClearwaterForest      (alias configured by machine type)
      ClearwaterForest-v1   Intel Xeon Processor (ClearwaterForest)
      Conroe                (alias configured by machine type)
      Conroe-v1             Intel Celeron_4x0 (Conroe/Merom Class Core 2)
      Cooperlake            (alias configured by machine type)
      Cooperlake-v1         Intel Xeon Processor (Cooperlake)
      Cooperlake-v2         Intel Xeon Processor (Cooperlake) [XSAVES]
      Denverton             (alias configured by machine type)
      Denverton-v1          Intel Atom Processor (Denverton)
      Denverton-v2          Intel Atom Processor (Denverton) [no MPX, no MONITOR]
      Denverton-v3          Intel Atom Processor (Denverton) [XSAVES, no MPX, no MONITOR]
      Dhyana                (alias configured by machine type)
      Dhyana-v1             Hygon Dhyana Processor
      Dhyana-v2             Hygon Dhyana Processor [XSAVES]
      EPYC                  (alias configured by machine type)
      EPYC-Genoa            (alias configured by machine type)
      EPYC-Genoa-v1         AMD EPYC-Genoa Processor
      EPYC-IBPB             (alias of EPYC-v2)
      EPYC-Milan            (alias configured by machine type)
      EPYC-Milan-v1         AMD EPYC-Milan Processor
      EPYC-Milan-v2         AMD EPYC-Milan-v2 Processor
      EPYC-Rome             (alias configured by machine type)
      EPYC-Rome-v1          AMD EPYC-Rome Processor
      EPYC-Rome-v2          AMD EPYC-Rome Processor
      EPYC-Rome-v3          AMD EPYC-Rome-v3 Processor
      EPYC-Rome-v4          AMD EPYC-Rome-v4 Processor (no XSAVES)
      EPYC-v1               AMD EPYC Processor
      EPYC-v2               AMD EPYC Processor (with IBPB)
      EPYC-v3               AMD EPYC Processor
      EPYC-v4               AMD EPYC-v4 Processor
      GraniteRapids         (alias configured by machine type)
      GraniteRapids-v1      Intel Xeon Processor (GraniteRapids)
      GraniteRapids-v2      Intel Xeon Processor (GraniteRapids)
      Haswell               (alias configured by machine type)
      Haswell-IBRS          (alias of Haswell-v3)
      Haswell-noTSX         (alias of Haswell-v2)
      Haswell-noTSX-IBRS    (alias of Haswell-v4)
      Haswell-v1            Intel Core Processor (Haswell)
      Haswell-v2            Intel Core Processor (Haswell, no TSX)
      Haswell-v3            Intel Core Processor (Haswell, IBRS)
      Haswell-v4            Intel Core Processor (Haswell, no TSX, IBRS)
      Icelake-Server        (alias configured by machine type)
      Icelake-Server-noTSX  (alias of Icelake-Server-v2)
      Icelake-Server-v1     Intel Xeon Processor (Icelake)
      Icelake-Server-v2     Intel Xeon Processor (Icelake) [no TSX]
      Icelake-Server-v3     Intel Xeon Processor (Icelake)
      Icelake-Server-v4     Intel Xeon Processor (Icelake)
      Icelake-Server-v5     Intel Xeon Processor (Icelake) [XSAVES]
      Icelake-Server-v6     Intel Xeon Processor (Icelake) [5-level EPT]
      Icelake-Server-v7     Intel Xeon Processor (Icelake) [TSX, taa-no]
      IvyBridge             (alias configured by machine type)
      IvyBridge-IBRS        (alias of IvyBridge-v2)
      IvyBridge-v1          Intel Xeon E3-12xx v2 (Ivy Bridge)
      IvyBridge-v2          Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)
      KnightsMill           (alias configured by machine type)
      KnightsMill-v1        Intel Xeon Phi Processor (Knights Mill)
      Nehalem               (alias configured by machine type)
      Nehalem-IBRS          (alias of Nehalem-v2)
      Nehalem-v1            Intel Core i7 9xx (Nehalem Class Core i7)
      Nehalem-v2            Intel Core i7 9xx (Nehalem Core i7, IBRS update)
      Opteron_G1            (alias configured by machine type)
      Opteron_G1-v1         AMD Opteron 240 (Gen 1 Class Opteron)
      Opteron_G2            (alias configured by machine type)
      Opteron_G2-v1         AMD Opteron 22xx (Gen 2 Class Opteron)
      Opteron_G3            (alias configured by machine type)
      Opteron_G3-v1         AMD Opteron 23xx (Gen 3 Class Opteron)
      Opteron_G4            (alias configured by machine type)
      Opteron_G4-v1         AMD Opteron 62xx class CPU
      Opteron_G5            (alias configured by machine type)
      Opteron_G5-v1         AMD Opteron 63xx class CPU
      Penryn                (alias configured by machine type)
      Penryn-v1             Intel Core 2 Duo P9xxx (Penryn Class Core 2)
      SandyBridge           (alias configured by machine type)
      SandyBridge-IBRS      (alias of SandyBridge-v2)
      SandyBridge-v1        Intel Xeon E312xx (Sandy Bridge)
      SandyBridge-v2        Intel Xeon E312xx (Sandy Bridge, IBRS update)
      SapphireRapids        (alias configured by machine type)
      SapphireRapids-v1     Intel Xeon Processor (SapphireRapids)
      SapphireRapids-v2     Intel Xeon Processor (SapphireRapids)
      SapphireRapids-v3     Intel Xeon Processor (SapphireRapids)
      SierraForest          (alias configured by machine type)
      SierraForest-v1       Intel Xeon Processor (SierraForest)
      SierraForest-v2       Intel Xeon Processor (SierraForest)
      Skylake-Client        (alias configured by machine type)
      Skylake-Client-IBRS   (alias of Skylake-Client-v2)
      Skylake-Client-noTSX-IBRS  (alias of Skylake-Client-v3)
      Skylake-Client-v1     Intel Core Processor (Skylake)
      Skylake-Client-v2     Intel Core Processor (Skylake, IBRS)
      Skylake-Client-v3     Intel Core Processor (Skylake, IBRS, no TSX)
      Skylake-Client-v4     Intel Core Processor (Skylake, IBRS, no TSX) [IBRS, XSAVES, no TSX]
      Skylake-Server        (alias configured by machine type)
      Skylake-Server-IBRS   (alias of Skylake-Server-v2)
      Skylake-Server-noTSX-IBRS  (alias of Skylake-Server-v3)
      Skylake-Server-v1     Intel Xeon Processor (Skylake)
      Skylake-Server-v2     Intel Xeon Processor (Skylake, IBRS)
      Skylake-Server-v3     Intel Xeon Processor (Skylake, IBRS, no TSX)
      Skylake-Server-v4     Intel Xeon Processor (Skylake, IBRS, no TSX) [IBRS, EPT switching, no TSX]
      Skylake-Server-v5     Intel Xeon Processor (Skylake, IBRS, no TSX) [IBRS, XSAVES, EPT switching, no TSX]
      Snowridge             (alias configured by machine type)
      Snowridge-v1          Intel Atom Processor (SnowRidge)
      Snowridge-v2          Intel Atom Processor (Snowridge, no MPX)
      Snowridge-v3          Intel Atom Processor (Snowridge, no MPX) [XSAVES, no MPX]
      Snowridge-v4          Intel Atom Processor (Snowridge, no MPX) [no split lock detect, no core-capability]
      Westmere              (alias configured by machine type)
      Westmere-IBRS         (alias of Westmere-v2)
      Westmere-v1           Westmere E56xx/L56xx/X56xx (Nehalem-C)
      Westmere-v2           Westmere E56xx/L56xx/X56xx (IBRS update)
      YongFeng              (alias configured by machine type)
      YongFeng-v1           Zhaoxin YongFeng Processor
      YongFeng-v2           Zhaoxin YongFeng Processor [with the correct model number]
      athlon                (alias configured by machine type)
      athlon-v1             QEMU Virtual CPU version 2.5+
      core2duo              (alias configured by machine type)
      core2duo-v1           Intel(R) Core(TM)2 Duo CPU     T7700  @ 2.40GHz
      coreduo               (alias configured by machine type)
      coreduo-v1            Genuine Intel(R) CPU           T2600  @ 2.16GHz
      kvm32                 (alias configured by machine type)
      kvm32-v1              Common 32-bit KVM processor
      kvm64                 (alias configured by machine type)
      kvm64-v1              Common KVM processor
      n270                  (alias configured by machine type)
      n270-v1               Intel(R) Atom(TM) CPU N270   @ 1.60GHz
      pentium               (alias configured by machine type)
      pentium-v1
      pentium2              (alias configured by machine type)
      pentium2-v1
      pentium3              (alias configured by machine type)
      pentium3-v1
      phenom                (alias configured by machine type)
      phenom-v1             AMD Phenom(tm) 9550 Quad-Core Processor
      qemu32                (alias configured by machine type)
      qemu32-v1             QEMU Virtual CPU version 2.5+
      qemu64                (alias configured by machine type)
      qemu64-v1             QEMU Virtual CPU version 2.5+
      base                  base CPU model type with no features enabled
      host                  processor with all supported host features
      max                   Enables all features supported by the accelerator in the current host
    
    Recognized CPUID flags:
      3dnow 3dnowext 3dnowprefetch abm ace2 ace2-en acpi adx aes amd-no-ssb
      amd-psfd amd-ssbd amd-stibp amx-bf16 amx-complex amx-fp16 amx-int8
      amx-tile apic arat arch-capabilities arch-lbr auto-ibrs avic avx avx-ifma
      avx-ne-convert avx-vnni avx-vnni-int16 avx-vnni-int8 avx10 avx10-128
      avx10-256 avx10-512 avx2 avx512-4fmaps avx512-4vnniw avx512-bf16
      avx512-fp16 avx512-vp2intersect avx512-vpopcntdq avx512bitalg avx512bw
      avx512cd avx512dq avx512er avx512f avx512ifma avx512pf avx512vbmi
      avx512vbmi2 avx512vl avx512vnni bhi-ctrl bhi-no bmi1 bmi2 bus-lock-detect
      cid cldemote clflush clflushopt clwb clzero cmov cmp-legacy cmpccxadd
      core-capability cr8legacy cx16 cx8 dca ddpd-u de decodeassists ds ds-cpl
      dtes64 eraps erms est extapic f16c fb-clear fbsdp-no fdp-excptn-only
      flush-l1d flushbyasid fma fma4 fpu fred fsgsbase fsrc fsrm fsrs
      full-width-write fxsr fxsr-opt fzrm gds-no gfni hle ht hypervisor ia64
      ibpb ibpb-brtype ibrs ibrs-all ibs intel-psfd intel-pt intel-pt-lip
      invpcid invtsc ipred-ctrl kvm-asyncpf kvm-asyncpf-int kvm-asyncpf-vmexit
      kvm-hint-dedicated kvm-mmu kvm-msi-ext-dest-id kvm-nopiodelay
      kvm-poll-control kvm-pv-eoi kvm-pv-ipi kvm-pv-sched-yield
      kvm-pv-tlb-flush kvm-pv-unhalt kvm-steal-time kvmclock kvmclock
      kvmclock-stable-bit la57 lahf-lm lam lbrv lfence-always-serializing lkgs
      lm lwp mca mcdt-no mce md-clear mds-no misalignsse mmx mmxext monitor
      movbe movdir64b movdiri mpx msr mtrr no-nested-data-bp nodeid-msr npt
      nrip-save null-sel-clr-base nx osvw overflow-recov pae pat pause-filter
      pbe pbrsb-no pcid pclmulqdq pcommit pdcm pdpe1gb perfctr-core perfctr-nb
      perfmon-v2 pfthreshold pge phe phe-en pks pku pmm pmm-en pn pni popcnt
      prefetchiti pschange-mc-no psdp-no pse pse36 rdctl-no rdpid rdrand rdseed
      rdtscp rfds-clear rfds-no rrsba-ctrl rsba rtm sbdr-ssdp-no sbpb sep
      serialize sgx sgx-aex-notify sgx-debug sgx-edeccssa sgx-exinfo sgx-kss
      sgx-mode64 sgx-provisionkey sgx-tokenkey sgx1 sgx2 sgxlc sha-ni sha512
      skinit skip-l1dfl-vmentry sm3 sm4 smap smep smx spec-ctrl
      split-lock-detect srso-no srso-user-kernel-no ss ssb-no ssbd sse sse2
      sse4.1 sse4.2 sse4a ssse3 stibp stibp-always-on succor svm svm-lock
      svme-addr-chk syscall taa-no tbm tce tm tm2 topoext tsc tsc-adjust
      tsc-deadline tsc-scale tsx-ctrl tsx-ldtrk umip v-vmsave-vmload vaes vgif
      virt-ssbd vmcb-clean vme vmx vmx-activity-hlt vmx-activity-shutdown
      vmx-activity-wait-sipi vmx-any-errcode vmx-apicv-register vmx-apicv-vid
      vmx-apicv-x2apic vmx-apicv-xapic vmx-cr3-load-noexit vmx-cr3-store-noexit
      vmx-cr8-load-exit vmx-cr8-store-exit vmx-desc-exit
      vmx-enable-user-wait-pause vmx-encls-exit vmx-entry-ia32e-mode
      vmx-entry-load-bndcfgs vmx-entry-load-efer vmx-entry-load-fred
      vmx-entry-load-pat vmx-entry-load-perf-global-ctrl vmx-entry-load-pkrs
      vmx-entry-load-rtit-ctl vmx-entry-noload-debugctl vmx-ept vmx-ept-1gb
      vmx-ept-2mb vmx-ept-advanced-exitinfo vmx-ept-execonly vmx-eptad
      vmx-eptp-switching vmx-exit-ack-intr vmx-exit-clear-bndcfgs
      vmx-exit-clear-rtit-ctl vmx-exit-load-efer vmx-exit-load-pat
      vmx-exit-load-perf-global-ctrl vmx-exit-load-pkrs
      vmx-exit-nosave-debugctl vmx-exit-save-efer vmx-exit-save-pat
      vmx-exit-save-preemption-timer vmx-exit-secondary-ctls vmx-flexpriority
      vmx-hlt-exit vmx-ins-outs vmx-intr-exit vmx-invept vmx-invept-all-context
      vmx-invept-single-context vmx-invept-single-context
      vmx-invept-single-context-noglobals vmx-invlpg-exit vmx-invpcid-exit
      vmx-invvpid vmx-invvpid-all-context vmx-invvpid-single-addr vmx-io-bitmap
      vmx-io-exit vmx-monitor-exit vmx-movdr-exit vmx-msr-bitmap vmx-mtf
      vmx-mwait-exit vmx-nested-exception vmx-nmi-exit vmx-page-walk-4
      vmx-page-walk-5 vmx-pause-exit vmx-ple vmx-pml vmx-posted-intr
      vmx-preemption-timer vmx-rdpmc-exit vmx-rdrand-exit vmx-rdseed-exit
      vmx-rdtsc-exit vmx-rdtscp-exit vmx-secondary-ctls vmx-shadow-vmcs
      vmx-store-lma vmx-true-ctls vmx-tsc-offset vmx-tsc-scaling
      vmx-unrestricted-guest vmx-vintr-pending vmx-vmfunc
      vmx-vmwrite-vmexit-fields vmx-vnmi vmx-vnmi-pending vmx-vpid
      vmx-wbinvd-exit vmx-xsaves vmx-zero-len-inject vnmi vpclmulqdq waitpkg
      wbnoinvd wdt wrmsrns x2apic xcrypt xcrypt-en xfd xgetbv1 xop xsave xsavec
      xsaveerptr xsaveopt xsaves xstore xstore-en xtpr zero-fcs-fds
    

    So what do you recommend for the providers to provide other than stock Qemu? Should the hosts try to set the flags for each hardware that they own or are there any better alternatives in general which could help a provider and how well does firecracker compare to Qemu.

    and What are (if any) some things that you recommend providers to do?

    Also I must say that it was a good writeup and I enjoyed reading your post :-D

  • forestforest Member
    edited July 6

    @whynotlearn said: So what do you recommend for the providers to provide other than stock Qemu? Should the hosts try to set the flags for each hardware that they own or are there any better alternatives in general which could help a provider and how well does firecracker compare to Qemu.

    Unless the provider is going to be doing live migrations, they should just do -cpu host (aka enabling passthrough, which would be the same as manually setting the flags for that specific hardware to everything it supports). Otherwise they should just set the type to the oldest in their fleet. If they decommission their oldest node and now their "new" oldest is a different model, they can just change the configuration on all the nodes to expose that model instead.

    For example, my MetroVPS shows as "Intel Core Processor (Broadwell, IBRS)" which means they set -cpu Broadwell-v3, even though it's probably running something newer under the hood. But that means they can live migrate to anything that old or newer, generally. So even though I'm not getting 100% of the features of the real CPU (assuming the node's real CPU isn't actually a Broadwell), I'm still getting all the really important ones like AES-NI, AVX2, RDRAND, SMAP, etc.

    Since most low-end hosts aren't going to need to do live migration like some superscalar, they should just set host CPU passthrough. The majority of my VPSes do that, with the exceptions of MetroVPS and Trabia (-cpu Broadwell-v3) and NoAckHosting (-cpu qemu64,+aes, which is the base QEMU model but with an override to additionally pass AES-NI).

  • raindog308raindog308 Administrator, Veteran

    @forest said: If you try to do a live migration when the whole CPU is passed through, things can break if you migrate to different hardware that lacks a feature that is currently being used, so hosts will often set the advertised CPU model to be the lowest common denominator in their fleet (e.g. Broadwell if that's what their oldest node is running).

    Make sense, though some googling reveals that AES-NI was available in CPUs from 2010 onwards. Then again, >16-year-old CPUs would not surprise me for some hosts...

  • forestforest Member

    @raindog308 said: Then again, >16-year-old CPUs would not surprise me for some hosts...

    And any host with a >16 year old CPU is probably not going to be doing live migration anyway. :D

  • forestforest Member
    edited July 7

    Come to think of it, I could write a program that automatically checks for the presence of every feature and determines exactly what flags the underlying host hardware really supports. Just some inline asm to attempt to issue a representative instruction for each feature and catch the SIGILL when it's unsupported.

    For example, if it issues AESENC and it doesn't cause an illegal instruction trap (which raises SIGILL), then it means the underlying hardware supports AES-NI. If not, it means it doesn't. Same with most other CPU features.

    If I turn this into a real project, I could even have a library preloaded in /etc/ld.so.preload that uses a constructor to run arch_prctl(ARCH_SET_CPUID, 0) so that the instruction traps, and install a SIGSEGV handler that emulates the result so the CPUID that applications see matches (as far as performance extensions are concerned) what the host actually provides. Combined with setting setcpuid on newer kernels, it could give the guest full performance back.

  • @forest said: I could write a program

    Look forward to it!

  • forestforest Member
    edited July 7

    @JohnFilch123 said:

    @forest said: I could write a program

    Look forward to it!

    Unfortunately, it seems that ARCH_SET_CPUID only works on Intel processors. But pretty much all important uses of AES-NI (and PCLMULQDQ and a few other common important features like AVX2) can be changed by using OPENSSL_ia32cap, setcpuid, and GLIBC_TUNABLES=glibc.cpu.hwcaps (the latter of which is necessary for optimized string functions in glibc). But it should still help with a majority of applications. Maybe a minority might use getauxval(AT_HWCAP / AT_HWCAP2).

    So I'll write a program to automate that instead, which should still solve 90% of use-cases.

    It'll be necessary to wait for kernel 6.15 to get AVX2 optimizations though, because those require kernel support (for XSAVE) which requires setcpuid. But AES-NI and PCLMULQDQ will work in userspace even on older kernels.

  • forestforest Member
    edited July 8

    Annoyingly, No Ack Hosting (https://noackhosting.se) has just told me they cannot do host passthrough or accept any flag passthrough besides AES-NI, so for everything but unauthenticated AES, I'm stuck with pre-2005 features. Apparently, the last time they "tried to add special flags" they lost the whole node and had to spend 8 hours bringing it back. :/

    Well, at least I have been able to forcibly re-enable PCLMULQDQ, but I'm still stuck without important security features, including some which allow cross-VM snooping and even breaking encryption due to low-entropy at boot (a problem that was solved in 2012). So yeah... If they didn't allow exits, I'd be cancelling right now.

    They say it's a limit of the Hostbill control software, but they really have no reason not to just enable full CPU passthrough (which Hostbill can do). I can re-enable all the performance features I need myself since they aren't disabled, just not advertised, but some of the security-relevant features actually do require hypervisor cooperation, sadly. I won't be an MJJ and argue with him in tickets about whether or not host CPU passthrough "exposes the host to the guests" or try to convince him that, yes, virtio-rng is something that is used for VPSes, so I'll have to leave it be. It is what it is.

    Thanked by 3Murv rpqu TrikeLike
Sign In or Register to comment.