Re: [PATCH V6 7/8] hv: vCAT: implementing the vCAT MSRs write handler


Dongsheng Zhang
 

+static int32_t write_vcbm(struct acrn_vcpu *vcpu, uint32_t vmsr,
+uint64_t val, int res)
{
- /* TODO: this is going to be implemented in a subsequent commit,
will
perform the following actions:
- * write vCBM
- * vmsr_to_pmsr and vcbm_to_pcbm
- * write pCBM
+ int32_t ret = -EINVAL;
+ /*
+ * vcbm set bits should only be in the range of [0, vcbm_len)
(vcat_get_max_vcbm),
+ * so mask with vcat_get_max_vcbm to prevent erroneous vCBM
value
*/
- return -EFAULT;
+ uint64_t masked_vcbm = val & vcat_get_max_vcbm(vcpu->vm, res);
If SW sets bits beyond hardware supported value, I thought we should
inject #GP.
Yes, we should inject #GP when the SW sets bits beyond hardware supported value, or when the vcbm is not contiguous,
I already added the code for these 2 cases.

Join acrn-dev@lists.projectacrn.org to automatically receive all group messages.