[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: swiotlb cleanups v3


  • To: hch@xxxxxx
  • From: Tom Lendacky <thomas.lendacky@xxxxxxx>
  • Date: Sat, 17 Apr 2021 16:20:57 -0500
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KMRCQAz62yxAxQYydZ3OIU/kAdlPzJGamQ+EZHW0nQc=; b=WGCf+sZRFbsLCRSwBXppYref1BB/W0w5kcjwu6jUBGl9eAS1usJtcsr5RecVaMbXfXtKr+T5jSC6wuv1ZaHDPLqY38DzZkKXj6SOc2y4G26t0LVINOOG5Su0nybf24tW2mru5w4LRw8ROsTMF66I7PNPVRAbB9fWzFHM+RT8+Q7bn+afa4Tk0w0mj8tsujLK4BDZ9eWcoukw/EdBxtQNWp9hzsSoGcgG2U7nUWBPvuQVwRfOtlQtDqJJvqpaozuuIyweLd12G0ViXD18uE5KAAo8gbAl3kzpzdaFM22fMsnodwOFnQ2vO9Bsx8ETDt4aLFHxBI+tdWIQpG8wIVmZBQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bl+5+HRXFW/MakV5JzouCezfNzKY6yiCeu2MgA+E8mRSpm1GAwjaH9zUDtzYI0noB/BpY8KLxssLxN/1shTBCETP8uhhEMyFrkiPTYPaSup77eZ89GgCJpmZyN1SFh5cnP5mDWmkY6h741r9/oiI7r4FkK8ULIP3TzNWDqTtGz6JdgH6fz2WbIb9H1O6EFG59+VXuhtTQzfhy7xoblpkS50hpksf+YXXEZmEL0Z6dQhwtWNcmm2mfJAG5WgXimgrvdPlR8fgO4S8Ew3oRAQKQzWWRc0c47Z8NURlEp7xDzaiR/ufg4QjB16OoWgdr2352aT0SKAIghP2+8aySpO7lw==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=amd.com;
  • Cc: dongli.zhang@xxxxxxxxxx, iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx, konrad.wilk@xxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, mpe@xxxxxxxxxxxxxx, tientzu@xxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Sat, 17 Apr 2021 21:21:25 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 4/17/21 11:39 AM, Tom Lendacky wrote:
>> Hi Konrad,
>>
>> this series contains a bunch of swiotlb cleanups, mostly to reduce the
>> amount of internals exposed to code outside of swiotlb.c, which should
>> helper to prepare for supporting multiple different bounce buffer pools.
> 
> Somewhere between the 1st and 2nd patch, specifying a specific swiotlb
> for an SEV guest is no longer honored. For example, if I start an SEV
> guest with 16GB of memory and specify swiotlb=131072 I used to get a
> 256MB SWIOTLB. However, after the 2nd patch, the swiotlb=131072 is no
> longer honored and I get a 982MB SWIOTLB (as set via sev_setup_arch() in
> arch/x86/mm/mem_encrypt.c).
> 
> I can't be sure which patch caused the issue since an SEV guest fails to
> boot with the 1st patch but can boot with the 2nd patch, at which point
> the SWIOTLB comes in at 982MB (I haven't had a chance to debug it and so
> I'm hoping you might be able to quickly spot what's going on).

Ok, I figured out the 1st patch boot issue (which is gone when the
second patch is applied). Here's the issue if anyone is interested:

diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index d9c097f0f78c..dbe369674afe 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -226,7 +226,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long 
nslabs, int verbose)
 
        alloc_size = PAGE_ALIGN(mem->nslabs * sizeof(size_t));
        mem->alloc_size = memblock_alloc(alloc_size, PAGE_SIZE);
-       if (mem->alloc_size)
+       if (!mem->alloc_size)
                panic("%s: Failed to allocate %zu bytes align=0x%lx\n",
                      __func__, alloc_size, PAGE_SIZE);
 

The 1st patch still allowed the command line specified size of 256MB
SWIOTLB. So that means the 2nd patch causes the command line specified
256MB SWIOTLB size to be ignored and results in a 982MB SWIOTLB size
for the 16GB guest.

Thanks,
Tom

> 
> Thanks,
> Tom
> 
>>
>> Changes since v2:
>>  - fix a bisetion hazard that did not allocate the alloc_size array
>>  - dropped all patches already merged
>>
>> Changes since v1:
>>  - rebased to v5.12-rc1
>>  - a few more cleanups
>>  - merge and forward port the patch from Claire to move all the global
>>    variables into a struct to prepare for multiple instances
> 



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.