All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: arch/x86/kvm/svm/sev.c:982 svm_register_enc_region() warn: impossible condition '(range->addr > (~0)) => (0-u64max > u64max)'
Date: Thu, 27 Aug 2020 20:24:24 +0800	[thread overview]
Message-ID: <202008272020.3Bu6Fxcz%lkp@intel.com> (raw)

[-- 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 --]

             reply	other threads:[~2020-08-27 12:24 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202008272020.3Bu6Fxcz%lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.