From patchwork Wed Mar 7 15:09:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= X-Patchwork-Id: 10264259 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D03FA6016D for ; Wed, 7 Mar 2018 15:10:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCAB229663 for ; Wed, 7 Mar 2018 15:10:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA88A29675; Wed, 7 Mar 2018 15:10:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.9 required=2.0 tests=BAYES_00,HK_RANDOM_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7866829663 for ; Wed, 7 Mar 2018 15:10:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754739AbeCGPKd (ORCPT ); Wed, 7 Mar 2018 10:10:33 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46400 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754608AbeCGPKb (ORCPT ); Wed, 7 Mar 2018 10:10:31 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B10E40704A3 for ; Wed, 7 Mar 2018 15:10:31 +0000 (UTC) Received: from flask (unknown [10.43.2.80]) by smtp.corp.redhat.com (Postfix) with SMTP id A29CD2026980; Wed, 7 Mar 2018 15:10:29 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Wed, 07 Mar 2018 16:09:51 +0100 From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= To: kvm@vger.kernel.org Cc: Paolo Bonzini Subject: [kvm-unit-tests PATCH v2] x86: prevent GCC from using sse* instructions Date: Wed, 7 Mar 2018 16:09:31 +0100 Message-Id: <20180307150931.15462-1-rkrcmar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Mar 2018 15:10:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Mar 2018 15:10:31 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'rkrcmar@redhat.com' RCPT:'' Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP GCC 8 emitted MOVDQU when compiling vmx.elf, but we do not enable CR4.OSFXSR in that test, so the instruction throws #UD. This patch forbids sse instructions, instead of enabling CR4.OSFXSR, as I think it's better to keep the environment minimal. Paolo suggested a way to keep sse around the function that uses it, allowing us to disable all sse instructions. Signed-off-by: Radim Krčmář Reviewed-by: Paolo Bonzini --- v2: add -mno-sse [Paolo] --- x86/Makefile.x86_64 | 2 +- x86/emulator.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64 index 623fc5b37726..af2f1dd8ce55 100644 --- a/x86/Makefile.x86_64 +++ b/x86/Makefile.x86_64 @@ -1,7 +1,7 @@ cstart.o = $(TEST_DIR)/cstart64.o bits = 64 ldarch = elf64-x86-64 -COMMON_CFLAGS += -mno-red-zone +COMMON_CFLAGS += -mno-red-zone -mno-sse -mno-sse2 cflatobjs += lib/x86/setjmp64.o cflatobjs += lib/x86/intel-iommu.o diff --git a/x86/emulator.c b/x86/emulator.c index e6f27cccd031..c74237fb1b23 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -652,7 +652,7 @@ static bool sseeq(sse_union *v1, sse_union *v2) return ok; } -static void test_sse(sse_union *mem) +static __attribute__((target("sse"))) void test_sse(sse_union *mem) { sse_union v;