From: Ram Pai <linuxram@us.ibm.com>
To: Paul Mackerras <paulus@ozlabs.org>
Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org,
David Gibson <david@gibson.dropbear.id.au>
Subject: RE: [PATCH] KVM: PPC: Book3S HV: Add a capability for enabling secure guests
Date: Thu, 19 Mar 2020 18:20:59 -0700 [thread overview]
Message-ID: <20200320012059.GC5563@oc0525413822.ibm.com> (raw)
In-Reply-To: <20200319231713.GA3260@blackberry>
On Fri, Mar 20, 2020 at 10:17:13AM +1100, Paul Mackerras wrote:
> On Thu, Mar 19, 2020 at 12:41:08PM -0700, Ram Pai wrote:
> > On Thu, Mar 19, 2020 at 03:33:01PM +1100, Paul Mackerras wrote:
> [snip]
> > > --- a/arch/powerpc/kvm/powerpc.c
> > > +++ b/arch/powerpc/kvm/powerpc.c
> > > @@ -670,6 +670,11 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
> > > (hv_enabled && cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST));
> > > break;
> > > #endif
> > > +#if defined(CONFIG_KVM_BOOK3S_HV_POSSIBLE) && defined(CONFIG_PPC_UV)
> > > + case KVM_CAP_PPC_SECURE_GUEST:
> > > + r = hv_enabled && !!firmware_has_feature(FW_FEATURE_ULTRAVISOR);
> >
> > We also need to check if the kvmppc_uvmem_init() has been successfully
> > called and initialized.
> >
> > r = hv_enabled && !!firmware_has_feature(FW_FEATURE_ULTRAVISOR)
> > && kvmppc_uvmem_bitmap;
>
> Well I can't do that exactly because kvmppc_uvmem_bitmap is in a
> different module (the kvm_hv module, whereas this code is in the kvm
> module), and I wouldn't want to depend on kvmppc_uvmem_bitmap, since
> that's an internal implementation detail.
yes. checking for kvmppc_uvmem_bitmap depends on internal implementation
detail. Its also a loose approximation. There has to be something
better which can tell, if everything needed to support secure guests, is
available and initialized.
>
> The firmware_has_feature(FW_FEATURE_ULTRAVISOR) test ultimately
> depends on there being a device tree node with "ibm,ultravisor" in its
> compatible property (see early_init_dt_scan_ultravisor()). So that
> means there is an ultravisor there. The cases where that test would
> pass but kvmppc_uvmem_bitmap == NULL would be those where the device
> tree nodes are present but not right, or where the host is so short of
> memory that it couldn't allocate the kvmppc_uvmem_bitmap. If you
> think those cases are worth worrying about then I will have to devise
> a way to do the test without depending on any symbols from the kvm-hv
> module.
the cases, where incorrect behavior can happen; if we do not have this additional
check, are --
a) zero secure memory in the system.
b) "kvmppc_uvmem" memory region is not defined.
c) the memory region fails to map.
d) kvmppc_uvmem_bitmap allocation failed.
All these are possible to varying level of certainity.
I do not know we should be concerned about these possibilities.
But if we do, than will a patch like this help? compile tested.
------------------
diff --git a/arch/powerpc/include/asm/kvm_book3s_uvmem.h b/arch/powerpc/include/asm/kvm_book3s_uvmem.h
index 5a9834e..643c497 100644
--- a/arch/powerpc/include/asm/kvm_book3s_uvmem.h
+++ b/arch/powerpc/include/asm/kvm_book3s_uvmem.h
@@ -4,6 +4,7 @@
#ifdef CONFIG_PPC_UV
int kvmppc_uvmem_init(void);
+int kvmppc_uv_enabled(void);
void kvmppc_uvmem_free(void);
int kvmppc_uvmem_slot_init(struct kvm *kvm, const struct kvm_memory_slot *slot);
void kvmppc_uvmem_slot_free(struct kvm *kvm,
@@ -28,6 +29,11 @@ static inline int kvmppc_uvmem_init(void)
return 0;
}
+static inline int kvmppc_uv_enabled(void)
+{
+ return 0;
+}
+
static inline void kvmppc_uvmem_free(void) { }
static inline int
diff --git a/arch/powerpc/kvm/book3s_hv_uvmem.c b/arch/powerpc/kvm/book3s_hv_uvmem.c
index 79b1202..3331ac5 100644
--- a/arch/powerpc/kvm/book3s_hv_uvmem.c
+++ b/arch/powerpc/kvm/book3s_hv_uvmem.c
@@ -804,6 +804,11 @@ int kvmppc_uvmem_init(void)
return ret;
}
+int kvmppc_uv_enabled(void)
+{
+ return !kvmppc_uvmem_bitmap;
+}
+
void kvmppc_uvmem_free(void)
{
memunmap_pages(&kvmppc_uvmem_pgmap);
------------------
>
> Paul.
--
Ram Pai
next prev parent reply other threads:[~2020-03-20 1:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-19 4:33 [PATCH] KVM: PPC: Book3S HV: Add a capability for enabling secure guests Paul Mackerras
2020-03-19 16:30 ` Greg Kurz
2020-03-19 17:44 ` Fabiano Rosas
2020-03-19 17:52 ` Cédric Le Goater
2020-03-19 19:41 ` Ram Pai
2020-03-19 23:17 ` Paul Mackerras
2020-03-20 1:20 ` Ram Pai [this message]
2020-03-23 3:18 ` David Gibson
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=20200320012059.GC5563@oc0525413822.ibm.com \
--to=linuxram@us.ibm.com \
--cc=david@gibson.dropbear.id.au \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=paulus@ozlabs.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;
as well as URLs for NNTP newsgroup(s).