Skip to content

Commit c0000e5

Browse files
shamiali2008oupton
authored andcommitted
KVM: arm64: Introduce KVM_REG_ARM_VENDOR_HYP_BMAP_2
The vendor_hyp_bmap bitmap holds the information about the Vendor Hyp services available to the user space and can be get/set using {G, S}ET_ONE_REG interfaces. This is done using the pseudo-firmware bitmap register KVM_REG_ARM_VENDOR_HYP_BMAP. At present, this bitmap is a 64 bit one and since the function numbers for newly added DISCOVER_IPML_* hypercalls are 64-65, introduce another pseudo-firmware bitmap register KVM_REG_ARM_VENDOR_HYP_BMAP_2. Reviewed-by: Sebastian Ott <[email protected]> Signed-off-by: Shameer Kolothum <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 57e5cc9 commit c0000e5

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

Documentation/virt/kvm/arm/fw-pseudo-registers.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ The pseudo-firmware bitmap register are as follows:
116116
ARM DEN0057A.
117117

118118
* KVM_REG_ARM_VENDOR_HYP_BMAP:
119-
Controls the bitmap of the Vendor specific Hypervisor Service Calls.
119+
Controls the bitmap of the Vendor specific Hypervisor Service Calls[0-63].
120120

121121
The following bits are accepted:
122122

@@ -127,6 +127,19 @@ The pseudo-firmware bitmap register are as follows:
127127
Bit-1: KVM_REG_ARM_VENDOR_HYP_BIT_PTP:
128128
The bit represents the Precision Time Protocol KVM service.
129129

130+
* KVM_REG_ARM_VENDOR_HYP_BMAP_2:
131+
Controls the bitmap of the Vendor specific Hypervisor Service Calls[64-127].
132+
133+
The following bits are accepted:
134+
135+
Bit-0: KVM_REG_ARM_VENDOR_HYP_BIT_DISCOVER_IMPL_VER
136+
This represents the ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_VER_FUNC_ID
137+
function-id. This is reset to 0.
138+
139+
Bit-1: KVM_REG_ARM_VENDOR_HYP_BIT_DISCOVER_IMPL_CPUS
140+
This represents the ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_CPUS_FUNC_ID
141+
function-id. This is reset to 0.
142+
130143
Errors:
131144

132145
======= =============================================================

arch/arm64/include/asm/kvm_host.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ struct kvm_arch_memory_slot {
237237
struct kvm_smccc_features {
238238
unsigned long std_bmap;
239239
unsigned long std_hyp_bmap;
240-
unsigned long vendor_hyp_bmap;
240+
unsigned long vendor_hyp_bmap; /* Function numbers 0-63 */
241+
unsigned long vendor_hyp_bmap_2; /* Function numbers 64-127 */
241242
};
242243

243244
typedef unsigned int pkvm_handle_t;

arch/arm64/include/uapi/asm/kvm.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ enum {
371371
#endif
372372
};
373373

374+
/* Vendor hyper call function numbers 0-63 */
374375
#define KVM_REG_ARM_VENDOR_HYP_BMAP KVM_REG_ARM_FW_FEAT_BMAP_REG(2)
375376

376377
enum {
@@ -381,6 +382,17 @@ enum {
381382
#endif
382383
};
383384

385+
/* Vendor hyper call function numbers 64-127 */
386+
#define KVM_REG_ARM_VENDOR_HYP_BMAP_2 KVM_REG_ARM_FW_FEAT_BMAP_REG(3)
387+
388+
enum {
389+
KVM_REG_ARM_VENDOR_HYP_BIT_DISCOVER_IMPL_VER = 0,
390+
KVM_REG_ARM_VENDOR_HYP_BIT_DISCOVER_IMPL_CPUS = 1,
391+
#ifdef __KERNEL__
392+
KVM_REG_ARM_VENDOR_HYP_BMAP_2_BIT_COUNT,
393+
#endif
394+
};
395+
384396
/* Device Control API on vm fd */
385397
#define KVM_ARM_VM_SMCCC_CTRL 0
386398
#define KVM_ARM_VM_SMCCC_FILTER 0

arch/arm64/kvm/hypercalls.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
GENMASK(KVM_REG_ARM_STD_HYP_BMAP_BIT_COUNT - 1, 0)
1616
#define KVM_ARM_SMCCC_VENDOR_HYP_FEATURES \
1717
GENMASK(KVM_REG_ARM_VENDOR_HYP_BMAP_BIT_COUNT - 1, 0)
18+
#define KVM_ARM_SMCCC_VENDOR_HYP_FEATURES_2 \
19+
GENMASK(KVM_REG_ARM_VENDOR_HYP_BMAP_2_BIT_COUNT - 1, 0)
1820

1921
static void kvm_ptp_get_time(struct kvm_vcpu *vcpu, u64 *val)
2022
{
@@ -360,6 +362,8 @@ int kvm_smccc_call_handler(struct kvm_vcpu *vcpu)
360362
break;
361363
case ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID:
362364
val[0] = smccc_feat->vendor_hyp_bmap;
365+
/* Function numbers 2-63 are reserved for pKVM for now */
366+
val[2] = smccc_feat->vendor_hyp_bmap_2;
363367
break;
364368
case ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID:
365369
kvm_ptp_get_time(vcpu, val);
@@ -387,6 +391,7 @@ static const u64 kvm_arm_fw_reg_ids[] = {
387391
KVM_REG_ARM_STD_BMAP,
388392
KVM_REG_ARM_STD_HYP_BMAP,
389393
KVM_REG_ARM_VENDOR_HYP_BMAP,
394+
KVM_REG_ARM_VENDOR_HYP_BMAP_2,
390395
};
391396

392397
void kvm_arm_init_hypercalls(struct kvm *kvm)
@@ -497,6 +502,9 @@ int kvm_arm_get_fw_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
497502
case KVM_REG_ARM_VENDOR_HYP_BMAP:
498503
val = READ_ONCE(smccc_feat->vendor_hyp_bmap);
499504
break;
505+
case KVM_REG_ARM_VENDOR_HYP_BMAP_2:
506+
val = READ_ONCE(smccc_feat->vendor_hyp_bmap_2);
507+
break;
500508
default:
501509
return -ENOENT;
502510
}
@@ -527,6 +535,10 @@ static int kvm_arm_set_fw_reg_bmap(struct kvm_vcpu *vcpu, u64 reg_id, u64 val)
527535
fw_reg_bmap = &smccc_feat->vendor_hyp_bmap;
528536
fw_reg_features = KVM_ARM_SMCCC_VENDOR_HYP_FEATURES;
529537
break;
538+
case KVM_REG_ARM_VENDOR_HYP_BMAP_2:
539+
fw_reg_bmap = &smccc_feat->vendor_hyp_bmap_2;
540+
fw_reg_features = KVM_ARM_SMCCC_VENDOR_HYP_FEATURES_2;
541+
break;
530542
default:
531543
return -ENOENT;
532544
}
@@ -633,6 +645,7 @@ int kvm_arm_set_fw_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
633645
case KVM_REG_ARM_STD_BMAP:
634646
case KVM_REG_ARM_STD_HYP_BMAP:
635647
case KVM_REG_ARM_VENDOR_HYP_BMAP:
648+
case KVM_REG_ARM_VENDOR_HYP_BMAP_2:
636649
return kvm_arm_set_fw_reg_bmap(vcpu, reg->id, val);
637650
default:
638651
return -ENOENT;

0 commit comments

Comments
 (0)