From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: Re: [RFC PATCH v2 2/3] vfio/iommu_type1: Optimize dirty bitmap population based on iommu HWDBM
Date: Sat, 08 May 2021 09:03:18 +0800 [thread overview]
Message-ID: <202105080826.HRculAqP-lkp@intel.com> (raw)
In-Reply-To: <20210507103608.39440-3-zhukeqian1@huawei.com>
[-- Attachment #1: Type: text/plain, Size: 9303 bytes --]
Hi Keqian,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on vfio/next]
[also build test ERROR on linux/master linus/master v5.12 next-20210507]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Keqian-Zhu/vfio-iommu_type1-Implement-dirty-log-tracking-based-on-IOMMU-HWDBM/20210507-183832
base: https://github.com/awilliam/linux-vfio.git next
config: x86_64-randconfig-a006-20210506 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project a3a8a1a15b524d91b5308db68e9d293b34cd88dd)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/53385033942861d447f335f3b605adef5f2ec4cd
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Keqian-Zhu/vfio-iommu_type1-Implement-dirty-log-tracking-based-on-IOMMU-HWDBM/20210507-183832
git checkout 53385033942861d447f335f3b605adef5f2ec4cd
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> drivers/vfio/vfio_iommu_type1.c:1213:9: error: implicit declaration of function 'iommu_clear_dirty_log' [-Werror,-Wimplicit-function-declaration]
ret = iommu_clear_dirty_log(d->domain, start_iova, size,
^
>> drivers/vfio/vfio_iommu_type1.c:1232:9: error: implicit declaration of function 'iommu_sync_dirty_log' [-Werror,-Wimplicit-function-declaration]
ret = iommu_sync_dirty_log(d->domain, dma->iova, dma->size,
^
>> drivers/vfio/vfio_iommu_type1.c:1372:11: error: implicit declaration of function 'iommu_switch_dirty_log' [-Werror,-Wimplicit-function-declaration]
WARN_ON(iommu_switch_dirty_log(d->domain, enable, dma->iova,
^
drivers/vfio/vfio_iommu_type1.c:2344:11: error: implicit declaration of function 'iommu_switch_dirty_log' [-Werror,-Wimplicit-function-declaration]
WARN_ON(iommu_switch_dirty_log(d->domain, enable, dma->iova,
^
drivers/vfio/vfio_iommu_type1.c:2359:19: error: implicit declaration of function 'iommu_support_dirty_log' [-Werror,-Wimplicit-function-declaration]
bool new_hwdbm = iommu_support_dirty_log(domain->domain);
^
5 errors generated.
vim +/iommu_clear_dirty_log +1213 drivers/vfio/vfio_iommu_type1.c
1202
1203 static int vfio_iommu_dirty_log_clear(struct vfio_iommu *iommu,
1204 dma_addr_t start_iova, size_t size,
1205 unsigned long *bitmap_buffer,
1206 dma_addr_t base_iova,
1207 unsigned long pgshift)
1208 {
1209 struct vfio_domain *d;
1210 int ret = 0;
1211
1212 list_for_each_entry(d, &iommu->domain_list, next) {
> 1213 ret = iommu_clear_dirty_log(d->domain, start_iova, size,
1214 bitmap_buffer, base_iova, pgshift);
1215 if (ret) {
1216 pr_warn("vfio_iommu dirty log clear failed!\n");
1217 break;
1218 }
1219 }
1220
1221 return ret;
1222 }
1223
1224 static int vfio_iommu_dirty_log_sync(struct vfio_iommu *iommu,
1225 struct vfio_dma *dma,
1226 unsigned long pgshift)
1227 {
1228 struct vfio_domain *d;
1229 int ret = 0;
1230
1231 list_for_each_entry(d, &iommu->domain_list, next) {
> 1232 ret = iommu_sync_dirty_log(d->domain, dma->iova, dma->size,
1233 dma->bitmap, dma->iova, pgshift);
1234 if (ret) {
1235 pr_warn("vfio_iommu dirty log sync failed!\n");
1236 break;
1237 }
1238 }
1239
1240 return ret;
1241 }
1242
1243 static int update_user_bitmap(u64 __user *bitmap, struct vfio_iommu *iommu,
1244 struct vfio_dma *dma, dma_addr_t base_iova,
1245 size_t pgsize)
1246 {
1247 unsigned long pgshift = __ffs(pgsize);
1248 unsigned long nbits = dma->size >> pgshift;
1249 unsigned long bit_offset = (dma->iova - base_iova) >> pgshift;
1250 unsigned long copy_offset = bit_offset / BITS_PER_LONG;
1251 unsigned long shift = bit_offset % BITS_PER_LONG;
1252 unsigned long leftover;
1253 bool iommu_hwdbm_dirty = false;
1254 int ret;
1255
1256 if (!iommu->num_non_pinned_groups || !dma->iommu_mapped) {
1257 /* nothing to do */
1258 } else if (!iommu->num_non_hwdbm_domains) {
1259 /* try to get dirty log from IOMMU */
1260 iommu_hwdbm_dirty = true;
1261 ret = vfio_iommu_dirty_log_sync(iommu, dma, pgshift);
1262 if (ret)
1263 return ret;
1264 } else {
1265 /*
1266 * mark all pages dirty if any IOMMU capable device is not able
1267 * to report dirty pages and all pages are pinned and mapped.
1268 */
1269 bitmap_set(dma->bitmap, 0, nbits);
1270 }
1271
1272 if (shift) {
1273 bitmap_shift_left(dma->bitmap, dma->bitmap, shift,
1274 nbits + shift);
1275
1276 if (copy_from_user(&leftover,
1277 (void __user *)(bitmap + copy_offset),
1278 sizeof(leftover)))
1279 return -EFAULT;
1280
1281 bitmap_or(dma->bitmap, dma->bitmap, &leftover, shift);
1282 }
1283
1284 if (copy_to_user((void __user *)(bitmap + copy_offset), dma->bitmap,
1285 DIRTY_BITMAP_BYTES(nbits + shift)))
1286 return -EFAULT;
1287
1288 /* Recover the bitmap if it'll be used to clear hardware dirty log */
1289 if (shift && iommu_hwdbm_dirty)
1290 bitmap_shift_right(dma->bitmap, dma->bitmap, shift,
1291 nbits + shift);
1292
1293 return 0;
1294 }
1295
1296 static int vfio_iova_dirty_bitmap(u64 __user *bitmap, struct vfio_iommu *iommu,
1297 dma_addr_t iova, size_t size, size_t pgsize)
1298 {
1299 struct vfio_dma *dma;
1300 struct rb_node *n;
1301 unsigned long pgshift = __ffs(pgsize);
1302 int ret;
1303
1304 /*
1305 * GET_BITMAP request must fully cover vfio_dma mappings. Multiple
1306 * vfio_dma mappings may be clubbed by specifying large ranges, but
1307 * there must not be any previous mappings bisected by the range.
1308 * An error will be returned if these conditions are not met.
1309 */
1310 dma = vfio_find_dma(iommu, iova, 1);
1311 if (dma && dma->iova != iova)
1312 return -EINVAL;
1313
1314 dma = vfio_find_dma(iommu, iova + size - 1, 0);
1315 if (dma && dma->iova + dma->size != iova + size)
1316 return -EINVAL;
1317
1318 for (n = rb_first(&iommu->dma_list); n; n = rb_next(n)) {
1319 struct vfio_dma *dma = rb_entry(n, struct vfio_dma, node);
1320
1321 if (dma->iova < iova)
1322 continue;
1323
1324 if (dma->iova > iova + size - 1)
1325 break;
1326
1327 ret = update_user_bitmap(bitmap, iommu, dma, iova, pgsize);
1328 if (ret)
1329 return ret;
1330
1331 /* Clear iommu dirty log to re-enable dirty log tracking */
1332 if (iommu->num_non_pinned_groups && dma->iommu_mapped &&
1333 !iommu->num_non_hwdbm_domains) {
1334 ret = vfio_iommu_dirty_log_clear(iommu, dma->iova,
1335 dma->size, dma->bitmap, dma->iova,
1336 pgshift);
1337 if (ret)
1338 return ret;
1339 }
1340
1341 /*
1342 * Re-populate bitmap to include all pinned pages which are
1343 * considered as dirty but exclude pages which are unpinned and
1344 * pages which are marked dirty by vfio_dma_rw()
1345 */
1346 bitmap_clear(dma->bitmap, 0, dma->size >> pgshift);
1347 vfio_dma_populate_bitmap(dma, pgsize);
1348 }
1349 return 0;
1350 }
1351
1352 static int verify_bitmap_size(uint64_t npages, uint64_t bitmap_size)
1353 {
1354 if (!npages || !bitmap_size || (bitmap_size > DIRTY_BITMAP_SIZE_MAX) ||
1355 (bitmap_size < DIRTY_BITMAP_BYTES(npages)))
1356 return -EINVAL;
1357
1358 return 0;
1359 }
1360
1361 static void vfio_dma_dirty_log_switch(struct vfio_iommu *iommu,
1362 struct vfio_dma *dma, bool enable)
1363 {
1364 struct vfio_domain *d;
1365
1366 if (!dma->iommu_mapped)
1367 return;
1368
1369 list_for_each_entry(d, &iommu->domain_list, next) {
1370 if (!d->iommu_hwdbm)
1371 continue;
> 1372 WARN_ON(iommu_switch_dirty_log(d->domain, enable, dma->iova,
1373 dma->size, d->prot | dma->prot));
1374 }
1375 }
1376
---
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: 36507 bytes --]
next prev parent reply other threads:[~2021-05-08 1:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-07 10:36 [RFC PATCH v2 0/3] vfio/iommu_type1: Implement dirty log tracking based on IOMMU HWDBM Keqian Zhu
2021-05-07 10:36 ` [RFC PATCH v2 1/3] vfio/iommu_type1: Add HWDBM status maintenance Keqian Zhu
2021-05-07 16:15 ` kernel test robot
2021-05-07 18:25 ` kernel test robot
2021-05-07 10:36 ` [RFC PATCH v2 2/3] vfio/iommu_type1: Optimize dirty bitmap population based on iommu HWDBM Keqian Zhu
2021-05-08 1:03 ` kernel test robot [this message]
2021-05-07 10:36 ` [RFC PATCH v2 3/3] vfio/iommu_type1: Add support for manual dirty log clear Keqian Zhu
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=202105080826.HRculAqP-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild-all@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.