From patchwork Fri Jun 22 14:12:00 2018 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: 139679 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp968294lji; Fri, 22 Jun 2018 07:54:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdnwRwLJ/RKEzju3MSWYOd+PTFKOCX0rk7NrCCSXn/g3NeYYNGY9s6jusYAweRrt3m5zut1 X-Received: by 2002:a0c:f54d:: with SMTP id p13-v6mr1685778qvm.149.1529679250078; Fri, 22 Jun 2018 07:54:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529679250; cv=none; d=google.com; s=arc-20160816; b=mEOtG5OIbABYOaihSvvWHxsK6hSqQSqEQUj1GAYcHxEZyuCivP/jQ101bLswmMa88U sb9tQsXnI0v+tD/uy12QZKcHPHdgyAV0/eyF/ID/UVB8enZh48EKKPCsbn4vVzTCF+8y o0zJk3eQ+TEKx+Dh8/uH9yvin2OkN3qdmaDJkPpsmfp/wvWaMBBIOHSTbtzJfwVhV8k7 NUhYGB5JLaqG996zGWstmHXK8B8Qhj5zqCyIk9TLSdCklD4ZNQx/rQwvMbBTPBe6AFtv 8yHeAn1BvrPMr7EqV/nyJNJ4xoz6aYvGgYcQlMMTNb0iAtdesRUXBMOVQW4bUosfB/5x qFEg== 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=rzwy1wygd0hzu64f2W+6KlSmTAZV7pjBu+NhIXCdKKw=; b=q9uIH+Gtq15/MNpj6Mu1mj8xHZoJ7i54ajAL6a5m2R0oa0h4pnkYRmbpFCmcYC7NTd Aj9/5huVJOSTEJv+2eqESPO6fnqlt3FOFuPucKJdhQmjRHk422HuVOZM7Go2MqiSy4hk NMJkNZP+ztn/GWAm2v8iolCIOQNjwBrfCfPRtpmIYgG2xBBC/yXhblEm3GbMuyID07kn quVh7hxfUSJ3ebZYUOLr6luEHkTi+lU/34j/MQGeSd8hkGr0bkv1JfEcqtD6AERJKaO6 UQOpoAripjrZ31Uq4zoIX3Z52+mKb3NDLEF4aUPKxGOdlyEdtQhl+Ci82w26kKkei87p /jNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d8NJfP37; 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 i191-v6si918671qke.315.2018.06.22.07.54.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Jun 2018 07:54:10 -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.s=google header.b=d8NJfP37; 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]:34557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWNRx-0006St-Iq for patch@linaro.org; Fri, 22 Jun 2018 10:54:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWMww-0005uA-Hh for qemu-devel@nongnu.org; Fri, 22 Jun 2018 10:22:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWMwu-0003WJ-2E for qemu-devel@nongnu.org; Fri, 22 Jun 2018 10:22:06 -0400 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:40714) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fWMwt-0003VY-On for qemu-devel@nongnu.org; Fri, 22 Jun 2018 10:22:03 -0400 Received: by mail-wm0-x232.google.com with SMTP id n5-v6so2799610wmc.5 for ; Fri, 22 Jun 2018 07:22:03 -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=rzwy1wygd0hzu64f2W+6KlSmTAZV7pjBu+NhIXCdKKw=; b=d8NJfP37aP9cz9sTOUViexCXGisWXvhegG+3CC11QDp4p9w6AcsYNf5J3bigvbnFbf MuolB4cuNxsJMNmE5zTxS4ZPEUVbUgUIUMsussD85gSBeLHuKN9vvMZDCMSbB6THDOvw AnvHvQVXPfug03IURMj0AiOl/nLLllI0M6hXs= 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=rzwy1wygd0hzu64f2W+6KlSmTAZV7pjBu+NhIXCdKKw=; b=jgOTi7xZhHNnSRM3TfQ1Ip3gZvRqEiorJ8IphehZra7A/RtxHcJOEhuvWGCLQQGQKj NIZRavYsnb7AKDZOFbOngCJLh6TJMvttp9gSDZq4nIEvH+RAzWfZdZMEEs6hZYNKHyfv c74n/E6kGiRM4P6/ZcNNgW3F94GrgE/uCjp/sXbwNkH90das3keCHdkPVZrcSwHX7Bee 7NRzTeIhPAC2Uz7Z+bDvBXS5QqP3R7D6W1PYlgtwe6iI89RIukTSP1RIHy+A/7aCte/j THUr5JTLxumHGeMf7Z3TEzkNQs/1wl8znn0O6J3/tP49wgpS8QLndzmbfSM8zbl8uj2I aSow== X-Gm-Message-State: APt69E37OhAq2WeZvxC0h6yg9EOW0OVQSSzjV4qXdrLphbw6PAEbaIGz msUL6UiT6XbGBCfIFe2zCMiDFA== X-Received: by 2002:a1c:ec47:: with SMTP id k68-v6mr1930522wmh.109.1529677322698; Fri, 22 Jun 2018 07:22:02 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u15-v6sm2369028wma.37.2018.06.22.07.22.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Jun 2018 07:22:00 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 29A893E0C65; Fri, 22 Jun 2018 15:12:06 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 22 Jun 2018 15:12:00 +0100 Message-Id: <20180622141205.16306-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180622141205.16306-1-alex.bennee@linaro.org> References: <20180622141205.16306-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:c09::232 Subject: [Qemu-devel] [RISU PATCH v4 17/22] risu_reginfo: introduce reginfo_size() 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-arm@nongnu.org, richard.henderson@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In preparation for conditionally supporting SVE we need to be able to have different sized reginfos. This introduces reginfo_size() to abstract the size away to the code the actually knows. For aarch64 we also use this while initialising the block. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- reginfo.c | 6 +++--- risu.h | 3 +++ risu_reginfo_aarch64.c | 11 ++++++++++- risu_reginfo_aarch64.h | 1 + risu_reginfo_arm.c | 5 +++++ risu_reginfo_m68k.c | 5 +++++ risu_reginfo_ppc64.c | 5 +++++ 7 files changed, 32 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/reginfo.c b/reginfo.c index 1f55d06..dd42ae2 100644 --- a/reginfo.c +++ b/reginfo.c @@ -39,7 +39,7 @@ int send_register_info(write_fn write_fn, void *uc) switch (op) { case OP_TESTEND: - write_fn(&ri, sizeof(ri)); + write_fn(&ri, reginfo_size()); /* if we are tracing write_fn will return 0 unlike a remote end, hence we force return of 1 here */ return 1; @@ -58,7 +58,7 @@ int send_register_info(write_fn write_fn, void *uc) /* Do a simple register compare on (a) explicit request * (b) end of test (c) a non-risuop UNDEF */ - return write_fn(&ri, sizeof(ri)); + return write_fn(&ri, reginfo_size()); } return 0; } @@ -101,7 +101,7 @@ int recv_and_compare_register_info(read_fn read_fn, /* 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))) { + if (read_fn(&apprentice_ri, reginfo_size())) { packet_mismatch = 1; resp = 2; } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { diff --git a/risu.h b/risu.h index 48c50d9..8d2d646 100644 --- a/risu.h +++ b/risu.h @@ -133,4 +133,7 @@ int reginfo_dump(struct reginfo *ri, FILE * f); /* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f); +/* return size of reginfo */ +const int reginfo_size(void); + #endif /* RISU_H */ diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 62a5599..5da9e39 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -15,6 +15,8 @@ #include #include /* for FPSIMD_MAGIC */ #include +#include +#include #include "risu.h" #include "risu_reginfo_aarch64.h" @@ -27,6 +29,13 @@ void process_arch_opt(int opt, const char *arg) abort(); } +const int reginfo_size(void) +{ + const int size = offsetof(struct reginfo, simd.end); + assert(sizeof(struct reginfo)==size); + return size; +} + /* reginfo_init: initialize with a ucontext */ void reginfo_init(struct reginfo *ri, ucontext_t *uc) { @@ -71,7 +80,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) /* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */ int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2) { - return memcmp(r1, r2, sizeof(*r1)) == 0; + return memcmp(r1, r2, reginfo_size()) == 0; } /* reginfo_dump: print state to a stream, returns nonzero on success */ diff --git a/risu_reginfo_aarch64.h b/risu_reginfo_aarch64.h index a1c708b..ef97622 100644 --- a/risu_reginfo_aarch64.h +++ b/risu_reginfo_aarch64.h @@ -15,6 +15,7 @@ struct simd_reginfo { __uint128_t vregs[32]; + char end[0]; }; struct reginfo { diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index 12ad0ef..3662f12 100644 --- a/risu_reginfo_arm.c +++ b/risu_reginfo_arm.c @@ -36,6 +36,11 @@ void process_arch_opt(int opt, const char *arg) abort(); } +const int reginfo_size(void) +{ + return sizeof(struct reginfo); +} + static void reginfo_init_vfp(struct reginfo *ri, ucontext_t *uc) { /* Read VFP registers. These live in uc->uc_regspace, which is diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c index 7a1c5a9..32b28c8 100644 --- a/risu_reginfo_m68k.c +++ b/risu_reginfo_m68k.c @@ -23,6 +23,11 @@ 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) { diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index 4b70460..f9d2f0d 100644 --- a/risu_reginfo_ppc64.c +++ b/risu_reginfo_ppc64.c @@ -31,6 +31,11 @@ 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) {