Re: [PATCH] x86/sev: Move sev_setup_arch() to mem_encrypt.c

From: Alexander Shishkin
Date: Fri Jun 09 2023 - 13:20:12 EST


Alison Schofield <alison.schofield@xxxxxxxxx> writes:

> On Tue, May 30, 2023 at 03:17:28PM +0300, Alexander Shishkin wrote:
>> Since commit 4d96f9109109b ("x86/sev: Replace occurrences of
>> sev_active() with cc_platform_has()"), the SWIOTLB bounce buffer size
>> adjustment and restricted virtio memory setting also inadvertently apply
>> to TDX, which just happens to be what we want.
>
> Hi Alexander,

Hi Alison,

> Can you offer more context on how this inadvertently applies?

Yes, the code uses cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT) condition
for setting the bounce buffer size and enabling restricted virtio
memory, which is also true for TDX. I've added a bit about this to v2
[0].

> One bit below...
>> --- a/arch/x86/mm/mem_encrypt.c
>> +++ b/arch/x86/mm/mem_encrypt.c
>> @@ -12,6 +12,7 @@
>> #include <linux/swiotlb.h>
>> #include <linux/cc_platform.h>
>> #include <linux/mem_encrypt.h>
>> +#include <linux/virtio_anchor.h>
>
> It looks like this #include can be removed from mem_encrypt_amd.c

Good catch! This is also addressed in v2.

[0] https://lore.kernel.org/lkml/20230609171214.31846-1-alexander.shishkin@xxxxxxxxxxxxxxx/

Thanks,
--
Alex