On Tue, Dec 14, 2021 at 06:14:34PM -0600, Venu Busireddy wrote: > On 2021-12-14 20:10:16 +0100, Borislav Petkov wrote: > > On Tue, Dec 14, 2021 at 11:46:14AM -0600, Venu Busireddy wrote: > > > What I am suggesting should not have anything to do with the boot stage > > > of the kernel. > > > > I know exactly what you're suggesting. > > > > > For example, both these functions call native_cpuid(), which is declared > > > as an inline function. I am merely suggesting to do something similar > > > to avoid the code duplication. > > > > Try it yourself. If you can come up with something halfway readable and > > it builds, I'm willing to take a look. > > Patch (to be applied on top of sev-snp-v8 branch of > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAMDESE%2Flinux.git&data=04%7C01%7Cmichael.roth%40amd.com%7Cbff83ee03b1147c39ea808d9bf5fe9d8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637751240979543818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=DZpgEtthswLhhfWqZlLkHHd5nJW2jb%2FVFuTssAFJ6Uo%3D&reserved=0) is attached at the end. > > Here are a few things I did. > > 1. Moved all the common code that existed at the begining of > sme_enable() and sev_enable() to an inline function named > get_pagetable_bit_pos(). > 2. sme_enable() was using AMD_SME_BIT and AMD_SEV_BIT, whereas > sev_enable() was dealing with raw bits. Moved those definitions to > sev.h, and changed sev_enable() to use those definitions. > 3. Make consistent use of BIT_ULL. Hi Venu, I know there's still comments floating around, but once there's consensus feel free to respond with a separate precursor patch against tip which moves sme_enable() cpuid code into your helper function, along with your S-o-B, and I can include it directly in the next version. Otherwise, I can incorporate your suggestions into the next spin, just let me know if it's okay to add: Co-authored-by: Venu Busireddy <venu.busireddy@xxxxxxxxxx> Signed-off-by: Venu Busireddy <venu.busireddy@xxxxxxxxxx> to the relevant commits. Thank you (and Boris/Tom) for the suggestions! -Mike > > Venu >