On Mon, Apr 03, 2023, Paolo Bonzini wrote: > Checking that instructions are absent is broken when running with CPU > models other than the bare metal processor's, because neither VMX nor SVM have > intercept controls for the instructions. > > This can even happen with "-cpu max" when running under nested > virtualization, which is the current situation in the Fedora KVM job > on Cirrus-CI: > > FAIL: clflushopt (ABSENT) > FAIL: clwb (ABSENT) > > In other words it looks like the features have been marked as disabled > in the L0 host, while the hardware supports them. > > Reported-by: Thomas Huth <thuth@xxxxxxxxxx> > Reviewed-by: Thomas Huth <thuth@xxxxxxxxxx> > Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx> > --- > x86/memory.c | 83 +++++++++++++++++++++++++++++++--------------------- > 1 file changed, 49 insertions(+), 34 deletions(-) > > diff --git a/x86/memory.c b/x86/memory.c > index 351e7c0..58ef835 100644 > --- a/x86/memory.c > +++ b/x86/memory.c > @@ -25,53 +25,68 @@ static void handle_ud(struct ex_regs *regs) > > int main(int ac, char **av) > { > - int expected; > - > handle_exception(UD_VECTOR, handle_ud); > > /* 3-byte instructions: */ > isize = 3; We can clean this up even further by utilizing TRY_ASM(). Though I think this is a good excuse to add things like asm_safe(), asm_safe_report(), and asm_safe_report_ex(), to cut down on the boilerplate even more. I'll send patches on top.