From nobody Fri May 17 02:03:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1689868813; cv=none; d=zohomail.com; s=zohoarc; b=T3yMrCQZb05PyqRhZkw3KAs5tBKfnOhgocCe1PjC4OQuM38Olx+5sXBYXM52F1eDccW2WhdQYUmhnLINT9M+uqKR7fl0FCvxQAfkh3scMgnZaeuKMqLGN6dgtkYeLt0y3onS5aijVRne3O3YiXQNrJsfZnhkIjlkg8VJYYF0Tas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689868813; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SzNtfI3TP/wA6vffJRkjpFoMkJ0EgXW2e/UYOIIB1hM=; b=IEQUjorlBMng5Q8CpkNXr8yud0MFNOJ2j1NCszwlwLENXNmC5CSgEy9kB0ehDcwGCnt9ebZoAAxYvG7yXU7t50tGvuqiMXjaFy1mJql80ob5tAeVVA9kksd8Xu9Ys3zF6TjBRXTmNgroUCBNZo7mHvL5vMlrEuK4N/TsPffFdCY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689868813506294.31100283748526; Thu, 20 Jul 2023 09:00:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMW3s-0000Yl-Rb; Thu, 20 Jul 2023 11:59:28 -0400 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 1qMW3X-0000Ww-R3 for qemu-devel@nongnu.org; Thu, 20 Jul 2023 11:59:07 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qMW3V-00053Q-I9 for qemu-devel@nongnu.org; Thu, 20 Jul 2023 11:59:07 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fbc5d5742eso8466985e9.3 for ; Thu, 20 Jul 2023 08:59:05 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z5-20020a05600c220500b003fc02a410d0sm4187572wml.48.2023.07.20.08.59.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jul 2023 08:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689868744; x=1690473544; 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=SzNtfI3TP/wA6vffJRkjpFoMkJ0EgXW2e/UYOIIB1hM=; b=RDhqxn/2Q8IIgM96ul0f8XeG+GNYAYGHkTKcTCuTclukKJy0YzZUFmukxxrMJ2iLQW KInMu+vYFsFOavLudpWtGeKdO7ONrBneD4h9eBgsXeUWL6ANlFrHdN+61XeOJw78r+GV T13xNY9zBbRSxC03xX5xzo3/zF8qcas/CdLEEK00WmSvCJjMfGVmbQpxPns9B5KfG4SI v+kMUjqKkbL40cehsJjWlS5XYgNYlztpTty6bzm7EDeeCqgeLWqIIvV7w8itFQHcKJgO cJ6XEHk5q9BeYG2DG9gfX6Wa6MzGVdTgyEmeuQgQXngM3TMQ1LTtZFUH/x/mEgrzjYPo YhKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689868744; x=1690473544; 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=SzNtfI3TP/wA6vffJRkjpFoMkJ0EgXW2e/UYOIIB1hM=; b=LVbTueV7rnqIZYXi02WWrHdhslHbSsFN/r1si7Ww08DT08kEH2qfMMtkOZESvS80wX 59j+4n4mkM2puSTw8+tjbgGw8WoHA7INdus/vwHy+xCW0yZ6JLCvjRdX3zuvxSYZnKiv Ue4vQDnngzEzscVruG93G5PXUouB4qtLtzQl5Wt6q1xnIuVJQRURMB2k3chMttFudJec HV+v47LV22s9NXtBZDeXW40+Jp34G0UAXhJa7GjPmbLNrOuCO0FkipQozcyGdV0qYLYE mxPx14WO+pkZeoI7FyS+MJLczHcX2mKSnckfUMO8jnYK7NXTw+Na/ycP7wYibzqS/vBm UPTg== X-Gm-Message-State: ABy/qLacjLYULK9gIpBQ4Nhgz/24ppd0kv8shiHMEClWbXU0tH1HqqXD g5Stdt3rhTnHUuIOr/Q1iMBo0K77+9numoSxRak= X-Google-Smtp-Source: APBJJlH5USkAaP37iXPEdZz7u+4OcjyttG7pJV8ELRUo1QoflntYpcGrXZqTodbc3sa/1hQVLQ4auQ== X-Received: by 2002:a1c:f30e:0:b0:3fa:91d2:55b6 with SMTP id q14-20020a1cf30e000000b003fa91d255b6mr2251865wmq.9.1689868744058; Thu, 20 Jul 2023 08:59:04 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Andrew Jeffery , Joel Stanley , Paolo Bonzini , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH for-8.2 1/4] hw/rtc/m48t59: Use 64-bit arithmetic in set_alarm() Date: Thu, 20 Jul 2023 16:58:59 +0100 Message-Id: <20230720155902.1590362-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230720155902.1590362-1-peter.maydell@linaro.org> References: <20230720155902.1590362-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1689868814635100001 Content-Type: text/plain; charset="utf-8" In the m48t59 device we almost always use 64-bit arithmetic when dealing with time_t deltas. The one exception is in set_alarm(), which currently uses a plain 'int' to hold the difference between two time_t values. Switch to int64_t instead to avoid any possible overflow issues. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/rtc/m48t59.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/rtc/m48t59.c b/hw/rtc/m48t59.c index ec3e56e84fd..2e2c849985c 100644 --- a/hw/rtc/m48t59.c +++ b/hw/rtc/m48t59.c @@ -133,7 +133,7 @@ static void alarm_cb (void *opaque) =20 static void set_alarm(M48t59State *NVRAM) { - int diff; + int64_t diff; if (NVRAM->alrm_timer !=3D NULL) { timer_del(NVRAM->alrm_timer); diff =3D qemu_timedate_diff(&NVRAM->alarm) - NVRAM->time_offset; --=20 2.34.1 From nobody Fri May 17 02:03:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1689868805; cv=none; d=zohomail.com; s=zohoarc; b=GOKoXV0judpIE0dxvb1LFxDwxcq1HcaxixNhwmBgpFolqr9um1y20Gmkjp2euawDjmeI6m1p13K9Cu63vMEr/5xllOW75+Zro2GoQXYSyPead4E7kYg13RNHA66elRtmKPcWLQZG4854XhJIL35yw8Sz+AekYfX4gDgbaQv5A2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689868805; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xQLZW4i4RwSsIRthgz4zXgxBtJp6nXoRhcDsoNfo8Zg=; b=H0iGUdfjoaJ0RH/GMRaB18CLzXZzEiMLApG8Lotk2GAZJk79RMZcv3EWY6TRFCnkWc70l/MG8UzN3JwReyVpnuHz+aPFGVihHrK3E7+AsG0lM33xvpVSELZV2+03o1lJkRbXwzcyGwB6gwTF7pqF2OLc+djVBxY9pQ3HjspqqnA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689868805556643.7677569334032; Thu, 20 Jul 2023 09:00:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMW3q-0000YJ-Gp; Thu, 20 Jul 2023 11:59:27 -0400 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 1qMW3X-0000X0-SY for qemu-devel@nongnu.org; Thu, 20 Jul 2023 11:59:07 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qMW3W-00053t-4B for qemu-devel@nongnu.org; Thu, 20 Jul 2023 11:59:07 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fbd33a57b6so8486055e9.2 for ; Thu, 20 Jul 2023 08:59:05 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z5-20020a05600c220500b003fc02a410d0sm4187572wml.48.2023.07.20.08.59.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jul 2023 08:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689868744; x=1690473544; 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=xQLZW4i4RwSsIRthgz4zXgxBtJp6nXoRhcDsoNfo8Zg=; b=WjuU/m2JrumlbIxMi6C4lDSTFURyPZy6V01bUd1JHSD5fuB2IJwbWhOU9nJUK3/JcY O/XpCbALYG+XV7X/LncX5UdOBlRSSrcocINyDMv1ArfG9tZfqV+OJji7gkW4eUzsBCtq PEIZzT1gP3d7qsI2a3bPUVHXv4Hwnt9neM4JpzLMqPkdYlAqZI9EDVl6NQnz4dPjSLzK k1pqFbftEU8bqLAcuPm1YGBQEzLHFNoV/iOMuJd+I4ndQsDPajIR0Niyu6pBv8JDCaWB tNQWKzcQjRtFDgJ4Wk2h392RJG4+gPPxovt4krz7WoToXP+HiQstMOP839nNAPxLn0HO M2MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689868744; x=1690473544; 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=xQLZW4i4RwSsIRthgz4zXgxBtJp6nXoRhcDsoNfo8Zg=; b=PvQOM2nubShZgl+iucNqQdgNBRPoPSaNsXNvOUeP/JRloB3BgOeqoDqTxpNLplz5Rw gwjyFQMaI8LIN8LqKfvc8JESrivh+jQJGuZ2UxE5bxXTmXl6nhFOWkSObge2eoYGErCt oU84puEtLM5SQpo8JoTVxltmK4QPUmEcmnZ/l37NzS1ZKLrcUv3+yfmb4Zfm4GsUhnd5 kxH16k79tjdqkrFK73blPggcqrV9S/H0KnMHO2rK3/eBvZ+yBQmJVZQTrE0QZ7/CTDAK lwo6yzDJFkLYpIrGOQ8oARVMV6CSRnn3Opn0XxSpWGfyiKbthl5tMknusRNWlidNCGT5 IH8A== X-Gm-Message-State: ABy/qLYxC++T0jwWkV3P0E/YLi4FbAZHmTqx2uH3M6vkWJDlsKY1OJYT uuT3zZAXsEx+8DAsIN7u+jAm7KpN5jTb1m8/rwY= X-Google-Smtp-Source: APBJJlEj66efBVt2tcL5ODmn4VJuBvjsMxImyf2VK95LmOS6pjMBoG0IDGzFLNREMEqclh49e+L4xw== X-Received: by 2002:a1c:4c11:0:b0:3f9:b748:ff37 with SMTP id z17-20020a1c4c11000000b003f9b748ff37mr7722489wmf.20.1689868744659; Thu, 20 Jul 2023 08:59:04 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Andrew Jeffery , Joel Stanley , Paolo Bonzini , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH for-8.2 2/4] hw/rtc/twl92230: Use int64_t for sec_offset and alm_sec Date: Thu, 20 Jul 2023 16:59:00 +0100 Message-Id: <20230720155902.1590362-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230720155902.1590362-1-peter.maydell@linaro.org> References: <20230720155902.1590362-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1689868807236100001 Content-Type: text/plain; charset="utf-8" In the twl92230 device, use int64_t for the two state fields sec_offset and alm_sec, because we set these to values that are either time_t or differences between two time_t values. These fields aren't saved in vmstate anywhere, so we can safely widen them. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- I have a suspicion that really these fields *should* be being migrated, but this device is only used in the n800 and n810 boards, so I'm not going to investigate how broken migration/vmsave is there... --- hw/rtc/twl92230.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/rtc/twl92230.c b/hw/rtc/twl92230.c index d8534dad949..64c61c3daeb 100644 --- a/hw/rtc/twl92230.c +++ b/hw/rtc/twl92230.c @@ -65,8 +65,8 @@ struct MenelausState { struct tm tm; struct tm new; struct tm alm; - int sec_offset; - int alm_sec; + int64_t sec_offset; + int64_t alm_sec; int next_comp; } rtc; uint16_t rtc_next_vmstate; --=20 2.34.1 From nobody Fri May 17 02:03:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1689868814; cv=none; d=zohomail.com; s=zohoarc; b=YfXJ67aYjwwRG7/qLTtLcfgdKyXfHxk5PCmXI3zXUH1nk5IDbe1ZSMO386XCdXRbpId6zGz9SZleI5dbh9Sud4nzMrpuYf0+0fDMKJezbHOi1/Lk2hr0fD9jDNodyTOCc7DtNs2DIxJ8S9sV9WOZMmpf3oLLaexAZ+Fzvcl7Il0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689868814; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p+fu3Hdhlxf6MgJgkEAusairljl/PpUC4pvYOeOu/ZE=; b=ZKKl4ka2OcjIs1gpiMYE2CVgMrBEkh6+GGFDAJNNDEEwxc3EhhGElDgjB9yJtzab+SGdhdOSFel257LLf0vAw3FCfjVUrzQB6XcOowdHVo9sxK/LkHrEt/dTW+CCnpYM2yZguuBwQHY3fMRAa9d8jYW5ng8VvzGENDD7oZUsb8w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689868814056838.3478242210884; Thu, 20 Jul 2023 09:00:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMW3s-0000Yj-Lr; Thu, 20 Jul 2023 11:59:28 -0400 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 1qMW3Y-0000XI-9P for qemu-devel@nongnu.org; Thu, 20 Jul 2023 11:59:08 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qMW3W-00054E-Ln for qemu-devel@nongnu.org; Thu, 20 Jul 2023 11:59:08 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fbc0609cd6so7825175e9.1 for ; Thu, 20 Jul 2023 08:59:06 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z5-20020a05600c220500b003fc02a410d0sm4187572wml.48.2023.07.20.08.59.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jul 2023 08:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689868745; x=1690473545; 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=p+fu3Hdhlxf6MgJgkEAusairljl/PpUC4pvYOeOu/ZE=; b=Ao525uJK2+OHzTfjR94YhIfsPC4vVvIYQP5BPwxLczfgvHgSPskJq6hrJUv/dexQr9 dd31SY3nbLcSEcg3Dqs9ZjLvTmka1P2EuOZHC8cw6bCBoEDqVuDUQ7aM4KbDu5lo2diU 0AGGdV5cnY/A4ICk688uZQXOHtcFvUmi29vM8tspQIhp8Cko83N5X4aM3XAOyUbKGQRH F+BUTGObiBsU/di/sWONylNDFhRwC+MIk9YfMUEqEouf/9rGQ6FJrpqr/O+nakCvdKH1 RLT3D72YG50eqtWzJM4R0PBmeBJo9Rkjpv1O/76dFU21njLqOHVDNZikL0KAK4yLGd8F RHpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689868745; x=1690473545; 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=p+fu3Hdhlxf6MgJgkEAusairljl/PpUC4pvYOeOu/ZE=; b=QwSCD333t6niRyzNbBaV6p8Ad6++ucKWbq4hwsCJSvGt+lzgSLS2XWiOsXGAvLdfHD 1XjOTUdK4XgSrLE+JQe3e4So1MJrverDD6GDKVl7MCBVoW54U0sGrxbyo0NGDeVilGcP WY3Nj5Hzq7ROG7RqA3ey5oTdOAdyPW+CypiQm5PT4Yd4tkMNVxNna47qIC6RFp2zY7OX prF06z2fYD8NyY6cZfSAVBpzOxo0Te0uKtpxQ103MHL1Pk6PrV0bUtv3ZsdpqD66e9Ub HhqlpA7x1uYTq6Y/jI1vuw2wQZZceZvE9flg7joxS3r+lGo+HmpaLKH09GFFZd7QPZQ5 ZaNQ== X-Gm-Message-State: ABy/qLbUUeexpGexKCv6Z2RAaThDwgp9B5EjWGwfdFW4sOomJ/3bKuN0 /KcQH8M2XJCiD/sxfZG1bNvG/ndacXZkJELHVJs= X-Google-Smtp-Source: APBJJlFF+EU571plm4fQ3YtZZjUDXajpFnaY2l0+FSX9l4LyINyuY9HX1jNYiH6R94KGtgzdHHOyew== X-Received: by 2002:a05:600c:d5:b0:3fb:b890:128b with SMTP id u21-20020a05600c00d500b003fbb890128bmr5148407wmm.27.1689868745257; Thu, 20 Jul 2023 08:59:05 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Andrew Jeffery , Joel Stanley , Paolo Bonzini , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH for-8.2 3/4] hw/rtc/aspeed_rtc: Use 64-bit offset for holding time_t difference Date: Thu, 20 Jul 2023 16:59:01 +0100 Message-Id: <20230720155902.1590362-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230720155902.1590362-1-peter.maydell@linaro.org> References: <20230720155902.1590362-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1689868815415100003 Content-Type: text/plain; charset="utf-8" In the aspeed_rtc device we store a difference between two time_t values in an 'int'. This is not really correct when time_t could be 64 bits. Enlarge the field to 'int64_t'. This is a migration compatibility break for the aspeed boards. While we are changing the vmstate, remove the accidental duplicate of the offset field. Signed-off-by: Peter Maydell Reviewed-by: C=C3=A9dric Le Goater --- I took "bump the migration version" as the simplest approach here, because I don't think we care about migration compat in this case. If we do I can write the alternate version of the patch... --- include/hw/rtc/aspeed_rtc.h | 2 +- hw/rtc/aspeed_rtc.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/hw/rtc/aspeed_rtc.h b/include/hw/rtc/aspeed_rtc.h index df61e46059e..596dfebb46c 100644 --- a/include/hw/rtc/aspeed_rtc.h +++ b/include/hw/rtc/aspeed_rtc.h @@ -18,7 +18,7 @@ struct AspeedRtcState { qemu_irq irq; =20 uint32_t reg[0x18]; - int offset; + int64_t offset; =20 }; =20 diff --git a/hw/rtc/aspeed_rtc.c b/hw/rtc/aspeed_rtc.c index f6da7b666d6..fa861e2d494 100644 --- a/hw/rtc/aspeed_rtc.c +++ b/hw/rtc/aspeed_rtc.c @@ -136,11 +136,10 @@ static const MemoryRegionOps aspeed_rtc_ops =3D { =20 static const VMStateDescription vmstate_aspeed_rtc =3D { .name =3D TYPE_ASPEED_RTC, - .version_id =3D 1, + .version_id =3D 2, .fields =3D (VMStateField[]) { VMSTATE_UINT32_ARRAY(reg, AspeedRtcState, 0x18), - VMSTATE_INT32(offset, AspeedRtcState), - VMSTATE_INT32(offset, AspeedRtcState), + VMSTATE_INT64(offset, AspeedRtcState), VMSTATE_END_OF_LIST() } }; --=20 2.34.1 From nobody Fri May 17 02:03:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1689869009; cv=none; d=zohomail.com; s=zohoarc; b=U5YlzLllgRfgacGnU1RJLFZNZ6woF9WQCHgWWGk6W9Uy5RwNMZE21IzYOe97BT3RhIf1tsnnIdtXUzIkUAI10FF9sePNPLXY+4krhI/2Ff2jj3Qe+KCzyf0Q5CLZcTj3VpogV79ZQM7kMnjg6yeIPihwtnPCEGGL2sVebgYyBRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689869009; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RqoBrwb3O6xPxonYvG2KesZmPgQJqZE5ArjMIGo47jo=; b=P7LgWV2u3IO+e/J/j9Jn5wqAY2cyCaIBzXwa4d5RsiaCEC0lhV+uTrmF4rFIhgw6rR7hf6LFAzb63G2s86a3RgEmr7d/SnzOzq/+7B9tGxIa87YKxTGyQ9Qd+0Iz8RMammqQ+aD6at8dvMvtmkKKZ1zGB9qntTQqfXKS7CKx/YY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689869009206646.5450257761372; Thu, 20 Jul 2023 09:03:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMW3t-0000ZJ-NQ; Thu, 20 Jul 2023 11:59:29 -0400 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 1qMW3i-0000Xh-C4 for qemu-devel@nongnu.org; Thu, 20 Jul 2023 11:59:25 -0400 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qMW3X-00054Z-Db for qemu-devel@nongnu.org; Thu, 20 Jul 2023 11:59:08 -0400 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4f9fdb0ef35so1560254e87.0 for ; Thu, 20 Jul 2023 08:59:07 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z5-20020a05600c220500b003fc02a410d0sm4187572wml.48.2023.07.20.08.59.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jul 2023 08:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689868746; x=1690473546; 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=RqoBrwb3O6xPxonYvG2KesZmPgQJqZE5ArjMIGo47jo=; b=bRFrMk2s1BnbFjrIcdW9Hd8QMDfK3AsqTdGpbkKZIUI8Wt5bboegGBH+XCE6hjQJkL MzhlYp48EjCxrA761wwJNMzeXOEHuZpKLJpYXlK/tyZdtnOIBjNIi7Rk1aUsrl8opS6v wNkJPHJWE13RRlIe8PPbY6XZl44unntey3lViRKNj6hhWGDIugeOG1WBDNBSgkElnt3f Qkj+7t3vuUp/QtmT0P8tXEqMHTA4CSw78UfmpvcxOuXlapZHmTrV1tayjeIvl3bPSYOB 7YS9SzYpW6yFes9QRGnZcTeI7aNur6btW9e74/LhJItBodALLwBvXQmF237s/mfrVDOw uGWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689868746; x=1690473546; 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=RqoBrwb3O6xPxonYvG2KesZmPgQJqZE5ArjMIGo47jo=; b=UCyXRFnFntGweezxyFt/2sPTEnX65xQ8sKYptJNIWDAZSoE8A8b+u5Ctd41SeKGfgL tDilPaE3LdckSdKFdc6abJcSQj4SWt+2pq0otKyPyW4VBNzaQqKjeuRnt/Hxv0e9npr9 hS+DgeYpKxTJYlrRg6sSUQM/fhuXtnxHnHpYBH61qu2y9tb7DGLiOEaj0x9ywAc4k+Wn 6TNwdQRxQLzwpX1iBg5oMADkVDb/M5vSJw3gdjjaVc/HFEUH5/NLJRnnc0vNJFWArsyK kXGzSBT9AiyK6HJAgsxtNIOs2nOBu8fSuQQLDP3zzHgPOZrVGl/WYrm6u1Y9o7NkPMp3 07LA== X-Gm-Message-State: ABy/qLYhGBT1rXxuQmpyLAHZu8sJ79LHpz1YLC0U3e1mnMpVk+e9HozE YcbT9NyuWOUg+1sAaC+5it/5I3JdRlOIXR41/i0= X-Google-Smtp-Source: APBJJlFscCloGNVNfegSbozo+JIroDgE6QXbPToUe9wCrXvlFyJtboFgyUgtQT952nSESitn5ChEgQ== X-Received: by 2002:a05:6512:1115:b0:4fa:f79f:85a with SMTP id l21-20020a056512111500b004faf79f085amr2124742lfg.69.1689868745881; Thu, 20 Jul 2023 08:59:05 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Andrew Jeffery , Joel Stanley , Paolo Bonzini , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH for-8.2 4/4] rtc: Use time_t for passing and returning time offsets Date: Thu, 20 Jul 2023 16:59:02 +0100 Message-Id: <20230720155902.1590362-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230720155902.1590362-1-peter.maydell@linaro.org> References: <20230720155902.1590362-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=peter.maydell@linaro.org; helo=mail-lf1-x12c.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1689869010071100001 Content-Type: text/plain; charset="utf-8" The functions qemu_get_timedate() and qemu_timedate_diff() take and return a time offset as an integer. Coverity points out that means that when an RTC device implementation holds an offset as a time_t, as the m48t59 does, the time_t will get truncated. (CID 1507157, 1517772). The functions work with time_t internally, so make them use that type in their APIs. Note that this won't help any Y2038 issues where either the device model itself is keeping the offset in a 32-bit integer, or where the hardware under emulation has Y2038 or other rollover problems. If we missed any cases of the former then hopefully Coverity will warn us about them since after this patch we'd be truncating a time_t in assignments from qemu_timedate_diff().) Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/sysemu/rtc.h | 4 ++-- softmmu/rtc.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/sysemu/rtc.h b/include/sysemu/rtc.h index 159702b45b5..0fc8ad6fdf1 100644 --- a/include/sysemu/rtc.h +++ b/include/sysemu/rtc.h @@ -42,7 +42,7 @@ * The behaviour of the clock whose value this function returns will * depend on the -rtc command line option passed by the user. */ -void qemu_get_timedate(struct tm *tm, int offset); +void qemu_get_timedate(struct tm *tm, time_t offset); =20 /** * qemu_timedate_diff: Return difference between a struct tm and the RTC @@ -53,6 +53,6 @@ void qemu_get_timedate(struct tm *tm, int offset); * a timestamp one hour further ahead than the current RTC time * then this function will return 3600. */ -int qemu_timedate_diff(struct tm *tm); +time_t qemu_timedate_diff(struct tm *tm); =20 #endif diff --git a/softmmu/rtc.c b/softmmu/rtc.c index 4b2bf75dd67..4904581abeb 100644 --- a/softmmu/rtc.c +++ b/softmmu/rtc.c @@ -68,7 +68,7 @@ static time_t qemu_ref_timedate(QEMUClockType clock) return value; } =20 -void qemu_get_timedate(struct tm *tm, int offset) +void qemu_get_timedate(struct tm *tm, time_t offset) { time_t ti =3D qemu_ref_timedate(rtc_clock); =20 @@ -85,7 +85,7 @@ void qemu_get_timedate(struct tm *tm, int offset) } } =20 -int qemu_timedate_diff(struct tm *tm) +time_t qemu_timedate_diff(struct tm *tm) { time_t seconds; =20 --=20 2.34.1