Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932265AbdIFNzS (ORCPT ); Wed, 6 Sep 2017 09:55:18 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:48504 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754639AbdIFNzO (ORCPT ); Wed, 6 Sep 2017 09:55:14 -0400 Subject: Re: SME/32-bit regression To: Borislav Petkov References: <4c07148a-5d97-0fc2-aa9b-1db31429736d@oracle.com> <20170906092618.fkvzrqx32z6iqf2t@pd.tnic> Cc: thomas.lendacky@amd.com, X86 ML , "linux-kernel@vger.kernel.org" , Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner From: Boris Ostrovsky Message-ID: <86bcf09d-255d-3ad7-ecfe-497e3f57c4eb@oracle.com> Date: Wed, 6 Sep 2017 09:54:37 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170906092618.fkvzrqx32z6iqf2t@pd.tnic> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1779 Lines: 52 On 09/06/2017 05:26 AM, Borislav Petkov wrote: > On Tue, Sep 05, 2017 at 11:45:07PM -0400, Boris Ostrovsky wrote: >> It appears there is a regression for 32-bit kernels due to SME changes. >> >> I bisected my particular problem > It being? Doesn't boot, splats? Xen guest crashes very early, before a splat can can be generated. > >> (Xen PV guest) to >> 21729f81ce8ae76a6995681d40e16f7ce8075db4 but I also saw pmd_clear_bad() >> errors on baremetal. This seems to be caused by sme_me_mask being an >> unsigned long as opposed to phys_addr_t (the actual problem is that >> __PHYSICAL_MASK is truncated). When I declare it as u64 and drop unsigned >> long cast in __sme_set()/__sme_clr() the problem goes way. (This presumably >> won't work for non-PAE which I haven't tried). > Right, so I think we should do this because those macros should not have > any effect on !CONFIG_AMD_MEM_ENCRYPT setups. This won't help though if kernel is built with SME support. -boris > > --- > diff --git a/include/linux/mem_encrypt.h b/include/linux/mem_encrypt.h > index 1255f09f5e42..823eec6ba951 100644 > --- a/include/linux/mem_encrypt.h > +++ b/include/linux/mem_encrypt.h > @@ -35,6 +35,7 @@ static inline unsigned long sme_get_me_mask(void) > return sme_me_mask; > } > > +#ifdef CONFIG_AMD_MEM_ENCRYPT > /* > * The __sme_set() and __sme_clr() macros are useful for adding or removing > * the encryption mask from a value (e.g. when dealing with pagetable > @@ -42,6 +43,10 @@ static inline unsigned long sme_get_me_mask(void) > */ > #define __sme_set(x) ((unsigned long)(x) | sme_me_mask) > #define __sme_clr(x) ((unsigned long)(x) & ~sme_me_mask) > +#else > +#define __sme_set(x) (x) > +#define __sme_clr(x) (x) > +#endif > > #endif /* __ASSEMBLY__ */ > > > >