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

Configure Feed

Select the types of activity you want to include in your feed.

KVM: arm64: Add vendor hypervisor firmware register

Introduce the firmware register to hold the vendor specific
hypervisor service calls (owner value 6) as a bitmap. The
bitmap represents the features that'll be enabled for the
guest, as configured by the user-space. Currently, this
includes support for KVM-vendor features along with
reading the UID, represented by bit-0, and Precision Time
Protocol (PTP), represented by bit-1.

Signed-off-by: Raghavendra Rao Ananta <rananta@google.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
[maz: tidy-up bitmap values]
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20220502233853.1233742-5-rananta@google.com

authored by

Raghavendra Rao Ananta and committed by
Marc Zyngier
b22216e1 428fd678

+30 -5
+2
arch/arm64/include/asm/kvm_host.h
··· 106 106 * 107 107 * @std_bmap: Bitmap of standard secure service calls 108 108 * @std_hyp_bmap: Bitmap of standard hypervisor service calls 109 + * @vendor_hyp_bmap: Bitmap of vendor specific hypervisor service calls 109 110 */ 110 111 struct kvm_smccc_features { 111 112 unsigned long std_bmap; 112 113 unsigned long std_hyp_bmap; 114 + unsigned long vendor_hyp_bmap; 113 115 }; 114 116 115 117 struct kvm_arch {
+8
arch/arm64/include/uapi/asm/kvm.h
··· 352 352 KVM_REG_ARM_STD_HYP_BMAP_BIT_COUNT, 353 353 }; 354 354 355 + #define KVM_REG_ARM_VENDOR_HYP_BMAP KVM_REG_ARM_FW_FEAT_BMAP_REG(2) 356 + 357 + enum { 358 + KVM_REG_ARM_VENDOR_HYP_BIT_FUNC_FEAT = 0, 359 + KVM_REG_ARM_VENDOR_HYP_BIT_PTP = 1, 360 + KVM_REG_ARM_VENDOR_HYP_BMAP_BIT_COUNT, 361 + }; 362 + 355 363 /* Device Control API: ARM VGIC */ 356 364 #define KVM_DEV_ARM_VGIC_GRP_ADDR 0 357 365 #define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1
+20 -5
arch/arm64/kvm/hypercalls.c
··· 13 13 GENMASK(KVM_REG_ARM_STD_BMAP_BIT_COUNT - 1, 0) 14 14 #define KVM_ARM_SMCCC_STD_HYP_FEATURES \ 15 15 GENMASK(KVM_REG_ARM_STD_HYP_BMAP_BIT_COUNT - 1, 0) 16 + #define KVM_ARM_SMCCC_VENDOR_HYP_FEATURES \ 17 + GENMASK(KVM_REG_ARM_VENDOR_HYP_BMAP_BIT_COUNT - 1, 0) 16 18 17 19 static void kvm_ptp_get_time(struct kvm_vcpu *vcpu, u64 *val) 18 20 { ··· 75 73 */ 76 74 case ARM_SMCCC_VERSION_FUNC_ID: 77 75 case ARM_SMCCC_ARCH_FEATURES_FUNC_ID: 78 - case ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID: 79 - case ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID: 80 - case ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID: 81 76 return true; 82 77 default: 83 78 /* PSCI 0.2 and up is in the 0:0x1f range */ ··· 109 110 case ARM_SMCCC_HV_PV_TIME_ST: 110 111 return test_bit(KVM_REG_ARM_STD_HYP_BIT_PV_TIME, 111 112 &smccc_feat->std_hyp_bmap); 113 + case ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID: 114 + case ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID: 115 + return test_bit(KVM_REG_ARM_VENDOR_HYP_BIT_FUNC_FEAT, 116 + &smccc_feat->vendor_hyp_bmap); 117 + case ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID: 118 + return test_bit(KVM_REG_ARM_VENDOR_HYP_BIT_PTP, 119 + &smccc_feat->vendor_hyp_bmap); 112 120 default: 113 121 return kvm_hvc_call_default_allowed(func_id); 114 122 } ··· 208 202 val[3] = ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_3; 209 203 break; 210 204 case ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID: 211 - val[0] = BIT(ARM_SMCCC_KVM_FUNC_FEATURES); 212 - val[0] |= BIT(ARM_SMCCC_KVM_FUNC_PTP); 205 + val[0] = smccc_feat->vendor_hyp_bmap; 213 206 break; 214 207 case ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID: 215 208 kvm_ptp_get_time(vcpu, val); ··· 235 230 KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3, 236 231 KVM_REG_ARM_STD_BMAP, 237 232 KVM_REG_ARM_STD_HYP_BMAP, 233 + KVM_REG_ARM_VENDOR_HYP_BMAP, 238 234 }; 239 235 240 236 void kvm_arm_init_hypercalls(struct kvm *kvm) ··· 244 238 245 239 smccc_feat->std_bmap = KVM_ARM_SMCCC_STD_FEATURES; 246 240 smccc_feat->std_hyp_bmap = KVM_ARM_SMCCC_STD_HYP_FEATURES; 241 + smccc_feat->vendor_hyp_bmap = KVM_ARM_SMCCC_VENDOR_HYP_FEATURES; 247 242 } 248 243 249 244 int kvm_arm_get_fw_num_regs(struct kvm_vcpu *vcpu) ··· 336 329 case KVM_REG_ARM_STD_HYP_BMAP: 337 330 val = READ_ONCE(smccc_feat->std_hyp_bmap); 338 331 break; 332 + case KVM_REG_ARM_VENDOR_HYP_BMAP: 333 + val = READ_ONCE(smccc_feat->vendor_hyp_bmap); 334 + break; 339 335 default: 340 336 return -ENOENT; 341 337 } ··· 364 354 case KVM_REG_ARM_STD_HYP_BMAP: 365 355 fw_reg_bmap = &smccc_feat->std_hyp_bmap; 366 356 fw_reg_features = KVM_ARM_SMCCC_STD_HYP_FEATURES; 357 + break; 358 + case KVM_REG_ARM_VENDOR_HYP_BMAP: 359 + fw_reg_bmap = &smccc_feat->vendor_hyp_bmap; 360 + fw_reg_features = KVM_ARM_SMCCC_VENDOR_HYP_FEATURES; 367 361 break; 368 362 default: 369 363 return -ENOENT; ··· 470 456 return 0; 471 457 case KVM_REG_ARM_STD_BMAP: 472 458 case KVM_REG_ARM_STD_HYP_BMAP: 459 + case KVM_REG_ARM_VENDOR_HYP_BMAP: 473 460 return kvm_arm_set_fw_reg_bmap(vcpu, reg->id, val); 474 461 default: 475 462 return -ENOENT;