BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: "Janis Schoetterl-Glausch" <[email protected]>
CC: Janosch Frank <[email protected]>
CC: Claudio Imbrenda <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   69dac8e431af26173ca0a1ebc87054e01c585bcc
commit: 7faa543df19bf62d4583a64d3902705747f2ad29 KVM: s390: gaccess: Refactor 
access address range check
date:   8 months ago
:::::: branch date: 16 hours ago
:::::: commit date: 8 months ago
config: s390-randconfig-m031-20220812 
(https://download.01.org/0day-ci/archive/20220814/[email protected]/config)
compiler: s390-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

smatch warnings:
arch/s390/kvm/gaccess.c:859 guest_range_to_gpas() error: uninitialized symbol 
'prot'.

vim +/prot +859 arch/s390/kvm/gaccess.c

2293897805c2fe Heiko Carstens           2014-01-01  796  
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  797  /**
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  798   * 
guest_range_to_gpas() - Calculate guest physical addresses of page fragments
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  799   * covering a logical 
range
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  800   * @vcpu: virtual cpu
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  801   * @ga: guest address, 
start of range
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  802   * @ar: access register
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  803   * @gpas: output 
argument, may be NULL
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  804   * @len: length of 
range in bytes
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  805   * @asce: 
address-space-control element to use for translation
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  806   * @mode: access mode
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  807   *
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  808   * Translate a logical 
range to a series of guest absolute addresses,
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  809   * such that the 
concatenation of page fragments starting at each gpa make up
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  810   * the whole range.
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  811   * The translation is 
performed as if done by the cpu for the given @asce, @ar,
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  812   * @mode and state of 
the @vcpu.
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  813   * If the translation 
causes an exception, its program interruption code is
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  814   * returned and the 
&struct kvm_s390_pgm_info pgm member of @vcpu is modified
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  815   * such that a 
subsequent call to kvm_s390_inject_prog_vcpu() will inject
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  816   * a correct exception 
into the guest.
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  817   * The resulting gpas 
are stored into @gpas, unless it is NULL.
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  818   *
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  819   * Note: All fragments 
except the first one start at the beginning of a page.
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  820   *      When deriving 
the boundaries of a fragment from a gpa, all but the last
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  821   *      fragment end 
at the end of the page.
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  822   *
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  823   * Return:
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  824   * * 0         - 
success
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  825   * * <0                
- translation could not be performed, for example if  guest
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  826   *               
memory could not be accessed
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  827   * * >0                
- an access exception occurred. In this case the returned value
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  828   *               is 
the program interruption code and the contents of pgm may
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  829   *               be 
used to inject an exception into the guest.
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  830   */
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  831  static int 
guest_range_to_gpas(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar,
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  832                         
       unsigned long *gpas, unsigned long len,
92c9632119b67f David Hildenbrand        2015-11-16  833                         
       const union asce asce, enum gacc_mode mode)
2293897805c2fe Heiko Carstens           2014-01-01  834  {
2293897805c2fe Heiko Carstens           2014-01-01  835         psw_t *psw = 
&vcpu->arch.sie_block->gpsw;
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  836         unsigned int 
offset = offset_in_page(ga);
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  837         unsigned int 
fragment_len;
cde0dcfb5df1db David Hildenbrand        2016-05-31  838         int 
lap_enabled, rc = 0;
6ae1574c2a24ee Christian Borntraeger    2017-06-07  839         enum prot_type 
prot;
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  840         unsigned long 
gpa;
2293897805c2fe Heiko Carstens           2014-01-01  841  
75a1812230ad7a Alexander Yarygin        2015-01-22  842         lap_enabled = 
low_address_protection_enabled(vcpu, asce);
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  843         while 
(min(PAGE_SIZE - offset, len) > 0) {
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  844                 
fragment_len = min(PAGE_SIZE - offset, len);
2293897805c2fe Heiko Carstens           2014-01-01  845                 ga = 
kvm_s390_logical_to_effective(vcpu, ga);
cde0dcfb5df1db David Hildenbrand        2016-05-31  846                 if 
(mode == GACC_STORE && lap_enabled && is_low_address(ga))
cde0dcfb5df1db David Hildenbrand        2016-05-31  847                         
return trans_exc(vcpu, PGM_PROTECTION, ga, ar, mode,
cde0dcfb5df1db David Hildenbrand        2016-05-31  848                         
                 PROT_TYPE_LA);
a752598254016d Heiko Carstens           2017-06-03  849                 if 
(psw_bits(*psw).dat) {
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  850                         
rc = guest_translate(vcpu, ga, &gpa, asce, mode, &prot);
2293897805c2fe Heiko Carstens           2014-01-01  851                         
if (rc < 0)
2293897805c2fe Heiko Carstens           2014-01-01  852                         
        return rc;
2293897805c2fe Heiko Carstens           2014-01-01  853                 } else {
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  854                         
gpa = kvm_s390_real_to_abs(vcpu, ga);
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  855                         
if (kvm_is_error_gpa(vcpu->kvm, gpa))
cde0dcfb5df1db David Hildenbrand        2016-05-31  856                         
        rc = PGM_ADDRESSING;
2293897805c2fe Heiko Carstens           2014-01-01  857                 }
cde0dcfb5df1db David Hildenbrand        2016-05-31  858                 if (rc)
6ae1574c2a24ee Christian Borntraeger    2017-06-07 @859                         
return trans_exc(vcpu, rc, ga, ar, mode, prot);
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  860                 if 
(gpas)
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  861                         
*gpas++ = gpa;
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  862                 offset 
= 0;
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  863                 ga += 
fragment_len;
7faa543df19bf6 Janis Schoetterl-Glausch 2021-11-26  864                 len -= 
fragment_len;
2293897805c2fe Heiko Carstens           2014-01-01  865         }
2293897805c2fe Heiko Carstens           2014-01-01  866         return 0;
2293897805c2fe Heiko Carstens           2014-01-01  867  }
2293897805c2fe Heiko Carstens           2014-01-01  868  

:::::: The code at line 859 was first introduced by commit
:::::: 6ae1574c2a24eec5efa8bac305a8f87c839acc64 KVM: s390: implement 
instruction execution protection for emulated ifetch

:::::: TO: Christian Borntraeger <[email protected]>
:::::: CC: Christian Borntraeger <[email protected]>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to