mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
x86/emul: Fix emulation of RDSEED with older toolchains
This is reported as a MISRA R16.3 (missing break) violation, but turns out to be substantially more complicated than expected. In commita8fe4ec532("x86emul: support RDRAND/RDSEED"), the switch() statement had a default case going to cannot_emulate, with both the case 6 and case 7 labels being fully within #ifdef HAVE_GAS_RD{RAND,SEED}. Therefore, when the toolchain didn't understand the RDRAND/RDSEED instructions, attempts to emulate them suffered #UD. (In principle, this is a problem as there's no interlock to prevent RDRAND/RDSEED being advertised to the guest, but as instructions with only register encodings, they can only legitimately be emulated when VM Introspection is in use.) In commit58f1bba440("x86emul: support RDPID"), case 7 was taken outside of HAVE_GAS_RDSEED, meaning that emulating an RDSEED instruction no longer hit the default case when the toolchain was too old. Instead, it would fall out of the switch statement and be completed normally, behaving as a NOP to the guest. Retrofit a "return X86EMUL_UNIMPLEMENTED" in the case that the toolchain doesn't know the RDRAND instruction, matching how RDRAND work. Note that this has been fixed differently in Xen 4.21. Commit05bf9f1f0f("x86/emulate: Remove HAVE_AS_RDRAND and HAVE_AS_RDSEED") has removed the problematic condition due to the toolchain baseline upgrade. Fixes:58f1bba440("x86emul: support RDPID") Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
612cfd7215
commit
ddec00769c
1 file changed
+2
@@ -102,6 +102,8 @@ int x86emul_0fc7(struct x86_emulate_state *s,
|
||||
if ( carry )
|
||||
regs->eflags |= X86_EFLAGS_CF;
|
||||
break;
|
||||
#else
|
||||
return X86EMUL_UNIMPLEMENTED;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||