bksg2015
bksg2015

Reputation: 13

Undefined CPU instructions without execution cause bugs?

Now I try to dispatch codes dynamically, for example, SSE, AVX and so on. In a binary file, all codes which will be dispatched at the time of execution are bundled.

I worry that undefined CPU instructions in a code path which will not be executed in the CPU cause unintended behavior via speculative execution or others.

Then, I have two questions.

  1. Will CPU report error occurred in speculative execution usually?
  2. Do undefined CPU instructions without execution cause bugs?

Upvotes: 1

Views: 99

Answers (1)

Ondrej Tucny
Ondrej Tucny

Reputation: 27974

You are worrying too much. Speculative execution is called speculative because a CPU executes some code only if it thinks it's worth doing so, but can't assume the code won't cause any CPU exceptions. Machine code execution has a strict sequential, instruction-by-instruction, semantics, so the CPU cannot legitimately report issues from the (speculative) future in respect to the (logically) current instruction pointer.

Upvotes: 1

Related Questions