Skip to contentSkip to conversation

Provide target_install_packages_nonfree_nonconcurrent

PATCH In review Ian Jackson 2 participants 4 messages Dec 19, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Provide target_install_packages_nonfree_nonconcurrent

Right now this is only useful with Debian. We will call it from ts-host-install to install the microcode.

We enable and then disable non-free so that we don't install non-free packages unintentionally.

---
 Osstest/TestSupport.pm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Osstest/TestSupport.pm +16 -0
index 44f01a86..63087260 100644
@@ -71,6 +71,7 @@ BEGIN {
                       target_editfile_kvp_replace
                       target_run_pkgmanager_install
                       target_install_packages target_install_packages_norec
+		      target_install_packages_nonfree_nonconcurrent
                       target_jobdir target_extract_jobdistpath_subdir
                       target_extract_jobdistpath target_extract_distpart
 		      target_tftp_prefix
@@ -627,6 +628,21 @@ sub target_install_packages_norec ($@) {
     my ($ho, @packages) = @_;
     target_run_pkgmanager_install($ho,\@packages,1);
 }
+sub target_install_packages_nonfree_nonconcurrent ($@) {
+    # inadequate locking, should be called during installation only
+    my ($ho, @packages) = @_;
+    my $slist= '/etc/apt/sources.list';
+    my $xsuites= 'contrib non-free';
+    target_cmd_root($ho, <<END, 30);
+    perl -i~ -pe 'next unless m/^deb/; s{ main\$}{\$& $xsuites};' $slist
+    apt update
+END
+    target_run_pkgmanager_install($ho,\@packages);
+    target_cmd_root($ho, <<END, 30);
+    mv $slist~ $slist
+    apt update
+END
+}
 
 sub tpfcs_core {
     my ($tputfilef,$ho,$timeout,$filedata, $rdest,$lleaf) = @_;
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH 2/3 Revert "Arrange to upgrade microcode on x86 test hosts."

We are going to do this differently, by installing the packages from Debian. We couldn't do that in 2015 because not every version of Xen supported scanning the dom0 initrd for microcode, but now all supported versions do. So we will do that, in a moment.

This reverts commit 6cedb8c7d76a0ab3820ed0a48a3aebcb18fa0813.

---
 Osstest/Debian.pm           | 44 ------------------------
 mg-cpu-microcode-update     | 83 ---------------------------------------------
 production-config           |  5 ---
 production-config-cambridge |  4 ---
 ts-xen-install              |  7 ----
 5 files changed, 143 deletions(-)
 delete mode 100755 mg-cpu-microcode-update
Osstest/Debian.pm +0 -44
index c22aaadf..6e9d2072 100644
@@ -753,48 +753,6 @@ chroot /target chown -R \$u.\$u \$h/.ssh
 END
 }
 
-sub preseed_microcode($$)
-{
-    my ($ho,$sfx) = @_;
-    my $prop = "MicrocodeUpdate".ucfirst($ho->{Arch});
-    return unless $c{$prop};
-    logm("ucode=$prop $c{$prop}");
-    my $ucode = get_filecontents("$c{Images}/$c{$prop}");
-    my $cpio_url = create_webfile($ho, "microcode-cpio",
-	sub {
-	    my $f = "$c{Images}/$c{$prop}";
-	    copy($f, $_[0]) or die "Copy $f failed: $!";
-    });
-
-    # The ability to prepend from an initramfs-hook was not added
-    # until Jessie, therefore for Wheezy we use a custom compression
-    # method which sneaks the necessary cpio onto the front.
-    my $gzip_url = create_webfile($ho, "microcode-gzip",<<END);
-#!/bin/bash
-if [ -f /boot/microcode.cpio ]; then
-    cat /boot/microcode.cpio
-fi
-exec gzip
-END
-
-    preseed_hook_installscript($ho, $sfx,
-       '/usr/lib/base-installer.d/','osstest-microcode', <<END);
-#!/bin/sh
-set -ex
-
-mkdir -p /target/boot
-$preseed_wget -O /target/boot/microcode.cpio $cpio_url
-
-mkdir -p /target/usr/sbin
-$preseed_wget -O /target/usr/sbin/osstest-initramfs-gzip $gzip_url
-chmod +x /target/usr/sbin/osstest-initramfs-gzip
-
-mkdir -p /target/etc/initramfs-tools/conf.d/
-echo COMPRESS=/usr/sbin/osstest-initramfs-gzip >> \\
-	/target/etc/initramfs-tools/conf.d/osstest-initramfs-gzip.conf
-END
-}
-
 sub debian_overlays ($$) {
     my ($ho, $func) = @_;
     # calls $func->($local_dir, $tarball_leafname);
@@ -1503,8 +1461,6 @@ d-i partman-auto/expert_recipe string					\\
 
 END
 
-    preseed_microcode($ho,$sfx);
-
     if (get_host_property($ho, "firmware") eq "uefi") {
 	die unless $ho->{Suite} =~ m/jessie|stretch/;
 	# Prevent grub-install from making a new Debian boot entry, so
mg-cpu-microcode-update deleted +0 -83

83 lines not on this page · raw message

production-config +0 -5
index bd200182..41f68409 100644
@@ -99,11 +99,6 @@ DebianImageVersion_wheezy 7.2.0
 DebianImageVersion_jessie 8.2.0
 DebianImageVersion_stretch 9.4.0
 
-# These should normally be the same.
-# Update with ./mg-cpu-microcode-update
-MicrocodeUpdateAmd64 microcode.x86.2015-06-12.cpio
-MicrocodeUpdateI386 microcode.x86.2015-06-12.cpio
-
 # Update with ./mg-netgrub-loader-update
 TftpGrubVersion XXXX-XX-XX
 
production-config-cambridge +0 -4
index a50b19b3..16cf9bfe 100644
@@ -87,10 +87,6 @@ DebianImageVersion_jessie 8.2.0
 
 DebianExtraPackages_jessie chiark-scripts_6.0.3~citrix1_all.deb
 
-# These should normally be the same.
-MicrocodeUpdateAmd64 microcode.x86.2015-06-12.cpio
-MicrocodeUpdateI386 microcode.x86.2015-06-12.cpio
-
 XenUsePath /usr/groups/xencore/systems/bin/xenuse
 XenUseUser osstest
 
ts-xen-install +0 -7
index d8e9d7e6..9113f318 100755
@@ -209,13 +209,6 @@ sub setupboot () {
         my $mem = $r{'dom0_mem'} // 512;
         $xenhopt .= " dom0_mem=${mem}M,max:${mem}M";
     }
-
-    # If /boot/microcode.cpio is present then ts-host-install has
-    # arranged that it will be prepended to the initrd already, all we
-    # need to do is look for it.
-    $xenhopt .= " ucode=scan"
-	if target_file_exists($ho, "/boot/microcode.cpio");
-
     my $append= $r{xen_boot_append};
     $xenhopt .= " $append" if defined $append;
     $append = get_host_property($ho, 'xen-commandline-append', undef);
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw

PATCH 3/3 microcode: Install Debian microcode packages and add ucode=scan

In reply to Ian Jackson

We are no longer using the frozen-in-amber microcode from 2015. Now we use current microcode from Debian (or hopefully in future via other distros).

Empirically this fixes the XSA-308 test on rimava1, which was failing and producing very strange symptoms.

---
 ts-host-install | 6 ++++++
 ts-xen-install  | 2 ++
 2 files changed, 8 insertions(+)
ts-host-install +6 -0
index 4bfa2f5e..7a72a867 100755
@@ -139,6 +139,12 @@ END
     target_cmd_root($ho, "chmod 2775 /root");
 
     target_install_packages($ho, qw(ed));
+    if ($ho->{Arch} =~ m/^(?:i386|amd64)$/) {
+	# We don't necessarily know the CPU vendor, but the Debian
+	# packaged microcode doesn't mind us installing both.
+	target_install_packages_nonfree_nonconcurrent($ho,
+            qw(amd64-microcode intel-microcode));
+    }
 
     my $ntpserver = get_target_property($ho, 'NtpServer');
     if ($ntpserver) {
ts-xen-install +2 -0
index 9113f318..08b4ea23 100755
@@ -209,6 +209,8 @@ sub setupboot () {
         my $mem = $r{'dom0_mem'} // 512;
         $xenhopt .= " dom0_mem=${mem}M,max:${mem}M";
     }
+    $xenhopt .= " ucode=scan";
+
     my $append= $r{xen_boot_append};
     $xenhopt .= " $append" if defined $append;
     $append = get_host_property($ho, 'xen-commandline-append', undef);
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 3/3
#3 lore raw

Re: [Xen-devel] [OSSTEST PATCH 3/3] microcode: Install Debian microcode packages and add ucode=scan

Quoted 9 lines · Ian Jackson

We are no longer using the frozen-in-amber microcode from 2015. Now we use current microcode from Debian (or hopefully in future via other distros).

Empirically this fixes the XSA-308 test on rimava1, which was failing and producing very strange symptoms.

This is a definite improvement over the status quo.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel