Hi Ashish,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on v5.11-rc6]
[also build test WARNING on next-20210125]
[cannot apply to kvm/linux-next tip/x86/mm tip/x86/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url:
https://github.com/0day-ci/linux/commits/Ashish-Kalra/KVM-SVM-Add-KVM_SEV...
base: 1048ba83fb1c00cd24172e23e8263972f6b5d9ac
config: i386-randconfig-r015-20210209 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
#
https://github.com/0day-ci/linux/commit/c086cd5491c6b84adcffedc1bf798df75...
git remote add linux-review
https://github.com/0day-ci/linux
git fetch --no-tags linux-review
Ashish-Kalra/KVM-SVM-Add-KVM_SEV-SEND_START-command/20210204-093647
git checkout c086cd5491c6b84adcffedc1bf798df758b18080
# save the attached .config to linux build tree
make W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
arch/x86/kvm/svm/sev.c: In function 'handle_unencrypted_region':
> arch/x86/kvm/svm/sev.c:945:18: warning: variable 'd_off'
set but not used [-Wunused-but-set-variable]
945 | int len, s_off, d_off;
| ^~~~~
vim +/d_off +945 arch/x86/kvm/svm/sev.c
934
935 static int handle_unencrypted_region(struct kvm *kvm,
936 unsigned long vaddr,
937 unsigned long vaddr_end,
938 unsigned long dst_vaddr,
939 unsigned int size,
940 bool *is_decrypted)
941 {
942 struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
943 struct page *page = NULL;
944 gfn_t gfn_start, gfn_end;
945 int len, s_off, d_off;
946 int srcu_idx;
947 int ret = 0;
948
949 /* ensure hva_to_gfn translations remain valid */
950 srcu_idx = srcu_read_lock(&kvm->srcu);
951
952 if (!hva_to_gfn(kvm, vaddr, &gfn_start)) {
953 srcu_read_unlock(&kvm->srcu, srcu_idx);
954 return -EINVAL;
955 }
956
957 if (!hva_to_gfn(kvm, vaddr_end, &gfn_end)) {
958 srcu_read_unlock(&kvm->srcu, srcu_idx);
959 return -EINVAL;
960 }
961
962 if (sev->shared_pages_list_count) {
963 if (is_unencrypted_region(gfn_start, gfn_end,
964 &sev->shared_pages_list)) {
965 page = alloc_page(GFP_KERNEL);
966 if (!page) {
967 srcu_read_unlock(&kvm->srcu, srcu_idx);
968 return -ENOMEM;
969 }
970
971 /*
972 * Since user buffer may not be page aligned, calculate the
973 * offset within the page.
974 */
975 s_off = vaddr & ~PAGE_MASK;
976 d_off = dst_vaddr & ~PAGE_MASK;
977 len = min_t(size_t, (PAGE_SIZE - s_off), size);
978
979 if (copy_from_user(page_address(page),
980 (void __user *)(uintptr_t)vaddr, len)) {
981 __free_page(page);
982 srcu_read_unlock(&kvm->srcu, srcu_idx);
983 return -EFAULT;
984 }
985
986 if (copy_to_user((void __user *)(uintptr_t)dst_vaddr,
987 page_address(page), len)) {
988 ret = -EFAULT;
989 }
990
991 __free_page(page);
992 srcu_read_unlock(&kvm->srcu, srcu_idx);
993 *is_decrypted = true;
994 return ret;
995 }
996 }
997 srcu_read_unlock(&kvm->srcu, srcu_idx);
998 *is_decrypted = false;
999 return ret;
1000 }
1001
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org