All of lore.kernel.org
 help / color / mirror / Atom feed
* arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->addr > (~0)) => (0-u64max > u64max)'
@ 2020-10-07 18:47 kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2020-10-07 18:47 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4410 bytes --]

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Joerg Roedel <jroedel@suse.de>
CC: Paolo Bonzini <pbonzini@redhat.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   c85fb28b6f999db9928b841f63f1beeb3074eeca
commit: eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5 KVM: SVM: Move SEV code to separate file
date:   6 months ago
:::::: branch date: 24 hours ago
:::::: commit date: 6 months ago
config: x86_64-randconfig-m001-20201008 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->addr > (~0)) => (0-u64max > u64max)'
arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->size > (~0)) => (0-u64max > u64max)'

vim +982 arch/x86/kvm/svm/sev.c

eaf78265a4ab339 Joerg Roedel 2020-03-24   971  
eaf78265a4ab339 Joerg Roedel 2020-03-24   972  int svm_register_enc_region(struct kvm *kvm,
eaf78265a4ab339 Joerg Roedel 2020-03-24   973  			    struct kvm_enc_region *range)
eaf78265a4ab339 Joerg Roedel 2020-03-24   974  {
eaf78265a4ab339 Joerg Roedel 2020-03-24   975  	struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
eaf78265a4ab339 Joerg Roedel 2020-03-24   976  	struct enc_region *region;
eaf78265a4ab339 Joerg Roedel 2020-03-24   977  	int ret = 0;
eaf78265a4ab339 Joerg Roedel 2020-03-24   978  
eaf78265a4ab339 Joerg Roedel 2020-03-24   979  	if (!sev_guest(kvm))
eaf78265a4ab339 Joerg Roedel 2020-03-24   980  		return -ENOTTY;
eaf78265a4ab339 Joerg Roedel 2020-03-24   981  
eaf78265a4ab339 Joerg Roedel 2020-03-24  @982  	if (range->addr > ULONG_MAX || range->size > ULONG_MAX)
eaf78265a4ab339 Joerg Roedel 2020-03-24   983  		return -EINVAL;
eaf78265a4ab339 Joerg Roedel 2020-03-24   984  
eaf78265a4ab339 Joerg Roedel 2020-03-24   985  	region = kzalloc(sizeof(*region), GFP_KERNEL_ACCOUNT);
eaf78265a4ab339 Joerg Roedel 2020-03-24   986  	if (!region)
eaf78265a4ab339 Joerg Roedel 2020-03-24   987  		return -ENOMEM;
eaf78265a4ab339 Joerg Roedel 2020-03-24   988  
eaf78265a4ab339 Joerg Roedel 2020-03-24   989  	region->pages = sev_pin_memory(kvm, range->addr, range->size, &region->npages, 1);
eaf78265a4ab339 Joerg Roedel 2020-03-24   990  	if (!region->pages) {
eaf78265a4ab339 Joerg Roedel 2020-03-24   991  		ret = -ENOMEM;
eaf78265a4ab339 Joerg Roedel 2020-03-24   992  		goto e_free;
eaf78265a4ab339 Joerg Roedel 2020-03-24   993  	}
eaf78265a4ab339 Joerg Roedel 2020-03-24   994  
eaf78265a4ab339 Joerg Roedel 2020-03-24   995  	/*
eaf78265a4ab339 Joerg Roedel 2020-03-24   996  	 * The guest may change the memory encryption attribute from C=0 -> C=1
eaf78265a4ab339 Joerg Roedel 2020-03-24   997  	 * or vice versa for this memory range. Lets make sure caches are
eaf78265a4ab339 Joerg Roedel 2020-03-24   998  	 * flushed to ensure that guest data gets written into memory with
eaf78265a4ab339 Joerg Roedel 2020-03-24   999  	 * correct C-bit.
eaf78265a4ab339 Joerg Roedel 2020-03-24  1000  	 */
eaf78265a4ab339 Joerg Roedel 2020-03-24  1001  	sev_clflush_pages(region->pages, region->npages);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1002  
eaf78265a4ab339 Joerg Roedel 2020-03-24  1003  	region->uaddr = range->addr;
eaf78265a4ab339 Joerg Roedel 2020-03-24  1004  	region->size = range->size;
eaf78265a4ab339 Joerg Roedel 2020-03-24  1005  
eaf78265a4ab339 Joerg Roedel 2020-03-24  1006  	mutex_lock(&kvm->lock);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1007  	list_add_tail(&region->list, &sev->regions_list);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1008  	mutex_unlock(&kvm->lock);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1009  
eaf78265a4ab339 Joerg Roedel 2020-03-24  1010  	return ret;
eaf78265a4ab339 Joerg Roedel 2020-03-24  1011  
eaf78265a4ab339 Joerg Roedel 2020-03-24  1012  e_free:
eaf78265a4ab339 Joerg Roedel 2020-03-24  1013  	kfree(region);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1014  	return ret;
eaf78265a4ab339 Joerg Roedel 2020-03-24  1015  }
eaf78265a4ab339 Joerg Roedel 2020-03-24  1016  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 40525 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->addr > (~0)) => (0-u64max > u64max)'
@ 2020-11-01 21:59 kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2020-11-01 21:59 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4409 bytes --]

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Joerg Roedel <jroedel@suse.de>
CC: Paolo Bonzini <pbonzini@redhat.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   7b56fbd83e261484da43f04090bce07570bd117f
commit: eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5 KVM: SVM: Move SEV code to separate file
date:   7 months ago
:::::: branch date: 3 hours ago
:::::: commit date: 7 months ago
config: x86_64-randconfig-m031-20201102 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->addr > (~0)) => (0-u64max > u64max)'
arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->size > (~0)) => (0-u64max > u64max)'

vim +982 arch/x86/kvm/svm/sev.c

eaf78265a4ab339 Joerg Roedel 2020-03-24   971  
eaf78265a4ab339 Joerg Roedel 2020-03-24   972  int svm_register_enc_region(struct kvm *kvm,
eaf78265a4ab339 Joerg Roedel 2020-03-24   973  			    struct kvm_enc_region *range)
eaf78265a4ab339 Joerg Roedel 2020-03-24   974  {
eaf78265a4ab339 Joerg Roedel 2020-03-24   975  	struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
eaf78265a4ab339 Joerg Roedel 2020-03-24   976  	struct enc_region *region;
eaf78265a4ab339 Joerg Roedel 2020-03-24   977  	int ret = 0;
eaf78265a4ab339 Joerg Roedel 2020-03-24   978  
eaf78265a4ab339 Joerg Roedel 2020-03-24   979  	if (!sev_guest(kvm))
eaf78265a4ab339 Joerg Roedel 2020-03-24   980  		return -ENOTTY;
eaf78265a4ab339 Joerg Roedel 2020-03-24   981  
eaf78265a4ab339 Joerg Roedel 2020-03-24  @982  	if (range->addr > ULONG_MAX || range->size > ULONG_MAX)
eaf78265a4ab339 Joerg Roedel 2020-03-24   983  		return -EINVAL;
eaf78265a4ab339 Joerg Roedel 2020-03-24   984  
eaf78265a4ab339 Joerg Roedel 2020-03-24   985  	region = kzalloc(sizeof(*region), GFP_KERNEL_ACCOUNT);
eaf78265a4ab339 Joerg Roedel 2020-03-24   986  	if (!region)
eaf78265a4ab339 Joerg Roedel 2020-03-24   987  		return -ENOMEM;
eaf78265a4ab339 Joerg Roedel 2020-03-24   988  
eaf78265a4ab339 Joerg Roedel 2020-03-24   989  	region->pages = sev_pin_memory(kvm, range->addr, range->size, &region->npages, 1);
eaf78265a4ab339 Joerg Roedel 2020-03-24   990  	if (!region->pages) {
eaf78265a4ab339 Joerg Roedel 2020-03-24   991  		ret = -ENOMEM;
eaf78265a4ab339 Joerg Roedel 2020-03-24   992  		goto e_free;
eaf78265a4ab339 Joerg Roedel 2020-03-24   993  	}
eaf78265a4ab339 Joerg Roedel 2020-03-24   994  
eaf78265a4ab339 Joerg Roedel 2020-03-24   995  	/*
eaf78265a4ab339 Joerg Roedel 2020-03-24   996  	 * The guest may change the memory encryption attribute from C=0 -> C=1
eaf78265a4ab339 Joerg Roedel 2020-03-24   997  	 * or vice versa for this memory range. Lets make sure caches are
eaf78265a4ab339 Joerg Roedel 2020-03-24   998  	 * flushed to ensure that guest data gets written into memory with
eaf78265a4ab339 Joerg Roedel 2020-03-24   999  	 * correct C-bit.
eaf78265a4ab339 Joerg Roedel 2020-03-24  1000  	 */
eaf78265a4ab339 Joerg Roedel 2020-03-24  1001  	sev_clflush_pages(region->pages, region->npages);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1002  
eaf78265a4ab339 Joerg Roedel 2020-03-24  1003  	region->uaddr = range->addr;
eaf78265a4ab339 Joerg Roedel 2020-03-24  1004  	region->size = range->size;
eaf78265a4ab339 Joerg Roedel 2020-03-24  1005  
eaf78265a4ab339 Joerg Roedel 2020-03-24  1006  	mutex_lock(&kvm->lock);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1007  	list_add_tail(&region->list, &sev->regions_list);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1008  	mutex_unlock(&kvm->lock);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1009  
eaf78265a4ab339 Joerg Roedel 2020-03-24  1010  	return ret;
eaf78265a4ab339 Joerg Roedel 2020-03-24  1011  
eaf78265a4ab339 Joerg Roedel 2020-03-24  1012  e_free:
eaf78265a4ab339 Joerg Roedel 2020-03-24  1013  	kfree(region);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1014  	return ret;
eaf78265a4ab339 Joerg Roedel 2020-03-24  1015  }
eaf78265a4ab339 Joerg Roedel 2020-03-24  1016  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 31424 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->addr > (~0)) => (0-u64max > u64max)'
@ 2020-08-27 12:24 kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2020-08-27 12:24 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4664 bytes --]

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Joerg Roedel <jroedel@suse.de>
CC: Paolo Bonzini <pbonzini@redhat.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   15bc20c6af4ceee97a1f90b43c0e386643c071b4
commit: eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5 KVM: SVM: Move SEV code to separate file
date:   5 months ago
:::::: branch date: 18 hours ago
:::::: commit date: 5 months ago
config: x86_64-randconfig-m001-20200827 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->addr > (~0)) => (0-u64max > u64max)'
arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->size > (~0)) => (0-u64max > u64max)'

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5
vim +982 arch/x86/kvm/svm/sev.c

eaf78265a4ab33 Joerg Roedel 2020-03-24   971  
eaf78265a4ab33 Joerg Roedel 2020-03-24   972  int svm_register_enc_region(struct kvm *kvm,
eaf78265a4ab33 Joerg Roedel 2020-03-24   973  			    struct kvm_enc_region *range)
eaf78265a4ab33 Joerg Roedel 2020-03-24   974  {
eaf78265a4ab33 Joerg Roedel 2020-03-24   975  	struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
eaf78265a4ab33 Joerg Roedel 2020-03-24   976  	struct enc_region *region;
eaf78265a4ab33 Joerg Roedel 2020-03-24   977  	int ret = 0;
eaf78265a4ab33 Joerg Roedel 2020-03-24   978  
eaf78265a4ab33 Joerg Roedel 2020-03-24   979  	if (!sev_guest(kvm))
eaf78265a4ab33 Joerg Roedel 2020-03-24   980  		return -ENOTTY;
eaf78265a4ab33 Joerg Roedel 2020-03-24   981  
eaf78265a4ab33 Joerg Roedel 2020-03-24  @982  	if (range->addr > ULONG_MAX || range->size > ULONG_MAX)
eaf78265a4ab33 Joerg Roedel 2020-03-24   983  		return -EINVAL;
eaf78265a4ab33 Joerg Roedel 2020-03-24   984  
eaf78265a4ab33 Joerg Roedel 2020-03-24   985  	region = kzalloc(sizeof(*region), GFP_KERNEL_ACCOUNT);
eaf78265a4ab33 Joerg Roedel 2020-03-24   986  	if (!region)
eaf78265a4ab33 Joerg Roedel 2020-03-24   987  		return -ENOMEM;
eaf78265a4ab33 Joerg Roedel 2020-03-24   988  
eaf78265a4ab33 Joerg Roedel 2020-03-24   989  	region->pages = sev_pin_memory(kvm, range->addr, range->size, &region->npages, 1);
eaf78265a4ab33 Joerg Roedel 2020-03-24   990  	if (!region->pages) {
eaf78265a4ab33 Joerg Roedel 2020-03-24   991  		ret = -ENOMEM;
eaf78265a4ab33 Joerg Roedel 2020-03-24   992  		goto e_free;
eaf78265a4ab33 Joerg Roedel 2020-03-24   993  	}
eaf78265a4ab33 Joerg Roedel 2020-03-24   994  
eaf78265a4ab33 Joerg Roedel 2020-03-24   995  	/*
eaf78265a4ab33 Joerg Roedel 2020-03-24   996  	 * The guest may change the memory encryption attribute from C=0 -> C=1
eaf78265a4ab33 Joerg Roedel 2020-03-24   997  	 * or vice versa for this memory range. Lets make sure caches are
eaf78265a4ab33 Joerg Roedel 2020-03-24   998  	 * flushed to ensure that guest data gets written into memory with
eaf78265a4ab33 Joerg Roedel 2020-03-24   999  	 * correct C-bit.
eaf78265a4ab33 Joerg Roedel 2020-03-24  1000  	 */
eaf78265a4ab33 Joerg Roedel 2020-03-24  1001  	sev_clflush_pages(region->pages, region->npages);
eaf78265a4ab33 Joerg Roedel 2020-03-24  1002  
eaf78265a4ab33 Joerg Roedel 2020-03-24  1003  	region->uaddr = range->addr;
eaf78265a4ab33 Joerg Roedel 2020-03-24  1004  	region->size = range->size;
eaf78265a4ab33 Joerg Roedel 2020-03-24  1005  
eaf78265a4ab33 Joerg Roedel 2020-03-24  1006  	mutex_lock(&kvm->lock);
eaf78265a4ab33 Joerg Roedel 2020-03-24  1007  	list_add_tail(&region->list, &sev->regions_list);
eaf78265a4ab33 Joerg Roedel 2020-03-24  1008  	mutex_unlock(&kvm->lock);
eaf78265a4ab33 Joerg Roedel 2020-03-24  1009  
eaf78265a4ab33 Joerg Roedel 2020-03-24  1010  	return ret;
eaf78265a4ab33 Joerg Roedel 2020-03-24  1011  
eaf78265a4ab33 Joerg Roedel 2020-03-24  1012  e_free:
eaf78265a4ab33 Joerg Roedel 2020-03-24  1013  	kfree(region);
eaf78265a4ab33 Joerg Roedel 2020-03-24  1014  	return ret;
eaf78265a4ab33 Joerg Roedel 2020-03-24  1015  }
eaf78265a4ab33 Joerg Roedel 2020-03-24  1016  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 42218 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->addr > (~0)) => (0-u64max > u64max)'
@ 2020-07-15 23:15 kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2020-07-15 23:15 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4699 bytes --]

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Joerg Roedel <jroedel@suse.de>
CC: Paolo Bonzini <pbonzini@redhat.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   e9919e11e219eaa5e8041b7b1a196839143e9125
commit: eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5 KVM: SVM: Move SEV code to separate file
date:   3 months ago
:::::: branch date: 2 days ago
:::::: commit date: 3 months ago
config: x86_64-randconfig-m001-20200716 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->addr > (~0)) => (0-u64max > u64max)'
arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->size > (~0)) => (0-u64max > u64max)'

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git remote update linus
git checkout eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5
vim +982 arch/x86/kvm/svm/sev.c

eaf78265a4ab339 Joerg Roedel 2020-03-24   971  
eaf78265a4ab339 Joerg Roedel 2020-03-24   972  int svm_register_enc_region(struct kvm *kvm,
eaf78265a4ab339 Joerg Roedel 2020-03-24   973  			    struct kvm_enc_region *range)
eaf78265a4ab339 Joerg Roedel 2020-03-24   974  {
eaf78265a4ab339 Joerg Roedel 2020-03-24   975  	struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
eaf78265a4ab339 Joerg Roedel 2020-03-24   976  	struct enc_region *region;
eaf78265a4ab339 Joerg Roedel 2020-03-24   977  	int ret = 0;
eaf78265a4ab339 Joerg Roedel 2020-03-24   978  
eaf78265a4ab339 Joerg Roedel 2020-03-24   979  	if (!sev_guest(kvm))
eaf78265a4ab339 Joerg Roedel 2020-03-24   980  		return -ENOTTY;
eaf78265a4ab339 Joerg Roedel 2020-03-24   981  
eaf78265a4ab339 Joerg Roedel 2020-03-24  @982  	if (range->addr > ULONG_MAX || range->size > ULONG_MAX)
eaf78265a4ab339 Joerg Roedel 2020-03-24   983  		return -EINVAL;
eaf78265a4ab339 Joerg Roedel 2020-03-24   984  
eaf78265a4ab339 Joerg Roedel 2020-03-24   985  	region = kzalloc(sizeof(*region), GFP_KERNEL_ACCOUNT);
eaf78265a4ab339 Joerg Roedel 2020-03-24   986  	if (!region)
eaf78265a4ab339 Joerg Roedel 2020-03-24   987  		return -ENOMEM;
eaf78265a4ab339 Joerg Roedel 2020-03-24   988  
eaf78265a4ab339 Joerg Roedel 2020-03-24   989  	region->pages = sev_pin_memory(kvm, range->addr, range->size, &region->npages, 1);
eaf78265a4ab339 Joerg Roedel 2020-03-24   990  	if (!region->pages) {
eaf78265a4ab339 Joerg Roedel 2020-03-24   991  		ret = -ENOMEM;
eaf78265a4ab339 Joerg Roedel 2020-03-24   992  		goto e_free;
eaf78265a4ab339 Joerg Roedel 2020-03-24   993  	}
eaf78265a4ab339 Joerg Roedel 2020-03-24   994  
eaf78265a4ab339 Joerg Roedel 2020-03-24   995  	/*
eaf78265a4ab339 Joerg Roedel 2020-03-24   996  	 * The guest may change the memory encryption attribute from C=0 -> C=1
eaf78265a4ab339 Joerg Roedel 2020-03-24   997  	 * or vice versa for this memory range. Lets make sure caches are
eaf78265a4ab339 Joerg Roedel 2020-03-24   998  	 * flushed to ensure that guest data gets written into memory with
eaf78265a4ab339 Joerg Roedel 2020-03-24   999  	 * correct C-bit.
eaf78265a4ab339 Joerg Roedel 2020-03-24  1000  	 */
eaf78265a4ab339 Joerg Roedel 2020-03-24  1001  	sev_clflush_pages(region->pages, region->npages);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1002  
eaf78265a4ab339 Joerg Roedel 2020-03-24  1003  	region->uaddr = range->addr;
eaf78265a4ab339 Joerg Roedel 2020-03-24  1004  	region->size = range->size;
eaf78265a4ab339 Joerg Roedel 2020-03-24  1005  
eaf78265a4ab339 Joerg Roedel 2020-03-24  1006  	mutex_lock(&kvm->lock);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1007  	list_add_tail(&region->list, &sev->regions_list);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1008  	mutex_unlock(&kvm->lock);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1009  
eaf78265a4ab339 Joerg Roedel 2020-03-24  1010  	return ret;
eaf78265a4ab339 Joerg Roedel 2020-03-24  1011  
eaf78265a4ab339 Joerg Roedel 2020-03-24  1012  e_free:
eaf78265a4ab339 Joerg Roedel 2020-03-24  1013  	kfree(region);
eaf78265a4ab339 Joerg Roedel 2020-03-24  1014  	return ret;
eaf78265a4ab339 Joerg Roedel 2020-03-24  1015  }
eaf78265a4ab339 Joerg Roedel 2020-03-24  1016  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34792 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->addr > (~0)) => (0-u64max > u64max)'
@ 2020-06-11  0:19 kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2020-06-11  0:19 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4654 bytes --]

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Joerg Roedel <jroedel@suse.de>
CC: Paolo Bonzini <pbonzini@redhat.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   79ca035d2d941839f55f3b8b69f8e81c66946ed8
commit: eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5 KVM: SVM: Move SEV code to separate file
date:   10 weeks ago
:::::: branch date: 2 hours ago
:::::: commit date: 10 weeks ago
config: x86_64-randconfig-m001-20200611 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->addr > (~0)) => (0-u64max > u64max)'
arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->size > (~0)) => (0-u64max > u64max)'

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git remote update linus
git checkout eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5
vim +982 arch/x86/kvm/svm/sev.c

eaf78265a4ab33 Joerg Roedel 2020-03-24   971  
eaf78265a4ab33 Joerg Roedel 2020-03-24   972  int svm_register_enc_region(struct kvm *kvm,
eaf78265a4ab33 Joerg Roedel 2020-03-24   973  			    struct kvm_enc_region *range)
eaf78265a4ab33 Joerg Roedel 2020-03-24   974  {
eaf78265a4ab33 Joerg Roedel 2020-03-24   975  	struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
eaf78265a4ab33 Joerg Roedel 2020-03-24   976  	struct enc_region *region;
eaf78265a4ab33 Joerg Roedel 2020-03-24   977  	int ret = 0;
eaf78265a4ab33 Joerg Roedel 2020-03-24   978  
eaf78265a4ab33 Joerg Roedel 2020-03-24   979  	if (!sev_guest(kvm))
eaf78265a4ab33 Joerg Roedel 2020-03-24   980  		return -ENOTTY;
eaf78265a4ab33 Joerg Roedel 2020-03-24   981  
eaf78265a4ab33 Joerg Roedel 2020-03-24  @982  	if (range->addr > ULONG_MAX || range->size > ULONG_MAX)
eaf78265a4ab33 Joerg Roedel 2020-03-24   983  		return -EINVAL;
eaf78265a4ab33 Joerg Roedel 2020-03-24   984  
eaf78265a4ab33 Joerg Roedel 2020-03-24   985  	region = kzalloc(sizeof(*region), GFP_KERNEL_ACCOUNT);
eaf78265a4ab33 Joerg Roedel 2020-03-24   986  	if (!region)
eaf78265a4ab33 Joerg Roedel 2020-03-24   987  		return -ENOMEM;
eaf78265a4ab33 Joerg Roedel 2020-03-24   988  
eaf78265a4ab33 Joerg Roedel 2020-03-24   989  	region->pages = sev_pin_memory(kvm, range->addr, range->size, &region->npages, 1);
eaf78265a4ab33 Joerg Roedel 2020-03-24   990  	if (!region->pages) {
eaf78265a4ab33 Joerg Roedel 2020-03-24   991  		ret = -ENOMEM;
eaf78265a4ab33 Joerg Roedel 2020-03-24   992  		goto e_free;
eaf78265a4ab33 Joerg Roedel 2020-03-24   993  	}
eaf78265a4ab33 Joerg Roedel 2020-03-24   994  
eaf78265a4ab33 Joerg Roedel 2020-03-24   995  	/*
eaf78265a4ab33 Joerg Roedel 2020-03-24   996  	 * The guest may change the memory encryption attribute from C=0 -> C=1
eaf78265a4ab33 Joerg Roedel 2020-03-24   997  	 * or vice versa for this memory range. Lets make sure caches are
eaf78265a4ab33 Joerg Roedel 2020-03-24   998  	 * flushed to ensure that guest data gets written into memory with
eaf78265a4ab33 Joerg Roedel 2020-03-24   999  	 * correct C-bit.
eaf78265a4ab33 Joerg Roedel 2020-03-24  1000  	 */
eaf78265a4ab33 Joerg Roedel 2020-03-24  1001  	sev_clflush_pages(region->pages, region->npages);
eaf78265a4ab33 Joerg Roedel 2020-03-24  1002  
eaf78265a4ab33 Joerg Roedel 2020-03-24  1003  	region->uaddr = range->addr;
eaf78265a4ab33 Joerg Roedel 2020-03-24  1004  	region->size = range->size;
eaf78265a4ab33 Joerg Roedel 2020-03-24  1005  
eaf78265a4ab33 Joerg Roedel 2020-03-24  1006  	mutex_lock(&kvm->lock);
eaf78265a4ab33 Joerg Roedel 2020-03-24  1007  	list_add_tail(&region->list, &sev->regions_list);
eaf78265a4ab33 Joerg Roedel 2020-03-24  1008  	mutex_unlock(&kvm->lock);
eaf78265a4ab33 Joerg Roedel 2020-03-24  1009  
eaf78265a4ab33 Joerg Roedel 2020-03-24  1010  	return ret;
eaf78265a4ab33 Joerg Roedel 2020-03-24  1011  
eaf78265a4ab33 Joerg Roedel 2020-03-24  1012  e_free:
eaf78265a4ab33 Joerg Roedel 2020-03-24  1013  	kfree(region);
eaf78265a4ab33 Joerg Roedel 2020-03-24  1014  	return ret;
eaf78265a4ab33 Joerg Roedel 2020-03-24  1015  }
eaf78265a4ab33 Joerg Roedel 2020-03-24  1016  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33200 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-01 21:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-07 18:47 arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->addr > (~0)) => (0-u64max > u64max)' kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2020-11-01 21:59 kernel test robot
2020-08-27 12:24 kernel test robot
2020-07-15 23:15 kernel test robot
2020-06-11  0:19 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.