tree:   https://github.com/codomania/kvm devel
head:   d131361bbc4c2bbf27c47f4215648b004e7ed503
commit: 4e68491f8e378163201f1850aed8e6a412315ca4 [5/10] KVM: SVM: Add 
KVM_SEV_RECEIVE_UPDATE_DATA command

New smatch warnings:
arch/x86/kvm/svm.c:7306 sev_receive_update_data() error: 'hdr' dereferencing 
possible ERR_PTR()
arch/x86/kvm/svm.c:7307 sev_receive_update_data() error: 'trans' dereferencing 
possible ERR_PTR()

Old smatch warnings:
arch/x86/kvm/svm.c:882 has_svm() error: uninitialized symbol 'msg'.
arch/x86/kvm/svm.c:5242 get_pi_vcpu_info() warn: should 
'((((*svm)->avic_backing_page) - mem_map) + (0)) << 12' be a 64 bit type?
arch/x86/kvm/svm.c:6969 sev_send_start() warn: possible memory leak of 'data'
arch/x86/kvm/svm.c:7032 sev_send_start() error: 'pdh_cert' dereferencing 
possible ERR_PTR()
arch/x86/kvm/svm.c:7033 sev_send_start() error: 'plat_cert' dereferencing 
possible ERR_PTR()
arch/x86/kvm/svm.c:7034 sev_send_start() error: 'amd_cert' dereferencing 
possible ERR_PTR()
arch/x86/kvm/svm.c:7232 sev_receive_start() error: 'pdh_data' dereferencing 
possible ERR_PTR()
arch/x86/kvm/svm.c:7233 sev_receive_start() error: 'session_data' dereferencing 
possible ERR_PTR()

# 
https://github.com/codomania/kvm/commit/4e68491f8e378163201f1850aed8e6a412315ca4
git remote add codomania-kvm https://github.com/codomania/kvm
git remote update codomania-kvm
git checkout 4e68491f8e378163201f1850aed8e6a412315ca4
vim +/hdr +7306 arch/x86/kvm/svm.c

25c3768e Brijesh Singh 2019-03-29  7237  
4e68491f Brijesh Singh 2019-03-29  7238  static int 
sev_receive_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp)
4e68491f Brijesh Singh 2019-03-29  7239  {
4e68491f Brijesh Singh 2019-03-29  7240         struct kvm_sev_info *sev = 
&to_kvm_svm(kvm)->sev_info;
4e68491f Brijesh Singh 2019-03-29  7241         struct 
kvm_sev_receive_update_data params;
4e68491f Brijesh Singh 2019-03-29  7242         struct 
sev_data_receive_update_data *data;
4e68491f Brijesh Singh 2019-03-29  7243         void *hdr = NULL, *trans = NULL;
4e68491f Brijesh Singh 2019-03-29  7244         struct page **guest_page;
4e68491f Brijesh Singh 2019-03-29  7245         unsigned long n;
4e68491f Brijesh Singh 2019-03-29  7246         int ret, offset;
4e68491f Brijesh Singh 2019-03-29  7247  
4e68491f Brijesh Singh 2019-03-29  7248         if (!sev_guest(kvm))
4e68491f Brijesh Singh 2019-03-29  7249                 return -EINVAL;
4e68491f Brijesh Singh 2019-03-29  7250  
4e68491f Brijesh Singh 2019-03-29  7251         if (copy_from_user(&params, 
(void __user *)(uintptr_t)argp->data,
4e68491f Brijesh Singh 2019-03-29  7252                         sizeof(struct 
kvm_sev_receive_update_data)))
4e68491f Brijesh Singh 2019-03-29  7253                 return -EFAULT;
4e68491f Brijesh Singh 2019-03-29  7254  
4e68491f Brijesh Singh 2019-03-29  7255         if (!params.hdr_uaddr || 
!params.hdr_len ||
4e68491f Brijesh Singh 2019-03-29  7256             !params.guest_uaddr || 
!params.guest_len ||
4e68491f Brijesh Singh 2019-03-29  7257             !params.trans_uaddr || 
!params.trans_len)
4e68491f Brijesh Singh 2019-03-29  7258                 return -EINVAL;
4e68491f Brijesh Singh 2019-03-29  7259  
4e68491f Brijesh Singh 2019-03-29  7260         /* Check if we are crossing the 
page boundry */
4e68491f Brijesh Singh 2019-03-29  7261         offset = params.guest_uaddr & 
(PAGE_SIZE - 1);
4e68491f Brijesh Singh 2019-03-29  7262         if ((params.guest_len + offset 
> PAGE_SIZE))
4e68491f Brijesh Singh 2019-03-29  7263                 return -EINVAL;
4e68491f Brijesh Singh 2019-03-29  7264  
4e68491f Brijesh Singh 2019-03-29  7265         data = kzalloc(sizeof(*data), 
GFP_KERNEL);
4e68491f Brijesh Singh 2019-03-29  7266         if (!data)
4e68491f Brijesh Singh 2019-03-29  7267                 return -ENOMEM;
4e68491f Brijesh Singh 2019-03-29  7268  
4e68491f Brijesh Singh 2019-03-29  7269         hdr = 
psp_copy_user_blob(params.hdr_uaddr, params.hdr_len);
4e68491f Brijesh Singh 2019-03-29  7270         if (IS_ERR(hdr)) {
4e68491f Brijesh Singh 2019-03-29  7271                 ret = PTR_ERR(hdr);
4e68491f Brijesh Singh 2019-03-29  7272                 goto e_free;
4e68491f Brijesh Singh 2019-03-29  7273         }
4e68491f Brijesh Singh 2019-03-29  7274  
4e68491f Brijesh Singh 2019-03-29  7275         data->hdr_address = 
__psp_pa(hdr);
4e68491f Brijesh Singh 2019-03-29  7276         data->hdr_len = params.hdr_len;
4e68491f Brijesh Singh 2019-03-29  7277  
4e68491f Brijesh Singh 2019-03-29  7278         trans = 
psp_copy_user_blob(params.trans_uaddr, params.trans_len);
4e68491f Brijesh Singh 2019-03-29  7279         if (IS_ERR(trans)) {
4e68491f Brijesh Singh 2019-03-29  7280                 ret = PTR_ERR(trans);
4e68491f Brijesh Singh 2019-03-29  7281                 goto e_free;
4e68491f Brijesh Singh 2019-03-29  7282         }
4e68491f Brijesh Singh 2019-03-29  7283  
4e68491f Brijesh Singh 2019-03-29  7284         data->trans_address = 
__psp_pa(trans);
4e68491f Brijesh Singh 2019-03-29  7285         data->trans_len = 
params.trans_len;
4e68491f Brijesh Singh 2019-03-29  7286  
4e68491f Brijesh Singh 2019-03-29  7287         /* Pin guest memory */
4e68491f Brijesh Singh 2019-03-29  7288         ret = -EFAULT;
4e68491f Brijesh Singh 2019-03-29  7289         guest_page = 
sev_pin_memory(kvm, params.guest_uaddr & PAGE_MASK,
4e68491f Brijesh Singh 2019-03-29  7290                                     
PAGE_SIZE, &n, 0);
4e68491f Brijesh Singh 2019-03-29  7291         if (!guest_page)
4e68491f Brijesh Singh 2019-03-29  7292                 goto e_free;
4e68491f Brijesh Singh 2019-03-29  7293  
4e68491f Brijesh Singh 2019-03-29  7294         data->guest_address = 
__sme_page_pa(guest_page[0]) + offset;
4e68491f Brijesh Singh 2019-03-29  7295         data->guest_len = 
params.guest_len;
4e68491f Brijesh Singh 2019-03-29  7296  
4e68491f Brijesh Singh 2019-03-29  7297         /* flush the caches to ensure 
that DRAM has recent contents */
4e68491f Brijesh Singh 2019-03-29  7298         sev_clflush_pages(guest_page, 
n);
4e68491f Brijesh Singh 2019-03-29  7299  
4e68491f Brijesh Singh 2019-03-29  7300         data->handle = sev->handle;
4e68491f Brijesh Singh 2019-03-29  7301         ret = sev_issue_cmd(kvm, 
SEV_CMD_RECEIVE_UPDATE_DATA, data, &argp->error);
4e68491f Brijesh Singh 2019-03-29  7302  
4e68491f Brijesh Singh 2019-03-29  7303         sev_unpin_memory(kvm, 
guest_page, n);
4e68491f Brijesh Singh 2019-03-29  7304  e_free:
4e68491f Brijesh Singh 2019-03-29  7305         kfree(data);
4e68491f Brijesh Singh 2019-03-29 @7306         kfree(hdr);
4e68491f Brijesh Singh 2019-03-29 @7307         kfree(trans);
                                                      ^^^^^

4e68491f Brijesh Singh 2019-03-29  7308         return ret;
4e68491f Brijesh Singh 2019-03-29  7309  }
4e68491f Brijesh Singh 2019-03-29  7310  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
_______________________________________________
kbuild mailing list
kbuild@lists.01.org
https://lists.01.org/mailman/listinfo/kbuild

Reply via email to