From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: kvm-ppc@vger.kernel.org
Subject: Re: [RFC PATCH] kvmppc: protection keys fix
Date: Wed, 02 Aug 2017 08:49:00 +0000 [thread overview]
Message-ID: <87vam6z76d.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1501258978-6666-1-git-send-email-linuxram@us.ibm.com>
Ram Pai <linuxram@us.ibm.com> writes:
> kvmppc_do_h_enter() hcall, clobbers the high-order two bits of
> the protection key in the lower pte (ptel). Hence
> any pkey number above 7 fails to behave.
>
> The following patch, preserves the pkey bits.
>
> Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> ---
> arch/powerpc/include/asm/book3s/64/mmu-hash.h | 1 +
> arch/powerpc/kvm/book3s_hv_rm_mmu.c | 2 +-
> 2 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
> index 369f9ff..f07a1c0 100644
> --- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h
> +++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
> @@ -109,6 +109,7 @@
> #define HPTE_R_KEY_BIT2 ASM_CONST(0x0000000000000800)
> #define HPTE_R_KEY_BIT3 ASM_CONST(0x0000000000000400)
> #define HPTE_R_KEY_BIT4 ASM_CONST(0x0000000000000200)
> +#define HPTE_R_KEY (HPTE_R_KEY_LO | HPTE_R_KEY_HI)
>
> #define HPTE_V_1TB_SEG ASM_CONST(0x4000000000000000)
> #define HPTE_V_VRMA_MASK ASM_CONST(0x4001ffffff000000)
> diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> index ce6f212..d9462ab 100644
> --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> @@ -268,7 +268,7 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags,
> if (!realmode)
> local_irq_restore(irq_flags);
>
> - ptel &= ~(HPTE_R_PP0 - psize);
> + ptel &= HPTE_R_KEY | HPTE_R_PP0 | (psize-1);
Is this all needed to get keys to work on kvm ? We use key value 31 and
key value 0 along with absent and invalid hpte config to indicate mmio
and host swapped pages ? Won't that need to be fixed ?
> ptel |= pa;
>
> if (pa)
> --
> 1.7.1
-aneesh
next prev parent reply other threads:[~2017-08-02 8:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-28 16:22 [RFC PATCH] kvmppc: protection keys fix Ram Pai
2017-07-31 5:35 ` Paul Mackerras
2017-07-31 5:56 ` Balbir Singh
2017-08-02 8:49 ` Aneesh Kumar K.V [this message]
2017-08-02 9:54 ` Paul Mackerras
2017-08-17 15:58 ` Ram Pai
2017-08-17 20:54 ` Thiago Jung Bauermann
2017-08-17 22:01 ` Ram Pai
2017-08-18 0:02 ` Paul Mackerras
2017-08-18 17:24 ` Ram Pai
2017-08-31 3:41 ` Paul Mackerras
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=87vam6z76d.fsf@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=kvm-ppc@vger.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