Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp36653pxb; Wed, 30 Mar 2022 22:15:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYAGWJ6B4rFr1lPtm11ZIhNW3bvlYnQfO+Z7gAM6rgNv1B/A9KJg+c7F3Lvn18XE4ZaSnO X-Received: by 2002:a17:902:f605:b0:14d:bd53:e2cd with SMTP id n5-20020a170902f60500b0014dbd53e2cdmr39303262plg.164.1648703732077; Wed, 30 Mar 2022 22:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648703732; cv=none; d=google.com; s=arc-20160816; b=JAj6C8FWuH/GBhhZ8jICJjD0fWdkrrqNKstYNBj5sVOK4+svtrbt0G+iZ/tMOFfJ8P eecrLw1H/L2zaP4ItuTA0lSQ4+SDxHaITC2uyWs7hCXNNxsU8/xq/SvCoE6oEwYjB5k4 bQ7Uj9C69ABAh9EXbePmBt2yTVgF6qJf1O9dw9hGAnNK/iPVVwnishStss75b97CaFxc 808gClVcvynGrXW2w9kq6homy9bOiyRpxtMFQcMxLZgDUARm0lVHuePZCXKfzd+Xia2e LBcFtsZzz9X5Er7lx74UeyZim3b+RybbucERCjZmr3HcXnmbpTGJ8i5/ygxaxn906TMQ duew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=TyI6lSLb2VMNQkD37oAbbw8GrUUXDy6JGKq3S68+GAs=; b=VUsQsmMd+vMGP4qkhGiqv6xWf9gLW9tpOXwzZzeMCRIac7vyr7gEFJTA3tGQDK+kP1 DwF2YpxsYj8SiJUhMlQgoCxNgg3ETTtm67oG6zFX314TRijyqE0d5VEBWB7VMV1HBDwr N6tIAMYXaBWHi76IIFXwoMn9VJig6dCzK6zkOKFb/SwX8qaS8opVRJgPzNVgx6TxZUi7 xmwqQpB3qs0h3hd9TN7+BjLI/flKEyvsQ4LcZok0nK6r/nsTMbBE9FQuZrv9v3EVOD4Q 92qLHzpDYqXPmf8BhyFnnzIWX+Lz5uAh1lxAO5Tt5DWVks5v/JHBexYphgUBoqxjMr4Y zoYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=N2RXeHOl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 13-20020a056a00072d00b004fb806eb0e6si9527396pfm.80.2022.03.30.22.15.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 22:15:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=N2RXeHOl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DA490149671; Wed, 30 Mar 2022 21:20:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229986AbiCaEVR (ORCPT + 99 others); Thu, 31 Mar 2022 00:21:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbiCaEVB (ORCPT ); Thu, 31 Mar 2022 00:21:01 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58EF022F3EB for ; Wed, 30 Mar 2022 21:08:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=TyI6lSLb2VMNQkD37oAbbw8GrUUXDy6JGKq3S68+GAs=; b=N2RXeHOlVWMotZnWmDzYjFmRvE 1rwxS4cCRHz+rrLZW3bq1Klzv9tSR/P+pFfwJduGkx/RHOrXbiCGigZQezP+2RVGDrWeUW6b4ldS7 Et5MhqtaU7oAaftlUdnP24FfW5v95xyYRqsGlVWKkHMEECZwvSZ3Xeu+n9h9yLangvp/XsKl9mWvO /5GM1jSiGKNMTxt2HGVyV0jgNaRgnd9B0SkYHVtMI7oHPcViliW7Dt7dpLkQub0DtM1tpkHMAr5E6 3QoetEDLgY2g5033b79N10yje6RFYtjVWzlHVxBAlO11pMWi5ASbag1mt5Ugh5T1eB3zc0mC0GmAT y8Pda/ZA==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nZm71-000atJ-TS; Thu, 31 Mar 2022 04:08:43 +0000 Date: Wed, 30 Mar 2022 21:08:43 -0700 From: Christoph Hellwig To: "Alex Xu (Hello71)" Cc: Christoph Hellwig , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, regressions@lists.linux.dev Subject: Re: "dma-mapping: remove CONFIG_DMA_REMAP" causes AMD SME boot fail Message-ID: References: <1648659326.eabkokyuym.none.ref@localhost> <1648659326.eabkokyuym.none@localhost> <1648667469.u35o6clg82.none@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1648667469.u35o6clg82.none@localhost> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 30, 2022 at 03:17:20PM -0400, Alex Xu (Hello71) wrote: > Excerpts from Christoph Hellwig's message of March 30, 2022 2:01 pm: > > Can you try this patch, which is a bit of a hack? > > > > diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c > > index 50d209939c66c..61997c2ee0a17 100644 > > --- a/arch/x86/mm/mem_encrypt.c > > +++ b/arch/x86/mm/mem_encrypt.c > > @@ -28,7 +28,8 @@ bool force_dma_unencrypted(struct device *dev) > > * device does not support DMA to addresses that include the > > * encryption mask. > > */ > > - if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) { > > + if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT) && > > + !get_dma_ops(dev)) { > > u64 dma_enc_mask = DMA_BIT_MASK(__ffs64(sme_me_mask)); > > u64 dma_dev_mask = min_not_zero(dev->coherent_dma_mask, > > dev->bus_dma_limit); > > > > This seems to work for me. Ok, I'll try to come up with a less hacky version and will start a discussion with the AMD folks that know memory encryption better. Thanks for the report and testing already!