From: Daniel De Graaf Subject: Re: [PATCH v3 09/14] vTPM/TPM2: Support 'tpm2' extra command line. Date: Tue, 13 Jan 2015 10:50:14 -0500 Message-ID: <54B53EB6.2090000@tycho.nsa.gov> References: <1420005061-25816-1-git-send-email-quan.xu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1420005061-25816-1-git-send-email-quan.xu@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Quan Xu , xen-devel@lists.xen.org Cc: samuel.thibault@ens-lyon.org, stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org On 12/31/2014 12:51 AM, Quan Xu wrote: > Make vtpm-stubdom domain compatible to launch on TPM 1.x / TPM 2.0. > Add: > .. > extra="tpm2" > .. > to launch vtpm-stubdom domain on TPM 2.0, ignore it on TPM 1.x. for > example, > vtpm-stubdom domain configuration on TPM 2.0: > > kernel="/usr/lib/xen/boot/vtpmmgr-stubdom.gz" > memory=16 > disk=["file:/var/scale/vdisk/vmgr,hda,w"] > name="vtpmmgr" > iomem=["fed40,5"] > extra="tpm2" > > vtpm-stubdom domain configuration on TPM 1.x: > > kernel="/usr/lib/xen/boot/vtpmmgr-stubdom.gz" > memory=16 > disk=["file:/var/scale/vdisk/vmgr,hda,w"] > name="vtpmmgr" > iomem=["fed40,5"] > > Signed-off-by: Quan Xu > --- > stubdom/vtpmmgr/vtpmmgr.c | 46 ++++++++++++++++++++++++++++++++++++++++------ > stubdom/vtpmmgr/vtpmmgr.h | 14 ++++++++++++++ > 2 files changed, 54 insertions(+), 6 deletions(-) > > diff --git a/stubdom/vtpmmgr/vtpmmgr.c b/stubdom/vtpmmgr/vtpmmgr.c > index 270ca8a..f743ca6 100644 > --- a/stubdom/vtpmmgr/vtpmmgr.c > +++ b/stubdom/vtpmmgr/vtpmmgr.c > @@ -45,6 +45,27 @@ > #include "vtpmmgr.h" > #include "tcg.h" > > +struct tpm_hardware_version hardware_version = { > + .hw_version = TPM1_HARDWARE, > +}; > + > +int parse_cmdline_hw(int argc, char** argv) > +{ > + int i; > + > + for (i = 1; i < argc; ++i) { > + if (!strncmp(argv[i], TPM2_EXTRA_OPT, 4)) { > + hardware_version.hw_version = TPM2_HARDWARE; > + break; > + } > + } > + return 0; > +} I would change this from strncmp to strcmp so that it does not just match any argument that starts with "tpm2". If you also want to support "tpm2=1", then checking for that explicitly is preferred. Currently, "tpm2=0" will enable the tpm2 driver, which is confusing. -- Daniel De Graaf National Security Agency