From patchwork Sat Nov 11 01:32:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 743082 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp541493wrw; Fri, 10 Nov 2023 17:33:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEulRC+oQiyY9e4B2QFstPGe+7j/IvK4B4m7CGtIkb9GXQ4/nC5H64ubV3OrH8MQnWjJDdw X-Received: by 2002:a05:622a:a:b0:417:9c40:c606 with SMTP id x10-20020a05622a000a00b004179c40c606mr1179646qtw.4.1699666436359; Fri, 10 Nov 2023 17:33:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699666436; cv=none; d=google.com; s=arc-20160816; b=aNTp/2lDN8pK2KElZQxzstxAWCyTBfCMVVtfWwrznfykzPvuclBGII6FHgUJlS76sh 4nAWWawtIQSdSQAQfb6WLvs7PAC0q+tgcJxiUwOu39bTvNo1oQaVPE/4LWKGEldOWopz My/ShZcLLXvj2/VSaXFOvvdyXDynkFfpM22VU96Wi/nWb38y5Zj2WlB1oi17itNddgzD lipRaYcUJW8G178go7vqBtZr/YPnFOrP67+rsKVVMFxbeJaFAZFgBlL0ifbt4ij5JqrR XiM7TCNjTod2CGwJ5BHmnZKgr/kGflSCxOZNRkMNk1AKHeD/yOn3jkS/7t/biCjHj6NH gUqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=7D/Is0q9/XY5O6mimvb47xPlpmUh6SE4PEHCKmELxsQ=; fh=Fj0Zuc8sq4K6k4oHPZOcnopUxOuwcXsIqbbdytUdbPg=; b=fM4nkB7FzOReyM4bVGE2FGu5THfHolBnR7qZlvRVsgClLTxzgdq6w1I6WCMhiLEOFG /ai7cqiux5cctFzUBRJJSgtjO1zLWS1oUhj6HkKv9Wp2r3oFNZNG6dPp+Dx/Sg7kk4MK PjzA0HwY+L2ml+VIXinH8OZcxq7M4g7m7MLGfR4Xuf8ehlfy1fPfY4hS9UWb/7NeduQq Cq1BmkvR+lvI8/vUWoaNBjPPLys/5TEGDcFu/STMS/Bgo+729lUbZNwaQ4lyDweUVKCS VqvNOq2KVJUDBWw55kdmnpQ4bYNhAzOuUyqqGpZfsrFTA9BwpyC492/GvLF2Qt5S4Juv +crA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wr2JMVja; 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 h5-20020a05622a170500b00410a622566asi655664qtk.201.2023.11.10.17.33.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Nov 2023 17:33:56 -0800 (PST) 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=wr2JMVja; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r1crN-0002Br-HW; Fri, 10 Nov 2023 20:32:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r1crK-00024y-1t for qemu-devel@nongnu.org; Fri, 10 Nov 2023 20:32:26 -0500 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r1crI-0001bI-Ej for qemu-devel@nongnu.org; Fri, 10 Nov 2023 20:32:25 -0500 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-1f04c5ed8d7so1483404fac.1 for ; Fri, 10 Nov 2023 17:32:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699666343; x=1700271143; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7D/Is0q9/XY5O6mimvb47xPlpmUh6SE4PEHCKmELxsQ=; b=wr2JMVjajQIaudnOILXp/z4+/VC3ytkvbvAM+vmrwvLl2XYLvZxXehqB1C4wHrLLrO WOu1dZTHb5MoJuj5lyajA9UvHaTU+1FGyhatXhq0lQf3MomGIYyWsLfnyCis9TJjES6J fyxy8SrVnBHR5SmRiAgND4E5N4ywJAQn3CLmMcq2WBvFUGw6xmPHG8VYgkkkEMG/mN7w wwuws0jjXC6w26nP2UBg+CXq32zq8sD2NEhH0V54WA9i5+9vBX7Kcx1SoV6fyWcIWLJo BlwfDQATVztXyshWhkPCmhWmTHKqPbPQBag7i4OMwKa7aC4E7V6Nk8ppLC5CO0IO5Xqq IMew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699666343; x=1700271143; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7D/Is0q9/XY5O6mimvb47xPlpmUh6SE4PEHCKmELxsQ=; b=u0ZNXB3uXfm8hWKFBZOkLqyHWYPSuyoPBNHMW3TgrUHwWZB2ZeZDhi4+LGbUti750q I8twVqRdfnWMSXPyWoQ17P5y029NbvqC7S+3foFatlHcWUuiPMPFtbl35F4dks8uVINP 6w9bEYFLAZGCVM9h57rKcuA5vjUUF7w0UlRC76mLD2nWNd2b86AzrzjjgM9vrxRV7Kny XRMqTHmvlu9G7UKHpoqbHSFVKWKYF42FS++vLEQygGIJKD2NGv2FkEDw6wzOGZrnBjm3 wP1BonRdgVjJ1JiUt9B7Y0Y6R7toBsHhXoTkftK3nwSUYFXyBidCx1rpHzNWcJM0c/O7 QXmA== X-Gm-Message-State: AOJu0YwfZEypLn53YVCo6cTYHXU2TeFX+GVvf5nvXVp4GoSxqGA1pAxH dUAqHtbFxuAJdYAwEzBp9iya41dWJxLmEHhBO+A= X-Received: by 2002:a05:6870:3051:b0:1d5:8fb8:98ef with SMTP id u17-20020a056870305100b001d58fb898efmr1138307oau.31.1699666343047; Fri, 10 Nov 2023 17:32:23 -0800 (PST) Received: from stoup.hsd1.or.comcast.net ([2601:1c0:5e02:2a20:a99c:45a6:14e9:ea6]) by smtp.gmail.com with ESMTPSA id m11-20020a62f20b000000b006c1221bc58bsm333502pfh.115.2023.11.10.17.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Nov 2023 17:32:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@gmx.de, Peter Maydell Subject: [PATCH 07/11] target/hppa: Fix possible overflow in TLB size calculation Date: Fri, 10 Nov 2023 17:32:08 -0800 Message-Id: <20231111013212.229673-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231111013212.229673-1-richard.henderson@linaro.org> References: <20231111013212.229673-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::2f; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2f.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Helge Deller Coverty found that the shift of TARGET_PAGE_SIZE (32-bit type) might overflow. Fix it by casting TARGET_PAGE_SIZE to a 64-bit type before doing the shift (CID 1523902 and CID 1523908). Reported-by: Peter Maydell Signed-off-by: Helge Deller Message-Id: Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- target/hppa/mem_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index 858ce6ec7f..a13f200359 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -450,7 +450,7 @@ static void itlbt_pa20(CPUHPPAState *env, target_ulong r1, int mask_shift; mask_shift = 2 * (r1 & 0xf); - va_size = TARGET_PAGE_SIZE << mask_shift; + va_size = (uint64_t)TARGET_PAGE_SIZE << mask_shift; va_b &= -va_size; va_e = va_b + va_size - 1; @@ -505,7 +505,7 @@ static void ptlb_work(CPUState *cpu, run_on_cpu_data data) */ end = start & 0xf; start &= TARGET_PAGE_MASK; - end = TARGET_PAGE_SIZE << (2 * end); + end = (vaddr)TARGET_PAGE_SIZE << (2 * end); end = start + end - 1; hppa_flush_tlb_range(env, start, end);