From patchwork Thu Aug 9 03:40:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 955315 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ebzIbn4n"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41mDf23vGnz9s1c for ; Thu, 9 Aug 2018 13:44:42 +1000 (AEST) Received: from localhost ([::1]:46399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnbsO-0000sv-3c for incoming@patchwork.ozlabs.org; Wed, 08 Aug 2018 23:44:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnbof-0006kj-9C for qemu-devel@nongnu.org; Wed, 08 Aug 2018 23:40:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnboc-0003Bu-5z for qemu-devel@nongnu.org; Wed, 08 Aug 2018 23:40:49 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:44189) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnboc-0003BS-1A for qemu-devel@nongnu.org; Wed, 08 Aug 2018 23:40:46 -0400 Received: by mail-pf1-x442.google.com with SMTP id k21-v6so2138890pff.11 for ; Wed, 08 Aug 2018 20:40:45 -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; bh=6a/GOR0oVfrC4aMp6j4tHYOY3mUq7Mczl/rWUwhb0gg=; b=ebzIbn4n1U82foawoMg8HbRy4fPNJZVlb8nkgidoeg3n15uxaipgS4dmxgYBAVszlV MO75G5/SgkymYOkDTv7rEF7PuUu9++GjW4dXQ0FzxwE7oMucJMHDJ5pOzdk7Hxahy4+b a9G+eAxW6x8jnywXl2P0IMfnVD4fbem9eqtTs= 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; bh=6a/GOR0oVfrC4aMp6j4tHYOY3mUq7Mczl/rWUwhb0gg=; b=si8LaerQGkAM7nCrjJdHhTjoEoL261/aJMrxJfUNZJ25qWIlqfHYx+jId4YAA6gmf9 QJCujC8p6NNlgms4IGCone77uIQR2uFQ0ZW7FJcl1Gxwi0Z/p/RreIdtNbsEMxqIPzJE SzeFhWQekl0CGh35stga596LtZXJyM3GPyGqSGY9IHx8og0e2b++Gb07XjlXRLO0aj8y Cmr1w5p2WDhSUSZTbmKtE0nF8c/wp/4nsKgiri/Gs/ILayMqK28C6hdSWdlCsRfmBIe7 ITRnPDyOSEzyQxwjaxV2IQHm4NLtGV6Rq8s+5DARI7J+x2Zhghh4DUzCoiOaMv3wA5/v /BFw== X-Gm-Message-State: AOUpUlGzwOE2YhbihGt0B7XjGbE24SrZ/JUhJ5zajm8WTJG7TFgsejHG Cn55paGfiPTN3MUDMoo+1kkfEsZWi9M= X-Google-Smtp-Source: AA+uWPxaW6REvIyu1ALnT58yIw/0f7y7UzHes3mgonpew4iyJO11gzxBibne3OZT7LvDyQDca8w64g== X-Received: by 2002:a62:404e:: with SMTP id n75-v6mr462567pfa.232.1533786044820; Wed, 08 Aug 2018 20:40:44 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id q78-v6sm9674103pfi.185.2018.08.08.20.40.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Aug 2018 20:40:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 8 Aug 2018 20:40:28 -0700 Message-Id: <20180809034033.10579-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180809034033.10579-1-richard.henderson@linaro.org> References: <20180809034033.10579-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH 06/11] target/arm: Fix sign-extension in sve do_ldr/do_str 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: laurent.desnogues@gmail.com, peter.maydell@linaro.org, alex.bennee@linaro.org, qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The expression (int) imm + (uint32_t) len_align turns into uint32_t and thus with negative imm produces a memory operation at the wrong offset. None of the numbers involved are particularly large, so change everything to use int. Cc: qemu-stable@nongnu.org (3.0.1) Reported-by: Laurent Desnogues Signed-off-by: Richard Henderson Tested-by: Laurent Desnogues Reviewed-by: Laurent Desnogues Reviewed-by: Alex Bennée --- target/arm/translate-sve.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index 89efc80ee7..9e63b5f8e5 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -4372,12 +4372,11 @@ static bool trans_UCVTF_dd(DisasContext *s, arg_rpr_esz *a, uint32_t insn) * The load should begin at the address Rn + IMM. */ -static void do_ldr(DisasContext *s, uint32_t vofs, uint32_t len, - int rn, int imm) +static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm) { - uint32_t len_align = QEMU_ALIGN_DOWN(len, 8); - uint32_t len_remain = len % 8; - uint32_t nparts = len / 8 + ctpop8(len_remain); + int len_align = QEMU_ALIGN_DOWN(len, 8); + int len_remain = len % 8; + int nparts = len / 8 + ctpop8(len_remain); int midx = get_mem_index(s); TCGv_i64 addr, t0, t1; @@ -4458,12 +4457,11 @@ static void do_ldr(DisasContext *s, uint32_t vofs, uint32_t len, } /* Similarly for stores. */ -static void do_str(DisasContext *s, uint32_t vofs, uint32_t len, - int rn, int imm) +static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm) { - uint32_t len_align = QEMU_ALIGN_DOWN(len, 8); - uint32_t len_remain = len % 8; - uint32_t nparts = len / 8 + ctpop8(len_remain); + int len_align = QEMU_ALIGN_DOWN(len, 8); + int len_remain = len % 8; + int nparts = len / 8 + ctpop8(len_remain); int midx = get_mem_index(s); TCGv_i64 addr, t0;