Messages in this thread | | | Date | Sun, 17 Jul 2022 07:41:26 +0800 | From | kernel test robot <> | Subject | [intel-tdx:guest-hardening-rebased 13/23] kernel/dma/swiotlb.c:531:75: warning: suggest parentheses around '-' in operand of '&' |
| |
tree: https://github.com/intel/tdx.git guest-hardening-rebased head: c170462888e1dab8e3e80c1c6e3708dd473ad1ed commit: 294874a30f655fe082a24e1ca1aa3cafe41d00fd [13/23] swiotlb: Allocate memory in a cache-friendly way config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20220717/202207170722.7onSclOe-lkp@intel.com/config) compiler: gcc-11 (Debian 11.3.0-3) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel/tdx/commit/294874a30f655fe082a24e1ca1aa3cafe41d00fd git remote add intel-tdx https://github.com/intel/tdx.git git fetch --no-tags intel-tdx guest-hardening-rebased git checkout 294874a30f655fe082a24e1ca1aa3cafe41d00fd # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash kernel/dma/
If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
kernel/dma/swiotlb.c: In function 'swiotlb_find_slots': >> kernel/dma/swiotlb.c:531:75: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses] 531 | if (alloc_align_mask && (slot_dma_addr & alloc_align_mask - 1)) | ~~~~~~~~~~~~~~~~~^~~
vim +531 kernel/dma/swiotlb.c
487 488 /* 489 * Find a suitable number of IO TLB entries size that will fit this request and 490 * allocate a buffer from that IO TLB pool. 491 */ 492 static int swiotlb_find_slots(struct device *dev, phys_addr_t orig_addr, 493 size_t alloc_size, unsigned int alloc_align_mask) 494 { 495 struct io_tlb_mem *mem = dev->dma_io_tlb_mem; 496 struct io_tlb_slot *slot, *tmp; 497 unsigned long boundary_mask = dma_get_seg_boundary(dev); 498 dma_addr_t tbl_dma_addr = 499 phys_to_dma_unencrypted(dev, mem->start) & boundary_mask; 500 dma_addr_t slot_dma_addr; 501 unsigned long max_slots = get_max_slots(boundary_mask); 502 unsigned int iotlb_align_mask = 503 dma_get_min_align_mask(dev) & ~(IO_TLB_SIZE - 1); 504 unsigned int nslots = nr_slots(alloc_size); 505 unsigned int index, i; 506 unsigned int offset = swiotlb_align_offset(dev, orig_addr); 507 unsigned long flags; 508 509 BUG_ON(!nslots); 510 511 spin_lock_irqsave(&mem->lock, flags); 512 if (unlikely(nslots > mem->nslabs - mem->used)) 513 goto not_found; 514 515 list_for_each_entry_safe(slot, tmp, &mem->free_slots, node) { 516 index = slot - mem->slots; 517 slot_dma_addr = slot_addr(tbl_dma_addr, index); 518 if (orig_addr && 519 (slot_dma_addr & iotlb_align_mask) != 520 (orig_addr & iotlb_align_mask)) { 521 continue; 522 } 523 /* 524 * If requested size is larger than a page, ensure allocated 525 * memory to be page aligned. 526 */ 527 if (alloc_size >= PAGE_SIZE && (slot_dma_addr & ~PAGE_MASK)) 528 continue; 529 530 /* Ensure requested alignment is met */ > 531 if (alloc_align_mask && (slot_dma_addr & alloc_align_mask - 1)) 532 continue; 533 534 if (io_tlb_offset(index) + nslots > IO_TLB_SEGSIZE) 535 continue; 536 537 /* 538 * If we find a slot that indicates we have 'nslots' number of 539 * contiguous buffers, we allocate the buffers from that slot 540 * and mark the entries as '0' indicating unavailable. 541 */ 542 if (!iommu_is_span_boundary(index, nslots, 543 nr_slots(tbl_dma_addr), 544 max_slots)) { 545 if (find_next_zero_bit(mem->bitmap, index + nslots, index) == 546 index + nslots) 547 goto found; 548 } 549 } 550 551 not_found: 552 spin_unlock_irqrestore(&mem->lock, flags); 553 return -1; 554 555 found: 556 for (i = index; i < index + nslots; i++) { 557 __clear_bit(i, mem->bitmap); 558 mem->slots[i].alloc_size = 559 alloc_size - (offset + ((i - index) << IO_TLB_SHIFT)); 560 list_del(&mem->slots[i].node); 561 } 562 563 mem->used += nslots; 564 565 spin_unlock_irqrestore(&mem->lock, flags); 566 return index; 567 } 568
-- 0-DAY CI Kernel Test Service https://01.org/lkp
| |