From patchwork Wed Jun 21 15:42:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 106105 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1996261qgd; Wed, 21 Jun 2017 08:46:51 -0700 (PDT) X-Received: by 10.159.38.20 with SMTP id 20mr9870118uag.25.1498060011422; Wed, 21 Jun 2017 08:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498060011; cv=none; d=google.com; s=arc-20160816; b=ltaAhTsGs4rvtB77qKIrqul/VPKsPg+fLahpBTsDvnIvC+8O57z8GJgMthQzHCP/Ga vV6oeXlzPw/CsPU6RnB3hVx+TqNj1LQautwaNZ3Zi0ltlCI2gwWBsyoCWSrZdxk6XP0Y zepoDTMKkPV2GnaZe/nuQL/c1G6oL6RBAD6w4FmcT7+Dr/oG8o8zWcgEwU7o6IGN8qNF eFVWp1RCa0Z4ag7d+l3/g60Pao89dR6s/Fz0TnLs00QKV+YNqFcjJ0jAIDzpWxSbhCvv 0H15zk7hm9PMPeYNYKACFQWof1ti1OLRQRaQYA8P3sjrtO1ogzKgWRyvtGshc6TIS07c MuBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=tMgDTSHa8lLwJGNm/6z4Z2OUPhmpjo+b51sWBxLAqwk=; b=0IbjvviuBIRwf4ZgUUKoLdCq1v84xjgvscItELYYFx/JKM6MbGF+y4oGinwJk855Y6 nqesRL0N91+8m8jgk0/kUWqisF6CxZIhexdfNjBH3n8V8cvlkKKotdmDvutEFiPz6Uk/ d+YvisxnMKV/j2agSWPRvfyAJlyqa9obrYhYHyP3n7rOUMa+ZIScPn43TMxC/GO2hqTe uao/gxXMdZOqX4dd2X7Z2ygKYmIjoa4dkhGgNYqyOtGfq9ZTqGx9ImluWKxI4IfKVe9V 1CoRezB7iR+4w6A81oTbRLpVbGihYCCQCN5iB9/eb6f1UXgmHAh8s4zuniwhTR3vK3YQ dyyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=fOXQgRhe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 72si8046783vki.25.2017.06.21.08.46.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Jun 2017 08:46:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.b=fOXQgRhe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:54762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhqC-0001RQ-PL for patch@linaro.org; Wed, 21 Jun 2017 11:46:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNhlp-0006FZ-Cf for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNhlo-0002rS-3Q for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:17 -0400 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:33559) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNhln-0002r8-Pq for qemu-devel@nongnu.org; Wed, 21 Jun 2017 11:42:16 -0400 Received: by mail-wr0-x234.google.com with SMTP id r103so140133947wrb.0 for ; Wed, 21 Jun 2017 08:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tMgDTSHa8lLwJGNm/6z4Z2OUPhmpjo+b51sWBxLAqwk=; b=fOXQgRhekMaoqudVplwluU4IgmSO1M2GgK6mmIbt3klQpphgaQGr/vMw2jw3LVOKM/ uEHPbhIepHmLjvP2RdcoY1cPOregwo8gD3WWS+eGLgRKwGG58u/wEMxMO1kfouZSsDqV 96ZmL5LskWvy+skf/RMPii1/zSLjgq1mr63/8= 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=tMgDTSHa8lLwJGNm/6z4Z2OUPhmpjo+b51sWBxLAqwk=; b=r9HaIBrHofqbGu9th9z6hGu8QYsR3304XL5vJDpdG3yqeI0CsRBNMLYmNySVRlfM+8 vJt1dhyScYqGON8s7fsa5jveHQEB3LmLJ6en9D06d1gw7GobTIhDmrLJ3/d77No3FX/l wNwRJABkpee+TFkOcx5vEzjUHELak1+hVB1YpUosMUleQsV4vZoga3wVr0EWlnGs/0Yi k849UWY2/s18GdfIN/RG0qH6aGPTG2Rn+mdbUFUCXu3wlPTFHliPFHohwaUhGKPzcz49 v5D5GgKsvpc2bQkW9Gxc+Ybbxl0awWQMPaB6CPoJxTxbqfB5Yoe+sWYMyBbb9jaHKMn+ X7Uw== X-Gm-Message-State: AKS2vOy9+QBVlXSYoFlupUHv+8+4lcKh7IX6E8R5zqqYkzSN4gPDs8W9 1rpZqGcDNeIOkrIOJobOOQ== X-Received: by 10.223.136.116 with SMTP id e49mr15426469wre.14.1498059734502; Wed, 21 Jun 2017 08:42:14 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x94sm19462887wrb.47.2017.06.21.08.42.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 08:42:12 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 5E2E33E0F7F; Wed, 21 Jun 2017 16:42:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 21 Jun 2017 16:42:39 +0100 Message-Id: <20170621154244.28309-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170621154244.28309-1-alex.bennee@linaro.org> References: <20170621154244.28309-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::234 Subject: [Qemu-devel] [RISU PATCH v6 05/10] risu: add header to trace stream 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?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" I've also added a header packet with pc/risu op in it so we can keep better track of how things are going. Signed-off-by: Alex Bennée Reviewed-by: Peter Maydell --- v5 - re-base without formatting fixes - dropped fprintfs in signal context v4 - split from previous patch --- reginfo.c | 94 +++++++++++++++++++++++++++++++++++++--------------------- risu.h | 9 ++++++ risu_aarch64.c | 5 ++++ risu_arm.c | 5 ++++ risu_m68k.c | 5 ++++ risu_ppc64.c | 5 ++++ 6 files changed, 89 insertions(+), 34 deletions(-) -- 2.13.0 diff --git a/reginfo.c b/reginfo.c index b69d11f..44d2786 100644 --- a/reginfo.c +++ b/reginfo.c @@ -24,10 +24,19 @@ static int packet_mismatch; int send_register_info(write_fn write_fn, void *uc) { struct reginfo ri; + trace_header_t header; int op; + reginfo_init(&ri, uc); op = get_risuop(&ri); + /* Write a header with PC/op to keep in sync */ + header.pc = get_pc(&ri); + header.risu_op = op; + if (write_fn(&header, sizeof(header)) != 0) { + return -1; + } + switch (op) { case OP_TESTEND: return write_fn(&ri, sizeof(ri)); @@ -62,46 +71,63 @@ int send_register_info(write_fn write_fn, void *uc) int recv_and_compare_register_info(read_fn read_fn, respond_fn resp_fn, void *uc) { int resp = 0, op; + trace_header_t header; reginfo_init(&master_ri, uc); op = get_risuop(&master_ri); - switch (op) { - case OP_COMPARE: - case OP_TESTEND: - default: - /* Do a simple register compare on (a) explicit request - * (b) end of test (c) a non-risuop UNDEF - */ - if (read_fn(&apprentice_ri, sizeof(apprentice_ri))) { - packet_mismatch = 1; - resp = 2; - } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { - /* register mismatch */ - resp = 2; - } else if (op == OP_TESTEND) { - resp = 1; - } - resp_fn(resp); - break; - case OP_SETMEMBLOCK: - memblock = (void *)(uintptr_t)get_reginfo_paramreg(&master_ri); - break; - case OP_GETMEMBLOCK: - set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) + - (uintptr_t)memblock); - break; - case OP_COMPAREMEM: - mem_used = 1; - if (read_fn(apprentice_memblock, MEMBLOCKLEN)) { - packet_mismatch = 1; - resp = 2; - } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) { - /* memory mismatch */ - resp = 2; + if (read_fn(&header, sizeof(header)) != 0) { + return -1; + } + + if (header.risu_op == op ) { + + /* send OK for the header */ + resp_fn(0); + + switch (op) { + case OP_COMPARE: + case OP_TESTEND: + default: + /* Do a simple register compare on (a) explicit request + * (b) end of test (c) a non-risuop UNDEF + */ + if (read_fn(&apprentice_ri, sizeof(apprentice_ri))) { + packet_mismatch = 1; + resp = 2; + + } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { + /* register mismatch */ + resp = 2; + + } else if (op == OP_TESTEND) { + resp = 1; + } + resp_fn(resp); + break; + case OP_SETMEMBLOCK: + memblock = (void *)(uintptr_t)get_reginfo_paramreg(&master_ri); + break; + case OP_GETMEMBLOCK: + set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) + + (uintptr_t)memblock); + break; + case OP_COMPAREMEM: + mem_used = 1; + if (read_fn(apprentice_memblock, MEMBLOCKLEN)) { + packet_mismatch = 1; + resp = 2; + } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) { + /* memory mismatch */ + resp = 2; + } + resp_fn(resp); + break; } + } else { + /* We are out of sync */ + resp = 2; resp_fn(resp); - break; } return resp; diff --git a/risu.h b/risu.h index 20bb824..5248285 100644 --- a/risu.h +++ b/risu.h @@ -50,6 +50,12 @@ extern int test_fp_exc; struct reginfo; +typedef struct +{ + uintptr_t pc; + uint32_t risu_op; +} trace_header_t; + /* Functions operating on reginfo */ /* Function prototypes for read/write helper functions. @@ -102,6 +108,9 @@ uint64_t get_reginfo_paramreg(struct reginfo *ri); */ int get_risuop(struct reginfo *ri); +/* Return the PC from a reginfo */ +uintptr_t get_pc(struct reginfo *ri); + /* initialize structure from a ucontext */ void reginfo_init(struct reginfo *ri, ucontext_t *uc); diff --git a/risu_aarch64.c b/risu_aarch64.c index 9c6809d..492d141 100644 --- a/risu_aarch64.c +++ b/risu_aarch64.c @@ -40,3 +40,8 @@ int get_risuop(struct reginfo *ri) uint32_t risukey = 0x00005af0; return (key != risukey) ? -1 : op; } + +uintptr_t get_pc(struct reginfo *ri) +{ + return ri->pc; +} diff --git a/risu_arm.c b/risu_arm.c index a55c6c2..5fcb2a5 100644 --- a/risu_arm.c +++ b/risu_arm.c @@ -68,3 +68,8 @@ int get_risuop(struct reginfo *ri) uint32_t risukey = (isz == 2) ? 0xdee0 : 0xe7fe5af0; return (key != risukey) ? -1 : op; } + +uintptr_t get_pc(struct reginfo *ri) +{ + return ri->gpreg[15]; +} diff --git a/risu_m68k.c b/risu_m68k.c index 0bf5c14..1056eef 100644 --- a/risu_m68k.c +++ b/risu_m68k.c @@ -33,3 +33,8 @@ int get_risuop(struct reginfo *ri) uint32_t risukey = 0x4afc7000; return (key != risukey) ? -1 : op; } + +uintptr_t get_pc(struct reginfo *ri) +{ + return ri->gregs[R_PC]; +} diff --git a/risu_ppc64.c b/risu_ppc64.c index eb60573..83f8d1f 100644 --- a/risu_ppc64.c +++ b/risu_ppc64.c @@ -38,3 +38,8 @@ int get_risuop(struct reginfo *ri) uint32_t risukey = 0x00005af0; return (key != risukey) ? -1 : op; } + +uintptr_t get_pc(struct reginfo *ri) +{ + return ri->nip; +}