|
7 | 7 |
|
8 | 8 | #include <linux/args.h> |
9 | 9 | #include <linux/init.h> |
| 10 | + |
| 11 | +#ifndef __ASSEMBLY__ |
| 12 | +#include <linux/uuid.h> |
| 13 | +#endif |
| 14 | + |
10 | 15 | #include <uapi/linux/const.h> |
11 | 16 |
|
12 | 17 | /* |
|
107 | 112 | ARM_SMCCC_FUNC_QUERY_CALL_UID) |
108 | 113 |
|
109 | 114 | /* KVM UID value: 28b46fb6-2ec5-11e9-a9ca-4b564d003a74 */ |
110 | | -#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_0 0xb66fb428U |
111 | | -#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_1 0xe911c52eU |
112 | | -#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_2 0x564bcaa9U |
113 | | -#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_3 0x743a004dU |
| 115 | +#define ARM_SMCCC_VENDOR_HYP_UID_KVM UUID_INIT(\ |
| 116 | + 0xb66fb428, 0xc52e, 0xe911, \ |
| 117 | + 0xa9, 0xca, 0x4b, 0x56, \ |
| 118 | + 0x4d, 0x00, 0x3a, 0x74) |
114 | 119 |
|
115 | 120 | /* KVM "vendor specific" services */ |
116 | 121 | #define ARM_SMCCC_KVM_FUNC_FEATURES 0 |
@@ -348,6 +353,57 @@ s32 arm_smccc_get_soc_id_version(void); |
348 | 353 | */ |
349 | 354 | s32 arm_smccc_get_soc_id_revision(void); |
350 | 355 |
|
| 356 | +#ifndef __ASSEMBLY__ |
| 357 | + |
| 358 | +/* |
| 359 | + * Returns whether a specific hypervisor UUID is advertised for the |
| 360 | + * Vendor Specific Hypervisor Service range. |
| 361 | + */ |
| 362 | +bool arm_smccc_hypervisor_has_uuid(const uuid_t *uuid); |
| 363 | + |
| 364 | +static inline uuid_t smccc_res_to_uuid(u32 r0, u32 r1, u32 r2, u32 r3) |
| 365 | +{ |
| 366 | + uuid_t uuid = { |
| 367 | + .b = { |
| 368 | + [0] = (r0 >> 0) & 0xff, |
| 369 | + [1] = (r0 >> 8) & 0xff, |
| 370 | + [2] = (r0 >> 16) & 0xff, |
| 371 | + [3] = (r0 >> 24) & 0xff, |
| 372 | + |
| 373 | + [4] = (r1 >> 0) & 0xff, |
| 374 | + [5] = (r1 >> 8) & 0xff, |
| 375 | + [6] = (r1 >> 16) & 0xff, |
| 376 | + [7] = (r1 >> 24) & 0xff, |
| 377 | + |
| 378 | + [8] = (r2 >> 0) & 0xff, |
| 379 | + [9] = (r2 >> 8) & 0xff, |
| 380 | + [10] = (r2 >> 16) & 0xff, |
| 381 | + [11] = (r2 >> 24) & 0xff, |
| 382 | + |
| 383 | + [12] = (r3 >> 0) & 0xff, |
| 384 | + [13] = (r3 >> 8) & 0xff, |
| 385 | + [14] = (r3 >> 16) & 0xff, |
| 386 | + [15] = (r3 >> 24) & 0xff, |
| 387 | + }, |
| 388 | + }; |
| 389 | + |
| 390 | + return uuid; |
| 391 | +} |
| 392 | + |
| 393 | +static inline u32 smccc_uuid_to_reg(const uuid_t *uuid, int reg) |
| 394 | +{ |
| 395 | + u32 val = 0; |
| 396 | + |
| 397 | + val |= (u32)(uuid->b[4 * reg + 0] << 0); |
| 398 | + val |= (u32)(uuid->b[4 * reg + 1] << 8); |
| 399 | + val |= (u32)(uuid->b[4 * reg + 2] << 16); |
| 400 | + val |= (u32)(uuid->b[4 * reg + 3] << 24); |
| 401 | + |
| 402 | + return val; |
| 403 | +} |
| 404 | + |
| 405 | +#endif /* !__ASSEMBLY__ */ |
| 406 | + |
351 | 407 | /** |
352 | 408 | * struct arm_smccc_res - Result from SMC/HVC call |
353 | 409 | * @a0-a3 result values from registers 0 to 3 |
|
0 commit comments