Provide configuration variables to customize the command line.
Configuration is read from /etc/default/grub-tboot.

Command line for tboot itself: GRUB_CMDLINE_TBOOT
Linux kernel parameters to append for tboot: GRUB_CMDLINE_LINUX_TBOOT
Xen parameters to append for tboot: GRUB_CMDLINE_XEN_TBOOT
Linux kernel parameters to append for tboot + Xen:
GRUB_CMDLINE_LINUX_XEN_TBOOT

# HG changeset patch
# User Martin Wilck <martin.wi...@ts.fujitsu.com>
# Date 1456314107 -3600
#      Wed Feb 24 12:41:47 2016 +0100
# Branch mw-001
# Node ID cfcea2044adf6bb226b23082a117687feb108f0c
# Parent  498de007f4eaf9114a7df617d9202ad09615eacc
grub2 support: allow the user to customize the command line

Provide configuration variables to be customize the command line.
Configuration is read from /etc/default/grub-tboot.

Command line for tboot itself: GRUB_CMDLINE_TBOOT
Linux kernel parameters to append for tboot: GRUB_CMDLINE_LINUX_TBOOT
Xen parameters to append for tboot: GRUB_CMDLINE_XEN_TBOOT
Linux kernel parameters to append for tboot + Xen: GRUB_CMDLINE_LINUX_XEN_TBOOT

diff -r 498de007f4ea -r cfcea2044adf tboot/20_linux_tboot
--- a/tboot/20_linux_tboot	Wed Feb 24 09:17:24 2016 +0100
+++ b/tboot/20_linux_tboot	Wed Feb 24 12:41:47 2016 +0100
@@ -21,12 +21,44 @@
 exec_prefix=${prefix}
 bindir=${exec_prefix}/bin
 libdir=${exec_prefix}/lib
+sysconfdir=/etc
 if test -e /usr/share/grub/grub-mkconfig_lib; then
   . /usr/share/grub/grub-mkconfig_lib
 elif test -e ${libdir}/grub/grub-mkconfig_lib; then
   . ${libdir}/grub/grub-mkconfig_lib
 fi
 
+if test -e ${sysconfdir}/default/grub-tboot; then
+  .  ${sysconfdir}/default/grub-tboot
+fi
+
+# Set the following variables in /etc/default/grub-tboot to customize command lines
+# (empty values are treated as if the variables were unset).
+[ -z "${GRUB_CMDLINE_TBOOT}" ] && unset GRUB_CMDLINE_TBOOT
+[ -z "${GRUB_CMDLINE_LINUX_TBOOT}" ] && unset GRUB_CMDLINE_LINUX_TBOOT
+# Command line for tboot itself
+: ${GRUB_CMDLINE_TBOOT='logging=serial,memory,vga'}
+# Linux kernel parameters to append for tboot
+: ${GRUB_CMDLINE_LINUX_TBOOT='intel_iommu=on'}
+
+# VGA logging is not supported in UEFI environment
+if [ -d /sys/firmware/efi ]; then
+  _cmdline=
+  for _arg in ${GRUB_CMDLINE_TBOOT}; do
+    case ${_arg} in
+      logging=*vga*)
+	echo "UEFI environment: deactivating VGA logging for tboot" >&2
+	_arg=`echo "${_arg}" | sed -e 's/=vga,/=/' -e s'/,\{0,1\}vga//' -e s'/=$/=none/'`;;
+    esac
+    if [ -z "${_cmdline}" ]; then
+      _cmdline=${_arg}
+    else
+      _cmdline="${_cmdline} ${_arg}"
+    fi
+  done
+  GRUB_CMDLINE_TBOOT=${_cmdline}
+fi
+
 export TEXTDOMAIN=grub
 export TEXTDOMAINDIR=${prefix}/share/locale
 
@@ -173,18 +205,13 @@
 	    linux_root_device_thisversion=${GRUB_DEVICE}
 	fi
 	
-	if [ -d /sys/firmware/efi ] ; then
-	    # there's no vga console available under EFI
-	    tboot_log="logging=serial,memory"
-	else
-	    tboot_log="logging=serial,vga,memory"
-	fi
-
 	linux_entry "${OS}" "${version}" "${tboot_version}" false \
-	    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ${tboot_log} "intel_iommu=on"
+		    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_TBOOT}" \
+		    "${GRUB_CMDLINE_LINUX_TBOOT}"
 	if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
 	    linux_entry "${OS}" "${version}" "${tboot_version}" true \
-		"single ${GRUB_CMDLINE_LINUX}" ${tboot_log} "intel_iommu=on"
+			"single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_TBOOT}" \
+			"${GRUB_CMDLINE_LINUX_TBOOT}"
 	fi
 
 	list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
diff -r 498de007f4ea -r cfcea2044adf tboot/20_linux_xen_tboot
--- a/tboot/20_linux_xen_tboot	Wed Feb 24 09:17:24 2016 +0100
+++ b/tboot/20_linux_xen_tboot	Wed Feb 24 12:41:47 2016 +0100
@@ -21,12 +21,29 @@
 exec_prefix=${prefix}
 bindir=${exec_prefix}/bin
 libdir=${exec_prefix}/lib
+sysconfdir=/etc
 if test -e /usr/share/grub/grub-mkconfig_lib; then
   . /usr/share/grub/grub-mkconfig_lib
 elif test -e ${libdir}/grub/grub-mkconfig_lib; then
   . ${libdir}/grub/grub-mkconfig_lib
 fi
 
+if test -e ${sysconfdir}/default/grub-tboot; then
+  .  ${sysconfdir}/default/grub-tboot
+fi
+
+# Set the following variables in /etc/default/grub-tboot to customize command lines
+# (empty values are treated as if the variables were unset).
+[ -z "${GRUB_CMDLINE_TBOOT}" ] && unset GRUB_CMDLINE_TBOOT
+[ -z "${GRUB_CMDLINE_XEN_TBOOT}" ] && unset GRUB_CMDLINE_XEN_TBOOT
+[ -z "${GRUB_CMDLINE_LINUX_XEN_TBOOT}" ] && unset GRUB_CMDLINE_LINUX_XEN_TBOOT
+# Command line for tboot itself
+: ${GRUB_CMDLINE_TBOOT='logging=serial,memory,vga'}
+# Xen parameters to append for tboot
+: ${GRUB_CMDLINE_XEN_TBOOT=''}
+# Linux kernel parameters to append for tboot + Xen
+: ${GRUB_CMDLINE_LINUX_XEN_TBOOT=''}
+
 export TEXTDOMAIN=grub
 export TEXTDOMAINDIR=${prefix}/share/locale
 
@@ -203,10 +220,14 @@
             fi
 
             linux_entry "${OS}" "${version}" "${xen_version}" false \
-	        "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}" "${tboot_version}" "logging=serial,vga,memory" "iommu=force"
+			"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_XEN_TBOOT}" \
+			"${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT} ${GRUB_CMDLINE_XEN_TBOOT}" \
+			"${tboot_version}" "${GRUB_CMDLINE_TBOOT}" "iommu=force"
             if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
                 linux_entry "${OS}" "${version}" "${xen_version}" true \
-		    "single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}" "${tboot_version}" "logging=serial,vga,memory" "iommu=force"
+			    "single ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_XEN_TBOOT}" \
+			    "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_TBOOT}" \
+			    "${tboot_version}" "${GRUB_CMDLINE_TBOOT}" "iommu=force"
             fi
 
             list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
tboot-devel mailing list
tboot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tboot-devel

Reply via email to