From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7411CC61DA4 for ; Mon, 13 Mar 2023 11:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229899AbjCMLDr (ORCPT ); Mon, 13 Mar 2023 07:03:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229877AbjCMLDo (ORCPT ); Mon, 13 Mar 2023 07:03:44 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFD0F13D4D; Mon, 13 Mar 2023 04:03:41 -0700 (PDT) Received: from zn.tnic (p5de8e9fe.dip0.t-ipconnect.de [93.232.233.254]) (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 6AA151EC04DA; Mon, 13 Mar 2023 12:03:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1678705420; 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=LtyOPOOWBs+hlc/CXfZFBydFPquT6KOjs11AJIp5x3s=; b=W5NtNYHASJ8ymhQ56TWX2poWPntiPfwL0Jm6wgZu5FXtkL/4BQxiKuEYXM0MfJy1z/wVrb OEDBwqThoSqO6S+EXw2mqWVI1Rv1oESm2+3HriA30+euNEv/+eH6cPWSUaXB0bF/8X1zzO ypXqNIiVPvf2YY7M5mSGiC/7KcmacAE= Date: Mon, 13 Mar 2023 12:03:35 +0100 From: Borislav Petkov To: "Edgecombe, Rick P" Cc: "david@redhat.com" , "bsingharora@gmail.com" , "hpa@zytor.com" , "Syromiatnikov, Eugene" , "peterz@infradead.org" , "rdunlap@infradead.org" , "keescook@chromium.org" , "dave.hansen@linux.intel.com" , "kirill.shutemov@linux.intel.com" , "Eranian, Stephane" , "linux-mm@kvack.org" , "fweimer@redhat.com" , "nadav.amit@gmail.com" , "jannh@google.com" , "dethoma@microsoft.com" , "kcc@google.com" , "linux-arch@vger.kernel.org" , "pavel@ucw.cz" , "oleg@redhat.com" , "hjl.tools@gmail.com" , "Yang, Weijiang" , "Lutomirski, Andy" , "linux-doc@vger.kernel.org" , "arnd@arndb.de" , "tglx@linutronix.de" , "Schimpe, Christina" , "mike.kravetz@oracle.com" , "x86@kernel.org" , "akpm@linux-foundation.org" , "debug@rivosinc.com" , "jamorris@linux.microsoft.com" , "john.allen@amd.com" , "rppt@kernel.org" , "andrew.cooper3@citrix.com" , "mingo@redhat.com" , "corbet@lwn.net" , "linux-kernel@vger.kernel.org" , "linux-api@vger.kernel.org" , "gorcunov@gmail.com" Subject: Re: [PATCH v7 38/41] x86/fpu: Add helper for initing features Message-ID: <20230313110335.GAZA8DB6PNSMGOGHpw@fat_crate.local> References: <20230227222957.24501-1-rick.p.edgecombe@intel.com> <20230227222957.24501-39-rick.p.edgecombe@intel.com> <3385eaf888f4178607ce4621ae2103d08ba79994.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <3385eaf888f4178607ce4621ae2103d08ba79994.camel@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org On Mon, Mar 13, 2023 at 02:45:08AM +0000, Edgecombe, Rick P wrote: > These two are from the existing code. Basically they get extracted into > a new function. I know but you can fix them while at it. > I did it up, and it makes the caller code cleaner. But I'm not sure > what to think of it. Is this not mixing two operations together? Today > get_xsave_addr() pretty much just gets a buffer offset with some > checks. Now it would compute the offset and also silently go off and > changes the buffer. Ok, so why don't you write the call site this way instead: cetregs = get_xsave_addr(xsave, XFEATURE_CET_USER); if (!cetregs) { if (xfeature_saved(xsave, XFEATURE_CET_USER)) { WARN("something's wrong with this buffer") return ...; } /* Not saved, initialize it */ init_xfeature(xsave, XFEATURE_CET_USER)); } cetregs = get_xsave_addr(xsave, XFEATURE_CET_USER); if (!cetregs) { WARN_ON("WTF") return -ENODEV; } Now it is clear what happens and it is a common code pattern of trying to get something and initializing it if it wasn't initialized yet, and then retrying... Hmm? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette