Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2822275ybb; Mon, 30 Mar 2020 13:44:12 -0700 (PDT) X-Google-Smtp-Source: ADFU+vujt7F52cI9sxTgA5fspLIhHrzN1/nrVjpaFxObKqMN3sVIhXYQR7zzxHqN9Xw+pWqUHoaU X-Received: by 2002:a4a:2a09:: with SMTP id k9mr5760059oof.64.1585601052134; Mon, 30 Mar 2020 13:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585601052; cv=none; d=google.com; s=arc-20160816; b=TZnOipCMPHdiYD3Kd1IFKzoxjt3+5fVCFQiqQu7uCLRmENRRMFv9spP++3p60M03i3 rCJuY/qZpyYs3h9grrQP3cBMXa3aRiyhBtl91BJlAL32CzePr5FkipCyzFlkNH3tmdnV exXUR6hfK3F7L8VyPLks4AToFkpFCTojcvaNFTdf+qLWEn8ygiNRX1Fi6gfRw5teI+rh nJmV4/cImCVvsEDfg8BcjIDlMeiil5IToAaEW0qKzCCR1ZBlRuXSNZrDHVl28bA+zrfZ IrAfigXK5noWICW0IzP6P07hQOK5PWnDb/zpxUb9rGVTRU+5AC/pPI7Zpu8NOQLAe5I6 2Eew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr :dkim-signature; bh=pzei7EPNdSl0vQstWZdYvFBARJOekVDWFMh3y2n4Zzg=; b=QeIskth0C4e2Xhy7cuxlZC2CnIyZFDPxK6whMK+K6ekEXfUWXopr7onsLbbu1dWUbO 7+kldCbc3dORt/e0OtOo3IBnept+/8eRIGtwnRDB8f6QpzFi8R8yNQ4+rEkZoVHDGYmS OZhjkE6aq2ruprmDqlf1HA8cUWtl8CyHlPm2i1mAiJqSa82bfbMvnkz69ltve57zTXfb 3VgRMAknJyOwgibHgf7d4N3YRGfcOhKST7t1wBqiLuBPCTYA6UVZ20lcT9o71RwVDZqk d4DLUEQkT7j+9auNxPINqSXUnrUx2lm9f843YDNYMaVXRD4cnuDm87Ovbw67wMN27Ekw ZU/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=SoqkNnxD; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m12si6575677ooe.71.2020.03.30.13.43.59; Mon, 30 Mar 2020 13:44:12 -0700 (PDT) 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=@amazon.com header.s=amazon201209 header.b=SoqkNnxD; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728540AbgC3UmW (ORCPT + 99 others); Mon, 30 Mar 2020 16:42:22 -0400 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]:64132 "EHLO smtp-fw-9101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727437AbgC3UmW (ORCPT ); Mon, 30 Mar 2020 16:42:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1585600940; x=1617136940; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=pzei7EPNdSl0vQstWZdYvFBARJOekVDWFMh3y2n4Zzg=; b=SoqkNnxDDNpLJEjSehgHaebK+wGoVdRSn1EUjoFNeiLFwvu+XsbQ52Wb WFIYkGy9huKpC9aYl7CpIqR0zH/6qnFmDeLNj2BoAJ1/HSoJbiPbbCK7b 6FktbahnxEU1cznScP+FEEL1r5VaNTna9q+cTStoIFd+OZJ76CGnHqytR g=; IronPort-SDR: ZQ+rhy1V3tG9tO8gx4zMdwYV99PRd2MSqkQa6tUb6O30D5v+rRPtyfdHoJg1n+6rvekwp2wRW2 RRTQjGuwOMAQ== X-IronPort-AV: E=Sophos;i="5.72,325,1580774400"; d="scan'208";a="25953907" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1a-16acd5e0.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 30 Mar 2020 20:42:17 +0000 Received: from EX13MTAUWC001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-16acd5e0.us-east-1.amazon.com (Postfix) with ESMTPS id C9F3AA2992; Mon, 30 Mar 2020 20:42:09 +0000 (UTC) Received: from EX13D20UWC001.ant.amazon.com (10.43.162.244) by EX13MTAUWC001.ant.amazon.com (10.43.162.135) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Mar 2020 20:42:09 +0000 Received: from 38f9d3867b82.ant.amazon.com (10.43.162.134) by EX13D20UWC001.ant.amazon.com (10.43.162.244) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 30 Mar 2020 20:42:02 +0000 Subject: Re: [PATCH] swiotlb: Allow swiotlb to live at pre-defined address To: Konrad Rzeszutek Wilk , Kairui Song , , Jan Setje-Eilers CC: Dave Young , , "the arch/x86 maintainers" , Christoph Hellwig , "Marek Szyprowski" , Robin Murphy , , Linux Kernel Mailing List , Mark Rutland , , , Jan Kiszka , , , , , Laszlo Ersek , Baoquan He , Lianbo Jiang , , "Lendacky, Thomas" , , "Schoenherr, Jan H." References: <20200326162922.27085-1-graf@amazon.com> <20200328115733.GA67084@dhcp-128-65.nay.redhat.com> <20200330134004.GA31026@char.us.oracle.com> From: Alexander Graf Message-ID: <51432837-8804-0600-c7a3-8849506f999e@amazon.com> Date: Mon, 30 Mar 2020 22:42:00 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200330134004.GA31026@char.us.oracle.com> Content-Language: en-US X-Originating-IP: [10.43.162.134] X-ClientProxiedBy: EX13D10UWB002.ant.amazon.com (10.43.161.130) To EX13D20UWC001.ant.amazon.com (10.43.162.244) Content-Type: text/plain; charset="windows-1252"; format="flowed" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30.03.20 15:40, Konrad Rzeszutek Wilk wrote: > = > = > = > On Mon, Mar 30, 2020 at 02:06:01PM +0800, Kairui Song wrote: >> On Sat, Mar 28, 2020 at 7:57 PM Dave Young wrote: >>> >>> On 03/26/20 at 05:29pm, Alexander Graf wrote: >>>> The swiotlb is a very convenient fallback mechanism for bounce bufferi= ng of >>>> DMAable data. It is usually used for the compatibility case where devi= ces >>>> can only DMA to a "low region". >>>> >>>> However, in some scenarios this "low region" may be bound even more >>>> heavily. For example, there are embedded system where only an SRAM reg= ion >>>> is shared between device and CPU. There are also heterogeneous computi= ng >>>> scenarios where only a subset of RAM is cache coherent between the >>>> components of the system. There are partitioning hypervisors, where >>>> a "control VM" that implements device emulation has limited view into a >>>> partition's memory for DMA capabilities due to safety concerns. >>>> >>>> This patch adds a command line driven mechanism to move all DMA memory= into >>>> a predefined shared memory region which may or may not be part of the >>>> physical address layout of the Operating System. >>>> >>>> Ideally, the typical path to set this configuration would be through D= evice >>>> Tree or ACPI, but neither of the two mechanisms is standardized yet. A= lso, >>>> in the x86 MicroVM use case, we have neither ACPI nor Device Tree, but >>>> instead configure the system purely through kernel command line option= s. >>>> >>>> I'm sure other people will find the functionality useful going forward >>>> though and extend it to be triggered by DT/ACPI in the future. >>> >>> Hmm, we have a use case for kdump, this maybe useful. For example >>> swiotlb is enabled by default if AMD SME/SEV is active, and in kdump >>> kernel we have to increase the crashkernel reserved size for the extra >>> swiotlb requirement. I wonder if we can just reuse the old kernel's >>> swiotlb region and pass the addr to kdump kernel. >>> >> >> Yes, definitely helpful for kdump kernel. This can help reduce the >> crashkernel value. >> >> Previously I was thinking about something similar, play around the >> e820 entry passed to kdump and let it place swiotlb in wanted region. >> Simply remap it like in this patch looks much cleaner. >> >> If this patch is acceptable, one more patch is needed to expose the >> swiotlb in iomem, so kexec-tools can pass the right kernel cmdline to >> second kernel. > = > We seem to be passsing a lot of data to kexec.. Perhaps something > of a unified way since we seem to have a lot of things to pass - disabling > IOMMU, ACPI RSDT address, and then this. > = > CC-ing Anthony who is working on something - would you by any chance > have a doc on this? I see in general 2 use cases here: 1) Allow for a generic mechanism to have the fully system, individual = buses, devices or functions of a device go through a particular, = self-contained bounce buffer. This sounds like the holy grail to a lot of problems. It would solve = typical embedded scenarios where you only have a shared SRAM. It solves = the safety case (to some extent) where you need to ensure that one = device interaction doesn't conflict with another device interaction. It = also solves the problem I've tried to solve with the patch here. It's unfortunately a lot harder than the patch I sent, so it will take = me some time to come up with a working patch set.. I suppose starting = with a DT binding only is sensible. Worst case, x86 does also support DT ... (And yes, I'm always happy to review patches if someone else beats me to it) 2) Reuse the SWIOTLB from the previous boot on kexec/kdump I see little direct relation to SEV here. The only reason SEV makes it = more relevant, is that you need to have an SWIOTLB region available with = SEV while without you could live with a disabled IOMMU. However, I can definitely understand how you would want to have a way to = tell the new kexec'ed kernel where the old SWIOTLB was, so it can reuse = its memory for its own SWIOTLB. That way, you don't have to reserve = another 64MB of RAM for kdump. What I'm curious on is whether we need to be as elaborate. Can't we just = pass the old SWIOTLB as free memory to the new kexec'ed kernel and = everything else will fall into place? All that would take is a bit of = shuffling on the e820 table pass-through to the kexec'ed kernel, no? Thanks, Alex Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879