lkml.org 
[lkml]   [2022]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/8] KVM: SVM: move guest vmsave/vmload to assembly
On Mon, Nov 07, 2022 at 09:54:32AM -0500, Paolo Bonzini wrote:
> @@ -56,6 +59,16 @@ SYM_FUNC_START(__svm_vcpu_run)
> /* Move @svm to RDI. */
> mov %_ASM_ARG2, %_ASM_DI
>
> + /*
> + * Use a single vmcb (vmcb01 because it's always valid) for
> + * context switching guest state via VMLOAD/VMSAVE, that way
> + * the state doesn't need to be copied between vmcb01 and
> + * vmcb02 when switching vmcbs for nested virtualization.
> + */
> + mov SVM_vmcb01_pa(%_ASM_DI), %_ASM_AX
> +1: vmload %_ASM_AX
> +2:
> +
> /* "POP" @vmcb to RAX. */
> pop %_ASM_AX
>
> @@ -80,16 +93,11 @@ SYM_FUNC_START(__svm_vcpu_run)
> /* Enter guest mode */
> sti
>
> +3: vmrun %_ASM_AX
> +4:
> + cli
>
> + /* Pop @svm to RAX while it's the only available register. */
> pop %_ASM_AX
>
> /* Save all guest registers. */

So Andrew noted that once the vmload has executed any exception taken
(say at 3) will crash and burn because %gs is scribbled.

Might be good to make a record of this in the code so it can be cleaned
up some day.

> @@ -159,11 +179,19 @@ SYM_FUNC_START(__svm_vcpu_run)
> pop %_ASM_BP
> RET
>
> +10: cmpb $0, kvm_rebooting
> jne 2b
> ud2
> +30: cmpb $0, kvm_rebooting
> + jne 4b
> + ud2
> +50: cmpb $0, kvm_rebooting
> + jne 6b
> + ud2
>
> + _ASM_EXTABLE(1b, 10b)
> + _ASM_EXTABLE(3b, 30b)
> + _ASM_EXTABLE(5b, 50b)

\
 
 \ /
  Last update: 2022-11-07 16:24    [W:0.240 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site