kvm-ppc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Murilo Opsfelder Araújo" <muriloo@linux.ibm.com>
To: Fabiano Rosas <farosas@linux.ibm.com>, linuxppc-dev@lists.ozlabs.org
Cc: kvm-ppc@vger.kernel.org, npiggin@gmail.com
Subject: Re: [PATCH] KVM: PPC: Align pt_regs in kvm_vcpu_arch structure
Date: Fri, 17 Jun 2022 15:24:43 +0000	[thread overview]
Message-ID: <a2378b90-a465-b60c-cc92-616b9c13daea@linux.ibm.com> (raw)
In-Reply-To: <20220525124944.2613333-1-farosas@linux.ibm.com>

Hi, Fabiano.

On 5/25/22 09:49, Fabiano Rosas wrote:
> The H_ENTER_NESTED hypercall receives as second parameter the address
> of a region of memory containing the values for the nested guest
> privileged registers. We currently use the pt_regs structure contained
> within kvm_vcpu_arch for that end.
> 
> Most hypercalls that receive a memory address expect that region to
> not cross a 4k page boundary. We would want H_ENTER_NESTED to follow
> the same pattern so this patch ensures the pt_regs structure sits
> within a page.
> 
> Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>

Is it necessary to explain in the commit message that even though the second
parameter needs to be 4k-aligned, we're aligning pt_regs to 512 bytes so it can
be placed within a 4k boundary because its size is below 512 bytes?

The natural thinking would be aligning it to 4k bytes, which would punch a huge
hole in kvm_vcpu_arch. I think having the explanation of why 512 vs. 4k is
worthwhile mentioning.

> ---
>   arch/powerpc/include/asm/kvm_host.h | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
> index faf301d0dec0..87eba60f2920 100644
> --- a/arch/powerpc/include/asm/kvm_host.h
> +++ b/arch/powerpc/include/asm/kvm_host.h
> @@ -519,7 +519,11 @@ struct kvm_vcpu_arch {
>   	struct kvmppc_book3s_shadow_vcpu *shadow_vcpu;
>   #endif
>   
> -	struct pt_regs regs;
> +	/*
> +	 * This is passed along to the HV via H_ENTER_NESTED. Align to
> +	 * prevent it crossing a real 4K page.
> +	 */
> +	struct pt_regs regs __aligned(512);
>   
>   	struct thread_fp_state fp;
>   


-- 
Murilo

      reply	other threads:[~2022-06-17 15:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-25 12:49 [PATCH] KVM: PPC: Align pt_regs in kvm_vcpu_arch structure Fabiano Rosas
2022-06-17 15:24 ` Murilo Opsfelder Araújo [this message]

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=a2378b90-a465-b60c-cc92-616b9c13daea@linux.ibm.com \
    --to=muriloo@linux.ibm.com \
    --cc=farosas@linux.ibm.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=npiggin@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).