Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp182511ybl; Thu, 12 Dec 2019 16:12:31 -0800 (PST) X-Google-Smtp-Source: APXvYqy/VJSvrpEo5aXJkN+QUmEPuC2ynLb90CZJa3pRPnShvtTbgXYqawZVQKbzuOzu8D3vxqML X-Received: by 2002:a9d:730e:: with SMTP id e14mr10793094otk.62.1576195951433; Thu, 12 Dec 2019 16:12:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576195951; cv=none; d=google.com; s=arc-20160816; b=ER1GGHV7ve/s6BUrJ9nE5rJWjRKPjB9RK0+C9txA4+6aTqm7KFNFbtOQHMNQF+++AQ 2tyMX0kLWszUt7WbGHBltqgP46TQTWF4w1+ABMXiE8nlBQ2RR76xUuKnj+PS+lmUrlky kmjmjysZux04AQhP2SbwgXC9UbrEtJSjnMzS8RXPJNLUVp/CRnAab4bL6wL4kIQNjTWx pUC8RWt+9iHnBG3fjI5z9KsGYOc+dGuBdxwRh/Vrm8Qr5TTtvs/EPRgQdfDjXCepFy3K L/kz001I9OtpwRT7sIYxieEU9eSyjE7mX/zmp6WodpOtRXuPko1pbdQds3qRGUvslFY0 VCqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=TS0VnFP4wmXpcgCTt3VYjH+yAnIJ0NLMtHmpsTJa70s=; b=WfAEYkb2+Bh25Z/xm5WlaW3cSBGSlxh5IiSZrBLl5HYBc+vVM/DU1yhSe5L8STQkUO 8SXkVw2Ch7OyIS5qqg7/avfp02wmFV+MNgQOsetODjSFqHqQ68tavt97NzGZtBt5oJKG cqdqQz5ZEEw3sbsvx5lE8E2buRskwcrt7e1TfQtH6JFidg6PZ1OIZPYYGOVf8/vyLC7k K3WprnqZ9qoWKAB85OGwy0ssDYBcjGfcPVubn6q0wVppVCJ/kvC1eUyhnLYei/PoXvw2 jfO9iI2X9quPRU8Men1i7rWFs87dk9nUgwu33Mh/xUB62D/yKzgzT7dSBRLhQ0necC9I v4ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="O/yuRss+"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l20si3901219otd.292.2019.12.12.16.12.19; Thu, 12 Dec 2019 16:12:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="O/yuRss+"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731582AbfLMALI (ORCPT + 99 others); Thu, 12 Dec 2019 19:11:08 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:35249 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731574AbfLMAH7 (ORCPT ); Thu, 12 Dec 2019 19:07:59 -0500 Received: by mail-pf1-f194.google.com with SMTP id b19so397423pfo.2 for ; Thu, 12 Dec 2019 16:07:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=TS0VnFP4wmXpcgCTt3VYjH+yAnIJ0NLMtHmpsTJa70s=; b=O/yuRss+BmZ0/IH2KRo97L+6BZmXdi3DpHxPfoVh2jQ3ueWoHUSRG7f/nZ2tXcFePX t7hVQ2MzfV2M9LIiTlTZSck/vK4+qW4P2UYOjnYJiKW+flXb/33cDmhArQ5csCgbhZ2q 8Hv6DdbCeZnPRoQOp23dWt9nsaZFojFhLZscMYxiPvVzc6UJxWiOxmqkdd0AeYxBZrde XcI/dd/wvFdLDrxBKyLOCY+eDBr4ctN//dre2jP+c4Q1RQV8FXJJrK02IJxHtmj7eq1c uel8zAyvN2cBnlPr27m7WKBd/j0A4xvfIDapzLqaQouB8RkJIQgE7Podaj9OjV8c3gFl tOEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=TS0VnFP4wmXpcgCTt3VYjH+yAnIJ0NLMtHmpsTJa70s=; b=kWzE3thOqzSoDfxExGsYCGEENZ6WZ8B+c7FWD5oFLI9igCPB991J2cmqBI1JGEDRZe zQtKCYQQXP9iTkfG0PpJJmFpbRPif4uTvD1M+Mp/j2jrh9UTxPwnD8qEOMG8nvHCvCya F5dW0/plXMQO+w08msZM1VG0LOrrnS4E0QyWE7/Y8TPdCqtdy8mQWJ0n6aURZaAGAFRL 7n9/Gorpbn+7SrYNyuo7Qbg7tLt0AjwHrS/XzVSVVLckPkYnHWBl2HTjesr+Fw4EeyVw 6Sa2q7NfNYn3fEXHOZfFbeaAqgSADTwbPtN73MlHkzUSR7/kGB6+bAT3VTwqmBSjZgv4 Lhjg== X-Gm-Message-State: APjAAAXxKHyr+1jME0ZSZfdV91snUIMUPQrmiTkMjwc5rGe7irkXtFPx 51YQWVYsH01V1I/avyuAGBPNfNUca+I= X-Received: by 2002:a62:7986:: with SMTP id u128mr13463087pfc.192.1576195678234; Thu, 12 Dec 2019 16:07:58 -0800 (PST) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id g8sm8537407pfh.43.2019.12.12.16.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2019 16:07:56 -0800 (PST) Date: Thu, 12 Dec 2019 16:07:56 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Christoph Hellwig cc: "Lendacky, Thomas" , Keith Busch , Jens Axboe , "Singh, Brijesh" , Ming Lei , Peter Gonda , Jianxiong Gao , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "iommu@lists.linux-foundation.org" Subject: Re: [bug] __blk_mq_run_hw_queue suspicious rcu usage In-Reply-To: <20191128064056.GA19822@lst.de> Message-ID: References: <20190905060627.GA1753@lst.de> <1d74607e-37f7-56ca-aba3-5a3bd7a68561@amd.com> <20190918132242.GA16133@lst.de> <20191128064056.GA19822@lst.de> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 28 Nov 2019, Christoph Hellwig wrote: > > So we're left with making dma_pool_alloc(GFP_ATOMIC) actually be atomic > > even when the DMA needs to be unencrypted for SEV. Christoph's suggestion > > was to wire up dmapool in kernel/dma/remap.c for this. Is that necessary > > to be done for all devices that need to do dma_pool_alloc(GFP_ATOMIC) or > > can we do it within the DMA API itself so it's transparent to the driver? > > It needs to be transparent to the driver. Lots of drivers use GFP_ATOMIC > dma allocations, and all of them are broken on SEV setups currently. > Not my area, so bear with me. Since all DMA must be unencrypted in this case, what happens if all dma_direct_alloc_pages() calls go through the DMA pool in kernel/dma/remap.c when force_dma_unencrypted(dev) == true since __PAGE_ENC is cleared for these ptes? (Ignoring for a moment that this special pool should likely be a separate dma pool.) I assume a general depletion of that atomic pool so DEFAULT_DMA_COHERENT_POOL_SIZE becomes insufficient. I'm not sure what size any DMA pool wired up for this specific purpose would need to be sized at, so I assume dynamic resizing is required. It shouldn't be *that* difficult to supplement kernel/dma/remap.c with the ability to do background expansion of the atomic pool when nearing its capacity for this purpose? I imagine that if we just can't allocate pages within the DMA mask that it's the only blocker to dynamic expansion and we don't oom kill for lowmem. But perhaps vm.lowmem_reserve_ratio is good enough protection? Beyond that, I'm not sure what sizing would be appropriate if this is to be a generic solution in the DMA API for all devices that may require unecrypted memory.