KVM: x86: xen_hvm_config: cleanup return values
Return 1 on errors that are caused by wrong guest behavior (which will inject #GP to the guest) And return a negative error value on issues that are the kernel's fault (e.g -ENOMEM) Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Message-Id: <20201001112954.6258-2-mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
d5d6c18dc4
commit
36385ccc9b
|
@ -2842,24 +2842,19 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
|
||||||
u32 page_num = data & ~PAGE_MASK;
|
u32 page_num = data & ~PAGE_MASK;
|
||||||
u64 page_addr = data & PAGE_MASK;
|
u64 page_addr = data & PAGE_MASK;
|
||||||
u8 *page;
|
u8 *page;
|
||||||
int r;
|
|
||||||
|
|
||||||
r = -E2BIG;
|
|
||||||
if (page_num >= blob_size)
|
if (page_num >= blob_size)
|
||||||
goto out;
|
return 1;
|
||||||
r = -ENOMEM;
|
|
||||||
page = memdup_user(blob_addr + (page_num * PAGE_SIZE), PAGE_SIZE);
|
page = memdup_user(blob_addr + (page_num * PAGE_SIZE), PAGE_SIZE);
|
||||||
if (IS_ERR(page)) {
|
if (IS_ERR(page))
|
||||||
r = PTR_ERR(page);
|
return PTR_ERR(page);
|
||||||
goto out;
|
|
||||||
|
if (kvm_vcpu_write_guest(vcpu, page_addr, page, PAGE_SIZE)) {
|
||||||
|
kfree(page);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
if (kvm_vcpu_write_guest(vcpu, page_addr, page, PAGE_SIZE))
|
return 0;
|
||||||
goto out_free;
|
|
||||||
r = 0;
|
|
||||||
out_free:
|
|
||||||
kfree(page);
|
|
||||||
out:
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool kvm_pv_async_pf_enabled(struct kvm_vcpu *vcpu)
|
static inline bool kvm_pv_async_pf_enabled(struct kvm_vcpu *vcpu)
|
||||||
|
|
Loading…
Reference in New Issue