RTC support for QEMU RISC-V virt machine
cover RTC support for QEMU RISC-V virt machine
This series adds RTC device to QEMU RISC-V virt machine. We have selected Goldfish RTC device model for this. It's a pretty simple synthetic device with few MMIO registers and no dependency external clock. The driver for Goldfish RTC is already available in Linux so we just need to enable it in Kconfig for RISCV and also update Linux defconfigs.
We have tested this series with Linux-5.3 plus defconfig changes available in 'goldfish_rtc_v1' branch of:
https://github.com/avpatel/linux.git
Anup Patel (2):
hw: timer: Add Goldfish RTC device
riscv: virt: Use Goldfish RTC device
hw/riscv/Kconfig | 1 + hw/riscv/virt.c | 15 +++ hw/timer/Kconfig | 3 + hw/timer/Makefile.objs | 1 + hw/timer/goldfish_rtc.c | 221 ++++++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 2 + include/hw/timer/goldfish_rtc.h | 45 +++++++ 7 files changed, 288 insertions(+) create mode 100644 hw/timer/goldfish_rtc.c create mode 100644 include/hw/timer/goldfish_rtc.h
--
2.17.1
PATCH 1/2 hw: timer: Add Goldfish RTC device
This patch adds model for Google Goldfish virtual platform RTC device.
We will be adding Goldfish RTC device to the QEMU RISC-V virt machine for providing real date-time to Guest Linux. The corresponding Linux driver for Goldfish RTC device is already available in upstream Linux.
For now, VM migration support is not available for Goldfish RTC device but it will be added later when we implement VM migration for KVM RISC-V.
--- hw/timer/Kconfig | 3 + hw/timer/Makefile.objs | 1 + hw/timer/goldfish_rtc.c | 221 ++++++++++++++++++++++++++++++++ include/hw/timer/goldfish_rtc.h | 45 +++++++ 4 files changed, 270 insertions(+) create mode 100644 hw/timer/goldfish_rtc.c create mode 100644 include/hw/timer/goldfish_rtc.h
hw/timer/Kconfig +3 -0
@@ -58,3 +58,6 @@ config CMSDK_APB_TIMER config CMSDK_APB_DUALTIMER bool select PTIMER + +config GOLDFISH_RTC + bool
hw/timer/Makefile.objs +1 -0
@@ -47,3 +47,4 @@ common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o common-obj-$(CONFIG_CMSDK_APB_DUALTIMER) += cmsdk-apb-dualtimer.o common-obj-$(CONFIG_MSF2) += mss-timer.o +common-obj-$(CONFIG_GOLDFISH_RTC) += goldfish_rtc.o
hw/timer/goldfish_rtc.c new file +221 -0
221 lines not on this page · raw message
include/hw/timer/goldfish_rtc.h new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH 1/2] hw: timer: Add Goldfish RTC device
Quoted 12 lines · Anup Patel
This patch adds model for Google Goldfish virtual platform RTC device.
We will be adding Goldfish RTC device to the QEMU RISC-V virt machine for providing real date-time to Guest Linux. The corresponding Linux driver for Goldfish RTC device is already available in upstream Linux.
For now, VM migration support is not available for Goldfish RTC device but it will be added later when we implement VM migration for KVM RISC-V.
Signed-off-by Anup Patel <[email protected]>---
hw/timer/goldfish_rtc.c line 200
Quoted 9 lines
hw/timer/goldfish_rtc.c new file +9
-0+ +static Property goldfish_rtc_properties[] = { +DEFINE_PROP_UINT64 ("tick-offset" , GoldfishRTCState, tick_offset,0 ), +DEFINE_PROP_UINT64 ("alarm-next" , GoldfishRTCState, alarm_next,0 ), +DEFINE_PROP_UINT32 ("alarm-running" , GoldfishRTCState, alarm_running,0 ), +DEFINE_PROP_UINT32 ("irq-pending" , GoldfishRTCState, irq_pending,0 ), +DEFINE_PROP_UINT32 ("irq-enabled" , GoldfishRTCState, irq_enabled,0 ), +DEFINE_PROP_END_OF_LIST (), +};
What are all these properties trying to do ?
hw/timer/goldfish_rtc.c line 205
Quoted 5 lines
hw/timer/goldfish_rtc.c new file +5
-0+ +static void goldfish_rtc_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + dc->props = goldfish_rtc_properties;
Missing reset function.
If you don't want to implement migration support now you should at least put in something that block migration. (Personally I prefer to just write the vmstate, it's as easy as writing the code to block migrations.)
thanks
-- PMM
RE: [PATCH 1/2] hw: timer: Add Goldfish RTC device
Quoted 33 lines
-----Original Message-----
From: Peter Maydell <[email protected]>
Sent: Tuesday, September 24, 2019 3:21 PM
To: Anup Patel <[email protected]>
Cc: Palmer Dabbelt <[email protected]>; Alistair Francis <[email protected]>; Sagar Karandikar <[email protected]>; Bastian Koppelmann <[email protected]>; Atish Patra <[email protected]>; [email protected]; qemu- [email protected]; Anup Patel <[email protected]>
Subject: Re: [PATCH 1/2] hw: timer: Add Goldfish RTC deviceQuoted 9 lines · Anup Patel
This patch adds model for Google Goldfish virtual platform RTC device.
We will be adding Goldfish RTC device to the QEMU RISC-V virt machine for providing real date-time to Guest Linux. The corresponding Linux driver for Goldfish RTC device is already available in upstream Linux.
For now, VM migration support is not available for Goldfish RTC device but it will be added later when we implement VM migration for KVM RISC-
V.
hw/timer/goldfish_rtc.c
Quoted 8 lines
Signed-off-by Anup Patel <[email protected]>---
hw/timer/goldfish_rtc.c new file +5
-0+ +static Property goldfish_rtc_properties[] = { +DEFINE_PROP_UINT64 ("tick-offset" , GoldfishRTCState, tick_offset,0 ), +DEFINE_PROP_UINT64 ("alarm-next" , GoldfishRTCState, alarm_next,0 ), + DEFINE_PROP_UINT32("alarm-running", GoldfishRTCState,
alarm_running, 0),
Quoted 8 lines
Quoted 1 line
+ DEFINE_PROP_UINT32("irq-pending", GoldfishRTCState,
irq_pending,0),
Quoted 1 line
+ DEFINE_PROP_UINT32("irq-enabled", GoldfishRTCState,
irq_enabled,0),
Review
Quoted 2 lines
(quoted diff) +2
-0+ DEFINE_PROP_END_OF_LIST(), +};What are all these properties trying to do ?
Argh, I forgot to remove these before sending.
I will drop these in next revision.
Quoted 7 lines
hw/timer/goldfish_rtc.c line 205
Quoted 5 lines
hw/timer/goldfish_rtc.c new file +4
-0+ +static void goldfish_rtc_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass); + dc->props = goldfish_rtc_properties;Missing reset function.
Sure, I will add it. I got confused because I saw reset function in HPET but not in PL031.
Quoted 5 lines
If you don't want to implement migration support now you should at least put in something that block migration.
(Personally I prefer to just write the vmstate, it's as easy as writing the code to block migrations.)
Okay, I will add vmstate.
Is there a way to unit test the vmstate part ?
OR
Are you fine if we test-n-fix it later ?
Quoted 3 lines
thanks
-- PMM
Regards,
Anup
Re: [PATCH 1/2] hw: timer: Add Goldfish RTC device
Quoted 56 lines · Anup Patel
Quoted 35 lines
-----Original Message-----
From: Peter Maydell <[email protected]>
Sent: Tuesday, September 24, 2019 3:21 PM
To: Anup Patel <[email protected]>
Cc: Palmer Dabbelt <[email protected]>; Alistair Francis <[email protected]>; Sagar Karandikar <[email protected]>; Bastian Koppelmann <[email protected]>; Atish Patra <[email protected]>; [email protected]; qemu- [email protected]; Anup Patel <[email protected]>
Subject: Re: [PATCH 1/2] hw: timer: Add Goldfish RTC deviceQuoted 9 lines · Anup Patel
This patch adds model for Google Goldfish virtual platform RTC device.
We will be adding Goldfish RTC device to the QEMU RISC-V virt machine for providing real date-time to Guest Linux. The corresponding Linux driver for Goldfish RTC device is already available in upstream Linux.
For now, VM migration support is not available for Goldfish RTC device but it will be added later when we implement VM migration for KVM RISC-
V.
hw/timer/goldfish_rtc.c
Quoted 9 lines
Signed-off-by Anup Patel <[email protected]>---
hw/timer/goldfish_rtc.c new file +5
-0+ +static Property goldfish_rtc_properties[] = { +DEFINE_PROP_UINT64 ("tick-offset" , GoldfishRTCState, tick_offset,0 ), +DEFINE_PROP_UINT64 ("alarm-next" , GoldfishRTCState, alarm_next,0 ), + DEFINE_PROP_UINT32("alarm-running", GoldfishRTCState,
alarm_running, 0),Quoted 8 lines
Quoted 1 line
+ DEFINE_PROP_UINT32("irq-pending", GoldfishRTCState,
irq_pending,0),
Quoted 1 line
+ DEFINE_PROP_UINT32("irq-enabled", GoldfishRTCState,
irq_enabled,0),
Review
Quoted 2 lines
(quoted diff) +2
-0+ DEFINE_PROP_END_OF_LIST(), +};What are all these properties trying to do ?
Argh, I forgot to remove these before sending.
I will drop these in next revision.
Quoted 7 lines
hw/timer/goldfish_rtc.c line 205
Quoted 5 lines
hw/timer/goldfish_rtc.c new file +4
-0+ +static void goldfish_rtc_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass); + dc->props = goldfish_rtc_properties;Missing reset function.
Quoted 2 lines
Sure, I will add it. I got confused because I saw reset function in HPET but not in PL031.
Yeah, the lack of reset is a bug in the pl031. I did have a draft set of patches where I tried to fix that, but I got stuck because it was a bit unclear what I ought to be resetting. In a real hardware pl031 there is no persistent storage of the RTC value -- it's just a 1Hz counter, really, and guest firmware will write to it on startup (from some other real RTC). In QEMU we use it as a sort of "RTC for a VM", and back it with the QEMU RTC clock, so it doesn't behave quite as the hardware does but more like "view that you'd see from a combination of h/w and firmware behaviour".
TLDR: don't use the pl031 code as a good model of how to do an RTC, it has some definite flaws. x86 or ppc RTC handling is probably a better place to look.
Another random question -- is there an existing RTC device we could put in the riscv board rather than adding a new model of this goldfish device? Put another way, what are the merits of using goldfish in particular?
We should probably document this device in docs/specs since it's a pure-virtual device. (You have a link to the URL for the GOLDFISH-VIRTUAL-HARDWARE.TXT for the android emulator, but that doesn't seem to match the implementation here -- the doc says the alarm registers are non-functional but this code does something with them.)
Quoted 10 lines
Quoted 4 lines
If you don't want to implement migration support now you should at least put in something that block migration.
(Personally I prefer to just write the vmstate, it's as easy as writing the code to block migrations.)Okay, I will add vmstate.
Is there a way to unit test the vmstate part ?
OR
Are you fine if we test-n-fix it later ?
Test and fix later is fine. That said, I've just remembered that for an RTC migration is potentially a tricky area because you typically don't want a vmsave-vmload to give you the same RTC value after load that there was on store, you want it to still be following the host RTC. We got that wrong on the PL031 and had to put in some ugly workarounds to maintain migration compatibility when we fixed it. So maybe it would be better to mark as non-migratable for now.
thanks
-- PMM
RE: [PATCH 1/2] hw: timer: Add Goldfish RTC device
Quoted 90 lines
-----Original Message-----
From: Peter Maydell <[email protected]>
Sent: Tuesday, September 24, 2019 5:02 PM
To: Anup Patel <[email protected]>
Cc: Palmer Dabbelt <[email protected]>; Alistair Francis <[email protected]>; Sagar Karandikar <[email protected]>; Bastian Koppelmann <[email protected]>; Atish Patra <[email protected]>; [email protected]; qemu- [email protected]; Anup Patel <[email protected]>
Subject: Re: [PATCH 1/2] hw: timer: Add Goldfish RTC deviceQuoted 11 lines · Anup Patel
Quoted 11 lines
-----Original Message-----
From: Peter Maydell <[email protected]>
Sent: Tuesday, September 24, 2019 3:21 PM
To: Anup Patel <[email protected]>
Cc: Palmer Dabbelt <[email protected]>; Alistair Francis <[email protected]>; Sagar Karandikar <[email protected]>; Bastian Koppelmann <[email protected]>; Atish PatraQuoted 11 lines
Quoted 11 lines
[email protected]; qemu- [email protected]; Anup Patel <[email protected]>
Subject: Re: [PATCH 1/2] hw: timer: Add Goldfish RTC deviceQuoted 6 lines · Anup Patel
This patch adds model for Google Goldfish virtual platform RTC device.
We will be adding Goldfish RTC device to the QEMU RISC-V virt machine for providing real date-time to Guest Linux. The corresponding Linux driver for Goldfish RTC device is already available in
upstream Linux.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
For now, VM migration support is not available for Goldfish RTC device but it will be added later when we implement VM migration for KVM RISC-
Quoted 8 lines
Quoted 8 lines
V.
hw/timer/goldfish_rtc.c
Quoted 7 lines
Signed-off-by Anup Patel <[email protected]>---
hw/timer/goldfish_rtc.c new file +3
-0+ +static Property goldfish_rtc_properties[] = { + DEFINE_PROP_UINT64("tick-offset", GoldfishRTCState, tick_offset,0),
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ DEFINE_PROP_UINT64("alarm-next", GoldfishRTCState,
alarm_next,0),
Quoted 25 lines
Quoted 4 lines
Quoted 1 line
+ DEFINE_PROP_UINT32("alarm-running", GoldfishRTCState,
alarm_running, 0),Quoted 2 lines
+ DEFINE_PROP_UINT32("irq-pending", GoldfishRTCState,
+irq_pending,Quoted 8 lines
0),
Quoted 2 lines
+ DEFINE_PROP_UINT32("irq-enabled", GoldfishRTCState,
+irq_enabled,0),
Review
Quoted 2 lines
(quoted diff) +2
-0+ DEFINE_PROP_END_OF_LIST(), +};What are all these properties trying to do ?
Argh, I forgot to remove these before sending.
I will drop these in next revision.
Quoted 7 lines
hw/timer/goldfish_rtc.c line 205
Quoted 5 lines
hw/timer/goldfish_rtc.c new file +4
-0+ +static void goldfish_rtc_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass); + dc->props = goldfish_rtc_properties;Missing reset function.
Quoted 2 lines
Sure, I will add it. I got confused because I saw reset function in HPET but not in PL031.
Yeah, the lack of reset is a bug in the pl031. I did have a draft set of patches where I tried to fix that, but I got stuck because it was a bit unclear what I ought to be resetting. In a real hardware pl031 there is no persistent storage of the RTC value -- it's just a 1Hz counter, really, and guest firmware will write to it on startup (from some other real RTC). In QEMU we use it as a sort of "RTC for a VM", and back it with the QEMU RTC clock, so it doesn't behave quite as the hardware does but more like "view that you'd see from a combination of h/w and firmware behaviour".
Quoted 7 lines
TLDR: don't use the pl031 code as a good model of how to do an RTC, it has some definite flaws. x86 or ppc RTC handling is probably a better place to look.
Another random question -- is there an existing RTC device we could put in the riscv board rather than adding a new model of this goldfish device? Put another way, what are the merits of using goldfish in particular?
As of now, there is no RTC device used across SOCs. Atleast nothing that I am aware of.
I just wanted a very simple RTC for RISC-V virt machine and found goldfish RTC to be really useful. Although other Goldfish devices are not very attractive and we generally have an equivalent VirtIO device.
Ideally, we should have a VirtIO RTC thingy but not sure if RTC fits in VirtIO ring programming model.
Quoted 7 lines
We should probably document this device in docs/specs since it's a pure- virtual device. (You have a link to the URL for the GOLDFISH-VIRTUAL- HARDWARE.TXT for the android emulator, but that doesn't seem to match the implementation here -- the doc says the alarm registers are non- functional but this code does something with
them.)
The implementation matches corresponding driver available in upstream Linux. We should certainly have a more complete document under docs/sepcs (like you suggested) for this device.
Quoted 12 lines
Quoted 11 lines
Quoted 5 lines
If you don't want to implement migration support now you should at least put in something that block migration. (Personally I prefer to just write the vmstate, it's as easy as writing the code to block migrations.)
Okay, I will add vmstate.
Is there a way to unit test the vmstate part ?
OR
Are you fine if we test-n-fix it later ?
Quoted 7 lines
Test and fix later is fine. That said, I've just remembered that for an RTC migration is potentially a tricky area because you typically don't want a vmsave-vmload to give you the same RTC value after load that there was on store, you want it to still be following the host RTC.
We got that wrong on the PL031 and had to put in some ugly workarounds to maintain migration compatibility when we fixed it.
So maybe it would be better to mark as non-migratable for now.
Yes, I saw the workaround in PL031 and the backward compatibility bits.
This is first version of Goldfish RTC vmstate so we don't need the PL031 backward compatibility bits.
I will try implement this in v2 and you can have a look.
Regards,
Anup
PATCH 2/2 riscv: virt: Use Goldfish RTC device
In reply to Anup PatelWe extend QEMU RISC-V virt machine by adding Goldfish RTC device to it. This will allow Guest Linux to sync it's local date/time with Host date/time via RTC device.
--- hw/riscv/Kconfig | 1 + hw/riscv/virt.c | 15 +++++++++++++++ include/hw/riscv/virt.h | 2 ++ 3 files changed, 18 insertions(+)
hw/riscv/Kconfig +1 -0
@@ -34,6 +34,7 @@ config RISCV_VIRT select PCI select HART select SERIAL + select GOLDFISH_RTC select VIRTIO_MMIO select PCI_EXPRESS_GENERIC_BRIDGE select SIFIVE
hw/riscv/virt.c +15 -0
@@ -57,6 +57,7 @@ static const struct MemmapEntry { [VIRT_DEBUG] = { 0x0, 0x100 }, [VIRT_MROM] = { 0x1000, 0x11000 }, [VIRT_TEST] = { 0x100000, 0x1000 }, + [VIRT_RTC] = { 0x101000, 0x1000 }, [VIRT_CLINT] = { 0x2000000, 0x10000 }, [VIRT_PLIC] = { 0xc000000, 0x4000000 }, [VIRT_UART0] = { 0x10000000, 0x100 },
@@ -310,6 +311,17 @@ static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,qemu_fdt_setprop_cell (fdt, nodename,"interrupt-parent" , plic_phandle);qemu_fdt_setprop_cell (fdt, nodename,"interrupts" ,UART0_IRQ ); + nodename =g_strdup_printf ("/rtc@%lx" , + (long )memmap[VIRT_RTC ].base); +qemu_fdt_add_subnode (fdt, nodename); +qemu_fdt_setprop_string (fdt, nodename,"compatible" , +"google,goldfish-rtc" ); +qemu_fdt_setprop_cells (fdt, nodename,"reg" , +0x0 , memmap[VIRT_RTC ].base, +0x0 , memmap[VIRT_RTC ].size); +qemu_fdt_setprop_cell (fdt, nodename,"interrupt-parent" , plic_phandle); +qemu_fdt_setprop_cell (fdt, nodename,"interrupts" ,RTC_IRQ ); +qemu_fdt_add_subnode (fdt,"/chosen" );qemu_fdt_setprop_string (fdt,"/chosen" ,"stdout-path" , nodename);if (cmdline) {
@@ -496,6 +508,9 @@ static void riscv_virt_board_init(MachineState *machine)0 ,qdev_get_gpio_in (DEVICE (s->plic),UART0_IRQ ),399193 , serial_hd(0), DEVICE_LITTLE_ENDIAN); +sysbus_create_simple ("goldfish_rtc" , memmap[VIRT_RTC ].base, +qdev_get_gpio_in (DEVICE (s->plic),RTC_IRQ )); +g_free (plic_hart_config); }
include/hw/riscv/virt.h +2 -0
@@ -37,6 +37,7 @@ enum {VIRT_DEBUG ,VIRT_MROM ,VIRT_TEST , +VIRT_RTC ,VIRT_CLINT ,VIRT_PLIC , VIRT_UART0,
@@ -49,6 +50,7 @@ enum {enum {UART0_IRQ =10 , +RTC_IRQ =11 ,VIRTIO_IRQ =1 ,/* 1 to 8 */ VIRTIO_COUNT =8 ,PCIE_IRQ =0x20 ,/* 32 to 35 */
Signature · 1 line
2.17.1
Quoted 10 lines · Anup Patel
This series adds RTC device to QEMU RISC-V virt machine. We have selected Goldfish RTC device model for this. It's a pretty simple synthetic device with few MMIO registers and no dependency external clock. The driver for Goldfish RTC is already available in Linux so we just need to enable it in
Kconfigfor RISCV and also update Linux defconfigs.We have tested this series with Linux-5.3 plus defconfig changes available in '
goldfish_rtc_v1' branch of:
https://github.com/avpatel/linux.git
Why was this device chosen instead of kvm-clock?
Rich.
Quoted 17 lines
Anup Patel (2):
hw: timer: Add Goldfish RTC device
riscv: virt: Use Goldfish RTC devicehw/riscv/Kconfig | 1 + hw/riscv/virt.c | 15 +++ hw/timer/Kconfig | 3 + hw/timer/Makefile.objs | 1 + hw/timer/goldfish_rtc.c | 221 ++++++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 2 + include/hw/timer/goldfish_rtc.h | 45 +++++++ 7 files changed, 288 insertions(+) create mode 100644 hw/timer/goldfish_rtc.c create mode 100644 include/hw/timer/goldfish_rtc.h--
2.17.1
Signature · 5 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Quoted 22 lines
-----Original Message-----
From: Richard W.M. Jones <[email protected]>
Sent: Friday, September 27, 2019 5:21 PM
To: Anup Patel <[email protected]>
Cc: Palmer Dabbelt <[email protected]>; Alistair Francis <[email protected]>; Sagar Karandikar <[email protected]>; Bastian Koppelmann <[email protected]>; Atish Patra <[email protected]>; [email protected]; qemu- [email protected]; Anup Patel <[email protected]>
Subject: Re: [PATCH 0/2] RTC support for QEMU RISC-V virt machineQuoted 7 lines · Anup Patel
This series adds RTC device to QEMU RISC-V virt machine. We have selected Goldfish RTC device model for this. It's a pretty simple synthetic device with few MMIO registers and no dependency external clock. The driver for Goldfish RTC is already available in Linux so we just need to enable it in
Kconfigfor RISCV and also update Linux defconfigs.
Quoted 5 lines
Quoted 3 lines
We have tested this series with Linux-5.3 plus defconfig changes available in '
goldfish_rtc_v1' branch of:
https://github.com/avpatel/linux.gitWhy was this device chosen instead of kvm-clock?
We need a RTC device which worked fine in TCG mode (even without KVM). The KVMCLOCK is PTP clock which depends on KVM hypercalls.
On ARM virt machine, we have PL031 so instead of that we have Goldfish RTC on RISC-V virt machine.
Regards,
Anup
Quoted 29 lines
Rich.
Quoted 9 lines
Anup Patel (2):
hw: timer: Add Goldfish RTC device
riscv: virt: Use Goldfish RTC devicehw/riscv/Kconfig | 1 + hw/riscv/virt.c | 15 +++ hw/timer/Kconfig | 3 + hw/timer/Makefile.objs | 1 + hw/timer/goldfish_rtc.c | 221++++++++++++++++++++++++++++++++
Quoted 8 lines
include/hw/riscv/virt.h | 2 + include/hw/timer/goldfish_rtc.h | 45 +++++++ 7 files changed, 288 insertions(+) create mode 100644 hw/timer/goldfish_rtc.c create mode 100644
include/hw/timer/goldfish_rtc.h--
2.17.1--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones Read my programming and virtualization
blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
Quoted 26 lines · Anup Patel
Quoted 26 lines
-----Original Message-----
From: Richard W.M. Jones <[email protected]>
Sent: Friday, September 27, 2019 5:21 PM
To: Anup Patel <[email protected]>
Cc: Palmer Dabbelt <[email protected]>; Alistair Francis <[email protected]>; Sagar Karandikar <[email protected]>; Bastian Koppelmann <[email protected]>; Atish Patra <[email protected]>; [email protected]; qemu- [email protected]; Anup Patel <[email protected]>
Subject: Re: [PATCH 0/2] RTC support for QEMU RISC-V virt machineQuoted 10 lines · Anup Patel
This series adds RTC device to QEMU RISC-V virt machine. We have selected Goldfish RTC device model for this. It's a pretty simple synthetic device with few MMIO registers and no dependency external clock. The driver for Goldfish RTC is already available in Linux so we just need to enable it in
Kconfigfor RISCV and also update Linux defconfigs.We have tested this series with Linux-5.3 plus defconfig changes available in '
goldfish_rtc_v1' branch of:
https://github.com/avpatel/linux.git
Quoted 7 lines
Quoted 1 line
Why was this device chosen instead of kvm-clock?
We need a RTC device which worked fine in TCG mode (even without KVM). The KVMCLOCK is PTP clock which depends on KVM hypercalls.
On ARM virt machine, we have PL031 so instead of that we have Goldfish RTC on RISC-V virt machine.
Could we not make kvm-clock work on TCG (I wasn't aware that it needed actual KVM - I wonder how timekeeping works on TCG?)
Alternately why not use PL031 here?
The reason I'm asking this is because adding a new virtual device means we have to change this all the way up the stack (libvirt, virt-*) _and_ have special cases everywhere just for RISC-V. That's a load of extra work for everyone.
Rich.
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Quoted 48 lines
-----Original Message-----
From: Richard W.M. Jones <[email protected]>
Sent: Friday, September 27, 2019 6:01 PM
To: Anup Patel <[email protected]>
Cc: Palmer Dabbelt <[email protected]>; Alistair Francis <[email protected]>; Sagar Karandikar <[email protected]>; Bastian Koppelmann <[email protected]>; Atish Patra <[email protected]>; [email protected]; qemu- [email protected]; Anup Patel <[email protected]>
Subject: Re: [PATCH 0/2] RTC support for QEMU RISC-V virt machineQuoted 10 lines · Anup Patel
Quoted 10 lines
-----Original Message-----
From: Richard W.M. Jones <[email protected]>
Sent: Friday, September 27, 2019 5:21 PM
To: Anup Patel <[email protected]>
Cc: Palmer Dabbelt <[email protected]>; Alistair Francis <[email protected]>; Sagar Karandikar <[email protected]>; Bastian Koppelmann <[email protected]>; Atish PatraQuoted 13 lines
Quoted 13 lines
[email protected]; qemu- [email protected]; Anup Patel <[email protected]>
Subject: Re: [PATCH 0/2] RTC support for QEMU RISC-V virt machineQuoted 7 lines · Anup Patel
This series adds RTC device to QEMU RISC-V virt machine. We have selected Goldfish RTC device model for this. It's a pretty simple synthetic device with few MMIO registers and no dependency external clock. The driver for Goldfish RTC is already available in Linux so we just need to enable it in
Kconfigfor RISCV and also update Linux defconfigs.Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
We have tested this series with Linux-5.3 plus defconfig changes available in '
goldfish_rtc_v1' branch of:
https://github.com/avpatel/linux.gitWhy was this device chosen instead of kvm-clock?
We need a RTC device which worked fine in TCG mode (even without
KVM).
Quoted 2 lines
The KVMCLOCK is PTP clock which depends on KVM hypercalls.
Quoted 7 lines
Quoted 2 lines
On ARM virt machine, we have PL031 so instead of that we have Goldfish RTC on RISC-V virt machine.
Could we not make kvm-clock work on TCG (I wasn't aware that it needed actual KVM - I wonder how timekeeping works on TCG?)
Alternately why not use PL031 here?
PL031 requires input clock.
Of course, we can provide fake input clock (i.e. some random fixed clock) to make it work but it will be a HACK.
Also, it will be really strange to hook an ARM device into RISC-V virt machine. On other hand, Goldfish para-virt devices are used across architectures x86, ARM and MIPS.
Quoted 5 lines
The reason I'm asking this is because adding a new virtual device means we have to change this all the way up the stack (libvirt,
virt-*) _and_ have special cases everywhere just for RISC-V. That's a load of extra work for everyone.
The RTC devices are pretty much transparent in usage. I am not sure why libvirt will require to know about type of RTC device.
Regards,
Anup