From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [PATCH] add privileged/unprivileged kernel feature indication Date: Tue, 05 Jul 2011 14:34:00 +0100 Message-ID: <4E132EE8020000780004C2ED@nat28.tlf.novell.com> References: <4E132450020000780004C297@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <4E132450020000780004C297@nat28.tlf.novell.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org >>> On 05.07.11 at 14:48, "Jan Beulich" wrote: > With our switching away from supporting 32-bit Dom0 operation, users > complained that attempts (perhaps due to lack of knowledge of that > change) to boot the no longer privileged kernel in Dom0 resulted in > apparently silent failure. To make the mismatch explicit and visible, > add feature flags that the kernel can set to indicate operation in > what modes it supports. For backward compatibility, absence of both > feature flags is taken to indicate a kernel that may be capable of > operating in both modes. With elf_xen_parse_features() erroring out upon encountering an unrecognized feature, the only alternative to this approach that I can see would be to add a new note type, and store the information there. With that, it would seem to make sense to store all required/supported features in binary form, making the parsing unnecessary on hypervisors that understand this new note type. Does anyone have any other ideas? Should this erroring out be fixed (to only do so on unrecognized *required* features) at least for future releases? Jan > Signed-off-by: Jan Beulich >=20 > --- a/tools/libxc/xc_dom_elfloader.c > +++ b/tools/libxc/xc_dom_elfloader.c > @@ -286,6 +286,15 @@ static int xc_dom_parse_elf_kernel(struc > if ( (rc =3D elf_xen_parse(elf, &dom->parms)) !=3D 0 ) > return rc; > =20 > + if ( elf_xen_feature_get(XENFEAT_privileged, dom->parms.f_required) = || > + (elf_xen_feature_get(XENFEAT_privileged, dom->parms.f_supported= ) && > + !elf_xen_feature_get(XENFEAT_unprivileged, dom->parms.f_suppor= ted))=20 > ) > + { > + xc_dom_panic(dom->xch, XC_INVALID_KERNEL, "%s: Kernel does not" > + " support unprivileged (DomU) operation",=20 > __FUNCTION__); > + return -EINVAL; > + } > + > /* find kernel segment */ > dom->kernel_seg.vstart =3D dom->parms.virt_kstart; > dom->kernel_seg.vend =3D dom->parms.virt_kend; > --- a/xen/arch/ia64/xen/domain.c > +++ b/xen/arch/ia64/xen/domain.c > @@ -2164,6 +2164,14 @@ int __init construct_dom0(struct domain=20 > return -1; > } > =20 > + if (test_bit(XENFEAT_unprivileged, parms.f_required) || > + (test_bit(XENFEAT_unprivileged, parms.f_supported) && > + !test_bit(XENFEAT_privileged, parms.f_supported))) > + { > + printk("Kernel does not support Dom0 operation\n"); > + return -1; > + } > + > p_start =3D parms.virt_base; > pkern_start =3D parms.virt_kstart; > pkern_end =3D parms.virt_kend; > --- a/xen/arch/x86/domain_build.c > +++ b/xen/arch/x86/domain_build.c > @@ -415,6 +415,14 @@ int __init construct_dom0( > return -EINVAL; > } > =20 > + if ( test_bit(XENFEAT_unprivileged, parms.f_required) || > + (test_bit(XENFEAT_unprivileged, parms.f_supported) && > + !test_bit(XENFEAT_privileged, parms.f_supported)) ) > + { > + printk("Kernel does not support Dom0 operation\n"); > + return -EINVAL; > + } > + > #if defined(__x86_64__) > if ( compat32 ) > { > --- a/xen/common/kernel.c > +++ b/xen/common/kernel.c > @@ -278,7 +278,8 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDL > switch ( fi.submap_idx ) > { > case 0: > - fi.submap =3D 0; > + fi.submap =3D 1U << (IS_PRIV(current->domain) ? > + XENFEAT_privileged : XENFEAT_unprivileged= ); > if ( VM_ASSIST(d, VMASST_TYPE_pae_extended_cr3) ) > fi.submap |=3D (1U << XENFEAT_pae_pgdir_above_4gb); > if ( paging_mode_translate(current->domain) ) > --- a/xen/common/libelf/libelf-dominfo.c > +++ b/xen/common/libelf/libelf-dominfo.c > @@ -26,7 +26,9 @@ static const char *const elf_xen_feature > [XENFEAT_writable_descriptor_tables] =3D "writable_descriptor_tables= ", > [XENFEAT_auto_translated_physmap] =3D "auto_translated_physmap", > [XENFEAT_supervisor_mode_kernel] =3D "supervisor_mode_kernel", > - [XENFEAT_pae_pgdir_above_4gb] =3D "pae_pgdir_above_4gb" > + [XENFEAT_pae_pgdir_above_4gb] =3D "pae_pgdir_above_4gb", > + [XENFEAT_privileged] =3D "privileged", > + [XENFEAT_unprivileged] =3D "unprivileged" > }; > static const int elf_xen_features =3D > sizeof(elf_xen_feature_names) / sizeof(elf_xen_feature_names[0]); > --- a/xen/include/public/features.h > +++ b/xen/include/public/features.h > @@ -75,7 +75,13 @@ > #define XENFEAT_hvm_safe_pvclock 9 > =20 > /* x86: pirq can be used by HVM guests */ > -#define XENFEAT_hvm_pirqs 10 > +#define XENFEAT_hvm_pirqs 10 > + > +/* privileged operation is supported */ > +#define XENFEAT_privileged 11 > + > +/* un-privileged operation is supported */ > +#define XENFEAT_unprivileged 12 > =20 > #define XENFEAT_NR_SUBMAPS 1 > =20