From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Lendacky Subject: Re: [PATCH v9 04/38] x86/CPU/AMD: Add the Secure Memory Encryption CPU feature Date: Tue, 11 Jul 2017 10:14:34 -0500 Message-ID: References: <20170707133804.29711.1616.stgit@tlendack-t1.amdoffice.net> <20170707133850.29711.29549.stgit@tlendack-t1.amdoffice.net> <20170711055659.GA4554@nazgul.tnic> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20170711055659.GA4554-K5JNixvcfoxupOikMc4+xw@public.gmane.org> Content-Language: en-US Sender: linux-efi-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Borislav Petkov , Brian Gerst Cc: linux-arch , linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, the arch/x86 maintainers , kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Linux Kernel Mailing List , kasan-dev-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org, xen-devel-GuqFBffKawuEi8DpZVb4nw@public.gmane.org, Linux-MM , iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, Brijesh Singh , Toshimitsu Kani , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Matt Fleming , Alexander Potapenko , "H. Peter Anvin" , Larry Woodman , Jonathan Corbet , Joerg Roedel , "Michael S. Tsirkin" , Ingo List-Id: linux-efi@vger.kernel.org On 7/11/2017 12:56 AM, Borislav Petkov wrote: > On Tue, Jul 11, 2017 at 01:07:46AM -0400, Brian Gerst wrote: >>> If I make the scattered feature support conditional on CONFIG_X86_64 >>> (based on comment below) then cpu_has() will always be false unless >>> CONFIG_X86_64 is enabled. So this won't need to be wrapped by the >>> #ifdef. >> >> If you change it to use cpu_feature_enabled(), gcc will see that it is >> disabled and eliminate the dead code at compile time. > > Just do this: > > if (cpu_has(c, X86_FEATURE_SME)) { > if (IS_ENABLED(CONFIG_X86_32)) { > clear_cpu_cap(c, X86_FEATURE_SME); > } else { > u64 msr; > > /* Check if SME is enabled */ > rdmsrl(MSR_K8_SYSCFG, msr); > if (!(msr & MSR_K8_SYSCFG_MEM_ENCRYPT)) > clear_cpu_cap(c, X86_FEATURE_SME); > } > } > > so that it is explicit that we disable it on 32-bit and we can save us > the ifdeffery elsewhere. I'll use this method for the change and avoid the #ifdefs. Thanks, Tom > > Thanks. >