From de6b29ab9d1a90a56874e6b33d35b5bf077acbfc Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 20 Dec 2018 11:49:46 -0800 Subject: tpm: Virtio tpm device This CL adds a "tpm" Cargo cfg to crosvm which enables a TPM device backed by libtpm2 simulator. Tested by running the following inside cros_sdk: LIBRARY_PATH=~/src/minijail LD_LIBRARY_PATH=~/src/minijail \ cargo run --release \ --features tpm \ -- \ run \ -r rootfs.ext4 \ --seccomp-policy-dir seccomp/x86_64/ \ -p init=/bin/bash \ -p panic=-1 \ --disable-sandbox \ vmlinux.bin with a Linux image built from CL:1387655. The TPM self test completes successfully with the following output: https://paste.googleplex.com/5996075978588160?raw Justin's TPM playground runs with the following trace output. https://paste.googleplex.com/4909751007707136?raw Design doc: go/vtpm-for-glinux TEST=ran TPM playground program inside crosvm TEST=local kokoro BUG=chromium:911799 Change-Id: I2feb24a3e38cba91f62c6d2cd1f378de4dd03ecf Reviewed-on: https://chromium-review.googlesource.com/1387624 Commit-Ready: David Tolnay Tested-by: David Tolnay Tested-by: kokoro Reviewed-by: Dylan Reid --- tpm2-sys/build.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tpm2-sys/build.rs') diff --git a/tpm2-sys/build.rs b/tpm2-sys/build.rs index f1abd4a..604d936 100644 --- a/tpm2-sys/build.rs +++ b/tpm2-sys/build.rs @@ -8,10 +8,11 @@ use std::path::Path; use std::process::{self, Command}; fn main() -> io::Result<()> { - println!("cargo:rustc-link-lib=ssl"); - println!("cargo:rustc-link-lib=crypto"); - - if pkg_config::probe_library("libtpm2").is_ok() { + if pkg_config::Config::new() + .statik(true) + .probe("libtpm2") + .is_ok() + { // Use tpm2 package from the standard system location if available. return Ok(()); } @@ -44,5 +45,7 @@ fn main() -> io::Result<()> { let dir = env::var("CARGO_MANIFEST_DIR").unwrap(); println!("cargo:rustc-link-search={}/libtpm2/build", dir); println!("cargo:rustc-link-lib=static=tpm2"); + println!("cargo:rustc-link-lib=ssl"); + println!("cargo:rustc-link-lib=crypto"); Ok(()) } -- cgit 1.4.1