Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75987C64E90 for ; Mon, 30 Nov 2020 10:51:01 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 14931206B7 for ; Mon, 30 Nov 2020 10:51:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EWstEzre" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 14931206B7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.40998.74080 (Exim 4.92) (envelope-from ) id 1kjgla-0005hn-TS; Mon, 30 Nov 2020 10:50:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 40998.74080; Mon, 30 Nov 2020 10:50:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kjgla-0005hg-Pq; Mon, 30 Nov 2020 10:50:46 +0000 Received: by outflank-mailman (input) for mailman id 40998; Mon, 30 Nov 2020 10:50:46 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kjggo-0004Aj-HG for xen-devel@lists.xenproject.org; Mon, 30 Nov 2020 10:45:50 +0000 Received: from mail-wr1-x42a.google.com (unknown [2a00:1450:4864:20::42a]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id fce6a8ae-1655-4ee9-858f-ecb60cdda627; Mon, 30 Nov 2020 10:45:39 +0000 (UTC) Received: by mail-wr1-x42a.google.com with SMTP id e7so15506949wrv.6 for ; Mon, 30 Nov 2020 02:45:39 -0800 (PST) Received: from CBGR90WXYV0 ([2a00:23c5:5785:9a01:8931:214a:807a:cb80]) by smtp.gmail.com with ESMTPSA id a65sm7213049wmc.35.2020.11.30.02.45.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Nov 2020 02:45:38 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fce6a8ae-1655-4ee9-858f-ecb60cdda627 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:reply-to:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-transfer-encoding:thread-index :content-language; bh=/diZ7VyXKP6X0O8jl6ZE2tV3//7EXwwtnKHThnr1OrI=; b=EWstEzre2pVp1WZ73KD7U4Lc0jp6RrfMUZLmSEQDAYXR8SwrUJDwYbDBQMb3qkG9WO sRg6rnrh14Vrd7tmJh+nv0K8KO4YRrR+99SyzXSRLKlIIEgIAiYJaB5gC8pwuf3FGe6z YHukkUKEJPS/CJKrg76SYWrZb4mxevjNZvZQ2V9hUj3IvRlSyjp0Vd2+vAaUxYtV0Fvn thdmP22iJ3UlV+jjG1d3Q4ole60R0U8nMDlsUAMfFQqrcyvbAAVGspzkRtHWouA7yVrK O7L6Ff6DszFUCT1dB7VV+nUIjc9AKi+h9miDHCkCPkgON/7Y7JcOfasfn6GZJq1SRlbU lxVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:reply-to:to:cc:references:in-reply-to :subject:date:message-id:mime-version:content-transfer-encoding :thread-index:content-language; bh=/diZ7VyXKP6X0O8jl6ZE2tV3//7EXwwtnKHThnr1OrI=; b=V7zGdsONtvq0hODOWeG1vFhK1AuFwFeI6u2+YFvM4vkjt1vH2Q0GTpJ5MQPsOTt3nn RPPRsLkm5WH+9Q/Bgo2rr1KKtlXD1KeRgQn9C2zNE4IQcqiNZxYl3c4+PsYghRBCXiRV EHNhoh5Zg2sx+Jhx+wu1jIPez7hAqCJQ/tPQkZVD40UBzsIJ16JE3c+3E8PC1lWZAOXu JWBGMH9HzCKIrbD9csSv8bcZhUD5FEgRgK0df9JUaA8SxpHKOGrjBNb5GpTXPVtYZn4I Ck8tYrCaO4GneOrs4sowKnRijkJl4x5xdEXnD3LZmp4neCort/vCw5iFintHIBJqHRr3 /Vww== X-Gm-Message-State: AOAM530kx2s+jzK27hpi049YKNkWr7AVvJlnlCcll0TrNaiQX79RwCn7 jUHCs5v8n6nw8YGn315brC4= X-Google-Smtp-Source: ABdhPJxl2R2FeAhkgx28P0MkA80KZrR1KI2bcy0PiaoXvbbgPlycFWvcCZKFlvEmHyHfAOyawsweGA== X-Received: by 2002:adf:82ca:: with SMTP id 68mr27203214wrc.332.1606733138482; Mon, 30 Nov 2020 02:45:38 -0800 (PST) From: Paul Durrant X-Google-Original-From: "Paul Durrant" Reply-To: To: "'Jan Beulich'" , Cc: "'Andrew Cooper'" , "'Kevin Tian'" References: In-Reply-To: Subject: RE: [PATCH v4] IOMMU: make DMA containment of quarantined devices optional Date: Mon, 30 Nov 2020 10:45:37 -0000 Message-ID: <013601d6c705$f09fd9a0$d1df8ce0$@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQI15LetYabIv76Hs54hT8VKRuHZ1akiP7Iw Content-Language: en-gb > -----Original Message----- > From: Jan Beulich > Sent: 27 November 2020 16:46 > To: xen-devel@lists.xenproject.org > Cc: Andrew Cooper ; Paul Durrant = ; Kevin Tian > > Subject: [PATCH v4] IOMMU: make DMA containment of quarantined devices = optional >=20 > Containing still in flight DMA was introduced to work around certain > devices / systems hanging hard upon hitting a "not-present" IOMMU = fault. > Passing through (such) devices (on such systems) is inherently = insecure > (as guests could easily arrange for IOMMU faults of any kind to = occur). > Defaulting to a mode where admins may not even become aware of issues > with devices can be considered undesirable. Therefore convert this = mode > of operation to an optional one, not one enabled by default. >=20 > This involves resurrecting code commit ea38867831da ("x86 / iommu: set > up a scratch page in the quarantine domain") did remove, in a slightly > extended and abstracted fashion. Here, instead of reintroducing a = pretty > pointless use of "goto" in domain_context_unmap(), and instead of = making > the function (at least temporarily) inconsistent, take the opportunity > and replace the other similarly pointless "goto" as well. >=20 > In order to key the re-instated bypasses off of there (not) being a = root > page table this further requires moving the = allocate_domain_resources() > invocation from reassign_device() to amd_iommu_setup_domain_device() = (or > else reassign_device() would allocate a root page table anyway); this = is > benign to the second caller of the latter function. >=20 > Take the opportunity and also limit the control to builds supporting > PCI. >=20 > Signed-off-by: Jan Beulich > --- > v4: "full" -> "scratch_page". Duplicate Kconfig help text into command > line doc. Re-base. > v3: IOMMU_quarantine_basic -> IOMMU_quarantine_fault, > IOMMU_quarantine_full -> IOMMU_quarantine_write_fault. Kconfig > option (choice) to select default. Limit to HAS_PCI. > v2: Don't use true/false. Introduce QUARANTINE_SKIP() (albeit I'm not > really convinced this is an improvement). Add comment. >=20 > --- a/docs/misc/xen-command-line.pandoc > +++ b/docs/misc/xen-command-line.pandoc > @@ -1278,7 +1278,7 @@ detection of systems known to misbehave > > Default: `new` unless directed-EOI is supported >=20 > ### iommu > - =3D List of [ , verbose, debug, force, required, = quarantine, > + =3D List of [ , verbose, debug, force, required, = quarantine[=3Dscratch-page], > sharept, intremap, intpost, crash-disable, > snoop, qinval, igfx, amd-iommu-perdev-intremap, > dom0-{passthrough,strict} ] > @@ -1316,11 +1316,32 @@ boolean (e.g. `iommu=3Dno`) can override t > will prevent Xen from booting if IOMMUs aren't discovered and = enabled > successfully. >=20 > -* The `quarantine` boolean can be used to control Xen's behavior = when > - de-assigning devices from guests. If enabled (the default), Xen = always > +* The `quarantine` option can be used to control Xen's behavior = when > + de-assigning devices from guests. > + > + When a PCI device is assigned to an untrusted domain, it is = possible > + for that domain to program the device to DMA to an arbitrary = address. > + The IOMMU is used to protect the host from malicious DMA by = making > + sure that the device addresses can only target memory assigned to = the > + guest. However, when the guest domain is torn down, assigning = the > + device back to the hardware domain would allow any in-flight DMA = to > + potentially target critical host data. To avoid this, = quarantining > + should be enabled. Quarantining can be done in two ways: In its = basic > + form, all in-flight DMA will simply be forced to encounter IOMMU > + faults. Since there are systems where doing so can cause host = lockup, > + an alternative form is available where writes to memory will be = made > + fault, but reads will be directed to a dummy page. The = implication > + here is that such reads will go unnoticed, i.e. an admin may not > + become aware of the underlying problem. > + > + Therefore, if this option is set to true (the default), Xen = always > quarantines such devices; they must be explicitly assigned back = to Dom0 > - before they can be used there again. If disabled, Xen will only > - quarantine devices the toolstack hass arranged for getting = quarantined. > + before they can be used there again. If set to "scratch-page", = still > + active DMA reads will additionally be directed to a "scratch" = page. If There's inconsistency of terms here. We should choose either 'dummy = page' or 'scratch page' (and my vote goes for the latter). Also, rather = than true or false, shouldn't we have 'off', 'basic', and = 'scratch-page'? Paul