From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id D6879780091 for ; Wed, 31 Jan 2024 13:28:17 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=djpdQnnxqQr+8bGXQF402JCt7oUH9WEQrHYPJUBn9gw=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1706707696; v=1; b=A3sb9NzzzbMueU3pUkpd/3D8n5aNw19lpGcA88/QtcpBBTTo5muLzK4m0q0aZxdSDy3MuZ9K O+DGuguylyV0Iw1hIIy9ODLtP397Kgii0ScIBhZbec9XDyy5kNc1f7aP/LXSPD1LedAGzuI74F8 MgzdNmJXnELooURRuIpNtnfs= X-Received: by 127.0.0.2 with SMTP id MJb8YY7687511xrN7gK8NbH1; Wed, 31 Jan 2024 05:28:16 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.13756.1706707695782489265 for ; Wed, 31 Jan 2024 05:28:15 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-671-1wy_IikrNNiPw8367h-UeA-1; Wed, 31 Jan 2024 08:28:11 -0500 X-MC-Unique: 1wy_IikrNNiPw8367h-UeA-1 X-Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F110E86D4D6; Wed, 31 Jan 2024 13:28:10 +0000 (UTC) X-Received: from [10.39.192.35] (unknown [10.39.192.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF5B6492BC8; Wed, 31 Jan 2024 13:28:09 +0000 (UTC) Message-ID: <51ccf2eb-25fd-7f12-608b-7d5a401c67e3@redhat.com> Date: Wed, 31 Jan 2024 14:28:08 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH] OvmfPkg/IoMmuDxe: Provide an implementation for SetAttribute To: devel@edk2.groups.io, thomas.lendacky@amd.com Cc: Ard Biesheuvel , Erdem Aktas , Gerd Hoffmann , Jiewen Yao , Min Xu , Michael Roth References: From: "Laszlo Ersek" In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: k9GKvW5x1qijlSVIkz7OFOAOx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=A3sb9Nzz; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 1/30/24 18:15, Lendacky, Thomas via groups.io wrote: > A recent change to the PciIoMap() function now propagates the return code > from the IoMmu protocol SetAttribute() operation. The implementation of > this operation in OvmfPkg/IoMmuDxe/CcIoMmu.c returns EFI_UNSUPPORTED, > resulting in a failure to boot the guest. >=20 > Provide an implementation for SetAttribute() that validates the IoMmu > access method being requested against the IoMmu mapping operation. >=20 > Suggested-by: Laszlo Ersek > Reviewed-by: Laszlo Ersek > Signed-off-by: Tom Lendacky > --- > OvmfPkg/IoMmuDxe/CcIoMmu.c | 55 +++++++++++++++++++- > 1 file changed, 53 insertions(+), 2 deletions(-) >=20 > diff --git a/OvmfPkg/IoMmuDxe/CcIoMmu.c b/OvmfPkg/IoMmuDxe/CcIoMmu.c > index b83a9690062b..795b945dacb0 100644 > --- a/OvmfPkg/IoMmuDxe/CcIoMmu.c > +++ b/OvmfPkg/IoMmuDxe/CcIoMmu.c > @@ -5,7 +5,7 @@ > operations must be performed on unencrypted buffer hence we use a boun= ce > buffer to map the guest buffer into an unencrypted DMA buffer. > =20 > - Copyright (c) 2017, AMD Inc. All rights reserved.
> + Copyright (c) 2017 - 2024, AMD Inc. All rights reserved.
> Copyright (c) 2017, Intel Corporation. All rights reserved.
> =20 > SPDX-License-Identifier: BSD-2-Clause-Patent > @@ -751,7 +751,58 @@ IoMmuSetAttribute ( > IN UINT64 IoMmuAccess > ) > { > - return EFI_UNSUPPORTED; > + MAP_INFO *MapInfo; > + EFI_STATUS Status; > + > + DEBUG ((DEBUG_VERBOSE, "%a: Mapping=3D0x%p Access=3D%lu\n", __func__, = Mapping, IoMmuAccess)); > + > + if (Mapping =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + Status =3D EFI_SUCCESS; > + > + // > + // An IoMmuAccess value of 0 is always accepted, validate any non-zero= value. > + // > + if (IoMmuAccess !=3D 0) { > + MapInfo =3D (MAP_INFO *)Mapping; > + > + // > + // The mapping operation already implied the access mode. Validate t= hat > + // the supplied access mode matches operation access mode. > + // > + switch (MapInfo->Operation) { > + case EdkiiIoMmuOperationBusMasterRead: > + case EdkiiIoMmuOperationBusMasterRead64: > + if (IoMmuAccess !=3D EDKII_IOMMU_ACCESS_READ) { > + Status =3D EFI_INVALID_PARAMETER; > + } > + > + break; > + > + case EdkiiIoMmuOperationBusMasterWrite: > + case EdkiiIoMmuOperationBusMasterWrite64: > + if (IoMmuAccess !=3D EDKII_IOMMU_ACCESS_WRITE) { > + Status =3D EFI_INVALID_PARAMETER; > + } > + > + break; > + > + case EdkiiIoMmuOperationBusMasterCommonBuffer: > + case EdkiiIoMmuOperationBusMasterCommonBuffer64: > + if (IoMmuAccess !=3D (EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCE= SS_WRITE)) { > + Status =3D EFI_INVALID_PARAMETER; > + } > + > + break; > + > + default: > + Status =3D EFI_UNSUPPORTED; > + } > + } > + > + return Status; > } > =20 > EDKII_IOMMU_PROTOCOL mIoMmu =3D { merged as commit 3 97c3f5b8d272 OvmfPkg/IoMmuDxe: Provide an implementation for SetAtt= ribute via -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114899): https://edk2.groups.io/g/devel/message/114899 Mute This Topic: https://groups.io/mt/104058148/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-