Re: [RFC v3][PATCH 2/2] intel_txt: Intel(R) TXT and tboot kernel support

Ingo Molnar
2009-05-12T09:46:29Z

* Cihula, Joseph <joseph.cihula@intel.com> wrote:

> > From: Ingo Molnar [mailto:mingo@elte.hu]
> > Sent: Friday, May 08, 2009 2:58 AM
> >
> > * Joseph Cihula <joseph.cihula@intel.com> wrote:
> >
> > > + /* if we're being called before the 1:1 mapping is set up then just
> > > + return and let the normal shutdown happen; this should only be
> > > + due to very early panic() */
> > > + if (!tboot_pg_dir)
> > > + return;
> >
> > Please use the customary comment style:
> >
> > /*
> > * Comment .....
> > * ...... goes here:
> > */
> >
> > specified in Documentation/CodingStyle. Please fix this in all other
> > multi-line comments in your patch as well.
>
> Will do.
>
> > > + if (shutdown_type == TB_SHUTDOWN_S3) {
> > > + tboot_shared->num_mac_regions = 3;
> > > + /* S3 resume code */
> > > + tboot_shared->mac_regions[0].start =
> > > + PFN_PHYS(PFN_DOWN(acpi_wakeup_address));
> > > + tboot_shared->mac_regions[0].size =
> > > + PFN_UP(WAKEUP_SIZE) << PAGE_SHIFT;
> > > + /* AP trampoline code */
> > > + tboot_shared->mac_regions[1].start =
> > > + PFN_PHYS(PFN_DOWN(virt_to_phys(trampoline_base)));
> > > + tboot_shared->mac_regions[1].size =
> > > + PFN_UP(TRAMPOLINE_SIZE) << PAGE_SHIFT;
> > > + /* kernel code + data + bss */
> > > + tboot_shared->mac_regions[2].start =
> > > + PFN_PHYS(PFN_DOWN(virt_to_phys(&_text)));
> > > + tboot_shared->mac_regions[2].size =
> > > + PFN_PHYS(PFN_UP(virt_to_phys(&_end))) -
> > > + PFN_PHYS(PFN_DOWN(virt_to_phys(&_text)));
> > > + }
> > > +
> > > + tboot_shared->shutdown_type = shutdown_type;
> > > +
> > > + switch_to_tboot_pt();
> > > +
> > > + ((void(*)(void))(unsigned long)tboot_shared->shutdown_entry)();
> >
> > shutdown_entry should probably have a proper function pointer
> > type, to avoid this ugliness.
>
> Since pointer types are different lengths depending on whether it
> is a 32b or 64b build environment, that would not allow a
> separately-compiled tboot to be used with both 32b and 64b
> kernels.

then the sign extension is done slightly wrong/unclean i guess.
Wouldnt:

> > > + ((void(*)(void))(long)tboot_shared->shutdown_entry)();

be better? Or is shutdown_entry always mapped into [0..2GB) on
64-bit? Even then, not sign-extending RIP addresses is wrong and
invites bugs/restrictions.

Ingo