From patchwork Mon Aug 10 13:06:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11707385 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 ECEA9109A for ; Mon, 10 Aug 2020 13:06:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D54A92073A for ; Mon, 10 Aug 2020 13:06:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="S6AqCDnV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726819AbgHJNGi (ORCPT ); Mon, 10 Aug 2020 09:06:38 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:47970 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726582AbgHJNGh (ORCPT ); Mon, 10 Aug 2020 09:06:37 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 616844C8A9; Mon, 10 Aug 2020 13:06:35 +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= 1597064793; x=1598879194; bh=wUN5jHU/zBYZJQjo7ncYgKjE4TFXDiYyECm cEyGlvTw=; b=S6AqCDnVKm+zYVsyyqJIeaCXl+mnCRs4tJMlAa+x9VBIB2IqoEd gtGocw6qsdK8gyU9F2MjD2aGcUoXFSev6pPm8F621ybMmIHH2tnVzYVJEBsvxb0C ywX2st9IT5AoKCRPs6Q49lBDkb7nMhZc7Ywq5e0Lm+0PhhqAkzCh+y38= 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 X6ktgHB82ZA5; Mon, 10 Aug 2020 16:06:33 +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 E45D54C890; Mon, 10 Aug 2020 16:06:33 +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; Mon, 10 Aug 2020 16:06:33 +0300 From: Roman Bolshakov To: CC: Roman Bolshakov , Cameron Esfahani Subject: [kvm-unit-tests PATCH 1/7] x86: Makefile: Allow division on x86_64-elf binutils Date: Mon, 10 Aug 2020 16:06:12 +0300 Message-ID: <20200810130618.16066-2-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200810130618.16066-1-r.bolshakov@yadro.com> References: <20200810130618.16066-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. The option is ignored on the Linux target of GNU binutils. 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 --- x86/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x86/Makefile b/x86/Makefile index 8a007ab..22afbb9 100644 --- a/x86/Makefile +++ b/x86/Makefile @@ -1 +1,3 @@ include $(SRCDIR)/$(TEST_DIR)/Makefile.$(ARCH) + +COMMON_CFLAGS += -Wa,--divide From patchwork Mon Aug 10 13:06:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11707389 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 C79FA109A for ; Mon, 10 Aug 2020 13:06:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB5382075F for ; Mon, 10 Aug 2020 13:06:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="SVMVhPIP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726846AbgHJNGn (ORCPT ); Mon, 10 Aug 2020 09:06:43 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:47978 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726545AbgHJNGl (ORCPT ); Mon, 10 Aug 2020 09:06:41 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 6DE9B4C8AA; Mon, 10 Aug 2020 13:06:36 +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= 1597064794; x=1598879195; bh=YCHEH+2TNnwPMP800cfZDqgw/KJs3ms6w07 6DKOG21k=; b=SVMVhPIPNEpVsv47d6d0gn/DxyQ7WECxqz+Tf4Mgu4CV0P1oEHp e2PzC2a9AegotNcKaOABI1LFJx34wb4Wa8sQlmWk1pB6mpBJJiy7GhTa3F49KONY Umf+5Ac/fNwt+bU7WFnyI0ZKHSdelaHl/NYbuK+TBAXj0T4BF+Dq8Cfc= 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 kyjKu0Jdq00e; Mon, 10 Aug 2020 16:06:34 +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 95A954C667; Mon, 10 Aug 2020 16:06:34 +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; Mon, 10 Aug 2020 16:06:34 +0300 From: Roman Bolshakov To: CC: Roman Bolshakov , Cameron Esfahani Subject: [kvm-unit-tests PATCH 2/7] x86: Replace instruction prefixes with spaces Date: Mon, 10 Aug 2020 16:06:13 +0300 Message-ID: <20200810130618.16066-3-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200810130618.16066-1-r.bolshakov@yadro.com> References: <20200810130618.16066-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 Signed-off-by: Roman Bolshakov Reviewed-by: Thomas Huth --- 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 Mon Aug 10 13:06:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11707387 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 1692917CB for ; Mon, 10 Aug 2020 13:06:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1E342073A for ; Mon, 10 Aug 2020 13:06:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="lOZ+Lxr0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726830AbgHJNGk (ORCPT ); Mon, 10 Aug 2020 09:06:40 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:47984 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726815AbgHJNGj (ORCPT ); Mon, 10 Aug 2020 09:06:39 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id EDBE24C8B0; Mon, 10 Aug 2020 13:06:36 +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= 1597064795; x=1598879196; bh=kSkMdcaH4hQa0Ft6KVr0aTYUxYzVR0vbo2H XLiHtojI=; b=lOZ+Lxr0UWvNC4I0L5hbYSFvFTI0mlylVoCOzg3Oiym0DYELp4P FSEv0Tg0oAwKZsNxugJz9hDxioNKokyhhTu2WWbYlngL3sKRidn5I3eh1A6+0Jrl nuI/+GchJhoqERp0CLfcEEcjQqM65e2eu5DCJNc0KkygHPD1gvbnIOJs= 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 pSd5SjL05hRX; Mon, 10 Aug 2020 16:06:35 +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 301A24C8A2; Mon, 10 Aug 2020 16:06:35 +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; Mon, 10 Aug 2020 16:06:35 +0300 From: Roman Bolshakov To: CC: Roman Bolshakov , Cameron Esfahani Subject: [kvm-unit-tests PATCH 3/7] x86: Makefile: Fix linkage of realmode on x86_64-elf binutils Date: Mon, 10 Aug 2020 16:06:14 +0300 Message-ID: <20200810130618.16066-4-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200810130618.16066-1-r.bolshakov@yadro.com> References: <20200810130618.16066-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 Signed-off-by: Roman Bolshakov Reviewed-by: Thomas Huth --- x86/Makefile.common | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x86/Makefile.common b/x86/Makefile.common index 2ea9c9f..8230ac0 100644 --- a/x86/Makefile.common +++ b/x86/Makefile.common @@ -66,7 +66,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 Mon Aug 10 13:06:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11707393 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 C60E913B1 for ; Mon, 10 Aug 2020 13:06:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD7AF2075F for ; Mon, 10 Aug 2020 13:06:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="I+OkQ4Or" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726859AbgHJNGp (ORCPT ); Mon, 10 Aug 2020 09:06:45 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:47998 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726821AbgHJNGl (ORCPT ); Mon, 10 Aug 2020 09:06:41 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 5EF6A4C88F; Mon, 10 Aug 2020 13:06:38 +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= 1597064796; x=1598879197; bh=Yu8w4ld04o1+eFBtzmy2ZK9TAqK6tEo2gu/ o6kbO4K0=; b=I+OkQ4OrlunSsuy7VVpjU04zLPGCz5T1xR3gNwbhbXJbqzohJa4 qoBrpvJZEIyFWcA+gHq4kNQSR4lSIhq7s6h0ioZWSi1WdR2skVRM/MdIjyqeq1q7 DvTyLUy53b1M/PerYcVlMMHougn2Nicg/rPcyK23DPzqeSu0E/JMuMsQ= 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 wrVJtvs0XoZY; Mon, 10 Aug 2020 16:06:36 +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 AB9614C89B; Mon, 10 Aug 2020 16:06:35 +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; Mon, 10 Aug 2020 16:06:35 +0300 From: Roman Bolshakov To: CC: Roman Bolshakov , Jim Mattson , Peter Shier , Paolo Bonzini , Cameron Esfahani Subject: [kvm-unit-tests PATCH 4/7] lib: Bundle debugreg.h from the kernel Date: Mon, 10 Aug 2020 16:06:15 +0300 Message-ID: <20200810130618.16066-5-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200810130618.16066-1-r.bolshakov@yadro.com> References: <20200810130618.16066-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 Signed-off-by: Roman Bolshakov Reviewed-by: Thomas Huth --- 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 Mon Aug 10 13:06:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11707391 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 DC936109A for ; Mon, 10 Aug 2020 13:06:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C61952075F for ; Mon, 10 Aug 2020 13:06:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="dxOWZQ8/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726855AbgHJNGo (ORCPT ); Mon, 10 Aug 2020 09:06:44 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:48008 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726828AbgHJNGl (ORCPT ); Mon, 10 Aug 2020 09:06:41 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id A83AD4C890; Mon, 10 Aug 2020 13:06:39 +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= 1597064798; x=1598879199; bh=kvB2A6T1I0wX87Bm2REoN+ABKLzsnR7QUqC 6tIkoiiQ=; b=dxOWZQ8/zoZ0TdAfhPprFG5BVvzsGjZg4zIb8BJBq5sEd9vvcqo rkm3xFxuPhUHETS5+Ws9ByaoVpsYQQpl/x50RI6bqm7ncsK9NxsKO+raNZRZ092v 2LYzeOp92eRx4aErXPYB8XMeGwjrUuZqKfdyXbj9ethGHEIoOgxtiS84= 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 s3y9NI-5tvX7; Mon, 10 Aug 2020 16:06:38 +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 3F7824C896; Mon, 10 Aug 2020 16:06:36 +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; Mon, 10 Aug 2020 16:06:36 +0300 From: Roman Bolshakov To: CC: Roman Bolshakov , =?utf-8?q?Alex_Benn=C3=A9e?= , Andrew Jones , Cameron Esfahani , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= Subject: [kvm-unit-tests PATCH 5/7] lib: x86: Use portable format macros for uint32_t Date: Mon, 10 Aug 2020 16:06:16 +0300 Message-ID: <20200810130618.16066-6-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200810130618.16066-1-r.bolshakov@yadro.com> References: <20200810130618.16066-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 Mon Aug 10 13:06:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11707397 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 A4108109A for ; Mon, 10 Aug 2020 13:06:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8931720748 for ; Mon, 10 Aug 2020 13:06:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="LnLD5Pwz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726857AbgHJNGt (ORCPT ); Mon, 10 Aug 2020 09:06:49 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:48018 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726582AbgHJNGn (ORCPT ); Mon, 10 Aug 2020 09:06:43 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 48BBA4C891; Mon, 10 Aug 2020 13:06:41 +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= 1597064800; x=1598879201; bh=5i+oOdei6MHmdYzVHJtxN+8Vf4HkfKSmai7 ip5ROpe4=; b=LnLD5PwzdE6H7FjBmx2/rS/6EJY6kpq3ZINcCV2hQ/51BJm30LF csLuHU+pqtzft/3zz++YOMHul25mGiiiqbB3YePX32R0cL9F+btI+3ANPN5Bglfo abCeLgl1J6nHBLML6pVbTBP2TMSy8ACHij9ocGKrfyRUgh6x6qOxgbto= 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 iqzpZI9aUKG7; Mon, 10 Aug 2020 16:06:40 +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 CBE8B4C88C; Mon, 10 Aug 2020 16:06:36 +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; Mon, 10 Aug 2020 16:06:36 +0300 From: Roman Bolshakov To: CC: Roman Bolshakov , Cameron Esfahani Subject: [kvm-unit-tests PATCH 6/7] configure: Add an option to specify getopt Date: Mon, 10 Aug 2020 16:06:17 +0300 Message-ID: <20200810130618.16066-7-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200810130618.16066-1-r.bolshakov@yadro.com> References: <20200810130618.16066-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 --- configure | 13 +++++++++++++ run_tests.sh | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/configure b/configure index f9d030f..556ff13 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= @@ -31,6 +32,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 @@ -76,6 +78,9 @@ while [[ "$1" = -* ]]; do --ld) ld="$arg" ;; + --getopt) + getopt="$arg" + ;; --enable-pretty-print-stacks) pretty_print_stacks=yes ;; @@ -156,6 +161,13 @@ EOF u32_long=$("$cross_prefix$cc" -E lib-test.c | grep -v '^#' | grep -q long && echo yes) rm -f lib-test.c +# 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 @@ -198,6 +210,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 Mon Aug 10 13:06:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 11707395 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 93232109A for ; Mon, 10 Aug 2020 13:06:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77EB12075F for ; Mon, 10 Aug 2020 13:06:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yadro.com header.i=@yadro.com header.b="HgmJ97yy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726868AbgHJNGq (ORCPT ); Mon, 10 Aug 2020 09:06:46 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:47978 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726815AbgHJNGo (ORCPT ); Mon, 10 Aug 2020 09:06:44 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id DE1FB4C88C; Mon, 10 Aug 2020 13:06:42 +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= 1597064801; x=1598879202; bh=3+BnVU1emfZqWuACNhhvRbzAKUlk9OStoLf NwfeYqvI=; b=HgmJ97yyIc9BRyHp9k3Gu5sQPduo14UGhAofW0AeS+64V3WUE8O GZD7QmNoJAK8OC4GUI7j4muVdlIhD8PJsIHE6NbovhvRSBpAnQXRHjURUWG2PGDf KgrpUgPByV2aUogMjD50XSBodcMhtIwR2Q9gDyTqfFIKLq+qLkahh24g= 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 WT3lccldD8ed; Mon, 10 Aug 2020 16:06:41 +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 5AF4A4C8B2; Mon, 10 Aug 2020 16:06:37 +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; Mon, 10 Aug 2020 16:06:37 +0300 From: Roman Bolshakov To: CC: Roman Bolshakov , Cameron Esfahani Subject: [kvm-unit-tests PATCH 7/7] README: Update build instructions for macOS Date: Mon, 10 Aug 2020 16:06:18 +0300 Message-ID: <20200810130618.16066-8-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200810130618.16066-1-r.bolshakov@yadro.com> References: <20200810130618.16066-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) ```