Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp3477194lkm; Tue, 21 Sep 2021 17:06:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4uFBQEXZjJEp5BvTD9NwB7N9ome7NkeGKqfiZ/z+5kVHvd8U8qOIf5YtFczf8x6LhOxfZ X-Received: by 2002:aa7:df8b:: with SMTP id b11mr38921686edy.61.1632269200733; Tue, 21 Sep 2021 17:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632269200; cv=none; d=google.com; s=arc-20160816; b=MsYrtZVcN8aepZ0SxDa4LDvyskBi7SBSyFypkqLPcqgkagXWeyyeYQWfwsLyMwd3Rk oMxGFYI2+hkT5pNVHK3uAhx4cW+nMzoqKgF1ENrbMIPPoLSYuUxru/4wjWrA8okM2N6c z9qLQEjmktGAZ9E2vq6dWmhsjjsGQ4y3R3UpF+pOTBwtaPzaGiJIUaGXvzfcBZVcagkT HQenJmpB1x+Y5bCDrKjzWYoxB2TDhSg51ygqgJ9iTPUd0AOY/F9BBN5Nc/SCQyd9+EIx c4sPgo92f1SaBHBDWBpZoVUWRgDRmlQLAsqTFRbaIiIaVuObfvMrq3hdiIBV9pRZ0KPT AkIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GYWKxxwDs0cZgU7zoLo4TUhsJ8M50sSfexrGGa7nvK0=; b=w2B3sCQO4VyG3voIY5JPeGwDa7FvamV3sUpzyl5YHVmy69TCOqXOOlFT38lche/Z53 CkcLGlLpVQak49vyfhQ2QDBjPizwKn23BsxBrlZStdXBGEaCZymXdRcKnfJ48DkQtGgw wMYp3hDCrGTmXeifW50fT/k2t9TovA80MER6od4ietTuMuRVPhn9aHCCmtY3zjuAah8W evSTOJUHoj24TUf+G+GETTSPJdB5sgSK1wOXMH40isXjxeIqP6uzGDGOqbpTfem2RvZC N2TeYlHl0rpqsOtEPz0uveDXdMxrbxPfNjCdup/FhKWhArPqST2lP1rPHWfkbLTc5Eui CCww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20210112.gappssmtp.com header.s=20210112 header.b=6GA+nKi4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z5si579299edr.302.2021.09.21.17.06.12; Tue, 21 Sep 2021 17:06:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov-name.20210112.gappssmtp.com header.s=20210112 header.b=6GA+nKi4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229926AbhIUVYW (ORCPT + 99 others); Tue, 21 Sep 2021 17:24:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234221AbhIUVW3 (ORCPT ); Tue, 21 Sep 2021 17:22:29 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FE86C06175F for ; Tue, 21 Sep 2021 14:21:00 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id p29so2829802lfa.11 for ; Tue, 21 Sep 2021 14:21:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GYWKxxwDs0cZgU7zoLo4TUhsJ8M50sSfexrGGa7nvK0=; b=6GA+nKi4dJGN5Y/djnNixBrKu6T3pljCu3U/BgzvrwouwWOron03nG2FotSmE1IvQS MgoEePxggSU/gxjqerZifjJ0UmN+Rpgv4VXnbx+GeN6FcHZXKGVGGXh/gwowELfGRgeB k1v+6RGz165vVjf8qTg9T5T2FYUEcrHSwLBk5fRy4e1eic4Bwe7QkdtvB988rBItCSlw 5pJbiBObITlEWIumnOpwgWSOod/vvf6//SPAXj5IzXKsXsn8DowBeLy2GH+tdsAPmUH0 ZbwUoQIW4DTzzxX46eJW+ys3iupLGzexzYNkzIcWmfRnNP3AUY1kX51pUUaEoehoA6Yb KPPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GYWKxxwDs0cZgU7zoLo4TUhsJ8M50sSfexrGGa7nvK0=; b=voXp46SqjTUzaP8EpjCmc1l+j0QKKDvDUqHoCeLnabXZxm7jOOF591FClsPwtaFmq3 seiwfTdIwiUJMfTcCC5yjQHtsDcD7C8Mu4VEe4dbTG4rY9l6de5rRUMkZEBhejZbou3d tXaRNgfc19bG887nEACiOLXnILTMSFO+SYQ3pFmzy42Hj5shPTTDiY25J9szcYVDaM1i ZwwipDj0WFKi5fYQbdfW202ZfRJVcgW88eON4MNHaY5iGDNEaCpT75/6w3oo4V736wGH gWFu4LNOn34yOfggqBGaJOl0BBd2kO0nQ8yyuYZPqOOlSFiiIFkB6x1yfqzXgtxHzQDB DtrQ== X-Gm-Message-State: AOAM530NK6NnrdvZto81WtwXN6fluARnWHBqXR8O0KzqQr6hemXZr5FN Bntog4BKG9uBGtJvoIJztX/Lcg== X-Received: by 2002:a2e:5009:: with SMTP id e9mr25102801ljb.245.1632259258818; Tue, 21 Sep 2021 14:20:58 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id t12sm13948lfc.55.2021.09.21.14.20.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 14:20:58 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 1B39910305C; Wed, 22 Sep 2021 00:20:59 +0300 (+03) Date: Wed, 22 Sep 2021 00:20:59 +0300 From: "Kirill A. Shutemov" To: Borislav Petkov Cc: Tom Lendacky , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, iommu@lists.linux-foundation.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-graphics-maintainer@vmware.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org, Brijesh Singh , Joerg Roedel , Andi Kleen , Sathyanarayanan Kuppuswamy , Tianyu Lan , Christoph Hellwig , Thomas Gleixner , Ingo Molnar , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Will Deacon Subject: Re: [PATCH v3 5/8] x86/sme: Replace occurrences of sme_active() with cc_platform_has() Message-ID: <20210921212059.wwlytlmxoft4cdth@box.shutemov.name> References: <367624d43d35d61d5c97a8b289d9ddae223636e9.1631141919.git.thomas.lendacky@amd.com> <20210920192341.maue7db4lcbdn46x@box.shutemov.name> <77df37e1-0496-aed5-fd1d-302180f1edeb@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 21, 2021 at 07:47:15PM +0200, Borislav Petkov wrote: > On Tue, Sep 21, 2021 at 12:04:58PM -0500, Tom Lendacky wrote: > > Looks like instrumentation during early boot. I worked with Boris offline to > > exclude arch/x86/kernel/cc_platform.c from some of the instrumentation and > > that allowed an allyesconfig to boot. > > And here's the lineup I have so far, I'd appreciate it if ppc and s390 folks > could run it too: > > https://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git/log/?h=rc2-cc Still broken for me with allyesconfig. gcc version 11.2.0 (Gentoo 11.2.0 p1) GNU ld (Gentoo 2.37_p1 p0) 2.37 I still believe calling cc_platform_has() from __startup_64() is totally broken as it lacks proper wrapping while accessing global variables. I think sme_get_me_mask() has the same problem. I just happened to work (until next compiler update). This hack makes kernel boot again: diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index f98c76a1d16c..e9110a44bf1b 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -285,7 +285,7 @@ unsigned long __head __startup_64(unsigned long physaddr, * there is no need to zero it after changing the memory encryption * attribute. */ - if (cc_platform_has(CC_ATTR_MEM_ENCRYPT)) { + if (0 && cc_platform_has(CC_ATTR_MEM_ENCRYPT)) { vaddr = (unsigned long)__start_bss_decrypted; vaddr_end = (unsigned long)__end_bss_decrypted; for (; vaddr < vaddr_end; vaddr += PMD_SIZE) { diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c index eff4d19f9cb4..91638ed0b1db 100644 --- a/arch/x86/mm/mem_encrypt_identity.c +++ b/arch/x86/mm/mem_encrypt_identity.c @@ -288,7 +288,7 @@ void __init sme_encrypt_kernel(struct boot_params *bp) unsigned long pgtable_area_len; unsigned long decrypted_base; - if (!cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) + if (1 || !cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) return; /* -- Kirill A. Shutemov