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

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