From patchwork Fri May 17 22:44:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Bobek X-Patchwork-Id: 10948751 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8DE376 for ; Fri, 17 May 2019 22:46:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98A7328474 for ; Fri, 17 May 2019 22:46:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CE3C284B3; Fri, 17 May 2019 22:46:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2814E28474 for ; Fri, 17 May 2019 22:46:59 +0000 (UTC) Received: from localhost ([127.0.0.1]:54736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlcw-0003BE-DV for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 May 2019 18:46:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlbE-0001CU-HM for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRlbD-0005KU-Hv for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:12 -0400 Received: from mail-yb1-xb43.google.com ([2607:f8b0:4864:20::b43]:44836) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRlbD-0005J7-D8 for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:11 -0400 Received: by mail-yb1-xb43.google.com with SMTP id t62so3219782ybi.11 for ; Fri, 17 May 2019 15:45:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+Po4c2MYiwQPlsRFoqhNsViqq9vMYTJOCyBm8w65Nqc=; b=fVaNQVbg0fWUhbvU1EH8c+BfXdwtFT979URQ3vs5ko2dSTc2q5vE5/G4luk40Q+w8Y XebEbYoEvomTbOWubJJjXM4Gyc7aVoPXV7LkySHgUwRkWlfbOWePXPV0wkDgmJVnqnex d//HEJAAuDlLEYkrr6Ywa6d+Jb5mTom57KsZ9HsfENGkCFBOxYiP5sWRLXEOmnhOsz3u jqO8024lLGeJUydXVCg6glvuBdfc5JvitEZtc6q8bJhNK6hdPQCFTX6jM8ez2FxYwecn XfOQ2jP2oVs8B+gb52csewY/mXDDQaTb3XkHpzZ9jynAz8iXKeZcnPbAbtF/2hFsrr+C sBHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+Po4c2MYiwQPlsRFoqhNsViqq9vMYTJOCyBm8w65Nqc=; b=pFC1m8UEsOQ87LLMHMO7QIkpJUvK/yDK+x3DmhTQ9kmI05Yrxr8RFbMNpjH1jYPh56 IMuKtzO8K5o4Js4PAyahaJTIsmgotalNX3qX1/LCuRRXYnREgSensR8RWzeMhpCZezz4 bwOaCZsjEqoszn6u0C5Pi3rhwaE++XuTY6uLxJLGEHSRLNQTXa6luqY/TxJ7M0Z6pS6h bD4GnWEcD1CNxCuOtKTmRHomHzVx4Nt2t4y4j1RK88GkRxkWkYAjnnEzmb5+UTCNUZeI uLKw0j088iANNDlDr/VyWgzhbj28EkOfNbkZQ1MvU6krFakS7Mn6gsFk2d2CdDMLIR2R W9pA== X-Gm-Message-State: APjAAAX46wT1TyrIyz8Zh0wO+oae8Z740wYGreXSXEQkhkGx4rCCbdji qls6G/2dunzOmNsApvUGM29QpbI9vxDScg== X-Google-Smtp-Source: APXvYqzcR0Qh4qGAqXnNRK8Sx6MPmUA6lqDBUpKaPIrWMZsIzYeAEusAnmxpP9EX7QqDCnGFj+xGSw== X-Received: by 2002:a25:828c:: with SMTP id r12mr414403ybk.94.1558133110729; Fri, 17 May 2019 15:45:10 -0700 (PDT) Received: from dionysus.attlocal.net (69-222-133-165.lightspeed.tukrga.sbcglobal.net. [69.222.133.165]) by smtp.gmail.com with ESMTPSA id u73sm2480260ywf.62.2019.05.17.15.45.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 15:45:10 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:44:40 -0400 Message-Id: <20190517224450.15566-2-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517224450.15566-1-jan.bobek@gmail.com> References: <20190517224450.15566-1-jan.bobek@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::b43 Subject: [Qemu-devel] [RISU v2 01/11] Makefile: undefine the arch name symbol X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Bobek , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP At least GCC defines the symbol "i386" to 1 to signal the target platform. We need to use "i386" as an undefined symbol in order to correctly include risu_reginfo_i386.h from risu.h. Add an -U option to the build command to make sure the symbol remains undefined. Suggested-by: Richard Henderson Signed-off-by: Jan Bobek Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4aad448..b362dbe 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ VPATH=$(SRCDIR) CFLAGS ?= -g -ALL_CFLAGS = -Wall -D_GNU_SOURCE -DARCH=$(ARCH) $(BUILD_INC) $(CFLAGS) $(EXTRA_CFLAGS) +ALL_CFLAGS = -Wall -D_GNU_SOURCE -DARCH=$(ARCH) -U$(ARCH) $(BUILD_INC) $(CFLAGS) $(EXTRA_CFLAGS) PROG=risu SRCS=risu.c comms.c reginfo.c risu_$(ARCH).c risu_reginfo_$(ARCH).c From patchwork Fri May 17 22:44:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Bobek X-Patchwork-Id: 10948753 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CAA6F76 for ; Fri, 17 May 2019 22:47:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B85F628474 for ; Fri, 17 May 2019 22:47:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC267284B3; Fri, 17 May 2019 22:47:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 486E628474 for ; Fri, 17 May 2019 22:47:04 +0000 (UTC) Received: from localhost ([127.0.0.1]:54738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRld1-0003Fo-HD for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 May 2019 18:47:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43179) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlbG-0001Gj-TE for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRlbF-0005QU-J7 for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:14 -0400 Received: from mail-yb1-xb43.google.com ([2607:f8b0:4864:20::b43]:36234) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRlbF-0005PI-E0 for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:13 -0400 Received: by mail-yb1-xb43.google.com with SMTP id m10so3243000ybk.3 for ; Fri, 17 May 2019 15:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G8++Lr3rIIt9kikJ2cxj2YKTqF9/McsFoEFrbLSU8eY=; b=tMkJkTJz44esF7IecnmRUEIPyPlB7gqYB60+B1b3npGCZiax2MGOLi74+aHShW6vng nC3hNKsi3PHs9d2r/jgQ6zxFygx5wztcEAVXeghbOmdifBs6LLqar8XNw2CohUcK54Nd zGMBW8L4dKrs2Qaec8a9CxPwScTniOJVVG+hztydiKUhNQlXNiZkJnETun8WUaDplIQ4 JTPaNZAL60ch6lLUWHnTgcm8YJHi91xWKzQugVSR1D1JEJkoaZ+ia0oyGj+EUWNa8H2i jeOst76gsCah1Mrc7QYzqA7t5TnSvXe9atvA+5IwGseyinKrRw2LCkvyip6aRmpKuoF4 R7sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G8++Lr3rIIt9kikJ2cxj2YKTqF9/McsFoEFrbLSU8eY=; b=spufjPGumFRNX5J0LpAnUH70jxBKaOH4vgLWvevO5jgg3NcoBntKG0radCl7sU7nFP QIrdtTQrJC07IEPfP3+V/1iBkPJmwJ3PcAhYwfI+ilUCdoWFHEuaa5i64kerIATwQ+Ll UT8w+C5X2mj//DPvurvwGo8dznFcOr4hPuAieWlWUYujI7E+Hnpg/sgqkNxQbj86+Pmp pcfGd4sJKT5vf+xacGjYLb4Abe8knriNZwchHg2ozBXatRzV/UQgAQxsf10R+npwmLgB VAtJs2DsmmbRrGtgXZZLRsTdoUPBbS6QZdmIny+NReleXvh/S/oq7hWcn8L2iPCzVvNq Ru9w== X-Gm-Message-State: APjAAAV8k2/AUEvN8aSbAi7AeUAThUitG1y0AtX3XStUSImV0fBRzIuG FJOebLHA7HD1vVQ+/skQ2xVZ27jgKlljSA== X-Google-Smtp-Source: APXvYqxGY66LudO9Tc9MaNpHj/MnmwnpWxBem9PyJCkgpAA1/NnLQJHvN4TWmOBZCxLdN2abecyJ6A== X-Received: by 2002:a25:81c3:: with SMTP id n3mr27146039ybm.206.1558133112858; Fri, 17 May 2019 15:45:12 -0700 (PDT) Received: from dionysus.attlocal.net (69-222-133-165.lightspeed.tukrga.sbcglobal.net. [69.222.133.165]) by smtp.gmail.com with ESMTPSA id u73sm2480260ywf.62.2019.05.17.15.45.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 15:45:12 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:44:41 -0400 Message-Id: <20190517224450.15566-3-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517224450.15566-1-jan.bobek@gmail.com> References: <20190517224450.15566-1-jan.bobek@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::b43 Subject: [Qemu-devel] [RISU v2 02/11] risu_i386: move reginfo_t and related defines to risu_reginfo_i386.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Bobek , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In order to build risu successfully for i386, we need files risu_reginfo_i386.{h,c}; this patch adds the former by extracting the relevant code from risu_i386.c. This patch is pure code motion; no functional changes were made. Reviewed-by: Alex Bennée Signed-off-by: Jan Bobek Reviewed-by: Richard Henderson --- risu_reginfo_i386.h | 37 +++++++++++++++++++++++++++++++++++++ risu_i386.c | 23 +---------------------- 2 files changed, 38 insertions(+), 22 deletions(-) create mode 100644 risu_reginfo_i386.h diff --git a/risu_reginfo_i386.h b/risu_reginfo_i386.h new file mode 100644 index 0000000..5bba439 --- /dev/null +++ b/risu_reginfo_i386.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2010 Linaro Limited + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Peter Maydell (Linaro) - initial implementation + ******************************************************************************/ + +#ifndef RISU_REGINFO_I386_H +#define RISU_REGINFO_I386_H + +/* This is the data structure we pass over the socket. + * It is a simplified and reduced subset of what can + * be obtained with a ucontext_t* + */ +struct reginfo { + uint32_t faulting_insn; + gregset_t gregs; +}; + +#ifndef REG_GS +/* Assume that either we get all these defines or none */ +# define REG_GS 0 +# define REG_FS 1 +# define REG_ES 2 +# define REG_DS 3 +# define REG_ESP 7 +# define REG_TRAPNO 12 +# define REG_EIP 14 +# define REG_EFL 16 +# define REG_UESP 17 +#endif /* !defined(REG_GS) */ + +#endif /* RISU_REGINFO_I386_H */ diff --git a/risu_i386.c b/risu_i386.c index 5e7e01d..6798a78 100644 --- a/risu_i386.c +++ b/risu_i386.c @@ -14,28 +14,7 @@ #include #include "risu.h" - -/* This is the data structure we pass over the socket. - * It is a simplified and reduced subset of what can - * be obtained with a ucontext_t* - */ -struct reginfo { - uint32_t faulting_insn; - gregset_t gregs; -}; - -#ifndef REG_GS -/* Assume that either we get all these defines or none */ -#define REG_GS 0 -#define REG_FS 1 -#define REG_ES 2 -#define REG_DS 3 -#define REG_ESP 7 -#define REG_TRAPNO 12 -#define REG_EIP 14 -#define REG_EFL 16 -#define REG_UESP 17 -#endif +#include "risu_reginfo_i386.h" struct reginfo master_ri, apprentice_ri; From patchwork Fri May 17 22:44:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Bobek X-Patchwork-Id: 10948759 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5FA6912 for ; Fri, 17 May 2019 22:50:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1656280B0 for ; Fri, 17 May 2019 22:50:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEB15284B3; Fri, 17 May 2019 22:50:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 113A7280B0 for ; Fri, 17 May 2019 22:50:03 +0000 (UTC) Received: from localhost ([127.0.0.1]:54760 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlfu-0005UV-Bm for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 May 2019 18:50:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlbH-0001Hb-TU for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRlbG-0005T2-Ca for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:15 -0400 Received: from mail-yb1-xb41.google.com ([2607:f8b0:4864:20::b41]:41326) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRlbG-0005Rq-8E for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:14 -0400 Received: by mail-yb1-xb41.google.com with SMTP id a13so3230074ybl.8 for ; Fri, 17 May 2019 15:45:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2heJh5tCMxArqPxVmn3FS840JL0uYSXskTv3N4HdCKg=; b=jzWEq8BfFj0ZGxNoJkQhZJgUCfzhQXVefTcknyPau2RhGKm923Wf7PBrkUGpxF0skf Oosv4WETA7J3VJWyeGPryuZXbTD4f4TXjIGQXPPndCO7tjj//24RW2kb1eWOPfVVDt1x VuUcJWxQc+CmrJ1voBM78rD/Uo080w5YBxFN/s4ETYXhaDqrumtRkuSvcY5hY2b1dJjz s8AvNVXph5rmtmeE5+JekmC7VHKWte4J4tGJrni2Uds4khSOQa3NWcRFeUz3HQlXxtrd TX5PF2Zx2SZdvkn01V79XRHPemAInW8OkkS2lrSKvUDBsq2gHA/Odd/b/qq4tk3TLV+N 1VpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2heJh5tCMxArqPxVmn3FS840JL0uYSXskTv3N4HdCKg=; b=ten9EngP3eHhvYkmiQijRt+xsHzmmKXaH8AAgoaV3SDeQJHc1RiRiwOMIq5OraAEDt mr9GSGBTnye63KE3c1xV+v3oqzdtbfZNPE1Fdd6nQdxCPTcZGDSW8t7JnuKMMe4Ex/Xi d4xKtRcD5la7k03lI7sIyF8CYHqRkygXggZI8Rso3X0eoo2im+T7wDo8jTFGvlquk8eH gpiiSz6r9DbrXCICsMZf9/Q4EIjgwbOzxR9MgkF8rREsDrc4wpzwiLyxsocJigI6RCiu CQ5GiPkYTWiGaAiZ7samzaATv/ylu5Yj4dSnAz7XrX5LnI9V40sOGQBKN3jhwJCetq42 9drA== X-Gm-Message-State: APjAAAWGRH/+Y8Wk2WzNX5rY52aUXICKG5l3d2DoOzfxJ7eNzRvYs1r+ 1WW3fM8vUzaxamazhS4brUoIkzRCXyhMsA== X-Google-Smtp-Source: APXvYqye3C8YWZd6QMbshI+9wVPb1zH4gvXgPvPF/rw5jukWSepaOCVKorQ1pAVQRCJvFxKtrF/+eA== X-Received: by 2002:a25:a1e6:: with SMTP id a93mr5089114ybi.15.1558133113564; Fri, 17 May 2019 15:45:13 -0700 (PDT) Received: from dionysus.attlocal.net (69-222-133-165.lightspeed.tukrga.sbcglobal.net. [69.222.133.165]) by smtp.gmail.com with ESMTPSA id u73sm2480260ywf.62.2019.05.17.15.45.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 15:45:13 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:44:42 -0400 Message-Id: <20190517224450.15566-4-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517224450.15566-1-jan.bobek@gmail.com> References: <20190517224450.15566-1-jan.bobek@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::b41 Subject: [Qemu-devel] [RISU v2 03/11] risu_i386: move reginfo-related code to risu_reginfo_i386.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Bobek , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In order to build risu successfully for i386, we need files risu_reginfo_i386.{h,c}; this patch adds the latter by extracting the relevant code from risu_i386.c. This patch is pure code motion; no functional changes were made. Reviewed-by: Alex Bennée Signed-off-by: Jan Bobek Reviewed-by: Richard Henderson --- risu_i386.c | 54 ----------------------------------- risu_reginfo_i386.c | 68 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 54 deletions(-) create mode 100644 risu_reginfo_i386.c diff --git a/risu_i386.c b/risu_i386.c index 6798a78..2d2f325 100644 --- a/risu_i386.c +++ b/risu_i386.c @@ -33,43 +33,6 @@ void advance_pc(void *vuc) uc->uc_mcontext.gregs[REG_EIP] += 2; } -static void fill_reginfo(struct reginfo *ri, ucontext_t * uc) -{ - int i; - for (i = 0; i < NGREG; i++) { - switch (i) { - case REG_ESP: - case REG_UESP: - case REG_GS: - case REG_FS: - case REG_ES: - case REG_DS: - case REG_TRAPNO: - case REG_EFL: - /* Don't store these registers as it results in mismatches. - * In particular valgrind has different values for some - * segment registers, and they're boring anyway. - * We really shouldn't be ignoring EFL but valgrind doesn't - * seem to set it right and I don't care to investigate. - */ - ri->gregs[i] = 0xDEADBEEF; - break; - case REG_EIP: - /* Store the offset from the start of the test image */ - ri->gregs[i] = uc->uc_mcontext.gregs[i] - image_start_address; - break; - default: - ri->gregs[i] = uc->uc_mcontext.gregs[i]; - break; - } - } - /* x86 insns aren't 32 bit but we're not really testing x86 so - * this is just to distinguish 'do compare' from 'stop' - */ - ri->faulting_insn = *((uint32_t *) uc->uc_mcontext.gregs[REG_EIP]); -} - - int send_register_info(int sock, void *uc) { struct reginfo ri; @@ -100,23 +63,6 @@ int recv_and_compare_register_info(int sock, void *uc) return resp; } -static char *regname[] = { - "GS", "FS", "ES", "DS", "EDI", "ESI", "EBP", "ESP", - "EBX", "EDX", "ECX", "EAX", "TRAPNO", "ERR", "EIP", - "CS", "EFL", "UESP", "SS", 0 -}; - -static void dump_reginfo(struct reginfo *ri) -{ - int i; - fprintf(stderr, " faulting insn %x\n", ri->faulting_insn); - for (i = 0; i < NGREG; i++) { - fprintf(stderr, " %s: %x\n", regname[i] ? regname[i] : "???", - ri->gregs[i]); - } -} - - /* Print a useful report on the status of the last comparison * done in recv_and_compare_register_info(). This is called on * exit, so need not restrict itself to signal-safe functions. diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c new file mode 100644 index 0000000..e8d671f --- /dev/null +++ b/risu_reginfo_i386.c @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2010 Linaro Limited + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Peter Maydell (Linaro) - initial implementation + ******************************************************************************/ + +#include +#include + +#include "risu.h" +#include "risu_reginfo_i386.h" + +static void fill_reginfo(struct reginfo *ri, ucontext_t * uc) +{ + int i; + for (i = 0; i < NGREG; i++) { + switch (i) { + case REG_ESP: + case REG_UESP: + case REG_GS: + case REG_FS: + case REG_ES: + case REG_DS: + case REG_TRAPNO: + case REG_EFL: + /* Don't store these registers as it results in mismatches. + * In particular valgrind has different values for some + * segment registers, and they're boring anyway. + * We really shouldn't be ignoring EFL but valgrind doesn't + * seem to set it right and I don't care to investigate. + */ + ri->gregs[i] = 0xDEADBEEF; + break; + case REG_EIP: + /* Store the offset from the start of the test image */ + ri->gregs[i] = uc->uc_mcontext.gregs[i] - image_start_address; + break; + default: + ri->gregs[i] = uc->uc_mcontext.gregs[i]; + break; + } + } + /* x86 insns aren't 32 bit but we're not really testing x86 so + * this is just to distinguish 'do compare' from 'stop' + */ + ri->faulting_insn = *((uint32_t *) uc->uc_mcontext.gregs[REG_EIP]); +} + +static char *regname[] = { + "GS", "FS", "ES", "DS", "EDI", "ESI", "EBP", "ESP", + "EBX", "EDX", "ECX", "EAX", "TRAPNO", "ERR", "EIP", + "CS", "EFL", "UESP", "SS", 0 +}; + +static void dump_reginfo(struct reginfo *ri) +{ + int i; + fprintf(stderr, " faulting insn %x\n", ri->faulting_insn); + for (i = 0; i < NGREG; i++) { + fprintf(stderr, " %s: %x\n", regname[i] ? regname[i] : "???", + ri->gregs[i]); + } +} From patchwork Fri May 17 22:44:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Bobek X-Patchwork-Id: 10948761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D6287912 for ; Fri, 17 May 2019 22:50:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5C481FF7E for ; Fri, 17 May 2019 22:50:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B99BC284BD; Fri, 17 May 2019 22:50:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1C068280B0 for ; Fri, 17 May 2019 22:50:09 +0000 (UTC) Received: from localhost ([127.0.0.1]:54778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlg0-0005cM-C5 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 May 2019 18:50:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlbI-0001JI-Up for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRlbH-0005VA-88 for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:16 -0400 Received: from mail-yb1-xb44.google.com ([2607:f8b0:4864:20::b44]:39225) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRlbH-0005U5-3E for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:15 -0400 Received: by mail-yb1-xb44.google.com with SMTP id a3so41178ybr.6 for ; Fri, 17 May 2019 15:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vpgsr3Dz5tYkOfTAdvJCbJ3RLyITFgDknol3fJuhD2w=; b=ADAwan8AEyWxPWevOBMAhGNBcVOmHWOapB1h89tgYqpzWIs1+NTN7wUzaBo584NYX+ OWLwGPVoqDLFWJDTWXvQ8JBuyvMPwGJjc+2Ee+mMtxWpH/4BBsDy7ltW2uVS4wKMojV7 xYhJToMw0QXP9GoBY6UiOPT5GfXL4GhnUGnK9+o7pv5Msm3M7Oc3qK+zJMfs/xQtl4hO xN9cXnybL+M1tRyE7MDi8fRlqIQjLtkdMDlw8/I/0ePdoa9qi+iY6cbAlw650EMPUwSS jGkmye5Is1YMIQl/OTjn22zHCSLW5yb8OTR7njrHP1RSctLju+TpiPrB3EbmgJ7tpxyE MhAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vpgsr3Dz5tYkOfTAdvJCbJ3RLyITFgDknol3fJuhD2w=; b=EQ5ZDsgynuLzXRzVLLtvpHjQmwlgi8NzRCNXo6oQZIpmxouHfvkc6KfUl7iLwI04Yq LbaHfrBN4PrtyfU2tE61o7T5/c7JaXBpj4kT6qa9TCpc988+gJRaoVUSr8Yh2P/UiRJQ ZL6kot21Gu+P1uq/vRQFPWBC/d+MO9jsQkHzFmR6NzA0Uc4HXb4h7h2pruKS5Qbzjpf2 HlHUmVMe/SITa3x3dufRtV49MifFPdM6XJGx8FMu1LfjfYhOIkHUAMJkKEViDZZn6Hc6 0TXUPNU3gW6xeReRwAUVX3MsukHuHEopLwDs3XylIhHHALQwVRfmDEPB5y16wuRWOPlh aD9A== X-Gm-Message-State: APjAAAWb+Gc5iCJUPHWWmVBkN2GSoTJ6S7p26KHev9Ls1kZgc6E0hJRO yCfhHMcVC9a0ETS5fUxcR9iE9fVBmLr8Cw== X-Google-Smtp-Source: APXvYqwhaYk2u3KkUnnXA0PWgMlLsqjderwit0pdVG9MxOGfGo0iHVNg+R7hcvQvL4RiJSt7xBNTiw== X-Received: by 2002:a25:7156:: with SMTP id m83mr27227169ybc.57.1558133114381; Fri, 17 May 2019 15:45:14 -0700 (PDT) Received: from dionysus.attlocal.net (69-222-133-165.lightspeed.tukrga.sbcglobal.net. [69.222.133.165]) by smtp.gmail.com with ESMTPSA id u73sm2480260ywf.62.2019.05.17.15.45.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 15:45:13 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:44:43 -0400 Message-Id: <20190517224450.15566-5-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517224450.15566-1-jan.bobek@gmail.com> References: <20190517224450.15566-1-jan.bobek@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::b44 Subject: [Qemu-devel] [RISU v2 04/11] risu_reginfo_i386: implement arch-specific reginfo interface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Bobek , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP CPU-specific code in risu_reginfo_* is expected to define and export the following symbols: - arch_long_opts, arch_extra_help, process_arch_opt - reginfo_size - reginfo_init - reginfo_is_eq - reginfo_dump, reginfo_dump_mismatch Make risu_reginfo_i386.c implement this interface; and while we're at it, expand the support to x86_64 as well. Suggested-by: Richard Henderson Signed-off-by: Jan Bobek Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée --- risu_reginfo_i386.h | 24 ++++---- risu_reginfo_i386.c | 147 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 127 insertions(+), 44 deletions(-) diff --git a/risu_reginfo_i386.h b/risu_reginfo_i386.h index 5bba439..e350f01 100644 --- a/risu_reginfo_i386.h +++ b/risu_reginfo_i386.h @@ -12,7 +12,8 @@ #ifndef RISU_REGINFO_I386_H #define RISU_REGINFO_I386_H -/* This is the data structure we pass over the socket. +/* + * This is the data structure we pass over the socket. * It is a simplified and reduced subset of what can * be obtained with a ucontext_t* */ @@ -21,17 +22,14 @@ struct reginfo { gregset_t gregs; }; -#ifndef REG_GS -/* Assume that either we get all these defines or none */ -# define REG_GS 0 -# define REG_FS 1 -# define REG_ES 2 -# define REG_DS 3 -# define REG_ESP 7 -# define REG_TRAPNO 12 -# define REG_EIP 14 -# define REG_EFL 16 -# define REG_UESP 17 -#endif /* !defined(REG_GS) */ +/* + * For i386, the defines are named REG_EAX, etc. + * For x86_64, the defines are named REG_RAX, etc. + */ +#ifdef __x86_64__ +# define REG_E(X) REG_R##X +#else +# define REG_E(X) REG_E##X +#endif #endif /* RISU_REGINFO_I386_H */ diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index e8d671f..c4dc14a 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -10,59 +10,144 @@ ******************************************************************************/ #include +#include +#include #include +#include #include "risu.h" #include "risu_reginfo_i386.h" -static void fill_reginfo(struct reginfo *ri, ucontext_t * uc) +const struct option * const arch_long_opts; +const char * const arch_extra_help; + +void process_arch_opt(int opt, const char *arg) +{ + abort(); +} + +const int reginfo_size(void) +{ + return sizeof(struct reginfo); +} + +/* reginfo_init: initialize with a ucontext */ +void reginfo_init(struct reginfo *ri, ucontext_t *uc) { int i; + + memset(ri, 0, sizeof(*ri)); + for (i = 0; i < NGREG; i++) { switch (i) { - case REG_ESP: - case REG_UESP: - case REG_GS: - case REG_FS: - case REG_ES: - case REG_DS: - case REG_TRAPNO: - case REG_EFL: - /* Don't store these registers as it results in mismatches. - * In particular valgrind has different values for some - * segment registers, and they're boring anyway. - * We really shouldn't be ignoring EFL but valgrind doesn't - * seem to set it right and I don't care to investigate. - */ - ri->gregs[i] = 0xDEADBEEF; - break; - case REG_EIP: - /* Store the offset from the start of the test image */ + case REG_E(IP): + /* Store the offset from the start of the test image. */ ri->gregs[i] = uc->uc_mcontext.gregs[i] - image_start_address; break; - default: + case REG_EFL: + /* Store only the "flaggy" bits: SF, ZF, AF, PF, CF. */ + ri->gregs[i] = uc->uc_mcontext.gregs[i] & 0xd5; + break; + case REG_E(SP): + /* Ignore the stack. */ + ri->gregs[i] = 0xdeadbeef; + break; + case REG_E(AX): + case REG_E(BX): + case REG_E(CX): + case REG_E(DX): + case REG_E(DI): + case REG_E(SI): + case REG_E(BP): +#ifdef __x86_64__ + case REG_R8: + case REG_R9: + case REG_R10: + case REG_R11: + case REG_R12: + case REG_R13: + case REG_R14: + case REG_R15: +#endif ri->gregs[i] = uc->uc_mcontext.gregs[i]; break; } } - /* x86 insns aren't 32 bit but we're not really testing x86 so - * this is just to distinguish 'do compare' from 'stop' + + /* + * x86 insns aren't 32 bit but 3 bytes are sufficient to + * distinguish 'do compare' from 'stop'. */ - ri->faulting_insn = *((uint32_t *) uc->uc_mcontext.gregs[REG_EIP]); + ri->faulting_insn = *(uint32_t *)uc->uc_mcontext.gregs[REG_E(IP)]; } -static char *regname[] = { - "GS", "FS", "ES", "DS", "EDI", "ESI", "EBP", "ESP", - "EBX", "EDX", "ECX", "EAX", "TRAPNO", "ERR", "EIP", - "CS", "EFL", "UESP", "SS", 0 +/* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */ +int reginfo_is_eq(struct reginfo *m, struct reginfo *a) +{ + return 0 == memcmp(m, a, sizeof(*m)); +} + +static const char *const regname[NGREG] = { + [REG_EFL] = "eflags", +#ifdef __x86_64__ + [REG_RIP] = "rip", + [REG_RAX] = "rax", + [REG_RBX] = "rbx", + [REG_RCX] = "rcx", + [REG_RDX] = "rdx", + [REG_RDI] = "rdi", + [REG_RSI] = "rsi", + [REG_RBP] = "rbp", + [REG_RSP] = "rsp", + [REG_R8] = "r8", + [REG_R9] = "r9", + [REG_R10] = "r10", + [REG_R11] = "r11", + [REG_R12] = "r12", + [REG_R13] = "r13", + [REG_R14] = "r14", + [REG_R15] = "r15", +#else + [REG_EIP] = "eip", + [REG_EAX] = "eax", + [REG_EBX] = "ebx", + [REG_ECX] = "ecx", + [REG_EDX] = "edx", + [REG_EDI] = "edi", + [REG_ESI] = "esi", + [REG_EBP] = "ebp", + [REG_ESP] = "esp", +#endif }; -static void dump_reginfo(struct reginfo *ri) +#ifdef __x86_64__ +# define PRIxREG "%016llx" +#else +# define PRIxREG "%08x" +#endif + +/* reginfo_dump: print state to a stream, returns nonzero on success */ +int reginfo_dump(struct reginfo *ri, FILE *f) { int i; - fprintf(stderr, " faulting insn %x\n", ri->faulting_insn); + fprintf(f, " faulting insn %x\n", ri->faulting_insn); for (i = 0; i < NGREG; i++) { - fprintf(stderr, " %s: %x\n", regname[i] ? regname[i] : "???", - ri->gregs[i]); + if (regname[i]) { + fprintf(f, " %-6s: " PRIxREG "\n", regname[i], ri->gregs[i]); + } } + return !ferror(f); +} + +int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) +{ + int i; + for (i = 0; i < NGREG; i++) { + if (m->gregs[i] != a->gregs[i]) { + assert(regname[i]); + fprintf(f, "Mismatch: %s: " PRIxREG " v " PRIxREG "\n", + regname[i], m->gregs[i], a->gregs[i]); + } + } + return !ferror(f); } From patchwork Fri May 17 22:44:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Bobek X-Patchwork-Id: 10948755 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFADB912 for ; Fri, 17 May 2019 22:47:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE5A428474 for ; Fri, 17 May 2019 22:47:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2EFC284B3; Fri, 17 May 2019 22:47:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4F7AF28474 for ; Fri, 17 May 2019 22:47:08 +0000 (UTC) Received: from localhost ([127.0.0.1]:54740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRld5-0003Kf-JV for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 May 2019 18:47:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlbJ-0001JN-1C for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRlbI-0005XB-1Z for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:16 -0400 Received: from mail-yb1-xb44.google.com ([2607:f8b0:4864:20::b44]:44837) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRlbH-0005WC-TH for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:15 -0400 Received: by mail-yb1-xb44.google.com with SMTP id t62so3219830ybi.11 for ; Fri, 17 May 2019 15:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=asAnLoiLmn9O1f8JyRCjR6gJZ9RVkxFZTDo//TEA/II=; b=e5NxnRF1hyeOTzaapDBlxabihYu3grKGNhVleIJJ+9bO1nl89UvDsTZyfsBTRaD+SD XZ8ips/Z9kd8bbBgtY4zBDc71JAh2a1IiQ5oeJ0pczuhugmxT9AGpdb/W2P08Q2FViR3 YHWyDHcmbmL8oRFTaj92P7tdMjoHwIu8Fb5n1sHw+0dIOge8gus8su3qzsKudrqvCl4u 3DnhhSttcfkrJIYofxOE2Q6hqwzjG9rUB8fXTFRRW/RKgyk3kfwLiKO/d3XSsBNw0ojj H7qfeOi0zS7bSOVoFcovKoqLhXbJWBqEzoSM4Oa7ZR4h3LibHDCWcGnKZiRw1YTxXDnA FcWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=asAnLoiLmn9O1f8JyRCjR6gJZ9RVkxFZTDo//TEA/II=; b=mIMB50pAsboTQmyW9rX3sVdu+DQcckaLOBRZ7JF9ZrgpZqNrmHhlUEYOKdbR0a2xWa g6pkjRJVTKqHBHQ0N5gXZGwrrw8+J3/Lii9c3N6o7jJ8C9NE7ROmqpWcqbscWaWnVblU DN8wb8iJZiHFV/KDM9udhDOVT5vwCWe8LKVSbfkLGaaSPQMY8r1PM1HAmjaV8Yzdsx2f jNkpQfcUVmii51s2891elzJk++gtg3oNdmAuXX5Jw3Jp98Gr9vPz5Pr8uf8kjJNiUNNJ g68Q5qmqnxXOAFeulN8xMDlDZuH749RL1s/p2+AEKGLGUrl9XcP7KtzdB0aA1W3sOIk5 3cDg== X-Gm-Message-State: APjAAAVIjGgnsfmZ4ccV4kYvi3vnmxvTVOwAWUij6VmT7VVGhnsZLLnt YTZTJ30bcMnlTyzGoTVHdcu6M1eXhBWucA== X-Google-Smtp-Source: APXvYqzr8M7YvB0vj73tDQA3xc6GfIYCse9SO+XAxa9Ih3qTkzhU+PbGP8gjm/89kvucL6x64GfAXA== X-Received: by 2002:a25:e801:: with SMTP id k1mr5960665ybd.266.1558133115287; Fri, 17 May 2019 15:45:15 -0700 (PDT) Received: from dionysus.attlocal.net (69-222-133-165.lightspeed.tukrga.sbcglobal.net. [69.222.133.165]) by smtp.gmail.com with ESMTPSA id u73sm2480260ywf.62.2019.05.17.15.45.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 15:45:14 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:44:44 -0400 Message-Id: <20190517224450.15566-6-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517224450.15566-1-jan.bobek@gmail.com> References: <20190517224450.15566-1-jan.bobek@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::b44 Subject: [Qemu-devel] [RISU v2 05/11] risu_i386: implement missing CPU-specific functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Bobek , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP risu_i386.c is expected to implement the following functions: - advance_pc - get_reginfo_paramreg, set_ucontext_paramreg - get_risuop - get_pc This patch adds the necessary code. We use EAX as the parameter register and opcode "UD1 %xxx,%eax" for triggering RISU actions. Suggested-by: Richard Henderson Signed-off-by: Jan Bobek Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée --- risu_i386.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/risu_i386.c b/risu_i386.c index 2d2f325..06d95e5 100644 --- a/risu_i386.c +++ b/risu_i386.c @@ -25,12 +25,37 @@ static int insn_is_ud2(uint32_t insn) void advance_pc(void *vuc) { - /* We assume that this is either UD1 or UD2. - * This would need tweaking if we want to test - * expected undefs on x86. + ucontext_t *uc = (ucontext_t *) vuc; + + /* + * We assume that this is UD1 as per get_risuop below. + * This would need tweaking if we want to test expected undefs. */ - ucontext_t *uc = vuc; - uc->uc_mcontext.gregs[REG_EIP] += 2; + uc->uc_mcontext.gregs[REG_E(IP)] += 3; +} + +void set_ucontext_paramreg(void *vuc, uint64_t value) +{ + ucontext_t *uc = (ucontext_t *) vuc; + uc->uc_mcontext.gregs[REG_E(AX)] = value; +} + +uint64_t get_reginfo_paramreg(struct reginfo *ri) +{ + return ri->gregs[REG_E(AX)]; +} + +int get_risuop(struct reginfo *ri) +{ + if ((ri->faulting_insn & 0xf8ffff) == 0xc0b90f) { /* UD1 %xxx,%eax */ + return (ri->faulting_insn >> 16) & 7; + } + return -1; +} + +uintptr_t get_pc(struct reginfo *ri) +{ + return ri->gregs[REG_E(IP)]; } int send_register_info(int sock, void *uc) From patchwork Fri May 17 22:44:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Bobek X-Patchwork-Id: 10948757 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7CE976 for ; Fri, 17 May 2019 22:49:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D568828474 for ; Fri, 17 May 2019 22:49:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7F21284B3; Fri, 17 May 2019 22:49:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 69A0328474 for ; Fri, 17 May 2019 22:49:56 +0000 (UTC) Received: from localhost ([127.0.0.1]:54758 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlfn-0005Ns-Hf for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 May 2019 18:49:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlbK-0001KQ-3G for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRlbJ-0005Zg-11 for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:18 -0400 Received: from mail-yb1-xb41.google.com ([2607:f8b0:4864:20::b41]:33290) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRlbI-0005Yg-SC for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:16 -0400 Received: by mail-yb1-xb41.google.com with SMTP id k128so1597218ybf.0 for ; Fri, 17 May 2019 15:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7+yQx6OLxf+FYJ6x1tpH2MOMowTuy0Bufj466O5eB5Q=; b=B+xj45yMVSCbvtpPUuFWgPhf/Wg7HJ41aW/rDILhKzKJuUhm+QYkeJG/FEMtNs2uiM JHcboJQhN2FK2SSl1haLAFrCvwi3yVmL6Fd/R1aIDLymRLNwrBXmHgp8QMxDznWhDl8J nVLQh9u+z8yd2+hzg0Rb4PtoiAk6MnjuU7YEkMrVviDbmXBgKGsdjhFF7KAMfswrp36s apF4OodbN73piRNIWuVF8J6PeCqAbGFS9VEqz6Vsx0d7qC7HmyeTVrzvTNFkvxXtb/ys hnj9SVGlTEYyw5zg+BIuknNFyVikEx3HNxVgnViPDoToas/fVU/3APjyF/HfnZ5SNeQ+ 23vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7+yQx6OLxf+FYJ6x1tpH2MOMowTuy0Bufj466O5eB5Q=; b=VqdKIDUVRffyn5grcx5Qp7AecjdQlsxPaSC3pbVnEjOUSeKiTvOX1XTsNTeI1t0FBC 2XOXqAc4YF6AsRGjV3eJ3KX0GWcexoPPgU/s4AQgzWXeSEpG+VR+bqHvyIH06tNPnqvM mxIQ2BjLAK0PuZ9Jv3SfcojOWqgBZ2Mu8lvbOmxyZWF+3fvdAxAtbSqBLU9nG99jdnAH cs0oZLAcuwxLB7jcXI6Dd9LoE5goTpkIUvxDQgUbrJoRtVV3IGY6CGRyQf9yiFLK7CRX 5Et9mrS+KUVQ5oqFQX8/Jk1GZeolV8phgPoX0gcxEGgwh+c0oTKUgZRsu8qylYUbsFlt VvHg== X-Gm-Message-State: APjAAAVP9V8UTWGrc4uJ3nplLUYV0wK/ZGuWQPMvBFXppSS6qv9fHzDz pAWx7a5zTMc+V3DeV4GePgoxMXfkDKhT7w== X-Google-Smtp-Source: APXvYqzfjpvKZYxPTPIXCjTPpehftjtuaKvuvKNoha09Q1hUkqAJsCreJYThWG5H1W9vaMScZZqK6A== X-Received: by 2002:a25:ba0c:: with SMTP id t12mr28684641ybg.70.1558133116318; Fri, 17 May 2019 15:45:16 -0700 (PDT) Received: from dionysus.attlocal.net (69-222-133-165.lightspeed.tukrga.sbcglobal.net. [69.222.133.165]) by smtp.gmail.com with ESMTPSA id u73sm2480260ywf.62.2019.05.17.15.45.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 15:45:15 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:44:45 -0400 Message-Id: <20190517224450.15566-7-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517224450.15566-1-jan.bobek@gmail.com> References: <20190517224450.15566-1-jan.bobek@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::b41 Subject: [Qemu-devel] [RISU v2 06/11] risu_i386: remove old unused code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Bobek , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The code being removed is a remnant of the past implementation; it has since been replaced by its more powerful, architecture-independent counterpart in reginfo.c. Reviewed-by: Alex Bennée Signed-off-by: Jan Bobek Reviewed-by: Richard Henderson --- risu_i386.c | 58 ----------------------------------------------------- 1 file changed, 58 deletions(-) diff --git a/risu_i386.c b/risu_i386.c index 06d95e5..9962b8f 100644 --- a/risu_i386.c +++ b/risu_i386.c @@ -16,13 +16,6 @@ #include "risu.h" #include "risu_reginfo_i386.h" -struct reginfo master_ri, apprentice_ri; - -static int insn_is_ud2(uint32_t insn) -{ - return ((insn & 0xffff) == 0x0b0f); -} - void advance_pc(void *vuc) { ucontext_t *uc = (ucontext_t *) vuc; @@ -57,54 +50,3 @@ uintptr_t get_pc(struct reginfo *ri) { return ri->gregs[REG_E(IP)]; } - -int send_register_info(int sock, void *uc) -{ - struct reginfo ri; - fill_reginfo(&ri, uc); - return send_data_pkt(sock, &ri, sizeof(ri)); -} - -/* Read register info from the socket and compare it with that from the - * ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch. - * NB: called from a signal handler. - */ -int recv_and_compare_register_info(int sock, void *uc) -{ - int resp; - fill_reginfo(&master_ri, uc); - recv_data_pkt(sock, &apprentice_ri, sizeof(apprentice_ri)); - if (memcmp(&master_ri, &apprentice_ri, sizeof(master_ri)) != 0) { - /* mismatch */ - resp = 2; - } else if (insn_is_ud2(master_ri.faulting_insn)) { - /* end of test */ - resp = 1; - } else { - /* either successful match or expected undef */ - resp = 0; - } - send_response_byte(sock, resp); - return resp; -} - -/* Print a useful report on the status of the last comparison - * done in recv_and_compare_register_info(). This is called on - * exit, so need not restrict itself to signal-safe functions. - * Should return 0 if it was a good match (ie end of test) - * and 1 for a mismatch. - */ -int report_match_status(void) -{ - fprintf(stderr, "match status...\n"); - fprintf(stderr, "master reginfo:\n"); - dump_reginfo(&master_ri); - fprintf(stderr, "apprentice reginfo:\n"); - dump_reginfo(&apprentice_ri); - if (memcmp(&master_ri, &apprentice_ri, sizeof(master_ri)) == 0) { - fprintf(stderr, "match!\n"); - return 0; - } - fprintf(stderr, "mismatch!\n"); - return 1; -} From patchwork Fri May 17 22:44:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Bobek X-Patchwork-Id: 10948763 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3553A76 for ; Fri, 17 May 2019 22:50:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 007C7280B0 for ; Fri, 17 May 2019 22:50:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFE7D284BF; Fri, 17 May 2019 22:50:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 73476280B0 for ; Fri, 17 May 2019 22:50:13 +0000 (UTC) Received: from localhost ([127.0.0.1]:54784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlg4-0005eR-MV for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 May 2019 18:50:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlbL-0001La-8z for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRlbJ-0005c2-U0 for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:19 -0400 Received: from mail-yw1-xc44.google.com ([2607:f8b0:4864:20::c44]:39785) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRlbJ-0005at-P8 for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:17 -0400 Received: by mail-yw1-xc44.google.com with SMTP id w21so3353064ywd.6 for ; Fri, 17 May 2019 15:45:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KO9FR2wnB/UsZf46rgIZq75rCEsrhLW+LB3x7uowhw8=; b=Nu8+oHqhDejdPKOeHI906DhMTh82QwXVqr7QY7v8t6SHUiZkFoJ4RdAq5O2s1vyWNA 0b6JgzlIZkQ/cddTviXgI/00lQuUSLAyIVGK/gXlusGjWt0GO6bEyOn+J0Q9wMx8fQl/ iBVLfBJRG/ukDT/63afRkBscFTjawF5OJXR44k/pckEdGe9NAVZ9tclTRWuVYeFLLySA KAIS2hVKGEdBNUE2mnVQIMfT3PQu+GeFPZf+YXJpRG/h6l+Pet9Iq4R+QHOgQVGaMfZB KTp3ZUx7F9dmcIWyrYGPGYIMay+4lEX1/s7Rs/LQlHV8VmwYlSMvIsKcCQLOviD7Gcxf xmcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KO9FR2wnB/UsZf46rgIZq75rCEsrhLW+LB3x7uowhw8=; b=p7b5kaB0RTRDbR/i8/oZa47qILfI8RJ1ABap+GmZysemGvZ/evlyeK9kLCTh460Rde vxdgzoGD1oCUykTorfYVg9BJHPvzN1WiOai1b1zRS9Q4+jxqbWwEMEGntTirONl+iEIa pG9DQRXpUdhfq4US3gvojXhfcXY09ZItf2RCaJ9lGYNv8OJzqgF7jZz+8MQMvZxjg0o8 N5eDP/vl7o5i0ZbY+paDXHh0pxdtJGMr1HzHO6DvcdhysKUqav+hYWqMJK9qgla7dkIc 5oxAz+r5UluPxQdOWanv//+Ft5pcvAhkcS9vanCpBjJ7pjLOlgLgAy6ZRaFXLkE3jcmn ENwg== X-Gm-Message-State: APjAAAXehIAhtDninQXxF4uQJD64eOud1IDkOdauDdmqSYorXzj6xQZE DEse8hwXRd+/QCNF3MvE2rj/DepYV1uYWQ== X-Google-Smtp-Source: APXvYqw4htd6MxDmKAdNhCrCu4wixDBKwpJBMJS5eiWqOjm4D14x8I32SjoSvVrz2JwDkmouFBdFMA== X-Received: by 2002:a81:9982:: with SMTP id q124mr15064034ywg.493.1558133117048; Fri, 17 May 2019 15:45:17 -0700 (PDT) Received: from dionysus.attlocal.net (69-222-133-165.lightspeed.tukrga.sbcglobal.net. [69.222.133.165]) by smtp.gmail.com with ESMTPSA id u73sm2480260ywf.62.2019.05.17.15.45.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 15:45:16 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:44:46 -0400 Message-Id: <20190517224450.15566-8-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517224450.15566-1-jan.bobek@gmail.com> References: <20190517224450.15566-1-jan.bobek@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::c44 Subject: [Qemu-devel] [RISU v2 07/11] test_i386: change syntax from nasm to gas X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Bobek , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This allows us to drop dependency on NASM and build the test image with GCC only. Adds support for x86_64, too. Suggested-by: Richard Henderson Signed-off-by: Jan Bobek Reviewed-by: Richard Henderson --- Makefile | 3 +++ test_i386.S | 41 +++++++++++++++++++++++++++++++++++++++++ test_i386.s | 27 --------------------------- 3 files changed, 44 insertions(+), 27 deletions(-) create mode 100644 test_i386.S delete mode 100644 test_i386.s diff --git a/Makefile b/Makefile index b362dbe..6ab014a 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,9 @@ $(PROG): $(OBJS) %_$(ARCH).elf: %_$(ARCH).s $(AS) -o $@ $< +%_$(ARCH).elf: %_$(ARCH).S + $(CC) $(CPPFLAGS) -o $@ -c $< + clean: rm -f $(PROG) $(OBJS) $(BINS) diff --git a/test_i386.S b/test_i386.S new file mode 100644 index 0000000..456b99c --- /dev/null +++ b/test_i386.S @@ -0,0 +1,41 @@ +/*############################################################################# + * Copyright (c) 2010 Linaro Limited + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Peter Maydell (Linaro) - initial implementation + *###########################################################################*/ + +/* A trivial test image for x86 */ + +/* Initialise the registers to avoid spurious mismatches */ + xor %eax, %eax + sahf /* init eflags */ + + mov $0x12345678, %eax + mov $0x9abcdef0, %ebx + mov $0x97361234, %ecx + mov $0x84310284, %edx + mov $0x83624173, %edi + mov $0xfaebfaeb, %esi + mov $0x84610123, %ebp + +#ifdef __x86_64__ + movq $0x123456789abcdef0, %r8 + movq $0xaaaabbbbccccdddd, %r9 + movq $0x1010101010101010, %r10 + movq $0x1111111111111111, %r11 + movq $0x1212121212121212, %r12 + movq $0x1313131313131313, %r13 + movq $0x1414141414141414, %r14 + movq $0x1515151515151515, %r15 +#endif + +/* do compare */ + ud1 %eax, %eax + +/* exit test */ + ud1 %ecx, %eax diff --git a/test_i386.s b/test_i386.s deleted file mode 100644 index a2140a0..0000000 --- a/test_i386.s +++ /dev/null @@ -1,27 +0,0 @@ -;############################################################################### -;# Copyright (c) 2010 Linaro Limited -;# All rights reserved. This program and the accompanying materials -;# are made available under the terms of the Eclipse Public License v1.0 -;# which accompanies this distribution, and is available at -;# http://www.eclipse.org/legal/epl-v10.html -;# -;# Contributors: -;# Peter Maydell (Linaro) - initial implementation -;############################################################################### - -; A trivial test image for x86 - -BITS 32 -; Initialise the registers to avoid spurious mismatches -mov eax, 0x12345678 -mov ebx, 0x9abcdef0 -mov ecx, 0x97361234 -mov edx, 0x84310284 -mov edi, 0x83624173 -mov esi, 0xfaebfaeb -mov ebp, 0x84610123 -; UD1 : do compare -UD1 - -; UD2 : exit test -UD2 From patchwork Fri May 17 22:44:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Bobek X-Patchwork-Id: 10948767 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CA7C112C for ; Fri, 17 May 2019 22:52:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B7AF1FF7E for ; Fri, 17 May 2019 22:52:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3AB0284BD; Fri, 17 May 2019 22:52:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AA88C1FF7E for ; Fri, 17 May 2019 22:52:53 +0000 (UTC) Received: from localhost ([127.0.0.1]:54818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlie-00083x-R5 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 May 2019 18:52:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlbL-0001Lx-N0 for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRlbK-0005ea-Ow for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:19 -0400 Received: from mail-yw1-xc33.google.com ([2607:f8b0:4864:20::c33]:34568) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRlbK-0005d8-Kc for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:18 -0400 Received: by mail-yw1-xc33.google.com with SMTP id n76so3367125ywd.1 for ; Fri, 17 May 2019 15:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hhGYRrDTg0TV6d2VhrzIbknIoq/1n1f5yDRC8WcG6PA=; b=UsKESoLN7jGxG8KS7Kq3KCtUsA9sbDZ3dokQ8i/ynROsDFc/h4FwdQLYCMvFfVIDSl 3/qQvruR10kaoWnHuRfPlxOHVPvLaGaA90yL34lwhPrKCOkgMw+/QkfNwhnyAUFj8le6 LqN6gLDJrt3STsoGoZLlmMTdOsl2EPAhML3A/r38xso6v7L3cgckkCYu1u1VST/U+2Z3 k7IxZLsVXJne0nwMx5rNh+rUxsrIXfYPwXzHFUU8WakH6cJfo5TykjyjGVI3N/r+hrB/ +gyorbyGTxCziIFJbCbrhJQ8PNvedivI8erKzGa+gmLOgwOFzl8d1waS6TbmDlxIIRdh 6FRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hhGYRrDTg0TV6d2VhrzIbknIoq/1n1f5yDRC8WcG6PA=; b=iyD5+u23j9t32mbBd9ecgYoDlPTVzLpmEDn6AvtZ14FkuyXvSc3cwLUmbN/QeeQnkC WBF2glX3bqxXhqQVVLn8wo80NN+l/uSzk5YVvhRtPoWLWLaClPjotvcY0vRu32912A7j 0qX0ngYseBuFmEDIaGYAoSHBLV3+m8cm7XRVm84PhQPIce/wW1laZqsD/tISEgIkCjMM bS+mmwNhsAnx+S/i1+/Sm6dNbxf3lc5O2ZDS8f5+De1P6aS0s4bAdhrcD16Qa0liYavN 8nL88P80a5uNUzx4TDoF98oGupd/Ro+FbWuOo6qRZiYnkWb/60afUF1y7Z16zDPaG+K2 fEMA== X-Gm-Message-State: APjAAAV5plhG1hl5DKasDpPhWiyVo8f3HD7cmSaB61mpVIMrI74Ca8Ni +JQus/EODS2/IEyHRPqGc8a4HFL57LJdzQ== X-Google-Smtp-Source: APXvYqxadDli5Gt6iPHTuf+iFlOzl76TzYdrHqeDq/Mg8j/8FalIZZ07lCMdP+Zp8lUr8bm4Iza33w== X-Received: by 2002:a81:2f45:: with SMTP id v66mr17907151ywv.491.1558133117853; Fri, 17 May 2019 15:45:17 -0700 (PDT) Received: from dionysus.attlocal.net (69-222-133-165.lightspeed.tukrga.sbcglobal.net. [69.222.133.165]) by smtp.gmail.com with ESMTPSA id u73sm2480260ywf.62.2019.05.17.15.45.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 15:45:17 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:44:47 -0400 Message-Id: <20190517224450.15566-9-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517224450.15566-1-jan.bobek@gmail.com> References: <20190517224450.15566-1-jan.bobek@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::c33 Subject: [Qemu-devel] [RISU v2 08/11] configure: add i386/x86_64 architectures X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Bobek , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Now that i386 and x86_64 architectures are supported by RISU, we want to detect them and build RISU for them automatically. Suggested-by: Richard Henderson Signed-off-by: Jan Bobek Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée --- configure | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 65e1819..ca2d7db 100755 --- a/configure +++ b/configure @@ -48,12 +48,14 @@ EOF } guess_arch() { - if check_define __m68k__ ; then - ARCH="m68k" + if check_define __aarch64__ ; then + ARCH="aarch64" elif check_define __arm__ ; then ARCH="arm" - elif check_define __aarch64__ ; then - ARCH="aarch64" + elif check_define __i386__ || check_define __x86_64__ ; then + ARCH="i386" + elif check_define __m68k__ ; then + ARCH="m68k" elif check_define __powerpc64__ ; then ARCH="ppc64" else From patchwork Fri May 17 22:44:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Bobek X-Patchwork-Id: 10948791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFE9F112C for ; Fri, 17 May 2019 22:55:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D1F727F88 for ; Fri, 17 May 2019 22:55:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9177828434; Fri, 17 May 2019 22:55:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C09E827F88 for ; Fri, 17 May 2019 22:55:28 +0000 (UTC) Received: from localhost ([127.0.0.1]:54888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRllA-0001jp-5w for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 May 2019 18:55:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlbN-0001MI-HK for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRlbL-0005hC-OU for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:21 -0400 Received: from mail-yb1-xb41.google.com ([2607:f8b0:4864:20::b41]:37681) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRlbL-0005g0-IG for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:19 -0400 Received: by mail-yb1-xb41.google.com with SMTP id p134so3241429ybc.4 for ; Fri, 17 May 2019 15:45:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GAv4G2PUfIt35FCB0/KIHsJkbnKZpm2yjnfZz6BlY9k=; b=e1/58Ttjfxq38pEBI0xyF0NC47hPdjqCkrBFIZgBjUNdEgKRb0hUrW48z50PbmB0TC miKhBCq2uEPZXuBWVw06U1i+3eHiDncvkmbnDF8jhOUZfWNZdriJqXPUtyVH0zh8Ab6u 1w68Kq1Kf3Zp+8yWqRrZUyt0BF6O6Vhm9hfRCwYhp0oiYsqA8VH71w2xnign9WFynTWt w1bw9Otgz2VwjOGTR8Go/hBEPSi6Ke3COSxOHtZPfj+p3SZ04r8bAOT6HKYnY/rOld+D s+5mD4w4ckULIY4JB8+fvEviGbB/wmKMyoO+utswLGeBnRwUD+fPEd1s58bMRRSgn8mq B62w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GAv4G2PUfIt35FCB0/KIHsJkbnKZpm2yjnfZz6BlY9k=; b=rQ7DpzuvNupTTEEJtmRV1VgQV708xh8iyjfHmZgByywAyYXF50QsFvnR1wjj7EvueL EJesf35Imp0X9KS3buoqpjVDKTyM3SGpUTiiZgldWJrn/9SFdZjeH9iKE9MqPBukNpaG Nw2eDVlJpNdoYQbRNLuoGUxn/Phx7217aIW1iJlhfy8REUP2WqgCLwIg2H4iuGK3+W7j y8o+RpxYkXDNuQ7Ehw19NWBTooI69pLeWm3htVxEG2CeEn7kfsWxKWFirQcuenMpx5lH dZ2LlPEXgA6RBeHSvb/s5vBHA9A6fTJQXfRQTegiCrPKgR2+XMFu88WQA31jaqdj2qZK +hqQ== X-Gm-Message-State: APjAAAUcGEqeiN92MOc/SZBjIp2cG4h/4G5je25lgXdh1lLxeElCzMBr ezugpbNcuH1O4qV0gMiYhVw2OQKEqSLxzg== X-Google-Smtp-Source: APXvYqwYBxDYOMp9yksnIWZTVZ4LKfZXOvYGI7pm4/wqWBaczJAbxWeNVHq/Q9lQxfgCs01Uao4saQ== X-Received: by 2002:a25:420b:: with SMTP id p11mr26869175yba.179.1558133118784; Fri, 17 May 2019 15:45:18 -0700 (PDT) Received: from dionysus.attlocal.net (69-222-133-165.lightspeed.tukrga.sbcglobal.net. [69.222.133.165]) by smtp.gmail.com with ESMTPSA id u73sm2480260ywf.62.2019.05.17.15.45.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 15:45:18 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:44:48 -0400 Message-Id: <20190517224450.15566-10-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517224450.15566-1-jan.bobek@gmail.com> References: <20190517224450.15566-1-jan.bobek@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::b41 Subject: [Qemu-devel] [RISU v2 09/11] i386: Add avx512 state to reginfo_t X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Richard Henderson The state expected for a given test must be specifically requested with the --xfeatures=mask command-line argument. This is recorded with the saved state so that it is obvious if the apprentice is given a different argument. Any features beyond what are present on the running cpu will read as zero. Signed-off-by: Richard Henderson --- risu_reginfo_i386.h | 14 +++ risu_reginfo_i386.c | 228 ++++++++++++++++++++++++++++++++++++++++++-- test_i386.S | 39 ++++++++ 3 files changed, 273 insertions(+), 8 deletions(-) diff --git a/risu_reginfo_i386.h b/risu_reginfo_i386.h index e350f01..b468f79 100644 --- a/risu_reginfo_i386.h +++ b/risu_reginfo_i386.h @@ -12,6 +12,10 @@ #ifndef RISU_REGINFO_I386_H #define RISU_REGINFO_I386_H +struct avx512_reg { + uint64_t q[8]; +}; + /* * This is the data structure we pass over the socket. * It is a simplified and reduced subset of what can @@ -19,7 +23,17 @@ */ struct reginfo { uint32_t faulting_insn; + uint32_t mxcsr; + uint64_t xfeatures; + gregset_t gregs; + +#ifdef __x86_64__ + struct avx512_reg vregs[32]; +#else + struct avx512_reg vregs[8]; +#endif + uint64_t kregs[8]; }; /* diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index c4dc14a..35ff7c8 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -11,19 +11,32 @@ #include #include +#include #include #include #include +#include #include "risu.h" #include "risu_reginfo_i386.h" -const struct option * const arch_long_opts; -const char * const arch_extra_help; +#include + +static uint64_t xfeatures = 3; /* SSE */ + +static const struct option extra_ops[] = { + {"xfeatures", required_argument, NULL, FIRST_ARCH_OPT }, + {0, 0, 0, 0} +}; + +const struct option * const arch_long_opts = extra_ops; +const char * const arch_extra_help + = " --xfeatures= Use features in mask for XSAVE\n"; void process_arch_opt(int opt, const char *arg) { - abort(); + assert(opt == FIRST_ARCH_OPT); + xfeatures = strtoull(arg, 0, 0); } const int reginfo_size(void) @@ -31,13 +44,37 @@ const int reginfo_size(void) return sizeof(struct reginfo); } +static void *xsave_feature_buf(struct _xstate *xs, int feature) +{ + unsigned int eax, ebx, ecx, edx; + int ok; + + /* + * Get the location of the XSAVE feature from the cpuid leaf. + * Given that we know the xfeature bit is set, this must succeed. + */ + ok = __get_cpuid_count(0xd, feature, &eax, &ebx, &ecx, &edx); + assert(ok); + + /* Sanity check that the frame stored by the kernel contains the data. */ + assert(xs->fpstate.sw_reserved.extended_size >= eax + ebx); + + return (void *)xs + ebx; +} + /* reginfo_init: initialize with a ucontext */ void reginfo_init(struct reginfo *ri, ucontext_t *uc) { - int i; + int i, nvecregs; + struct _fpstate *fp; + struct _xstate *xs; + uint64_t features; memset(ri, 0, sizeof(*ri)); + /* Require master and apprentice to be given the same arguments. */ + ri->xfeatures = xfeatures; + for (i = 0; i < NGREG; i++) { switch (i) { case REG_E(IP): @@ -79,12 +116,89 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) * distinguish 'do compare' from 'stop'. */ ri->faulting_insn = *(uint32_t *)uc->uc_mcontext.gregs[REG_E(IP)]; + + /* + * FP state is omitted if unused (aka in init state). + * Use the struct for access to AVX state. + */ + + fp = (struct _fpstate *)uc->uc_mcontext.fpregs; + if (fp == NULL) { + return; + } + +#ifdef __x86_64__ + nvecregs = 16; +#else + /* We don't (currently) care about the 80387 state, only SSE+. */ + if (fp->magic != X86_FXSR_MAGIC) { + return; + } + nvecregs = 8; +#endif + + /* + * Now we know that _fpstate contains FXSAVE data. + */ + ri->mxcsr = fp->mxcsr; + + for (i = 0; i < nvecregs; ++i) { +#ifdef __x86_64__ + memcpy(&ri->vregs[i], &fp->xmm_space[i], 16); +#else + memcpy(&ri->vregs[i], &fp->_xmm[i * 4], 16); +#endif + } + + if (fp->sw_reserved.magic1 != FP_XSTATE_MAGIC1) { + return; + } + xs = (struct _xstate *)fp; + features = xfeatures & xs->xstate_hdr.xfeatures; + + /* + * Now we know that _fpstate contains XSAVE data. + */ + + if (features & (1 << 2)) { + /* YMM_Hi128 state */ + void *buf = xsave_feature_buf(xs, 2); + for (i = 0; i < nvecregs; ++i) { + memcpy(&ri->vregs[i].q[2], buf + 16 * i, 16); + } + } + + if (features & (1 << 5)) { + /* Opmask state */ + uint64_t *buf = xsave_feature_buf(xs, 5); + for (i = 0; i < 8; ++i) { + ri->kregs[i] = buf[i]; + } + } + + if (features & (1 << 6)) { + /* ZMM_Hi256 state */ + void *buf = xsave_feature_buf(xs, 6); + for (i = 0; i < nvecregs; ++i) { + memcpy(&ri->vregs[i].q[4], buf + 32 * i, 32); + } + } + +#ifdef __x86_64__ + if (features & (1 << 7)) { + /* Hi16_ZMM state */ + void *buf = xsave_feature_buf(xs, 7); + for (i = 0; i < 16; ++i) { + memcpy(&ri->vregs[i + 16], buf + 64 * i, 64); + } + } +#endif } /* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */ int reginfo_is_eq(struct reginfo *m, struct reginfo *a) { - return 0 == memcmp(m, a, sizeof(*m)); + return !memcmp(m, a, sizeof(*m)); } static const char *const regname[NGREG] = { @@ -126,28 +240,126 @@ static const char *const regname[NGREG] = { # define PRIxREG "%08x" #endif +static int get_nvecregs(uint64_t features) +{ +#ifdef __x86_64__ + return features & (1 << 7) ? 32 : 16; +#else + return 8; +#endif +} + +static int get_nvecquads(uint64_t features) +{ + if (features & (1 << 6)) { + return 8; + } else if (features & (1 << 2)) { + return 4; + } else { + return 2; + } +} + +static char get_vecletter(uint64_t features) +{ + if (features & (1 << 6 | 1 << 7)) { + return 'z'; + } else if (features & (1 << 2)) { + return 'y'; + } else { + return 'x'; + } +} + /* reginfo_dump: print state to a stream, returns nonzero on success */ int reginfo_dump(struct reginfo *ri, FILE *f) { - int i; + uint64_t features; + int i, j, n, w; + char r; + fprintf(f, " faulting insn %x\n", ri->faulting_insn); for (i = 0; i < NGREG; i++) { if (regname[i]) { fprintf(f, " %-6s: " PRIxREG "\n", regname[i], ri->gregs[i]); } } + + fprintf(f, " mxcsr : %x\n", ri->mxcsr); + fprintf(f, " xfeat : %" PRIx64 "\n", ri->xfeatures); + + features = ri->xfeatures; + n = get_nvecregs(features); + w = get_nvecquads(features); + r = get_vecletter(features); + + for (i = 0; i < n; i++) { + fprintf(f, " %cmm%-3d: ", r, i); + for (j = w - 1; j >= 0; j--) { + fprintf(f, "%016" PRIx64 "%c", + ri->vregs[i].q[j], j == 0 ? '\n' : ' '); + } + } + + if (features & (1 << 5)) { + for (i = 0; i < 8; i++) { + fprintf(f, " k%-5d: %016" PRIx64 "\n", i, ri->kregs[i]); + } + } + return !ferror(f); } int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f) { - int i; + int i, j, n, w; + uint64_t features; + char r; + + fprintf(f, "Mismatch (master v apprentice):\n"); + for (i = 0; i < NGREG; i++) { if (m->gregs[i] != a->gregs[i]) { assert(regname[i]); - fprintf(f, "Mismatch: %s: " PRIxREG " v " PRIxREG "\n", + fprintf(f, " %-6s: " PRIxREG " v " PRIxREG "\n", regname[i], m->gregs[i], a->gregs[i]); } } + + if (m->mxcsr != a->mxcsr) { + fprintf(f, " mxcsr : %x v %x\n", m->mxcsr, a->mxcsr); + } + if (m->xfeatures != a->xfeatures) { + fprintf(f, " xfeat : %" PRIx64 " v %" PRIx64 "\n", + m->xfeatures, a->xfeatures); + } + + features = m->xfeatures; + n = get_nvecregs(features); + w = get_nvecquads(features); + r = get_vecletter(features); + + for (i = 0; i < n; i++) { + if (memcmp(&m->vregs[i], &a->vregs[i], w * 8)) { + fprintf(f, " %cmm%-3d: ", r, i); + for (j = w - 1; j >= 0; j--) { + fprintf(f, "%016" PRIx64 "%c", + m->vregs[i].q[j], j == 0 ? '\n' : ' '); + } + fprintf(f, " v: "); + for (j = w - 1; j >= 0; j--) { + fprintf(f, "%016" PRIx64 "%c", + a->vregs[i].q[j], j == 0 ? '\n' : ' '); + } + } + } + + for (i = 0; i < 8; i++) { + if (m->kregs[i] != a->kregs[i]) { + fprintf(f, " k%-5d: %016" PRIx64 " v %016" PRIx64 "\n", + i, m->kregs[i], a->kregs[i]); + } + } + return !ferror(f); } diff --git a/test_i386.S b/test_i386.S index 456b99c..05344d7 100644 --- a/test_i386.S +++ b/test_i386.S @@ -12,6 +12,37 @@ /* A trivial test image for x86 */ /* Initialise the registers to avoid spurious mismatches */ + +#ifdef __x86_64__ +#define BASE %rax + lea 2f(%rip), BASE +#else +#define BASE %eax + call 1f +1: pop BASE + add $2f-1b, BASE +#endif + + movdqa 0(BASE), %xmm0 + movdqa 1*16(BASE), %xmm1 + movdqa 2*16(BASE), %xmm2 + movdqa 3*16(BASE), %xmm3 + movdqa 4*16(BASE), %xmm4 + movdqa 5*16(BASE), %xmm5 + movdqa 6*16(BASE), %xmm6 + movdqa 7*16(BASE), %xmm7 + +#ifdef __x86_64__ + movdqa 8*16(BASE), %xmm8 + movdqa 9*16(BASE), %xmm9 + movdqa 10*16(BASE), %xmm10 + movdqa 11*16(BASE), %xmm11 + movdqa 12*16(BASE), %xmm12 + movdqa 13*16(BASE), %xmm13 + movdqa 14*16(BASE), %xmm14 + movdqa 15*16(BASE), %xmm15 +#endif + xor %eax, %eax sahf /* init eflags */ @@ -39,3 +70,11 @@ /* exit test */ ud1 %ecx, %eax + + .p2align 16 +2: + .set i, 0 + .rept 256 + .byte i + .set i, i + 1 + .endr From patchwork Fri May 17 22:44:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Bobek X-Patchwork-Id: 10948765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 720D3112C for ; Fri, 17 May 2019 22:52:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57ED21FF7E for ; Fri, 17 May 2019 22:52:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A8AF284BD; Fri, 17 May 2019 22:52:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C08CC1FF7E for ; Fri, 17 May 2019 22:52:45 +0000 (UTC) Received: from localhost ([127.0.0.1]:54816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRliW-0007yS-Q7 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 May 2019 18:52:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlbN-0001MK-IO for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRlbM-0005ij-9O for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:21 -0400 Received: from mail-yw1-xc2d.google.com ([2607:f8b0:4864:20::c2d]:37999) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRlbM-0005hI-4s for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:20 -0400 Received: by mail-yw1-xc2d.google.com with SMTP id b74so3350117ywe.5 for ; Fri, 17 May 2019 15:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BNGYBuGPGNDuM5xfMmUkjPf3rGoNf3wcZlgZaC2W07g=; b=o/sFKPvCPiXhtp8moSTYrqmPC/qvA2UDkS42YPHJot7mg9IU8/lff1NHf/88bobMfN UDCXiNl6TZuxOx3QXqdQVKlrYq4Wbbi87JRfG3WJ+edxQv1oDQ1IHEpOPxHoYS2dD9BL nwg1TPqYnQB0x5GHl8zJlu7GI2RHooP5G0+NX4mpQnJnozbjA/QG9gDzL7qb2XFkon9t +xYBEWblOSrnchcp7IqYr4be+lqzdNyF3JOQYlOHBUjP4g4SWgQSbZb4U97Yx9qd4l4G G1nCYMhQPvHHarWC8uTSfBBOCvudTET19ZG0JkNDyZLJfFIkraKs9MzSu0rMYLiTybNh Y0Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BNGYBuGPGNDuM5xfMmUkjPf3rGoNf3wcZlgZaC2W07g=; b=BppBW/7WIYEJFB0aCZTd1pXfy8OjFaAn+T0tQK1pNNnnmEhUUs/8qHjsnZfsVUBVpd HrQ4Xs09IqhqRJskdgp4vP7n0Yox+KdXM0fTPBQFp9r21RtQybYNtdTQPCyc6sQPE+a2 A5bvdGFTyPPtbLM2DrNEQOuGh1LaHf0c4E84KUdDF74Hc+hl5ms3RnQakIPuqESUhsbw +bpJi1f5KMStivpZplzeI0zIWHKKd9Fbyl58EsghbvDQhmHnpKhNlj3W8PUf1ni37CtZ Sx8/3wp26VXUa/Ss2EtWRHDjopud2JTHDGB8NPWYPhEooMLADgyodgnprpqZY9vwdgiq SuXw== X-Gm-Message-State: APjAAAWl6m309NuP1X37iiQ+YQ0bXA/TXC7sjKypxq4r/CeJWiY189Hm r+y505vL6yEFr24wZzLgk6j08w+hiceVxg== X-Google-Smtp-Source: APXvYqxZCzrkj1AkbJZrOmNHQ7CEQ9gXYQ8+k0F2rn+zaGGvD28PrY09XHkbQ2+1+xkz4otqG2I+6A== X-Received: by 2002:a81:6d88:: with SMTP id i130mr1902890ywc.266.1558133119377; Fri, 17 May 2019 15:45:19 -0700 (PDT) Received: from dionysus.attlocal.net (69-222-133-165.lightspeed.tukrga.sbcglobal.net. [69.222.133.165]) by smtp.gmail.com with ESMTPSA id u73sm2480260ywf.62.2019.05.17.15.45.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 15:45:18 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:44:49 -0400 Message-Id: <20190517224450.15566-11-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517224450.15566-1-jan.bobek@gmail.com> References: <20190517224450.15566-1-jan.bobek@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::c2d Subject: [Qemu-devel] [RISU v2 10/11] risu_reginfo_i386: replace xfeature constants with symbolic names X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Bobek , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The original code used "magic numbers", which made it unclear in some places. Include a reference to the Intel manual where the constants' meaning is discussed. Signed-off-by: Jan Bobek Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée --- risu_reginfo_i386.c | 48 +++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index 35ff7c8..aba5ae3 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -22,7 +22,25 @@ #include -static uint64_t xfeatures = 3; /* SSE */ +/* + * Refer to "Intel(R) 64 and IA-32 Architectures Software Developer's + * Manual", Volume 1, Section 13.1 "XSAVE-Supported Features and + * State-Component Bitmaps" for detailed discussion of these constants + * and their meaning. + */ +enum { + XFEAT_X87 = 1 << 0, + XFEAT_SSE = 1 << 1, + XFEAT_AVX = 1 << 2, + XFEAT_AVX512_OPMASK = 1 << 5, + XFEAT_AVX512_ZMM_HI256 = 1 << 6, + XFEAT_AVX512_HI16_ZMM = 1 << 7, + XFEAT_AVX512 = XFEAT_AVX512_OPMASK + | XFEAT_AVX512_ZMM_HI256 + | XFEAT_AVX512_HI16_ZMM +}; + +static uint64_t xfeatures = XFEAT_X87 | XFEAT_SSE; static const struct option extra_ops[] = { {"xfeatures", required_argument, NULL, FIRST_ARCH_OPT }, @@ -160,34 +178,34 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) * Now we know that _fpstate contains XSAVE data. */ - if (features & (1 << 2)) { + if (features & XFEAT_AVX) { /* YMM_Hi128 state */ - void *buf = xsave_feature_buf(xs, 2); + void *buf = xsave_feature_buf(xs, XFEAT_AVX); for (i = 0; i < nvecregs; ++i) { memcpy(&ri->vregs[i].q[2], buf + 16 * i, 16); } } - if (features & (1 << 5)) { + if (features & XFEAT_AVX512_OPMASK) { /* Opmask state */ - uint64_t *buf = xsave_feature_buf(xs, 5); + uint64_t *buf = xsave_feature_buf(xs, XFEAT_AVX512_OPMASK); for (i = 0; i < 8; ++i) { ri->kregs[i] = buf[i]; } } - if (features & (1 << 6)) { + if (features & XFEAT_AVX512_ZMM_HI256) { /* ZMM_Hi256 state */ - void *buf = xsave_feature_buf(xs, 6); + void *buf = xsave_feature_buf(xs, XFEAT_AVX512_ZMM_HI256); for (i = 0; i < nvecregs; ++i) { memcpy(&ri->vregs[i].q[4], buf + 32 * i, 32); } } #ifdef __x86_64__ - if (features & (1 << 7)) { + if (features & XFEAT_AVX512_HI16_ZMM) { /* Hi16_ZMM state */ - void *buf = xsave_feature_buf(xs, 7); + void *buf = xsave_feature_buf(xs, XFEAT_AVX512_HI16_ZMM); for (i = 0; i < 16; ++i) { memcpy(&ri->vregs[i + 16], buf + 64 * i, 64); } @@ -243,7 +261,7 @@ static const char *const regname[NGREG] = { static int get_nvecregs(uint64_t features) { #ifdef __x86_64__ - return features & (1 << 7) ? 32 : 16; + return features & XFEAT_AVX512_HI16_ZMM ? 32 : 16; #else return 8; #endif @@ -251,9 +269,9 @@ static int get_nvecregs(uint64_t features) static int get_nvecquads(uint64_t features) { - if (features & (1 << 6)) { + if (features & XFEAT_AVX512_ZMM_HI256) { return 8; - } else if (features & (1 << 2)) { + } else if (features & XFEAT_AVX) { return 4; } else { return 2; @@ -262,9 +280,9 @@ static int get_nvecquads(uint64_t features) static char get_vecletter(uint64_t features) { - if (features & (1 << 6 | 1 << 7)) { + if (features & (XFEAT_AVX512_ZMM_HI256 | XFEAT_AVX512_HI16_ZMM)) { return 'z'; - } else if (features & (1 << 2)) { + } else if (features & XFEAT_AVX) { return 'y'; } else { return 'x'; @@ -301,7 +319,7 @@ int reginfo_dump(struct reginfo *ri, FILE *f) } } - if (features & (1 << 5)) { + if (features & XFEAT_AVX512_OPMASK) { for (i = 0; i < 8; i++) { fprintf(f, " k%-5d: %016" PRIx64 "\n", i, ri->kregs[i]); } From patchwork Fri May 17 22:44:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Bobek X-Patchwork-Id: 10948769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3AD2C1398 for ; Fri, 17 May 2019 22:53:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A6FE1FF7E for ; Fri, 17 May 2019 22:53:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F0A0284BD; Fri, 17 May 2019 22:53:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BD0381FF7E for ; Fri, 17 May 2019 22:53:02 +0000 (UTC) Received: from localhost ([127.0.0.1]:54820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlin-0008CH-WD for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 May 2019 18:53:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRlbO-0001NM-1i for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRlbN-0005kv-3R for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:22 -0400 Received: from mail-yw1-xc2a.google.com ([2607:f8b0:4864:20::c2a]:39996) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRlbM-0005jg-Um for qemu-devel@nongnu.org; Fri, 17 May 2019 18:45:21 -0400 Received: by mail-yw1-xc2a.google.com with SMTP id 18so3349059ywe.7 for ; Fri, 17 May 2019 15:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Gi+xV8hZZ8MM2hR8q1Ptxgv3mk/SLE89TCM1Wb+jzls=; b=qqIKMJQDynycgLbBvSyiAX1GayrfB3gNTiIz7ycbiQ7cpvNBgnhyY75fJ9K5fDWQxG dZ4KXHqa/rzFrZRBhRDeP7eNjAtrDfoXgFM0xNoLcSJasBBIOrdd0H9TT9LcQzTw7Q0v HwFQEk/w4L5JY2S8q0/4X29/doHodeP29TH5WrihMfpDs524mKDa5wsHU5so43zkbKpg Mj2MSByx/0w1xx+rnVowUESrkHNK8ddV8ehaJyrVeqOlwIQPQ/GDyav1yr6NyEhi+OwX CsKCIvP1ihgWKZ1jki2fY2DgYdMbkRPHk0g0kbiioX3M9IoluhEi9/W1eC21WCCS0hOD CLyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gi+xV8hZZ8MM2hR8q1Ptxgv3mk/SLE89TCM1Wb+jzls=; b=nR7IG7Xhc+iLxk0ZG+75Phw0rgUALxwXIpdyq+Dwd8e7pZkFzuGjd9E7aTDKddFwEB ICif8RfP8SEibrIN533f00s1F+sRcKnTwlOZvHlUeVNqKipHzgDQdXI+bKeIwosptiZ/ /Z5dovtchRVCvzsFbZq9mS8F8d5mwRXtItauhZK43R5Ll1oTo73qWiy2tWjVngkFInXI q9SJN7OBKZ0+d7pHeZIB/XicFSLNU/vSOS9oZpLWa8DSO7XNLZsKaLitVI0v8jbwnlWX 3T6KR79B3lig3t63kx75BjBnnNWO1xdZaHWQxh8EgVLpPW8F0zus0RWDI7cYzBiJhAh1 dseg== X-Gm-Message-State: APjAAAVwoTSR5QlhVxTs/wT4iTda359Ob6E2qfQxSQzzcc1iE1Qy/kZe kavNl0OUoQdGVCtw6IRgHNbXFbrU9JQTnQ== X-Google-Smtp-Source: APXvYqweCUY3sA18NV8cfz9omN08JXU6c7MPBg4xG+my+QYYvbcrBrePJ57joayQiGOk5Tt5ziJ6og== X-Received: by 2002:a81:a983:: with SMTP id g125mr15328434ywh.417.1558133120328; Fri, 17 May 2019 15:45:20 -0700 (PDT) Received: from dionysus.attlocal.net (69-222-133-165.lightspeed.tukrga.sbcglobal.net. [69.222.133.165]) by smtp.gmail.com with ESMTPSA id u73sm2480260ywf.62.2019.05.17.15.45.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 15:45:19 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:44:50 -0400 Message-Id: <20190517224450.15566-12-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517224450.15566-1-jan.bobek@gmail.com> References: <20190517224450.15566-1-jan.bobek@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::c2a Subject: [Qemu-devel] [RISU v2 11/11] risu_reginfo_i386: accept named feature sets for --xfeature X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Bobek , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Have the --xfeature option accept "sse", "avx" and "avx512" in addition to a plain numerical value, purely for users' convenience. Suggested-by: Richard Henderson Signed-off-by: Jan Bobek Reviewed-by: Richard Henderson --- risu_reginfo_i386.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index aba5ae3..c15fe63 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -54,7 +54,16 @@ const char * const arch_extra_help void process_arch_opt(int opt, const char *arg) { assert(opt == FIRST_ARCH_OPT); - xfeatures = strtoull(arg, 0, 0); + + if (!strcmp(arg, "sse")) { + xfeatures = XFEAT_X87 | XFEAT_SSE; + } else if (!strcmp(arg, "avx")) { + xfeatures = XFEAT_X87 | XFEAT_SSE | XFEAT_AVX; + } else if (!strcmp(arg, "avx512")) { + xfeatures = XFEAT_X87 | XFEAT_SSE | XFEAT_AVX | XFEAT_AVX512; + } else { + xfeatures = strtoull(arg, 0, 0); + } } const int reginfo_size(void)