From: Paul Mackerras Date: Fri, 18 Aug 2017 00:02:01 +0000 Subject: Re: [RFC PATCH] kvmppc: protection keys fix Message-Id: <20170818000201.GA1059@fergus.ozlabs.ibm.com> List-Id: References: <1501258978-6666-1-git-send-email-linuxram@us.ibm.com> In-Reply-To: <1501258978-6666-1-git-send-email-linuxram@us.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: kvm-ppc@vger.kernel.org On Thu, Aug 17, 2017 at 03:01:31PM -0700, Ram Pai wrote: > On Thu, Aug 17, 2017 at 05:54:45PM -0300, Thiago Jung Bauermann wrote: [snip] > >=20 > > I'm currently preparing a patch for that. One question: did I understand > > correctly that Paul Mackerras' answer on this thread=B9 means that KVM > > doesn't need to reserve any keys for itself and can pass on 32 keys to > > the guest? >=20 > No. KVM does use key 31 for emulated MMIO. >=20 > if (!(memslot && !(memslot->flags & KVM_MEMSLOT_INVALID))) { > /* Emulated MMIO - mark this with key1 */ > pteh |=3D HPTE_V_ABSENT; > ptel |=3D HPTE_R_KEY_HI | > HPTE_R_KEY_LO; > goto do_insert; > } Actually, the guest *can* use all 32 keys. We only use key 31 on absent HPTEs (see the HPTE_V_ABSENT flag above - these are HPTEs that the guest thinks are valid but are not actually mapped in the real HPT). Paul.