From: Ram Pai Date: Fri, 18 Aug 2017 17:24:57 +0000 Subject: Re: [RFC PATCH] kvmppc: protection keys fix Message-Id: <20170818172457.GD5545@ram.oc3035372033.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 Fri, Aug 18, 2017 at 10:02:01AM +1000, Paul Mackerras wrote: > 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 underst= and > > > 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; > > } >=20 > 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). Ok. looks like you use the HPTE_V_ABSENT flag to determine if a key fault on key 31, needs to be redirected to the guest or handled internally. RP