linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
To: Christophe Leroy <christophe.leroy@csgroup.eu>,
	Nicholas Piggin <npiggin@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org
Subject: Re: [PATCH] KVM: PPC: Book3S HV: Fix reverse map real-mode address lookup with huge vmalloc
Date: Mon, 24 May 2021 13:17:07 +0530	[thread overview]
Message-ID: <87zgwkr2tg.fsf@linux.ibm.com> (raw)
In-Reply-To: <20210523181054.Horde.1K8Ldhm0aj339_vHlUQCkQ1@messagerie.c-s.fr>

Christophe Leroy <christophe.leroy@csgroup.eu> writes:

> Nicholas Piggin <npiggin@gmail.com> a écrit :
>
>> real_vmalloc_addr() does not currently work for huge vmalloc, which is
>> what the reverse map can be allocated with for radix host, hash guest.
>>
>> Add huge page awareness to the function.
>>
>> Fixes: 8abddd968a30 ("powerpc/64s/radix: Enable huge vmalloc mappings")
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> ---
>>  arch/powerpc/kvm/book3s_hv_rm_mmu.c | 17 ++++++++++++-----
>>  1 file changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c  
>> b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
>> index 7af7c70f1468..5f68cb5cc009 100644
>> --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
>> +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
>> @@ -26,16 +26,23 @@
>>  static void *real_vmalloc_addr(void *x)
>>  {
>>  	unsigned long addr = (unsigned long) x;
>> +	unsigned long mask;
>> +	int shift;
>>  	pte_t *p;
>> +
>>  	/*
>> -	 * assume we don't have huge pages in vmalloc space...
>> -	 * So don't worry about THP collapse/split. Called
>> -	 * Only in realmode with MSR_EE = 0, hence won't need irq_save/restore.
>> +	 * This is called only in realmode with MSR_EE = 0, hence won't need
>> +	 * irq_save/restore around find_init_mm_pte.
>>  	 */
>> -	p = find_init_mm_pte(addr, NULL);
>> +	p = find_init_mm_pte(addr, &shift);
>>  	if (!p || !pte_present(*p))
>>  		return NULL;
>> -	addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & ~PAGE_MASK);
>> +	if (!shift)
>> +		shift = PAGE_SHIFT;
>> +
>> +	mask = (1UL << shift) - 1;
>> +	addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & mask);
>
> Looks strange, before we have ~MASK now we have mask without the ~

#define PAGE_MASK      (~((1 << PAGE_SHIFT) - 1))

-aneesh

      reply	other threads:[~2021-05-24  7:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-23 15:53 [PATCH] KVM: PPC: Book3S HV: Fix reverse map real-mode address lookup with huge vmalloc Nicholas Piggin
2021-05-23 16:10 ` Christophe Leroy
2021-05-24  7:47   ` Aneesh Kumar K.V [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=87zgwkr2tg.fsf@linux.ibm.com \
    --to=aneesh.kumar@linux.ibm.com \
    --cc=christophe.leroy@csgroup.eu \
    --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 NNTP newsgroup(s).