[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202211270740.iwVw8jun-lkp@intel.com>
Date: Sun, 27 Nov 2022 08:04:23 +0800
From: kernel test robot <lkp@...el.com>
To: Thomas Bogendoerfer <tsbogend@...ha.franken.de>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: arch/mips/kvm/vz.c:705:55: sparse: sparse: cast truncates bits from
constant value (fc0000000 becomes c0000000)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: e5f3ec38c8496dd7f6ada8a5e8d4958ef46ddb3f
commit: 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64 MIPS: Remove KVM_TE support
date: 1 year, 9 months ago
config: mips-randconfig-s041-20221127
compiler: mips-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=mips SHELL=/bin/bash arch/mips/kvm/ fs/proc/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
sparse warnings: (new ones prefixed by >>)
>> arch/mips/kvm/vz.c:705:55: sparse: sparse: cast truncates bits from constant value (fc0000000 becomes c0000000)
arch/mips/kvm/vz.c:710:55: sparse: sparse: cast truncates bits from constant value (fc0000000 becomes c0000000)
>> arch/mips/kvm/vz.c:714:55: sparse: sparse: cast truncates bits from constant value (fe0000000 becomes e0000000)
arch/mips/kvm/vz.c:718:55: sparse: sparse: cast truncates bits from constant value (fe0000000 becomes e0000000)
arch/mips/kvm/vz.c:722:55: sparse: sparse: cast truncates bits from constant value (fe0000000 becomes e0000000)
arch/mips/kvm/vz.c:726:55: sparse: sparse: cast truncates bits from constant value (fe0000000 becomes e0000000)
vim +705 arch/mips/kvm/vz.c
4b7de028e66cc4 James Hogan 2017-03-14 677
c992a4f6a9b0a3 James Hogan 2017-03-14 678 /**
c992a4f6a9b0a3 James Hogan 2017-03-14 679 * kvm_vz_gva_to_gpa() - Convert valid GVA to GPA.
c992a4f6a9b0a3 James Hogan 2017-03-14 680 * @vcpu: KVM VCPU state.
c992a4f6a9b0a3 James Hogan 2017-03-14 681 * @gva: Guest virtual address to convert.
c992a4f6a9b0a3 James Hogan 2017-03-14 682 * @gpa: Output guest physical address.
c992a4f6a9b0a3 James Hogan 2017-03-14 683 *
c992a4f6a9b0a3 James Hogan 2017-03-14 684 * Convert a guest virtual address (GVA) which is valid according to the guest
c992a4f6a9b0a3 James Hogan 2017-03-14 685 * context, to a guest physical address (GPA).
c992a4f6a9b0a3 James Hogan 2017-03-14 686 *
c992a4f6a9b0a3 James Hogan 2017-03-14 687 * Returns: 0 on success.
c992a4f6a9b0a3 James Hogan 2017-03-14 688 * -errno on failure.
c992a4f6a9b0a3 James Hogan 2017-03-14 689 */
c992a4f6a9b0a3 James Hogan 2017-03-14 690 static int kvm_vz_gva_to_gpa(struct kvm_vcpu *vcpu, unsigned long gva,
c992a4f6a9b0a3 James Hogan 2017-03-14 691 unsigned long *gpa)
c992a4f6a9b0a3 James Hogan 2017-03-14 692 {
c992a4f6a9b0a3 James Hogan 2017-03-14 693 u32 gva32 = gva;
4b7de028e66cc4 James Hogan 2017-03-14 694 unsigned long segctl;
c992a4f6a9b0a3 James Hogan 2017-03-14 695
c992a4f6a9b0a3 James Hogan 2017-03-14 696 if ((long)gva == (s32)gva32) {
c992a4f6a9b0a3 James Hogan 2017-03-14 697 /* Handle canonical 32-bit virtual address */
4b7de028e66cc4 James Hogan 2017-03-14 698 if (cpu_guest_has_segments) {
4b7de028e66cc4 James Hogan 2017-03-14 699 unsigned long mask, pa;
4b7de028e66cc4 James Hogan 2017-03-14 700
4b7de028e66cc4 James Hogan 2017-03-14 701 switch (gva32 >> 29) {
4b7de028e66cc4 James Hogan 2017-03-14 702 case 0:
4b7de028e66cc4 James Hogan 2017-03-14 703 case 1: /* CFG5 (1GB) */
4b7de028e66cc4 James Hogan 2017-03-14 704 segctl = read_gc0_segctl2() >> 16;
4b7de028e66cc4 James Hogan 2017-03-14 @705 mask = (unsigned long)0xfc0000000ull;
4b7de028e66cc4 James Hogan 2017-03-14 706 break;
4b7de028e66cc4 James Hogan 2017-03-14 707 case 2:
4b7de028e66cc4 James Hogan 2017-03-14 708 case 3: /* CFG4 (1GB) */
4b7de028e66cc4 James Hogan 2017-03-14 709 segctl = read_gc0_segctl2();
4b7de028e66cc4 James Hogan 2017-03-14 710 mask = (unsigned long)0xfc0000000ull;
4b7de028e66cc4 James Hogan 2017-03-14 711 break;
4b7de028e66cc4 James Hogan 2017-03-14 712 case 4: /* CFG3 (512MB) */
4b7de028e66cc4 James Hogan 2017-03-14 713 segctl = read_gc0_segctl1() >> 16;
4b7de028e66cc4 James Hogan 2017-03-14 @714 mask = (unsigned long)0xfe0000000ull;
4b7de028e66cc4 James Hogan 2017-03-14 715 break;
4b7de028e66cc4 James Hogan 2017-03-14 716 case 5: /* CFG2 (512MB) */
4b7de028e66cc4 James Hogan 2017-03-14 717 segctl = read_gc0_segctl1();
4b7de028e66cc4 James Hogan 2017-03-14 718 mask = (unsigned long)0xfe0000000ull;
4b7de028e66cc4 James Hogan 2017-03-14 719 break;
4b7de028e66cc4 James Hogan 2017-03-14 720 case 6: /* CFG1 (512MB) */
4b7de028e66cc4 James Hogan 2017-03-14 721 segctl = read_gc0_segctl0() >> 16;
4b7de028e66cc4 James Hogan 2017-03-14 722 mask = (unsigned long)0xfe0000000ull;
4b7de028e66cc4 James Hogan 2017-03-14 723 break;
4b7de028e66cc4 James Hogan 2017-03-14 724 case 7: /* CFG0 (512MB) */
4b7de028e66cc4 James Hogan 2017-03-14 725 segctl = read_gc0_segctl0();
4b7de028e66cc4 James Hogan 2017-03-14 726 mask = (unsigned long)0xfe0000000ull;
4b7de028e66cc4 James Hogan 2017-03-14 727 break;
4b7de028e66cc4 James Hogan 2017-03-14 728 default:
4b7de028e66cc4 James Hogan 2017-03-14 729 /*
4b7de028e66cc4 James Hogan 2017-03-14 730 * GCC 4.9 isn't smart enough to figure out that
4b7de028e66cc4 James Hogan 2017-03-14 731 * segctl and mask are always initialised.
4b7de028e66cc4 James Hogan 2017-03-14 732 */
4b7de028e66cc4 James Hogan 2017-03-14 733 unreachable();
4b7de028e66cc4 James Hogan 2017-03-14 734 }
4b7de028e66cc4 James Hogan 2017-03-14 735
4b7de028e66cc4 James Hogan 2017-03-14 736 if (is_eva_am_mapped(vcpu, (segctl >> 4) & 0x7,
4b7de028e66cc4 James Hogan 2017-03-14 737 segctl & 0x0008))
4b7de028e66cc4 James Hogan 2017-03-14 738 goto tlb_mapped;
4b7de028e66cc4 James Hogan 2017-03-14 739
4b7de028e66cc4 James Hogan 2017-03-14 740 /* Unmapped, find guest physical address */
4b7de028e66cc4 James Hogan 2017-03-14 741 pa = (segctl << 20) & mask;
4b7de028e66cc4 James Hogan 2017-03-14 742 pa |= gva32 & ~mask;
4b7de028e66cc4 James Hogan 2017-03-14 743 *gpa = pa;
4b7de028e66cc4 James Hogan 2017-03-14 744 return 0;
4b7de028e66cc4 James Hogan 2017-03-14 745 } else if ((s32)gva32 < (s32)0xc0000000) {
c992a4f6a9b0a3 James Hogan 2017-03-14 746 /* legacy unmapped KSeg0 or KSeg1 */
c992a4f6a9b0a3 James Hogan 2017-03-14 747 *gpa = gva32 & 0x1fffffff;
c992a4f6a9b0a3 James Hogan 2017-03-14 748 return 0;
c992a4f6a9b0a3 James Hogan 2017-03-14 749 }
c992a4f6a9b0a3 James Hogan 2017-03-14 750 #ifdef CONFIG_64BIT
c992a4f6a9b0a3 James Hogan 2017-03-14 751 } else if ((gva & 0xc000000000000000) == 0x8000000000000000) {
c992a4f6a9b0a3 James Hogan 2017-03-14 752 /* XKPHYS */
4b7de028e66cc4 James Hogan 2017-03-14 753 if (cpu_guest_has_segments) {
4b7de028e66cc4 James Hogan 2017-03-14 754 /*
4b7de028e66cc4 James Hogan 2017-03-14 755 * Each of the 8 regions can be overridden by SegCtl2.XR
4b7de028e66cc4 James Hogan 2017-03-14 756 * to use SegCtl1.XAM.
4b7de028e66cc4 James Hogan 2017-03-14 757 */
4b7de028e66cc4 James Hogan 2017-03-14 758 segctl = read_gc0_segctl2();
4b7de028e66cc4 James Hogan 2017-03-14 759 if (segctl & (1ull << (56 + ((gva >> 59) & 0x7)))) {
4b7de028e66cc4 James Hogan 2017-03-14 760 segctl = read_gc0_segctl1();
4b7de028e66cc4 James Hogan 2017-03-14 761 if (is_eva_am_mapped(vcpu, (segctl >> 59) & 0x7,
4b7de028e66cc4 James Hogan 2017-03-14 762 0))
4b7de028e66cc4 James Hogan 2017-03-14 763 goto tlb_mapped;
4b7de028e66cc4 James Hogan 2017-03-14 764 }
4b7de028e66cc4 James Hogan 2017-03-14 765
4b7de028e66cc4 James Hogan 2017-03-14 766 }
c992a4f6a9b0a3 James Hogan 2017-03-14 767 /*
c992a4f6a9b0a3 James Hogan 2017-03-14 768 * Traditionally fully unmapped.
c992a4f6a9b0a3 James Hogan 2017-03-14 769 * Bits 61:59 specify the CCA, which we can just mask off here.
c992a4f6a9b0a3 James Hogan 2017-03-14 770 * Bits 58:PABITS should be zero, but we shouldn't have got here
c992a4f6a9b0a3 James Hogan 2017-03-14 771 * if it wasn't.
c992a4f6a9b0a3 James Hogan 2017-03-14 772 */
c992a4f6a9b0a3 James Hogan 2017-03-14 773 *gpa = gva & 0x07ffffffffffffff;
c992a4f6a9b0a3 James Hogan 2017-03-14 774 return 0;
c992a4f6a9b0a3 James Hogan 2017-03-14 775 #endif
c992a4f6a9b0a3 James Hogan 2017-03-14 776 }
c992a4f6a9b0a3 James Hogan 2017-03-14 777
4b7de028e66cc4 James Hogan 2017-03-14 778 tlb_mapped:
c992a4f6a9b0a3 James Hogan 2017-03-14 779 return kvm_vz_guest_tlb_lookup(vcpu, gva, gpa);
c992a4f6a9b0a3 James Hogan 2017-03-14 780 }
c992a4f6a9b0a3 James Hogan 2017-03-14 781
:::::: The code at line 705 was first introduced by commit
:::::: 4b7de028e66cc499ab85b5003af944225c8c87e9 KVM: MIPS/VZ: Support guest segmentation control
:::::: TO: James Hogan <james.hogan@...tec.com>
:::::: CC: James Hogan <james.hogan@...tec.com>
--
0-DAY CI Kernel Test Service
https://01.org/lkp
View attachment "config" of type "text/plain" (85936 bytes)
Powered by blists - more mailing lists