Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1423034pxb; Wed, 2 Feb 2022 04:49:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYLOmo3k9KhvtHsd5/BEjJu2uwNSw+zmMWEypyGK9rd1zuKmZZDvDakkmdAdrJFT88fZQ9 X-Received: by 2002:a62:e704:: with SMTP id s4mr28884688pfh.25.1643806155440; Wed, 02 Feb 2022 04:49:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643806155; cv=none; d=google.com; s=arc-20160816; b=UKxn5Kv+NNzPkUQknk4OVPZbAcqpuSbzexosqIbdYCvjx7uCjtImlhTHJ0SsirTjk1 4Me1PV2GB9/zX2gPK2gcshr4i5B8vdOv8T1UY8LG8x4Isu6w7SmgVdyMmU64bCx7406T 1hZ1jYWMa2qDK6By/+/CDa44mH1nXFRv4i8ugIGzJZv1/70iPrQEF2RYwQjEiv5QMkhn YJtzG23WqfbChGJcw3iunjlPHf80N3aZsfr84WGjT7qE3fGagjx/f7kPY4OjDFdICeE3 cktlcbzSOKZbTF1DaG72whzDuDaiqXjbCqdIwYmio2+/JEOvswcT4xRY3AqrmiHVRTco gzBA== 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=HcxfykENH1gJphgVT/KA5LzM4HTc3s8TrkMJadPsK0o=; b=X5AkANcFKf/wLb2J8zBKWXKJf/aNgG9sMzFe2YtiQiXm1THiB+oaunylQbiR46Kyov RYEQxK2MF3+5pBSrarK4sbLWtuvZAm10hjGTCKJspz6ohdWPvTfuJCnXMl3mN5ixNvqC ndE9hOGGvZ3J/wJRcfUyp+6fxBepCZImwW7twMGNHSvMcMQb4xjbg7ZJGC8wDfsRGDK0 RC9+9oqWpwwwLBU+Se+BcE2Cyh2QEUlCT2Kn8jbLZpo/pPaRL6nhISbjONIQ5Qg1rtMy BggBfmENrBtoMgUWuE15Kve5iCzr4SOxEpDBKlwlbDCTA9O+iXp3mmq0adqktlhhW6cT r89g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="KXbXzL/i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o8si19202466pgn.270.2022.02.02.04.49.01; Wed, 02 Feb 2022 04:49:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="KXbXzL/i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241806AbiBASId (ORCPT + 99 others); Tue, 1 Feb 2022 13:08:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240279AbiBASIc (ORCPT ); Tue, 1 Feb 2022 13:08:32 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28B7AC061714; Tue, 1 Feb 2022 10:08:32 -0800 (PST) Received: from zn.tnic (dslb-088-067-221-104.088.067.pools.vodafone-ip.de [88.67.221.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 516CF1EC0513; Tue, 1 Feb 2022 19:08:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1643738905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=HcxfykENH1gJphgVT/KA5LzM4HTc3s8TrkMJadPsK0o=; b=KXbXzL/iB0jKOsbk9qpYGF6/22Lz5a/yb/4wRPItKGq08Nf9mtYk6z8AxfiRU+3tIkIfEG FoO2WzE7cON07bDcMWOi4HfjZrFU5nNqFueDJlN3mRccAQLFfYx5q0RsEhan2J+KoAC6il ptqdQQQZkYvoCP+d82KprLCa/WIl2XQ= Date: Tue, 1 Feb 2022 19:08:21 +0100 From: Borislav Petkov To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Michael Roth , Vlastimil Babka , "Kirill A . Shutemov" , Andi Kleen , "Dr . David Alan Gilbert" , brijesh.ksingh@gmail.com, tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com Subject: Re: [PATCH v9 05/43] x86/compressed/64: Detect/setup SEV/SME features earlier in boot Message-ID: References: <20220128171804.569796-1-brijesh.singh@amd.com> <20220128171804.569796-6-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220128171804.569796-6-brijesh.singh@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 28, 2022 at 11:17:26AM -0600, Brijesh Singh wrote: > diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S > index fd9441f40457..49064a9f96e2 100644 > --- a/arch/x86/boot/compressed/head_64.S > +++ b/arch/x86/boot/compressed/head_64.S > @@ -191,9 +191,8 @@ SYM_FUNC_START(startup_32) > /* > * Mark SEV as active in sev_status so that startup32_check_sev_cbit() > * will do a check. The sev_status memory will be fully initialized That "sev_status memory" formulation is just weird. Pls fix it while you're touching that comment. > +static inline u64 rd_sev_status_msr(void) > +{ > + unsigned long low, high; > + > + asm volatile("rdmsr" : "=a" (low), "=d" (high) : > + "c" (MSR_AMD64_SEV)); > + > + return ((high << 32) | low); > +} Don't you see sev_es_rd_ghcb_msr() in that same file above? Do a common rdmsr() helper and call it where needed, pls, instead of duplicating code. misc.h looks like a good place. Extra bonus points will be given if you unify callers in arch/x86/boot/cpucheck.c too but you don't have to - I can do that ontop. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette