LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Nicholas Piggin" <npiggin@gmail.com>
To: "Kautuk Consul" <kconsul@linux.vnet.ibm.com>,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Christophe Leroy" <christophe.leroy@csgroup.eu>,
	"Fabiano Rosas" <farosas@linux.ibm.com>,
	"Sathvika Vasireddy" <sv@linux.ibm.com>,
	"Alexey Kardashevskiy" <aik@ozlabs.ru>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] arch/powerpc/kvm: kvmppc_hv_entry: remove r4 argument
Date: Tue, 21 Mar 2023 14:15:14 +1000	[thread overview]
Message-ID: <CRBRQAXJRZZW.28LH58EV3T8AL@bobo> (raw)
In-Reply-To: <20230316051025.1424093-3-kconsul@linux.vnet.ibm.com>

On Thu Mar 16, 2023 at 3:10 PM AEST, Kautuk Consul wrote:
> kvmppc_hv_entry is called from only 2 locations within
> book3s_hv_rmhandlers.S. Both of those locations set r4
> as HSTATE_KVM_VCPU(r13) before calling kvmppc_hv_entry.
> So, shift the r4 load instruction to kvmppc_hv_entry and
> thus modify the calling convention of this function.

Is r4 there only used for CONFIG_KVM_BOOK3S_HV_P8_TIMING? Could put it
under there. Although you then lose the barrier if it's disabled, that
is okay if you're sure that's the only memory operation being ordered.

I'm not sure how much new work we want to put into changing this asm
code, since it's POWER7/8 only. I would love to move this (and the
other) KVM implementations to C like we did with P9. It's a pretty big
job though.

Thanks,
Nick

>
> Signed-off-by: Kautuk Consul <kconsul@linux.vnet.ibm.com>
> ---
>  arch/powerpc/kvm/book3s_hv_rmhandlers.S | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> index b81ba4ee0521..b61f0b2c677b 100644
> --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> @@ -85,7 +85,7 @@ _GLOBAL_TOC(kvmppc_hv_entry_trampoline)
>  	RFI_TO_KERNEL
>  
>  kvmppc_call_hv_entry:
> -	ld	r4, HSTATE_KVM_VCPU(r13)
> +	/* Enter guest. */
>  	bl	kvmppc_hv_entry
>  
>  	/* Back from guest - restore host state and return to caller */
> @@ -352,9 +352,7 @@ kvm_secondary_got_guest:
>  	mtspr	SPRN_LDBAR, r0
>  	isync
>  63:
> -	/* Order load of vcpu after load of vcore */
> -	lwsync
> -	ld	r4, HSTATE_KVM_VCPU(r13)
> +	/* Enter guest. */
>  	bl	kvmppc_hv_entry
>  
>  	/* Back from the guest, go back to nap */
> @@ -506,7 +504,6 @@ SYM_INNER_LABEL(kvmppc_hv_entry, SYM_L_LOCAL)
>  
>  	/* Required state:
>  	 *
> -	 * R4 = vcpu pointer (or NULL)
>  	 * MSR = ~IR|DR
>  	 * R13 = PACA
>  	 * R1 = host R1
> @@ -524,6 +521,10 @@ SYM_INNER_LABEL(kvmppc_hv_entry, SYM_L_LOCAL)
>  	li	r6, KVM_GUEST_MODE_HOST_HV
>  	stb	r6, HSTATE_IN_GUEST(r13)
>  
> +	/* Order load of vcpu after load of vcore */
> +	lwsync
> +	ld	r4, HSTATE_KVM_VCPU(r13)
> +
>  #ifdef CONFIG_KVM_BOOK3S_HV_P8_TIMING
>  	/* Store initial timestamp */
>  	cmpdi	r4, 0
> -- 
> 2.39.2


  reply	other threads:[~2023-03-21  4:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16  5:10 [PATCH v3 0/2] Improving calls to kvmppc_hv_entry Kautuk Consul
2023-03-16  5:10 ` [PATCH v3 1/2] arch/powerpc/kvm: kvmppc_hv_entry: remove .global scope Kautuk Consul
2023-03-27  9:19   ` Nicholas Piggin
2023-03-27  9:27     ` Kautuk Consul
2023-03-27  9:34       ` Kautuk Consul
2023-03-27  9:43         ` Kautuk Consul
2023-03-27  9:51         ` Nicholas Piggin
2023-03-27  9:55           ` Kautuk Consul
2023-03-27 10:07             ` Kautuk Consul
2023-03-27 10:24             ` Nicholas Piggin
2023-03-16  5:10 ` [PATCH v3 2/2] arch/powerpc/kvm: kvmppc_hv_entry: remove r4 argument Kautuk Consul
2023-03-21  4:15   ` Nicholas Piggin [this message]
2023-03-21  4:54     ` Kautuk Consul
2023-03-21  8:37       ` Kautuk Consul
2023-03-22 12:17   ` Michael Ellerman
2023-03-23  4:53     ` Kautuk Consul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CRBRQAXJRZZW.28LH58EV3T8AL@bobo \
    --to=npiggin@gmail.com \
    --cc=aik@ozlabs.ru \
    --cc=christophe.leroy@csgroup.eu \
    --cc=farosas@linux.ibm.com \
    --cc=kconsul@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=sv@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox