Discussion:
virtualbox vcvtsi2sd illegal instruction
(too old to reply)
a***@nospicedham.spamtrap.com
2020-08-09 14:08:05 UTC
Permalink
Hi!

When I use

mov rax,123456789012
vcvtsi2sd xmm0,xmm0,rax

on the host system, and step through it in a debugger it works well,
but when I do the same thing in virtualbox on a linux guest I get an
illegal instruction.

I thought the virtualbox code runs natively on the host cpu, so the
instruction set should be the same.

What's going on here?
--
aen
JJ
2020-08-09 17:08:49 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
I thought the virtualbox code runs natively on the host cpu, so the
instruction set should be the same.
Not always, even though the VM is configured to use hardware virtualization.
VirtualBox may decide to use other type of virtualization engine as
necessary.

Check the "VM Execution Engine" field on the "Runtime Information" tab of
the "Session Information" dialog of a running VM. i.e. on the running VM's
window:

Main menu -> Machine -> Session Information

Or press the Host+N keyboard shortcut.
a***@nospicedham.spamtrap.com
2020-08-09 18:58:33 UTC
Permalink
On Mon, 10 Aug 2020 00:08:49 +0700, JJ
Post by JJ
Post by a***@nospicedham.spamtrap.com
I thought the virtualbox code runs natively on the host cpu, so the
instruction set should be the same.
Not always, even though the VM is configured to use hardware virtualization.
VirtualBox may decide to use other type of virtualization engine as
necessary.
Check the "VM Execution Engine" field on the "Runtime Information" tab of
the "Session Information" dialog of a running VM. i.e. on the running VM's
Main menu -> Machine -> Session Information
I have:

Konfiguration

Allgemein
Name Debian
Betriebssystem Debian (64-bit)
System
Hauptspeicher 4096 MB
Bootreihenfolge Diskettenlaufwerk, Optisch, Platte
Beschleunigung VT-x/AMD-V, Nested Paging, KVM-Paravirtualisierung
Anzeige
Grafikspeicher 16 MB
Grafikcontroller VMSVGA
Fernsteuerung deaktiviert
Aufnahme deaktiviert
Massenspeicher
Controller: IDE
Sekundärer Master [Optisches Laufwerk] leer
Controller: SATA
SATA-Port 0 Debian.vdi (normal, 32,00 GB)
Audio
Host-Treiber Windows DirectSound
Controller ICH AC97
Netzwerk
Adapter 1 Intel PRO/1000 MT Desktop (NAT)
Serielle Schnittstellen
deaktiviert
USB
USB-Controller OHCI
Gerätefilter 0 (0 aktiv)
Gemeinsame Ordner
Gemeinsame Ordner 1

Laufzeit

Laufzeit-Attribute
Bildschirmauflösung 1280x623x32 @0,0
VM-Laufzeit 0d 01:24:50
Zwischenablage-Modus bidirektional
Drag-und-Drop Modus deaktiviert
VM-Ausführungsschicht native API
---------------------------------
Nested Paging inaktiv
Unrestricted Execution inaktiv
Paravirtualisierung KVM
Gasterweiterungen 6.1.12 r139181
Gast-Betriebssystem Linux 2.6 / 3.x / 4.x (64-bit)
Port für Fernsteuerung nicht verfügbar

Performance Monitor

Some graphs

Gastkontrolle
Sitzungs-/Prozess-ID

Sorry for the language (german installation).

The Processor is an Intel Core i7-8700 CPU @ 3.20GHz
--
aen
Melzzzzz
2020-08-10 01:37:14 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
Hi!
When I use
mov rax,123456789012
vcvtsi2sd xmm0,xmm0,rax
on the host system, and step through it in a debugger it works well,
but when I do the same thing in virtualbox on a linux guest I get an
illegal instruction.
I thought the virtualbox code runs natively on the host cpu, so the
instruction set should be the same.
What's going on here?
Check support for AVX, perhaps your version of vbox does not support it?
--
current job title: senior software engineer
skills: c++,c,rust,go,nim,haskell...

press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Svi smo svedoci - oko 3 godine intenzivne propagande je dovoljno da jedan narod poludi -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi
bili naoruzani. -- Mladen Gogala
a***@nospicedham.spamtrap.com
2020-08-10 04:35:25 UTC
Permalink
On Mon, 10 Aug 2020 01:37:14 GMT, Melzzzzz
<***@nospicedham.zzzzz.com> wrote:
...
Post by Melzzzzz
Check support for AVX, perhaps your version of vbox does not support it?
In Wikipedia under VirtualBox in the Feature set section I find:

Feature set
...
Since version 5.0
AVX, AVX-2, AES-NI, SSE 4.1/4.2 instructions (if supported by the host
CPU)
...
I have version 6.1.
--
aen
a***@nospicedham.spamtrap.com
2020-08-10 12:24:28 UTC
Permalink
On Mon, 10 Aug 2020 01:37:14 GMT, Melzzzzz
<***@nospicedham.zzzzz.com> wrote:
...
Post by Melzzzzz
Check support for AVX, perhaps your version of vbox does not support it?
Here is the /proc/cpuinfo from the guest:

processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
stepping : 10
microcode : 0xffffffff
cpu MHz : 3192.010
cache size : 12288 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm
constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq
pni ssse3 pcid sse4_1 sse4_2 hypervisor lahf_lm invpcid_single pti
fsgsbase invpcid md_clear flush_l1d arch_capabilities
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass
l1tf mds swapgs itlb_multihit
bogomips : 6384.02
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:

There is no avx in the flags.
Could it be that buster doesn't support avx?
--
aen
George Neuner
2020-08-10 15:15:40 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
On Mon, 10 Aug 2020 01:37:14 GMT, Melzzzzz
...
Post by Melzzzzz
Check support for AVX, perhaps your version of vbox does not support it?
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 158
stepping : 10
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm
constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq
pni ssse3 pcid sse4_1 sse4_2 hypervisor lahf_lm invpcid_single pti
fsgsbase invpcid md_clear flush_l1d arch_capabilities
There is no avx in the flags.
Could it be that buster doesn't support avx?
The i7-8700 [if that is the correct CPU] supports both AVX and AVX2.
Somehow it is not being detected properly.

https://ark.intel.com/content/www/us/en/ark/products/126686/intel-core-i7-8700-processor-12m-cache-up-to-4-60-ghz.html

George
a***@nospicedham.spamtrap.com
2020-08-10 20:02:25 UTC
Permalink
On Mon, 10 Aug 2020 11:15:40 -0400, George Neuner
<***@nospicedham.comcast.net> wrote:
...
Post by George Neuner
Post by a***@nospicedham.spamtrap.com
There is no avx in the flags.
Could it be that buster doesn't support avx?
The i7-8700 [if that is the correct CPU] supports both AVX and AVX2.
Somehow it is not being detected properly.
It definitely is a coffee lake.

Is someone out there with a natively installed debian buster on that
cpu, who could show what's in the /proc/cpuinfo there?
--
aen
Bonita Montero
2020-08-10 12:29:01 UTC
Permalink
Post by Melzzzzz
Post by a***@nospicedham.spamtrap.com
vcvtsi2sd xmm0,xmm0,rax
Check support for AVX, perhaps your version of vbox does not support it?
The above instruction is SSE.
a***@nospicedham.spamtrap.com
2020-08-10 14:04:32 UTC
Permalink
On Mon, 10 Aug 2020 14:29:01 +0200, Bonita Montero
Post by Bonita Montero
Post by Melzzzzz
Post by a***@nospicedham.spamtrap.com
vcvtsi2sd xmm0,xmm0,rax
Check support for AVX, perhaps your version of vbox does not support it?
The above instruction is SSE.
From Intel 64 and IA-32 Architectues Software Developer's Manual
Volume 2 (2A, 2B & 2C): Instruction Set Reference, A-Z

CVTSI2SD - Convert Dword Integer to Scalar Double-Precision FP value
Opcode/ Op 64/32-bit CPUID Description
Instruction /En Mode Feature
Flag

F2 0F 2A /r RM V/V SSE2 Convert one signed
CVTSI2SD xmm,r/m32 doubleword integer from
r/m32 to one double-
precision floating-point
value in xmm.

F2 REX.W 0F 2A /r RM V/N.E. SSE2 Convert one signed
CVTSI2SD xmm,r/m32 quadword integer from
r/m64 to one double-
precision floating-point
value in xmm.

VEX.NDS.LIG.F2.0F.W0 2A /r RM V/V AVX Convert one signed
VCVTSI2SD xmm,r/m32 doubleword integer from
r/m32 to one double-
precision floating-point
value in xmm1.
VEX.NDS.LIG.F2.0F.W1 2A /r RM V/V AVX Convert one signed
VCVTSI2SD xmm,r/m32 quadword integer from
r/m64 to one double-
precision floating-point
value in xmm1.

But looking that up made me realize that I overlooked the sse2
instruction (silly, silly), which solves my problem, because I can use
that one instead of the avx instruction.

Thanks to all for your tips and hints.

P.S.: Still wondering though, why there isn't an avx in the flags.
--
aen
Bonita Montero
2020-08-10 16:18:17 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
But looking that up made me realize that I overlooked the sse2
instruction (silly, silly), which solves my problem, because I can use
that one instead of the avx instruction.
You don't have to replace "vcvtsi2sd xmm0,xmm0,rax" with something
else - it is already SSE2.
Bonita Montero
2020-08-10 16:34:13 UTC
Permalink
Post by Bonita Montero
You don't have to replace "vcvtsi2sd xmm0,xmm0,rax" with something
else - it is already SSE2.
Sorry, it's "... xmm0, rax" that is SSE2, not "... xmm0, xmm0, rax".
Bonita Montero
2020-08-10 18:24:51 UTC
Permalink
Post by Bonita Montero
Post by Bonita Montero
You don't have to replace "vcvtsi2sd xmm0,xmm0,rax" with something
else - it is already SSE2.
Sorry, it's "... xmm0, rax" that is SSE2, not "... xmm0, xmm0, rax".
But why has AVX this three-parameter-versions and the destination
parameter where the double is written to is the first parameter,
i.e. the second is ignored ?
a***@nospicedham.spamtrap.com
2020-08-10 20:02:09 UTC
Permalink
On Mon, 10 Aug 2020 20:24:51 +0200, Bonita Montero
<***@nospicedham.gmail.com> wrote:
...
Post by Bonita Montero
But why has AVX this three-parameter-versions and the destination
parameter where the double is written to is the first parameter,
i.e. the second is ignored ?
You can better see the value of the three-parameter versions in an
instruction like:

VADDSD xmm1,xmm2,xmm3

That adds xmm2 and xmm3 and puts the result into xmm1, but doesn't
change xmm2 (which is the point).

so instead of:

movsd xmm1,xmm2
addsd xmm1,xmm3

you can do it with just one instruction.
--
aen
Bonita Montero
2020-08-10 20:22:35 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
You can better see the value of the three-parameter versions in an
No, it's just more confusing.

Loading...