arm(64)/kvm: improve the documentation about HVC calls
Subsystems (3)
PATCH 1/1 arm(64)/kvm: improve the documentation about HVC calls
Both arm and arm64 kernel entry point have the following prerequisite:
MMU = off, D-cache = off, I-cache = dont care.
HVC_SOFT_RESTART call should meet this prerequisite before jumping to the new kernel.
Furthermore, on arm64, el2_setup doesn't set I+C bits and keeps EL2 MMU off, and KVM resets them when its unload. These are achieved by HVC_RESET_VECTORS call.
Improve the document.
--- Documentation/virt/kvm/arm/hyp-abi.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/virt/kvm/arm/hyp-abi.rst +3 -3
@@ -40,9 +40,9 @@ these functions (see arch/arm{,64}/include/asm/virt.h): * :: - r0/x0 = HVC_RESET_VECTORS + x0 = HVC_RESET_VECTORS (arm64 only) - Turn HYP/EL2 MMU off, and reset HVBAR/VBAR_EL2 to the initials + Disable HYP/EL2 MMU and D-cache, and reset HVBAR/VBAR_EL2 to the initials stubs' exception vector value. This effectively disables an existing hypervisor.
@@ -54,7 +54,7 @@ these functions (see arch/arm{,64}/include/asm/virt.h): x3 = x1's value when entering the next payload (arm64) x4 = x2's value when entering the next payload (arm64) - Mask all exceptions, disable the MMU, move the arguments into place + Mask all exceptions, disable the MMU and D-cache, move the arguments into place (arm64 only), and jump to the restart address while at HYP/EL2. This hypercall is not expected to return to its caller.
Signature · 1 line
2.7.5
This issue is detected by Morse
(https://lore.kernel.org/linux-arm-kernel/[email protected]/)
during the discussion for my patch.
I am not quite sure about the arm, but based on the note at the head of arm/kernel/head.S, things should go that way. If any mistake, please correct me.
Thanks,
Pingfan
Quoted 54 lines · Pingfan Liu
Both arm and arm64 kernel entry point have the following prerequisite:
MMU = off, D-cache = off, I-cache = dont care.
HVC_SOFT_RESTARTcall should meet this prerequisite before jumping to the new kernel.Furthermore, on arm64,
el2_setupdoesn't set I+C bits and keeps EL2 MMU off, and KVM resets them when its unload. These are achieved byHVC_RESET_VECTORScall.Improve the document.
Signed-off-by Pingfan Liu <[email protected]>Cc James Morse <[email protected]>Cc Russell King <[email protected]>Cc Marc Zyngier <[email protected]>Cc Julien Thierry <[email protected]>Cc Suzuki K Poulose <[email protected]>--- Documentation/virt/kvm/arm/hyp-abi.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)Documentation/virt/kvm/arm/hyp-abi.rst +3
-4@@ -40,9 +40,9 @@ these functions (see arch/arm{,64}/include/asm/virt.h): * :: - r0/x0 = HVC_RESET_VECTORS + x0 = HVC_RESET_VECTORS (arm64 only) - Turn HYP/EL2 MMU off, and reset HVBAR/VBAR_EL2 to the initials + Disable HYP/EL2 MMU and D-cache, and reset HVBAR/VBAR_EL2 to the initials stubs' exception vector value. This effectively disables an existing hypervisor.@@ -54,7 +54,7 @@ these functions (see arch/arm{,64}/include/asm/virt.h): x3 = x1's value when entering the next payload (arm64) x4 = x2's value when entering the next payload (arm64) - Mask all exceptions, disable the MMU, move the arguments into place + Mask all exceptions, disable the MMU and D-cache, move the arguments into place (arm64 only), and jump to the restart address while at HYP/EL2. This hypercall is not expected to return to its caller. --2.7.5
Hi Pingfan,
Quoted 5 lines · Pingfan Liu
Both arm and arm64 kernel entry point have the following prerequisite:
MMU = off, D-cache = off, I-cache = dont care.
HVC_SOFT_RESTARTcall should meet this prerequisite before jumping to the new kernel.
I think you have this the wrong way up. This should describe what HVC_SOFT_RESTART does.
We want to remove some extra work kexec does on arm64, and both implementations of HVC_SOFT_RESTART on arm64 already do what we need. The change here should be to document that the D/I bits are cleared after a HVC_SOFT_RESTART on arm64.
Quoted 12 lines
Furthermore, on arm64,
el2_setupdoesn't set I+C bits and keeps EL2 MMU off, and KVM resets them when its unload. These are achieved byHVC_RESET_VECTORScall.Improve the document.
Documentation/virt/kvm/arm/hyp-abi.rst +0
-0
Documentation/virt/kvm/arm/hyp-abi.rst these functions (see arch/arm{,64}/include/asm/virt.h): · line 47
Quoted 10 lines
Documentation/virt/kvm/arm/hyp-abi.rst +2
-2@@ -40,9 +40,9 @@ these functions (see arch/arm{,64}/include/asm/virt.h): * :: - r0/x0 = HVC_RESET_VECTORS + x0 = HVC_RESET_VECTORS (arm64 only) - Turn HYP/EL2 MMU off, and reset HVBAR/VBAR_EL2 to the initials + Disable HYP/EL2 MMU and D-cache, and reset HVBAR/VBAR_EL2 to the initials stubs' exception vector value. This effectively disables an existing hypervisor.
I don't think we should remove this. KVM on 32bit was the only implementer, but if there ever is another, this is how it should work.
Documentation/virt/kvm/arm/hyp-abi.rst these functions (see arch/arm{,64}/include/asm/virt.h): · line 59
Quoted 8 lines
Documentation/virt/kvm/arm/hyp-abi.rst +1
-1@@ -54,7 +54,7 @@ these functions (see arch/arm{,64}/include/asm/virt.h): x3 = x1's value when entering the next payload (arm64) x4 = x2's value when entering the next payload (arm64) - Mask all exceptions, disable the MMU, move the arguments into place + Mask all exceptions, disable the MMU and D-cache, move the arguments into place (arm64 only), and jump to the restart address while at HYP/EL2. This hypercall is not expected to return to its caller.
(I don't think disable the D-cache is what the bit does, it forces the attributes that are used for a data access).
Please just describe this as the on arm64 the D and I bits are cleared. (it might be true on 32bit, I can't work the assembly out).
Thanks,
James
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Quoted 11 lines · James Morse
Hi Pingfan,
Quoted 5 lines · Pingfan Liu
Both arm and arm64 kernel entry point have the following prerequisite:
MMU = off, D-cache = off, I-cache = dont care.
HVC_SOFT_RESTARTcall should meet this prerequisite before jumping to the new kernel.I think you have this the wrong way up. This should describe what
HVC_SOFT_RESTARTdoes.
Yes, it is a wrong way.
Quoted 45 lines
We want to remove some extra work kexec does on arm64, and both implementations of
HVC_SOFT_RESTARTon arm64 already do what we need. The change here should be to document that the D/I bits are cleared after aHVC_SOFT_RESTARTon arm64.Quoted 12 lines
Furthermore, on arm64,
el2_setupdoesn't set I+C bits and keeps EL2 MMU off, and KVM resets them when its unload. These are achieved byHVC_RESET_VECTORScall.Improve the document.
Documentation/virt/kvm/arm/hyp-abi.rst +0
-0Documentation/virt/kvm/arm/hyp-abi.rst these functions (see arch/arm{,64}/include/asm/virt.h): · line 47
Quoted 10 lines
Documentation/virt/kvm/arm/hyp-abi.rst +2
-2@@ -40,9 +40,9 @@ these functions (see arch/arm{,64}/include/asm/virt.h): * :: - r0/x0 = HVC_RESET_VECTORS + x0 = HVC_RESET_VECTORS (arm64 only) - Turn HYP/EL2 MMU off, and reset HVBAR/VBAR_EL2 to the initials + Disable HYP/EL2 MMU and D-cache, and reset HVBAR/VBAR_EL2 to the initials stubs' exception vector value. This effectively disables an existing hypervisor.I don't think we should remove this. KVM on 32bit was the only implementer, but if there ever is another, this is how it should work.
Documentation/virt/kvm/arm/hyp-abi.rst these functions (see arch/arm{,64}/include/asm/virt.h): · line 59
Quoted 8 lines
Documentation/virt/kvm/arm/hyp-abi.rst +1
-1@@ -54,7 +54,7 @@ these functions (see arch/arm{,64}/include/asm/virt.h): x3 = x1's value when entering the next payload (arm64) x4 = x2's value when entering the next payload (arm64) - Mask all exceptions, disable the MMU, move the arguments into place + Mask all exceptions, disable the MMU and D-cache, move the arguments into place (arm64 only), and jump to the restart address while at HYP/EL2. This hypercall is not expected to return to its caller.(I don't think disable the D-cache is what the bit does, it forces the attributes that are used for a data access).
Quoted 1 line
Please just describe this as the on arm64 the D and I bits are cleared.
OK, I will do it.
Quoted 1 line
(it might be true on 32bit, I can't work the assembly out).
I will leave 32bit as it is.
Thanks,
Pingfan