From patchwork Mon Nov 6 18:20:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118079 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3061361qgn; Mon, 6 Nov 2017 10:20:55 -0800 (PST) X-Google-Smtp-Source: ABhQp+RQ2mkaOKjNug92c1MroOrYMRMhk5iOtdKOFxXhyvolBNxICjX1pmikyfsgQXIj4Mx2QsPz X-Received: by 10.99.119.3 with SMTP id s3mr16165460pgc.172.1509992455588; Mon, 06 Nov 2017 10:20:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509992455; cv=none; d=google.com; s=arc-20160816; b=GZx2hnukeTkCfQaqCfWlCeZzfmovjk5Jalv0kP3DLFaAJ45ess/jPDxR3xW2BNNbSe Ip9+il2ErdR9QFecY8tCuqwReP/4OHKN3fiFimAzTFcemR+nkuNo3xXHxukWldZ/XX5F C3Nh2PRToW0k7SraKtuqFNnERo98oRGD8NDAWQQx3akGjGbaVuVj0AOVtycjnJUCIowi XxBMBfen2ZTG9KGEIqmj8BpHLH9LkXrEgPRtb7UWdD7InRwdwS1X/350iBD6qyhiyefE yOlWaLRH9wb36zy2hpwZhOHtruKJf1ZbOD6HtSkf6oyD0IG5aFS7sDf23ZgfmMbo03WE QD3g== 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=cjU4zth5W/rY58rl5TBuB938CM2TruHJr/DiBktmndE=; b=uQAtsZmMseuSGx64LfoPr38wssly7ao+jvmJABE2PKkE34B0ZSkw0UJI7N+B9k1+j5 1pwcUDm2Ntdn72ih/AUq9DZvikMNPxYRlOGq9sIGsb4xKr407oOOlEFjCSBty8BmVIoV LGoOKQq/I3N3YxiwSTuO6Xg2IZex1qhjbe2ZGK6pcQtKeTMppcDA6BXXy5SP0Jg8K2ht Brp+JfHVQrC2QdVmLDrJ9yqvCvnBW++Ez2G1NoEBtfKoT0rTpn+/smCHWW1SjkvhoFn/ IV3TQe32HQnDyGXPAdX1448ScHbFoFPxBwxq/qqPoOJ1xPlOv8cM3NLG0YdPZqqoO2h1 GoFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YBLpYmPW; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id c41si10499330plj.293.2017.11.06.10.20.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 10:20:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YBLpYmPW; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 C90912035D106; Mon, 6 Nov 2017 10:16:54 -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::242; helo=mail-wr0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) (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 601F32035D0FD for ; Mon, 6 Nov 2017 10:16:53 -0800 (PST) Received: by mail-wr0-x242.google.com with SMTP id 4so5270300wrt.0 for ; Mon, 06 Nov 2017 10:20:52 -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=SeiuGvicd4VwFrfYng7sMSU/xLSAdX4v0UP5ySAu51M=; b=YBLpYmPW2yORhQlN8ImXQqWkOmwkNk8wk/iw3LVT6zF1isoo6ss6DJ5b8vKmO8VooT YZMn9qAM9smxcbDw2YEHTxFVq078JKSAyOHSEZbcur4D3/vrB1EwMlaEkRR2xkCO8fMa ueg6nzomirwfh6QZ6EwXAqjDOpWJh7/Cu3dhc= 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=SeiuGvicd4VwFrfYng7sMSU/xLSAdX4v0UP5ySAu51M=; b=RA8Hb2QRXvWloWkMzkVpC+ztIMiBFzJstlfpFZVVg1m16pTOUugvYSzzL38Xu7K1AX 3R1AOUrDwYqW7cc37Gnj9FieDj85rG5aeKFrrTHaVR5vhjHaqN99EToDUx+KOjlmFXp8 D0nQD6JJZn0gEVIeTgaFOtdssdpyi/OOV7BDEijxEMS6ClQx/HPttRXh3yjJ5fv2Iw9j 53Tt8q86UFO2mcxRX6RxNED8BP/a/Gf9V6HP/Yd9dFV1aLyf+o+/rsuxtPH3qG88qIOA WwwXnk0UCT47xcDagy737aXglhNsJzN3giPNcO/8MsOUT0zacSxF9G74HHOapG/R/Wc0 Hbjw== X-Gm-Message-State: AJaThX5N2wWqV2naJYWiSr+BRVgFNb2WMqO32OY6bqqq0qN4wTL5hMhU f9B6pFkUpC2jghsyVgyPsOwwkI4t8u4= X-Received: by 10.223.174.74 with SMTP id u10mr4740860wrd.267.1509992450478; Mon, 06 Nov 2017 10:20:50 -0800 (PST) Received: from localhost.localdomain ([105.129.222.2]) by smtp.gmail.com with ESMTPSA id w206sm4516507wmd.36.2017.11.06.10.20.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 10:20:49 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Mon, 6 Nov 2017 18:20:38 +0000 Message-Id: <20171106182038.16750-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171106182038.16750-1-ard.biesheuvel@linaro.org> References: <20171106182038.16750-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 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 --- 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 Reviewed-by: Leif Lindholm 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; }