Messages in this thread | | | Date | Sun, 13 Feb 2022 08:50:48 -0600 | From | Tom Lendacky <> | Subject | Re: [PATCH v10 21/45] x86/mm: Add support to validate memory when changing C-bit |
| |
On 2/13/22 06:15, Borislav Petkov wrote: > On Fri, Feb 11, 2022 at 11:27:54AM -0600, Brijesh Singh wrote: >>> Simply have them always present. They will have !0 values on the >>> respective guest types and 0 otherwise. This should simplify a lot of >>> code and another unconditionally present u64 won't be the end of the >>> world. >>> >>> Any other aspect I'm missing? >> >> I think that's mostly about it. IIUC, the recommendation is to define a >> new callback in x86_platform_op. The callback will be invoked >> unconditionally; The default implementation for this callback is NOP; >> The TDX and SEV will override with the platform specific implementation. >> I think we may able to handle everything in one callback hook but having >> pre and post will be a more desirable. Here is why I am thinking so: >> >> * On SNP, the page must be invalidated before clearing the _PAGE_ENC >> from the page table attribute >> >> * On SNP, the page must be validated after setting the _PAGE_ENC in the >> page table attribute. > > Right, we could have a pre- and post- callback, if that would make > things simpler/clearer. > > Also, in thinking further about the encryption mask, we could make it a > *single*, *global* variable called cc_mask which each guest type sets it > as it wants to. > > Then, it would use it in the vendor-specific encrypt/decrypt helpers > accordingly and that would simplify a lot of code. And we can get rid of > all the ifdeffery around it too. > > So I think the way to go should be we do the common functionality, I > queue it on the common tip:x86/cc branch and then SNP and TDX will be > both based ontop of it. > > Thoughts?
I think there were a lot of assumptions that only SME/SEV would set sme_me_mask and that is used, for example, in the cc_platform_has() routine to figure out whether we're AMD or Intel. If you go the cc_mask route, I think we'll need to add a cc_vendor variable that would then be checked in cc_platform_has(). All other uses of sme_me_mask would need to be audited to see whether cc_vendor would need to be checked, too.
Thanks, Tom
>
| |