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 0867EC64ED8 for ; Sun, 19 Feb 2023 20:48:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231440AbjBSUs0 (ORCPT ); Sun, 19 Feb 2023 15:48:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231562AbjBSUsX (ORCPT ); Sun, 19 Feb 2023 15:48:23 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76554D53A for ; Sun, 19 Feb 2023 12:48:21 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id e13so1295045pjt.4 for ; Sun, 19 Feb 2023 12:48:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=T6ogOI5fy9kZcGmbOh8R1Tnmx877fgaJfUkyo2bbhz4=; b=O64JFYurCY6KM6mSXnFI/bvhb4Oa7RXnSdm6ui3KUo5AtmBeggaByaOWdeJ5bmXsLd 9PqYTDu9rTXfXM2IcL8/n66U5zPD/np1Bp/SfCRphnXkKuduPyIRKvgOESVi+YFCt4cz R+rhrvpGrzmZSwcUHRZykq8tc4/RtynnmgL9M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=T6ogOI5fy9kZcGmbOh8R1Tnmx877fgaJfUkyo2bbhz4=; b=CFsl1NyJuZgNFuEJG6RdKv2I0SO+075y+U5gmVTS+d+ynT1O4d1RUH4Em5aCe5dgwH leLyOhgD5c/bgyLn6gozo5Px7r9qNgARPb9jKCYckymU9MkCQlF2aFwYofBsxn/MKsvU bO2YdU4yG2l2Omm54RJQV76ISmPK/PQwRuZ3Teq8cmrwV6grhFoc82+aW83bPaSQTV3x exWbn7mY706lk0xra+yhKIzoBVX0ssx9hRCfVHz9p/Bf7JSV1+SY9bgVpjVglsat3nOt ZIL9PHObCKDCLBOzmY4CmtPdtU1+Y0Hd8bQgDSF6tXU0OeZlTiUcB+cQqpB4p92nMFHN yOiQ== X-Gm-Message-State: AO0yUKW05wDoLQ4hI4ziBaBaXyWvW8rHvKCM4JwruiJmCaknj3OeqHC2 PRjVvmrscbL7NfCG8vshEEY54Q== X-Google-Smtp-Source: AK7set9AJDoPz3P8WrcTJKnVtGvdAn9cKTBx7QRH7COR7s96aLWXshdttfPlfDlbwFpcAoS0d+P3Rg== X-Received: by 2002:a17:90b:2243:b0:234:b03:5a70 with SMTP id hk3-20020a17090b224300b002340b035a70mr2120176pjb.35.1676839700900; Sun, 19 Feb 2023 12:48:20 -0800 (PST) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id d13-20020a17090ae28d00b00233e52b7797sm941662pjz.44.2023.02.19.12.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Feb 2023 12:48:20 -0800 (PST) Message-ID: <63f28b14.170a0220.8cbeb.12e3@mx.google.com> X-Google-Original-Message-ID: <202302191248.@keescook> Date: Sun, 19 Feb 2023 12:48:19 -0800 From: Kees Cook To: Rick Edgecombe Cc: x86@kernel.org, "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H . J . Lu" , Jann Horn , Jonathan Corbet , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , Weijiang Yang , "Kirill A . Shutemov" , John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, akpm@linux-foundation.org, Andrew.Cooper3@citrix.com, christina.schimpe@intel.com, david@redhat.com, debug@rivosinc.com Subject: Re: [PATCH v6 38/41] x86/fpu: Add helper for initing features References: <20230218211433.26859-1-rick.p.edgecombe@intel.com> <20230218211433.26859-39-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230218211433.26859-39-rick.p.edgecombe@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 18, 2023 at 01:14:30PM -0800, Rick Edgecombe wrote: > If an xfeature is saved in a buffer, the xfeature's bit will be set in > xsave->header.xfeatures. The CPU may opt to not save the xfeature if it > is in it's init state. In this case the xfeature buffer address cannot > be retrieved with get_xsave_addr(). > > Future patches will need to handle the case of writing to an xfeature > that may not be saved. So provide helpers to init an xfeature in an > xsave buffer. > > This could of course be done directly by reaching into the xsave buffer, > however this would not be robust against future changes to optimize the > xsave buffer by compacting it. In that case the xsave buffer would need > to be re-arranged as well. So the logic properly belongs encapsulated > in a helper where the logic can be unified. > > Tested-by: Pengfei Xu > Tested-by: John Allen > Signed-off-by: Rick Edgecombe Reviewed-by: Kees Cook -- Kees Cook