Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: selftests: Move Intel and AMD module param helpers to x86/processor.h

Move the x86 specific helpers for getting kvm_{amd,intel} module params to
x86 where they belong. Expose the module-agnostic helpers globally, there
is nothing secret about the logic.

Link: https://lore.kernel.org/r/20250806225159.1687326-1-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>

+33 -38
+11 -6
tools/testing/selftests/kvm/include/kvm_util.h
··· 260 260 int open_path_or_exit(const char *path, int flags); 261 261 int open_kvm_dev_path_or_exit(void); 262 262 263 - bool get_kvm_param_bool(const char *param); 264 - bool get_kvm_intel_param_bool(const char *param); 265 - bool get_kvm_amd_param_bool(const char *param); 263 + int kvm_get_module_param_integer(const char *module_name, const char *param); 264 + bool kvm_get_module_param_bool(const char *module_name, const char *param); 266 265 267 - int get_kvm_param_integer(const char *param); 268 - int get_kvm_intel_param_integer(const char *param); 269 - int get_kvm_amd_param_integer(const char *param); 266 + static inline bool get_kvm_param_bool(const char *param) 267 + { 268 + return kvm_get_module_param_bool("kvm", param); 269 + } 270 + 271 + static inline int get_kvm_param_integer(const char *param) 272 + { 273 + return kvm_get_module_param_integer("kvm", param); 274 + } 270 275 271 276 unsigned int kvm_check_cap(long cap); 272 277
+20
tools/testing/selftests/kvm/include/x86/processor.h
··· 1314 1314 1315 1315 bool kvm_is_tdp_enabled(void); 1316 1316 1317 + static inline bool get_kvm_intel_param_bool(const char *param) 1318 + { 1319 + return kvm_get_module_param_bool("kvm_intel", param); 1320 + } 1321 + 1322 + static inline bool get_kvm_amd_param_bool(const char *param) 1323 + { 1324 + return kvm_get_module_param_bool("kvm_amd", param); 1325 + } 1326 + 1327 + static inline int get_kvm_intel_param_integer(const char *param) 1328 + { 1329 + return kvm_get_module_param_integer("kvm_intel", param); 1330 + } 1331 + 1332 + static inline int get_kvm_amd_param_integer(const char *param) 1333 + { 1334 + return kvm_get_module_param_integer("kvm_amd", param); 1335 + } 1336 + 1317 1337 static inline bool kvm_is_pmu_enabled(void) 1318 1338 { 1319 1339 return get_kvm_param_bool("enable_pmu");
+2 -32
tools/testing/selftests/kvm/lib/kvm_util.c
··· 95 95 return bytes_read; 96 96 } 97 97 98 - static int get_module_param_integer(const char *module_name, const char *param) 98 + int kvm_get_module_param_integer(const char *module_name, const char *param) 99 99 { 100 100 /* 101 101 * 16 bytes to hold a 64-bit value (1 byte per char), 1 byte for the ··· 119 119 return atoi_paranoid(value); 120 120 } 121 121 122 - static bool get_module_param_bool(const char *module_name, const char *param) 122 + bool kvm_get_module_param_bool(const char *module_name, const char *param) 123 123 { 124 124 char value; 125 125 ssize_t r; ··· 133 133 return false; 134 134 135 135 TEST_FAIL("Unrecognized value '%c' for boolean module param", value); 136 - } 137 - 138 - bool get_kvm_param_bool(const char *param) 139 - { 140 - return get_module_param_bool("kvm", param); 141 - } 142 - 143 - bool get_kvm_intel_param_bool(const char *param) 144 - { 145 - return get_module_param_bool("kvm_intel", param); 146 - } 147 - 148 - bool get_kvm_amd_param_bool(const char *param) 149 - { 150 - return get_module_param_bool("kvm_amd", param); 151 - } 152 - 153 - int get_kvm_param_integer(const char *param) 154 - { 155 - return get_module_param_integer("kvm", param); 156 - } 157 - 158 - int get_kvm_intel_param_integer(const char *param) 159 - { 160 - return get_module_param_integer("kvm_intel", param); 161 - } 162 - 163 - int get_kvm_amd_param_integer(const char *param) 164 - { 165 - return get_module_param_integer("kvm_amd", param); 166 136 } 167 137 168 138 /*