mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-18 19:57:31 +00:00
hv: fix bug when set MSR_IA32_COPY_PLATFORM_TO_LOCAL before setting MSR_IA32_COPY_LOCAL_TO_PLATFORM
The current code would inject GP to guest, when there's no IWKeyBackup, and the guest tried to write MSR MSR_IA32_COPY_PLATFORM_TO_LOCAL(0xd92) to copy IWKeyBackup for the platform to the IWKey for this logical processor. This patch fixes it by adjusting the code logic, and it'll do nothing instead of inject GP if no valid IWKeyBackup. This patch alse add checking for the value being written to avoid setting reserved MSR bits. Tracked-On: #7018 Signed-off-by: Wen Qian <qian.wen@intel.com> Signed-off-by: Li Fei <fei1.li@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
parent
ace5ef44e8
commit
5d7465a055
@ -1045,7 +1045,9 @@ int32_t wrmsr_vmexit_handler(struct acrn_vcpu *vcpu)
|
||||
}
|
||||
case MSR_IA32_COPY_LOCAL_TO_PLATFORM:
|
||||
{
|
||||
if ((v == 0x1UL) && is_iwkey_backup_support(vcpu)) {
|
||||
/* check feature support and avoid setting reserved MSR bits */
|
||||
if (is_iwkey_backup_support(vcpu) && ((v & ~0x1UL) == 0x0UL)) {
|
||||
if (v == 0x1UL) {
|
||||
vcpu->vm->arch_vm.iwkey_backup_status = 0UL;
|
||||
spinlock_obtain(&vcpu->vm->arch_vm.iwkey_backup_lock);
|
||||
vcpu->vm->arch_vm.iwkey_backup = vcpu->arch.IWKey;
|
||||
@ -1056,6 +1058,7 @@ int32_t wrmsr_vmexit_handler(struct acrn_vcpu *vcpu)
|
||||
*/
|
||||
vcpu->vm->arch_vm.iwkey_backup_status = 0x9UL;
|
||||
vcpu->arch.iwkey_copy_status = 1UL;
|
||||
}
|
||||
} else {
|
||||
err = -EINVAL;
|
||||
}
|
||||
@ -1063,8 +1066,9 @@ int32_t wrmsr_vmexit_handler(struct acrn_vcpu *vcpu)
|
||||
}
|
||||
case MSR_IA32_COPY_PLATFORM_TO_LOCAL:
|
||||
{
|
||||
if ((v == 0x1UL) && is_iwkey_backup_support(vcpu) &&
|
||||
(vcpu->vm->arch_vm.iwkey_backup_status == 0x9UL)) {
|
||||
/* check feature support and avoid setting reserved MSR bits */
|
||||
if (is_iwkey_backup_support(vcpu) && ((v & ~0x1UL) == 0x0UL)) {
|
||||
if ((v == 0x1UL) && (vcpu->vm->arch_vm.iwkey_backup_status == 0x9UL)) {
|
||||
spinlock_obtain(&vcpu->vm->arch_vm.iwkey_backup_lock);
|
||||
vcpu->arch.IWKey = vcpu->vm->arch_vm.iwkey_backup;
|
||||
spinlock_release(&vcpu->vm->arch_vm.iwkey_backup_lock);
|
||||
@ -1072,6 +1076,7 @@ int32_t wrmsr_vmexit_handler(struct acrn_vcpu *vcpu)
|
||||
get_cpu_var(whose_iwkey) = NULL;
|
||||
load_iwkey(vcpu);
|
||||
vcpu->arch.iwkey_copy_status = 1UL;
|
||||
}
|
||||
} else {
|
||||
err = -EINVAL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user