public inbox for linux-kselftest@vger.kernel.org
 help / color / mirror / Atom feed
From: Oliver Upton <oliver.upton@linux.dev>
To: Ryan Roberts <ryan.roberts@arm.com>
Cc: Marc Zyngier <maz@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org, kvmarm@lists.linux.dev
Subject: Re: [PATCH v1 2/2] KVM: selftests: arm64: Fix pte encode/decode for PA bits > 48
Date: Tue, 7 Mar 2023 17:44:43 +0000	[thread overview]
Message-ID: <ZAd4CyBM79JzqkEu@linux.dev> (raw)
In-Reply-To: <20230228170756.769461-3-ryan.roberts@arm.com>

Hi Ryan,

Thanks for fixing this. Couple of nits:

On Tue, Feb 28, 2023 at 05:07:56PM +0000, Ryan Roberts wrote:
> The high bits [51:48] of a physical address should appear at [15:12] in
> a 64K pte, not at [51:48] as was previously being programmed. Fix this
> with new helper functions that do the conversion correctly. This also
> sets us up nicely for adding LPA2 encodings in future.
> 
> Fixes: 7a6629ef746d ("kvm: selftests: add virt mem support for aarch64")
> 
> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>

nit: no whitespace between footers.

> ---
>  .../selftests/kvm/lib/aarch64/processor.c     | 32 ++++++++++++++-----
>  1 file changed, 24 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/lib/aarch64/processor.c b/tools/testing/selftests/kvm/lib/aarch64/processor.c
> index 5972a23b2765..13f28d96521c 100644
> --- a/tools/testing/selftests/kvm/lib/aarch64/processor.c
> +++ b/tools/testing/selftests/kvm/lib/aarch64/processor.c
> @@ -58,10 +58,27 @@ static uint64_t pte_index(struct kvm_vm *vm, vm_vaddr_t gva)
>  	return (gva >> vm->page_shift) & mask;
>  }
>  
> -static uint64_t pte_addr(struct kvm_vm *vm, uint64_t entry)
> +static uint64_t addr_pte(struct kvm_vm *vm, uint64_t pa, uint64_t attrs)
>  {
> -	uint64_t mask = ((1UL << (vm->va_bits - vm->page_shift)) - 1) << vm->page_shift;
> -	return entry & mask;
> +	uint64_t pte;
> +
> +	pte = pa & GENMASK(47, vm->page_shift);
> +	if (vm->page_shift == 16)
> +		pte |= (pa & GENMASK(51, 48)) >> (48 - 12);

nit: this is a bit of an odd transformation, of course courtesy of the
architecture. FIELD_GET() might make it a bit more readable:

		pte |= FIELD_GET(GENMASK(51, 48), pa) << 12;

-- 
Thanks,
Oliver

  reply	other threads:[~2023-03-07 17:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-28 17:07 [PATCH v1 0/2] KVM: selftests: Fixes for broken tests Ryan Roberts
2023-02-28 17:07 ` [PATCH v1 1/2] KVM: selftests: Fixup config fragment for access_tracking_perf_test Ryan Roberts
2023-02-28 17:07 ` [PATCH v1 2/2] KVM: selftests: arm64: Fix pte encode/decode for PA bits > 48 Ryan Roberts
2023-03-07 17:44   ` Oliver Upton [this message]
2023-03-08 11:18     ` Ryan Roberts
2023-03-02 15:27 ` [PATCH v1 0/2] KVM: selftests: Fixes for broken tests Ryan Roberts

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=ZAd4CyBM79JzqkEu@linux.dev \
    --to=oliver.upton@linux.dev \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=ryan.roberts@arm.com \
    --cc=shuah@kernel.org \
    /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