PSCI system off and reset for KVM ARM/ARM64
Subsystems (4)
cover PSCI system off and reset for KVM ARM/ARM64
The Power State and Coordination Interface (PSCI) specification defines SYSTEM_OFF and SYSTEM_RESET functions for system poweroff and reboot.
This patchset adds emulation of PSCI SYSTEM_OFF and SYSTEM_RESET functions in KVM ARM/ARM64 by forwarding them to user space (QEMU or KVMTOOL) using KVM_EXIT_SHUTDOWN and KVM_EXIT_RESET exit reasons.
To try this patch from guest kernel, we will need PSCI-based restart and poweroff support in the guest kenel for both ARM and ARM64.
Rob Herring has already submitted patches for PSCI-based restart and poweroff in ARM kernel but these are not merged yet due unstable device tree bindings of kernel PSCI support. We will be having similar patches for PSCI-based restart and poweroff in ARM64 kernel.
(Refer http://www.spinics.net/lists/arm-kernel/msg262217.html)
(Refer http://www.spinics.net/lists/devicetree/msg05348.html)
Anup Patel (2):
KVM: Add KVM_EXIT_RESET to user space API header ARM/ARM64: KVM: Forward PSCI SYSTEM_OFF and SYSTEM_RESET to user
space
arch/arm/include/asm/kvm_psci.h | 2 +- arch/arm/include/uapi/asm/kvm.h | 2 ++ arch/arm/kvm/handle_exit.c | 7 ++++++- arch/arm/kvm/psci.c | 38 +++++++++++++++++++++++++++++-------- arch/arm64/include/asm/kvm_psci.h | 2 +- arch/arm64/include/uapi/asm/kvm.h | 2 ++ arch/arm64/kvm/handle_exit.c | 10 ++++++---- include/uapi/linux/kvm.h | 1 + 8 files changed, 49 insertions(+), 15 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/2 KVM: Add KVM_EXIT_RESET to user space API header
Currently, we don't have an exit reason for VM reset emulation in user space hence this patch adds exit reason KVM_EXIT_RESET for this purpose.
This newly added KVM_EXIT_RESET will be used by KVM arm/arm64 in-kernel PSCI support to reset VMs.
--- include/uapi/linux/kvm.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/kvm.h +1 -0
@@ -171,6 +171,7 @@ struct kvm_pit_config {#define KVM_EXIT_WATCHDOG 21#define KVM_EXIT_S390_TSCH 22#define KVM_EXIT_EPR 23 +#define KVM_EXIT_RESET 24/* For KVM_EXIT_INTERNAL_ERROR */ /* Emulate instruction failed. */
Signature · 1 line
1.7.9.5
PATCH 1/2 KVM: Add KVM_EXIT_RESET to user space API header
(Adding Christoffer, forgot to add him to CC)
Quoted 32 lines · Anup Patel
Currently, we don't have an exit reason for VM reset emulation in user space hence this patch adds exit reason
KVM_EXIT_RESETfor this purpose.This newly added
KVM_EXIT_RESETwill be used by KVM arm/arm64 in-kernel PSCI support to reset VMs.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>--- include/uapi/linux/kvm.h | 1 + 1 file changed, 1 insertion(+)include/uapi/linux/kvm.h +1
-1@@ -171,6 +171,7 @@ struct kvm_pit_config {#define KVM_EXIT_WATCHDOG 21#define KVM_EXIT_S390_TSCH 22#define KVM_EXIT_EPR 23 +#define KVM_EXIT_RESET 24/* For KVM_EXIT_INTERNAL_ERROR */ /* Emulate instruction failed. */ --1.7.9.5
_______________________________________________
kvmarm mailing list
kvmarm at lists.cs.columbia.edu
https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm
PATCH 1/2 KVM: Add KVM_EXIT_RESET to user space API header
In reply to Anup PatelQuoted 6 lines · Anup Patel
Currently, we don't have an exit reason for VM reset emulation in user space hence this patch adds exit reason
KVM_EXIT_RESETfor this purpose.This newly added
KVM_EXIT_RESETwill be used by KVM arm/arm64 in-kernel PSCI support to reset VMs.
Quoted 22 lines
Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>--- include/uapi/linux/kvm.h | 1 + 1 file changed, 1 insertion(+)include/uapi/linux/kvm.h +1
-0@@ -171,6 +171,7 @@ struct kvm_pit_config {#define KVM_EXIT_WATCHDOG 21#define KVM_EXIT_S390_TSCH 22#define KVM_EXIT_EPR 23 +#define KVM_EXIT_RESET 24/* For KVM_EXIT_INTERNAL_ERROR */ /* Emulate instruction failed. */ Signature · 1 line
1.7.9.5
PATCH 1/2 KVM: Add KVM_EXIT_RESET to user space API header
In reply to Anup PatelQuoted 18 lines · Anup Patel
Currently, we don't have an exit reason for VM reset emulation in user space hence this patch adds exit reason
KVM_EXIT_RESETfor this purpose.This newly added
KVM_EXIT_RESETwill be used by KVM arm/arm64 in-kernel PSCI support to reset VMs.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>---
include/uapi/linux/kvm.h| 1 +1 file changed, 1 insertion(+)include/uapi/linux/kvm.h +0
-0
include/uapi/linux/kvm.h struct kvm_pit_config { · line 174
Quoted 4 lines
include/uapi/linux/kvm.h +1
-0@@ -171,6 +171,7 @@ struct kvm_pit_config {#define KVM_EXIT_WATCHDOG 21#define KVM_EXIT_S390_TSCH 22#define KVM_EXIT_EPR 23 +#define KVM_EXIT_RESET 24
I have to admit that I'm not particularly happy with the exit name. It's not obvious from the name under which circumstances it gets triggered. Does it get triggered when a core level reset happens? Does it get triggered when a system level reset happened? When the guest requests one?
I know what it does, but I find the name too generic for what it is. What you're really doing is introduce a new communication channel in parallel to MMIO / PIO / HCALL which is only used for system level reset / shutdown today.
Can we treat it as such? Could you please make this a common exit number that's called something like
KVM_EXIT_SYSTEM_EVENT
with a parameter that can either be TRIGGER_SHUTDOWN or TRIGGER_RESET.
That way it's obvious what's going on and people don't get confused.
Alex
PATCH 1/2 KVM: Add KVM_EXIT_RESET to user space API header
Quoted 16 lines · Alexander Graf
Quoted 13 lines · Anup Patel
Currently, we don't have an exit reason for VM reset emulation in user space hence this patch adds exit reason
KVM_EXIT_RESETfor this purpose.This newly added
KVM_EXIT_RESETwill be used by KVM arm/arm64 in-kernel PSCI support to reset VMs.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>---
include/uapi/linux/kvm.h| 1 +1 file changed, 1 insertion(+)
Quoted 11 lines
include/uapi/linux/kvm.h struct kvm_pit_config { · line 174
Quoted 9 lines
include/uapi/linux/kvm.h +1
-0@@ -171,6 +171,7 @@ struct kvm_pit_config {#define KVM_EXIT_WATCHDOG 21#define KVM_EXIT_S390_TSCH 22#define KVM_EXIT_EPR 23 +#define KVM_EXIT_RESET 24I have to admit that I'm not particularly happy with the exit name. It's not obvious from the name under which circumstances it gets triggered. Does it get triggered when a core level reset happens? Does it get triggered when a system level reset happened? When the guest requests one?
The KVM_EXIT_RESET gets triggered when system level reset is initiated by VCPU. For arm/arm64, this is through SYSTEM_RESET PSCI call. In KVM x86 SVM/VMX, we have KVM_EXIT_SHUTDOWN being used for system shutdown which we have re-used for arm/arm64.
Quoted 10 lines
I know what it does, but I find the name too generic for what it is. What you're really doing is introduce a new communication channel in parallel to MMIO / PIO / HCALL which is only used for system level reset / shutdown today.
Can we treat it as such? Could you please make this a common exit number that's called something like
KVM_EXIT_SYSTEM_EVENTwith a parameter that can either be
TRIGGER_SHUTDOWNorTRIGGER_RESET.That way it's obvious what's going on and people don't get confused.
I don't foresee any system level operations other than SHUTDOWN and RESET to be handled from KVM in-kernel code but I might be wrong.
May be we can rename KVM_EXIT_SHUTDOWN and KVM_EXIT_RESET to KVM_EXIT_SYSTEM_SHUTDOWN and KVM_EXIT_SYSTEM_RESET ??
--
Anup
Quoted 9 lines
Alex
_______________________________________________
kvmarm mailing list
kvmarm at lists.cs.columbia.edu
https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm
PATCH 1/2 KVM: Add KVM_EXIT_RESET to user space API header
Quoted 29 lines · Anup Patel
Quoted 16 lines · Alexander Graf
Quoted 13 lines · Anup Patel
Currently, we don't have an exit reason for VM reset emulation in user space hence this patch adds exit reason
KVM_EXIT_RESETfor this purpose.This newly added
KVM_EXIT_RESETwill be used by KVM arm/arm64 in-kernel PSCI support to reset VMs.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>---
include/uapi/linux/kvm.h| 1 +1 file changed, 1 insertion(+)Quoted 11 lines
include/uapi/linux/kvm.h struct kvm_pit_config { · line 174
Quoted 9 lines
include/uapi/linux/kvm.h +1
-0@@ -171,6 +171,7 @@ struct kvm_pit_config {#define KVM_EXIT_WATCHDOG 21#define KVM_EXIT_S390_TSCH 22#define KVM_EXIT_EPR 23 +#define KVM_EXIT_RESET 24I have to admit that I'm not particularly happy with the exit name. It's not obvious from the name under which circumstances it gets triggered. Does it get triggered when a core level reset happens? Does it get triggered when a system level reset happened? When the guest requests one?
Quoted 4 lines
The
KVM_EXIT_RESETgets triggered when system level reset is initiated by VCPU. For arm/arm64, this is throughSYSTEM_RESETPSCI call. In KVM x86 SVM/VMX, we haveKVM_EXIT_SHUTDOWNbeing used for system shutdown which we have re-used for arm/arm64.
Yeah, that name already did mislead you once :).
KVM_EXIT_SHUTDOWN happens on
* triple fault
* CPU internal severe problems
the latter is defined as:
In contrast, an error that cannot be contained and is of such severity that it has compromised the continued operation of a processor core requires immediate action to terminate system processing and may result in a hardware-enforced shutdown. In the shutdown state, the execution of instructions by that processor core is halted. See Section 8.2.9 ?#DF?Double-Fault Exception (Vector 8)? on page 220 for a description of the shutdown processor state.
Triple faults are used commonly in 286 code to switch from PG to real mode. So they _have_ to be emulated as core reset. Otherwise you break old guests.
However, the scope of this exit is definitely vcpu wide. What you are looking for is a system wide notification. Commonly this happens through MMIO, but I can see why you wouldn't want that with PSCI interpreted in the kernel. That's why I asked you to create a completely new one to not add up the the confusion.
Quoted 8 lines
Quoted 8 lines
I know what it does, but I find the name too generic for what it is. What you're really doing is introduce a new communication channel in parallel to MMIO / PIO / HCALL which is only used for system level reset / shutdown today.
Can we treat it as such? Could you please make this a common exit number that's called something like
KVM_EXIT_SYSTEM_EVENT
Quoted 7 lines
Quoted 3 lines
with a parameter that can either be
TRIGGER_SHUTDOWNorTRIGGER_RESET.That way it's obvious what's going on and people don't get confused.
I don't foresee any system level operations other than SHUTDOWN and RESET to be handled from KVM in-kernel code but I might be wrong.
The good but about the EXIT_SYSTEM_EVENT is that it's immediately obvious that we're not talking about a vcpu local event. But I'm open to better names.
Quoted 2 lines
May be we can rename
KVM_EXIT_SHUTDOWNandKVM_EXIT_RESETtoKVM_EXIT_SYSTEM_SHUTDOWNandKVM_EXIT_SYSTEM_RESET??
You definitely can not rename KVM_EXIT_SHUTDOWN. It's part of the KVM API. In fact, I think it's a bad idea to even reuse the name as it clearly works on vcpu level.
Alex
PATCH 1/2 KVM: Add KVM_EXIT_RESET to user space API header
Quoted 44 lines · Alexander Graf
Quoted 29 lines · Anup Patel
Quoted 16 lines · Alexander Graf
Quoted 13 lines · Anup Patel
Currently, we don't have an exit reason for VM reset emulation in user space hence this patch adds exit reason
KVM_EXIT_RESETfor this purpose.This newly added
KVM_EXIT_RESETwill be used by KVM arm/arm64 in-kernel PSCI support to reset VMs.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>---
include/uapi/linux/kvm.h| 1 +1 file changed, 1 insertion(+)Quoted 11 lines
include/uapi/linux/kvm.h struct kvm_pit_config { · line 174
Quoted 9 lines
include/uapi/linux/kvm.h +1
-0@@ -171,6 +171,7 @@ struct kvm_pit_config {#define KVM_EXIT_WATCHDOG 21#define KVM_EXIT_S390_TSCH 22#define KVM_EXIT_EPR 23 +#define KVM_EXIT_RESET 24I have to admit that I'm not particularly happy with the exit name. It's not obvious from the name under which circumstances it gets triggered. Does it get triggered when a core level reset happens? Does it get triggered when a system level reset happened? When the guest requests one?
Quoted 4 lines
The
KVM_EXIT_RESETgets triggered when system level reset is initiated by VCPU. For arm/arm64, this is throughSYSTEM_RESETPSCI call. In KVM x86 SVM/VMX, we haveKVM_EXIT_SHUTDOWNbeing used for system shutdown which we have re-used for arm/arm64.Yeah, that name already did mislead you once :).
KVM_EXIT_SHUTDOWNhappens on* triple fault
* CPU internal severe problems
Quoted 7 lines
the latter is defined as:
In contrast, an error that cannot be contained and is of such severity that it has compromised the continued operation of a processor core requires immediate action to terminate system processing and may result in a hardware-enforced shutdown. In the shutdown state, the execution of instructions by that processor core is halted. See Section 8.2.9 ?#DF?Double-Fault Exception (Vector 8)? on page 220 for a description of the shutdown processor state.
Triple faults are used commonly in 286 code to switch from PG to real mode. So they _have_ to be emulated as core reset. Otherwise you break old guests.
However, the scope of this exit is definitely vcpu wide. What you are looking for is a system wide notification. Commonly this happens through MMIO, but I can see why you wouldn't want that with PSCI interpreted in the kernel. That's why I asked you to create a completely new one to not add up the the confusion.
Thanks for the info on the x86 part.
I think all this info should have been part of KVM api documentation for KVM_EXIT_SHUTDOWN.
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
I know what it does, but I find the name too generic for what it is. What you're really doing is introduce a new communication channel in parallel to MMIO / PIO / HCALL which is only used for system level reset / shutdown today.
Can we treat it as such? Could you please make this a common exit number that's called something like
KVM_EXIT_SYSTEM_EVENTQuoted 7 lines
Quoted 3 lines
with a parameter that can either be
TRIGGER_SHUTDOWNorTRIGGER_RESET.That way it's obvious what's going on and people don't get confused.
I don't foresee any system level operations other than SHUTDOWN and RESET to be handled from KVM in-kernel code but I might be wrong.
Quoted 6 lines
The good but about the
EXIT_SYSTEM_EVENTis that it's immediately obvious that we're not talking about a vcpu local event. But I'm open to better names.Quoted 2 lines
May be we can rename
KVM_EXIT_SHUTDOWNandKVM_EXIT_RESETtoKVM_EXIT_SYSTEM_SHUTDOWNandKVM_EXIT_SYSTEM_RESET??You definitely can not rename
KVM_EXIT_SHUTDOWN. It's part of the KVM API. In fact, I think it's a bad idea to even reuse the name as it clearly works on vcpu level.
Sure, it makes sense to avoid use of KVM_EXIT_SHUTDOWN in arm/arm64.
How about adding exit reasons KVM_EXIT_SYSTEM_RESET and KVM_EXIT_SYSTEM_SHUTDOWN ?
These exit reasons will be used for arm/arm64 but can also be used by other architectures if they want.
--
Anup
Quoted 4 lines
Alex
PATCH 1/2 KVM: Add KVM_EXIT_RESET to user space API header
Quoted 82 lines · Anup Patel
Quoted 44 lines · Alexander Graf
Quoted 29 lines · Anup Patel
Quoted 16 lines · Alexander Graf
Quoted 13 lines · Anup Patel
Currently, we don't have an exit reason for VM reset emulation in user space hence this patch adds exit reason
KVM_EXIT_RESETfor this purpose.This newly added
KVM_EXIT_RESETwill be used by KVM arm/arm64 in-kernel PSCI support to reset VMs.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>---
include/uapi/linux/kvm.h| 1 +1 file changed, 1 insertion(+)Quoted 11 lines
include/uapi/linux/kvm.h struct kvm_pit_config { · line 174
Quoted 9 lines
include/uapi/linux/kvm.h +1
-0@@ -171,6 +171,7 @@ struct kvm_pit_config {#define KVM_EXIT_WATCHDOG 21#define KVM_EXIT_S390_TSCH 22#define KVM_EXIT_EPR 23 +#define KVM_EXIT_RESET 24I have to admit that I'm not particularly happy with the exit name. It's not obvious from the name under which circumstances it gets triggered. Does it get triggered when a core level reset happens? Does it get triggered when a system level reset happened? When the guest requests one?
Quoted 4 lines
The
KVM_EXIT_RESETgets triggered when system level reset is initiated by VCPU. For arm/arm64, this is throughSYSTEM_RESETPSCI call. In KVM x86 SVM/VMX, we haveKVM_EXIT_SHUTDOWNbeing used for system shutdown which we have re-used for arm/arm64.Yeah, that name already did mislead you once :).
KVM_EXIT_SHUTDOWNhappens on* triple fault
* CPU internal severe problemsQuoted 7 lines
the latter is defined as:
In contrast, an error that cannot be contained and is of such severity that it has compromised the continued operation of a processor core requires immediate action to terminate system processing and may result in a hardware-enforced shutdown. In the shutdown state, the execution of instructions by that processor core is halted. See Section 8.2.9 ?#DF?Double-Fault Exception (Vector 8)? on page 220 for a description of the shutdown processor state.
Triple faults are used commonly in 286 code to switch from PG to real mode. So they _have_ to be emulated as core reset. Otherwise you break old guests.
However, the scope of this exit is definitely vcpu wide. What you are looking for is a system wide notification. Commonly this happens through MMIO, but I can see why you wouldn't want that with PSCI interpreted in the kernel. That's why I asked you to create a completely new one to not add up the the confusion.
Thanks for the info on the x86 part.
I think all this info should have been part of KVM api documentation for
KVM_EXIT_SHUTDOWN.Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
I know what it does, but I find the name too generic for what it is. What you're really doing is introduce a new communication channel in parallel to MMIO / PIO / HCALL which is only used for system level reset / shutdown today.
Can we treat it as such? Could you please make this a common exit number that's called something like
KVM_EXIT_SYSTEM_EVENTQuoted 7 lines
Quoted 3 lines
with a parameter that can either be
TRIGGER_SHUTDOWNorTRIGGER_RESET.That way it's obvious what's going on and people don't get confused.
I don't foresee any system level operations other than SHUTDOWN and RESET to be handled from KVM in-kernel code but I might be wrong.
Quoted 6 lines
The good but about the
EXIT_SYSTEM_EVENTis that it's immediately obvious that we're not talking about a vcpu local event. But I'm open to better names.Quoted 2 lines
May be we can rename
KVM_EXIT_SHUTDOWNandKVM_EXIT_RESETtoKVM_EXIT_SYSTEM_SHUTDOWNandKVM_EXIT_SYSTEM_RESET??You definitely can not rename
KVM_EXIT_SHUTDOWN. It's part of the KVM API. In fact, I think it's a bad idea to even reuse the name as it clearly works on vcpu level.
Quoted 8 lines
Sure, it makes sense to avoid use of
KVM_EXIT_SHUTDOWNin arm/arm64.How about adding exit reasons
KVM_EXIT_SYSTEM_RESETandKVM_EXIT_SYSTEM_SHUTDOWN?These exit reasons will be used for arm/arm64 but can also be used by other architectures if they want.
I don't think we'll be able to reuse anything for other archs. For hcall PPC for example, we want to keep the hcall number scheme as the same between guest <-> kvm and kvm <-> qemu. That makes the overall logic easier, as the hcall number space is already properly standardized.
Alex
PATCH 1/2 KVM: Add KVM_EXIT_RESET to user space API header
Quoted 88 lines · Alexander Graf
Quoted 85 lines · Anup Patel
Quoted 44 lines · Alexander Graf
Quoted 29 lines · Anup Patel
Quoted 16 lines · Alexander Graf
Quoted 13 lines · Anup Patel
Currently, we don't have an exit reason for VM reset emulation in user space hence this patch adds exit reason
KVM_EXIT_RESETfor this purpose.This newly added
KVM_EXIT_RESETwill be used by KVM arm/arm64 in-kernel PSCI support to reset VMs.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>---
include/uapi/linux/kvm.h| 1 +1 file changed, 1 insertion(+)Quoted 11 lines
include/uapi/linux/kvm.h struct kvm_pit_config { · line 174
Quoted 9 lines
include/uapi/linux/kvm.h +1
-0@@ -171,6 +171,7 @@ struct kvm_pit_config {#define KVM_EXIT_WATCHDOG 21#define KVM_EXIT_S390_TSCH 22#define KVM_EXIT_EPR 23 +#define KVM_EXIT_RESET 24I have to admit that I'm not particularly happy with the exit name. It's not obvious from the name under which circumstances it gets triggered. Does it get triggered when a core level reset happens? Does it get triggered when a system level reset happened? When the guest requests one?
Quoted 4 lines
The
KVM_EXIT_RESETgets triggered when system level reset is initiated by VCPU. For arm/arm64, this is throughSYSTEM_RESETPSCI call. In KVM x86 SVM/VMX, we haveKVM_EXIT_SHUTDOWNbeing used for system shutdown which we have re-used for arm/arm64.Yeah, that name already did mislead you once :).
KVM_EXIT_SHUTDOWNhappens on* triple fault
* CPU internal severe problemsQuoted 7 lines
the latter is defined as:
In contrast, an error that cannot be contained and is of such severity that it has compromised the continued operation of a processor core requires immediate action to terminate system processing and may result in a hardware-enforced shutdown. In the shutdown state, the execution of instructions by that processor core is halted. See Section 8.2.9 ?#DF?Double-Fault Exception (Vector 8)? on page 220 for a description of the shutdown processor state.
Triple faults are used commonly in 286 code to switch from PG to real mode. So they _have_ to be emulated as core reset. Otherwise you break old guests.
However, the scope of this exit is definitely vcpu wide. What you are looking for is a system wide notification. Commonly this happens through MMIO, but I can see why you wouldn't want that with PSCI interpreted in the kernel. That's why I asked you to create a completely new one to not add up the the confusion.
Thanks for the info on the x86 part.
I think all this info should have been part of KVM api documentation for
KVM_EXIT_SHUTDOWN.Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
I know what it does, but I find the name too generic for what it is. What you're really doing is introduce a new communication channel in parallel to MMIO / PIO / HCALL which is only used for system level reset / shutdown today.
Can we treat it as such? Could you please make this a common exit number that's called something like
KVM_EXIT_SYSTEM_EVENTQuoted 7 lines
Quoted 3 lines
with a parameter that can either be
TRIGGER_SHUTDOWNorTRIGGER_RESET.That way it's obvious what's going on and people don't get confused.
I don't foresee any system level operations other than SHUTDOWN and RESET to be handled from KVM in-kernel code but I might be wrong.
Quoted 6 lines
The good but about the
EXIT_SYSTEM_EVENTis that it's immediately obvious that we're not talking about a vcpu local event. But I'm open to better names.Quoted 2 lines
May be we can rename
KVM_EXIT_SHUTDOWNandKVM_EXIT_RESETtoKVM_EXIT_SYSTEM_SHUTDOWNandKVM_EXIT_SYSTEM_RESET??You definitely can not rename
KVM_EXIT_SHUTDOWN. It's part of the KVM API. In fact, I think it's a bad idea to even reuse the name as it clearly works on vcpu level.Sure, it makes sense to avoid use of
KVM_EXIT_SHUTDOWNin arm/arm64.
Quoted 9 lines
Quoted 5 lines
How about adding exit reasons
KVM_EXIT_SYSTEM_RESETandKVM_EXIT_SYSTEM_SHUTDOWN?These exit reasons will be used for arm/arm64 but can also be used by other architectures if they want.
I don't think we'll be able to reuse anything for other archs. For hcall PPC for example, we want to keep the hcall number scheme as the same between guest <-> kvm and kvm <-> qemu. That makes the overall logic easier, as the hcall number space is already properly standardized.
It should also make the first switch in userspace on the exit reason easier, as the same code is likely to handle all sorts of system events.
-Christoffer
PATCH 1/2 KVM: Add KVM_EXIT_RESET to user space API header
In reply to Alexander GrafQuoted 44 lines · Alexander Graf
Quoted 29 lines · Anup Patel
Quoted 16 lines · Alexander Graf
Quoted 13 lines · Anup Patel
Currently, we don't have an exit reason for VM reset emulation in user space hence this patch adds exit reason
KVM_EXIT_RESETfor this purpose.This newly added
KVM_EXIT_RESETwill be used by KVM arm/arm64 in-kernel PSCI support to reset VMs.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>---
include/uapi/linux/kvm.h| 1 +1 file changed, 1 insertion(+)Quoted 11 lines
include/uapi/linux/kvm.h struct kvm_pit_config { · line 174
Quoted 9 lines
include/uapi/linux/kvm.h +1
-0@@ -171,6 +171,7 @@ struct kvm_pit_config {#define KVM_EXIT_WATCHDOG 21#define KVM_EXIT_S390_TSCH 22#define KVM_EXIT_EPR 23 +#define KVM_EXIT_RESET 24I have to admit that I'm not particularly happy with the exit name. It's not obvious from the name under which circumstances it gets triggered. Does it get triggered when a core level reset happens? Does it get triggered when a system level reset happened? When the guest requests one?
Quoted 4 lines
The
KVM_EXIT_RESETgets triggered when system level reset is initiated by VCPU. For arm/arm64, this is throughSYSTEM_RESETPSCI call. In KVM x86 SVM/VMX, we haveKVM_EXIT_SHUTDOWNbeing used for system shutdown which we have re-used for arm/arm64.Yeah, that name already did mislead you once :).
KVM_EXIT_SHUTDOWNhappens on* triple fault
* CPU internal severe problems
Quoted 8 lines
the latter is defined as:
In contrast, an error that cannot be contained and is of such severity that it has compromised the continued operation of a processor core requires immediate action to terminate system processing and may result in a hardware-enforced shutdown. In the shutdown state, the execution of instructions by that processor core is halted. See Section 8.2.9 ?#DF?Double-Fault Exception (Vector 8)? on page 220 for a description of the shutdown processor state.
Triple faults are used commonly in 286 code to switch from PG to real mode. So they _have_ to be emulated as core reset. Otherwise you break old guests.
However, the scope of this exit is definitely vcpu wide. What you are looking for is a system wide notification. Commonly this happens through MMIO, but I can see why you wouldn't want that with PSCI interpreted in the kernel. That's why I asked you to create a completely new one to not add up the the confusion.
Did you grab this documentation from somewhere that I can't find with grep, or did you just come up with it?
Shouldn't we have all exit reasons documented inDocumentation/virtual/kvm/... ?
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
I know what it does, but I find the name too generic for what it is. What you're really doing is introduce a new communication channel in parallel to MMIO / PIO / HCALL which is only used for system level reset / shutdown today.
Can we treat it as such? Could you please make this a common exit number that's called something like
KVM_EXIT_SYSTEM_EVENTQuoted 7 lines
Quoted 3 lines
with a parameter that can either be
TRIGGER_SHUTDOWNorTRIGGER_RESET.That way it's obvious what's going on and people don't get confused.
I don't foresee any system level operations other than SHUTDOWN and RESET to be handled from KVM in-kernel code but I might be wrong.
Quoted 8 lines
The good but about the
EXIT_SYSTEM_EVENTis that it's immediately obvious that we're not talking about a vcpu local event. But I'm open to better names.Quoted 2 lines
May be we can rename
KVM_EXIT_SHUTDOWNandKVM_EXIT_RESETtoKVM_EXIT_SYSTEM_SHUTDOWNandKVM_EXIT_SYSTEM_RESET??You definitely can not rename
KVM_EXIT_SHUTDOWN. It's part of the KVM API. In fact, I think it's a bad idea to even reuse the name as it clearly works on vcpu level.
-Christoffer
PATCH 1/2 KVM: Add KVM_EXIT_RESET to user space API header
Quoted 49 lines · Christoffer Dall
Quoted 48 lines · Alexander Graf
Quoted 29 lines · Anup Patel
Quoted 16 lines · Alexander Graf
Quoted 13 lines · Anup Patel
Currently, we don't have an exit reason for VM reset emulation in user space hence this patch adds exit reason
KVM_EXIT_RESETfor this purpose.This newly added
KVM_EXIT_RESETwill be used by KVM arm/arm64 in-kernel PSCI support to reset VMs.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>---
include/uapi/linux/kvm.h| 1 +1 file changed, 1 insertion(+)Quoted 11 lines
include/uapi/linux/kvm.h struct kvm_pit_config { · line 174
Quoted 9 lines
include/uapi/linux/kvm.h +1
-0@@ -171,6 +171,7 @@ struct kvm_pit_config {#define KVM_EXIT_WATCHDOG 21#define KVM_EXIT_S390_TSCH 22#define KVM_EXIT_EPR 23 +#define KVM_EXIT_RESET 24I have to admit that I'm not particularly happy with the exit name. It's not obvious from the name under which circumstances it gets triggered. Does it get triggered when a core level reset happens? Does it get triggered when a system level reset happened? When the guest requests one?
Quoted 4 lines
The
KVM_EXIT_RESETgets triggered when system level reset is initiated by VCPU. For arm/arm64, this is throughSYSTEM_RESETPSCI call. In KVM x86 SVM/VMX, we haveKVM_EXIT_SHUTDOWNbeing used for system shutdown which we have re-used for arm/arm64.Yeah, that name already did mislead you once :).
KVM_EXIT_SHUTDOWNhappens on* triple fault
* CPU internal severe problemsthe latter is defined as:
In contrast, an error that cannot be contained and is of such severity that it has compromised the continued operation of a processor core requires immediate action to terminate system processing and may result in a hardware-enforced shutdown. In the shutdown state, the execution of instructions by that processor core is halted. See Section 8.2.9 ?#DF?Double-Fault Exception (Vector 8)? on page 220 for a description of the shutdown processor state.
Quoted 7 lines
Quoted 4 lines
Triple faults are used commonly in 286 code to switch from PG to real mode. So they _have_ to be emulated as core reset. Otherwise you break old guests.
However, the scope of this exit is definitely vcpu wide. What you are looking for is a system wide notification. Commonly this happens through MMIO, but I can see why you wouldn't want that with PSCI interpreted in the kernel. That's why I asked you to create a completely new one to not add up the the confusion.
Did you grab this documentation from somewhere that I can't find with grep, or did you just come up with it?
That was from the AMD64 architecture reference manual :).
Quoted 2 lines
Shouldn't we have all exit reasons documented in
Documentation/virtual/kvm/... ?
Yes, that would be great. The only reason I knew something was fishy was that there's no way for a guest to trigger a non-MMIO/PIO/HCALL event that would end up in a genuine shutdown request ;).
Alex
PATCH 1/2 KVM: Add KVM_EXIT_RESET to user space API header
In reply to Alexander GrafQuoted 30 lines · Alexander Graf
Quoted 18 lines · Anup Patel
Currently, we don't have an exit reason for VM reset emulation in user space hence this patch adds exit reason
KVM_EXIT_RESETfor this purpose.This newly added
KVM_EXIT_RESETwill be used by KVM arm/arm64 in-kernel PSCI support to reset VMs.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>---
include/uapi/linux/kvm.h| 1 +1 file changed, 1 insertion(+)include/uapi/linux/kvm.h +0
-0include/uapi/linux/kvm.h struct kvm_pit_config { · line 174
Quoted 4 lines
include/uapi/linux/kvm.h +1
-0@@ -171,6 +171,7 @@ struct kvm_pit_config {#define KVM_EXIT_WATCHDOG 21#define KVM_EXIT_S390_TSCH 22#define KVM_EXIT_EPR 23 +#define KVM_EXIT_RESET 24I have to admit that I'm not particularly happy with the exit name. It's not obvious from the name under which circumstances it gets triggered. Does it get triggered when a core level reset happens? Does it get triggered when a system level reset happened? When the guest requests one?
I know what it does, but I find the name too generic for what it is. What you're really doing is introduce a new communication channel in parallel to MMIO / PIO / HCALL which is only used for system level reset / shutdown today.
Quoted 8 lines
Can we treat it as such? Could you please make this a common exit number that's called something like
KVM_EXIT_SYSTEM_EVENTwith a parameter that can either be
TRIGGER_SHUTDOWNorTRIGGER_RESET.That way it's obvious what's going on and people don't get confused.
I didn't realize what the KVM_EXIT_SHUTDOWN really was, thanks for explaining that. In that case, the SYSTEM_EVENT sounds good to me.
How do you propose the parameter gets passed? As a new struct to the untion in kvm_run ?
-Christoffer
PATCH 1/2 KVM: Add KVM_EXIT_RESET to user space API header
Quoted 37 lines · Christoffer Dall
Quoted 36 lines · Alexander Graf
Quoted 18 lines · Anup Patel
Currently, we don't have an exit reason for VM reset emulation in user space hence this patch adds exit reason
KVM_EXIT_RESETfor this purpose.This newly added
KVM_EXIT_RESETwill be used by KVM arm/arm64 in-kernel PSCI support to reset VMs.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>---
include/uapi/linux/kvm.h| 1 +1 file changed, 1 insertion(+)include/uapi/linux/kvm.h +0
-0include/uapi/linux/kvm.h struct kvm_pit_config { · line 174
Quoted 4 lines
include/uapi/linux/kvm.h +1
-0@@ -171,6 +171,7 @@ struct kvm_pit_config {#define KVM_EXIT_WATCHDOG 21#define KVM_EXIT_S390_TSCH 22#define KVM_EXIT_EPR 23 +#define KVM_EXIT_RESET 24I have to admit that I'm not particularly happy with the exit name. It's not obvious from the name under which circumstances it gets triggered. Does it get triggered when a core level reset happens? Does it get triggered when a system level reset happened? When the guest requests one?
I know what it does, but I find the name too generic for what it is. What you're really doing is introduce a new communication channel in parallel to MMIO / PIO / HCALL which is only used for system level reset / shutdown today.
Can we treat it as such? Could you please make this a common exit number that's called something like
KVM_EXIT_SYSTEM_EVENTwith a parameter that can either be
TRIGGER_SHUTDOWNorTRIGGER_RESET.
Quoted 7 lines
Quoted 2 lines
That way it's obvious what's going on and people don't get confused.
I didn't realize what the
KVM_EXIT_SHUTDOWNreally was, thanks for explaining that. In that case, theSYSTEM_EVENTsounds good to me.How do you propose the parameter gets passed? As a new struct to the untion in
kvm_run?
Yup, that's how we usually pass information along with an exit reason. Make sure to add a flags field so it can be extended if we need to pass in more later for future unknown events. PPC for example has fun system wide hypercalls like "enable little endian mode on all virtual cpus". I don't even want to start imagining what people will come up with next.
Alex
PATCH 1/2 KVM: Add KVM_EXIT_RESET to user space API header
Quoted 42 lines · Alexander Graf
Quoted 39 lines · Christoffer Dall
Quoted 38 lines · Alexander Graf
Quoted 18 lines · Anup Patel
Currently, we don't have an exit reason for VM reset emulation in user space hence this patch adds exit reason
KVM_EXIT_RESETfor this purpose.This newly added
KVM_EXIT_RESETwill be used by KVM arm/arm64 in-kernel PSCI support to reset VMs.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>---
include/uapi/linux/kvm.h| 1 +1 file changed, 1 insertion(+)include/uapi/linux/kvm.h +0
-0include/uapi/linux/kvm.h struct kvm_pit_config { · line 174
Quoted 4 lines
include/uapi/linux/kvm.h +1
-0@@ -171,6 +171,7 @@ struct kvm_pit_config {#define KVM_EXIT_WATCHDOG 21#define KVM_EXIT_S390_TSCH 22#define KVM_EXIT_EPR 23 +#define KVM_EXIT_RESET 24I have to admit that I'm not particularly happy with the exit name. It's not obvious from the name under which circumstances it gets triggered. Does it get triggered when a core level reset happens? Does it get triggered when a system level reset happened? When the guest requests one?
I know what it does, but I find the name too generic for what it is. What you're really doing is introduce a new communication channel in parallel to MMIO / PIO / HCALL which is only used for system level reset / shutdown today.
Can we treat it as such? Could you please make this a common exit number that's called something like
KVM_EXIT_SYSTEM_EVENTwith a parameter that can either be
TRIGGER_SHUTDOWNorTRIGGER_RESET.That way it's obvious what's going on and people don't get confused.
Quoted 7 lines
Quoted 5 lines
I didn't realize what the
KVM_EXIT_SHUTDOWNreally was, thanks for explaining that. In that case, theSYSTEM_EVENTsounds good to me.How do you propose the parameter gets passed? As a new struct to the untion in
kvm_run?Yup, that's how we usually pass information along with an exit reason. Make sure to add a flags field so it can be extended if we need to pass in more later for future unknown events. PPC for example has fun system wide hypercalls like "enable little endian mode on all virtual cpus". I don't even want to start imagining what people will come up with next.
Sure, I will add KVM_EXIT_SYSTEM_EVENT exit reason and related documentation.
--
Anup
Quoted 9 lines
Alex
_______________________________________________
kvmarm mailing list
kvmarm at lists.cs.columbia.edu
https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm
PATCH 2/2 ARM/ARM64: KVM: Forward PSCI SYSTEM_OFF and SYSTEM_RESET to user space
In reply to Anup PatelThe PSCI SYSTEM_OFF and SYSTEM_RESET functions are system-level functions hence cannot be fully emulated by the in-kernel PSCI emulation code.
To tackle this, we forward PSCI SYSTEM_OFF and SYSTEM_RESET function calls from guest to user space (i.e. QEMU or KVMTOOL) via KVM run structure using KVM_EXIT_SHUTDOWN and KVM_EXIT_RESET exit reasons.
--- arch/arm/include/asm/kvm_psci.h | 2 +- arch/arm/include/uapi/asm/kvm.h | 2 ++ arch/arm/kvm/handle_exit.c | 7 ++++++- arch/arm/kvm/psci.c | 38 +++++++++++++++++++++++++++++-------- arch/arm64/include/asm/kvm_psci.h | 2 +- arch/arm64/include/uapi/asm/kvm.h | 2 ++ arch/arm64/kvm/handle_exit.c | 10 ++++++---- 7 files changed, 48 insertions(+), 15 deletions(-)
arch/arm/include/asm/kvm_psci.h +1 -1
@@ -18,6 +18,6 @@#ifndef __ARM_KVM_PSCI_H__#define __ARM_KVM_PSCI_H__ -bool kvm_psci_call (struct kvm_vcpu *vcpu); +int kvm_psci_call (struct kvm_vcpu *vcpu);#endif /* __ARM_KVM_PSCI_H__ */
arch/arm/include/uapi/asm/kvm.h +2 -0
@@ -172,6 +172,8 @@ struct kvm_arch_memory_slot {#define KVM_PSCI_FN_CPU_OFF KVM_PSCI_FN(1)#define KVM_PSCI_FN_CPU_ON KVM_PSCI_FN(2)#define KVM_PSCI_FN_MIGRATE KVM_PSCI_FN(3) +#define KVM_PSCI_FN_SYSTEM_OFF KVM_PSCI_FN(4) +#define KVM_PSCI_FN_SYSTEM_RESET KVM_PSCI_FN(5)#define KVM_PSCI_RET_SUCCESS 0#define KVM_PSCI_RET_NI ((unsigned long)-1)
arch/arm/kvm/handle_exit.c +6 -1
@@ -40,11 +40,16 @@ static int handle_svc_hyp(struct kvm_vcpu *vcpu, struct kvm_run *run)static int handle_hvc (struct kvm_vcpu *vcpu,struct kvm_run *run) { +int ret; +trace_kvm_hvc (*vcpu_pc (vcpu), *vcpu_reg (vcpu,0 ),kvm_vcpu_hvc_get_imm (vcpu)); -if (kvm_psci_call (vcpu)) + ret =kvm_psci_call (vcpu); +if (ret ==0 )return 1 ; +else if (ret >0 ) +return 0 ;kvm_inject_undefined (vcpu);return 1 ;
arch/arm/kvm/psci.c +30 -8
@@ -84,18 +84,31 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)return KVM_PSCI_RET_SUCCESS ; } +static void kvm_psci_system_off (struct kvm_vcpu *vcpu) +{ + vcpu->run->exit_reason =KVM_EXIT_SHUTDOWN ; +} + +static void kvm_psci_system_reset (struct kvm_vcpu *vcpu) +{ + vcpu->run->exit_reason =KVM_EXIT_RESET ; +} +/** * kvm_psci_call - handle PSCI call if r0 value is in range * @vcpu: Pointer to the VCPU struct * * Handle PSCI calls from guests through traps from HVC instructions. -* The calling convention is similar to SMC calls to the secure world where -* the function number is placed in r0 and this function returns true if the -* function number specified in r0 is withing the PSCI range, and false -* otherwise. +* The calling convention is similar to SMC calls to the secure world +* where the function number is placed in r0 and function number +* specified in r0 is withing the PSCI range. +* +* This function returns: 0 (success), > 0 (success but exit to user +* space), and < 0 (failure) */ -bool kvm_psci_call (struct kvm_vcpu *vcpu) +int kvm_psci_call (struct kvm_vcpu *vcpu) { +int ret =0 ;unsigned long psci_fn = *vcpu_reg (vcpu,0 ) & ~((u32 )0 );unsigned long val;
@@ -111,11 +124,20 @@ bool kvm_psci_call(struct kvm_vcpu *vcpu)case KVM_PSCI_FN_MIGRATE : val =KVM_PSCI_RET_NI ;break ; - +case KVM_PSCI_FN_SYSTEM_OFF : +kvm_psci_system_off (vcpu); + val =KVM_PSCI_RET_SUCCESS ; + ret =1 ; +break ; +case KVM_PSCI_FN_SYSTEM_RESET : +kvm_psci_system_reset (vcpu); + val =KVM_PSCI_RET_SUCCESS ; + ret =1 ; +break ;default : -return false; +return -EINVAL ; } *vcpu_reg (vcpu,0 ) = val; -return true; +return ret; }
arch/arm64/include/asm/kvm_psci.h +1 -1
@@ -18,6 +18,6 @@#ifndef __ARM64_KVM_PSCI_H__#define __ARM64_KVM_PSCI_H__ -bool kvm_psci_call (struct kvm_vcpu *vcpu); +int kvm_psci_call (struct kvm_vcpu *vcpu);#endif /* __ARM64_KVM_PSCI_H__ */
arch/arm64/include/uapi/asm/kvm.h +2 -0
@@ -158,6 +158,8 @@ struct kvm_arch_memory_slot {#define KVM_PSCI_FN_CPU_OFF KVM_PSCI_FN(1)#define KVM_PSCI_FN_CPU_ON KVM_PSCI_FN(2)#define KVM_PSCI_FN_MIGRATE KVM_PSCI_FN(3) +#define KVM_PSCI_FN_SYSTEM_OFF KVM_PSCI_FN(4) +#define KVM_PSCI_FN_SYSTEM_RESET KVM_PSCI_FN(5)#define KVM_PSCI_RET_SUCCESS 0#define KVM_PSCI_RET_NI ((unsigned long)-1)
arch/arm64/kvm/handle_exit.c +6 -4
@@ -30,8 +30,13 @@ typedef int (*exit_handle_fn)(struct kvm_vcpu *, struct kvm_run *);static int handle_hvc (struct kvm_vcpu *vcpu,struct kvm_run *run) { -if (kvm_psci_call (vcpu)) +int ret; + + ret =kvm_psci_call (vcpu); +if (ret ==0 )return 1 ; +else if (ret >0 ) +return 0 ;kvm_inject_undefined (vcpu);return 1 ;
@@ -39,9 +44,6 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run)static int handle_smc (struct kvm_vcpu *vcpu,struct kvm_run *run) { -if (kvm_psci_call (vcpu)) -return 1 ; -kvm_inject_undefined (vcpu);return 1 ; }
Signature · 1 line
1.7.9.5
PATCH 2/2 ARM/ARM64: KVM: Forward PSCI SYSTEM_OFF and SYSTEM_RESET to user space
(Adding Christoffer, forgot to add him to CC)
Quoted 193 lines · Anup Patel
The PSCI
SYSTEM_OFFandSYSTEM_RESETfunctions are system-level functions hence cannot be fully emulated by the in-kernel PSCI emulation code.To tackle this, we forward PSCI
SYSTEM_OFFandSYSTEM_RESETfunction calls from guest to user space (i.e. QEMU or KVMTOOL) via KVM run structure usingKVM_EXIT_SHUTDOWNandKVM_EXIT_RESETexit reasons.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>--- arch/arm/include/asm/kvm_psci.h | 2 +- arch/arm/include/uapi/asm/kvm.h | 2 ++ arch/arm/kvm/handle_exit.c | 7 ++++++- arch/arm/kvm/psci.c | 38 +++++++++++++++++++++++++++++-------- arch/arm64/include/asm/kvm_psci.h | 2 +- arch/arm64/include/uapi/asm/kvm.h | 2 ++ arch/arm64/kvm/handle_exit.c | 10 ++++++---- 7 files changed, 48 insertions(+), 15 deletions(-)arch/arm/include/asm/kvm_psci.h +1
-1@@ -18,6 +18,6 @@#ifndef __ARM_KVM_PSCI_H__#define __ARM_KVM_PSCI_H__ -bool kvm_psci_call (struct kvm_vcpu *vcpu); +int kvm_psci_call (struct kvm_vcpu *vcpu);#endif /* __ARM_KVM_PSCI_H__ */ arch/arm/include/uapi/asm/kvm.h +2
-0@@ -172,6 +172,8 @@ struct kvm_arch_memory_slot {#define KVM_PSCI_FN_CPU_OFF KVM_PSCI_FN(1)#define KVM_PSCI_FN_CPU_ON KVM_PSCI_FN(2)#define KVM_PSCI_FN_MIGRATE KVM_PSCI_FN(3) +#define KVM_PSCI_FN_SYSTEM_OFF KVM_PSCI_FN(4) +#define KVM_PSCI_FN_SYSTEM_RESET KVM_PSCI_FN(5)#define KVM_PSCI_RET_SUCCESS 0#define KVM_PSCI_RET_NI ((unsigned long)-1)arch/arm/kvm/handle_exit.c +6
-1@@ -40,11 +40,16 @@ static int handle_svc_hyp(struct kvm_vcpu *vcpu, struct kvm_run *run)static int handle_hvc (struct kvm_vcpu *vcpu,struct kvm_run *run) { +int ret; +trace_kvm_hvc (*vcpu_pc (vcpu), *vcpu_reg (vcpu,0 ),kvm_vcpu_hvc_get_imm (vcpu)); -if (kvm_psci_call (vcpu)) + ret =kvm_psci_call (vcpu); +if (ret ==0 )return 1 ; +else if (ret >0 ) +return 0 ;kvm_inject_undefined (vcpu);return 1 ;arch/arm/kvm/psci.c +30
-8@@ -84,18 +84,31 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)return KVM_PSCI_RET_SUCCESS ; } +static void kvm_psci_system_off (struct kvm_vcpu *vcpu) +{ + vcpu->run->exit_reason =KVM_EXIT_SHUTDOWN ; +} + +static void kvm_psci_system_reset (struct kvm_vcpu *vcpu) +{ + vcpu->run->exit_reason =KVM_EXIT_RESET ; +} +/** * kvm_psci_call - handle PSCI call if r0 value is in range * @vcpu: Pointer to the VCPU struct * * Handle PSCI calls from guests through traps from HVC instructions. -* The calling convention is similar to SMC calls to the secure world where -* the function number is placed in r0 and this function returns true if the -* function number specified in r0 is withing the PSCI range, and false -* otherwise. +* The calling convention is similar to SMC calls to the secure world +* where the function number is placed in r0 and function number +* specified in r0 is withing the PSCI range. +* +* This function returns: 0 (success), > 0 (success but exit to user +* space), and < 0 (failure) */ -bool kvm_psci_call (struct kvm_vcpu *vcpu) +int kvm_psci_call (struct kvm_vcpu *vcpu) { +int ret =0 ;unsigned long psci_fn = *vcpu_reg (vcpu,0 ) & ~((u32 )0 );unsigned long val;@@ -111,11 +124,20 @@ bool kvm_psci_call(struct kvm_vcpu *vcpu)case KVM_PSCI_FN_MIGRATE : val =KVM_PSCI_RET_NI ;break ; - +case KVM_PSCI_FN_SYSTEM_OFF : +kvm_psci_system_off (vcpu); + val =KVM_PSCI_RET_SUCCESS ; + ret =1 ; +break ; +case KVM_PSCI_FN_SYSTEM_RESET : +kvm_psci_system_reset (vcpu); + val =KVM_PSCI_RET_SUCCESS ; + ret =1 ; +break ;default : -return false; +return -EINVAL ; } *vcpu_reg (vcpu,0 ) = val; -return true; +return ret; }arch/arm64/include/asm/kvm_psci.h +1
-1@@ -18,6 +18,6 @@#ifndef __ARM64_KVM_PSCI_H__#define __ARM64_KVM_PSCI_H__ -bool kvm_psci_call (struct kvm_vcpu *vcpu); +int kvm_psci_call (struct kvm_vcpu *vcpu);#endif /* __ARM64_KVM_PSCI_H__ */ arch/arm64/include/uapi/asm/kvm.h +2
-0@@ -158,6 +158,8 @@ struct kvm_arch_memory_slot {#define KVM_PSCI_FN_CPU_OFF KVM_PSCI_FN(1)#define KVM_PSCI_FN_CPU_ON KVM_PSCI_FN(2)#define KVM_PSCI_FN_MIGRATE KVM_PSCI_FN(3) +#define KVM_PSCI_FN_SYSTEM_OFF KVM_PSCI_FN(4) +#define KVM_PSCI_FN_SYSTEM_RESET KVM_PSCI_FN(5)#define KVM_PSCI_RET_SUCCESS 0#define KVM_PSCI_RET_NI ((unsigned long)-1)arch/arm64/kvm/handle_exit.c +6
-5@@ -30,8 +30,13 @@ typedef int (*exit_handle_fn)(struct kvm_vcpu *, struct kvm_run *);static int handle_hvc (struct kvm_vcpu *vcpu,struct kvm_run *run) { -if (kvm_psci_call (vcpu)) +int ret; + + ret =kvm_psci_call (vcpu); +if (ret ==0 )return 1 ; +else if (ret >0 ) +return 0 ;kvm_inject_undefined (vcpu);return 1 ;@@ -39,9 +44,6 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run)static int handle_smc (struct kvm_vcpu *vcpu,struct kvm_run *run) { -if (kvm_psci_call (vcpu)) -return 1 ; -kvm_inject_undefined (vcpu);return 1 ; } --1.7.9.5
_______________________________________________
kvmarm mailing list
kvmarm at lists.cs.columbia.edu
https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm
PATCH 2/2 ARM/ARM64: KVM: Forward PSCI SYSTEM_OFF and SYSTEM_RESET to user space
In reply to Anup PatelQuoted 90 lines · Anup Patel
The PSCI
SYSTEM_OFFandSYSTEM_RESETfunctions are system-level functions hence cannot be fully emulated by the in-kernel PSCI emulation code.To tackle this, we forward PSCI
SYSTEM_OFFandSYSTEM_RESETfunction calls from guest to user space (i.e. QEMU or KVMTOOL) via KVM run structure usingKVM_EXIT_SHUTDOWNandKVM_EXIT_RESETexit reasons.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>--- arch/arm/include/asm/kvm_psci.h | 2 +- arch/arm/include/uapi/asm/kvm.h | 2 ++ arch/arm/kvm/handle_exit.c | 7 ++++++- arch/arm/kvm/psci.c | 38 +++++++++++++++++++++++++++++-------- arch/arm64/include/asm/kvm_psci.h | 2 +- arch/arm64/include/uapi/asm/kvm.h | 2 ++ arch/arm64/kvm/handle_exit.c | 10 ++++++---- 7 files changed, 48 insertions(+), 15 deletions(-)arch/arm/include/asm/kvm_psci.h +1
-1@@ -18,6 +18,6 @@#ifndef __ARM_KVM_PSCI_H__#define __ARM_KVM_PSCI_H__ -bool kvm_psci_call (struct kvm_vcpu *vcpu); +int kvm_psci_call (struct kvm_vcpu *vcpu);#endif /* __ARM_KVM_PSCI_H__ */ arch/arm/include/uapi/asm/kvm.h +2
-0@@ -172,6 +172,8 @@ struct kvm_arch_memory_slot {#define KVM_PSCI_FN_CPU_OFF KVM_PSCI_FN(1)#define KVM_PSCI_FN_CPU_ON KVM_PSCI_FN(2)#define KVM_PSCI_FN_MIGRATE KVM_PSCI_FN(3) +#define KVM_PSCI_FN_SYSTEM_OFF KVM_PSCI_FN(4) +#define KVM_PSCI_FN_SYSTEM_RESET KVM_PSCI_FN(5)#define KVM_PSCI_RET_SUCCESS 0#define KVM_PSCI_RET_NI ((unsigned long)-1)arch/arm/kvm/handle_exit.c +6
-1@@ -40,11 +40,16 @@ static int handle_svc_hyp(struct kvm_vcpu *vcpu, struct kvm_run *run)static int handle_hvc (struct kvm_vcpu *vcpu,struct kvm_run *run) { +int ret; +trace_kvm_hvc (*vcpu_pc (vcpu), *vcpu_reg (vcpu,0 ),kvm_vcpu_hvc_get_imm (vcpu)); -if (kvm_psci_call (vcpu)) + ret =kvm_psci_call (vcpu); +if (ret ==0 )return 1 ; +else if (ret >0 ) +return 0 ;kvm_inject_undefined (vcpu);return 1 ;arch/arm/kvm/psci.c +10
-0@@ -84,18 +84,31 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)return KVM_PSCI_RET_SUCCESS ; } +static void kvm_psci_system_off (struct kvm_vcpu *vcpu) +{ + vcpu->run->exit_reason =KVM_EXIT_SHUTDOWN ; +} + +static void kvm_psci_system_reset (struct kvm_vcpu *vcpu) +{ + vcpu->run->exit_reason =KVM_EXIT_RESET ; +} +/** * kvm_psci_call - handle PSCI call if r0 value is in range * @vcpu: Pointer to the VCPU struct * * Handle PSCI calls from guests through traps from HVC instructions.
arch/arm/kvm/psci.c static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) · line 107
Quoted 10 lines
arch/arm/kvm/psci.c +6
-4-* The calling convention is similar to SMC calls to the secure world where -* the function number is placed in r0 and this function returns true if the -* function number specified in r0 is withing the PSCI range, and false -* otherwise. +* The calling convention is similar to SMC calls to the secure world +* where the function number is placed in r0 and function number +* specified in r0 is withing the PSCI range. +* +* This function returns: 0 (success), > 0 (success but exit to user +* space), and < 0 (failure)
Hmmm, I think this is a bit confusing because it essentially does the reverse of all the other kvm internal return convention. Wouldn't it make more sense to have 0 (success, but exit to user space), 1 (success, resume VM), and < 0 (failure).
Also note that you are general-casing all error codes that may happen to mean that it did not match the PSCI function to anything well-known. In this case, that's sort of ok, because we don't expect the PSCI code to randomly fail (if it does, it reports it to the caller in the return register), but not fail, as in, I'm out of memory or anything like that. But I think you can clarify this in the comment, by saying something like:
Errors:
-EINVAL: Unrecognized PSCI function
in the comment for the function.
Quoted 77 lines
arch/arm/kvm/psci.c +14
-4*/ -bool kvm_psci_call (struct kvm_vcpu *vcpu) +int kvm_psci_call (struct kvm_vcpu *vcpu) { +int ret =0 ;unsigned long psci_fn = *vcpu_reg (vcpu,0 ) & ~((u32 )0 );unsigned long val;@@ -111,11 +124,20 @@ bool kvm_psci_call(struct kvm_vcpu *vcpu)case KVM_PSCI_FN_MIGRATE : val =KVM_PSCI_RET_NI ;break ; - +case KVM_PSCI_FN_SYSTEM_OFF : +kvm_psci_system_off (vcpu); + val =KVM_PSCI_RET_SUCCESS ; + ret =1 ; +break ; +case KVM_PSCI_FN_SYSTEM_RESET : +kvm_psci_system_reset (vcpu); + val =KVM_PSCI_RET_SUCCESS ; + ret =1 ; +break ;default : -return false; +return -EINVAL ; } *vcpu_reg (vcpu,0 ) = val; -return true; +return ret; }arch/arm64/include/asm/kvm_psci.h +1
-1@@ -18,6 +18,6 @@#ifndef __ARM64_KVM_PSCI_H__#define __ARM64_KVM_PSCI_H__ -bool kvm_psci_call (struct kvm_vcpu *vcpu); +int kvm_psci_call (struct kvm_vcpu *vcpu);#endif /* __ARM64_KVM_PSCI_H__ */ arch/arm64/include/uapi/asm/kvm.h +2
-0@@ -158,6 +158,8 @@ struct kvm_arch_memory_slot {#define KVM_PSCI_FN_CPU_OFF KVM_PSCI_FN(1)#define KVM_PSCI_FN_CPU_ON KVM_PSCI_FN(2)#define KVM_PSCI_FN_MIGRATE KVM_PSCI_FN(3) +#define KVM_PSCI_FN_SYSTEM_OFF KVM_PSCI_FN(4) +#define KVM_PSCI_FN_SYSTEM_RESET KVM_PSCI_FN(5)#define KVM_PSCI_RET_SUCCESS 0#define KVM_PSCI_RET_NI ((unsigned long)-1)arch/arm64/kvm/handle_exit.c +6
-1@@ -30,8 +30,13 @@ typedef int (*exit_handle_fn)(struct kvm_vcpu *, struct kvm_run *);static int handle_hvc (struct kvm_vcpu *vcpu,struct kvm_run *run) { -if (kvm_psci_call (vcpu)) +int ret; + + ret =kvm_psci_call (vcpu); +if (ret ==0 )return 1 ; +else if (ret >0 ) +return 0 ;kvm_inject_undefined (vcpu);return 1 ;
arch/arm64/kvm/handle_exit.c static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) · line 44
Quoted 6 lines
arch/arm64/kvm/handle_exit.c +0
-3@@ -39,9 +44,6 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run)static int handle_smc (struct kvm_vcpu *vcpu,struct kvm_run *run) { -if (kvm_psci_call (vcpu)) -return 1 ; -
Isn't this an unrelated change, which should go in a separate patch with some justification text for the change?
Quoted 6 lines
arch/arm64/kvm/handle_exit.c +0
-0kvm_inject_undefined (vcpu);return 1 ; }Signature · 1 line
1.7.9.5
Otherwise, it looks overall to go in the right direction.
-Christoffer
PATCH 2/2 ARM/ARM64: KVM: Forward PSCI SYSTEM_OFF and SYSTEM_RESET to user space
Quoted 98 lines · Christoffer Dall
Quoted 97 lines · Anup Patel
The PSCI
SYSTEM_OFFandSYSTEM_RESETfunctions are system-level functions hence cannot be fully emulated by the in-kernel PSCI emulation code.To tackle this, we forward PSCI
SYSTEM_OFFandSYSTEM_RESETfunction calls from guest to user space (i.e. QEMU or KVMTOOL) via KVM run structure usingKVM_EXIT_SHUTDOWNandKVM_EXIT_RESETexit reasons.Signed-off-by Anup Patel <[email protected]>Signed-off-by Pranavkumar Sawargaonkar <[email protected]>--- arch/arm/include/asm/kvm_psci.h | 2 +- arch/arm/include/uapi/asm/kvm.h | 2 ++ arch/arm/kvm/handle_exit.c | 7 ++++++- arch/arm/kvm/psci.c | 38 +++++++++++++++++++++++++++++-------- arch/arm64/include/asm/kvm_psci.h | 2 +- arch/arm64/include/uapi/asm/kvm.h | 2 ++ arch/arm64/kvm/handle_exit.c | 10 ++++++---- 7 files changed, 48 insertions(+), 15 deletions(-)arch/arm/include/asm/kvm_psci.h +1
-1@@ -18,6 +18,6 @@#ifndef __ARM_KVM_PSCI_H__#define __ARM_KVM_PSCI_H__ -bool kvm_psci_call (struct kvm_vcpu *vcpu); +int kvm_psci_call (struct kvm_vcpu *vcpu);#endif /* __ARM_KVM_PSCI_H__ */ arch/arm/include/uapi/asm/kvm.h +2
-0@@ -172,6 +172,8 @@ struct kvm_arch_memory_slot {#define KVM_PSCI_FN_CPU_OFF KVM_PSCI_FN(1)#define KVM_PSCI_FN_CPU_ON KVM_PSCI_FN(2)#define KVM_PSCI_FN_MIGRATE KVM_PSCI_FN(3) +#define KVM_PSCI_FN_SYSTEM_OFF KVM_PSCI_FN(4) +#define KVM_PSCI_FN_SYSTEM_RESET KVM_PSCI_FN(5)#define KVM_PSCI_RET_SUCCESS 0#define KVM_PSCI_RET_NI ((unsigned long)-1)arch/arm/kvm/handle_exit.c +6
-1@@ -40,11 +40,16 @@ static int handle_svc_hyp(struct kvm_vcpu *vcpu, struct kvm_run *run)static int handle_hvc (struct kvm_vcpu *vcpu,struct kvm_run *run) { +int ret; +trace_kvm_hvc (*vcpu_pc (vcpu), *vcpu_reg (vcpu,0 ),kvm_vcpu_hvc_get_imm (vcpu)); -if (kvm_psci_call (vcpu)) + ret =kvm_psci_call (vcpu); +if (ret ==0 )return 1 ; +else if (ret >0 ) +return 0 ;kvm_inject_undefined (vcpu);return 1 ;arch/arm/kvm/psci.c +13
-4@@ -84,18 +84,31 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)return KVM_PSCI_RET_SUCCESS ; } +static void kvm_psci_system_off (struct kvm_vcpu *vcpu) +{ + vcpu->run->exit_reason =KVM_EXIT_SHUTDOWN ; +} + +static void kvm_psci_system_reset (struct kvm_vcpu *vcpu) +{ + vcpu->run->exit_reason =KVM_EXIT_RESET ; +} +/** * kvm_psci_call - handle PSCI call if r0 value is in range * @vcpu: Pointer to the VCPU struct * * Handle PSCI calls from guests through traps from HVC instructions. -* The calling convention is similar to SMC calls to the secure world where -* the function number is placed in r0 and this function returns true if the -* function number specified in r0 is withing the PSCI range, and false -* otherwise. +* The calling convention is similar to SMC calls to the secure world +* where the function number is placed in r0 and function number +* specified in r0 is withing the PSCI range.
Quoted 8 lines
arch/arm/kvm/psci.c static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) · line 107
Quoted 3 lines
arch/arm/kvm/psci.c +3
-0+* +* This function returns: 0 (success), > 0 (success but exit to user +* space), and < 0 (failure) Hmmm, I think this is a bit confusing because it essentially does the reverse of all the other kvm internal return convention. Wouldn't it make more sense to have 0 (success, but exit to user space), 1 (success, resume VM), and < 0 (failure).
OK, I will change kvm_psci_call() return convention as-per your suggestion.
Quoted 11 lines
Also note that you are general-casing all error codes that may happen to mean that it did not match the PSCI function to anything well-known. In this case, that's sort of ok, because we don't expect the PSCI code to randomly fail (if it does, it reports it to the caller in the return register), but not fail, as in, I'm out of memory or anything like that. But I think you can clarify this in the comment, by saying something like:
Errors:
-EINVAL: Unrecognized PSCI function
Sure, I will update the comments.
Quoted 81 lines
in the comment for the function.
Quoted 78 lines
arch/arm/kvm/psci.c +14
-4*/ -bool kvm_psci_call (struct kvm_vcpu *vcpu) +int kvm_psci_call (struct kvm_vcpu *vcpu) { +int ret =0 ;unsigned long psci_fn = *vcpu_reg (vcpu,0 ) & ~((u32 )0 );unsigned long val;@@ -111,11 +124,20 @@ bool kvm_psci_call(struct kvm_vcpu *vcpu)case KVM_PSCI_FN_MIGRATE : val =KVM_PSCI_RET_NI ;break ; - +case KVM_PSCI_FN_SYSTEM_OFF : +kvm_psci_system_off (vcpu); + val =KVM_PSCI_RET_SUCCESS ; + ret =1 ; +break ; +case KVM_PSCI_FN_SYSTEM_RESET : +kvm_psci_system_reset (vcpu); + val =KVM_PSCI_RET_SUCCESS ; + ret =1 ; +break ;default : -return false; +return -EINVAL ; } *vcpu_reg (vcpu,0 ) = val; -return true; +return ret; }arch/arm64/include/asm/kvm_psci.h +1
-1@@ -18,6 +18,6 @@#ifndef __ARM64_KVM_PSCI_H__#define __ARM64_KVM_PSCI_H__ -bool kvm_psci_call (struct kvm_vcpu *vcpu); +int kvm_psci_call (struct kvm_vcpu *vcpu);#endif /* __ARM64_KVM_PSCI_H__ */ arch/arm64/include/uapi/asm/kvm.h +2
-0@@ -158,6 +158,8 @@ struct kvm_arch_memory_slot {#define KVM_PSCI_FN_CPU_OFF KVM_PSCI_FN(1)#define KVM_PSCI_FN_CPU_ON KVM_PSCI_FN(2)#define KVM_PSCI_FN_MIGRATE KVM_PSCI_FN(3) +#define KVM_PSCI_FN_SYSTEM_OFF KVM_PSCI_FN(4) +#define KVM_PSCI_FN_SYSTEM_RESET KVM_PSCI_FN(5)#define KVM_PSCI_RET_SUCCESS 0#define KVM_PSCI_RET_NI ((unsigned long)-1)arch/arm64/kvm/handle_exit.c +6
-1@@ -30,8 +30,13 @@ typedef int (*exit_handle_fn)(struct kvm_vcpu *, struct kvm_run *);static int handle_hvc (struct kvm_vcpu *vcpu,struct kvm_run *run) { -if (kvm_psci_call (vcpu)) +int ret; + + ret =kvm_psci_call (vcpu); +if (ret ==0 )return 1 ; +else if (ret >0 ) +return 0 ;kvm_inject_undefined (vcpu);return 1 ;@@ -39,9 +44,6 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run)
Quoted 8 lines
arch/arm64/kvm/handle_exit.c static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) · line 44
Quoted 5 lines
arch/arm64/kvm/handle_exit.c +0
-3static int handle_smc (struct kvm_vcpu *vcpu,struct kvm_run *run) { -if (kvm_psci_call (vcpu)) -return 1 ; -Isn't this an unrelated change, which should go in a separate patch with some justification text for the change?
Actually, handle_smc() was already using kvm_psci_call() so I had to change it anyway because of changes in kvm_psic_call(). Also, user space emulation of SMC-based PSCI is going to be different from in-kernel HVC-based PSCI emulation hence, for now it seemed more appropriate to inject undefined exception for KVM arm64 (just like KVM arm).
--
Anup
Quoted 15 lines
Quoted 7 lines
arch/arm64/kvm/handle_exit.c +0
-1kvm_inject_undefined (vcpu);return 1 ; } --1.7.9.5
Otherwise, it looks overall to go in the right direction.
-Christoffer
_______________________________________________
kvmarm mailing list
kvmarm at lists.cs.columbia.edu
https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm
PATCH 2/2 ARM/ARM64: KVM: Forward PSCI SYSTEM_OFF and SYSTEM_RESET to user space
Quoted 14 lines · Anup Patel
Quoted 11 lines · Christoffer Dall
arch/arm64/kvm/handle_exit.c static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) · line 44
Quoted 7 lines · Anup Patel
arch/arm64/kvm/handle_exit.c +0
-3@@ -39,9 +44,6 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run)static int handle_smc (struct kvm_vcpu *vcpu,struct kvm_run *run) { -if (kvm_psci_call (vcpu)) -return 1 ; -Isn't this an unrelated change, which should go in a separate patch with some justification text for the change?
Quoted 5 lines
Actually,
handle_smc()was already usingkvm_psci_call()so I had to change it anyway because of changes inkvm_psic_call(). Also, user space emulation of SMC-based PSCI is going to be different from in-kernel HVC-based PSCI emulation hence, for now it seemed more appropriate to inject undefined exception for KVM arm64 (just like KVM arm).
Doh. I though I got rid of that.
That chunk should have been been removed ages ago (probably before merging the arm64 code), as per 24a7f6757.
Please make it a separate patch, and I'll merge that independently.
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
PATCH 2/2 ARM/ARM64: KVM: Forward PSCI SYSTEM_OFF and SYSTEM_RESET to user space
Quoted 21 lines · Marc Zyngier
Quoted 14 lines · Anup Patel
Quoted 11 lines · Christoffer Dall
arch/arm64/kvm/handle_exit.c static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) · line 44
Quoted 7 lines · Anup Patel
arch/arm64/kvm/handle_exit.c +0
-3@@ -39,9 +44,6 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run)static int handle_smc (struct kvm_vcpu *vcpu,struct kvm_run *run) { -if (kvm_psci_call (vcpu)) -return 1 ; -Isn't this an unrelated change, which should go in a separate patch with some justification text for the change?
Quoted 5 lines
Actually,
handle_smc()was already usingkvm_psci_call()so I had to change it anyway because of changes inkvm_psic_call(). Also, user space emulation of SMC-based PSCI is going to be different from in-kernel HVC-based PSCI emulation hence, for now it seemed more appropriate to inject undefined exception for KVM arm64 (just like KVM arm).
Quoted 6 lines
Doh. I though I got rid of that.
That chunk should have been been removed ages ago (probably before merging the arm64 code), as per
24a7f6757.Please make it a separate patch, and I'll merge that independently.
Sure, I'll make this a separate patch and send it soon.
--
Anup
Quoted 6 lines
Thanks,
M.--
Jazz is not dead. It just smells funny...
cover PSCI system off and reset for KVM ARM/ARM64
In reply to Anup PatelQuoted 32 lines · Anup Patel
The Power State and Coordination Interface (PSCI) specification defines
SYSTEM_OFFandSYSTEM_RESETfunctions for system poweroff and reboot.This patchset adds emulation of PSCI
SYSTEM_OFFandSYSTEM_RESETfunctions in KVM ARM/ARM64 by forwarding them to user space (QEMU or KVMTOOL) usingKVM_EXIT_SHUTDOWNandKVM_EXIT_RESETexit reasons.To try this patch from guest kernel, we will need PSCI-based restart and poweroff support in the guest kenel for both ARM and ARM64.
Rob Herring has already submitted patches for PSCI-based restart and poweroff in ARM kernel but these are not merged yet due unstable device tree bindings of kernel PSCI support. We will be having similar patches for PSCI-based restart and poweroff in ARM64 kernel.
(Refer http://www.spinics.net/lists/arm-kernel/msg262217.html)
(Refer http://www.spinics.net/lists/devicetree/msg05348.html)Anup Patel (2):
KVM: AddKVM_EXIT_RESETto user space API header ARM/ARM64: KVM: Forward PSCISYSTEM_OFFandSYSTEM_RESETto user
spacearch/arm/include/asm/kvm_psci.h | 2 +- arch/arm/include/uapi/asm/kvm.h | 2 ++ arch/arm/kvm/handle_exit.c | 7 ++++++- arch/arm/kvm/psci.c | 38 +++++++++++++++++++++++++++++-------- arch/arm64/include/asm/kvm_psci.h | 2 +- arch/arm64/include/uapi/asm/kvm.h | 2 ++ arch/arm64/kvm/handle_exit.c | 10 ++++++---- include/uapi/linux/kvm.h | 1 + 8 files changed, 49 insertions(+), 15 deletions(-)
Quoted 3 lines
--
1.7.9.5
Hi All,
If anyone wants to try this patches using KVMTOOL then they can find guest kernel side PSCI patches and KVMTOOL patch attached here.
Regards,
Anup
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-ARM-psci-Add-support-for-system-reboot-and-poweroff.patch
Type: text/x-diff
Size: 2340 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131125/a3142151/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0007-ARM64-psci-Add-support-for-system-reboot-and-powerof.patch
Type: text/x-diff
Size: 2381 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131125/a3142151/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kvmtool_psci_emulation.patch
Type: text/x-diff
Size: 4544 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131125/a3142151/attachment-0005.bin>
cover PSCI system off and reset for KVM ARM/ARM64
(Adding Christoffer, forgot to add him to CC)
Quoted 50 lines · Anup Patel
Quoted 32 lines · Anup Patel
The Power State and Coordination Interface (PSCI) specification defines
SYSTEM_OFFandSYSTEM_RESETfunctions for system poweroff and reboot.This patchset adds emulation of PSCI
SYSTEM_OFFandSYSTEM_RESETfunctions in KVM ARM/ARM64 by forwarding them to user space (QEMU or KVMTOOL) usingKVM_EXIT_SHUTDOWNandKVM_EXIT_RESETexit reasons.To try this patch from guest kernel, we will need PSCI-based restart and poweroff support in the guest kenel for both ARM and ARM64.
Rob Herring has already submitted patches for PSCI-based restart and poweroff in ARM kernel but these are not merged yet due unstable device tree bindings of kernel PSCI support. We will be having similar patches for PSCI-based restart and poweroff in ARM64 kernel.
(Refer http://www.spinics.net/lists/arm-kernel/msg262217.html)
(Refer http://www.spinics.net/lists/devicetree/msg05348.html)Anup Patel (2):
KVM: AddKVM_EXIT_RESETto user space API header ARM/ARM64: KVM: Forward PSCISYSTEM_OFFandSYSTEM_RESETto user
spacearch/arm/include/asm/kvm_psci.h | 2 +- arch/arm/include/uapi/asm/kvm.h | 2 ++ arch/arm/kvm/handle_exit.c | 7 ++++++- arch/arm/kvm/psci.c | 38 +++++++++++++++++++++++++++++-------- arch/arm64/include/asm/kvm_psci.h | 2 +- arch/arm64/include/uapi/asm/kvm.h | 2 ++ arch/arm64/kvm/handle_exit.c | 10 ++++++---- include/uapi/linux/kvm.h | 1 + 8 files changed, 49 insertions(+), 15 deletions(-)Quoted 3 lines
--
1.7.9.5Hi All,
If anyone wants to try this patches using KVMTOOL then they can find guest kernel side PSCI patches and KVMTOOL patch attached here.
Regards,
Anup_______________________________________________
kvmarm mailing list
kvmarm at lists.cs.columbia.edu
https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm