+static int set_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r,
+ u64 val)
+{
+ struct kvm *kvm = vcpu->kvm;
+ u64 new_n, mutable_mask;
+
+ mutex_lock(&kvm->arch.config_lock);
+
+ /*
+ * Make PMCR immutable once the VM has started running, but do
+ * not return an error (-EBUSY) to meet the existing expectations.
+ */
+ if (kvm_vm_has_ran_once(vcpu->kvm)) {
+ mutex_unlock(&kvm->arch.config_lock);
+ return 0;
+ }