1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Test the known dependencies for facilities 4 * 5 * Copyright 2019, 2021 IBM Corp. 6 * 7 * Authors: 8 * Christian Borntraeger <borntraeger@de.ibm.com> 9 * Janosch Frank <frankja@linux.ibm.com> 10 */ 11 12 #include <asm/facility.h> 13 #include <hardware.h> 14 #include <sclp.h> 15 #include <uv.h> 16 #include <asm/uv.h> 17 18 static void test_sclp_missing_sief2_implications(void) 19 { 20 /* Virtualization related facilities */ 21 report(!sclp_facilities.has_64bscao, "!64bscao"); 22 report(!sclp_facilities.has_pfmfi, "!pfmfi"); 23 report(!sclp_facilities.has_gsls, "!gsls"); 24 report(!sclp_facilities.has_cmma, "!cmma"); 25 report(!sclp_facilities.has_esca, "!esca"); 26 report(!sclp_facilities.has_kss, "!kss"); 27 report(!sclp_facilities.has_ibs, "!ibs"); 28 29 /* Virtualization related facilities reported via CPU entries */ 30 report(!sclp_facilities.has_sigpif, "!sigpif"); 31 report(!sclp_facilities.has_sief2, "!sief2"); 32 report(!sclp_facilities.has_skeyi, "!skeyi"); 33 report(!sclp_facilities.has_siif, "!siif"); 34 report(!sclp_facilities.has_cei, "!cei"); 35 report(!sclp_facilities.has_ib, "!ib"); 36 } 37 38 static void test_sclp_features_fmt4(void) 39 { 40 /* 41 * STFLE facilities are handled by the Ultravisor but SCLP 42 * facilities are advertised by the hypervisor. 43 */ 44 report_prefix_push("PV guest implies"); 45 46 /* General facilities */ 47 report(!sclp_facilities.has_diag318, "!diag318"); 48 49 /* 50 * Virtualization related facilities, all of which are 51 * unavailable because there's no virtualization support in a 52 * protected guest. 53 */ 54 test_sclp_missing_sief2_implications(); 55 56 report_prefix_pop(); 57 } 58 59 static void test_sclp_features_fmt2(void) 60 { 61 if (sclp_facilities.has_sief2) 62 return; 63 64 report_prefix_push("!sief2 implies"); 65 test_sclp_missing_sief2_implications(); 66 report_prefix_pop(); 67 } 68 69 static void test_sclp_features(void) 70 { 71 report_prefix_push("sclp"); 72 73 if (uv_os_is_guest()) 74 test_sclp_features_fmt4(); 75 else 76 test_sclp_features_fmt2(); 77 78 report_prefix_pop(); 79 } 80 81 static struct { 82 int facility; 83 int implied; 84 bool expected_tcg_fail; 85 } dep[] = { 86 /* from SA22-7832-11 4-98 facility indications */ 87 { 4, 3 }, 88 { 5, 3 }, 89 { 5, 4 }, 90 { 19, 18 }, 91 { 37, 42, true }, /* TCG does not have DFP and won't get it soon */ 92 { 43, 42 }, 93 { 73, 49 }, 94 { 134, 129 }, 95 { 135, 129 }, 96 { 139, 25 }, 97 { 139, 28 }, 98 { 146, 76 }, 99 /* indirectly documented in description */ 100 { 78, 8 }, /* EDAT */ 101 /* new dependencies from gen15 */ 102 { 61, 45 }, 103 { 148, 129 }, 104 { 148, 135 }, 105 { 152, 129 }, 106 { 152, 134 }, 107 { 155, 76 }, 108 { 155, 77 }, 109 }; 110 111 int main(void) 112 { 113 int i; 114 115 report_prefix_push("cpumodel"); 116 117 report_prefix_push("dependency"); 118 for (i = 0; i < ARRAY_SIZE(dep); i++) { 119 report_prefix_pushf("%d implies %d", dep[i].facility, dep[i].implied); 120 if (test_facility(dep[i].facility)) { 121 report_xfail(dep[i].expected_tcg_fail && host_is_tcg(), 122 test_facility(dep[i].implied), 123 "implication not correct"); 124 } else { 125 report_skip("facility %d not present", dep[i].facility); 126 } 127 report_prefix_pop(); 128 } 129 report_prefix_pop(); 130 131 test_sclp_features(); 132 133 report_prefix_pop(); 134 return report_summary(); 135 } 136