Re: [RFC v2-fix 1/1] x86/tdx: Handle in-kernel MMIO

From: Andi Kleen
Date: Tue May 18 2021 - 16:21:13 EST

On 5/18/2021 10:46 AM, Dave Hansen wrote:
On 5/18/21 10:21 AM, Andi Kleen wrote:
Besides instruction decoding works fine for all the existing
hypervisors. All we really want to do is to do the same thing as KVM
would do.
Dumb question of the day: If you want to do the same thing that KVM
does, why don't you share more code with KVM? Wouldn't you, for
instance, need to crack the same instruction opcodes?

We're talking about ~60 lines of codes that calls an established standard library.

You're proposing a gigantic refactoring to avoid 60 lines of straight forward code.

That's not a practical proposal.

I'd feel a lot better about this if you said:

Listen, this doesn't work for everything. But, it will run
every single driver as a TDX guest that KVM can handle as a
host. So, if the TDX code is broken, so is the KVM host code.

I don't really know what problem you're trying to solve here. We only have a small number of drivers and we tested them and they work fine. There are special macros that limit the number of instructions. If there are ever more instructions and the macros break somehow we'll add them. There will be a clean error if it ever happens. We're not trying to solve hypothetical problems here.