From patchwork Fri Nov 10 08:09:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118512 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1905880edl; Fri, 10 Nov 2017 00:09:45 -0800 (PST) X-Google-Smtp-Source: ABhQp+QOGxShxtYuDYW3JlJqrEDrP/TVLmtKcfLlTRkpbwpuVf5LKvupPfmvHvlTVhdqS+HxHc2+ X-Received: by 10.84.178.131 with SMTP id z3mr3277026plb.165.1510301385825; Fri, 10 Nov 2017 00:09:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510301385; cv=none; d=google.com; s=arc-20160816; b=sHiTXqgOPxhqLYjRh7fgRjn/rlFa4HXL8O94SJRso3MutkPGpN4K8i6AoShU9UoOEL gW3NKP3jkLJpk/vdWAkHFhL6yant5vrOC7ehnlM3E/daBXxYWWmk1qASwQ3jxnjJ1qSf ZgRgPSUIlMc9Q1AR8SJNKtwBldDhl8CShpGC4gWp9RCkB+wPJWPR+OQ8nSjOsJ7mOhIV Muju75C0pX8pGNMdAtRpgTwqhDDauyIIyr+XWRiU8BbLtO2BQQxtdHL4hlkIxvVMveMW hJfICOegKuacdaJvGQ1yajNL9ZeyW7C1PqTCoaFdLfgreJ4L76NTMHmJTo4M4xNh98dc 7vjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=EhFx6wxQQV/Fjxe2jXdxJ5hvXUBPI2tuIUI1lF1F6bs=; b=0A30ZNUEzVWhb4+ZNkdpiBAermPbcUsKSHUzyJpvUwQdb3+hjQcUOIIlkaexi6g9wT ZVPEhiwTY98pk4CZPVcDEJzkb3B9acf4u2x35cMO0QPTvt3ueniWvwE0FiZZIqTuiykL vvWPKm0LbB7Lvp5FpAM9YBxhxWN8QZ5Mksd90RFD46Su6w0aFUN/2UGPFQp5BKV1obPQ kC1TKqXeGSyQVAvkoFWCYh5yZT4/Zyyhhhny0MoIeb6BrrGaROEru5ObIJkiqRJdWCSo CKhM4BOReJ2liQkPDx4GWAlyvPmZp64xPdvt1so5r1+63QoyX8m1RgC4Yk/LaDrdp2Dy r/ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IUtcsgIo; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id d193si7898028pgc.632.2017.11.10.00.09.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 00:09:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IUtcsgIo; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CA5DA2034EE08; Fri, 10 Nov 2017 00:05:41 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::244; helo=mail-wr0-x244.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 25FFC21B00DC8 for ; Fri, 10 Nov 2017 00:05:40 -0800 (PST) Received: by mail-wr0-x244.google.com with SMTP id p96so7832287wrb.7 for ; Fri, 10 Nov 2017 00:09:42 -0800 (PST) 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=Lmhlve1qgn3pm1/A0AFbFclzv3TsRBn2IY1qQdCD/oE=; b=IUtcsgIoeuZbDjz/eVqiwyunrHOxXeLp2cBaE57StEpvTB/jdW5K7+z+bKF6WBXxy4 4ZaG8wSxuWKBrlJJRXOn4fgCDXCveM6Xg8xLqU33E+G9niQnjFSA/od/3/ptfHCkuIGK VjKqyy6Z0w/DVzVzlJt070fMJVJxEBCGvqkAU= 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=Lmhlve1qgn3pm1/A0AFbFclzv3TsRBn2IY1qQdCD/oE=; b=M0TABP+4eaJPV/CCv35JD6+AMUxQjwSpSsc2ZjJ8y7v0UMjNw3M7g++QgjGxyQ/VNo z/bZ/kPWA2BYtwlRr8/HzWcXDmyOhwq9P2iVZmhJ6ZEhWlOqoUoZsDvdyo3uc4d+CuTP QY0SdrNFGlaEjbgJ2SAzu41nBGOU2QJ9SO1XzQ031H/A6IuSE3nxn3STe9o0H170nerH VZ7CHPpQaVzAaXNQmK9QSZHVI8Lrqp9lWxTv/vCKmTR7Q2VQJMa5OgF3xTZ9U8kCd+dt stLbSMhU/Vzcza7B8KiAuad1XocLBjVebLCbJqBqsmbDQ3cNURJlF4A2o130dscz8oPM On+Q== X-Gm-Message-State: AJaThX6WBWC2nSG3CFyOzEk6IMcXo9Y2OakECr/4Ylk+Gl/jmN7wKYkQ r+jaxMhTs56LgV2+rX/3nV/oYbtnue4= X-Received: by 10.223.139.149 with SMTP id o21mr2553515wra.87.1510301381178; Fri, 10 Nov 2017 00:09:41 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id r23sm4133884wrc.93.2017.11.10.00.09.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 00:09:40 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Fri, 10 Nov 2017 08:09:25 +0000 Message-Id: <20171110080925.28599-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110080925.28599-1-ard.biesheuvel@linaro.org> References: <20171110080925.28599-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v3 3/3] ArmPlatformPkg/PL031RealTimeClockLib: ignore DST setting when timezone is set X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" According to the UEFI spec, the timezone setting which the platform needs to record in addition to the actual date and time already reflects the current DST setting. In other words, moving the clock from standard time to daylight saving time also involves adding or subtracting 60 minutes from the timezone setting, as well as flicking the EFI_TIME_IN_DAYLIGHT bit in the DST setting. This means we need to disregard the DST setting if the timezone is specified, and only add or subtract the additional hour if we are on local time. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c index f1eb0deb3249..459dcc0a0519 100644 --- a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c +++ b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c @@ -164,12 +164,10 @@ LibGetTime ( } // Adjust for the correct time zone + // The timezone setting also reflects the DST setting of the clock if (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) { EpochSeconds += Time->TimeZone * SEC_PER_MIN; - } - - // Adjust for the correct period - if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) { + } else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) { // Convert to adjusted time, i.e. spring forwards one hour EpochSeconds += SEC_PER_HOUR; } @@ -229,12 +227,10 @@ LibSetTime ( EpochSeconds = EfiTimeToEpoch (Time); // Adjust for the correct time zone, i.e. convert to UTC time zone + // The timezone setting also reflects the DST setting of the clock if (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) { EpochSeconds -= Time->TimeZone * SEC_PER_MIN; - } - - // Adjust for the correct period - if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) { + } else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) { // Convert to un-adjusted time, i.e. fall back one hour EpochSeconds -= SEC_PER_HOUR; }