All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sami Mujawar <Sami.Mujawar@arm.com>
To: Andre Przywara <Andre.Przywara@arm.com>,
	Julien Thierry <Julien.Thierry@arm.com>
Cc: Will Deacon <Will.Deacon@arm.com>,
	"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: RE: [PATCH kvmtool 1/6] rtc: Initialize the Register D for MC146818 RTC
Date: Fri, 14 Dec 2018 18:58:13 +0000	[thread overview]
Message-ID: <DB6PR0802MB2375C8F28CBDBF7DD7B38AF084A10@DB6PR0802MB2375.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <20181212181601.7afcba1c@donnerap.cambridge.arm.com>

Hi Andre,

We are using the edk2 PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe RTC driver. This RTC driver derives the IO port values for the Index and Target register from Pcds (Platform Configuration Database), which can be considered as constants defined at build time, so sort of hardcoded.
We have also added MMIO capability to this driver (enabled by setting the PcdRtcUseMmio to TRUE). This change effectively performs MMIO accesses on 0x70 and 0x71.

Regards,

Sami Mujawar

-----Original Message-----
From: Andre Przywara <andre.przywara@arm.com>
Sent: 12 December 2018 06:16 PM
To: Julien Thierry <Julien.Thierry@arm.com>
Cc: kvm@vger.kernel.org; kvmarm@lists.cs.columbia.edu; Will Deacon <Will.Deacon@arm.com>; Sami Mujawar <Sami.Mujawar@arm.com>; Mark Rutland <Mark.Rutland@arm.com>
Subject: Re: [PATCH kvmtool 1/6] rtc: Initialize the Register D for MC146818 RTC

On Tue,  4 Dec 2018 11:14:28 +0000
Julien Thierry <julien.thierry@arm.com> wrote:

> From: Sami Mujawar <sami.mujawar@arm.com>
>
> Some software drivers check the VRT bit (BIT7) of Register D before
> using the MC146818 RTC. Initialized the VRT bit in rtc__init() to
> indicate that the RAM and time contents are valid.
>
> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
> Signed-off-by: Julien Thierry <julien.thierry@arm.com>

Checked against the data sheet.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

This is quite interesting: we build the RTC emulation unconditionally for every architecture, but don't expose it in the DT (for arm/arm64).
The Linux driver can't even be configured for arm64.
Interestingly it works if one pokes 0x70 and 0x71 directly in memory from a guest. Which sounds hackish (do we want that?), but fits more a less the firmware use case. We would just need to make sure it actually works correctly on ARM, since nobody tested this properly before.

I guess EDK2 would just hardcode the address?

Cheers,
Andre.

> ---
>  hw/rtc.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/hw/rtc.c b/hw/rtc.c
> index 0649b5d..c1fa72f 100644
> --- a/hw/rtc.c
> +++ b/hw/rtc.c
> @@ -25,6 +25,11 @@
>  #define RTC_REG_C0x0C
>  #define RTC_REG_D0x0D
>
> +/*
> + * Register D Bits
> + */
> +#define RTC_REG_D_VRT(1 << 7)
> +
>  struct rtc_device {
>  u8cmos_idx;
>  u8cmos_data[128];
> @@ -140,6 +145,9 @@ int rtc__init(struct kvm *kvm)
>  return r;
>  }
>
> +/* Set the VRT bit in Register D to indicate valid RAM and
> time */
> +rtc.cmos_data[RTC_REG_D] = RTC_REG_D_VRT;
> +
>  return r;
>  }
>  dev_init(rtc__init);

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

  reply	other threads:[~2018-12-14 18:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04 11:14 [PATCH kvmtool 0/6] arm: Add support for firmware booting Julien Thierry
2018-12-04 11:14 ` [PATCH kvmtool 1/6] rtc: Initialize the Register D for MC146818 RTC Julien Thierry
2018-12-12 18:16   ` Andre Przywara
2018-12-14 18:58     ` Sami Mujawar [this message]
2018-12-04 11:14 ` [PATCH kvmtool 2/6] arm: Move firmware function Julien Thierry
2018-12-12 18:16   ` Andre Przywara
2018-12-04 11:14 ` [PATCH kvmtool 3/6] builtin-run: Do not look for default kernel when firmware is provided Julien Thierry
2018-12-12 18:16   ` Andre Przywara
2018-12-04 11:14 ` [PATCH kvmtool 4/6] arm: Support firmware loading Julien Thierry
2018-12-14 18:08   ` Andre Przywara
2018-12-17 10:05     ` Julien Thierry
2018-12-17 12:01       ` André Przywara
2018-12-04 11:14 ` [PATCH kvmtool 5/6] kvm: Add arch specific reset Julien Thierry
2018-12-14 18:11   ` Andre Przywara
2018-12-17 10:25     ` Julien Thierry
2018-12-04 11:14 ` [PATCH kvmtool 6/6] arm: Support non-volatile memory Julien Thierry
2018-12-14 18:09   ` Andre Przywara
2018-12-17 10:31     ` Julien Thierry
2018-12-17 12:04       ` André Przywara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DB6PR0802MB2375C8F28CBDBF7DD7B38AF084A10@DB6PR0802MB2375.eurprd08.prod.outlook.com \
    --to=sami.mujawar@arm.com \
    --cc=Andre.Przywara@arm.com \
    --cc=Julien.Thierry@arm.com \
    --cc=Will.Deacon@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.