KVM: ARM: Enable vtimers with user space gic
Subsystems (5)
v3 cover KVM: ARM: Enable vtimers with user space gic
Some systems out there (well, one type in particular - the Raspberry Pi series) do have virtualization capabilities in the core, but no ARM GIC interrupt controller.
To run on these systems, the cleanest route is to just handle all interrupt delivery in user space and only deal with IRQ pins in the core side in KVM.
This works pretty well already, but breaks when the guest starts to use architected timers, as these are handled straight inside kernel space today.
This patch set allows user space to receive vtimer events as well as mask them, so that we can handle all vtimer related interrupt injection from user space, enabling us to use architected timer with user space gic emulation.
I have successfully run edk2 as well as Linux using these patches on a Raspberry Pi 3 system with acceptable speed.
A branch with WIP QEMU code can be found here:
https://github.com/agraf/qemu.git no-kvm-irqchip
To use the user space irqchip, just run it with
$ qemu-system-aarch64 -M virt,kernel-irqchip=off
v1 -> v2:
- Add back curly brace that got lost
v2 -> v3:
- Fix "only only" in documentation
- Split patches
- Remove kvm_emulate.h include
Alexander Graf (2):
KVM: arm/arm64: Add vcpu ENABLE_CAP functionality
KVM: arm/arm64: Route vtimer events to user space
Documentation/virtual/kvm/api.txt | 28 ++++++++- arch/arm/include/asm/kvm_host.h | 3 + arch/arm/kvm/arm.c | 47 +++++++++++--- arch/arm64/include/asm/kvm_host.h | 3 + include/uapi/linux/kvm.h | 14 +++++ virt/kvm/arm/arch_timer.c | 125 +++++++++++++++++++++++++++----------- 6 files changed, 177 insertions(+), 43 deletions(-)
Signature · 1 line
2.6.6
PATCH v3 1/2 KVM: arm/arm64: Add vcpu ENABLE_CAP functionality
In a follow-up patch we will need to enable capabilities on demand for backwards compatibility. This patch adds the generic framework to handle vcpu cap enablement to the arm code base.
--- Documentation/virtual/kvm/api.txt | 4 +++- arch/arm/kvm/arm.c | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-)
Documentation/virtual/kvm/api.txt +3 -1
@@ -997,7 +997,9 @@ documentation when it pops into existence). Capability: KVM_CAP_ENABLE_CAP, KVM_CAP_ENABLE_CAP_VM Architectures: x86 (only KVM_CAP_ENABLE_CAP_VM), - mips (only KVM_CAP_ENABLE_CAP), ppc, s390 + mips (only KVM_CAP_ENABLE_CAP), ppc, s390, + arm (only KVM_CAP_ENABLE_CAP), + arm64 (only KVM_CAP_ENABLE_CAP) Type: vcpu ioctl, vm ioctl (with KVM_CAP_ENABLE_CAP_VM) Parameters: struct kvm_enable_cap (in) Returns: 0 on success; -1 on error
arch/arm/kvm/arm.c +25 -0
@@ -878,6 +878,23 @@ static int kvm_arm_vcpu_has_attr(struct kvm_vcpu *vcpu,return ret; } +static int kvm_vcpu_ioctl_enable_cap (struct kvm_vcpu *vcpu, +struct kvm_enable_cap *cap) +{ +int r; + +if (cap->flags) +return -EINVAL ; + +switch (cap->cap) { +default : + r = -EINVAL ; +break ; + } + +return r; +} +long kvm_arch_vcpu_ioctl (struct file *filp,unsigned int ioctl,unsigned long arg) {
@@ -941,6 +958,14 @@ long kvm_arch_vcpu_ioctl(struct file *filp,return -EFAULT ;return kvm_arm_vcpu_has_attr (vcpu, &attr); } +case KVM_ENABLE_CAP : + { +struct kvm_enable_cap cap; + +if (copy_from_user (&cap, argp,sizeof (cap))) +return -EFAULT ; +return kvm_vcpu_ioctl_enable_cap (vcpu, &cap); + }default :return -EINVAL ; }
Signature · 1 line
2.6.6
PATCH v3 2/2 KVM: arm/arm64: Route vtimer events to user space
In reply to Alexander GrafWe have 2 modes for dealing with interrupts in the ARM world. We can either handle them all using hardware acceleration through the vgic or we can emulate a gic in user space and only drive CPU IRQ pins from there.
Unfortunately, when driving IRQs from user space, we never tell user space about timer events that may result in interrupt line state changes, so we lose out on timer events if we run with user space gic emulation.
This patch fixes that by routing vtimer expiration events to user space. With this patch I can successfully run edk2 and Linux with user space gic emulation.
---
v1 -> v2:
- Add back curly brace that got lost
v2 -> v3:
- Split into patch set
--- Documentation/virtual/kvm/api.txt | 24 +++++++- arch/arm/include/asm/kvm_host.h | 3 + arch/arm/kvm/arm.c | 22 ++++--- arch/arm64/include/asm/kvm_host.h | 3 + include/uapi/linux/kvm.h | 14 +++++ virt/kvm/arm/arch_timer.c | 125 +++++++++++++++++++++++++++----------- 6 files changed, 149 insertions(+), 42 deletions(-)
Documentation/virtual/kvm/api.txt +23 -1
@@ -3202,8 +3202,10 @@ struct kvm_run { /* in */ __u8 request_interrupt_window; -Request that KVM_RUN return when it becomes possible to inject external +[x86] Request that KVM_RUN return when it becomes possible to inject external interrupts into the guest. Useful in conjunction with KVM_INTERRUPT. +[arm*] Bits set to 1 in here mask IRQ lines that would otherwise potentially +trigger forever. Useful with KVM_CAP_ARM_TIMER. __u8 padding1[7];
@@ -3519,6 +3521,16 @@ Hyper-V SynIC state change. Notification is used to remap SynIC event/message pages and to enable/disable SynIC messages/events processing in userspace. + /* KVM_EXIT_ARM_TIMER */ + struct { + __u8 timesource; + } arm_timer; + +Indicates that a timer triggered that user space needs to handle and +potentially mask with vcpu->run->request_interrupt_window to allow the +guest to proceed. This only happens for timers that got enabled through +KVM_CAP_ARM_TIMER. + /* Fix the size of the union. */ char padding[256]; };
@@ -3739,6 +3751,16 @@ Once this is done the KVM_REG_MIPS_VEC_* and KVM_REG_MIPS_MSA_* registers can be accessed, and the Config5.MSAEn bit is accessible via the KVM API and also from the guest. +6.11 KVM_CAP_ARM_TIMER + +Architectures: arm, arm64 +Target: vcpu +Parameters: args[0] contains a bitmap of timers to enable + +This capability allows to route per-core timers into user space. When it's +enabled, the enabled timers trigger KVM_EXIT_ARM_TIMER guest exits when they +are pending, unless masked by vcpu->run->request_interrupt_window. + 7. Capabilities that can be enabled on VMs ------------------------------------------
arch/arm/include/asm/kvm_host.h +3 -0
@@ -180,6 +180,9 @@ struct kvm_vcpu_arch {/* Detect first run of a vcpu */ bool has_run_once; + +/* User space wants timer notifications */ +bool user_space_arm_timers; };struct kvm_vm_stat {
arch/arm/kvm/arm.c +15 -7
@@ -187,6 +187,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)case KVM_CAP_ARM_PSCI_0_2 :case KVM_CAP_READONLY_MEM :case KVM_CAP_MP_STATE : +case KVM_CAP_ARM_TIMER : r =1 ;break ;case KVM_CAP_COALESCED_MMIO :
@@ -474,13 +475,7 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu)return ret; } -/* -* Enable the arch timers only if we have an in-kernel VGIC -* and it has been properly initialized, since we cannot handle -* interrupts from the virtual timer with a userspace gic. -*/ -if (irqchip_in_kernel (kvm) &&vgic_initialized (kvm)) - ret =kvm_timer_enable (vcpu); + ret =kvm_timer_enable (vcpu);return ret; }
@@ -601,6 +596,13 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) run->exit_reason =KVM_EXIT_INTR ; } +if (kvm_check_request (KVM_REQ_PENDING_TIMER , vcpu)) { +/* Tell user space about the pending vtimer */ + ret =0 ; + run->exit_reason =KVM_EXIT_ARM_TIMER ; + run->arm_timer.timesource =KVM_ARM_TIMER_VTIMER ; + } +if (ret <=0 ||need_new_vmid_gen (vcpu->kvm) || vcpu->arch.power_off || vcpu->arch.pause) {local_irq_enable ();
@@ -887,6 +889,12 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,return -EINVAL ;switch (cap->cap) { +case KVM_CAP_ARM_TIMER : + r =0 ; +if (cap->args[0 ] !=KVM_ARM_TIMER_VTIMER ) +return -EINVAL ; + vcpu->arch.user_space_arm_timers = true; +break ;default : r = -EINVAL ;break ;
arch/arm64/include/asm/kvm_host.h +3 -0
@@ -270,6 +270,9 @@ struct kvm_vcpu_arch {/* Detect first run of a vcpu */ bool has_run_once; + +/* User space wants timer notifications */ +bool user_space_arm_timers; };#define vcpu_gp_regs (v) (&(v)->arch.ctxt.gp_regs)
include/uapi/linux/kvm.h +14 -0
@@ -205,6 +205,7 @@ struct kvm_hyperv_exit {#define KVM_EXIT_S390_STSI 25#define KVM_EXIT_IOAPIC_EOI 26#define KVM_EXIT_HYPERV 27 +#define KVM_EXIT_ARM_TIMER 28/* For KVM_EXIT_INTERNAL_ERROR */ /* Emulate instruction failed. */
@@ -361,6 +362,10 @@ struct kvm_run { } eoi;/* KVM_EXIT_HYPERV */ struct kvm_hyperv_exit hyperv; +/* KVM_EXIT_ARM_TIMER */ +struct { +__u8 timesource; + } arm_timer;/* Fix the size of the union. */ char padding[256 ]; };
@@ -870,6 +875,7 @@ struct kvm_ppc_smmu_info {#define KVM_CAP_S390_USER_INSTR0 130#define KVM_CAP_MSI_DEVID 131#define KVM_CAP_PPC_HTM 132 +#define KVM_CAP_ARM_TIMER 133#ifdef KVM_CAP_IRQ_ROUTING
@@ -1327,4 +1333,12 @@ struct kvm_assigned_msix_entry {#define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)#define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) +/* Available with KVM_CAP_ARM_TIMER */ + +/* Bits for run->request_interrupt_window */ +#define KVM_IRQWINDOW_VTIMER (1 << 0) + +/* Bits for run->arm_timer.timesource */ +#define KVM_ARM_TIMER_VTIMER (1 << 0) +#endif /* __LINUX_KVM_H */
virt/kvm/arm/arch_timer.c +91 -34
161 lines not on this page · raw message
Signature · 1 line
2.6.6
Re: [PATCH v3 2/2] KVM: arm/arm64: Route vtimer events to user space
Quoted 11 lines · Alexander Graf
We have 2 modes for dealing with interrupts in the ARM world. We can either handle them all using hardware acceleration through the vgic or we can emulate a gic in user space and only drive CPU IRQ pins from there.
Unfortunately, when driving IRQs from user space, we never tell user space about timer events that may result in interrupt line state changes, so we lose out on timer events if we run with user space gic emulation.
This patch fixes that by routing vtimer expiration events to user space. With this patch I can successfully run edk2 and Linux with user space gic emulation.
Hi Alex. I have some comments just on the userspace API docs. These are mostly requests for clarification or expansion, and they boil down to "if you gave me this API document change I wouldn't be able to deduce from it the necessary changes to QEMU or kvmtool to use this functionality".
Quoted 6 lines
Signed-off-by Alexander Graf <[email protected]>Documentation/virtual/kvm/api.txt +0
-0
Documentation/virtual/kvm/api.txt struct kvm_run { · line 3208
Quoted 8 lines
Documentation/virtual/kvm/api.txt +3
-1@@ -3202,8 +3202,10 @@ struct kvm_run { /* in */ __u8 request_interrupt_window; -Request that KVM_RUN return when it becomes possible to inject external +[x86] Request that KVM_RUN return when it becomes possible to inject external interrupts into the guest. Useful in conjunction with KVM_INTERRUPT. +[arm*] Bits set to 1 in here mask IRQ lines that would otherwise potentially +trigger forever. Useful with KVM_CAP_ARM_TIMER.
It's only a _u8 and there's more than 8 IRQ lines -- which ones can you mask this way?
Quoted 5 lines
Documentation/virtual/kvm/api.txt +0
-0__u8 padding1[7];@@ -3519,6 +3521,16 @@ Hyper-V SynIC state change. Notification is used to remap SynIC event/message pages and to enable/disable SynIC messages/events processing in userspace.
Documentation/virtual/kvm/api.txt Hyper-V SynIC state change. Notification is used to remap SynIC · line 3532
Quoted 10 lines
Documentation/virtual/kvm/api.txt +9
-0+ /* KVM_EXIT_ARM_TIMER */ + struct { + __u8 timesource; + } arm_timer; + +Indicates that a timer triggered that user space needs to handle and +potentially mask with vcpu->run->request_interrupt_window to allow the +guest to proceed. This only happens for timers that got enabled through +KVM_CAP_ARM_TIMER.
What values can the timesource field contain?
Quoted 7 lines
Documentation/virtual/kvm/api.txt +1
-0+ /* Fix the size of the union. */ char padding[256]; };@@ -3739,6 +3751,16 @@ Once this is done the KVM_REG_MIPS_VEC_* and KVM_REG_MIPS_MSA_* registers can be accessed, and the Config5.MSAEn bit is accessible via the KVM API and also from the guest.
Documentation/virtual/kvm/api.txt Once this is done the KVM_REG_MIPS_VEC_* and KVM_REG_MIPS_MSA_* registers can be · line 3762
Quoted 10 lines
Documentation/virtual/kvm/api.txt +9
-0+6.11 KVM_CAP_ARM_TIMER + +Architectures: arm, arm64 +Target: vcpu +Parameters: args[0] contains a bitmap of timers to enable + +This capability allows to route per-core timers into user space. When it's +enabled, the enabled timers trigger KVM_EXIT_ARM_TIMER guest exits when they +are pending, unless masked by vcpu->run->request_interrupt_window.
How are the timers enumerated within the bitmap? Which timers can be enabled like this?
Shouldn't this be talking about "timers to route to userspace" rather than "timers to enable", since AIUI the timers are always enabled regardless of what you set here ?
The KVM_CAP constant name seems rather generic given this is an obscure corner of the API.
What is the mechanism for the kernel to tell userspace when the timer *stops* being pending, so it can update the interrupt level for it in userspace? (What you really want I think is for the kernel to notify "timer level goes high" and "timer level goes low" and handle the masking internally.)
Documentation/virtual/kvm/api.txt Once this is done the KVM_REG_MIPS_VEC_* and KVM_REG_MIPS_MSA_* registers can be · line 3765
Quoted 3 lines
Documentation/virtual/kvm/api.txt +1
-0+ 7. Capabilities that can be enabled on VMs ------------------------------------------
thanks
-- PMM
Re: [PATCH v3 2/2] KVM: arm/arm64: Route vtimer events to user space
Quoted 16 lines · Peter Maydell
Quoted 11 lines · Alexander Graf
We have 2 modes for dealing with interrupts in the ARM world. We can either handle them all using hardware acceleration through the vgic or we can emulate a gic in user space and only drive CPU IRQ pins from there.
Unfortunately, when driving IRQs from user space, we never tell user space about timer events that may result in interrupt line state changes, so we lose out on timer events if we run with user space gic emulation.
This patch fixes that by routing vtimer expiration events to user space. With this patch I can successfully run edk2 and Linux with user space gic emulation.
Quoted 5 lines
Hi Alex. I have some comments just on the userspace API docs. These are mostly requests for clarification or expansion, and they boil down to "if you gave me this API document change I wouldn't be able to deduce from it the necessary changes to QEMU or kvmtool to use this functionality”.
Yeah, most of the documentation wouldn’t be enough to deduce the changes you need in user space applications, but I agree that that doesn’t mean we can’t improve going forward :).
Quoted 10 lines
Quoted 10 lines
Signed-off-by Alexander Graf <[email protected]>Documentation/virtual/kvm/api.txt +0
-0@@ -3202,8 +3202,10 @@ struct kvm_run { /* in */ __u8 request_interrupt_window;
Quoted 8 lines
Quoted 5 lines
Documentation/virtual/kvm/api.txt +1
-1-Request that KVM_RUN return when it becomes possible to inject external +[x86] Request that KVM_RUN return when it becomes possible to inject externalinterrupts into the guest. Useful in conjunction with
KVM_INTERRUPT. +[arm*] Bits set to 1 in here mask IRQ lines that would otherwise potentially +trigger forever. Useful withKVM_CAP_ARM_TIMER.It's only a
_u8and there's more than 8 IRQ lines -- which ones can you mask this way?
There are defines for the individual event lines you can mask. I’ll clarify.
Quoted 7 lines
Quoted 7 lines
__u8 padding1[7];Documentation/virtual/kvm/api.txt +0
-0@@ -3519,6 +3521,16 @@ Hyper-V SynIC state change. Notification is used to remap SynICevent/message pages and to enable/disable SynIC messages/events processing in userspace.
Quoted 11 lines
Documentation/virtual/kvm/api.txt Hyper-V SynIC state change. Notification is used to remap SynIC · line 3532
Quoted 9 lines
Documentation/virtual/kvm/api.txt +9
-0+ /* KVM_EXIT_ARM_TIMER */ + struct { + __u8 timesource; + } arm_timer; + +Indicates that a timer triggered that user space needs to handle and +potentially mask with vcpu->run->request_interrupt_window to allow the +guest to proceed. This only happens for timers that got enabled through +KVM_CAP_ARM_TIMER.What values can the timesource field contain?
There are defines for that again, I’ll clarify :).
Quoted 9 lines
Quoted 9 lines
Documentation/virtual/kvm/api.txt +1
-0+ /* Fix the size of the union. */ char padding[256]; };@@ -3739,6 +3751,16 @@ Once this is done the KVM_REG_MIPS_VEC_* and KVM_REG_MIPS_MSA_* registers can beaccessed, and the Config5.MSAEn bit is accessible via the KVM API and also from the guest.
Quoted 12 lines
Documentation/virtual/kvm/api.txt Once this is done the KVM_REG_MIPS_VEC_* and KVM_REG_MIPS_MSA_* registers can be · line 3762
Quoted 9 lines
+6.11
KVM_CAP_ARM_TIMERDocumentation/virtual/kvm/api.txt +8
-0+ +Architectures: arm, arm64 +Target: vcpu +Parameters: args[0] contains a bitmap of timers to enable + +This capability allows to route per-core timers into user space. When it's +enabled, the enabled timers trigger KVM_EXIT_ARM_TIMER guest exits when they +are pending, unless masked by vcpu->run->request_interrupt_window.How are the timers enumerated within the bitmap? Which timers can be enabled like this?
See above ;).
Quoted 3 lines
Shouldn't this be talking about "timers to route to userspace" rather than "timers to enable", since AIUI the timers are always enabled regardless of what you set here ?
The counter is enabled, but the timer isn’t, as you can never receive an event. But yes, I agree that the wording isn’t explicit enough. I’ll see if I can come up with something better.
Quoted 2 lines
The
KVM_CAPconstant name seems rather generic given this is an obscure corner of the API.
It basically enables the KVM_EXIT_ARM_TIMER capability - and I didn’t want to make the name too long. Any suggestions?
Quoted 2 lines
What is the mechanism for the kernel to tell userspace when the timer *stops* being pending, so it can update the interrupt
It can’t, because it doesn’t know :(. We can’t trap that event.
Quoted 3 lines
level for it in userspace? (What you really want I think is for the kernel to notify "timer level goes high" and "timer level goes low" and handle the masking internally.)
That’s what I want, but it’s not what hardware gives me. All I can do is poll whether it’s still up - and that’s basically what this interface does.
Alex
Hi Alex,
Quoted 8 lines · Alexander Graf
Some systems out there (well, one type in particular - the Raspberry Pi series) do have virtualization capabilities in the core, but no ARM GIC interrupt controller.
To run on these systems, the cleanest route is to just handle all interrupt delivery in user space and only deal with IRQ pins in the core side in KVM.
Quoted 6 lines
This works pretty well already, but breaks when the guest starts to use architected timers, as these are handled straight inside kernel space today.
This patch set allows user space to receive vtimer events as well as mask them, so that we can handle all vtimer related interrupt injection from user space, enabling us to use architected timer with user space gic emulation.
I have already voiced my concerns in the past, including face to face, and I'm going to repeat it: I not keen at all on adding a new userspace interface that is going to bitrot extremely quickly.
Let's face it, this new ABI will have a single user, with a limited shelf life. I understand that the RPi is a popular product, but it looks fairly obvious that this kind of sub-standard HW will eventually disappear. We'll then be left with a userspace ABI that will break at every single release, given that nobody in the RPi community actually uses a mainline kernel.
And breaking this ABI will introduce userspace exploitable bugs, like the one you've already shown. If anything, I would have loved to completely kill the whole userspace GIC, because nobody cares. Yes, I understand it is fun to have KVM running on the RPi. But the maintenance costs far outweigh the fun aspect already.
You could still run KVM with an external emulated timer (not the arch timer). No need for a new ABI for that.
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Paolo Bonzini
maintainerQuoted 7 lines · Marc Zyngier
Quoted 3 lines
This patch set allows user space to receive vtimer events as well as mask them, so that we can handle all vtimer related interrupt injection from user space, enabling us to use architected timer with user space gic emulation.
I have already voiced my concerns in the past, including face to face, and I'm going to repeat it: I not keen at all on adding a new userspace interface that is going to bitrot extremely quickly.
You don't have automated tests set up? It's not going to bitrot if you test it, either with kvm-unit-tests or just by smoke-testing Linux. It's _for_ the raspi, but it's not limited to it.
Paolo
Quoted 7 lines · Paolo Bonzini
Quoted 4 lines · Marc Zyngier
Quoted 3 lines
This patch set allows user space to receive vtimer events as well as mask them, so that we can handle all vtimer related interrupt injection from user space, enabling us to use architected timer with user space gic emulation.
Quoted 8 lines
Quoted 3 lines
I have already voiced my concerns in the past, including face to face, and I'm going to repeat it: I not keen at all on adding a new userspace interface that is going to bitrot extremely quickly.
You don't have automated tests set up? It's not going to bitrot if you test it, either with kvm-unit-tests or just by smoke-testing Linux. It's _for_ the raspi, but it's not limited to it.
Our automated testing situation is not great, no. Something we're looking at, but have resource problems with.
-Christoffer
Paolo Bonzini
maintainerQuoted 8 lines · Christoffer Dall
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
This patch set allows user space to receive vtimer events as well as mask them, so that we can handle all vtimer related interrupt injection from user space, enabling us to use architected timer with user space gic emulation.
I have already voiced my concerns in the past, including face to face, and I'm going to repeat it: I not keen at all on adding a new userspace interface that is going to bitrot extremely quickly.
Quoted 6 lines
Quoted 3 lines
You don't have automated tests set up? It's not going to bitrot if you test it, either with kvm-unit-tests or just by smoke-testing Linux. It's _for_ the raspi, but it's not limited to it.
Our automated testing situation is not great, no. Something we're looking at, but have resource problems with.
But it's not a good reason to hold back a feature...
Paolo
Quoted 11 lines · Paolo Bonzini
Quoted 8 lines · Christoffer Dall
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
This patch set allows user space to receive vtimer events as well as mask them, so that we can handle all vtimer related interrupt injection from user space, enabling us to use architected timer with user space gic emulation.
I have already voiced my concerns in the past, including face to face, and I'm going to repeat it: I not keen at all on adding a new userspace interface that is going to bitrot extremely quickly.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
You don't have automated tests set up? It's not going to bitrot if you test it, either with kvm-unit-tests or just by smoke-testing Linux. It's _for_ the raspi, but it's not limited to it.
Our automated testing situation is not great, no. Something we're looking at, but have resource problems with.
But it's not a good reason to hold back a feature...
I didn't say that exactly, but choosing not to merge something we cannot maintain and which we're not paid to look after and where there's a minimal interest, is not entirely unreasonable.
That being said, I'm not categorically against these patches, but I share Marc's view that we've already seen that non-vgic support had been broken for multiple versions without anyone complaining, and without automated testing or substantial interest in the work, the patches really are likely to bit-rot.
But I haven't even looked at the patches in detail, I was just replying to the comment about testing.
-Christoffer
Quoted 26 lines · Christoffer Dall
Quoted 11 lines · Paolo Bonzini
Quoted 8 lines · Christoffer Dall
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
This patch set allows user space to receive vtimer events as well as mask them, so that we can handle all vtimer related interrupt injection from user space, enabling us to use architected timer with user space gic emulation.
I have already voiced my concerns in the past, including face to face, and I'm going to repeat it: I not keen at all on adding a new userspace interface that is going to bitrot extremely quickly.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
You don't have automated tests set up? It's not going to bitrot if you test it, either with kvm-unit-tests or just by smoke-testing Linux. It's _for_ the raspi, but it's not limited to it.
Our automated testing situation is not great, no. Something we're looking at, but have resource problems with.
But it's not a good reason to hold back a feature...
I didn't say that exactly, but choosing not to merge something we cannot maintain and which we're not paid to look after and where there's a minimal interest, is not entirely unreasonable.
Quoted 8 lines
That being said, I'm not categorically against these patches, but I share Marc's view that we've already seen that non-vgic support had been broken for multiple versions without anyone complaining, and without automated testing or substantial interest in the work, the patches really are likely to bit-rot.
But I haven't even looked at the patches in detail, I was just replying to the comment about testing.
This may be a great time to start encouraging feature writers to submit kvm-unit-tests patches at the same time as the feature (Hi Alex :-) I'm happy to help when a test isn't easy to write due to a lack of framework, but don't have nearly enough bandwidth to write all the tests myself.
As for additional motivation for this series, I'll point out that it's good for bug isolation. When a guest fails to boot over KVM I can try TCG. If that works, then I've likely narrowed it to KVM. If I can further try kernel_irqchip=no, then I may further narrow it down to the vgic implementation.
Thanks,
drew
Paolo Bonzini
maintainerQuoted 7 lines · Andrew Jones
Quoted 2 lines
But I haven't even looked at the patches in detail, I was just replying to the comment about testing.
This may be a great time to start encouraging feature writers to submit kvm-unit-tests patches at the same time as the feature (Hi Alex :-) I'm happy to help when a test isn't easy to write due to a lack of framework, but don't have nearly enough bandwidth to write all the tests myself.
In this case really a kernel smoke test can just work. But yes, architectural timer tests would be nice too.
Quoted 5 lines
As for additional motivation for this series, I'll point out that it's good for bug isolation. When a guest fails to boot over KVM I can try TCG. If that works, then I've likely narrowed it to KVM. If I can further try kernel_irqchip=no, then I may further narrow it down to the vgic implementation.
(Or vice versa to the userspace GIC if you're looking at a TCG bug).
Paolo
Quoted 36 lines
Am 16.09.2016 um 15:46 schrieb Andrew Jones <[email protected]>:
Quoted 32 lines · Christoffer Dall
Quoted 12 lines · Paolo Bonzini
Quoted 8 lines · Christoffer Dall
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
This patch set allows user space to receive vtimer events as well as mask them, so that we can handle all vtimer related interrupt injection from user space, enabling us to use architected timer with user space gic emulation.
I have already voiced my concerns in the past, including face to face, and I'm going to repeat it: I not keen at all on adding a new userspace interface that is going to bitrot extremely quickly.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
You don't have automated tests set up? It's not going to bitrot if you test it, either with kvm-unit-tests or just by smoke-testing Linux. It's _for_ the raspi, but it's not limited to it.
Our automated testing situation is not great, no. Something we're looking at, but have resource problems with.
But it's not a good reason to hold back a feature...
I didn't say that exactly, but choosing not to merge something we cannot maintain and which we're not paid to look after and where there's a minimal interest, is not entirely unreasonable.
That being said, I'm not categorically against these patches, but I share Marc's view that we've already seen that non-vgic support had been broken for multiple versions without anyone complaining, and without automated testing or substantial interest in the work, the patches really are likely to bit-rot.
Quoted 5 lines
Quoted 2 lines
But I haven't even looked at the patches in detail, I was just replying to the comment about testing.
This may be a great time to start encouraging feature writers to submit kvm-unit-tests patches at the same time as the feature (Hi Alex :-)
I actually started off implementing this with the help of kvm-unit-tests. It's awesome!
I'm lacking actual irq support to make the test reasonable though and wanted to get the kernel bits out first :). But I'll sit down on that again soon I hope.
Alex
Quoted 39 lines · Alexander Graf
Quoted 39 lines
Am 16.09.2016 um 15:46 schrieb Andrew Jones <[email protected]>:
Quoted 34 lines · Christoffer Dall
Quoted 12 lines · Paolo Bonzini
Quoted 8 lines · Christoffer Dall
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
This patch set allows user space to receive vtimer events as well as mask them, so that we can handle all vtimer related interrupt injection from user space, enabling us to use architected timer with user space gic emulation.
I have already voiced my concerns in the past, including face to face, and I'm going to repeat it: I not keen at all on adding a new userspace interface that is going to bitrot extremely quickly.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
You don't have automated tests set up? It's not going to bitrot if you test it, either with kvm-unit-tests or just by smoke-testing Linux. It's _for_ the raspi, but it's not limited to it.
Our automated testing situation is not great, no. Something we're looking at, but have resource problems with.
But it's not a good reason to hold back a feature...
I didn't say that exactly, but choosing not to merge something we cannot maintain and which we're not paid to look after and where there's a minimal interest, is not entirely unreasonable.
That being said, I'm not categorically against these patches, but I share Marc's view that we've already seen that non-vgic support had been broken for multiple versions without anyone complaining, and without automated testing or substantial interest in the work, the patches really are likely to bit-rot.
But I haven't even looked at the patches in detail, I was just replying to the comment about testing.
Quoted 6 lines
Quoted 2 lines
This may be a great time to start encouraging feature writers to submit kvm-unit-tests patches at the same time as the feature (Hi Alex :-)
I actually started off implementing this with the help of kvm-unit-tests. It's awesome!
I'm lacking actual irq support to make the test reasonable though and wanted to get the kernel bits out first :). But I'll sit down on that again soon I hope.
I'm glad it looks like a good base for you. I need to get this series
https://github.com/rhdrjones/kvm-unit-tests/commits/arm/gic refreshed and merged, and also it's time to start looking into adding interrupt injection to chr-testdev. With those in place I hope it'll be an even better base for you.
Thanks,
drew
Quoted 45 lines · Andrew Jones
Quoted 44 lines · Alexander Graf
Quoted 36 lines
Am 16.09.2016 um 15:46 schrieb Andrew Jones <[email protected]>:
Quoted 32 lines · Christoffer Dall
Quoted 12 lines · Paolo Bonzini
Quoted 8 lines · Christoffer Dall
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
This patch set allows user space to receive vtimer events as well as mask them, so that we can handle all vtimer related interrupt injection from user space, enabling us to use architected timer with user space gic emulation.
I have already voiced my concerns in the past, including face to face, and I'm going to repeat it: I not keen at all on adding a new userspace interface that is going to bitrot extremely quickly.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
You don't have automated tests set up? It's not going to bitrot if you test it, either with kvm-unit-tests or just by smoke-testing Linux. It's _for_ the raspi, but it's not limited to it.
Our automated testing situation is not great, no. Something we're looking at, but have resource problems with.
But it's not a good reason to hold back a feature...
I didn't say that exactly, but choosing not to merge something we cannot maintain and which we're not paid to look after and where there's a minimal interest, is not entirely unreasonable.
That being said, I'm not categorically against these patches, but I share Marc's view that we've already seen that non-vgic support had been broken for multiple versions without anyone complaining, and without automated testing or substantial interest in the work, the patches really are likely to bit-rot.
Quoted 5 lines
Quoted 2 lines
But I haven't even looked at the patches in detail, I was just replying to the comment about testing.
This may be a great time to start encouraging feature writers to submit kvm-unit-tests patches at the same time as the feature (Hi Alex :-)
I actually started off implementing this with the help of kvm-unit-tests. It's awesome!
Quoted 7 lines
Quoted 1 line
I'm lacking actual irq support to make the test reasonable though and wanted to get the kernel bits out first :). But I'll sit down on that again soon I hope.
I'm glad it looks like a good base for you. I need to get this series
https://github.com/rhdrjones/kvm-unit-tests/commits/arm/gic refreshed and merged, and also it's time to start looking into adding interrupt injection to chr-testdev. With those in place I hope it'll be an even better base for you.
Awesome. Let me know when you're further ahead with the gic work then so that we can actually trigger interrupts and measure irq latencies :).
Until then, I sent the simplistic version that I used for bringup to the list.
Alex
Hi,
Quoted 3 lines
That being said, I'm not categorically against these patches, but I share Marc's view that we've already seen that non-vgic support had been broken for multiple versions without anyone complaining,
Oh, did this ever work? Work as in "can actually run a virtual machine", not as in "kvm doesn't throw an error on initialization".
Quoted 3 lines
and without
automated testing or substantial interest in the work, the patches really are likely to bit-rot.
Well, as far I know the rpi3 is the *only* aarch64 hardware which is easily available and can (with these patches) run kvm.
More powerful stuff with more ram and sata storage and gbit network (which I'd love to have to play with arm virt on real hardware) is announced to be available really soon now since ... half a year at least?
cheers,
Gerd
Quoted 26 lines · Christoffer Dall
Quoted 11 lines · Paolo Bonzini
Quoted 8 lines · Christoffer Dall
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
This patch set allows user space to receive vtimer events as well as mask them, so that we can handle all vtimer related interrupt injection from user space, enabling us to use architected timer with user space gic emulation.
I have already voiced my concerns in the past, including face to face, and I'm going to repeat it: I not keen at all on adding a new userspace interface that is going to bitrot extremely quickly.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
You don't have automated tests set up? It's not going to bitrot if you test it, either with kvm-unit-tests or just by smoke-testing Linux. It's _for_ the raspi, but it's not limited to it.
Our automated testing situation is not great, no. Something we're looking at, but have resource problems with.
But it's not a good reason to hold back a feature...
I didn't say that exactly, but choosing not to merge something we cannot maintain and which we're not paid to look after and where there's a minimal interest, is not entirely unreasonable.
Quoted 5 lines
That being said, I'm not categorically against these patches, but I share Marc's view that we've already seen that non-vgic support had been broken for multiple versions without anyone complaining, and without automated testing or substantial interest in the work, the patches really are likely to bit-rot.
I know that it's very hard to grasp from an upstream maintainer perspective, but keep in mind where the bulk of execution of kernel code lies. The average life cycle of a "stable" Linux distribution's kernel is a few years.
So far all regressions in the user space gic code have been found within less than 1y of the respective code release. I'd say that counts for quite a well used feature.
Quoted 2 lines
But I haven't even looked at the patches in detail, I was just replying to the comment about testing.
Also keep in mind that without the architected timer support (and/or without qemu patches than enable user space timers) the user space gic support is pretty unusable to most people, so you obviously get less reports.
Alex
Quoted 3 lines · Alexander Graf
On 16.09.16 15:30, Christoffer Dall wrote:
[...]
Quoted 9 lines
Quoted 6 lines
That being said, I'm not categorically against these patches, but I share Marc's view that we've already seen that non-vgic support had been broken for multiple versions without anyone complaining, and without automated testing or substantial interest in the work, the patches really are likely to bit-rot.
I know that it's very hard to grasp from an upstream maintainer perspective,
pfff
Quoted 8 lines
but keep in mind where the bulk of execution of kernel code lies. The average life cycle of a "stable" Linux distribution's kernel is a few years.
So far all regressions in the user space gic code have been found within less than 1y of the respective code release. I'd say that counts for quite a well used feature.
The only report I can think of about this was Pavel using an upstream kernel for in-house Samsung development on non-public hardware.
But, again, I didn't look at the patches in detail yet, I'm not categorically against them, I will take a careful look at them like I do with all patches on the kvmarm list. There's a risk they'll break in mainline unless we sort out our testing story, and it may just be something we'll have to live with.
Quoted 8 lines
Quoted 2 lines
But I haven't even looked at the patches in detail, I was just replying to the comment about testing.
Also keep in mind that without the architected timer support (and/or without qemu patches than enable user space timers) the user space gic support is pretty unusable to most people, so you obviously get less reports.
I don't disagree with this. I don't know what this has to do with the part of my mail you're replying to, but I completely agree that the current userspace irqchip support has limited value.
-Christoffer
Quoted 21 lines · Marc Zyngier
Hi Alex,
Quoted 8 lines · Alexander Graf
Some systems out there (well, one type in particular - the Raspberry Pi series) do have virtualization capabilities in the core, but no ARM GIC interrupt controller.
To run on these systems, the cleanest route is to just handle all interrupt delivery in user space and only deal with IRQ pins in the core side in KVM.
Quoted 6 lines
This works pretty well already, but breaks when the guest starts to use architected timers, as these are handled straight inside kernel space today.
This patch set allows user space to receive vtimer events as well as mask them, so that we can handle all vtimer related interrupt injection from user space, enabling us to use architected timer with user space gic emulation.
Quoted 8 lines
I have already voiced my concerns in the past, including face to face, and I'm going to repeat it: I not keen at all on adding a new userspace interface that is going to bitrot extremely quickly.
Let's face it, this new ABI will have a single user, with a limited shelf life. I understand that the RPi is a popular product, but it looks fairly obvious that this kind of sub-standard HW will eventually disappear. We'll then be left with a userspace ABI that will break at
I’m not 100% convinced that this is the case. Emulating the GIC in user space can have other interesting use cases. For example, it might come in handy for nesting. It may be useful for migrating a gicv2 VM to a gicv3 host without gicv2 emulation as well.
Quoted 2 lines
every single release, given that nobody in the RPi community actually uses a mainline kernel.
I actually verified all of this patch on 4.8-rc5 upstream, which is the only 64bit kernel you can find for the RPi. So I’d expect the situation to change with 64bit.
Quoted 5 lines
And breaking this ABI will introduce userspace exploitable bugs, like the one you've already shown. If anything, I would have loved to completely kill the whole userspace GIC, because nobody cares. Yes, I understand it is fun to have KVM running on the RPi. But the maintenance costs far outweigh the fun aspect already.
Having CPU pins accessible is very useful for use cases of KVM that are beyond your traditional VM.
Quoted 2 lines
You could still run KVM with an external emulated timer (not the arch timer). No need for a new ABI for that.
That’s what I thought too, but turns out that it’s not quite as simple as I hoped ;). Also, I much rather at least have a common notion of “arch timers are always available on arm64” than “kvm always uses the vgic”. The former has much more impact and much more reach.
Alex
Quoted 25 lines · Alexander Graf
Quoted 25 lines · Marc Zyngier
Hi Alex,
Quoted 8 lines · Alexander Graf
Some systems out there (well, one type in particular - the Raspberry Pi series) do have virtualization capabilities in the core, but no ARM GIC interrupt controller.
To run on these systems, the cleanest route is to just handle all interrupt delivery in user space and only deal with IRQ pins in the core side in KVM.
Quoted 6 lines
This works pretty well already, but breaks when the guest starts to use architected timers, as these are handled straight inside kernel space today.
This patch set allows user space to receive vtimer events as well as mask them, so that we can handle all vtimer related interrupt injection from user space, enabling us to use architected timer with user space gic emulation.
I have already voiced my concerns in the past, including face to face, and I'm going to repeat it: I not keen at all on adding a new userspace interface that is going to bitrot extremely quickly.
Quoted 7 lines
Quoted 4 lines
Let's face it, this new ABI will have a single user, with a limited shelf life. I understand that the RPi is a popular product, but it looks fairly obvious that this kind of sub-standard HW will eventually disappear. We'll then be left with a userspace ABI that will break at
I’m not 100% convinced that this is the case. Emulating the GIC in user space can have other interesting use cases. For example, it might come in handy for nesting. It may be useful for migrating a gicv2 VM to a gicv3 host without gicv2 emulation as well.
I don't see why you'd do this; the VGIC hardware can perfectly well be used for nesting as well, and this works rather well.
Quoted 11 lines
Quoted 2 lines
every single release, given that nobody in the RPi community actually uses a mainline kernel.
I actually verified all of this patch on 4.8-rc5 upstream, which is the only 64bit kernel you can find for the RPi. So I’d expect the situation to change with 64bit.
Quoted 5 lines
And breaking this ABI will introduce userspace exploitable bugs, like the one you've already shown. If anything, I would have loved to completely kill the whole userspace GIC, because nobody cares. Yes, I understand it is fun to have KVM running on the RPi. But the maintenance costs far outweigh the fun aspect already.
Quoted 6 lines
Having CPU pins accessible is very useful for use cases of KVM that are beyond your traditional VM.
Quoted 2 lines
You could still run KVM with an external emulated timer (not the arch timer). No need for a new ABI for that.
That’s what I thought too, but turns out that it’s not quite as simple as I hoped ;).
Why not? I thought a few people had this running recently. What were the issues? Perhaps I can convince someone to submit the patches they used if useful.
Thanks,
-Christoffer
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Paolo Bonzini
maintainerQuoted 4 lines · Christoffer Dall
Quoted 1 line
It may be useful for migrating a gicv2 VM to a gicv3 host without gicv2 emulation as well.
I don't see why you'd do this; the VGIC hardware can perfectly well be used for nesting as well, and this works rather well.
Can GICv3 emulate GICv2 in a guest?
Paolo
Quoted 12 lines · Paolo Bonzini
Quoted 4 lines · Christoffer Dall
Quoted 1 line
It may be useful for migrating a gicv2 VM to a gicv3 host without gicv2 emulation as well.
I don't see why you'd do this; the VGIC hardware can perfectly well be used for nesting as well, and this works rather well.
Can GICv3 emulate GICv2 in a guest?
It depends on the gicv3 configuration. As an SOC vendor you can either enable gicv2 compatibility or disable it. ThunderX for example is gicv3 only. LS2085 can handle gicv2 in the guest with gicv3 on the host.
Alex
Paolo Bonzini
maintainerQuoted 10 lines · Alexander Graf
Quoted 10 lines
On 16 Sep 2016, at 14:40, Paolo Bonzini <[email protected]> wrote:
Quoted 3 lines · Christoffer Dall
Quoted 2 lines
It may be useful for migrating a gicv2 VM to a gicv3 host without gicv2 emulation as well.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I don't see why you'd do this; the VGIC hardware can perfectly well be used for nesting as well, and this works rather well.
Can GICv3 emulate GICv2 in a guest?
It depends on the gicv3 configuration. As an SOC vendor you can either enable gicv2 compatibility or disable it. ThunderX for example is gicv3 only.
And QEMU complains on startup and exits, I hope.
I am not too optimistic about having migration from kernel GIC to userspace GIC, honestly. But GICv2 emulation on GICv3-only hosts is a very reasonable thing to want, if only for testing/debugging purposes.
Paolo
Quoted 6 lines · Alexander Graf
Quoted 6 lines · Paolo Bonzini
On 16/09/2016 14:29, Christoffer Dall wrote:
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
It may be useful for migrating a gicv2 VM to a gicv3 host without gicv2 emulation as well.
I don't see why you'd do this; the VGIC hardware can perfectly well be used for nesting as well, and this works rather well.
Can GICv3 emulate GICv2 in a guest?
It depends on the gicv3 configuration. As an SOC vendor you can either enable gicv2 compatibility or disable it. ThunderX for example is gicv3 only. LS2085 can handle gicv2 in the guest with gicv3 on the host.
Note that 'disabled' here means 'not implemented it in silicon', so there is no way you will ever be able to re-enable GICv2 compatibility on a ThunderX. Another thing to keep in mind is that GICv2 compatibility is disabled on the non-secure side if the secure side elects to configure its view of the GIC as v3 (i.e., in order to support >8 cores)
Quoted 4 lines · Ard Biesheuvel
Another thing to keep in mind is that GICv2 compatibility is disabled on the non-secure side if the secure side elects to configure its view of the GIC as v3 (i.e., in order to support >8 cores)
If I'm reading the 'legacy configurations' chapter of the GICv3 spec correctly, that is true for the NS host OS (ie the one handling physical interrupts) but a guest OS can still use the old GICv2-compat interface (assuming it was implemented in silicon at all).
thanks
-- PMM
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Ard Biesheuvel
Another thing to keep in mind is that GICv2 compatibility is disabled on the non-secure side if the secure side elects to configure its view of the GIC as v3 (i.e., in order to support >8 cores)
Quoted 6 lines
If I'm reading the 'legacy configurations' chapter of the GICv3 spec correctly, that is true for the NS host OS (ie the one handling physical interrupts) but a guest OS can still use the old GICv2-compat interface (assuming it was implemented in silicon at all).
Ah right, apologies for spreading misinformation. But my first point is still valid.
Quoted 34 lines · Christoffer Dall
Quoted 30 lines · Alexander Graf
Quoted 29 lines · Marc Zyngier
Hi Alex,
Quoted 8 lines · Alexander Graf
Some systems out there (well, one type in particular - the Raspberry Pi series) do have virtualization capabilities in the core, but no ARM GIC interrupt controller.
To run on these systems, the cleanest route is to just handle all interrupt delivery in user space and only deal with IRQ pins in the core side in KVM.
Quoted 6 lines
This works pretty well already, but breaks when the guest starts to use architected timers, as these are handled straight inside kernel space today.
This patch set allows user space to receive vtimer events as well as mask them, so that we can handle all vtimer related interrupt injection from user space, enabling us to use architected timer with user space gic emulation.
I have already voiced my concerns in the past, including face to face, and I'm going to repeat it: I not keen at all on adding a new userspace interface that is going to bitrot extremely quickly.
Let's face it, this new ABI will have a single user, with a limited shelf life. I understand that the RPi is a popular product, but it looks fairly obvious that this kind of sub-standard HW will eventually disappear. We'll then be left with a userspace ABI that will break at
Quoted 5 lines
Quoted 2 lines
I’m not 100% convinced that this is the case. Emulating the GIC in user space can have other interesting use cases. For example, it might come in handy for nesting. It may be useful for migrating a gicv2 VM to a gicv3 host without gicv2 emulation as well.
I don't see why you'd do this; the VGIC hardware can perfectly well be used for nesting as well, and this works rather well.
Mostly because it’s more. I like my problems self-contained, and simulating only nesting on the CPU level is less to worry about than simulating vgic switchover as well. Of course eventually with nesting you’d want a nested vgic ;).
Quoted 14 lines
Quoted 14 lines
Quoted 3 lines
every single release, given that nobody in the RPi community actually uses a mainline kernel.
I actually verified all of this patch on 4.8-rc5 upstream, which is the only 64bit kernel you can find for the RPi. So I’d expect the situation to change with 64bit.
Quoted 5 lines
And breaking this ABI will introduce userspace exploitable bugs, like the one you've already shown. If anything, I would have loved to completely kill the whole userspace GIC, because nobody cares. Yes, I understand it is fun to have KVM running on the RPi. But the maintenance costs far outweigh the fun aspect already.
Having CPU pins accessible is very useful for use cases of KVM that are beyond your traditional VM.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
You could still run KVM with an external emulated timer (not the arch timer). No need for a new ABI for that.
That’s what I thought too, but turns out that it’s not quite as simple as I hoped ;).
Why not? I thought a few people had this running recently. What were the issues? Perhaps I can convince someone to submit the patches they used if useful.
Just give it a try - I didn’t get any timer events and couldn’t quite figure out why. Patch is attached below.
Alex
hw/arm/virt.c +55 -0
@@ -91,6 +91,7 @@ typedef struct {bool secure;bool highmem;int32_t gic_version; +bool archtimer; } VirtMachineState;#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt")
@@ -177,6 +178,7 @@ static const MemMapEntry a15memmap[] = { [VIRT_FW_CFG] = { 0x09020000, 0x00000018 }, [VIRT_GPIO] = { 0x09030000, 0x00001000 }, [VIRT_SECURE_UART] = { 0x09040000, 0x00001000 }, + [VIRT_SP804] = { 0x09050000, 0x00001000 }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 },
@@ -195,6 +197,7 @@ static const int a15irqmap[] = { [VIRT_PCIE] = 3, /* ... to 6 */ [VIRT_GPIO] = 7, [VIRT_SECURE_UART] = 8, + [VIRT_SP804] = 9, [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */ [VIRT_PLATFORM_BUS] = 112, /* ...to 112 + PLATFORM_BUS_NUM_IRQS -1 */
@@ -352,11 +355,13 @@ static void fdt_add_timer_nodes(const VirtBoardInfo *vbi, int gictype) "arm,armv7-timer"); }qemu_fdt_setprop (vbi->fdt,"/timer" ,"always-on" ,NULL ,0 ); +#if 0 qemu_fdt_setprop_cells (vbi->fdt,"/timer" ,"interrupts" ,GIC_FDT_IRQ_TYPE_PPI ,ARCH_TIMER_S_EL1_IRQ , irqflags,GIC_FDT_IRQ_TYPE_PPI ,ARCH_TIMER_NS_EL1_IRQ , irqflags,GIC_FDT_IRQ_TYPE_PPI ,ARCH_TIMER_VIRT_IRQ , irqflags,GIC_FDT_IRQ_TYPE_PPI ,ARCH_TIMER_NS_EL2_IRQ , irqflags); +#endif }static void fdt_add_cpu_nodes (const VirtBoardInfo *vbi)
@@ -655,6 +660,29 @@ static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic)g_free (nodename); } +static void create_sp804 (const VirtBoardInfo *vbi,qemu_irq *pic) +{ +char *nodename; +hwaddr base = vbi->memmap[VIRT_SP804 ].base; +hwaddr size = vbi->memmap[VIRT_SP804 ].size; +int irq = vbi->irqmap[VIRT_SP804 ]; +const char compat[] ="arm,sp804\0arm,primecell" ; + +sysbus_create_simple ("sp804" , base, pic[irq]); + + nodename =g_strdup_printf ("/sp804@%" PRIx64, base); +qemu_fdt_add_subnode (vbi->fdt, nodename); +qemu_fdt_setprop (vbi->fdt, nodename,"compatible" , compat,sizeof (compat)); +qemu_fdt_setprop_sized_cells (vbi->fdt, nodename,"reg" , +2 , base,2 , size); +qemu_fdt_setprop_cells (vbi->fdt, nodename,"interrupts" , +GIC_FDT_IRQ_TYPE_SPI , irq, +GIC_FDT_IRQ_FLAGS_LEVEL_HI ); +qemu_fdt_setprop_cell (vbi->fdt, nodename,"clocks" , vbi->clock_phandle); +qemu_fdt_setprop_string (vbi->fdt, nodename,"clock-names" ,"apb_pclk" ); +g_free (nodename); +} +static DeviceState *gpio_key_dev;static void virt_powerdown_req (Notifier *n,void *opaque) {
@@ -1354,6 +1385,10 @@ static void machvirt_init(MachineState *machine)create_rtc (vbi, pic); +if (!vms->archtimer) { +create_sp804 (vbi, pic); + } +create_pcie (vbi, pic, vms->highmem);create_gpio (vbi, pic);
@@ -1448,6 +1483,20 @@ static void virt_set_gic_version(Object *obj, const char *value, Error **errp) } } +static bool virt_get_archtimer (Object *obj,Error **errp) +{ +VirtMachineState *vms =VIRT_MACHINE (obj); + +return vms->archtimer; +} + +static void virt_set_archtimer (Object *obj,bool value,Error **errp) +{ +VirtMachineState *vms =VIRT_MACHINE (obj); + + vms->archtimer = value; +} +static void virt_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -1510,6 +1559,15 @@ static void virt_2_7_instance_init(Object *obj)object_property_set_description (obj,"gic-version" ,"Set GIC version. " "Valid values are 2, 3 and host" ,NULL ); + +/* Architected Timers are available by default */ + vms->archtimer = true; +object_property_add_bool (obj,"archtimer" , virt_get_archtimer, + virt_set_archtimer,NULL ); +object_property_set_description (obj,"archtimer" , +"Set on/off to enable/disable exposure " +"of architected timers to the guest" , +NULL ); }static void virt_machine_2_7_options (MachineClass *mc)
hw/timer/arm_timer.c +0 -0
include/hw/arm/virt.h +1 -0
@@ -67,6 +67,7 @@ enum {VIRT_GPIO ,VIRT_SECURE_UART ,VIRT_SECURE_MEM , + VIRT_SP804, }; typedef struct MemMapEntry {