From patchwork Fri Jun 7 09:05:31 2019 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: 166106 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp417409ili; Fri, 7 Jun 2019 02:52:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzA4ZbGWuQYVgTsfw32TWHlMCY4IANBJ9Z5LIv8KVQYOHU3f1IhiX6ohit9waCZBAOTV3fw X-Received: by 2002:a0c:b084:: with SMTP id o4mr16720621qvc.227.1559901131111; Fri, 07 Jun 2019 02:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559901131; cv=none; d=google.com; s=arc-20160816; b=s6RrKg8URFiJOo0mt8/LqbxvVJk6PM94x84YMFXg0h6zU9G89pM6KUhH4v7mNDvVGq LGJTZgGXy+Fv7VdANj5lWL9FD0vwbEEt3ubDhERUbBWvEnoDJV1/NN6pqid4hUaORvfs loxK+7y0rFS+StVBFYCvLEGSddby6oVV03XnZgz/RTy5P7hIYLeKcO11t6N1dj+cIba5 1d1r42CaHblEc75e+tvMGxGU0MRVMZXl9nevQZGxp8rTUqmETrCYA93v6WkZv0VEkDES YPktkImhAF6FRvY3R/AfpAjxjJR9gimIMjiVFiw1eCofiJXshll2/d86b+OFYa/odaHt evUA== 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; bh=s5wS2YCmNrWOpRGICG3GBDDb7iKA90ngEqstlnBtJU0=; b=Ui0QQ7lyKCIuXdG41zwDqmVp4NqFZ9fU+66nvmObmRnEu6L2eY639mvK37fr3OZ2Ov /8qB1rNW5oq12D9p1fDVS1po2b7igJFpZTyVZMTaOe566C8tQhWpkJnGgodhI+hHa7lp VhO7Xk/TQqSasz/wWHgGdyj529SK3F7GYKNpAlgJHRk21fIpvrdqExfjriGX+G5iim8+ L4p742H/jPf3DWvJ6UbcXBIyQ4hOSeP9Ofcr9NelGej1jWhoa49vb7G6NWkA1GrfR07R +qtDIJ8FBKNkmHQxmyDCGwTD2ERzto0qCxUuu+a573lpG+F4wW+K2NTKvdz8WnJD8Skr OYRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cxnAAiEm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 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. [209.51.188.47]) by mx.google.com with ESMTPS id k127si887926qkd.39.2019.06.07.02.52.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jun 2019 02:52:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 as permitted sender) client-ip=209.51.188.47; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cxnAAiEm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 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]:47660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZBXe-0000cz-N7 for patch@linaro.org; Fri, 07 Jun 2019 05:52:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42065) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAvK-000292-8p for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAvI-0004iI-8n for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:34 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:46959) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAvG-0004ag-8v for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:12:32 -0400 Received: by mail-wr1-x433.google.com with SMTP id n4so1339528wrw.13 for ; Fri, 07 Jun 2019 02:12:28 -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=s5wS2YCmNrWOpRGICG3GBDDb7iKA90ngEqstlnBtJU0=; b=cxnAAiEmIBVJHy3IBBaqTIJXzpehox8BHAdbLUseNY2SHCywMO9iIrziTu0Dg6AvY3 Wo6h1RlO7zmqB2sXZ2+ALwUPUIEJATIIAV+RaO3zhNkCkvTynVVkC+Il2GR+YwloRB3W hPig/QDMKJCH7k94pYk6Tl/3dQJ3Y9ID7ufwxCwHeKFZWq9c2GZLXHoYLRfZY0S7oJ2p /hkkTz4Zv9ir+y/fyKnRv1wrLH6kyxbOLo2k+biq/nIj/i711G+1jHd2nPac8CofQ4kD s3gD/h8klzAOwZtv60oLUWWmb2PS7oWlWWxIZrRfXyPly+yHHywznPvB1yMH8ax9Mqb1 CMMg== 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=s5wS2YCmNrWOpRGICG3GBDDb7iKA90ngEqstlnBtJU0=; b=d8ACLAvPMQK4Ms691PrTXEG+jKbiQctFoyXxWAKdbSHfgJepMFymmLaWoOg2rd2/al 9rQPDe37k+M3se8+AZHmS476Z8WvCUu4A5TmcCpdAhsfOBQ6R5BXyT8AJpnug5cQg4+M 9kYjP3wCZcggGD6r1X9cki/ex5pIoAr2T0SLg6d6tON3u2mCcBQG9fqjrQr1aOAk9ldd i7A5G4gX1/hnXsCB7wV6ohnNLX8J+7f1+ovB+XGT32exY6UR2MGm+T56FxeLInedv3Ha gJzeCYhRMsKLLznW+M9fy8LaLBpn4GNewVXgHlPPUivdTQ+KlULLOyG4x2kUC516QPLY kKNQ== X-Gm-Message-State: APjAAAW7bEMrLkplgryLcFRq4EBwugktgaV9Qc+hzGGjYKCAp89SF76x 3DZdu4Oh+AfqwNztnPTZBl2JDw== X-Received: by 2002:a5d:43d0:: with SMTP id v16mr31413845wrr.252.1559898747207; Fri, 07 Jun 2019 02:12:27 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t6sm1552335wmb.29.2019.06.07.02.12.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:12:26 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 939E21FF8F; Fri, 7 Jun 2019 10:05:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:31 +0100 Message-Id: <20190607090552.12434-33-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-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:4864:20::433 Subject: [Qemu-devel] [PULL 32/52] cputlb: cast size_t to target_ulong before using for address masks 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: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , qemu-devel@nongnu.org, Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Randrianasulu , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" While size_t is defined to happily access the biggest host object this isn't the case when generating masks for 64 bit guests on 32 bit hosts. Otherwise we end up truncating the address when we fall back to our unaligned helper. Fixes: https://bugs.launchpad.net/qemu/+bug/1831545 Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Tested-by: Andrew Randrianasulu Reviewed-by: Philippe Mathieu-Daudé -- 2.20.1 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index b796ab1cbe..8f814a1a2c 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1306,7 +1306,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uint64_t r1, r2; unsigned shift; do_unaligned_access: - addr1 = addr & ~(size - 1); + addr1 = addr & ~((target_ulong)size - 1); addr2 = addr1 + size; r1 = full_load(env, addr1, oi, retaddr); r2 = full_load(env, addr2, oi, retaddr);