From: Juergen Gross <jgross@suse.com>
To: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
Cc: "SK, SivaSangeetha (Siva Sangeetha)" <SivaSangeetha.SK@amd.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Julien Grall <julien@xen.org>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Bertrand Marquis <bertrand.marquis@arm.com>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
"boris.ostrovsky@oracle.com" <boris.ostrovsky@oracle.com>,
"Pandeshwara krishna, Mythri" <Mythri.Pandeshwarakrishna@amd.com>,
"Rangasamy, Devaraj" <Devaraj.Rangasamy@amd.com>,
"Thomas, Rijo-john" <Rijo-john.Thomas@amd.com>
Subject: Re: Reg. Tee init fail...
Date: Thu, 11 Aug 2022 09:34:00 +0200 [thread overview]
Message-ID: <23495ff0-4561-00b4-d96b-2f1bf4117b7a@suse.com> (raw)
In-Reply-To: <YvQ3cEFxWFi7fXjX@mail-itl>
[-- Attachment #1.1.1: Type: text/plain, Size: 3326 bytes --]
On 11.08.22 00:55, Marek Marczykowski-Górecki wrote:
> On Thu, Jun 30, 2022 at 07:31:38AM +0200, Juergen Gross wrote:
>> On 30.06.22 05:32, SK, SivaSangeetha (Siva Sangeetha) wrote:
>>> [AMD Official Use Only - General]
>>>
>>> +team
>>>
>>> -----Original Message-----
>>> From: Stefano Stabellini <sstabellini@kernel.org>
>>> Sent: Thursday, June 30, 2022 1:34 AM
>>> To: Julien Grall <julien@xen.org>
>>> Cc: SK, SivaSangeetha (Siva Sangeetha) <SivaSangeetha.SK@amd.com>; xen-devel@lists.xenproject.org; Stefano Stabellini <sstabellini@kernel.org>; Bertrand Marquis <bertrand.marquis@arm.com>; Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>; jgross@suse.com; boris.ostrovsky@oracle.com
>>> Subject: Re: Reg. Tee init fail...
>>>
>>> Adding Juergen and Boris because this is a Linux/x86 issue.
>>>
>>>
>>> As you can see from this Linux driver:
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Felixir.bootlin.com%2Flinux%2Flatest%2Fsource%2Fdrivers%2Fcrypto%2Fccp%2Ftee-dev.c%23L132&data=05%7C01%7CSivaSangeetha.SK%40amd.com%7Ce962a907794f4917a80b08da5a0a7b3b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637921298315828104%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=NxmMUckiDRGLv3qLJrhZKBt2zNTuomEZqYJdV74tXxA%3D&reserved=0
>>>
>>> Linux as dom0 on x86 is trying to communicate with firmware (TEE). Linux is calling __pa to pass a physical address to firmware. However, __pa returns a "fake" address not an mfn. I imagine that a quick workaround would be to call "virt_to_machine" instead of "__pa" in tee-dev.c.
>>>
>>> Normally, if this was a device, the "right fix" would be to use swiotlb-xen:xen_swiotlb_map_page to get back a real physical address.
>>>
>>> However, xen_swiotlb_map_page is meant to be used as part of the dma_ops API and takes a struct device *dev as input parameter. Maybe xen_swiotlb_map_page can be used for tee-dev as well?
>>>
>>>
>>> Basically tee-dev would need to call dma_map_page before passing addresses to firmware, and dma_unmap_page when it is done. E.g.:
>>>
>>>
>>> cmd_buffer = dma_map_page(dev, virt_to_page(cmd),
>>> cmd & ~PAGE_MASK,
>>> ring_size,
>>> DMA_TO_DEVICE);
>>>
>>>
>>> Juergen, Boris,
>>> what do you think?
>>
>> Yes, I think using the DMA interface is the correct way to handle that.
>>
>> BTW, I did a similar fix for the dcdbas driver recently:
>>
>> https://lore.kernel.org/r/20220318150950.16843-1-jgross@suse.com
>
> I hit similar issue, and the patch below made it work for me (ugly
> workaround), or at least stop complaining.
>
> But note one of those places have this comment:
>
> /* We need actual physical address instead of DMA address, since
> * Trusted OS running on AMD Secure Processor will map this region
> */
>
> I guess it means AMD Secure Processor bypasses IOMMU...
It seems not to be attached via an IOMMU, same as for the DCDBAS fix,
where the address is used in SMM handler running on the main processor.
It should be possible to use DMA mapping in your case, too, as long as
the related device has the correct DMA settings not using any IOMMU
translations.
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
next prev parent reply other threads:[~2022-08-11 7:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <DM4PR12MB5200C7C38770E07B5946424A80B49@DM4PR12MB5200.namprd12.prod.outlook.com>
2022-06-24 17:28 ` Reg. Tee init fail Julien Grall
2022-06-29 20:03 ` Stefano Stabellini
2022-06-29 22:45 ` Boris Ostrovsky
2022-06-30 3:32 ` SK, SivaSangeetha (Siva Sangeetha)
2022-06-30 5:31 ` Juergen Gross
2022-08-10 22:55 ` Marek Marczykowski-Górecki
2022-08-11 7:34 ` Juergen Gross [this message]
2022-06-29 22:53 ` Andrew Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=23495ff0-4561-00b4-d96b-2f1bf4117b7a@suse.com \
--to=jgross@suse.com \
--cc=Devaraj.Rangasamy@amd.com \
--cc=Mythri.Pandeshwarakrishna@amd.com \
--cc=Rijo-john.Thomas@amd.com \
--cc=SivaSangeetha.SK@amd.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=bertrand.marquis@arm.com \
--cc=boris.ostrovsky@oracle.com \
--cc=julien@xen.org \
--cc=marmarek@invisiblethingslab.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.