hv:remove redundant memset in some cases

No need to memset since it will overwrite the memory
by copy_from_gpa in some cases.

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
This commit is contained in:
Mingqiang Chi 2019-09-19 15:35:33 +08:00 committed by wenlingz
parent 9e759bcfa0
commit c36908dce2
4 changed files with 9 additions and 37 deletions

View File

@ -152,7 +152,6 @@ int32_t hcall_create_vm(struct acrn_vm *vm, uint64_t param)
struct acrn_create_vm cv;
struct acrn_vm_config* vm_config = NULL;
(void)memset((void *)&cv, 0U, sizeof(cv));
if (copy_from_gpa(vm, &cv, param, sizeof(cv)) == 0) {
vm_id = get_vmid_by_uuid(&cv.uuid[0]);
if ((vm_id > vm->vm_id) && (vm_id < CONFIG_MAX_VM_NUM)
@ -477,11 +476,11 @@ static void inject_msi_lapic_pt(struct acrn_vm *vm, const struct acrn_msi_entry
int32_t hcall_inject_msi(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
{
int32_t ret = -1;
struct acrn_msi_entry msi;
struct acrn_vm *target_vm = get_vm_from_vmid(vmid);
if (!is_poweroff_vm(target_vm) && is_postlaunched_vm(target_vm)) {
(void)memset((void *)&msi, 0U, sizeof(msi));
struct acrn_msi_entry msi;
if (copy_from_gpa(vm, &msi, param, sizeof(msi)) != 0) {
pr_err("%s: Unable copy param to vm\n", __func__);
} else {
@ -533,13 +532,13 @@ int32_t hcall_inject_msi(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
int32_t hcall_set_ioreq_buffer(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
{
uint64_t hpa;
struct acrn_set_ioreq_buffer iobuf;
struct acrn_vm *target_vm = get_vm_from_vmid(vmid);
uint16_t i;
int32_t ret = -1;
(void)memset((void *)&iobuf, 0U, sizeof(iobuf));
if (is_created_vm(target_vm) && is_postlaunched_vm(target_vm)) {
struct acrn_set_ioreq_buffer iobuf;
if (copy_from_gpa(vm, &iobuf, param, sizeof(iobuf)) != 0) {
pr_err("%p %s: Unable copy param to vm\n", target_vm, __func__);
} else {
@ -717,8 +716,6 @@ int32_t hcall_set_vm_memory_regions(struct acrn_vm *vm, uint64_t param)
uint32_t idx;
int32_t ret = -1;
(void)memset((void *)&regions, 0U, sizeof(regions));
if (copy_from_gpa(vm, &regions, param, sizeof(regions)) == 0) {
/* the vmid in regions is a relative vm id, need to convert to absolute vm id */
uint16_t target_vmid = rel_vmid_2_vmid(vm->vm_id, regions.vmid);
@ -799,12 +796,11 @@ static int32_t write_protect_page(struct acrn_vm *vm,const struct wp_data *wp)
*/
int32_t hcall_write_protect_page(struct acrn_vm *vm, uint16_t vmid, uint64_t wp_gpa)
{
struct wp_data wp;
struct acrn_vm *target_vm = get_vm_from_vmid(vmid);
int32_t ret = -1;
if (!is_poweroff_vm(target_vm) && is_postlaunched_vm(target_vm)) {
(void)memset((void *)&wp, 0U, sizeof(wp));
struct wp_data wp;
if (copy_from_gpa(vm, &wp, wp_gpa, sizeof(wp)) != 0) {
pr_err("%s: Unable copy param to vm\n", __func__);
@ -951,11 +947,11 @@ int32_t hcall_deassign_ptdev(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
int32_t hcall_set_ptdev_intr_info(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
{
int32_t ret = -1;
struct hc_ptdev_irq irq;
struct acrn_vm *target_vm = get_vm_from_vmid(vmid);
(void)memset((void *)&irq, 0U, sizeof(irq));
if (!is_poweroff_vm(target_vm) && is_postlaunched_vm(target_vm)) {
struct hc_ptdev_irq irq;
if (copy_from_gpa(vm, &irq, param, sizeof(irq)) != 0) {
pr_err("%s: Unable copy param to vm\n", __func__);
} else {
@ -994,11 +990,10 @@ int32_t
hcall_reset_ptdev_intr_info(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
{
int32_t ret = -1;
struct hc_ptdev_irq irq;
struct acrn_vm *target_vm = get_vm_from_vmid(vmid);
if (!is_poweroff_vm(target_vm) && is_postlaunched_vm(target_vm)) {
(void)memset((void *)&irq, 0U, sizeof(irq));
struct hc_ptdev_irq irq;
if (copy_from_gpa(vm, &irq, param, sizeof(irq)) != 0) {
pr_err("%s: Unable copy param to vm\n", __func__);

View File

@ -55,13 +55,12 @@ int32_t hcall_world_switch(struct acrn_vcpu *vcpu)
int32_t hcall_initialize_trusty(struct acrn_vcpu *vcpu, uint64_t param)
{
int32_t ret = -EFAULT;
struct trusty_boot_param boot_param;
if ((vcpu->vm->sworld_control.flag.supported != 0UL)
&& (vcpu->vm->sworld_control.flag.active == 0UL)
&& (vcpu->arch.cur_context == NORMAL_WORLD)) {
struct trusty_boot_param boot_param;
(void)memset(&boot_param, 0U, sizeof(boot_param));
if (copy_from_gpa(vcpu->vm, &boot_param, param, sizeof(boot_param)) == 0) {
if (initialize_trusty(vcpu, &boot_param)) {
vcpu->vm->sworld_control.flag.active = 1UL;

View File

@ -81,8 +81,6 @@ static int32_t hcall_setup_sbuf(struct acrn_vm *vm, uint64_t param)
struct sbuf_setup_param ssp;
uint64_t *hva;
(void)memset((void *)&ssp, 0U, sizeof(ssp));
if (copy_from_gpa(vm, &ssp, param, sizeof(ssp)) != 0) {
pr_err("%s: Unable copy param to vm\n", __func__);
return -1;
@ -111,8 +109,6 @@ static int32_t hcall_setup_hv_npk_log(struct acrn_vm *vm, uint64_t param)
{
struct hv_npk_log_param npk_param;
(void)memset((void *)&npk_param, 0U, sizeof(npk_param));
if (copy_from_gpa(vm, &npk_param, param, sizeof(npk_param)) != 0) {
pr_err("%s: Unable copy param from vm\n", __func__);
return -1;

View File

@ -815,8 +815,6 @@ int32_t profiling_msr_ops_all_cpus(struct acrn_vm *vm, uint64_t addr)
uint16_t pcpu_nums = get_pcpu_nums();
struct profiling_msr_ops_list msr_list[pcpu_nums];
(void)memset((void *)&msr_list, 0U, sizeof(msr_list));
dev_dbg(ACRN_DBG_PROFILING, "%s: entering", __func__);
if (copy_from_gpa(vm, &msr_list, addr, sizeof(msr_list)) != 0) {
@ -852,8 +850,6 @@ int32_t profiling_vm_list_info(struct acrn_vm *vm, uint64_t addr)
struct profiling_vm_info_list vm_info_list;
uint16_t pcpu_nums = get_pcpu_nums();
(void)memset((void *)&vm_info_list, 0U, sizeof(vm_info_list));
dev_dbg(ACRN_DBG_PROFILING, "%s: entering", __func__);
if (copy_from_gpa(vm, &vm_info_list, addr, sizeof(vm_info_list)) != 0) {
@ -914,8 +910,6 @@ int32_t profiling_get_version_info(struct acrn_vm *vm, uint64_t addr)
{
struct profiling_version_info ver_info;
(void)memset((void *)&ver_info, 0U, sizeof(ver_info));
dev_dbg(ACRN_DBG_PROFILING, "%s: entering", __func__);
if (copy_from_gpa(vm, &ver_info, addr, sizeof(ver_info)) != 0) {
@ -948,8 +942,6 @@ int32_t profiling_get_control(struct acrn_vm *vm, uint64_t addr)
{
struct profiling_control prof_control;
(void)memset((void *)&prof_control, 0U, sizeof(prof_control));
dev_dbg(ACRN_DBG_PROFILING, "%s: entering", __func__);
if (copy_from_gpa(vm, &prof_control, addr, sizeof(prof_control)) != 0) {
@ -990,8 +982,6 @@ int32_t profiling_set_control(struct acrn_vm *vm, uint64_t addr)
uint16_t pcpu_nums = get_pcpu_nums();
struct profiling_control prof_control;
(void)memset((void *)&prof_control, 0U, sizeof(prof_control));
dev_dbg(ACRN_DBG_PROFILING, "%s: entering", __func__);
if (copy_from_gpa(vm, &prof_control, addr, sizeof(prof_control)) != 0) {
@ -1103,8 +1093,6 @@ int32_t profiling_configure_pmi(struct acrn_vm *vm, uint64_t addr)
struct profiling_pmi_config pmi_config;
uint16_t pcpu_nums = get_pcpu_nums();
(void)memset((void *)&pmi_config, 0U, sizeof(pmi_config));
dev_dbg(ACRN_DBG_PROFILING, "%s: entering", __func__);
if (copy_from_gpa(vm, &pmi_config, addr, sizeof(pmi_config)) != 0) {
@ -1182,8 +1170,6 @@ int32_t profiling_configure_vmsw(struct acrn_vm *vm, uint64_t addr)
struct profiling_vmsw_config vmsw_config;
uint16_t pcpu_nums = get_pcpu_nums();
(void)memset((void *)&vmsw_config, 0U, sizeof(vmsw_config));
dev_dbg(ACRN_DBG_PROFILING, "%s: entering", __func__);
if (copy_from_gpa(vm, &vmsw_config, addr, sizeof(vmsw_config)) != 0) {
@ -1244,8 +1230,6 @@ int32_t profiling_get_pcpu_id(struct acrn_vm *vm, uint64_t addr)
{
struct profiling_pcpuid pcpuid;
(void)memset((void *)&pcpuid, 0U, sizeof(pcpuid));
dev_dbg(ACRN_DBG_PROFILING, "%s: entering", __func__);
if (copy_from_gpa(vm, &pcpuid, addr, sizeof(pcpuid)) != 0) {
@ -1275,8 +1259,6 @@ int32_t profiling_get_status_info(struct acrn_vm *vm, uint64_t gpa)
uint16_t pcpu_nums = get_pcpu_nums();
struct profiling_status pstats[pcpu_nums];
(void)memset((void *)&pstats, 0U, pcpu_nums*sizeof(struct profiling_status));
dev_dbg(ACRN_DBG_PROFILING, "%s: entering", __func__);
if (copy_from_gpa(vm, &pstats, gpa,