From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAFC24DBD69 for ; Thu, 9 Jul 2026 18:13:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783620820; cv=none; b=Qj/uZDFxThb/zlMSLXadyXOumh0FitY5k9YiFmyBHvs15ITPccK7jj+KVkKk1PmZKklYFZEpgtp1s0zrVmrWH/syG7JXyPYG4Zs+48u1ASu1T5yRg+JUprj0XH1qCT3kS+yOfFKdWUtBJ/h4CHWTACDvBKhykarYG+cK3Fh+878= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783620820; c=relaxed/simple; bh=bvUrlGSFk5YOKRSganZsEuUYcVv+Ux1auqFKnDwJzG8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gruGzNAksQX2rLaIEffzEPb+IEfG/hx0uvHMeK74Q5kaPuJVTUHc9vzVph6opQJ8u9nSdXJV65fpaeCRYKYmYlgF1PA60Xtei65tKhgK10hds/0sf6TSO7KBwL3Thf1s1Mt6Ux2E1e3O17Wa6nQchNhvbQVXL+m9Q3fACq1YFSU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=CyuetQGX; arc=none smtp.client-ip=209.85.219.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="CyuetQGX" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-8efb708b1a0so2094166d6.3 for ; Thu, 09 Jul 2026 11:13:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1783620817; x=1784225617; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=cHkQmsdB2OewXXEQfHxageXwJQg6EnEw6Gurdq9kErI=; b=CyuetQGXo+XLSmoKTPOORB5iZq46kMYcinoWKTTT9t9YgZLQLkYpNwaUJHmexivIiu ECEWeHDILxRaM4+Ayvc+zpSU+PNsac7aNY6/lZqmH/QL/AoFDMu8CGhEKbIksPBegCUm UuqJfcc3QHSp+a+5qVjpvW4boDrYD+LeVpXx9OUax3+4uc+KdA0hzCejWb4CcqIDpTx8 4EazscwPbkuS+p88qBUmV24VJb72qoR9F89Z+B3/+befVNJt/e2UziS9nm3eL81IA/eF tnaxW2tmKDOVyQo4KijfP9MSuarwiJdw2Yh880kQAkUEGw9gtkNEvizju8tYl4otpXt1 cdlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783620817; x=1784225617; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=cHkQmsdB2OewXXEQfHxageXwJQg6EnEw6Gurdq9kErI=; b=YJm0Xi54AeZlSIjavhwxQ0YKs25I1gHN2IMo8gp6gW85g88WiYl30HwJNFcM5Hm33H l3m76AHkGNuscxkF5DW4fmBpjZe8ML9izEE3ILMvU5u+dBeSknfgHw2MKEhwXeuZ3ZMZ uHe6el72GTxythGGohQwq1oYO3CrCwogktPDfsaK39Jszdo3LCMIlvbgHdSQ3H9tGp5u +gGSoLSjH7z5hfG1LoKwHJoF5F29Rd/+zOTxi79fqogCeayks3ulsQBH7PqSnUulH9s5 88DEozRwfQ6jJbfS0ezoSWO1POD/UaueLkXB/ZkUFH9UM3DHwkB6q6ODGJlJK7mzYEZD lFhg== X-Forwarded-Encrypted: i=1; AHgh+RoPltcBItHwI+vp7NHD7CHcVkbC3EMThZ9MC2sicZrCwwUhKmjHqAyV6rVG/FNlxzVheyq1sy/8K6/hy90=@vger.kernel.org X-Gm-Message-State: AOJu0YwA8JdmGMMS33WzVcg7gw7NH53N6ncXjGvBLJpULtH85yS5rkSg nVqAc5Fs2HOQHk9xjYx5/KfqxZeX/tZo7SkyhNOWNfk0Qeh994RgZEI6lEQ2dg/xtu0= X-Gm-Gg: AfdE7ck4oz2F/n2DXKA8jZUXrNdokimAh1Nfkr5YdGzf2Rhdn3Xqb/f3svFySd6G7xC bTHdUidKr/iJmGef3OJE34nksrkjDbg+D0OhSmsLQnevRnRGREIR1WOVDzMktajhfb4+W/OLULU UAP1TOKaocfNXSoOEMruxXi0ghp5mKkUyENb+8yCZ9PUNAzsgBnxVfKQW2a1EldaP0F6E7YDOBW euKwlh84zri3yWdzdlfhSlRn/jCAVT107Un93QOo1Dd7R3O21GPiBxJlj5fNCexzuHYVqG78z7C AEn2bjESGfJMpBC4FUJrJPkULPl3q5p/pPRRTVOyCEIuTIqEfBdT0bFzyaD+i8UqekcHJm6/YFe IIGkxEGy4lkfHlJLmZsavNrsOUmVtqOHuNUZy98AxG43XjM5MA5Mw8VbijneT X-Received: by 2002:ac8:690c:0:b0:51c:43d8:8604 with SMTP id d75a77b69052e-51c8b3b4eb1mr92527611cf.51.1783620817365; Thu, 09 Jul 2026 11:13:37 -0700 (PDT) Received: from ziepe.ca ([159.2.72.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ffd82ea9casm22695666d6.42.2026.07.09.11.13.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 11:13:36 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1whtFg-00000005Kqr-0IQc; Thu, 09 Jul 2026 15:13:36 -0300 Date: Thu, 9 Jul 2026 15:13:36 -0300 From: Jason Gunthorpe To: Catalin Marinas Cc: "Aneesh Kumar K.V" , iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev, Robin Murphy , Marek Szyprowski , Will Deacon , Marc Zyngier , Steven Price , Suzuki K Poulose , Jiri Pirko , Mostafa Saleh , Petr Tesarik , Alexey Kardashevskiy , Dan Williams , Xu Yilun , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , x86@kernel.org, Jiri Pirko , Michael Kelley Subject: Re: [PATCH v7 16/22] dma-direct: make dma_direct_map_phys() honor DMA_ATTR_CC_SHARED Message-ID: <20260709181336.GM118978@ziepe.ca> References: <20260701054926.825925-1-aneesh.kumar@kernel.org> <20260701054926.825925-17-aneesh.kumar@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Jul 09, 2026 at 12:13:19PM +0100, Catalin Marinas wrote: > > > For AMD/SME, on host with memory encryption we now end up setting the C > > > bit for DMA_ATTR_MMIO. This is fine for RAM but not sure whether > > > some other MMIO bus understands this attribute. Maybe we should stick to > > > something like __phys_to_dma() for the !CC_SHARED && MMIO path. Or, > > > since this is not universally defined, just use the old dma_addr = phys > > > if MMIO and ignore any unlikely DMA offsets. > > > > > > > Considering for AMD/SME system an unencrypted dma addr is one without C > > bit, will this be good? > > > > /* > > * For host memory encryption and device requiring unencrypted DMA, > > * MMIO memory is treated as shared by default. > > */ > > if (attrs & DMA_ATTR_MMIO) { > > if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT) || force_dma_unencrypted(dev)) > > attrs |= DMA_ATTR_CC_SHARED; > > } > > Yes, I think it does the trick, preserves the current semantics for AMD. > I guess you could use a single 'if' for all checks (up to you). Please don't change it, MMIO P2P is broken on CC systems today and it should stay broken. Passing DMA_ATTR_MMIO with DMA_ATTR_CC_SHARED is an error that we need to correct in the drivers not make work in the core code. Jason