From patchwork Tue Sep 1 08:50:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11747673 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF71D1575 for ; Tue, 1 Sep 2020 08:51:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3686205CB for ; Tue, 1 Sep 2020 08:51:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="cU+7RcpN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727935AbgIAIvK (ORCPT ); Tue, 1 Sep 2020 04:51:10 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:55006 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727089AbgIAIvI (ORCPT ); Tue, 1 Sep 2020 04:51:08 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 0399C5732F; Tue, 1 Sep 2020 08:51:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received; s=mta-01; t= 1598950264; x=1600764665; bh=+2lWsZX/gRrm4AzavLRxhHDoo/GY5h4wfKb /Xw6NKbk=; b=cU+7RcpNN+qY1FvsZYK6AxU1pJZG0ppxa/L4u5lD87zb5H+Hizu 4oddiUyMThGy149T9C23A767BeBOga41zmjt54tHSOaGh0b6lpm9yv6FvjtrFUhf Vxc+4TWW/I/TMFs7OPEWrRgAkQIDICl8cCTtDNQ2lXPV345l0xNRTuSI= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x2t1_GzJ4rV9; Tue, 1 Sep 2020 11:51:04 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 7ED2252215; Tue, 1 Sep 2020 11:51:04 +0300 (MSK) Received: from localhost (172.17.204.212) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Tue, 1 Sep 2020 11:51:04 +0300 From: Roman Bolshakov To: CC: Thomas Huth , Paolo Bonzini , Roman Bolshakov , Cameron Esfahani Subject: [kvm-unit-tests PATCH v2 01/10] x86: Makefile: Allow division on x86_64-elf binutils Date: Tue, 1 Sep 2020 11:50:47 +0300 Message-ID: <20200901085056.33391-2-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901085056.33391-1-r.bolshakov@yadro.com> References: <20200901085056.33391-1-r.bolshakov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [172.17.204.212] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org For compatibility with other SVR4 assemblers, '/' starts a comment on *-elf binutils target and thus division operator is not allowed [1][2]. That breaks cstart64.S build: x86/cstart64.S: Assembler messages: x86/cstart64.S:294: Error: unbalanced parenthesis in operand 1. configure should detect if --divide needs to be passed to assembler by compiling a small snippet where division is used inside parentheses. 1. https://sourceware.org/binutils/docs/as/i386_002dChars.html 2. https://sourceware.org/binutils/docs/as/i386_002dOptions.html#index-_002d_002ddivide-option_002c-i386 Cc: Cameron Esfahani Signed-off-by: Roman Bolshakov Reviewed-by: Thomas Huth --- configure | 12 ++++++++++++ x86/Makefile.common | 3 +++ 2 files changed, 15 insertions(+) diff --git a/configure b/configure index f9d030f..4eb504f 100755 --- a/configure +++ b/configure @@ -15,6 +15,7 @@ endian="" pretty_print_stacks=yes environ_default=yes u32_long= +wa_divide= vmm="qemu" errata_force=0 erratatxt="$srcdir/errata.txt" @@ -156,6 +157,16 @@ EOF u32_long=$("$cross_prefix$cc" -E lib-test.c | grep -v '^#' | grep -q long && echo yes) rm -f lib-test.c +# check if slash can be used for division +if [ "$arch" = "i386" ] || [ "$arch" = "x86_64" ]; then + cat << EOF > lib-test.S +foo: + movl (8 / 2), %eax +EOF + wa_divide=$("$cross_prefix$cc" -c lib-test.S >/dev/null 2>&1 || echo yes) + rm -f lib-test.{o,S} +fi + # Are we in a separate build tree? If so, link the Makefile # and shared stuff so that 'make' and run_tests.sh work. if test ! -e Makefile; then @@ -205,6 +216,7 @@ PRETTY_PRINT_STACKS=$pretty_print_stacks ENVIRON_DEFAULT=$environ_default ERRATATXT=$erratatxt U32_LONG_FMT=$u32_long +WA_DIVIDE=$wa_divide EOF cat < lib/config.h diff --git a/x86/Makefile.common b/x86/Makefile.common index 2ea9c9f..c3f7dc4 100644 --- a/x86/Makefile.common +++ b/x86/Makefile.common @@ -29,6 +29,9 @@ $(libcflat): LDFLAGS += -nostdlib $(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib COMMON_CFLAGS += -m$(bits) +ifneq ($(WA_DIVIDE),) +COMMON_CFLAGS += -Wa,--divide +endif COMMON_CFLAGS += -O1 # stack.o relies on frame pointers. From patchwork Tue Sep 1 08:50:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11747679 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFF08109B for ; Tue, 1 Sep 2020 08:51:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A710E20866 for ; Tue, 1 Sep 2020 08:51:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="b12VXjEo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727984AbgIAIvP (ORCPT ); Tue, 1 Sep 2020 04:51:15 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:55022 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727824AbgIAIvK (ORCPT ); Tue, 1 Sep 2020 04:51:10 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 3F610574EF; Tue, 1 Sep 2020 08:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received; s=mta-01; t= 1598950265; x=1600764666; bh=1UjTiYX6af8NytUxqP3QbMZW0l+4vplX4tl p1B5XtAQ=; b=b12VXjEoPzcIHXn30OLwxtxT9rFMZIl40kTTFxYz74qBr7KZRD3 eC7L5nGd8Lg9BoBZZBGP3Py22BE6r0Sy2AGLgYvTaMKVCG1hH8bUGouNGpAMXZ10 2ylaD+rdue6jA5L34TTaG5o8UnrisM7QYYUWhOMU2t23axSh1D1Ds0f0= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NSxvOgSibVvP; Tue, 1 Sep 2020 11:51:05 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 08F5E57315; Tue, 1 Sep 2020 11:51:05 +0300 (MSK) Received: from localhost (172.17.204.212) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Tue, 1 Sep 2020 11:51:04 +0300 From: Roman Bolshakov To: CC: Thomas Huth , Paolo Bonzini , Roman Bolshakov , Cameron Esfahani Subject: [kvm-unit-tests PATCH v2 02/10] x86: Replace instruction prefixes with spaces Date: Tue, 1 Sep 2020 11:50:48 +0300 Message-ID: <20200901085056.33391-3-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901085056.33391-1-r.bolshakov@yadro.com> References: <20200901085056.33391-1-r.bolshakov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [172.17.204.212] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org There are three kinds of x86 prefix delimiters in GNU binutils: '/', '\\' and a space. The first works on Linux and few other platforms. The second one is SVR-4 compatible and works on the generic elf target. The last kind is universal and works everywhere, it's also used in the GAS manual [1]. Space delimiters fix the build errors on x86_64-elf binutils: x86/cstart64.S:217: Error: invalid character '/' in mnemonic x86/cstart64.S:313: Error: invalid character '/' in mnemonic 1. https://sourceware.org/binutils/docs/as/i386_002dPrefixes.html Cc: Cameron Esfahani Reviewed-by: Thomas Huth Signed-off-by: Roman Bolshakov --- x86/cstart.S | 4 ++-- x86/cstart64.S | 4 ++-- x86/emulator.c | 38 +++++++++++++++++++------------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/x86/cstart.S b/x86/cstart.S index c0efc5f..489c561 100644 --- a/x86/cstart.S +++ b/x86/cstart.S @@ -149,7 +149,7 @@ save_id: ap_start32: setup_segments mov $-4096, %esp - lock/xaddl %esp, smp_stacktop + lock xaddl %esp, smp_stacktop setup_percpu_area call prepare_32 call reset_apic @@ -206,7 +206,7 @@ ap_init: lea sipi_entry, %esi xor %edi, %edi mov $(sipi_end - sipi_entry), %ecx - rep/movsb + rep movsb mov $APIC_DEFAULT_PHYS_BASE, %eax movl $(APIC_DEST_ALLBUT | APIC_DEST_PHYSICAL | APIC_DM_INIT | APIC_INT_ASSERT), APIC_ICR(%eax) movl $(APIC_DEST_ALLBUT | APIC_DEST_PHYSICAL | APIC_DM_STARTUP), APIC_ICR(%eax) diff --git a/x86/cstart64.S b/x86/cstart64.S index 2d16688..25a296c 100644 --- a/x86/cstart64.S +++ b/x86/cstart64.S @@ -226,7 +226,7 @@ sipi_end: ap_start32: setup_segments mov $-4096, %esp - lock/xaddl %esp, smp_stacktop + lock xaddl %esp, smp_stacktop setup_percpu_area call prepare_64 ljmpl $8, $ap_start64 @@ -323,7 +323,7 @@ ap_init: lea sipi_entry, %rsi xor %rdi, %rdi mov $(sipi_end - sipi_entry), %rcx - rep/movsb + rep movsb mov $APIC_DEFAULT_PHYS_BASE, %eax movl $(APIC_DEST_ALLBUT | APIC_DEST_PHYSICAL | APIC_DM_INIT | APIC_INT_ASSERT), APIC_ICR(%rax) movl $(APIC_DEST_ALLBUT | APIC_DEST_PHYSICAL | APIC_DM_STARTUP), APIC_ICR(%rax) diff --git a/x86/emulator.c b/x86/emulator.c index 98743d1..e46d97e 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -61,71 +61,71 @@ static void test_cmps_one(unsigned char *m1, unsigned char *m3) rsi = m1; rdi = m3; rcx = 30; asm volatile("xor %[tmp], %[tmp] \n\t" - "repe/cmpsb" + "repe cmpsb" : "+S"(rsi), "+D"(rdi), "+c"(rcx), [tmp]"=&r"(tmp) : : "cc"); report(rcx == 0 && rsi == m1 + 30 && rdi == m3 + 30, "repe/cmpsb (1)"); rsi = m1; rdi = m3; rcx = 30; asm volatile("or $1, %[tmp]\n\t" // clear ZF - "repe/cmpsb" + "repe cmpsb" : "+S"(rsi), "+D"(rdi), "+c"(rcx), [tmp]"=&r"(tmp) : : "cc"); report(rcx == 0 && rsi == m1 + 30 && rdi == m3 + 30, - "repe/cmpsb (1.zf)"); + "repe cmpsb (1.zf)"); rsi = m1; rdi = m3; rcx = 15; asm volatile("xor %[tmp], %[tmp] \n\t" - "repe/cmpsw" + "repe cmpsw" : "+S"(rsi), "+D"(rdi), "+c"(rcx), [tmp]"=&r"(tmp) : : "cc"); - report(rcx == 0 && rsi == m1 + 30 && rdi == m3 + 30, "repe/cmpsw (1)"); + report(rcx == 0 && rsi == m1 + 30 && rdi == m3 + 30, "repe cmpsw (1)"); rsi = m1; rdi = m3; rcx = 7; asm volatile("xor %[tmp], %[tmp] \n\t" - "repe/cmpsl" + "repe cmpsl" : "+S"(rsi), "+D"(rdi), "+c"(rcx), [tmp]"=&r"(tmp) : : "cc"); - report(rcx == 0 && rsi == m1 + 28 && rdi == m3 + 28, "repe/cmpll (1)"); + report(rcx == 0 && rsi == m1 + 28 && rdi == m3 + 28, "repe cmpll (1)"); rsi = m1; rdi = m3; rcx = 4; asm volatile("xor %[tmp], %[tmp] \n\t" - "repe/cmpsq" + "repe cmpsq" : "+S"(rsi), "+D"(rdi), "+c"(rcx), [tmp]"=&r"(tmp) : : "cc"); - report(rcx == 0 && rsi == m1 + 32 && rdi == m3 + 32, "repe/cmpsq (1)"); + report(rcx == 0 && rsi == m1 + 32 && rdi == m3 + 32, "repe cmpsq (1)"); rsi = m1; rdi = m3; rcx = 130; asm volatile("xor %[tmp], %[tmp] \n\t" - "repe/cmpsb" + "repe cmpsb" : "+S"(rsi), "+D"(rdi), "+c"(rcx), [tmp]"=&r"(tmp) : : "cc"); report(rcx == 29 && rsi == m1 + 101 && rdi == m3 + 101, - "repe/cmpsb (2)"); + "repe cmpsb (2)"); rsi = m1; rdi = m3; rcx = 65; asm volatile("xor %[tmp], %[tmp] \n\t" - "repe/cmpsw" + "repe cmpsw" : "+S"(rsi), "+D"(rdi), "+c"(rcx), [tmp]"=&r"(tmp) : : "cc"); report(rcx == 14 && rsi == m1 + 102 && rdi == m3 + 102, - "repe/cmpsw (2)"); + "repe cmpsw (2)"); rsi = m1; rdi = m3; rcx = 32; asm volatile("xor %[tmp], %[tmp] \n\t" - "repe/cmpsl" + "repe cmpsl" : "+S"(rsi), "+D"(rdi), "+c"(rcx), [tmp]"=&r"(tmp) : : "cc"); report(rcx == 6 && rsi == m1 + 104 && rdi == m3 + 104, - "repe/cmpll (2)"); + "repe cmpll (2)"); rsi = m1; rdi = m3; rcx = 16; asm volatile("xor %[tmp], %[tmp] \n\t" - "repe/cmpsq" + "repe cmpsq" : "+S"(rsi), "+D"(rdi), "+c"(rcx), [tmp]"=&r"(tmp) : : "cc"); report(rcx == 3 && rsi == m1 + 104 && rdi == m3 + 104, - "repe/cmpsq (2)"); + "repe cmpsq (2)"); } @@ -304,8 +304,8 @@ static void test_ljmp(void *mem) volatile int res = 1; *(unsigned long**)m = &&jmpf; - asm volatile ("data16/mov %%cs, %0":"=m"(*(m + sizeof(unsigned long)))); - asm volatile ("rex64/ljmp *%0"::"m"(*m)); + asm volatile ("data16 mov %%cs, %0":"=m"(*(m + sizeof(unsigned long)))); + asm volatile ("rex64 ljmp *%0"::"m"(*m)); res = 0; jmpf: report(res, "ljmp"); From patchwork Tue Sep 1 08:50:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11747681 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3199A1575 for ; Tue, 1 Sep 2020 08:51:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A3932098B for ; Tue, 1 Sep 2020 08:51:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="ba6s41vq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728015AbgIAIvQ (ORCPT ); Tue, 1 Sep 2020 04:51:16 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:55028 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727884AbgIAIvJ (ORCPT ); Tue, 1 Sep 2020 04:51:09 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 7333057315; Tue, 1 Sep 2020 08:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received; s=mta-01; t= 1598950266; x=1600764667; bh=PlSUgFRbJ9yRAz8gWhFmmI1rwJfRoe0zbIY vZ0vfBZk=; b=ba6s41vqfVbtIsVjfiGF+ZAjRAdDhfOAOum6B3CerRNgVxEYr87 FtB0HSFAld91mnSUtJ1KTKvV5oh4Y7fYOG613UaKB5EXs65iFgNf0I2Bp1AGLVaE vMjTQYLP+/W5kL9+UW2Xvj6ZVDogfxtVOWoVOMpzaTab5ZUBK1Gn/g3Y= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1Poy6571b0eB; Tue, 1 Sep 2020 11:51:06 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 8892F5141E; Tue, 1 Sep 2020 11:51:05 +0300 (MSK) Received: from localhost (172.17.204.212) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Tue, 1 Sep 2020 11:51:05 +0300 From: Roman Bolshakov To: CC: Thomas Huth , Paolo Bonzini , Roman Bolshakov , Cameron Esfahani Subject: [kvm-unit-tests PATCH v2 03/10] x86: Makefile: Fix linkage of realmode on x86_64-elf binutils Date: Tue, 1 Sep 2020 11:50:49 +0300 Message-ID: <20200901085056.33391-4-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901085056.33391-1-r.bolshakov@yadro.com> References: <20200901085056.33391-1-r.bolshakov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [172.17.204.212] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org link spec [1][2] is empty on x86_64-elf-gcc, i.e. -m32 is not propogated to the linker as "-m elf_i386" and that causes the error: /usr/local/opt/x86_64-elf-binutils/bin/x86_64-elf-ld: i386 architecture of input file `x86/realmode.o' is incompatible with i386:x86-64 output 1. https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html 2. https://gcc.gnu.org/onlinedocs/gccint/Driver.html Cc: Cameron Esfahani Reviewed-by: Thomas Huth Signed-off-by: Roman Bolshakov --- x86/Makefile.common | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x86/Makefile.common b/x86/Makefile.common index c3f7dc4..090ce22 100644 --- a/x86/Makefile.common +++ b/x86/Makefile.common @@ -69,7 +69,8 @@ test_cases: $(tests-common) $(tests) $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/x86 -I lib $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o - $(CC) -m32 -nostdlib -o $@ -Wl,-T,$(SRCDIR)/$(TEST_DIR)/realmode.lds $^ + $(CC) -m32 -nostdlib -o $@ -Wl,-m,elf_i386 \ + -Wl,-T,$(SRCDIR)/$(TEST_DIR)/realmode.lds $^ $(TEST_DIR)/realmode.o: bits = 32 From patchwork Tue Sep 1 08:50:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11747677 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB8D81575 for ; Tue, 1 Sep 2020 08:51:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C09620866 for ; Tue, 1 Sep 2020 08:51:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="YWiBE6Vx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727962AbgIAIvO (ORCPT ); Tue, 1 Sep 2020 04:51:14 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:55040 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727929AbgIAIvK (ORCPT ); Tue, 1 Sep 2020 04:51:10 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 8BCC5574F5; Tue, 1 Sep 2020 08:51:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received; s=mta-01; t= 1598950267; x=1600764668; bh=Ae7UJwA1NRF9KGinIXmBf8CXArSPiyN6yGl /zL36On4=; b=YWiBE6Vx1wu4nENeYSvVRVRzY/PH2abm0F7O8T7cQnEBCHUkol9 +jzaFQafRRRyI4WNRctSBl/A88xBZdo5pjlGOUwG1vPdrFGa88Hmb3iYRXiRVD8C X4dsWvSR4yg+3s7nDIkNavbIg88iWZVK6b+U853uwNaFfYl2004XqytA= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HFe4r6d0F_Wc; Tue, 1 Sep 2020 11:51:07 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 0C17852215; Tue, 1 Sep 2020 11:51:06 +0300 (MSK) Received: from localhost (172.17.204.212) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Tue, 1 Sep 2020 11:51:06 +0300 From: Roman Bolshakov To: CC: Thomas Huth , Paolo Bonzini , Roman Bolshakov , Jim Mattson , Peter Shier , Cameron Esfahani Subject: [kvm-unit-tests PATCH v2 04/10] lib: Bundle debugreg.h from the kernel Date: Tue, 1 Sep 2020 11:50:50 +0300 Message-ID: <20200901085056.33391-5-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901085056.33391-1-r.bolshakov@yadro.com> References: <20200901085056.33391-1-r.bolshakov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [172.17.204.212] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org x86/vmx_tests.c depends on the kernel header and can't be compiled otherwise on x86_64-elf gcc on macOS. Cc: Jim Mattson Cc: Peter Shier Cc: Paolo Bonzini Cc: Cameron Esfahani Reviewed-by: Thomas Huth Signed-off-by: Roman Bolshakov --- lib/x86/asm/debugreg.h | 81 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 lib/x86/asm/debugreg.h diff --git a/lib/x86/asm/debugreg.h b/lib/x86/asm/debugreg.h new file mode 100644 index 0000000..d95d080 --- /dev/null +++ b/lib/x86/asm/debugreg.h @@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_ASM_X86_DEBUGREG_H +#define _UAPI_ASM_X86_DEBUGREG_H + + +/* Indicate the register numbers for a number of the specific + debug registers. Registers 0-3 contain the addresses we wish to trap on */ +#define DR_FIRSTADDR 0 /* u_debugreg[DR_FIRSTADDR] */ +#define DR_LASTADDR 3 /* u_debugreg[DR_LASTADDR] */ + +#define DR_STATUS 6 /* u_debugreg[DR_STATUS] */ +#define DR_CONTROL 7 /* u_debugreg[DR_CONTROL] */ + +/* Define a few things for the status register. We can use this to determine + which debugging register was responsible for the trap. The other bits + are either reserved or not of interest to us. */ + +/* Define reserved bits in DR6 which are always set to 1 */ +#define DR6_RESERVED (0xFFFF0FF0) + +#define DR_TRAP0 (0x1) /* db0 */ +#define DR_TRAP1 (0x2) /* db1 */ +#define DR_TRAP2 (0x4) /* db2 */ +#define DR_TRAP3 (0x8) /* db3 */ +#define DR_TRAP_BITS (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3) + +#define DR_STEP (0x4000) /* single-step */ +#define DR_SWITCH (0x8000) /* task switch */ + +/* Now define a bunch of things for manipulating the control register. + The top two bytes of the control register consist of 4 fields of 4 + bits - each field corresponds to one of the four debug registers, + and indicates what types of access we trap on, and how large the data + field is that we are looking at */ + +#define DR_CONTROL_SHIFT 16 /* Skip this many bits in ctl register */ +#define DR_CONTROL_SIZE 4 /* 4 control bits per register */ + +#define DR_RW_EXECUTE (0x0) /* Settings for the access types to trap on */ +#define DR_RW_WRITE (0x1) +#define DR_RW_READ (0x3) + +#define DR_LEN_1 (0x0) /* Settings for data length to trap on */ +#define DR_LEN_2 (0x4) +#define DR_LEN_4 (0xC) +#define DR_LEN_8 (0x8) + +/* The low byte to the control register determine which registers are + enabled. There are 4 fields of two bits. One bit is "local", meaning + that the processor will reset the bit after a task switch and the other + is global meaning that we have to explicitly reset the bit. With linux, + you can use either one, since we explicitly zero the register when we enter + kernel mode. */ + +#define DR_LOCAL_ENABLE_SHIFT 0 /* Extra shift to the local enable bit */ +#define DR_GLOBAL_ENABLE_SHIFT 1 /* Extra shift to the global enable bit */ +#define DR_LOCAL_ENABLE (0x1) /* Local enable for reg 0 */ +#define DR_GLOBAL_ENABLE (0x2) /* Global enable for reg 0 */ +#define DR_ENABLE_SIZE 2 /* 2 enable bits per register */ + +#define DR_LOCAL_ENABLE_MASK (0x55) /* Set local bits for all 4 regs */ +#define DR_GLOBAL_ENABLE_MASK (0xAA) /* Set global bits for all 4 regs */ + +/* The second byte to the control register has a few special things. + We can slow the instruction pipeline for instructions coming via the + gdt or the ldt if we want to. I am not sure why this is an advantage */ + +#ifdef __i386__ +#define DR_CONTROL_RESERVED (0xFC00) /* Reserved by Intel */ +#else +#define DR_CONTROL_RESERVED (0xFFFFFFFF0000FC00UL) /* Reserved */ +#endif + +#define DR_LOCAL_SLOWDOWN (0x100) /* Local slow the pipeline */ +#define DR_GLOBAL_SLOWDOWN (0x200) /* Global slow the pipeline */ + +/* + * HW breakpoint additions + */ + +#endif /* _UAPI_ASM_X86_DEBUGREG_H */ From patchwork Tue Sep 1 08:50:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11747683 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C733A1667 for ; Tue, 1 Sep 2020 08:51:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ACFD92098B for ; Tue, 1 Sep 2020 08:51:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="i0YD9MXb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728019AbgIAIvR (ORCPT ); Tue, 1 Sep 2020 04:51:17 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:55048 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727930AbgIAIvL (ORCPT ); Tue, 1 Sep 2020 04:51:11 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id B2DDC52215; Tue, 1 Sep 2020 08:51:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received; s=mta-01; t= 1598950267; x=1600764668; bh=ZmM9ZWKttDorIzOM/FDHNNVOBMf5H7JT8Wp NGiTYJnQ=; b=i0YD9MXbb4jANEeie5XRcA4BnH1vbqREY1VGWTgIvczgg6yu/MG FN6qa4ezeBOiymLL5erKQeijhiaXuJFzdhS4DQOa5ydJ3RoxeFr1DlsVR7zNb6As o8k7UKiXzgrEushzPSCSjbxzlY7mV3HjW6mwpFd5u2HYU9JI82MKi8DI= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pJ1UgbhxzZ6c; Tue, 1 Sep 2020 11:51:07 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 8CA425725D; Tue, 1 Sep 2020 11:51:06 +0300 (MSK) Received: from localhost (172.17.204.212) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Tue, 1 Sep 2020 11:51:06 +0300 From: Roman Bolshakov To: CC: Thomas Huth , Paolo Bonzini , Roman Bolshakov , =?utf-8?q?Alex_Benn=C3=A9e?= , Andrew Jones , Cameron Esfahani , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= Subject: [kvm-unit-tests PATCH v2 05/10] lib: x86: Use portable format macros for uint32_t Date: Tue, 1 Sep 2020 11:50:51 +0300 Message-ID: <20200901085056.33391-6-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901085056.33391-1-r.bolshakov@yadro.com> References: <20200901085056.33391-1-r.bolshakov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [172.17.204.212] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Compilation of the files fails on ARCH=i386 with i686-elf gcc because they use "%x" or "%d" format specifier that does not match the actual size of uint32_t: x86/s3.c: In function ‘main’: x86/s3.c:53:35: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘u32’ {aka ‘long unsigned int’} [-Werror=format=] 53 | printf("PM1a event registers at %x\n", fadt->pm1a_evt_blk); | ~^ ~~~~~~~~~~~~~~~~~~ | | | | | u32 {aka long unsigned int} | unsigned int | %lx Use PRIx32 instead of "x" and PRId32 instead of "d" to take into account u32_long case. Cc: Alex Bennée Cc: Andrew Jones Cc: Cameron Esfahani Cc: Radim Krčmář Signed-off-by: Roman Bolshakov Reviewed-by: Thomas Huth --- lib/pci.c | 2 +- x86/asyncpf.c | 2 +- x86/msr.c | 3 ++- x86/s3.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pci.c b/lib/pci.c index daa33e1..175caf0 100644 --- a/lib/pci.c +++ b/lib/pci.c @@ -248,7 +248,7 @@ void pci_bar_print(struct pci_dev *dev, int bar_num) printf("BAR#%d,%d [%" PRIx64 "-%" PRIx64 " ", bar_num, bar_num + 1, start, end); } else { - printf("BAR#%d [%02x-%02x ", + printf("BAR#%d [%02" PRIx32 "-%02" PRIx32 " ", bar_num, (uint32_t)start, (uint32_t)end); } diff --git a/x86/asyncpf.c b/x86/asyncpf.c index 305a923..8239e16 100644 --- a/x86/asyncpf.c +++ b/x86/asyncpf.c @@ -78,7 +78,7 @@ static void pf_isr(struct ex_regs *r) phys = 0; break; default: - report(false, "unexpected async pf reason %d", reason); + report(false, "unexpected async pf reason %" PRId32, reason); break; } } diff --git a/x86/msr.c b/x86/msr.c index f7539c3..ce5dabe 100644 --- a/x86/msr.c +++ b/x86/msr.c @@ -89,7 +89,8 @@ static void test_msr_rw(int msr_index, unsigned long long input, unsigned long l wrmsr(msr_index, input); r = rdmsr(msr_index); if (expected != r) { - printf("testing %s: output = %#x:%#x expected = %#x:%#x\n", sptr, + printf("testing %s: output = %#" PRIx32 ":%#" PRIx32 + " expected = %#" PRIx32 ":%#" PRIx32 "\n", sptr, (u32)(r >> 32), (u32)r, (u32)(expected >> 32), (u32)expected); } report(expected == r, "%s", sptr); diff --git a/x86/s3.c b/x86/s3.c index da2d00c..6e41d0c 100644 --- a/x86/s3.c +++ b/x86/s3.c @@ -50,7 +50,7 @@ int main(int argc, char **argv) *resume_vec++ = *addr; printf("copy resume code from %p\n", &resume_start); - printf("PM1a event registers at %x\n", fadt->pm1a_evt_blk); + printf("PM1a event registers at %" PRIx32 "\n", fadt->pm1a_evt_blk); outw(0x400, fadt->pm1a_evt_blk + 2); /* Setup RTC alarm to wake up on the next second. */ From patchwork Tue Sep 1 08:50:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11747685 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 693FE109B for ; Tue, 1 Sep 2020 08:51:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F4622098B for ; Tue, 1 Sep 2020 08:51:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="No4UZgH4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728035AbgIAIvS (ORCPT ); Tue, 1 Sep 2020 04:51:18 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:55054 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727089AbgIAIvL (ORCPT ); Tue, 1 Sep 2020 04:51:11 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id C392652195; Tue, 1 Sep 2020 08:51:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received; s=mta-01; t= 1598950268; x=1600764669; bh=BNBYuBfEPgv86IqOtJm1CBAiXwwqlis6GlD TxXzfZWs=; b=No4UZgH4vXgdMFVGEy33lZO6AsZ0lvBsDBGqQ4IIi2wrUpdzlBb jZPRc3yU+yTNVQ6TZhYOBwrTyZPlNof2/75BprBRvVgi3YtsaMJjJLREGsHuLL4D BncUoQ2rlZKE1p+E6hQya6cxYtXyChcXTCm1ZGKd2UK5QFNaAVJs/0QQ= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RaOKKxQkWjJO; Tue, 1 Sep 2020 11:51:08 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 1EE0E574EC; Tue, 1 Sep 2020 11:51:07 +0300 (MSK) Received: from localhost (172.17.204.212) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Tue, 1 Sep 2020 11:51:07 +0300 From: Roman Bolshakov To: CC: Thomas Huth , Paolo Bonzini , Roman Bolshakov , Cameron Esfahani Subject: [kvm-unit-tests PATCH v2 06/10] configure: Add an option to specify getopt Date: Tue, 1 Sep 2020 11:50:52 +0300 Message-ID: <20200901085056.33391-7-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901085056.33391-1-r.bolshakov@yadro.com> References: <20200901085056.33391-1-r.bolshakov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [172.17.204.212] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org macOS is shipped with an old non-enhanced version of getopt and it doesn't support options used by run_tests.sh. Proper version of getopt is available from homebrew but it has to be added to PATH before invoking run_tests.sh. It's not convenient because it has to be done in each shell instance and there could be many if a multiplexor is used. The change provides a way to override getopt and halts ./configure if enhanced getopt can't be found. Cc: Cameron Esfahani Signed-off-by: Roman Bolshakov Reviewed-by: Thomas Huth --- configure | 13 +++++++++++++ run_tests.sh | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 4eb504f..b85420b 100755 --- a/configure +++ b/configure @@ -8,6 +8,7 @@ objcopy=objcopy objdump=objdump ar=ar addr2line=addr2line +getopt=getopt arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/'` host=$arch cross_prefix= @@ -32,6 +33,7 @@ usage() { --cross-prefix=PREFIX cross compiler prefix --cc=CC c compiler to use ($cc) --ld=LD ld linker to use ($ld) + --getopt=GETOPT enhanced getopt to use ($getopt) --prefix=PREFIX where to install things ($prefix) --endian=ENDIAN endianness to compile for (little or big, ppc64 only) --[enable|disable]-pretty-print-stacks @@ -77,6 +79,9 @@ while [[ "$1" = -* ]]; do --ld) ld="$arg" ;; + --getopt) + getopt="$arg" + ;; --enable-pretty-print-stacks) pretty_print_stacks=yes ;; @@ -167,6 +172,13 @@ EOF rm -f lib-test.{o,S} fi +# require enhanced getopt +$getopt -T > /dev/null +if [ $? -ne 4 ]; then + echo "Enchanced getopt is not available" + exit 1 +fi + # Are we in a separate build tree? If so, link the Makefile # and shared stuff so that 'make' and run_tests.sh work. if test ! -e Makefile; then @@ -209,6 +221,7 @@ OBJCOPY=$cross_prefix$objcopy OBJDUMP=$cross_prefix$objdump AR=$cross_prefix$ar ADDR2LINE=$cross_prefix$addr2line +GETOPT=$getopt TEST_DIR=$testdir FIRMWARE=$firmware ENDIAN=$endian diff --git a/run_tests.sh b/run_tests.sh index 01e36dc..c4f436b 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -35,7 +35,7 @@ RUNTIME_arch_run="./$TEST_DIR/run" source scripts/runtime.bash only_tests="" -args=`getopt -u -o ag:htj:v -l all,group:,help,tap13,parallel:,verbose -- $*` +args=`$GETOPT -u -o ag:htj:v -l all,group:,help,tap13,parallel:,verbose -- $*` [ $? -ne 0 ] && exit 2; set -- $args; while [ $# -gt 0 ]; do From patchwork Tue Sep 1 08:50:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11747693 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E629109B for ; Tue, 1 Sep 2020 08:51:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6758320866 for ; Tue, 1 Sep 2020 08:51:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="Jc+Z5JYz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727997AbgIAIvk (ORCPT ); Tue, 1 Sep 2020 04:51:40 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:55060 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726102AbgIAIvM (ORCPT ); Tue, 1 Sep 2020 04:51:12 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 655C7574EC; Tue, 1 Sep 2020 08:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received; s=mta-01; t= 1598950268; x=1600764669; bh=/ry0efbsvzQsEkUgKcgBXyG0N52ntDqNyeV 1RVrvvUM=; b=Jc+Z5JYzsY+sOhTgGQHqGZD+nRFSd9h9MrfRK+UxcUoHIiCttJW 2IDeSVyDnynnAoqLy0dhrR4NumCT8mX6kCpicTeCjQkDQOmID0FAtdR2scly+bQl Z75tvomCW0a/Ed+AU3bqriMJ8M01sz/xpfxTdWFtuHQp272q89fytHvU= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M1vn-TP2delL; Tue, 1 Sep 2020 11:51:08 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id B5222574E8; Tue, 1 Sep 2020 11:51:07 +0300 (MSK) Received: from localhost (172.17.204.212) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Tue, 1 Sep 2020 11:51:07 +0300 From: Roman Bolshakov To: CC: Thomas Huth , Paolo Bonzini , Roman Bolshakov , Cameron Esfahani Subject: [kvm-unit-tests PATCH v2 07/10] README: Update build instructions for macOS Date: Tue, 1 Sep 2020 11:50:53 +0300 Message-ID: <20200901085056.33391-8-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901085056.33391-1-r.bolshakov@yadro.com> References: <20200901085056.33391-1-r.bolshakov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [172.17.204.212] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Pre-built cross-compilers for x86 are available in homebrew and can be used to build the tests. Cc: Cameron Esfahani Signed-off-by: Roman Bolshakov --- README.macOS.md | 71 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/README.macOS.md b/README.macOS.md index de46d5f..4ca5a57 100644 --- a/README.macOS.md +++ b/README.macOS.md @@ -1,14 +1,54 @@ # kvm-unit-tests on macOS -Cross-compiler with ELF support is required for build of kvm-unit-tests on -macOS. +The tests can be used to validate TCG or HVF accel on macOS. -## Building cross-compiler from source +## Prerequisites -A cross-compiler toolchain can be built from source using crosstool-ng. The -latest released version of +GNU getopt and coreutils should be installed prior to building and running the +tests. They're available in [homebrew](https://brew.sh): +``` +$ brew install coreutils +$ brew install gnu-getopt +``` + +A cross-compiler with ELF support is required to build kvm-unit-tests on macOS. + +### Pre-built cross-compiler + +Binary packages of ELF cross-compilers for i386 and x86_64 target can be +installed from homebrew: +``` +$ brew install i686-elf-gcc +$ brew install x86_64-elf-gcc +``` + +32-bit x86 tests can be built like that: +``` +$ ./configure \ + --getopt=/usr/local/opt/gnu-getopt/bin/getopt \ + --arch=i386 \ + --cross-prefix=i686-elf- +$ make -j $(nproc) +``` + +64-bit x86 tests can be built likewise: +``` +$ ./configure \ + --getopt=/usr/local/opt/gnu-getopt/bin/getopt \ + --arch=x86_64 \ + --cross-prefix=x86_64-elf- +$ make -j $(nproc) +``` + +Out-of-tree build can be used to make tests for both architectures +simultaneously in separate build directories. + +### Building cross-compiler from source + +An alternative is to build cross-compiler toolchain from source using +crosstool-ng. The latest released version of [crosstool-ng](https://github.com/crosstool-ng/crosstool-ng) can be installed -using [homebrew](https://brew.sh) +using homebrew: ``` $ brew install crosstool-ng ``` @@ -30,18 +70,9 @@ $ ct-ng -C $X_BUILD_DIR build CT_PREFIX=$X_INSTALL_DIR Once compiled, the cross-compiler can be used to build the tests: ``` -$ ./configure --cross-prefix=$X_INSTALL_DIR/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu- -$ make -``` - -## Pre-built cross-compiler - -x86_64-elf-gcc package in Homebrew provides pre-built cross-compiler but it -fails to compile kvm-unit-tests. - -## Running the tests - -GNU coreutils should be installed prior to running the tests: -``` -$ brew install coreutils +$ ./configure \ + --getopt=/usr/local/opt/gnu-getopt/bin/getopt \ + --arch=x86_64 \ + --cross-prefix=$X_INSTALL_DIR/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu- +$ make -j $(nproc) ``` From patchwork Tue Sep 1 08:50:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11747687 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B97A109B for ; Tue, 1 Sep 2020 08:51:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E147C2071B for ; Tue, 1 Sep 2020 08:51:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="SJlNy+nH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728043AbgIAIvS (ORCPT ); Tue, 1 Sep 2020 04:51:18 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:55068 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727943AbgIAIvM (ORCPT ); Tue, 1 Sep 2020 04:51:12 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id DFE9C5732F; Tue, 1 Sep 2020 08:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received; s=mta-01; t= 1598950269; x=1600764670; bh=R9U4A4Al/SFgblTs20VQHVUr7X1m/ISsT6o 3qGFtoAQ=; b=SJlNy+nHYcbHDINbw1i0YdP8PCdK3cdQ88hVUL+bHlInn7FU0tw z4SJbKgU/RRnQb4f+0R4nL7WhkUTsG+02Q07zMZ/hA6Hz1BP0ESd0cWsw73mN7yc NwHoVu9dkeAXnfSRgY/j9uBcASY/b2RzCzVmuwP2iSsekCIi71lpASbw= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LF4wWVIQ4ygM; Tue, 1 Sep 2020 11:51:09 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 3E286574F3; Tue, 1 Sep 2020 11:51:08 +0300 (MSK) Received: from localhost (172.17.204.212) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Tue, 1 Sep 2020 11:51:08 +0300 From: Roman Bolshakov To: CC: Thomas Huth , Paolo Bonzini , Roman Bolshakov Subject: [kvm-unit-tests PATCH v2 08/10] travis.yml: Add CI for macOS Date: Tue, 1 Sep 2020 11:50:54 +0300 Message-ID: <20200901085056.33391-9-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901085056.33391-1-r.bolshakov@yadro.com> References: <20200901085056.33391-1-r.bolshakov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [172.17.204.212] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Build the tests on macOS and test TCG. HVF doesn't work in travis. sieve tests pass but they might timeout in travis, they were left out because of that. Suggested-by: Thomas Huth Signed-off-by: Roman Bolshakov Reviewed-by: Thomas Huth --- .travis.yml | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.travis.yml b/.travis.yml index f0cfc82..7bd0205 100644 --- a/.travis.yml +++ b/.travis.yml @@ -108,6 +108,48 @@ matrix: - TESTS="sieve" - ACCEL="tcg,firmware=s390x/run" + - os: osx + osx_image: xcode11.6 + addons: + homebrew: + packages: + - bash + - coreutils + - gnu-getopt + - qemu + - x86_64-elf-gcc + env: + - CONFIG="--cross-prefix=x86_64-elf- + --getopt=/usr/local/opt/gnu-getopt/bin/getopt" + - BUILD_DIR="build" + - TESTS="ioapic-split smptest smptest3 vmexit_cpuid vmexit_mov_from_cr8 + vmexit_mov_to_cr8 vmexit_inl_pmtimer vmexit_ipi vmexit_ipi_halt + vmexit_ple_round_robin vmexit_tscdeadline + vmexit_tscdeadline_immed eventinj msr port80 setjmp + syscall tsc rmap_chain umip intel_iommu" + - ACCEL="tcg" + + - os: osx + osx_image: xcode11.6 + addons: + homebrew: + packages: + - bash + - coreutils + - gnu-getopt + - qemu + - i686-elf-gcc + env: + - CONFIG="--arch=i386 --cross-prefix=i686-elf- + --getopt=/usr/local/opt/gnu-getopt/bin/getopt" + - BUILD_DIR="build" + - TESTS="cmpxchg8b vmexit_cpuid vmexit_mov_from_cr8 vmexit_mov_to_cr8 + vmexit_inl_pmtimer vmexit_ipi vmexit_ipi_halt + vmexit_ple_round_robin vmexit_tscdeadline + vmexit_tscdeadline_immed eventinj port80 setjmp tsc + taskswitch umip" + - ACCEL="tcg" + before_script: - if [ "$ACCEL" = "kvm" ]; then sudo chgrp kvm /usr/bin/qemu-system-* ; From patchwork Tue Sep 1 08:50:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11747691 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C73E109B for ; Tue, 1 Sep 2020 08:51:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 59E9720866 for ; Tue, 1 Sep 2020 08:51:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="wEcmqweA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726212AbgIAIvj (ORCPT ); Tue, 1 Sep 2020 04:51:39 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:55074 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727944AbgIAIvM (ORCPT ); Tue, 1 Sep 2020 04:51:12 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 755B6574E8; Tue, 1 Sep 2020 08:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received; s=mta-01; t= 1598950270; x=1600764671; bh=NdA+6+BccPWVUWOh/PnqUnf8ENv2nQ2zLip qh3CRl4U=; b=wEcmqweAhG13lNAdk5sLG6cj9SYsYgriR5o/IHN9GVp2QjB+h6I oMY303BKRMwPc91PJGJl7Cjajx7/fskKG2akcSiL+N7Sg2vDME6sDH1Q2AB93rgf ERxszDJXudviOG+SUGJvJ33K8u/W4wL+JKn3jWUzkGnQxvckHiGrd1Lg= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8wbbdDAS809w; Tue, 1 Sep 2020 11:51:10 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id C16E35141E; Tue, 1 Sep 2020 11:51:08 +0300 (MSK) Received: from localhost (172.17.204.212) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Tue, 1 Sep 2020 11:51:08 +0300 From: Roman Bolshakov To: CC: Thomas Huth , Paolo Bonzini , Roman Bolshakov Subject: [kvm-unit-tests PATCH v2 09/10] travis.yml: Change matrix keyword to jobs Date: Tue, 1 Sep 2020 11:50:55 +0300 Message-ID: <20200901085056.33391-10-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901085056.33391-1-r.bolshakov@yadro.com> References: <20200901085056.33391-1-r.bolshakov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [172.17.204.212] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org jobs keyword is used throughout Travis documentation and matrix is an alias for it (according to Travis config validation): root: key matrix is an alias for jobs, using jobs At first glance it's not clear if they're the same and if jobs documentation applies to matrix. Changing keyword name should make it obvious. While at it, fix the Travis config warning: root: deprecated key sudo (The key `sudo` has no effect anymore.) Signed-off-by: Roman Bolshakov Tested-by: Thomas Huth --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7bd0205..f3a8899 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,10 @@ -sudo: true dist: bionic language: c cache: ccache git: submodules: false -matrix: +jobs: include: - addons: From patchwork Tue Sep 1 08:50:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11747689 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AED2B1575 for ; Tue, 1 Sep 2020 08:51:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 937B920866 for ; Tue, 1 Sep 2020 08:51:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="iPtMphLZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727943AbgIAIvc (ORCPT ); Tue, 1 Sep 2020 04:51:32 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:55068 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727997AbgIAIvR (ORCPT ); Tue, 1 Sep 2020 04:51:17 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 240BB5141E; Tue, 1 Sep 2020 08:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received; s=mta-01; t= 1598950270; x=1600764671; bh=HR6hkEJLE+0SqABXBGpMRYsT1wpbx2+YucN gAQUSKuY=; b=iPtMphLZRz75d7yXKAFShfT1WSAOfa5JMCwrZ8sZcxQzoB4arNC RZCy0Zkncqdo9JePUBkaSdeFKOAKE7dJX4uEt7sLpfpmeTlfguMd3r6YNghVO2xD aWAr5bWm+XNd2Bl9OQxx+DjGDX4a4bNii7hwZKHFjT+KfaJ3nl+383rM= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sEjx-AmobgVR; Tue, 1 Sep 2020 11:51:10 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 5740F574FB; Tue, 1 Sep 2020 11:51:09 +0300 (MSK) Received: from localhost (172.17.204.212) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Tue, 1 Sep 2020 11:51:09 +0300 From: Roman Bolshakov To: CC: Thomas Huth , Paolo Bonzini , Roman Bolshakov Subject: [kvm-unit-tests PATCH v2 10/10] travis.yml: Add x86 build with clang 10 Date: Tue, 1 Sep 2020 11:50:56 +0300 Message-ID: <20200901085056.33391-11-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901085056.33391-1-r.bolshakov@yadro.com> References: <20200901085056.33391-1-r.bolshakov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [172.17.204.212] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org .gitlab-ci.yml already has a job to build the tests with clang but it's not clear how to set it up on a personal github repo. NB, realmode test is disabled because it fails immediately after start if compiled with clang-10. Signed-off-by: Roman Bolshakov --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.travis.yml b/.travis.yml index f3a8899..ae4ed08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,16 @@ jobs: kvmclock_test msr pcid rdpru realmode rmap_chain s3 setjmp umip" - ACCEL="kvm" + - addons: + apt_packages: clang-10 qemu-system-x86 + env: + - CONFIG="--cc=clang-10" + - BUILD_DIR="." + - TESTS="access asyncpf debug emulator ept hypercall hyperv_stimer + hyperv_synic idt_test intel_iommu ioapic ioapic-split + kvmclock_test msr pcid rdpru rmap_chain s3 setjmp umip" + - ACCEL="kvm" + - addons: apt_packages: gcc qemu-system-x86 env: