From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c06::244; helo=mail-io0-x244.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-io0-x244.google.com (mail-io0-x244.google.com [IPv6:2607:f8b0:4001:c06::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8038A2034AB25 for ; Sat, 4 Nov 2017 15:06:11 -0700 (PDT) Received: by mail-io0-x244.google.com with SMTP id 97so12085133iok.7 for ; Sat, 04 Nov 2017 15:10:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Sm7us8zwQz6+OjEiDboIJvFU/TWoyX8t3v6VVifG0aM=; b=h7oT3rvW9vQPSzpI/OldVcMTn9eDBQtxD+uRudcfs7r2j8is73iUWvsFL1TA4wH67w /b24wh7IWTc2xcFnP5g/mo3c7sly4gLkmmpP3GXdKG3G8jDYjoWuuiuuDLnlCq2diLic ZoieIamUE6Q3PCWosGEWbyAwXfUADKH5FyXM0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Sm7us8zwQz6+OjEiDboIJvFU/TWoyX8t3v6VVifG0aM=; b=ZoWhQx0qhLBhrn7x5Bbt9CE/zLhfG3PoSCXn0W2Af+Jt1OJ0ckwVHLHydDhBkGZ6/A 7vBoCQZOlvYmx/mMFeGOqlgVnufouepbRxjcYZKOJp/kEWG5Gs3OlzbWPwOAJgByIHTX jpDM5t3hNGs1P7v6wuBcwoOiu8q/jQvGk1gLcbSJ2Ve6vctgMNEUYm11HFg65Y5waC8f hVtedsEgMtr2KKkhhN0DPV3cj1CxtFidblfNwGCHrPh+nVSE8HEvwp0LbPafVspvMn0a y596uX77M2p0PDqNU1uQU86pAq27eZsKi+CXBSbCpcDjSvI3SXJwzJLKkNS6x/cbvF4w WQig== X-Gm-Message-State: AJaThX6M4wc7sff4U4u3vmQHDdbQqcyPGcxT2k1FeSFOS4cki2BufQpv gkuGn7dtcwu134fz+0sKqoyFMbJOV2SzV5NIZqGlvtSc X-Google-Smtp-Source: ABhQp+R9yNlamBVCi7qxngGVS8COugTVI9sJlD3ybFnJkbQP61Y/juis0nDeB6GE4ek0+/Ov0hpFgwXC9CCQX6K0HIM= X-Received: by 10.107.174.206 with SMTP id n75mr2383144ioo.43.1509833407246; Sat, 04 Nov 2017 15:10:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.131.167 with HTTP; Sat, 4 Nov 2017 15:10:06 -0700 (PDT) In-Reply-To: <20171104214012.30888-1-ard.biesheuvel@linaro.org> References: <20171104214012.30888-1-ard.biesheuvel@linaro.org> From: Ard Biesheuvel Date: Sat, 4 Nov 2017 22:10:06 +0000 Message-ID: To: "edk2-devel@lists.01.org" Cc: "Tian, Feng" , "Zeng, Star" , Eric Dong , Ard Biesheuvel Subject: Re: [PATCH] MdeModulePkg/SdMmcPciHcDxe: use FreeBuffer not FreePages from DMA buffer X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Nov 2017 22:06:11 -0000 Content-Type: text/plain; charset="UTF-8" On 4 November 2017 at 21:40, Ard Biesheuvel wrote: > Don't use EFI_PCI_IO_PROTOCOL::FreePages () to free an allocation > created with EFI_PCI_IO_PROTOCOL::AllocatePages (). It is simply > incorrect, but given that it may interfere with IOMMU DMA protection > and/or memory encryption, it could pose a security risk as well. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > index 23faec5e2be0..a6005dd33bce 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > @@ -1009,7 +1009,7 @@ SdMmcPassThruPassThru ( > > Done: > if ((Trb != NULL) && (Trb->AdmaDesc != NULL)) { > - FreePages (Trb->AdmaDesc, Trb->AdmaPages); > + Private->PciIo->FreeBuffer (Private->PciIo, Trb->AdmaPages, Trb->AdmaDesc); Actually, looking a bit deeper, it seems we need to simply call SdMmcFreeTrb () here, otherwise PciIo->Unmap() is never called on the DataMap mapping, which breaks non-coherent DMA (and also coherent bounce buffering DMA) > } > > if (Trb != NULL) { > -- > 2.11.0 >