From patchwork Mon Apr 8 18:27: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: 10889965 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 175D417E0 for ; Mon, 8 Apr 2019 18:31:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02B29286CF for ; Mon, 8 Apr 2019 18:31:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB6BF286FE; Mon, 8 Apr 2019 18:31:15 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI 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 5F03D286CF for ; Mon, 8 Apr 2019 18:31:15 +0000 (UTC) Received: from localhost ([127.0.0.1]:57155 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hDZ34-0001Ir-OY for patchwork-qemu-devel@patchwork.kernel.org; Mon, 08 Apr 2019 14:31:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hDZ0M-0007Zv-It for qemu-devel@nongnu.org; Mon, 08 Apr 2019 14:28:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hDZ0K-0007BU-Kk for qemu-devel@nongnu.org; Mon, 08 Apr 2019 14:28:26 -0400 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]:41805) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hDZ0K-0007B1-Cm for qemu-devel@nongnu.org; Mon, 08 Apr 2019 14:28:24 -0400 Received: by mail-oi1-x22c.google.com with SMTP id v7so11304808oie.8 for ; Mon, 08 Apr 2019 11:28:24 -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=ZZX//Rv+ayyPhWmMCWfxTWkZjELBsgYzluMsiNdCjJI=; b=cf5DZK8urg91rpQk9z3hQbVqJlnjvlM2+fTRHJd2mryWj1M4izBQ9tXA5fmijk8Dna j3PkNN8KRfknwKTe5NHNKsnjsZEtM4ypmGq5Vq2geq7TXKn94uvHVriJBTcPqTbap0yY HGyEMHWIeVbtOQeKP6zj8re3B2K8l6X/G6g7rm+V0a9rEv785ePe2HXey1c07KdnVrZ7 cMzWGdXk1tn6MOit2O1B3CiBn5XgXLOBciD1kIvOjL3vrDn7N1uUkUP2GUWVLH9T86wU d7yChCtSM1jGxBVbvdN+Z9k+blHAlFZlntuOGnlP0h1fsQvclTlL5Zgxeh/CHCfvMSAr b27Q== 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=ZZX//Rv+ayyPhWmMCWfxTWkZjELBsgYzluMsiNdCjJI=; b=BKs23AdH6R3M4LJSesSeG63g7RlnYfXEB/mgLufqSXV52NfsE0mDPkJKd5oNrDgEC3 qDmbnQAIxQcHODLJUBwDWq/HHDFX6hSKEH3kTkvAm6bPE/EWou9OI/eKDHX5ZuP9i4k1 y3VqA/gYPehmVbUsxr2r+JpdexmqXTQ8wp2W654WIrB/cHgq+6EzbrG8ksfY8Fzwpm+P 6KPW7IOofQvIYeMWBwPMRjw2redvEjTY2BVQUb93cZ8/4ujm+zkDWa+rVJH4N4C1YKDw 6xLgTHMQa5C9EM0rtet8uRIUs9glvCs6CdBG4HU2TkTs3nHuiIA+oEr2zeTP92p3+HSP wDug== X-Gm-Message-State: APjAAAXUPiR/TczVni//TsNs/gedbXBC54cSrT7wT6HfUHWCfkDDz4fw UMO38chYQ1Qr0quqVNf3JCuwVuF4108= X-Google-Smtp-Source: APXvYqzYnv4D2Vtva/Gvum0qbcCYA8A/L4Ira3kiAz0cKrMMdjW2WSZZp1C3uD9lTVDgPx/aptgdkw== X-Received: by 2002:aca:407:: with SMTP id 7mr16289515oie.90.1554748103343; Mon, 08 Apr 2019 11:28:23 -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 r133sm9940295oib.21.2019.04.08.11.28.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 11:28:22 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Mon, 8 Apr 2019 14:27:45 -0400 Message-Id: <20190408182748.1238-3-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190408182748.1238-1-jan.bobek@gmail.com> References: <20190408182748.1238-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::22c Subject: [Qemu-devel] [RISU PATCH 2/5] 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: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Jan Bobek , Stefan Hajnoczi , Peter Maydell 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. Signed-off-by: Jan Bobek Reviewed-by: Alex Bennée --- 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]); + } +}