From patchwork Fri May 22 02:34:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187135 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2106991ilb; Thu, 21 May 2020 19:45:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKnykSheLgpTM4OJ8OQX1+8zHXu04ulpO5cKt0+sQdcmBi8FM09+eC3ppk8KoOeKHhGpQX X-Received: by 2002:a37:b743:: with SMTP id h64mr12498514qkf.460.1590115508222; Thu, 21 May 2020 19:45:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115508; cv=none; d=google.com; s=arc-20160816; b=HyIqTWn6d1u/grvIDLgK51TzrL0pYjZFNd3vP2Y+QVJ9dH78CMY2Ev+oHfa9E0X+eJ 7kOD9Ivtswsv2hNBttQbadh9zPI9CcNEXdlrcruO/3OmjHxpJjIXrGWu2vldhKieQsWW 8bDDN5VvX/Jr6PbsHHyrEWLnw0hIP4TxLD155zs1kmfK/5shhA7zLWjhqzfkL7CB4aga dnxvzpWZdmRGpAeFiJUeGEjb/2POq7dZZWZlOuDyKRZHdyyHdtmRzpr0Mf/XmDAbslej 0Lo6aOw+TlSaHRJShUb5lpCXSCBdQSPv/ABmqD6qnqvY4gZ2eTnIT4EhgmtSxGkpbi/f LS7g== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=luiwJqNtbF93pa4B4WEBIHdTcK0G0uHbjDw2xJ7Jaew=; b=XW5PiRLM8QB2t4Bz1jgnvCSf25XRZtwrOymC3pF1Gq7IR5GnGfGIP0Pv94mhKfBwq9 TmiotovVSQGoAFAvV9bf9imhzI/4xSrZddGJ0ceb5qtZEvSmY+5re/Fn5XTw48Dl77ED fBqH1MmOoyPj3CAVD+4vIKkXq06nVXoAphfDhDO3SYAc3kTt25AeBhyXtfQHtwGQ56f6 8b6cPCYwrLvv7H40wjxueKKgoEPnJjJhjQbdpNhXjoOHSqojdVxVvAo+eP9tG83xpa89 JoW5uPQhnREPNdEOPQ8JCWjHYZHdw2YaMNs9bWqLjMtLWSfwc2JBqg15dsnlt3knt3zY EceQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="aY/6jD3E"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q56si4337076qtb.347.2020.05.21.19.45.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:45:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="aY/6jD3E"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:35922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxgJ-000180-Q7 for patch@linaro.org; Thu, 21 May 2020 22:45:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWd-0002t4-Qn for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:07 -0400 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]:36961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWc-00058I-Mn for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:07 -0400 Received: by mail-pj1-x1044.google.com with SMTP id q9so4346658pjm.2 for ; Thu, 21 May 2020 19:35:06 -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=luiwJqNtbF93pa4B4WEBIHdTcK0G0uHbjDw2xJ7Jaew=; b=aY/6jD3EsjlwEoRTgPmICL0MkRiVyaBx8KayP38X/AVAvNkC69XW+F7RuVcnTTMmw3 nMB7SnSE309lKgASpqSA+X4+4PL9FnA6scLJh9W5qsve8DRmPnQsetyiQU/lSrgBik5y Pe4/oLrV8QbyprXhcut6piyNDC6fudenaVMw2LrRoJuUnE+799HvfSWR6kjYpe29qHtM gIBCim8u4NYBZ5tHyQsSfbUI+rTLO3uK2JJ7pyHGMD/VeVSgbGDLQ2M8B+hRAGTGgLUF P6HhpBZJYuBjC7PEFuZ3jiFjJQOjiMeEKQ8OBcXOA9Q64puvt5KU8QH9HDrxpt6Bkxpa 8obg== 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=luiwJqNtbF93pa4B4WEBIHdTcK0G0uHbjDw2xJ7Jaew=; b=JA8lpo4ZvIT/YLVTdchEZ5CL6l/ONK1y/tvfRXxXtdwwyoK5IzMkKn7kmPmcoOCAor uDF2XWfm52hgKwxD4o4XmoPKBMZH5BhoZM8BOB1OIUNCAgaat5TzKkv+wHgV7sYoA7JT XbTpGe8HECS5yG7ArV4TQwpUfU721jzAR9B4zH2yqwCEduEE4jNwAKPvsRtUwcJDtUnq D6SrvxFcpURD50qZswRKmJtyLr8NDDxfqUcXILofTBpLCYKDv+MxjTP4UdWcZznNFld8 LiMAw8lezW5Yl5iblcWp6lFaiOStrW7T0R2D0L4DCzNBrpuQJw0pa+WcYRQtFbuJy3YV yjfQ== X-Gm-Message-State: AOAM5313b2moQtkn6dfPvPIUuf0rbovpo4AEoUiwkuVSUctKX0jZGi9e L+LXiM0DGZgkE3O0GhxvgCb7mTRt5/0= X-Received: by 2002:a17:902:7045:: with SMTP id h5mr12695977plt.108.1590114904835; Thu, 21 May 2020 19:35:04 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 18/25] Compute reginfo_size based on the reginfo Date: Thu, 21 May 2020 19:34:33 -0700 Message-Id: <20200522023440.26261-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1044; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1044.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This will allow dumping of SVE frames without having to know the SVE vector length beforehand. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- risu.h | 2 +- risu.c | 9 +++++++-- risu_reginfo_aarch64.c | 4 ++-- risu_reginfo_arm.c | 4 ++-- risu_reginfo_i386.c | 4 ++-- risu_reginfo_m68k.c | 4 ++-- risu_reginfo_ppc64.c | 4 ++-- 7 files changed, 18 insertions(+), 13 deletions(-) -- 2.20.1 diff --git a/risu.h b/risu.h index bfcf0af..3cad3d5 100644 --- a/risu.h +++ b/risu.h @@ -126,6 +126,6 @@ int reginfo_dump(struct reginfo *ri, FILE * f); int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f); /* return size of reginfo */ -const int reginfo_size(void); +int reginfo_size(struct reginfo *ri); #endif /* RISU_H */ diff --git a/risu.c b/risu.c index a248db1..a70b778 100644 --- a/risu.c +++ b/risu.c @@ -125,7 +125,7 @@ static RisuResult send_register_info(void *uc) case OP_TESTEND: case OP_COMPARE: case OP_SIGILL: - header.size = reginfo_size(); + header.size = reginfo_size(&ri[MASTER]); extra = &ri[MASTER]; break; case OP_COMPAREMEM: @@ -209,7 +209,12 @@ static RisuResult recv_register_info(struct reginfo *ri) return RES_BAD_SIZE; } respond(RES_OK); - return read_buffer(ri, header.size); + res = read_buffer(ri, header.size); + if (res == RES_OK && header.size != reginfo_size(ri)) { + /* The payload size is not self-consistent with the data. */ + return RES_BAD_SIZE; + } + return res; case OP_COMPAREMEM: if (header.size != MEMBLOCKLEN) { diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 028c690..7044648 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -69,7 +69,7 @@ void process_arch_opt(int opt, const char *arg) #endif } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { int size = offsetof(struct reginfo, simd.end); #ifdef SVE_MAGIC @@ -194,7 +194,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, reginfo_size()) == 0; + return memcmp(r1, r2, reginfo_size(r1)) == 0; } #ifdef SVE_MAGIC diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index 3662f12..47c52e8 100644 --- a/risu_reginfo_arm.c +++ b/risu_reginfo_arm.c @@ -36,9 +36,9 @@ void process_arch_opt(int opt, const char *arg) abort(); } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { - return sizeof(struct reginfo); + return sizeof(*ri); } static void reginfo_init_vfp(struct reginfo *ri, ucontext_t *uc) diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index 60fc239..50505ab 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -74,9 +74,9 @@ void process_arch_opt(int opt, const char *arg) } } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { - return sizeof(struct reginfo); + return sizeof(*ri); } static void *xsave_feature_buf(struct _xstate *xs, int feature) diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c index 32b28c8..4eb30cd 100644 --- a/risu_reginfo_m68k.c +++ b/risu_reginfo_m68k.c @@ -23,9 +23,9 @@ void process_arch_opt(int opt, const char *arg) abort(); } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { - return sizeof(struct reginfo); + return sizeof(*ri); } /* reginfo_init: initialize with a ucontext */ diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index 071c951..39e8f1c 100644 --- a/risu_reginfo_ppc64.c +++ b/risu_reginfo_ppc64.c @@ -32,9 +32,9 @@ void process_arch_opt(int opt, const char *arg) abort(); } -const int reginfo_size(void) +int reginfo_size(struct reginfo *ri) { - return sizeof(struct reginfo); + return sizeof(*ri); } /* reginfo_init: initialize with a ucontext */