From patchwork Wed Feb 20 20:24:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Shier X-Patchwork-Id: 10822711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01FFF1399 for ; Wed, 20 Feb 2019 20:25:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E138D2E650 for ; Wed, 20 Feb 2019 20:25:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4D312E655; Wed, 20 Feb 2019 20:25:06 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 6F5362E650 for ; Wed, 20 Feb 2019 20:25:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726199AbfBTUZF (ORCPT ); Wed, 20 Feb 2019 15:25:05 -0500 Received: from mail-pl1-f202.google.com ([209.85.214.202]:56824 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726070AbfBTUZE (ORCPT ); Wed, 20 Feb 2019 15:25:04 -0500 Received: by mail-pl1-f202.google.com with SMTP id w17so18215831plp.23 for ; Wed, 20 Feb 2019 12:25:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=66D7gR2IfYSVU9lR0g007R00C67MjOipBfFW5+NiH8M=; b=HwP4ozEjvDAOdrTlOv5hV8kpICnxDZyIfWMWh+9a/QOEVGEwsyA5M/C0+ogFjcqdtg EOYYVhOmalQDFQypskp1+F6PHxt94FfRisiMSVR0g/8KgDCfJ8JgYLTZyyASO5yh0w8F Pvg7G/QWoIbgATY0k+aQsTfrDUzZ5FBbJHmgC78D7gf8yc4hZqt+MS/jB/4SNZg5j+yB lvbHrJHiQhr0e2W/hbD9/a2RntCddl62iC9iwWnN4cSIXzuUgv1UWWpx8krkiwDxGWEW /q2/CMhd2MBwFIlrQ+X/olAdeA5OoDqOz+Y1ERJ+18p3R5WlsrYCjSsrDVaLujcjQRbq iYBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=66D7gR2IfYSVU9lR0g007R00C67MjOipBfFW5+NiH8M=; b=dul1nMT9uCM2COjeqUyeW9Cf5pBTXxuMur87Lxg0atzLPUbFbEoVAO7FamsGY+l0vl zExJA4Etwh8MTiMop9UAy2qI7CAGmCR/SwetJ5BSkqZZxtoJuqyfUkVPknCEoqCDx16x 7tUDDziJsVTjPelcLfNXNAUTvLyLvBem2zqgzjLA61ESvhDdvULZEQLtU8u1ovp56VK4 7UUnMRNCM3nnG+D2bGNh9OGIi2JFvzAMEuOKMdAHDqVjt/NzzzjAoPKsasKrsbm9+cWi 0hjk0D2JR23v3PlAAsDBmCjkb512mtdWVhQhCgUWLuhOOcGitFmXMo4YTZmyLNhAvOow DkjQ== X-Gm-Message-State: AHQUAuYsf0TgCHvbnhuCuH3Zwpr35IgcAtA0NaZ66Ms2WTYT6EFnB0j1 TQBGTHZ/EiolX2nIt9M6F6ZeLYIQusir+cz5xp4Y98FK3PLem1tFp/FJz5lyHJ048/fvdq6GGd6 n4Gm0tVN1WcHf30ZQxx74+mo1NihZnk+W6fDKK3yXnvdl2SInpnrhWYkb6Q== X-Google-Smtp-Source: AHgI3IYR+JrGSMIT3TcRy+QDBHRu/R8a16E29Lpsd/RXx7H21RXxkky2DWPbp/HXp4Os8A5igPu8ADyTRT4= X-Received: by 2002:a65:6295:: with SMTP id f21mr13732387pgv.74.1550694304021; Wed, 20 Feb 2019 12:25:04 -0800 (PST) Date: Wed, 20 Feb 2019 12:24:42 -0800 Message-Id: <20190220202442.145494-1-pshier@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.21.0.rc0.258.g878e2cd30e-goog Subject: [PATCH kvm-unit-tests] Update AMD instructions to conform to LLVM assembler From: Peter Shier To: kvm@vger.kernel.org, drjones@redhat.com Cc: Peter Shier , Marc Orr , Jim Mattson Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The GNU assembler (gas) allows omitting operands where there is only a single choice e.g. "VMRUN rAX".The LLVM assembler requires those operands even though they are the default and only choice. In addition, LLVM does not allow a CLGI instruction with a terminating \n\t. Adding a ; separator after the instruction is a workaround. Signed-off-by: Peter Shier Reviewed-by: Marc Orr Reviewed-by: Jim Mattson --- x86/svm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/x86/svm.c b/x86/svm.c index bc74e7c690a8..e5cb730b08cb 100644 --- a/x86/svm.c +++ b/x86/svm.c @@ -154,7 +154,7 @@ static void vmcb_ident(struct vmcb *vmcb) struct descriptor_table_ptr desc_table_ptr; memset(vmcb, 0, sizeof(*vmcb)); - asm volatile ("vmsave" : : "a"(vmcb_phys) : "memory"); + asm volatile ("vmsave %0" : : "a"(vmcb_phys) : "memory"); vmcb_set_seg(&save->es, read_es(), 0, -1U, data_seg_attr); vmcb_set_seg(&save->cs, read_cs(), 0, -1U, code_seg_attr); vmcb_set_seg(&save->ss, read_ss(), 0, -1U, data_seg_attr); @@ -262,20 +262,20 @@ static void test_run(struct test *test, struct vmcb *vmcb) do { tsc_start = rdtsc(); asm volatile ( - "clgi \n\t" - "vmload \n\t" + "clgi;\n\t" // semi-colon needed for LLVM compatibility + "vmload %0\n\t" "mov regs+0x80, %%r15\n\t" // rflags "mov %%r15, 0x170(%0)\n\t" "mov regs, %%r15\n\t" // rax "mov %%r15, 0x1f8(%0)\n\t" LOAD_GPR_C - "vmrun \n\t" + "vmrun %0\n\t" SAVE_GPR_C "mov 0x170(%0), %%r15\n\t" // rflags "mov %%r15, regs+0x80\n\t" "mov 0x1f8(%0), %%r15\n\t" // rax "mov %%r15, regs\n\t" - "vmsave \n\t" + "vmsave %0\n\t" "stgi" : : "a"(vmcb_phys) : "rbx", "rcx", "rdx", "rsi", @@ -330,7 +330,7 @@ static bool check_no_vmrun_int(struct test *test) static void test_vmrun(struct test *test) { - asm volatile ("vmrun" : : "a"(virt_to_phys(test->vmcb))); + asm volatile ("vmrun %0" : : "a"(virt_to_phys(test->vmcb))); } static bool check_vmrun(struct test *test) @@ -1241,7 +1241,7 @@ static bool lat_svm_insn_finished(struct test *test) for ( ; runs != 0; runs--) { tsc_start = rdtsc(); - asm volatile("vmload\n\t" : : "a"(vmcb_phys) : "memory"); + asm volatile("vmload %0\n\t" : : "a"(vmcb_phys) : "memory"); cycles = rdtsc() - tsc_start; if (cycles > latvmload_max) latvmload_max = cycles; @@ -1250,7 +1250,7 @@ static bool lat_svm_insn_finished(struct test *test) vmload_sum += cycles; tsc_start = rdtsc(); - asm volatile("vmsave\n\t" : : "a"(vmcb_phys) : "memory"); + asm volatile("vmsave %0\n\t" : : "a"(vmcb_phys) : "memory"); cycles = rdtsc() - tsc_start; if (cycles > latvmsave_max) latvmsave_max = cycles;