Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1440070pxb; Fri, 24 Sep 2021 04:44:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGIkJ954aoDoQDXz7hb8WRvmBJ+DHAS+lEk9Rw+sRF5LIhDtHKa1hstzHG84UAF4P+0vvI X-Received: by 2002:a05:6402:13d0:: with SMTP id a16mr4404825edx.155.1632483883279; Fri, 24 Sep 2021 04:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632483883; cv=none; d=google.com; s=arc-20160816; b=zc1vOErDJhU8VoTVv46RV0mSra3LlracsQPmuHUFJMXIagcLgFeBnRzrBWKilopXEb H3QyiDSFCP9HkDE7V7h0HvqPSpmGgW0W6zVqrRvd9HFA4wGc36NcDt4zu1J8ePHL5RfL qEuRYfAbbe0Cw4G9xyVCHzYtecQ7Fm2dmSh2NXlcmqUB0KRnFqTvEGsV9cOw/gAm3q/p aRQL+injDi3blg9b+j1X9Rd5F20piv4/nMgG2lqG7dxg+6XCgMdbnDrAWBBueCvr0olI 4wmRPNFO4JhelU+3P0N2bGpKa4vMAsIGc+ZIM73gToRenwUP3n673rH9b/61UQUHskSn ngyA== 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=7QWYmDDdQ14wxTTMWtNorG+4hnmrm04qfz4ZOujDnZs=; b=tV1t5O+Ts2Grwcj8ptBwNRchT/Sfu0DGHVHfhCVCNsyOjJHInH1Ax+jk/OodaV92FU A0/Rf3yuYpdllxxxnGs1jsp5tZyz8A4w92CvlBAK94U7VcJ0uqoFul4+HWvJi4FKxiEz GeTIGgUcMwUW3c1C/N88SLFNpD5AYSqTbSHHSCM9EYFje0at+NohUTY9wOtYBIcQzwRp gJMiN5ubn5eZkywfp7CJgYwWLfwUqNCla2QgqlMplkysKn+ca0z/dUkHQHttp4GK6guK ph1N8x4vzMpeu85WlKMqu0l6Xy4Roj9daW9x/hdW0rytm5bCFXQxoGp86HAI56qL0QVW ZM0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20210112.gappssmtp.com header.s=20210112 header.b=a94RXEUJ; 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 c11si10484964edw.382.2021.09.24.04.44.17; Fri, 24 Sep 2021 04:44:43 -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=a94RXEUJ; 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 S245221AbhIXJnF (ORCPT + 99 others); Fri, 24 Sep 2021 05:43:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245259AbhIXJnF (ORCPT ); Fri, 24 Sep 2021 05:43:05 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24D46C061756 for ; Fri, 24 Sep 2021 02:41:32 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id i25so38290942lfg.6 for ; Fri, 24 Sep 2021 02:41:32 -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=7QWYmDDdQ14wxTTMWtNorG+4hnmrm04qfz4ZOujDnZs=; b=a94RXEUJuMmQvxSDKok9kJbMV98Mo28f1Csi4Z4iwvW7+MkRyX5SrQhnYAAaonglNs TqzSbC141ptsWvvzM0S2r5099PgvSLUTd+llMs5cQH1O/KYv2VKwA3rHbEQ17XEUoJiN b88sf+8/Kq6CN5gKqNMDbt0WofHePWjCWhJfrHH/URopiQYKQJViZtb5wMUubTQfdu6m e490qkHKD0Pb0R4D5rMx+0JuhhDDbQUkFWETXBCjCVPYNSZnkKFRM+sk+iiLVm+sara7 E1aPac0dVliF4TZMk0iL6yousngzwZf3UFxxtnempLUEnPswt9hwLB+6ECQ/gPgJLFvg u+ag== 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=7QWYmDDdQ14wxTTMWtNorG+4hnmrm04qfz4ZOujDnZs=; b=c6bWIICYv8pg0ofw/uUqBtylw7uQSyQt/p3XO30P4hofxTJq0sGKh2vpZya/v+HkRK vvsz/Vuvx1nRgh0qZ2khlEq6SHtspAiiKVoMmpe0tGO/CBGntF66zyyCONOBmKxqbLLy RAJ/uwIqVtZrB7q+n5737Sn+1BD5J8Wi/uf0sB8m9jhoK3n2LUROhiB5hXxUrHmfVov2 68P0CqXB/0s3lD25MbYjNe9OXqcGsa9IBB0Dm0E6cQY2ffWuRbKWJBuXjKM3fd8eBJ/N 6Jka2SONZcJJLUsLrPntkPMwwE7Nc4AWszUx0/dL4vHfqKFXcdYsMparbauM8dMGJ0v6 abxw== X-Gm-Message-State: AOAM531nVqJR/DCPm4StIHf6yLU5J7d2R5VQvw2EitHT4V79TIeBSEsx cTX6oLzg+O4nm50kb37PLPuX+A== X-Received: by 2002:a2e:804c:: with SMTP id p12mr10420673ljg.344.1632476490492; Fri, 24 Sep 2021 02:41:30 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id k21sm952544lji.81.2021.09.24.02.41.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 02:41:29 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 84289103068; Fri, 24 Sep 2021 12:41:32 +0300 (+03) Date: Fri, 24 Sep 2021 12:41:32 +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: <20210924094132.gxyqp4z3qdk5w4j6@box.shutemov.name> References: <20210921212059.wwlytlmxoft4cdth@box.shutemov.name> <20210921213401.i2pzaotgjvn4efgg@box.shutemov.name> <00f52bf8-cbc6-3721-f40e-2f51744751b0@amd.com> <20210921215830.vqxd75r4eyau6cxy@box.shutemov.name> <01891f59-7ec3-cf62-a8fc-79f79ca76587@amd.com> <20210922143015.vvxvh6ec73lffvkf@box.shutemov.name> <20210922210558.itofvu3725dap5xx@box.shutemov.name> 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 Thu, Sep 23, 2021 at 08:21:03PM +0200, Borislav Petkov wrote: > On Thu, Sep 23, 2021 at 12:05:58AM +0300, Kirill A. Shutemov wrote: > > Unless we find other way to guarantee RIP-relative access, we must use > > fixup_pointer() to access any global variables. > > Yah, I've asked compiler folks about any guarantees we have wrt > rip-relative addresses but it doesn't look good. Worst case, we'd have > to do the fixup_pointer() thing. > > In the meantime, Tom and I did some more poking at this and here's a > diff ontop. > > The direction being that we'll stick both the AMD and Intel > *cc_platform_has() call into cc_platform.c for which instrumentation > will be disabled so no issues with that. > > And that will keep all that querying all together in a single file. And still do cc_platform_has() calls in __startup_64() codepath? It's broken. Intel detection in cc_platform_has() relies on boot_cpu_data.x86_vendor which is not initialized until early_cpu_init() in setup_arch(). Given that X86_VENDOR_INTEL is 0 it leads to false-positive. I think opencode these two calls is the way forward. Maybe also move the check from sme_encrypt_kernel() to __startup_64(). -- Kirill A. Shutemov