From: Wei Liu <wei.liu2@citrix.com>
To: xen-devel@lists.xen.org
Cc: Wei Liu <wei.liu2@citrix.com>,
dgdegra@tycho.nsa.gov, ian.jackson@eu.citrix.com,
ian.campbell@citrix.com
Subject: [OSSTEST PATCH v2 08/12] ts-xen-install: install Xen with XSM support if requested
Date: Wed, 24 Sep 2014 22:04:33 +0100 [thread overview]
Message-ID: <1411592677-2632-9-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1411592677-2632-1-git-send-email-wei.liu2@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
ts-xen-install | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 114 insertions(+), 1 deletion(-)
diff --git a/ts-xen-install b/ts-xen-install
index 4d34d1f..3bc4d2e 100755
--- a/ts-xen-install
+++ b/ts-xen-install
@@ -46,6 +46,8 @@ if (@ARGV and $ARGV[0] eq '--check') {
our $ho;
+my $enable_xsm = $r{enable_xsm} =~ m/y/ ? 1 : 0;
+
my %distpath;
sub packages () {
@@ -73,6 +75,15 @@ sub extract () {
$r{"${part}buildjob"}, \%distpath);
}
target_cmd_root($ho, '/sbin/ldconfig');
+ if ($enable_xsm) {
+ my $flaskpolicy = target_cmd_output_root($ho,
+ 'find /boot -name \'xenpolicy-*\' -exec basename {} \;');
+ # there should only be one xenpolicy file for a clean install
+ my $c = () = $flaskpolicy =~ /xenpolicy/g;
+ die "Too many XSM policy files $c" if $c > 1;
+ die "XSM policy file is required" if $c == 0;
+ store_runvar("flaskpolicy", $flaskpolicy);
+ }
}
sub adjustconfig () {
@@ -133,6 +144,86 @@ sub adjustconfig () {
setup_cxfabric($ho);
}
+
+sub grub_patch () {
+ return << 'END';
+--- /etc/grub.d/20_linux_xen.orig 2014-09-22 11:39:09.120630051 +0100
++++ /etc/grub.d/20_linux_xen 2014-09-22 11:43:07.069802099 +0100
+@@ -63,10 +63,27 @@
+ recovery="$4"
+ args="$5"
+ xen_args="$6"
+- if ${recovery} ; then
+- title="$(gettext_quoted "%s, with Linux %s and XEN %s (recovery mode)")"
++ xsm="$7"
++ # If user want to enable XSM support, make sure there's corresponding
++ # policy file.
++ if ${xsm} ; then
++ xenpolicy=`echo xenpolicy-$xen_version`
++ if test ! -e "${xen_dirname}/${xenpolicy}" ; then
++ return
++ fi
++ xen_args=`echo $xen_args flask_enabled=1 flask_enforcing=1`
++ if ${recovery} ; then
++ title="$(gettext_quoted "%s, with Xen %s (XSM enabled) and Linux %s (recovery mode)")"
++ else
++ title="$(gettext_quoted "%s, with Xen %s (XSM enabled) and Linux %s")"
++ fi
+ else
+- title="$(gettext_quoted "%s, with Linux %s and XEN %s")"
++ xenpolicy=""
++ if ${recovery} ; then
++ title="$(gettext_quoted "%s, with Linux %s and XEN %s (recovery mode)")"
++ else
++ title="$(gettext_quoted "%s, with Linux %s and XEN %s")"
++ fi
+ fi
+ printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}" "${xen_version}"
+ save_default_entry | sed -e "s/^/\t/"
+@@ -88,6 +105,13 @@
+ module ${rel_dirname}/${initrd}
+ EOF
+ fi
++ if test -n "${xenpolicy}" ; then
++ message="$(gettext_printf "Loading XSM policy ...")"
++ cat << EOF
++ echo '$message'
++ module ${rel_dirname}/${xenpolicy}
++EOF
++ fi
+ cat << EOF
+ }
+ EOF
+@@ -98,7 +122,7 @@
+ version=$(echo $basename | sed -e "s,^[^0-9]*-,,g")
+ if grub_file_is_not_garbage "$i" && grep -qx 'CONFIG_XEN_\(DOM0\|PRIVILEGED_GUEST\)=y' /boot/config-${version} 2> /dev/null ; then echo -n "$i " ; fi
+ done`
+-xen_list=`for i in /boot/xen*; do
++xen_list=`for i in /boot/xen[-.]*; do
+ if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
+ done`
+ prepare_boot_cache=
+@@ -137,10 +161,14 @@
+ fi
+
+ linux_entry "${OS}" "${version}" "${xen_version}" false \
+- "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
++ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}" false
++ linux_entry "${OS}" "${version}" "${xen_version}" false \
++ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}" true
+ if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
+ linux_entry "${OS}" "${version}" "${xen_version}" true \
+- "single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
++ "single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}" false
++ linux_entry "${OS}" "${version}" "${xen_version}" true \
++ "single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}" true
+ fi
+
+ list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
+
+END
+}
+
sub setupboot () {
my $xenhopt= "conswitch=x watchdog";
@@ -170,8 +261,30 @@ sub setupboot () {
};
}
+ if ($enable_xsm) {
+ die if !defined($r{flaskpolicy});
+ target_putfilecontents_root_stash($ho, 10, grub_patch(), "grub.patch");
+ target_cmd_root($ho, << 'END');
+if test ! -e /etc/grub.d/20_linux_xen ; then
+ case `uname -m` in
+ x86*) echo '/etc/grub.d/20_linux_xen doesn't exist, abort'
+ exit 1 ;;
+ arm*) echo '/etc/grub.d/20_linux_xen doesn't exist on ARM, not patching'
+ exit 0 ;;
+ *) echo 'unknown architecture, abort'
+ exit 1;;
+ esac
+elif ! grep -q -- xenpolicy /etc/grub.d/20_linux_xen ; then
+ patch -p0 /etc/grub.d/20_linux_xen < grub.patch
+else
+ echo 'Grub script already supports XSM, not patching'
+ exit 1
+fi
+END
+ }
+
my $want_kernver = get_runvar('kernel_ver',$r{'kernbuildjob'});
- debian_boot_setup($ho, $want_kernver, $xenhopt, \%distpath, \@hooks);
+ debian_boot_setup($ho, $want_kernver, $enable_xsm, $xenhopt, \%distpath, \@hooks);
logm("ready to boot Xen");
}
--
1.7.10.4
next prev parent reply other threads:[~2014-09-24 21:04 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-24 21:04 [OSSTEST PATCH v2 00/12] XSM test cases for OSSTest Wei Liu
2014-09-24 21:04 ` [OSSTEST PATCH v2 01/12] README: list chiark-utils-bin as requirement Wei Liu
2014-10-10 15:28 ` Ian Jackson
2014-09-24 21:04 ` [OSSTEST PATCH v2 02/12] gitignore: ignore images directory Wei Liu
2014-10-10 15:28 ` Ian Jackson
2014-09-24 21:04 ` [OSSTEST PATCH v2 03/12] ts-xen-build-prep: install checkpolicy Wei Liu
2014-10-10 15:28 ` Ian Jackson
2014-09-24 21:04 ` [OSSTEST PATCH v2 04/12] ts-xen-build: build with XSM support if requested Wei Liu
2014-10-10 15:29 ` Ian Jackson
2014-09-24 21:04 ` [OSSTEST PATCH v2 05/12] mfi-common: create build-$arch-xsm job Wei Liu
2014-10-10 15:32 ` Ian Jackson
2014-10-10 15:38 ` Wei Liu
2014-09-24 21:04 ` [OSSTEST PATCH v2 06/12] Debian.pm: pass in XSM configuration to bootloader setup routines Wei Liu
2014-10-10 15:39 ` Ian Jackson
2014-09-24 21:04 ` [OSSTEST PATCH v2 07/12] Debian.pm: load flask policy in uboot Wei Liu
2014-10-10 15:39 ` Ian Jackson
2014-10-10 15:55 ` Wei Liu
2014-10-10 16:06 ` Ian Jackson
2014-09-24 21:04 ` Wei Liu [this message]
2014-10-10 15:51 ` [OSSTEST PATCH v2 08/12] ts-xen-install: install Xen with XSM support if requested Ian Jackson
2014-10-10 16:27 ` Wei Liu
2014-10-10 16:38 ` Ian Jackson
2014-09-24 21:04 ` [OSSTEST PATCH v2 09/12] mfi-common: use XSM build if job name contains -xsm suffix Wei Liu
2014-10-10 15:53 ` Ian Jackson
2014-09-24 21:04 ` [OSSTEST PATCH v2 10/12] make-flight: create XSM test jobs Wei Liu
2014-10-10 16:00 ` Ian Jackson
2014-10-13 18:41 ` Wei Liu
2014-10-14 15:41 ` Ian Jackson
2014-10-14 16:10 ` Wei Liu
2014-09-24 21:04 ` [OSSTEST PATCH v2 11/12] ts-debian-install: add in seclabel if XSM is enabled Wei Liu
2014-10-10 16:01 ` Ian Jackson
2014-10-10 16:29 ` Wei Liu
2014-10-10 16:41 ` Ian Jackson
2014-10-10 17:11 ` Wei Liu
2014-10-10 17:26 ` Ian Jackson
2014-10-10 17:31 ` Wei Liu
2014-10-14 7:26 ` Ian Campbell
2014-10-14 14:04 ` Ian Jackson
2014-09-24 21:04 ` [OSSTEST PATCH v2 12/12] ts-debian-hvm-install: " Wei Liu
2014-10-10 16:03 ` Ian Jackson
2014-10-10 16:36 ` Wei Liu
2014-10-10 17:25 ` Ian Jackson
2014-10-10 12:14 ` [OSSTEST PATCH v2 00/12] XSM test cases for OSSTest Wei Liu
2014-10-10 14:20 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1411592677-2632-9-git-send-email-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).