Blame SOURCES/0005-Add-support-for-Alibaba-cloud-on-aarch64.patch

c5ff1f
From 04b504c47e0dc43c82b0d413a253d0599ce83321 Mon Sep 17 00:00:00 2001
c5ff1f
From: Yongkui Guo <yoguo@redhat.com>
c5ff1f
Date: Mon, 30 Jan 2023 18:20:32 +0800
c5ff1f
Subject: [PATCH] Add support for Alibaba cloud on aarch64
c5ff1f
c5ff1f
This assumes you are running RHEL or another tenant which supports
c5ff1f
ACPI.  It probably won't work for guests using device tree.
c5ff1f
c5ff1f
Also we assume that the hypervisor is KVM.  Since the hypervisor
c5ff1f
indicates that it is RHEL 7, this is very likely to be true, but hard
c5ff1f
to prove since there is no CPUID on Arm.
c5ff1f
c5ff1f
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2165285
c5ff1f
(cherry picked from commit 805604762468b754ea60e5dc176fa26f68d211b8)
c5ff1f
---
c5ff1f
 configure.ac                                  |   2 +
c5ff1f
 tests/alibaba-cloud-arm/Makefile.am           |  28 +++++
c5ff1f
 tests/alibaba-cloud-arm/proc/cpuinfo          |  18 +++
c5ff1f
 tests/alibaba-cloud-arm/proc/self/status      |  57 +++++++++
c5ff1f
 tests/alibaba-cloud-arm/sbin/dmidecode        | 116 ++++++++++++++++++
c5ff1f
 tests/alibaba-cloud-arm/sbin/uname            |   2 +
c5ff1f
 .../sbin/virt-what-cpuid-helper               |   3 +
c5ff1f
 tests/alibaba-cloud-arm/test.sh               |  33 +++++
c5ff1f
 virt-what.in                                  |   5 +
c5ff1f
 9 files changed, 264 insertions(+)
c5ff1f
 create mode 100644 tests/alibaba-cloud-arm/Makefile.am
c5ff1f
 create mode 100644 tests/alibaba-cloud-arm/proc/cpuinfo
c5ff1f
 create mode 100644 tests/alibaba-cloud-arm/proc/self/status
c5ff1f
 create mode 100755 tests/alibaba-cloud-arm/sbin/dmidecode
c5ff1f
 create mode 100755 tests/alibaba-cloud-arm/sbin/uname
c5ff1f
 create mode 100755 tests/alibaba-cloud-arm/sbin/virt-what-cpuid-helper
c5ff1f
 create mode 100755 tests/alibaba-cloud-arm/test.sh
c5ff1f
c5ff1f
diff --git a/configure.ac b/configure.ac
c5ff1f
index a80a4b6f0..cfb7ca371 100644
c5ff1f
--- a/configure.ac
c5ff1f
+++ b/configure.ac
c5ff1f
@@ -34,6 +34,7 @@ AM_CONDITIONAL([HOST_CPU_IA64], [ test "x$host_cpu" = "xia64" ])
c5ff1f
 
c5ff1f
 dnl List of tests.
c5ff1f
 tests="\
c5ff1f
+	alibaba-cloud-arm \
c5ff1f
 	alibaba-cloud-x86 \
c5ff1f
 	aws-baremetal-x86 \
c5ff1f
 	aws-kvm-arm \
c5ff1f
@@ -83,6 +84,7 @@ AC_CONFIG_HEADERS([config.h])
c5ff1f
 AC_CONFIG_FILES([virt-what],[chmod +x virt-what])
c5ff1f
 AC_CONFIG_FILES([Makefile
c5ff1f
                  tests/Makefile
c5ff1f
+                 tests/alibaba-cloud-arm/Makefile
c5ff1f
                  tests/alibaba-cloud-x86/Makefile
c5ff1f
 	         tests/aws-baremetal-x86/Makefile
c5ff1f
 	         tests/aws-kvm-arm/Makefile
c5ff1f
diff --git a/tests/alibaba-cloud-arm/Makefile.am b/tests/alibaba-cloud-arm/Makefile.am
c5ff1f
new file mode 100644
c5ff1f
index 000000000..09ce07861
c5ff1f
--- /dev/null
c5ff1f
+++ b/tests/alibaba-cloud-arm/Makefile.am
c5ff1f
@@ -0,0 +1,28 @@
c5ff1f
+# Makefile for virt-what
c5ff1f
+# Copyright (C) 2008-2023 Red Hat Inc.
c5ff1f
+#
c5ff1f
+# This program is free software; you can redistribute it and/or modify
c5ff1f
+# it under the terms of the GNU General Public License as published by
c5ff1f
+# the Free Software Foundation; either version 2 of the License, or
c5ff1f
+# (at your option) any later version.
c5ff1f
+#
c5ff1f
+# This program is distributed in the hope that it will be useful,
c5ff1f
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
c5ff1f
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c5ff1f
+# GNU General Public License for more details.
c5ff1f
+#
c5ff1f
+# You should have received a copy of the GNU General Public License
c5ff1f
+# along with this program; if not, write to the Free Software
c5ff1f
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
c5ff1f
+
c5ff1f
+CLEANFILES = *~
c5ff1f
+
c5ff1f
+TESTS = test.sh
c5ff1f
+
c5ff1f
+EXTRA_DIST = \
c5ff1f
+	test.sh \
c5ff1f
+	proc/cpuinfo \
c5ff1f
+	proc/self/status \
c5ff1f
+	sbin/dmidecode \
c5ff1f
+	sbin/uname \
c5ff1f
+	sbin/virt-what-cpuid-helper
c5ff1f
diff --git a/tests/alibaba-cloud-arm/proc/cpuinfo b/tests/alibaba-cloud-arm/proc/cpuinfo
c5ff1f
new file mode 100644
c5ff1f
index 000000000..03dbb22ab
c5ff1f
--- /dev/null
c5ff1f
+++ b/tests/alibaba-cloud-arm/proc/cpuinfo
c5ff1f
@@ -0,0 +1,18 @@
c5ff1f
+processor	: 0
c5ff1f
+BogoMIPS	: 50.00
c5ff1f
+Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
c5ff1f
+CPU implementer	: 0x41
c5ff1f
+CPU architecture: 8
c5ff1f
+CPU variant	: 0x3
c5ff1f
+CPU part	: 0xd0c
c5ff1f
+CPU revision	: 1
c5ff1f
+
c5ff1f
+processor	: 1
c5ff1f
+BogoMIPS	: 50.00
c5ff1f
+Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
c5ff1f
+CPU implementer	: 0x41
c5ff1f
+CPU architecture: 8
c5ff1f
+CPU variant	: 0x3
c5ff1f
+CPU part	: 0xd0c
c5ff1f
+CPU revision	: 1
c5ff1f
+
c5ff1f
diff --git a/tests/alibaba-cloud-arm/proc/self/status b/tests/alibaba-cloud-arm/proc/self/status
c5ff1f
new file mode 100644
c5ff1f
index 000000000..08c63e9cb
c5ff1f
--- /dev/null
c5ff1f
+++ b/tests/alibaba-cloud-arm/proc/self/status
c5ff1f
@@ -0,0 +1,57 @@
c5ff1f
+Name:	cat
c5ff1f
+Umask:	0022
c5ff1f
+State:	R (running)
c5ff1f
+Tgid:	6341
c5ff1f
+Ngid:	0
c5ff1f
+Pid:	6341
c5ff1f
+PPid:	1588
c5ff1f
+TracerPid:	0
c5ff1f
+Uid:	0	0	0	0
c5ff1f
+Gid:	0	0	0	0
c5ff1f
+FDSize:	256
c5ff1f
+Groups:	0 
c5ff1f
+NStgid:	6341
c5ff1f
+NSpid:	6341
c5ff1f
+NSpgid:	6341
c5ff1f
+NSsid:	1588
c5ff1f
+VmPeak:	    2352 kB
c5ff1f
+VmSize:	    2352 kB
c5ff1f
+VmLck:	       0 kB
c5ff1f
+VmPin:	       0 kB
c5ff1f
+VmHWM:	     768 kB
c5ff1f
+VmRSS:	     768 kB
c5ff1f
+RssAnon:	      80 kB
c5ff1f
+RssFile:	     688 kB
c5ff1f
+RssShmem:	       0 kB
c5ff1f
+VmData:	     348 kB
c5ff1f
+VmStk:	     132 kB
c5ff1f
+VmExe:	      24 kB
c5ff1f
+VmLib:	    1728 kB
c5ff1f
+VmPTE:	      44 kB
c5ff1f
+VmSwap:	       0 kB
c5ff1f
+HugetlbPages:	       0 kB
c5ff1f
+CoreDumping:	0
c5ff1f
+THP_enabled:	1
c5ff1f
+Threads:	1
c5ff1f
+SigQ:	0/29002
c5ff1f
+SigPnd:	0000000000000000
c5ff1f
+ShdPnd:	0000000000000000
c5ff1f
+SigBlk:	0000000000000000
c5ff1f
+SigIgn:	0000000000000000
c5ff1f
+SigCgt:	0000000000000000
c5ff1f
+CapInh:	0000000000000000
c5ff1f
+CapPrm:	000001ffffffffff
c5ff1f
+CapEff:	000001ffffffffff
c5ff1f
+CapBnd:	000001ffffffffff
c5ff1f
+CapAmb:	0000000000000000
c5ff1f
+NoNewPrivs:	0
c5ff1f
+Seccomp:	0
c5ff1f
+Seccomp_filters:	0
c5ff1f
+Speculation_Store_Bypass:	thread vulnerable
c5ff1f
+SpeculationIndirectBranch:	unknown
c5ff1f
+Cpus_allowed:	3
c5ff1f
+Cpus_allowed_list:	0-1
c5ff1f
+Mems_allowed:	00000000,00000001
c5ff1f
+Mems_allowed_list:	0
c5ff1f
+voluntary_ctxt_switches:	0
c5ff1f
+nonvoluntary_ctxt_switches:	0
c5ff1f
diff --git a/tests/alibaba-cloud-arm/sbin/dmidecode b/tests/alibaba-cloud-arm/sbin/dmidecode
c5ff1f
new file mode 100755
c5ff1f
index 000000000..89fa9a34b
c5ff1f
--- /dev/null
c5ff1f
+++ b/tests/alibaba-cloud-arm/sbin/dmidecode
c5ff1f
@@ -0,0 +1,116 @@
c5ff1f
+#!/bin/sh -
c5ff1f
+cat <<'EOF'
c5ff1f
+# dmidecode 3.3
c5ff1f
+Getting SMBIOS data from sysfs.
c5ff1f
+SMBIOS 3.0.0 present.
c5ff1f
+Table at 0x2348C0000.
c5ff1f
+
c5ff1f
+Handle 0x0100, DMI type 1, 27 bytes
c5ff1f
+System Information
c5ff1f
+	Manufacturer: Alibaba Cloud
c5ff1f
+	Product Name: Alibaba Cloud ECS
c5ff1f
+	Version: virt-rhel7.6.0
c5ff1f
+	Serial Number: 8c43355a-242e-42c2-bdf7-9fae99316221
c5ff1f
+	UUID: 8c43355a-242e-42c2-bdf7-9fae99316221
c5ff1f
+	Wake-up Type: Power Switch
c5ff1f
+	SKU Number: Not Specified
c5ff1f
+	Family: Red Hat Enterprise Linux
c5ff1f
+
c5ff1f
+Handle 0x0300, DMI type 3, 21 bytes
c5ff1f
+Chassis Information
c5ff1f
+	Manufacturer: Alibaba Cloud
c5ff1f
+	Type: Other
c5ff1f
+	Lock: Not Present
c5ff1f
+	Version: virt-rhel7.6.0
c5ff1f
+	Serial Number: Not Specified
c5ff1f
+	Asset Tag: Not Specified
c5ff1f
+	Boot-up State: Safe
c5ff1f
+	Power Supply State: Safe
c5ff1f
+	Thermal State: Safe
c5ff1f
+	Security Status: Unknown
c5ff1f
+	OEM Information: 0x00000000
c5ff1f
+	Height: Unspecified
c5ff1f
+	Number Of Power Cords: Unspecified
c5ff1f
+	Contained Elements: 0
c5ff1f
+
c5ff1f
+Handle 0x0400, DMI type 4, 42 bytes
c5ff1f
+Processor Information
c5ff1f
+	Socket Designation: CPU 0
c5ff1f
+	Type: Central Processor
c5ff1f
+	Family: Other
c5ff1f
+	Manufacturer: Alibaba Cloud
c5ff1f
+	ID: 00 00 00 00 00 00 00 00
c5ff1f
+	Version: virt-rhel7.6.0
c5ff1f
+	Voltage: Unknown
c5ff1f
+	External Clock: Unknown
c5ff1f
+	Max Speed: 2000 MHz
c5ff1f
+	Current Speed: 2000 MHz
c5ff1f
+	Status: Populated, Enabled
c5ff1f
+	Upgrade: Other
c5ff1f
+	L1 Cache Handle: Not Provided
c5ff1f
+	L2 Cache Handle: Not Provided
c5ff1f
+	L3 Cache Handle: Not Provided
c5ff1f
+	Serial Number: Not Specified
c5ff1f
+	Asset Tag: Not Specified
c5ff1f
+	Part Number: Not Specified
c5ff1f
+	Core Count: 2
c5ff1f
+	Core Enabled: 2
c5ff1f
+	Thread Count: 1
c5ff1f
+	Characteristics: None
c5ff1f
+
c5ff1f
+Handle 0x1000, DMI type 16, 23 bytes
c5ff1f
+Physical Memory Array
c5ff1f
+	Location: Other
c5ff1f
+	Use: System Memory
c5ff1f
+	Error Correction Type: Multi-bit ECC
c5ff1f
+	Maximum Capacity: 8 GB
c5ff1f
+	Error Information Handle: Not Provided
c5ff1f
+	Number Of Devices: 1
c5ff1f
+
c5ff1f
+Handle 0x1100, DMI type 17, 40 bytes
c5ff1f
+Memory Device
c5ff1f
+	Array Handle: 0x1000
c5ff1f
+	Error Information Handle: Not Provided
c5ff1f
+	Total Width: Unknown
c5ff1f
+	Data Width: Unknown
c5ff1f
+	Size: 8 GB
c5ff1f
+	Form Factor: DIMM
c5ff1f
+	Set: None
c5ff1f
+	Locator: DIMM 0
c5ff1f
+	Bank Locator: Not Specified
c5ff1f
+	Type: RAM
c5ff1f
+	Type Detail: Other
c5ff1f
+	Speed: Unknown
c5ff1f
+	Manufacturer: Alibaba Cloud
c5ff1f
+	Serial Number: Not Specified
c5ff1f
+	Asset Tag: Not Specified
c5ff1f
+	Part Number: Not Specified
c5ff1f
+	Rank: Unknown
c5ff1f
+	Configured Memory Speed: Unknown
c5ff1f
+	Minimum Voltage: Unknown
c5ff1f
+	Maximum Voltage: Unknown
c5ff1f
+	Configured Voltage: Unknown
c5ff1f
+
c5ff1f
+Handle 0x2000, DMI type 32, 11 bytes
c5ff1f
+System Boot Information
c5ff1f
+	Status: No errors detected
c5ff1f
+
c5ff1f
+Handle 0x0000, DMI type 0, 26 bytes
c5ff1f
+BIOS Information
c5ff1f
+	Vendor: EFI Development Kit II / OVMF
c5ff1f
+	Version: 0.0.0
c5ff1f
+	Release Date: 02/06/2015
c5ff1f
+	Address: 0xE8000
c5ff1f
+	Runtime Size: 96 kB
c5ff1f
+	ROM Size: 64 kB
c5ff1f
+	Characteristics:
c5ff1f
+		BIOS characteristics not supported
c5ff1f
+		Targeted content distribution is supported
c5ff1f
+		UEFI is supported
c5ff1f
+		System is a virtual machine
c5ff1f
+	BIOS Revision: 0.0
c5ff1f
+
c5ff1f
+Handle 0xFEFF, DMI type 127, 4 bytes
c5ff1f
+End Of Table
c5ff1f
+
c5ff1f
+EOF
c5ff1f
diff --git a/tests/alibaba-cloud-arm/sbin/uname b/tests/alibaba-cloud-arm/sbin/uname
c5ff1f
new file mode 100755
c5ff1f
index 000000000..bd33a2d73
c5ff1f
--- /dev/null
c5ff1f
+++ b/tests/alibaba-cloud-arm/sbin/uname
c5ff1f
@@ -0,0 +1,2 @@
c5ff1f
+#!/bin/sh -
c5ff1f
+echo aarch64
c5ff1f
diff --git a/tests/alibaba-cloud-arm/sbin/virt-what-cpuid-helper b/tests/alibaba-cloud-arm/sbin/virt-what-cpuid-helper
c5ff1f
new file mode 100755
c5ff1f
index 000000000..08e293436
c5ff1f
--- /dev/null
c5ff1f
+++ b/tests/alibaba-cloud-arm/sbin/virt-what-cpuid-helper
c5ff1f
@@ -0,0 +1,3 @@
c5ff1f
+#!/bin/sh -
c5ff1f
+# Arm, so no cpuid.
c5ff1f
+# No output, exits with 0.
c5ff1f
diff --git a/tests/alibaba-cloud-arm/test.sh b/tests/alibaba-cloud-arm/test.sh
c5ff1f
new file mode 100755
c5ff1f
index 000000000..1e7360931
c5ff1f
--- /dev/null
c5ff1f
+++ b/tests/alibaba-cloud-arm/test.sh
c5ff1f
@@ -0,0 +1,33 @@
c5ff1f
+# Test for Alibaba Cloud
c5ff1f
+# Copyright (C) 2018-2023 Red Hat Inc.
c5ff1f
+#
c5ff1f
+# This program is free software; you can redistribute it and/or modify
c5ff1f
+# it under the terms of the GNU General Public License as published by
c5ff1f
+# the Free Software Foundation; either version 2 of the License, or
c5ff1f
+# (at your option) any later version.
c5ff1f
+#
c5ff1f
+# This program is distributed in the hope that it will be useful,
c5ff1f
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
c5ff1f
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c5ff1f
+# GNU General Public License for more details.
c5ff1f
+#
c5ff1f
+# You should have received a copy of the GNU General Public License
c5ff1f
+# along with this program; if not, write to the Free Software
c5ff1f
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
c5ff1f
+
c5ff1f
+output="$(PATH=../..:$PATH virt-what --test-root=. 2>&1)"
c5ff1f
+expected="alibaba_cloud
c5ff1f
+kvm"
c5ff1f
+
c5ff1f
+if [ "$output" != "$expected" ]; then
c5ff1f
+    echo "$0: test failed because output did not match expected"
c5ff1f
+    echo "Expected output was:"
c5ff1f
+    echo "----------------------------------------"
c5ff1f
+    echo "$expected"
c5ff1f
+    echo "----------------------------------------"
c5ff1f
+    echo "But the actual output of the program was:"
c5ff1f
+    echo "----------------------------------------"
c5ff1f
+    echo "$output"
c5ff1f
+    echo "----------------------------------------"
c5ff1f
+    exit 1
c5ff1f
+fi
c5ff1f
diff --git a/virt-what.in b/virt-what.in
c5ff1f
index 102e23f67..fbf8c54c5 100644
c5ff1f
--- a/virt-what.in
c5ff1f
+++ b/virt-what.in
c5ff1f
@@ -354,6 +354,11 @@ if ! "$skip_qemu_kvm"; then
c5ff1f
         # This is for AWS Graviton (Arm) systems which don't have CPUID.
c5ff1f
         echo kvm
c5ff1f
         skip_lkvm=true
c5ff1f
+    elif echo "$dmi" | grep -q 'Manufacturer: Alibaba Cloud' &&
c5ff1f
+        echo "$dmi" | grep -q 'System is a virtual machine'; then
c5ff1f
+        # This is for Alibaba Arm systems which don't have CPUID.
c5ff1f
+        echo kvm
c5ff1f
+        skip_lkvm=true
c5ff1f
     elif echo "$dmi" | grep -q 'Manufacturer: QEMU'; then
c5ff1f
         # The test for KVM above failed, so now we know we're
c5ff1f
         # not using KVM acceleration.
c5ff1f
-- 
c5ff1f
2.31.1
c5ff1f