Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1312613pxb; Wed, 2 Feb 2022 01:54:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxJ5C4QtNK1zAnDyCbf1ixsOpBkwiLXR1Nliq4fe9ll6QbEV8xbFzaD0whju31swYiqGMB X-Received: by 2002:a63:81c7:: with SMTP id t190mr24085515pgd.575.1643795647812; Wed, 02 Feb 2022 01:54:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643795647; cv=none; d=google.com; s=arc-20160816; b=fFakRpVtkQoZ94Kr+29TjNvhDQVVCsi5CepgjEMM/Y3V1zZegT/zgwLUTxPqY879YT kSxrSBZYiHIEZuNlE3ey5K9Saye1Zy84p0WuqcSbf2WU1qZq/8EY3h7eOq8h++77ENYR RuMvIDiywOY46ug9zhXYha8rs9Lq85pE+JNdAI9B4x/iHGh+zw2+BxVfeZmCuA3KePIb SszHkka5LLnq6CQm5xubQ3+9+0n9qsu3MqYTramkKts59bAJW5BMVfD0AnCkZEPE1SdP m4mexijNEhygE6JfKjId0m7vbOEaNkwfJa69xixOBrofNt4wZ59Np00KZ+9pqj1SjBd4 NAjw== 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=7l7vocFxdezL9X3EUKTSMo+nYjMem25yARKYTuyX8jo=; b=GTN06wtLw1xoY8sPCIMMtp7oL3V+uXRgLGHGJYgVnG7uLzPAjU0AleopUR2KdQVPNV D+0XOFMjz7/HugGpr/vpLLeCiGZH7bc9HgjXqfxsQZ6/rxCUMfh6Ugi4TGj1Mi/AKDhv pBDG6xSfn1o/0ZTktdhW7tDVEZ9STvz8cOL2TlVrRKl+QsgpT40555acM/366rZDr5Au X+rwY7lzMMBPFEti2Th6PQFqrqrVMFULxhG9cC3OBwp5tD0Zc9c/pqVbHewjP22jF9Ne axKG0vCKhkXVdVu2RxrANY8vTDTsUgTTSXfwjCqlPz6qBOwssDcFeikhXywPi4/MOx3J 1p6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="UqY6/pu2"; 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 l10si19311215pfu.149.2022.02.02.01.53.56; Wed, 02 Feb 2022 01:54:07 -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="UqY6/pu2"; 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 S232674AbiBAV2v (ORCPT + 99 others); Tue, 1 Feb 2022 16:28:51 -0500 Received: from mail.skyhub.de ([5.9.137.197]:59112 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232463AbiBAV2u (ORCPT ); Tue, 1 Feb 2022 16:28:50 -0500 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 BB1171EC04AD; Tue, 1 Feb 2022 22:28:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1643750924; 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=7l7vocFxdezL9X3EUKTSMo+nYjMem25yARKYTuyX8jo=; b=UqY6/pu2Ue28uGppx/YJY4gkORX0RykPUqAdSDRchnnYt4NjKqnkwxUmhNgCRs7FckxK7f 1pzKGK6KEJUNmRbkUwTZape/D5jU3FBobXFz22E3nxw6f5eTL9EmNgVU99rgmM7c7b816l I+PJ5mEE7Bl4LDHK9aNUF7u8RSHEypM= Date: Tue, 1 Feb 2022 22:28:39 +0100 From: Borislav Petkov To: Michael Roth Cc: Brijesh Singh , 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 , 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> <20220201203507.goibbaln6dxyoogv@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220201203507.goibbaln6dxyoogv@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 01, 2022 at 02:35:07PM -0600, Michael Roth wrote: > Unfortunately rdmsr()/wrmsr()/__rdmsr()/__wrmsr() etc. definitions are all > already getting pulled in via: > > misc.h: > #include linux/elf.h > #include linux/thread_info.h > #include linux/cpufeature.h > #include linux/processor.h > #include linux/msr.h > > Those definitions aren't usable in boot/compressed because of __ex_table > and possibly some other dependency hellishness. And they should not be. Mixing kernel proper and decompressor code needs to stop and untangling that is a multi-year effort, unfortunately. ;-\ > Would read_msr()/write_msr() be reasonable alternative names for these new > helpers, or something else that better distinguishes them from the > kernel proper definitions? Nah, just call them rdmsr/wrmsr(). There is already {read,write}_msr() tracepoint symbols in kernel proper and there's no point in keeping them apart using different names - that ship has long sailed. > It doesn't look like anything in boot/ pulls in boot/compressed/ > headers. It seems to be the other way around, with boot/compressed > pulling in headers and whole C files from boot/. > > So perhaps these new definitions should be added to a small boot/msr.h > header and pulled in from there? That sounds good too. > Should we introduce something like this as well for cpucheck.c? Or > re-write cpucheck.c to make use of the u64 versions? Or just set the > cpucheck.c rework aside for now? (but still introduce the above helpers > as boot/msr.h in preparation)? How about you model it after static int msr_read(u32 msr, struct msr *m) from arch/x86/lib/msr.c which takes struct msr from which you can return either u32s or a u64? The stuff you share between the decompressor and kernel proper you put in a arch/x86/include/asm/shared/ folder, for an example, see what we do there in the TDX patchset: https://lore.kernel.org/r/20220124150215.36893-11-kirill.shutemov@linux.intel.com I.e., you move struct msr in such a shared header and then you include it everywhere needed. The arch/x86/boot/ msr helpers are then plain and simple, without tracepoints and exception fixups and you define them in ...boot/msr.c or so. If the patch gets too big, make sure to split it in a couple so that it is clear what happens at each step. How does that sound? Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette