From patchwork Sat Jan 13 02:21:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Weber X-Patchwork-Id: 860274 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zJNdy0SLmz9sP1 for ; Sat, 13 Jan 2018 13:21:24 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 9A0602E392; Sat, 13 Jan 2018 02:21:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AMr5eLf6aVRG; Sat, 13 Jan 2018 02:21:19 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 7AFEA2E1FF; Sat, 13 Jan 2018 02:21:19 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 19BDC1C2C9B for ; Sat, 13 Jan 2018 02:21:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 8702A883DA for ; Sat, 13 Jan 2018 02:21:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0ZIIA2gwhKoo for ; Sat, 13 Jan 2018 02:21:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from ch3vs01.rockwellcollins.com (smtpimr.rockwellcollins.com [205.175.226.27]) by whitealder.osuosl.org (Postfix) with ESMTPS id 47FA0883D6 for ; Sat, 13 Jan 2018 02:21:14 +0000 (UTC) Received: from ofwch3n02.rockwellcollins.com (HELO dtulimr02.rockwellcollins.com) ([205.175.226.14]) by ch3vs01.rockwellcollins.com with ESMTP; 12 Jan 2018 20:21:12 -0600 X-Received: from largo.rockwellcollins.com (unknown [192.168.140.76]) by dtulimr02.rockwellcollins.com (Postfix) with ESMTP id B16A92006A; Fri, 12 Jan 2018 20:21:12 -0600 (CST) From: Matt Weber To: buildroot@buildroot.org Date: Fri, 12 Jan 2018 20:21:11 -0600 Message-Id: <1515810071-10003-1-git-send-email-matthew.weber@rockwellcollins.com> X-Mailer: git-send-email 1.9.1 Subject: [Buildroot] [PATCH v3] kvm-unit-tests: test for rdseed/rdrand X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" The build fails when the host binutils isn't at least 2.23 (2.22.x introduced RDSEED). The host toolchain is used for x86_64 target builds where we need to do a 32bit build. Most other buildroot builds are using a much newer binutils unless it's a external older toolchain. Fixes: http://autobuild.buildroot.net/results/c39/c3987a3cbd2960b0ff50f872636bdfd8d1a9c820/ Upstream: https://marc.info/?l=kvm&m=151580743523259&w=2 Signed-off-by: Matthew Weber --- Thomas/Peter could you test this on one of your builders? I've requested a gcc farm account but still waiting at this point. Here's the builders which can reproduce the failure (ie have old enough host binutils). http://autobuild.buildroot.net/?reason=kvm-unit-tests-kvm-unit-tests-20171020 Changes v2 -> v3 [Thomas - Actually hooked up a extra cflags variable from configure so they are used. I didn't notice the CFLAGS are cleared by default. Changes v1 -> v2 [Thomas - Suggested a configure check vs the original revert of the upstream commit which added these instructions to the package. --- ...002-kvm-unit-tests-test-for-rdseed-rdrand.patch | 110 +++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 package/kvm-unit-tests/0002-kvm-unit-tests-test-for-rdseed-rdrand.patch diff --git a/package/kvm-unit-tests/0002-kvm-unit-tests-test-for-rdseed-rdrand.patch b/package/kvm-unit-tests/0002-kvm-unit-tests-test-for-rdseed-rdrand.patch new file mode 100644 index 0000000..47f15c6 --- /dev/null +++ b/package/kvm-unit-tests/0002-kvm-unit-tests-test-for-rdseed-rdrand.patch @@ -0,0 +1,110 @@ +From 8d9a62a5fa89001266352a929c5d40b28c0dda85 Mon Sep 17 00:00:00 2001 +From: Matt Weber +Date: Fri, 12 Jan 2018 19:07:27 -0600 +Subject: [PATCH v2] kvm-unit-tests: test for rdseed/rdrand + +The build fails when the host binutils isn't at least 2.23 +(2.22.x introduced RDSEED). + +Fixes: +http://autobuild.buildroot.net/results/c39/c3987a3cbd2960b0ff50f872636bdfd8d1a9c820/ + +Upstream: +https://marc.info/?l=kvm&m=151580743523259&w=2 + +Signed-off-by: Matthew Weber +--- + Makefile | 2 +- + configure | 18 ++++++++++++++++++ + x86/vmx_tests.c | 6 ++++++ + 3 files changed, 25 insertions(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index d9ad42b..799e9b5 100644 +--- a/Makefile ++++ b/Makefile +@@ -50,7 +50,7 @@ include $(SRCDIR)/$(TEST_DIR)/Makefile + cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \ + > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) + +-COMMON_CFLAGS += -g $(autodepend-flags) ++COMMON_CFLAGS += -g $(autodepend-flags) $(EXTRA_CFLAGS) + COMMON_CFLAGS += -Wall -Wwrite-strings -Wclobbered -Wempty-body -Wuninitialized + COMMON_CFLAGS += -Wignored-qualifiers -Wunused-but-set-parameter + frame-pointer-flag=-f$(if $(KEEP_FRAME_POINTER),no-,)omit-frame-pointer +diff --git a/configure b/configure +index dd9d361..21c0219 100755 +--- a/configure ++++ b/configure +@@ -171,6 +171,23 @@ mkdir -p lib + ln -sf "$asm" lib/asm + + ++cat > rd_test.c < ++int main() { ++ uint16_t seed=0; ++ unsigned char ok; ++ asm volatile ("rdseed %0; setc %1" ++ : "=r" (seed), "=qm" (ok)); ++ return ok; ++} ++EOF ++if $cross_prefix$cc -o /dev/null rd_test.c &> /dev/null; then ++ echo "Checking for rdseed/rdrand... Yes." ++else ++ echo "Checking for rdseed/rdrand... No." ++ extra_cflags="-DNO_RDSEEDRAND" ++fi ++ + # create the config + cat < config.mak + SRCDIR=$srcdir +@@ -181,6 +198,7 @@ ARCH_NAME=$arch_name + PROCESSOR=$processor + CC=$cross_prefix$cc + CXX=$cross_prefix$cxx ++EXTRA_CFLAGS=$extra_cflags + LD=$cross_prefix$ld + OBJCOPY=$cross_prefix$objcopy + OBJDUMP=$cross_prefix$objdump +diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c +index 4a3e94b..2cbe3eb 100644 +--- a/x86/vmx_tests.c ++++ b/x86/vmx_tests.c +@@ -770,8 +770,10 @@ asm( + "insn_sldt: sldt %ax;ret\n\t" + "insn_lldt: xor %eax, %eax; lldt %ax;ret\n\t" + "insn_str: str %ax;ret\n\t" ++#ifndef NO_RDSEEDRAND + "insn_rdrand: rdrand %rax;ret\n\t" + "insn_rdseed: rdseed %rax;ret\n\t" ++#endif + ); + extern void insn_hlt(); + extern void insn_invlpg(); +@@ -796,8 +798,10 @@ extern void insn_lldt(); + extern void insn_str(); + extern void insn_cpuid(); + extern void insn_invd(); ++#ifndef NO_RDSEEDRAND + extern void insn_rdrand(); + extern void insn_rdseed(); ++#endif + + u32 cur_insn; + u64 cr3; +@@ -853,8 +857,10 @@ static struct insn_table insn_table[] = { + {"DESC_TABLE (LLDT)", CPU_DESC_TABLE, insn_lldt, INSN_CPU1, 47, 0, 0, 0}, + {"DESC_TABLE (STR)", CPU_DESC_TABLE, insn_str, INSN_CPU1, 47, 0, 0, 0}, + /* LTR causes a #GP if done with a busy selector, so it is not tested. */ ++#ifndef NO_RDSEEDRAND + {"RDRAND", CPU_RDRAND, insn_rdrand, INSN_CPU1, VMX_RDRAND, 0, 0, 0}, + {"RDSEED", CPU_RDSEED, insn_rdseed, INSN_CPU1, VMX_RDSEED, 0, 0, 0}, ++#endif + // Instructions always trap + {"CPUID", 0, insn_cpuid, INSN_ALWAYS_TRAP, 10, 0, 0, 0}, + {"INVD", 0, insn_invd, INSN_ALWAYS_TRAP, 13, 0, 0, 0}, +-- +1.9.1 +