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 4421DAC171D for ; Tue, 30 Jan 2024 21:32:54 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=zUtbhpCF3nr1V0ELyyCMuOxe2Zz/mUdoWUiB6cganzA=; 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=1706650373; v=1; b=CuErazpMXoXxsp4cIhyEI9bbwkmkb2qtylrCxjYaBIpJadoLGnhH6QAT9TlI8LFpbUbQRSRq TE/n2qa8pNBacMuBSbyAX/e0yGu7wlBxaBK8hPPiRUxMqDiU8KSmxdn2Ixi5poc0QZFz/XN/82S qVXk7bfaH0RiIeCW3UbEanSg= X-Received: by 127.0.0.2 with SMTP id fMA9YY7687511xYp72PblR7F; Tue, 30 Jan 2024 13:32:53 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.8903.1706650372136665832 for ; Tue, 30 Jan 2024 13:32:52 -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-610-t94VnNu6M02Iv3C5d69TGw-1; Tue, 30 Jan 2024 16:32:49 -0500 X-MC-Unique: t94VnNu6M02Iv3C5d69TGw-1 X-Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 65F15185A782; Tue, 30 Jan 2024 21:32:48 +0000 (UTC) X-Received: from [10.39.192.28] (unknown [10.39.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3C05A8B; Tue, 30 Jan 2024 21:32:47 +0000 (UTC) Message-ID: Date: Tue, 30 Jan 2024 22:32:41 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH] OvmfPkg/IoMmuDxe: Provide an implementation for SetAttribute To: Tom Lendacky , devel@edk2.groups.io 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.5 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: fdj1ztIaOa0EBTg7WffRHl41x7686176AA= 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=CuErazpM; 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, Tom Lendacky 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(-) Thanks -- I'd like Min or Jiewen to approve this, then I'm glad to merge it= . Laszlo >=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 { -=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 (#114829): https://edk2.groups.io/g/devel/message/114829 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-