From patchwork Wed Jun 13 12:55:56 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: 138465 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp698173lji; Wed, 13 Jun 2018 06:05:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJWrE6Dp7bEzzO7n0LLjgxnZ6gVm36pAiQGxAU3aveeArt+Ct3JT55nBdfbhk8mlKaEg+yG X-Received: by 2002:aed:3541:: with SMTP id b1-v6mr4440587qte.68.1528895154876; Wed, 13 Jun 2018 06:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528895154; cv=none; d=google.com; s=arc-20160816; b=erGskPY7mKRTaT8Ub0erj7eKuzS6PuufLyYpSCTKBYI2Dtztk4NmdGn/+Lfh2lRzRN bYn8Eu7mR1Vrxzg/CgU5BKF5hLMd3VmnU3zHTF04zrzdndUxGnYJPD2kjnewQnNLAUPg Fb2gnwXfe8FdxSg1SXR11WNc8KhBRPW019vYfZX3Sef5iuStS2KN6PX9mN9ShOfRpXO0 vgraXbHDv4dLX0KwgQuBvcyPAlX624keJ0PTE6aERLW0/cMscNzoGovGDpVc1HQ1xpIW btGWucd9Znc9TOrfOeIxpdRXk0Gao9x9IVrZA4EcaFuIYOPzRX2JxJ1Qc9qVQckJG/mj /UhQ== 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=HAIX9tTUSqBJuCs9MaUHymal6G4zj6ophHdsDwTVexY=; b=DJiFYvukAzFs7ataiU4ePePi6HP6qxOy/Yk1b2ip5uy8B1uQCsYzj0CTobpJ7Xwd86 tftrGDVfCBIEJHug+7ZpKe2OTAVpCpC17ft6Njc+3vw9Y9+e3/HqUVWLaNNB4CIuM3XT PCnKiKHvuOGpIwzvHcsH5gQ4bqHGmfWspYZFA8C844Ys5BB9TThJYnJuPAxqYJgLPJ+N 1CkMKyk4MNysagIFQsaU1dSwRbWQh4ccfc+ftcSitHTxRowKE1lAYhEBFYeyadGKd3XF S6k597ZmL6fVByFIIs7+rwBKs/VdLDsX9AsmhsS6HZcFOMHKWsyVRJTEAGy5xORINdDn Z2Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hcoBddz2; 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 y2-v6si2517965qvi.233.2018.06.13.06.05.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 13 Jun 2018 06:05:54 -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=hcoBddz2; 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]:34045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fT5TG-0002Oj-9A for patch@linaro.org; Wed, 13 Jun 2018 09:05:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fT5Jx-0002kx-E1 for qemu-devel@nongnu.org; Wed, 13 Jun 2018 08:56:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fT5Jw-0005KJ-1z for qemu-devel@nongnu.org; Wed, 13 Jun 2018 08:56:17 -0400 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:55264) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fT5Jv-0005Ir-P6 for qemu-devel@nongnu.org; Wed, 13 Jun 2018 08:56:15 -0400 Received: by mail-wm0-x234.google.com with SMTP id o13-v6so4526573wmf.4 for ; Wed, 13 Jun 2018 05:56: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=HAIX9tTUSqBJuCs9MaUHymal6G4zj6ophHdsDwTVexY=; b=hcoBddz2bO+27vWsOcqWZW8RnxeG/RMlCT2lv8yoYxqkXe1xfdf96lYc/lUG40u+BE d07jW8AqF8r2vezL+v8cpmJ2nH2tVV/FdemsRQsueCnKkGDWVHGB+NYqeDEk7h39wnUX I/34v42WAj7ojJNM8CdlSutRgtOzQDOsSNUy4= 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=HAIX9tTUSqBJuCs9MaUHymal6G4zj6ophHdsDwTVexY=; b=QT5NR8KOB8hy+wdWo6lC3HEd3S9B6Ht6r47pgOK8xNq+U7NG2gttYfJhz0JHNl1IBv ZeMo0h9SzRWR3YC1nNtUOYoEIUSdEjf9JjyWx6zPQhQkOtEuZSQb9itF77njUxsOjwXC WPzasIipoqcoV05CD6j6CNj2V/3GuI+8k7uju6Flief6XGhBwkDRzDdld1Bv/WYsZY5u uWLUguAaMEzprBA08mxrFiUcynre4bumA+69/tLOm0RZMc8u2wXbbTzTzlC3iUH1cHHt /eNtHaFyI5xb5A5l+LvZY4Gw3DeMljCrpp5HloTxej+N31OeCfuNvDu11Mjun/1GDG0s BmPQ== X-Gm-Message-State: APt69E3I95HPrKTLNE3y1F6QxPjl281h+Z1S2rata1G9f/Yf4K7XZsi0 IEVcUx1SVddF2GuO6QHXcei1ElIN/A8= X-Received: by 2002:a1c:43c5:: with SMTP id q188-v6mr3603739wma.69.1528894574626; Wed, 13 Jun 2018 05:56:14 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id s10-v6sm4512025wmb.12.2018.06.13.05.56.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Jun 2018 05:56:09 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 0C6603E12E5; Wed, 13 Jun 2018 13:56:02 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 13 Jun 2018 13:55:56 +0100 Message-Id: <20180613125601.14371-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180613125601.14371-1-alex.bennee@linaro.org> References: <20180613125601.14371-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::234 Subject: [Qemu-devel] [RISU PATCH v3 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 --- 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 Reviewed-by: Richard Henderson 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) {